From e9d63291fecb475c3d54552174c73cf0da7007b2 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sun, 5 Jul 2026 15:48:15 -0700 Subject: [PATCH] feat(native-chat): select runtime owner in caller view (U4) Co-authored-by: Orca --- .../src/components/native-chat/NativeChatView.tsx | 14 +++++++++++++- .../native-chat/native-chat-session-transport.ts | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/native-chat/NativeChatView.tsx b/src/renderer/src/components/native-chat/NativeChatView.tsx index fa190c37879..ceaa0a3be22 100644 --- a/src/renderer/src/components/native-chat/NativeChatView.tsx +++ b/src/renderer/src/components/native-chat/NativeChatView.tsx @@ -47,6 +47,7 @@ import { resolveNativeChatFileLink, resolveNativeChatFileLinkContext } from './native-chat-file-link' +import { selectNativeChatRuntimeEnvironmentId } from './native-chat-runtime-owner' import type { CommentMarkdownLinkClickHandler } from '@/components/sidebar/CommentMarkdown' import { openDetectedFilePath } from '@/components/terminal-pane/terminal-file-open-routing' @@ -155,7 +156,18 @@ function NativeChatResolvedView({ onSwitchToTerminal?: () => void contextMenuActions?: Omit }): React.JSX.Element { - const session = useNativeChatLiveSession({ paneKey, agent, sessionId, transcriptPath }) + // Primitive owner selection (no useShallow): routes the pane's read/subscribe to + // the remote runtime host for a runtime-owned pane; null keeps the local path. + const runtimeEnvironmentId = useAppStore((s) => + selectNativeChatRuntimeEnvironmentId(s, terminalTabId) + ) + const session = useNativeChatLiveSession({ + paneKey, + agent, + sessionId, + transcriptPath, + runtimeEnvironmentId + }) // Live hook state for this pane, selected directly so the working indicator // flips the instant the agent reports 'working' — even when switching to chat // mid-turn before the transcript merge has caught up. diff --git a/src/renderer/src/components/native-chat/native-chat-session-transport.ts b/src/renderer/src/components/native-chat/native-chat-session-transport.ts index 41053b1e4ac..0b4cbbdb74b 100644 --- a/src/renderer/src/components/native-chat/native-chat-session-transport.ts +++ b/src/renderer/src/components/native-chat/native-chat-session-transport.ts @@ -75,7 +75,10 @@ function createRuntimeNativeChatTransport(environmentId: string): NativeChatSess }, { onResponse: (response) => { - if (cancelled || response.ok === false) { + if (cancelled) { + return + } + if (response.ok === false) { return } const frame = response.result as {