@notrico/pi-fold 3.1.0 → 3.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Release notes
2
2
 
3
+ ## 3.1.1 — Clearer action headings
4
+
5
+ - Show a short description of a folded action group before the per-tool call counts.
6
+ - Show the failure reason directly in a failed tool heading. Keep an uncertain outcome visible, including when a timeout leaves a commit unconfirmed.
7
+
3
8
  ## 3.1.0
4
9
 
5
10
  - Enable features by available Pi interfaces instead of an exact version list.
@@ -20,7 +20,7 @@ pi remove git:github.com/rrrrrrrrrricoxi/pi-fold@v3.0.0
20
20
 
21
21
  - Questions use a bold purple heading, aligned with ordinary action headings, without a background or vertical rail. Recorded answers use a green checkmark inline with the options. Ordinary action headings stay blue. The `codemode` label uses native teal (`syntaxVariable`), while counts and timing stay muted; handled nested problems retain warning color; thinking headings stay muted and failures stay red. Expanded content remains unfilled. Keyboard focus has its own selection highlight. User prompts keep their blue surface. Subagent transcript activity uses the same compact headings and inspection controls.
22
22
  - Running actions remain separate. Successful completed bash, file, and codemode calls can share one action group within visible conversation boundaries. Each outer codemode call counts as one action; nested calls stay inside its inspectable content. Nested errors, cancellations, unresolved calls, images, and unsupported codemode records stay separate. Pure thinking does not split an action group; visible assistant replies and user messages do.
23
- - Successful group headings use “4 actions”; singleton headings show only the operation. Shell interpreter scripts use labels such as “Run Node.js script,” with a literal script filename when reliably available. Inline source stays in Arguments. Known errors show a short category such as “Path too long”; exact errors stay in Output/Details. Labels describe recorded operations and do not infer a script’s purpose.
23
+ - Successful group headings lead with a short phrase describing the recorded operations, followed by outer call counts, for example “4 actions · Edit files and read files · write ×2 · read ×2”. Up to four tool types are named in first-use order. Singleton headings show only the operation. Shell interpreter scripts use labels such as “Run Node.js script,” with a literal script filename when reliably available. Inline source stays in Arguments. A failure heading shows the recorded category, structured reason, or exit code when available. An explicitly unknown outcome stays visible in structured failure summaries. Exact errors stay in Output/Details. Labels describe recorded operations and do not infer a script’s purpose.
24
24
  - Expanded source and diffs use Pi’s syntax colors. Recorded thinking and Markdown files use bounded Markdown rendering; shell stdout and unknown text remain literal. Formatting reads at most 2,048 source characters per block. Markdown uses one source line per block, so multiline tables, paragraphs, and cross-line inline formatting are not fully reconstructed. Very long code blocks can lose lexer context at block boundaries. The original recorded source remains unchanged.
25
25
  - A single-action card opens directly to useful content without repeating a numbered action row. Successful native `write` actions show submitted content with syntax colors from the path. Only the exact standard acknowledgement is moved under Details. Reads and unknown tools keep their output visible. Known ordinary-tool OS diagnostics can show a short code/category while Details retains the exact error; unknown/custom failures keep full visible output. Status marks follow the title.
26
26
  - Open a group to see tightly stacked actions without blank rows between siblings. Several actions and their inline Details can remain expanded independently in the same scrollable pane. Details contains exact arguments, secondary diagnostics, and any acknowledgement/error moved from the main content. Short scalar fields share a line; null and empty values remain explicit. Empty diagnostic objects do not add a section.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notrico/pi-fold",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "type": "module",
5
5
  "description": "Pi Fold: readable agent transcripts with collapsible work, inspectable details, and clear final replies",
6
6
  "license": "MIT",
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ // Isolated recorded-content preview; no model or tool execution.
3
+ import { createWorkStripPreview } from './preview-work-strip.mjs';
4
+ const preview = await createWorkStripPreview({ inspection: true, standaloneCode: true });
5
+ let ui;
6
+ try {
7
+ ui = new preview.core.InteractiveMode(preview.runtime, { tuiMode: 'fullscreen' });
8
+ await ui.run();
9
+ } finally { ui?.stop(); await preview.cleanup(); }
@@ -5,7 +5,7 @@ import path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { createPreview } from './preview.mjs';
7
7
 
