From 506d375de33d6aaa210b73b64ab0a200aeba6f55 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 26 Aug 2026 19:44:57 -0700 Subject: [PATCH] fix(native-chat): refuse structured chat on every Windows execution path canUseStructuredNativeChat only refused win32 when a project runtime resolved, so folder-workspace keys (and other keys with no project runtime) failed open into structured chat on Windows. Fail closed on win32 unconditionally after the host check, matching the settings copy: local macOS/Linux only; Windows/WSL/SSH stay on terminal chat. --- ...tructured-native-chat-availability.test.ts | 19 +++++++++++++++++++ .../structured-native-chat-availability.ts | 15 +++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/lib/structured-native-chat-availability.test.ts b/src/renderer/src/lib/structured-native-chat-availability.test.ts index 5924a773cc4..9e31bea2669 100644 --- a/src/renderer/src/lib/structured-native-chat-availability.test.ts +++ b/src/renderer/src/lib/structured-native-chat-availability.test.ts @@ -82,4 +82,23 @@ describe('canUseStructuredNativeChat', () => { false ) }) + + it('refuses a Windows folder workspace even though its key resolves no project runtime', () => { + mockGetRendererAppPlatform.mockReturnValue('win32') + const state = { + ...stateFor({}), + activeRepoId: null, + activeWorktreeId: null + } as unknown as AppState + expect(canUseStructuredNativeChat(state, 'folder:folder-1')).toBe(false) + }) + + it('allows a folder workspace on a non-Windows platform', () => { + const state = { + ...stateFor({}), + activeRepoId: null, + activeWorktreeId: null + } as unknown as AppState + expect(canUseStructuredNativeChat(state, 'folder:folder-1')).toBe(true) + }) }) diff --git a/src/renderer/src/lib/structured-native-chat-availability.ts b/src/renderer/src/lib/structured-native-chat-availability.ts index 1eb132eeda2..28df6ad0c40 100644 --- a/src/renderer/src/lib/structured-native-chat-availability.ts +++ b/src/renderer/src/lib/structured-native-chat-availability.ts @@ -1,5 +1,4 @@ import type { AppState } from '@/store/types' -import { getLocalProjectExecutionRuntimeContext } from '@/lib/local-preflight-context' import { getExecutionHostIdForWorktree } from '@/lib/worktree-runtime-owner' import { getRendererAppPlatform } from '@/lib/renderer-app-platform' @@ -10,13 +9,9 @@ export function canUseStructuredNativeChat(state: AppState, worktreeId: string): if (getExecutionHostIdForWorktree(state, worktreeId) !== 'local') { return false } - const projectRuntime = getLocalProjectExecutionRuntimeContext(state, worktreeId) - return !( - projectRuntime?.status === 'repair-required' || - projectRuntime?.runtime.kind === 'wsl' || - // The shipped Windows process-tree addon may not expose creation time. Until - // the host advertises that proof, keep this experimental surface on the - // ordinary terminal path instead of letting create fail after the click. - (getRendererAppPlatform() === 'win32' && projectRuntime?.runtime.kind === 'windows-host') - ) + // The shipped Windows process-tree addon may not expose creation time. Until + // the host advertises that proof, refuse every local Windows execution path — + // windows-host, WSL, and keys that resolve no project runtime (folder + // workspaces, floating terminal) — so create cannot fail after the click. + return getRendererAppPlatform() !== 'win32' }