feat(custom-chips): AI entry point + friendly auth error
- 'Create with AI' button in CustomChipDialog dispatches the generic velxio:agent-prompt window event (no-op without a listener — the pro overlay's chat panel picks it up and prefills the composer). - chipCompileService maps the hosted deployment's 401 gate to a human 'sign in to compile custom chips' message instead of a raw status line. Self-hosted OSS keeps the route open and never sees either.
This commit is contained in:
parent
d85e4ac14a
commit
cd22335838
|
|
@ -283,6 +283,23 @@ export const CustomChipDialog = ({ initial, onClose, onSave }: CustomChipDialogP
|
||||||
{compiling ? t('editor.customChip.compiling') : t('editor.customChip.compile')}
|
{compiling ? t('editor.customChip.compiling') : t('editor.customChip.compile')}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
<button
|
||||||
|
style={cancelBtn}
|
||||||
|
title="Describe the chip and the AI agent writes, compiles and programs it"
|
||||||
|
onClick={() => {
|
||||||
|
// Pro AI agent hook — no-op when no overlay listener is mounted.
|
||||||
|
window.dispatchEvent(new CustomEvent('velxio:agent-prompt', {
|
||||||
|
detail: {
|
||||||
|
prompt:
|
||||||
|
'Crea un custom chip que ... (describe qué debe hacer; ' +
|
||||||
|
'el agente escribe el C, lo compila y lo programa en el canvas)',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
✨ Create with AI
|
||||||
|
</button>
|
||||||
<div style={{ flex: 1 }} />
|
<div style={{ flex: 1 }} />
|
||||||
<button style={cancelBtn} onClick={onClose}>{t('editor.customChip.cancel')}</button>
|
<button style={cancelBtn} onClick={onClose}>{t('editor.customChip.cancel')}</button>
|
||||||
<button style={canSave ? saveBtn : saveBtnDisabled} disabled={!canSave} onClick={doSave}>
|
<button style={canSave ? saveBtn : saveBtnDisabled} disabled={!canSave} onClick={doSave}>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,11 @@ export async function compileChip(source: string, chipJson?: string): Promise<Ch
|
||||||
wasm_base64: null,
|
wasm_base64: null,
|
||||||
stdout: '',
|
stdout: '',
|
||||||
stderr: '',
|
stderr: '',
|
||||||
error: `HTTP ${res.status}: ${text}`,
|
// Hosted deployments gate this route behind login (401) — surface a
|
||||||
|
// human instruction instead of a raw status line.
|
||||||
|
error: res.status === 401
|
||||||
|
? 'login_required: sign in to compile custom chips.'
|
||||||
|
: `HTTP ${res.status}: ${text}`,
|
||||||
byte_size: 0,
|
byte_size: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue