diff --git a/src/main/text-generation/source-control-local-generation.ts b/src/main/text-generation/source-control-local-generation.ts index 0d3e354c8e3..fa6dcc0d5c4 100644 --- a/src/main/text-generation/source-control-local-generation.ts +++ b/src/main/text-generation/source-control-local-generation.ts @@ -33,7 +33,9 @@ export function runLocalPlanForAgent(input: { }): Promise { const needsPolicy = ['codex', 'kimi', 'dsh', 'antigravity', 'amp', 'muse'].includes(input.agentId) const wslDistro = - wslDistroForCommand(input.target.cwd, input.target.wslDistro) ?? input.target.wslDistro + input.plan.promptFile || input.plan.taskFiles?.length || needsPolicy + ? (wslDistroForCommand(input.target.cwd, input.target.wslDistro) ?? undefined) + : input.target.wslDistro const target = { ...input.target, wslDistro, diff --git a/src/main/text-generation/source-control-wsl-policy.test.ts b/src/main/text-generation/source-control-wsl-policy.test.ts index 2df892052ee..d06cae661b5 100644 --- a/src/main/text-generation/source-control-wsl-policy.test.ts +++ b/src/main/text-generation/source-control-wsl-policy.test.ts @@ -140,6 +140,30 @@ it('launches a non-policy agent in the resolved cwd while cancel still targets t child.emit('close', 0) }) +it('keeps a Windows-host generation in a WSL-share workspace on the selected host', async () => { + const cwd = '\\\\wsl.localhost\\Ubuntu\\home\\repo' + const child = createMockDiscoveryChild() + child.stdin.end.mockImplementation(() => + queueMicrotask(() => { + child.stdout.emit('data', Buffer.from('Keep the selected Windows host\n')) + child.emit('close', 0) + }) + ) + await expect( + runLocalPlanForAgent({ + agentId: 'claude', + plan: planned('claude'), + target: { kind: 'local', cwd }, + operation: 'commit-message', + spawnAgent: (input) => { + expect(input.cwd).toBe(cwd) + expect(input.wslDistro).toBeUndefined() + return child + } + }) + ).resolves.toMatchObject({ success: true, rawOutput: 'Keep the selected Windows host' }) +}) + it('uses the resolved project for Antigravity policy discovery and the resulting generation', async () => { runWsl.mockResolvedValue(output('/c/repo\n')) const child = createMockDiscoveryChild()