pi-pretty-tui 0.2.6 → 0.2.7

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
@@ -6,8 +6,8 @@ A beautiful, polished TUI for the [Pi coding agent](https://pi.dev/).
6
6
 
7
7
  ## Features
8
8
 
9
- - **Collapsible activity timeline:** instead of filling the conversation with individual calls, thoughts, tools, and ordinary `info` notifications share one chronological activity stream. Work appears beneath a single `Running(...)` row and settles into a quiet `Done(...)` row. Parent rows distinguish top-level tool calls, nested calls, and thoughts; expanding one reveals every ordered member with summaries retained above nested details. Thoughts and tools are peers: a turn that calls no tool still gets its own `Running(1 thought)` / `Done(1 thought)` parent row with the Thought as its child, so thinking is never dropped.
10
- - **Live working duration:** in clean mode, elapsed time appears beside `Working` in the prompt editor's top border, using the border's own color. It shares the agent-run clock and duration format with the completion footer, includes automatic retries, and disappears when the run settles. Narrow editors omit the timer when it cannot fit. The clean-mode `Running` parent dot alternates between `accent` and `dim` about every 800 ms; its label and tool dots stay stable, and the pulse stops when the run settles. Expanded `Done` titles and markers use the theme's `success` color; collapsed summaries remain quiet gray.
9
+ - **Collapsible activity timeline:** instead of filling the conversation with individual calls, thoughts, tools, and ordinary `info` notifications share one chronological activity stream. Work appears beneath a single `Running(...)` row and settles into a quiet `Done(...)` row. Parent rows show a combined total of top-level and nested tool calls, plus thoughts; expanding one reveals every ordered member with summaries retained above nested details. Thoughts and tools are peers: a turn that calls no tool still gets its own `Running(1 thought)` / `Done(1 thought)` parent row with the Thought as its child, so thinking is never dropped.
10
+ - **Live working duration:** in clean mode, elapsed time appears beside `Working` in the prompt editor's top border, using the border's own color. It shares the agent-run clock and duration format with the completion footer, includes automatic retries, and disappears when the run settles. Narrow editors omit the timer when it cannot fit. The clean-mode `Running` parent dot alternates between the prompt editor’s current border color and `dim` about every 800 ms; its label uses that same border color, and tool dots stay stable, and the pulse stops when the run settles. Expanded `Done` titles and markers use the theme's `success` color; collapsed summary dots, titles, and details use `dim`.
11
11
  - **Transient UI status:** one line above the editor shows direct Pi UI feedback such as Thinking/tool-output visibility changes. A newer UI status replaces it, and it disappears automatically after ten seconds without entering the transcript or session.
12
12
  - **Durable response footers:** once the complete agent run settles—including tools, retries, and compaction—the final answer ends with one quiet gray divider containing the elapsed-work time and, in fullscreen, a `[Copy]` control. It copies only the final visible answer, excluding thoughts, tools, statuses, and the footer itself; the footer survives reloads and session-tree navigation.
13
13
  - **Useful details on demand:** tool-aware summaries keep paths, commands, results, diffs, file previews, and live shell output concise without removing access to the original content.
@@ -41,7 +41,7 @@ Pi's direct internal `showStatus()` feedback is transient: it appears only in th
41
41
 
42
42
  In clean mode, tools that call other tools through Pi's nested execution API keep their own parent node. Expand the activity group to see each internal call, its status, compact arguments, duration, and result summary. Click an internal call to inspect its arguments and text result independently. Click its expanded body to collapse just that call. Script and script-output bodies also collapse their own sections when clicked. Tool calls use a `●` marker: dim while running, success-colored when successful, and error-colored when failed. Tool names use bold theme text. `[Script]` and `[Script output]` are separate disclosures; the nested parent title is informational and clicking it does not expand or collapse details. Use each section or child to expand and collapse its own details; `Ctrl+O` only shows a hint in clean mode. Extensions can still use Pi's `setToolsExpanded()` API for global control; local disclosures remain usable afterward, and another global API call resets the local overrides. Calls retain their start order even when they finish in parallel. A handled child failure remains marked as failed even if the script succeeds.
43
43
 
44
- The group distinguishes, for example, `1 tool call · 3 nested calls`. Internal calls never become phantom transcript members or displace the end-of-tree collapse action. Ownership uses Pi's `parentToolCallId`, not tool names or JavaScript parsing; wrappers other than codemode benefit too. This requires a Pi version with nested execution events (0.99.0 or later); older Pi keeps its existing display. Full and compact modes retain the native tool presentation.
44
+ The activity-group summary combines top-level and nested calls: one parent call plus three internal calls displays as `4 tool calls`. The parent call itself counts once, while its node retains the nested-call count and tree structure. Internal calls never become phantom transcript members or displace the end-of-tree collapse action. Ownership uses Pi's `parentToolCallId`, not tool names or JavaScript parsing; wrappers other than codemode benefit too. This requires a Pi version with nested execution events (0.99.0 or later); older Pi keeps its existing display. Full and compact modes retain the native tool presentation.
45
45
 
46
46
  Child text results and edit diffs are saved in hidden, UI-only session entries for reload and branch navigation. Each root retains at most 256 calls, 4,096 characters of arguments per call, 8,192 characters of text per result, and 131,072 characters of arguments/results in total; truncation is indicated. Detail previews also have a 200-line limit, and nested trees display up to eight levels below the root. Old sessions without a snapshot explicitly show that only call metadata was retained. Nested results currently use a generic text presentation, not each third-party renderer, and images are not stored in these snapshots. Root media remains available in native full/compact mode.
47
47
 
@@ -61,6 +61,8 @@ In fullscreen mode, left-click a user bubble's body or border to copy its comple
61
61
 
62
62
  ## Copy code blocks
63
63
 
64
+ Rounded code-block lines and corners use `borderMuted`; language labels, `[Copy]`, and code text retain their existing colors.
65
+
64
66
  In fullscreen TUI mode, fenced Markdown code blocks in user and assistant transcript messages include a clickable `[Copy]` control in the top rule:
65
67
 
66
68
  ```sh
@@ -82,7 +84,7 @@ The suite covers live and restored activity timelines, retries and terminal stat
82
84
 
83
85
  ## Compatibility notice
84
86
 
85
- The current development and regression-test baseline is **Pi 1.0.1**. User chat bubbles support its direct Markdown layout, keeping their transparent background and content-sized width. Nested execution requires Pi 0.99.0 or later; this is a feature requirement, not a promise that every older Pi release is tested.
87
+ The current development and regression-test baseline is **Pi 1.1.0**. User chat bubbles support its direct Markdown layout, keeping their transparent background and content-sized width. Nested execution requires Pi 0.99.0 or later; this is a feature requirement, not a promise that every older Pi release is tested.
86
88
 
87
89
  Tool rendering uses Pi's documented extension APIs. Active-tool state follows Pi's built-in execution transitions through its exported interactive components. Clean-mode thought details use the activity hierarchy's own disclosure state; full and compact modes retain Pi's built-in Thinking visibility control. Rendering native user messages as adaptive chat bubbles, rounding the native prompt editor, changing unordered-list markers, and enhancing fenced code blocks require reload-safe runtime patches because Pi does not currently expose public renderer hooks for those presentation details. Markdown enhancements are activated only while rendering user and assistant messages in the main transcript; Markdown created by extension overlays keeps Pi's native layout. Markdown parsing, syntax highlighting, and terminal semantic zones remain handled by Pi.
88
90
 
package/README.zh-CN.md CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  ## 功能特性
8
8
 
9
- - **可折叠的活动时间线:** 不再让大量独立调用填满对话。思考、工具和普通 `info` 通知会进入同一条按真实时间排序的活动流;工作进行时显示为 `Running(...)`,结束后变为低调的 `Done(...)`。父级分别统计顶层工具调用、嵌套调用和思考数量;展开后可查看所有有序成员,成员摘要在展开嵌套详情后仍然保留。思考与工具地位相同:没有调用任何工具的那一轮同样会有自己的 `Running(1 thought)` / `Done(1 thought)` 父行,思考作为其子级,内容不会被丢弃。
9
+ - **可折叠的活动时间线:** 不再让大量独立调用填满对话。思考、工具和普通 `info` 通知会进入同一条按真实时间排序的活动流;工作进行时显示为 `Running(...)`,结束后变为低调的 `Done(...)`。父级合并统计顶层与嵌套工具调用总数,并单独显示思考数量;展开后可查看所有有序成员,成员摘要在展开嵌套详情后仍然保留。思考与工具地位相同:没有调用任何工具的那一轮同样会有自己的 `Running(1 thought)` / `Done(1 thought)` 父行,思考作为其子级,内容不会被丢弃。
10
10
  - **可持久化的回答 footer:** 整轮 Agent 工作真正 settled 后(包括工具、自动重试和 compaction),最终回答底部会显示一条低调的灰色分隔线,工作时长与 fullscreen 模式下的 `[Copy]` 控件都嵌在线中。`[Copy]` 只复制最终可见回答,不包含 thought、工具、状态或 footer;reload 和 session tree 切换后仍会保留。
11
- - **实时工作计时:** clean 模式下,耗时显示在输入框顶部边框的 `Working` 右侧,颜色与边框一致。它与完成 footer 共用 Agent 整轮工作的计时起点和时长格式,包含自动重试,工作真正结束后消失;窄输入框放不下时会隐藏计时。clean 模式下,`Running` 父节点圆点约每 800 ms 在 `accent` 和 `dim` 间切换;文字与工具圆点保持稳定,整轮结束后停止闪烁。展开后的 `Done` 标题和圆点使用主题的 `success` 色,折叠摘要仍保持低调的灰色。
11
+ - **实时工作计时:** clean 模式下,耗时显示在输入框顶部边框的 `Working` 右侧,颜色与边框一致。它与完成 footer 共用 Agent 整轮工作的计时起点和时长格式,包含自动重试,工作真正结束后消失;窄输入框放不下时会隐藏计时。clean 模式下,`Running` 父节点圆点约每 800 ms 在输入框当前边框色和 `dim` 间切换;`Running` 文字使用相同边框色,工具圆点保持稳定,整轮结束后停止闪烁。展开后的 `Done` 标题和圆点使用主题的 `success` 色,折叠摘要的圆点、标题与内容统一使用 `dim`。
12
12
  - **临时 UI 状态:** 编辑器上方的一行只显示 Pi 直接产生的 UI 操作反馈,例如 Thinking 或工具输出可见性变化。新状态会替换旧状态,并在十秒后自动消失,不进入 transcript 或 session。
13
13
  - **按需查看有效信息:** 针对不同工具设计的摘要,会简洁呈现路径、命令、结果、diff、文件预览和实时 shell 输出,同时保留查看原始完整内容的能力。
14
14
  - **统一、精致的视觉体验:** 透明、右对齐的用户聊天气泡会根据短消息自适应宽度,长消息则在终端宽度的 75% 处换行;气泡使用主题链接色(`mdLink`)的圆角边框,并移除了多余的 `User` 标注。配合圆角输入框、主题感知配色、层级清晰的 Markdown 标题、更清爽的列表,以及带语法高亮的圆角代码块,让整个 TUI 更协调。在 fullscreen 模式下,每个围栏代码块还带有符合原生体验的 `[Copy]` 控件。
@@ -41,7 +41,7 @@ Pi 内部直接调用 `showStatus()` 产生的反馈属于临时 UI 状态:它
41
41
 
42
42
  clean 模式下,通过 Pi 嵌套执行 API 调用其他工具的工具保留自己的父节点。展开活动组后,会显示各内部调用的状态、紧凑参数、耗时和结果摘要;点击某个内部调用,可以独立展开其参数和文本结果;点击展开后的正文可收起该调用,脚本和脚本输出正文也可点击收起各自区块。工具统一使用 `●` 圆点:运行中为主题暗色,成功与失败分别为主题成功色与错误色;工具名使用正文色加粗。`[Script]` 和 `[Script output]` 分别控制脚本与汇总输出;嵌套父工具标题仅用于展示,点击不会展开或折叠详情。各区块或子调用通过自己的入口独立展开/收起,`Ctrl+O` 在 clean 模式下只显示提示。扩展仍可通过 Pi 的 `setToolsExpanded()` API 全局控制,之后也可局部展开/收起;再次调用全局 API 会重置局部状态。并行调用按照启动顺序排列,不会随完成顺序跳动。即使脚本捕获错误后成功,失败的子调用仍会明确标记。
43
43
 
44
- 活动组会分别统计,例如 `1 tool call · 3 nested calls`。内部调用不会变成不存在的顶层 transcript 成员,也不会挤掉树尾折叠按钮。归属依据 Pi 的 `parentToolCallId`,不依赖工具名或 JavaScript 源码解析,因此其他嵌套调用工具也适用。这需要支持嵌套执行事件的 Pi(0.99.0 及以后);旧版本保持原有显示。full 和 compact 模式保留原生工具展示。
44
+ 活动组摘要合并统计顶层与嵌套调用:一个父调用加三个内部调用显示为 `4 tool calls`,父调用本身也计一次;父工具节点仍保留子调用数量和树结构。内部调用不会变成不存在的顶层 transcript 成员,也不会挤掉树尾折叠按钮。归属依据 Pi 的 `parentToolCallId`,不依赖工具名或 JavaScript 源码解析,因此其他嵌套调用工具也适用。这需要支持嵌套执行事件的 Pi(0.99.0 及以后);旧版本保持原有显示。full 和 compact 模式保留原生工具展示。
45
45
 
46
46
  子工具的文本结果和 edit diff 会存入隐藏的、仅用于 UI 的 session 条目,支持 reload 和会话分支恢复。每个父调用最多保留 256 个子调用,每项参数最多 4,096 字符,每项文本结果最多 8,192 字符,参数和结果合计最多 131,072 字符;截断会明确提示。每项展开预览还设有 200 行上限,嵌套树最多展示父调用以下八层。没有快照的旧会话会明确显示仅保留调用记录。目前子结果使用通用文本视图,不调用各第三方工具的 renderer,也不在快照中保存图片;父工具自身的媒体结果仍可在原生 full/compact 模式查看。
47
47
 
@@ -61,6 +61,8 @@ fullscreen 模式下,左键点击用户气泡的正文或边框,可复制完
61
61
 
62
62
  ## 复制代码块
63
63
 
64
+ 代码块的圆角与线条使用 `borderMuted`,语言标签、`[Copy]` 和代码正文保持原有配色。
65
+
64
66
  在 fullscreen TUI 模式下,用户消息与助手回复中的 Markdown 围栏代码块会在顶部边框显示可点击的 `[Copy]` 控件:
65
67
 
66
68
  ```sh
@@ -82,7 +84,7 @@ npm test
82
84
 
83
85
  ## 兼容性说明
84
86
 
85
- 当前开发与回归测试基线为 **Pi 1.0.1**。用户气泡已适配该版本直接使用 Markdown 的布局,保留透明背景与按内容自适应的宽度。嵌套执行需要 Pi 0.99.0 及以后;这是功能要求,不代表每个旧版都经过测试。
87
+ 当前开发与回归测试基线为 **Pi 1.1.0**。用户气泡已适配该版本直接使用 Markdown 的布局,保留透明背景与按内容自适应的宽度。嵌套执行需要 Pi 0.99.0 及以后;这是功能要求,不代表每个旧版都经过测试。
86
88
 
87
89
  工具渲染使用 Pi 的公开扩展 API。活动工具状态通过 Pi 导出的交互组件跟随其内置执行状态变化;clean 模式的 thought 详情使用活动时间线自身的展开状态,full 和 compact 模式则保留 Pi 内置的 Thinking 可见性控制。由于 Pi 目前没有为这些展示细节提供公开渲染钩子,自适应的原生用户消息气泡、原生输入编辑器圆角、无序列表标记和围栏代码块增强需要使用可安全重载的运行时补丁。Markdown 增强仅在渲染主 transcript 中的用户消息和助手回复时启用;扩展 overlay 创建的 Markdown 保持 Pi 原生布局。Markdown 解析、语法高亮和终端语义区域仍由 Pi 处理。
88
90
 
@@ -99,6 +99,11 @@ export default function prettyTui(pi: ExtensionAPI) {
99
99
  let fullscreenTui = false;
100
100
  const mouseClickHitTests = new WeakMap<object, (event: any) => boolean>();
101
101
  let currentTui: any;
102
+ let currentPromptEditor: any;
103
+ const runningColor = (theme: any, text: string): string =>
104
+ typeof currentPromptEditor?.borderColor === "function"
105
+ ? currentPromptEditor.borderColor(text)
106
+ : theme.fg("border", text);
102
107
  let currentExtensionUi: any;
103
108
  let changingAllToolsExpansion = false;
104
109
  const latestActivityWidgetKey = "pretty-tui-latest-activity";
@@ -420,6 +425,10 @@ export default function prettyTui(pi: ExtensionAPI) {
420
425
  }
421
426
  }
422
427
  };
