pi-bro 0.36.2 → 0.37.0

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
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to pi-bro are documented here.
4
4
 
5
+ ## [0.37.0] - 2026-11-18
6
+
7
+ ### Highlights
8
+
9
+ - Open `/bro` or `/bro simplify` to read the saved explanation, or help if none exists, without a model call, starting at the top of the view.
10
+ - Press Esc from Simplify help to return to the saved explanation without losing your unfinished input.
11
+ - Explain supported local documents outside the workspace using relative paths, absolute paths or symlinks.
12
+
13
+ ### Breaking
14
+
15
+ - Bare `/bro` no longer generates an explanation of the latest assistant reply. Open `/bro`, then run `/simplify` inside, or use `/bro text` without text to generate it directly. Headless callers must use `/bro text` instead of `/bro`.
16
+ - Replaced the exported `isWorkspaceFile` helper with `isDocumentFile`.
17
+
18
+ ## [0.36.3] - 2026-11-10
19
+
20
+ ### Improved
21
+
22
+ - Add simple, live elapsed-time hints for Grill Me interviews and decision briefs, Remember Me proposal drafting, Elevate discovery and rewrites, and Simplify/Show. The shared result modal also shows time for other long-running tasks.
23
+ - Status distinguishes preparation, waiting and receiving output when known. It never guesses completion or displays hidden reasoning or raw tool output.
24
+ - Stop status timers on completion and cancellation; do not store progress with replies, saved memories, or clipboard output. Add quiet-backend, cleanup and constrained-terminal regression coverage.
25
+
5
26
  ## [0.36.2] - 2026-11-10
6
27
 
7
28
  ### Improved
package/README.md CHANGED
@@ -46,7 +46,7 @@ For a first success, type this in Pi after setting up a backend:
46
46
 
47
47
  | After that | What happens |
48
48
  | --- | --- |
49
- | `/bro` | Explains the agent's latest completed reply (requires one) |
49
+ | `/bro` | Shows the saved explanation, or help if none exists. Run `/simplify` inside to explain the latest reply again. |
50
50
  | `/bro copy` | Edit and preview the raw Markdown of the last assistant reply before copying |
51
51
  | `/bro btw What is a race condition?` | Asks a private side question |
52
52
  | `/bro show` | Draws the current session's recent conversation, if any |
package/docs/elevate.md CHANGED
@@ -41,6 +41,8 @@ The **Context: Messages** button toggles to **Context: Full**. Use Tab to focus
41
41
  1. **Discover:** “Given my objective, what would a skilled expert know, question, investigate, or test that I haven't accounted for?” Bro looks across **altitude** (right problem), **depth** (evidence, methods, tests), and **range** (useful ideas from other fields). It offers up to **five** non-overlapping suggestions, with a reason and an expert action for each. It can also report **zero** suggestions.
42
42
  2. **Upgrade:** “Rewrite my request using only the insights I approve. Keep my outcome, constraints, and scope. Improve the quality of the work, not the amount of work.” Bro returns the improved assignment for **you to review**.
43
43
 
44
+ Discovery and rewrite show a live elapsed-time status in the modal footer, even when the selected backend has not begun replying. The footer is not part of the proposed assignment and clears on completion or cancellation.
45
+
44
46
  The flow is **Discover → Select → Upgrade → Copy**. It typically makes **two model calls** (discovery and rewrite); if Bro finds no useful changes, it makes only the discovery call and keeps the original request.
45
47
 
46
48
  ## Example: before and after
@@ -2,6 +2,8 @@
2
2
 
3
3
  [Docs home](../README.md) · [All commands](../reference/commands.md) · [Safety and permissions](../reference/data-and-permissions.md)
4
4
 
5
+ Opening `/bro` or `/bro simplify` shows your saved explanation, or command help if none exists. It does not call the model. Run `/simplify` inside the modal to explain the latest completed assistant reply again.
6
+
5
7
  ## Explanation modes
6
8
 
7
9
  Bro treats quoted source as data and asks the model to ignore embedded
@@ -31,7 +33,7 @@ next mode without saving it:
31
33
  the mode saved by `/bro mode`; pressing it again while Bro is working skips
32
34
  ahead
33
35
  - **O**: Open the diagram (an HTML layout or a rendered sequence diagram) when a show reply contains one
34
- - **Esc**: Close the modal, or cancel while Bro is working
36
+ - **Esc**: From `/help`, return to the saved explanation without rerunning it. If there is no saved explanation, or you are already reading it, close the modal. While Bro is working, cancel and close.
35
37
 
36
38
  The modal header shows the model and reasoning effort the explanation or
