From bbbe81be93cfb50cb93606a8b19d9bf74da76de6 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:51:05 -0700 Subject: [PATCH] refactor: colocate native-chat agent support (#36816) --- config/scripts/ci-shard-timings.json | 2 +- mobile/src/session/MobileNativeChatOverlay.tsx | 2 +- .../native-chat/input/use-mobile-native-chat-answer-send.ts | 2 +- .../native-chat/input/use-mobile-native-chat-cancel-ask.ts | 2 +- mobile/src/session/use-mobile-native-chat-stop.ts | 2 +- .../agent-session-journal/journal-legacy-identity.ts | 2 +- .../agent-session-journal/journal-legacy-import.ts | 2 +- src/main/native-chat/session-file-resolver.ts | 2 +- src/main/native-chat/transcript-read-cache.ts | 2 +- src/main/native-chat/transcript-reader.ts | 2 +- src/main/native-chat/transcript-tail-reader.ts | 2 +- src/main/native-chat/transcript-turn-lifecycle.ts | 2 +- src/main/native-chat/transcript-watch.ts | 2 +- src/main/runtime/orchestration/worker-transcript-read.ts | 2 +- src/main/runtime/rpc/methods/native-chat.ts | 2 +- .../src/components/native-chat/NativeChatResolvedView.tsx | 2 +- .../components/native-chat/native-chat-pane-resolution.ts | 2 +- .../native-chat/use-native-chat-interactive-send.ts | 2 +- src/renderer/src/lib/agent-launch-prompt-delivery.ts | 2 +- src/renderer/src/lib/native-chat-supported-agent.ts | 5 ----- src/shared/agent-pending-prompt.ts | 2 +- src/shared/native-chat-approval-envelope.ts | 2 +- src/shared/native-chat-availability.ts | 2 +- .../{ => native-chat}/native-chat-agent-support.test.ts | 0 src/shared/{ => native-chat}/native-chat-agent-support.ts | 2 +- 25 files changed, 23 insertions(+), 28 deletions(-) delete mode 100644 src/renderer/src/lib/native-chat-supported-agent.ts rename src/shared/{ => native-chat}/native-chat-agent-support.test.ts (100%) rename src/shared/{ => native-chat}/native-chat-agent-support.ts (98%) diff --git a/config/scripts/ci-shard-timings.json b/config/scripts/ci-shard-timings.json index 1219642cee1..936153507bb 100644 --- a/config/scripts/ci-shard-timings.json +++ b/config/scripts/ci-shard-timings.json @@ -11866,7 +11866,7 @@ "src/shared/muse-session-log.test.ts": 43, "src/shared/native-chat/transcript/native-chat-activity-tail-line.test.ts": 141, "src/shared/native-chat-agent-profiles.test.ts": 37, - "src/shared/native-chat-agent-support.test.ts": 38, + "src/shared/native-chat/native-chat-agent-support.test.ts": 38, "src/shared/native-chat/native-chat-appearance-settings.test.ts": 34, "src/shared/native-chat-approval-envelope.test.ts": 49, "src/shared/native-chat/input/native-chat-ask.test.ts": 95, diff --git a/mobile/src/session/MobileNativeChatOverlay.tsx b/mobile/src/session/MobileNativeChatOverlay.tsx index 6557a78902e..6b0785615e8 100644 --- a/mobile/src/session/MobileNativeChatOverlay.tsx +++ b/mobile/src/session/MobileNativeChatOverlay.tsx @@ -16,7 +16,7 @@ import { useMobileNativeChatReplyReveals } from './native-chat/transcript/mobile-native-chat-reply-reveals' import { MobileNativeChatRowOverlaysHost } from './native-chat/transcript/MobileNativeChatRowOverlaysHost' -import { nativeChatAskRequiresTerminal } from '../../../src/shared/native-chat-agent-support' +import { nativeChatAskRequiresTerminal } from '../../../src/shared/native-chat/native-chat-agent-support' import { tuiAgentDisplayName } from '../../../src/shared/tui-agent-display-names' import { MobileNativeChatNoticeContext } from './mobile-native-chat-notice-context' import type { MobileNativeChatImageSource } from './native-chat/visual/mobile-native-chat-image-preview' diff --git a/mobile/src/session/native-chat/input/use-mobile-native-chat-answer-send.ts b/mobile/src/session/native-chat/input/use-mobile-native-chat-answer-send.ts index 22f9888aa8b..380eb679126 100644 --- a/mobile/src/session/native-chat/input/use-mobile-native-chat-answer-send.ts +++ b/mobile/src/session/native-chat/input/use-mobile-native-chat-answer-send.ts @@ -22,7 +22,7 @@ import { nativeChatAskRequiresTerminal, resolveNativeChatTranscriptAgent, shouldStepNativeChatAskAnswer -} from '../../../../../src/shared/native-chat-agent-support' +} from '../../../../../src/shared/native-chat/native-chat-agent-support' import { buildNativeChatPasteBytes } from '../../../../../src/shared/native-chat-paste-bytes' export type MobileNativeChatAnswerSend = { diff --git a/mobile/src/session/native-chat/input/use-mobile-native-chat-cancel-ask.ts b/mobile/src/session/native-chat/input/use-mobile-native-chat-cancel-ask.ts index fe67b39947f..d0b28e00aec 100644 --- a/mobile/src/session/native-chat/input/use-mobile-native-chat-cancel-ask.ts +++ b/mobile/src/session/native-chat/input/use-mobile-native-chat-cancel-ask.ts @@ -1,5 +1,5 @@ import { useCallback, type MutableRefObject } from 'react' -import { nativeChatAskRequiresTerminal } from '../../../../../src/shared/native-chat-agent-support' +import { nativeChatAskRequiresTerminal } from '../../../../../src/shared/native-chat/native-chat-agent-support' import type { RpcClient } from '../../../transport/rpc-client' import { sendMobileNativeChatMessageWithOutcome } from '../mobile-native-chat-send' diff --git a/mobile/src/session/use-mobile-native-chat-stop.ts b/mobile/src/session/use-mobile-native-chat-stop.ts index ccb5822a4ae..a34c9b7ffb2 100644 --- a/mobile/src/session/use-mobile-native-chat-stop.ts +++ b/mobile/src/session/use-mobile-native-chat-stop.ts @@ -5,7 +5,7 @@ import { isRpcDeliveryUnknown } from '../transport/rpc-delivery-ambiguity' import { isLogicalClientCutoverError } from '../transport/stable-logical-rpc-client' import { nativeChatTerminalWrite } from './mobile-session-write-operations' import { openMobileNativeChatSendBudget } from './native-chat/mobile-native-chat-send' -import { nativeChatStopSendsSecondEscape } from '../../../src/shared/native-chat-agent-support' +import { nativeChatStopSendsSecondEscape } from '../../../src/shared/native-chat/native-chat-agent-support' import { NATIVE_CHAT_QUESTION_STEP_MS } from '../../../src/shared/native-chat/input/native-chat-answer-stepping' // Resolves false only when no Escape could have landed, so the chat may offer Stop again. diff --git a/src/main/native-chat/agent-session-journal/journal-legacy-identity.ts b/src/main/native-chat/agent-session-journal/journal-legacy-identity.ts index dde94044870..bc80056edef 100644 --- a/src/main/native-chat/agent-session-journal/journal-legacy-identity.ts +++ b/src/main/native-chat/agent-session-journal/journal-legacy-identity.ts @@ -3,7 +3,7 @@ import type { AgentType } from '../../../shared/agent-status-types' import type { AgentJournalItemIdentity } from '../../../shared/agent-session-journal-types' -import type { NativeChatTranscriptAgent } from '../../../shared/native-chat-agent-support' +import type { NativeChatTranscriptAgent } from '../../../shared/native-chat/native-chat-agent-support' export type LegacyIdentityTracker = { /** Observe every raw line, including discarded ones, to keep decoder identities aligned. */ diff --git a/src/main/native-chat/agent-session-journal/journal-legacy-import.ts b/src/main/native-chat/agent-session-journal/journal-legacy-import.ts index 88805af9b95..f43e6c4cfd1 100644 --- a/src/main/native-chat/agent-session-journal/journal-legacy-import.ts +++ b/src/main/native-chat/agent-session-journal/journal-legacy-import.ts @@ -12,7 +12,7 @@ import type { AgentJournalItemIdentity } from '../../../shared/agent-session-journal-types' import type { NativeChatBlock, NativeChatMessage } from '../../../shared/native-chat-types' -import { resolveNativeChatTranscriptAgent } from '../../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../../shared/native-chat/native-chat-agent-support' import { resolveSessionFilePath, type ResolveSessionFileOptions } from '../session-file-resolver' import { decodeClaudeTranscriptLine, diff --git a/src/main/native-chat/session-file-resolver.ts b/src/main/native-chat/session-file-resolver.ts index 5b524beadb5..58c8d924511 100644 --- a/src/main/native-chat/session-file-resolver.ts +++ b/src/main/native-chat/session-file-resolver.ts @@ -5,7 +5,7 @@ import type { AgentType } from '../../shared/native-chat-types' import { resolveNativeChatTranscriptAgent, type NativeChatTranscriptAgent -} from '../../shared/native-chat-agent-support' +} from '../../shared/native-chat/native-chat-agent-support' import { isWslUncPath } from '../../shared/wsl-paths' import { walkSessionFiles } from '../ai-vault/session-scanner-discovery' import { resolveOmpSessionsDir } from '../ai-vault/omp-session-root' diff --git a/src/main/native-chat/transcript-read-cache.ts b/src/main/native-chat/transcript-read-cache.ts index 2d6be8f5e96..35bb2e98e6c 100644 --- a/src/main/native-chat/transcript-read-cache.ts +++ b/src/main/native-chat/transcript-read-cache.ts @@ -1,4 +1,4 @@ -import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat/native-chat-agent-support' import { readOpenCodeNativeChatTranscriptFull } from './transcript-opencode' import type { AgentType } from '../../shared/native-chat-types' import { InFlightPromiseDedupe, stableInFlightKey } from '../../shared/in-flight-promise-dedupe' diff --git a/src/main/native-chat/transcript-reader.ts b/src/main/native-chat/transcript-reader.ts index b27c1f543ef..3969497ffb0 100644 --- a/src/main/native-chat/transcript-reader.ts +++ b/src/main/native-chat/transcript-reader.ts @@ -5,7 +5,7 @@ import type { NativeChatMessage, NativeChatTurnLifecycle } from '../../shared/native-chat-types' -import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat/native-chat-agent-support' import { errorMessage } from '../ai-vault/session-scanner-values' import { resolveSessionFilePath, type ResolveSessionFileOptions } from './session-file-resolver' import { openTranscriptReadStream } from './wsl-transcript-fs-access' diff --git a/src/main/native-chat/transcript-tail-reader.ts b/src/main/native-chat/transcript-tail-reader.ts index 0535049ae8d..b43f5b6841e 100644 --- a/src/main/native-chat/transcript-tail-reader.ts +++ b/src/main/native-chat/transcript-tail-reader.ts @@ -5,7 +5,7 @@ import type { NativeChatMessage, NativeChatTurnLifecycle } from '../../shared/native-chat-types' -import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat/native-chat-agent-support' import { resolveSessionFilePath, type ResolveSessionFileOptions } from './session-file-resolver' import { decodeClaudeTranscriptLine, diff --git a/src/main/native-chat/transcript-turn-lifecycle.ts b/src/main/native-chat/transcript-turn-lifecycle.ts index 7082b4efb2a..2ec312efc63 100644 --- a/src/main/native-chat/transcript-turn-lifecycle.ts +++ b/src/main/native-chat/transcript-turn-lifecycle.ts @@ -1,5 +1,5 @@ import type { AgentType, NativeChatTurnLifecycle } from '../../shared/native-chat-types' -import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat/native-chat-agent-support' import { isNoiseMessage } from '../../shared/native-chat-noise' import { claudeBashInputAsTypedCommand } from '../../shared/claude-bash-input' import { diff --git a/src/main/native-chat/transcript-watch.ts b/src/main/native-chat/transcript-watch.ts index 77ebbc0bba4..16ac68da9c6 100644 --- a/src/main/native-chat/transcript-watch.ts +++ b/src/main/native-chat/transcript-watch.ts @@ -1,6 +1,6 @@ import { UNFLUSHED_SETTLE_MS } from './transcript-watch-contract' import { subscribeOpenCodeNativeChatTranscript } from './transcript-opencode-subscribe' -import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../shared/native-chat/native-chat-agent-support' import { extname } from 'node:path' import type { NativeChatMessage } from '../../shared/native-chat-types' import { diff --git a/src/main/runtime/orchestration/worker-transcript-read.ts b/src/main/runtime/orchestration/worker-transcript-read.ts index 3272281bad8..d046fa59946 100644 --- a/src/main/runtime/orchestration/worker-transcript-read.ts +++ b/src/main/runtime/orchestration/worker-transcript-read.ts @@ -1,5 +1,5 @@ import type { AgentType, NativeChatMessage } from '../../../shared/native-chat-types' -import { resolveNativeChatTranscriptAgent } from '../../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../../shared/native-chat/native-chat-agent-support' import type { OrchestrationWorkerReadFallbackReason } from '../../../shared/orchestration-worker-output' import { resolveSessionFilePath } from '../../native-chat/session-file-resolver' import { nativeChatLineDecoderForAgent } from '../../native-chat/transcript-tail-reader' diff --git a/src/main/runtime/rpc/methods/native-chat.ts b/src/main/runtime/rpc/methods/native-chat.ts index 374518f0945..e6f9e8275fe 100644 --- a/src/main/runtime/rpc/methods/native-chat.ts +++ b/src/main/runtime/rpc/methods/native-chat.ts @@ -1,5 +1,5 @@ import type { NativeChatMessage } from '../../../../shared/native-chat-types' -import { resolveNativeChatTranscriptAgent } from '../../../../shared/native-chat-agent-support' +import { resolveNativeChatTranscriptAgent } from '../../../../shared/native-chat/native-chat-agent-support' import { readNativeChatTranscriptTail, subscribeNativeChatTranscript, diff --git a/src/renderer/src/components/native-chat/NativeChatResolvedView.tsx b/src/renderer/src/components/native-chat/NativeChatResolvedView.tsx index 086b8fd1de2..19b70ea6604 100644 --- a/src/renderer/src/components/native-chat/NativeChatResolvedView.tsx +++ b/src/renderer/src/components/native-chat/NativeChatResolvedView.tsx @@ -19,7 +19,7 @@ import { useNativeChatFind } from './use-native-chat-find' import { NativeChatFindBar } from './NativeChatFindBar' import { useNativeChatCanSend } from './use-native-chat-can-send' import { NativeChatInteractiveCard } from './NativeChatInteractiveCard' -import { nativeChatAskRequiresTerminal } from '../../../../shared/native-chat-agent-support' +import { nativeChatAskRequiresTerminal } from '../../../../shared/native-chat/native-chat-agent-support' import { useNativeChatTerminalPromptCard } from './use-native-chat-interactive-prompt-card' import { NativeChatPromptStrip } from './NativeChatPromptCollapse' import { NativeChatEmptyState } from './NativeChatEmptyState' diff --git a/src/renderer/src/components/native-chat/native-chat-pane-resolution.ts b/src/renderer/src/components/native-chat/native-chat-pane-resolution.ts index cedecf82c0b..c201b650abb 100644 --- a/src/renderer/src/components/native-chat/native-chat-pane-resolution.ts +++ b/src/renderer/src/components/native-chat/native-chat-pane-resolution.ts @@ -1,6 +1,6 @@ import type { AgentStatusEntry, AgentType } from '../../../../shared/agent-status-types' import type { TuiAgent } from '../../../../shared/tui-agent' -import { isNativeChatSupportedAgent } from '../../../../shared/native-chat-agent-support' +import { isNativeChatSupportedAgent } from '../../../../shared/native-chat/native-chat-agent-support' import { nativeChatAvailabilityAgent } from '../../../../shared/native-chat-availability' export type NativeChatPaneResolutionInput = { diff --git a/src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts b/src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts index 843091d67bc..c3cb63c4526 100644 --- a/src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts +++ b/src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts @@ -8,7 +8,7 @@ import { nativeChatStopSendsSecondEscape, resolveNativeChatTranscriptAgent, shouldStepNativeChatAskAnswer -} from '../../../../shared/native-chat-agent-support' +} from '../../../../shared/native-chat/native-chat-agent-support' import { buildAskAnswerKeys, buildCodexAskAnswerKeys, diff --git a/src/renderer/src/lib/agent-launch-prompt-delivery.ts b/src/renderer/src/lib/agent-launch-prompt-delivery.ts index 235e5d8fe95..fe85d7d712a 100644 --- a/src/renderer/src/lib/agent-launch-prompt-delivery.ts +++ b/src/renderer/src/lib/agent-launch-prompt-delivery.ts @@ -1,7 +1,7 @@ import { agentDeliversDraftViaNativePrefill } from '@/lib/agent-native-draft-prefill' import { pasteDraftWhenAgentReady } from '@/lib/agent-paste-draft' import { canMirrorLaunchDraftToNativeChat } from '../../../shared/native-chat/input/native-chat-launch-draft-mirrorability' -import { isNativeChatSupportedAgent } from '@/lib/native-chat-supported-agent' +import { isNativeChatSupportedAgent } from '../../../shared/native-chat/native-chat-agent-support' import { useAppStore } from '@/store' import type { TuiAgent } from '../../../shared/tui-agent' diff --git a/src/renderer/src/lib/native-chat-supported-agent.ts b/src/renderer/src/lib/native-chat-supported-agent.ts deleted file mode 100644 index 25bac3427ad..00000000000 --- a/src/renderer/src/lib/native-chat-supported-agent.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { - isNativeChatSupportedAgent, - nativeChatRequiresLocalTranscript, - NATIVE_CHAT_SUPPORTED_AGENTS -} from '../../../shared/native-chat-agent-support' diff --git a/src/shared/agent-pending-prompt.ts b/src/shared/agent-pending-prompt.ts index 2be6cf24829..2f248f93cb2 100644 --- a/src/shared/agent-pending-prompt.ts +++ b/src/shared/agent-pending-prompt.ts @@ -6,7 +6,7 @@ import { parseNativeChatApprovalEnvelope } from './native-chat-approval-envelope import { resolveNativeChatTranscriptAgent, shouldStepNativeChatAskAnswer -} from './native-chat-agent-support' +} from './native-chat/native-chat-agent-support' export type PendingPromptOption = { id: string; label: string; description?: string } diff --git a/src/shared/native-chat-approval-envelope.ts b/src/shared/native-chat-approval-envelope.ts index 4d1de7d968b..464046b9136 100644 --- a/src/shared/native-chat-approval-envelope.ts +++ b/src/shared/native-chat-approval-envelope.ts @@ -1,4 +1,4 @@ -import { nativeChatApprovalAcceptKey } from './native-chat-agent-support' +import { nativeChatApprovalAcceptKey } from './native-chat/native-chat-agent-support' /** The facts in a status row's `{ approval: { tool, summary } }` envelope; callers own labels. */ export type NativeChatApprovalEnvelope = { diff --git a/src/shared/native-chat-availability.ts b/src/shared/native-chat-availability.ts index e65e88bc710..57dce73306e 100644 --- a/src/shared/native-chat-availability.ts +++ b/src/shared/native-chat-availability.ts @@ -4,7 +4,7 @@ import type { AgentType } from './agent-status-types' import { isNativeChatSupportedAgent, nativeChatRequiresLocalTranscript -} from './native-chat-agent-support' +} from './native-chat/native-chat-agent-support' /** Resolve launched/detected identity from the tab and status before applying this pure toggle policy. */ export type NativeChatAvailabilityInput = { diff --git a/src/shared/native-chat-agent-support.test.ts b/src/shared/native-chat/native-chat-agent-support.test.ts similarity index 100% rename from src/shared/native-chat-agent-support.test.ts rename to src/shared/native-chat/native-chat-agent-support.test.ts diff --git a/src/shared/native-chat-agent-support.ts b/src/shared/native-chat/native-chat-agent-support.ts similarity index 98% rename from src/shared/native-chat-agent-support.ts rename to src/shared/native-chat/native-chat-agent-support.ts index 7cc8fc2d369..4220a883a31 100644 --- a/src/shared/native-chat-agent-support.ts +++ b/src/shared/native-chat/native-chat-agent-support.ts @@ -1,4 +1,4 @@ -import type { TuiAgent } from './tui-agent' +import type { TuiAgent } from '../tui-agent' export type NativeChatTranscriptAgent = 'claude' | 'codex' | 'grok' | 'omp' | 'opencode'