feat(native-chat): select runtime owner in caller view (U4)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinjing
2026-07-05 15:48:15 -07:00
co-authored by Orca
parent 96ffeee250
commit e9d63291fe
2 changed files with 17 additions and 2 deletions
@@ -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<NativeChatContextMenuActions, 'onPaste'>
}): 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.
@@ -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 {