From e8488f6b41f56f1c19a39f3c3e8e7ce7b6543bd8 Mon Sep 17 00:00:00 2001 From: yudshj Date: Thu, 15 Oct 2026 15:57:11 +0800 Subject: [PATCH] fix(shell): preserve missing exit codes in terminal presentation --- apps/web/tests/clickable-links-gallery.e2e.ts | 13 +++++++++++ .../clickable-links-gallery/ui.expected.md | 5 +++++ packages/client/ui-tool/README.i18n.yaml | 4 ++-- packages/client/ui-tool/README.md | 2 +- packages/client/ui-tool/README.zh.md | 2 +- .../client/tool/models/terminal-card-model.ts | 19 ++++++++-------- .../tests/terminal-card.client.spec.tsx | 22 ++++++++++++++----- packages/core/tools/README.i18n.yaml | 4 ++-- packages/core/tools/README.md | 2 +- packages/core/tools/README.zh.md | 2 +- packages/core/tools/src/presentation.ts | 6 ++--- .../extensions/tool-cordis/src/api-catalog.ts | 2 +- packages/shell/shell/README.i18n.yaml | 4 ++-- packages/shell/shell/README.md | 2 +- packages/shell/shell/README.zh.md | 2 +- packages/shell/shell/src/render.ts | 8 +++---- packages/shell/shell/tests/render.spec.ts | 8 +++++++ packages/shell/tool-bash/tests/tools.spec.ts | 1 + packages/shell/tool-pwsh/tests/tools.spec.ts | 1 + 19 files changed, 74 insertions(+), 35 deletions(-) diff --git a/apps/web/tests/clickable-links-gallery.e2e.ts b/apps/web/tests/clickable-links-gallery.e2e.ts index 46d03b126e..f508456d08 100644 --- a/apps/web/tests/clickable-links-gallery.e2e.ts +++ b/apps/web/tests/clickable-links-gallery.e2e.ts @@ -173,6 +173,11 @@ const CALLS: GalleryCall[] = [ args: { command: 'pnpm run lint:styles', description: LONG_COMMAND_DESCRIPTION, workdir: 'site' }, result: 'theme.css: unexpected hex literal\n[exit code: 1]', }, + { + name: 'bash', + args: { command: 'pnpm run build', description: 'Build the site', workdir: 'site' }, + result: '(no output)\n[timed out after 100ms]\n[exit code: null]', + }, { name: 'web_search', args: { queries: ['clickable link styles', 'produced files ui'] }, @@ -453,12 +458,20 @@ describe('web e2e: clickable links gallery', () => { /^Edit src\/tokens\.css/, /^Grep linkColor/, /Run the lint gate|pnpm run lint/, + /Build the site/, ]) { const toggle = page.getByRole('button', { name: row }).first() await toggle.waitFor({ timeout: 10_000 }) const box = await toggle.boundingBox() await toggle.click(box === null ? {} : { position: { x: box.width - 8, y: box.height / 2 } }) } + const noExitCommand = page.locator('[data-sample="bash"]').filter({ hasText: 'Build the site' }) + expect(await noExitCommand.getAttribute('data-state')).toBe('error') + expect(await noExitCommand.getByText('no exit code', { exact: true }).count()).toBe(1) + const noExitTerminal = page.locator('[data-terminal]').filter({ hasText: 'pnpm run build' }) + expect(await noExitTerminal.getByText('no exit code', { exact: true }).count()).toBe(1) + expect(await noExitTerminal.getByText('[timed out after 100ms]', { exact: true }).count()).toBe(1) + expect(await noExitTerminal.getByText('[exit code: null]', { exact: true }).count()).toBe(0) // Both generic rows (the unclassified str_replace_editor and the unknown // design_tokens_sync) expand to their IN/OUT surfaces. const genericRows = page.getByRole('button', { name: /^Tool call/ }) diff --git a/apps/web/tests/expected/clickable-links-gallery/ui.expected.md b/apps/web/tests/expected/clickable-links-gallery/ui.expected.md index 4c975abd6a..f51a8054d8 100644 --- a/apps/web/tests/expected/clickable-links-gallery/ui.expected.md +++ b/apps/web/tests/expected/clickable-links-gallery/ui.expected.md @@ -71,6 +71,11 @@ - text: "style.css: unexpected hex literal" - button "Inspect" - button "Failed Bash Check every generated stylesheet and component theme against the shared design tokens, inspect the application pages for inconsistent colors, and report all remaining lint failures before publishing the production build exit code 1" +- button "Failed Bash Build the site no exit code" [expanded] +- text: Failed site pnpm run build no exit code +- button "Copy" +- text: (no output) [timed out after {{duration}}] +- button "Inspect" - button "Search clickable link styles, produced files ui" [expanded] - paragraph: - text: Unify links per diff --git a/packages/client/ui-tool/README.i18n.yaml b/packages/client/ui-tool/README.i18n.yaml index a470120cdd..86d8299c11 100644 --- a/packages/client/ui-tool/README.i18n.yaml +++ b/packages/client/ui-tool/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-tool/use-this-package: - en: 7ab422fdd48f35fe - zh: e253c4eee3e3eb45 + en: c6d4e666191521b2 + zh: 2498020e7080e172 /deepseek-ai-dsh-client-ui-tool/use-this-package/registering-a-business-tool-view: en: 2e3c306b13d3bc25 zh: 77127f01763b3976 diff --git a/packages/client/ui-tool/README.md b/packages/client/ui-tool/README.md index 704a61e000..32d394cdaf 100644 --- a/packages/client/ui-tool/README.md +++ b/packages/client/ui-tool/README.md @@ -27,7 +27,7 @@ English | [中文](README.zh.md) Tool calls appear in the conversation as cards: a root call tree with its nested subcalls, each atomic call rendered by its owning view. Every lifecycle state retains the tool's ordinary business glyph; failure and interruption remain explicit through the frozen call/result state, accessible status text, and failure summary. Users can open files or inspect calls through the Host callbacks. A collapsed `web_fetch` row links its http(s) URL, which opens in a new browser tab. -Settled foreground commands with a nonzero exit code or terminating signal keep their description in the ordinary gray text and show a neutral capsule with a red dot immediately after it. The capsule displays only the recorded code or signal and stays on the same line; the description truncates with an ellipsis to reserve its space. Running, successful, and background calls omit it. Generic execution errors and stopped summaries retain their error and warning colors, including on hover. +Settled foreground commands with a nonzero exit code, a terminating signal, or an explicit missing exit code keep their description in the ordinary gray text and show a neutral capsule with a red dot immediately after it. The capsule displays only the recorded code, signal, or localized missing-code status and stays on the same line; the description truncates with an ellipsis to reserve its space. Running, successful, and background calls omit it. Generic execution errors and stopped summaries retain their error and warning colors, including on hover. Before dispatch, a named model call appears as one non-expandable row with its tool-owned icon and title. A generic row shows `Tool call · `. Read/write/edit show an openable path once `file_path` closes and decodes without errors; write/edit show `NKB` after that path once content arrives, retaining it during execution and after success, before any diff totals. N rounds the decoded input's UTF-16 length up in units of 1024, summing old and new text for edit; it is not file bytes. Error and stopped rows omit the size and diff totals. Command rows show the streamed description. `tool/call` enables the existing call presentation; completing an argument block alone does not start execution. diff --git a/packages/client/ui-tool/README.zh.md b/packages/client/ui-tool/README.zh.md index 0e704a506d..7f3d0ef79d 100644 --- a/packages/client/ui-tool/README.zh.md +++ b/packages/client/ui-tool/README.zh.md @@ -27,7 +27,7 @@ kind: "package-reference" 工具调用在对话中显示为卡片:一个根调用树带其嵌套子调用,每个原子调用由所属视图渲染。所有生命周期状态都保留工具的普通业务图标;失败与中断仍通过冻结调用/结果状态、无障碍状态文本和失败摘要明确表达。用户可通过宿主回调打开文件或检查调用。折叠的 `web_fetch` 行把其 http(s) URL 显示为链接,在新浏览器标签页中打开。 -已结束的前台命令若返回非零退出码或终止信号,描述保持普通灰色,后面紧接带红点的中性胶囊。胶囊仅显示记录的退出码或信号,并保持在同一行;描述超出可用宽度时显示省略号,为胶囊预留空间。运行中、成功和后台调用不显示胶囊。通用执行错误与停止摘要仍保留错误色和警告色,悬停时也不改变。 +已结束的前台命令若返回非零退出码、终止信号,或明确记录为无退出码,描述保持普通灰色,后面紧接带红点的中性胶囊。胶囊仅显示记录的退出码、信号或本地化的“未正常退出”状态,并保持在同一行;描述超出可用宽度时显示省略号,为胶囊预留空间。运行中、成功和后台调用不显示胶囊。通用执行错误与停止摘要仍保留错误色和警告色,悬停时也不改变。 派发前,模型已给出名称的调用显示为不可展开的一行,使用工具自己的图标与标题。通用行显示为 `工具调用 · <工具名>`。read/write/edit 在 `file_path` 闭合且解码无误后显示可打开的路径;write/edit 从内容到达起在该路径后显示 `NKB`,执行中和成功后仍保留,位于差异统计之前。N 按解码后输入的 UTF-16 长度除以 1024 向上取整,edit 合计新旧文本长度;它不是文件字节数。失败和停止的行省略大小与差异统计。命令行显示流入中的描述。`tool/call` 才启用既有调用展示;参数块结束本身不代表开始执行。 diff --git a/packages/client/ui-tool/src/client/tool/models/terminal-card-model.ts b/packages/client/ui-tool/src/client/tool/models/terminal-card-model.ts index 6f03151b62..468706c8e0 100644 --- a/packages/client/ui-tool/src/client/tool/models/terminal-card-model.ts +++ b/packages/client/ui-tool/src/client/tool/models/terminal-card-model.ts @@ -86,9 +86,9 @@ export function localizeTerminalCardModel( } /** - * True when a settled terminal card reports a failing exit — a non-zero code - * or a terminating signal. The bash tool settles a failing command as a - * completed call (`isError` stays false: the exit status is result data), so + * True when a settled terminal card reports a failing exit — a non-zero code, + * an explicitly missing exit code, or a terminating signal. The bash tool settles + * a failing command as a completed call (`isError` stays false: the exit status is result data), so * the row retains that failure state alongside its exit capsule. * @param model - a derived terminal card. * @returns whether the card's exit status is a failure. @@ -105,12 +105,11 @@ export function terminalFailed(model: TerminalCardModel): boolean { * @returns the capsule label, or null for running, background, or successful calls. */ export function terminalExitLabel(model: TerminalCardModel | null | undefined, t: TranslateNS<'conversation'>): string | null { - if (model == null || model.card.running || model.card.background) return null + if (model == null || model.card.background || !terminalFailed(model)) return null const { exitCode, signal } = model.card if (signal !== undefined) return t('terminal.signal', { signal }) - if (exitCode === null) return t('terminal.noExitCode') - if (exitCode !== undefined && exitCode !== 0) return t('terminal.exitCode', { code: exitCode }) - return null + if (exitCode == null) return t('terminal.noExitCode') + return t('terminal.exitCode', { code: exitCode }) } /** @@ -291,11 +290,11 @@ function terminalSendCall(name: string, args: Record): Terminal * @param text - rendered shell result text. * @returns output with a trailing exit-code or signal marker extracted. */ -function parseExitStatus(text: string): { output: string; exitCode?: number; signal?: string } { +function parseExitStatus(text: string): { output: string; exitCode?: number | null; signal?: string } { const signal = /\n\[killed by signal: ([^\]\n]+)\]$/.exec(text) if (signal?.[1] !== undefined) return { output: text.slice(0, signal.index), signal: signal[1] } - const exit = /\n\[exit code: (-?\d+)\]$/.exec(text) - if (exit?.[1] !== undefined) return { output: text.slice(0, exit.index), exitCode: Number(exit[1]) } + const exit = /\n\[exit code: (-?\d+|null)\]$/.exec(text) + if (exit?.[1] !== undefined) return { output: text.slice(0, exit.index), exitCode: exit[1] === 'null' ? null : Number(exit[1]) } return { output: text, exitCode: 0 } } diff --git a/packages/client/ui-tool/tests/terminal-card.client.spec.tsx b/packages/client/ui-tool/tests/terminal-card.client.spec.tsx index b10c7cf182..0ef6514c4e 100644 --- a/packages/client/ui-tool/tests/terminal-card.client.spec.tsx +++ b/packages/client/ui-tool/tests/terminal-card.client.spec.tsx @@ -79,14 +79,26 @@ describe('terminalCardModel', () => { expect(terminalExitLabel(undefined, enT)).toBeNull() expect(terminalExitLabel(terminalCardModel(running()), enT)).toBeNull() expect(terminalExitLabel(terminalCardModel(settled()), enT)).toBeNull() + expect(terminalExitLabel(terminalCardModel(settled({ + call: { name: 'terminal_send', argsRaw: JSON.stringify({ sessionId: 'term-1', text: 'hello' }) }, + })), enT)).toBeNull() expect(terminalExitLabel(terminalCardModel(settled({ call: { name: 'bash', argsRaw: shellArgs({ run_in_background: true }) } })), enT)).toBeNull() }) - it('names signals and unknown exits without substituting an exit code', () => { - const model = terminalCardModel(settled())! - expect(terminalExitLabel({ ...model, card: { running: false, signal: 'SIGTERM' } }, enT)).toBe('signal SIGTERM') - expect(terminalExitLabel({ ...model, card: { running: false, exitCode: null } }, enT)).toBe('no exit code') - expect(terminalExitLabel({ ...model, card: { running: false } }, enT)).toBeNull() + it('names a recorded signal without substituting an exit code', () => { + const model = terminalCardModel(settled({ content: [{ type: 'text', text: 'gone\n[killed by signal: SIGTERM]' }] })) + expect(terminalExitLabel(model, enT)).toBe('signal SIGTERM') + }) + + it.each(['bash', 'pwsh'])('preserves a %s timeout without an exit code', (name) => { + const model = terminalCardModel(settled({ + call: { name, argsRaw: ARGS }, + content: [{ type: 'text', text: '(no output)\n[timed out after 100ms]\n[exit code: null]' }], + }))! + expect(model.card).toMatchObject({ output: '(no output)\n[timed out after 100ms]', exitCode: null }) + expect(terminalFailed(model)).toBe(true) + expect(terminalExitLabel(model, enT)).toBe('no exit code') + expect(terminalExitLabel(model, t)).toBe('未正常退出') }) it('derives a running standard-shell card from raw arguments', () => { diff --git a/packages/core/tools/README.i18n.yaml b/packages/core/tools/README.i18n.yaml index 2817538d44..33b102c69f 100644 --- a/packages/core/tools/README.i18n.yaml +++ b/packages/core/tools/README.i18n.yaml @@ -30,8 +30,8 @@ en: cbfe8317565ac62d zh: 1e71c66941e50881 /deepseek-ai-dsh-tools/use-this-package/host-presentation-descriptors: - en: 258e16bb367229e5 - zh: 7c1eb91062b4e4ad + en: 34c14a449987d500 + zh: 5aef879f45dc9adb /deepseek-ai-dsh-tools/understand-the-implementation: en: ce7e776e9d516bdb zh: 59d2751743db7795 diff --git a/packages/core/tools/README.md b/packages/core/tools/README.md index db88aad341..a24b23c59a 100644 --- a/packages/core/tools/README.md +++ b/packages/core/tools/README.md @@ -92,7 +92,7 @@ A tool’s `projectContent` installs execution-prepared content before post-exec ### Host presentation descriptors -A tool can retain pure `presentCall()` and `presentResult()` methods for Host-local consumers. The built-in Web Client does not consume those values. It selects a renderer through `tool.call.toolview` and derives card props from raw call arguments, result content, failure state, and persisted metadata. The [Client-derived presentation decision](../../../.agents/notes/implemented/architecture/2026-08-23-client-derived-tool-presentation.md) owns this transport split. +A tool can retain pure `presentCall()` and `presentResult()` methods for Host-local consumers. The built-in Web Client does not consume those values. It selects a renderer through `tool.call.toolview` and derives card props from raw call arguments, result content, failure state, and persisted metadata. The [Client-derived presentation decision](../../../.agents/notes/implemented/architecture/2026-08-23-client-derived-tool-presentation.md) owns this transport split. A terminal result uses `exitCode: null` when no code or signal was available; an omitted exit code leaves that status unspecified. ----- diff --git a/packages/core/tools/README.zh.md b/packages/core/tools/README.zh.md index b8fe64c4f0..ec82b89e36 100644 --- a/packages/core/tools/README.zh.md +++ b/packages/core/tools/README.zh.md @@ -92,7 +92,7 @@ ctx.tools.register(defineTool({ ### Host 展示描述 -工具可以为 Host 本地消费方保留纯函数 `presentCall()` 与 `presentResult()` 方法。内置 Web Client 不消费这些值,而是通过 `tool.call.toolview` 选择 renderer,并从原始调用参数、结果内容、失败状态与持久 metadata 派生 card props。[Client 派生展示决策](../../../.agents/notes/implemented/architecture/2026-08-23-client-derived-tool-presentation.zh.md)负责该 transport 拆分。 +工具可以为 Host 本地消费方保留纯函数 `presentCall()` 与 `presentResult()` 方法。内置 Web Client 不消费这些值,而是通过 `tool.call.toolview` 选择 renderer,并从原始调用参数、结果内容、失败状态与持久 metadata 派生 card props。[Client 派生展示决策](../../../.agents/notes/implemented/architecture/2026-08-23-client-derived-tool-presentation.zh.md)负责该 transport 拆分。 终端结果在退出码与信号均不可用时使用 `exitCode: null`;省略退出码则表示结果未声明该状态。 ----- diff --git a/packages/core/tools/src/presentation.ts b/packages/core/tools/src/presentation.ts index 8d8aa8ac24..d001d1ebf8 100644 --- a/packages/core/tools/src/presentation.ts +++ b/packages/core/tools/src/presentation.ts @@ -167,10 +167,10 @@ export interface TerminalResultView { /** Captured command output (stdout+stderr as the tool chooses to combine them). */ output?: string /** - * Process exit code, when the run ended by exiting (not a signal). Lets a - * capable UI show an exit-status pill. Omit when killed by a signal or unknown. + * Process exit code, or null when the run ended without a code or signal. + * Omit when killed by a signal or when the result carries no exit status. */ - exitCode?: number + exitCode?: number | null /** Signal name that killed the process (e.g. `SIGTERM`). Mutually exclusive with `exitCode`. */ signal?: string } diff --git a/packages/extensions/tool-cordis/src/api-catalog.ts b/packages/extensions/tool-cordis/src/api-catalog.ts index 97da088137..092b7b8b01 100644 --- a/packages/extensions/tool-cordis/src/api-catalog.ts +++ b/packages/extensions/tool-cordis/src/api-catalog.ts @@ -8095,7 +8095,7 @@ export const TYPE_API: readonly TypeApiEntry[] = [ }, { name: 'TerminalResultView', - declaration: 'export interface TerminalResultView {\n card: \'terminal\';\n title?: string;\n output?: string;\n exitCode?: number;\n signal?: string;\n}', + declaration: 'export interface TerminalResultView {\n card: \'terminal\';\n title?: string;\n output?: string;\n exitCode?: number | null;\n signal?: string;\n}', }, { name: 'TerminalRetentionFrame', diff --git a/packages/shell/shell/README.i18n.yaml b/packages/shell/shell/README.i18n.yaml index 2255ab1dba..8d73a0c0a5 100644 --- a/packages/shell/shell/README.i18n.yaml +++ b/packages/shell/shell/README.i18n.yaml @@ -33,8 +33,8 @@ en: ddcf8a0c7a45e8d3 zh: e4ee99e2e27234fe /deepseek-ai-dsh-shell/use-this-package/the-shared-exit-status-contract: - en: f4125282c1deab36 - zh: 46b8ee789ae68a9a + en: c3f31a01d98eab72 + zh: 9605f58f21c6ad9d /deepseek-ai-dsh-shell/understand-the-implementation: en: d2192b68c2faf92b zh: 7678a2fd356d8587 diff --git a/packages/shell/shell/README.md b/packages/shell/shell/README.md index 0e87c9f25e..76b719105c 100644 --- a/packages/shell/shell/README.md +++ b/packages/shell/shell/README.md @@ -64,7 +64,7 @@ The seam is not an executor: mount exactly one provider per composition, and the ### The shared exit-status contract -Tool results end with a machine-readable exit marker — `[exit code: N]` or `[killed by signal: X]` — so the model can always tell how a command ended. The seam owns that marker format and the `parseExitStatus` helper that splits a rendered result back into its output body and structured exit status, keeping the `bash` and `pwsh` tools from drifting on it. +Tool results end with a machine-readable exit marker — `[exit code: N]`, `[exit code: null]` when no exit code is available, or `[killed by signal: X]` — so the model can always tell how a command ended. The seam owns that marker format and the `parseExitStatus` helper that splits a rendered result back into its output body and structured exit status, keeping the `bash` and `pwsh` tools from drifting on it. ----- diff --git a/packages/shell/shell/README.zh.md b/packages/shell/shell/README.zh.md index cf12395912..e9341dfca1 100644 --- a/packages/shell/shell/README.zh.md +++ b/packages/shell/shell/README.zh.md @@ -64,7 +64,7 @@ seam 本身不是执行器:每个组合只挂载一个提供方,工具即可 ### 共享的退出状态约定 -工具结果以机器可读的退出标记结尾——`[exit code: N]` 或 `[killed by signal: X]`——模型因此总能知道命令如何结束。seam 拥有该标记格式,以及把渲染结果拆回输出正文与结构化退出状态的 `parseExitStatus` 辅助函数,使 `bash` 与 `pwsh` 两个工具永远不会在此漂移。 +工具结果以机器可读的退出标记结尾——`[exit code: N]`、无退出码时的 `[exit code: null]` 或 `[killed by signal: X]`——模型因此总能知道命令如何结束。seam 拥有该标记格式,以及把渲染结果拆回输出正文与结构化退出状态的 `parseExitStatus` 辅助函数,使 `bash` 与 `pwsh` 两个工具永远不会在此漂移。 ----- diff --git a/packages/shell/shell/src/render.ts b/packages/shell/shell/src/render.ts index 8fc924ef63..154147ba7c 100644 --- a/packages/shell/shell/src/render.ts +++ b/packages/shell/shell/src/render.ts @@ -12,13 +12,13 @@ */ export type ParsedExitStatus = & { body: string } - & ({ exitCode: number } | { signal: string }) + & ({ exitCode: number | null } | { signal: string }) /** * Split a rendered shell-tool result string into its output body and the * structured exit status — the inverse of the `[exit code: N]` / * `[killed by signal: X]` markers the shell tools' renderers append. A killed - * marker yields `signal`; otherwise a non-zero marker yields `exitCode`; + * marker yields `signal`; otherwise a numeric or `null` marker yields `exitCode`; * absent both means a clean exit 0. * * The consumed marker is removed from `body` because a terminal presentation @@ -37,7 +37,7 @@ export type ParsedExitStatus = export function parseExitStatus(text: string): ParsedExitStatus { const signal = /\n\[killed by signal: ([^\]\n]+)\]$/.exec(text) if (signal?.[1] !== undefined) return { body: text.slice(0, signal.index), signal: signal[1] } - const exit = /\n\[exit code: (\d+)\]$/.exec(text) - if (exit?.[1] !== undefined) return { body: text.slice(0, exit.index), exitCode: Number(exit[1]) } + const exit = /\n\[exit code: (\d+|null)\]$/.exec(text) + if (exit?.[1] !== undefined) return { body: text.slice(0, exit.index), exitCode: exit[1] === 'null' ? null : Number(exit[1]) } return { body: text, exitCode: 0 } } diff --git a/packages/shell/shell/tests/render.spec.ts b/packages/shell/shell/tests/render.spec.ts index 3a9060d289..c93464f7fd 100644 --- a/packages/shell/shell/tests/render.spec.ts +++ b/packages/shell/shell/tests/render.spec.ts @@ -23,6 +23,14 @@ describe('parseExitStatus', () => { expect(parseExitStatus('[exit code: 5]')).toEqual({ body: '[exit code: 5]', exitCode: 0 }) }) + it('preserves a missing exit code and leaves the timeout in the body', () => { + expect(parseExitStatus('(no output)\n[timed out after 100ms]\n[exit code: null]')) + .toEqual({ body: '(no output)\n[timed out after 100ms]', exitCode: null }) + expect(parseExitStatus('[exit code: null]')).toEqual({ body: '[exit code: null]', exitCode: 0 }) + expect(parseExitStatus('output\n[exit code: null]\nmore output')) + .toEqual({ body: 'output\n[exit code: null]\nmore output', exitCode: 0 }) + }) + it('recovers a signal kill ahead of any non-zero exit marker', () => { expect(parseExitStatus('gone\n[killed by signal: SIGKILL]')).toEqual({ body: 'gone', signal: 'SIGKILL' }) // A fake signal marker with no leading newline is output, not a kill. diff --git a/packages/shell/tool-bash/tests/tools.spec.ts b/packages/shell/tool-bash/tests/tools.spec.ts index 0b01d7c81b..302d372e49 100644 --- a/packages/shell/tool-bash/tests/tools.spec.ts +++ b/packages/shell/tool-bash/tests/tools.spec.ts @@ -1201,6 +1201,7 @@ describe('tool-owned UI presentation (presentCall / presentResult)', () => { const cases = [ { result: { ...base, exitCode: 0, signal: null, timedOut: false }, expect: { exitCode: 0 } }, { result: { ...base, exitCode: 7, signal: null, timedOut: false }, expect: { exitCode: 7 } }, + { result: { ...base, exitCode: null, signal: null, timedOut: true }, expect: { exitCode: null } }, { result: { ...base, exitCode: null, signal: 'SIGTERM' as const, timedOut: false }, expect: { signal: 'SIGTERM' } }, // A trapped-timeout run that exits 0 has no signal/exit marker → reads as exit 0 (it did exit 0). { result: { ...base, exitCode: 0, signal: null, timedOut: true }, expect: { exitCode: 0 } }, diff --git a/packages/shell/tool-pwsh/tests/tools.spec.ts b/packages/shell/tool-pwsh/tests/tools.spec.ts index 66920cc9e9..278f54ccf9 100644 --- a/packages/shell/tool-pwsh/tests/tools.spec.ts +++ b/packages/shell/tool-pwsh/tests/tools.spec.ts @@ -1048,6 +1048,7 @@ describe('UI presentation', () => { const cases = [ { result: { ...base, exitCode: 0, signal: null, timedOut: false }, expect: { exitCode: 0 } }, { result: { ...base, exitCode: 7, signal: null, timedOut: false }, expect: { exitCode: 7 } }, + { result: { ...base, exitCode: null, signal: null, timedOut: true }, expect: { exitCode: null } }, { result: { ...base, exitCode: null, signal: 'SIGTERM' as const, timedOut: false }, expect: { signal: 'SIGTERM' } }, // A trapped-timeout run that exits 0 has no signal/exit marker → reads as exit 0 (it did exit 0). { result: { ...base, exitCode: 0, signal: null, timedOut: true }, expect: { exitCode: 0 } },