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.
This commit is contained in:
Brennan Benson
2026-08-26 19:44:57 -07:00
parent d4a7202996
commit 506d375de3
2 changed files with 24 additions and 10 deletions
@@ -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)
})
})
@@ -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'
}