pi-todo-ledger 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,7 @@ On top of them it publishes a bookkeeping contract, [CONTRACT.md](CONTRACT.md):
14
14
 
15
15
  ## Replaces rpiv-todo
16
16
 
17
- This package registers the tool name `todo`, as rpiv-todo does, so install one or the other.
17
+ Install this package or its predecessor, `@juicesharp/rpiv-todo`, not both. At startup the ledger warns if another extension owns the `todo` tool or registers `/todo` or `/todos`. It also checks personal and project package settings and installation paths for rpiv-todo. The warning names the active tool provider and gives the removal command for a matching package declaration. For an extension loaded with `-e`, omit it on the next launch. Pi does not expose losing tool registrations: a later, unknown extension that only registers `todo` cannot be detected.
18
18
  With both installed, the two `todo` tools clash.
19
19
 
20
20
  Switching keeps your lists.
@@ -49,6 +49,11 @@ Use `metadata.herdr.id` to resolve or message the worker by its run key.
49
49
  Use a name with `/boss send` only if it matches the name Straw Boss shows; a launch named `API worker` may appear there as `api-worker`.
50
50
  You can still set `owner` by hand.
51
51
 
52
+ The panel lists each task's live bound runs under it.
53
+ A run that belongs to no task, such as a scout sent out on the side, is listed under an `Other workers` group (`其他 worker` in zh-TW) after the tasks, in the same row format; the panel shows that group even when the list is empty.
54
+ The panel claims every run row it paints, so the host's Subagents box shows only the runs the panel does not.
55
+ See [docs/overlay.md](docs/overlay.md#other-workers).
56
+
52
57
  `/todos` and the panel's full view indent each open task under its first unfinished blocker; the panel's default focus view lists tasks flat and names every unfinished blocker after the subject. Both show the owner as `@owner`.
53
58
  To mark a task as waiting for someone, set `metadata.waitsOn` to their name; to defer it until a particular time, set `metadata.until` to an ISO timestamp, e.g. `2027-01-15T09:00:00+08:00`.
54
59
  An open task shows `⏸` with the name or the future deadline in local time.
package/docs/overlay.md CHANGED
@@ -10,7 +10,7 @@ The widget is mounted above the Pi editor under the key `rpiv-todos`, the key rp
10
10
  | Stage | Condition |
11
11
  | --- | --- |
12
12
  | Created | At the first session start that has a UI. A headless session never creates it. |
13
- | Registered | Only while at least one overlay-visible task exists. The widget unregisters itself when the list empties, and re-registers when a task reappears. |
13
+ | Registered | While at least one overlay-visible task exists, or the run host lists a run of this session (see [Other workers](#other-workers)). The widget unregisters itself when both are gone, and re-registers when a task or a run appears. With no task, a refresh after a `subagent` or `subagent_resume` call, or at the end of a turn, finds the new run. |
14
14
  | Bound | Only the foreground session's overlay is refreshed. A detached or child session has its own task state and never rebinds or repaints the foreground panel. |
15
15
  | Disposed | On the foreground session's shutdown. A child session shutting down leaves the overlay alone. |
16
16
 
@@ -39,8 +39,9 @@ Rows come in this order, until the row budget runs out:
39
39
  1. the heading;
40
40
  2. every task in progress, each followed by its run rows;
41
41
  3. the next two open tasks in display order, or the next three when nothing is in progress;
42
- 4. completed tasks from the current turn, only if rows are left after the run rows;
43
- 5. one summary row counting the hidden tasks in progress, pending, and completed, in that order, such as `+1 in progress, 5 pending, 2 completed` (`+1 進行中、5 待處理、2 已完成` in zh-TW). Zero counts are left out, and with nothing hidden there is no summary row.
42
+ 4. the [Other workers](#other-workers) group, with the rows the tasks and their runs leave;
43
+ 5. completed tasks from the current turn, only if rows are left after the group; they are drawn above the group, but get their rows after it;
44
+ 6. one summary row counting the hidden tasks in progress, pending, and completed, then the hidden other workers, in that order, such as `+1 in progress, 5 pending, 2 completed, 2 workers` (`+1 進行中、5 待處理、2 已完成、2 worker` in zh-TW). Zero counts are left out, and with nothing hidden there is no summary row.
44
45
 
45
46
  The summary row ends with a dim hint that names the panel key and the state it switches to next; see [Switching views](#switching-views).
46
47
 
@@ -99,6 +100,39 @@ The panel asks the Subagents widget to hide a run only once it knows the run's r
99
100
 
100
101
  Collapsing the panel, or the run leaving the panel, returns the run to the Subagents widget.
101
102
 
103
+ ## Other workers
104
+
105
+ An agent often sends out a run that belongs to no todo item: a quick scout, a reviewer, a one-off check.
106
+ The group follows the task rows. It includes unbound runs and runs whose task is folded away or cut by the row budget. A run from a hidden task carries its task number (`#4 worker-four`). A fully drawn run is claimed here; if there is no room, the summary counts it and the host can still show it.
107
+
108
+ ```text
109
+ ● Todos (0/3)
110
+ ├─ ◐ #1 API
111
+ │ └ api-worker · astra · 執行中 5s
112
+ ├─ ◐ #2 UI
113
+ │ └ ui-worker · astra · 執行中 42s
114
+ ├─ ○ #3 Docs
115
+ ├─ 其他 worker
116
+ │ ├ scout-x · astra · 執行中 3s
117
+ │ └ ◇ scout-y · sol · 閒置 1m
118
+ └─ ctrl+shift+t 完整
119
+ ```
120
+
121
+ - The heading row reads `Other workers` (`其他 worker` in zh-TW), in muted text. The group is normal work, not a warning, so it has no warning colour or icon.
122
+ - Each run row has the format of a bound run row: the idle and waiting marks, the time in the current state, and the claim marker. A run waiting for a reply keeps the warning colour it has under a task.
123
+ - Runs appear in the host's order.
124
+ - A run counts as bound when its id is in the `metadata.herdr.runs` of a task the panel shows. A run bound to a completed task that has faded out, or to a deleted one, joins the group.
125
+ - When a run gets bound to a task, it moves under that task on the next frame and leaves the group, so it is never drawn twice.
126
+ - With no task at all, the panel still shows its heading and the group.
127
+
128
+ The group follows the row budget:
129
+
130
+ - In the focus view, tasks in progress, the next tasks and their runs come first. The group gets the rows left: its heading and as many runs as fit, or nothing when fewer than two rows are left. The runs that do not fit are added to the summary row as `+2 workers` (`+2 worker` in zh-TW), or after the task counts, as in `+5 待處理、2 worker`.
131
+ - In the full view, the group follows the tree and lists every run within `maxWidgetLines`; the rest are counted in the summary row, as in `+3 more (3 pending), 2 workers`.
132
+ - In the collapsed view, the closing row counts the group before the key hint: `└─ +2 worker · ctrl+shift+t 焦點`.
133
+
134
+ The panel claims a group row the way it claims a bound run row: only a row painted in full, checked by its exact line in the fullscreen layout. A row cut by the width, clipped by the layout, covered by a popup, or folded into the summary stays unclaimed, so the Subagents widget keeps showing that run. When no ledger claims a run, the host's own widget is the fallback that shows it.
135
+
102
136
  ## Overflow
103
137
 
104
138
  The content-row budget is `maxWidgetLines` (default `12`), and the heading counts
@@ -131,7 +165,7 @@ session resets that tracking, so a fresh session shows the full list again.
131
165
 
132
166
  1. focus view;
133
167
  2. full view;
134
- 3. collapsed: the heading and one dim hint row, `└─ ctrl+shift+t focus`.
168
+ 3. collapsed: the heading and one dim hint row, `└─ ctrl+shift+t focus`, which starts with the count of [other workers](#other-workers) when there are any.
135
169
 
136
170
  The panel starts in the state `view` names, `"focus"` unless you set `"full"`,
137
171
  and the next press continues the cycle from there: from `"full"` it goes to
@@ -146,8 +180,8 @@ the hint takes its own closing `└─` row, and only when the row budget has a
146
180
  to spare, so it never pushes a task out. The hint always shows the configured
147
181
  key.
148
182
 
149
- Collapsing hides the run rows, so the panel releases its claim on them; the
150
- Subagents widget can show them again. In the focus and full views the panel
183
+ Collapsing hides the run rows, including the Other workers group, so the panel
184
+ releases its claim on them; the Subagents widget can show them again. In the focus and full views the panel
151
185
  claims the run rows it actually paints, as described under
152
186
  [Worker runs under a task](#worker-runs-under-a-task).
153
187
 
@@ -179,8 +213,8 @@ tasks. Tombstoned tasks are never listed.
179
213
 
180
214
  ## Localization
181
215
 
182
- The overlay heading, both summary rows, the key hint, the `/todos`
183
- section headers, and the status words all localize through
216
+ The overlay heading, both summary rows, the key hint, the Other workers heading and
217
+ count, the run states, the `/todos` section headers, and the status words all localize through
184
218
  [`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n)
185
219
  when that package is installed. Bundled locales: `de`, `en`, `es`, `fr`, `pt`,
186
220
  `pt-BR`, `ru`, `uk`, `zh` (Simplified), and `zh-TW` (Traditional).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-todo-ledger",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "A todo list for pi agents with a public bookkeeping contract: snapshot entries, change events, and namespace validators. Fork of @juicesharp/rpiv-todo",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,148 @@
1
+ import { readFileSync, realpathSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import type {
6
+ ExtensionAPI,
7
+ ExtensionContext,
8
+ } from "@earendil-works/pi-coding-agent";
9
+ import { t } from "./state/i18n-bridge.ts";
10
+
11
+ const self = realpathSync(fileURLToPath(new URL("../", import.meta.url)));
12
+ const predecessors = ["@juicesharp/rpiv-todo", "rpiv-todo"];
13
+ function real(path: string) {
14
+ try {
15
+ return realpathSync(path);
16
+ } catch {
17
+ return path;
18
+ }
19
+ }
20
+ function json(path: string) {
21
+ try {
22
+ return JSON.parse(readFileSync(path, "utf8"));
23
+ } catch {
24
+ return undefined;
25
+ }
26
+ }
27
+ function owner(path: string) {
28
+ for (let dir = dirname(path); ; dir = dirname(dir)) {
29
+ const name: unknown = json(join(dir, "package.json"))?.name;
30
+ if (typeof name === "string" && name) return { root: dir, name };
31
+ if (dirname(dir) === dir) return { root: path, name: basename(path) };
32
+ }
33
+ }
34
+ const quote = (s: string) =>
35
+ /^[\w@.:/+~-]+$/.test(s) ? s : `'${s.replaceAll("'", "'\\''")}'`;
36
+ interface Rival {
37
+ name: string;
38
+ path: string;
39
+ commands: Set<string>;
40
+ }
41
+ export function conflictWarning(pi: ExtensionAPI, ctx: ExtensionContext) {
42
+ const found = new Map<string, Rival>();
43
+ function add(path: string, name: string, root: string) {
44
+ let item = found.get(root);
45
+ if (!item) {
46
+ item = { name, path, commands: new Set() };
47
+ found.set(root, item);
48
+ }
49
+ return item;
50
+ }
51
+ const tool = pi.getAllTools().find((x) => x.name === "todo");
52
+ const toolPath = tool?.sourceInfo?.path;
53
+ const active = toolPath ? owner(real(toolPath)).name : "—";
54
+ const registrations = new Map<string, Set<string>>();
55
+ for (const info of [
56
+ tool?.sourceInfo,
57
+ ...pi
58
+ .getCommands()
59
+ .filter(
60
+ (c) => c.source === "extension" && /^todos?(?::\d+)?$/.test(c.name),
61
+ )
62
+ .map((c) => c.sourceInfo),
63
+ ]) {
64
+ const path = info?.path;
65
+ if (!path || !isAbsolute(path)) continue;
66
+ const p = real(path),
67
+ pkg = owner(p);
68
+ if (pkg.root === self) continue;
69
+ add(p, pkg.name, pkg.root);
70
+ const sources = registrations.get(pkg.root) ?? new Set<string>();
71
+ sources.add(`${info.scope}:${info.source}`);
72
+ registrations.set(pkg.root, sources);
73
+ }
74
+ const globalDir = resolve(
75
+ (
76
+ process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent")
77
+ ).replace(/^~(?=\/)/, homedir()),
78
+ );
79
+ for (const [dir, local] of [
80
+ [globalDir, false],
81
+ [join(ctx.cwd, ".pi"), true],
82
+ ] as const) {
83
+ const npmRoot = join(dir, "npm", "node_modules");
84
+ const gitRoot = join(dir, "git");
85
+ for (const root of [
86
+ ...predecessors.map((n) => join(npmRoot, n)),
87
+ join(
88
+ gitRoot,
89
+ "github.com",
90
+ "juicesharp",
91
+ "rpiv-mono",
92
+ "packages",
93
+ "rpiv-todo",
94
+ ),
95
+ join(gitRoot, "github.com", "juicesharp", "rpiv-todo"),
96
+ ]) {
97
+ const name = json(join(root, "package.json"))?.name;
98
+ if (predecessors.includes(name)) add(real(root), name, real(root));
99
+ }
100
+ const packages: unknown = json(join(dir, "settings.json"))?.packages;
101
+ if (!Array.isArray(packages)) continue;
102
+ for (const entry of packages) {
103
+ const source = typeof entry === "string" ? entry : entry?.source;
104
+ if (typeof source !== "string" || /[\x00-\x1f\x7f]/.test(source))
105
+ continue;
106
+ const npm = /^npm:((?:@[^/@]+\/)?[^/@]+)(?:@.*)?$/.exec(source)?.[1];
107
+ const git =
108
+ /^(?:git:|https?:\/\/|ssh:\/\/)(?:https?:\/\/)?(?:git@)?([\w.-]+)[/:]([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:@[^\s]+)?$/.exec(
109
+ source,
110
+ );
111
+ const root = real(
112
+ npm
113
+ ? join(npmRoot, npm)
114
+ : git
115
+ ? join(gitRoot, git[1], git[2], git[3])
116
+ : resolve(dir, source.replace(/^~(?=\/)/, homedir())),
117
+ );
118
+ const name = npm ?? json(join(root, "package.json"))?.name;
119
+ if (predecessors.includes(name)) add(root, name, root);
120
+ for (const [key, item] of found)
121
+ if (
122
+ key === root ||
123
+ (git && key.startsWith(root + sep)) ||
124
+ registrations.get(key)?.has(`${local ? "project" : "user"}:${source}`)
125
+ )
126
+ item.commands.add(
127
+ `pi remove ${local ? "--local " : ""}${quote(source)}`,
128
+ );
129
+ }
130
+ }
131
+ if (!found.size) return;
132
+ const rivals = [...found.values()]
133
+ .map((x) => `${x.name} (${x.path})`)
134
+ .join("; ");
135
+ const commands = [
136
+ ...new Set([...found.values()].flatMap((x) => [...x.commands])),
137
+ ];
138
+ return (
139
+ t(
140
+ "conflict.warning",
141
+ "Todo conflict: {rivals}. Active todo tool: {active}.",
142
+ )
143
+ .replace("{rivals}", () => rivals)
144
+ .replace("{active}", () => active) +
145
+ " " +
146
+ [...commands, "/reload"].join(" → ")
147
+ );
148
+ }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@
23
23
 
24
24
  import type { ExtensionAPI, ExtensionUIContext } from "@earendil-works/pi-coding-agent";
25
25
  import type { KeyId } from "@earendil-works/pi-tui";
26
+ import { conflictWarning } from './conflicts.ts';
26
27
  import { COLLAPSE_KEY_OFF, resolveCollapseKey } from "./config.ts";
27
28
  import {
28
29
  CHANGED_EVENT,
@@ -51,6 +52,7 @@ import {
51
52
  } from "./state/store.ts";
52
53
  import { registerTodosCommand, registerTodoTool, TOOL_NAME } from "./todo.ts";
53
54
  import type { TodoOverlay } from "./todo-overlay.ts";
55
+ import { RUN_ROWS_EVENT } from "./view/live-runs.ts";
54
56
 
55
57
  // Held in a variable so the type checker does not require the optional peer.
56
58
  const I18N_LOADER: string = "@juicesharp/rpiv-i18n/loader";
@@ -159,17 +161,30 @@ export default function (
159
161
  let uiCtx: ExtensionUIContext | undefined;
160
162
  let lifecycleGeneration = 0;
161
163
 
164
+ // The host's run-rows probe. Without a claim it only reads this session's runs.
165
+ const queryRuns = (p: object) => pi.events.emit(RUN_ROWS_EVENT, p);
166
+ /** Whether the host lists any run of this session: such runs show on the panel even with no task. */
167
+ const hostHasRuns = (): boolean => {
168
+ const p: { rows?: { rows?: unknown } } = {};
169
+ try {
170
+ queryRuns(p);
171
+ } catch {
172
+ return false;
173
+ }
174
+ return Array.isArray(p.rows?.rows) && p.rows.rows.length > 0;
175
+ };
176
+
162
177
  async function updateTodoOverlay(
163
178
  resetCompletedDisplayState = false,
164
179
  generation = lifecycleGeneration,
165
180
  ): Promise<void> {
166
181
  const hasVisibleTasks = getRenderState().tasks.some((task) => task.status !== "deleted");
167
- if (!uiCtx || (!todoOverlay && !hasVisibleTasks)) return;
182
+ if (!uiCtx || (!todoOverlay && !hasVisibleTasks && !hostHasRuns())) return;
168
183
 
169
184
  const { TodoOverlay } = await loadTodoOverlay();
170
185
  if (generation !== lifecycleGeneration || !uiCtx) return;
171
186
 
172
- todoOverlay ??= new TodoOverlay(p => pi.events.emit('pi-herdr-agents:run-rows:v1', p));
187
+ todoOverlay ??= new TodoOverlay(queryRuns);
173
188
  todoOverlay.setUICtx(uiCtx);
174
189
  if (resetCompletedDisplayState) todoOverlay.resetCompletedDisplayState();
175
190
  todoOverlay.update();
@@ -241,6 +256,7 @@ export default function (
241
256
  if (isForeground) await updateTodoOverlay(true);
242
257
  };
243
258
 
259
+ const warned = new Set<string>();
244
260
  pi.on("session_start", async (_event, ctx) => {
245
261
  let id: string;
246
262
  try {
@@ -254,6 +270,14 @@ export default function (
254
270
  if (!isStaleCtxError(e)) throw e;
255
271
  return;
256
272
  }
273
+ if (!warned.has(id)) {
274
+ const message = conflictWarning(pi, ctx);
275
+ if (message) {
276
+ warned.add(id);
277
+ if (ctx.hasUI) ctx.ui.notify(message, 'warning');
278
+ else console.error(message.replace(/[\r\n]+/g, ' '));
279
+ }
280
+ }
257
281
  if (!ctx.hasUI) return;
258
282
  // First UI-bearing session_start claims the foreground (the interactive
259
283
  // launcher, by spawn-ordering) without eagerly loading the overlay.
@@ -309,14 +333,12 @@ export default function (
309
333
  }
310
334
  });
311
335
 
312
- // Reads getTodos() at render time; do NOT call replayFromBranch here
313
- // (branch is stale — message_end runs after tool_execution_end).
314
- pi.on("tool_execution_end", async (event) => {
315
- if ((event.toolName !== TOOL_NAME && event.toolName !== "subagent") || event.isError) return;
336
+ // A refresh after something that may change the list or this session's runs.
337
+ const refresh = async (): Promise<void> => {
316
338
  try {
317
339
  await updateTodoOverlay();
318
340
  } catch (e) {
319
- // The tool itself succeeded — a transient overlay-load failure only
341
+ // The tool or turn itself succeeded — a transient overlay-load failure only
320
342
  // costs this one refresh, and the loader's cleared memo lets the next
321
343
  // update retry. Don't surface that as an extension error. The latched
322
344
  // stale-namespace error still propagates: it never self-heals, and the
@@ -324,8 +346,19 @@ export default function (
324
346
  if (isStaleOverlayModuleError(e)) throw e;
325
347
  console.warn(`[pi-todo-ledger] overlay refresh failed (will retry on next update): ${formatError(e)}`);
326
348
  }
349
+ };
350
+
351
+ // Reads getTodos() at render time; do NOT call replayFromBranch here
352
+ // (branch is stale — message_end runs after tool_execution_end). A launch or
353
+ // resume may start a run bound to no task, which the panel shows too.
354
+ pi.on("tool_execution_end", async (event) => {
355
+ if (event.isError || ![TOOL_NAME, "subagent", "subagent_resume"].includes(event.toolName)) return;
356
+ await refresh();
327
357
  });
328
358
 
359
+ // Runs can also start without a tool call of this session; the end of a turn picks them up.
360
+ pi.on("agent_end", refresh);
361
+
329
362
  // Evaluate the lazy graph after startup while Pi's boot-time dependency paths
330
363
  // are still stable. This loads no widget and constructs no overlay; those stay
331
364
  // deferred until a foreground session has visible tasks. A rejected pre-warm
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Todo-Konflikt: {rivals}. Aktives todo-Werkzeug: {active}.",
2
3
  "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated. Note: 'overlay.more' renders as '+5 weitere' which is grammatically loose for plural agreement — accepted for badge brevity.",
3
4
 
4
5
  "status.pending": "ausstehend",
@@ -13,6 +14,9 @@
13
14
  "overlay.next.full": "voll",
14
15
  "overlay.next.collapsed": "einklappen",
15
16
  "overlay.collapsed": "eingeklappt",
17
+ "overlay.others": "Weitere Worker",
18
+ "overlay.worker.one": "Worker",
19
+ "overlay.worker.other": "Worker",
16
20
 
17
21
  "command.no_todos": "Noch keine Todos. Bitte den Agenten, welche hinzuzufügen!",
18
22
  "command.requires_interactive": "/todos erfordert den interaktiven Modus",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Todo conflict: {rivals}. Active todo tool: {active}.",
2
3
  "status.pending": "pending",
3
4
  "status.in_progress": "in progress",
4
5
  "status.completed": "completed",
@@ -12,6 +13,9 @@
12
13
  "overlay.next.collapsed": "collapse",
13
14
  "overlay.collapsed": "collapsed",
14
15
  "overlay.separator": ", ",
16
+ "overlay.others": "Other workers",
17
+ "overlay.worker.one": "worker",
18
+ "overlay.worker.other": "workers",
15
19
 
16
20
  "command.no_todos": "No todos yet. Ask the agent to add some!",
17
21
  "command.requires_interactive": "/todos requires interactive mode",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Conflicto de tareas: {rivals}. Herramienta todo activa: {active}.",
2
3
  "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
3
4
 
4
5
  "status.pending": "pendientes",
@@ -13,6 +14,9 @@
13
14
  "overlay.next.full": "completo",
14
15
  "overlay.next.collapsed": "contraer",
15
16
  "overlay.collapsed": "contraído",
17
+ "overlay.others": "Otros workers",
18
+ "overlay.worker.one": "worker",
19
+ "overlay.worker.other": "workers",
16
20
 
17
21
  "command.no_todos": "Sin tareas aún. ¡Pídele al agente que añada algunas!",
18
22
  "command.requires_interactive": "/todos requiere modo interactivo",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Conflit de tâches : {rivals}. Outil todo actif : {active}.",
2
3
  "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
3
4
 
4
5
  "status.pending": "en attente",
@@ -13,6 +14,9 @@
13
14
  "overlay.next.full": "complet",
14
15
  "overlay.next.collapsed": "réduire",
15
16
  "overlay.collapsed": "réduit",
17
+ "overlay.others": "Autres workers",
18
+ "overlay.worker.one": "worker",
19
+ "overlay.worker.other": "workers",
16
20
 
17
21
  "command.no_todos": "Pas encore de tâches. Demandez à l'agent d'en ajouter !",
18
22
  "command.requires_interactive": "/todos nécessite le mode interactif",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Conflito de tarefas: {rivals}. Ferramenta todo ativa: {active}.",
2
3
  "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
3
4
 
4
5
  "status.pending": "pendentes",
@@ -13,6 +14,9 @@
13
14
  "overlay.next.full": "completo",
14
15
  "overlay.next.collapsed": "recolher",
15
16
  "overlay.collapsed": "recolhido",
17
+ "overlay.others": "Outros workers",
18
+ "overlay.worker.one": "worker",
19
+ "overlay.worker.other": "workers",
16
20
 
17
21
  "command.no_todos": "Nenhuma tarefa ainda. Peça ao agente para adicionar algumas!",
18
22
  "command.requires_interactive": "/todos requer modo interativo",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Conflito de tarefas: {rivals}. Ferramenta todo ativa: {active}.",
2
3
  "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
3
4
 
4
5
  "status.pending": "pendentes",
@@ -13,6 +14,9 @@
13
14
  "overlay.next.full": "completo",
14
15
  "overlay.next.collapsed": "recolher",
15
16
  "overlay.collapsed": "recolhido",
17
+ "overlay.others": "Outros workers",
18
+ "overlay.worker.one": "worker",
19
+ "overlay.worker.other": "workers",
16
20
 
17
21
  "command.no_todos": "Sem tarefas ainda. Peça ao agente para adicionar algumas!",
18
22
  "command.requires_interactive": "/todos requer modo interativo",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Конфликт расширений задач: {rivals}. Активный инструмент todo: {active}.",
2
3
  "_meta.notes": "Автоперевод. Приветствуется проверка носителем языка через PR. Символы юникода (──) не переводятся.",
3
4
 
4
5
  "status.pending": "ожидание",
@@ -13,6 +14,11 @@
13
14
  "overlay.next.full": "полностью",
14
15
  "overlay.next.collapsed": "свернуть",
15
16
  "overlay.collapsed": "свёрнуто",
17
+ "overlay.others": "Другие воркеры",
18
+ "overlay.worker.one": "воркер",
19
+ "overlay.worker.few": "воркера",
20
+ "overlay.worker.many": "воркеров",
21
+ "overlay.worker.other": "воркера",
16
22
 
17
23
  "command.no_todos": "Задач пока нет. Попросите агента добавить!",
18
24
  "command.requires_interactive": "/todos требует интерактивного режима",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "Конфлікт розширень завдань: {rivals}. Активний інструмент todo: {active}.",
2
3
  "_meta.notes": "Автопереклад. Привітна перевірка носієм мови через PR. Символи юнікоду (──) не перекладаються.",
3
4
 
4
5
  "status.pending": "очікування",
@@ -13,6 +14,11 @@
13
14
  "overlay.next.full": "повністю",
14
15
  "overlay.next.collapsed": "згорнути",
15
16
  "overlay.collapsed": "згорнуто",
17
+ "overlay.others": "Інші воркери",
18
+ "overlay.worker.one": "воркер",
19
+ "overlay.worker.few": "воркери",
20
+ "overlay.worker.many": "воркерів",
21
+ "overlay.worker.other": "воркера",
16
22
 
17
23
  "command.no_todos": "Завдань поки немає. Попросіть агента додати!",
18
24
  "command.requires_interactive": "/todos потребує інтерактивного режиму",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "偵測到待辦套件衝突:{rivals}。目前的 todo 工具由 {active} 提供。",
2
3
  "status.pending": "待處理",
3
4
  "status.in_progress": "進行中",
4
5
  "status.completed": "已完成",
@@ -11,6 +12,8 @@
11
12
  "overlay.next.collapsed": "收合",
12
13
  "overlay.collapsed": "已收合",
13
14
  "overlay.separator": "、",
15
+ "overlay.others": "其他 worker",
16
+ "overlay.worker.other": "worker",
14
17
  "command.no_todos": "目前沒有待辦事項。",
15
18
  "command.requires_interactive": "/todos 需要互動模式",
16
19
  "command.section.pending": "── 待處理 ──",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "conflict.warning": "检测到待办扩展冲突:{rivals}。当前 todo 工具由 {active} 提供。",
2
3
  "_meta.notes": "中文翻译。欢迎中文母语者通过 PR 审校。",
3
4
 
4
5
  "status.pending": "待处理",
@@ -14,6 +15,8 @@
14
15
  "overlay.next.collapsed": "收起",
15
16
  "overlay.collapsed": "已折叠",
16
17
  "overlay.separator": "、",
18
+ "overlay.others": "其他 worker",
19
+ "overlay.worker.other": "worker",
17
20
 
18
21
  "command.no_todos": "暂无任务。可以让 agent 添加一些!",
19
22
  "command.requires_interactive": "/todos 需要交互模式",
@@ -96,6 +96,18 @@ export const t: ScopeFn = (key, fallback) => {
96
96
  return scopeImpl(key, fallback);
97
97
  };
98
98
 
99
+ /** `2 workers`, `2 worker` (zh-TW): the word follows the locale's plural rule; a category the locale lacks uses `other`. */
100
+ export function formatWorkerCount(n: number): string {
101
+ let category = "other";
102
+ try {
103
+ category = new Intl.PluralRules(/^[a-z]{2,3}(?=$|[-_.@])/.exec(renderLocale())?.[0] ?? "en").select(n);
104
+ } catch {
105
+ /* unknown locale: other */
106
+ }
107
+ const word = t(`overlay.worker.${category}`, "") || t("overlay.worker.other", n === 1 ? "worker" : "workers");
108
+ return `${n} ${word}`;
109
+ }
110
+
99
111
  const STATUS_LABEL_PENDING = "pending";
100
112
  const STATUS_LABEL_IN_PROGRESS = "in progress";
101
113
  const STATUS_LABEL_COMPLETED = "completed";
@@ -28,7 +28,7 @@ import {
28
28
  type OverlayView,
29
29
  resolveCollapseKey,
30
30
  } from "./config.ts";
31
- import { formatStatusLabel, t } from "./state/i18n-bridge.ts";
31
+ import { formatStatusLabel, formatWorkerCount, t } from "./state/i18n-bridge.ts";
32
32
  import {
33
33
  selectHasActive,
34
34
  selectOverlayLayout,
@@ -51,6 +51,7 @@ const OVERLAY_MORE = "more";
51
51
  const OVERLAY_KEY_HINT = "{key} {next}";
52
52
  const OVERLAY_COLLAPSED = "collapsed";
53
53
  const OVERLAY_SEPARATOR = ", ";
54
+ const OVERLAY_OTHERS = "Other workers";
54
55
 
55
56
  /** What the panel shows: one of the two views, or the two-line collapsed state. */
56
57
  type PanelState = OverlayView | "collapsed";
@@ -59,6 +60,18 @@ const NEXT_STATE: Record<PanelState, PanelState> = { focus: "full", full: "colla
59
60
  /** English names of the state the key goes to next, as the hint shows them. */
60
61
  const NEXT_STATE_NAME: Record<PanelState, string> = { focus: "focus", full: "full", collapsed: "collapse" };
61
62
 
63
+ /** Run rows drawn on one frame, for the claim bookkeeping. */
64
+ interface Frame {
65
+ /** Inline: runs drawn whole. */
66
+ drawn: string[];
67
+ /** Fullscreen: runs drawn whole, with their marked line. */
68
+ marked: Map<string, string>;
69
+ ticking: boolean;
70
+ }
71
+
72
+ /** Runs of the Other workers group that fit `rows`: the heading and at least one run, or none. */
73
+ const groupFit = (rows: number, runs: number) => (runs > 0 && rows >= 2 ? Math.min(runs, rows - 1) : 0);
74
+
62
75
  /** What one frame's row drawing needs, shared by the full and focus views. */
63
76
  interface DrawContext {
64
77
  theme: Theme;
@@ -66,6 +79,9 @@ interface DrawContext {
66
79
  truncate: (line: string) => string;
67
80
  bound: Map<number, ReturnType<typeof history>>;
68
81
  live: ReturnType<typeof liveRows>;
82
+ /** Live runs of this session bound to no task on the panel, in the host's order. */
83
+ others: RunRow[];
84
+ runOwners: Map<string, number>;
69
85
  showIds: boolean;
70
86
  now: number;
71
87
  evidence: "inline" | "screen" | undefined;
@@ -212,7 +228,8 @@ export class TodoOverlay {
212
228
  const snapshot = this.getSnapshot();
213
229
  const visible = this.selectOverlayTasks(snapshot);
214
230
 
215
- if (visible.length === 0) {
231
+ // With no task to show, the panel stays for this session's runs (the Other workers group).
232
+ if (visible.length === 0 && !liveRows(this.query)?.size) {
216
233
  this.finishFrame([]);
217
234
  if (this.widgetRegistered) {
218
235
  this.uiCtx.setWidget(WIDGET_KEY, undefined);
@@ -344,7 +361,9 @@ export class TodoOverlay {
344
361
  private renderWidget(theme: Theme, width: number): string[] {
345
362
  const snapshot = this.getSnapshot();
346
363
  const overlayTasks = this.selectOverlayTasks(snapshot);
347
- if (overlayTasks.length === 0) {
364
+ // Every state asks the host: runs bound to no task join the Other workers group, or its count.
365
+ const live = liveRows(this.query);
366
+ if (overlayTasks.length === 0 && !live?.size) {
348
367
  this.finishFrame([]);
349
368
  return [];
350
369
  }
@@ -352,9 +371,8 @@ export class TodoOverlay {
352
371
  overlayTasks.map((t) => [t.id, history(t.metadata?.herdr)] as const),
353
372
  );
354
373
  const hasRuns = [...bound.values()].some((h) => h.runs.length > 0);
355
- // Ask the host only when some todo has bound runs and the tree is shown.
356
- const live =
357
- hasRuns && this.current() !== "collapsed" ? liveRows(this.query) : undefined;
374
+ const boundIds = new Set([...bound.values()].flatMap((h) => h.runs.map((r) => r.id)));
375
+ const others = [...(live?.values() ?? [])].filter((r) => !boundIds.has(r.id));
358
376
 
359
377
  const plan = planView(overlayTasks);
360
378
  // Keep completed rows in their old slots; fill open slots in display order before budgeting.
@@ -367,7 +385,7 @@ export class TodoOverlay {
367
385
  truncateToWidth(line, width, "…");
368
386
  const counts = selectTodoCounts(overlayState);
369
387
  const hasActive = selectHasActive(overlayState);
370
- const showIds = !!live?.size || selectShowTaskIds(overlayState);
388
+ const showIds = (hasRuns && !!live?.size) || selectShowTaskIds(overlayState);
371
389
 
372
390
  const headingColor = hasActive ? "accent" : "dim";
373
391
  const headingIcon = hasActive ? "●" : "○";
@@ -379,20 +397,32 @@ export class TodoOverlay {
379
397
  `${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, headingText)}${graph}`,
380
398
  );
381
399
 
400
+ const draw: DrawContext = {
401
+ theme,
402
+ width,
403
+ truncate,
404
+ bound,
405
+ live,
406
+ others,
407
+ runOwners: new Map([...bound].flatMap(([id, h]) => h.runs.map(r => [r.id, id] as const))),
408
+ showIds,
409
+ now: Date.now(),
410
+ evidence: this.evidence(),
411
+ };
412
+
382
413
  // Collapsed view: just the heading + a dim "└─" hint naming the next state,
383
- // then the trailing spacer. Short-circuit before the budget math and the
384
- // completed-display tracking — nothing is shown to track, and skipping the
385
- // tracking when nothing is rendered is correctness, not optimization. The
386
- // "off" sentinel is reachable here mid-session (config edited after the
387
- // shortcut was bound and the overlay collapsed) — render a static collapsed
388
- // label instead of advertising an unbound key.
414
+ // after the count of other workers, then the trailing spacer. Short-circuit
415
+ // before the budget math and the completed-display tracking — nothing is
416
+ // shown to track, and skipping the tracking when nothing is rendered is
417
+ // correctness, not optimization. The "off" sentinel is reachable here
418
+ // mid-session (config edited after the shortcut was bound and the overlay
419
+ // collapsed) — render a static collapsed label instead of advertising an
420
+ // unbound key. Nothing is claimed; the tick keeps the count current.
389
421
  if (this.current() === "collapsed") {
390
- this.finishFrame([]);
422
+ this.finishFrame([], others.length > 0);
391
423
  const hint = this.keyHint() ?? t("overlay.collapsed", OVERLAY_COLLAPSED);
392
- return this.withTrailingSpacer([
393
- heading,
394
- truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", hint)}`),
395
- ]);
424
+ const count = others.length ? `+${formatWorkerCount(others.length)}` : undefined;
425
+ return this.withTrailingSpacer([heading, this.closingRow(draw, count, hint)]);
396
426
  }
397
427
 
398
428
  // Budget for content rows below the heading (tasks, run rows, summary). The
@@ -404,16 +434,6 @@ export class TodoOverlay {
404
434
  this.uiCtx?.getToolsExpanded?.() === true
405
435
  ? Infinity
406
436
  : getMaxWidgetLines() - 1;
407
- const draw: DrawContext = {
408
- theme,
409
- width,
410
- truncate,
411
- bound,
412
- live,
413
- showIds,
414
- now: Date.now(),
415
- evidence: this.evidence(),
416
- };
417
437
  const body =
418
438
  this.current() === "full"
419
439
  ? this.fullBody(overlayState, plan, bodyBudget, draw)
@@ -433,7 +453,7 @@ export class TodoOverlay {
433
453
  return this.withTrailingSpacer([heading, ...body]);
434
454
  }
435
455
 
436
- /** The whole dependency tree, budgeted by selectOverlayLayout (the `"full"` view). */
456
+ /** The whole dependency tree, budgeted by selectOverlayLayout (the `"full"` view), then the Other workers group. */
437
457
  private fullBody(
438
458
  overlayState: { tasks: Task[]; nextId: number },
439
459
  plan: ReturnType<typeof planView>,
@@ -443,42 +463,68 @@ export class TodoOverlay {
443
463
  const layout = selectOverlayLayout(overlayState, bodyBudget);
444
464
  const overflow = layout.hiddenCompleted + layout.truncatedTail;
445
465
  const hint = this.keyHint();
466
+ draw.others = this.groupCandidates(layout.visible, draw);
467
+ const others = draw.others.length;
446
468
  // With nothing to summarize, the hint takes its own row only when one is spare.
447
- const needed = layout.visible.reduce((n, task) => n + 1 + this.children(task, draw).length, 0);
469
+ const needed =
470
+ layout.visible.reduce((n, task) => n + 1 + this.children(task, draw).length, 0) +
471
+ (others ? 1 + others : 0);
448
472
  const hintRow = overflow === 0 && hint !== undefined && needed < bodyBudget;
449
- const spare = bodyBudget - layout.visible.length - Number(overflow > 0 || hintRow);
473
+ let spare = bodyBudget - layout.visible.length - Number(overflow > 0 || hintRow);
474
+ // The group gets the rows the bound runs leave; a group cut short needs the summary row.
475
+ let rest = spare - this.boundRows(layout.visible, spare, draw);
476
+ let summarized = overflow > 0;
477
+ let group = others;
478
+ if (1 + others > rest) {
479
+ if (!summarized && rest > 0) {
480
+ summarized = true;
481
+ rest--;
482
+ }
483
+ group = groupFit(rest, others);
484
+ }
485
+ spare -= group ? 1 + group : 0;
486
+ const frame: Frame = { drawn: [], marked: new Map(), ticking: false };
450
487
  const lines = this.drawTasks(
451
488
  layout.visible.map((task) => ({ task, row: plan.rows.get(task.id) })),
452
489
  spare,
453
- overflow === 0 && !hintRow,
490
+ !summarized && !hintRow && !group,
454
491
  draw,
492
+ frame,
455
493
  );
494
+ lines.push(...this.drawGroup(draw.others.slice(0, group), !summarized && !hintRow, draw, frame));
495
+ this.endFrame(frame, draw);
456
496
  if (hintRow) lines.push(this.closingRow(draw, undefined, hint));
457
- if (overflow === 0) return lines;
497
+ if (!summarized) return lines;
458
498
 
459
- const overflowParts: string[] = [];
460
- if (layout.hiddenCompleted > 0)
461
- overflowParts.push(
462
- `${layout.hiddenCompleted} ${formatStatusLabel("completed")}`,
499
+ const parts: string[] = [];
500
+ if (overflow > 0) {
501
+ const overflowParts: string[] = [];
502
+ if (layout.hiddenCompleted > 0)
503
+ overflowParts.push(
504
+ `${layout.hiddenCompleted} ${formatStatusLabel("completed")}`,
505
+ );
506
+ if (layout.truncatedTail > 0)
507
+ overflowParts.push(
508
+ `${layout.truncatedTail} ${formatStatusLabel("pending")}`,
509
+ );
510
+ const more = t("overlay.more", OVERLAY_MORE);
511
+ parts.push(
512
+ overflowParts.length > 0
513
+ ? `+${overflow} ${more} (${overflowParts.join(", ")})`
514
+ : `+${overflow} ${more}`,
463
515
  );
464
- if (layout.truncatedTail > 0)
465
- overflowParts.push(
466
- `${layout.truncatedTail} ${formatStatusLabel("pending")}`,
467
- );
468
- const more = t("overlay.more", OVERLAY_MORE);
469
- const summary =
470
- overflowParts.length > 0
471
- ? `+${overflow} ${more} (${overflowParts.join(", ")})`
472
- : `+${overflow} ${more}`;
473
- lines.push(this.closingRow(draw, summary, hint));
516
+ }
517
+ if (group < others) parts.push(`${parts.length ? "" : "+"}${formatWorkerCount(others - group)}`);
518
+ lines.push(this.closingRow(draw, parts.join(t("overlay.separator", OVERLAY_SEPARATOR)), hint));
474
519
  return lines;
475
520
  }
476
521
 
477
522
  /**
478
523
  * The focus view (default): in-progress tasks with their runs, the next open
479
- * tasks (two, or three when nothing is in progress), then this turn's completed
480
- * rows if room is left, and one summary row counting whatever is hidden. Rows are
481
- * flat, so every unfinished blocker goes to the `⛓` tail.
524
+ * tasks (two, or three when nothing is in progress), the Other workers group,
525
+ * then this turn's completed rows if room is left, and one summary row counting
526
+ * whatever is hidden. Completed rows are drawn before the group but get rows
527
+ * after it. Rows are flat, so every unfinished blocker goes to the `⛓` tail.
482
528
  */
483
529
  private focusBody(
484
530
  overlayTasks: Task[],
@@ -493,20 +539,26 @@ export class TodoOverlay {
493
539
  const total = inProgress.length + pending.length + completed.length;
494
540
 
495
541
  // Task rows first, in priority order; runs take the spare rows in display order;
496
- // completed rows get what is left. The summary row is reserved only when needed.
542
+ // the group and then completed rows get what is left. The summary row is reserved only when needed.
497
543
  const fit = (slots: number) => {
498
544
  const core = [...inProgress, ...next].slice(0, slots);
499
- let spare = slots - core.length;
500
- for (const task of core) {
501
- const n = this.children(task, draw).length;
502
- if (n <= spare) spare -= n;
503
- }
545
+ let spare = slots - core.length - this.boundRows(core, slots - core.length, draw);
546
+ const candidates = this.groupCandidates([...core, ...completed], draw);
547
+ const initialGroup = groupFit(spare, candidates.length);
548
+ const possibleDone = completed.slice(0, spare - (initialGroup ? 1 + initialGroup : 0));
549
+ const workers = this.groupCandidates([...core, ...possibleDone], draw);
550
+ const group = groupFit(spare, workers.length);
551
+ spare -= group ? 1 + group : 0;
504
552
  const done = completed.slice(0, spare);
505
- return { core, done, spare: slots - core.length - done.length, left: spare - done.length };
553
+ const rows = core.length + done.length + (group ? 1 + group : 0);
554
+ return { core, done, group, workers: this.groupCandidates([...core, ...done], draw), spare: slots - rows, left: spare - done.length };
506
555
  };
507
556
  let shown = fit(bodyBudget);
508
- let summarized = shown.core.length + shown.done.length < total;
557
+ const summarized =
558
+ shown.core.length + shown.done.length < total || shown.group < shown.workers.length;
509
559
  if (summarized) shown = fit(bodyBudget - 1);
560
+ draw.others = shown.workers;
561
+ const others = shown.workers.length;
510
562
  // With nothing to summarize, the hint takes its own row only when one is spare;
511
563
  // one row less leaves the same layout then.
512
564
  const hint = this.keyHint();
@@ -524,12 +576,16 @@ export class TodoOverlay {
524
576
  }
525
577
  : undefined;
526
578
  };
579
+ const frame: Frame = { drawn: [], marked: new Map(), ticking: false };
527
580
  const lines = this.drawTasks(
528
581
  [...shown.core, ...shown.done].map((task) => ({ task, row: flat(task) })),
529
582
  shown.spare,
530
- !summarized && !hintRow,
583
+ !summarized && !hintRow && !shown.group,
531
584
  draw,
585
+ frame,
532
586
  );
587
+ lines.push(...this.drawGroup(draw.others.slice(0, shown.group), !summarized && !hintRow, draw, frame));
588
+ this.endFrame(frame, draw);
533
589
  if (hintRow) lines.push(this.closingRow(draw, undefined, hint));
534
590
  if (!summarized) return lines;
535
591
 
@@ -544,33 +600,90 @@ export class TodoOverlay {
544
600
  )
545
601
  .filter(([n]) => n > 0)
546
602
  .map(([n, status]) => `${n} ${formatStatusLabel(status)}`);
603
+ if (shown.group < others) parts.push(formatWorkerCount(others - shown.group));
547
604
  const summary = `+${parts.join(t("overlay.separator", OVERLAY_SEPARATOR))}`;
548
605
  lines.push(this.closingRow(draw, summary, hint));
549
606
  return lines;
550
607
  }
551
608
 
609
+ private groupCandidates(visible: readonly Task[], draw: DrawContext): RunRow[] {
610
+ const ids = new Set(visible.map(task => task.id));
611
+ return [...(draw.live?.values() ?? [])].filter(run => !ids.has(draw.runOwners.get(run.id) ?? -1));
612
+ }
613
+
552
614
  /** Live run rows bound to a task (empty when the host gave no rows). */
553
615
  private children(task: Task, draw: DrawContext): RunRow[] {
554
616
  const { runs } = draw.bound.get(task.id) ?? history(undefined);
555
617
  return runs.flatMap((r) => draw.live?.get(r.id) ?? []);
556
618
  }
557
619
 
620
+ /** Rows the tasks' runs take from `spare`, given in display order to each task whose runs all fit, as drawTasks does. */
621
+ private boundRows(tasks: readonly Task[], spare: number, draw: DrawContext): number {
622
+ let used = 0;
623
+ for (const task of tasks) {
624
+ const n = this.children(task, draw).length;
625
+ if (used + n <= spare) used += n;
626
+ }
627
+ return used;
628
+ }
629
+
630
+ /** End the frame's claim bookkeeping; a group folded into the summary keeps the tick so its count stays current. */
631
+ private endFrame(frame: Frame, draw: DrawContext) {
632
+ this.finishFrame(frame.drawn, frame.ticking || draw.others.length > 0, frame.marked);
633
+ }
634
+
635
+ /**
636
+ * One run row under `branch`. A run waiting for a reply stands out; idle and
637
+ * running rows stay dim, and so does the tree. Only a row shown in full is
638
+ * claimed; a truncated one carries no marker.
639
+ */
640
+ private drawRun(lines: string[], r: RunRow, branch: string, draw: DrawContext, frame: Frame) {
641
+ const { theme, width, truncate, now, evidence } = draw;
642
+ const line =
643
+ runState(r) === "waiting"
644
+ ? theme.fg("dim", branch) + theme.fg("warning", runLine(r, now))
645
+ : theme.fg("dim", branch + runLine(r, now));
646
+ const whole = visibleWidth(line) <= width;
647
+ frame.ticking = true;
648
+ if (whole && evidence === "screen") {
649
+ const marked = line + this.marker(r.id);
650
+ frame.marked.set(r.id, marked);
651
+ lines.push(marked);
652
+ } else {
653
+ lines.push(truncate(line));
654
+ if (whole && evidence === "inline") frame.drawn.push(r.id);
655
+ }
656
+ }
657
+
658
+ /**
659
+ * The Other workers group: a heading row, then this session's runs bound to no
660
+ * task, drawn and claimed like bound run rows. `closed` means it ends the panel.
661
+ */
662
+ private drawGroup(runs: RunRow[], closed: boolean, draw: DrawContext, frame: Frame): string[] {
663
+ if (!runs.length) return [];
664
+ const { theme, truncate } = draw;
665
+ const lines = [
666
+ truncate(`${theme.fg("dim", closed ? "└─" : "├─")} ${theme.fg("muted", t("overlay.others", OVERLAY_OTHERS))}`),
667
+ ];
668
+ for (const [j, r] of runs.entries())
669
+ this.drawRun(lines, r, `${closed ? " " : "│"} ${j === runs.length - 1 ? "└" : "├"} ${draw.runOwners.has(r.id) ? `#${draw.runOwners.get(r.id)} ` : ''}`, draw, frame);
670
+ return lines;
671
+ }
672
+
558
673
  /**
559
674
  * Draw task rows and, where `spare` rows remain, their run rows; a task whose
560
- * runs do not fit shows `· N runs`. Ends the frame's claim bookkeeping. `closed`
561
- * means no summary row follows, so the last task row takes `└─`.
675
+ * runs do not fit shows `· N runs`. `closed` means nothing follows, so the last
676
+ * task row takes `└─`.
562
677
  */
563
678
  private drawTasks(
564
679
  entries: { task: Task; row?: PlanRow }[],
565
680
  spare: number,
566
681
  closed: boolean,
567
682
  draw: DrawContext,
683
+ frame: Frame,
568
684
  ): string[] {
569
- const { theme, width, truncate, live, showIds, now, evidence } = draw;
685
+ const { theme, truncate, live, showIds } = draw;
570
686
  const lines: string[] = [];
571
- const drawn: string[] = [];
572
- let ticking = false;
573
- const marked = new Map<string, string>();
574
687
  for (const [i, { task, row }] of entries.entries()) {
575
688
  const { older } = draw.bound.get(task.id) ?? history(undefined);
576
689
  const children = this.children(task, draw);
@@ -590,28 +703,10 @@ export class TodoOverlay {
590
703
  );
591
704
  if (!fits) continue;
592
705
  spare -= children.length;
593
- for (const [j, r] of children.entries()) {
594
- const indent = " ".repeat(row?.depth ?? 0);
595
- const branch = `${last ? " " : "│"} ${indent}${j === children.length - 1 ? "└" : "├"} `;
596
- // A run waiting for a reply stands out; idle and running rows stay dim. The tree stays dim.
597
- const childLine =
598
- runState(r) === "waiting"
599
- ? theme.fg("dim", branch) + theme.fg("warning", runLine(r, now))
600
- : theme.fg("dim", branch + runLine(r, now));
601
- const whole = visibleWidth(childLine) <= width;
602
- ticking = true;
603
- // Only a row shown in full is claimed; a truncated one carries no marker.
604
- if (whole && evidence === "screen") {
605
- const line = childLine + this.marker(r.id);
606
- marked.set(r.id, line);
607
- lines.push(line);
608
- } else {
609
- lines.push(truncate(childLine));
610
- if (whole && evidence === "inline") drawn.push(r.id);
611
- }
612
- }
706
+ const indent = " ".repeat(row?.depth ?? 0);
707
+ for (const [j, r] of children.entries())
708
+ this.drawRun(lines, r, `${last ? " " : "│"} ${indent}${j === children.length - 1 ? "└" : "├"} `, draw, frame);
613
709
  }
614
- this.finishFrame(drawn, ticking, marked);
615
710
  return lines;
616
711
  }
617
712
 
@@ -9,6 +9,8 @@ export interface RunRow {
9
9
  phase: { kind: string; label?: string; since?: number };
10
10
  cancel?: string;
11
11
  }
12
+ /** The host's run-rows event (pi-herdr-agents, and pi-straw-boss after the move): the probe and the claim. */
13
+ export const RUN_ROWS_EVENT = "pi-herdr-agents:run-rows:v1";
12
14
  export interface Probe {
13
15
  claim?: { by: string; ids: string[] };
14
16
  rows?: { version: 1; rows: RunRow[] };