* Support WSL Codex settings promotion and harden config write-back - Enable settings promotion for WSL runtimes using per-distro baselines. - Create parent directories if missing to prevent promotion ENOENTs. - Keep restrictive permissions (0600) and follow symlinks on promote. - Respect CRLF line endings when inserting keys into CRLF config files. - Skip redundant baseline file writes when settings are unchanged. - Include the release scan report for the 1.4.131-rc2 prep. * Refactor sleeping agent wake flow and fetch rate limits via backend - Background-mount only targeted terminal tabs during passive wake to prevent spawning unnecessary PTYs for unvisited tabs. - Latch edge-triggered wake requests that arrive mid-hibernation and track active claims to prevent double-resuming a provider session. - Query the ChatGPT wham usage backend API directly with fetch for rate limits, avoiding launching Codex or WSL login shells. - Asynchronously probe and serialize WSL auth files with timeouts to prevent synchronous I/O from stalling Electron's main process. - Fix config promotion edge cases such as missing parent directories, dangling symlinks, and atomic write permission widening. * Support WSL dotfile-symlink write-back and lengthen redeem timeout - Preserve symlinked Codex config on WSL by writing through the existing file instead of atomic-rename, since \\wsl$ symlink metadata isn't reliably detected and rename would clobber the link. - Tighten new ~/.codex directory creation to 0700 (holds auth.json). - Give explicit reset-credit redemption a 30s backend timeout instead of the 10s background-poll default, since it's user-triggered. - Read sleeping-agent session state from the worktree's actual execution-host partition instead of always the local one, so the headless-wake check works correctly for SSH-hosted worktrees. - Isolate serve-sim watcher tests from the real $TMPDIR/serve-sim state file to avoid leaking unrelated events.
94 lines
4.0 KiB
TypeScript
94 lines
4.0 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const source = readFileSync(
|
|
new URL('../../app/h/[hostId]/session/[worktreeId].tsx', import.meta.url),
|
|
'utf8'
|
|
)
|
|
|
|
function sliceBetween(startPattern: string, endPattern: string): string {
|
|
const start = source.indexOf(startPattern)
|
|
expect(start).toBeGreaterThanOrEqual(0)
|
|
const end = source.indexOf(endPattern, start)
|
|
expect(end).toBeGreaterThan(start)
|
|
return source.slice(start, end)
|
|
}
|
|
|
|
describe('mobile session startup', () => {
|
|
it('auto-creates one terminal for an initially empty connected session', () => {
|
|
expect(source).toContain('const initialEmptySessionAutoCreateRef = useRef<string | null>(null)')
|
|
expect(source).toContain('initialEmptySessionAutoCreateRef.current = null')
|
|
|
|
const autoCreateEffect = sliceBetween(
|
|
'if (\n !client ||\n !showEmptyState',
|
|
'const terminalSummary ='
|
|
)
|
|
expect(autoCreateEffect).toContain('initialEmptySessionAutoCreateRef.current === worktreeId')
|
|
expect(autoCreateEffect).toContain('initialEmptySessionAutoCreateRef.current = worktreeId')
|
|
expect(autoCreateEffect).toContain("setCreateError('')")
|
|
expect(autoCreateEffect).toContain('void handleCreateTerminal()')
|
|
})
|
|
|
|
it('loads session tabs without waiting for desktop activation', () => {
|
|
const startupEffect = sliceBetween(
|
|
'void (async () => {',
|
|
'return () => {\n disposed = true'
|
|
)
|
|
|
|
expect(startupEffect).toContain("void client\n .sendRequest('worktree.activate'")
|
|
expect(startupEffect).toContain('notifyClients: false')
|
|
expect(startupEffect).not.toContain("await client\n .sendRequest('worktree.activate'")
|
|
expect(startupEffect.indexOf("sendRequest('worktree.activate'")).toBeLessThan(
|
|
startupEffect.indexOf('await fetchSessionTabs()')
|
|
)
|
|
expect(startupEffect).toContain('headlessActivationNeedsHostRenderer(response.result)')
|
|
expect(startupEffect).toContain("showToast('Open Orca on the host to wake sleeping agents.'")
|
|
})
|
|
|
|
it('activates an already-selected pending terminal tab after hydration', () => {
|
|
expect(source).toContain(
|
|
'const pendingTerminalActivationAttemptRef = useRef<string | null>(null)'
|
|
)
|
|
expect(source).toContain('pendingTerminalActivationAttemptRef.current = null')
|
|
|
|
const pendingActivationEffect = sliceBetween(
|
|
"if (!client || connState !== 'connected' || !activePendingTerminalTab) {",
|
|
'const showLoadingState ='
|
|
)
|
|
expect(pendingActivationEffect).toContain(
|
|
'pendingTerminalActivationAttemptRef.current === activationKey'
|
|
)
|
|
expect(pendingActivationEffect).toContain("sendRequest('session.tabs.activate'")
|
|
expect(pendingActivationEffect).toContain('tabId: activePendingTerminalTab.id')
|
|
expect(pendingActivationEffect).toContain('leafId: activePendingTerminalTab.leafId')
|
|
expect(pendingActivationEffect).toContain('notifyClients: false')
|
|
expect(pendingActivationEffect).toContain(
|
|
'applySessionTabs((response as RpcSuccess).result as SessionTabsResult)'
|
|
)
|
|
expect(pendingActivationEffect).toContain('scheduleDelayedAction(() => void fetchSessionTabs()')
|
|
})
|
|
|
|
it('keeps mobile session tab activation local to the phone', () => {
|
|
const activationRequests = source.split("sendRequest('session.tabs.activate'").slice(1)
|
|
|
|
expect(activationRequests).toHaveLength(4)
|
|
for (const request of activationRequests) {
|
|
expect(request.slice(0, request.indexOf('})'))).toContain('notifyClients: false')
|
|
}
|
|
})
|
|
|
|
it('keeps dynamic agent rows above fixed New Tab actions', () => {
|
|
const newTabActions = sliceBetween('title="New Tab"', 'onClose={() => setShowCreateTabDrawer')
|
|
|
|
expect(newTabActions.indexOf('...createTabAgentActions')).toBeLessThan(
|
|
newTabActions.indexOf("label: 'Terminal'")
|
|
)
|
|
expect(newTabActions.indexOf("label: 'Terminal'")).toBeLessThan(
|
|
newTabActions.indexOf("label: 'Browser'")
|
|
)
|
|
expect(newTabActions.indexOf("label: 'Browser'")).toBeLessThan(
|
|
newTabActions.indexOf("label: 'Markdown Note'")
|
|
)
|
|
})
|
|
})
|