Files
orca/src/shared/local-account-runtime.test.ts
T
OrcaWinandBrennan Benson 6444be3a01 fix(accounts): follow the runtime for WSL provider account detection (#9537) (#9611)
* fix(accounts): follow the runtime for WSL provider account detection (#9537)

On Windows + WSL, provider-account detection (usage recognition and the
status-bar account switcher) was pinned to the Windows host even when the
project runs in WSL, so WSL accounts were never recognized and the WSL
switcher group never appeared.

Root cause: `localAccountRuntime` hard-defaulted to 'host', which
short-circuited `getInitialClaude/CodexRateLimitTarget` before the existing
"follow the global Windows runtime default" branch could run. That branch was
therefore dead for every real user.

Fix: add an 'auto' value for `localAccountRuntime`, make it the default, and
migrate the untouched legacy 'host' default to 'auto' once (guarded by
`localAccountRuntimeDefaultedToAutoForAllUsers`; explicit 'wsl' is preserved).
'auto' resolves via a shared `resolveLocalAccountRuntimeTarget` helper: on a
windows-host default it stays host (no behavior change); on a WSL default it
follows WSL, so WSL accounts are recognized and the WSL group appears.

Wired the shared resolver into the managed-account default target, the
status-bar WSL-group gate, and the Accounts settings location toggle.

Note: detection follows the global Windows runtime default, not the live
active project's runtime (the fetch target is a single global value); the
latter is a larger follow-up.

* fix(accounts): align auto runtime consumers

* fix(accounts): keep runtime polling aligned with settings

---------

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
2026-07-20 18:35:14 -07:00

67 lines
1.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { getDefaultSettings } from './constants'
import { resolveLocalAccountRuntimeTarget } from './local-account-runtime'
describe('resolveLocalAccountRuntimeTarget', () => {
it('honors an explicit host pin', () => {
expect(
resolveLocalAccountRuntimeTarget(
{ ...getDefaultSettings('/tmp'), localAccountRuntime: 'host' },
'win32'
)
).toEqual({ runtime: 'host', wslDistro: null })
})
it('honors an explicit WSL pin and its distro', () => {
expect(
resolveLocalAccountRuntimeTarget(
{
...getDefaultSettings('/tmp'),
localAccountRuntime: 'wsl',
localAccountWslDistro: 'Ubuntu'
},
'win32'
)
).toEqual({ runtime: 'wsl', wslDistro: 'Ubuntu' })
})
it('auto follows the global WSL project runtime default', () => {
expect(
resolveLocalAccountRuntimeTarget(
{
...getDefaultSettings('/tmp'),
localAccountRuntime: 'auto',
localWindowsRuntimeDefault: { kind: 'wsl', distro: 'Ubuntu' }
},
'win32'
)
).toEqual({ runtime: 'wsl', wslDistro: 'Ubuntu' })
})
it('auto resolves to host when the global project runtime is windows-host', () => {
expect(
resolveLocalAccountRuntimeTarget(
{
...getDefaultSettings('/tmp'),
localAccountRuntime: 'auto',
localWindowsRuntimeDefault: { kind: 'windows-host' }
},
'win32'
)
).toEqual({ runtime: 'host', wslDistro: null })
})
it('auto resolves to host on non-Windows platforms even with a WSL default', () => {
expect(
resolveLocalAccountRuntimeTarget(
{
...getDefaultSettings('/tmp'),
localAccountRuntime: 'auto',
localWindowsRuntimeDefault: { kind: 'wsl', distro: 'Ubuntu' }
},
'linux'
)
).toEqual({ runtime: 'host', wslDistro: null })
})
})