Files
orca/src/main/native-chat/transcript-tail-reader-wsl-gate.test.ts
T
Jinjing 7b326e212f Gate WSL transcript filesystem ops with timeout and capacity limits
Why: WSL filesystem access can stall when a distro hangs, and stalled
operations must degrade gracefully rather than misreport as "not found".

Distinguish gate refusals (timeout, capacity, unavailable) from actual
missing files so callers can retry or fall through to alternatives. Fail
fast when stuck I/O holds a permit to prevent caller pileup. Route-level
sequencing and waiter deadlines keep one stalled distro from blocking
others.
2026-08-12 13:09:08 -07:00

35 lines
1.1 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest'
const mocks = vi.hoisted(() => ({
resolve: vi.fn<() => Promise<string | null>>()
}))
vi.mock('./session-file-resolver', () => ({
resolveSessionFilePath: mocks.resolve
}))
import { readNativeChatTranscriptTail } from './transcript-tail-reader'
import { WslTranscriptFsError } from './wsl-transcript-fs-gate'
describe('native chat transcript tail under WSL gate refusals', () => {
beforeEach(() => {
mocks.resolve.mockReset()
})
it('reports a gate refusal as a retryable error, not a missing transcript', async () => {
mocks.resolve.mockRejectedValueOnce(new WslTranscriptFsError('timeout', 'slow share'))
await expect(
readNativeChatTranscriptTail({ agent: 'codex', sessionId: 'session-id', limit: 10 })
).resolves.toEqual({ error: 'slow share' })
})
it('rethrows non-gate resolver failures', async () => {
mocks.resolve.mockRejectedValueOnce(new Error('resolver crashed'))
await expect(
readNativeChatTranscriptTail({ agent: 'codex', sessionId: 'session-id', limit: 10 })
).rejects.toThrow('resolver crashed')
})
})