From 90c1fb94e2e16b67ed90f52e7a4f1f807b23b469 Mon Sep 17 00:00:00 2001 From: Hibryda Date: Sun, 8 Mar 2026 03:24:31 +0100 Subject: [PATCH] =?UTF-8?q?feat(v3):=20agent=20preview=20terminal=20?= =?UTF-8?q?=E2=80=94=20read-only=20xterm.js=20tracking=20agent=20activity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Terminal/AgentPreviewPane.svelte | 197 ++++++++++++++++++ .../components/Workspace/ProjectBox.svelte | 2 +- .../components/Workspace/TerminalTabs.svelte | 51 ++++- v2/src/lib/stores/workspace.svelte.ts | 4 +- 4 files changed, 245 insertions(+), 9 deletions(-) create mode 100644 v2/src/lib/components/Terminal/AgentPreviewPane.svelte diff --git a/v2/src/lib/components/Terminal/AgentPreviewPane.svelte b/v2/src/lib/components/Terminal/AgentPreviewPane.svelte new file mode 100644 index 0000000..ebfd199 --- /dev/null +++ b/v2/src/lib/components/Terminal/AgentPreviewPane.svelte @@ -0,0 +1,197 @@ + + +
+ + diff --git a/v2/src/lib/components/Workspace/ProjectBox.svelte b/v2/src/lib/components/Workspace/ProjectBox.svelte index 5a8b31d..bacad04 100644 --- a/v2/src/lib/components/Workspace/ProjectBox.svelte +++ b/v2/src/lib/components/Workspace/ProjectBox.svelte @@ -74,7 +74,7 @@
- +
diff --git a/v2/src/lib/components/Workspace/TerminalTabs.svelte b/v2/src/lib/components/Workspace/TerminalTabs.svelte index 3738fb2..edc983f 100644 --- a/v2/src/lib/components/Workspace/TerminalTabs.svelte +++ b/v2/src/lib/components/Workspace/TerminalTabs.svelte @@ -7,12 +7,14 @@ type TerminalTab, } from '../../stores/workspace.svelte'; import TerminalPane from '../Terminal/TerminalPane.svelte'; + import AgentPreviewPane from '../Terminal/AgentPreviewPane.svelte'; interface Props { project: ProjectConfig; + agentSessionId?: string | null; } - let { project }: Props = $props(); + let { project, agentSessionId }: Props = $props(); let tabs = $derived(getTerminalTabs(project.id)); let activeTabId = $state(null); @@ -38,6 +40,26 @@ activeTabId = id; } + function addAgentPreviewTab() { + if (!agentSessionId) return; + // Don't create duplicate — check if one already exists for this session + const existing = tabs.find( + t => t.type === 'agent-preview' && t.agentSessionId === agentSessionId, + ); + if (existing) { + activeTabId = existing.id; + return; + } + const id = crypto.randomUUID(); + addTerminalTab(project.id, { + id, + title: 'Agent Preview', + type: 'agent-preview', + agentSessionId, + }); + activeTabId = id; + } + function closeTab(tabId: string) { removeTerminalTab(project.id, tabId); } @@ -66,18 +88,29 @@ >× {/each} - + + {#if agentSessionId} + + {/if}
{#each tabs as tab (tab.id)}
{#if activeTabId === tab.id} - handleTabExit(tab.id)} - /> + {#if tab.type === 'agent-preview' && tab.agentSessionId} + + {:else} + handleTabExit(tab.id)} + /> + {/if} {/if}
{/each} @@ -171,6 +204,10 @@ background: var(--ctp-surface0); } + .tab-agent-preview { + font-size: 0.7rem; + } + .tab-content { flex: 1; position: relative; diff --git a/v2/src/lib/stores/workspace.svelte.ts b/v2/src/lib/stores/workspace.svelte.ts index 0d42342..ea2d5b0 100644 --- a/v2/src/lib/stores/workspace.svelte.ts +++ b/v2/src/lib/stores/workspace.svelte.ts @@ -7,9 +7,11 @@ export type WorkspaceTab = 'sessions' | 'docs' | 'context' | 'settings'; export interface TerminalTab { id: string; title: string; - type: 'shell' | 'ssh' | 'agent-terminal'; + type: 'shell' | 'ssh' | 'agent-terminal' | 'agent-preview'; /** SSH session ID if type === 'ssh' */ sshSessionId?: string; + /** Agent session ID if type === 'agent-preview' */ + agentSessionId?: string; } // --- Core state ---