From 1d0bdb86c7f3ea6f0ce8521f0d4e1982fe3d4e24 Mon Sep 17 00:00:00 2001 From: Merge Sim Date: Fri, 11 Sep 2026 16:11:00 -0700 Subject: [PATCH] fix: preserve launch platform in structured fallback --- .../src/lib/launch-agent-in-new-tab.ts | 2 ++ ...launch-agent-structured-chat-guard.test.ts | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/renderer/src/lib/launch-agent-in-new-tab.ts b/src/renderer/src/lib/launch-agent-in-new-tab.ts index 90911c0c5d1..57385795ce1 100644 --- a/src/renderer/src/lib/launch-agent-in-new-tab.ts +++ b/src/renderer/src/lib/launch-agent-in-new-tab.ts @@ -84,6 +84,7 @@ function launchAgentInNewTabInternal(args: LaunchAgentInNewTabArgs): LaunchAgent promptDelivery = 'auto-submit', launchSource, quickCommandLabel, + launchPlatform, onPromptDelivered } = args const prepared = prepareAgentInNewTabLaunch(args) @@ -149,6 +150,7 @@ function launchAgentInNewTabInternal(args: LaunchAgentInNewTabArgs): LaunchAgent prompt: trimmedPrompt, promptDelivery: viewModePromptDelivery, tuiCustomization: { cwd: initialCwd, agentArgs }, + ...(launchPlatform ? { launchPlatform } : {}), initialSessionOptions: startupPlan.sessionOptions, onPromptDelivered, launchPlan: plan, diff --git a/src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts b/src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts index 8e02a949269..923d0274898 100644 --- a/src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts +++ b/src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts @@ -49,6 +49,7 @@ const store = { experimentalNativeChat: true, experimentalStructuredNativeChat: true, openAgentTabsInChatByDefault: true, + terminalWindowsShell: undefined as string | undefined, nativeChatSessionOptions: undefined as | Record< string, @@ -193,6 +194,7 @@ describe('structured chat adoption guard on the launch path', () => { mockToastError.mockReset() hostCapabilities = STRUCTURED_HOST_CAPABILITIES store.settings.openAgentTabsInChatByDefault = true + store.settings.terminalWindowsShell = undefined store.settings.nativeChatSessionOptions = undefined }) @@ -360,6 +362,34 @@ describe('structured chat adoption guard on the launch path', () => { expect(mockPasteDraftWhenAgentReady).not.toHaveBeenCalled() }) + it('preserves an explicit launch platform through terminal fallback', async () => { + const { StructuredAgentSessionCreateRefusalError } = + await import('./launch-structured-agent-session') + mockLaunchStructuredCodexSession.mockRejectedValueOnce( + new StructuredAgentSessionCreateRefusalError('provider unavailable') + ) + const { launchAgentInNewTab } = await import('./launch-agent-in-new-tab') + store.settings.terminalWindowsShell = 'cmd.exe' + + const result = launchAgentInNewTab({ + agent: 'codex', + worktreeId: 'wt-1', + prompt: 'start this task', + launchPlatform: 'win32' + }) + + await expect(result?.structuredSettlement).resolves.toMatchObject({ + kind: 'terminal', + viaRefusal: true + }) + expect(mockActivateAndRevealWorkspace).toHaveBeenCalledWith( + 'wt-1', + expect.objectContaining({ + startup: expect.objectContaining({ command: result?.startupPlan.launchCommand }) + }) + ) + }) + it('logs a fallback that throws and never re-enters the terminal launch', async () => { const { StructuredAgentSessionCreateRefusalError } = await import('./launch-structured-agent-session')