From 478079cc98460effb8ced86b6882a260e5988c7e Mon Sep 17 00:00:00 2001 From: Turtle Date: Wed, 22 Jul 2026 13:13:04 +0800 Subject: [PATCH] test: close the merged branches' coverage gaps Cover the fs-provider load path without a cancellation signal, the app-level resumeCommand forwarding, and a command returning an error result. --- .../tests/workspace-context.spec.ts | 14 ++++++++++++++ packages/examples/tui-demo/tests/tui-agent.spec.ts | 8 +++++++- packages/ui/tui/tests/tui.spec.ts | 10 ++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/context/workspace-context/tests/workspace-context.spec.ts b/packages/context/workspace-context/tests/workspace-context.spec.ts index c02f1f5a45..620f8f6eee 100644 --- a/packages/context/workspace-context/tests/workspace-context.spec.ts +++ b/packages/context/workspace-context/tests/workspace-context.spec.ts @@ -383,6 +383,20 @@ describe('workspace context instruction discovery', () => { } }) + it('loads through a FileSystem provider without a cancellation signal', async () => { + // Direct-library callers may omit `signal`; the fs-backed probe must pass + // no options object rather than `{ signal: undefined }`. + const ctx = new Context() + await ctx.plugin(RecordingFileSystem) + const fs = ctx.fs as RecordingFileSystem + fs.entries.set('/repo/.git', { type: 'directory' }) + fs.entries.set('/repo/AGENTS.md', { type: 'file', content: 'signalless rule' }) + const rendered = await loadBaselineInstructions({ cwd: '/repo', maxBytes: 65536 }, fs) + expect(rendered?.text).toContain('signalless rule') + expect(fs.signals).toHaveLength(0) + await ctx.fiber.dispose() + }) + it('skips a file that becomes unreadable after discovery without failing the request', async () => { const root = await tempRepo() const home = await tempRepo() diff --git a/packages/examples/tui-demo/tests/tui-agent.spec.ts b/packages/examples/tui-demo/tests/tui-agent.spec.ts index d1cb0808a7..433eb5c0b7 100644 --- a/packages/examples/tui-demo/tests/tui-agent.spec.ts +++ b/packages/examples/tui-demo/tests/tui-agent.spec.ts @@ -33,6 +33,7 @@ describe('dsh-tui-demo app', () => { persistenceRoot: '/tmp/tui-sessions', persistenceCompression: 'none', welcome: 'TUI ready', + resumeCommand: 'dsh --resume {session}', ui: { color: false, maxToolOutputLines: 3 }, skills: { tool: { catalogDescriptionMaxLength: 8 } }, toolBash: { enableRunInBackground: false }, @@ -52,7 +53,12 @@ describe('dsh-tui-demo app', () => { expect(calls[0]?.config).toBeUndefined() expect(calls[2]?.config).toEqual({ root: '/tmp/tui-sessions', compression: 'none' }) const tuiConfig = calls[4]?.config as { sessionId: string } - expect(tuiConfig).toMatchObject({ welcome: 'TUI ready', color: false, maxToolOutputLines: 3 }) + expect(tuiConfig).toMatchObject({ + welcome: 'TUI ready', + resumeCommand: 'dsh --resume {session}', + color: false, + maxToolOutputLines: 3, + }) expect(tuiConfig.sessionId).toMatch(/^main-session-[0-9a-f-]{36}$/) const spineConfig = calls[5]?.config as { readonly agents: Array> diff --git a/packages/ui/tui/tests/tui.spec.ts b/packages/ui/tui/tests/tui.spec.ts index af988bc78c..4598da4d9a 100644 --- a/packages/ui/tui/tests/tui.spec.ts +++ b/packages/ui/tui/tests/tui.spec.ts @@ -1099,6 +1099,11 @@ describe('pi-tui chat lifecycle and transcript', () => { description: 'Fail a plugin command', handler: () => { throw new Error('plugin command exploded') }, }) + result.ctx.commands.register({ + name: 'plugin-error', + description: 'Return an error result', + handler: () => ({ kind: 'error' as const, text: 'plugin error result' }), + }) result.terminal.send('/plugin-check value ') result.terminal.send('\r') @@ -1115,6 +1120,10 @@ describe('pi-tui chat lifecycle and transcript', () => { result.terminal.send('\r') await tick() expect(result.terminal.output).toContain('Command failed: plugin command exploded') + result.terminal.send('/plugin-error') + result.terminal.send('\r') + await tick() + expect(result.terminal.output).toContain('plugin error result') result.terminal.send('/help') result.terminal.send('\r') await tick() @@ -1124,6 +1133,7 @@ describe('pi-tui chat lifecycle and transcript', () => { await result.controller.dispose() expect(result.ctx.commands.list(result.agent).map(command => command.name)).toEqual([ 'plugin-check', + 'plugin-error', 'plugin-fail', ]) await result.ctx.fiber.dispose()