From eaa5678e806989e0e5731b957d3b65e1b08b203d Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 13:48:21 -0700 Subject: [PATCH 01/10] feat(chat): a chat pane of its own, opened for any chat the host runs Chats lived inside the agent's terminal pane and were tracked by a terminal id that died when the chat took over, so chats with no pane (Roster's createSession, automation runs) never showed up, and a continued automation run could not find the chat it should prompt. - The chat-v3 pane now renders the ACP chat, keyed by its chat session; the ChatV3Pane prototype is removed. Saved terminal panes that held a chat move to a chat pane on load. - The CLI/CHAT toggle swaps the pane between a terminal and a chat pane, stopping the process behind the one it leaves. - useAutoAdoptChatSessions opens a chat pane for every live chat session in the workspace that no pane holds, on chat:sessions-changed. - agents.run takes surface: "chat" and starts a host chat session; a continued run prompts the previous run's chat when it is still live. Automations ask for a chat when the owner has the acp-chat flag. - listSessions reports live and terminalId; the chat shows a notice when it was stopped from outside. --- .../useWorkspaceEvent/useWorkspaceEvent.ts | 22 ++- .../lib/acpHarness/acpHarness.test.ts | 9 +- .../src/renderer/lib/acpHarness/acpHarness.ts | 6 + .../src/renderer/lib/acpHarness/index.ts | 2 +- .../persisted-key-registry.test-data.ts | 2 +- .../components/AddTabMenu/AddTabMenu.tsx | 12 +- .../RightPaneArea/RightPaneArea.tsx | 6 +- .../RightPaneAddMenu/RightPaneAddMenu.tsx | 16 +- .../components/RightPaneArea/types.ts | 1 - .../WorkspaceEmptyState.tsx | 18 +- .../useAgentSessionLauncher.ts | 12 +- .../hooks/useAutoAdoptChatSessions/index.ts | 1 + .../useAutoAdoptChatSessions.ts | 107 +++++++++++ .../useConsumeAutomationRunLink.ts | 6 +- .../AgentTerminalPane/AgentTerminalPane.tsx | 161 +++++----------- .../AgentSurfaceToggle/AgentSurfaceToggle.tsx | 22 +-- .../hooks/useAgentSurface/index.ts | 2 +- .../hooks/useAgentSurface/useAgentSurface.ts | 49 +++-- .../useAgentSurfaceSwitch.ts | 101 +++++----- .../components/AgentTerminalPane/index.ts | 6 - .../components/ChatPane/ChatPane.tsx | 93 +++++++++ .../components/AcpChatPane/AcpChatPane.tsx | 60 +++++- .../AcpChatPending/AcpChatPending.tsx | 0 .../components/AcpChatPending/index.ts | 0 .../components/AcpRecovery/AcpRecovery.tsx | 25 ++- .../components/AcpRecovery/index.ts | 0 .../components/AcpChatPane/index.ts | 0 .../hooks/useForkChat/index.ts | 0 .../hooks/useForkChat/useForkChat.ts | 0 .../components/ChatPane/index.ts | 1 + .../utils/savedChatMode/index.ts | 0 .../utils/savedChatMode/savedChatMode.test.ts | 0 .../utils/savedChatMode/savedChatMode.ts | 0 .../components/ChatV3Pane/ChatV3Pane.tsx | 78 -------- .../NewSessionView/NewSessionView.tsx | 67 ------- .../components/NewSessionView/index.ts | 2 - .../SessionPicker/SessionPicker.tsx | 82 -------- .../components/SessionPicker/index.ts | 1 - .../components/ChatV3Pane/index.ts | 1 - .../hooks/usePaneRegistry/usePaneRegistry.tsx | 130 ++++++------- .../useWorkspacePaneOpeners.ts | 14 -- .../v2-workspace/$workspaceId/page.tsx | 15 +- .../v2-workspace/$workspaceId/types.ts | 51 ++--- .../closedChatSessions/closedChatSessions.ts | 10 + .../utils/closedChatSessions/index.ts | 4 + .../focusTerminalPane/focusTerminalPane.ts | 2 +- .../renderer/stores/v2-notifications/store.ts | 3 +- .../src/commands/commands/commands.test.ts | 28 +++ .../src/commands/commands/commands.ts | 20 +- .../src/commands/commands/index.ts | 1 + packages/chat-runtime/src/commands/index.ts | 1 + packages/host-service/src/app.ts | 1 + .../host-service/src/chat-v3/acpCatalogue.ts | 11 ++ .../src/trpc/router/agents/agents.test.ts | 38 ++++ .../src/trpc/router/agents/agents.ts | 178 ++++++++++++++++-- packages/host-service/src/types.ts | 2 + packages/i18n/locales/cs/messages.po | 24 +-- packages/i18n/locales/de/messages.po | 24 +-- packages/i18n/locales/en/messages.po | 24 +-- packages/i18n/locales/es/messages.po | 24 +-- packages/i18n/locales/fr/messages.po | 24 +-- packages/i18n/locales/id/messages.po | 24 +-- packages/i18n/locales/it/messages.po | 24 +-- packages/i18n/locales/ja/messages.po | 24 +-- packages/i18n/locales/ko/messages.po | 24 +-- packages/i18n/locales/nl/messages.po | 24 +-- packages/i18n/locales/pl/messages.po | 24 +-- packages/i18n/locales/pt-BR/messages.po | 24 +-- packages/i18n/locales/ru/messages.po | 24 +-- packages/i18n/locales/tr/messages.po | 24 +-- packages/i18n/locales/vi/messages.po | 24 +-- packages/i18n/locales/zh-CN/messages.po | 24 +-- packages/i18n/locales/zh-TW/messages.po | 24 +-- .../trpc/src/router/automation/dispatch.ts | 17 ++ 74 files changed, 930 insertions(+), 975 deletions(-) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/index.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/useAutoAdoptChatSessions.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/components/AcpChatPane/AcpChatPane.tsx (87%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/components/AcpChatPane/components/AcpChatPending/index.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx (67%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/components/AcpChatPane/components/AcpRecovery/index.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/components/AcpChatPane/index.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/hooks/useForkChat/index.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/hooks/useForkChat/useForkChat.ts (100%) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/index.ts rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/utils/savedChatMode/index.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/utils/savedChatMode/savedChatMode.test.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{AgentTerminalPane => ChatPane}/utils/savedChatMode/savedChatMode.ts (100%) delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/ChatV3Pane.tsx delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/NewSessionView.tsx delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/index.ts delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/SessionPicker.tsx delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/index.ts delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/index.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/closedChatSessions.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/index.ts diff --git a/apps/desktop/src/renderer/hooks/host-service/useWorkspaceEvent/useWorkspaceEvent.ts b/apps/desktop/src/renderer/hooks/host-service/useWorkspaceEvent/useWorkspaceEvent.ts index 922a445de6d..0703ff9c347 100644 --- a/apps/desktop/src/renderer/hooks/host-service/useWorkspaceEvent/useWorkspaceEvent.ts +++ b/apps/desktop/src/renderer/hooks/host-service/useWorkspaceEvent/useWorkspaceEvent.ts @@ -1,6 +1,7 @@ import type { AgentBindingsChangedPayload, AgentLifecyclePayload, + ChatSessionsChangedPayload, GitChangedPayload, PageWatchChangedPayload, PortChangedPayload, @@ -57,6 +58,12 @@ export function useWorkspaceEvent( callback: (payload: PageWatchChangedPayload) => void, enabled?: boolean, ): void; +export function useWorkspaceEvent( + type: "chat:sessions-changed", + workspaceId: string, + callback: (payload: ChatSessionsChangedPayload) => void, + enabled?: boolean, +): void; export function useWorkspaceEvent( type: | "git:changed" @@ -65,7 +72,8 @@ export function useWorkspaceEvent( | "agent:bindings-changed" | "terminal:lifecycle" | "port:changed" - | "page-watch:changed", + | "page-watch:changed" + | "chat:sessions-changed", workspaceId: string, callback: | ((event: FsWatchEvent) => void) @@ -74,7 +82,8 @@ export function useWorkspaceEvent( | ((payload: AgentBindingsChangedPayload) => void) | ((payload: TerminalLifecyclePayload) => void) | ((payload: PortChangedPayload) => void) - | ((payload: PageWatchChangedPayload) => void), + | ((payload: PageWatchChangedPayload) => void) + | ((payload: ChatSessionsChangedPayload) => void), enabled = true, ): void { const hostUrl = useWorkspaceHostUrl(workspaceId); @@ -143,6 +152,15 @@ export function useWorkspaceEvent( }, ); cleanups.push(removeListener); + } else if (type === "chat:sessions-changed") { + const removeListener = bus.on( + "chat:sessions-changed", + workspaceId, + (_wid, payload) => { + (handler as (payload: ChatSessionsChangedPayload) => void)(payload); + }, + ); + cleanups.push(removeListener); } else { // GitWatcher only watches a workspace while someone holds interest // (see #6729) — watchGit/unwatchGit drive that refcount so this diff --git a/apps/desktop/src/renderer/lib/acpHarness/acpHarness.test.ts b/apps/desktop/src/renderer/lib/acpHarness/acpHarness.test.ts index 9f854b6b91a..8b669e16571 100644 --- a/apps/desktop/src/renderer/lib/acpHarness/acpHarness.test.ts +++ b/apps/desktop/src/renderer/lib/acpHarness/acpHarness.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "bun:test"; -import { acpHarnessForPreset } from "./acpHarness"; +import { acpHarnessForPreset, presetForAcpHarness } from "./acpHarness"; describe("acpHarnessForPreset", () => { it("maps a preset to its harness", () => { @@ -20,3 +20,10 @@ describe("acpHarnessForPreset", () => { expect(acpHarnessForPreset(undefined)).toBeUndefined(); }); }); + +describe("presetForAcpHarness", () => { + it("maps a harness back to its preset", () => { + expect(presetForAcpHarness("claude-acp")).toBe("claude"); + expect(presetForAcpHarness("claude-code")).toBeUndefined(); + }); +}); diff --git a/apps/desktop/src/renderer/lib/acpHarness/acpHarness.ts b/apps/desktop/src/renderer/lib/acpHarness/acpHarness.ts index 0fd28f50093..aff11c79f0a 100644 --- a/apps/desktop/src/renderer/lib/acpHarness/acpHarness.ts +++ b/apps/desktop/src/renderer/lib/acpHarness/acpHarness.ts @@ -19,3 +19,9 @@ export function acpHarnessForPreset( ): string | undefined { return presetId ? ACP_HARNESS_BY_PRESET[presetId] : undefined; } + +export function presetForAcpHarness(harness: string): string | undefined { + return Object.entries(ACP_HARNESS_BY_PRESET).find( + ([, candidate]) => candidate === harness, + )?.[0]; +} diff --git a/apps/desktop/src/renderer/lib/acpHarness/index.ts b/apps/desktop/src/renderer/lib/acpHarness/index.ts index 531d52051c5..bce0cccaefa 100644 --- a/apps/desktop/src/renderer/lib/acpHarness/index.ts +++ b/apps/desktop/src/renderer/lib/acpHarness/index.ts @@ -1 +1 @@ -export { acpHarnessForPreset } from "./acpHarness"; +export { acpHarnessForPreset, presetForAcpHarness } from "./acpHarness"; diff --git a/apps/desktop/src/renderer/lib/persisted-keys/persisted-key-registry.test-data.ts b/apps/desktop/src/renderer/lib/persisted-keys/persisted-key-registry.test-data.ts index 9bd9cce65c7..7c0e4989286 100644 --- a/apps/desktop/src/renderer/lib/persisted-keys/persisted-key-registry.test-data.ts +++ b/apps/desktop/src/renderer/lib/persisted-keys/persisted-key-registry.test-data.ts @@ -168,7 +168,7 @@ export const PERSISTED_KEY_REGISTRY: ReadonlyArray< ["chatFavoriteModels"], ], [ - "src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/savedChatMode.ts", + "src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/savedChatMode.ts", ["chatModeByAgent"], ], [ diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/AddTabMenu/AddTabMenu.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/AddTabMenu/AddTabMenu.tsx index 9fca3beae1f..ff4e1bd038c 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/AddTabMenu/AddTabMenu.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/AddTabMenu/AddTabMenu.tsx @@ -6,12 +6,11 @@ import { } from "@superset/ui/dropdown-menu"; import { BsTerminalPlus } from "react-icons/bs"; import { LuGitCompareArrows } from "react-icons/lu"; -import { TbDeviceDesktop, TbMessageCirclePlus, TbWorld } from "react-icons/tb"; +import { TbDeviceDesktop, TbWorld } from "react-icons/tb"; import { HotkeyMenuShortcut } from "renderer/components/HotkeyMenuShortcut"; interface AddTabMenuProps { onAddTerminal: () => void; - onAddChatV3?: (() => void) | undefined; onAddBrowser: () => void; onAddChanges: () => void; onAddDesktop?: (() => void) | undefined; @@ -21,7 +20,6 @@ interface AddTabMenuProps { export function AddTabMenu({ onAddTerminal, - onAddChatV3, onAddBrowser, onAddChanges, onAddDesktop, @@ -37,14 +35,6 @@ export function AddTabMenu({ - {onAddChatV3 && ( - - - - Chat v3 - - - )} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/RightPaneArea.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/RightPaneArea.tsx index 36c7e02b318..6f1ce65064f 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/RightPaneArea.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/RightPaneArea.tsx @@ -35,7 +35,6 @@ interface RightPaneAreaProps { onToggleExpanded: () => void; onMergeIntoCenter: () => void; onAdd: (kind: RightPaneKind) => void; - isChatEnabled: boolean; showWindowControls: boolean; } @@ -51,7 +50,6 @@ export function RightPaneArea({ onToggleExpanded, onMergeIntoCenter, onAdd, - isChatEnabled, showWindowControls, }: RightPaneAreaProps) { const { t } = useLingui(); @@ -68,9 +66,7 @@ export function RightPaneArea({ sources={getV2NotificationSourcesForTab(tab)} /> )} - renderAddTabMenu={() => ( - - )} + renderAddTabMenu={() => } renderTabBarTrailing={() => (
void; - isChatEnabled: boolean; } -export function RightPaneAddMenu({ - onAdd, - isChatEnabled, -}: RightPaneAddMenuProps) { +export function RightPaneAddMenu({ onAdd }: RightPaneAddMenuProps) { return ( <> onAdd("files")}> @@ -62,14 +58,6 @@ export function RightPaneAddMenu({ Browser - {isChatEnabled && ( - onAdd("chat-v3")}> - - - Chat v3 - - - )} onAdd("terminal")}> diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/types.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/types.ts index 19e0c8cdb2d..7117448ed14 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/types.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/RightPaneArea/types.ts @@ -5,5 +5,4 @@ export type RightPaneKind = | "review" | "pages-list" | "browser" - | "chat-v3" | "terminal"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceEmptyState/WorkspaceEmptyState.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceEmptyState/WorkspaceEmptyState.tsx index 3838242d5fa..1d05227d77f 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceEmptyState/WorkspaceEmptyState.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceEmptyState/WorkspaceEmptyState.tsx @@ -3,7 +3,7 @@ import { useMemo } from "react"; import type { IconType } from "react-icons"; import { BsTerminalPlus } from "react-icons/bs"; import { LuGitCompareArrows, LuSearch } from "react-icons/lu"; -import { TbMessageCirclePlus, TbWorld } from "react-icons/tb"; +import { TbWorld } from "react-icons/tb"; import { GitHubStarPill } from "renderer/components/GitHubStarPill"; import { useHotkeyDisplay } from "renderer/hotkeys"; import supersetEmptyStateWordmark from "renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/assets/superset-empty-state-wordmark.svg"; @@ -13,7 +13,6 @@ import { useTheme } from "renderer/stores/theme"; interface WorkspaceEmptyStateProps { onOpenBrowser: () => void; onOpenChanges: () => void; - onOpenChatV3?: (() => void) | undefined; onOpenQuickOpen: () => void; onOpenTerminal: () => void; } @@ -29,7 +28,6 @@ interface WorkspaceEmptyStateAction { export function WorkspaceEmptyState({ onOpenBrowser, onOpenChanges, - onOpenChatV3, onOpenQuickOpen, onOpenTerminal, }: WorkspaceEmptyStateProps) { @@ -51,19 +49,6 @@ export function WorkspaceEmptyState({ icon: BsTerminalPlus, onClick: onOpenTerminal, }, - ...(onOpenChatV3 - ? [ - { - id: "chat-v3", - label: t({ - message: "Open Chat v3", - }), - display: [], - icon: TbMessageCirclePlus, - onClick: onOpenChatV3, - }, - ] - : []), { id: "browser", label: t({ @@ -97,7 +82,6 @@ export function WorkspaceEmptyState({ newGroupDisplay, onOpenBrowser, onOpenChanges, - onOpenChatV3, onOpenQuickOpen, onOpenTerminal, openChangesDisplay, diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAgentSessionLauncher/useAgentSessionLauncher.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAgentSessionLauncher/useAgentSessionLauncher.ts index e4a66431f99..451eb0de155 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAgentSessionLauncher/useAgentSessionLauncher.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAgentSessionLauncher/useAgentSessionLauncher.ts @@ -14,7 +14,11 @@ import { import { acpHarnessForPreset } from "renderer/lib/acpHarness"; import { terminalQueryColors } from "renderer/lib/terminal/terminal-query-colors"; import type { StoreApi } from "zustand/vanilla"; -import type { PaneViewerData, TerminalPaneData } from "../../types"; +import type { + ChatPaneData, + PaneViewerData, + TerminalPaneData, +} from "../../types"; import { focusOrAddTerminalPane } from "../../utils/focusTerminalPane"; export interface CreateNewAgentSessionInput { @@ -71,11 +75,11 @@ export function useAgentSessionLauncher({ const terminalId = crypto.randomUUID(); const label = config?.label; const pane = { - kind: "terminal" as const, + kind: "chat-v3" as const, ...(label ? { titleOverride: label } : {}), data: { terminalId, - agentSurface: "acp", + sessionId: null, agent: { id: presetId }, ...(input.prompt ? { pendingPrompt: input.prompt } : {}), ...(input.attachments?.length @@ -83,7 +87,7 @@ export function useAgentSessionLauncher({ : {}), ...(input.modelId ? { chatModelId: input.modelId } : {}), ...(input.modeId ? { chatModeId: input.modeId } : {}), - } as TerminalPaneData, + } satisfies ChatPaneData, }; if (input.placement === "split-pane" && state.activeTabId) { state.addPane({ tabId: state.activeTabId, pane }); diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/index.ts new file mode 100644 index 00000000000..a909456f496 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/index.ts @@ -0,0 +1 @@ +export { useAutoAdoptChatSessions } from "./useAutoAdoptChatSessions"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/useAutoAdoptChatSessions.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/useAutoAdoptChatSessions.ts new file mode 100644 index 00000000000..3488d51ca37 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useAutoAdoptChatSessions/useAutoAdoptChatSessions.ts @@ -0,0 +1,107 @@ +import type { WorkspaceStore } from "@superset/panes"; +import { useWorkspaceClient } from "@superset/workspace-client"; +import { useQuery, useQueryClient } from "@tanstack/react-query"; +import { useEffect, useMemo } from "react"; +import { useWorkspaceEvent } from "renderer/hooks/host-service/useWorkspaceEvent"; +import { useAcpChatEnabled } from "renderer/hooks/useAcpChatEnabled"; +import { presetForAcpHarness } from "renderer/lib/acpHarness"; +import type { StoreApi } from "zustand/vanilla"; +import type { ChatPaneData, PaneViewerData } from "../../types"; +import { isChatSessionClosed } from "../../utils/closedChatSessions"; +import { useChatWiring } from "../usePaneRegistry/components/ChatSession/hooks/useSessionClient"; + +interface UseAutoAdoptChatSessionsArgs { + store: StoreApi>; + linkedStores: readonly StoreApi>[]; + workspaceId: string; + isLayoutReady: boolean; +} + +export function useAutoAdoptChatSessions({ + store, + linkedStores, + workspaceId, + isLayoutReady, +}: UseAutoAdoptChatSessionsArgs): void { + const enabled = useAcpChatEnabled() === "enabled" && isLayoutReady; + const { hostUrl } = useWorkspaceClient(); + const { transport } = useChatWiring(); + const queryClient = useQueryClient(); + const queryKey = useMemo( + () => ["chat-v3", hostUrl, "listSessions", workspaceId], + [hostUrl, workspaceId], + ); + const sessionsQuery = useQuery({ + queryKey, + queryFn: () => transport.listSessions({ workspaceId }), + enabled, + refetchOnWindowFocus: false, + }); + const sessions = sessionsQuery.data; + const isFetchingSessions = sessionsQuery.isFetching; + + useWorkspaceEvent( + "chat:sessions-changed", + workspaceId, + () => { + void queryClient.invalidateQueries({ queryKey }); + }, + enabled, + ); + + useEffect(() => { + if (!enabled || !sessions || isFetchingSessions) return; + + const attached = new Set(); + for (const tab of [store, ...linkedStores].flatMap( + (paneStore) => paneStore.getState().tabs, + )) { + for (const pane of Object.values(tab.panes)) { + if (pane.kind !== "terminal" && pane.kind !== "chat-v3") continue; + const data = pane.data as Partial; + if (data.terminalId) attached.add(data.terminalId); + if (data.sessionId) attached.add(data.sessionId); + } + } + + const toAdopt = sessions + .filter( + (session) => + session.live && + !isChatSessionClosed(session.sessionId) && + !attached.has(session.sessionId) && + !(session.terminalId && attached.has(session.terminalId)) && + presetForAcpHarness(session.harness), + ) + .sort((a, b) => a.updatedAt - b.updatedAt); + if (toAdopt.length === 0) return; + + const state = store.getState(); + const restoreActiveTabId = state.tabs.length > 0 ? state.activeTabId : null; + for (const session of toAdopt) { + const presetId = presetForAcpHarness(session.harness); + if (!presetId) continue; + store.getState().addTab({ + panes: [ + { + kind: "chat-v3", + data: { + terminalId: session.terminalId ?? session.sessionId, + sessionId: session.sessionId, + agent: { + id: presetId, + ...(session.harnessSessionId + ? { sessionId: session.harnessSessionId } + : {}), + }, + ...(session.title ? { chatTitle: session.title } : {}), + } satisfies ChatPaneData, + }, + ], + }); + } + if (restoreActiveTabId) { + store.getState().setActiveTab(restoreActiveTabId); + } + }, [enabled, isFetchingSessions, sessions, store, linkedStores]); +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useConsumeAutomationRunLink/useConsumeAutomationRunLink.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useConsumeAutomationRunLink/useConsumeAutomationRunLink.ts index 4083935ea8b..4f24f0d00d2 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useConsumeAutomationRunLink/useConsumeAutomationRunLink.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useConsumeAutomationRunLink/useConsumeAutomationRunLink.ts @@ -3,7 +3,10 @@ import { workspaceTrpc } from "@superset/workspace-client"; import { useEffect, useRef } from "react"; import type { StoreApi } from "zustand/vanilla"; import type { ConsumeSearch, PaneViewerData } from "../../types"; -import { focusOrAddTerminalPane } from "../../utils/focusTerminalPane"; +import { + focusOrAddTerminalPane, + focusTerminalPane, +} from "../../utils/focusTerminalPane"; interface UseConsumeAutomationRunLinkArgs { store: StoreApi>; @@ -73,6 +76,7 @@ export function useConsumeAutomationRunLink({ consumedRef.current.add(key); consumeSearch(["terminalId"]); if (targetTerminalId === null) { + if (focusTerminalPane(store, terminalId)) return; console.warn( "[automation-run-link] Ignoring terminal link: not in this workspace and not resumed elsewhere", { terminalId, workspaceId }, diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/AgentTerminalPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/AgentTerminalPane.tsx index 60379b6b07c..d4a27ba31c5 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/AgentTerminalPane.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/AgentTerminalPane.tsx @@ -1,22 +1,22 @@ -import { Trans } from "@lingui/react/macro"; import type { RendererContext } from "@superset/panes"; -import { useEffect, useRef } from "react"; +import { useEffect } from "react"; import type { + ChatPaneData, OpenFile, PaneViewerData, + TerminalPaneData, } from "renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types"; -import type { TerminalPaneData } from "../../../../types"; import { TerminalPane } from "../TerminalPane"; -import { AcpChatPane } from "./components/AcpChatPane"; -import { AcpChatPending } from "./components/AcpChatPane/components/AcpChatPending"; -import { useAgentSurface } from "./hooks/useAgentSurface"; -import { useAgentSurfaceSwitch } from "./hooks/useAgentSurfaceSwitch"; -import { saveChatMode } from "./utils/savedChatMode"; + +type ChatOnTerminalPaneData = TerminalPaneData & + Omit & { + agentSurface?: "cli" | "acp"; + acpSessionId?: string | null; + }; /** - * A terminal pane, shown on whichever surface its agent calls for. The choice - * needs the agent binding, which is a hook, so it lives here rather than in the - * pane registry's render callback. + * Chats used to be shown on the terminal pane. A layout saved then still holds + * them there, so each one moves to its own chat pane the first time it renders. */ export function AgentTerminalPane({ ctx, @@ -29,115 +29,42 @@ export function AgentTerminalPane({ onOpenFile: OpenFile; onRevealPath: (path: string) => void; }) { - const data = ctx.pane.data as TerminalPaneData; - const { agent, surface } = useAgentSurface(workspaceId, data); - const { switchSurface } = useAgentSurfaceSwitch(workspaceId); + const data = ctx.pane.data as ChatOnTerminalPaneData; + const isSavedChat = data.agentSurface === "acp"; - // A pane that derives onto the chat has recorded nothing: the agent identity - // the chat resumes from is not in its data, and the pty it is replacing is - // still running the agent. Adopting the surface does both, through the same - // path an explicit toggle takes. Keyed by terminal id so a relaunch can be - // adopted again, and so this runs once per terminal rather than per render. - const adopted = useRef(null); - const unrecorded = data.agentSurface === undefined; useEffect(() => { - if (!unrecorded || surface !== "acp" || !agent) return; - if (adopted.current === data.terminalId) return; - adopted.current = data.terminalId; - void switchSurface(ctx, "acp", agent); - }, [unrecorded, surface, agent, data.terminalId, ctx, switchSurface]); + if (!isSavedChat) return; + const { + agentSurface: _surface, + acpSessionId, + createOnAttach: _create, + ...chat + } = data; + const state = ctx.store.getState(); + state.setPanePinned({ paneId: ctx.pane.id, pinned: false }); + state.replacePane({ + tabId: ctx.tab.id, + paneId: ctx.pane.id, + newPane: { + kind: "chat-v3", + pinned: ctx.pane.pinned, + ...(ctx.pane.titleOverride + ? { titleOverride: ctx.pane.titleOverride } + : {}), + data: { ...chat, sessionId: acpSessionId ?? null } as ChatPaneData, + }, + }); + }, [ + isSavedChat, + data, + ctx.store, + ctx.tab.id, + ctx.pane.id, + ctx.pane.titleOverride, + ctx.pane.pinned, + ]); - // Unmounted, not hidden: its pty is stopped on the chat surface, and a - // mounted TerminalPane would auto-resume the agent straight back into it. - if (surface === "acp") { - if (!data.agent) { - return ( - - Opening the chat… - - ); - } - return ( - { - if ( - data.pendingPrompt === undefined && - data.pendingAttachments === undefined - ) - return; - const { - pendingPrompt: _sent, - pendingAttachments: _attached, - ...rest - } = data; - ctx.actions.updateData(rest); - }} - pendingFirstPrompt={ - data.pendingPrompt || data.pendingAttachments?.length - ? [ - ...(data.pendingPrompt - ? [{ type: "text" as const, text: data.pendingPrompt }] - : []), - ...(data.pendingAttachments ?? []).map((attachment) => ({ - type: "attachment" as const, - ...attachment, - })), - ] - : null - } - modelId={data.chatModelId} - modelLabel={data.chatModelLabel} - modeId={data.chatModeId} - onSessionInfo={({ harnessSessionId, title }) => { - const rebound = harnessSessionId !== undefined && data.agent; - const retitled = title !== undefined && title !== data.chatTitle; - if (!rebound && !retitled) return; - ctx.actions.updateData({ - ...data, - ...(rebound - ? { agent: { ...rebound, sessionId: harnessSessionId } } - : {}), - ...(retitled ? { chatTitle: title } : {}), - }); - }} - onSwitchAgent={({ presetId, label, model, modeId, handoffPrompt }) => { - ctx.actions.setTitle(label); - const { - acpSessionId: _session, - chatModelId: _model, - chatModelLabel: _modelLabel, - chatModeId: _mode, - pendingPrompt: _prompt, - pendingAttachments: _attachments, - ...rest - } = data; - ctx.actions.updateData({ - ...rest, - agent: { id: presetId }, - ...(model - ? { chatModelId: model.id, chatModelLabel: model.label } - : {}), - ...(modeId ? { chatModeId: modeId } : {}), - ...(handoffPrompt ? { pendingPrompt: handoffPrompt } : {}), - }); - }} - onModeChange={(chatModeId) => { - if (data.agent) saveChatMode(data.agent.id, chatModeId); - ctx.actions.updateData({ ...data, chatModeId }); - }} - onSessionCreated={(acpSessionId) => - ctx.actions.updateData({ ...data, acpSessionId }) - } - onOpenFile={onOpenFile} - sessionId={data.acpSessionId ?? null} - terminalId={data.terminalId} - workspaceId={workspaceId} - /> - ); - } + if (isSavedChat) return null; return (
); diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/index.ts index 20af8ed8ec6..afebb075e53 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/index.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/index.ts @@ -1,2 +1,2 @@ -export type { ResolvedAgentSurface } from "./useAgentSurface"; +export type { AgentPane, ResolvedAgentSurface } from "./useAgentSurface"; export { useAgentSurface } from "./useAgentSurface"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/useAgentSurface.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/useAgentSurface.ts index be7f18eaf2d..2e5f0f649b0 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/useAgentSurface.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurface/useAgentSurface.ts @@ -1,49 +1,42 @@ import { useTerminalAgentBinding } from "renderer/hooks/host-service/useTerminalAgentBindings"; import { useAcpChatEnabled } from "renderer/hooks/useAcpChatEnabled"; import { acpHarnessForPreset } from "renderer/lib/acpHarness"; -import type { TerminalPaneData } from "../../../../../../types"; +import type { ChatPaneData, TerminalPaneData } from "../../../../../../types"; import type { AgentIdentity, AgentSurface } from "../useAgentSurfaceSwitch"; +export type AgentPane = + | { kind: "terminal"; data: TerminalPaneData } + | { kind: "chat"; data: ChatPaneData }; + export type ResolvedAgentSurface = { surface: AgentSurface; - /** Present only when this agent can be opened as a chat at all. */ agent: AgentIdentity | undefined; - /** Whether the surface can be switched, for the toggle's visibility. */ switchable: boolean; }; -/** - * Which surface an agent terminal shows. - * - * Derived rather than stamped at creation: a terminal becomes an agent - * terminal when the agent reports its binding, and several paths create one - * (the launcher, presets, hotkeys, the session dropdown). Deciding here means - * every one of them opens on the chat, and a pane the user has toggled keeps - * the choice they made. - */ export function useAgentSurface( workspaceId: string, - data: TerminalPaneData, + pane: AgentPane, ): ResolvedAgentSurface { const acpChat = useAcpChatEnabled(); - const binding = useTerminalAgentBinding(workspaceId, data.terminalId); - const harness = acpHarnessForPreset(binding?.agentId); + const binding = useTerminalAgentBinding(workspaceId, pane.data.terminalId); + + if (pane.kind === "chat") { + return { + surface: "acp", + agent: pane.data.agent, + switchable: Boolean(pane.data.agent), + }; + } + const harness = acpHarnessForPreset(binding?.agentId); const agent = harness && binding?.agentId && binding.agentSessionId && !binding.endedAt ? { id: binding.agentId, sessionId: binding.agentSessionId } : undefined; - - // The pane remembers an agent it has already opened as a chat, so the - // surface survives the binding going away with the pty. - const chatCapable = Boolean(acpChat === "enabled" && (agent || data.agent)); - // A stored "acp" outlives the flag it was chosen under, so the flag is read - // first: turning it off has to return every pane to its terminal, not just - // hide the toggle on a pane that keeps running the chat. - const surface: AgentSurface = - acpChat === "disabled" - ? "cli" - : (data.agentSurface ?? (chatCapable ? "acp" : "cli")); - - return { surface, agent, switchable: chatCapable }; + return { + surface: "cli", + agent, + switchable: acpChat === "enabled" && agent !== undefined, + }; } diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurfaceSwitch/useAgentSurfaceSwitch.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurfaceSwitch/useAgentSurfaceSwitch.ts index 7c35646fa0c..0fa10198b91 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurfaceSwitch/useAgentSurfaceSwitch.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useAgentSurfaceSwitch/useAgentSurfaceSwitch.ts @@ -1,13 +1,18 @@ import { useLingui } from "@lingui/react/macro"; import { errorMessage } from "@superset/i18n/errors"; -import type { RendererContext } from "@superset/panes"; +import type { CreatePaneInput, RendererContext } from "@superset/panes"; import { toast } from "@superset/ui/sonner"; import { workspaceTrpc } from "@superset/workspace-client"; import { useCallback, useMemo } from "react"; import { useTerminalAppearance } from "renderer/hooks/useTerminalAppearance"; import { terminalQueryColors } from "renderer/lib/terminal/terminal-query-colors"; import { terminalRuntimeRegistry } from "renderer/lib/terminal/terminal-runtime-registry"; -import type { PaneViewerData, TerminalPaneData } from "../../../../../../types"; +import type { + ChatPaneData, + PaneViewerData, + TerminalPaneData, +} from "../../../../../../types"; +import { markChatSessionClosed } from "../../../../../../utils/closedChatSessions"; import { useChatWiring } from "../../../ChatSession/hooks/useSessionClient"; export type AgentSurface = "cli" | "acp"; @@ -16,19 +21,16 @@ export type AgentIdentity = { id: string; sessionId?: string }; export type AgentSurfaceSwitch = { /** - * Moves an agent terminal between its surfaces, stopping the process behind - * the one being left: two live processes on one session transcript would - * both be writing it. `agent` comes from the caller's own binding read. + * Replaces an agent's terminal pane with its chat pane, or the reverse, + * stopping the process behind the one being left: two live processes on one + * session transcript would both be writing it. */ switchSurface( ctx: RendererContext, surface: AgentSurface, agent: AgentIdentity | undefined, ): Promise; - /** - * For a pane closing on the ACP surface, whose adapter nothing else stops. - * Resolves false when the adapter is still running. - */ + /** Resolves false when the adapter is still running. */ stopChat(sessionId: string): Promise; }; @@ -41,11 +43,13 @@ export function useAgentSurfaceSwitch(workspaceId: string): AgentSurfaceSwitch { const stopChat = useCallback( async (sessionId: string) => { + const reopen = markChatSessionClosed(sessionId); try { await wiring.transport.closeSession({ sessionId }); return true; } catch (error) { console.warn("[acp-chat] could not stop the chat session", error); + reopen(); return false; } }, @@ -58,51 +62,47 @@ export function useAgentSurfaceSwitch(workspaceId: string): AgentSurfaceSwitch { surface: AgentSurface, agent: AgentIdentity | undefined, ) => { - const data = ctx.pane.data as TerminalPaneData; - if ((data.agentSurface ?? "cli") === surface) return; + const replaceWith = (newPane: CreatePaneInput) => { + const state = ctx.store.getState(); + state.setPanePinned({ paneId: ctx.pane.id, pinned: false }); + state.replacePane({ + tabId: ctx.tab.id, + paneId: ctx.pane.id, + newPane: { ...newPane, pinned: ctx.pane.pinned }, + }); + }; if (surface === "acp") { - if (!agent) return; - // Written before the kill: the binding these ids come from dies with - // the terminal, and until the surface is recorded the pane derives - // its own — which the kill is about to change the answer to. - ctx.actions.updateData({ ...data, agentSurface: "acp", agent }); - if ( - data.cliTitle !== undefined && - ctx.pane.titleOverride === data.cliTitle - ) { - ctx.store.getState().setPaneTitleOverride({ - tabId: ctx.tab.id, - paneId: ctx.pane.id, - }); - } - terminalRuntimeRegistry.dispose(data.terminalId); + if (ctx.pane.kind !== "terminal" || !agent) return; + const { terminalId } = ctx.pane.data as TerminalPaneData; + terminalRuntimeRegistry.dispose(terminalId); try { - await killTerminal.mutateAsync({ - terminalId: data.terminalId, - workspaceId, - }); + await killTerminal.mutateAsync({ terminalId, workspaceId }); } catch (error) { - // Put the pane back rather than run a chat over a live pty: both - // would drive the one agent session. console.warn("[acp-chat] could not stop the terminal", error); - ctx.actions.updateData({ ...data, agentSurface: "cli", agent }); toast.error(t({ message: "Couldn't stop the agent's terminal" })); + return; } + replaceWith({ + kind: "chat-v3", + ...(ctx.pane.titleOverride + ? { titleOverride: ctx.pane.titleOverride } + : {}), + data: { + terminalId, + sessionId: null, + agent, + } satisfies ChatPaneData, + }); return; } + if (ctx.pane.kind !== "chat-v3") return; + const data = ctx.pane.data as ChatPaneData; const resumeFrom = data.agent; - if (!resumeFrom) { - ctx.actions.updateData({ ...data, agentSurface: "cli" }); - return; - } + if (!resumeFrom) return; - // Before the launch, not after: the pty resumes the same agent session - // the adapter still has open, and two processes on one session is what - // this whole switch exists to avoid. A chat that would not stop keeps - // the pane where it is rather than racing the terminal against it. - if (data.acpSessionId && !(await stopChat(data.acpSessionId))) { + if (data.sessionId && !(await stopChat(data.sessionId))) { toast.error(t({ message: "Couldn't stop the chat" })); return; } @@ -113,8 +113,6 @@ export function useAgentSurfaceSwitch(workspaceId: string): AgentSurfaceSwitch { colors: terminalQueryColors(appearance.theme), agent: resumeFrom.id, prompt: "", - // A chat the launcher opened may not have run a turn yet, so - // there is no agent session to resume into the terminal. ...(resumeFrom.sessionId ? { resumeSessionId: resumeFrom.sessionId } : {}), @@ -125,18 +123,11 @@ export function useAgentSurfaceSwitch(workspaceId: string): AgentSurfaceSwitch { ); return; } - // `updateData` replaces the pane's data rather than merging into it, - // so the surface has to be written again here: dropped, it derives - // back to the chat for a chat-capable agent and the terminal this - // just launched is unmounted before it draws. `acpSessionId` is kept - // so toggling back resumes that chat instead of starting a new one. - ctx.actions.updateData({ - ...data, - agentSurface: "cli", - terminalId: result.sessionId, - cliTitle: result.label, + replaceWith({ + kind: "terminal", + titleOverride: result.label, + data: { terminalId: result.sessionId } satisfies TerminalPaneData, }); - ctx.actions.setTitle(result.label); } catch (error) { toast.error(t({ message: "Couldn't reopen the agent in a terminal" }), { description: errorMessage(error, t({ message: "Unknown error" })), diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/index.ts index 17d3bc0840f..5689706936b 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/index.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/index.ts @@ -1,9 +1,3 @@ -/** - * The ACP chat surface, behind the `acp-chat` flag. Everything it needs lives - * under this folder — the pane, its chat, the toggle, the surface derivation - * and the harness table — so removing the prototype is removing the folder - * and these three imports. - */ export { AgentTerminalPane } from "./AgentTerminalPane"; export { AgentSurfaceToggle } from "./components/AgentSurfaceToggle"; export { useAgentSurfaceSwitch } from "./hooks/useAgentSurfaceSwitch"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx new file mode 100644 index 00000000000..1fc87ad6f95 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx @@ -0,0 +1,93 @@ +import type { RendererContext } from "@superset/panes"; +import type { + ChatPaneData, + OpenFile, + PaneViewerData, +} from "renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types"; +import { AcpChatPane } from "./components/AcpChatPane"; +import { saveChatMode } from "./utils/savedChatMode"; + +export function ChatPane({ + ctx, + onOpenFile, + workspaceId, +}: { + ctx: RendererContext; + workspaceId: string; + onOpenFile: OpenFile; +}) { + const data = ctx.pane.data as ChatPaneData; + + return ( + { + if ( + data.pendingPrompt === undefined && + data.pendingAttachments === undefined + ) + return; + const { + pendingPrompt: _sent, + pendingAttachments: _attached, + ...rest + } = data; + ctx.actions.updateData(rest); + }} + pendingFirstPrompt={ + data.pendingPrompt || data.pendingAttachments?.length + ? [ + ...(data.pendingPrompt + ? [{ type: "text" as const, text: data.pendingPrompt }] + : []), + ...(data.pendingAttachments ?? []).map((attachment) => ({ + type: "attachment" as const, + ...attachment, + })), + ] + : null + } + modelId={data.chatModelId} + modelLabel={data.chatModelLabel} + modeId={data.chatModeId} + onSessionInfo={({ harnessSessionId, title }) => { + const rebound = harnessSessionId !== undefined && data.agent; + const retitled = title !== undefined && title !== data.chatTitle; + if (!rebound && !retitled) return; + ctx.actions.updateData({ + ...data, + ...(rebound + ? { agent: { ...rebound, sessionId: harnessSessionId } } + : {}), + ...(retitled ? { chatTitle: title } : {}), + }); + }} + onSwitchAgent={({ presetId, label, model, modeId, handoffPrompt }) => { + ctx.actions.setTitle(label); + ctx.actions.updateData({ + terminalId: data.terminalId, + sessionId: null, + agent: { id: presetId }, + ...(model + ? { chatModelId: model.id, chatModelLabel: model.label } + : {}), + ...(modeId ? { chatModeId: modeId } : {}), + ...(handoffPrompt ? { pendingPrompt: handoffPrompt } : {}), + }); + }} + onModeChange={(chatModeId) => { + if (data.agent) saveChatMode(data.agent.id, chatModeId); + ctx.actions.updateData({ ...data, chatModeId }); + }} + onSessionCreated={(sessionId) => + ctx.actions.updateData({ ...data, sessionId }) + } + onOpenFile={onOpenFile} + sessionId={data.sessionId} + terminalId={data.terminalId} + workspaceId={workspaceId} + /> + ); +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/AcpChatPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx similarity index 87% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/AcpChatPane.tsx rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx index b663778ba00..bef895d7b19 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/AcpChatPane.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx @@ -4,8 +4,10 @@ import { getAgentModelSupport } from "@superset/shared/agent-models"; import { buildChatSessionHandoffPrompt } from "@superset/shared/terminal-session-handoff"; import { toast } from "@superset/ui/sonner"; import { useWorkspaceClient } from "@superset/workspace-client"; -import { useQuery } from "@tanstack/react-query"; +import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { useTerminalAgentBindings } from "renderer/hooks/host-service/useTerminalAgentBindings"; +import { useWorkspaceEvent } from "renderer/hooks/host-service/useWorkspaceEvent"; import { useV2AgentConfigs } from "renderer/hooks/useV2AgentConfigs"; import { acpHarnessForPreset } from "renderer/lib/acpHarness"; import type { OpenFile } from "../../../../../../types"; @@ -19,9 +21,8 @@ import { AcpChatPending } from "./components/AcpChatPending"; import { AcpRecovery } from "./components/AcpRecovery"; /** - * The ACP surface of an agent terminal: a chat bridged to the agent session the - * terminal was running, resumed by its session id. The pty is stopped while - * this shows, so `agent` comes from the pane rather than the live binding. + * A chat bridged to an agent session, resumed by its session id. `agent` comes + * from the pane: the terminal it may have come from is stopped. */ export function AcpChatPane({ agent, @@ -85,6 +86,17 @@ export function AcpChatPane({ : Promise.resolve(null), staleTime: 5_000, }); + const queryClient = useQueryClient(); + useWorkspaceEvent( + "chat:sessions-changed", + workspaceId, + () => { + void queryClient.invalidateQueries({ + queryKey: ["acp-chat-session", sessionId], + }); + }, + sessionId !== null, + ); const attaching = useRef(false); // A switch to another agent remounts this pane; its pending calls must not @@ -267,28 +279,47 @@ export function AcpChatPane({ // bound to can be loaded again. Dead means the agent exited or failed to // start, and a later attempt may get past either. Reopening a pane should // just work, so do it. + const bindings = useTerminalAgentBindings(workspaceId); + const continuedInTerminal = + agentSessionId !== undefined && + [...bindings.values()].some( + (binding) => + binding.agentSessionId === agentSessionId && + !binding.chatSessionId && + binding.endedAt === undefined, + ); + const sawLive = useRef(false); + if (stored?.live) sawLive.current = true; const canResume = Boolean( - (sessionStopped || sessionDead) && harness && agentSessionId, + (sessionStopped || sessionDead) && + harness && + agentSessionId && + !continuedInTerminal, ); + const stoppedWhileOpen = canResume && sawLive.current; // Once per mount: if the session we resume into is itself unusable, fall // through to the panel instead of spawning adapters in a loop. const autoResumed = useRef(false); const resumingFrom = useRef(null); - useEffect(() => { - if (!canResume || autoResumed.current) return; + const resume = useCallback(() => { if (!harness || !agentSessionId || !sessionId) return; - autoResumed.current = true; resumingFrom.current = sessionId; attaching.current = false; void wiring.transport .closeSession({ sessionId }) .catch(() => undefined) .then(() => start(harness, agentSessionId)); - }, [canResume, harness, agentSessionId, sessionId, start, wiring.transport]); + }, [harness, agentSessionId, sessionId, start, wiring.transport]); + useEffect(() => { + if (!canResume || stoppedWhileOpen || autoResumed.current) return; + autoResumed.current = true; + resume(); + }, [canResume, stoppedWhileOpen, resume]); const resuming = canResume && + !stoppedWhileOpen && (!autoResumed.current || (resumingFrom.current === sessionId && !failure)); if (resuming) { return ( @@ -303,7 +334,16 @@ export function AcpChatPane({ ); } diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpChatPending/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/index.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpChatPending/index.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx similarity index 67% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx index 51faf1f59e1..5f1b5ece540 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx @@ -12,11 +12,13 @@ import { Button } from "@superset/ui/button"; */ export function AcpRecovery({ detail, + onResume, onStartNew, reason, }: { - reason: "no-transcript" | "stopped"; + reason: "no-transcript" | "stopped" | "in-terminal" | "stopped-while-open"; detail?: string | undefined; + onResume?: () => void; onStartNew: () => void; }) { return ( @@ -24,7 +26,13 @@ export function AcpRecovery({ // sizes to its content and hugs the left edge.

- {reason === "no-transcript" ? ( + {reason === "stopped-while-open" ? ( + This chat was stopped. + ) : reason === "in-terminal" ? ( + + This chat stopped because the conversation continued in a terminal. + + ) : reason === "no-transcript" ? ( That agent session has no conversation to open yet — it was started but never prompted. @@ -38,9 +46,16 @@ export function AcpRecovery({ {detail}

)} - +
+ {onResume && ( + + )} + +
); } diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpRecovery/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/index.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/components/AcpRecovery/index.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/index.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/components/AcpChatPane/index.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useForkChat/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useForkChat/index.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useForkChat/index.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useForkChat/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useForkChat/useForkChat.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useForkChat/useForkChat.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/hooks/useForkChat/useForkChat.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useForkChat/useForkChat.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/index.ts new file mode 100644 index 00000000000..50356fa07cf --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/index.ts @@ -0,0 +1 @@ +export { ChatPane } from "./ChatPane"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/index.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/index.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/savedChatMode.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/savedChatMode.test.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/savedChatMode.test.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/savedChatMode.test.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/savedChatMode.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/savedChatMode.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/savedChatMode.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/savedChatMode.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/ChatV3Pane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/ChatV3Pane.tsx deleted file mode 100644 index 5630cc4c3b7..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/ChatV3Pane.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import type { UserContent } from "@superset/chat/protocol"; -import { useCallback, useState } from "react"; -import type { OpenFile } from "../../../../types"; -import { SessionView } from "../ChatSession/components/SessionView"; -import { useSessionClient } from "../ChatSession/hooks/useSessionClient"; -import type { HarnessId } from "./components/NewSessionView"; -import { NewSessionView } from "./components/NewSessionView"; -import { SessionPicker } from "./components/SessionPicker"; - -export function ChatV3Pane({ - isActive, - onOpenFile, - onSessionIdChange, - sessionId, - workspaceId, -}: { - workspaceId: string; - isActive: boolean; - sessionId: string | null; - onSessionIdChange: (sessionId: string | null) => void; - onOpenFile?: OpenFile; -}) { - const { client, wiring } = useSessionClient(sessionId); - const [harness, setHarness] = useState("claude-code"); - const [pendingFirstPrompt, setPendingFirstPrompt] = useState< - UserContent[] | null - >(null); - - const createSession = useCallback( - async (content: UserContent[] | null) => { - const created = await wiring.transport.createSession({ - commandId: crypto.randomUUID(), - workspaceId, - harness, - }); - setPendingFirstPrompt(content); - onSessionIdChange(created.sessionId); - }, - [wiring.transport, workspaceId, harness, onSessionIdChange], - ); - - const picker = ( - onSessionIdChange(null)} - onSelect={onSessionIdChange} - transport={wiring.transport} - workspaceId={workspaceId} - /> - ); - - if (!client || !sessionId) { - return ( - void createSession(content)} - workspaceId={workspaceId} - /> - ); - } - - return ( - setPendingFirstPrompt(null)} - openFile={onOpenFile} - pendingFirstPrompt={pendingFirstPrompt} - sessionId={sessionId} - /> - ); -} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/NewSessionView.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/NewSessionView.tsx deleted file mode 100644 index 8a4a62f1150..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/NewSessionView.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { Trans, useLingui } from "@lingui/react/macro"; -import type { UserContent } from "@superset/chat/protocol"; -import { Button } from "@superset/ui/button"; -import type { ReactNode } from "react"; -import { Composer } from "../../../ChatSession/components/Composer"; - -export const HARNESSES = ["claude-code", "codex"] as const; -export type HarnessId = (typeof HARNESSES)[number]; - -export function NewSessionView({ - harness, - headerLeft, - isActive, - onHarnessChange, - onSend, - workspaceId, -}: { - workspaceId: string; - harness: HarnessId; - isActive: boolean; - onHarnessChange: (harness: HarnessId) => void; - onSend: (content: UserContent[]) => void; - headerLeft?: ReactNode; -}) { - const { t } = useLingui(); - return ( -
-
- {headerLeft} -
- {HARNESSES.map((candidate) => ( - - ))} -
-
-
- - New chat - - - Send a message to start a {harness} session - -
- { - onSend(content); - return null; - }} - workspaceId={workspaceId} - placeholder={t({ - message: `Start a ${harness} session`, - })} - /> -
- ); -} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/index.ts deleted file mode 100644 index 43f650bd775..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/NewSessionView/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { HarnessId } from "./NewSessionView"; -export { HARNESSES, NewSessionView } from "./NewSessionView"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/SessionPicker.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/SessionPicker.tsx deleted file mode 100644 index 4d4b0e3e5a4..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/SessionPicker.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { Trans } from "@lingui/react/macro"; -import type { ChatTransport } from "@superset/chat/client"; -import type { ChatSessionRow } from "@superset/chat-runtime"; -import { Button } from "@superset/ui/button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@superset/ui/dropdown-menu"; -import { ChevronDown, Plus } from "lucide-react"; -import { useCallback, useEffect, useState } from "react"; - -function sessionLabel(session: ChatSessionRow): string { - return session.title ?? session.sessionId.slice(0, 8); -} - -export function SessionPicker({ - activeSessionId, - onNewSession, - onSelect, - transport, - workspaceId, -}: { - workspaceId: string; - transport: ChatTransport; - activeSessionId: string | null; - onSelect: (sessionId: string) => void; - onNewSession: () => void; -}) { - const [sessions, setSessions] = useState([]); - - const refresh = useCallback(async () => { - try { - setSessions(await transport.listSessions({ workspaceId })); - } catch { - setSessions([]); - } - }, [transport, workspaceId]); - - useEffect(() => { - void refresh(); - }, [refresh]); - - const active = sessions.find( - (session) => session.sessionId === activeSessionId, - ); - - return ( - { - if (open) void refresh(); - }} - > - - - - - {sessions.map((session) => ( - onSelect(session.sessionId)} - > - {sessionLabel(session)} - - {session.harness} - - - ))} - {sessions.length > 0 && } - - - New session - - - - ); -} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/index.ts deleted file mode 100644 index b43e3e80ffa..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/components/SessionPicker/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { SessionPicker } from "./SessionPicker"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/index.ts deleted file mode 100644 index 75f6244309b..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatV3Pane/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ChatV3Pane } from "./ChatV3Pane"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/usePaneRegistry.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/usePaneRegistry.tsx index 5fa61cc1cfb..145c0db4841 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/usePaneRegistry.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/usePaneRegistry.tsx @@ -6,7 +6,6 @@ import type { RendererContext, WorkspaceStore, } from "@superset/panes"; -import { FEATURE_FLAGS } from "@superset/shared/constants"; import { alert } from "@superset/ui/atoms/Alert"; import { toast } from "@superset/ui/sonner"; import { cn } from "@superset/ui/utils"; @@ -24,7 +23,6 @@ import { Monitor, Smartphone, } from "lucide-react"; -import { useFeatureFlagEnabled } from "posthog-js/react"; import { useMemo } from "react"; import { LuArrowDownToLine, @@ -59,7 +57,7 @@ import { } from "../../state/fileDocumentStore"; import { type BrowserPaneData, - type ChatV3PaneData, + type ChatPaneData, type CommentPaneData, type DevtoolsPaneData, type FilePaneData, @@ -85,7 +83,7 @@ import { } from "./components/AgentTerminalPane"; import { BrowserPane, BrowserPaneToolbar } from "./components/BrowserPane"; import { ChangesListPane } from "./components/ChangesListPane"; -import { ChatV3Pane } from "./components/ChatV3Pane"; +import { ChatPane } from "./components/ChatPane"; import { CommentPane } from "./components/CommentPane"; import { CommentPaneHeaderExtras } from "./components/CommentPane/components/CommentPaneHeaderExtras"; import { CommentPaneTitle } from "./components/CommentPane/components/CommentPaneTitle"; @@ -179,7 +177,6 @@ export function usePaneRegistry({ const { t } = useLingui(); const { workspace } = useWorkspace(); const workspaceId = workspace.id; - const isChatV3Enabled = useFeatureFlagEnabled(FEATURE_FLAGS.CHAT_V3) ?? false; const agentSurface = useAgentSurfaceSwitch(workspaceId); const host = useWorkspaceHostTarget(workspaceId); const desktopUrl = @@ -385,14 +382,7 @@ export function usePaneRegistry({ message: "Terminal", }), titleSource: (pane) => { - const { terminalId, agentSurface, chatTitle } = - pane.data as TerminalPaneData; - if (agentSurface === "acp") { - return { - subscribe: () => () => {}, - getSnapshot: () => chatTitle, - }; - } + const { terminalId } = pane.data as TerminalPaneData; const instanceId = pane.id; return { subscribe: (callback) => @@ -426,17 +416,8 @@ export function usePaneRegistry({ ); }, onAfterClose: (pane, closedPanes) => { - const { - acpSessionId, - agentSurface: surface, - terminalId, - } = pane.data as TerminalPaneData; - // On the ACP surface the adapter is the only process the close has - // left to end: the pty was either stopped by the switch or — for a - // chat opened from the launcher — never started, and asking the - // host to kill an id it has never seen only logs a failure. - if (surface === "acp") { - if (acpSessionId) void agentSurface.stopChat(acpSessionId); + const { terminalId } = pane.data as TerminalPaneData; + if ((pane.data as { agentSurface?: string }).agentSurface === "acp") { return; } const firstClosed = closedPanes.find( @@ -476,7 +457,10 @@ export function usePaneRegistry({ workspaceId={workspaceId} /> void agentSurface.switchSurface(ctx, surface, agent) } @@ -797,45 +781,62 @@ export function usePaneRegistry({ }), renderPane: () => , }, - ...(isChatV3Enabled - ? { - "chat-v3": { - getIcon: () => , - getTitle: () => - t({ - message: "Chat v3", - }), - renderPane: (ctx: RendererContext) => { - const data = ctx.pane.data as ChatV3PaneData; - return ( - - ctx.actions.updateData({ ...data, sessionId: id }) - } - /> - ); - }, - contextMenuActions: ( - _ctx: RendererContext, - defaults: ContextMenuActionConfig[], - ) => - defaults.map((d) => - d.key === "close-pane" - ? { - ...d, - label: t({ - message: "Close Chat", - }), - } - : d, - ), - }, - } - : {}), + "chat-v3": { + getIcon: (ctx) => { + const { terminalId } = ctx.pane.data as ChatPaneData; + return ( + + ); + }, + getTitle: () => + t({ + message: "Chat", + }), + titleSource: (pane) => { + const { chatTitle } = pane.data as ChatPaneData; + return { + subscribe: () => () => {}, + getSnapshot: () => chatTitle, + }; + }, + onAfterClose: (pane) => { + const { sessionId } = pane.data as ChatPaneData; + if (sessionId) void agentSurface.stopChat(sessionId); + }, + renderHeaderExtras: (ctx: RendererContext) => ( + + void agentSurface.switchSurface(ctx, surface, agent) + } + workspaceId={workspaceId} + /> + ), + renderPane: (ctx: RendererContext) => ( + + ), + contextMenuActions: ( + _ctx: RendererContext, + defaults: ContextMenuActionConfig[], + ) => + defaults.map((d) => + d.key === "close-pane" + ? { + ...d, + label: t({ + message: "Close Chat", + }), + } + : d, + ), + }, comment: { getIcon: (ctx: RendererContext) => { const data = ctx.pane.data as CommentPaneData; @@ -984,7 +985,6 @@ export function usePaneRegistry({ store, linkedStores, workspaceId, - isChatV3Enabled, agentSurface, clearWorkspaceRunTerminal, clearShortcut, diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts index 6ba8111dafa..c658b0717b3 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts @@ -9,7 +9,6 @@ import { useSettings } from "renderer/stores/settings"; import type { StoreApi } from "zustand/vanilla"; import type { BrowserPaneData, - ChatV3PaneData, CommentPaneData, DiffFocusSide, DiffPaneData, @@ -54,7 +53,6 @@ export function useWorkspacePaneOpeners({ changeKey?: string, ) => void; addTerminalTab: () => Promise; - addChatV3Tab: () => void; addBrowserTab: () => void; openChangesPane: () => void; /** Close the visible Changes pane, or open/focus one when none is showing. */ @@ -161,17 +159,6 @@ export function useWorkspacePaneOpeners({ } }, [addBlankTerminalTab, executePreset, newTabPresets]); - const addChatV3Tab = useCallback(() => { - store.getState().addTab({ - panes: [ - { - kind: "chat-v3", - data: { sessionId: null } as ChatV3PaneData, - }, - ], - }); - }, [store]); - const defaultBrowserUrl = useDefaultBrowserUrl(); const addBrowserTab = useCallback(() => { store.getState().addTab({ @@ -254,7 +241,6 @@ export function useWorkspacePaneOpeners({ return { openDiffPane, addTerminalTab, - addChatV3Tab, addBrowserTab, openChangesPane, toggleChangesPane, diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx index ed54335b45b..9a8c7a80b73 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx @@ -40,6 +40,7 @@ import { WorkspaceMoreMenu } from "./components/WorkspaceMoreMenu"; import { WorkspaceSidebar } from "./components/WorkspaceSidebar"; import { useAgentSessionLauncher } from "./hooks/useAgentSessionLauncher"; import { useAutoAdoptBackgroundSessions } from "./hooks/useAutoAdoptBackgroundSessions"; +import { useAutoAdoptChatSessions } from "./hooks/useAutoAdoptChatSessions"; import { useClearActivePaneAttention } from "./hooks/useClearActivePaneAttention"; import { useConsumeAutomationRunLink } from "./hooks/useConsumeAutomationRunLink"; import { useConsumeOpenUrlRequest } from "./hooks/useConsumeOpenUrlRequest"; @@ -260,6 +261,12 @@ function V2WorkspaceContent() { workspaceId, isLayoutReady: isLayoutReady && isRightLayoutReady, }); + useAutoAdoptChatSessions({ + store, + linkedStores: linkedPaneStores, + workspaceId, + isLayoutReady: isLayoutReady && isRightLayoutReady, + }); useConsumeOpenUrlRequest({ store, url: openUrl, @@ -283,7 +290,6 @@ function V2WorkspaceContent() { const { openDiffPane, addTerminalTab, - addChatV3Tab, addBrowserTab, openChangesPane, toggleChangesPane, @@ -375,7 +381,6 @@ function V2WorkspaceContent() { panes: [{ kind: "desktop", data: { kind: "desktop" } }], }); }, [store]); - const isChatV3Enabled = useFeatureFlagEnabled(FEATURE_FLAGS.CHAT_V3) ?? false; useRunPendingChatHandoff({ workspaceId, isLayoutReady, @@ -416,9 +421,6 @@ function V2WorkspaceContent() { case "browser": rightOpeners.addBrowserTab(); return; - case "chat-v3": - rightOpeners.addChatV3Tab(); - return; case "terminal": void rightOpeners.addTerminalTab(); return; @@ -586,7 +588,6 @@ function V2WorkspaceContent() { onToggleExpanded={toggleRightPaneAreaExpanded} onMergeIntoCenter={mergeRightPaneAreaIntoCenter} onAdd={addRightPane} - isChatEnabled={isChatV3Enabled} showWindowControls={!isMac} /> ); @@ -627,7 +628,6 @@ function V2WorkspaceContent() { renderAddTabMenu={() => ( diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts index 61e60d96b0f..5a823cb1c90 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts @@ -29,38 +29,6 @@ export interface TerminalPaneData { * clobber a live or exited session. */ createOnAttach?: boolean; - /** - * Which surface an agent terminal shows. Only one of the two runs at a time: - * on "acp" the pty is stopped and the chat drives the agent session; going - * back to "cli" stops the chat and relaunches the agent on its resume args. - * Absent means the terminal, as it always was. - */ - agentSurface?: "cli" | "acp"; - /** chat-runtime session the ACP surface resumed this agent into. */ - acpSessionId?: string | null; - /** - * Captured before the pty is stopped, because the terminal row and its agent - * binding go with it — and they are what the trip back needs. A pane opened - * straight onto the chat has no session yet: the agent reports one on its - * first turn, and until then there is nothing to resume on either surface. - */ - agent?: { - id: string; - sessionId?: string; - }; - /** First message for a chat opened from the launcher, sent once. */ - pendingPrompt?: string; - pendingAttachments?: Array<{ - attachmentId: string; - name: string; - mimeType: string; - }>; - chatModelId?: string; - /** A model picked from the curated catalog, whose id the agent may not share. */ - chatModelLabel?: string; - chatModeId?: string; - chatTitle?: string; - cliTitle?: string; } export interface BrowserPaneData { @@ -108,8 +76,23 @@ export interface PagePaneData { title?: string; } -export interface ChatV3PaneData { +export interface ChatPaneData { + terminalId: string; sessionId: string | null; + agent?: { + id: string; + sessionId?: string; + }; + pendingPrompt?: string; + pendingAttachments?: Array<{ + attachmentId: string; + name: string; + mimeType: string; + }>; + chatModelId?: string; + chatModelLabel?: string; + chatModeId?: string; + chatTitle?: string; } export interface DesktopPaneData { @@ -171,7 +154,7 @@ export type ConsumeSearch = (keys: WorkspaceSearchKey[]) => void; export type PaneViewerData = | FilePaneData | TerminalPaneData - | ChatV3PaneData + | ChatPaneData | BrowserPaneData | DevtoolsPaneData | DiffPaneData diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/closedChatSessions.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/closedChatSessions.ts new file mode 100644 index 00000000000..dad482d9713 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/closedChatSessions.ts @@ -0,0 +1,10 @@ +const closed = new Set(); + +export function markChatSessionClosed(sessionId: string): () => void { + closed.add(sessionId); + return () => closed.delete(sessionId); +} + +export function isChatSessionClosed(sessionId: string): boolean { + return closed.has(sessionId); +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/index.ts new file mode 100644 index 00000000000..89d29c919ca --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/closedChatSessions/index.ts @@ -0,0 +1,4 @@ +export { + isChatSessionClosed, + markChatSessionClosed, +} from "./closedChatSessions"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/focusTerminalPane/focusTerminalPane.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/focusTerminalPane/focusTerminalPane.ts index a668218c808..ff8ca802bcf 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/focusTerminalPane/focusTerminalPane.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/focusTerminalPane/focusTerminalPane.ts @@ -15,7 +15,7 @@ export function findTerminalPaneLocation( ): TerminalPaneLocation | null { for (const tab of state.tabs) { for (const pane of Object.values(tab.panes)) { - if (pane.kind !== "terminal") continue; + if (pane.kind !== "terminal" && pane.kind !== "chat-v3") continue; const data = pane.data as Partial; if (data.terminalId !== terminalId) continue; return { tabId: tab.id, paneId: pane.id }; diff --git a/apps/desktop/src/renderer/stores/v2-notifications/store.ts b/apps/desktop/src/renderer/stores/v2-notifications/store.ts index 80cf21d3b40..ebbbe43f246 100644 --- a/apps/desktop/src/renderer/stores/v2-notifications/store.ts +++ b/apps/desktop/src/renderer/stores/v2-notifications/store.ts @@ -196,7 +196,8 @@ export function getV2NotificationSourcesForTab( function getTerminalIdForPane( pane: V2NotificationPaneLike | null | undefined, ): string | null { - if (!pane || pane.kind !== "terminal") return null; + if (!pane || (pane.kind !== "terminal" && pane.kind !== "chat-v3")) + return null; if (!pane.data || typeof pane.data !== "object") return null; const terminalId = (pane.data as { terminalId?: unknown }).terminalId; return typeof terminalId === "string" && terminalId ? terminalId : null; diff --git a/packages/chat-runtime/src/commands/commands/commands.test.ts b/packages/chat-runtime/src/commands/commands/commands.test.ts index ee4909f07af..3fda08a4b12 100644 --- a/packages/chat-runtime/src/commands/commands/commands.test.ts +++ b/packages/chat-runtime/src/commands/commands/commands.test.ts @@ -210,6 +210,34 @@ describe("chat commands", () => { await runtime.dispose(); }); + test("listSessions reports which sessions are live and their terminal", async () => { + const { runtime } = newRuntime(); + const withTerminal = runtime.commands.createSession({ + commandId: randomUUID(), + scopeId: "workspace-1", + harness: FAKE_HARNESS, + cwd: "/tmp/workspace", + terminalId: "terminal-1", + }); + const closed = createSession(runtime); + await runtime.commands.closeSession({ sessionId: closed.sessionId }); + + const byId = new Map( + runtime.commands + .listSessions({}) + .map((session) => [session.sessionId, session]), + ); + expect(byId.get(withTerminal.sessionId)).toMatchObject({ + live: true, + terminalId: "terminal-1", + }); + expect(byId.get(closed.sessionId)).toMatchObject({ + live: false, + terminalId: null, + }); + await runtime.dispose(); + }); + test("getItems pages the spine backwards", async () => { const { runtime } = newRuntime(); const created = createSession(runtime); diff --git a/packages/chat-runtime/src/commands/commands/commands.ts b/packages/chat-runtime/src/commands/commands/commands.ts index 5820b9c3e8e..b3529d6d02f 100644 --- a/packages/chat-runtime/src/commands/commands/commands.ts +++ b/packages/chat-runtime/src/commands/commands/commands.ts @@ -78,6 +78,11 @@ export type GetSessionResult = { export type GetQueueResult = QueueState & { live: boolean }; +export type ChatSessionListEntry = ChatSessionRow & { + live: boolean; + terminalId: string | null; +}; + export type ChatCommands = { createSession(input: CreateSessionCommandInput): CreateSessionResult; prompt(input: PromptInput): PromptResult; @@ -95,7 +100,7 @@ export type ChatCommands = { ): Promise; getSession(input: GetSessionInput): GetSessionResult; getQueue(input: GetSessionInput): GetQueueResult; - listSessions(input: ListSessionsCommandInput): ChatSessionRow[]; + listSessions(input: ListSessionsCommandInput): ChatSessionListEntry[]; getItems(input: z.input): PageResult; }; @@ -111,12 +116,21 @@ export type CommandsOptions = { export function createCommands(options: CommandsOptions): ChatCommands { const mintSessionId = options.mintSessionId ?? randomUUID; - const listSessions = (input: ListSessionsCommandInput): ChatSessionRow[] => { + const listSessions = ( + input: ListSessionsCommandInput, + ): ChatSessionListEntry[] => { const parsed = listSessionsCommandSchema.parse(input); const rows = parsed.scopeId ? options.sessions.listByScope(parsed.scopeId) : options.sessions.list(); - return rows.slice(0, parsed.limit); + return rows.slice(0, parsed.limit).map((row) => { + const live = options.live.get(row.sessionId); + return { + ...row, + live: live !== null, + terminalId: live?.terminalId ?? null, + }; + }); }; return { diff --git a/packages/chat-runtime/src/commands/commands/index.ts b/packages/chat-runtime/src/commands/commands/index.ts index 86db47e08a4..9c2c0d8f120 100644 --- a/packages/chat-runtime/src/commands/commands/index.ts +++ b/packages/chat-runtime/src/commands/commands/index.ts @@ -1,5 +1,6 @@ export type { ChatCommands, + ChatSessionListEntry, CommandsOptions, CreateSessionCommandInput, CreateSessionResult, diff --git a/packages/chat-runtime/src/commands/index.ts b/packages/chat-runtime/src/commands/index.ts index 5fe5177bd07..b879c729bab 100644 --- a/packages/chat-runtime/src/commands/index.ts +++ b/packages/chat-runtime/src/commands/index.ts @@ -1,6 +1,7 @@ export { CommandDedupe, DEFAULT_DEDUPE_CAPACITY } from "./commandDedupe"; export type { ChatCommands, + ChatSessionListEntry, CommandsOptions, CreateSessionCommandInput, CreateSessionResult, diff --git a/packages/host-service/src/app.ts b/packages/host-service/src/app.ts index 4e0f6ca0175..d6e3a6365b9 100644 --- a/packages/host-service/src/app.ts +++ b/packages/host-service/src/app.ts @@ -309,6 +309,7 @@ export function createApp(options: CreateAppOptions): CreateAppResult { filesystem, pullRequests: pullRequestRuntime, pageWatch, + chat: () => chatV3.runtime(), }; // Chat v3 runtime (plans/chat-v3-pane-mount.md). Registered unconditionally: diff --git a/packages/host-service/src/chat-v3/acpCatalogue.ts b/packages/host-service/src/chat-v3/acpCatalogue.ts index e45ab8d3e53..3a22d1ae1a1 100644 --- a/packages/host-service/src/chat-v3/acpCatalogue.ts +++ b/packages/host-service/src/chat-v3/acpCatalogue.ts @@ -79,3 +79,14 @@ export function cliFloor(harness: string): { upgrade: entry?.upgrade, }; } + +const ACP_HARNESS_BY_PRESET: Record = { + claude: "claude-acp", + codex: "codex-acp", + opencode: "opencode-acp", + pi: "pi-acp", +}; + +export function acpHarnessForPreset(presetId: string): string | undefined { + return ACP_HARNESS_BY_PRESET[presetId]; +} diff --git a/packages/host-service/src/trpc/router/agents/agents.test.ts b/packages/host-service/src/trpc/router/agents/agents.test.ts index 6e5496c8ece..dfe92a47afe 100644 --- a/packages/host-service/src/trpc/router/agents/agents.test.ts +++ b/packages/host-service/src/trpc/router/agents/agents.test.ts @@ -16,6 +16,8 @@ import { bindResumedSession, buildAgentCommandString, buildTerminalAgentLaunch, + chatContinuationTarget, + chatLaunchTarget, continuationTarget, validateAgentEffortSelection, validateAgentForkSelection, @@ -1037,4 +1039,40 @@ describe("continuationTarget", () => { }), ).toBeNull(); }); + it("continues a chat bound to the terminal while its session is alive", () => { + const db = createTestDb(); + seedClaude(db); + const store = new TerminalAgentStore(); + store.recordChatEvent({ + terminalId, + workspaceId, + eventType: "Stop", + agentId: "claude", + chatSessionId: "chat-1", + occurredAt: Date.now(), + }); + const live = (status: string) => ({ get: () => ({ state: { status } }) }); + + expect(chatContinuationTarget(db, store, live("idle"), run)).toEqual({ + terminalId, + chatSessionId: "chat-1", + label: "Claude", + }); + expect(chatContinuationTarget(db, store, live("dead"), run)).toBeNull(); + }); + + it("launches a chat only when asked for one with an ACP harness", () => { + const db = createTestDb(); + seedClaude(db); + const launch = { workspaceId, agent: "claude", prompt: "go" }; + + expect(chatLaunchTarget(db, { ...launch, surface: "chat" })).toEqual({ + harness: "claude-acp", + label: "Claude", + }); + expect(chatLaunchTarget(db, launch)).toBeNull(); + expect( + chatLaunchTarget(db, { ...launch, surface: "chat", effort: "high" }), + ).toBeNull(); + }); }); diff --git a/packages/host-service/src/trpc/router/agents/agents.ts b/packages/host-service/src/trpc/router/agents/agents.ts index cbcf3e9ab17..8a5edceabfb 100644 --- a/packages/host-service/src/trpc/router/agents/agents.ts +++ b/packages/host-service/src/trpc/router/agents/agents.ts @@ -25,13 +25,17 @@ import { import { TRPCError } from "@trpc/server"; import { and, eq, isNull } from "drizzle-orm"; import { z } from "zod"; +import { acpHarnessForPreset } from "../../../chat-v3/acpCatalogue"; import type { HostDb } from "../../../db"; import { workspaces } from "../../../db/schema"; import { createTerminalSessionInternal, sendAgentMessage, } from "../../../terminal/terminal"; -import type { TerminalAgentStore } from "../../../terminal-agents"; +import type { + TerminalAgentBinding, + TerminalAgentStore, +} from "../../../terminal-agents"; import { agentLaunchEnv, type ResolvedHostAgentConfig, @@ -149,6 +153,7 @@ export interface AgentRunInput { * usual, so a caller may always name a terminal it is unsure about. */ continueTerminalId?: string; + surface?: "terminal" | "chat"; } export type AgentRunResult = { @@ -527,10 +532,52 @@ export function continuationTarget( store: Pick, input: AgentRunInput, ): { terminalId: string; label: string } | null { + const config = continuationConfig(db, input); const terminalId = input.continueTerminalId; + if (!config || !terminalId) return null; + + // Live bindings only, and scoped to this workspace: a binding whose + // terminal died or whose agent detached is not a continuation target. + const binding = store + .listByWorkspace(input.workspaceId) + .find((candidate) => candidate.terminalId === terminalId); + if (!binding || !bindingRunsConfig(db, binding, config)) return null; + + return { terminalId, label: config.label }; +} + +export function chatContinuationTarget( + db: HostDb, + store: Pick, + live: { get(sessionId: string): { state: { status: string } } | null }, + input: AgentRunInput, +): { terminalId: string; chatSessionId: string; label: string } | null { + const config = continuationConfig(db, input); + const terminalId = input.continueTerminalId; + if (!config || !terminalId) return null; + + const binding = store.getChat(terminalId); + const chatSessionId = binding?.chatSessionId; + if (!binding || !chatSessionId || binding.workspaceId !== input.workspaceId) { + return null; + } + const session = live.get(chatSessionId); + if (!session || session.state.status === "dead") return null; + if (!bindingRunsConfig(db, binding, config)) return null; + + return { terminalId, chatSessionId, label: config.label }; +} + +function continuationConfig( + db: HostDb, + input: AgentRunInput, +): ResolvedHostAgentConfig | null { // An empty prompt means "just launch the agent", which a running session // cannot honour. - if (!terminalId || sanitizePromptForPty(input.prompt).trim() === "") { + if ( + !input.continueTerminalId || + sanitizePromptForPty(input.prompt).trim() === "" + ) { return null; } // These all pick something about how the process starts, and the process is @@ -545,28 +592,114 @@ export function continuationTarget( ) { return null; } + return resolveHostAgentConfig(db, input.agent); +} - const config = resolveHostAgentConfig(db, input.agent); - if (!config) return null; - - // Live bindings only, and scoped to this workspace: a binding whose - // terminal died or whose agent detached is not a continuation target. - const binding = store - .listByWorkspace(input.workspaceId) - .find((candidate) => candidate.terminalId === terminalId); - if (!binding) return null; - - // Resolve both sides before comparing: the caller may name a preset while - // the binding carries the instance that preset resolved to, or the reverse. - // This is what stops a prompt landing in whatever agent holds the terminal - // nowrather than the one the caller means. +// Resolve both sides before comparing: the caller may name a preset while +// the binding carries the instance that preset resolved to, or the reverse. +// This is what stops a prompt landing in whatever agent holds the terminal +// now rather than the one the caller means. +function bindingRunsConfig( + db: HostDb, + binding: Pick, + config: ResolvedHostAgentConfig, +): boolean { const bound = resolveHostAgentConfig( db, binding.definitionId ?? binding.agentId, ); - if (!bound || bound.id !== config.id) return null; + return bound?.id === config.id; +} - return { terminalId, label: config.label }; +export function chatLaunchTarget( + db: HostDb, + input: AgentRunInput, +): { harness: string; label: string } | null { + if ( + input.surface !== "chat" || + input.effort || + input.mode || + input.resumeSessionId || + input.forkSessionId || + (input.attachmentIds?.length ?? 0) > 0 + ) { + return null; + } + const config = resolveHostAgentConfig(db, input.agent); + if (!config) return null; + const launchPresetId = resolveAgentLaunchPresetId( + config.presetId, + config.command, + ); + const harness = acpHarnessForPreset(launchPresetId); + if (!harness) return null; + validateAgentModelSelection(launchPresetId, config.label, input.model); + return { harness, label: config.label }; +} + +function continueChatAgent( + ctx: Pick, + input: AgentRunInput, +): AgentRunResult | null { + const terminalId = input.continueTerminalId; + if (!terminalId || !ctx.terminalAgentStore.getChat(terminalId)) return null; + const chat = ctx.runtime.chat?.(); + if (!chat) return null; + const target = chatContinuationTarget( + ctx.db, + ctx.terminalAgentStore, + chat.live, + input, + ); + if (!target) return null; + + try { + chat.commands.prompt({ + commandId: crypto.randomUUID(), + sessionId: target.chatSessionId, + clientId: crypto.randomUUID(), + content: [{ type: "text", text: input.prompt }], + }); + } catch { + return null; + } + + return { + kind: "terminal", + sessionId: target.terminalId, + label: target.label, + }; +} + +function launchChatAgent( + ctx: Pick, + input: AgentRunInput, + cwd: string, +): AgentRunResult | null { + const target = chatLaunchTarget(ctx.db, input); + if (!target) return null; + const chat = ctx.runtime.chat?.(); + if (!chat?.live.supports(target.harness)) return null; + + const terminalId = crypto.randomUUID(); + const { sessionId } = chat.commands.createSession({ + commandId: crypto.randomUUID(), + scopeId: input.workspaceId, + harness: target.harness, + cwd, + terminalId, + ...(input.model ? { modelId: input.model } : {}), + }); + if (input.prompt.trim() !== "") { + chat.commands.prompt({ + commandId: crypto.randomUUID(), + sessionId, + clientId: crypto.randomUUID(), + content: [{ type: "text", text: input.prompt }], + }); + } + + return { kind: "terminal", sessionId: terminalId, label: target.label }; } /** @@ -634,7 +767,8 @@ export async function runAgentInWorkspace( }); } // Ahead of the launch path: continuing costs no pty and no trust seeding. - const continued = await continueTerminalAgent(ctx, input); + const continued = + continueChatAgent(ctx, input) ?? (await continueTerminalAgent(ctx, input)); if (continued) return continued; // Session workspaces are standalone repos the host itself scaffolded, so @@ -648,7 +782,10 @@ export async function runAgentInWorkspace( await seedAgentFolderTrust(ctx.db, workspace.worktreePath, config); } } - return runTerminalAgent(ctx, input); + return ( + launchChatAgent(ctx, input, workspace.worktreePath) ?? + runTerminalAgent(ctx, input) + ); } export const agentsRouter = router({ @@ -668,6 +805,7 @@ export const agentsRouter = router({ resumeSessionId: z.string().min(1).optional(), forkSessionId: z.string().min(1).optional(), continueTerminalId: z.string().min(1).optional(), + surface: z.enum(["terminal", "chat"]).optional(), }), ) .mutation(async ({ ctx, input }) => runAgentInWorkspace(ctx, input)), diff --git a/packages/host-service/src/types.ts b/packages/host-service/src/types.ts index 39503b82395..fa8bf1c64f4 100644 --- a/packages/host-service/src/types.ts +++ b/packages/host-service/src/types.ts @@ -1,4 +1,5 @@ import type { Octokit } from "@octokit/rest"; +import type { ChatRuntime } from "@superset/chat-runtime"; import type { AppRouter } from "@superset/trpc"; import type { TRPCClient } from "@trpc/client"; import type { HostDb } from "./db"; @@ -16,6 +17,7 @@ export interface HostServiceRuntime { filesystem: WorkspaceFilesystemManager; pullRequests: PullRequestRuntimeManager; pageWatch: PageWatchManager; + chat?: () => ChatRuntime; } export interface HostServiceContext { diff --git a/packages/i18n/locales/cs/messages.po b/packages/i18n/locales/cs/messages.po index 8ef2c1d4f61..3132e9748e5 100644 --- a/packages/i18n/locales/cs/messages.po +++ b/packages/i18n/locales/cs/messages.po @@ -3376,9 +3376,6 @@ msgstr "Relace chatu nenalezena" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Plochy chatu: zprávy, uvažování, návrhy" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Zkontrolovat znovu" @@ -10018,9 +10015,6 @@ msgstr "Nový prohlížeč" msgid "new challengers" msgstr "noví vyzyvatelé" -msgid "New chat" -msgstr "Nový chat" - msgid "New cloud workspace" msgstr "Nový cloudový pracovní prostor" @@ -11185,9 +11179,6 @@ msgstr "Otevřít změny" msgid "Open Changes" msgstr "Otevřít změny" -msgid "Open Chat v3" -msgstr "Otevřít Chat v3" - msgid "Open Command Palette" msgstr "Otevřít paletu příkazů" @@ -11545,9 +11536,6 @@ msgstr "Otevírání složek" msgid "Opening pages" msgstr "Otevírání stránek" -msgid "Opening the chat…" -msgstr "Otevírání chatu…" - msgid "Opening the conversation…" msgstr "Otevírám konverzaci…" @@ -14331,9 +14319,6 @@ msgstr "Výběr textu v terminálu ho hned zkopíruje do schránky, bez koncový msgid "Send" msgstr "Odeslat" -msgid "Send a message to start a {harness} session" -msgstr "Odešlete zprávu a spusťte relaci {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Pošlete pozvánku do {organizationName}. Platnost vyprší za 48 hodin." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Začátek" -msgid "Start a {harness} session" -msgstr "Spustit relaci {harness}" - msgid "Start a conversation to see messages here" msgstr "Začněte konverzaci a zprávy se objeví tady" @@ -16519,6 +16501,12 @@ msgstr "Tato automatizace je v jiné organizaci" msgid "This cannot be undone." msgstr "Nelze vrátit zpět." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Tento chat se zastavil, protože konverzace pokračovala v terminálu." + +msgid "This chat was stopped." +msgstr "Tento chat byl zastaven." + msgid "This chat's agent has stopped and can't be resumed." msgstr "Agent tohoto chatu byl zastaven a nelze jej obnovit." diff --git a/packages/i18n/locales/de/messages.po b/packages/i18n/locales/de/messages.po index d2e3a125799..a8dc5b24f88 100644 --- a/packages/i18n/locales/de/messages.po +++ b/packages/i18n/locales/de/messages.po @@ -3376,9 +3376,6 @@ msgstr "Chat-Sitzung nicht gefunden" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Chat-Oberflächen: Nachrichten, Reasoning, Vorschläge" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Erneut prüfen" @@ -10018,9 +10015,6 @@ msgstr "Neuer Browser" msgid "new challengers" msgstr "neue Herausforderer" -msgid "New chat" -msgstr "Neuer Chat" - msgid "New cloud workspace" msgstr "Neuer Cloud-Arbeitsbereich" @@ -11185,9 +11179,6 @@ msgstr "Änderungen öffnen" msgid "Open Changes" msgstr "Änderungen öffnen" -msgid "Open Chat v3" -msgstr "Chat v3 öffnen" - msgid "Open Command Palette" msgstr "Befehlspalette öffnen" @@ -11545,9 +11536,6 @@ msgstr "Ordner öffnen" msgid "Opening pages" msgstr "Seiten öffnen" -msgid "Opening the chat…" -msgstr "Chat wird geöffnet…" - msgid "Opening the conversation…" msgstr "Unterhaltung wird geöffnet…" @@ -14331,9 +14319,6 @@ msgstr "Markierter Text im Terminal wird sofort in die Zwischenablage kopiert, o msgid "Send" msgstr "Senden" -msgid "Send a message to start a {harness} session" -msgstr "Schick eine Nachricht, um eine {harness}-Sitzung zu starten" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Sende eine Einladung zu {organizationName}. Läuft in 48 Stunden ab." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Start" -msgid "Start a {harness} session" -msgstr "Eine {harness}-Sitzung starten" - msgid "Start a conversation to see messages here" msgstr "Starte eine Unterhaltung, damit hier Nachrichten erscheinen" @@ -16519,6 +16501,12 @@ msgstr "Diese Automatisierung befindet sich in einer anderen Organisation" msgid "This cannot be undone." msgstr "Das lässt sich nicht rückgängig machen." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Dieser Chat wurde beendet, weil die Unterhaltung in einem Terminal fortgesetzt wurde." + +msgid "This chat was stopped." +msgstr "Dieser Chat wurde beendet." + msgid "This chat's agent has stopped and can't be resumed." msgstr "Der Agent dieses Chats wurde beendet und lässt sich nicht fortsetzen." diff --git a/packages/i18n/locales/en/messages.po b/packages/i18n/locales/en/messages.po index 5f1681d1511..f88075c5833 100644 --- a/packages/i18n/locales/en/messages.po +++ b/packages/i18n/locales/en/messages.po @@ -3376,9 +3376,6 @@ msgstr "Chat session not found" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Chat surfaces: messages, reasoning, suggestions" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Check again" @@ -10018,9 +10015,6 @@ msgstr "New Browser" msgid "new challengers" msgstr "new challengers" -msgid "New chat" -msgstr "New chat" - msgid "New cloud workspace" msgstr "New cloud workspace" @@ -11185,9 +11179,6 @@ msgstr "Open changes" msgid "Open Changes" msgstr "Open Changes" -msgid "Open Chat v3" -msgstr "Open Chat v3" - msgid "Open Command Palette" msgstr "Open Command Palette" @@ -11545,9 +11536,6 @@ msgstr "Opening folders" msgid "Opening pages" msgstr "Opening pages" -msgid "Opening the chat…" -msgstr "Opening the chat…" - msgid "Opening the conversation…" msgstr "Opening the conversation…" @@ -14331,9 +14319,6 @@ msgstr "Selecting text in a terminal copies it to the clipboard right away, with msgid "Send" msgstr "Send" -msgid "Send a message to start a {harness} session" -msgstr "Send a message to start a {harness} session" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Send an invitation to join {organizationName}. Expires in 48 hours." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Start" -msgid "Start a {harness} session" -msgstr "Start a {harness} session" - msgid "Start a conversation to see messages here" msgstr "Start a conversation to see messages here" @@ -16519,6 +16501,12 @@ msgstr "This automation is in another organization" msgid "This cannot be undone." msgstr "This cannot be undone." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "This chat stopped because the conversation continued in a terminal." + +msgid "This chat was stopped." +msgstr "This chat was stopped." + msgid "This chat's agent has stopped and can't be resumed." msgstr "This chat's agent has stopped and can't be resumed." diff --git a/packages/i18n/locales/es/messages.po b/packages/i18n/locales/es/messages.po index cb30eb7612b..0d8deb6d1f7 100644 --- a/packages/i18n/locales/es/messages.po +++ b/packages/i18n/locales/es/messages.po @@ -3376,9 +3376,6 @@ msgstr "Sesión de chat no encontrada" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Superficies de chat: mensajes, razonamiento, sugerencias" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Volver a comprobar" @@ -10018,9 +10015,6 @@ msgstr "Nuevo navegador" msgid "new challengers" msgstr "nuevos rivales" -msgid "New chat" -msgstr "Chat nuevo" - msgid "New cloud workspace" msgstr "Nuevo espacio de trabajo en la nube" @@ -11185,9 +11179,6 @@ msgstr "Abrir cambios" msgid "Open Changes" msgstr "Abrir cambios" -msgid "Open Chat v3" -msgstr "Abrir Chat v3" - msgid "Open Command Palette" msgstr "Abrir la paleta de comandos" @@ -11545,9 +11536,6 @@ msgstr "Abrir carpetas" msgid "Opening pages" msgstr "Abrir páginas" -msgid "Opening the chat…" -msgstr "Abriendo el chat…" - msgid "Opening the conversation…" msgstr "Abriendo la conversación…" @@ -14331,9 +14319,6 @@ msgstr "Seleccionar texto en un terminal lo copia de inmediato al portapapeles, msgid "Send" msgstr "Enviar" -msgid "Send a message to start a {harness} session" -msgstr "Envía un mensaje para iniciar una sesión de {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Envía una invitación para unirse a {organizationName}. Caduca en 48 horas." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Inicio" -msgid "Start a {harness} session" -msgstr "Inicia una sesión de {harness}" - msgid "Start a conversation to see messages here" msgstr "Inicia una conversación para ver los mensajes aquí" @@ -16519,6 +16501,12 @@ msgstr "Esta automatización está en otra organización" msgid "This cannot be undone." msgstr "Esto no se puede deshacer." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Este chat se detuvo porque la conversación continuó en una terminal." + +msgid "This chat was stopped." +msgstr "Este chat se detuvo." + msgid "This chat's agent has stopped and can't be resumed." msgstr "El agente de este chat se ha detenido y no se puede reanudar." diff --git a/packages/i18n/locales/fr/messages.po b/packages/i18n/locales/fr/messages.po index 376d3ef3ba6..942401386b1 100644 --- a/packages/i18n/locales/fr/messages.po +++ b/packages/i18n/locales/fr/messages.po @@ -3376,9 +3376,6 @@ msgstr "Session de chat introuvable" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Surfaces de chat : messages, raisonnement, suggestions" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Vérifier à nouveau" @@ -10018,9 +10015,6 @@ msgstr "Nouveau navigateur" msgid "new challengers" msgstr "nouveaux adversaires" -msgid "New chat" -msgstr "Nouvelle discussion" - msgid "New cloud workspace" msgstr "Nouvel espace de travail cloud" @@ -11185,9 +11179,6 @@ msgstr "Ouvrir les modifications" msgid "Open Changes" msgstr "Ouvrir les modifications" -msgid "Open Chat v3" -msgstr "Ouvrir le chat v3" - msgid "Open Command Palette" msgstr "Ouvrir la palette de commandes" @@ -11545,9 +11536,6 @@ msgstr "Ouverture des dossiers" msgid "Opening pages" msgstr "Ouverture des pages" -msgid "Opening the chat…" -msgstr "Ouverture de la discussion…" - msgid "Opening the conversation…" msgstr "Ouverture de la conversation…" @@ -14331,9 +14319,6 @@ msgstr "Sélectionner du texte dans un terminal le copie immédiatement dans le msgid "Send" msgstr "Envoyer" -msgid "Send a message to start a {harness} session" -msgstr "Envoyez un message pour démarrer une session {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Envoyez une invitation à rejoindre {organizationName}. Elle expire dans 48 heures." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Début" -msgid "Start a {harness} session" -msgstr "Démarrer une session {harness}" - msgid "Start a conversation to see messages here" msgstr "Démarrez une conversation pour voir les messages ici" @@ -16519,6 +16501,12 @@ msgstr "Cette automatisation se trouve dans une autre organisation" msgid "This cannot be undone." msgstr "Cette action est irréversible." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Ce chat s'est arrêté car la conversation s'est poursuivie dans un terminal." + +msgid "This chat was stopped." +msgstr "Ce chat a été arrêté." + msgid "This chat's agent has stopped and can't be resumed." msgstr "L'agent de cette discussion s'est arrêté et ne peut pas être repris." diff --git a/packages/i18n/locales/id/messages.po b/packages/i18n/locales/id/messages.po index ca4a26eb7bc..d5c981ce47d 100644 --- a/packages/i18n/locales/id/messages.po +++ b/packages/i18n/locales/id/messages.po @@ -3376,9 +3376,6 @@ msgstr "Sesi chat tidak ditemukan" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Permukaan chat: pesan, penalaran, saran" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Periksa lagi" @@ -10018,9 +10015,6 @@ msgstr "Browser Baru" msgid "new challengers" msgstr "penantang baru" -msgid "New chat" -msgstr "Chat baru" - msgid "New cloud workspace" msgstr "Workspace cloud baru" @@ -11185,9 +11179,6 @@ msgstr "Buka perubahan" msgid "Open Changes" msgstr "Buka Perubahan" -msgid "Open Chat v3" -msgstr "Buka Chat v3" - msgid "Open Command Palette" msgstr "Buka Command Palette" @@ -11545,9 +11536,6 @@ msgstr "Membuka folder" msgid "Opening pages" msgstr "Membuka halaman" -msgid "Opening the chat…" -msgstr "Membuka obrolan…" - msgid "Opening the conversation…" msgstr "Membuka percakapan…" @@ -14331,9 +14319,6 @@ msgstr "Memilih teks di terminal langsung menyalinnya ke clipboard, tanpa spasi msgid "Send" msgstr "Kirim" -msgid "Send a message to start a {harness} session" -msgstr "Kirim pesan untuk memulai sesi {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Kirim undangan untuk bergabung ke {organizationName}. Kedaluwarsa dalam 48 jam." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Mulai" -msgid "Start a {harness} session" -msgstr "Mulai sesi {harness}" - msgid "Start a conversation to see messages here" msgstr "Mulai percakapan untuk melihat pesan di sini" @@ -16519,6 +16501,12 @@ msgstr "Otomatisasi ini berada di organisasi lain" msgid "This cannot be undone." msgstr "Ini tidak bisa dibatalkan." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Chat ini berhenti karena percakapan dilanjutkan di terminal." + +msgid "This chat was stopped." +msgstr "Chat ini telah dihentikan." + msgid "This chat's agent has stopped and can't be resumed." msgstr "Agen chat ini sudah berhenti dan tidak dapat dilanjutkan." diff --git a/packages/i18n/locales/it/messages.po b/packages/i18n/locales/it/messages.po index 95323cb0a99..54c94efeee1 100644 --- a/packages/i18n/locales/it/messages.po +++ b/packages/i18n/locales/it/messages.po @@ -3376,9 +3376,6 @@ msgstr "Sessione di chat non trovata" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Superfici della chat: messaggi, ragionamento, suggerimenti" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Controlla di nuovo" @@ -10018,9 +10015,6 @@ msgstr "Nuovo browser" msgid "new challengers" msgstr "nuovi sfidanti" -msgid "New chat" -msgstr "Nuova chat" - msgid "New cloud workspace" msgstr "Nuovo workspace cloud" @@ -11185,9 +11179,6 @@ msgstr "Apri le modifiche" msgid "Open Changes" msgstr "Apri le modifiche" -msgid "Open Chat v3" -msgstr "Apri Chat v3" - msgid "Open Command Palette" msgstr "Apri la palette dei comandi" @@ -11545,9 +11536,6 @@ msgstr "Apertura delle cartelle" msgid "Opening pages" msgstr "Apertura delle pagine" -msgid "Opening the chat…" -msgstr "Apertura della chat…" - msgid "Opening the conversation…" msgstr "Apertura della conversazione…" @@ -14331,9 +14319,6 @@ msgstr "Selezionare del testo in un terminale lo copia subito negli appunti, sen msgid "Send" msgstr "Invia" -msgid "Send a message to start a {harness} session" -msgstr "Invia un messaggio per avviare una sessione {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Invia un invito a entrare in {organizationName}. Scade tra 48 ore." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Inizio" -msgid "Start a {harness} session" -msgstr "Avvia una sessione {harness}" - msgid "Start a conversation to see messages here" msgstr "Avvia una conversazione per vedere i messaggi qui" @@ -16519,6 +16501,12 @@ msgstr "Questa automazione si trova in un'altra organizzazione" msgid "This cannot be undone." msgstr "L'operazione non può essere annullata." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Questa chat si è interrotta perché la conversazione è proseguita in un terminale." + +msgid "This chat was stopped." +msgstr "Questa chat è stata interrotta." + msgid "This chat's agent has stopped and can't be resumed." msgstr "L'agente di questa chat si è fermato e non può essere ripreso." diff --git a/packages/i18n/locales/ja/messages.po b/packages/i18n/locales/ja/messages.po index c6a4eec8c5b..b8a8c2c3e39 100644 --- a/packages/i18n/locales/ja/messages.po +++ b/packages/i18n/locales/ja/messages.po @@ -3376,9 +3376,6 @@ msgstr "チャットセッションが見つかりません" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "チャットの構成要素: メッセージ、推論、提案" -msgid "Chat v3" -msgstr "チャットv3" - msgid "Check again" msgstr "再確認" @@ -10018,9 +10015,6 @@ msgstr "新規ブラウザ" msgid "new challengers" msgstr "別の対戦相手" -msgid "New chat" -msgstr "新しいチャット" - msgid "New cloud workspace" msgstr "新規クラウドワークスペース" @@ -11185,9 +11179,6 @@ msgstr "変更を開く" msgid "Open Changes" msgstr "変更を開く" -msgid "Open Chat v3" -msgstr "チャットv3を開く" - msgid "Open Command Palette" msgstr "コマンドパレットを開く" @@ -11545,9 +11536,6 @@ msgstr "フォルダーを開く" msgid "Opening pages" msgstr "ページを開く" -msgid "Opening the chat…" -msgstr "チャットを開いています…" - msgid "Opening the conversation…" msgstr "会話を開いています…" @@ -14331,9 +14319,6 @@ msgstr "ターミナルでテキストを選択すると、行末の空白を取 msgid "Send" msgstr "送信" -msgid "Send a message to start a {harness} session" -msgstr "メッセージを送って{harness}セッションを開始" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "{organizationName}への招待を送ります。48時間で失効します。" @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "開始日" -msgid "Start a {harness} session" -msgstr "{harness}セッションを開始" - msgid "Start a conversation to see messages here" msgstr "会話を始めるとここにメッセージが表示されます" @@ -16519,6 +16501,12 @@ msgstr "このオートメーションは別の組織にあります" msgid "This cannot be undone." msgstr "この操作は元に戻せません。" +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "会話がターミナルで続行されたため、このチャットは停止しました。" + +msgid "This chat was stopped." +msgstr "このチャットは停止されました。" + msgid "This chat's agent has stopped and can't be resumed." msgstr "このチャットのエージェントは停止しており、再開できません。" diff --git a/packages/i18n/locales/ko/messages.po b/packages/i18n/locales/ko/messages.po index a2b13b8dffa..203826490f6 100644 --- a/packages/i18n/locales/ko/messages.po +++ b/packages/i18n/locales/ko/messages.po @@ -3376,9 +3376,6 @@ msgstr "채팅 세션을 찾을 수 없습니다" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "채팅 화면: 메시지, 추론, 제안" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "다시 확인" @@ -10018,9 +10015,6 @@ msgstr "새 브라우저" msgid "new challengers" msgstr "새 도전자" -msgid "New chat" -msgstr "새 채팅" - msgid "New cloud workspace" msgstr "새 클라우드 워크스페이스" @@ -11185,9 +11179,6 @@ msgstr "변경 열기" msgid "Open Changes" msgstr "변경 열기" -msgid "Open Chat v3" -msgstr "Chat v3 열기" - msgid "Open Command Palette" msgstr "명령 팔레트 열기" @@ -11545,9 +11536,6 @@ msgstr "폴더 열기" msgid "Opening pages" msgstr "페이지 열기" -msgid "Opening the chat…" -msgstr "채팅을 여는 중…" - msgid "Opening the conversation…" msgstr "대화를 여는 중…" @@ -14331,9 +14319,6 @@ msgstr "터미널에서 텍스트를 선택하면 끝의 공백이 제거된 상 msgid "Send" msgstr "보내기" -msgid "Send a message to start a {harness} session" -msgstr "메시지를 보내 {harness} 세션을 시작하세요" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "{organizationName}에 참여하도록 초대를 보냅니다. 48시간 후 만료됩니다." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "시작일" -msgid "Start a {harness} session" -msgstr "{harness} 세션 시작" - msgid "Start a conversation to see messages here" msgstr "대화를 시작하면 메시지가 여기에 표시됩니다" @@ -16519,6 +16501,12 @@ msgstr "이 자동화는 다른 조직에 있습니다" msgid "This cannot be undone." msgstr "되돌릴 수 없습니다." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "대화가 터미널에서 계속되어 이 채팅이 중지되었습니다." + +msgid "This chat was stopped." +msgstr "이 채팅이 중지되었습니다." + msgid "This chat's agent has stopped and can't be resumed." msgstr "이 채팅의 에이전트가 중지되어 이어갈 수 없습니다." diff --git a/packages/i18n/locales/nl/messages.po b/packages/i18n/locales/nl/messages.po index d7740488748..2336b87421d 100644 --- a/packages/i18n/locales/nl/messages.po +++ b/packages/i18n/locales/nl/messages.po @@ -3376,9 +3376,6 @@ msgstr "Chatsessie niet gevonden" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Chatoppervlakken: berichten, redeneren, suggesties" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Opnieuw controleren" @@ -10018,9 +10015,6 @@ msgstr "Nieuwe browser" msgid "new challengers" msgstr "nieuwe uitdagers" -msgid "New chat" -msgstr "Nieuwe chat" - msgid "New cloud workspace" msgstr "Nieuwe cloudwerkruimte" @@ -11185,9 +11179,6 @@ msgstr "Wijzigingen openen" msgid "Open Changes" msgstr "Wijzigingen openen" -msgid "Open Chat v3" -msgstr "Chat v3 openen" - msgid "Open Command Palette" msgstr "Opdrachtenpalet openen" @@ -11545,9 +11536,6 @@ msgstr "Mappen openen" msgid "Opening pages" msgstr "Pagina's openen" -msgid "Opening the chat…" -msgstr "Chat openen…" - msgid "Opening the conversation…" msgstr "Gesprek wordt geopend…" @@ -14331,9 +14319,6 @@ msgstr "Tekst selecteren in een terminal kopieert die meteen naar het klembord, msgid "Send" msgstr "Versturen" -msgid "Send a message to start a {harness} session" -msgstr "Stuur een bericht om een {harness}-sessie te starten" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Stuur een uitnodiging om lid te worden van {organizationName}. Verloopt na 48 uur." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Start" -msgid "Start a {harness} session" -msgstr "Start een {harness}-sessie" - msgid "Start a conversation to see messages here" msgstr "Begin een gesprek om hier berichten te zien" @@ -16519,6 +16501,12 @@ msgstr "Deze automatisering staat in een andere organisatie" msgid "This cannot be undone." msgstr "Dit kan niet ongedaan worden gemaakt." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Deze chat is gestopt omdat het gesprek in een terminal verderging." + +msgid "This chat was stopped." +msgstr "Deze chat is gestopt." + msgid "This chat's agent has stopped and can't be resumed." msgstr "De agent van deze chat is gestopt en kan niet worden hervat." diff --git a/packages/i18n/locales/pl/messages.po b/packages/i18n/locales/pl/messages.po index b30c7a6908c..c65a7639590 100644 --- a/packages/i18n/locales/pl/messages.po +++ b/packages/i18n/locales/pl/messages.po @@ -3376,9 +3376,6 @@ msgstr "Nie znaleziono sesji czatu" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Powierzchnie czatu: wiadomości, rozumowanie, sugestie" -msgid "Chat v3" -msgstr "Czat v3" - msgid "Check again" msgstr "Sprawdź ponownie" @@ -10018,9 +10015,6 @@ msgstr "Nowa przeglądarka" msgid "new challengers" msgstr "nowi przeciwnicy" -msgid "New chat" -msgstr "Nowy czat" - msgid "New cloud workspace" msgstr "Nowy obszar roboczy w chmurze" @@ -11185,9 +11179,6 @@ msgstr "Otwórz zmiany" msgid "Open Changes" msgstr "Otwórz zmiany" -msgid "Open Chat v3" -msgstr "Otwórz czat v3" - msgid "Open Command Palette" msgstr "Otwórz paletę poleceń" @@ -11545,9 +11536,6 @@ msgstr "Otwieranie folderów" msgid "Opening pages" msgstr "Otwieranie stron" -msgid "Opening the chat…" -msgstr "Otwieranie czatu…" - msgid "Opening the conversation…" msgstr "Otwieranie rozmowy…" @@ -14331,9 +14319,6 @@ msgstr "Zaznaczenie tekstu w terminalu od razu kopiuje go do schowka, bez końco msgid "Send" msgstr "Wyślij" -msgid "Send a message to start a {harness} session" -msgstr "Wyślij wiadomość, aby rozpocząć sesję {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Wyślij zaproszenie do {organizationName}. Wygasa po 48 godzinach." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Start" -msgid "Start a {harness} session" -msgstr "Rozpocznij sesję {harness}" - msgid "Start a conversation to see messages here" msgstr "Rozpocznij rozmowę, aby zobaczyć tu wiadomości" @@ -16519,6 +16501,12 @@ msgstr "Ta automatyzacja znajduje się w innej organizacji" msgid "This cannot be undone." msgstr "Tej operacji nie można cofnąć." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Ten czat został zatrzymany, ponieważ rozmowa była kontynuowana w terminalu." + +msgid "This chat was stopped." +msgstr "Ten czat został zatrzymany." + msgid "This chat's agent has stopped and can't be resumed." msgstr "Agent tego czatu został zatrzymany i nie można go wznowić." diff --git a/packages/i18n/locales/pt-BR/messages.po b/packages/i18n/locales/pt-BR/messages.po index 681ccd6d331..07278586fad 100644 --- a/packages/i18n/locales/pt-BR/messages.po +++ b/packages/i18n/locales/pt-BR/messages.po @@ -3376,9 +3376,6 @@ msgstr "Sessão de chat não encontrada" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Superfícies de chat: mensagens, raciocínio, sugestões" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Verificar novamente" @@ -10018,9 +10015,6 @@ msgstr "Novo navegador" msgid "new challengers" msgstr "novos desafiantes" -msgid "New chat" -msgstr "Novo chat" - msgid "New cloud workspace" msgstr "Nova área de trabalho na nuvem" @@ -11185,9 +11179,6 @@ msgstr "Abrir alterações" msgid "Open Changes" msgstr "Abrir alterações" -msgid "Open Chat v3" -msgstr "Abrir o Chat v3" - msgid "Open Command Palette" msgstr "Abrir a paleta de comandos" @@ -11545,9 +11536,6 @@ msgstr "Abertura de pastas" msgid "Opening pages" msgstr "Abertura de páginas" -msgid "Opening the chat…" -msgstr "Abrindo o chat…" - msgid "Opening the conversation…" msgstr "Abrindo a conversa…" @@ -14331,9 +14319,6 @@ msgstr "Selecionar texto em um terminal copia na hora para a área de transferê msgid "Send" msgstr "Enviar" -msgid "Send a message to start a {harness} session" -msgstr "Envie uma mensagem para iniciar uma sessão do {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Envie um convite para entrar em {organizationName}. Expira em 48 horas." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Início" -msgid "Start a {harness} session" -msgstr "Iniciar uma sessão do {harness}" - msgid "Start a conversation to see messages here" msgstr "Comece uma conversa para ver as mensagens aqui" @@ -16519,6 +16501,12 @@ msgstr "Esta automação está em outra organização" msgid "This cannot be undone." msgstr "Não dá para desfazer." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Este chat parou porque a conversa continuou em um terminal." + +msgid "This chat was stopped." +msgstr "Este chat foi interrompido." + msgid "This chat's agent has stopped and can't be resumed." msgstr "O agente deste chat parou e não pode ser retomado." diff --git a/packages/i18n/locales/ru/messages.po b/packages/i18n/locales/ru/messages.po index 4ba36490edf..393e21bcdcd 100644 --- a/packages/i18n/locales/ru/messages.po +++ b/packages/i18n/locales/ru/messages.po @@ -3376,9 +3376,6 @@ msgstr "Сессия чата не найдена" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Поверхности чата: сообщения, рассуждения, подсказки" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Проверить снова" @@ -10018,9 +10015,6 @@ msgstr "Новый браузер" msgid "new challengers" msgstr "другие соперники" -msgid "New chat" -msgstr "Новый чат" - msgid "New cloud workspace" msgstr "Новая облачная рабочая область" @@ -11185,9 +11179,6 @@ msgstr "Открыть изменения" msgid "Open Changes" msgstr "Открыть изменения" -msgid "Open Chat v3" -msgstr "Открыть Chat v3" - msgid "Open Command Palette" msgstr "Открыть палитру команд" @@ -11545,9 +11536,6 @@ msgstr "Открытие папок" msgid "Opening pages" msgstr "Открытие страниц" -msgid "Opening the chat…" -msgstr "Открытие чата…" - msgid "Opening the conversation…" msgstr "Открываем разговор…" @@ -14331,9 +14319,6 @@ msgstr "Выделенный в терминале текст сразу коп msgid "Send" msgstr "Отправить" -msgid "Send a message to start a {harness} session" -msgstr "Отправьте сообщение, чтобы начать сессию {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Отправьте приглашение в {organizationName}. Действует 48 часов." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Начало" -msgid "Start a {harness} session" -msgstr "Начать сессию {harness}" - msgid "Start a conversation to see messages here" msgstr "Начните диалог, чтобы сообщения появились здесь" @@ -16519,6 +16501,12 @@ msgstr "Эта автоматизация находится в другой о msgid "This cannot be undone." msgstr "Это нельзя отменить." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Этот чат остановлен, потому что разговор продолжился в терминале." + +msgid "This chat was stopped." +msgstr "Этот чат остановлен." + msgid "This chat's agent has stopped and can't be resumed." msgstr "Агент этого чата остановлен, и его нельзя возобновить." diff --git a/packages/i18n/locales/tr/messages.po b/packages/i18n/locales/tr/messages.po index 116c634ae17..0426713f9d4 100644 --- a/packages/i18n/locales/tr/messages.po +++ b/packages/i18n/locales/tr/messages.po @@ -3376,9 +3376,6 @@ msgstr "Sohbet oturumu bulunamadı" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Sohbet yüzeyleri: mesajlar, akıl yürütme, öneriler" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Yeniden denetle" @@ -10018,9 +10015,6 @@ msgstr "Yeni tarayıcı" msgid "new challengers" msgstr "yeni rakipler" -msgid "New chat" -msgstr "Yeni sohbet" - msgid "New cloud workspace" msgstr "Yeni bulut çalışma alanı" @@ -11185,9 +11179,6 @@ msgstr "Değişiklikleri aç" msgid "Open Changes" msgstr "Değişiklikleri aç" -msgid "Open Chat v3" -msgstr "Chat v3'ü aç" - msgid "Open Command Palette" msgstr "Komut paletini aç" @@ -11545,9 +11536,6 @@ msgstr "Klasörleri açma" msgid "Opening pages" msgstr "Sayfaları açma" -msgid "Opening the chat…" -msgstr "Sohbet açılıyor…" - msgid "Opening the conversation…" msgstr "Sohbet açılıyor…" @@ -14331,9 +14319,6 @@ msgstr "Terminalde metin seçmek, sondaki boşluklar kırpılmış olarak panoya msgid "Send" msgstr "Gönder" -msgid "Send a message to start a {harness} session" -msgstr "{harness} oturumu başlatmak için bir mesaj gönderin" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "{organizationName} kuruluşuna katılmak için davet gönderin. 48 saat içinde sona erer." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Başlangıç" -msgid "Start a {harness} session" -msgstr "{harness} oturumu başlatın" - msgid "Start a conversation to see messages here" msgstr "Mesajları burada görmek için bir konuşma başlatın" @@ -16519,6 +16501,12 @@ msgstr "Bu otomasyon başka bir kuruluşta" msgid "This cannot be undone." msgstr "Bu geri alınamaz." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Konuşma bir terminalde devam ettiği için bu sohbet durdu." + +msgid "This chat was stopped." +msgstr "Bu sohbet durduruldu." + msgid "This chat's agent has stopped and can't be resumed." msgstr "Bu sohbetin aracısı durdu ve devam ettirilemiyor." diff --git a/packages/i18n/locales/vi/messages.po b/packages/i18n/locales/vi/messages.po index 0f12869eb15..bf516299e91 100644 --- a/packages/i18n/locales/vi/messages.po +++ b/packages/i18n/locales/vi/messages.po @@ -3376,9 +3376,6 @@ msgstr "Không tìm thấy phiên chat" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "Các bề mặt chat: tin nhắn, suy luận, gợi ý" -msgid "Chat v3" -msgstr "Chat v3" - msgid "Check again" msgstr "Kiểm tra lại" @@ -10018,9 +10015,6 @@ msgstr "Trình duyệt mới" msgid "new challengers" msgstr "đối thủ mới" -msgid "New chat" -msgstr "Chat mới" - msgid "New cloud workspace" msgstr "Workspace cloud mới" @@ -11185,9 +11179,6 @@ msgstr "Mở thay đổi" msgid "Open Changes" msgstr "Mở thay đổi" -msgid "Open Chat v3" -msgstr "Mở Chat v3" - msgid "Open Command Palette" msgstr "Mở bảng lệnh" @@ -11545,9 +11536,6 @@ msgstr "Mở thư mục" msgid "Opening pages" msgstr "Mở trang" -msgid "Opening the chat…" -msgstr "Đang mở trò chuyện…" - msgid "Opening the conversation…" msgstr "Đang mở cuộc trò chuyện…" @@ -14331,9 +14319,6 @@ msgstr "Chọn văn bản trong terminal sẽ sao chép ngay vào clipboard, đ msgid "Send" msgstr "Gửi" -msgid "Send a message to start a {harness} session" -msgstr "Gửi một tin nhắn để bắt đầu phiên {harness}" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "Gửi lời mời tham gia {organizationName}. Hết hạn sau 48 giờ." @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "Bắt đầu" -msgid "Start a {harness} session" -msgstr "Bắt đầu một phiên {harness}" - msgid "Start a conversation to see messages here" msgstr "Bắt đầu một cuộc trò chuyện để thấy tin nhắn ở đây" @@ -16519,6 +16501,12 @@ msgstr "Tự động hóa này nằm trong một tổ chức khác" msgid "This cannot be undone." msgstr "Không thể hoàn tác." +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "Cuộc trò chuyện này đã dừng vì nó được tiếp tục trong một terminal." + +msgid "This chat was stopped." +msgstr "Cuộc trò chuyện này đã bị dừng." + msgid "This chat's agent has stopped and can't be resumed." msgstr "Tác nhân của cuộc trò chuyện này đã dừng và không thể tiếp tục." diff --git a/packages/i18n/locales/zh-CN/messages.po b/packages/i18n/locales/zh-CN/messages.po index b8f7e64e464..de6f7c248d5 100644 --- a/packages/i18n/locales/zh-CN/messages.po +++ b/packages/i18n/locales/zh-CN/messages.po @@ -3376,9 +3376,6 @@ msgstr "未找到聊天会话" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "聊天界面:消息、推理、建议" -msgid "Chat v3" -msgstr "聊天v3" - msgid "Check again" msgstr "重新检查" @@ -10018,9 +10015,6 @@ msgstr "新建浏览器" msgid "new challengers" msgstr "换对手" -msgid "New chat" -msgstr "新建聊天" - msgid "New cloud workspace" msgstr "新建云端工作区" @@ -11185,9 +11179,6 @@ msgstr "打开更改" msgid "Open Changes" msgstr "打开更改" -msgid "Open Chat v3" -msgstr "打开Chat v3" - msgid "Open Command Palette" msgstr "打开命令面板" @@ -11545,9 +11536,6 @@ msgstr "打开文件夹" msgid "Opening pages" msgstr "打开页面" -msgid "Opening the chat…" -msgstr "正在打开聊天…" - msgid "Opening the conversation…" msgstr "正在打开对话…" @@ -14331,9 +14319,6 @@ msgstr "在终端中选中文本后立即复制到剪贴板,并去除行尾空 msgid "Send" msgstr "发送" -msgid "Send a message to start a {harness} session" -msgstr "发送消息以开始{harness}会话" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "发送加入{organizationName}的邀请。48小时后过期。" @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "开始日期" -msgid "Start a {harness} session" -msgstr "开始一个{harness}会话" - msgid "Start a conversation to see messages here" msgstr "开始一段对话,消息会显示在这里" @@ -16519,6 +16501,12 @@ msgstr "此自动化位于其他组织" msgid "This cannot be undone." msgstr "此操作无法撤销。" +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "由于对话已在终端中继续,此聊天已停止。" + +msgid "This chat was stopped." +msgstr "此聊天已停止。" + msgid "This chat's agent has stopped and can't be resumed." msgstr "此聊天的智能体已停止,无法继续。" diff --git a/packages/i18n/locales/zh-TW/messages.po b/packages/i18n/locales/zh-TW/messages.po index 82b46313f11..9854192d9d7 100644 --- a/packages/i18n/locales/zh-TW/messages.po +++ b/packages/i18n/locales/zh-TW/messages.po @@ -3376,9 +3376,6 @@ msgstr "未找到聊天會話" msgid "Chat surfaces: messages, reasoning, suggestions" msgstr "聊天介面:訊息、推理、建議" -msgid "Chat v3" -msgstr "聊天v3" - msgid "Check again" msgstr "重新檢查" @@ -10018,9 +10015,6 @@ msgstr "新建瀏覽器" msgid "new challengers" msgstr "換對手" -msgid "New chat" -msgstr "新建聊天" - msgid "New cloud workspace" msgstr "新建雲端工作區" @@ -11185,9 +11179,6 @@ msgstr "開啟更改" msgid "Open Changes" msgstr "開啟更改" -msgid "Open Chat v3" -msgstr "開啟Chat v3" - msgid "Open Command Palette" msgstr "開啟命令面板" @@ -11545,9 +11536,6 @@ msgstr "開啟資料夾" msgid "Opening pages" msgstr "開啟頁面" -msgid "Opening the chat…" -msgstr "正在開啟聊天…" - msgid "Opening the conversation…" msgstr "正在開啟對話…" @@ -14331,9 +14319,6 @@ msgstr "在終端中選取文字後立即複製到剪貼簿,並移除結尾空 msgid "Send" msgstr "傳送" -msgid "Send a message to start a {harness} session" -msgstr "傳送訊息以開始{harness}會話" - msgid "Send an invitation to join {organizationName}. Expires in 48 hours." msgstr "傳送加入{organizationName}的邀請。48小時後過期。" @@ -15232,9 +15217,6 @@ msgctxt "project date" msgid "Start" msgstr "開始日期" -msgid "Start a {harness} session" -msgstr "開始一個{harness}會話" - msgid "Start a conversation to see messages here" msgstr "開始一段對話,訊息會顯示在這裡" @@ -16519,6 +16501,12 @@ msgstr "此自動化位於其他組織" msgid "This cannot be undone." msgstr "此操作無法復原。" +msgid "This chat stopped because the conversation continued in a terminal." +msgstr "由於對話已在終端機中繼續,此聊天已停止。" + +msgid "This chat was stopped." +msgstr "此聊天已停止。" + msgid "This chat's agent has stopped and can't be resumed." msgstr "此聊天的代理已停止,無法繼續。" diff --git a/packages/trpc/src/router/automation/dispatch.ts b/packages/trpc/src/router/automation/dispatch.ts index 98885a884d5..021030ac143 100644 --- a/packages/trpc/src/router/automation/dispatch.ts +++ b/packages/trpc/src/router/automation/dispatch.ts @@ -11,6 +11,7 @@ import { v2UsersHosts, } from "@superset/db/schema"; import { CLOUD_AGENT_PROMPT_MAX_LENGTH } from "@superset/shared/cloud-agent-launch"; +import { FEATURE_FLAGS } from "@superset/shared/constants"; import { parseGitHubRemote } from "@superset/shared/github-remote"; import { buildHostRoutingKey, @@ -22,6 +23,7 @@ import { slugifyForBranch, } from "@superset/shared/workspace-launch"; import { and, eq, sql } from "drizzle-orm"; +import { posthog } from "../../lib/analytics"; import { nudge } from "../../lib/realtime"; import { fetchRelayPresence } from "../../lib/relay-presence"; import { runInCloud } from "./cloudDispatch"; @@ -252,6 +254,8 @@ export async function dispatchAutomation( }) : undefined; + const chatSurface = await acpChatEnabled(automation.ownerUserId); + const runAgent = (targetWorkspaceId: string) => runAgentOnHost({ relayUrl, @@ -260,6 +264,7 @@ export async function dispatchAutomation( workspaceId: targetWorkspaceId, agent: automation.agent, prompt, + ...(chatSurface ? { surface: "chat" as const } : {}), // Only the pinned workspace holds that session; the stale-pin // recovery below branches a fresh one, which has none. ...(continueTerminalId && targetWorkspaceId === automation.v2WorkspaceId @@ -696,6 +701,7 @@ async function runAgentOnHost(args: { prompt: string; /** See {@link previousRunTerminal}. */ continueTerminalId?: string; + surface?: "chat"; }): Promise { return relayMutation< { @@ -703,6 +709,7 @@ async function runAgentOnHost(args: { agent: string; prompt: string; continueTerminalId?: string; + surface?: "chat"; }, AgentRunResult >( @@ -717,6 +724,16 @@ async function runAgentOnHost(args: { ...(args.continueTerminalId ? { continueTerminalId: args.continueTerminalId } : {}), + ...(args.surface ? { surface: args.surface } : {}), }, ); } + +async function acpChatEnabled(userId: string): Promise { + const enabled = await posthog + .isFeatureEnabled(FEATURE_FLAGS.ACP_CHAT, userId, { + sendFeatureFlagEvents: false, + }) + .catch(() => undefined); + return enabled === true; +} From 2a18cb25b322efb49dcc0c4ad57bc673e078c547 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 14:38:10 -0700 Subject: [PATCH 02/10] fix(desktop): drop the Superset agent choice that opened the removed ChatV3 prototype --- .../useV2AgentChoices/useV2AgentChoices.ts | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/apps/desktop/src/renderer/hooks/useV2AgentChoices/useV2AgentChoices.ts b/apps/desktop/src/renderer/hooks/useV2AgentChoices/useV2AgentChoices.ts index b842a9b3cfb..caed5fa6a76 100644 --- a/apps/desktop/src/renderer/hooks/useV2AgentChoices/useV2AgentChoices.ts +++ b/apps/desktop/src/renderer/hooks/useV2AgentChoices/useV2AgentChoices.ts @@ -1,6 +1,4 @@ import { resolveAgentLaunchPresetId } from "@superset/shared/agent-models"; -import { FEATURE_FLAGS } from "@superset/shared/constants"; -import { useFeatureFlagEnabled } from "posthog-js/react"; import { useMemo } from "react"; import type { AgentSelectAgent } from "renderer/components/AgentSelect"; import { useV2AgentConfigs } from "renderer/hooks/useV2AgentConfigs"; @@ -10,24 +8,13 @@ interface UseV2AgentChoicesResult { isFetched: boolean; } -const SUPERSET_AGENT: AgentSelectAgent = { - id: "superset", - label: "Superset", - iconId: "superset", -}; - -// Superset chat isn't in the host's `host_agent_configs` table — it's -// chat-v3's entry point, so it rides the same flag as the rest of chat-v3. -// Append after the host's terminal rows so the user's preferred terminal -// agents stay on top. export function useV2AgentChoices( hostUrl: string | null, ): UseV2AgentChoicesResult { const query = useV2AgentConfigs(hostUrl); - const isChatV3Enabled = useFeatureFlagEnabled(FEATURE_FLAGS.CHAT_V3) ?? false; - const agents = useMemo(() => { - const terminalAgents: AgentSelectAgent[] = (query.data ?? []).map( - (config) => ({ + const agents = useMemo( + () => + (query.data ?? []).map((config) => ({ id: config.id, label: config.label, // Prefer the user's icon override (built-in key or uploaded data @@ -38,12 +25,9 @@ export function useV2AgentChoices( config.presetId, config.command, ), - }), - ); - return isChatV3Enabled - ? [...terminalAgents, SUPERSET_AGENT] - : terminalAgents; - }, [query.data, isChatV3Enabled]); + })), + [query.data], + ); return { agents, isFetched: query.isFetched }; } From 4d0619ff7dddc380c1063245219811093f1ec274 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 14:46:09 -0700 Subject: [PATCH 03/10] fix(chat): stop chat agents a workspace delete or a remount leaves behind Deleting a workspace stopped its terminals but not its chat sessions, so their agent processes ran until the host restarted. A chat pane that unmounted while its session was starting dropped the session and started a second one when it came back. A remount now joins the create in flight, and a session that starts after its pane is gone is closed. --- .../components/AcpChatPane/AcpChatPane.tsx | 42 ++++++++++++----- .../utils/sharedChatCreate/index.ts | 1 + .../sharedChatCreate/sharedChatCreate.test.ts | 46 +++++++++++++++++++ .../sharedChatCreate/sharedChatCreate.ts | 28 +++++++++++ .../src/commands/commands/commands.ts | 6 +++ .../src/sessions/liveSession/liveSession.ts | 4 ++ .../src/sessions/registry/registry.test.ts | 17 +++++++ .../src/sessions/registry/registry.ts | 15 +++++- packages/host-service/src/app.ts | 1 + packages/host-service/src/chat-v3/mount.ts | 4 ++ .../workspace-cleanup/workspace-cleanup.ts | 7 +++ packages/host-service/src/types.ts | 1 + 12 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.test.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx index bef895d7b19..664256dea2b 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx @@ -19,6 +19,7 @@ import { useForkChat } from "../../hooks/useForkChat"; import { readSavedChatMode } from "../../utils/savedChatMode"; import { AcpChatPending } from "./components/AcpChatPending"; import { AcpRecovery } from "./components/AcpRecovery"; +import { sharedChatCreate, watchChatCreate } from "./utils/sharedChatCreate"; /** * A chat bridged to an agent session, resumed by its session id. `agent` comes @@ -98,6 +99,8 @@ export function AcpChatPane({ sessionId !== null, ); + const createKey = `${terminalId}:${agent?.id ?? ""}`; + useEffect(() => watchChatCreate(createKey), [createKey]); const attaching = useRef(false); // A switch to another agent remounts this pane; its pending calls must not // write the old agent back over the new one. @@ -116,22 +119,34 @@ export function AcpChatPane({ const startModeId = modeId ?? (resume || !agent ? undefined : readSavedChatMode(agent.id)); - const created = await wiring.transport.createSession({ - commandId: crypto.randomUUID(), - workspaceId, - harness: resumeHarness, - terminalId, - ...(modelId ? { modelId } : {}), - ...(startModeId ? { modeId: startModeId } : {}), - ...(resume ? { resume: { harnessSessionId: resume } } : {}), - }); - if (mounted.current) onSessionCreated(created.sessionId); + const createdId = await sharedChatCreate( + createKey, + () => + wiring.transport + .createSession({ + commandId: crypto.randomUUID(), + workspaceId, + harness: resumeHarness, + terminalId, + ...(modelId ? { modelId } : {}), + ...(startModeId ? { modeId: startModeId } : {}), + ...(resume ? { resume: { harnessSessionId: resume } } : {}), + }) + .then((created) => created.sessionId), + (orphan) => { + void wiring.transport + .closeSession({ sessionId: orphan }) + .catch(() => undefined); + }, + ); + if (mounted.current) onSessionCreated(createdId); } catch (error) { attaching.current = false; setFailure(error instanceof Error ? error.message : String(error)); } }, [ + createKey, wiring.transport, workspaceId, terminalId, @@ -164,7 +179,12 @@ export function AcpChatPane({ }) .then((forked) => { if (forked) { - if (!mounted.current) return; + if (!mounted.current) { + void wiring.transport + .closeSession({ sessionId: forked.sessionId }) + .catch(() => undefined); + return; + } onSessionCreated(forked.sessionId); void wiring.transport .closeSession({ sessionId }) diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts new file mode 100644 index 00000000000..b6949faaf83 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts @@ -0,0 +1 @@ +export { sharedChatCreate, watchChatCreate } from "./sharedChatCreate"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.test.ts new file mode 100644 index 00000000000..cadf8ed75e8 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.test.ts @@ -0,0 +1,46 @@ +import { describe, expect, test } from "bun:test"; +import { sharedChatCreate, watchChatCreate } from "./sharedChatCreate"; + +function deferred() { + let resolve: (sessionId: string) => void = () => {}; + const promise = new Promise((done) => { + resolve = done; + }); + return { promise, resolve }; +} + +describe("sharedChatCreate", () => { + test("a remount joins the create already running", async () => { + const pending = deferred(); + let creates = 0; + const create = () => { + creates += 1; + return pending.promise; + }; + const unwatch = watchChatCreate("pane-a"); + const first = sharedChatCreate("pane-a", create, () => {}); + const second = sharedChatCreate("pane-a", create, () => {}); + pending.resolve("session-1"); + + expect(await first).toBe("session-1"); + expect(await second).toBe("session-1"); + expect(creates).toBe(1); + unwatch(); + }); + + test("closes a session whose pane went away before it started", async () => { + const pending = deferred(); + const closed: string[] = []; + const unwatch = watchChatCreate("pane-b"); + const created = sharedChatCreate( + "pane-b", + () => pending.promise, + (sessionId) => closed.push(sessionId), + ); + unwatch(); + pending.resolve("session-2"); + + await created; + expect(closed).toEqual(["session-2"]); + }); +}); diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts new file mode 100644 index 00000000000..ab775d6fd72 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts @@ -0,0 +1,28 @@ +const inflight = new Map>(); +const watchers = new Map(); + +export function watchChatCreate(key: string): () => void { + watchers.set(key, (watchers.get(key) ?? 0) + 1); + return () => { + const remaining = (watchers.get(key) ?? 1) - 1; + if (remaining > 0) watchers.set(key, remaining); + else watchers.delete(key); + }; +} + +export function sharedChatCreate( + key: string, + create: () => Promise, + close: (sessionId: string) => void, +): Promise { + const running = inflight.get(key); + if (running) return running; + const started = create() + .then((sessionId) => { + if (!watchers.has(key)) close(sessionId); + return sessionId; + }) + .finally(() => inflight.delete(key)); + inflight.set(key, started); + return started; +} diff --git a/packages/chat-runtime/src/commands/commands/commands.ts b/packages/chat-runtime/src/commands/commands/commands.ts index b3529d6d02f..242805a7547 100644 --- a/packages/chat-runtime/src/commands/commands/commands.ts +++ b/packages/chat-runtime/src/commands/commands/commands.ts @@ -95,6 +95,7 @@ export type ChatCommands = { setMode(input: SetModeInput): void; setConfigOption(input: SetConfigOptionInput): void; closeSession(input: CloseSessionInput): Promise; + closeScope(scopeId: string): Promise; forkSession( input: ForkSessionCommandInput, ): Promise; @@ -277,6 +278,11 @@ export function createCommands(options: CommandsOptions): ChatCommands { } }, + async closeScope(scopeId) { + const closed = await options.live.disposeScope(scopeId); + for (const sessionId of closed) options.journal.announce(sessionId); + }, + getSession(input) { const parsed: GetSessionInput = getSessionInputSchema.parse(input); const session = options.sessions.get(parsed.sessionId); diff --git a/packages/chat-runtime/src/sessions/liveSession/liveSession.ts b/packages/chat-runtime/src/sessions/liveSession/liveSession.ts index e7b1261a475..e2c6138104a 100644 --- a/packages/chat-runtime/src/sessions/liveSession/liveSession.ts +++ b/packages/chat-runtime/src/sessions/liveSession/liveSession.ts @@ -76,6 +76,10 @@ export class LiveSession { return this.options.sessionId; } + get scopeId(): string { + return this.options.scopeId; + } + get terminalId(): string | undefined { return this.options.terminalId; } diff --git a/packages/chat-runtime/src/sessions/registry/registry.test.ts b/packages/chat-runtime/src/sessions/registry/registry.test.ts index e7a34a75e97..7603954be57 100644 --- a/packages/chat-runtime/src/sessions/registry/registry.test.ts +++ b/packages/chat-runtime/src/sessions/registry/registry.test.ts @@ -80,6 +80,23 @@ describe("LiveSessionRegistry", () => { await runtime.dispose(); }); + test("closing a scope stops only that scope's sessions", async () => { + const runtime = createTestRuntime({ harnesses: registryOf(idleAdapter) }); + const kept = createSession(runtime); + const removed = runtime.commands.createSession({ + commandId: randomUUID(), + scopeId: "workspace-2", + harness: HARNESS, + cwd: "/tmp/workspace-2", + }).sessionId; + + await runtime.commands.closeScope("workspace-2"); + + expect(runtime.live.get(removed)).toBeNull(); + expect(runtime.live.get(kept)).not.toBeNull(); + await runtime.dispose(); + }); + test("settles every disposal and still closes the database when one fails", async () => { let secondDisposed = false; let created = 0; diff --git a/packages/chat-runtime/src/sessions/registry/registry.ts b/packages/chat-runtime/src/sessions/registry/registry.ts index ba0c5964f73..4ba0cd29f4a 100644 --- a/packages/chat-runtime/src/sessions/registry/registry.ts +++ b/packages/chat-runtime/src/sessions/registry/registry.ts @@ -109,8 +109,18 @@ export class LiveSessionRegistry { } async disposeAll(): Promise { - const sessions = [...this.live.values()]; - this.live.clear(); + await this.disposeWhere(() => true); + } + + async disposeScope(scopeId: string): Promise { + return this.disposeWhere((session) => session.scopeId === scopeId); + } + + private async disposeWhere( + matches: (session: LiveSession) => boolean, + ): Promise { + const sessions = [...this.live.values()].filter(matches); + for (const session of sessions) this.live.delete(session.sessionId); for (const session of sessions) { this.observe(() => this.options.observer?.stopped(session.sessionId)); } @@ -119,5 +129,6 @@ export class LiveSessionRegistry { ); const failure = results.find((result) => result.status === "rejected"); if (failure?.status === "rejected") throw failure.reason; + return sessions.map((session) => session.sessionId); } } diff --git a/packages/host-service/src/app.ts b/packages/host-service/src/app.ts index d6e3a6365b9..97b43d1123b 100644 --- a/packages/host-service/src/app.ts +++ b/packages/host-service/src/app.ts @@ -310,6 +310,7 @@ export function createApp(options: CreateAppOptions): CreateAppResult { pullRequests: pullRequestRuntime, pageWatch, chat: () => chatV3.runtime(), + closeChats: (scopeId: string) => chatV3.closeScope(scopeId), }; // Chat v3 runtime (plans/chat-v3-pane-mount.md). Registered unconditionally: diff --git a/packages/host-service/src/chat-v3/mount.ts b/packages/host-service/src/chat-v3/mount.ts index 16f0e90fe5d..f8f20d147b5 100644 --- a/packages/host-service/src/chat-v3/mount.ts +++ b/packages/host-service/src/chat-v3/mount.ts @@ -103,6 +103,7 @@ function harnessRegistry( export type ChatV3Mount = { runtime(): ChatRuntime; + closeScope(scopeId: string): Promise; dispose(): Promise; }; @@ -132,6 +133,9 @@ export function createChatV3Mount(options: { return { runtime, + closeScope: async (scopeId) => { + await built?.commands.closeScope(scopeId); + }, dispose: async () => { const current = built; built = null; diff --git a/packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts b/packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts index 52c3071c5ee..ef142c5371d 100644 --- a/packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts +++ b/packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts @@ -473,6 +473,13 @@ async function runDestroyPhases( warnings.push(`Failed to dispose terminal sessions: ${message}`); } + try { + await ctx.runtime.closeChats?.(input.workspaceId); + } catch (err) { + const message = err instanceof Error ? err.message : String(err); + warnings.push(`Failed to stop chat sessions: ${message}`); + } + // 3b. Worktree. Double-force unlocks the rare locked-worktree case and // clears stale metadata when the directory was manually removed. // Runs in the worker pool: the removal is a recursive delete of the diff --git a/packages/host-service/src/types.ts b/packages/host-service/src/types.ts index fa8bf1c64f4..1ab6869547f 100644 --- a/packages/host-service/src/types.ts +++ b/packages/host-service/src/types.ts @@ -18,6 +18,7 @@ export interface HostServiceRuntime { pullRequests: PullRequestRuntimeManager; pageWatch: PageWatchManager; chat?: () => ChatRuntime; + closeChats?: (scopeId: string) => Promise; } export interface HostServiceContext { From 001127f000b44a4686b56a226eb974882e68a16f Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 14:46:10 -0700 Subject: [PATCH 04/10] feat(chat): the host starts a new workspace's chat With the chat flag on, a new workspace queued its prompt in desktop state and only started the chat once the workspace page was open. The create now asks the host for surface: chat, which starts the session in the worktree and sends the first message. Chat launches report their chatSessionId so the layout leaves them to the chat pane, and the setup-terminal chain applies only to terminal agents. The host's chat launch also takes a mode and attachments instead of falling back to a terminal. --- .../useSubmitWorkspace/useSubmitWorkspace.ts | 52 ++++++------------- .../appendLaunchesToPaneLayout.test.ts | 18 +++++++ .../appendLaunchesToPaneLayout.ts | 13 ++++- .../workspace-creates/useWorkspaceCreates.ts | 8 ++- packages/host-service/src/events/types.ts | 8 ++- .../src/trpc/router/agents/agents.test.ts | 5 +- .../src/trpc/router/agents/agents.ts | 48 ++++++++++++++--- .../shared/dispatch-agents.ts | 2 + .../src/trpc/router/workspaces/workspaces.ts | 7 ++- 9 files changed, 110 insertions(+), 51 deletions(-) diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts index cebb35e9d89..2c5fd849402 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts @@ -8,12 +8,10 @@ import { useAwaitAcpChatEnabled } from "renderer/hooks/useAcpChatEnabled"; import { useActiveOrganizationId } from "renderer/hooks/useActiveOrganizationId"; import { acpHarnessForPreset } from "renderer/lib/acpHarness"; import { cloudTrpc, cloudTrpcClient } from "renderer/lib/cloud-trpc"; -import { useCollections } from "renderer/routes/_authenticated/providers/CollectionsProvider"; import { useLocalHostService } from "renderer/routes/_authenticated/providers/LocalHostServiceProvider"; import type { NewWorkspacePromptContextApi } from "renderer/stores/new-workspace-prompt-context"; import { usePromptHistoryStore } from "renderer/stores/prompt-history"; import { useWorkspaceCreates } from "renderer/stores/workspace-creates"; -import { queuePendingChatHandoff } from "renderer/stores/workspace-creates/queuePendingChatHandoff"; import { useDashboardNewWorkspaceDraft } from "../../../../../DashboardNewWorkspaceDraftContext"; import type { WorkspaceCreateAgent } from "../../types"; import type { UseUploadAttachmentsApi } from "../useUploadAttachments"; @@ -41,7 +39,6 @@ export function useSubmitWorkspace( const { closeAndResetDraft, draft } = useDashboardNewWorkspaceDraft(); const { submit } = useWorkspaceCreates(); const { machineId } = useLocalHostService(); - const collections = useCollections(); const activeOrganizationId = useActiveOrganizationId(); const awaitAcpChatEnabled = useAwaitAcpChatEnabled(); const createCloudWorkspace = cloudTrpc.cloudWorkspace.create.useMutation(); @@ -98,11 +95,8 @@ export function useSubmitWorkspace( return; } - const { - readyIds: attachmentIds, - ready: readyAttachments, - errors, - } = await uploadAttachments.awaitUploads(); + const { readyIds: attachmentIds, errors } = + await uploadAttachments.awaitUploads(); if (errors.length > 0) { const first = errors[0]; toast.error( @@ -252,20 +246,19 @@ export function useSubmitWorkspace( wantAgent && Boolean(acpHarnessForPreset(selectedPresetId)) && (await awaitAcpChatEnabled()); - const agents = - wantAgent && !openAsChat - ? [ - { - agent: selectedAgent, - prompt: finalPrompt ?? "", - attachmentIds: - attachmentIds.length > 0 ? attachmentIds : undefined, - model: selectedModel ?? undefined, - effort: selectedEffort ?? undefined, - mode: selectedMode ?? undefined, - }, - ] - : undefined; + const agents = wantAgent + ? [ + { + agent: selectedAgent, + prompt: finalPrompt ?? "", + attachmentIds: attachmentIds.length > 0 ? attachmentIds : undefined, + model: selectedModel ?? undefined, + effort: openAsChat ? undefined : (selectedEffort ?? undefined), + mode: selectedMode ?? undefined, + ...(openAsChat ? { surface: "chat" as const } : {}), + }, + ] + : undefined; // PR path supplies a name (PR title) so the in-flight UI has // something to show immediately. Branch path leaves both `name` @@ -327,20 +320,6 @@ export function useSubmitWorkspace( usePromptHistoryStore.getState().recordPrompt(trimmedPrompt); } - if (openAsChat) { - queuePendingChatHandoff( - collections, - { id: workspaceId, projectId }, - { - agentId: selectedAgent, - prompt: finalPrompt ?? "", - attachments: readyAttachments, - modelId: selectedModel ?? undefined, - modeId: selectedMode ?? undefined, - }, - ); - } - closeAndResetDraft(); const { completed } = submit({ hostId, snapshot }); void navigate({ @@ -381,7 +360,6 @@ export function useSubmitWorkspace( activeOrganizationId, awaitAcpChatEnabled, selectedPresetId, - collections, closeAndResetDraft, createCloudWorkspace, draft, diff --git a/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.test.ts b/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.test.ts index 0f0df08954a..2067f7bafa0 100644 --- a/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.test.ts +++ b/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.test.ts @@ -40,4 +40,22 @@ describe("appendLaunchesToPaneLayout", () => { expect(state.tabs).toHaveLength(0); }); + + it("leaves a chat launch to the chat pane instead of a terminal tab", () => { + const state = appendLaunchesToPaneLayout({ + existing: undefined, + terminals: [], + agents: [ + { + ok: true, + kind: "terminal", + sessionId: "terminal-1", + label: "Claude", + chatSessionId: "chat-1", + }, + ], + }); + + expect(state.tabs).toHaveLength(0); + }); }); diff --git a/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.ts b/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.ts index 2801d098c1d..53a2ab59567 100644 --- a/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.ts +++ b/apps/desktop/src/renderer/stores/workspace-creates/appendLaunchesToPaneLayout.ts @@ -11,7 +11,13 @@ const EMPTY_STATE: WorkspaceState = { }; type AgentLaunchResult = - | { ok: true; kind: "terminal"; sessionId: string; label: string } + | { + ok: true; + kind: "terminal"; + sessionId: string; + label: string; + chatSessionId?: string; + } | { ok: false; error: string }; interface AppendArgs { @@ -35,7 +41,10 @@ export function appendLaunchesToPaneLayout({ label: entry.label, })); const agentLaunches: PaneLaunch[] = agents - .filter((entry): entry is Extract => entry.ok) + .filter( + (entry): entry is Extract => + entry.ok && !entry.chatSessionId, + ) .map((entry) => ({ sessionId: entry.sessionId, label: entry.label, diff --git a/apps/desktop/src/renderer/stores/workspace-creates/useWorkspaceCreates.ts b/apps/desktop/src/renderer/stores/workspace-creates/useWorkspaceCreates.ts index da65d141d9d..fc786fc9ab1 100644 --- a/apps/desktop/src/renderer/stores/workspace-creates/useWorkspaceCreates.ts +++ b/apps/desktop/src/renderer/stores/workspace-creates/useWorkspaceCreates.ts @@ -63,7 +63,13 @@ interface CreateOutcome { workspace: { id: string; projectId: string | null }; terminals: Array<{ terminalId: string; label?: string }>; agents: Array< - | { ok: true; kind: "terminal"; sessionId: string; label: string } + | { + ok: true; + kind: "terminal"; + sessionId: string; + label: string; + chatSessionId?: string; + } | { ok: false; error: string } >; /** diff --git a/packages/host-service/src/events/types.ts b/packages/host-service/src/events/types.ts index a3113586e3d..9cd68c2a273 100644 --- a/packages/host-service/src/events/types.ts +++ b/packages/host-service/src/events/types.ts @@ -200,7 +200,13 @@ export interface WorkspaceCreateTerminalLaunch { } export type WorkspaceCreateAgentLaunch = - | { ok: true; kind: "terminal"; sessionId: string; label: string } + | { + ok: true; + kind: "terminal"; + sessionId: string; + label: string; + chatSessionId?: string; + } | { ok: false; error: string }; /** diff --git a/packages/host-service/src/trpc/router/agents/agents.test.ts b/packages/host-service/src/trpc/router/agents/agents.test.ts index dfe92a47afe..46b8e408f48 100644 --- a/packages/host-service/src/trpc/router/agents/agents.test.ts +++ b/packages/host-service/src/trpc/router/agents/agents.test.ts @@ -1066,9 +1066,12 @@ describe("continuationTarget", () => { seedClaude(db); const launch = { workspaceId, agent: "claude", prompt: "go" }; - expect(chatLaunchTarget(db, { ...launch, surface: "chat" })).toEqual({ + expect( + chatLaunchTarget(db, { ...launch, surface: "chat", mode: "plan" }), + ).toEqual({ harness: "claude-acp", label: "Claude", + attachments: [], }); expect(chatLaunchTarget(db, launch)).toBeNull(); expect( diff --git a/packages/host-service/src/trpc/router/agents/agents.ts b/packages/host-service/src/trpc/router/agents/agents.ts index 8a5edceabfb..2601f5d0a08 100644 --- a/packages/host-service/src/trpc/router/agents/agents.ts +++ b/packages/host-service/src/trpc/router/agents/agents.ts @@ -160,6 +160,7 @@ export type AgentRunResult = { kind: "terminal"; sessionId: string; label: string; + chatSessionId?: string; }; /** @@ -614,17 +615,33 @@ function bindingRunsConfig( export function chatLaunchTarget( db: HostDb, input: AgentRunInput, -): { harness: string; label: string } | null { +): { + harness: string; + label: string; + attachments: Array<{ attachmentId: string; name: string; mimeType: string }>; +} | null { if ( input.surface !== "chat" || input.effort || - input.mode || input.resumeSessionId || - input.forkSessionId || - (input.attachmentIds?.length ?? 0) > 0 + input.forkSessionId ) { return null; } + const attachments: Array<{ + attachmentId: string; + name: string; + mimeType: string; + }> = []; + for (const attachmentId of input.attachmentIds ?? []) { + const resolved = resolveAttachmentPath(attachmentId); + if (!resolved) return null; + attachments.push({ + attachmentId, + name: resolved.metadata.originalFilename ?? attachmentId, + mimeType: resolved.metadata.mediaType, + }); + } const config = resolveHostAgentConfig(db, input.agent); if (!config) return null; const launchPresetId = resolveAgentLaunchPresetId( @@ -634,7 +651,7 @@ export function chatLaunchTarget( const harness = acpHarnessForPreset(launchPresetId); if (!harness) return null; validateAgentModelSelection(launchPresetId, config.label, input.model); - return { harness, label: config.label }; + return { harness, label: config.label, attachments }; } function continueChatAgent( @@ -689,17 +706,32 @@ function launchChatAgent( cwd, terminalId, ...(input.model ? { modelId: input.model } : {}), + ...(input.mode ? { modeId: input.mode } : {}), }); - if (input.prompt.trim() !== "") { + const content = [ + ...(input.prompt.trim() !== "" + ? [{ type: "text" as const, text: input.prompt }] + : []), + ...target.attachments.map((attachment) => ({ + type: "attachment" as const, + ...attachment, + })), + ]; + if (content.length > 0) { chat.commands.prompt({ commandId: crypto.randomUUID(), sessionId, clientId: crypto.randomUUID(), - content: [{ type: "text", text: input.prompt }], + content, }); } - return { kind: "terminal", sessionId: terminalId, label: target.label }; + return { + kind: "terminal", + sessionId: terminalId, + label: target.label, + chatSessionId: sessionId, + }; } /** diff --git a/packages/host-service/src/trpc/router/workspace-creation/shared/dispatch-agents.ts b/packages/host-service/src/trpc/router/workspace-creation/shared/dispatch-agents.ts index debd86c3fc1..b4cad598592 100644 --- a/packages/host-service/src/trpc/router/workspace-creation/shared/dispatch-agents.ts +++ b/packages/host-service/src/trpc/router/workspace-creation/shared/dispatch-agents.ts @@ -10,6 +10,7 @@ export const agentLaunchSchema = z model: z.string().optional(), effort: z.string().optional(), mode: z.string().optional(), + surface: z.enum(["terminal", "chat"]).optional(), }) .refine( (value) => @@ -38,6 +39,7 @@ export async function dispatchSugarAgents( model: entry.model, effort: entry.effort, mode: entry.mode, + surface: entry.surface, }); return { ok: true as const, ...result }; } catch (err) { diff --git a/packages/host-service/src/trpc/router/workspaces/workspaces.ts b/packages/host-service/src/trpc/router/workspaces/workspaces.ts index e93d5ac1b62..487ebb8d00a 100644 --- a/packages/host-service/src/trpc/router/workspaces/workspaces.ts +++ b/packages/host-service/src/trpc/router/workspaces/workspaces.ts @@ -1299,7 +1299,12 @@ export const workspacesRouter = router({ // result. let chainAgent: { fullCommand: string; label: string } | null = null; const soleLaunch = sugarLaunches.length === 1 ? sugarLaunches[0] : null; - if (!alreadyExists && input.waitForSetupBeforeAgents && soleLaunch) { + if ( + !alreadyExists && + input.waitForSetupBeforeAgents && + soleLaunch && + soleLaunch.surface !== "chat" + ) { try { chainAgent = buildTerminalAgentLaunch(ctx.db, { workspaceId: workspaceRow.id, From 5b1404be915ce1d19495a691d1a43843e55c5b48 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 15:35:25 -0700 Subject: [PATCH 05/10] fix(chat): show a harness notice as one plain line, like a tool summary --- .../UserMessageRow/UserMessageRow.tsx | 37 +++---------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/Transcript/components/UserMessageRow/UserMessageRow.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/Transcript/components/UserMessageRow/UserMessageRow.tsx index cbefa5430f4..3c9033351d8 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/Transcript/components/UserMessageRow/UserMessageRow.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/Transcript/components/UserMessageRow/UserMessageRow.tsx @@ -4,43 +4,18 @@ import type { UserMessage } from "@superset/chat/protocol"; import { Message, MessageContent } from "@superset/ui/ai-elements/message"; import { Badge } from "@superset/ui/badge"; import { Button } from "@superset/ui/button"; -import { - Collapsible, - CollapsibleContent, - CollapsibleTrigger, -} from "@superset/ui/collapsible"; import { cn } from "@superset/ui/utils"; -import { ChevronRight } from "lucide-react"; -import { useRef, useState } from "react"; +import { useRef } from "react"; import { parseAttachmentTags } from "../../../../utils/attachmentTags"; import { userMessageText } from "../../../../utils/userMessageText"; import { AttachmentImage } from "./components/AttachmentImage"; import { useFitsOneLine } from "./hooks/useFitsOneLine"; -/** - * A harness bookkeeping turn: one muted line with the raw block behind a - * disclosure, the way the CLI shows it. Rendering it as a user bubble puts - * task ids and file paths in the middle of the conversation. - */ -function BookkeepingRow({ label, text }: { label: string; text: string }) { - const [open, setOpen] = useState(false); +function BookkeepingRow({ label }: { label: string }) { return ( - - - - {label} - - -
-					{text}
-				
-
-
+
+ {label} +
); } @@ -65,7 +40,7 @@ export function UserMessageRow({ const { text, attachments } = parseAttachmentTags(raw); const textRef = useRef(null); const oneLine = useFitsOneLine(textRef); - if (note && !pending) return ; + if (note && !pending) return ; const images = attachments.filter((attachment) => attachment.type.startsWith("image/"), From df937aab559057879250ac243d1903298466ce3d Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 15:40:49 -0700 Subject: [PATCH 06/10] feat(chat): show account usage in the chat pane header The usage button read the account the terminal hook reports, which a chat agent never runs. The host now captures the account from the chat agent's own env when it launches, the same profile and API key checks as the hook, and keeps it on the chat's binding. The button moves up to the pane components so the terminal and chat headers share it. --- .../AccountUsage.tsx} | 7 ++--- .../UsageProgressRing/UsageProgressRing.tsx | 0 .../components/UsageProgressRing/index.ts | 0 .../components/AccountUsage/index.ts | 1 + .../getAccountUsageState.test.ts | 0 .../getAccountUsageState.ts | 0 .../utils/getAccountUsageState/index.ts | 0 .../TerminalPaneHeaderExtras.tsx | 4 +-- .../components/TerminalAccountUsage/index.ts | 1 - .../hooks/usePaneRegistry/usePaneRegistry.tsx | 29 +++++++++++++------ .../host-service/src/chat-v3/acpHarnesses.ts | 15 ++++++++++ .../src/chat-v3/chatAgentBridge.ts | 11 +++++++ .../src/terminal-agents/store.test.ts | 24 +++++++++++++++ .../host-service/src/terminal-agents/store.ts | 1 + 14 files changed, 76 insertions(+), 17 deletions(-) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/TerminalAccountUsage.tsx => AccountUsage/AccountUsage.tsx} (98%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage => AccountUsage}/components/UsageProgressRing/UsageProgressRing.tsx (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage => AccountUsage}/components/UsageProgressRing/index.ts (100%) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/index.ts rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage => AccountUsage}/utils/getAccountUsageState/getAccountUsageState.test.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage => AccountUsage}/utils/getAccountUsageState/getAccountUsageState.ts (100%) rename apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/{TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage => AccountUsage}/utils/getAccountUsageState/index.ts (100%) delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/TerminalAccountUsage.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/AccountUsage.tsx similarity index 98% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/TerminalAccountUsage.tsx rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/AccountUsage.tsx index 51945dc8a4f..642b60840a5 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/TerminalAccountUsage.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/AccountUsage.tsx @@ -17,15 +17,12 @@ import { formatResetLabel } from "renderer/utils/usage/formatResetIn"; import { UsageProgressRing } from "./components/UsageProgressRing"; import { getAccountUsageState } from "./utils/getAccountUsageState"; -interface TerminalAccountUsageProps { +interface AccountUsageProps { workspaceId: string; terminalId: string; } -export function TerminalAccountUsage({ - workspaceId, - terminalId, -}: TerminalAccountUsageProps) { +export function AccountUsage({ workspaceId, terminalId }: AccountUsageProps) { const { t } = useLingui(); const [openSession, setOpenSession] = useState(null); const binding = useTerminalAgentBinding(workspaceId, terminalId); diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/components/UsageProgressRing/UsageProgressRing.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/components/UsageProgressRing/UsageProgressRing.tsx similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/components/UsageProgressRing/UsageProgressRing.tsx rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/components/UsageProgressRing/UsageProgressRing.tsx diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/components/UsageProgressRing/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/components/UsageProgressRing/index.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/components/UsageProgressRing/index.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/components/UsageProgressRing/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/index.ts new file mode 100644 index 00000000000..42d01a2c66f --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/index.ts @@ -0,0 +1 @@ +export { AccountUsage } from "./AccountUsage"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/utils/getAccountUsageState/getAccountUsageState.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/utils/getAccountUsageState/getAccountUsageState.test.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/utils/getAccountUsageState/getAccountUsageState.test.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/utils/getAccountUsageState/getAccountUsageState.test.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/utils/getAccountUsageState/getAccountUsageState.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/utils/getAccountUsageState/getAccountUsageState.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/utils/getAccountUsageState/getAccountUsageState.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/utils/getAccountUsageState/getAccountUsageState.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/utils/getAccountUsageState/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/utils/getAccountUsageState/index.ts similarity index 100% rename from apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/components/TerminalAccountUsage/utils/getAccountUsageState/index.ts rename to apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AccountUsage/utils/getAccountUsageState/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/TerminalPaneHeaderExtras.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/TerminalPaneHeaderExtras.tsx index 7af9ef2323d..00ab9fb34f3 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/TerminalPaneHeaderExtras.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalPaneHeaderExtras/TerminalPaneHeaderExtras.tsx @@ -4,11 +4,11 @@ import { cn } from "@superset/ui/utils"; import { SquarePen } from "lucide-react"; import { useHotkeyDisplay } from "renderer/hotkeys"; import type { SubagentPaneData } from "../../../../../../types"; +import { AccountUsage } from "../../../AccountUsage"; import { terminalRichInputOpenStore, useTerminalRichInputOpen, } from "../../richInputOpenStore"; -import { TerminalAccountUsage } from "./components/TerminalAccountUsage"; import { TerminalConnectionIndicator } from "./components/TerminalConnectionIndicator"; import { TerminalIdCopyMenu } from "./components/TerminalIdCopyMenu"; import { TerminalPageWatchChip } from "./components/TerminalPageWatchChip"; @@ -58,7 +58,7 @@ export function TerminalPaneHeaderExtras({ return (
- ) => ( - - void agentSurface.switchSurface(ctx, surface, agent) - } - workspaceId={workspaceId} - /> - ), + renderHeaderExtras: (ctx: RendererContext) => { + const data = ctx.pane.data as ChatPaneData; + return ( +
+ + + void agentSurface.switchSurface(ctx, surface, agent) + } + workspaceId={workspaceId} + /> +
+ ); + }, renderPane: (ctx: RendererContext) => ( { + if (account) agents?.accountCaptured(options.sessionId, account); + }) + .catch(() => undefined); if (!adapterEntry) { return { command: cli.command, args: entry.args, env }; } diff --git a/packages/host-service/src/chat-v3/chatAgentBridge.ts b/packages/host-service/src/chat-v3/chatAgentBridge.ts index 08e6f801aab..38d420a2332 100644 --- a/packages/host-service/src/chat-v3/chatAgentBridge.ts +++ b/packages/host-service/src/chat-v3/chatAgentBridge.ts @@ -16,6 +16,7 @@ import { import type { AgentLifecycleEventType } from "../events"; import { chatPortTerminalIds, portManager } from "../ports/port-manager"; import { fanOutAgentLifecycle } from "../trpc/router/notifications/fan-out-agent-lifecycle"; +import type { SessionAccount } from "../trpc/router/usage/session-account/session-account"; import type { HostServiceContext } from "../types"; import { ACP_HARNESSES } from "./acpCatalogue"; @@ -43,6 +44,7 @@ type BoundChat = { queuedPrompts: number; pid?: number; established?: true; + account?: SessionAccount; }; function sameTasks( @@ -65,6 +67,7 @@ function sameTasks( export type ChatAgentBridge = LiveSessionObserver & { spawned(sessionId: string, pid: number): void; + accountCaptured(sessionId: string, account: SessionAccount): void; }; export function agentIdForHarness( @@ -125,6 +128,7 @@ export function createChatAgentBridge( agentId: chat.agentId, agentSessionId: chat.agentSessionId, chatSessionId: chat.sessionId, + ...(chat.account ? { account: chat.account } : {}), occurredAt, }); @@ -194,6 +198,13 @@ export function createChatAgentBridge( portManager.upsertSession(chat.terminalId, chat.workspaceId, pid); }, + accountCaptured(sessionId, account) { + const chat = chats.get(sessionId); + if (!chat) return; + chat.account = account; + if (current(sessionId)) attach(chat); + }, + published(envelope: Envelope, session: LiveSession) { const chat = current(envelope.sessionId); if (!chat) return; diff --git a/packages/host-service/src/terminal-agents/store.test.ts b/packages/host-service/src/terminal-agents/store.test.ts index 4c899fbfeeb..1fefe7da4bf 100644 --- a/packages/host-service/src/terminal-agents/store.test.ts +++ b/packages/host-service/src/terminal-agents/store.test.ts @@ -850,4 +850,28 @@ describe("session account attribution", () => { store.clearWorkspaceStatuses("ws-failed"); expect(store.listByWorkspace("ws-failed")[0]?.lastEventType).toBe("Failed"); }); + + it("keeps a chat's account through its later events", () => { + const store = new TerminalAgentStore(); + const account = { + agent: "claude" as const, + selection: null, + credentialKind: "api_key" as const, + identity: "api-env" as const, + }; + const chat = { + terminalId: "chat-terminal", + workspaceId: "ws-account", + agentId: "claude" as const, + chatSessionId: "chat-1", + }; + store.recordChatEvent({ + ...chat, + eventType: "Attached", + account, + occurredAt: 1, + }); + store.recordChatEvent({ ...chat, eventType: "Stop", occurredAt: 2 }); + expect(store.listByWorkspace("ws-account")[0]?.account).toEqual(account); + }); }); diff --git a/packages/host-service/src/terminal-agents/store.ts b/packages/host-service/src/terminal-agents/store.ts index 49fc7bf8c07..82938beafff 100644 --- a/packages/host-service/src/terminal-agents/store.ts +++ b/packages/host-service/src/terminal-agents/store.ts @@ -261,6 +261,7 @@ export class TerminalAgentStore extends EventEmitter { workspaceId: input.workspaceId, agentId: input.agentId, agentSessionId: input.agentSessionId ?? prior?.agentSessionId, + account: input.account ?? (sameSession ? prior.account : undefined), startedAt: sameSession ? prior.startedAt : input.occurredAt, lastEventAt: input.occurredAt, lastEventType: input.eventType, From fe6596175616c018109e99246beb6c249db954e6 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 16:10:28 -0700 Subject: [PATCH 07/10] feat(chat): load the chat at once and queue messages while the host connects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A chat pane showed a spinner until the host answered, and forever when it never did: useChatSession seeded once and dropped a failed or hung request on the floor, and a new chat waited on createSession before drawing anything. The transcript and composer now render straight away. useChatSession retries the seed with backoff and a per-attempt timeout, and holds sent messages in the outbox until the stream is open. A chat with no session yet shows its composer and keeps messages in a queue on the pane, sent in order once createSession succeeds; createSession retries with the same command id while the host is unreachable and stops on an error the host answered with. Both show "Connecting to the host service…" meanwhile. --- .../components/ChatPane/ChatPane.tsx | 50 ++++++---- .../components/AcpChatPane/AcpChatPane.tsx | 93 ++++++++++------- .../AcpChatPending/AcpChatPending.tsx | 12 --- .../components/AcpChatPending/index.ts | 1 - .../components/DraftChat/DraftChat.tsx | 62 ++++++++++++ .../AcpChatPane/components/DraftChat/index.ts | 1 + .../createWhenReachable.test.ts | 63 ++++++++++++ .../createWhenReachable.ts | 52 ++++++++++ .../utils/createWhenReachable/index.ts | 1 + .../utils/sharedChatCreate/index.ts | 6 +- .../sharedChatCreate/sharedChatCreate.ts | 4 + .../ConnectionNotice/ConnectionNotice.tsx | 11 +++ .../components/ConnectionNotice/index.ts | 1 + .../components/SessionView/SessionView.tsx | 99 +++++++++---------- .../v2-workspace/$workspaceId/types.ts | 2 + .../useChatSession/useChatSession.test.tsx | 82 +++++++++++++++ .../react/useChatSession/useChatSession.ts | 77 +++++++++++++-- packages/i18n/locales/cs/messages.po | 6 +- packages/i18n/locales/de/messages.po | 6 +- packages/i18n/locales/en/messages.po | 6 +- packages/i18n/locales/es/messages.po | 6 +- packages/i18n/locales/fr/messages.po | 6 +- packages/i18n/locales/id/messages.po | 6 +- packages/i18n/locales/it/messages.po | 6 +- packages/i18n/locales/ja/messages.po | 6 +- packages/i18n/locales/ko/messages.po | 6 +- packages/i18n/locales/nl/messages.po | 6 +- packages/i18n/locales/pl/messages.po | 6 +- packages/i18n/locales/pt-BR/messages.po | 6 +- packages/i18n/locales/ru/messages.po | 6 +- packages/i18n/locales/tr/messages.po | 6 +- packages/i18n/locales/vi/messages.po | 6 +- packages/i18n/locales/zh-CN/messages.po | 6 +- packages/i18n/locales/zh-TW/messages.po | 6 +- 34 files changed, 541 insertions(+), 178 deletions(-) delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/index.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/index.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.test.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/index.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/ConnectionNotice.tsx create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx index 1fc87ad6f95..9041e16c773 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx @@ -1,4 +1,6 @@ +import type { UserContent } from "@superset/chat/protocol"; import type { RendererContext } from "@superset/panes"; +import { useRef } from "react"; import type { ChatPaneData, OpenFile, @@ -17,38 +19,46 @@ export function ChatPane({ onOpenFile: OpenFile; }) { const data = ctx.pane.data as ChatPaneData; + const latest = useRef(data); + latest.current = data; + const firstPrompt: UserContent[] = + data.pendingPrompt || data.pendingAttachments?.length + ? [ + ...(data.pendingPrompt + ? [{ type: "text" as const, text: data.pendingPrompt }] + : []), + ...(data.pendingAttachments ?? []).map((attachment) => ({ + type: "attachment" as const, + ...attachment, + })), + ] + : []; + const pendingPrompts = [ + ...(firstPrompt.length > 0 ? [firstPrompt] : []), + ...(data.queuedPrompts ?? []), + ]; return ( { - if ( - data.pendingPrompt === undefined && - data.pendingAttachments === undefined - ) - return; + onPendingPromptsSent={() => { const { pendingPrompt: _sent, pendingAttachments: _attached, + queuedPrompts: _queued, ...rest - } = data; + } = latest.current; ctx.actions.updateData(rest); }} - pendingFirstPrompt={ - data.pendingPrompt || data.pendingAttachments?.length - ? [ - ...(data.pendingPrompt - ? [{ type: "text" as const, text: data.pendingPrompt }] - : []), - ...(data.pendingAttachments ?? []).map((attachment) => ({ - type: "attachment" as const, - ...attachment, - })), - ] - : null + onQueuePrompt={(content) => + ctx.actions.updateData({ + ...latest.current, + queuedPrompts: [...(latest.current.queuedPrompts ?? []), content], + }) } + pendingPrompts={pendingPrompts} modelId={data.chatModelId} modelLabel={data.chatModelLabel} modeId={data.chatModeId} @@ -82,7 +92,7 @@ export function ChatPane({ ctx.actions.updateData({ ...data, chatModeId }); }} onSessionCreated={(sessionId) => - ctx.actions.updateData({ ...data, sessionId }) + ctx.actions.updateData({ ...latest.current, sessionId }) } onOpenFile={onOpenFile} sessionId={data.sessionId} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx index 664256dea2b..dbc487c6eb2 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx @@ -5,6 +5,8 @@ import { buildChatSessionHandoffPrompt } from "@superset/shared/terminal-session import { toast } from "@superset/ui/sonner"; import { useWorkspaceClient } from "@superset/workspace-client"; import { useQuery, useQueryClient } from "@tanstack/react-query"; +import { TRPCClientError } from "@trpc/client"; +import type { ReactNode } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useTerminalAgentBindings } from "renderer/hooks/host-service/useTerminalAgentBindings"; import { useWorkspaceEvent } from "renderer/hooks/host-service/useWorkspaceEvent"; @@ -17,9 +19,14 @@ import type { ChatForkTarget } from "../../../ChatSession/types"; import { isUnrestrictedMode } from "../../../ChatSession/utils/isUnrestrictedMode"; import { useForkChat } from "../../hooks/useForkChat"; import { readSavedChatMode } from "../../utils/savedChatMode"; -import { AcpChatPending } from "./components/AcpChatPending"; import { AcpRecovery } from "./components/AcpRecovery"; -import { sharedChatCreate, watchChatCreate } from "./utils/sharedChatCreate"; +import { DraftChat } from "./components/DraftChat"; +import { createWhenReachable } from "./utils/createWhenReachable"; +import { + isChatCreateWatched, + sharedChatCreate, + watchChatCreate, +} from "./utils/sharedChatCreate"; /** * A chat bridged to an agent session, resumed by its session id. `agent` comes @@ -29,12 +36,13 @@ export function AcpChatPane({ agent, isActive, onSessionInfo, - onFirstPromptSent, + onPendingPromptsSent, + onQueuePrompt, onOpenFile, onModeChange, onSessionCreated, onSwitchAgent, - pendingFirstPrompt, + pendingPrompts, sessionId, terminalId, workspaceId, @@ -48,8 +56,9 @@ export function AcpChatPane({ agent: { id: string; sessionId?: string } | undefined; isActive: boolean; sessionId: string | null; - pendingFirstPrompt?: UserContent[] | null; - onFirstPromptSent?: (() => void) | undefined; + pendingPrompts: UserContent[][]; + onPendingPromptsSent: () => void; + onQueuePrompt: (content: UserContent[]) => void; onSessionCreated: (sessionId: string) => void; onModeChange?: (modeId: string) => void; onSessionInfo: (info: { harnessSessionId?: string; title?: string }) => void; @@ -75,6 +84,7 @@ export function AcpChatPane({ )?.label; const harness = acpHarnessForPreset(agent?.id); const [failure, setFailure] = useState(null); + const [unreachable, setUnreachable] = useState(false); // The stored session outlives its process — after a host restart the row // still reads "idle" and only the send fails. Ask who is actually running. @@ -119,20 +129,30 @@ export function AcpChatPane({ const startModeId = modeId ?? (resume || !agent ? undefined : readSavedChatMode(agent.id)); + const commandId = crypto.randomUUID(); const createdId = await sharedChatCreate( createKey, () => - wiring.transport - .createSession({ - commandId: crypto.randomUUID(), - workspaceId, - harness: resumeHarness, - terminalId, - ...(modelId ? { modelId } : {}), - ...(startModeId ? { modeId: startModeId } : {}), - ...(resume ? { resume: { harnessSessionId: resume } } : {}), - }) - .then((created) => created.sessionId), + createWhenReachable({ + attempt: () => + wiring.transport + .createSession({ + commandId, + workspaceId, + harness: resumeHarness, + terminalId, + ...(modelId ? { modelId } : {}), + ...(startModeId ? { modeId: startModeId } : {}), + ...(resume ? { resume: { harnessSessionId: resume } } : {}), + }) + .then((created) => created.sessionId), + isReachableFailure: (error) => + error instanceof TRPCClientError && error.data != null, + shouldContinue: () => isChatCreateWatched(createKey), + onUnreachable: (next) => { + if (mounted.current) setUnreachable(next); + }, + }), (orphan) => { void wiring.transport .closeSession({ sessionId: orphan }) @@ -341,12 +361,21 @@ export function AcpChatPane({ canResume && !stoppedWhileOpen && (!autoResumed.current || (resumingFrom.current === sessionId && !failure)); + const draft = (notice: ReactNode) => ( + Connecting to the host service… : notice + } + onQueue={onQueuePrompt} + queued={pendingPrompts} + workspaceId={workspaceId} + /> + ); + if (resuming) { - return ( - - Resuming the conversation… - - ); + return draft(Resuming the conversation…); } if (harness && sessionId && (sessionDead || sessionStopped)) { @@ -385,14 +414,12 @@ export function AcpChatPane({
); } - return ( - - {agentSessionId ? ( - Attaching to the running session… - ) : ( - Starting the agent… - )} - + return draft( + agentSessionId ? ( + Attaching to the running session… + ) : ( + Starting the agent… + ), ); } @@ -400,7 +427,7 @@ export function AcpChatPane({ ); } - -function NOOP() {} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx deleted file mode 100644 index 050b72ae05b..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/AcpChatPending.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { Spinner } from "@superset/ui/spinner"; -import type { ReactNode } from "react"; - -/** The pane is doing something that takes a moment; an empty pane reads broken. */ -export function AcpChatPending({ children }: { children: ReactNode }) { - return ( -
- - {children} -
- ); -} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/index.ts deleted file mode 100644 index 7236f48523e..00000000000 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpChatPending/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { AcpChatPending } from "./AcpChatPending"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx new file mode 100644 index 00000000000..ccdf38bdfbf --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx @@ -0,0 +1,62 @@ +import type { UserContent, UserMessage } from "@superset/chat/protocol"; +import type { ReactNode } from "react"; +import { useMemo } from "react"; +import { Composer } from "../../../../../ChatSession/components/Composer"; +import { ConnectionNotice } from "../../../../../ChatSession/components/ConnectionNotice"; + +const NO_COMMANDS: never[] = []; +const NOTHING = async () => {}; + +export function DraftChat({ + draftKey, + isActive, + notice, + onQueue, + queued, + workspaceId, +}: { + draftKey: string; + isActive: boolean; + notice: ReactNode; + onQueue: (content: UserContent[]) => void; + queued: UserContent[][]; + workspaceId: string; +}) { + const promptQueue = useMemo( + () => + queued.length === 0 + ? undefined + : { + prompts: queued.map( + (content, index): UserMessage => ({ + id: `draft-${index}`, + kind: "user_message", + startedAtMs: 0, + queued: true, + content, + }), + ), + paused: false, + actionable: false, + remove: NOTHING, + resume: NOTHING, + steer: NOTHING, + }, + [queued], + ); + + return ( +
+
+ {notice} + onQueue(content)} + promptQueue={promptQueue} + workspaceId={workspaceId} + /> +
+ ); +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/index.ts new file mode 100644 index 00000000000..57652a47e3e --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/index.ts @@ -0,0 +1 @@ +export { DraftChat } from "./DraftChat"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.test.ts new file mode 100644 index 00000000000..a8737e0e318 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.test.ts @@ -0,0 +1,63 @@ +import { describe, expect, test } from "bun:test"; +import { createWhenReachable, type Wait } from "./createWhenReachable"; + +const immediate: Wait = (callback, delayMs) => { + if (delayMs < 15_000) queueMicrotask(callback); + return () => {}; +}; + +describe("createWhenReachable", () => { + test("retries while the host is unreachable, then returns", async () => { + let calls = 0; + const states: boolean[] = []; + const result = await createWhenReachable({ + attempt: async () => { + calls += 1; + if (calls < 3) throw new TypeError("fetch failed"); + return "session-1"; + }, + isReachableFailure: () => false, + shouldContinue: () => true, + onUnreachable: (unreachable) => states.push(unreachable), + wait: immediate, + }); + expect(result).toBe("session-1"); + expect(calls).toBe(3); + expect(states).toEqual([true, true, false]); + }); + + test("gives up at once on an error the host answered with", async () => { + let calls = 0; + const answered = new Error("unknown harness"); + await expect( + createWhenReachable({ + attempt: async () => { + calls += 1; + throw answered; + }, + isReachableFailure: (error) => error === answered, + shouldContinue: () => true, + onUnreachable: () => {}, + wait: immediate, + }), + ).rejects.toBe(answered); + expect(calls).toBe(1); + }); + + test("stops retrying once nothing is waiting for the session", async () => { + let calls = 0; + await expect( + createWhenReachable({ + attempt: async () => { + calls += 1; + throw new TypeError("fetch failed"); + }, + isReachableFailure: () => false, + shouldContinue: () => calls < 2, + onUnreachable: () => {}, + wait: immediate, + }), + ).rejects.toThrow("fetch failed"); + expect(calls).toBe(2); + }); +}); diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.ts new file mode 100644 index 00000000000..a3d46e109f1 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/createWhenReachable.ts @@ -0,0 +1,52 @@ +export type Wait = (callback: () => void, delayMs: number) => () => void; + +const defaultWait: Wait = (callback, delayMs) => { + const timer = setTimeout(callback, delayMs); + return () => clearTimeout(timer); +}; + +export async function createWhenReachable({ + attempt, + isReachableFailure, + shouldContinue, + onUnreachable, + wait = defaultWait, + timeoutMs = 15_000, + initialDelayMs = 1_000, + maxDelayMs = 10_000, +}: { + attempt: () => Promise; + isReachableFailure: (error: unknown) => boolean; + shouldContinue: () => boolean; + onUnreachable: (unreachable: boolean) => void; + wait?: Wait; + timeoutMs?: number; + initialDelayMs?: number; + maxDelayMs?: number; +}): Promise { + for (let tries = 0; ; tries += 1) { + try { + const result = await new Promise((resolve, reject) => { + const cancel = wait(() => reject(new Error("timed out")), timeoutMs); + attempt().then( + (value) => { + cancel(); + resolve(value); + }, + (error: unknown) => { + cancel(); + reject(error); + }, + ); + }); + onUnreachable(false); + return result; + } catch (error) { + if (isReachableFailure(error) || !shouldContinue()) throw error; + onUnreachable(true); + await new Promise((resolve) => + wait(resolve, Math.min(initialDelayMs * 2 ** tries, maxDelayMs)), + ); + } + } +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/index.ts new file mode 100644 index 00000000000..0f2eda44d3b --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/createWhenReachable/index.ts @@ -0,0 +1 @@ +export { createWhenReachable } from "./createWhenReachable"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts index b6949faaf83..e9812a94b26 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/index.ts @@ -1 +1,5 @@ -export { sharedChatCreate, watchChatCreate } from "./sharedChatCreate"; +export { + isChatCreateWatched, + sharedChatCreate, + watchChatCreate, +} from "./sharedChatCreate"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts index ab775d6fd72..a372f2f079d 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/utils/sharedChatCreate/sharedChatCreate.ts @@ -10,6 +10,10 @@ export function watchChatCreate(key: string): () => void { }; } +export function isChatCreateWatched(key: string): boolean { + return watchers.has(key); +} + export function sharedChatCreate( key: string, create: () => Promise, diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/ConnectionNotice.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/ConnectionNotice.tsx new file mode 100644 index 00000000000..e38394ff69c --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/ConnectionNotice.tsx @@ -0,0 +1,11 @@ +import { Spinner } from "@superset/ui/spinner"; +import type { ReactNode } from "react"; + +export function ConnectionNotice({ children }: { children: ReactNode }) { + return ( + + + {children} + + ); +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/index.ts new file mode 100644 index 00000000000..0eb186b2b76 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/ConnectionNotice/index.ts @@ -0,0 +1 @@ +export { ConnectionNotice } from "./ConnectionNotice"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx index b57e9f14d3d..0babb088004 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx @@ -15,7 +15,6 @@ import { } from "@superset/chat/react"; import { MessageScroller } from "@superset/chat-ui/MessageScroller"; import { ChatHistorySidebarScroller } from "@superset/ui/chat-history-sidebar"; -import { Spinner } from "@superset/ui/spinner"; import type { ReactNode } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import type { OpenFile } from "../../../../../../types"; @@ -25,6 +24,7 @@ import { buildChatHandoffTranscript } from "../../utils/chatHandoffTranscript"; import { promptHistory } from "../../utils/promptHistory"; import { railMessages } from "../../utils/railMessages"; import { type AgentChoice, type AgentSwitcher, Composer } from "../Composer"; +import { ConnectionNotice } from "../ConnectionNotice"; import { SessionHeader } from "../SessionHeader"; import { Transcript } from "../Transcript"; import { useStableList } from "./hooks/useStableList"; @@ -43,9 +43,9 @@ export function SessionView({ headerLeft, isActive, onModeChange, - pendingFirstPrompt, + pendingPrompts, preferredModelLabel, - onFirstPromptSent, + onPendingPromptsSent, onFork, onSessionState, openFile, @@ -57,10 +57,10 @@ export function SessionView({ workspaceId: string; headerLeft?: ReactNode; isActive?: boolean; - pendingFirstPrompt: UserContent[] | null; + pendingPrompts: UserContent[][]; /** Selected by name once the agent lists its models, before the first prompt goes out. */ preferredModelLabel?: string; - onFirstPromptSent: () => void; + onPendingPromptsSent: () => void; onSessionState?: (session: SessionState | null) => void; /** The mode the user picked, so a resumed session can start in it again. */ onModeChange?: (modeId: string) => void; @@ -134,14 +134,14 @@ export function SessionView({ .finally(() => setModelSettled(true)); }, [agentStatus, configOptions, modelSettled, preferredModelLabel, session]); - const firstPromptSentRef = useRef(false); + const pendingSentRef = useRef(false); useEffect(() => { - if (!pendingFirstPrompt || firstPromptSentRef.current) return; + if (pendingPrompts.length === 0 || pendingSentRef.current) return; if (session.status !== "ready" || !modelSettled) return; - firstPromptSentRef.current = true; - session.sendPrompt(pendingFirstPrompt); - onFirstPromptSent(); - }, [pendingFirstPrompt, session, onFirstPromptSent, modelSettled]); + pendingSentRef.current = true; + for (const prompt of pendingPrompts) session.sendPrompt(prompt); + onPendingPromptsSent(); + }, [pendingPrompts, session, onPendingPromptsSent, modelSettled]); const sessionState = session.snapshot.session; useEffect(() => { @@ -257,11 +257,9 @@ export function SessionView({ ], ); - // The stream is ready well before the agent is: the harness still has to - // spawn and, when resuming, replay the whole transcript. Showing an empty - // pane through that reads as a broken chat rather than a loading one. + const connecting = + session.status === "loading" || session.connection !== "open"; const booting = sessionState?.status === "starting"; - const loadingTranscript = session.status === "loading" || booting; // w-full because the pane lays its children out in a row: without it this // sizes to its content and leaves the right of the pane empty. @@ -278,44 +276,42 @@ export function SessionView({ session={session.snapshot.session} /> )} - {loadingTranscript ? ( -
- - {booting && ( - - Opening the conversation… - + +
+ + {rail.length > 1 && ( + )}
- ) : ( - -
- - {rail.length > 1 && ( - - )} -
-
+
+ {(connecting || booting) && ( + + {connecting ? ( + Connecting to the host service… + ) : ( + Starting the agent… + )} + )} ; + queuedPrompts?: UserContent[][]; chatModelId?: string; chatModelLabel?: string; chatModeId?: string; diff --git a/packages/chat/src/react/useChatSession/useChatSession.test.tsx b/packages/chat/src/react/useChatSession/useChatSession.test.tsx index 3cbe03daffa..da8fad19294 100644 --- a/packages/chat/src/react/useChatSession/useChatSession.test.tsx +++ b/packages/chat/src/react/useChatSession/useChatSession.test.tsx @@ -97,6 +97,7 @@ function Probe(props: { client: SessionClient; scheduler?: FrameScheduler; pageSize?: number; + wait?: ReturnType["wait"]; }) { renders += 1; latest = useChatSession({ @@ -104,6 +105,7 @@ function Probe(props: { deltas: [], scheduler: props.scheduler, pageSize: props.pageSize, + wait: props.wait, }); return null; } @@ -113,7 +115,87 @@ function session(): ChatSession { return latest; } +function unreachableUntil( + transport: ChatTransport, + reachable: () => boolean, +): { transport: ChatTransport; prompts: () => number } { + let prompts = 0; + const refuse = () => Promise.reject(new Error("fetch failed")); + const getSession: ChatTransport["getSession"] = (input) => + reachable() ? transport.getSession(input) : refuse(); + const prompt: ChatTransport["prompt"] = (input) => { + prompts += 1; + return reachable() ? transport.prompt(input) : refuse(); + }; + return { + transport: new Proxy(transport, { + get: (target, key) => + key === "getSession" + ? getSession + : key === "prompt" + ? prompt + : Reflect.get(target, key), + }), + prompts: () => prompts, + }; +} + describe("useChatSession", () => { + test("keeps retrying while the host is unreachable and loads once it answers", async () => { + const stack = await startStack(); + let up = false; + const host = unreachableUntil(stack.transport, () => up); + const manual = createManualWait(); + const client = stack.makeClient({ + transport: host.transport, + wait: manual.wait, + }); + const view = render(); + + await domWaitFor(() => expect(manual.pendingCount()).toBeGreaterThan(0)); + act(() => manual.flush()); + await domWaitFor(() => expect(manual.pendingCount()).toBeGreaterThan(0)); + expect(session().status).toBe("loading"); + + up = true; + await domWaitFor(() => { + act(() => manual.flush()); + expect(session().status).toBe("ready"); + }); + view.unmount(); + client.close(); + await stack.runtime.dispose(); + }); + + test("holds a prompt sent before the host connects and sends it once connected", async () => { + const stack = await startStack(); + let up = false; + const host = unreachableUntil(stack.transport, () => up); + const manual = createManualWait(); + const client = stack.makeClient({ + transport: host.transport, + wait: manual.wait, + }); + const view = render(); + + act(() => { + session().sendPrompt([{ type: "text", text: "hello" }]); + }); + expect(session().outbox.map((entry) => entry.state)).toEqual(["queued"]); + expect(host.prompts()).toBe(0); + + up = true; + await domWaitFor(() => { + act(() => manual.flush()); + expect(session().connection).toBe("open"); + }); + await domWaitFor(() => expect(session().outbox).toHaveLength(0)); + expect(host.prompts()).toBe(1); + view.unmount(); + client.close(); + await stack.runtime.dispose(); + }); + test("seeds, streams a turn, and clears the outbox on clientId echo", async () => { const stack = await startStack(); const always = createRecordingSink(); diff --git a/packages/chat/src/react/useChatSession/useChatSession.ts b/packages/chat/src/react/useChatSession/useChatSession.ts index 8e6be7f4757..7cf4811f688 100644 --- a/packages/chat/src/react/useChatSession/useChatSession.ts +++ b/packages/chat/src/react/useChatSession/useChatSession.ts @@ -1,5 +1,14 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import type { SessionClient, SessionStream, StreamStatus } from "../../client"; +import type { + SessionClient, + SessionStream, + StreamStatus, + Wait, +} from "../../client"; +import { + DEFAULT_BACKOFF_INITIAL_MS, + DEFAULT_BACKOFF_MAX_MS, +} from "../../client"; import type { OutboxEntry, SessionSnapshot } from "../../core"; import { emptySnapshot, Outbox, reduceMany } from "../../core"; import type { Cursor } from "../../protocol/cursor"; @@ -22,6 +31,13 @@ const defaultScheduler: FrameScheduler = (flush) => { return () => clearTimeout(timer); }; +const defaultWait: Wait = (callback, delayMs) => { + const timer = setTimeout(callback, delayMs); + return () => clearTimeout(timer); +}; + +const SEED_TIMEOUT_MS = 10_000; + export const DEFAULT_DELTAS: readonly DeltaChannel[] = [ "text", "tool_input", @@ -33,6 +49,7 @@ export type UseChatSessionOptions = { deltas?: readonly DeltaChannel[]; pageSize?: number; scheduler?: FrameScheduler; + wait?: Wait; }; export type ChatSessionStatus = "loading" | "ready"; @@ -84,6 +101,9 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { const schedulerRef = useRef(options.scheduler ?? defaultScheduler); schedulerRef.current = options.scheduler ?? defaultScheduler; + const waitRef = useRef(options.wait ?? defaultWait); + waitRef.current = options.wait ?? defaultWait; + const connectedRef = useRef(false); const pendingRef = useRef([]); const cancelFlushRef = useRef<(() => void) | null>(null); @@ -112,6 +132,11 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { return outbox.subscribe(() => setOutboxEntries(outbox.snapshot())); }, [outbox]); + useEffect(() => { + connectedRef.current = connection === "open"; + if (connectedRef.current) void outbox.flush(); + }, [connection, outbox]); + const commit = useCallback(() => { cancelFlushRef.current = null; const batch = pendingRef.current; @@ -167,9 +192,46 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { nextBeforeRef.current = null; pendingRef.current = []; - const seed = async () => { - const session = await client.getSession(); - const page = await client.getItems({ limit: pageSize }); + let cancelRetry: (() => void) | null = null; + const retry = (attempt: number) => { + const delayMs = Math.min( + DEFAULT_BACKOFF_INITIAL_MS * 2 ** attempt, + DEFAULT_BACKOFF_MAX_MS, + ); + cancelRetry = waitRef.current(() => { + cancelRetry = null; + void seed(attempt + 1); + }, delayMs); + }; + + const timed = (request: Promise) => + new Promise((resolve, reject) => { + const cancelTimeout = waitRef.current( + () => reject(new Error("timed out")), + SEED_TIMEOUT_MS, + ); + request.then( + (value) => { + cancelTimeout(); + resolve(value); + }, + (error: unknown) => { + cancelTimeout(); + reject(error); + }, + ); + }); + + const seed = async (attempt: number) => { + let session: Awaited>; + let page: Awaited>; + try { + session = await timed(client.getSession()); + page = await timed(client.getItems({ limit: pageSize })); + } catch { + if (!cancelled) retry(attempt); + return; + } if (cancelled) return; let seeded = emptySnapshot(); if (page.ok) { @@ -189,10 +251,11 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { onStatusChange: setConnection, }); }; - void seed(); + void seed(0); return () => { cancelled = true; + cancelRetry?.(); cancelFlushRef.current?.(); cancelFlushRef.current = null; pendingRef.current = []; @@ -203,7 +266,7 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { const sendPrompt = useCallback( (content: UserContent[], steer?: { expectedTurnId: string }) => { const entry = outbox.enqueue(content, steer); - void outbox.flush(); + if (connectedRef.current) void outbox.flush(); return entry; }, [outbox], @@ -212,7 +275,7 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { const retryPrompt = useCallback( (clientId: string) => { outbox.retry(clientId); - void outbox.flush(); + if (connectedRef.current) void outbox.flush(); }, [outbox], ); diff --git a/packages/i18n/locales/cs/messages.po b/packages/i18n/locales/cs/messages.po index 3132e9748e5..6820ad7a0c9 100644 --- a/packages/i18n/locales/cs/messages.po +++ b/packages/i18n/locales/cs/messages.po @@ -4255,6 +4255,9 @@ msgstr "Připojením umožníte svým agentům číst a jednat v {name} vaším msgid "Connecting to the desktop…" msgstr "Připojování k ploše…" +msgid "Connecting to the host service…" +msgstr "Připojování k hostitelské službě…" + msgid "Connecting to the workspace" msgstr "Připojuji se k pracovnímu prostoru" @@ -11536,9 +11539,6 @@ msgstr "Otevírání složek" msgid "Opening pages" msgstr "Otevírání stránek" -msgid "Opening the conversation…" -msgstr "Otevírám konverzaci…" - msgid "Opening worktree..." msgstr "Otevírám worktree..." diff --git a/packages/i18n/locales/de/messages.po b/packages/i18n/locales/de/messages.po index a8dc5b24f88..2ade3631f49 100644 --- a/packages/i18n/locales/de/messages.po +++ b/packages/i18n/locales/de/messages.po @@ -4255,6 +4255,9 @@ msgstr "Durch das Verbinden können Ihre Agenten in {name} in Ihrem Namen lesen msgid "Connecting to the desktop…" msgstr "Verbindung zum Desktop wird hergestellt …" +msgid "Connecting to the host service…" +msgstr "Verbindung zum Host-Dienst wird hergestellt…" + msgid "Connecting to the workspace" msgstr "Verbindung zum Arbeitsbereich" @@ -11536,9 +11539,6 @@ msgstr "Ordner öffnen" msgid "Opening pages" msgstr "Seiten öffnen" -msgid "Opening the conversation…" -msgstr "Unterhaltung wird geöffnet…" - msgid "Opening worktree..." msgstr "Worktree wird geöffnet..." diff --git a/packages/i18n/locales/en/messages.po b/packages/i18n/locales/en/messages.po index f88075c5833..ca3f42add50 100644 --- a/packages/i18n/locales/en/messages.po +++ b/packages/i18n/locales/en/messages.po @@ -4255,6 +4255,9 @@ msgstr "Connecting lets your agents read and act in {name} on your behalf. Revie msgid "Connecting to the desktop…" msgstr "Connecting to the desktop…" +msgid "Connecting to the host service…" +msgstr "Connecting to the host service…" + msgid "Connecting to the workspace" msgstr "Connecting to the workspace" @@ -11536,9 +11539,6 @@ msgstr "Opening folders" msgid "Opening pages" msgstr "Opening pages" -msgid "Opening the conversation…" -msgstr "Opening the conversation…" - msgid "Opening worktree..." msgstr "Opening worktree..." diff --git a/packages/i18n/locales/es/messages.po b/packages/i18n/locales/es/messages.po index 0d8deb6d1f7..ccf6d0f15d1 100644 --- a/packages/i18n/locales/es/messages.po +++ b/packages/i18n/locales/es/messages.po @@ -4255,6 +4255,9 @@ msgstr "Conectar permite que tus agentes lean y actúen en {name} en tu nombre. msgid "Connecting to the desktop…" msgstr "Conectando con el escritorio…" +msgid "Connecting to the host service…" +msgstr "Conectando con el servicio del host…" + msgid "Connecting to the workspace" msgstr "Conectando con el espacio de trabajo" @@ -11536,9 +11539,6 @@ msgstr "Abrir carpetas" msgid "Opening pages" msgstr "Abrir páginas" -msgid "Opening the conversation…" -msgstr "Abriendo la conversación…" - msgid "Opening worktree..." msgstr "Abriendo el worktree..." diff --git a/packages/i18n/locales/fr/messages.po b/packages/i18n/locales/fr/messages.po index 942401386b1..4d99d57bd99 100644 --- a/packages/i18n/locales/fr/messages.po +++ b/packages/i18n/locales/fr/messages.po @@ -4255,6 +4255,9 @@ msgstr "La connexion permet à vos agents de lire et d'agir dans {name} en votre msgid "Connecting to the desktop…" msgstr "Connexion au bureau…" +msgid "Connecting to the host service…" +msgstr "Connexion au service d'hôte…" + msgid "Connecting to the workspace" msgstr "Connexion à l'espace de travail" @@ -11536,9 +11539,6 @@ msgstr "Ouverture des dossiers" msgid "Opening pages" msgstr "Ouverture des pages" -msgid "Opening the conversation…" -msgstr "Ouverture de la conversation…" - msgid "Opening worktree..." msgstr "Ouverture du worktree..." diff --git a/packages/i18n/locales/id/messages.po b/packages/i18n/locales/id/messages.po index d5c981ce47d..167e9dc4887 100644 --- a/packages/i18n/locales/id/messages.po +++ b/packages/i18n/locales/id/messages.po @@ -4255,6 +4255,9 @@ msgstr "Menghubungkan memungkinkan agen Anda membaca dan bertindak di {name} ata msgid "Connecting to the desktop…" msgstr "Menghubungkan ke desktop…" +msgid "Connecting to the host service…" +msgstr "Menghubungkan ke layanan host…" + msgid "Connecting to the workspace" msgstr "Menghubungkan ke workspace" @@ -11536,9 +11539,6 @@ msgstr "Membuka folder" msgid "Opening pages" msgstr "Membuka halaman" -msgid "Opening the conversation…" -msgstr "Membuka percakapan…" - msgid "Opening worktree..." msgstr "Membuka worktree..." diff --git a/packages/i18n/locales/it/messages.po b/packages/i18n/locales/it/messages.po index 54c94efeee1..325dfab7f72 100644 --- a/packages/i18n/locales/it/messages.po +++ b/packages/i18n/locales/it/messages.po @@ -4255,6 +4255,9 @@ msgstr "Collegandolo, i tuoi agenti potranno leggere e agire in {name} per tuo c msgid "Connecting to the desktop…" msgstr "Connessione al desktop…" +msgid "Connecting to the host service…" +msgstr "Connessione al servizio host…" + msgid "Connecting to the workspace" msgstr "Connessione al workspace" @@ -11536,9 +11539,6 @@ msgstr "Apertura delle cartelle" msgid "Opening pages" msgstr "Apertura delle pagine" -msgid "Opening the conversation…" -msgstr "Apertura della conversazione…" - msgid "Opening worktree..." msgstr "Apertura del worktree..." diff --git a/packages/i18n/locales/ja/messages.po b/packages/i18n/locales/ja/messages.po index b8a8c2c3e39..96a42244d62 100644 --- a/packages/i18n/locales/ja/messages.po +++ b/packages/i18n/locales/ja/messages.po @@ -4255,6 +4255,9 @@ msgstr "接続すると、エージェントがあなたに代わって {name} msgid "Connecting to the desktop…" msgstr "デスクトップに接続しています…" +msgid "Connecting to the host service…" +msgstr "ホストサービスに接続しています…" + msgid "Connecting to the workspace" msgstr "ワークスペースに接続中" @@ -11536,9 +11539,6 @@ msgstr "フォルダーを開く" msgid "Opening pages" msgstr "ページを開く" -msgid "Opening the conversation…" -msgstr "会話を開いています…" - msgid "Opening worktree..." msgstr "ワークツリーを開いています..." diff --git a/packages/i18n/locales/ko/messages.po b/packages/i18n/locales/ko/messages.po index 203826490f6..ae12f6ad98b 100644 --- a/packages/i18n/locales/ko/messages.po +++ b/packages/i18n/locales/ko/messages.po @@ -4255,6 +4255,9 @@ msgstr "연결하면 에이전트가 사용자를 대신해 {name}에서 읽고 msgid "Connecting to the desktop…" msgstr "데스크톱에 연결하는 중…" +msgid "Connecting to the host service…" +msgstr "호스트 서비스에 연결하는 중…" + msgid "Connecting to the workspace" msgstr "워크스페이스에 연결하는 중" @@ -11536,9 +11539,6 @@ msgstr "폴더 열기" msgid "Opening pages" msgstr "페이지 열기" -msgid "Opening the conversation…" -msgstr "대화를 여는 중…" - msgid "Opening worktree..." msgstr "worktree를 여는 중..." diff --git a/packages/i18n/locales/nl/messages.po b/packages/i18n/locales/nl/messages.po index 2336b87421d..fd48b147a5d 100644 --- a/packages/i18n/locales/nl/messages.po +++ b/packages/i18n/locales/nl/messages.po @@ -4255,6 +4255,9 @@ msgstr "Verbinden laat je agents in {name} lezen en handelen namens jou. Control msgid "Connecting to the desktop…" msgstr "Verbinden met het bureaublad…" +msgid "Connecting to the host service…" +msgstr "Verbinden met de hostservice…" + msgid "Connecting to the workspace" msgstr "Verbinden met de werkruimte" @@ -11536,9 +11539,6 @@ msgstr "Mappen openen" msgid "Opening pages" msgstr "Pagina's openen" -msgid "Opening the conversation…" -msgstr "Gesprek wordt geopend…" - msgid "Opening worktree..." msgstr "Worktree openen..." diff --git a/packages/i18n/locales/pl/messages.po b/packages/i18n/locales/pl/messages.po index c65a7639590..7def55c4dfd 100644 --- a/packages/i18n/locales/pl/messages.po +++ b/packages/i18n/locales/pl/messages.po @@ -4255,6 +4255,9 @@ msgstr "Połączenie pozwoli Twoim agentom czytać i działać w {name} w Twoim msgid "Connecting to the desktop…" msgstr "Łączenie z pulpitem…" +msgid "Connecting to the host service…" +msgstr "Łączenie z usługą hosta…" + msgid "Connecting to the workspace" msgstr "Łączenie z obszarem roboczym" @@ -11536,9 +11539,6 @@ msgstr "Otwieranie folderów" msgid "Opening pages" msgstr "Otwieranie stron" -msgid "Opening the conversation…" -msgstr "Otwieranie rozmowy…" - msgid "Opening worktree..." msgstr "Otwieranie worktree..." diff --git a/packages/i18n/locales/pt-BR/messages.po b/packages/i18n/locales/pt-BR/messages.po index 07278586fad..34777c1e66c 100644 --- a/packages/i18n/locales/pt-BR/messages.po +++ b/packages/i18n/locales/pt-BR/messages.po @@ -4255,6 +4255,9 @@ msgstr "Conectar permite que seus agentes leiam e ajam no {name} em seu nome. Re msgid "Connecting to the desktop…" msgstr "Conectando à área de trabalho…" +msgid "Connecting to the host service…" +msgstr "Conectando ao serviço do host…" + msgid "Connecting to the workspace" msgstr "Conectando à área de trabalho" @@ -11536,9 +11539,6 @@ msgstr "Abertura de pastas" msgid "Opening pages" msgstr "Abertura de páginas" -msgid "Opening the conversation…" -msgstr "Abrindo a conversa…" - msgid "Opening worktree..." msgstr "Abrindo worktree..." diff --git a/packages/i18n/locales/ru/messages.po b/packages/i18n/locales/ru/messages.po index 393e21bcdcd..98532119b18 100644 --- a/packages/i18n/locales/ru/messages.po +++ b/packages/i18n/locales/ru/messages.po @@ -4255,6 +4255,9 @@ msgstr "Подключение позволит вашим агентам чит msgid "Connecting to the desktop…" msgstr "Подключение к рабочему столу…" +msgid "Connecting to the host service…" +msgstr "Подключение к службе хоста…" + msgid "Connecting to the workspace" msgstr "Подключение к рабочей области" @@ -11536,9 +11539,6 @@ msgstr "Открытие папок" msgid "Opening pages" msgstr "Открытие страниц" -msgid "Opening the conversation…" -msgstr "Открываем разговор…" - msgid "Opening worktree..." msgstr "Открытие worktree..." diff --git a/packages/i18n/locales/tr/messages.po b/packages/i18n/locales/tr/messages.po index 0426713f9d4..627d424169c 100644 --- a/packages/i18n/locales/tr/messages.po +++ b/packages/i18n/locales/tr/messages.po @@ -4255,6 +4255,9 @@ msgstr "Bağlanmak, aracılarınızın {name} içinde sizin adınıza okuma ve i msgid "Connecting to the desktop…" msgstr "Masaüstüne bağlanılıyor…" +msgid "Connecting to the host service…" +msgstr "Ana makine hizmetine bağlanılıyor…" + msgid "Connecting to the workspace" msgstr "Çalışma alanına bağlanılıyor" @@ -11536,9 +11539,6 @@ msgstr "Klasörleri açma" msgid "Opening pages" msgstr "Sayfaları açma" -msgid "Opening the conversation…" -msgstr "Sohbet açılıyor…" - msgid "Opening worktree..." msgstr "Worktree açılıyor..." diff --git a/packages/i18n/locales/vi/messages.po b/packages/i18n/locales/vi/messages.po index bf516299e91..395c2840da5 100644 --- a/packages/i18n/locales/vi/messages.po +++ b/packages/i18n/locales/vi/messages.po @@ -4255,6 +4255,9 @@ msgstr "Kết nối cho phép các tác nhân của bạn đọc và thao tác t msgid "Connecting to the desktop…" msgstr "Đang kết nối tới màn hình nền…" +msgid "Connecting to the host service…" +msgstr "Đang kết nối tới dịch vụ máy chủ…" + msgid "Connecting to the workspace" msgstr "Đang kết nối tới workspace" @@ -11536,9 +11539,6 @@ msgstr "Mở thư mục" msgid "Opening pages" msgstr "Mở trang" -msgid "Opening the conversation…" -msgstr "Đang mở cuộc trò chuyện…" - msgid "Opening worktree..." msgstr "Đang mở worktree..." diff --git a/packages/i18n/locales/zh-CN/messages.po b/packages/i18n/locales/zh-CN/messages.po index de6f7c248d5..32bee6c2ab2 100644 --- a/packages/i18n/locales/zh-CN/messages.po +++ b/packages/i18n/locales/zh-CN/messages.po @@ -4255,6 +4255,9 @@ msgstr "连接后,你的智能体可代表你在 {name} 中读取和操作。 msgid "Connecting to the desktop…" msgstr "正在连接桌面…" +msgid "Connecting to the host service…" +msgstr "正在连接主机服务…" + msgid "Connecting to the workspace" msgstr "正在连接工作区" @@ -11536,9 +11539,6 @@ msgstr "打开文件夹" msgid "Opening pages" msgstr "打开页面" -msgid "Opening the conversation…" -msgstr "正在打开对话…" - msgid "Opening worktree..." msgstr "正在打开worktree..." diff --git a/packages/i18n/locales/zh-TW/messages.po b/packages/i18n/locales/zh-TW/messages.po index 9854192d9d7..c57f515be8a 100644 --- a/packages/i18n/locales/zh-TW/messages.po +++ b/packages/i18n/locales/zh-TW/messages.po @@ -4255,6 +4255,9 @@ msgstr "連線後,你的代理可代表你在 {name} 中讀取和操作。繼 msgid "Connecting to the desktop…" msgstr "正在連線至桌面…" +msgid "Connecting to the host service…" +msgstr "正在連線至主機服務…" + msgid "Connecting to the workspace" msgstr "正在連線工作區" @@ -11536,9 +11539,6 @@ msgstr "開啟資料夾" msgid "Opening pages" msgstr "開啟頁面" -msgid "Opening the conversation…" -msgstr "正在開啟對話…" - msgid "Opening worktree..." msgstr "正在開啟worktree..." From 02d8233a300f85642d17a54cac861dd971c84de6 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 16:14:26 -0700 Subject: [PATCH 08/10] fix(chat): give the composer's footer buttons back their rounded-square shape #8216 made the send, stop, mic and plus buttons circles. Keep its 26px sizing, restore the rounded-square corners they had before. --- .../PromptInput/components/ComposerBody/ComposerBody.tsx | 2 +- .../PromptInput/components/ContextButton/ContextButton.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/chat-ui/src/components/PromptInput/components/ComposerBody/ComposerBody.tsx b/packages/chat-ui/src/components/PromptInput/components/ComposerBody/ComposerBody.tsx index 165f30404b0..e0875a18425 100644 --- a/packages/chat-ui/src/components/PromptInput/components/ComposerBody/ComposerBody.tsx +++ b/packages/chat-ui/src/components/PromptInput/components/ComposerBody/ComposerBody.tsx @@ -77,7 +77,7 @@ import { DictationBar } from "../DictationBar"; import { MentionMenu } from "../MentionMenu"; const FOOTER_BUTTON_CLASS = - "flex size-[26px] shrink-0 items-center justify-center rounded-full transition-colors"; + "flex size-[26px] shrink-0 items-center justify-center rounded-md transition-colors"; const GHOST_FOOTER_BUTTON_CLASS = cn( FOOTER_BUTTON_CLASS, "cursor-pointer text-muted-foreground hover:bg-accent hover:text-foreground", diff --git a/packages/chat-ui/src/components/PromptInput/components/ContextButton/ContextButton.tsx b/packages/chat-ui/src/components/PromptInput/components/ContextButton/ContextButton.tsx index 45c8a680838..f5ea5134f99 100644 --- a/packages/chat-ui/src/components/PromptInput/components/ContextButton/ContextButton.tsx +++ b/packages/chat-ui/src/components/PromptInput/components/ContextButton/ContextButton.tsx @@ -22,7 +22,7 @@ export function ContextButton({ onClick, disabled }: ContextButtonProps) { })} disabled={disabled} onClick={onClick} - className="flex size-[26px] cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted-foreground" + className="flex size-[26px] cursor-pointer items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted-foreground" > From 13cdbfed36d7e2c2ad27d2af8bce212cf32ba5a1 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 16:45:44 -0700 Subject: [PATCH 09/10] feat(chat): resume a stopped chat by itself and keep its conversation on screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A chat whose agent stopped while it was open showed a panel and waited for Resume, and a resume showed an empty view until the agent replayed the transcript. The pane now resumes on its own, retrying with backoff, and keeps showing the stopped session's conversation with "Resuming the conversation…" until the new session is past starting; prompts typed meanwhile wait on the pane. The panel is left for a chat that moved to a terminal, or one that still fails after three attempts. useChatSession reports unreachable only once a request to the host fails, so a normal first load no longer says it is connecting. The replacement is polled in the background and on chat:sessions-changed, so an unfocused window does not delay the switch. --- .../components/AcpChatPane/AcpChatPane.tsx | 132 ++++++++++++------ .../components/AcpRecovery/AcpRecovery.tsx | 8 +- .../components/DraftChat/DraftChat.tsx | 27 +--- .../components/SessionView/SessionView.tsx | 60 +++++--- .../utils/heldPromptQueue/heldPromptQueue.ts | 23 +++ .../utils/heldPromptQueue/index.ts | 1 + .../useChatSession/useChatSession.test.tsx | 2 + .../react/useChatSession/useChatSession.ts | 9 +- packages/i18n/locales/cs/messages.po | 6 +- packages/i18n/locales/de/messages.po | 6 +- packages/i18n/locales/en/messages.po | 6 +- packages/i18n/locales/es/messages.po | 6 +- packages/i18n/locales/fr/messages.po | 6 +- packages/i18n/locales/id/messages.po | 6 +- packages/i18n/locales/it/messages.po | 6 +- packages/i18n/locales/ja/messages.po | 6 +- packages/i18n/locales/ko/messages.po | 6 +- packages/i18n/locales/nl/messages.po | 6 +- packages/i18n/locales/pl/messages.po | 6 +- packages/i18n/locales/pt-BR/messages.po | 6 +- packages/i18n/locales/ru/messages.po | 6 +- packages/i18n/locales/tr/messages.po | 6 +- packages/i18n/locales/vi/messages.po | 6 +- packages/i18n/locales/zh-CN/messages.po | 6 +- packages/i18n/locales/zh-TW/messages.po | 6 +- 25 files changed, 221 insertions(+), 143 deletions(-) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/heldPromptQueue.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx index dbc487c6eb2..7433ea289fc 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/AcpChatPane.tsx @@ -32,6 +32,9 @@ import { * A chat bridged to an agent session, resumed by its session id. `agent` comes * from the pane: the terminal it may have come from is stopped. */ +const MAX_RECOVERIES = 3; +const REPLACEMENT_TIMEOUT_MS = 30_000; + export function AcpChatPane({ agent, isActive, @@ -85,6 +88,7 @@ export function AcpChatPane({ const harness = acpHarnessForPreset(agent?.id); const [failure, setFailure] = useState(null); const [unreachable, setUnreachable] = useState(false); + const [replacement, setReplacement] = useState(null); // The stored session outlives its process — after a host restart the row // still reads "idle" and only the send fails. Ask who is actually running. @@ -105,6 +109,9 @@ export function AcpChatPane({ void queryClient.invalidateQueries({ queryKey: ["acp-chat-session", sessionId], }); + void queryClient.invalidateQueries({ + queryKey: ["acp-chat-replacement"], + }); }, sessionId !== null, ); @@ -112,6 +119,7 @@ export function AcpChatPane({ const createKey = `${terminalId}:${agent?.id ?? ""}`; useEffect(() => watchChatCreate(createKey), [createKey]); const attaching = useRef(false); + const recoveryInFlight = useRef(false); // A switch to another agent remounts this pane; its pending calls must not // write the old agent back over the new one. const mounted = useRef(true); @@ -122,7 +130,7 @@ export function AcpChatPane({ }; }, []); const start = useCallback( - async (resumeHarness: string, resume?: string) => { + async (resumeHarness: string, resume?: string, replacing = false) => { attaching.current = true; setFailure(null); try { @@ -159,9 +167,12 @@ export function AcpChatPane({ .catch(() => undefined); }, ); - if (mounted.current) onSessionCreated(createdId); + if (!mounted.current) return; + if (replacing) setReplacement(createdId); + else onSessionCreated(createdId); } catch (error) { attaching.current = false; + if (replacing) recoveryInFlight.current = false; setFailure(error instanceof Error ? error.message : String(error)); } }, @@ -328,39 +339,73 @@ export function AcpChatPane({ !binding.chatSessionId && binding.endedAt === undefined, ); - const sawLive = useRef(false); - if (stored?.live) sawLive.current = true; - const canResume = Boolean( - (sessionStopped || sessionDead) && - harness && - agentSessionId && - !continuedInTerminal, + const recoverable = Boolean( + (sessionStopped || sessionDead) && harness && !continuedInTerminal, ); - const stoppedWhileOpen = canResume && sawLive.current; - - // Once per mount: if the session we resume into is itself unusable, fall - // through to the panel instead of spawning adapters in a loop. - const autoResumed = useRef(false); - const resumingFrom = useRef(null); - const resume = useCallback(() => { - if (!harness || !agentSessionId || !sessionId) return; - resumingFrom.current = sessionId; - attaching.current = false; + const recoveries = useRef(0); + if (stored?.live && !sessionDead) recoveries.current = 0; + const recover = useCallback(() => { + if (!harness || !sessionId || recoveryInFlight.current) return; + recoveryInFlight.current = true; void wiring.transport .closeSession({ sessionId }) .catch(() => undefined) - .then(() => start(harness, agentSessionId)); + .then(() => start(harness, agentSessionId, true)); }, [harness, agentSessionId, sessionId, start, wiring.transport]); + const { data: replacementState } = useQuery({ + enabled: replacement !== null, + queryKey: ["acp-chat-replacement", replacement], + queryFn: () => + replacement + ? wiring.transport.getSession({ sessionId: replacement }) + : Promise.resolve(null), + refetchInterval: 500, + refetchIntervalInBackground: true, + }); useEffect(() => { - if (!canResume || stoppedWhileOpen || autoResumed.current) return; - autoResumed.current = true; - resume(); - }, [canResume, stoppedWhileOpen, resume]); + if (!replacement) return; + const commit = () => { + recoveryInFlight.current = false; + onSessionCreated(replacement); + setReplacement(null); + }; + const status = replacementState?.session?.status; + if (status === "dead") { + recoveryInFlight.current = false; + setReplacement(null); + setFailure( + t({ message: "The agent stopped while resuming the conversation." }), + ); + return; + } + if (replacementState?.live && status !== "starting") { + commit(); + return; + } + const timer = setTimeout(commit, REPLACEMENT_TIMEOUT_MS); + return () => clearTimeout(timer); + }, [replacement, replacementState, onSessionCreated, t]); + const recovering = + replacement !== null || + (recoverable && recoveries.current < MAX_RECOVERIES); + useEffect(() => { + if (!recovering || recoveryInFlight.current) return; + const delayMs = + recoveries.current === 0 && failure === null + ? 0 + : 1_000 * 2 ** Math.max(recoveries.current - 1, 0); + const timer = setTimeout(() => { + recoveries.current += 1; + recover(); + }, delayMs); + return () => clearTimeout(timer); + }, [recovering, recover, failure]); + const retryRecovery = useCallback(() => { + recoveries.current = 0; + setFailure(null); + recover(); + }, [recover]); - const resuming = - canResume && - !stoppedWhileOpen && - (!autoResumed.current || (resumingFrom.current === sessionId && !failure)); const draft = (notice: ReactNode) => ( ); - if (resuming) { - return draft(Resuming the conversation…); - } - - if (harness && sessionId && (sessionDead || sessionStopped)) { + if (harness && sessionId && (sessionDead || sessionStopped) && !recovering) { return ( ); } @@ -426,6 +459,19 @@ export function AcpChatPane({ return ( Connecting to the host service… + ) : ( + Resuming the conversation… + ), + queued: pendingPrompts, + onQueue: onQueuePrompt, + }, + } + : {})} key={sessionId} onPendingPromptsSent={onPendingPromptsSent} agentLabel={agentLabel} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx index 5f1b5ece540..8055eb3c539 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/AcpRecovery/AcpRecovery.tsx @@ -16,7 +16,7 @@ export function AcpRecovery({ onStartNew, reason, }: { - reason: "no-transcript" | "stopped" | "in-terminal" | "stopped-while-open"; + reason: "no-transcript" | "stopped" | "in-terminal"; detail?: string | undefined; onResume?: () => void; onStartNew: () => void; @@ -26,9 +26,7 @@ export function AcpRecovery({ // sizes to its content and hugs the left edge.

- {reason === "stopped-while-open" ? ( - This chat was stopped. - ) : reason === "in-terminal" ? ( + {reason === "in-terminal" ? ( This chat stopped because the conversation continued in a terminal. @@ -38,7 +36,7 @@ export function AcpRecovery({ but never prompted. ) : ( - This chat's agent has stopped and can't be resumed. + This chat was stopped. )}

{detail && ( diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx index ccdf38bdfbf..873b67ad32c 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/AcpChatPane/components/DraftChat/DraftChat.tsx @@ -1,11 +1,11 @@ -import type { UserContent, UserMessage } from "@superset/chat/protocol"; +import type { UserContent } from "@superset/chat/protocol"; import type { ReactNode } from "react"; import { useMemo } from "react"; import { Composer } from "../../../../../ChatSession/components/Composer"; import { ConnectionNotice } from "../../../../../ChatSession/components/ConnectionNotice"; +import { heldPromptQueue } from "../../../../../ChatSession/utils/heldPromptQueue"; const NO_COMMANDS: never[] = []; -const NOTHING = async () => {}; export function DraftChat({ draftKey, @@ -22,28 +22,7 @@ export function DraftChat({ queued: UserContent[][]; workspaceId: string; }) { - const promptQueue = useMemo( - () => - queued.length === 0 - ? undefined - : { - prompts: queued.map( - (content, index): UserMessage => ({ - id: `draft-${index}`, - kind: "user_message", - startedAtMs: 0, - queued: true, - content, - }), - ), - paused: false, - actionable: false, - remove: NOTHING, - resume: NOTHING, - steer: NOTHING, - }, - [queued], - ); + const promptQueue = useMemo(() => heldPromptQueue(queued), [queued]); return (
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx index 0babb088004..0615161fab4 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/components/SessionView/SessionView.tsx @@ -21,6 +21,7 @@ import type { OpenFile } from "../../../../../../types"; import { ChatPaneActionsProvider } from "../../providers/ChatPaneActionsProvider"; import type { ChatForkTarget } from "../../types"; import { buildChatHandoffTranscript } from "../../utils/chatHandoffTranscript"; +import { heldPromptQueue } from "../../utils/heldPromptQueue"; import { promptHistory } from "../../utils/promptHistory"; import { railMessages } from "../../utils/railMessages"; import { type AgentChoice, type AgentSwitcher, Composer } from "../Composer"; @@ -41,6 +42,7 @@ export function SessionView({ canForkToWorktree, client, headerLeft, + held, isActive, onModeChange, pendingPrompts, @@ -56,6 +58,11 @@ export function SessionView({ sessionId: string; workspaceId: string; headerLeft?: ReactNode; + held?: { + notice: ReactNode; + queued: UserContent[][]; + onQueue: (content: UserContent[]) => void; + }; isActive?: boolean; pendingPrompts: UserContent[][]; /** Selected by name once the agent lists its models, before the first prompt goes out. */ @@ -136,12 +143,12 @@ export function SessionView({ const pendingSentRef = useRef(false); useEffect(() => { - if (pendingPrompts.length === 0 || pendingSentRef.current) return; + if (held || pendingPrompts.length === 0 || pendingSentRef.current) return; if (session.status !== "ready" || !modelSettled) return; pendingSentRef.current = true; for (const prompt of pendingPrompts) session.sendPrompt(prompt); onPendingPromptsSent(); - }, [pendingPrompts, session, onPendingPromptsSent, modelSettled]); + }, [held, pendingPrompts, session, onPendingPromptsSent, modelSettled]); const sessionState = session.snapshot.session; useEffect(() => { @@ -222,21 +229,26 @@ export function SessionView({ }, [onModeChange, setMode], ); + const holdPrompt = held?.onQueue; const onSend = useCallback( (content: UserContent[], { steer }: { steer: boolean }) => - sendPrompt( - content, - steer && runningTurnId ? { expectedTurnId: runningTurnId } : undefined, - ), - [sendPrompt, runningTurnId], + holdPrompt + ? holdPrompt(content) + : sendPrompt( + content, + steer && runningTurnId + ? { expectedTurnId: runningTurnId } + : undefined, + ), + [holdPrompt, sendPrompt, runningTurnId], ); const awaitingBackground = sessionState?.awaitingBackground === true; const onCancelTurn = useMemo( () => - runningTurnId && !awaitingBackground + runningTurnId && !awaitingBackground && !held ? () => void cancelTurn(runningTurnId, { pauseQueue: true }) : null, - [runningTurnId, awaitingBackground, cancelTurn], + [runningTurnId, awaitingBackground, cancelTurn, held], ); const promptQueue = useMemo( () => ({ @@ -257,8 +269,14 @@ export function SessionView({ ], ); + const heldQueued = held?.queued; + const heldQueue = useMemo( + () => (heldQueued ? heldPromptQueue(heldQueued) : undefined), + [heldQueued], + ); const connecting = - session.status === "loading" || session.connection !== "open"; + session.unreachable || + (session.status === "ready" && session.connection === "closed"); const booting = sessionState?.status === "starting"; // w-full because the pane lays its children out in a row: without it this @@ -304,14 +322,18 @@ export function SessionView({ )}
- {(connecting || booting) && ( - - {connecting ? ( - Connecting to the host service… - ) : ( - Starting the agent… - )} - + {held ? ( + {held.notice} + ) : ( + (connecting || booting) && ( + + {connecting ? ( + Connecting to the host service… + ) : ( + Starting the agent… + )} + + ) )}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/heldPromptQueue.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/heldPromptQueue.ts new file mode 100644 index 00000000000..3ca3701516f --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/heldPromptQueue.ts @@ -0,0 +1,23 @@ +import type { UserContent, UserMessage } from "@superset/chat/protocol"; + +const NOTHING = async () => {}; + +export function heldPromptQueue(queued: UserContent[][]) { + if (queued.length === 0) return undefined; + return { + prompts: queued.map( + (content, index): UserMessage => ({ + id: `held-${index}`, + kind: "user_message", + startedAtMs: 0, + queued: true, + content, + }), + ), + paused: false, + actionable: false, + remove: NOTHING, + resume: NOTHING, + steer: NOTHING, + }; +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/index.ts new file mode 100644 index 00000000000..06a5c659462 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatSession/utils/heldPromptQueue/index.ts @@ -0,0 +1 @@ +export { heldPromptQueue } from "./heldPromptQueue"; diff --git a/packages/chat/src/react/useChatSession/useChatSession.test.tsx b/packages/chat/src/react/useChatSession/useChatSession.test.tsx index da8fad19294..18ada005be1 100644 --- a/packages/chat/src/react/useChatSession/useChatSession.test.tsx +++ b/packages/chat/src/react/useChatSession/useChatSession.test.tsx @@ -156,12 +156,14 @@ describe("useChatSession", () => { act(() => manual.flush()); await domWaitFor(() => expect(manual.pendingCount()).toBeGreaterThan(0)); expect(session().status).toBe("loading"); + expect(session().unreachable).toBe(true); up = true; await domWaitFor(() => { act(() => manual.flush()); expect(session().status).toBe("ready"); }); + expect(session().unreachable).toBe(false); view.unmount(); client.close(); await stack.runtime.dispose(); diff --git a/packages/chat/src/react/useChatSession/useChatSession.ts b/packages/chat/src/react/useChatSession/useChatSession.ts index 7cf4811f688..919965043d2 100644 --- a/packages/chat/src/react/useChatSession/useChatSession.ts +++ b/packages/chat/src/react/useChatSession/useChatSession.ts @@ -58,6 +58,7 @@ export type ChatSession = { snapshot: SessionSnapshot; status: ChatSessionStatus; connection: StreamStatus; + unreachable: boolean; outbox: OutboxEntry[]; hasOlder: boolean; sendPrompt( @@ -96,6 +97,7 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { const [snapshot, setSnapshot] = useState(emptySnapshot); const [status, setStatus] = useState("loading"); const [connection, setConnection] = useState("connecting"); + const [unreachable, setUnreachable] = useState(false); const [outboxEntries, setOutboxEntries] = useState([]); const [hasOlder, setHasOlder] = useState(false); @@ -186,6 +188,7 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { const deltas = deltasKey ? (deltasKey.split(",") as DeltaChannel[]) : []; setStatus("loading"); + setUnreachable(false); setConnection("connecting"); setSnapshot(emptySnapshot()); setHasOlder(false); @@ -229,9 +232,12 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { session = await timed(client.getSession()); page = await timed(client.getItems({ limit: pageSize })); } catch { - if (!cancelled) retry(attempt); + if (cancelled) return; + setUnreachable(true); + retry(attempt); return; } + setUnreachable(false); if (cancelled) return; let seeded = emptySnapshot(); if (page.ok) { @@ -350,6 +356,7 @@ export function useChatSession(options: UseChatSessionOptions): ChatSession { snapshot, status, connection, + unreachable, outbox: outboxEntries, hasOlder, sendPrompt, diff --git a/packages/i18n/locales/cs/messages.po b/packages/i18n/locales/cs/messages.po index 6820ad7a0c9..4b68a97b3d8 100644 --- a/packages/i18n/locales/cs/messages.po +++ b/packages/i18n/locales/cs/messages.po @@ -16125,6 +16125,9 @@ msgstr "Agent zkopíruje konverzaci; větev se otevře zde" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "Agent vlastní úkol od ticketu po diff. Člověk reviduje výsledek, ne úhozy. Pozornost se přesouvá od psaní kódu k zadávání práce a jejímu posuzování. Jeden inženýr běží několik agentů naráz v izolovaných pracovních prostorech." +msgid "The agent stopped while resuming the conversation." +msgstr "Agent se zastavil při obnovování konverzace." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "Agent, se kterým měla tato automatizace běžet, už na svém hostu neexistuje — agenti hosta mohli být resetováni nebo odebráni. Vyberte v nastavení automatizace jiného agenta." @@ -16507,9 +16510,6 @@ msgstr "Tento chat se zastavil, protože konverzace pokračovala v terminálu." msgid "This chat was stopped." msgstr "Tento chat byl zastaven." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "Agent tohoto chatu byl zastaven a nelze jej obnovit." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Tímto se zavřou všechny relace terminálu — v tomto pracovním prostoru i ve všech ostatních — a nelze to vrátit zpět. Pokud jsou zaseknuté jen na chvíli, obvykle se samy vzpamatují." diff --git a/packages/i18n/locales/de/messages.po b/packages/i18n/locales/de/messages.po index 2ade3631f49..1d4f263ed8d 100644 --- a/packages/i18n/locales/de/messages.po +++ b/packages/i18n/locales/de/messages.po @@ -16125,6 +16125,9 @@ msgstr "Der Agent kopiert die Unterhaltung; der Zweig öffnet sich hier" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "Der Agent verantwortet eine Aufgabe vom Ticket bis zum Diff. Der Mensch reviewt das Ergebnis, nicht die Tastenanschläge. Die Aufmerksamkeit verlagert sich vom Schreiben von Code zum Spezifizieren und Beurteilen von Arbeit. Eine Ingenieurin betreibt mehrere Agenten gleichzeitig in isolierten Arbeitsbereichen." +msgid "The agent stopped while resuming the conversation." +msgstr "Der Agent wurde beim Fortsetzen der Unterhaltung beendet." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "Den Agenten, mit dem diese Automatisierung laufen sollte, gibt es auf seinem Host nicht mehr — die Agenten des Hosts wurden möglicherweise zurückgesetzt oder entfernt. Wähle in den Einstellungen der Automatisierung erneut einen Agenten aus." @@ -16507,9 +16510,6 @@ msgstr "Dieser Chat wurde beendet, weil die Unterhaltung in einem Terminal fortg msgid "This chat was stopped." msgstr "Dieser Chat wurde beendet." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "Der Agent dieses Chats wurde beendet und lässt sich nicht fortsetzen." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Damit wird jede Terminal-Sitzung geschlossen — in diesem Arbeitsbereich und in allen anderen — und das lässt sich nicht rückgängig machen. Wenn sie nur kurz hängen, hilft Warten meist." diff --git a/packages/i18n/locales/en/messages.po b/packages/i18n/locales/en/messages.po index ca3f42add50..f64c5b47b8b 100644 --- a/packages/i18n/locales/en/messages.po +++ b/packages/i18n/locales/en/messages.po @@ -16125,6 +16125,9 @@ msgstr "The agent copies the conversation; the branch opens here" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." +msgid "The agent stopped while resuming the conversation." +msgstr "The agent stopped while resuming the conversation." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." @@ -16507,9 +16510,6 @@ msgstr "This chat stopped because the conversation continued in a terminal." msgid "This chat was stopped." msgstr "This chat was stopped." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "This chat's agent has stopped and can't be resumed." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." diff --git a/packages/i18n/locales/es/messages.po b/packages/i18n/locales/es/messages.po index ccf6d0f15d1..f734689dc6c 100644 --- a/packages/i18n/locales/es/messages.po +++ b/packages/i18n/locales/es/messages.po @@ -16125,6 +16125,9 @@ msgstr "El agente copia la conversación; la rama se abre aquí" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "El agente se encarga de una tarea desde el ticket hasta el diff. La persona revisa el resultado, no las pulsaciones. La atención pasa de escribir código a especificar el trabajo y juzgarlo. Un ingeniero ejecuta varios agentes a la vez en espacios de trabajo aislados." +msgid "The agent stopped while resuming the conversation." +msgstr "El agente se detuvo al reanudar la conversación." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "El agente con el que se configuró esta automatización ya no existe en su host: puede que los agentes del host se hayan restablecido o eliminado. Vuelve a seleccionar un agente en la configuración de la automatización." @@ -16507,9 +16510,6 @@ msgstr "Este chat se detuvo porque la conversación continuó en una terminal." msgid "This chat was stopped." msgstr "Este chat se detuvo." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "El agente de este chat se ha detenido y no se puede reanudar." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Esto cierra todas las sesiones de terminal, de este espacio de trabajo y de cualquier otro, y no se puede deshacer. Si solo están atascadas un momento, esperar suele bastar." diff --git a/packages/i18n/locales/fr/messages.po b/packages/i18n/locales/fr/messages.po index 4d99d57bd99..752cc565b67 100644 --- a/packages/i18n/locales/fr/messages.po +++ b/packages/i18n/locales/fr/messages.po @@ -16125,6 +16125,9 @@ msgstr "L'agent copie la conversation ; la branche s'ouvre ici" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "L'agent prend en charge une tâche du ticket au diff. L'humain relit le résultat, pas les frappes au clavier. L'attention passe de l'écriture du code à la spécification du travail et à son évaluation. Un ingénieur fait tourner plusieurs agents à la fois dans des espaces de travail isolés." +msgid "The agent stopped while resuming the conversation." +msgstr "L'agent s'est arrêté pendant la reprise de la conversation." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "L'agent que cette automatisation devait exécuter n'existe plus sur son hôte — les agents de l'hôte ont peut-être été réinitialisés ou supprimés. Sélectionnez à nouveau un agent dans les paramètres de l'automatisation." @@ -16507,9 +16510,6 @@ msgstr "Ce chat s'est arrêté car la conversation s'est poursuivie dans un term msgid "This chat was stopped." msgstr "Ce chat a été arrêté." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "L'agent de cette discussion s'est arrêté et ne peut pas être repris." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Cela ferme toutes les sessions de terminal — dans cet espace de travail comme dans les autres — et cette action est irréversible. Si elles ne sont bloquées que brièvement, attendre suffit généralement à les faire revenir." diff --git a/packages/i18n/locales/id/messages.po b/packages/i18n/locales/id/messages.po index 167e9dc4887..5041c67fba3 100644 --- a/packages/i18n/locales/id/messages.po +++ b/packages/i18n/locales/id/messages.po @@ -16125,6 +16125,9 @@ msgstr "Agen menyalin percakapan; cabang terbuka di sini" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "Agen memegang tugas dari tiket sampai diff. Manusia mereview hasilnya, bukan tiap ketukan tombolnya. Perhatian bergeser dari menulis kode ke menentukan pekerjaan dan menilainya. Satu engineer menjalankan beberapa agen sekaligus di workspace terisolasi." +msgid "The agent stopped while resuming the conversation." +msgstr "Agen berhenti saat melanjutkan percakapan." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "Agen yang disetel untuk menjalankan otomatisasi ini sudah tidak ada di host-nya — agen host itu mungkin telah direset atau dihapus. Pilih ulang agen di pengaturan otomatisasi." @@ -16507,9 +16510,6 @@ msgstr "Chat ini berhenti karena percakapan dilanjutkan di terminal." msgid "This chat was stopped." msgstr "Chat ini telah dihentikan." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "Agen chat ini sudah berhenti dan tidak dapat dilanjutkan." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Ini menutup setiap sesi terminal — di workspace ini maupun yang lain — dan tidak bisa dibatalkan. Kalau hanya macet sebentar, menunggu biasanya cukup." diff --git a/packages/i18n/locales/it/messages.po b/packages/i18n/locales/it/messages.po index 325dfab7f72..d6eb2e93d21 100644 --- a/packages/i18n/locales/it/messages.po +++ b/packages/i18n/locales/it/messages.po @@ -16125,6 +16125,9 @@ msgstr "L'agente copia la conversazione; il ramo si apre qui" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "L'agente prende in carico un task dal ticket al diff. L'umano rivede il risultato, non le battute sulla tastiera. L'attenzione si sposta dallo scrivere codice allo specificare il lavoro e giudicarlo. Un ingegnere fa girare diversi agenti insieme in workspace isolati." +msgid "The agent stopped while resuming the conversation." +msgstr "L'agente si è fermato durante la ripresa della conversazione." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "L'agente che questa automazione doveva eseguire non esiste più sul suo host — gli agenti dell'host potrebbero essere stati reimpostati o rimossi. Riseleziona un agente nelle impostazioni dell'automazione." @@ -16507,9 +16510,6 @@ msgstr "Questa chat si è interrotta perché la conversazione è proseguita in u msgid "This chat was stopped." msgstr "Questa chat è stata interrotta." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "L'agente di questa chat si è fermato e non può essere ripreso." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Questo chiude tutte le sessioni del terminale — in questo workspace e in tutti gli altri — e non può essere annullato. Se sono bloccati solo per poco, di solito basta aspettare." diff --git a/packages/i18n/locales/ja/messages.po b/packages/i18n/locales/ja/messages.po index 96a42244d62..20a963b2475 100644 --- a/packages/i18n/locales/ja/messages.po +++ b/packages/i18n/locales/ja/messages.po @@ -16125,6 +16125,9 @@ msgstr "エージェントが会話を複製し、分岐はここで開きます msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "エージェントがチケットから差分までタスクを引き受けます。人間はキー入力ではなく結果をレビューします。関心はコードを書くことから、作業を仕様化し判断することへ移ります。エンジニア1人が独立したワークスペースで複数のエージェントを同時に動かします。" +msgid "The agent stopped while resuming the conversation." +msgstr "会話の再開中にエージェントが停止しました。" + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "このオートメーションに設定されていたエージェントは、ホスト上に存在しなくなりました — ホストのエージェントがリセットまたは削除された可能性があります。オートメーションの設定でエージェントを選び直してください。" @@ -16507,9 +16510,6 @@ msgstr "会話がターミナルで続行されたため、このチャットは msgid "This chat was stopped." msgstr "このチャットは停止されました。" -msgid "This chat's agent has stopped and can't be resumed." -msgstr "このチャットのエージェントは停止しており、再開できません。" - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "このワークスペースと他のワークスペースのすべてのターミナルセッションを閉じます。元に戻せません。一時的に固まっているだけなら、待つことで復帰することが多いです。" diff --git a/packages/i18n/locales/ko/messages.po b/packages/i18n/locales/ko/messages.po index ae12f6ad98b..c037b0f81d6 100644 --- a/packages/i18n/locales/ko/messages.po +++ b/packages/i18n/locales/ko/messages.po @@ -16125,6 +16125,9 @@ msgstr "에이전트가 대화를 복사하고 분기는 여기서 열립니다" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "에이전트가 티켓부터 차이까지 작업을 맡습니다. 사람은 키 입력이 아니라 결과를 리뷰합니다. 관심은 코드를 쓰는 데서 일을 명세하고 판단하는 데로 옮겨 갑니다. 엔지니어 한 명이 격리된 워크스페이스에서 여러 에이전트를 동시에 돌립니다." +msgid "The agent stopped while resuming the conversation." +msgstr "대화를 재개하는 중에 에이전트가 중지되었습니다." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "이 자동화가 실행하도록 설정된 에이전트가 해당 호스트에 더 이상 존재하지 않습니다. 호스트의 에이전트가 초기화되었거나 제거되었을 수 있습니다. 자동화 설정에서 에이전트를 다시 선택하세요." @@ -16507,9 +16510,6 @@ msgstr "대화가 터미널에서 계속되어 이 채팅이 중지되었습니 msgid "This chat was stopped." msgstr "이 채팅이 중지되었습니다." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "이 채팅의 에이전트가 중지되어 이어갈 수 없습니다." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "이 워크스페이스를 포함한 모든 워크스페이스의 터미널 세션이 닫히며 되돌릴 수 없습니다. 잠깐 멈춘 것뿐이라면 기다리는 것만으로 대개 복구됩니다." diff --git a/packages/i18n/locales/nl/messages.po b/packages/i18n/locales/nl/messages.po index fd48b147a5d..f0621d0f70d 100644 --- a/packages/i18n/locales/nl/messages.po +++ b/packages/i18n/locales/nl/messages.po @@ -16125,6 +16125,9 @@ msgstr "De agent kopieert het gesprek; de aftakking opent hier" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "De agent bezit een taak van ticket tot diff. De mens reviewt het resultaat, niet de toetsaanslagen. De aandacht verschuift van code schrijven naar werk specificeren en beoordelen. Eén engineer laat meerdere agents tegelijk draaien in geïsoleerde werkruimtes." +msgid "The agent stopped while resuming the conversation." +msgstr "De agent stopte tijdens het hervatten van het gesprek." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "De agent waarmee deze automatisering zou draaien bestaat niet meer op de host — de agents van die host zijn mogelijk gereset of verwijderd. Kies opnieuw een agent in de instellingen van de automatisering." @@ -16507,9 +16510,6 @@ msgstr "Deze chat is gestopt omdat het gesprek in een terminal verderging." msgid "This chat was stopped." msgstr "Deze chat is gestopt." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "De agent van deze chat is gestopt en kan niet worden hervat." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Hiermee worden alle terminalsessies gesloten — in deze werkruimte en in alle andere — en dat kan niet ongedaan worden gemaakt. Zitten ze maar even vast, dan helpt wachten meestal." diff --git a/packages/i18n/locales/pl/messages.po b/packages/i18n/locales/pl/messages.po index 7def55c4dfd..f875fe63e8e 100644 --- a/packages/i18n/locales/pl/messages.po +++ b/packages/i18n/locales/pl/messages.po @@ -16125,6 +16125,9 @@ msgstr "Agent kopiuje rozmowę; gałąź otworzy się tutaj" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "Agent prowadzi zadanie od zgłoszenia do diffa. Człowiek przegląda wynik, a nie naciśnięcia klawiszy. Uwaga przenosi się z pisania kodu na opisywanie pracy i jej ocenę. Jeden inżynier prowadzi kilku agentów naraz w izolowanych obszarach roboczych." +msgid "The agent stopped while resuming the conversation." +msgstr "Agent zatrzymał się podczas wznawiania rozmowy." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "Agent, na którym miała działać ta automatyzacja, już nie istnieje na swoim hoście — agenci hosta mogli zostać zresetowani lub usunięci. Wybierz ponownie agenta w ustawieniach automatyzacji." @@ -16507,9 +16510,6 @@ msgstr "Ten czat został zatrzymany, ponieważ rozmowa była kontynuowana w term msgid "This chat was stopped." msgstr "Ten czat został zatrzymany." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "Agent tego czatu został zatrzymany i nie można go wznowić." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Zamknie to każdą sesję terminala — w tym obszarze roboczym i we wszystkich innych — i nie da się tego cofnąć. Jeśli zacięły się tylko na chwilę, zwykle wystarczy poczekać." diff --git a/packages/i18n/locales/pt-BR/messages.po b/packages/i18n/locales/pt-BR/messages.po index 34777c1e66c..4f9fedddda0 100644 --- a/packages/i18n/locales/pt-BR/messages.po +++ b/packages/i18n/locales/pt-BR/messages.po @@ -16125,6 +16125,9 @@ msgstr "O agente copia a conversa; a ramificação abre aqui" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "O agente é dono da tarefa, do ticket ao diff. A pessoa revisa o resultado, não as teclas digitadas. A atenção sai de escrever código e vai para especificar o trabalho e julgá-lo. Uma pessoa toca vários agentes ao mesmo tempo em áreas de trabalho isoladas." +msgid "The agent stopped while resuming the conversation." +msgstr "O agente parou ao retomar a conversa." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "O agente que esta automação usava não existe mais no host — os agentes do host podem ter sido redefinidos ou removidos. Selecione outro agente nas configurações da automação." @@ -16507,9 +16510,6 @@ msgstr "Este chat parou porque a conversa continuou em um terminal." msgid "This chat was stopped." msgstr "Este chat foi interrompido." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "O agente deste chat parou e não pode ser retomado." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Isso fecha todas as sessões de terminal — nesta área de trabalho e em qualquer outra — e não dá para desfazer. Se elas estiverem só travadas por um instante, esperar costuma resolver." diff --git a/packages/i18n/locales/ru/messages.po b/packages/i18n/locales/ru/messages.po index 98532119b18..a13c1d13270 100644 --- a/packages/i18n/locales/ru/messages.po +++ b/packages/i18n/locales/ru/messages.po @@ -16125,6 +16125,9 @@ msgstr "Агент копирует разговор; ветвь откроет msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "Агент ведёт задачу от тикета до diff. Человек проверяет результат, а не нажатия клавиш. Внимание смещается с написания кода на постановку задач и оценку результата. Один инженер ведёт несколько агентов одновременно в изолированных рабочих областях." +msgid "The agent stopped while resuming the conversation." +msgstr "Агент остановился при возобновлении разговора." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "Агента, на котором должна была запускаться эта автоматизация, больше нет на его хосте — возможно, агенты хоста были сброшены или удалены. Выберите агента заново в настройках автоматизации." @@ -16507,9 +16510,6 @@ msgstr "Этот чат остановлен, потому что разгово msgid "This chat was stopped." msgstr "Этот чат остановлен." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "Агент этого чата остановлен, и его нельзя возобновить." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Это закроет все сессии терминала — в этой рабочей области и в остальных — и отменить это нельзя. Если они зависли ненадолго, обычно достаточно подождать." diff --git a/packages/i18n/locales/tr/messages.po b/packages/i18n/locales/tr/messages.po index 627d424169c..00e16a59070 100644 --- a/packages/i18n/locales/tr/messages.po +++ b/packages/i18n/locales/tr/messages.po @@ -16125,6 +16125,9 @@ msgstr "Aracı konuşmayı kopyalar; çatal burada açılır" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "Ajan, bir görevi biletten farka kadar sahiplenir. İnsan tuş vuruşlarını değil, sonucu inceler. Dikkat, kod yazmaktan işi tanımlamaya ve değerlendirmeye kayar. Bir mühendis, yalıtılmış çalışma alanlarında aynı anda birkaç ajan çalıştırır." +msgid "The agent stopped while resuming the conversation." +msgstr "Ajan, konuşmayı sürdürürken durdu." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "Bu otomasyonun çalıştırılacağı ajan, host'unda artık yok — host'un ajanları sıfırlanmış veya kaldırılmış olabilir. Otomasyonun ayarlarından yeni bir ajan seçin." @@ -16507,9 +16510,6 @@ msgstr "Konuşma bir terminalde devam ettiği için bu sohbet durdu." msgid "This chat was stopped." msgstr "Bu sohbet durduruldu." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "Bu sohbetin aracısı durdu ve devam ettirilemiyor." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Bu işlem, bu çalışma alanındaki ve diğerlerindeki her terminal oturumunu kapatır ve geri alınamaz. Yalnızca kısa süre takıldılarsa beklemek genellikle onları geri getirir." diff --git a/packages/i18n/locales/vi/messages.po b/packages/i18n/locales/vi/messages.po index 395c2840da5..e6bcf1df043 100644 --- a/packages/i18n/locales/vi/messages.po +++ b/packages/i18n/locales/vi/messages.po @@ -16125,6 +16125,9 @@ msgstr "Tác nhân sao chép hội thoại; nhánh mở tại đây" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "Agent làm chủ một tác vụ từ ticket đến diff. Con người review kết quả, không phải từng thao tác gõ. Sự chú ý dịch từ viết code sang đặc tả công việc và đánh giá nó. Một kỹ sư chạy nhiều agent cùng lúc trong các workspace tách biệt." +msgid "The agent stopped while resuming the conversation." +msgstr "Tác tử đã dừng khi đang tiếp tục cuộc trò chuyện." + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "Agent mà tự động hóa này được đặt để chạy không còn tồn tại trên host của nó — agent của host có thể đã bị đặt lại hoặc gỡ bỏ. Hãy chọn lại agent trong cài đặt của tự động hóa." @@ -16507,9 +16510,6 @@ msgstr "Cuộc trò chuyện này đã dừng vì nó được tiếp tục tron msgid "This chat was stopped." msgstr "Cuộc trò chuyện này đã bị dừng." -msgid "This chat's agent has stopped and can't be resumed." -msgstr "Tác nhân của cuộc trò chuyện này đã dừng và không thể tiếp tục." - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "Thao tác này đóng mọi phiên terminal — trong workspace này và mọi workspace khác — và không thể hoàn tác. Nếu chúng chỉ kẹt trong chốc lát, chờ thêm thường là đủ." diff --git a/packages/i18n/locales/zh-CN/messages.po b/packages/i18n/locales/zh-CN/messages.po index 32bee6c2ab2..2ad6c03e682 100644 --- a/packages/i18n/locales/zh-CN/messages.po +++ b/packages/i18n/locales/zh-CN/messages.po @@ -16125,6 +16125,9 @@ msgstr "智能体复制该对话,分支在此打开" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "智能体从工单一路负责到差异。人类审查结果,而不是击键过程。注意力从写代码转向定义工作和判断成果。一名工程师在隔离工作区里同时跑好几个智能体。" +msgid "The agent stopped while resuming the conversation." +msgstr "恢复对话时代理已停止。" + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "这个自动化原本要运行的智能体在它的主机上已不存在,该主机的智能体可能被重置或删除了。请在自动化的设置中重新选择一个智能体。" @@ -16507,9 +16510,6 @@ msgstr "由于对话已在终端中继续,此聊天已停止。" msgid "This chat was stopped." msgstr "此聊天已停止。" -msgid "This chat's agent has stopped and can't be resumed." -msgstr "此聊天的智能体已停止,无法继续。" - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "这会关闭所有终端会话 — 包括此工作区和其他工作区中的 — 且无法撤销。如果它们只是短暂卡住,等待通常就能恢复。" diff --git a/packages/i18n/locales/zh-TW/messages.po b/packages/i18n/locales/zh-TW/messages.po index c57f515be8a..f40261ba9f6 100644 --- a/packages/i18n/locales/zh-TW/messages.po +++ b/packages/i18n/locales/zh-TW/messages.po @@ -16125,6 +16125,9 @@ msgstr "代理複製該對話,分支在此開啟" msgid "The agent owns a task from ticket to diff. The human reviews the result, not the keystrokes. Attention shifts from writing code to specifying work and judging it. One engineer runs several agents at once in isolated workspaces." msgstr "代理程式從工單一路負責到差異。人類審查結果,而不是擊鍵過程。注意力從寫程式碼轉向定義工作和判斷成果。一名工程師在隔離工作區裡同時跑好幾個代理程式。" +msgid "The agent stopped while resuming the conversation." +msgstr "恢復對話時代理已停止。" + msgid "The agent this automation was set to run no longer exists on its host — the host's agents may have been reset or removed. Re-select an agent in the automation's settings." msgstr "這個自動化原本要執行的代理程式在它的主機上已不存在,該主機的代理程式可能被重置或刪除了。請在自動化的設定中重新選擇一個代理程式。" @@ -16507,9 +16510,6 @@ msgstr "由於對話已在終端機中繼續,此聊天已停止。" msgid "This chat was stopped." msgstr "此聊天已停止。" -msgid "This chat's agent has stopped and can't be resumed." -msgstr "此聊天的代理已停止,無法繼續。" - msgid "This closes every terminal session — in this workspace and any others — and can't be undone. If they're only briefly stuck, waiting usually brings them back." msgstr "這會關閉所有終端會話 — 包括此工作區和其他工作區中的 — 且無法復原。如果它們只是短暫卡住,等待通常就能恢復。" From d33ddb6c61292f169c6246c94cb4ee29740ae83d Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Tue, 6 Oct 2026 16:55:33 -0700 Subject: [PATCH 10/10] fix(chat-runtime): record a reply when the agent's cycle ends A reply's text reached the journal only when the next item opened or a prompted turn ended. A reply the agent wrote on its own, after a background task finished, has no turn end, so it stayed an empty item until the user's next message. Streamed text is not replayed, so any remount or reconnect in between showed nothing where the reply was. Claude marks the end of each cycle with a cost on usage_update; the open text is flushed there. --- .../src/harness/acp/acpAdapter.test.ts | 33 +++++++++++++++++++ .../src/harness/acp/acpAdapter.ts | 1 + 2 files changed, 34 insertions(+) diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts index 36c9c4558c9..6b50b4e5168 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts @@ -1359,6 +1359,39 @@ describe("AcpAdapter on protocol v2", () => { await adapter.dispose(); }); + it("records a reply in full when the agent's cycle ends, not when the next item starts", async () => { + const agent = new FakeAcpAgent(); + agent.holdPrompts = true; + const { adapter, events } = startAdapter(agent); + await flush(); + adapter.prompt([{ type: "text", text: "say hi" }]); + await flush(); + + agent.notify("sess-1", { + sessionUpdate: "agent_message_chunk", + content: { type: "text", text: "Hello " }, + }); + agent.notify("sess-1", { + sessionUpdate: "agent_message_chunk", + content: { type: "text", text: "there." }, + }); + agent.notify("sess-1", { + sessionUpdate: "usage_update", + used: 10, + size: 100, + cost: { amount: 0.01, currency: "USD" }, + }); + await flush(); + + const recorded = events.flatMap((event) => + event.kind === "item" && event.item.kind === "agent_message" + ? [(event.item as { text: string }).text] + : [], + ); + expect(recorded.at(-1)).toBe("Hello there."); + await adapter.dispose(); + }); + it("treats a steered turn as working until the steered reply streams", async () => { const agent = new FakeAcpAgent(); agent.steeringOutcome = "injected"; diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.ts index 4889e4f7645..29852657733 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.ts @@ -751,6 +751,7 @@ export class AcpAdapter implements HarnessAdapter { if (variant === "usage_update") { const usage = acpUsageUpdateSchema.safeParse(outer.data.update); + if (usage.success && usage.data.cost !== undefined) this.flushOpenText(); if ( usage.success && usage.data.cost !== undefined &&