You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/08/27 17:00:00 UTC

(maka) branch main updated: test(desktop): story-cover the interrupted tool row after a turn abort (#3951)

This is an automated email from the ASF dual-hosted git repository.

Astro-Han pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/main by this push:
     new 4e1678254 test(desktop): story-cover the interrupted tool row after a turn abort (#3951)
4e1678254 is described below

commit 4e16782540eca8af28a9bd5a023ecd9a1b8e7e06
Author: Xiao Liu <li...@qq.com>
AuthorDate: Fri Aug 28 00:59:56 2026 +0800

    test(desktop): story-cover the interrupted tool row after a turn abort (#3951)
    
    * test(desktop): story-cover the interrupted tool row after a turn abort
    
    The interrupted tool state — a tool the user stops mid-run — rendered in
    no story. Add InterruptedToolAfterTurnAbort beside RunningStatusDuringToolRun:
    a Bash tool_call whose abort settles as a cancelled `terminal` result
    (exitCode 130, "Command cancelled"), so `toolResultActivityStatus` derives
    the row as `interrupted` — there is no interrupted turn status; the state
    comes from the settled result, and the aborted turn retains that partial
    output. It projects through the real ChatView -> materializeTurns ->
    ToolTrow path, rendering inside the production `.maka-turn` frame; the
    session is aborted with its timestamp aligned to the transcript.
    
    The result passes the canonical shell-result decoder, and the ledger
    carries the fields the AI-SDK backend persists (assistant step + stepId,
    origin, modelVisibility, durationMs). running/completed/errored already
    have coverage; this adds only the genuinely missing interrupted row.
    
    First surface under #3944.
    
    Refs #3944, #3893
    Generated-by: Claude Code
    
    * test(desktop): make the interrupted-tool fixture reachable and faithful
    
    Address review of InterruptedToolAfterTurnAbort. A `tsc` typecheck settles
    in under a second, so a multi-second cancel can't happen; and hand-written
    command output isn't the bytes the command produces. Use `npm test`, which
    runs for minutes (build:test then the runner), cancelled at ~16s while still
    building — genuinely `cancelled`/130, inside the 120s foreground default so
    it is not `timed_out`/124.
    
    The retained stdout is a verbatim prefix of a real `npm test` run killed
    mid-build, so the expanded panel shows the exact bytes — leading/trailing
    newlines included, no test-runner interleaving, nothing truncated. It
    derives through the real ChatView -> materializeTurns -> ToolTrow path and
    renders in the production `.maka-turn` frame; the session is aborted with
    its timestamp aligned to the transcript.
    
    Verified: shell-result decoder -> valid; materializeTurns -> tool.status
    interrupted, turn.status aborted; storybook smoke green (196 stories).
    
    Refs #3944, #3893
    
    Generated-by: Claude Code
---
 apps/desktop/stories/app-shell.stories.tsx | 103 +++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)

diff --git a/apps/desktop/stories/app-shell.stories.tsx b/apps/desktop/stories/app-shell.stories.tsx
index 340014f60..686d364a3 100644
--- a/apps/desktop/stories/app-shell.stories.tsx
+++ b/apps/desktop/stories/app-shell.stories.tsx
@@ -573,6 +573,109 @@ export const RunningStatusDuringToolRun: Story = {
   ),
 };
 
+// A real prefix of `npm test` stdout, copied verbatim from an actual run killed
+// mid-build (the full suite runs for minutes, so a cancel here is genuinely
+// reachable). Kept short by cutting inside the build phase — no test-runner
+// interleaving, no truncation. Cutting the fixture from a real run is what keeps
+// the expanded panel's bytes honest.
+const NPM_TEST_STDOUT_AT_CANCEL = "\n> maka@0.2.0 test\n> npm run build:test && node scripts/run-workspace-tests-parallel.mjs --concurrency=3\n\n\n> maka@0.2.0 build:test\n> npm run clean && npm --workspace @maka/core run build && npm --workspace @maka/storage run build && npm --workspace @maka/mcp run build && npm --workspace @maka/runtime run build && npm --workspace @maka/runtime-host run build && npm --workspace @maka/computer-use run build && npm --workspace @maka/eval run build &&  [...]
+
+// Real path: run the full test suite → the user hits stop before it returns.
+// Aborting settles the call as a cancelled `terminal` result (isError), and
+// `toolResultActivityStatus` maps a cancelled terminal to `interrupted`. There is
+// no `interrupted` turn status (only running/completed/aborted/failed) — the
+// tool-level state is derived from the settled result, not asserted. Because the
+// turn kept that partial result, `partialOutputRetained` is true.
+//
+// `npm test` runs for minutes (build:test then the runner), so a cancel at ~16s is
+// still inside a running process — it settles `cancelled`/130, not `timed_out`/124
+// (which needs the 120s foreground default) and not a `completed` run. The retained
+// stdout is a verbatim prefix of a real run (see NPM_TEST_STDOUT_AT_CANCEL), cut in
+// the build phase so there is no runner interleaving and nothing is truncated.
+//
+// This is the interrupted counterpart to RunningStatusDuringToolRun, and the only
+// story that reaches the interrupted tool row. It goes through the real
+// ChatView → materializeTurns → ToolTrow path, so the row renders inside the
+// production `.maka-turn` frame. The session is `aborted` too, so the sidebar row
+// and composer agree with the transcript instead of still reading as active.
+export const InterruptedToolAfterTurnAbort: Story = {
+  render: () => (
+    <ComposedShell
+      session={{ status: 'aborted', lastMessageAt: NOW - 98_000 }}
+      chat={{
+        messages: [
+          user('msg-i-1', 'turn-i', 2, '把整套测试跑一遍,我刚改完 core,想确认没打断别的。'),
+          {
+            type: 'turn_state',
+            id: 'state-i-running',
+            turnId: 'turn-i',
+            ts: NOW - 118_000,
+            status: 'running',
+            partialOutputRetained: false,
+          },
+          {
+            type: 'assistant',
+            id: 'msg-assistant-i',
+            turnId: 'turn-i',
+            ts: NOW - 116_000,
+            text: '跑 npm test —— 先全量重建再跑用例。',
+            modelId: 'claude-sonnet-4-5',
+          },
+          {
+            type: 'tool_call',
+            id: 'tool-i-1',
+            turnId: 'turn-i',
+            ts: NOW - 114_000,
+            toolName: 'Bash',
+            activityKind: 'command',
+            stepId: 'msg-assistant-i',
+            origin: 'provider',
+            modelVisibility: 'visible',
+            args: { command: 'npm test' },
+          },
+          {
+            type: 'tool_result',
+            id: 'tool-i-1-result',
+            turnId: 'turn-i',
+            ts: NOW - 98_000,
+            toolUseId: 'tool-i-1',
+            isError: true,
+            durationMs: 16_000,
+            origin: 'provider',
+            modelVisibility: 'visible',
+            content: {
+              kind: 'terminal',
+              cwd: '/workspace/maka-agent/.worktree/storybook',
+              cmd: 'npm test',
+              status: 'cancelled',
+              exitCode: 130,
+              failureMessage: 'Command cancelled',
+              output: {
+                mode: 'pipes',
+                stdout: NPM_TEST_STDOUT_AT_CANCEL,
+                stderr: '',
+                stdoutTruncated: false,
+                stderrTruncated: false,
+                redacted: false,
+              },
+            },
+          },
+          {
+            type: 'turn_state',
+            id: 'state-i-aborted',
+            turnId: 'turn-i',
+            ts: NOW - 98_000,
+            status: 'aborted',
+            abortedAt: NOW - 98_000,
+            abortSource: 'renderer.stop_button',
+            partialOutputRetained: true,
+          },
+        ],
+      }}
+    />
+  ),
+};
+
 // Real path: Desktop Computer Use is exposed through the Runtime Host Client
 // Capability bridge. The settled observation establishes the confirmed target;
 // the following sequence inherits it while live progress replaces the generic


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org