Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
fix(ai-vault): bound WSL session carryover to the most recent scopes (#36090)
Neil1e6b29a59cbc
diff --git a/src/main/ai-vault/ai-vault-wsl-session-carryover.test.ts b/src/main/ai-vault/ai-vault-wsl-session-carryover.test.tsnew file mode 100644index 00000000000..7213db10b73--- /dev/null+++ b/src/main/ai-vault/ai-vault-wsl-session-carryover.test.ts@@ -0,0 +1,98 @@+import { beforeEach, describe, expect, it } from 'vitest'+import type { AiVaultListResult, AiVaultSession } from '../../shared/ai-vault-types'+import {+ AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT,+ carryOverUnconfirmedWslSessions,+ resetAiVaultWslSessionCarryover+} from './ai-vault-wsl-session-carryover'++function wslSession(id: string): AiVaultSession {+ return {+ id,+ executionHostId: 'local',+ agent: 'codex',+ sessionId: id,+ title: id,+ cwd: null,+ branch: null,+ model: null,+ filePath: `\\\\wsl.localhost\\Ubuntu\\home\\me\\.codex\\sessions\\${id}.jsonl`,+ codexHome: null,+ createdAt: null,+ updatedAt: null,+ modifiedAt: '2026-10-29T00:00:00.000Z',+ messageCount: 1,+ totalTokens: 0,+ previewMessages: [],+ queuedMessageCount: 0,+ subagentTranscriptCount: 0,+ resumeCommand: '',+ subagent: null+ }+}++function listOf(sessions: AiVaultSession[]): AiVaultListResult {+ return { sessions, issues: [], scannedAt: '2026-10-29T00:00:00.000Z' }+}++const confirm = (scope: string, ids: string[]) =>+ carryOverUnconfirmedWslSessions(scope, listOf(ids.map(wslSession)), true)+const probeFailed = (scope: string) =>+ carryOverUnconfirmedWslSessions(scope, listOf([]), false).sessions.map((session) => session.id)++describe('AI Vault WSL session carryover retention', () => {+ beforeEach(() => resetAiVaultWslSessionCarryover())++ it('keeps the active scope through a transient WSL probe failure', () => {+ confirm('scope-a', ['a1', 'a2'])++ expect(probeFailed('scope-a')).toEqual(['a1', 'a2'])+ // Same-scope recovery: a later confirmed scan replaces the carried rows.+ confirm('scope-a', ['a3'])+ expect(probeFailed('scope-a')).toEqual(['a3'])+ })++ it('evicts the least recently used scope past the cap', () => {+ const scopes = Array.from(+ { length: AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT + 1 },+ (_, index) => `scope-${index}`+ )+ for (const scope of scopes) {+ confirm(scope, [`${scope}-row`])+ }++ expect(probeFailed('scope-0')).toEqual([])+ for (const scope of scopes.slice(1)) {+ expect(probeFailed(scope)).toEqual([`${scope}-row`])+ }+ })++ it('keeps the scope the user is on when others are visited after it', () => {+ confirm('active', ['row'])+ for (let index = 0; index < AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT - 1; index += 1) {+ confirm(`other-${index}`, ['x'])+ }+ // Back on the active scope, its probe fails: carrying it over marks it recent.+ expect(probeFailed('active')).toEqual(['row'])+ confirm('one-more', ['x'])++ expect(probeFailed('active')).toEqual(['row'])+ expect(probeFailed('other-0')).toEqual([])+ })++ it('spends no slot on a scope with no WSL rows', () => {+ confirm('wsl-scope', ['w'])+ for (let index = 0; index < AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT * 2; index += 1) {+ confirm(`host-only-${index}`, [])+ }++ expect(probeFailed('wsl-scope')).toEqual(['w'])+ })++ it('an explicit delete still clears every scope', () => {+ confirm('scope-a', ['a1'])+ resetAiVaultWslSessionCarryover()++ expect(probeFailed('scope-a')).toEqual([])+ })+})diff --git a/src/main/ai-vault/ai-vault-wsl-session-carryover.ts b/src/main/ai-vault/ai-vault-wsl-session-carryover.tsindex d578426fb55..ce350f4b5ff 100644--- a/src/main/ai-vault/ai-vault-wsl-session-carryover.ts+++ b/src/main/ai-vault/ai-vault-wsl-session-carryover.ts@@ -3,8 +3,27 @@ import { aiVaultScanIssueText } from '../../shared/ai-vault-scan-issue-copy'import { isWslUncPath } from '../../shared/wsl-paths'// The WSL rows of the last scan whose WSL roots a confirmed running list named, per scope key.+// Map order is recency: the oldest scope is evicted past the cap, so retired scopes don't pile up.const lastConfirmedWslSessions = new Map<string, AiVaultSession[]>()+/** Scopes kept: the active one plus a few recently switched away from, for switching back. */+export const AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT = 4++function rememberConfirmedWslSessions(scopeKey: string, sessions: AiVaultSession[]): void {+ lastConfirmedWslSessions.delete(scopeKey)+ // A confirmed scan with no WSL rows has nothing to carry; don't spend a slot on it.+ if (sessions.length === 0) {+ return+ }+ lastConfirmedWslSessions.set(scopeKey, sessions)+ for (const oldest of lastConfirmedWslSessions.keys()) {+ if (lastConfirmedWslSessions.size <= AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT) {+ break+ }+ lastConfirmedWslSessions.delete(oldest)+ }+}+const isWslSession = (session: AiVaultSession): boolean => isWslUncPath(session.filePath)/**@@ -17,13 +36,16 @@ export function carryOverUnconfirmedWslSessions(wslConfirmed: boolean): AiVaultListResult {if (wslConfirmed) {- lastConfirmedWslSessions.set(scopeKey, result.sessions.filter(isWslSession))+ rememberConfirmedWslSessions(scopeKey, result.sessions.filter(isWslSession))return result}+ const confirmed = lastConfirmedWslSessions.get(scopeKey)+ if (confirmed) {+ // Carrying a scope over is using it: keep the active scope ahead of retired ones.+ rememberConfirmedWslSessions(scopeKey, confirmed)+ }const present = new Set(result.sessions.map((session) => session.id))- const carried = (lastConfirmedWslSessions.get(scopeKey) ?? []).filter(- (session) => !present.has(session.id)- )+ const carried = (confirmed ?? []).filter((session) => !present.has(session.id))if (carried.length === 0) {return result}