diff --git a/src/lib/components/studio/terminal.svelte b/src/lib/components/studio/terminal.svelte index 3271f867d..b66b19eeb 100644 --- a/src/lib/components/studio/terminal.svelte +++ b/src/lib/components/studio/terminal.svelte @@ -8,9 +8,14 @@ height: number; synapse: Synapse; readonly?: boolean; + focus?: boolean; }; - let { height, synapse, readonly = false }: Props = $props(); + let { height, synapse, readonly = false, focus = false }: Props = $props(); + let terminalFocus; + function setTerminalFocus(terminal) { + terminalFocus = terminal; + } const terminal: Action = (node) => { const init = async () => { const [{ Terminal }, { FitAddon }] = await Promise.all([ @@ -60,6 +65,8 @@ } ); }); + setTerminalFocus(term); + term.focus(); synapse.addEventListener('terminal', ({ message }) => { const { data } = message; if (typeof data === 'string') term.write(data); @@ -89,6 +96,14 @@ }; init(); }; + + $effect(() => { + console.log('focus', focus); + if (focus && terminalFocus) { + console.log('setting focus'); + terminalFocus.focus(); + } + });
diff --git a/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte b/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte index 0af00d7db..f23995cd3 100644 --- a/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte +++ b/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte @@ -309,12 +309,18 @@ style:display={studio.activeTerminal === studio.mainTerminalId ? 'contents' : 'none'}> - + {/key} {#each studio.terminals as [symbol, synapse] (symbol)}
- +
{/each}