test(terminal-bash): cover the spawn signal forwarded into the pwsh bootstrap send

This commit is contained in:
Huanqi Cao committed 2026-08-13 10:54:23 +08:00
1 parent 13d859a619
commit 6e2a4fd08a
1 file changed
+33
@@ -432,6 +432,39 @@ describe('BashTerminalBackend startup rollback', () => {
const timedOut = new BashTerminalBackend(ctx, { ...config(), shellDialect: 'pwsh' }, async () => terminalHandle(), () => sessionFor('timeout'))
await expect(timedOut.spawn(spec(agent(ctx)))).rejects.toThrow('did not reach readiness before startup timeout')
})
it('forwards the spawn signal into the pwsh bootstrap sends', async () => {
const ctx = new Context()
await ctx.plugin(EmptySandbox)
await ctx.plugin(SandboxPolicyService, { mode: 'danger-full-access', workspaceRoot: '/workspace' })
const sends: TerminalSendRequest[] = []
const session = {
motd: '',
startSend: (request: TerminalSendRequest) => {
sends.push(request)
return {
done: Promise.resolve({
viewport: 'dsh> ', waitReason: 'stdin_read' as const,
sessionStatus: { kind: 'running' as const }, truncated: false,
}),
readOutput: () => ({ delta: '', truncated: false }),
cancel: () => false,
}
},
read: () => ({ text: '', totalLines: 0, lineBegin: 0, lineEnd: 0, truncated: false }),
} as unknown as LocalPtySession
const backend = new BashTerminalBackend(
ctx,
{ ...config(), shellDialect: 'pwsh', shellPath: 'pwsh' },
async () => terminalHandle(),
() => session,
)
const signal = new AbortController().signal
const spawned = await backend.spawn({ ...spec(agent(ctx)), signal })
expect(spawned.motd).toBe('dsh> ')
expect(sends).toHaveLength(1)
expect(sends[0]?.signal).toBe(signal)
})
})
describe('terminal-bash plugin shape', () => {