fix(wsl): keep the orcad idle window out of user shells; require the agent for discovered effort menus (#36492)

This commit is contained in:
Neil
2026-10-30 16:42:15 -07:00
committed by GitHub
parent cd481306e3
commit fba64aef1b
8 changed files with 21 additions and 9 deletions
@@ -130,7 +130,7 @@ describe('claude model catalog probe', () => {
expect(fastModeSupport).toEqual({ supported: true })
expect(models[0]?.supportsFastMode).toBe(true)
expect(
models[0] && discoveredModel(models[0], fastModeSupport?.supported === true).options
models[0] && discoveredModel(models[0], fastModeSupport?.supported === true, 'claude').options
).toContainEqual(expect.objectContaining({ id: 'fastMode' }))
expect(
models.map(({ id, isDefault, supportsAutoMode }) => ({ id, isDefault, supportsAutoMode }))
@@ -129,9 +129,11 @@ describe('createPtySubprocess', () => {
ORCA_WORKTREE_ID: process.env.ORCA_WORKTREE_ID,
ORCA_WSL_CLI_DIR: process.env.ORCA_WSL_CLI_DIR,
ORCA_ORCAD_MANAGED_ACTIVATION_ROOT: process.env.ORCA_ORCAD_MANAGED_ACTIVATION_ROOT,
ORCA_REMOTE_VIEWER_CLIPBOARD: process.env.ORCA_REMOTE_VIEWER_CLIPBOARD
ORCA_REMOTE_VIEWER_CLIPBOARD: process.env.ORCA_REMOTE_VIEWER_CLIPBOARD,
ORCA_ORCAD_IDLE_TIMEOUT_MS: process.env.ORCA_ORCAD_IDLE_TIMEOUT_MS
}
process.env.ORCA_ORCAD_MANAGED_ACTIVATION_ROOT = '/home/u/.orca-remote/.activation'
process.env.ORCA_ORCAD_IDLE_TIMEOUT_MS = '300000'
process.env.ORCA_REMOTE_VIEWER_CLIPBOARD = '1'
process.env.ORCA_PANE_KEY = 'parent-tab:parent-leaf'
process.env.ORCA_TAB_ID = 'parent-tab'
@@ -157,6 +159,7 @@ describe('createPtySubprocess', () => {
expect(env.ORCA_WSL_CLI_DIR).toBeUndefined()
expect(env.ORCA_ORCAD_MANAGED_ACTIVATION_ROOT).toBeUndefined()
expect(env.ORCA_REMOTE_VIEWER_CLIPBOARD).toBeUndefined()
expect(env.ORCA_ORCAD_IDLE_TIMEOUT_MS).toBeUndefined()
})
it('preserves explicit child Orca pane identity over parent env', async () => {
@@ -30,6 +30,7 @@ import type { TuiAgent } from '../../../shared/tui-agent'
import type { PtySubprocessOptions } from '../pty-subprocess'
import { ORCAD_MANAGED_ACTIVATION_ROOT_ENV } from '../../../shared/orcad-managed-launch-env'
import { REMOTE_VIEWER_CLIPBOARD_ENV } from '../../../shared/remote-viewer-clipboard-env'
import { ORCAD_IDLE_TIMEOUT_ENV } from '../../../shared/orcad-idle-exit'
const PANE_IDENTITY_ENV_KEYS = [
'ORCA_PANE_KEY',
@@ -42,7 +43,9 @@ const PANE_IDENTITY_ENV_KEYS = [
// Per-viewer: an Orca started from a remote viewer's pane must not mark its own local panes.
REMOTE_VIEWER_CLIPBOARD_ENV,
// A server's own launch marker; a user's `orcad` in this shell is not client-managed.
ORCAD_MANAGED_ACTIVATION_ROOT_ENV
ORCAD_MANAGED_ACTIVATION_ROOT_ENV,
// A WSL server's idle window; an `orcad` started from its shell must keep the default.
ORCAD_IDLE_TIMEOUT_ENV
] as const
const WINDOWS_PATH_ENV_KEY_RE = /^path$/i
@@ -6,6 +6,7 @@ import { expandWindowsEnvironmentVariables } from '../../shared/windows-environm
import { resolveSafePtyDefaultCwd } from './pty-default-cwd'
import { ORCAD_MANAGED_ACTIVATION_ROOT_ENV } from '../../shared/orcad-managed-launch-env'
import { REMOTE_VIEWER_CLIPBOARD_ENV } from '../../shared/remote-viewer-clipboard-env'
import { ORCAD_IDLE_TIMEOUT_ENV } from '../../shared/orcad-idle-exit'
const PANE_IDENTITY_ENV_KEYS = [
'ORCA_PANE_KEY',
@@ -16,7 +17,9 @@ const PANE_IDENTITY_ENV_KEYS = [
// Per-viewer: an Orca started from a remote viewer's pane must not mark its own local panes.
REMOTE_VIEWER_CLIPBOARD_ENV,
// A server's own launch marker; a user's `orcad` in this shell is not client-managed.
ORCAD_MANAGED_ACTIVATION_ROOT_ENV
ORCAD_MANAGED_ACTIVATION_ROOT_ENV,
// A WSL server's idle window; an `orcad` started from its shell must keep the default.
ORCAD_IDLE_TIMEOUT_ENV
] as const
export function getDefaultCwd(): string {
@@ -567,9 +567,11 @@ describe('LocalPtyProvider', () => {
ORCA_TAB_ID: process.env.ORCA_TAB_ID,
ORCA_WORKTREE_ID: process.env.ORCA_WORKTREE_ID,
ORCA_ORCAD_MANAGED_ACTIVATION_ROOT: process.env.ORCA_ORCAD_MANAGED_ACTIVATION_ROOT,
ORCA_REMOTE_VIEWER_CLIPBOARD: process.env.ORCA_REMOTE_VIEWER_CLIPBOARD
ORCA_REMOTE_VIEWER_CLIPBOARD: process.env.ORCA_REMOTE_VIEWER_CLIPBOARD,
ORCA_ORCAD_IDLE_TIMEOUT_MS: process.env.ORCA_ORCAD_IDLE_TIMEOUT_MS
}
process.env.ORCA_ORCAD_MANAGED_ACTIVATION_ROOT = '/home/u/.orca-remote/.activation'
process.env.ORCA_ORCAD_IDLE_TIMEOUT_MS = '300000'
process.env.ORCA_REMOTE_VIEWER_CLIPBOARD = '1'
process.env.ORCA_PANE_KEY = 'parent-tab:parent-leaf'
process.env.ORCA_TAB_ID = 'parent-tab'
@@ -593,6 +595,7 @@ describe('LocalPtyProvider', () => {
expect(spawnCall[2].env.ORCA_WORKTREE_ID).toBeUndefined()
expect(spawnCall[2].env.ORCA_ORCAD_MANAGED_ACTIVATION_ROOT).toBeUndefined()
expect(spawnCall[2].env.ORCA_REMOTE_VIEWER_CLIPBOARD).toBeUndefined()
expect(spawnCall[2].env.ORCA_ORCAD_IDLE_TIMEOUT_MS).toBeUndefined()
})
it('preserves explicit child Orca pane identity over parent env', async () => {
@@ -17,7 +17,7 @@ describe('unconfirmed effort menus', () => {
expect(discoveredModel(unconfirmed, false, 'pi').options).toEqual([])
})
it.each(['omp', 'claude', 'codex', undefined] as const)('still offers them for %s', (agent) => {
it.each(['omp', 'claude', 'codex'] as const)('still offers them for %s', (agent) => {
const [effort] = discoveredModel(unconfirmed, false, agent).options
expect(effort?.kind).toMatchObject({ type: 'select', choices: unconfirmed.efforts })
})
@@ -4,7 +4,7 @@ import type { AgentType } from './agent-status-types'
function effortOption(
model: AgentSessionOptionsResult['models'][number],
agent: AgentType | undefined
agent: AgentType
): CatalogOption | null {
// Pi menus are exact; other agents (OMP's recorded menus) still offer unconfirmed choices.
if ((agent === 'pi' && model.effortsKnown === false) || model.efforts.length === 0) {
@@ -52,7 +52,7 @@ export function serviceTierOption(tiers: readonly AgentSessionOptionChoice[]): C
export function discoveredModel(
model: AgentSessionOptionsResult['models'][number],
sessionSupportsFastMode: boolean,
agent?: AgentType
agent: AgentType
): CatalogModel {
const effort = effortOption(model, agent)
const serviceTier = model.serviceTiers?.length ? serviceTierOption(model.serviceTiers) : null
@@ -33,7 +33,7 @@ export {
export function structuredAgentSessionOptionCatalog(
seed: AgentSessionOptionCatalog,
result: AgentSessionOptionsResult,
agent?: StructuredAgentSessionOptionRecord['agent']
agent: StructuredAgentSessionOptionRecord['agent']
): AgentSessionOptionCatalog {
const models: CatalogModel[] = result.models.map((model) =>
discoveredModel(model, result.fastModeSupport?.supported === true, agent)