8
- export async function createWorkStripPreview({ stepMs = 1000, inspection = false, actionGroups = false } = {}) {
8
+ export async function createWorkStripPreview({ stepMs = 1000, inspection = false, actionGroups = false, standaloneCode = false } = {}) {
9
9
  const old = process.env.PI_PREVIEW_WORK_STRIP;
10
10
  process.env.PI_PREVIEW_WORK_STRIP = '1';
11
11
  const preview = await createPreview();
@@ -70,6 +70,20 @@ export async function createWorkStripPreview({ stepMs = 1000, inspection = false
70
70
  const finalId = manager.getBranch().at(-1).id;
71
71
  manager.appendCustomEntry('compact-renderer:work-settled:v1',{version:1,userId,finalId,endId:finalId,startedAt:base-45000,endedAt:base,outcome:'completed'});
72
72
  }
73
+ if (standaloneCode) {
74
+ manager.appendMessage({ role: 'user', content: '独立代码输出滚动测试:保留原始结果,并检查更多内容。', timestamp: Date.now() });
75
+ const userId = manager.getBranch().at(-1).id;
76
+ manager.appendMessage(assistant('这条说明将独立代码与前一组工具分开。'));
77
+ const call = assistant('');
78
+ call.stopReason = 'toolUse';
79
+ call.content = [{ type: 'toolCall', id: 'standalone-wheel-code', name: 'codemode', arguments: { code: 'const results = await Promise.all([tools.read({ path: "/fixture/a" }), tools.read({ path: "/fixture/b" }), tools.read({ path: "/fixture/c" })]);\nfor (const result of results) text(result);' } }];
80
+ manager.appendMessage(call);
81
+ const escaped = JSON.stringify({ content: [{ type: 'text', text: Array.from({ length: 240 }, (_, i) => `记录 ${i + 1}:示例文字、原始说明与数据行。`).join('\n') }], end: 'ESCAPED_JSON_END' });
82
+ manager.appendMessage({ role: 'toolResult', toolCallId: 'standalone-wheel-code', toolName: 'codemode', content: [{ type: 'text', text: 'Script completed\nWall time 0.75 seconds\nOutput:\n' }, { type: 'text', text: escaped + '\nFINAL_OUTPUT_SENTINEL' }], details: { calls: ['a', 'b', 'c'].map(path => ({ name: 'read', args: JSON.stringify({ path: `/fixture/${path}` }), status: 'ok', durationMs: 10 })) }, isError: false, durationMs: 750, timestamp: Date.now() });
83
+ manager.appendMessage(assistant('检查完成。这条最终答复保持在工作区外。'));
84
+ const finalId = manager.getBranch().at(-1).id;
85
+ manager.appendCustomEntry('compact-renderer:work-settled:v1', { version: 1, userId, finalId, endId: finalId, startedAt: Date.now() - 2000, endedAt: Date.now(), outcome: 'completed' });
86
+ }
73
87
  const emit = async event => {
74
88
  if (stopped) return;
75
89
  runtime.session._emit(event);
package/scripts/test.mjs CHANGED
@@ -7,7 +7,7 @@ import { spawnSync } from 'node:child_process';
7
7
  const directory = fileURLToPath(new URL('../tests/', import.meta.url));
8
8
  const required = ['action-intent.test.mjs', 'modern-workflows.test.mjs', 'display-mode.test.mjs', 'modern-tools.test.mjs', 'modern-subagent-messages.test.mjs', 'subagent-spacing.test.mjs', 'modern-subagent-groups.test.mjs', 'modern-thinking.test.mjs', 'modern-prompts.test.mjs', 'permission-presentation.test.mjs', 'input-focus.test.mjs', 'inspection.test.mjs', 'codemode.test.mjs', 'preview-example.test.mjs'];
9
9
  required.push('reload-lifecycle.test.mjs', 'ordinary-prompts.test.mjs', 'work-strip-hierarchy.test.mjs', 'work-strip-final-surface.test.mjs');
10
- required.push('modern-skill-prompts.test.mjs', 'inspection-wheel.test.mjs');
10
+ required.push('modern-skill-prompts.test.mjs', 'inspection-wheel.test.mjs', 'codemode-wheel.test.mjs');
11
11
  required.push('display-line-cache.test.mjs');
12
12
  required.push('display-cache-lifecycle.test.mjs');
13
13
  required.push('fold-command.test.mjs', 'fold-shortcut.test.mjs');
@@ -77,13 +77,17 @@ export function actionIntent(name: string, args: unknown): string {
77
77
  return combine(actionIntents(name, args));
78
78
  }
79
79
 
80
- export function groupIntent(actions: Action[]): string {
80
+ export function groupIntent(actions: Action[], format: "full" | "brief" = "full"): string {
81
81
  if (!Array.isArray(actions)) return "Run tool actions";
82
82
  const intents: string[] = [];
83
83
  for (let i = 0; i < Math.min(actions.length, 64); i++) {
84
84
  const action = field(actions, String(i));
85
85
  intents.push(...actionIntents(field(action, "name"), field(action, "args")));
86
86
  }
87
+ if (format === "brief") {
88
+ const specific = intents.filter(intent => intent !== "Run tool actions" && intent !== "Run code");
89
+ return combine([...new Set(specific.length ? specific : intents)].slice(0, 2));
90
+ }
87
91
  return combine(intents, actions.length > 64);
88
92
  }
89
93
 
@@ -10,8 +10,8 @@ import { CodePane } from "./modern-code-pane.ts";
10
10
  import { cardContentWidth, activityRow, activityHeading } from "./display-card.ts";
11
11
  import { acquireSubagentProjection, hiddenSubagent } from "./modern-subagent-groups.ts";
12
12
  import { compactSubagent, subagentDecision, subagentTitle } from "./modern-subagents.ts";
13
- import { groupIntent } from "./action-intent.ts";
14
13
  import { compactToolImages, installModernToolImages, type ToolImageView } from "./modern-tool-images.ts";
14
+ import { groupIntent } from "./action-intent.ts";
15
15
 
16
16
  const { Text, truncateToWidth } = Tui;
17
17
  const getLanguageFromPath = typeof Pi.getLanguageFromPath === "function" ? Pi.getLanguageFromPath : () => undefined;
@@ -203,13 +203,34 @@ function knownFailure(node: Node): { code: string; label: string } | undefined {
203
203
  return { code, label: categories[code] };
204
204
  }
205
205
  }
206
- function failureReason(node: Node): string {
207
- if (node.status !== "failed") return "";
206
+ // Count outer calls only. A codemode call owns its nested actions.
207
+ function groupCounts(nodes: Node[]): string {
208
+ const counts = new Map<string, number>();
209
+ for (const { name } of nodes) {
210
+ const label = clean(shortName(name)) || "tool";
211
+ counts.set(label, (counts.get(label) ?? 0) + 1);
212
+ }
213
+ const entries = [...counts].slice(0, 4);
214
+ const labels = entries.map(([name, count]) => `${name} ×${count}`);
215
+ const more = counts.size - entries.length;
216
+ if (more) labels.push(`+${more} tool type${more === 1 ? "" : "s"}`);
217
+ return labels.join(" · ");
218
+ }
219
+
220
+ function failureLabel(node: Node): string {
208
221
  const known = knownFailure(node);
209
- if (known) return known.label;
210
222
  const details = node.result?.details;
211
- if (typeof details?.exitCode === "number") return `Command failed (exit ${details.exitCode})`;
212
- return ["bash", "powershell"].includes(shortName(node.name)) ? "Command failed" : "Tool failed";
223
+ // Only compact structured identifiers belong in a heading. Keep free text in Details.
224
+ const identifier = [details?.failureReason, details?.code].find(value =>
225
+ typeof value === "string" && value.length <= 64 && /^[a-z][a-z0-9]*(?:_[a-z0-9]+)+$/i.test(value));
226
+ const reason = known?.label ?? identifier?.replaceAll("_", " ").toLowerCase();
227
+ const parts = reason ? [reason] : [];
228
+ if (details?.status === "unknown") parts.push(details.code === "commit_receipt_missing" ? "commit unconfirmed" : "outcome unknown");
229
+ if (parts.length) {
230
+ const label = parts.join(" · ");
231
+ return label[0].toUpperCase() + label.slice(1);
232
+ }
233
+ return typeof details?.exitCode === "number" ? `Exit code ${details.exitCode}` : "Failed";
213
234
  }
214
235
  function questionState(node: Node): string {
215
236
  const statuses: Record<string, string> = { pending: "Pending", running: "Pending", failed: "Failed", answered: "Answered", cancelled: "Cancelled", unavailable: "Unavailable", unanswered: "Unanswered" };
@@ -278,12 +299,17 @@ export function registerModernTools(pi: ExtensionAPI, mode: DisplayMode, options
278
299
  const signature = run.map(node => `${node.id}@${node.revision}`).join("|");
279
300
  let group = groups.get(id);
280
301
  if (!group) group = { members: [], signature: "", pane: new ToolPane([], "", height) };
281
- if (group.signature !== signature) { group.pane.actions = run.map(action); group.pane.selected = Math.min(group.pane.selected, run.length - 1); group.pane.reset(); group.signature = signature; }
302
+ if (group.signature !== signature) {
303
+ group.pane.actions = run.map(action);
304
+ group.pane.selected = Math.min(group.pane.selected, run.length - 1);
305
+ group.pane.reset();
306
+ group.signature = signature;
307
+ group.pane.title = run.length === 1 ? toolLabel(run[0].name, run[0].args) : `${run.length} actions · ${groupIntent(run, "brief")} · ${groupCounts(run)}`;
308
+ if (run.some(node => node.result?.details?.truncation?.truncated || node.result?.details?.truncated)) group.pane.title += " · output truncated";
309
+ if (run.some(node => node.result?.details?.fullOutputPath)) group.pane.title += " · full output saved";
310
+ if (run.some(node => node.result?.details?.warning || node.result?.details?.warnings?.length)) group.pane.title += " · warning recorded";
311
+ }
282
312
  group.members = run;
283
- group.pane.title = run.length === 1 ? toolLabel(run[0].name, run[0].args) : `${run.length} actions · ${groupIntent(run)}`;
284
- if (run.some(node => node.result?.details?.truncation?.truncated || node.result?.details?.truncated)) group.pane.title += " · output truncated";
285
- if (run.some(node => node.result?.details?.fullOutputPath)) group.pane.title += " · full output saved";
286
- if (run.some(node => node.result?.details?.warning || node.result?.details?.warnings?.length)) group.pane.title += " · warning recorded";
287
313
  for (const [index, node] of run.entries()) {
288
314
  node.group = group;
289
315
  if (node.code?.open) {
@@ -447,10 +473,15 @@ export function registerModernTools(pi: ExtensionAPI, mode: DisplayMode, options
447
473
  }
448
474
  node.pane ||= new ToolPane([action(node)], "", height);
449
475
  node.pane.expandedTitle = question(name) ? `Question · ${questionState(node)}` : undefined;
450
- const status = node.note || node.status[0].toUpperCase() + node.status.slice(1);
451
- node.pane.title = compactSubagent(name) ? subagentTitle(name, node.args, node.result, node.status) + indicators(node) : question(name) ? questionTitle(node) : `${toolLabel(name, node.args)}${node.images ? ` · ${node.images} image${node.images === 1 ? "" : "s"}` : ""}${node.status === "success" ? "" : ` · ${node.status === "failed" ? "✗ Failed" : `… ${status}`}`}${indicators(node)}`;
452
- const reason = compactSubagent(name) ? "" : failureReason(node);
453
- if (reason) node.pane.title += ` · ${reason}`;
476
+ if (compactSubagent(name)) node.pane.title = subagentTitle(name, node.args, node.result, node.status) + indicators(node);
477
+ else if (question(name)) node.pane.title = questionTitle(node);
478
+ else {
479
+ const parts = [toolLabel(name, node.args)];
480
+ if (node.images) parts.push(`${node.images} image${node.images === 1 ? "" : "s"}`);
481
+ if (node.status === "failed") parts.push(`✗ ${failureLabel(node)}`);
482
+ else if (node.status !== "success") parts.push(`… ${node.note || node.status[0].toUpperCase() + node.status.slice(1)}`);
483
+ node.pane.title = parts.join(" · ") + indicators(node);
484
+ }
454
485
  if (theme) {
455
486
  node.pane.theme = theme;
456
487
  node.pane.styleHeader = text => activityHeading(text, theme, node.status === "failed" ? "error" : question(name) || subagentDecision(name, node.args) ? "accent" : compactSubagent(name) && node.status === "notice" ? "warning" : "mdLink");
@@ -33,6 +33,8 @@ assert.equal(actionIntent('unknown\u001b[31m\u202e', { label: 'Reveal SECRET', d
33
33
  assert.equal(actionIntent('bash', { command: 'gh pr merge 19' }), 'Run shell commands', 'do not call a write operation a check');
34
34
  assert.equal(actionIntent('bash', { command: 'git reset --hard' }), 'Run shell commands');
35
35
  assert.equal(actionIntent('bash', { command: 'find . -delete' }), 'Run shell commands');
36
+ assert.equal(groupIntent([{ name: 'custom', args: {} }, bash('git status'), bash('npm test'), bash('rg term')], 'brief'),
37
+ 'Check Git changes and run checks', 'keep a short recorded intent before the tool counts');
36
38
  assert.equal(groupIntent([]), 'Run tool actions');
37
39
  assert.equal(groupIntent(Array.from({ length: 65 }, () => ({ name: 'read', args: {} }))), 'Read files; and other actions');
38
40
  let reads = 0;
@@ -0,0 +1,111 @@
1
+ import assert from 'node:assert/strict';
2
+ import { createWorkStripPreview } from '../scripts/preview-work-strip.mjs';
3
+
4
+ // Replay only invented text. This fixture does not execute tools or contact a model.
5
+ const preview = await createWorkStripPreview({ inspection: true, standaloneCode: true });
6
+ const terminal = { columns: 110, rows: 45, kittyProtocolActive: false, start() {}, stop() {}, async drainInput() {} };
7
+ for (const name of ['write', 'moveBy', 'hideCursor', 'showCursor', 'clearLine', 'clearFromCursor', 'clearScreen', 'setTitle', 'setProgress', 'setProgramStatus']) terminal[name] = () => {};
8
+ const plain = value => value.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)|\x1b\[[0-?]*[ -/]*[@-~]/g, '');
9
+ let ui;
10
+ try {
11
+ ui = new preview.core.InteractiveMode(preview.runtime, { tuiMode: 'fullscreen', terminal });
12
+ await ui.init();
13
+ const runner = preview.runtime.session.extensionRunner;
14
+ await runner.getCommand('fold').handler('expand', runner.createContext());
15
+ const renderer = ui.renderer, scroll = renderer.getPrimaryScrollView();
16
+ renderer.renderNow();
17
+ const row = ui.chatContainer.children.find(row => row.toolCallId === 'standalone-wheel-code');
18
+ assert.ok(row, 'native replay creates the standalone codemode');
19
+ const pane = row.callRendererComponent.owner.code;
20
+ const screen = () => renderer.getScreenLines().map(plain);
21
+ const send = data => { renderer.handleTerminalInput(data); renderer.renderNow(); };
22
+ // Distinct gestures must not become native double-click word selections.
23
+ const clickAt = async (x, y) => { await new Promise(resolve => setTimeout(resolve, 550)); send(`\x1b[<0;${x + 1};${y + 1}M`); send(`\x1b[<0;${x + 1};${y + 1}m`); };
24
+ const wheelAt = (x, y, down) => send(`\x1b[<${down ? 65 : 64};${x + 1};${y + 1}M`);
25
+ const positionPane = atEnd => {
26
+ scroll.scrollToEnd(); renderer.renderNow();
27
+ if (!atEnd) { scroll.scrollTo(Math.max(0, scroll.scrollTop - 3), { disableFollow: true }); renderer.renderNow(); }
28
+ const y = screen().findIndex(line => /▾ codemode/.test(line));
29
+ assert.ok(y >= 0, 'standalone header is visible at its native rendered width');
30
+ return y;
31
+ };
32
+ for (const width of [110, 72, 160]) {
33
+ terminal.columns = width; renderer.requestRender(true); renderer.renderNow();
34
+ pane.collapse(); row.invalidate(); renderer.renderNow();
35
+ scroll.scrollToEnd(); renderer.renderNow();
36
+ const headerY = screen().findIndex(line => /▸ codemode/.test(line));
37
+ assert.ok(headerY >= 0);
38
+ const headerX = screen()[headerY].indexOf('▸ codemode');
39
+ await clickAt(headerX + 2, headerY);
40
+ assert.equal(pane.open, true, 'terminal SGR click expands codemode without /inspect');
41
+ assert.equal(pane.focused, false);
42
+ for (const inspected of [false, true]) {
43
+ for (const atEnd of [true, false]) {
44
+ if (inspected) {
45
+ const choices = [];
46
+ preview.eventBus.emit('compact-renderer:inspect:v1', { add: choice => choices.push(choice) });
47
+ const choice = choices.find(choice => /codemode.*3 nested calls/.test(choice.label));
48
+ assert.ok(choice); choice.focus(); renderer.renderNow();
49
+ await new Promise(resolve => setTimeout(resolve, 50)); renderer.renderNow();
50
+ }
51
+ pane.offset = 0; renderer.renderNow();
52
+ const y = positionPane(atEnd), top = scroll.scrollTop;
53
+ const before = pane.offset;
54
+ wheelAt(headerX + 2, y + 2, true);
55
+ assert.ok(pane.offset > before, `wheel advances body: width=${width}, inspected=${inspected}, atEnd=${atEnd}`);
56
+ assert.equal(scroll.scrollTop, top, 'body wheel does not move transcript');
57
+ const moreY = screen().findIndex((line, index) => index > y && index < y + 21 && /more ↓/.test(line));
58
+ assert.ok(moreY > y);
59
+ const beforeClick = pane.offset;
60
+ await clickAt(screen()[moreY].indexOf('more ↓') + 2, moreY);
61
+ assert.ok(pane.offset > beforeClick, `terminal SGR more click advances settled codemode: width=${width}, inspected=${inspected}, atEnd=${atEnd}, before=${beforeClick}, after=${pane.offset}, footer=${moreY}, header=${y}, row=${screen()[moreY]}`);
62
+ assert.equal(scroll.scrollTop, top, 'more click does not move transcript');
63
+ let iterations = 0;
64
+ while (screen().some(line => /more ↓/.test(line)) && iterations++ < 400) {
65
+ const footerY = screen().findIndex((line, index) => index > y && index < y + 21 && /more ↓/.test(line));
66
+ if (footerY < 0) break;
67
+ wheelAt(headerX + 2, footerY, true);
68
+ assert.equal(scroll.scrollTop, top, 'footer wheel does not move transcript');
69
+ }
70
+ const footerY = screen().findIndex((line, index) => index > y && index < y + 21 && /more ↑/.test(line));
71
+ assert.ok(footerY >= 0, 'repeated native wheel reaches the final footer');
72
+ assert.ok(screen().some(line => line.includes('FINAL_OUTPUT_SENTINEL')), 'full escaped JSON output is reachable');
73
+ const endOffset = pane.offset;
74
+ wheelAt(headerX + 2, footerY, false);
75
+ assert.ok(pane.offset < endOffset, 'upward wheel reveals earlier output');
76
+ assert.equal(renderer.getFocusedComponent(), ui.defaultEditor);
77
+ }
78
+ }
79
+ }
80
+ const promptJump = renderer.getMountedRoots()[0]?.[Symbol.for('notrico/sticky-prompt-strip/owner')];
81
+ if (process.env.PI_PROMPT_JUMP_PATH) {
82
+ assert.ok(promptJump?.mounted, 'Prompt Jump candidate is mounted');
83
+ const beforeSnapshot = pane.offset;
84
+ const anchors = promptJump.prompts();
85
+ assert.equal(pane.offset, beforeSnapshot, 'collecting prompt-list anchors preserves the code viewport');
86
+ const index = anchors.findIndex(anchor => anchor.text.startsWith('独立代码输出滚动测试'));
87
+ assert.ok(index >= 0, 'prompt list includes the standalone fixture');
88
+ assert.equal(promptJump.jumpTo(index), true); renderer.renderNow();
89
+ assert.ok(screen().some(line => line.includes('独立代码输出滚动测试')), 'prompt navigation reveals its native prompt');
90
+ }
91
+ const fold = async action => { await runner.getCommand('fold').handler(action, runner.createContext()); renderer.renderNow(); };
92
+ const projected = () => ui.chatContainer[Symbol.for('compact-renderer:projected-children:v1')];
93
+ await fold('off');
94
+ assert.equal(row.callRendererComponent.owner, undefined, 'Fold off restores the native tool renderer');
95
+ await fold('on');
96
+ assert.equal(row.callRendererComponent.owner.code, pane, 'Fold on restores the same codemode owner');
97
+ await fold('collapse');
98
+ assert.ok(!projected().some(view => view.children?.[0] === row), 'collapse hides the completed work row');
99
+ await fold('expand');
100
+ assert.ok(projected().some(view => view.children?.[0] === row), 'expand restores the work row');
101
+ pane.open = true; pane.offset = 0; renderer.renderNow();
102
+ const reopenedY = positionPane(true), reopenedOffset = pane.offset;
103
+ wheelAt(8, reopenedY + 2, true);
104
+ assert.ok(pane.offset > reopenedOffset, 'wheel still advances after Fold mode and disclosure changes');
105
+ const reopenedMoreY = screen().findIndex((line, index) => index > reopenedY && index < reopenedY + 21 && /more ↓/.test(line));
106
+ assert.ok(reopenedMoreY > reopenedY);
107
+ const beforeReopenedClick = pane.offset;
108
+ await clickAt(screen()[reopenedMoreY].indexOf('more ↓') + 2, reopenedMoreY);
109
+ assert.ok(pane.offset > beforeReopenedClick, 'more click still advances after Fold mode and disclosure changes');
110
+ console.log('Standalone codemode: native SGR click/wheel, escaped JSON/Chinese, widths, inspection and scroll boundaries passed');
111
+ } finally { ui?.stop(); await preview.cleanup(); }
@@ -91,7 +91,8 @@ assert.ok(shell.render(100)[1].includes(themeModule.theme.getFgAnsi('mdLink')),
91
91
  assert.ok(shell.render(100)[1].includes(themeModule.theme.getFgAnsi('muted')), 'running intent and metadata use muted text');
92
92
  assert.doesNotMatch(paint(read), /Alt\+G/, 'unfocused collapsed cards omit repeated key hints');
93
93
  shell.updateResult(result('hello', { exitCode: 0 }));
94
- assert.match(paint(read), /2 actions/);
94
+ assert.match(paint(read), /2 actions · Read files and run shell commands · read ×1 · bash ×1/);
95
+ assert.match(paint(read, 34), /2 actions · Read files/, 'intent precedes the tool counts even at narrow widths');
95
96
  assert.ok(read.render(100)[1].includes(themeModule.theme.getFgAnsi('mdLink')), 'completed action group heading uses native blue');
96
97
  assert.ok(read.render(100)[1].includes(themeModule.theme.getFgAnsi('muted')), 'group intent uses muted text');
97
98
  assert.equal(paint(shell), '');
@@ -174,17 +175,25 @@ try {
174
175
  const fail = make('bash', 'c', { command: 'false' });
175
176
  fail.updateResult({ ...result('failure', { exitCode: 1 }), isError: true });
176
177
  const after = make('read', 'd', { path: '/tmp/after.txt' }); after.updateResult(result('after'));
177
- assert.match(paint(fail), /bash · false · ✗ Failed/); assert.match(paint(after), /read · \/tmp\/after\.txt/);
178
+ assert.match(paint(fail), /bash · false · ✗ Exit code 1/); assert.match(paint(after), /read · \/tmp\/after\.txt/);
178
179
  assert.equal(paint(fail).split('\n').filter(line => line.includes('bash · false')).length, 1, 'failure uses one exceptional header');
179
- assert.match(paint(fail), /Failed · Command failed \(exit 1\)/, 'header includes a bounded recorded failure excerpt');
180
+ assert.match(paint(fail), /✗ Exit code 1/, 'header includes a bounded recorded failure excerpt');
180
181
  assert.match(fail.render(120).map(stripAnsi)[1], /^ ▸ bash · /, 'failure status does not shift the tool name');
181
182
  capture('Single failed action collapsed with status after command', fail);
182
- const failedHeader = fail.render(120).find(line => stripAnsi(line).includes('Failed'));
183
+ const failedHeader = fail.render(120).find(line => stripAnsi(line).includes('✗ Exit code 1'));
183
184
  assert.ok(failedHeader.includes(themeModule.theme.getFgAnsi('error')), 'failed header uses native error color');
184
185
  assertNeutral([failedHeader]);
186
+ fail.updateResult({ ...result('synthetic details', { failureReason: 'precondition_failed', status: 'unknown', code: 'commit_receipt_missing' }), isError: true });
187
+ assert.match(paint(fail), /✗ Precondition failed · commit unconfirmed/);
188
+ capture('Structured failure with an unconfirmed commit', fail);
189
+ fail.updateResult({ ...result('ETIMEDOUT', { status: 'unknown', code: 'commit_receipt_missing' }), isError: true });
190
+ assert.match(paint(fail), /✗ Timed out · commit unconfirmed/);
191
+ fail.updateResult({ ...result('synthetic details', { failureReason: 'postcondition_failed', status: 'unknown' }), isError: true });
192
+ assert.match(paint(fail), /✗ Postcondition failed · outcome unknown/);
193
+ capture('Structured failure with an unknown outcome', fail);
185
194
  const partialFailureOutput = 'partial failure output\nexact second failure line';
186
195
  fail.updateResult({ ...result(partialFailureOutput, { error: 'Recorded denial: ' + 'x'.repeat(5000) }), isError: true }, true);
187
- assert.match(paint(fail), /Failed · Command failed/, 'partial errors remain visible as exceptional cards');
196
+ assert.match(paint(fail), /✗ Failed(?! · Tool failed)/, 'partial errors remain visible as exceptional cards');
188
197
  assert.equal(paint(fail).split('\n').filter(line => line.includes('bash · false')).length, 1);
189
198
  assert.ok(paint(fail, 500).split('\n').map(row => row.trim()).join('').length < 400, 'collapsed failure reason has a bounded length before the full-width card gutter');
190
199
  const failureMouse = (y) => fail.handleMouse({ type: 'click', button: 'left', x: 2, y, screenX: 2, screenY: y, width: 120, height: fail.render(120).length, shift: false, alt: false, ctrl: false });
@@ -454,7 +463,7 @@ clickSingle(densityWriteA, 2);
454
463
  assert.match(paint(densityWriteA), /Content alpha/);
455
464
  assert.doesNotMatch(paint(densityWriteA), /Successfully wrote|Arguments|Output|content:/);
456
465
  const densityChoices = []; pi.events.emit('compact-renderer:inspect:v1', { add: choice => densityChoices.push(choice) });
457
- densityChoices.find(choice => choice.label.includes('Edit files and read files')).focus();
466
+ densityChoices.find(choice => choice.label.includes('write ×2 · read ×2')).focus();
458
467
  input('\t');
459
468
  let detailsRows = densityWriteA.render(120);
460
469
  assert.match(stripAnsi(detailsRows.at(-1)), /Enter expand Details · Tab action/);
@@ -517,7 +526,7 @@ const laterHeadingRow = earlierLarge.render(120).findIndex(row => stripAnsi(row)
517
526
  clickSingle(earlierLarge, laterHeadingRow);
518
527
  inlinePane.expanded.add('density-earlier-large'); inlinePane.reset(); // Simulate another independently open sibling before the clicked action.
519
528
  const laterChoices = []; pi.events.emit('compact-renderer:inspect:v1', { add: choice => laterChoices.push(choice) });
520
- laterChoices.find(choice => choice.label === '2 actions · Read files' && choice.id === laterChoices.at(-1).id).focus();
529
+ laterChoices.find(choice => choice.label === '2 actions · Read files · read ×2' && choice.id === laterChoices.at(-1).id).focus();
521
530
  input('\t');
522
531
  assert.match(paint(earlierLarge), /later small output[\s\S]*▸ Details/);
523
532
  assert.doesNotMatch(paint(earlierLarge), /primary first line/, 'Tab anchors at the mouse-selected sibling');
@@ -562,7 +571,7 @@ const exactError = `Error: ENAMETOOLONG: name too long, lstat '${'\"/fixture/ver
562
571
  const scriptFailure = make('bash', 'script-failure', { command: nodeScripts[0] });
563
572
  const failureRecording = { ...result(exactError, { error: exactError, exitCode: 1 }), isError: true };
564
573
  scriptFailure.updateResult(failureRecording);
565
- assert.equal(paint(scriptFailure).trim(), '▸ bash · Run Node.js script · ✗ Failed · Path too long');
574
+ assert.equal(paint(scriptFailure).trim(), '▸ bash · Run Node.js script · ✗ Path too long');
566
575
  assert.ok(paint(scriptFailure, 500).trim().length < 100);
567
576
  scriptFailure.setExpanded(true);
568
577
  assert.doesNotMatch(paint(scriptFailure), /name too long, lstat/);
@@ -98,10 +98,10 @@ try {
98
98
  scripts[1].handleMouse({ type: 'click', button: 'left', x: 3, y: exactErrorRow, width: 100, height: scripts[1].render(100).length });
99
99
  assert.match(paint(scripts[1]), /ENAMETOOLONG: name too long, lstat/);
100
100
  const fourGroup = ui.chatContainer.children.find(item => item instanceof core.ToolExecutionComponent && item.toolName === 'read' && item.args?.path === '/fixture/source.js');
101
- assert.match(paint(fourGroup), /4 actions · Read files and edit files; and other actions/);
101
+ assert.match(paint(fourGroup), /4 actions · Read files and edit files · read ×2 · edit ×1 · bash ×1/);
102
102
  assert.doesNotMatch(paint(fourGroup), /successful|Completed|✓/);
103
103
  const densityGroup = ui.chatContainer.children.find(item => item instanceof core.ToolExecutionComponent && item.toolName === 'write' && item.args?.path === '/fixture/sample-a.txt');
104
- assert.match(paint(densityGroup), /4 actions · Edit files and read files/);
104
+ assert.match(paint(densityGroup), /4 actions · Edit files and read files · write ×2 · read ×2/);
105
105
  densityGroup.setExpanded(true);
106
106
  assert.equal(densityGroup.render(100).length, 6, 'four tight sibling headings plus header and native spacer');
107
107
  const densityPane = densityGroup.resultRendererComponent.owner.group.pane;