428
+ const requestActivityRender = (group?: ActivityGroup): void => {
429
+ if (group) refreshActivityGroup(group);
430
+ currentTui?.requestRender?.();
431
+ };
423
432
  const revealActivityGroup = (group: ActivityGroup, ui?: any): void => {
424
433
  collapsedActivityGroups.delete(group.id);
425
434
  revealedActivityGroups.add(group.id);
@@ -722,6 +731,7 @@ export default function prettyTui(pi: ExtensionAPI) {
722
731
  const originalEditorHandleMouse = customEditorPrototype.handleMouse;
723
732
  const patchedEditorTopBorder = function (this: any, width: number, hiddenLineCount: number): string {
724
733
  if (this.tui) currentTui = this.tui;
734
+ currentPromptEditor = this;
725
735
  const indicator = this.workingStatusIndicator;
726
736
  if (renderMode !== "clean" || indicator?.kind !== "working" || responseRunStartedAt === undefined) {
727
737
  return originalEditorTopBorder.call(this, width, hiddenLineCount);
@@ -743,6 +753,7 @@ export default function prettyTui(pi: ExtensionAPI) {
743
753
  }
744
754
  };
745
755
  const patchedEditorRender = function (this: any, width: number): string[] {
756
+ currentPromptEditor = this;
746
757
  if (width < 3) return originalEditorRender.call(this, width);
747
758
 
748
759
  const innerWidth = width - 2;
@@ -786,6 +797,7 @@ export default function prettyTui(pi: ExtensionAPI) {
786
797
  customEditorPrototype.handleMouse = patchedEditorHandleMouse;
787
798
 
788
799
  pi.on("session_shutdown", () => {
800
+ currentPromptEditor = undefined;
789
801
  const patch = customEditorPrototype[editorFramePatchKey];
790
802
  if (!patch) return;
791
803
  if (patch.patchedRender === customEditorPrototype.render) {
@@ -2254,17 +2266,23 @@ export default function prettyTui(pi: ExtensionAPI) {
2254
2266
  );
2255
2267
  const buttonStart = visibleWidth(topPrefix) + fillWidth + (showCopyButton ? 1 : 0);
2256
2268
  const topRule = topPrefix + "─".repeat(fillWidth) + topSuffix;
2257
- const styledTopRule = this.theme.codeBlockBorder(topRule);
2269
+ const frameBorder = (text: string) => currentExtensionUi?.theme?.fg
2270
+ ? currentExtensionUi.theme.fg("borderMuted", text)
2271
+ : this.theme.codeBlockBorder(text);
2272
+ // Keep labels and Copy at their original contrast; soften only the frame.
2273
+ const styledTopRule = frameBorder("╭─ ") + this.theme.codeBlockBorder(label + " ") +
2274
+ frameBorder("─".repeat(fillWidth)) +
2275
+ (showCopyButton ? this.theme.codeBlockBorder(` ${copyLabel} `) : "") + frameBorder("╮");
2258
2276
  const framedCodeWidth = Math.max(1, frameWidth - 4);
2259
2277
  const lines = [
2260
2278
  styledTopRule,
2261
2279
  ...codeLines.map((line) =>
2262
- this.theme.codeBlockBorder("│ ") +
2280
+ frameBorder("│ ") +
2263
2281
  line +
2264
2282
  " ".repeat(Math.max(0, framedCodeWidth - visibleWidth(line))) +
2265
- this.theme.codeBlockBorder(" │")
2283
+ frameBorder(" │")
2266
2284
  ),
2267
- this.theme.codeBlockBorder(`╰${"─".repeat(Math.max(0, frameWidth - 2))}╯`),
2285
+ frameBorder(`╰${"─".repeat(Math.max(0, frameWidth - 2))}╯`),
2268
2286
  ];
2269
2287
 
2270
2288
  if (showCopyButton && Array.isArray(this[codeBlockCollectionKey])) {
@@ -3103,6 +3121,7 @@ export default function prettyTui(pi: ExtensionAPI) {
3103
3121
  }
3104
3122
 
3105
3123
  const finishCleanGroup = (activity = cleanRun.activity ?? "done") => {
3124
+ const activeGroup = activityTimeline.currentGroup();
3106
3125
  if (cleanRun.lastCompletedToolCallId && cleanRun.count > 0) {
3107
3126
  const group: ToolSummaryGroup = {
3108
3127
  count: cleanRun.count,
@@ -3129,6 +3148,7 @@ export default function prettyTui(pi: ExtensionAPI) {
3129
3148
  cleanRun.activeToolCallId = undefined;
3130
3149
  cleanRun.activeToolName = undefined;
3131
3150
  activityTimeline.boundary();
3151
+ requestActivityRender(activeGroup);
3132
3152
  };
3133
3153
 
3134
3154
  closeCleanAtNativeCustomBoundary = () => {
@@ -3164,7 +3184,8 @@ export default function prettyTui(pi: ExtensionAPI) {
3164
3184
  const activityText = /^thinking(?:\.\.\.)?$/iu.test(normalizedActivityText)
3165
3185
  ? "thinking"
3166
3186
  : rawActivityText;
3167
- const countLabel = count > 0 ? `${count} tool ${count === 1 ? "call" : "calls"}` : "";
3187
+ const totalCalls = count + nestedCount;
3188
+ const countLabel = totalCalls > 0 ? `${totalCalls} tool ${totalCalls === 1 ? "call" : "calls"}` : "";
3168
3189
  const thoughtLabel = thoughtCount > 0
3169
3190
  ? `${thoughtCount} ${thoughtCount === 1 ? "thought" : "thoughts"}`
3170
3191
  : "";
@@ -3173,7 +3194,7 @@ export default function prettyTui(pi: ExtensionAPI) {
3173
3194
  const activityLabel = count > 0 && activityText !== "done" && activityText.trim()
3174
3195
  ? activityText
3175
3196
  : "";
3176
- return [countLabel, nestedCount ? `${nestedCount} nested ${nestedCount === 1 ? "call" : "calls"}` : "", thoughtLabel, activityLabel].filter(Boolean).join(" · ");
3197
+ return [countLabel, thoughtLabel, activityLabel].filter(Boolean).join(" · ");
3177
3198
  };
3178
3199
 
3179
3200
  const summaryRow = (
@@ -3190,19 +3211,24 @@ export default function prettyTui(pi: ExtensionAPI) {
3190
3211
  const dimPhase = responseRunStartedAt !== undefined &&
3191
3212
  Math.floor(Math.max(0, Date.now() - responseRunStartedAt) / RUNNING_DOT_INTERVAL_MS) % 2 === 1;
3192
3213
  const color = currentActivity === "done"
3193
- ? collapsedDone ? "thinkingText" : "success"
3214
+ ? collapsedDone ? "dim" : "success"
3194
3215
  : dimPhase ? "dim" : "accent";
3195
- return theme.fg(color, "● ");
3216
+ return currentActivity !== "done" && !dimPhase
3217
+ ? runningColor(theme, "● ")
3218
+ : theme.fg(color, "● ");
3196
3219
  },
3197
3220
  continuation: " ",
3198
3221
  content: () => {
3199
3222
  const currentActivity = typeof activity === "function" ? activity() : activity;
3200
3223
  const label = currentActivity === "done" ? "Done" : "Running";
3201
3224
  const color = label === "Done"
3202
- ? collapsedDone ? "thinkingText" : "success"
3225
+ ? collapsedDone ? "dim" : "success"
3203
3226
  : "accent";
3204
- const detailColor = label === "Done" && collapsedDone ? "thinkingText" : "text";
3205
- return theme.fg(color, theme.bold(label)) +
3227
+ const detailColor = label === "Done" && collapsedDone ? "dim" : "text";
3228
+ const title = label === "Running"
3229
+ ? runningColor(theme, theme.bold(label))
3230
+ : theme.fg(color, theme.bold(label));
3231
+ return title +
3206
3232
  theme.fg("dim", "(") +
3207
3233
  theme.fg(detailColor, summaryText(count, failed, thoughtCount, currentActivity, nestedCount)) +
3208
3234
  theme.fg("dim", ")");
@@ -3256,6 +3282,10 @@ export default function prettyTui(pi: ExtensionAPI) {
3256
3282
  const toolCount = group.toolCallIds.length;
3257
3283
  const nestedCount = group.toolCallIds.reduce((count, id) => count + nestedTools.count(id), 0);
3258
3284
  const live = () => cleanRun.activeToolName ?? currentCleanActivity();
3285
+ const currentGroup = activityTimeline.currentGroup();
3286
+ const isLiveGroup = currentGroup?.id === group.id &&
3287
+ !activityTimeline.isSettled(group.id) &&
3288
+ !cleanRun.settled;
3259
3289
  if (settled) {
3260
3290
  return fit(block([summaryRow(
3261
3291
  summaryTheme,
@@ -3267,8 +3297,8 @@ export default function prettyTui(pi: ExtensionAPI) {
3267
3297
  nestedCount,
3268
3298
  )]).render(width));
3269
3299
  }
3270
- if (owner && !cleanRun.settled) {
3271
- // Live tool group: keep the current tool name and the running count.
3300
+ if (owner && isLiveGroup) {
3301
+ // Only the current, unsettled group may consume live run state.
3272
3302
  return fit(block([summaryRow(
3273
3303
  summaryTheme,
3274
3304
  Math.max(toolCount, liveCleanToolCount()),
@@ -3279,8 +3309,8 @@ export default function prettyTui(pi: ExtensionAPI) {
3279
3309
  nestedCount,
3280
3310
  )]).render(width));
3281
3311
  }
3282
- if (!owner && !activityTimeline.isSettled(group.id)) {
3283
- // Thought-only group while the model is still working.
3312
+ if (!owner && isLiveGroup) {
3313
+ // Thought-only current group while the model is still working.
3284
3314
  return fit(block([summaryRow(
3285
3315
  summaryTheme,
3286
3316
  toolCount,
@@ -3314,6 +3344,11 @@ export default function prettyTui(pi: ExtensionAPI) {
3314
3344
  cleanToolThemes.set(toolCallId, theme);
3315
3345
  const activityGroup = activityTimeline.groupForTool(toolCallId);
3316
3346
  if (activityGroup) activityFallbackThemes.set(activityGroup.id, theme);
3347
+ const isLiveGroup = !activityGroup || (
3348
+ activityTimeline.currentGroup()?.id === activityGroup.id &&
3349
+ !activityTimeline.isSettled(activityGroup.id) &&
3350
+ !cleanRun.settled
3351
+ );
3317
3352
  return {
3318
3353
  render(width: number): string[] {
3319
3354
  if (renderMode !== "clean") return [];
@@ -3331,7 +3366,7 @@ export default function prettyTui(pi: ExtensionAPI) {
3331
3366
  }
3332
3367
  if (cleanRun.settled) return [];
3333
3368
 
3334
- if (cleanRun.activeToolCallId === toolCallId) {
3369
+ if (isLiveGroup && cleanRun.activeToolCallId === toolCallId) {
3335
3370
  return block([summaryRow(
3336
3371
  theme,
3337
3372
  liveCleanToolCount(),
@@ -3344,6 +3379,7 @@ export default function prettyTui(pi: ExtensionAPI) {
3344
3379
  // The active tool owns the live Running row. Keep the latest completed
3345
3380
  // portion hidden while that tool's minimum display time is running.
3346
3381
  if (
3382
+ isLiveGroup &&
3347
3383
  cleanRun.lastCompletedToolCallId === toolCallId &&
3348
3384
  cleanRun.count > 0 &&
3349
3385
  !cleanRun.activeToolCallId
@@ -3949,6 +3985,7 @@ export default function prettyTui(pi: ExtensionAPI) {
3949
3985
  cleanRun.active = true;
3950
3986
  cleanRun.activeToolCallId = event.toolCallId;
3951
3987
  beginToolActivity(event.toolCallId, displayName, true);
3988
+ requestActivityRender(activityTimeline.groupForTool(event.toolCallId));
3952
3989
  });
3953
3990
  pi.on("tool_execution_update", (event) => {
3954
3991
  if ((event as any).parentToolCallId) {
@@ -3990,6 +4027,7 @@ export default function prettyTui(pi: ExtensionAPI) {
3990
4027
  }
3991
4028
  const visibleSummaryToolCallId = cleanRun.activeToolCallId ?? cleanRun.lastCompletedToolCallId;
3992
4029
  setCleanGroupMembers(visibleSummaryToolCallId, cleanRun.currentToolCallIds.slice());
4030
+ requestActivityRender(activityTimeline.groupForTool(event.toolCallId));
3993
4031
  // Tool success and failure remain owned by the activity group. The bottom
3994
4032
  // line is reserved for transient UI status messages.
3995
4033
  });
@@ -4029,6 +4067,8 @@ export default function prettyTui(pi: ExtensionAPI) {
4029
4067
  cleanRun.activeToolName = undefined;
4030
4068
  cleanRun.activity = "done";
4031
4069
  cleanRun.settled = true;
4070
+ for (const group of activityTimeline.groups()) refreshActivityGroup(group);
4071
+ currentTui?.requestRender?.();
4032
4072
 
4033
4073
  if (responseRunStartedAt !== undefined) {
4034
4074
  // message_end runs before later extensions can replace the message and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-pretty-tui",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "A beautiful, polished TUI for the Pi coding agent",
5
5
  "license": "MIT",
6
6
  "author": "Kainan Yang <ykn0309@whu.edu.cn>",
@@ -39,8 +39,8 @@
39
39
  "@earendil-works/pi-tui": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@earendil-works/pi-coding-agent": "1.0.1",
43
- "@earendil-works/pi-tui": "1.0.1",
42
+ "@earendil-works/pi-coding-agent": "1.1.0",
43
+ "@earendil-works/pi-tui": "1.1.0",
44
44
  "@types/node": "^24.0.0",
45
45
  "jiti": "^2.7.0",
46
46
  "typescript": "^5.9.0"