37
39
  drawing used (`default` when the model's own effort applies), followed by the
@@ -56,7 +58,7 @@ to simplify the same captured text again.
56
58
 
57
59
  ## Explain a document
58
60
 
59
- Use a path relative to Pi's current workspace, or an absolute path inside it:
61
+ Use a relative or absolute path, including files outside Pi's current workspace. Symlinks are followed; normal OS file permissions apply:
60
62
 
61
63
  ```text
62
64
  /bro file "docs/incident review.pdf"
@@ -34,10 +34,10 @@ This step makes a **real model call**, which may use your backend account's quot
34
34
 
35
35
  | I want to… | Command |
36
36
  | --- | --- |
37
- | Understand the last agent answer | `/bro` (after the main agent has replied) |
37
+ | Understand the last agent answer | Open `/bro`, then run `/simplify` inside |
38
38
  | Ask a side question | `/bro btw What is a race condition?` |
39
39
  | Visualize what we discussed | `/bro show` (after at least one user turn) |
40
- | Explain a file in my workspace | `/bro file docs/my-report.md` (**replace with an existing path**) |
40
+ | Explain a local file | `/bro file docs/my-report.md` (**replace with an existing path**) |
41
41
  | Explain an actual public webpage | `/bro url https://your-public-page.example` (**replace with a real URL**) |
42
42
 
43
43
  See the [docs home](README.md) for detailed workflows.
package/docs/grill-me.md CHANGED
@@ -47,6 +47,8 @@ The old `/finish`, `/copy-all`, `/insert`, `/insert-all`, `/insert-last-message`
47
47
 
48
48
  Grill Me uses the **BTW model/backend/effort** selection from `/bro config`, but has its own independent thread. The header shows depth and effective access; `/help` keeps the footer short. Full access and Agy write risks remain visible in the header even when another notice is shown.
49
49
 
50
+ While Bro works, the footer shows the current stage and elapsed seconds. When the backend reports tools, it shows only the tool name/type. The timer confirms the request is still pending, not that the backend is making progress. Progress disappears on completion or cancellation and never enters saved replies or copies.
51
+
50
52
  ## Access, privacy and limits
51
53
 
52
54
  - Inspection uses the Guided Review backend path in your current workspace. Claude, Muse and Pi have file-only tools. Codex and Grok have read-only sandboxes with shell access. **Agy inspection can still write project files.** No-edit prompts are not security controls.
@@ -6,12 +6,12 @@
6
6
 
7
7
  | Source | Command | What Bro does |
8
8
  | --- | --- | --- |
9
- | Latest assistant reply | `/bro` | Opens Simplify and explains the latest completed reply without inserting the result into Pi's conversation. |
9
+ | Latest assistant reply | `/simplify` inside `/bro`, or `/bro text` | Explains the latest completed reply without inserting the result into Pi's conversation. Opening `/bro` itself shows the saved explanation, or help if none exists. |
10
10
  | Pasted text | `/bro text <text>` | Explains text supplied directly in the command. |
11
- | Local document | `/bro file <path>` | Extracts text from a workspace-local Markdown, text, PDF, or DOCX file. |
11
+ | Local document | `/bro file <path>` | Extracts text from a local Markdown, text, PDF, or DOCX file. |
12
12
  | Public webpage | `/bro url <url>` | Fetches one public HTML page and extracts its main readable content. |
13
13
  | Recent session turns | `/bro show` | Draws the last turns' conversation text as shapes instead of prose (tool calls, tool results, reasoning, and images are omitted). |
14
- | Any of the above, auto-detected | `/bro <input>` | Routes a lone URL to the webpage reader, an existing workspace file with a supported extension to the document reader, and anything else to pasted text. |
14
+ | Any of the above, auto-detected | `/bro <input>` | Routes a lone URL to the webpage reader, an existing local file with a supported extension to the document reader, and anything else to pasted text. |
15
15
 
16
16
  Pressing **R** simplifies the captured source again in the mode shown, and
17
17
  **M** re-simplifies it in the next mode. These commands capture a
@@ -26,12 +26,12 @@ Typing `/bro ` displays ten task-level suggestions: `simplify`, `show`, `btw`, `
26
26
 
27
27
  | Command | Description |
28
28
  | --- | --- |
29
- | `/bro` | Open Simplify and explain the latest completed assistant reply. |
29
+ | `/bro` | Show the saved explanation, or help if none exists. No model call; run `/simplify` inside to explain the latest reply again. |
30
30
  | `/bro simplify` | Reopen the last Simplify screen within this Pi session, without a new model call. |
31
31
  | `/bro copy` | Edit and preview the latest completed assistant reply as raw Markdown. Ctrl+D switches views; Ctrl+C copies Markdown; F1 opens Help. No backend call or saved draft. Native Pi `/copy` copies immediately. [Guide](../features/copy.md). |
32
- | `/bro text <text>` | Explain pasted text. |
33
- | `/bro <input>` | Explain it directly: a lone URL runs the webpage reader, an existing workspace file with a supported extension runs the document reader, and anything else is pasted text. A quoted path with spaces is routed too when the file exists. |
34
- | `/bro file <path>` | Explain a workspace-local `.md`, `.markdown`, `.txt`, `.pdf`, or `.docx` file. |
32
+ | `/bro text [text]` | Explain pasted text, or the latest completed assistant reply when text is omitted. |
33
+ | `/bro <input>` | Explain it directly: a lone URL runs the webpage reader, an existing local file with a supported extension runs the document reader, and anything else is pasted text. A quoted path with spaces is routed too when the file exists. |
34
+ | `/bro file <path>` | Explain a local `.md`, `.markdown`, `.txt`, `.pdf`, or `.docx` file. |
35
35
  | `/bro url <url>` | Explain one public, text-based webpage. |
36
36
  | `/bro open` | Legacy compatibility shortcut to the last result. No `/open` command inside Simplify. |
37
37
  | `/bro show [n-turns] [query]` | Draw recent session turns (default last 1) as shapes instead of prose, from user and assistant conversation text only — tool calls, tool results, reasoning, and images are omitted. An optional query steers what the shapes focus on, with or without a leading turn count. |
@@ -131,9 +131,9 @@ See [feature guide](../features/architecture.md).
131
131
  - **Private session continuity**: completed BTW and Grill Me turns, modes, drafts, the latest Simplify state and the last Show result are saved as Pi `custom` entries inside the current session file. They survive normal reload/restart and are never added to the main model or Advisor snapshot. A fork initially inherits earlier entries; later updates stay on its own branch. This is local disk storage, not a global memory store or an abrupt-crash guarantee. Backend-native sessions may persist independently.
132
132
  Standing Advisor priorities are stored in `~/.pi/agent/bro-advisor.md`, and
133
133
  the session steering brief uses another `custom` entry (`bro-advisor-steering`). Session entries remain readable to anyone with the session file; export/sharing may include them. The private boundary is model-context isolation, not encrypted storage or export redaction.
134
- - **File safety**: `/bro file` reads only regular files whose resolved path is
135
- inside Pi's current workspace, including after resolving symlinks. Bro's
136
- extractor does not modify them.
134
+ - **File access**: `/bro file` reads regular files at the selected relative or
135
+ absolute path, including outside Pi's current workspace and through symlinks.
136
+ Normal OS permissions apply. Bro's extractor does not modify the files.
137
137
  - **Web requests**: `/bro url` connects directly to the target website. The site
138
138
  sees your IP address and Bro's user agent. Bro sends no browser cookies,
139
139
  authorization, or referrer information, and it refuses local, private, and
@@ -37,6 +37,8 @@ Before the first model call, Bro identifies the selected model/backend, the capt
37
37
 
38
38
  Browsing and failed saves preserve the proposal. If the store changed after the proposal was reviewed, `/save` compares the original and current target (and related entries) and **does not save**. An explicit `/confirm-revision` approves against that exact new revision; if it changes again, another review is required. Durable drafts across restarts are not implemented.
39
39
 
40
+ During a draft or revision, the footer shows the current stage and elapsed seconds even if the model is quiet. It does not show the raw draft JSON, and progress is not saved as a memory. Elapsed time means the call remains pending, not that the model has made progress.
41
+
40
42
  Esc closes the modal and cancels an active model call. The draft conversation is not durable; **approved saved memories are durable**. Saved entries survive Pi restarts and project changes.
41
43
 
42
44
  ## Agent access
@@ -166,7 +166,7 @@ See [Troubleshooting and current limits](reference/troubleshooting.md#troublesho
166
166
 
167
167
  ## Simplify modal
168
168
 
169
- `/bro` opens Simplify and explains the latest completed assistant reply. `/bro simplify` returns to the most recent Simplify screen without another model request. Inside, `/simplify`, `/text <text>`, `/file <path>` and `/url <url>` produce one explanation at a time; `/copy` copies the answer, `/clear` clears it, and `/help` shows controls. Press **M** with an empty composer to change the explanation mode and rerun; **R** retries. The saved default mode remains unchanged. The latest result is preserved in private Pi session entries across reload/restart and stays off the main model's context. Old `/bro text|file|url|open` forms remain callable for compatibility.
169
+ `/bro` and `/bro simplify` open the saved explanation, or help if none exists, without a model request. Run `/simplify` inside to explain the latest completed assistant reply. Inside, `/simplify`, `/text <text>`, `/file <path>` and `/url <url>` produce one explanation at a time; `/copy` copies the answer, `/clear` clears it, and `/help` shows controls. Press **M** with an empty composer to change the explanation mode and rerun; **R** retries. The saved default mode remains unchanged. The latest result is preserved in private Pi session entries across reload/restart and stays off the main model's context. Old `/bro text|file|url|open` forms remain callable for compatibility.
170
170
 
171
171
  ## Bro command discovery and Config navigation
172
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-bro",
3
- "version": "0.36.2",
3
+ "version": "0.37.0",
4
4
  "description": "A sidekick for you and your Pi agent: plain-language explanations, side questions, diagrams, PR review and second opinions, without cluttering the agent's context.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/backend.ts CHANGED
@@ -2,6 +2,7 @@ import { type ChildProcess, type SpawnOptions, spawn } from "node:child_process"
2
2
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
+ import { stripVTControlCharacters } from "node:util";
5
6
  import { codexSubscriptionRouteProblem, isSubscriptionStatus, resolveCliChildAuth, type CliAuthBackend } from "./cli-auth.ts";
6
7
  import {
7
8
  createAgentSession,
@@ -60,15 +61,28 @@ export type BackendSelection =
60
61
  | { backend: "muse"; model: string; effort?: (typeof MUSE_EFFORTS)[number] }
61
62
  | { backend: "pi"; model: string; effort?: (typeof PI_EFFORTS)[number] };
62
63
  export type BackendContinuation = { id: string };
63
- export type BackendProgress = { kind: "text"; text: string } | { kind: "activity"; label: string; timestamp: number };
64
+ export type BackendProgress = { kind: "text"; text: string } | { kind: "activity"; label: string; timestamp: number; tool?: string };
64
65
  export type BackendOnProgress = (progress: BackendProgress) => void;
65
66
 
67
+ /** BTW reports a tool name/type, not a command, argument, or assistant message.
68
+ * All six adapters use this extraction before events cross into the UI. */
69
+ export function btwToolName(value: unknown): string | undefined {
70
+ if (typeof value !== "string") return undefined;
71
+ // Restrict to the initial identifier. Agy may supply "Read /path" (or
72
+ // "Read(/path)"); neither should expose the path in a status hint.
73
+ return /^[A-Za-z_][A-Za-z0-9_.-]*/.exec(
74
+ stripVTControlCharacters(value).replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").trim(),
75
+ )?.[0];
76
+ }
77
+
66
78
  export type BackendRequest = {
67
79
  feature: BackendFeature;
68
80
  prompt: string;
69
81
  access: BackendAccess;
70
82
  cwd?: string; // required for workspace-full
71
83
  continuation?: BackendContinuation;
84
+ /** Opt-in tool-only activity for Grill on the review path; Guided Review stays unchanged. */
85
+ reportReviewTools?: boolean;
72
86
  };
73
87
 
74
88
  export type BackendOutcome =
@@ -252,8 +266,10 @@ export function parseBtwAgyLine(line: string): { delta?: string; result?: string
252
266
  throw new Error("Agy returned invalid streaming data.");
253
267
  }
254
268
  const conversationId = event.conversation_id ?? event.result?.conversation_id;
255
- if (event.event === "step_update" && typeof event.step_update?.tool_name === "string" && event.step_update.tool_name.trim()) {
256
- return { activity: event.step_update.tool_name.trim(), conversationId };
269
+ const stepType = event.step_update?.step_type;
270
+ const tool = stepType === "agent_response" || stepType === "assistant" ? undefined : btwToolName(event.step_update?.tool_name);
271
+ if (event.event === "step_update" && tool) {
272
+ return { activity: tool, conversationId };
257
273
  }
258
274
  if (event.event === "step_update" && event.step_update?.step_type === "agent_response" && typeof event.step_update.text_delta === "string") {
259
275
  return { delta: event.step_update.text_delta, conversationId };
@@ -393,7 +409,7 @@ async function executeArgvPrint(
393
409
  if (isBtw) {
394
410
  const parsed = parseBtwAgyLine(line);
395
411
  if (parsed.conversationId) conversationId = parsed.conversationId;
396
- if (parsed.activity) onProgress?.({ kind: "activity", label: parsed.activity, timestamp: Date.now() });
412
+ if (parsed.activity) onProgress?.({ kind: "activity", label: parsed.activity, timestamp: Date.now(), tool: parsed.activity });
397
413
  if (parsed.error) throw new Error(parsed.error);
398
414
  if (parsed.delta) {
399
415
  partial += parsed.delta;
@@ -401,6 +417,11 @@ async function executeArgvPrint(
401
417
  }
402
418
  if (parsed.result !== undefined) final = parsed.result;
403
419
  } else {
420
+ // Review-backed Grill receives tool events without changing review access.
421
+ if (inspect && request.reportReviewTools) {
422
+ const tool = parseBtwAgyLine(line).activity;
423
+ if (tool) onProgress?.({ kind: "activity", label: tool, timestamp: Date.now(), tool });
424
+ }
404
425
  const parsed = parseExplainLine(line);
405
426
  if (parsed.delta) {
406
427
  partial += parsed.delta;
@@ -567,7 +588,12 @@ async function executeAdvisorStdin(
567
588
  throw new Error("Agy emitted invalid stream-json output.");
568
589
  }
569
590
  const activity = advisorActivityFromEvent(event);
570
- if (activity) onProgress?.({ kind: "activity", label: activity, timestamp: Date.now() });
591
+ if (activity) {
592
+ const step = event.step_update;
593
+ const tool = step?.step_type === "agent_response" || step?.step_type === "assistant"
594
+ ? undefined : btwToolName(step?.tool_name);
595
+ onProgress?.({ kind: "activity", label: activity, timestamp: Date.now(), ...(tool ? { tool } : {}) });
596
+ }
571
597
  if (event.event !== "result") return;
572
598
  sawTerminal = true;
573
599
  const result = event.result;
@@ -873,17 +899,18 @@ async function executeClaude(
873
899
  onProgress?.({ kind: "text", text: partial });
874
900
  }
875
901
  }
876
- if ((isAdvisor || isBtw) && topLevel && event.type === "assistant" && Array.isArray(event.message?.content)) {
902
+ if ((isAdvisor || isBtw || (inspect && request.reportReviewTools)) && topLevel && event.type === "assistant" && Array.isArray(event.message?.content)) {
877
903
  for (const block of event.message.content as Array<{ type?: unknown; name?: unknown; text?: unknown }>) {
878
904
  if (attempt.causeOf()) break;
879
- if (isBtw && block?.type !== "tool_use") continue;
905
+ if ((isBtw || (inspect && request.reportReviewTools)) && block?.type !== "tool_use") continue;
906
+ const tool = block?.type === "tool_use" ? btwToolName(block.name) : undefined;
880
907
  const label =
881
908
  block?.type === "tool_use" && typeof block.name === "string"
882
- ? block.name.trim()
909
+ ? ((isBtw || (inspect && request.reportReviewTools)) ? tool : block.name.trim())
883
910
  : block?.type === "text" && typeof block.text === "string"
884
911
  ? block.text.split("\n").find((text) => text.trim())?.trim()
885
912
  : undefined;
886
- if (label) onProgress?.({ kind: "activity", label, timestamp: Date.now() });
913
+ if (label) onProgress?.({ kind: "activity", label, timestamp: Date.now(), ...(tool ? { tool } : {}) });
887
914
  }
888
915
  }
889
916
  if (event.type !== "result" || !topLevel) return;
@@ -1064,17 +1091,18 @@ async function executeGrok(
1064
1091
  }
1065
1092
  streamedSinceAssistant = false;
1066
1093
  }
1067
- if ((isAdvisor || isBtw) && event.type === "assistant" && Array.isArray(message?.content)) {
1094
+ if ((isAdvisor || isBtw || (inspect && request.reportReviewTools)) && event.type === "assistant" && Array.isArray(message?.content)) {
1068
1095
  for (const block of message.content as Array<{ type?: unknown; name?: unknown; text?: unknown }>) {
1069
1096
  if (attempt.causeOf()) break;
1070
- if (isBtw && block?.type !== "tool_use") continue;
1097
+ if ((isBtw || (inspect && request.reportReviewTools)) && block?.type !== "tool_use") continue;
1098
+ const tool = block?.type === "tool_use" ? btwToolName(block.name) : undefined;
1071
1099
  const label =
1072
1100
  block?.type === "tool_use" && typeof block.name === "string"
1073
- ? block.name.trim()
1101
+ ? ((isBtw || (inspect && request.reportReviewTools)) ? tool : block.name.trim())
1074
1102
  : block?.type === "text" && typeof block.text === "string"
1075
1103
  ? block.text.split("\n").find((text) => text.trim())?.trim()
1076
1104
  : undefined;
1077
- if (label) onProgress?.({ kind: "activity", label, timestamp: Date.now() });
1105
+ if (label) onProgress?.({ kind: "activity", label, timestamp: Date.now(), ...(tool ? { tool } : {}) });
1078
1106
  }
1079
1107
  }
1080
1108
  if (event.type !== "result") return;
@@ -1263,11 +1291,10 @@ async function executeCodex(
1263
1291
  return;
1264
1292
  }
1265
1293
  const item = event.item;
1266
- if ((isAdvisor || isBtw) && (event.type === "item.started" || event.type === "item.completed")) {
1267
- const activity = isBtw
1268
- ? (typeof item?.type === "string" && item.type !== "agent_message" && item.type !== "reasoning" ? item.type : undefined)
1269
- : codexActivityFromEvent(event);
1270
- if (activity) onProgress?.({ kind: "activity", label: activity, timestamp: Date.now() });
1294
+ if ((isAdvisor || isBtw || (inspect && request.reportReviewTools)) && (event.type === "item.started" || event.type === "item.completed")) {
1295
+ const tool = item?.type !== "agent_message" && item?.type !== "reasoning" ? btwToolName(item?.type) : undefined;
1296
+ const activity = (isBtw || (inspect && request.reportReviewTools)) ? tool : codexActivityFromEvent(event);
1297
+ if (activity) onProgress?.({ kind: "activity", label: activity, timestamp: Date.now(), ...(tool ? { tool } : {}) });
1271
1298
  }
1272
1299
  if (event.type === "item.completed" && item?.type === "agent_message") {
1273
1300
  const text = extractCodexItemText(item);
@@ -1410,15 +1437,16 @@ async function executeMuse(
1410
1437
  const runStream = payload?.run_stream;
1411
1438
  const isRoot = rootRunId !== undefined && runStream?.kind === "run" && runStream.id === rootRunId;
1412
1439
 
1413
- if (isAdvisor || isBtw) {
1440
+ if (isAdvisor || isBtw || (inspect && request.reportReviewTools)) {
1414
1441
  if (envelope.payload_type === "tool.result") {
1415
1442
  const facts = payload?.correlation_facts as { tool_name?: unknown } | undefined;
1416
1443
  const toolName = typeof facts?.tool_name === "string" && facts.tool_name ? facts.tool_name : "tool";
1417
1444
  const candidate = [payload?.text, payload?.command, payload?.path, payload?.file_path, payload?.query]
1418
1445
  .find((v) => typeof v === "string" && v.trim());
1419
1446
  const preview = typeof candidate === "string" ? candidate.replace(/\s+/g, " ").trim() : "";
1420
- const label = isBtw ? toolName : `${toolName}${preview ? ` ${preview}` : ""}`;
1421
- onProgress?.({ kind: "activity", label, timestamp: Date.now() });
1447
+ const tool = btwToolName(toolName);
1448
+ const label = (isBtw || (inspect && request.reportReviewTools)) ? tool : `${toolName}${preview ? ` ${preview}` : ""}`;
1449
+ if (label) onProgress?.({ kind: "activity", label, timestamp: Date.now(), ...(tool ? { tool } : {}) });
1422
1450
  } else if (isAdvisor && envelope.payload_type === "task.lifecycle.status") {
1423
1451
  const event = payload?.event as { message?: unknown } | undefined;
1424
1452
  if (typeof event?.message === "string" && event.message.trim()) {
@@ -1877,7 +1905,9 @@ async function executePi(
1877
1905
  onProgress?.({ kind: "text", text });
1878
1906
  }
1879
1907
  } else if (event.type === "tool_execution_start" && onProgress) {
1880
- onProgress({ kind: "activity", label: event.toolName, timestamp: Date.now() });
1908
+ const tool = btwToolName(event.toolName);
1909
+ const label = request.feature === "btw" || (request.feature === "review" && request.reportReviewTools) ? tool : event.toolName;
1910
+ if (label) onProgress({ kind: "activity", label, timestamp: Date.now(), ...(tool ? { tool } : {}) });
1881
1911
  }
1882
1912
  });
1883
1913
 
package/src/bro.ts CHANGED
@@ -46,7 +46,7 @@ import {
46
46
  } from "./show.ts";
47
47
  import {
48
48
  type BroSource,
49
- isWorkspaceFile,
49
+ isDocumentFile,
50
50
  looksLikeWebUrl,
51
51
  } from "./sources.ts";
52
52
  import { hasBroCustomUi } from "./ui-capabilities.ts";
@@ -189,13 +189,6 @@ export default async function bro(pi: ExtensionAPI) {
189
189
  let action = parts[0] ?? "";
190
190
  let value = raw.slice(raw.split(/\s+/, 1)[0]?.length ?? 0).trim();
191
191
 
192
- if (action === "simplify") {
193
- if (value) { ctx.ui.notify("Use /bro simplify to reopen the last Simplify view; use /text, /file or /url inside it.", "warning"); return; }
194
- try { await openSimplifyWorkflow(ctx, simplifyState, {kind:"resume"}); saveSimplify(); if (simplifyState.result) remember(simplifyState.result); }
195
- catch (error) { ctx.ui.notify(withDoctor(error), "error"); }
196
- return;
197
- }
198
-
199
192
  // Removed commands must never fall through to a paid text explanation.
200
193
  if (action === "model" || action === "effort") {
201
194
  ctx.ui.notify(`/bro ${action} was removed. Use /bro config to choose the shared default and per-capability ${action}; use /bro text <text> to explain text.`, "warning");
@@ -209,7 +202,7 @@ export default async function bro(pi: ExtensionAPI) {
209
202
  action = quoted || !/\s/.test(candidate)
210
203
  ? looksLikeWebUrl(candidate)
211
204
  ? "url"
212
- : (await isWorkspaceFile(candidate, ctx.cwd))
205
+ : (await isDocumentFile(candidate, ctx.cwd))
213
206
  ? "file"
214
207
  : "text"
215
208
  : "text";
@@ -218,12 +211,18 @@ export default async function bro(pi: ExtensionAPI) {
218
211
 
219
212
  // Source operations open the same single-purpose Simplify modal, not separate
220
213
  // top-level workflows. Old /bro text|file|url commands remain valid aliases.
221
- if (!action || action === "text" || action === "file" || action === "url") {
214
+ if (!action || action === "simplify" || action === "text" || action === "file" || action === "url") {
215
+ if (action === "simplify" && value) {
216
+ ctx.ui.notify("Use /bro simplify to reopen the last Simplify view; use /text, /file or /url inside it.", "warning");
217
+ return;
218
+ }
222
219
  if ((action === "file" || action === "url") && !value) {
223
220
  ctx.ui.notify(`Use /bro ${action} <${action === "file" ? "path" : "url"}>.`, "warning");
224
221
  return;
225
222
  }
226
- const initial = !action || (action === "text" && !value)
223
+ const initial = !action || action === "simplify"
224
+ ? {kind:"resume" as const}
225
+ : action === "text" && !value
227
226
  ? {kind:"latest" as const}
228
227
  : {kind:action as "text" | "file" | "url", input:value};
229
228
  try {
@@ -501,7 +500,7 @@ export default async function bro(pi: ExtensionAPI) {
501
500
  }
502
501
  if (!lastResult) {
503
502
  await showBroModal(ctx, {
504
- text: "# Nothing to open yet\n\nUse `/bro text <text>`, run `/bro` after an assistant response, use `/bro file <path>`, use `/bro url <url>`, or run `/bro show` to draw recent turns.",
503
+ text: "# Nothing to open yet\n\nUse `/bro text <text>`, run `/bro text` (or `/simplify` inside `/bro`) after an assistant response, use `/bro file <path>`, use `/bro url <url>`, or run `/bro show` to draw recent turns.",
505
504
  kind: "empty",
506
505
  });
507
506
  return;
package/src/btw.ts CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  selectionLabel,
14
14
  } from "./settings.ts";
15
15
  import { captureShowTranscript } from "./show.ts";
16
- import { BRO_OVERLAY, broOverlayArea, formatNotice, modalHeight, openBroOverlay, renderFrame, Scroller, type Area, type NoticeTone, type Theme, type TuiLike } from "./modal-kit.ts";
16
+ import { BRO_OVERLAY, broOverlayArea, formatNotice, modalHeight, openBroOverlay, renderFrame, runningHint, Scroller, startProgressClock, type Area, type NoticeTone, type Theme, type TuiLike } from "./modal-kit.ts";
17
17
  import { type BroMouseEvent, type BroMouseResult } from "./ui-capabilities.ts";
18
18
  import { errorMessage } from "./util.ts";
19
19
 
@@ -139,12 +139,15 @@ export async function runBtwTurn(
139
139
  options: { full: boolean; cwd: string; conversationId?: string },
140
140
  signal: AbortSignal,
141
141
  onProgress?: (event: BackendProgress) => void,
142
+ onRenderedText?: (text: string) => void,
142
143
  ): Promise<{ text: string; conversationId?: string; expiredContinuation?: true }> {
143
- const textProgress = textProgressThrottle(signal, (text) => onProgress?.({ kind: "text", text }));
144
+ // Phases use backend event order. Only expensive transcript rendering is delayed.
145
+ // Otherwise an old throttled text update can replace a newer tool status.
146
+ const textProgress = textProgressThrottle(signal, onRenderedText);
144
147
  const receive = (event: BackendProgress) => {
145
148
  if (signal.aborted) return;
146
- if (event.kind === "activity") onProgress?.(event);
147
- else textProgress.receive?.(event);
149
+ onProgress?.(event);
150
+ if (event.kind === "text") textProgress.receive?.(event);
148
151
  };
149
152
 
150
153
  try {
@@ -226,6 +229,12 @@ export class BtwModal implements Focusable {
226
229
  this.tui.requestRender();
227
230
  }
228
231
 
232
+ /** Start at the top of a static or single-document view. */
233
+ scrollToStart(): void {
234
+ this.scroller.toStart();
235
+ this.tui.requestRender();
236
+ }
237
+
229
238
  /** Show the newest text and keep following it while a reply streams. */
230
239
  scrollToEnd(): void {
231
240
  this.scroller.toEnd();
@@ -337,7 +346,13 @@ export class BtwModal implements Focusable {
337
346
  this.input.render(inner)[0] ?? "",
338
347
  ],
339
348
  notice: this.noticeText ? formatNotice(this.theme, this.noticeText, this.noticeTone) : undefined,
340
- hints: this.running ? `${this.progressText || "Bro is thinking…"} · Esc close (stops reply)` : (this.appearance.idleHint ?? "Enter send · Esc close"),
349
+ // A tool label may be long. Preserve the elapsed seconds and Esc
350
+ // on one line; shorten only the stage so transcript height stays put.
351
+ hints: this.running
352
+ ? runningHint(this.progressText || "Bro is thinking…", inner, [
353
+ " · Esc close (stops reply)", " · Esc close",
354
+ ])
355
+ : (this.appearance.idleHint ?? "Enter send · Esc close"),
341
356
  });
342
357
  }
343
358
 
@@ -424,21 +439,22 @@ export async function openBtwModal(
424
439
  const work: { pending?: BtwTurn; original?: BtwTurn } = { original: replaced };
425
440
  activeTurn = work;
426
441
  controller = turnController;
427
- const startedAt = Date.now();
442
+ let elapsedSeconds = 0;
428
443
  let stage = "Preparing request";
429
444
  const updateProgress = () => {
430
445
  if (!closed && controller === turnController && !turnController.signal.aborted)
431
- modal.setProgress(`${stage} · ${Math.floor((Date.now() - startedAt) / 1000)}s`);
446
+ modal.setProgress(`${stage} · ${elapsedSeconds}s`);
432
447
  };
433
- const timer = setInterval(updateProgress, 1000);
434
- timer.unref?.();
448
+ modal.setRunning(true);
449
+ const stopClock = startProgressClock(turnController.signal, seconds => {
450
+ elapsedSeconds = seconds;
451
+ updateProgress();
452
+ });
435
453
  const stopProgress = () => {
436
- clearInterval(timer);
454
+ stopClock();
437
455
  if (stopActiveProgress === stopProgress) stopActiveProgress = undefined;
438
456
  };
439
457
  stopActiveProgress = stopProgress;
440
- modal.setRunning(true);
441
- updateProgress();
442
458
 
443
459
  let settings: BroSettings;
444
460
  let preferences: string;
@@ -491,16 +507,15 @@ export async function openBtwModal(
491
507
  updateProgress();
492
508
  const showBackendProgress = (event: BackendProgress) => {
493
509
  if (closed || turnController.signal.aborted) return;
494
- if (event.kind === "activity") {
495
- // Tool names/types only, never commands, tool results, or hidden reasoning.
496
- const label = event.label.trim().split(/\s+/)[0]?.slice(0, 30);
497
- if (label) stage = `Last tool: ${label}`;
498
- } else {
499
- stage = "Receiving answer";
500
- pending.answer = event.text;
501
- modal.setText(transcript());
502
- }
503
- updateProgress();
510
+ // Activity labels are name/type-only at the backend boundary.
511
+ // Process every phase here, before the 75 ms text render throttle.
512
+ const next = event.kind === "activity" ? `Last tool: ${event.label}` : "Receiving answer";
513
+ if (next !== stage) { stage = next; updateProgress(); }
514
+ };
515
+ const showRenderedText = (partial: string) => {
516
+ if (closed || turnController.signal.aborted) return;
517
+ pending.answer = partial;
518
+ modal.setText(transcript());
504
519
  };
505
520
  let result = await runBtwTurn(
506
521
  buildBtwPrompt(context, question, { full, history, preferences }),
@@ -508,6 +523,7 @@ export async function openBtwModal(
508
523
  { full, cwd: ctx.cwd, conversationId },
509
524
  turnController.signal,
510
525
  showBackendProgress,
526
+ showRenderedText,
511
527
  );
512
528
  if (closed || turnController.signal.aborted) return;
513
529
  if (result.expiredContinuation) {
@@ -524,6 +540,7 @@ export async function openBtwModal(
524
540
  { full, cwd: ctx.cwd },
525
541
  turnController.signal,
526
542
  showBackendProgress,
543
+ showRenderedText,
527
544
  );
528
545
  result = reseeded;
529
546
  }
package/src/elevate.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  selectedFindings, stripElevateFence, captureElevateContext, isElevateContextOverflow,
8
8
  reduceElevateContext, elevateDisplayText, type ElevateContextMode, type ElevateDiscovery, type ElevateInput,
9
9
  } from "./elevate-engine.ts";
10
- import { BRO_OVERLAY, broOverlayArea, buttonLabels, delegateMouse, formatNotice, modalHeight, openBroOverlay, renderFrame, Scroller, wrapButtons, type Area, type Theme, type TuiLike } from "./modal-kit.ts";
10
+ import { BRO_OVERLAY, broOverlayArea, buttonLabels, delegateMouse, formatNotice, modalHeight, openBroOverlay, renderFrame, Scroller, startProgressClock, wrapButtons, type Area, type Theme, type TuiLike } from "./modal-kit.ts";
11
11
  import { readPreferences, readSettings, selectionForCapability, selectionLabel } from "./settings.ts";
12
12
  import { type BroMouseEvent, type BroMouseResult } from "./ui-capabilities.ts";
13
13
  import { errorMessage } from "./util.ts";
@@ -32,6 +32,7 @@ export class ElevateModal implements Focusable {
32
32
  private rawArea: Area | undefined;
33
33
  private editorArea: Area = { top: 0, left: 0, width: 0, height: 0 };
34
34
  private stage: Stage = "compose";
35
+ private progressText = "";
35
36
  private zone: Zone = "editor";
36
37
  private notice = "";
37
38
  private model = "";
@@ -97,6 +98,11 @@ export class ElevateModal implements Focusable {
97
98
  get currentSelection(): ReadonlySet<number> { return this.accepted; }
98
99
  setModel(value: string): void { this.model = value; if (!this.disposed) this.tui.requestRender(); }
99
100
  setNotice(value: string): void { if (!this.disposed) { this.notice = value; this.tui.requestRender(); } }
101
+ setProgress(value: string): void {
102
+ if (this.disposed || (this.stage !== "discovering" && this.stage !== "upgrading")) return;
103
+ this.progressText = value;
104
+ this.tui.requestRender();
105
+ }
100
106
 
101
107
  // Every state setter is inert after disposal: a late backend result must never touch an
102
108
  // unmounted component.
@@ -107,6 +113,7 @@ export class ElevateModal implements Focusable {
107
113
  this.discovery = undefined;
108
114
  this.accepted.clear();
109
115
  this.stage = "discovering";
116
+ this.progressText = "";
110
117
  // Waiting stages have no zones; focusing actions keeps Page/wheel scrolling reachable.
111
118
  this.zone = "actions";
112
119
  this.notice = "";
@@ -131,9 +138,9 @@ export class ElevateModal implements Focusable {
131
138
  this.syncEditorFocus();
132
139
  this.drawFromTop();
133
140
  }
134
- setUpgrading(): void { if (this.disposed) return; this.stage = "upgrading"; this.zone = "actions"; this.notice = ""; this.syncEditorFocus(); this.drawFromTop(); }
135
- setReady(value: string): void { if (this.disposed) return; this.stage = "ready"; this.revised = value.trim(); this.notice = ""; this.zone = "actions"; this.action = 0; this.syncEditorFocus(); this.drawFromTop(); }
136
- setFailed(message: string): void { if (this.disposed) return; this.stage = "failed"; this.notice = message; this.zone = "actions"; this.action = 0; this.syncEditorFocus(); this.drawFromTop(); }
141
+ setUpgrading(): void { if (this.disposed) return; this.stage = "upgrading"; this.progressText = ""; this.zone = "actions"; this.notice = ""; this.syncEditorFocus(); this.drawFromTop(); }
142
+ setReady(value: string): void { if (this.disposed) return; this.stage = "ready"; this.progressText = ""; this.revised = value.trim(); this.notice = ""; this.zone = "actions"; this.action = 0; this.syncEditorFocus(); this.drawFromTop(); }
143
+ setFailed(message: string): void { if (this.disposed) return; this.stage = "failed"; this.progressText = ""; this.notice = message; this.zone = "actions"; this.action = 0; this.syncEditorFocus(); this.drawFromTop(); }
137
144
  /** Back to the objective for editing, keeping what the user already wrote. */
138
145
  setCompose(objective?: string): void {
139
146
  if (this.disposed) return;
@@ -387,7 +394,7 @@ export class ElevateModal implements Focusable {
387
394
  : this.stage === "review" ? "↑↓ move · Space/Enter toggle · Tab actions · Ctrl+C copy · Esc cancel"
388
395
  : this.stage === "ready" ? "↑↓ scroll · Ctrl+C copy · Esc close"
389
396
  : this.stage === "failed" ? "Ctrl+C copy · Esc close"
390
- : "Thinking… · Esc cancel";
397
+ : `${this.progressText || "Thinking…"} · Esc cancel`;
391
398
  return renderFrame(this.theme, width, height, {
392
399
  header: () => this.theme.fg("accent", this.theme.bold("Bro · elevate"))
393
400
  + this.theme.fg("dim", ` · ${this.contextMode === "messages" ? "Messages" : "Full"}${this.contextReduced ? " (reduced)" : ""}`)
@@ -457,6 +464,7 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
457
464
  await openBroOverlay<void>(ctx, (tui, theme, _keybindings, done) => {
458
465
  let closed = false;
459
466
  let controller: AbortController | undefined;
467
+ let stopProgress: (() => void) | undefined;
460
468
  let original = initialObjective;
461
469
  let contextMessages = captureElevateContext(branch, "messages");
462
470
  let reduced = false;
@@ -468,6 +476,7 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
468
476
  const close = () => {
469
477
  if (closed) return;
470
478
  closed = true;
479
+ stopProgress?.();
471
480
  controller?.abort();
472
481
  done(undefined);
473
482
  };
@@ -496,18 +505,30 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
496
505
  controller = run;
497
506
  pending = { kind: "discover" };
498
507
  modal.setDiscovering(original);
508
+ let phase = "Preparing discovery";
509
+ const stop = startProgressClock(run.signal, seconds => {
510
+ if (!closed && controller === run) modal.setProgress(`${phase} · ${seconds}s`);
511
+ });
512
+ stopProgress = stop;
499
513
  try {
500
514
  const [settings, preferences] = await Promise.all([readSettings(), readPreferences()]);
501
515
  if (closed || run.signal.aborted) return;
502
516
  input.preferences = preferences;
503
517
  const selection = selectionForCapability(settings, "btw");
504
518
  modal.setModel(selectionLabel(selection));
505
- const raw = await runBackendText(buildElevateDiscoveryPrompt(input), selection, run.signal);
519
+ phase = "Discovering improvements";
520
+ const raw = await runBackendText(buildElevateDiscoveryPrompt(input), selection, run.signal, () => {
521
+ phase = "Receiving findings";
522
+ });
506
523
  if (closed || run.signal.aborted) return;
507
524
  modal.setDiscovery(parseElevateDiscovery(raw));
508
525
  } catch (error) {
509
526
  if (!closed && !run.signal.aborted) fail(error);
510
- } finally { if (controller === run) controller = undefined; }
527
+ } finally {
528
+ stop();
529
+ if (stopProgress === stop) stopProgress = undefined;
530
+ if (controller === run) controller = undefined;
531
+ }
511
532
  }
512
533
 
513
534
  async function upgrade(indexes: ReadonlySet<number>): Promise<void> {
@@ -519,6 +540,11 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
519
540
  input.context = contextText();
520
541
  reduceOnRetry = false;
521
542
  modal.setUpgrading();
543
+ let phase = "Preparing rewrite";
544
+ const stop = startProgressClock(run.signal, seconds => {
545
+ if (!closed && controller === run) modal.setProgress(`${phase} · ${seconds}s`);
546
+ });
547
+ stopProgress = stop;
522
548
  try {
523
549
  const settings = await readSettings();
524
550
  if (closed || run.signal.aborted) return;
@@ -531,7 +557,10 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
531
557
  const approved = selectedFindings(discovery, indexes);
532
558
  const selection = selectionForCapability(settings, "btw");
533
559
  modal.setModel(selectionLabel(selection));
534
- const revised = await runBackendText(buildElevateUpgradePrompt(input, approved), selection, run.signal);
560
+ phase = "Rewriting request";
561
+ const revised = await runBackendText(buildElevateUpgradePrompt(input, approved), selection, run.signal, () => {
562
+ phase = "Receiving revision";
563
+ });
535
564
  if (closed || run.signal.aborted) return;
536
565
  if (!revised.trim()) throw new Error("Bro returned an empty request. Retry.");
537
566
  // Validate after stripping: a fence containing only whitespace is still empty output, and
@@ -541,7 +570,11 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
541
570
  modal.setReady(cleaned);
542
571
  } catch (error) {
543
572
  if (!closed && !run.signal.aborted) fail(error);
544
- } finally { if (controller === run) controller = undefined; }
573
+ } finally {
574
+ stop();
575
+ if (stopProgress === stop) stopProgress = undefined;
576
+ if (controller === run) controller = undefined;
577
+ }
545
578
  }
546
579
 
547
580
  /** Retry whichever call failed, with the objective and approvals the user already chose. */
@@ -36,7 +36,7 @@ import {
36
36
  } from "./settings.ts";
37
37
  import { openShowHtml, stripShowDiagramFence } from "./show.ts";
38
38
  import type { BroSource } from "./sources.ts";
39
- import { BRO_OVERLAY, broOverlayArea, delegateMouse, formatNotice, modalHeight, openBroOverlay, renderFrame, Scroller, type Area, type NoticeTone, type Theme, type TuiLike } from "./modal-kit.ts";
39
+ import { BRO_OVERLAY, broOverlayArea, delegateMouse, formatNotice, modalHeight, openBroOverlay, renderFrame, runningHint, Scroller, startProgressClock, type Area, type NoticeTone, type Theme, type TuiLike } from "./modal-kit.ts";
40
40
  import { hasBroCustomUi, type BroMouseEvent, type BroMouseResult } from "./ui-capabilities.ts";
41
41
  import { errorMessage } from "./util.ts";
42
42
  import { latestCompletedAssistantText } from "./last-assistant.ts";
@@ -381,10 +381,10 @@ These are needs, not modes. Copied text does not enter Pi until you paste and su
381
381
 
382
382
  ## Explain and show
383
383
 
384
- - \`/bro\` — open Simplify and explain the latest completed assistant reply
384
+ - \`/bro\` — read the saved explanation, or help if none exists; /simplify inside runs again
385
385
  - \`/bro simplify\` — reopen the current Simplify screen without another model call
386
386
  - \`/bro text [text]\` — explain pasted text, or the latest reply when text is omitted
387
- - \`/bro file <path>\` — explain a workspace \`.md\`, \`.markdown\`, \`.txt\`, \`.pdf\`, or \`.docx\` file
387
+ - \`/bro file <path>\` — explain a local \`.md\`, \`.markdown\`, \`.txt\`, \`.pdf\`, or \`.docx\` file
388
388
  - \`/bro url <url>\` — explain one public webpage
389
389
  - \`/bro <input>\` — a lone URL, an existing supported file, or anything else as pasted text
390
390
  - Inside Simplify: \`/simplify\`, \`/text <text>\`, \`/file <path>\`, \`/url <url>\`, \`/copy\`, \`/clear\`, \`/help\`. **M** changes the mode and re-explains; **R** retries. One source at a time, no chat thread.\n- \`/bro open\` — legacy last-result view (retained for compatibility)
@@ -477,6 +477,7 @@ export class BroModal implements Focusable {
477
477
  private modelLabel = "";
478
478
  private noticeText = "";
479
479
  private noticeTone: NoticeTone = "info";
480
+ private progressText = "";
480
481
  private rawArea: Area | undefined;
481
482
  private readonly scroller = new Scroller(() => {
482
483
  this.noticeText = "";
@@ -528,6 +529,12 @@ export class BroModal implements Focusable {
528
529
  this.tui.requestRender();
529
530
  }
530
531
 
532
+ setProgress(value: string): void {
533
+ if (this.disposed || (this.kind !== "loading" && this.kind !== "streaming")) return;
534
+ this.progressText = value;
535
+ this.tui.requestRender();
536
+ }
537
+
531
538
  setHtmlPath(path: string): void {
532
539
  this.htmlPath = path;
533
540
  this.tui.requestRender();
@@ -563,6 +570,7 @@ export class BroModal implements Focusable {
563
570
  noticeTone: NoticeTone = "info",
564
571
  ): void {
565
572
  this.kind = kind;
573
+ if (kind !== "streaming") this.progressText = "";
566
574
  if (kind !== "result") this.htmlPath = "";
567
575
  this.rawText = rawText;
568
576
  this.copyable = copyable;
@@ -583,10 +591,17 @@ export class BroModal implements Focusable {
583
591
  return Boolean(this.modeLabel) && (this.kind === "loading" || this.kind === "streaming" || this.kind === "result");
584
592
  }
585
593
 
586
- private controls(): string {
594
+ private controls(innerWidth: number): string {
587
595
  const mode = this.canSwitchMode() ? " · M mode" : "";
588
- if (this.kind === "loading") return mode ? "M mode · Esc cancel" : "Esc cancel";
589
- if (this.kind === "streaming") return `Simplifying… · ↑/↓ scroll${mode} · Esc cancel`;
596
+ if (this.kind === "loading" || this.kind === "streaming") {
597
+ // The elapsed seconds and Esc matter more than a long stage name.
598
+ // Keep one hint row so the body never jumps as that stage changes.
599
+ const scroll = this.kind === "streaming" ? " · ↑/↓ scroll" : "";
600
+ const phase = this.progressText || (this.kind === "loading" ? "Working…" : "Receiving output…");
601
+ return runningHint(phase, innerWidth, [
602
+ `${scroll}${mode} · Esc cancel`, `${mode} · Esc cancel`, " · Esc cancel",
603
+ ], 12);
604
+ }
590
605
  if (this.kind === "result") {
591
606
  return `↑/↓ scroll · C copy${this.htmlPath ? " · O open diagram" : ""}${mode}${this.retryable ? ` · R ${this.retryLabel}` : ""} · Esc close`;
592
607
  }
@@ -608,7 +623,7 @@ export class BroModal implements Focusable {
608
623
  },
609
624
  body: (rows, innerWidth) => this.scroller.view(this.markdown.render(innerWidth), rows),
610
625
  notice: this.noticeText ? formatNotice(this.theme, this.noticeText, this.noticeTone) : undefined,
611
- hints: this.controls(),
626
+ hints: this.controls(Math.max(1, width - 2)),
612
627
  });
613
628
  }
614
629
 
@@ -700,6 +715,7 @@ export async function showBroModal(ctx: ExtensionCommandContext, options: BroMod
700
715
  (tui, theme, _keybindings, done) => {
701
716
  let closed = false;
702
717
  let controller: AbortController | undefined;
718
+ let stopProgress: (() => void) | undefined;
703
719
  let current = options.result;
704
720
  let inFlightMode: BroMode | undefined;
705
721
  let execute: (source?: BroSource, mode?: BroMode, notice?: string, noticeTone?: NoticeTone) => void = () => {};
@@ -707,6 +723,7 @@ export async function showBroModal(ctx: ExtensionCommandContext, options: BroMod
707
723
  const close = () => {
708
724
  if (closed) return;
709
725
  closed = true;
726
+ stopProgress?.();
710
727
  controller?.abort();
711
728
  done(undefined);
712
729
  };
@@ -718,6 +735,7 @@ export async function showBroModal(ctx: ExtensionCommandContext, options: BroMod
718
735
  () => execute(current?.source, current?.mode),
719
736
  () => {
720
737
  closed = true;
738
+ stopProgress?.();
721
739
  controller?.abort();
722
740
  },
723
741
  options.retryLabel ?? "simplify again",
@@ -726,6 +744,7 @@ export async function showBroModal(ctx: ExtensionCommandContext, options: BroMod
726
744
  const from = inFlightMode ?? current?.mode;
727
745
  if (!from || !current?.source || closed) return;
728
746
  const next = nextBroMode(from);
747
+ stopProgress?.();
729
748
  controller?.abort();
730
749
  controller = undefined;
731
750
  execute(current.source, next, `Mode: ${next} (not saved)`);
@@ -749,10 +768,17 @@ export async function showBroModal(ctx: ExtensionCommandContext, options: BroMod
749
768
  modal.setLoading(options.loadingText);
750
769
  modal.setMode(mode);
751
770
  modal.setPreferences(false);
771
+ const phase = options.loadingText ?? "Working";
772
+ const stop = startProgressClock(nextController.signal, seconds => {
773
+ if (!closed && controller === nextController) modal.setProgress(`${phase} · ${seconds}s`);
774
+ });
775
+ stopProgress = stop;
752
776
 
753
777
  void options
754
778
  .run(nextController.signal, source, (text) => {
755
779
  if (closed || nextController.signal.aborted || controller !== nextController) return;
780
+ // This callback may be a workflow stage (Architecture), not
781
+ // a streaming answer. The body owns the stage; keep the hint neutral.
756
782
  modal.setStreaming(text);
757
783
  }, mode)
758
784
  .then((result) => {
@@ -773,6 +799,8 @@ export async function showBroModal(ctx: ExtensionCommandContext, options: BroMod
773
799
  }
774
800
  })
775
801
  .finally(() => {
802
+ stop();
803
+ if (stopProgress === stop) stopProgress = undefined;
776
804
  if (controller === nextController) {
777
805
  controller = undefined;
778
806
  inFlightMode = undefined;
package/src/grill.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  } from "./grill-engine.ts";
9
9
  import { readPreferences, readSettings, selectionForCapability, selectionLabel, capabilityBackend } from "./settings.ts";
10
10
  import { captureShowTranscript } from "./show.ts";
11
- import { openBroOverlay } from "./modal-kit.ts";
11
+ import { openBroOverlay, startProgressClock } from "./modal-kit.ts";
12
12
  import { errorMessage } from "./util.ts";
13
13
 
14
14
  /**
@@ -27,6 +27,7 @@ export async function openGrillModal(
27
27
  (tui, theme, _keys, done) => {
28
28
  let closed = false;
29
29
  let controller: AbortController | undefined;
30
+ let stopProgress: (() => void) | undefined;
30
31
  let composerTouched = false;
31
32
  let pendingTurn: GrillTurn | undefined;
32
33
  let pendingSummary: string | undefined;
@@ -54,6 +55,7 @@ export async function openGrillModal(
54
55
  if (closed) return;
55
56
  closed = true;
56
57
  saveDraft();
58
+ stopProgress?.();
57
59
  if (!controller) options.onChange?.();
58
60
  controller?.abort();
59
61
  done(undefined);
@@ -61,6 +63,7 @@ export async function openGrillModal(
61
63
  const modal = new BtwModal(tui, theme, close, submit, () => {
62
64
  closed = true;
63
65
  saveDraft();
66
+ stopProgress?.();
64
67
  if (!controller) options.onChange?.();
65
68
  controller?.abort();
66
69
  }, {
@@ -132,6 +135,11 @@ export async function openGrillModal(
132
135
  const attempt = new AbortController();
133
136
  controller = attempt;
134
137
  modal.setRunning(true);
138
+ let phase = turn ? "Preparing next question" : "Preparing decision brief";
139
+ const stop = startProgressClock(attempt.signal, seconds => {
140
+ if (!closed && controller === attempt) modal.setProgress(`${phase} · ${seconds}s`);
141
+ });
142
+ stopProgress = stop;
135
143
  if (turn) pendingReply = operation.reply;
136
144
  try {
137
145
  const prepared = await prepareRun(attempt.signal);
@@ -151,10 +159,18 @@ export async function openGrillModal(
151
159
  modal.setText(transcript());
152
160
  modal.scrollToEnd();
153
161
  }
162
+ phase = turn ? "Waiting for next question" : "Waiting for decision brief";
154
163
  const outcome = await executeBackend(
155
- { ...grillExecution(thread.fullAccess), cwd: ctx.cwd, prompt },
164
+ { ...grillExecution(thread.fullAccess), ...(thread.fullAccess ? {} : { reportReviewTools: true }), cwd: ctx.cwd, prompt },
156
165
  selection, attempt.signal, (event) => {
157
- if (closed || attempt.signal.aborted || event.kind !== "text") return;
166
+ if (closed || attempt.signal.aborted) return;
167
+ if (event.kind === "activity") {
168
+ // Advisor activity may be prose; only structured tool events
169
+ // qualify as a tool status. The adapter owns name filtering.
170
+ if (event.tool) phase = `Last tool: ${event.tool}`;
171
+ return;
172
+ }
173
+ phase = turn ? "Receiving next question" : "Receiving decision brief";
158
174
  if (turn) pendingTurn!.answer = event.text;
159
175
  else pendingSummary = event.text;
160
176
  modal.setText(transcript());
@@ -178,6 +194,8 @@ export async function openGrillModal(
178
194
  if (turn && !modal.getComposerText().trim()) modal.setComposerText(operation.reply);
179
195
  }
180
196
  } finally {
197
+ stop();
198
+ if (stopProgress === stop) stopProgress = undefined;
181
199
  pendingTurn = undefined;
182
200
  pendingSummary = undefined;
183
201
  pendingReply = undefined;
package/src/modal-kit.ts CHANGED
@@ -16,6 +16,40 @@ export type TuiLike = {
16
16
 
17
17
  export type NoticeTone = "info" | "success" | "warning" | "error";
18
18
 
19
+ /** One-second UI heartbeat. It reports elapsed time, not proof of backend activity. */
20
+ export function startProgressClock(signal: AbortSignal, onTick: (seconds: number) => void): () => void {
21
+ const startedAt = Date.now();
22
+ let stopped = false;
23
+ const tick = () => {
24
+ if (!stopped && !signal.aborted) onTick(Math.floor((Date.now() - startedAt) / 1000));
25
+ };
26
+ const timer = setInterval(tick, 1000);
27
+ timer.unref?.();
28
+ const stop = () => {
29
+ if (stopped) return;
30
+ stopped = true;
31
+ clearInterval(timer);
32
+ signal.removeEventListener("abort", stop);
33
+ };
34
+ signal.addEventListener("abort", stop, { once: true });
35
+ if (signal.aborted) stop();
36
+ else tick();
37
+ return stop;
38
+ }
39
+
40
+ /** Keep elapsed time and cancellation visible while trimming only the phase.
41
+ * Each action variant must end with the same short cancel control, longest first. */
42
+ export function runningHint(progress: string, innerWidth: number, actions: readonly string[], minStageWidth = 11): string {
43
+ const match = /^(.*?)( · [0-9]+s)$/.exec(progress);
44
+ const stage = match ? match[1] : progress;
45
+ const elapsed = match ? match[2] : "";
46
+ const action = actions.find((value) =>
47
+ visibleWidth(value) + visibleWidth(elapsed) + minStageWidth <= innerWidth
48
+ ) ?? actions.at(-1) ?? "";
49
+ const stageWidth = Math.max(0, innerWidth - visibleWidth(elapsed) - visibleWidth(action));
50
+ return truncateToWidth(stage, stageWidth, "…") + elapsed + action;
51
+ }
52
+
19
53
  /**
20
54
  * Format a notice text with the semantic tone.
21
55
  * Strips raw terminal control characters from the message to prevent escape sequence injection.
package/src/remember.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
3
3
  import { execute as executeBackend } from "./backend.ts";
4
4
  import { BtwModal, formatBtwTranscript } from "./btw.ts";
5
- import { openBroOverlay } from "./modal-kit.ts";
5
+ import { openBroOverlay, startProgressClock } from "./modal-kit.ts";
6
6
  import { captureShowTranscript } from "./show.ts";
7
7
  import { readPreferences, readSettings, selectionForCapability, selectionLabel } from "./settings.ts";
8
8
  import {
@@ -43,6 +43,7 @@ export async function openRememberModal(ctx: ExtensionCommandContext, initial =
43
43
  await openBroOverlay<void>(ctx, (tui, theme, _keys, done) => {
44
44
  let closed = false;
45
45
  let controller: AbortController | undefined;
46
+ let stopProgress: (() => void) | undefined;
46
47
  let busy = false;
47
48
  let proposal: RememberProposal | undefined;
48
49
  let transcript: RememberTurn[] = [];
@@ -54,8 +55,8 @@ export async function openRememberModal(ctx: ExtensionCommandContext, initial =
54
55
  let browserText = "";
55
56
  let selectedBackend = openingSelection.backend ?? "agy";
56
57
  let selectedModel = selectionLabel(openingSelection);
57
- const close = () => { if (closed) return; closed = true; controller?.abort(); done(undefined); };
58
- const modal = new BtwModal(tui, theme, close, submit, () => { closed = true; controller?.abort(); }, {
58
+ const close = () => { if (closed) return; closed = true; stopProgress?.(); controller?.abort(); done(undefined); };
59
+ const modal = new BtwModal(tui, theme, close, submit, () => { closed = true; stopProgress?.(); controller?.abort(); }, {
59
60
  title:"Bro · remember-me", commands:"", inputLabel:"Your memory or correction",
60
61
  idleHint:"Enter discuss · /save approve · /context show · /help",
61
62
  });
@@ -165,6 +166,11 @@ export async function openRememberModal(ctx: ExtensionCommandContext, initial =
165
166
  busy=true;
166
167
  const attempt=new AbortController();
167
168
  controller=attempt; modal.setRunning(true);
169
+ let phase = "Reading saved memories";
170
+ const stop = startProgressClock(attempt.signal, seconds => {
171
+ if (!closed && controller === attempt) modal.setProgress(`${phase} · ${seconds}s`);
172
+ });
173
+ stopProgress = stop;
168
174
  try {
169
175
  store=await readMemoryStore();
170
176
  const [settings,preferences]=await Promise.all([readSettings(),readPreferences()]);
@@ -177,9 +183,12 @@ export async function openRememberModal(ctx: ExtensionCommandContext, initial =
177
183
  });
178
184
  const pending:RememberTurn={user:input,bro:"Drafting…"};
179
185
  transcript.push(pending); show();
186
+ phase = "Waiting for proposal";
180
187
  const result=await executeBackend({
181
188
  feature:"explain",access:"restricted",cwd:ctx.cwd,prompt
182
- },selection,attempt.signal);
189
+ },selection,attempt.signal,event=>{
190
+ if (!closed && !attempt.signal.aborted && event.kind === "text") phase = "Receiving proposal";
191
+ });
183
192
  if(closed||attempt.signal.aborted)return;
184
193
  if(result.status!=="success")throw new Error(result.message);
185
194
  const parsed=parseRememberResult(result.text);
@@ -206,6 +215,8 @@ export async function openRememberModal(ctx: ExtensionCommandContext, initial =
206
215
  show();
207
216
  }
208
217
  } finally {
218
+ stop();
219
+ if (stopProgress === stop) stopProgress = undefined;
209
220
  if(controller===attempt)controller=undefined;
210
221
  busy=false; if(!closed)modal.setRunning(false);
211
222
  }
@@ -28,10 +28,10 @@ export const SIMPLIFY_MODAL_HELP = [
28
28
  "- \`/simplify\` — explain the latest completed assistant reply",
29
29
  "- \`/url <url>\` — explain a public webpage",
30
30
  "- \`/text <text>\` — explain pasted text",
31
- "- \`/file <path>\` — explain a workspace document",
31
+ "- \`/file <path>\` — explain a local document (any readable path)",
32
32
  "- \`/copy\` — copy the current explanation",
33
33
  "- \`/clear\` — clear the explanation and source",
34
34
  "- \`/help\` — show these commands",
35
35
  "",
36
- "With an empty composer, **M** changes explanation mode and re-explains the captured source; **R** retries. Both keep the backend configured for Explain. **Esc** closes; /bro simplify reopens this view in the current Pi session.",
36
+ "With an empty composer, **M** changes explanation mode and re-explains the captured source; **R** retries. Both keep the backend configured for Explain. **Esc** returns from help to your saved explanation; if there is none, or you are already reading it, **Esc** closes. /bro simplify reopens this view in the current Pi session.",
37
37
  ].join("\n");
@@ -5,7 +5,7 @@ import { copyToClipboard } from "@earendil-works/pi-coding-agent";
5
5
  import { matchesKey } from "@earendil-works/pi-tui";
6
6
  import { BtwModal } from "./btw.ts";
7
7
  import { latestAssistant, simplify, type BroResult } from "./explain-modal.ts";
8
- import { openBroOverlay } from "./modal-kit.ts";
8
+ import { openBroOverlay, startProgressClock } from "./modal-kit.ts";
9
9
  import { nextBroMode, type BroMode } from "./prompt.ts";
10
10
  import { readSettings } from "./settings.ts";
11
11
  import { extractDocumentText, extractWebPage, type BroSource } from "./sources.ts";
@@ -58,41 +58,60 @@ export async function openSimplifyWorkflow(
58
58
  return;
59
59
  }
60
60
 
61
+ if (initial.kind === "resume") {
62
+ state.view = state.result ? "result" : "help";
63
+ if (!state.draft?.trim()) state.error = undefined;
64
+ }
65
+
61
66
  await openBroOverlay<void>(ctx,(tui,theme,_keys,done)=>{
62
67
  let closed=false;
63
68
  let controller:AbortController|undefined;
69
+ let stopProgress:(()=>void)|undefined;
64
70
  let running=false;
65
- const close=()=>{if(closed)return; closed=true;state.draft=modal.getComposerText();controller?.abort();done(undefined);};
71
+ const syncDraft=()=>{const draft=modal.getComposerText();state.draft=draft;if(!draft.trim())state.error=undefined;};
72
+ const close=()=>{if(closed)return; closed=true;syncDraft();stopProgress?.();controller?.abort();done(undefined);};
66
73
  const modal=new BtwModal(tui,theme,close,submit,()=>{
67
- closed=true;state.draft=modal.getComposerText();controller?.abort();
74
+ if(!closed){closed=true;syncDraft();stopProgress?.();controller?.abort();}
68
75
  },{
69
76
  title:"Bro · simplify",
70
77
  commands:"",
71
- inputLabel:"Simplify command",
72
- idleHint:"Enter run · M change mode · R retry · /copy · /help · Esc close",
78
+ inputLabel:"Simplify command · /simplify runs again on the latest reply",
79
+ idleHint:"Enter run · M change mode · R retry · /copy · /help · Esc back from help / close",
73
80
  });
74
81
  const display=()=>{
75
82
  modal.setCustomMode(state.result?.mode ? state.result.mode+(state.result.preferences ? " · prefs" : "") : "one source · one explanation");
76
83
  modal.setModel(state.result?.model ?? "");
77
- if(state.view==="help")modal.setText(SIMPLIFY_MODAL_HELP);
78
- else if(state.view==="result"&&state.result)modal.setText((state.result.source.label ? "**Source:** "+stripVTControlCharacters(state.result.source.label).replace(/[\r\n]/g," ")+"\n\n---\n\n" : "")+state.result.text);
79
- else modal.setText("## Simplify\n\nUse /simplify for the latest reply, /text, /file or /url for another source. Type /help for all commands.");
84
+ modal.setText(
85
+ state.view==="result"&&state.result
86
+ ? (state.result.source.label ? "**Source:** "+stripVTControlCharacters(state.result.source.label).replace(/[\r\n]/g," ")+"\n\n---\n\n" : "")+state.result.text
87
+ : SIMPLIFY_MODAL_HELP,
88
+ );
80
89
  // Notices describe the currently shown state, not an earlier request.
81
90
  modal.setNotice(state.error ?? "",state.error ? "error" : "info");
82
- modal.scrollToEnd();
91
+ modal.scrollToStart();
83
92
  };
84
93
  const run=async (request:SimplifyStart|SimplifyAction, retained?:BroSource, mode?:BroMode, submitted?:string)=>{
85
94
  if(running||closed)return;
86
95
  const attempt=new AbortController();
87
96
  controller=attempt; running=true;
88
- modal.setRunning(true);modal.setNotice("Simplifying…");
97
+ modal.setRunning(true);modal.setNotice("");
98
+ let phase=request.kind==="url" ? "Fetching page" : request.kind==="file" ? "Reading file"
99
+ : request.kind==="latest" ? "Getting latest reply" : "Preparing source";
100
+ const stop=startProgressClock(attempt.signal,seconds=>{
101
+ if(!closed&&controller===attempt)modal.setProgress(`${phase} · ${seconds}s`);
102
+ });
103
+ stopProgress=stop;
89
104
  const previous=state.result,previousView=state.view;
90
105
  try {
91
106
  const source=await resolveSource(ctx,request,attempt.signal,retained);
92
107
  if(closed||attempt.signal.aborted)return;
93
108
  const currentSettings=await readSettings();
109
+ phase="Waiting for explanation";
94
110
  const result=await simplify(source.text,attempt.signal,currentSettings,text=>{
95
- if(!closed&&!attempt.signal.aborted)modal.setText(text);
111
+ if(!closed&&!attempt.signal.aborted){
112
+ phase="Receiving explanation";
113
+ modal.setText(text);
114
+ }
96
115
  },mode);
97
116
  if(closed||attempt.signal.aborted)return;
98
117
  state.result={source,...result};
@@ -111,6 +130,8 @@ export async function openSimplifyWorkflow(
111
130
  state.draft=submitted;
112
131
  }
113
132
  } finally {
133
+ stop();
134
+ if(stopProgress===stop)stopProgress=undefined;
114
135
  if(controller===attempt)controller=undefined;
115
136
  running=false;
116
137
  if(!closed)modal.setRunning(false);
@@ -141,6 +162,9 @@ export async function openSimplifyWorkflow(
141
162
  void run(action,undefined,undefined,raw);
142
163
  }
143
164
  modal.onKey=(data:string)=>{
165
+ if(!running && state.view==="help" && state.result && matchesKey(data,"escape")){
166
+ state.view="result";state.error=undefined;display();return true;
167
+ }
144
168
  if(running||modal.getComposerText().trim())return false;
145
169
  if(matchesKey(data,"m")||matchesKey(data,"shift+m")){retry(true);return Boolean(state.result);}
146
170
  if(matchesKey(data,"r")||matchesKey(data,"shift+r")){retry();return Boolean(state.result);}
package/src/sources.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFile, stat, realpath } from "node:fs/promises";
2
- import { isAbsolute, relative, resolve, extname, sep } from "node:path";
2
+ import { resolve, extname } from "node:path";
3
3
  import { request as httpRequest, type IncomingMessage, type ClientRequest } from "node:http";
4
4
  import { request as httpsRequest } from "node:https";
5
5
  import { lookup } from "node:dns/promises";
@@ -28,20 +28,13 @@ export async function extractDocumentText(input: string, cwd: string, signal?: A
28
28
  if (!requested) throw new Error("Use /bro file <path>.");
29
29
  if (signal?.aborted) throw new Error("Canceled.");
30
30
 
31
- let root: string;
32
31
  let path: string;
33
32
  try {
34
- root = await realpath(cwd);
35
33
  path = await realpath(resolve(cwd, requested));
36
34
  } catch (error) {
37
35
  throw fileError(requested, error);
38
36
  }
39
37
 
40
- const fromRoot = relative(root, path);
41
- if (fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
42
- throw new Error("Bro can read only files inside the current workspace.");
43
- }
44
-
45
38
  let info;
46
39
  try {
47
40
  info = await stat(path);
@@ -86,14 +79,9 @@ export async function extractDocumentText(input: string, cwd: string, signal?: A
86
79
  return text;
87
80
  }
88
81
 
89
- export async function isWorkspaceFile(input: string, cwd: string): Promise<boolean> {
90
- // ponytail: duplicates extractDocumentText's workspace guard rather than sharing its error semantics.
82
+ export async function isDocumentFile(input: string, cwd: string): Promise<boolean> {
91
83
  try {
92
84
  const path = await realpath(resolve(cwd, input));
93
- const fromRoot = relative(await realpath(cwd), path);
94
- if (fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
95
- return false;
96
- }
97
85
  const info = await stat(path);
98
86
  return info.isFile() && SNIFFABLE_FILE_EXTENSIONS.has(extname(path).toLowerCase());
99
87
  } catch {