@songtonyli/dsh-cli 0.1.29 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
26
26
  ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
27
27
  ordinary optional dependencies, so npm resolves the right one for your machine.
28
28
 
29
- Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.29; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.31; `dsh --version`
30
30
  also reports the harness build the package was assembled from.
31
31
 
32
32
  ## License
package/bin/dsh.mjs CHANGED
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
18
18
  // version this package publishes. Reporting only one of the two would make an
19
19
  // ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
20
20
  if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
21
- console.log('@songtonyli/dsh-cli 0.1.29 (deepseek-harness 0.1.6-alpha.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.31 (deepseek-harness 0.1.6-alpha.2)')
22
22
  process.exit(0)
23
23
  }
24
24
 
@@ -160,7 +160,7 @@ window.__ModuleLoader__.load({
160
160
  const SCROLLBAR_LINGER_MS = 2e3;
161
161
  /** Format complete-build metadata for the local brand badge. */
162
162
  function localBuildVersion() {
163
- return `0.1.6-alpha.2-0c7bf05` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
163
+ return `0.1.6-alpha.2-cf94565` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
164
164
  }
165
165
  /** Each panel row subscribes only to its own selection state. */
166
166
  function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
@@ -24,8 +24,8 @@
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
26
  "@types/react": "~18.3.1",
27
- "@deepseek-ai/cordis": "^4.0.2",
28
- "@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2"
27
+ "@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2",
28
+ "@deepseek-ai/cordis": "^4.0.2"
29
29
  },
30
30
  "files": [
31
31
  "lib/index.js",
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/bundle/tui-app/README.md
5
- README.md: 0ad4a73e8b9ef6b75a40caeae5b9737a6d7fe52b
6
- README.zh.md: 86d015df48377e05e45686203012b4b8d46b4325
5
+ README.md: 3e36ebb544a01b4f1f3730604279c6d05b3f848d
6
+ README.zh.md: 30c869743cc07d60e57a632e20758008ca347993
@@ -40,9 +40,9 @@ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui
40
40
 
41
41
  ### The screen
42
42
 
43
- The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `›` (attachments listed under them), assistant reasoning is dim above the Markdown reply, and each tool call is a card with a status glyph, the tool name, the presenter headline, and a body folded to `toolPreviewLines` rows. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt and a compaction replacement are omitted. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, and the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings, links, list markers, quotes, and inline code share one cool dark-mode scale — a pale cyan, a deeper blue, and dim — so a reply sits beside a highlighted fence without contrasting hues. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning and a tool card float out over the same duration: they appear at a lifted color and recede to the dim italic or palette colors they settle in; a card redrawn from persisted history carries no fade, and text that has settled is never dimmed again.
43
+ The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `›` (attachments listed under them), assistant reasoning is dim above the Markdown reply, and each tool call is a card with a status glyph, the tool name, the presenter headline, a loading row while it runs, and a body folded to `toolPreviewLines` rows. The card appears when the model starts the call; the result rows float out when the tool answers. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt and a compaction replacement are omitted. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, and the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings, links, list markers, quotes, and inline code share one cool dark-mode scale — a pale cyan, a deeper blue, and dim — so a reply sits beside a highlighted fence without contrasting hues. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning and a tool card float out over the same duration: they appear at a lifted color and recede to the dim italic or palette colors they settle in; a card redrawn from persisted history carries no fade, and text that has settled is never dimmed again.
44
44
 
45
- Below the transcript sit a spinner while the agent works, any open prompt, a boxed follow-ups list while messages wait, the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, cumulative token usage, the goal and plan-mode markers from the projection seam, and the count of pending attachments. Compaction and model-request retries appear as notices, the same facts the browser's markers carry.
45
+ Below the transcript sit a spinner while the agent works — its label is `thinking` while the model reasons, `writing` while visible text arrives, or `calling <tool>` while a tool is streamed or still running, plus live `↑` send and `↓` receive tokens for the current model call, as compact `k` / `M` / `B` counts, growing as the stream arrives and settling on the provider usage chunk — any open prompt, a boxed follow-ups list while messages wait, an activity board of the open turn's todos and latest descendant line while either has a row — completed todo content scratched out, at most four todo rows then `+<n> more`, not a focus region, gone on `turn/end` and bind — the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, token usage (session totals plus the in-flight call), the goal and plan-mode markers from the projection seam, and the count of pending attachments. Compaction and model-request retries appear as notices, the same facts the browser's markers carry.
46
46
 
47
47
  While the keyboard walks the conversation a framed inspector is docked directly above the editor, and the frame is the mode: it is drawn exactly while the conversation holds the keyboard. Its top rule carries an inverse ` ● READ ` chip and the focused section's heading — the section's position among the navigable blocks, the turn it belongs to, and what the section is — as in `╭ ● READ ─ 3/12 · turn 2 · bash git status · result ─╮`. Under it the block's parts draw as a numbered wrapping strip like `← 1 call · [2 result] →` when the block has more than one, the held label bracketed as well as accented so the selection is legible with no color at all; then the section's own source rows, each prefixed with `│ ` and wrapped two columns narrower, folded at `focusPreviewLines` for every section kind — a system prompt and an injected context included — with `… <n> more rows · Ctrl+G reads it` under them. The bottom rule carries the keys the conversation answers, `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`, narrowed to `↑↓ ←→ · Space folds · Esc input` and then to `Esc input` as the terminal loses columns.
48
48
 
@@ -52,13 +52,13 @@ The focused block is also marked where it stands, with a two-column gutter that
52
52
 
53
53
  Transient key feedback floats as a dim framed line in the top-right corner of the viewport: `press Esc again to stop turn <n>`, `press Ctrl+C again to quit`, and `nothing in the transcript to read yet`. It holds at full strength for `toastMs`, fades out, costs the conversation no row of its own, and takes no keyboard; where the renderer can no longer repaint the top of the viewport it is printed into the conversation instead, which keeps it. Facts worth keeping are notices in the conversation: `stopping the turn…`, `wait for the session switch to finish`, `above the repaint window · opened in the reader`, and every command result.
54
54
 
55
- Motion reaches past streamed text, and every effect rides the same fade tick. The keyboard landing on the conversation, the subagent panel, or the status bar lifts that surface's frame, its chip, and the mark it holds for six ticks; a step of the conversation walk lifts the newly focused gutter for three; and a step along the bar lifts the selected label for four. The reader animates nothing: it arrives complete on the screen it owns. No lift changes how many lines anything draws, and `reducedMotion` — like `NO_COLOR`, a disabled palette, and `TERM=dumb` — turns every one of them off and arms no repaint for them.
55
+ Motion reaches past streamed text, and every effect rides the same fade tick. The keyboard landing on the conversation, the subagent panel, or the status bar lifts that surface's frame, its chip, and the mark it holds for six ticks; a step of the conversation walk lifts the newly focused gutter for three; and a step along the bar lifts the selected label for four. A new or status-changed activity-board todo row, and a replaced descendant line, float out on that tick the same way a tool card does; replay and `reducedMotion` draw the settled board. The reader animates nothing: it arrives complete on the screen it owns. No lift changes how many lines anything draws, and `reducedMotion` — like `NO_COLOR`, a disabled palette, and `TERM=dumb` — turns every one of them off and arms no repaint for them.
56
56
 
57
57
  The subagent panel is drawn while a subagent session under the bound one is resident, or the listing carries a candidate it could not read. Unfocused it is one summary line with the listed count and the first child's key label; focused, its heading counts what it lists and ends on the keys it answers, `↑↓ children · Enter details · Tab regions · Esc input`, narrowed to `↑↓ children · Esc input` and then to `Esc input` on a terminal that cannot hold them, and each row gives the child's depth indent, its label or id, its mode (`one-shot` or `continuable`), `resident`, whether its agent is `running` or `idle`, its elapsed time — the open turn's, else the total its settled turns took — and its token usage, as far as this process's own view of that child and the composed projections carry them. Six rows are drawn at most, with `+<n> more · /subagents lists them all` under them; a candidate the listing could not interpret draws as `unreadable: <reason>` and opens nothing, and a failed listing keeps the rows the last good one produced with `listing failed: <reason>` beneath. The panel disappears with its last row.
58
58
 
59
59
  ### Keys and commands
60
60
 
61
- The conversation, input, subagent panel, and status bar form the vertical arrow-key walk: `Down` at the newest section, `Up` on the subagent panel's first row, and `Up` on the status bar with no subagent panel drawn all land at the caret. The follow-ups list sits above the input; `Shift+Down` enters it while it is drawn, and it joins the `Tab` walk. While a region other than the editor has the keyboard, `Tab` and `Shift+Tab` walk the regions that are drawn, wrapping at both ends; in the editor, `Tab` takes the offered completion and `Shift+Tab` opens the reasoning-effort picker. A printable key pressed in any of them returns to the input and types there, so a sentence started while reading lands where it was aimed; `Space` in the conversation is the one exception, and folds the marked tool card or context block. `Ctrl+G` and `Ctrl+O` mean the same thing in every one of those regions, and `Ctrl+C` and `Ctrl+D` return the keyboard to the input before they act. A prompt and the reader own their whole key stream instead, and answer `Ctrl+C` by giving the keyboard back.
61
+ The conversation, input, subagent panel, and status bar form the vertical arrow-key walk: `Down` at the newest section, `Up` on the subagent panel's first row, and `Up` on the status bar with no subagent panel drawn all land at the caret. The follow-ups list sits above the input; `Shift+Down` enters it while it is drawn, and it joins the `Tab` walk. The activity board sits between follow-ups and the input and is not a focus region. While a region other than the editor has the keyboard, `Tab` and `Shift+Tab` walk the regions that are drawn, wrapping at both ends; in the editor, `Tab` takes the offered completion and `Shift+Tab` opens the reasoning-effort picker. A printable key pressed in any of them returns to the input and types there, so a sentence started while reading lands where it was aimed; `Space` in the conversation is the one exception, and folds the marked tool card or context block. `Ctrl+G` and `Ctrl+O` mean the same thing in every one of those regions, and `Ctrl+C` and `Ctrl+D` return the keyboard to the input before they act. A prompt and the reader own their whole key stream instead, and answer `Ctrl+C` by giving the keyboard back.
62
62
 
63
63
  While the input has the keyboard:
64
64
 
@@ -242,7 +242,7 @@ The runner awaits the complete application (`ctx.get('loader')?.await()`) and bu
242
242
 
243
243
  ### Rendering model
244
244
 
245
- Durable facts come from the session log: `system/message` (a nonempty prompt draws in full; an empty rendering is omitted), `user/message` (own submissions are drawn once and their echo skipped by message id; injected context — instructions, catalogs, snapshots, notices, relays, recalls, and undeclared forms — draws in full as a dim `⬡` row, a snapshot as one named contribution per part; compaction replacements and tool or model sources are omitted), `assistant/message` (which replaces the streamed block with the committed text and folds usage into the footer), `tool/call` and `tool/result` (drawn through the tool's `presentCall` and `presentResult` views when it declares them, with a raw-argument and raw-result fallback), `turn/end` notices, `workspace/changes` (one notice with the turn's file and line counts while the Host still holds the summary), `session/title` (header), `permission/preset` (footer), and `todo/write` under the enclosing `turn/start` (the turns one todo item's page reports; the list carries no per-item identity, so a reworded item counts as a new one). Live incrementality comes from `agent/assistant-stream` text and reasoning deltas. Session facts outside the log come from the same services the browser reads: `sessionTitle`, `permissionPresets`, `sessionQuery` for the picker, `/deliverables`, and subagent details, `sessionProjections` for the footer, `/status`, `/todos`, and `/outline`, `fileReferences` and `sessionReferenceResolver` for `@` completion, `attachments`, `skills`, `authorization`, `settings`, `subagents`, and the Loader's entries for `/plugins`. Modal prompts are process-local presentation and are never logged.
245
+ Durable facts come from the session log: `system/message` (a nonempty prompt draws in full; an empty rendering is omitted), `user/message` (own submissions are drawn once and their echo skipped by message id; injected context — instructions, catalogs, snapshots, notices, relays, recalls, and undeclared forms — draws in full as a dim `⬡` row, a snapshot as one named contribution per part; compaction replacements and tool or model sources are omitted), `assistant/message` (which replaces the streamed block with the committed text and folds usage into the footer), `tool/call` and `tool/result` (drawn through the tool's `presentCall` and `presentResult` views when it declares them, with a raw-argument and raw-result fallback), `turn/end` notices, `workspace/changes` (one notice with the turn's file and line counts while the Host still holds the summary), `session/title` (header), `permission/preset` (footer), and `todo/write` under the enclosing `turn/start` (the turns one todo item's page reports; the list carries no per-item identity, so a reworded item counts as a new one; the same write refreshes the activity board from the `todos` projection). A descendant `tool/call`, `tool/result`, or `turn/end`, and a `subagent/start` or `subagent/end` for the bound parent, replace that board's one-line summary — tool title or first result row, never child assistant prose; `turn/end` on the bound session and bind clear the board. Live incrementality comes from `agent/assistant-stream` text, reasoning, tool-call, and usage deltas: a card is mounted when the model names the tool, and the working spinner follows that stream plus durable `tool/call` / `tool/result` so it says `thinking`, `writing`, or `calling <tool>` with live `↑` send and `↓` receive for that call. Session facts outside the log come from the same services the browser reads: `sessionTitle`, `permissionPresets`, `sessionQuery` for the picker, `/deliverables`, and subagent details, `sessionProjections` for the footer, `/status`, `/todos`, and `/outline`, `fileReferences` and `sessionReferenceResolver` for `@` completion, `attachments`, `skills`, `authorization`, `settings`, `subagents`, and the Loader's entries for `/plugins`. Modal prompts are process-local presentation and are never logged.
246
246
 
247
247
  ### Patch surface over base
248
248
 
@@ -254,7 +254,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
254
254
  |---|---|
255
255
  | [`src/index.ts`](src/index.ts) | The `tui-app` plugin: the session host (create, resume, fork), resume observation, quit flow, exit mapping |
256
256
  | [`src/startup.ts`](src/startup.ts) | The `tui-app-startup` provider: prompt positional, `--resume`, `--no-open`, and `--help` |
257
- | [`src/app.ts`](src/app.ts) | The terminal application: layout, the key router, commands, session binding, seams, log and stream folding, the stop arm, the transient line it mounts, the terminal handover the reader runs on, and prefix-on-submit `!` / `!!` |
257
+ | [`src/app.ts`](src/app.ts) | The terminal application: layout, the key router, commands, session binding, seams, log and stream folding, the activity board above the editor, the stop arm, the transient line it mounts, the terminal handover the reader runs on, and prefix-on-submit `!` / `!!` |
258
258
  | [`src/keys.ts`](src/keys.ts) | The key model: the focus regions, what one press means in each, the legends they degrade through, the entry keys, the `/help` lines, and the handoff window |
259
259
  | [`src/sessions.ts`](src/sessions.ts) | The persisted-session list and picker rows shared by `/resume` and `/sessions` |
260
260
  | [`src/effort.ts`](src/effort.ts) | Reasoning-effort names and picker rows shared by `/model`, `/effort`, and editor `Shift+Tab` |
@@ -285,11 +285,13 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
285
285
  | [`src/footer.ts`](src/footer.ts) | The status bar: the ordered segments, each segment's detail rows, the unfocused line built from both ends, and the focused sliding window |
286
286
  | [`src/subagent-panel.ts`](src/subagent-panel.ts) | The live subagent panel: one descendant listing plus sampled live facts become its rows, the unfocused summary line, and the focused listing |
287
287
  | [`src/queue-panel.ts`](src/queue-panel.ts) | The follow-ups list: pending-row glyphs, hanging wrap, and the enter-steer legend |
288
+ | [`src/activity-board.ts`](src/activity-board.ts) | The activity board: todo glyphs, the completed scratch-out, the row cap, and the one-line descendant summary |
288
289
  | [`src/catalog.ts`](src/catalog.ts) | Rows for `/settings`, `/plugins`, `/subagents`, `/deliverables`, `/changes`, and `/outline`, and the `/plugins` management verbs |
289
290
  | [`src/todos.ts`](src/todos.ts) | The todo list: the status glyphs, the picker rows with completed content scratched out, and one item's detail rows |
290
291
  | [`cordis.patch.yml`](cordis.patch.yml) | The terminal patch over `dsh-base` |
291
292
  | — | No runtime invariant companion is published; the app registers listeners on one Agent and holds no mutable relation another observer could contradict. |
292
- | [`tests/app.spec.ts`](tests/app.spec.ts) | Rendering, keys, commands, the stop arm, the follow-ups rows above the editor, and both seams over a fake terminal |
293
+ | [`tests/app.spec.ts`](tests/app.spec.ts) | Rendering, keys, commands, the stop arm, the follow-ups rows above the editor, the activity board, and both seams over a fake terminal |
294
+ | [`tests/activity-board.spec.ts`](tests/activity-board.spec.ts) | Activity-board glyphs, the completed scratch-out, the row cap, and the descendant line |
293
295
  | [`tests/keys.spec.ts`](tests/keys.spec.ts) | What each region claims for a key, the legend steps, and the text one press types |
294
296
  | [`tests/editor.spec.ts`](tests/editor.spec.ts) | The terminal caret and `Shift+Left` / `Shift+Right` word navigation against pi-tui's editor behavior |
295
297
  | [`tests/frame.spec.ts`](tests/frame.spec.ts) | The rules, the chip, the body rows, and the legend a width holds |
@@ -40,9 +40,9 @@ dsh tui --no-open # print sign-in URLs without opening a
40
40
 
41
41
  ### 屏幕布局
42
42
 
43
- 页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `›` 开头(附件列在其下),assistant 的推理以暗色显示在 Markdown 回复上方,每次工具调用是一张卡片,含状态符号、工具名、呈现器标题,以及折叠到 `toolPreviewLines` 行的正文。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词与压缩替换则省略。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行,以及 `edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题、链接、列表标记、引用与行内代码共用一套暗色冷色阶——浅青、更深的蓝与暗色——因此回复能挨着高亮围栏,而不靠对比色相。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
43
+ 页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `›` 开头(附件列在其下),assistant 的推理以暗色显示在 Markdown 回复上方,每次工具调用是一张卡片,含状态符号、工具名、呈现器标题、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。卡片在模型开始调用时出现;结果行在工具回答后浮出。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词与压缩替换则省略。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行,以及 `edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题、链接、列表标记、引用与行内代码共用一套暗色冷色阶——浅青、更深的蓝与暗色——因此回复能挨着高亮围栏,而不靠对比色相。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
44
44
 
45
- 对话记录下方依次是 agent 工作时的旋转指示、任何打开的提示、有消息等待时的带框 follow-ups 列表、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、累计 token 用量、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
45
+ 对话记录下方依次是 agent 工作时的旋转指示——其标签在模型推理时为 `thinking`,可见文本到达时为 `writing`,工具正在流出或仍在执行时为 `calling <tool>`,并带着当前这次模型调用的实时 `↑` 发送与 `↓` 接收 token,以紧凑的 `k` / `M` / `B` 计数,随数据流入增长,并在提供方的 usage 块到达后落定——任何打开的提示、有消息等待时的带框 follow-ups 列表、本轮 todo 与最新后代行的 activity board(有行时才绘制;已完成内容划掉,todo 最多四行其后 `+<n> more`,不是焦点区域,在 `turn/end` 与 bind 时消失)、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、token 用量(会话合计加上进行中的这次调用)、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
46
46
 
47
47
  键盘在对话记录中移动时,编辑器正上方停靠着一个带边框的检视面板,边框即模式:它恰好在对话记录持有键盘时绘制。其顶边线带有一个反白的 ` ● READ ` 徽标与当前聚焦小节的标题——该小节在可导航块中的位置、所属轮次,以及这是哪一种小节——例如 `╭ ● READ ─ 3/12 · turn 2 · bash git status · result ─╮`。其下在块含多个部分时,把这些部分绘制成形如 `← 1 call · [2 result] →` 的带编号、会折行的选择行,被持有的标签除强调色外还加上方括号,因此完全无颜色时选择仍然可读;再往下是该小节自身的源文本行,每行以 `│ ` 起头并按窄两列换行,对每一种小节——含系统提示词与注入的上下文——都折叠到 `focusPreviewLines` 行,其下写出 `… <n> more rows · Ctrl+G reads it`。底边线列出对话记录所应答的按键 `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`,随着终端列数减少收缩为 `↑↓ ←→ · Space folds · Esc input`,再收缩为 `Esc input`。
48
48
 
@@ -52,13 +52,13 @@ dsh tui --no-open # print sign-in URLs without opening a
52
52
 
53
53
  临时按键反馈以一行暗色带框文字浮在视口右上角:`press Esc again to stop turn <n>`、`press Ctrl+C again to quit` 与 `nothing in the transcript to read yet`。它以全亮度保持 `toastMs`、随后淡出,不占用对话记录自身的任何一行,也不接管键盘;渲染器已无法重绘视口顶部时,它改为打印进对话记录,从而被保留下来。值得留存的事实则是对话记录中的通知:`stopping the turn…`、`wait for the session switch to finish`、`above the repaint window · opened in the reader` 以及每一条命令结果。
54
54
 
55
- 动效不止于流式文本,而且每种效果都乘着同一个淡入时钟。键盘落到对话记录、子 agent 面板或状态栏上时,会把该表层的边框、其徽标与它持有的标记抬亮六拍;对话记录走查中的一步把新聚焦的标记条抬亮三拍;状态栏上的一步把所选标签抬亮四拍。阅读器没有任何动效:它在自己占据的屏幕上一次性完整出现。任何抬亮都不改变任何东西绘制的行数,而 `reducedMotion`——与 `NO_COLOR`、被禁用的调色板和 `TERM=dumb` 一样——会把它们全部关闭,并且不为它们安排任何重绘。
55
+ 动效不止于流式文本,而且每种效果都乘着同一个淡入时钟。键盘落到对话记录、子 agent 面板或状态栏上时,会把该表层的边框、其徽标与它持有的标记抬亮六拍;对话记录走查中的一步把新聚焦的标记条抬亮三拍;状态栏上的一步把所选标签抬亮四拍。活动板上新出现或状态已变的 todo 行,以及被替换的后代行,也在同一时钟上像工具卡片一样浮出;重放与 `reducedMotion` 则画出已稳定的活动板。阅读器没有任何动效:它在自己占据的屏幕上一次性完整出现。任何抬亮都不改变任何东西绘制的行数,而 `reducedMotion`——与 `NO_COLOR`、被禁用的调色板和 `TERM=dumb` 一样——会把它们全部关闭,并且不为它们安排任何重绘。
56
56
 
57
57
  子 agent 面板在绑定会话之下有常驻的子 agent 会话、或列表中带有无法读取的候选者时绘制。未聚焦时它是一行摘要,含列出的数量与第一个子会话的关键标签;聚焦时其标题统计所列出的条目,并以它所应答的按键 `↑↓ children · Enter details · Tab regions · Esc input` 结尾,在容纳不下时收缩为 `↑↓ children · Esc input`,再收缩为 `Esc input`;每一行给出该子会话的层级缩进、其标签或 id、其模式(`one-shot` 或 `continuable`)、`resident`、其 agent 处于 `running` 还是 `idle`、其已用时间——进行中轮次的用时,否则是已结束轮次的合计——以及其 token 用量,以本进程对该子会话的可见程度与已组合的投影所能提供的为限。最多绘制六行,其下是 `+<n> more · /subagents lists them all`;列表无法解读的候选者绘制为 `unreadable: <reason>` 且打不开任何页面,读取失败的列表则保留上一次成功读取产生的各行,并在其下写出 `listing failed: <reason>`。面板随其最后一行一同消失。
58
58
 
59
59
  ### 按键与命令
60
60
 
61
- 对话记录、编辑器、子 agent 面板与状态栏构成垂直方向键走查:在最新小节上按 `Down`、在子 agent 面板第一行上按 `Up`、在没有绘制子 agent 面板时于状态栏上按 `Up`,都会落到光标处。follow-ups 列表位于输入框上方;绘制该列表时,`Shift+Down` 会进入它,它也加入 `Tab` 走查。编辑器以外的区域持有键盘时,`Tab` 与 `Shift+Tab` 走遍已绘制的各区域,并在两端环绕;在编辑器中,`Tab` 采用给出的补全,`Shift+Tab` 打开推理强度选择器。在其中任何一个区域按下可打印键都会回到编辑器并在那里输入,因此在阅读时开始写的句子会落在它所指向的地方;对话记录中的 `Space` 是唯一的例外,它折叠被标记的工具卡片或上下文块。`Ctrl+G` 与 `Ctrl+O` 在这些区域中含义完全相同,而 `Ctrl+C` 与 `Ctrl+D` 会先把键盘交还编辑器再行动。提示与阅读器则各自持有整条按键流,并以交还键盘的方式应答 `Ctrl+C`。
61
+ 对话记录、编辑器、子 agent 面板与状态栏构成垂直方向键走查:在最新小节上按 `Down`、在子 agent 面板第一行上按 `Up`、在没有绘制子 agent 面板时于状态栏上按 `Up`,都会落到光标处。follow-ups 列表位于输入框上方;绘制该列表时,`Shift+Down` 会进入它,它也加入 `Tab` 走查。activity board 位于 follow-ups 与输入之间,不是焦点区域。编辑器以外的区域持有键盘时,`Tab` 与 `Shift+Tab` 走遍已绘制的各区域,并在两端环绕;在编辑器中,`Tab` 采用给出的补全,`Shift+Tab` 打开推理强度选择器。在其中任何一个区域按下可打印键都会回到编辑器并在那里输入,因此在阅读时开始写的句子会落在它所指向的地方;对话记录中的 `Space` 是唯一的例外,它折叠被标记的工具卡片或上下文块。`Ctrl+G` 与 `Ctrl+O` 在这些区域中含义完全相同,而 `Ctrl+C` 与 `Ctrl+D` 会先把键盘交还编辑器再行动。提示与阅读器则各自持有整条按键流,并以交还键盘的方式应答 `Ctrl+C`。
62
62
 
63
63
  编辑器持有键盘时:
64
64
 
@@ -242,7 +242,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
242
242
 
243
243
  ### 渲染模型
244
244
 
245
- 持久事实来自会话日志:`system/message`(非空提示词完整画出;空的绘制则省略)、`user/message`(自己提交的消息只绘制一次,其回显按消息 id 跳过;注入的上下文——instructions、catalogs、snapshots、notices、relays、recalls 以及未声明的形式——以暗色 `⬡` 行完整画出,快照按具名贡献各成一部分;压缩替换以及工具或模型来源则省略)、`assistant/message`(用已提交文本替换流式块,并把用量折入页脚)、`tool/call` 与 `tool/result`(工具声明 `presentCall` 与 `presentResult` 视图时据此绘制,否则回退到原始参数与原始结果)、`turn/end` 通知、`workspace/changes`(在 Host 仍保存摘要时,以一行通知给出该轮的文件数与行数)、`session/title`(页眉)、`permission/preset`(页脚),以及所属 `turn/start` 之下的 `todo/write`(某条 todo 的详情页所报告的轮次;该列表不带逐条标识,因此改写措辞的条目算作新条目)。实时增量来自 `agent/assistant-stream` 的文本与推理增量。日志之外的会话事实来自浏览器读取的同一批服务:`sessionTitle`、`permissionPresets`、供选择器、`/deliverables` 与子 agent 详情使用的 `sessionQuery`、供页脚、`/status`、`/todos` 与 `/outline` 使用的 `sessionProjections`、供 `@` 补全使用的 `fileReferences` 与 `sessionReferenceResolver`、`attachments`、`skills`、`authorization`、`settings`、`subagents`,以及供 `/plugins` 使用的 Loader 条目。模态提示是进程本地的呈现,从不写入日志。
245
+ 持久事实来自会话日志:`system/message`(非空提示词完整画出;空的绘制则省略)、`user/message`(自己提交的消息只绘制一次,其回显按消息 id 跳过;注入的上下文——instructions、catalogs、snapshots、notices、relays、recalls 以及未声明的形式——以暗色 `⬡` 行完整画出,快照按具名贡献各成一部分;压缩替换以及工具或模型来源则省略)、`assistant/message`(用已提交文本替换流式块,并把用量折入页脚)、`tool/call` 与 `tool/result`(工具声明 `presentCall` 与 `presentResult` 视图时据此绘制,否则回退到原始参数与原始结果)、`turn/end` 通知、`workspace/changes`(在 Host 仍保存摘要时,以一行通知给出该轮的文件数与行数)、`session/title`(页眉)、`permission/preset`(页脚),以及所属 `turn/start` 之下的 `todo/write`(某条 todo 的详情页所报告的轮次;该列表不带逐条标识,因此改写措辞的条目算作新条目;同一次写入还从 `todos` 投影刷新 activity board)。后代会话的 `tool/call`、`tool/result` 或 `turn/end`,以及绑定父会话的 `subagent/start` / `subagent/end`,会替换该板上的一行摘要——工具标题或结果首行,从不使用子会话的 assistant 正文;绑定会话的 `turn/end` 与 bind 会清空该板。实时增量来自 `agent/assistant-stream` 的文本、推理、工具调用与用量增量:模型一报出工具名就挂上卡片,工作时的旋转指示跟随该流以及持久的 `tool/call` / `tool/result`,从而标出 `thinking`、`writing` 或 `calling <tool>`,并带着该次调用的实时 `↑` 发送与 `↓` 接收。日志之外的会话事实来自浏览器读取的同一批服务:`sessionTitle`、`permissionPresets`、供选择器、`/deliverables` 与子 agent 详情使用的 `sessionQuery`、供页脚、`/status`、`/todos` 与 `/outline` 使用的 `sessionProjections`、供 `@` 补全使用的 `fileReferences` 与 `sessionReferenceResolver`、`attachments`、`skills`、`authorization`、`settings`、`subagents`,以及供 `/plugins` 使用的 Loader 条目。模态提示是进程本地的呈现,从不写入日志。
246
246
 
247
247
  ### 基于 base 的 patch 面
248
248
 
@@ -254,7 +254,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
254
254
  |---|---|
255
255
  | [`src/index.ts`](src/index.ts) | `tui-app` 插件:会话宿主(创建、恢复、fork)、恢复观察、退出流程、退出码映射 |
256
256
  | [`src/startup.ts`](src/startup.ts) | `tui-app-startup` 提供方:提示位置参数、`--resume`、`--no-open` 与 `--help` |
257
- | [`src/app.ts`](src/app.ts) | 终端应用:布局、按键路由、命令、会话绑定、接缝、日志与流的折叠、停止装填、它挂载的临时提示行、阅读器所依托的终端交接,以及提交时解析的 `!` / `!!` |
257
+ | [`src/app.ts`](src/app.ts) | 终端应用:布局、按键路由、命令、会话绑定、接缝、日志与流的折叠、编辑器上方的 activity board、停止装填、它挂载的临时提示行、阅读器所依托的终端交接,以及提交时解析的 `!` / `!!` |
258
258
  | [`src/keys.ts`](src/keys.ts) | 按键模型:各焦点区域、一次按键在每个区域中的含义、它们逐级收缩的按键提示、进入用的按键、`/help` 的各行,以及交接窗口 |
259
259
  | [`src/sessions.ts`](src/sessions.ts) | `/resume` 与 `/sessions` 共用的持久化会话列表及选择器行 |
260
260
  | [`src/effort.ts`](src/effort.ts) | `/model`、`/effort` 与编辑器 `Shift+Tab` 共用的推理强度名称及选择器行 |
@@ -285,11 +285,13 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
285
285
  | [`src/footer.ts`](src/footer.ts) | 状态栏:有序的各分段、每个分段的详情行、未聚焦时由两端向内构建的一行,以及聚焦时的滑动窗口 |
286
286
  | [`src/subagent-panel.ts`](src/subagent-panel.ts) | 实时子 agent 面板:一次后代列表加上采样到的实时事实构成其各行、未聚焦时的摘要行,以及聚焦时的列表 |
287
287
  | [`src/queue-panel.ts`](src/queue-panel.ts) | follow-ups 列表:待处理行符号、悬挂换行与 enter-steer 图例 |
288
+ | [`src/activity-board.ts`](src/activity-board.ts) | activity board:todo 状态符号、已完成内容划掉、行数上限,以及一行后代摘要 |
288
289
  | [`src/catalog.ts`](src/catalog.ts) | `/settings`、`/plugins`、`/subagents`、`/deliverables`、`/changes` 与 `/outline` 的行,以及 `/plugins` 的管理动作 |
289
290
  | [`src/todos.ts`](src/todos.ts) | todo 列表:状态符号、已完成内容划掉的选择器行与单个条目的详情行 |
290
291
  | [`cordis.patch.yml`](cordis.patch.yml) | 基于 `dsh-base` 的终端 patch |
291
292
  | — | 不发布运行时不变量伴随模块;应用只在一个 Agent 上注册监听器,不持有其他观察者可能与之矛盾的可变关系。 |
292
- | [`tests/app.spec.ts`](tests/app.spec.ts) | 基于伪终端的渲染、按键、命令、停止装填、编辑器上方的 follow-ups 行与两个接缝 |
293
+ | [`tests/app.spec.ts`](tests/app.spec.ts) | 基于伪终端的渲染、按键、命令、停止装填、编辑器上方的 follow-ups 行、activity board 与两个接缝 |
294
+ | [`tests/activity-board.spec.ts`](tests/activity-board.spec.ts) | activity board 的状态符号、已完成划掉、行数上限与后代行 |
293
295
  | [`tests/keys.spec.ts`](tests/keys.spec.ts) | 每个区域为一个按键认领什么、按键提示的各级,以及一次按键输入的文字 |
294
296
  | [`tests/editor.spec.ts`](tests/editor.spec.ts) | 对照 pi-tui 编辑器行为验证终端光标与 `Shift+Left` / `Shift+Right` 词导航 |
295
297
  | [`tests/frame.spec.ts`](tests/frame.spec.ts) | 边框线、徽标、正文行,以及某个宽度容纳得下的按键提示 |
@@ -345,14 +345,26 @@ function contentText(blocks) {
345
345
  }).filter((part) => part !== "").join("\n");
346
346
  }
347
347
  /**
348
- * Compact token count: `950`, `1.2k`, `3.4M`.
348
+ * Compact token count with a thousands/millions/billions unit: `950`, `1.2k`,
349
+ * `12.3k`, `3.4M`, `1.2B`. A trailing `.0` is dropped so `1000` reads `1k`.
349
350
  * @param count - a non-negative token count.
350
351
  * @returns the formatted count.
351
352
  */
352
353
  function formatTokens(count) {
353
354
  if (count < 1e3) return String(count);
354
- if (count < 1e6) return `${(count / 1e3).toFixed(count < 1e4 ? 1 : 0)}k`;
355
- return `${(count / 1e6).toFixed(1)}M`;
355
+ if (count < 1e6) return formatScaled(count / 1e3, "k");
356
+ if (count < 1e9) return formatScaled(count / 1e6, "M");
357
+ return formatScaled(count / 1e9, "B");
358
+ }
359
+ /**
360
+ * One decimal place and a unit letter, dropping a trailing `.0`.
361
+ * @param value - the count already divided by the unit's base.
362
+ * @param unit - `k`, `M`, or `B`.
363
+ * @returns the compact count.
364
+ */
365
+ function formatScaled(value, unit) {
366
+ const fixed = value.toFixed(1);
367
+ return `${fixed.endsWith(".0") ? fixed.slice(0, -2) : fixed}${unit}`;
356
368
  }
357
369
  /**
358
370
  * Compact elapsed time for the live counters: `0s`, `8s`, `1m12s`, `1h04m`,
@@ -391,6 +403,59 @@ const EMPTY_USAGE = {
391
403
  cacheReadTokens: 0,
392
404
  lastInputTokens: 0
393
405
  };
406
+ /** Characters treated as one token when the provider has not yet reported usage. */
407
+ const CHARS_PER_TOKEN = 4;
408
+ /**
409
+ * Approximate a token count from streamed character length, the same 4-chars
410
+ * rule the Cursor adapter uses when a provider omits prompt usage.
411
+ * @param chars - non-negative character count; a negative value counts as 0.
412
+ * @returns `ceil(chars / 4)`.
413
+ */
414
+ function estimateTokens(chars) {
415
+ return Math.ceil(Math.max(0, chars) / CHARS_PER_TOKEN);
416
+ }
417
+ /** Prompt tokens occupying the context window: uncached input plus cache read. */
418
+ function promptTokens(usage) {
419
+ return usage.inputTokens + (usage.cacheReadTokens ?? 0);
420
+ }
421
+ /**
422
+ * Billed prompt tokens of one usage record: uncached input plus cache read
423
+ * and cache write.
424
+ * @param usage - one model call's usage.
425
+ * @returns the billed send count.
426
+ */
427
+ function billedInputTokens(usage) {
428
+ return promptTokens(usage) + (usage.cacheWriteTokens ?? 0);
429
+ }
430
+ /**
431
+ * Fold an in-flight model call into the session totals for the footer.
432
+ * @param totals - committed totals so far.
433
+ * @param live - the current call; absent leaves `totals` unchanged.
434
+ * @returns the totals the footer should draw right now.
435
+ */
436
+ function withLiveUsage(totals, live) {
437
+ if (live === void 0) return totals;
438
+ const prompt = promptTokens(live);
439
+ return {
440
+ inputTokens: totals.inputTokens + live.inputTokens,
441
+ outputTokens: totals.outputTokens + live.outputTokens,
442
+ cacheReadTokens: totals.cacheReadTokens + (live.cacheReadTokens ?? 0),
443
+ lastInputTokens: prompt > 0 ? prompt : totals.lastInputTokens
444
+ };
445
+ }
446
+ /**
447
+ * The ↑send ↓receive suffix the working spinner draws for the current call.
448
+ * @param usage - the in-flight call; absent or zero draws nothing.
449
+ * @returns the suffix without a leading space, or the empty string.
450
+ */
451
+ function formatLiveUsage(usage) {
452
+ if (usage === void 0) return "";
453
+ const send = billedInputTokens(usage);
454
+ const parts = [];
455
+ if (send > 0) parts.push(`↑${formatTokens(send)}`);
456
+ if (usage.outputTokens > 0) parts.push(`↓${formatTokens(usage.outputTokens)}`);
457
+ return parts.length === 0 ? "" : `${parts.join(" ")} tokens`;
458
+ }
394
459
  /**
395
460
  * Fold one committed usage record into the totals.
396
461
  * @param totals - the totals so far.
@@ -402,7 +467,7 @@ function addUsage(totals, usage) {
402
467
  inputTokens: totals.inputTokens + usage.inputTokens,
403
468
  outputTokens: totals.outputTokens + usage.outputTokens,
404
469
  cacheReadTokens: totals.cacheReadTokens + (usage.cacheReadTokens ?? 0),
405
- lastInputTokens: usage.inputTokens + (usage.cacheReadTokens ?? 0)
470
+ lastInputTokens: promptTokens(usage)
406
471
  };
407
472
  }
408
473
  /**
@@ -3047,13 +3112,13 @@ var AssistantBlock = class {
3047
3112
  * A tool call card: status glyph, tool name, headline, then a foldable body.
3048
3113
  *
3049
3114
  * The card arrives in two pieces, and each floats out on its own: the header
3050
- * and the call rows when the call is logged, the result rows when the tool
3051
- * answers. A card rebuilt from history carries neither fade.
3115
+ * and the call rows when the model starts the call (a stream delta, or the
3116
+ * logged `tool/call`), the result rows when the tool answers. While it runs
3117
+ * the body carries {@link TOOL_RUNNING_ROW} in place of a result. A card
3118
+ * rebuilt from history carries neither fade.
3052
3119
  */
3053
3120
  var ToolBlock = class {
3054
3121
  theme;
3055
- name;
3056
- call;
3057
3122
  turn;
3058
3123
  navigable = true;
3059
3124
  blockKind = "tool";
@@ -3073,13 +3138,19 @@ var ToolBlock = class {
3073
3138
  highlightLevel = 0;
3074
3139
  /** The coloured, folded, wrapped body, by width, fold, focus, status, and result. */
3075
3140
  drawn = new LastDrawn();
3076
- /** Counts every result the card was given. */
3141
+ /** Counts every call or result the card was given. */
3077
3142
  revision = 0;
3143
+ toolName;
3144
+ call;
3078
3145
  constructor(theme, name, call, turn) {
3079
3146
  this.theme = theme;
3080
- this.name = name;
3081
- this.call = call;
3082
3147
  this.turn = turn;
3148
+ this.toolName = name;
3149
+ this.call = call;
3150
+ }
3151
+ /** The tool the model called. */
3152
+ get name() {
3153
+ return this.toolName;
3083
3154
  }
3084
3155
  /** The card headline, as the section heading names this call. */
3085
3156
  get title() {
@@ -3111,6 +3182,17 @@ var ToolBlock = class {
3111
3182
  this.highlightLevel = level;
3112
3183
  }
3113
3184
  /**
3185
+ * Replace the call half as streamed arguments arrive or the logged call
3186
+ * confirms them.
3187
+ * @param name - the tool the model called.
3188
+ * @param call - the headline and rows for those arguments.
3189
+ */
3190
+ setCall(name, call) {
3191
+ this.toolName = name;
3192
+ this.call = call;
3193
+ this.revision += 1;
3194
+ }
3195
+ /**
3114
3196
  * Draw the header and the call rows through `fade` until it settles.
3115
3197
  * @param fade - the level and drawing settings of this card's own fade.
3116
3198
  */
@@ -3204,12 +3286,21 @@ var ToolBlock = class {
3204
3286
  */
3205
3287
  layout(outer, marked) {
3206
3288
  const palette = this.theme.palette;
3207
- const header = `${this.status === "running" ? palette.warning("●") : this.status === "done" ? palette.success("●") : palette.error("●")} ${palette.bold(this.name)}${this.call.title === "" ? "" : ` ${palette.dim(this.call.title)}`}`;
3208
- const body = [...this.call.lines, ...this.resultLines];
3209
- const code = this.call.code === void 0 && this.resultCode === void 0 ? void 0 : [...this.call.code ?? new Array(this.call.lines.length).fill(void 0), ...this.resultCode ?? new Array(this.resultLines.length).fill(void 0)];
3289
+ const header = `${this.status === "running" ? palette.warning("●") : this.status === "done" ? palette.success("●") : palette.error("●")} ${palette.bold(this.toolName)}${this.call.title === "" ? "" : ` ${palette.dim(this.call.title)}`}`;
3290
+ const loading = this.status === "running" ? ["…"] : [];
3291
+ const body = [
3292
+ ...this.call.lines,
3293
+ ...loading,
3294
+ ...this.resultLines
3295
+ ];
3296
+ const code = this.call.code === void 0 && this.resultCode === void 0 ? void 0 : [
3297
+ ...this.call.code ?? new Array(this.call.lines.length).fill(void 0),
3298
+ ...new Array(loading.length).fill(void 0),
3299
+ ...this.resultCode ?? new Array(this.resultLines.length).fill(void 0)
3300
+ ];
3210
3301
  const kept = this.expanded ? body : foldRows(body, this.theme.toolPreviewLines, (hidden) => foldMarker(hidden, marked ? "marked" : "transcript"));
3211
3302
  const shown = paintDiffRows(paintCodeRows(kept, code, this.theme.codeHighlight), kept, palette);
3212
- const callCount = Math.min(this.call.lines.length, shown.length);
3303
+ const callCount = Math.min(this.call.lines.length + loading.length, shown.length);
3213
3304
  const inner = Math.max(1, outer - 4);
3214
3305
  const rows = (lines) => lines.flatMap((line) => wrapTextWithAnsi(line, inner).map((part) => ` ${palette.dim("│")} ${part}`));
3215
3306
  const call = [...wrapTextWithAnsi(header, outer), ...rows(shown.slice(0, callCount))];
@@ -4450,7 +4541,7 @@ const READ_CHIP = "READ";
4450
4541
  /** Columns a body row spends on the frame's left border and the space after it. */
4451
4542
  const BODY_MARGIN = 2;
4452
4543
  /** What separates two labels of the parts strip. */
4453
- const SEPARATOR$3 = " · ";
4544
+ const SEPARATOR$4 = " · ";
4454
4545
  /** What the heading appends while the focused block lies outside the repaint window. */
4455
4546
  const OFF_SCREEN = " · off screen";
4456
4547
  /** Opens the numbered parts strip, so Left/Right read as a walk along this row. */
@@ -4525,7 +4616,7 @@ function partsStrip(parts, palette, width) {
4525
4616
  const text = `${String(index + 1)} ${part.label}`;
4526
4617
  return part.focused ? palette.accent(`[${text}]`) : palette.dim(text);
4527
4618
  });
4528
- const sep = palette.dim(SEPARATOR$3);
4619
+ const sep = palette.dim(SEPARATOR$4);
4529
4620
  const indent = palette.dim(" ");
4530
4621
  const end = palette.dim(STRIP_END);
4531
4622
  const indentWidth = visibleWidth(" ");
@@ -4544,7 +4635,7 @@ function partsStrip(parts, palette, width) {
4544
4635
  if (token === void 0) continue;
4545
4636
  const extra = index === tokens.length - 1 ? endWidth : 0;
4546
4637
  let leading = index === 0 || current === indent ? "" : sep;
4547
- let leadingWidth = leading === "" ? 0 : visibleWidth(SEPARATOR$3);
4638
+ let leadingWidth = leading === "" ? 0 : visibleWidth(SEPARATOR$4);
4548
4639
  const tokenWidth = visibleWidth(token);
4549
4640
  if (used + leadingWidth + tokenWidth + extra > width && used > indentWidth) {
4550
4641
  startLine();
@@ -4626,7 +4717,7 @@ var InspectorPane = class {
4626
4717
  * @module @deepseek-ai/dsh-tui-app/navigation
4627
4718
  */
4628
4719
  /** What separates two facts inside one heading. */
4629
- const SEPARATOR$2 = " · ";
4720
+ const SEPARATOR$3 = " · ";
4630
4721
  /**
4631
4722
  * Whether one transcript child is navigable.
4632
4723
  * @param child - a child of the transcript container.
@@ -4979,7 +5070,7 @@ function subjectOf(block, part) {
4979
5070
  * @returns the label, e.g. `bash git status · result`.
4980
5071
  */
4981
5072
  function sectionLabel(block, part) {
4982
- return subjectOf(block, part).join(SEPARATOR$2);
5073
+ return subjectOf(block, part).join(SEPARATOR$3);
4983
5074
  }
4984
5075
  /**
4985
5076
  * The inspector heading of the held section: its position in the transcript,
@@ -4996,7 +5087,7 @@ function sectionHeading(cursor, blocks) {
4996
5087
  `${String(cursor.block + 1)}/${String(blocks.length)}`,
4997
5088
  `turn ${String(block.turn)}`,
4998
5089
  sectionLabel(block, part)
4999
- ].join(SEPARATOR$2);
5090
+ ].join(SEPARATOR$3);
5000
5091
  }
5001
5092
  /**
5002
5093
  * The parts strip of the held block.
@@ -5435,7 +5526,7 @@ function plural(count, noun) {
5435
5526
  /** The segment focus enters the bar on; `buildFooterSegments` always emits it first. */
5436
5527
  const FIRST_FOOTER_SEGMENT = "model";
5437
5528
  /** What separates two segments, and two parts inside a hint line. */
5438
- const SEPARATOR$1 = " · ";
5529
+ const SEPARATOR$2 = " · ";
5439
5530
  /**
5440
5531
  * Longest workspace label the bar draws in full. A wider path keeps its last
5441
5532
  * two segments behind `…/` so one long project path cannot crowd out the
@@ -5586,7 +5677,7 @@ function buildFooterSegments(inputs) {
5586
5677
  `turn ${String(turn.number)}`,
5587
5678
  `started: ${formatTimestamp(turn.startedAt)}`,
5588
5679
  `elapsed: ${turn.elapsed}`,
5589
- `queued: ${String(turn.queuedNextTurn)} for the next turn${SEPARATOR$1}${String(turn.queuedNextStep)} for the next step`
5680
+ `queued: ${String(turn.queuedNextTurn)} for the next turn${SEPARATOR$2}${String(turn.queuedNextStep)} for the next step`
5590
5681
  ])
5591
5682
  });
5592
5683
  if (inputs.usage !== "") segments.push({
@@ -5622,7 +5713,7 @@ function buildFooterSegments(inputs) {
5622
5713
  if (inputs.attachments.length > 0) segments.push({
5623
5714
  id: "attachments",
5624
5715
  label: `${String(inputs.attachments.length)} attached`,
5625
- detail: printed([...inputs.attachments.map((attachment) => `${attachment.kind}: ${attachment.name}`), `/attach <path> adds one${SEPARATOR$1}/attach clear drops them all`])
5716
+ detail: printed([...inputs.attachments.map((attachment) => `${attachment.kind}: ${attachment.name}`), `/attach <path> adds one${SEPARATOR$2}/attach clear drops them all`])
5626
5717
  });
5627
5718
  return segments;
5628
5719
  }
@@ -5712,7 +5803,7 @@ function middleFacts(facts, hidden, room) {
5712
5803
  const drawn = [];
5713
5804
  let used = 0;
5714
5805
  for (const label of facts) {
5715
- const cost = visibleWidth(SEPARATOR$1) + visibleWidth(label);
5806
+ const cost = visibleWidth(SEPARATOR$2) + visibleWidth(label);
5716
5807
  if (used + cost > room) break;
5717
5808
  used += cost;
5718
5809
  drawn.push(label);
@@ -5720,9 +5811,9 @@ function middleFacts(facts, hidden, room) {
5720
5811
  let folded = hidden + facts.length - drawn.length;
5721
5812
  if (folded === 0) return drawn;
5722
5813
  const token = () => `+${String(folded)}`;
5723
- const fits = () => used + visibleWidth(SEPARATOR$1) + visibleWidth(token()) <= room;
5814
+ const fits = () => used + visibleWidth(SEPARATOR$2) + visibleWidth(token()) <= room;
5724
5815
  while (!fits() && drawn.length > 0) {
5725
- used -= visibleWidth(SEPARATOR$1) + visibleWidth(drawn.pop());
5816
+ used -= visibleWidth(SEPARATOR$2) + visibleWidth(drawn.pop());
5726
5817
  folded += 1;
5727
5818
  }
5728
5819
  if (fits()) drawn.push(token());
@@ -5744,7 +5835,7 @@ function unfocusedLine(segments, palette, width) {
5744
5835
  const reserved = hint === "" ? 0 : visibleWidth(hint) + HINT_GAP;
5745
5836
  const facts = rest.filter((segment) => KEY_SEGMENT_IDS.has(segment.id)).map((segment) => segment.label);
5746
5837
  const drawn = middleFacts(facts, rest.length - facts.length, width - visibleWidth(model) - reserved);
5747
- const left = palette.dim([model, ...drawn].filter((token) => token !== "").join(SEPARATOR$1));
5838
+ const left = palette.dim([model, ...drawn].filter((token) => token !== "").join(SEPARATOR$2));
5748
5839
  if (hint === "") return fitLine(left, width);
5749
5840
  return fitLine(`${left}${" ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(hint)))}${palette.dim(hint)}`, width);
5750
5841
  }
@@ -5771,7 +5862,7 @@ function expansionBody(segment) {
5771
5862
  function expansionLine(segment, palette, width) {
5772
5863
  const body = expansionBody(segment);
5773
5864
  const legend = fitLegend(HINTS.bar, width);
5774
- const suffix = palette.dim(body === "" ? legend : `${SEPARATOR$1}${legend}`);
5865
+ const suffix = palette.dim(body === "" ? legend : `${SEPARATOR$2}${legend}`);
5775
5866
  const prefix = palette.dim(body);
5776
5867
  const rest = width - visibleWidth(suffix);
5777
5868
  if (rest < 1) return fitLine(`${prefix}${suffix}`, width);
@@ -5820,8 +5911,8 @@ function fitSelected(text, room) {
5820
5911
  */
5821
5912
  function focusedWindow(rest, held, palette, room, level) {
5822
5913
  if (rest.length === 0) return "";
5823
- const sep = palette.dim(SEPARATOR$1);
5824
- const sepWidth = visibleWidth(SEPARATOR$1);
5914
+ const sep = palette.dim(SEPARATOR$2);
5915
+ const sepWidth = visibleWidth(SEPARATOR$2);
5825
5916
  const selected = Math.max(0, held);
5826
5917
  const budget = room - sepWidth;
5827
5918
  const cap = budget - (selected < rest.length - 1 ? WINDOW_MARK_WIDTH : 0);
@@ -6430,6 +6521,97 @@ var ModalQueue = class {
6430
6521
  this.active?.withdraw();
6431
6522
  }
6432
6523
  };
6524
+ /** What separates two facts on the descendant line. */
6525
+ const SEPARATOR$1 = " · ";
6526
+ /**
6527
+ * Build one board draw: todos in write order cut to
6528
+ * {@link ACTIVITY_BOARD_MAX_TODOS}, plus the formatted descendant line.
6529
+ * @param inputs - the current list and the optional descendant fact.
6530
+ * @returns the drawn rows, the count they left out, and the descendant line.
6531
+ */
6532
+ function activityBoardView(inputs) {
6533
+ const todos = inputs.todos.slice(0, 4).map(rowOf$1);
6534
+ return {
6535
+ todos,
6536
+ hidden: inputs.todos.length - todos.length,
6537
+ ...inputs.subagent === void 0 ? {} : { subagent: formatActivitySubagentLine(inputs.subagent) }
6538
+ };
6539
+ }
6540
+ /**
6541
+ * One todo as a board row.
6542
+ * @param item - the current list item.
6543
+ * @returns the row.
6544
+ */
6545
+ function rowOf$1(item) {
6546
+ return {
6547
+ content: item.content,
6548
+ status: item.status,
6549
+ text: `${TODO_GLYPH[item.status]} ${item.content}`
6550
+ };
6551
+ }
6552
+ /**
6553
+ * Join the descendant line's parts, dropping an empty summary.
6554
+ * @param line - the label, status word, and optional summary.
6555
+ * @returns `{label} · {status}` or `{label} · {status} · {summary}`.
6556
+ */
6557
+ function formatActivitySubagentLine(line) {
6558
+ const parts = [line.label, line.status];
6559
+ if (line.summary !== void 0 && line.summary !== "") parts.push(line.summary);
6560
+ return parts.join(SEPARATOR$1);
6561
+ }
6562
+ /**
6563
+ * The status and summary one tool result draws on the descendant line.
6564
+ * @param firstRow - the first presented result row, when the result had one.
6565
+ * @param isError - whether the result is an error.
6566
+ * @returns `error` plus the row, the row alone, or `done` when the result had no row.
6567
+ */
6568
+ function activityResultParts(firstRow, isError) {
6569
+ if (isError) return firstRow === void 0 || firstRow === "" ? { status: "error" } : {
6570
+ status: "error",
6571
+ summary: firstRow
6572
+ };
6573
+ return { status: firstRow === void 0 || firstRow === "" ? "done" : firstRow };
6574
+ }
6575
+ /**
6576
+ * The status word a child `turn/end` draws: the existing notice, or `done`.
6577
+ * @param reason - the durable turn-end reason.
6578
+ * @returns the notice text, or `done` for an ordinary completion.
6579
+ */
6580
+ function activityTurnEndStatus(reason) {
6581
+ return turnEndNotice(reason) ?? "done";
6582
+ }
6583
+ /**
6584
+ * Render the board. Todo rows lead with the shared status glyphs; completed
6585
+ * content is dim and scratched out. A list past the cap ends on `+<n> more`.
6586
+ * The descendant line is last. An empty view returns the empty string so the
6587
+ * slot can unmount.
6588
+ * @param view - the rows one draw produced.
6589
+ * @param render - the palette and the fades still moving.
6590
+ * @returns the board text, or the empty string when nothing is drawn.
6591
+ */
6592
+ function renderActivityBoard(view, render) {
6593
+ const { palette } = render;
6594
+ const lines = [];
6595
+ for (const row of view.todos) {
6596
+ const content = paintTodoContent(row.content, row.status, (text) => palette.dim(palette.strikethrough(text)));
6597
+ lines.push(fadedLine(`${TODO_GLYPH[row.status]} ${content}`, render.todoFades?.get(row.content)));
6598
+ }
6599
+ if (view.hidden > 0) lines.push(palette.dim(`+${String(view.hidden)} more`));
6600
+ if (view.subagent !== void 0) lines.push(fadedLine(palette.dim(view.subagent), render.subagentFade));
6601
+ return lines.join("\n");
6602
+ }
6603
+ /**
6604
+ * Draw one row at the mix its fade reports.
6605
+ * @param text - the settled row.
6606
+ * @param fade - the row's fade; absent for a row that never faded.
6607
+ * @returns the row at that mix, or `text` once the fade settled or was never attached.
6608
+ */
6609
+ function fadedLine(text, fade) {
6610
+ if (fade === void 0) return text;
6611
+ const age = fade.age();
6612
+ if (age === void 0) return text;
6613
+ return recolorLines([text], age, fade.style(), 0).join("\n");
6614
+ }
6433
6615
  //#endregion
6434
6616
  //#region lib/types/queue-panel.js
6435
6617
  /**
@@ -8285,14 +8467,15 @@ var ToastPane = class {
8285
8467
  * The interactive terminal application: it renders the durable session log
8286
8468
  * and the live assistant stream of one Agent at a time into a pi-tui tree,
8287
8469
  * turns keystrokes into agent input, answers the approval and user-questions
8288
- * seams for that Agent, and switches between sessions through its host. Under
8289
- * the editor it keeps two docked regions the keyboard can take over — the
8290
- * subagent panel and the status bar — and one repeating tick advances their
8291
- * elapsed counters and re-reads a stale subagent listing. A second tick, at
8292
- * its own period, brightens streamed reply text and floats out reasoning and
8293
- * tool cards that just landed, each only as far up the frame as the
8294
- * renderer repaints without discarding the terminal's scrollback
8295
- * (`./screen.ts`).
8470
+ * seams for that Agent, and switches between sessions through its host. Above
8471
+ * the editor it draws an activity board of the open turn's todos and the
8472
+ * latest descendant line. Under the editor it keeps two docked regions the
8473
+ * keyboard can take over — the subagent panel and the status bar — and one
8474
+ * repeating tick advances their elapsed counters and re-reads a stale
8475
+ * subagent listing. A second tick, at its own period, brightens streamed
8476
+ * reply text and floats out reasoning, tool cards, and activity-board rows
8477
+ * that just landed, each only as far up the frame as the renderer repaints
8478
+ * without discarding the terminal's scrollback (`./screen.ts`).
8296
8479
  * @module @deepseek-ai/dsh-tui-app/app
8297
8480
  */
8298
8481
  /** A second Ctrl+C inside this window quits. */
@@ -8542,6 +8725,22 @@ function isSubscriptionMethod(method) {
8542
8725
  const SHELL_MISSING = "! needs a shell executor in this composition";
8543
8726
  /** Shown when a second `!` is submitted while one is still running. */
8544
8727
  const SHELL_BUSY = "A shell command is already running. Press Esc to cancel it first.";
8728
+ /**
8729
+ * Spinner word for a streamed or executing tool.
8730
+ * @param name - the tool name when one is known.
8731
+ * @returns `calling <name>`, or `calling` when the name has not arrived.
8732
+ */
8733
+ function callingActivity(name) {
8734
+ return name ? `calling ${name}` : "calling";
8735
+ }
8736
+ /**
8737
+ * Whether the spinner is already naming a tool call.
8738
+ * @param activity - the current spinner word.
8739
+ * @returns true for `calling` and `calling <name>`.
8740
+ */
8741
+ function isCallingActivity(activity) {
8742
+ return activity === "calling" || activity.startsWith("calling ");
8743
+ }
8545
8744
  /** The interactive terminal application; one instance per process. */
8546
8745
  var TuiApp = class {
8547
8746
  deps;
@@ -8556,8 +8755,16 @@ var TuiApp = class {
8556
8755
  editor;
8557
8756
  /** Holds {@link queue} exactly while the bound Agent's inbox has a prompt waiting. */
8558
8757
  queueSlot = new Container();
8758
+ /**
8759
+ * Holds {@link activity} exactly while the open turn has todo rows or a
8760
+ * latest-descendant line, so the editor sits directly under the conversation
8761
+ * the rest of the time.
8762
+ */
8763
+ activitySlot = new Container();
8559
8764
  /** The prompts queued for the next turn or step, drawn above the editor until the loop claims them. */
8560
8765
  queue;
8766
+ /** Current-turn todos and the latest descendant line, drawn above the editor. */
8767
+ activity;
8561
8768
  /** Rows of the last queued-prompt draw, in claim order. */
8562
8769
  queueView = [];
8563
8770
  /** Pending prompt held while the queue panel owns the keyboard. */
@@ -8580,10 +8787,26 @@ var TuiApp = class {
8580
8787
  theme;
8581
8788
  toolBlocks = /* @__PURE__ */ new Map();
8582
8789
  toolArguments = /* @__PURE__ */ new Map();
8790
+ /** Raw argument text accumulated from `tool-call-delta` chunks, keyed by call id. */
8791
+ toolStreamArgs = /* @__PURE__ */ new Map();
8792
+ /** Cards mounted from the live stream that no logged `tool/call` has confirmed yet. */
8793
+ unconfirmedTools = /* @__PURE__ */ new Map();
8583
8794
  submittedIds = /* @__PURE__ */ new Set();
8584
8795
  disposers = [];
8585
8796
  /** Turn facts of the bound session's todo lines, keyed by content. */
8586
8797
  todoTurns = /* @__PURE__ */ new Map();
8798
+ /** Todos the activity board draws for the open turn, from the `todos` projection. */
8799
+ activityTodos = [];
8800
+ /** Status last drawn for each activity-board todo, keyed by content. */
8801
+ activityTodoStatus = /* @__PURE__ */ new Map();
8802
+ /** Fades of todo rows that are still moving, keyed by content. */
8803
+ activityTodoFades = /* @__PURE__ */ new Map();
8804
+ /** Latest descendant line the activity board draws; absent before one lands. */
8805
+ activitySubagent;
8806
+ /** Fade of the descendant line while it is still moving. */
8807
+ activitySubagentFade;
8808
+ /** The last descendant `tool/call` the board saw, for presenting its result. */
8809
+ activityChildCall;
8587
8810
  /** The turn the last logged `turn/start` opened; 0 before the first one. */
8588
8811
  turn = 0;
8589
8812
  /** Whether a nonempty system prompt has already been drawn in this transcript. */
@@ -8679,6 +8902,16 @@ var TuiApp = class {
8679
8902
  /** Serializes `/attach` reads so pending attachments keep the typed order. */
8680
8903
  attaching = Promise.resolve();
8681
8904
  usage = EMPTY_USAGE;
8905
+ /** The in-flight model call's tokens, shown on the spinner and in the footer. */
8906
+ liveUsage;
8907
+ /** Streamed characters of the current call, used until a usage chunk arrives. */
8908
+ streamedChars = 0;
8909
+ /** Whether {@link TuiApp.liveUsage} came from a provider `usage` chunk. */
8910
+ usageExact = false;
8911
+ /** Spinner label without the live ↑↓ suffix (`thinking`, `writing`, `calling read`, …). */
8912
+ loaderActivity = "thinking";
8913
+ /** Tool names still streamed or executing, in first-seen order. */
8914
+ pendingToolNames = /* @__PURE__ */ new Map();
8682
8915
  lastCtrlC = 0;
8683
8916
  stopped = false;
8684
8917
  constructor(deps) {
@@ -8725,6 +8958,7 @@ var TuiApp = class {
8725
8958
  this.syncEditorBorder();
8726
8959
  };
8727
8960
  this.queue = new Text("", 0, 0);
8961
+ this.activity = new Text("", 0, 0);
8728
8962
  this.panel = new Text("", 0, 0);
8729
8963
  this.footer = new FooterBar(() => ({
8730
8964
  segments: this.segments,
@@ -8748,6 +8982,7 @@ var TuiApp = class {
8748
8982
  this.modalSlot,
8749
8983
  this.inspector,
8750
8984
  this.queueSlot,
8985
+ this.activitySlot,
8751
8986
  this.editor,
8752
8987
  this.panelSlot,
8753
8988
  this.footer
@@ -8775,10 +9010,18 @@ var TuiApp = class {
8775
9010
  return;
8776
9011
  }
8777
9012
  this.setWorking(status === "running");
8778
- }), ctx.on("subagent/start", () => {
9013
+ }), ctx.on("subagent/start", (info) => {
8779
9014
  this.markSubagentsStale();
8780
- }), ctx.on("subagent/end", () => {
9015
+ if (this.isBoundDescendantId(info.id)) this.setActivitySubagent({
9016
+ label: this.activityLabelFor(info.id),
9017
+ status: "running"
9018
+ });
9019
+ }), ctx.on("subagent/end", (info) => {
8781
9020
  this.markSubagentsStale();
9021
+ if (this.isBoundDescendantId(info.id)) this.setActivitySubagent({
9022
+ label: this.activityLabelFor(info.id),
9023
+ status: info.stopReason
9024
+ });
8782
9025
  }), ctx.on("agent/inbox/inserted", ({ agent: subject }) => {
8783
9026
  if (subject === this.agent) this.refreshQueue();
8784
9027
  }), ctx.on("agent/inbox/claimed", ({ agent: subject }) => {
@@ -8876,6 +9119,9 @@ var TuiApp = class {
8876
9119
  this.chat.clear();
8877
9120
  this.toolBlocks.clear();
8878
9121
  this.toolArguments.clear();
9122
+ this.toolStreamArgs.clear();
9123
+ this.unconfirmedTools.clear();
9124
+ this.pendingToolNames.clear();
8879
9125
  this.submittedIds.clear();
8880
9126
  this.todoTurns.clear();
8881
9127
  this.turn = 0;
@@ -8885,9 +9131,11 @@ var TuiApp = class {
8885
9131
  this.endFade();
8886
9132
  this.blockFades.clear();
8887
9133
  this.usage = EMPTY_USAGE;
9134
+ this.clearLiveUsage();
8888
9135
  this.pending = [];
8889
9136
  this.queueView = [];
8890
9137
  this.queueSelection = void 0;
9138
+ this.clearActivityBoard();
8891
9139
  this.subagentEntries = [];
8892
9140
  this.panelSelection = void 0;
8893
9141
  this.listingFailure = void 0;
@@ -8989,9 +9237,13 @@ var TuiApp = class {
8989
9237
  this.statusSlot.addChild(this.loader);
8990
9238
  this.loader.start();
8991
9239
  }
9240
+ this.refreshLoader();
8992
9241
  } else if (this.statusSlot.children.length > 0) {
8993
9242
  this.loader.stop();
8994
9243
  this.statusSlot.removeChild(this.loader);
9244
+ this.pendingToolNames.clear();
9245
+ this.loaderActivity = "thinking";
9246
+ this.clearLiveUsage();
8995
9247
  this.loader.setMessage("thinking");
8996
9248
  }
8997
9249
  this.tui.requestRender();
@@ -9018,7 +9270,7 @@ var TuiApp = class {
9018
9270
  queuedNextTurn: inbox.nextTurn.length,
9019
9271
  queuedNextStep: inbox.nextStep.length
9020
9272
  } },
9021
- usage: formatUsage(this.usage),
9273
+ usage: formatUsage(withLiveUsage(this.usage, this.liveUsage)),
9022
9274
  facts: this.statusFacts(),
9023
9275
  cwd: this.deps.cwd,
9024
9276
  home: this.home,
@@ -9056,6 +9308,153 @@ var TuiApp = class {
9056
9308
  this.tui.requestRender();
9057
9309
  }
9058
9310
  /**
9311
+ * Redraw the activity board above the editor from the open turn's todos and
9312
+ * the latest descendant line. The slot is mounted exactly while a row
9313
+ * draws, so the editor sits directly under follow-ups or the conversation
9314
+ * the rest of the time.
9315
+ */
9316
+ refreshActivityBoard() {
9317
+ const text = renderActivityBoard(activityBoardView({
9318
+ todos: this.activityTodos,
9319
+ ...this.activitySubagent === void 0 ? {} : { subagent: this.activitySubagent }
9320
+ }), {
9321
+ palette: this.deps.palette,
9322
+ todoFades: this.activityTodoFades,
9323
+ ...this.activitySubagentFade === void 0 ? {} : { subagentFade: this.activitySubagentFade }
9324
+ });
9325
+ const mounted = this.activitySlot.children.length > 0;
9326
+ if (text === "") {
9327
+ if (mounted) this.activitySlot.removeChild(this.activity);
9328
+ } else {
9329
+ if (!mounted) this.activitySlot.addChild(this.activity);
9330
+ this.activity.setText(text);
9331
+ }
9332
+ this.tui.requestRender();
9333
+ }
9334
+ /**
9335
+ * Replace the board's todos from the same `todos` projection `/todos` reads
9336
+ * and fade rows that are new or that changed status.
9337
+ */
9338
+ syncActivityTodos() {
9339
+ const items = this.statusFacts().todos?.items ?? [];
9340
+ const fades = /* @__PURE__ */ new Map();
9341
+ const statuses = /* @__PURE__ */ new Map();
9342
+ for (const item of items) {
9343
+ const previous = this.activityTodoStatus.get(item.content);
9344
+ if (previous === void 0 || previous !== item.status) this.fadeBlock((fade) => {
9345
+ fades.set(item.content, fade);
9346
+ });
9347
+ else {
9348
+ const existing = this.activityTodoFades.get(item.content);
9349
+ if (existing !== void 0) fades.set(item.content, existing);
9350
+ }
9351
+ statuses.set(item.content, item.status);
9352
+ }
9353
+ this.activityTodos = items;
9354
+ this.activityTodoFades = fades;
9355
+ this.activityTodoStatus = statuses;
9356
+ this.refreshActivityBoard();
9357
+ }
9358
+ /**
9359
+ * Replace the one descendant line, fading it when the text changed.
9360
+ * @param line - the label, status word, and optional summary.
9361
+ */
9362
+ setActivitySubagent(line) {
9363
+ const next = formatActivitySubagentLine(line);
9364
+ const previous = this.activitySubagent === void 0 ? void 0 : formatActivitySubagentLine(this.activitySubagent);
9365
+ this.activitySubagent = line;
9366
+ if (next !== previous) {
9367
+ this.activitySubagentFade = void 0;
9368
+ this.fadeBlock((fade) => {
9369
+ this.activitySubagentFade = fade;
9370
+ });
9371
+ }
9372
+ this.refreshActivityBoard();
9373
+ }
9374
+ /** Drop the open-turn board so bind and turn edges leave no stale rows. */
9375
+ clearActivityBoard() {
9376
+ this.activityTodos = [];
9377
+ this.activityTodoStatus = /* @__PURE__ */ new Map();
9378
+ this.activityTodoFades = /* @__PURE__ */ new Map();
9379
+ this.activitySubagent = void 0;
9380
+ this.activitySubagentFade = void 0;
9381
+ this.activityChildCall = void 0;
9382
+ this.refreshActivityBoard();
9383
+ }
9384
+ /**
9385
+ * Whether `id` belongs under the bound session: a listing entry, or a
9386
+ * live child whose header parent is the bound session.
9387
+ * @param id - the session id a lifecycle event named.
9388
+ * @returns true when the activity board may show that child's status word.
9389
+ */
9390
+ isBoundDescendantId(id) {
9391
+ if (this.subagentEntries.some((entry) => entry.id === id)) return true;
9392
+ const child = this.deps.ctx.get("agents")?.get(id);
9393
+ return child !== void 0 && child.session.header.parentSession === this.agent.session.id;
9394
+ }
9395
+ /**
9396
+ * Whether `session` is a descendant of the bound session: a listing entry,
9397
+ * or a header whose parent is the bound session.
9398
+ * @param session - the session that just logged an event.
9399
+ * @returns true when the activity board may show that session's latest line.
9400
+ */
9401
+ isBoundDescendant(session) {
9402
+ return this.isBoundDescendantId(session.id) || session.header.parentSession === this.agent.session.id;
9403
+ }
9404
+ /**
9405
+ * The listing label for a descendant, or its session id when the listing
9406
+ * has not named it.
9407
+ * @param id - the descendant session id.
9408
+ * @returns the board's label for that child.
9409
+ */
9410
+ activityLabelFor(id) {
9411
+ const entry = this.subagentEntries.find((candidate) => candidate.id === id);
9412
+ return entry?.kind === "child" && entry.label !== void 0 ? entry.label : id;
9413
+ }
9414
+ /**
9415
+ * Replace the descendant line from a child session event. Assistant prose
9416
+ * is ignored; only tool calls, tool results, and turn ends update the line.
9417
+ * @param session - the descendant that logged `event`.
9418
+ * @param event - the durable event.
9419
+ */
9420
+ onDescendantActivity(session, event) {
9421
+ switch (event.type) {
9422
+ case "tool/call": {
9423
+ const { name, arguments: argumentsJson } = event.data;
9424
+ const args = parseArguments(argumentsJson);
9425
+ this.activityChildCall = {
9426
+ name,
9427
+ args
9428
+ };
9429
+ const title = args === void 0 ? void 0 : this.presentCall(name, args)?.title;
9430
+ this.setActivitySubagent({
9431
+ label: this.activityLabelFor(session.id),
9432
+ status: callingActivity(name),
9433
+ ...title === void 0 ? {} : { summary: title }
9434
+ });
9435
+ return;
9436
+ }
9437
+ case "tool/result": {
9438
+ const [result] = event.data.message.content;
9439
+ const call = this.activityChildCall;
9440
+ this.activityChildCall = void 0;
9441
+ const view = this.presentResult(call?.name ?? "", call?.args, result.content, result.isError === true, event.data.meta);
9442
+ this.setActivitySubagent({
9443
+ label: this.activityLabelFor(session.id),
9444
+ ...activityResultParts(toolResultBody(view, result.content).lines[0], result.isError === true)
9445
+ });
9446
+ return;
9447
+ }
9448
+ case "turn/end":
9449
+ this.setActivitySubagent({
9450
+ label: this.activityLabelFor(session.id),
9451
+ status: activityTurnEndStatus(event.data.reason)
9452
+ });
9453
+ return;
9454
+ default: return;
9455
+ }
9456
+ }
9457
+ /**
9059
9458
  * Locate the held pending prompt after inbox insertions and claims.
9060
9459
  * @param rows - current queue rows.
9061
9460
  * @returns the selected index, or 0 when the prior row left.
@@ -11318,6 +11717,7 @@ var TuiApp = class {
11318
11717
  this.blockFades.tick();
11319
11718
  if (this.toast?.clock.expired() === true) this.hideToast();
11320
11719
  if (this.panelLift !== this.panelLiftNow()) this.refreshSubagentPanel();
11720
+ if (this.activitySlot.children.length > 0) this.refreshActivityBoard();
11321
11721
  this.motions.tick();
11322
11722
  this.tui.requestRender();
11323
11723
  this.updateFadeTicker();
@@ -11327,22 +11727,35 @@ var TuiApp = class {
11327
11727
  case "start":
11328
11728
  this.streaming = void 0;
11329
11729
  this.endFade();
11730
+ this.beginLiveUsage();
11731
+ if (this.dropUnconfirmedTools()) this.tui.requestRender();
11330
11732
  return;
11331
11733
  case "chunk": {
11332
11734
  const chunk = frame.chunk;
11333
11735
  switch (chunk.type) {
11334
11736
  case "text-delta":
11335
- if (chunk.text !== "") this.appendStreamedText(chunk.text);
11737
+ if (chunk.text !== "") {
11738
+ this.appendStreamedText(chunk.text);
11739
+ this.noteStreamedChars(chunk.text.length);
11740
+ this.setStreamActivity("writing");
11741
+ }
11336
11742
  break;
11337
11743
  case "reasoning-delta":
11338
- if (chunk.text !== "") this.appendStreamedReasoning(chunk.text);
11744
+ if (chunk.text !== "") {
11745
+ this.appendStreamedReasoning(chunk.text);
11746
+ this.noteStreamedChars(chunk.text.length);
11747
+ this.setStreamActivity("thinking");
11748
+ }
11339
11749
  break;
11340
11750
  case "tool-call-delta":
11341
- if (chunk.name !== void 0) this.loader.setMessage(`calling ${chunk.name}`);
11751
+ this.onToolCallDelta(chunk);
11752
+ this.noteStreamedChars(chunk.argumentsDelta.length);
11753
+ break;
11754
+ case "usage":
11755
+ this.applyLiveUsage(chunk.usage);
11342
11756
  break;
11343
11757
  case "block-start":
11344
11758
  case "block-end":
11345
- case "usage":
11346
11759
  case "finish": break;
11347
11760
  /* v8 ignore next -- closed-union exhaustiveness guard */
11348
11761
  default: assertNever(chunk, "tui stream chunk");
@@ -11353,6 +11766,7 @@ var TuiApp = class {
11353
11766
  case "end":
11354
11767
  this.streaming = void 0;
11355
11768
  this.endFade();
11769
+ if (frame.outcome.kind === "abandoned" || frame.outcome.kind === "committed" && frame.outcome.eventType === "assistant/attempt") this.dropUnconfirmedTools();
11356
11770
  this.tui.requestRender();
11357
11771
  return;
11358
11772
  /* v8 ignore next -- closed-union exhaustiveness guard */
@@ -11362,17 +11776,20 @@ var TuiApp = class {
11362
11776
  onSessionEvent(session, event) {
11363
11777
  if (session !== this.agent.session) {
11364
11778
  this.markSubagentsStale();
11779
+ if (this.isBoundDescendant(session)) this.onDescendantActivity(session, event);
11365
11780
  return;
11366
11781
  }
11367
11782
  switch (event.type) {
11368
11783
  case "turn/start":
11369
11784
  this.turn = event.data.turn;
11370
11785
  this.turnStartedAt = event.time;
11786
+ this.clearActivityBoard();
11371
11787
  this.updateTicker();
11372
11788
  this.refreshFooter();
11373
11789
  break;
11374
11790
  case "todo/write":
11375
11791
  this.trackTodoTurns(event.data.todos);
11792
+ this.syncActivityTodos();
11376
11793
  break;
11377
11794
  case "user/message":
11378
11795
  this.onUserMessage(event.data);
@@ -11387,23 +11804,17 @@ var TuiApp = class {
11387
11804
  this.streamingBlock().commit(text, reasoning, interrupted === true);
11388
11805
  this.streaming = void 0;
11389
11806
  this.endFade();
11390
- if (usage !== void 0) {
11391
- this.usage = addUsage(this.usage, usage);
11392
- this.refreshFooter();
11393
- }
11807
+ this.clearLiveUsage();
11808
+ if (usage !== void 0) this.usage = addUsage(this.usage, usage);
11809
+ this.refreshFooter();
11394
11810
  break;
11395
11811
  }
11396
11812
  case "tool/call": {
11397
11813
  const { callId, name, arguments: argumentsJson } = event.data;
11398
- const args = parseArguments(argumentsJson);
11399
- this.toolArguments.set(callId, args);
11400
- const block = new ToolBlock(this.theme, name, toolCallText(argumentsJson, this.presentCall(name, args)), this.turn);
11401
- block.setExpanded(this.toolsExpanded);
11402
- this.toolBlocks.set(callId, block);
11403
- this.chat.addChild(block);
11404
- this.fadeBlock((fade) => {
11405
- block.setFade(fade);
11406
- });
11814
+ this.toolStreamArgs.delete(callId);
11815
+ this.pendingToolNames.set(callId, name);
11816
+ this.setLoaderActivity(callingActivity(name));
11817
+ this.upsertToolCard(callId, name, argumentsJson, "log");
11407
11818
  break;
11408
11819
  }
11409
11820
  case "tool/result": {
@@ -11416,13 +11827,16 @@ var TuiApp = class {
11416
11827
  this.fadeBlock((fade) => {
11417
11828
  block.setResultFade(fade);
11418
11829
  });
11419
- this.loader.setMessage("thinking");
11830
+ this.pendingToolNames.delete(result.toolCallId);
11831
+ this.syncLoaderFromPendingTools();
11420
11832
  break;
11421
11833
  }
11422
11834
  case "turn/end": {
11423
11835
  this.turnStartedAt = void 0;
11424
11836
  this.updateTicker();
11425
11837
  this.endFade();
11838
+ this.clearLiveUsage();
11839
+ this.clearActivityBoard();
11426
11840
  this.refreshFooter();
11427
11841
  const notice = turnEndNotice(event.data.reason);
11428
11842
  if (notice !== void 0) this.notice(notice, event.data.reason.kind === "error" ? "error" : "dim");
@@ -11444,11 +11858,12 @@ var TuiApp = class {
11444
11858
  break;
11445
11859
  }
11446
11860
  case "llm/retry":
11447
- this.loader.setMessage(retryMessage(event.data));
11861
+ this.setLoaderActivity(retryMessage(event.data));
11448
11862
  break;
11449
11863
  default: return;
11450
11864
  }
11451
11865
  this.tui.requestRender();
11866
+ if (event.type === "tool/call" && !this.replaying) this.tui.renderNow();
11452
11867
  }
11453
11868
  /**
11454
11869
  * Fold one whole-list todo write into the turn facts: a content this
@@ -11509,6 +11924,165 @@ var TuiApp = class {
11509
11924
  block.setExpanded(this.toolsExpanded);
11510
11925
  this.chat.addChild(block);
11511
11926
  }
11927
+ /**
11928
+ * Replace the spinner's activity word and redraw its live ↑↓ suffix.
11929
+ * @param activity - `thinking`, `writing`, `calling` / `calling <name>`, or a retry notice.
11930
+ */
11931
+ setLoaderActivity(activity) {
11932
+ this.loaderActivity = activity;
11933
+ this.refreshLoader();
11934
+ }
11935
+ /**
11936
+ * Label a streamed reasoning or visible-text chunk unless a tool call is
11937
+ * already the current activity: calling stays until the last in-flight
11938
+ * tool settles or a new model call begins.
11939
+ * @param activity - `thinking` for reasoning, `writing` for visible text.
11940
+ */
11941
+ setStreamActivity(activity) {
11942
+ if (isCallingActivity(this.loaderActivity)) return;
11943
+ this.setLoaderActivity(activity);
11944
+ }
11945
+ /**
11946
+ * Draw `calling <name>` for the most recently remembered in-flight tool,
11947
+ * or `thinking` when none remain.
11948
+ */
11949
+ syncLoaderFromPendingTools() {
11950
+ let name;
11951
+ for (const candidate of this.pendingToolNames.values()) name = candidate;
11952
+ this.setLoaderActivity(name === void 0 ? "thinking" : callingActivity(name));
11953
+ }
11954
+ /**
11955
+ * Start a new model call's live counters: seed send from the projected
11956
+ * next-request size or the last committed prompt, and zero receive.
11957
+ */
11958
+ beginLiveUsage() {
11959
+ this.streamedChars = 0;
11960
+ this.usageExact = false;
11961
+ this.liveUsage = {
11962
+ inputTokens: this.seedLiveSend(),
11963
+ outputTokens: 0
11964
+ };
11965
+ if (this.pendingToolNames.size === 0) this.loaderActivity = "thinking";
11966
+ else this.syncLoaderFromPendingTools();
11967
+ this.refreshLiveUsage();
11968
+ }
11969
+ /**
11970
+ * Prompt tokens the current call is likely sending, before a usage chunk.
11971
+ * @returns context occupancy when the projection has one, else the last
11972
+ * committed prompt size, else 0.
11973
+ */
11974
+ seedLiveSend() {
11975
+ const used = this.statusFacts().context?.used;
11976
+ if (used !== void 0 && used > 0) return used;
11977
+ return this.usage.lastInputTokens;
11978
+ }
11979
+ /**
11980
+ * Grow the receive estimate from streamed characters until the provider
11981
+ * reports usage.
11982
+ * @param chars - characters just appended to the live stream.
11983
+ */
11984
+ noteStreamedChars(chars) {
11985
+ if (chars <= 0 || this.usageExact) return;
11986
+ this.streamedChars += chars;
11987
+ const send = this.liveUsage === void 0 ? this.seedLiveSend() : this.liveUsage.inputTokens;
11988
+ this.liveUsage = {
11989
+ inputTokens: send,
11990
+ outputTokens: estimateTokens(this.streamedChars)
11991
+ };
11992
+ this.refreshLiveUsage();
11993
+ }
11994
+ /**
11995
+ * Replace the live counters with a provider usage chunk.
11996
+ * @param usage - the call's reported usage.
11997
+ */
11998
+ applyLiveUsage(usage) {
11999
+ this.usageExact = true;
12000
+ this.liveUsage = usage;
12001
+ this.refreshLiveUsage();
12002
+ }
12003
+ /** Forget the in-flight call's counters and drop them from the spinner and footer. */
12004
+ clearLiveUsage() {
12005
+ this.liveUsage = void 0;
12006
+ this.streamedChars = 0;
12007
+ this.usageExact = false;
12008
+ this.refreshLiveUsage();
12009
+ }
12010
+ /** Redraw the spinner and the footer from the current live counters. */
12011
+ refreshLiveUsage() {
12012
+ this.refreshLoader();
12013
+ this.refreshFooter();
12014
+ }
12015
+ /** Draw the spinner label plus the current call's ↑send ↓receive suffix. */
12016
+ refreshLoader() {
12017
+ const suffix = formatLiveUsage(this.liveUsage);
12018
+ this.loader.setMessage(suffix === "" ? this.loaderActivity : `${this.loaderActivity} ${suffix}`);
12019
+ }
12020
+ /**
12021
+ * Mount or refresh a tool card from a stream delta: the name as soon as
12022
+ * the model sends one, then the presenter headline once the arguments
12023
+ * parse as JSON.
12024
+ * @param chunk - one `tool-call-delta` of the live assistant stream.
12025
+ */
12026
+ onToolCallDelta(chunk) {
12027
+ const name = chunk.name === "" ? void 0 : chunk.name ?? this.toolBlocks.get(chunk.id)?.name;
12028
+ if (name !== void 0) {
12029
+ if (chunk.id !== "") this.pendingToolNames.set(chunk.id, name);
12030
+ this.setLoaderActivity(callingActivity(name));
12031
+ } else if (!isCallingActivity(this.loaderActivity)) this.setLoaderActivity(callingActivity(void 0));
12032
+ if (chunk.id === "") return;
12033
+ const argumentsJson = (this.toolStreamArgs.get(chunk.id) ?? "") + chunk.argumentsDelta;
12034
+ this.toolStreamArgs.set(chunk.id, argumentsJson);
12035
+ if (name === void 0) return;
12036
+ this.upsertToolCard(chunk.id, name, argumentsJson, "stream");
12037
+ }
12038
+ /**
12039
+ * Draw one tool card, creating it on the first sighting and updating the
12040
+ * call half when later arguments arrive. A streamed card stays unconfirmed
12041
+ * until the matching `tool/call` is logged.
12042
+ * @param callId - the model's call id.
12043
+ * @param name - the tool name.
12044
+ * @param argumentsJson - arguments accumulated so far, or the logged string.
12045
+ * @param source - `stream` for a live delta, `log` for the durable call.
12046
+ */
12047
+ upsertToolCard(callId, name, argumentsJson, source) {
12048
+ const args = parseArguments(argumentsJson);
12049
+ if (args !== void 0) this.toolArguments.set(callId, args);
12050
+ const call = source === "stream" && args === void 0 ? {
12051
+ title: "",
12052
+ lines: []
12053
+ } : toolCallText(argumentsJson, args === void 0 ? void 0 : this.presentCall(name, args));
12054
+ const existing = this.toolBlocks.get(callId);
12055
+ if (existing !== void 0) {
12056
+ existing.setCall(name, call);
12057
+ if (source === "log") this.unconfirmedTools.delete(callId);
12058
+ return;
12059
+ }
12060
+ const block = new ToolBlock(this.theme, name, call, this.turn);
12061
+ block.setExpanded(this.toolsExpanded);
12062
+ this.toolBlocks.set(callId, block);
12063
+ this.chat.addChild(block);
12064
+ this.fadeBlock((fade) => {
12065
+ block.setFade(fade);
12066
+ });
12067
+ if (source === "stream") this.unconfirmedTools.set(callId, block);
12068
+ }
12069
+ /**
12070
+ * Take down every card the live stream mounted that no `tool/call` confirmed.
12071
+ * @returns true when at least one card left the transcript.
12072
+ */
12073
+ dropUnconfirmedTools() {
12074
+ if (this.unconfirmedTools.size === 0) return false;
12075
+ for (const [callId, block] of this.unconfirmedTools) {
12076
+ this.chat.removeChild(block);
12077
+ this.toolBlocks.delete(callId);
12078
+ this.toolArguments.delete(callId);
12079
+ this.toolStreamArgs.delete(callId);
12080
+ this.pendingToolNames.delete(callId);
12081
+ }
12082
+ this.unconfirmedTools.clear();
12083
+ this.syncLoaderFromPendingTools();
12084
+ return true;
12085
+ }
11512
12086
  presentCall(name, args) {
11513
12087
  const definition = this.deps.ctx.get("tools")?.get(name, this.agent);
11514
12088
  if (definition?.presentCall === void 0) return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "The dsh terminal agent: an interactive TUI over the DeepSeek Harness, with its whole Node runtime bundled in one install.",
5
5
  "license": "MIT",
6
6
  "type": "module",