pi-todo-ledger 0.7.0 → 0.7.2
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 +7 -2
- package/docs/configuration.md +9 -5
- package/docs/overlay.md +73 -15
- package/package.json +1 -1
- package/src/config.ts +1 -1
- package/src/index.ts +33 -10
- package/src/locales/de.json +7 -1
- package/src/locales/en.json +7 -1
- package/src/locales/es.json +7 -1
- package/src/locales/fr.json +7 -1
- package/src/locales/pt-BR.json +7 -1
- package/src/locales/pt.json +7 -1
- package/src/locales/ru.json +9 -1
- package/src/locales/uk.json +9 -1
- package/src/locales/zh-TW.json +6 -1
- package/src/locales/zh.json +6 -1
- package/src/state/i18n-bridge.ts +12 -0
- package/src/todo-overlay.ts +231 -111
- package/src/view/live-runs.ts +2 -0
package/README.md
CHANGED
|
@@ -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.
|
|
@@ -117,9 +122,9 @@ Without one, the extension reads `rpiv-todo/config.json` from the same directori
|
|
|
117
122
|
|
|
118
123
|
| Setting | What it does | Default |
|
|
119
124
|
| --- | --- | --- |
|
|
120
|
-
| `view` | `"focus"` lists the tasks in progress and the next open ones, and folds the rest into one summary row. `"full"` shows the whole dependency tree. | `"focus"` |
|
|
125
|
+
| `view` | The panel's starting state. `"focus"` lists the tasks in progress and the next open ones, and folds the rest into one summary row. `"full"` shows the whole dependency tree. | `"focus"` |
|
|
121
126
|
| `maxWidgetLines` | Content rows the panel may use, heading included. Minimum `3`. Pi's tool-output expansion mode lifts the limit. | `12` |
|
|
122
|
-
| `collapseKey` | Key that
|
|
127
|
+
| `collapseKey` | Key that cycles the panel focus → full → collapsed → focus, starting from `view`, in pi keybinding form (`alt+o`, `ctrl+shift+t`). A dim hint such as `+5 pending · ctrl+shift+t full` names the next state. `"off"` registers no shortcut and shows no hint. Needs `/reload` to rebind. | `"ctrl+shift+t"` |
|
|
123
128
|
| `guidance` | Replaces the built-in instructions the extension gives the model about the todo list (`promptSnippet`, `promptGuidelines`). Needs `/reload`. | built-ins |
|
|
124
129
|
|
|
125
130
|
More detail: [Configuration](docs/configuration.md), [`todo` tool reference](docs/tool-schema.md), [Panel and `/todos`](docs/overlay.md).
|
package/docs/configuration.md
CHANGED
|
@@ -52,6 +52,9 @@ The extension never writes this file — you create and edit it yourself.
|
|
|
52
52
|
- `"full"` shows the whole dependency tree, as releases up to 0.6.0 did.
|
|
53
53
|
- Any other value, or none, means `"focus"`.
|
|
54
54
|
- Read fresh on every render, like `maxWidgetLines`, so no `/reload`.
|
|
55
|
+
- It sets the starting state only. The `collapseKey` shortcut then cycles
|
|
56
|
+
focus → full → collapsed from there, and the chosen state holds for the rest
|
|
57
|
+
of the session.
|
|
55
58
|
|
|
56
59
|
[overlay.md](./overlay.md#focus-view) describes both layouts.
|
|
57
60
|
|
|
@@ -72,8 +75,10 @@ blank spacer sits outside the budget, so `12` renders up to 13 terminal rows.
|
|
|
72
75
|
|
|
73
76
|
## `collapseKey`
|
|
74
77
|
|
|
75
|
-
**Default `"ctrl+shift+t"`.** The shortcut that
|
|
76
|
-
|
|
78
|
+
**Default `"ctrl+shift+t"`.** The shortcut that cycles the overlay through
|
|
79
|
+
the focus view, the full view, and the collapsed state, in that order, starting
|
|
80
|
+
from `view`. Each state shows a dim hint with this key and the next state; see
|
|
81
|
+
[overlay.md](./overlay.md#switching-views).
|
|
77
82
|
|
|
78
83
|
The value is trimmed and lowercased, then matched against Pi's keybinding
|
|
79
84
|
grammar: zero or more distinct modifiers joined by `+`, then a base key.
|
|
@@ -90,11 +95,10 @@ Examples: `alt+o`, `ctrl+shift+t`, `super+alt+f5`.
|
|
|
90
95
|
default. The grammar is checked strictly on purpose: Pi takes the last `+`-part
|
|
91
96
|
as the base key and ignores unknown parts, so a typo like `ctr+]` would
|
|
92
97
|
otherwise capture every bare `]` keypress globally.
|
|
93
|
-
- `"off"` disables the feature
|
|
98
|
+
- `"off"` disables the feature: no shortcut is registered and no hint is shown.
|
|
94
99
|
- The binding is resolved **once at extension load**. After editing this value,
|
|
95
100
|
run `/reload` to rebind; until you do, the old key stays active even though the
|
|
96
|
-
|
|
97
|
-
new one.
|
|
101
|
+
panel's hint text (which is resolved per render) already shows the new one.
|
|
98
102
|
|
|
99
103
|
## Guidance
|
|
100
104
|
|
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 |
|
|
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
|
|
|
@@ -31,7 +31,7 @@ The panel opens in the focus view. It shows what is being worked on and what com
|
|
|
31
31
|
│ └ fixture-test · astra · 執行中 6s
|
|
32
32
|
├─ ○ #1 檢查畫面
|
|
33
33
|
├─ ○ #2 確認版面
|
|
34
|
-
└─ +5 待處理
|
|
34
|
+
└─ +5 待處理 · ctrl+shift+t 完整
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Rows come in this order, until the row budget runs out:
|
|
@@ -39,12 +39,15 @@ 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.
|
|
43
|
-
5.
|
|
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.
|
|
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).
|
|
44
47
|
|
|
45
48
|
`maxWidgetLines` is a hard cap here too: tasks in progress that do not fit are counted in the summary, and run rows that do not fit fold into `· N runs`.
|
|
46
49
|
Rows are flat, so the `⛓` tail lists every unfinished blocker of a task; `⏸`, owners, and the other marks are the same as in the full view.
|
|
47
|
-
Pi's tool-output expansion mode lifts the row cap but keeps this selection.
|
|
50
|
+
Pi's tool-output expansion mode lifts the row cap but keeps this selection. Press the panel key for the tree below, set `"view": "full"` (see [configuration.md](./configuration.md#view)) to start there, or use `/todos` to see everything once.
|
|
48
51
|
|
|
49
52
|
## Anatomy of a row
|
|
50
53
|
|
|
@@ -56,7 +59,8 @@ The full view (`"view": "full"`) draws the whole dependency tree:
|
|
|
56
59
|
├─ ○ #3 API
|
|
57
60
|
├─ ○ #4 Check API
|
|
58
61
|
├─ ○ #5 UI
|
|
59
|
-
|
|
62
|
+
├─ ⏸ #2 Approve waits Pat
|
|
63
|
+
└─ ctrl+shift+t collapse
|
|
60
64
|
```
|
|
61
65
|
|
|
62
66
|
- **Heading** — `● Todos (done/total)` in the accent color while any task is
|
|
@@ -96,6 +100,39 @@ The panel asks the Subagents widget to hide a run only once it knows the run's r
|
|
|
96
100
|
|
|
97
101
|
Collapsing the panel, or the run leaving the panel, returns the run to the Subagents widget.
|
|
98
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 panel lists this session's runs that no task on the panel is bound to as one group, after the task rows and before the summary row:
|
|
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
|
+
|
|
99
136
|
## Overflow
|
|
100
137
|
|
|
101
138
|
The content-row budget is `maxWidgetLines` (default `12`), and the heading counts
|
|
@@ -122,16 +159,37 @@ completed. At the start of the next agent turn, every completed row that has
|
|
|
122
159
|
already been displayed is hidden from later renders. Reloading or compacting the
|
|
123
160
|
session resets that tracking, so a fresh session shows the full list again.
|
|
124
161
|
|
|
125
|
-
##
|
|
162
|
+
## Switching views
|
|
163
|
+
|
|
164
|
+
`ctrl+shift+t` steps the panel through three states, always in this order:
|
|
165
|
+
|
|
166
|
+
1. focus view;
|
|
167
|
+
2. full view;
|
|
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.
|
|
169
|
+
|
|
170
|
+
The panel starts in the state `view` names, `"focus"` unless you set `"full"`,
|
|
171
|
+
and the next press continues the cycle from there: from `"full"` it goes to
|
|
172
|
+
collapsed, then focus, then full again. The chosen state holds until the next
|
|
173
|
+
press or the end of the session.
|
|
174
|
+
|
|
175
|
+
Each state shows a dim hint naming the key and the next state: `ctrl+shift+t
|
|
176
|
+
full`, `ctrl+shift+t collapse`, `ctrl+shift+t focus` (`完整`, `收合`, `焦點` in
|
|
177
|
+
zh-TW). In the focus and full views the hint ends the summary row after a ` · `.
|
|
178
|
+
It is the first thing cut when the row is too narrow. With nothing to summarize,
|
|
179
|
+
the hint takes its own closing `└─` row, and only when the row budget has a row
|
|
180
|
+
to spare, so it never pushes a task out. The hint always shows the configured
|
|
181
|
+
key.
|
|
126
182
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
the
|
|
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
|
|
185
|
+
claims the run rows it actually paints, as described under
|
|
186
|
+
[Worker runs under a task](#worker-runs-under-a-task).
|
|
130
187
|
|
|
131
188
|
Rebind or disable the shortcut with the `collapseKey` option; see
|
|
132
|
-
[configuration.md](./configuration.md#collapsekey).
|
|
133
|
-
`"off"` while the panel is collapsed, the
|
|
134
|
-
label rather than advertising an
|
|
189
|
+
[configuration.md](./configuration.md#collapsekey). With `"off"` no hint is
|
|
190
|
+
shown. If the shortcut is set to `"off"` while the panel is collapsed, the
|
|
191
|
+
collapsed row becomes a static `collapsed` label rather than advertising an
|
|
192
|
+
unbindable key.
|
|
135
193
|
|
|
136
194
|
## `/todos`
|
|
137
195
|
|
|
@@ -155,8 +213,8 @@ tasks. Tombstoned tasks are never listed.
|
|
|
155
213
|
|
|
156
214
|
## Localization
|
|
157
215
|
|
|
158
|
-
The overlay heading, both summary rows, the
|
|
159
|
-
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
|
|
160
218
|
[`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n)
|
|
161
219
|
when that package is installed. Bundled locales: `de`, `en`, `es`, `fr`, `pt`,
|
|
162
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.
|
|
3
|
+
"version": "0.7.2",
|
|
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",
|
package/src/config.ts
CHANGED
|
@@ -96,7 +96,7 @@ interface TodoConfig {
|
|
|
96
96
|
guidance?: GuidanceFields;
|
|
97
97
|
maxWidgetLines?: number;
|
|
98
98
|
/**
|
|
99
|
-
* Key spec for the overlay
|
|
99
|
+
* Key spec for the overlay cycle shortcut (focus → full → collapsed), in the same format as
|
|
100
100
|
* pi-coding-agent keybinding ids (`modifier+key`, e.g. `ctrl+shift+t`, `alt+o`).
|
|
101
101
|
* Defaults to `"ctrl+shift+t"`. Pass `"off"` to disable the collapse shortcut
|
|
102
102
|
* entirely. Validation happens in `resolveCollapseKey`, not at load.
|
package/src/index.ts
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
} from "./state/store.ts";
|
|
52
52
|
import { registerTodosCommand, registerTodoTool, TOOL_NAME } from "./todo.ts";
|
|
53
53
|
import type { TodoOverlay } from "./todo-overlay.ts";
|
|
54
|
+
import { RUN_ROWS_EVENT } from "./view/live-runs.ts";
|
|
54
55
|
|
|
55
56
|
// Held in a variable so the type checker does not require the optional peer.
|
|
56
57
|
const I18N_LOADER: string = "@juicesharp/rpiv-i18n/loader";
|
|
@@ -159,17 +160,30 @@ export default function (
|
|
|
159
160
|
let uiCtx: ExtensionUIContext | undefined;
|
|
160
161
|
let lifecycleGeneration = 0;
|
|
161
162
|
|
|
163
|
+
// The host's run-rows probe. Without a claim it only reads this session's runs.
|
|
164
|
+
const queryRuns = (p: object) => pi.events.emit(RUN_ROWS_EVENT, p);
|
|
165
|
+
/** Whether the host lists any run of this session: such runs show on the panel even with no task. */
|
|
166
|
+
const hostHasRuns = (): boolean => {
|
|
167
|
+
const p: { rows?: { rows?: unknown } } = {};
|
|
168
|
+
try {
|
|
169
|
+
queryRuns(p);
|
|
170
|
+
} catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return Array.isArray(p.rows?.rows) && p.rows.rows.length > 0;
|
|
174
|
+
};
|
|
175
|
+
|
|
162
176
|
async function updateTodoOverlay(
|
|
163
177
|
resetCompletedDisplayState = false,
|
|
164
178
|
generation = lifecycleGeneration,
|
|
165
179
|
): Promise<void> {
|
|
166
180
|
const hasVisibleTasks = getRenderState().tasks.some((task) => task.status !== "deleted");
|
|
167
|
-
if (!uiCtx || (!todoOverlay && !hasVisibleTasks)) return;
|
|
181
|
+
if (!uiCtx || (!todoOverlay && !hasVisibleTasks && !hostHasRuns())) return;
|
|
168
182
|
|
|
169
183
|
const { TodoOverlay } = await loadTodoOverlay();
|
|
170
184
|
if (generation !== lifecycleGeneration || !uiCtx) return;
|
|
171
185
|
|
|
172
|
-
todoOverlay ??= new TodoOverlay(
|
|
186
|
+
todoOverlay ??= new TodoOverlay(queryRuns);
|
|
173
187
|
todoOverlay.setUICtx(uiCtx);
|
|
174
188
|
if (resetCompletedDisplayState) todoOverlay.resetCompletedDisplayState();
|
|
175
189
|
todoOverlay.update();
|
|
@@ -200,7 +214,7 @@ export default function (
|
|
|
200
214
|
pi.events.emit(CHANGED_EVENT, toChangedEvent(id, getState(id)));
|
|
201
215
|
};
|
|
202
216
|
|
|
203
|
-
//
|
|
217
|
+
// Cycle hotkey for the todo overlay (focus → full → collapsed). The key is resolved once at
|
|
204
218
|
// factory scope from config (register-once contract: a config change needs
|
|
205
219
|
// `/reload` to re-bind, same as lane-switcher's env hotkey) and the binding is
|
|
206
220
|
// skipped entirely when collapseKey is "off". The handler closes over the
|
|
@@ -211,10 +225,10 @@ export default function (
|
|
|
211
225
|
const collapseKey = resolveCollapseKey();
|
|
212
226
|
if (collapseKey !== COLLAPSE_KEY_OFF) {
|
|
213
227
|
pi.registerShortcut(collapseKey as KeyId, {
|
|
214
|
-
description: "
|
|
228
|
+
description: "Cycle the todo overlay: focus, full, collapsed",
|
|
215
229
|
handler: (ctx) => {
|
|
216
230
|
if (!ctx.hasUI || !todoOverlay?.isRegistered()) return;
|
|
217
|
-
todoOverlay.
|
|
231
|
+
todoOverlay.cycleView();
|
|
218
232
|
},
|
|
219
233
|
});
|
|
220
234
|
}
|
|
@@ -309,14 +323,12 @@ export default function (
|
|
|
309
323
|
}
|
|
310
324
|
});
|
|
311
325
|
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
pi.on("tool_execution_end", async (event) => {
|
|
315
|
-
if ((event.toolName !== TOOL_NAME && event.toolName !== "subagent") || event.isError) return;
|
|
326
|
+
// A refresh after something that may change the list or this session's runs.
|
|
327
|
+
const refresh = async (): Promise<void> => {
|
|
316
328
|
try {
|
|
317
329
|
await updateTodoOverlay();
|
|
318
330
|
} catch (e) {
|
|
319
|
-
// The tool itself succeeded — a transient overlay-load failure only
|
|
331
|
+
// The tool or turn itself succeeded — a transient overlay-load failure only
|
|
320
332
|
// costs this one refresh, and the loader's cleared memo lets the next
|
|
321
333
|
// update retry. Don't surface that as an extension error. The latched
|
|
322
334
|
// stale-namespace error still propagates: it never self-heals, and the
|
|
@@ -324,8 +336,19 @@ export default function (
|
|
|
324
336
|
if (isStaleOverlayModuleError(e)) throw e;
|
|
325
337
|
console.warn(`[pi-todo-ledger] overlay refresh failed (will retry on next update): ${formatError(e)}`);
|
|
326
338
|
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// Reads getTodos() at render time; do NOT call replayFromBranch here
|
|
342
|
+
// (branch is stale — message_end runs after tool_execution_end). A launch or
|
|
343
|
+
// resume may start a run bound to no task, which the panel shows too.
|
|
344
|
+
pi.on("tool_execution_end", async (event) => {
|
|
345
|
+
if (event.isError || ![TOOL_NAME, "subagent", "subagent_resume"].includes(event.toolName)) return;
|
|
346
|
+
await refresh();
|
|
327
347
|
});
|
|
328
348
|
|
|
349
|
+
// Runs can also start without a tool call of this session; the end of a turn picks them up.
|
|
350
|
+
pi.on("agent_end", refresh);
|
|
351
|
+
|
|
329
352
|
// Evaluate the lazy graph after startup while Pi's boot-time dependency paths
|
|
330
353
|
// are still stable. This loads no widget and constructs no overlay; those stay
|
|
331
354
|
// deferred until a foreground session has visible tasks. A rejected pre-warm
|
package/src/locales/de.json
CHANGED
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Todos",
|
|
10
10
|
"overlay.more": "weitere",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "Fokus",
|
|
13
|
+
"overlay.next.full": "voll",
|
|
14
|
+
"overlay.next.collapsed": "einklappen",
|
|
12
15
|
"overlay.collapsed": "eingeklappt",
|
|
16
|
+
"overlay.others": "Weitere Worker",
|
|
17
|
+
"overlay.worker.one": "Worker",
|
|
18
|
+
"overlay.worker.other": "Worker",
|
|
13
19
|
|
|
14
20
|
"command.no_todos": "Noch keine Todos. Bitte den Agenten, welche hinzuzufügen!",
|
|
15
21
|
"command.requires_interactive": "/todos erfordert den interaktiven Modus",
|
package/src/locales/en.json
CHANGED
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
"overlay.heading": "Todos",
|
|
8
8
|
"overlay.more": "more",
|
|
9
|
-
"overlay.
|
|
9
|
+
"overlay.keyHint": "{key} {next}",
|
|
10
|
+
"overlay.next.focus": "focus",
|
|
11
|
+
"overlay.next.full": "full",
|
|
12
|
+
"overlay.next.collapsed": "collapse",
|
|
10
13
|
"overlay.collapsed": "collapsed",
|
|
11
14
|
"overlay.separator": ", ",
|
|
15
|
+
"overlay.others": "Other workers",
|
|
16
|
+
"overlay.worker.one": "worker",
|
|
17
|
+
"overlay.worker.other": "workers",
|
|
12
18
|
|
|
13
19
|
"command.no_todos": "No todos yet. Ask the agent to add some!",
|
|
14
20
|
"command.requires_interactive": "/todos requires interactive mode",
|
package/src/locales/es.json
CHANGED
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tareas",
|
|
10
10
|
"overlay.more": "más",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "enfoque",
|
|
13
|
+
"overlay.next.full": "completo",
|
|
14
|
+
"overlay.next.collapsed": "contraer",
|
|
12
15
|
"overlay.collapsed": "contraído",
|
|
16
|
+
"overlay.others": "Otros workers",
|
|
17
|
+
"overlay.worker.one": "worker",
|
|
18
|
+
"overlay.worker.other": "workers",
|
|
13
19
|
|
|
14
20
|
"command.no_todos": "Sin tareas aún. ¡Pídele al agente que añada algunas!",
|
|
15
21
|
"command.requires_interactive": "/todos requiere modo interactivo",
|
package/src/locales/fr.json
CHANGED
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tâches",
|
|
10
10
|
"overlay.more": "autres",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "focus",
|
|
13
|
+
"overlay.next.full": "complet",
|
|
14
|
+
"overlay.next.collapsed": "réduire",
|
|
12
15
|
"overlay.collapsed": "réduit",
|
|
16
|
+
"overlay.others": "Autres workers",
|
|
17
|
+
"overlay.worker.one": "worker",
|
|
18
|
+
"overlay.worker.other": "workers",
|
|
13
19
|
|
|
14
20
|
"command.no_todos": "Pas encore de tâches. Demandez à l'agent d'en ajouter !",
|
|
15
21
|
"command.requires_interactive": "/todos nécessite le mode interactif",
|
package/src/locales/pt-BR.json
CHANGED
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tarefas",
|
|
10
10
|
"overlay.more": "mais",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "foco",
|
|
13
|
+
"overlay.next.full": "completo",
|
|
14
|
+
"overlay.next.collapsed": "recolher",
|
|
12
15
|
"overlay.collapsed": "recolhido",
|
|
16
|
+
"overlay.others": "Outros workers",
|
|
17
|
+
"overlay.worker.one": "worker",
|
|
18
|
+
"overlay.worker.other": "workers",
|
|
13
19
|
|
|
14
20
|
"command.no_todos": "Nenhuma tarefa ainda. Peça ao agente para adicionar algumas!",
|
|
15
21
|
"command.requires_interactive": "/todos requer modo interativo",
|
package/src/locales/pt.json
CHANGED
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tarefas",
|
|
10
10
|
"overlay.more": "mais",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "foco",
|
|
13
|
+
"overlay.next.full": "completo",
|
|
14
|
+
"overlay.next.collapsed": "recolher",
|
|
12
15
|
"overlay.collapsed": "recolhido",
|
|
16
|
+
"overlay.others": "Outros workers",
|
|
17
|
+
"overlay.worker.one": "worker",
|
|
18
|
+
"overlay.worker.other": "workers",
|
|
13
19
|
|
|
14
20
|
"command.no_todos": "Sem tarefas ainda. Peça ao agente para adicionar algumas!",
|
|
15
21
|
"command.requires_interactive": "/todos requer modo interativo",
|
package/src/locales/ru.json
CHANGED
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Задачи",
|
|
10
10
|
"overlay.more": "ещё",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "фокус",
|
|
13
|
+
"overlay.next.full": "полностью",
|
|
14
|
+
"overlay.next.collapsed": "свернуть",
|
|
12
15
|
"overlay.collapsed": "свёрнуто",
|
|
16
|
+
"overlay.others": "Другие воркеры",
|
|
17
|
+
"overlay.worker.one": "воркер",
|
|
18
|
+
"overlay.worker.few": "воркера",
|
|
19
|
+
"overlay.worker.many": "воркеров",
|
|
20
|
+
"overlay.worker.other": "воркера",
|
|
13
21
|
|
|
14
22
|
"command.no_todos": "Задач пока нет. Попросите агента добавить!",
|
|
15
23
|
"command.requires_interactive": "/todos требует интерактивного режима",
|
package/src/locales/uk.json
CHANGED
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Завдання",
|
|
10
10
|
"overlay.more": "ще",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "фокус",
|
|
13
|
+
"overlay.next.full": "повністю",
|
|
14
|
+
"overlay.next.collapsed": "згорнути",
|
|
12
15
|
"overlay.collapsed": "згорнуто",
|
|
16
|
+
"overlay.others": "Інші воркери",
|
|
17
|
+
"overlay.worker.one": "воркер",
|
|
18
|
+
"overlay.worker.few": "воркери",
|
|
19
|
+
"overlay.worker.many": "воркерів",
|
|
20
|
+
"overlay.worker.other": "воркера",
|
|
13
21
|
|
|
14
22
|
"command.no_todos": "Завдань поки немає. Попросіть агента додати!",
|
|
15
23
|
"command.requires_interactive": "/todos потребує інтерактивного режиму",
|
package/src/locales/zh-TW.json
CHANGED
|
@@ -5,9 +5,14 @@
|
|
|
5
5
|
"status.deleted": "已刪除",
|
|
6
6
|
"overlay.heading": "Todos",
|
|
7
7
|
"overlay.more": "項未顯示",
|
|
8
|
-
"overlay.
|
|
8
|
+
"overlay.keyHint": "{key} {next}",
|
|
9
|
+
"overlay.next.focus": "焦點",
|
|
10
|
+
"overlay.next.full": "完整",
|
|
11
|
+
"overlay.next.collapsed": "收合",
|
|
9
12
|
"overlay.collapsed": "已收合",
|
|
10
13
|
"overlay.separator": "、",
|
|
14
|
+
"overlay.others": "其他 worker",
|
|
15
|
+
"overlay.worker.other": "worker",
|
|
11
16
|
"command.no_todos": "目前沒有待辦事項。",
|
|
12
17
|
"command.requires_interactive": "/todos 需要互動模式",
|
|
13
18
|
"command.section.pending": "── 待處理 ──",
|
package/src/locales/zh.json
CHANGED
|
@@ -8,9 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "任务清单",
|
|
10
10
|
"overlay.more": "更多",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "焦点",
|
|
13
|
+
"overlay.next.full": "完整",
|
|
14
|
+
"overlay.next.collapsed": "收起",
|
|
12
15
|
"overlay.collapsed": "已折叠",
|
|
13
16
|
"overlay.separator": "、",
|
|
17
|
+
"overlay.others": "其他 worker",
|
|
18
|
+
"overlay.worker.other": "worker",
|
|
14
19
|
|
|
15
20
|
"command.no_todos": "暂无任务。可以让 agent 添加一些!",
|
|
16
21
|
"command.requires_interactive": "/todos 需要交互模式",
|
package/src/state/i18n-bridge.ts
CHANGED
|
@@ -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";
|
package/src/todo-overlay.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Lifecycle controller for Pi's `setWidget` contract: factory-form
|
|
5
5
|
* registration in widgetContainerAbove, register-once + requestRender()
|
|
6
|
-
* refresh,
|
|
7
|
-
* getMaxWidgetLines(); plus a trailing spacer row so the widget renders up
|
|
6
|
+
* refresh, a cycle key (focus → full → collapsed), configurable
|
|
7
|
+
* collapse-not-scroll (default 12 content rows via getMaxWidgetLines(); plus a trailing spacer row so the widget renders up
|
|
8
8
|
* to 13 lines), Pi tool-output expansion awareness, auto-hide when empty.
|
|
9
9
|
*
|
|
10
10
|
* Reads live state via `getRenderState()` (the ctx-less foreground slot) at render
|
|
@@ -25,9 +25,10 @@ import {
|
|
|
25
25
|
COLLAPSE_KEY_OFF,
|
|
26
26
|
getMaxWidgetLines,
|
|
27
27
|
getView,
|
|
28
|
+
type OverlayView,
|
|
28
29
|
resolveCollapseKey,
|
|
29
30
|
} from "./config.ts";
|
|
30
|
-
import { formatStatusLabel, t } from "./state/i18n-bridge.ts";
|
|
31
|
+
import { formatStatusLabel, formatWorkerCount, t } from "./state/i18n-bridge.ts";
|
|
31
32
|
import {
|
|
32
33
|
selectHasActive,
|
|
33
34
|
selectOverlayLayout,
|
|
@@ -47,9 +48,29 @@ const WIDGET_KEY = "rpiv-todos";
|
|
|
47
48
|
// English fallbacks for localized overlay chrome strings.
|
|
48
49
|
const OVERLAY_HEADING = "Todos";
|
|
49
50
|
const OVERLAY_MORE = "more";
|
|
50
|
-
const
|
|
51
|
+
const OVERLAY_KEY_HINT = "{key} {next}";
|
|
51
52
|
const OVERLAY_COLLAPSED = "collapsed";
|
|
52
53
|
const OVERLAY_SEPARATOR = ", ";
|
|
54
|
+
const OVERLAY_OTHERS = "Other workers";
|
|
55
|
+
|
|
56
|
+
/** What the panel shows: one of the two views, or the two-line collapsed state. */
|
|
57
|
+
type PanelState = OverlayView | "collapsed";
|
|
58
|
+
/** The cycle key's order, from any starting state. */
|
|
59
|
+
const NEXT_STATE: Record<PanelState, PanelState> = { focus: "full", full: "collapsed", collapsed: "focus" };
|
|
60
|
+
/** English names of the state the key goes to next, as the hint shows them. */
|
|
61
|
+
const NEXT_STATE_NAME: Record<PanelState, string> = { focus: "focus", full: "full", collapsed: "collapse" };
|
|
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);
|
|
53
74
|
|
|
54
75
|
/** What one frame's row drawing needs, shared by the full and focus views. */
|
|
55
76
|
interface DrawContext {
|
|
@@ -58,6 +79,8 @@ interface DrawContext {
|
|
|
58
79
|
truncate: (line: string) => string;
|
|
59
80
|
bound: Map<number, ReturnType<typeof history>>;
|
|
60
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[];
|
|
61
84
|
showIds: boolean;
|
|
62
85
|
now: number;
|
|
63
86
|
evidence: "inline" | "screen" | undefined;
|
|
@@ -70,7 +93,8 @@ export class TodoOverlay {
|
|
|
70
93
|
private completedTaskIdsPendingHide = new Set<number>();
|
|
71
94
|
private hiddenCompletedTaskIds = new Set<number>();
|
|
72
95
|
private lastNextId: number | undefined;
|
|
73
|
-
|
|
96
|
+
/** Set by the cycle key; until then the panel follows the configured `view`. */
|
|
97
|
+
private state?: PanelState;
|
|
74
98
|
|
|
75
99
|
private previous: string[] = [];
|
|
76
100
|
private claimed: string[] = [];
|
|
@@ -203,7 +227,8 @@ export class TodoOverlay {
|
|
|
203
227
|
const snapshot = this.getSnapshot();
|
|
204
228
|
const visible = this.selectOverlayTasks(snapshot);
|
|
205
229
|
|
|
206
|
-
|
|
230
|
+
// With no task to show, the panel stays for this session's runs (the Other workers group).
|
|
231
|
+
if (visible.length === 0 && !liveRows(this.query)?.size) {
|
|
207
232
|
this.finishFrame([]);
|
|
208
233
|
if (this.widgetRegistered) {
|
|
209
234
|
this.uiCtx.setWidget(WIDGET_KEY, undefined);
|
|
@@ -251,16 +276,46 @@ export class TodoOverlay {
|
|
|
251
276
|
this.tui?.requestRender();
|
|
252
277
|
}
|
|
253
278
|
|
|
254
|
-
|
|
255
|
-
this.
|
|
279
|
+
private current(): PanelState {
|
|
280
|
+
return this.state ?? getView();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Step the panel to the next state: focus → full → collapsed → focus. */
|
|
284
|
+
cycleView(): void {
|
|
285
|
+
this.state = NEXT_STATE[this.current()];
|
|
256
286
|
// Release before the redraw: the host may draw its widget first in that frame.
|
|
257
|
-
if (this.collapsed) this.finishFrame([]);
|
|
258
|
-
// Forced full redraw on
|
|
287
|
+
if (this.state === "collapsed") this.finishFrame([]);
|
|
288
|
+
// Forced full redraw on every height step, mirroring the
|
|
259
289
|
// lane-dock's requestRender(shapeChanged); distinct from the non-forced
|
|
260
290
|
// requestRender() refresh paths in update()/hideCompletedTasksFromPreviousTurn().
|
|
261
291
|
this.tui?.requestRender(true);
|
|
262
292
|
}
|
|
263
293
|
|
|
294
|
+
/**
|
|
295
|
+
* The dim key hint naming the next state, e.g. `ctrl+shift+t full`, or
|
|
296
|
+
* undefined when the key is "off". The key is resolved per render; a config
|
|
297
|
+
* edit needs /reload to re-bind the actual shortcut.
|
|
298
|
+
*/
|
|
299
|
+
private keyHint(): string | undefined {
|
|
300
|
+
const key = resolveCollapseKey();
|
|
301
|
+
if (key === COLLAPSE_KEY_OFF) return undefined;
|
|
302
|
+
const next = NEXT_STATE[this.current()];
|
|
303
|
+
const name = t(`overlay.next.${next}`, NEXT_STATE_NAME[next]);
|
|
304
|
+
return t("overlay.keyHint", OVERLAY_KEY_HINT).replace(/\{(key|next)\}/g, (_m, k: string) => (k === "key" ? key : name));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* The closing `└─` row: the summary, then ` · ` and the key hint when both fit
|
|
309
|
+
* the width (the hint is cut first), or the hint alone.
|
|
310
|
+
*/
|
|
311
|
+
private closingRow(draw: DrawContext, summary: string | undefined, hint: string | undefined): string {
|
|
312
|
+
const { theme, width, truncate } = draw;
|
|
313
|
+
const row = (text: string) => `${theme.fg("dim", "└─")} ${theme.fg("dim", text)}`;
|
|
314
|
+
if (summary === undefined) return truncate(row(hint ?? ""));
|
|
315
|
+
const both = hint ? row(`${summary} · ${hint}`) : undefined;
|
|
316
|
+
return both && visibleWidth(both) <= width ? both : truncate(row(summary));
|
|
317
|
+
}
|
|
318
|
+
|
|
264
319
|
isRegistered(): boolean {
|
|
265
320
|
return this.widgetRegistered;
|
|
266
321
|
}
|
|
@@ -305,7 +360,9 @@ export class TodoOverlay {
|
|
|
305
360
|
private renderWidget(theme: Theme, width: number): string[] {
|
|
306
361
|
const snapshot = this.getSnapshot();
|
|
307
362
|
const overlayTasks = this.selectOverlayTasks(snapshot);
|
|
308
|
-
|
|
363
|
+
// Every state asks the host: runs bound to no task join the Other workers group, or its count.
|
|
364
|
+
const live = liveRows(this.query);
|
|
365
|
+
if (overlayTasks.length === 0 && !live?.size) {
|
|
309
366
|
this.finishFrame([]);
|
|
310
367
|
return [];
|
|
311
368
|
}
|
|
@@ -313,9 +370,8 @@ export class TodoOverlay {
|
|
|
313
370
|
overlayTasks.map((t) => [t.id, history(t.metadata?.herdr)] as const),
|
|
314
371
|
);
|
|
315
372
|
const hasRuns = [...bound.values()].some((h) => h.runs.length > 0);
|
|
316
|
-
|
|
317
|
-
const live
|
|
318
|
-
hasRuns && !this.collapsed ? liveRows(this.query) : undefined;
|
|
373
|
+
const boundIds = new Set([...bound.values()].flatMap((h) => h.runs.map((r) => r.id)));
|
|
374
|
+
const others = [...(live?.values() ?? [])].filter((r) => !boundIds.has(r.id));
|
|
319
375
|
|
|
320
376
|
const plan = planView(overlayTasks);
|
|
321
377
|
// Keep completed rows in their old slots; fill open slots in display order before budgeting.
|
|
@@ -328,7 +384,7 @@ export class TodoOverlay {
|
|
|
328
384
|
truncateToWidth(line, width, "…");
|
|
329
385
|
const counts = selectTodoCounts(overlayState);
|
|
330
386
|
const hasActive = selectHasActive(overlayState);
|
|
331
|
-
const showIds = !!live?.size || selectShowTaskIds(overlayState);
|
|
387
|
+
const showIds = (hasRuns && !!live?.size) || selectShowTaskIds(overlayState);
|
|
332
388
|
|
|
333
389
|
const headingColor = hasActive ? "accent" : "dim";
|
|
334
390
|
const headingIcon = hasActive ? "●" : "○";
|
|
@@ -340,26 +396,31 @@ export class TodoOverlay {
|
|
|
340
396
|
`${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, headingText)}${graph}`,
|
|
341
397
|
);
|
|
342
398
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
399
|
+
const draw: DrawContext = {
|
|
400
|
+
theme,
|
|
401
|
+
width,
|
|
402
|
+
truncate,
|
|
403
|
+
bound,
|
|
404
|
+
live,
|
|
405
|
+
others,
|
|
406
|
+
showIds,
|
|
407
|
+
now: Date.now(),
|
|
408
|
+
evidence: this.evidence(),
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// Collapsed view: just the heading + a dim "└─" hint naming the next state,
|
|
412
|
+
// after the count of other workers, then the trailing spacer. Short-circuit
|
|
413
|
+
// before the budget math and the completed-display tracking — nothing is
|
|
414
|
+
// shown to track, and skipping the tracking when nothing is rendered is
|
|
415
|
+
// correctness, not optimization. The "off" sentinel is reachable here
|
|
416
|
+
// mid-session (config edited after the shortcut was bound and the overlay
|
|
417
|
+
// collapsed) — render a static collapsed label instead of advertising an
|
|
418
|
+
// unbound key. Nothing is claimed; the tick keeps the count current.
|
|
419
|
+
if (this.current() === "collapsed") {
|
|
420
|
+
this.finishFrame([], others.length > 0);
|
|
421
|
+
const hint = this.keyHint() ?? t("overlay.collapsed", OVERLAY_COLLAPSED);
|
|
422
|
+
const count = others.length ? `+${formatWorkerCount(others.length)}` : undefined;
|
|
423
|
+
return this.withTrailingSpacer([heading, this.closingRow(draw, count, hint)]);
|
|
363
424
|
}
|
|
364
425
|
|
|
365
426
|
// Budget for content rows below the heading (tasks, run rows, summary). The
|
|
@@ -371,18 +432,8 @@ export class TodoOverlay {
|
|
|
371
432
|
this.uiCtx?.getToolsExpanded?.() === true
|
|
372
433
|
? Infinity
|
|
373
434
|
: getMaxWidgetLines() - 1;
|
|
374
|
-
const draw: DrawContext = {
|
|
375
|
-
theme,
|
|
376
|
-
width,
|
|
377
|
-
truncate,
|
|
378
|
-
bound,
|
|
379
|
-
live,
|
|
380
|
-
showIds,
|
|
381
|
-
now: Date.now(),
|
|
382
|
-
evidence: this.evidence(),
|
|
383
|
-
};
|
|
384
435
|
const body =
|
|
385
|
-
|
|
436
|
+
this.current() === "full"
|
|
386
437
|
? this.fullBody(overlayState, plan, bodyBudget, draw)
|
|
387
438
|
: this.focusBody(overlayTasks, plan, bodyBudget, draw);
|
|
388
439
|
|
|
@@ -400,50 +451,77 @@ export class TodoOverlay {
|
|
|
400
451
|
return this.withTrailingSpacer([heading, ...body]);
|
|
401
452
|
}
|
|
402
453
|
|
|
403
|
-
/** The whole dependency tree, budgeted by selectOverlayLayout (the `"full"` view). */
|
|
454
|
+
/** The whole dependency tree, budgeted by selectOverlayLayout (the `"full"` view), then the Other workers group. */
|
|
404
455
|
private fullBody(
|
|
405
456
|
overlayState: { tasks: Task[]; nextId: number },
|
|
406
457
|
plan: ReturnType<typeof planView>,
|
|
407
458
|
bodyBudget: number,
|
|
408
459
|
draw: DrawContext,
|
|
409
460
|
): string[] {
|
|
410
|
-
const { theme, truncate } = draw;
|
|
411
461
|
const layout = selectOverlayLayout(overlayState, bodyBudget);
|
|
412
462
|
const overflow = layout.hiddenCompleted + layout.truncatedTail;
|
|
413
|
-
const
|
|
463
|
+
const hint = this.keyHint();
|
|
464
|
+
const others = draw.others.length;
|
|
465
|
+
// With nothing to summarize, the hint takes its own row only when one is spare.
|
|
466
|
+
const needed =
|
|
467
|
+
layout.visible.reduce((n, task) => n + 1 + this.children(task, draw).length, 0) +
|
|
468
|
+
(others ? 1 + others : 0);
|
|
469
|
+
const hintRow = overflow === 0 && hint !== undefined && needed < bodyBudget;
|
|
470
|
+
let spare = bodyBudget - layout.visible.length - Number(overflow > 0 || hintRow);
|
|
471
|
+
// The group gets the rows the bound runs leave; a group cut short needs the summary row.
|
|
472
|
+
let rest = spare - this.boundRows(layout.visible, spare, draw);
|
|
473
|
+
let summarized = overflow > 0;
|
|
474
|
+
let group = others;
|
|
475
|
+
if (1 + others > rest) {
|
|
476
|
+
if (!summarized && rest > 0) {
|
|
477
|
+
summarized = true;
|
|
478
|
+
rest--;
|
|
479
|
+
}
|
|
480
|
+
group = groupFit(rest, others);
|
|
481
|
+
}
|
|
482
|
+
spare -= group ? 1 + group : 0;
|
|
483
|
+
const frame: Frame = { drawn: [], marked: new Map(), ticking: false };
|
|
414
484
|
const lines = this.drawTasks(
|
|
415
485
|
layout.visible.map((task) => ({ task, row: plan.rows.get(task.id) })),
|
|
416
486
|
spare,
|
|
417
|
-
|
|
487
|
+
!summarized && !hintRow && !group,
|
|
418
488
|
draw,
|
|
489
|
+
frame,
|
|
419
490
|
);
|
|
420
|
-
|
|
491
|
+
lines.push(...this.drawGroup(draw.others.slice(0, group), !summarized && !hintRow, draw, frame));
|
|
492
|
+
this.endFrame(frame, draw);
|
|
493
|
+
if (hintRow) lines.push(this.closingRow(draw, undefined, hint));
|
|
494
|
+
if (!summarized) return lines;
|
|
421
495
|
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
overflowParts
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
496
|
+
const parts: string[] = [];
|
|
497
|
+
if (overflow > 0) {
|
|
498
|
+
const overflowParts: string[] = [];
|
|
499
|
+
if (layout.hiddenCompleted > 0)
|
|
500
|
+
overflowParts.push(
|
|
501
|
+
`${layout.hiddenCompleted} ${formatStatusLabel("completed")}`,
|
|
502
|
+
);
|
|
503
|
+
if (layout.truncatedTail > 0)
|
|
504
|
+
overflowParts.push(
|
|
505
|
+
`${layout.truncatedTail} ${formatStatusLabel("pending")}`,
|
|
506
|
+
);
|
|
507
|
+
const more = t("overlay.more", OVERLAY_MORE);
|
|
508
|
+
parts.push(
|
|
509
|
+
overflowParts.length > 0
|
|
510
|
+
? `+${overflow} ${more} (${overflowParts.join(", ")})`
|
|
511
|
+
: `+${overflow} ${more}`,
|
|
430
512
|
);
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
? `+${overflow} ${more} (${overflowParts.join(", ")})`
|
|
435
|
-
: `+${overflow} ${more}`;
|
|
436
|
-
lines.push(
|
|
437
|
-
truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", summary)}`),
|
|
438
|
-
);
|
|
513
|
+
}
|
|
514
|
+
if (group < others) parts.push(`${parts.length ? "" : "+"}${formatWorkerCount(others - group)}`);
|
|
515
|
+
lines.push(this.closingRow(draw, parts.join(t("overlay.separator", OVERLAY_SEPARATOR)), hint));
|
|
439
516
|
return lines;
|
|
440
517
|
}
|
|
441
518
|
|
|
442
519
|
/**
|
|
443
520
|
* The focus view (default): in-progress tasks with their runs, the next open
|
|
444
|
-
* tasks (two, or three when nothing is in progress),
|
|
445
|
-
* rows if room is left, and one summary row counting
|
|
446
|
-
*
|
|
521
|
+
* tasks (two, or three when nothing is in progress), the Other workers group,
|
|
522
|
+
* then this turn's completed rows if room is left, and one summary row counting
|
|
523
|
+
* whatever is hidden. Completed rows are drawn before the group but get rows
|
|
524
|
+
* after it. Rows are flat, so every unfinished blocker goes to the `⛓` tail.
|
|
447
525
|
*/
|
|
448
526
|
private focusBody(
|
|
449
527
|
overlayTasks: Task[],
|
|
@@ -451,28 +529,33 @@ export class TodoOverlay {
|
|
|
451
529
|
bodyBudget: number,
|
|
452
530
|
draw: DrawContext,
|
|
453
531
|
): string[] {
|
|
454
|
-
const { theme, truncate } = draw;
|
|
455
532
|
const inProgress = plan.ordered.filter((t) => t.status === "in_progress");
|
|
456
533
|
const pending = plan.ordered.filter((t) => t.status === "pending");
|
|
457
534
|
const completed = overlayTasks.filter((t) => t.status === "completed");
|
|
458
535
|
const next = pending.slice(0, inProgress.length ? 2 : 3);
|
|
459
536
|
const total = inProgress.length + pending.length + completed.length;
|
|
537
|
+
const others = draw.others.length;
|
|
460
538
|
|
|
461
539
|
// Task rows first, in priority order; runs take the spare rows in display order;
|
|
462
|
-
// completed rows get what is left. The summary row is reserved only when needed.
|
|
540
|
+
// the group and then completed rows get what is left. The summary row is reserved only when needed.
|
|
463
541
|
const fit = (slots: number) => {
|
|
464
542
|
const core = [...inProgress, ...next].slice(0, slots);
|
|
465
|
-
let spare = slots - core.length;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (n <= spare) spare -= n;
|
|
469
|
-
}
|
|
543
|
+
let spare = slots - core.length - this.boundRows(core, slots - core.length, draw);
|
|
544
|
+
const group = groupFit(spare, others);
|
|
545
|
+
spare -= group ? 1 + group : 0;
|
|
470
546
|
const done = completed.slice(0, spare);
|
|
471
|
-
|
|
547
|
+
const rows = core.length + done.length + (group ? 1 + group : 0);
|
|
548
|
+
return { core, done, group, spare: slots - rows, left: spare - done.length };
|
|
472
549
|
};
|
|
473
550
|
let shown = fit(bodyBudget);
|
|
474
|
-
|
|
551
|
+
const summarized =
|
|
552
|
+
shown.core.length + shown.done.length < total || shown.group < others;
|
|
475
553
|
if (summarized) shown = fit(bodyBudget - 1);
|
|
554
|
+
// With nothing to summarize, the hint takes its own row only when one is spare;
|
|
555
|
+
// one row less leaves the same layout then.
|
|
556
|
+
const hint = this.keyHint();
|
|
557
|
+
const hintRow = !summarized && hint !== undefined && shown.left > 0;
|
|
558
|
+
if (hintRow) shown = { ...shown, spare: shown.spare - 1 };
|
|
476
559
|
|
|
477
560
|
const openIds = new Set(plan.ordered.map((t) => t.id));
|
|
478
561
|
const flat = (task: Task): PlanRow | undefined => {
|
|
@@ -485,12 +568,17 @@ export class TodoOverlay {
|
|
|
485
568
|
}
|
|
486
569
|
: undefined;
|
|
487
570
|
};
|
|
571
|
+
const frame: Frame = { drawn: [], marked: new Map(), ticking: false };
|
|
488
572
|
const lines = this.drawTasks(
|
|
489
573
|
[...shown.core, ...shown.done].map((task) => ({ task, row: flat(task) })),
|
|
490
574
|
shown.spare,
|
|
491
|
-
!summarized,
|
|
575
|
+
!summarized && !hintRow && !shown.group,
|
|
492
576
|
draw,
|
|
577
|
+
frame,
|
|
493
578
|
);
|
|
579
|
+
lines.push(...this.drawGroup(draw.others.slice(0, shown.group), !summarized && !hintRow, draw, frame));
|
|
580
|
+
this.endFrame(frame, draw);
|
|
581
|
+
if (hintRow) lines.push(this.closingRow(draw, undefined, hint));
|
|
494
582
|
if (!summarized) return lines;
|
|
495
583
|
|
|
496
584
|
const isShown = new Set([...shown.core, ...shown.done]);
|
|
@@ -504,10 +592,9 @@ export class TodoOverlay {
|
|
|
504
592
|
)
|
|
505
593
|
.filter(([n]) => n > 0)
|
|
506
594
|
.map(([n, status]) => `${n} ${formatStatusLabel(status)}`);
|
|
595
|
+
if (shown.group < others) parts.push(formatWorkerCount(others - shown.group));
|
|
507
596
|
const summary = `+${parts.join(t("overlay.separator", OVERLAY_SEPARATOR))}`;
|
|
508
|
-
lines.push(
|
|
509
|
-
truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", summary)}`),
|
|
510
|
-
);
|
|
597
|
+
lines.push(this.closingRow(draw, summary, hint));
|
|
511
598
|
return lines;
|
|
512
599
|
}
|
|
513
600
|
|
|
@@ -517,22 +604,73 @@ export class TodoOverlay {
|
|
|
517
604
|
return runs.flatMap((r) => draw.live?.get(r.id) ?? []);
|
|
518
605
|
}
|
|
519
606
|
|
|
607
|
+
/** Rows the tasks' runs take from `spare`, given in display order to each task whose runs all fit, as drawTasks does. */
|
|
608
|
+
private boundRows(tasks: readonly Task[], spare: number, draw: DrawContext): number {
|
|
609
|
+
let used = 0;
|
|
610
|
+
for (const task of tasks) {
|
|
611
|
+
const n = this.children(task, draw).length;
|
|
612
|
+
if (used + n <= spare) used += n;
|
|
613
|
+
}
|
|
614
|
+
return used;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** End the frame's claim bookkeeping; a group folded into the summary keeps the tick so its count stays current. */
|
|
618
|
+
private endFrame(frame: Frame, draw: DrawContext) {
|
|
619
|
+
this.finishFrame(frame.drawn, frame.ticking || draw.others.length > 0, frame.marked);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* One run row under `branch`. A run waiting for a reply stands out; idle and
|
|
624
|
+
* running rows stay dim, and so does the tree. Only a row shown in full is
|
|
625
|
+
* claimed; a truncated one carries no marker.
|
|
626
|
+
*/
|
|
627
|
+
private drawRun(lines: string[], r: RunRow, branch: string, draw: DrawContext, frame: Frame) {
|
|
628
|
+
const { theme, width, truncate, now, evidence } = draw;
|
|
629
|
+
const line =
|
|
630
|
+
runState(r) === "waiting"
|
|
631
|
+
? theme.fg("dim", branch) + theme.fg("warning", runLine(r, now))
|
|
632
|
+
: theme.fg("dim", branch + runLine(r, now));
|
|
633
|
+
const whole = visibleWidth(line) <= width;
|
|
634
|
+
frame.ticking = true;
|
|
635
|
+
if (whole && evidence === "screen") {
|
|
636
|
+
const marked = line + this.marker(r.id);
|
|
637
|
+
frame.marked.set(r.id, marked);
|
|
638
|
+
lines.push(marked);
|
|
639
|
+
} else {
|
|
640
|
+
lines.push(truncate(line));
|
|
641
|
+
if (whole && evidence === "inline") frame.drawn.push(r.id);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* The Other workers group: a heading row, then this session's runs bound to no
|
|
647
|
+
* task, drawn and claimed like bound run rows. `closed` means it ends the panel.
|
|
648
|
+
*/
|
|
649
|
+
private drawGroup(runs: RunRow[], closed: boolean, draw: DrawContext, frame: Frame): string[] {
|
|
650
|
+
if (!runs.length) return [];
|
|
651
|
+
const { theme, truncate } = draw;
|
|
652
|
+
const lines = [
|
|
653
|
+
truncate(`${theme.fg("dim", closed ? "└─" : "├─")} ${theme.fg("muted", t("overlay.others", OVERLAY_OTHERS))}`),
|
|
654
|
+
];
|
|
655
|
+
for (const [j, r] of runs.entries())
|
|
656
|
+
this.drawRun(lines, r, `${closed ? " " : "│"} ${j === runs.length - 1 ? "└" : "├"} `, draw, frame);
|
|
657
|
+
return lines;
|
|
658
|
+
}
|
|
659
|
+
|
|
520
660
|
/**
|
|
521
661
|
* Draw task rows and, where `spare` rows remain, their run rows; a task whose
|
|
522
|
-
* runs do not fit shows `· N runs`.
|
|
523
|
-
*
|
|
662
|
+
* runs do not fit shows `· N runs`. `closed` means nothing follows, so the last
|
|
663
|
+
* task row takes `└─`.
|
|
524
664
|
*/
|
|
525
665
|
private drawTasks(
|
|
526
666
|
entries: { task: Task; row?: PlanRow }[],
|
|
527
667
|
spare: number,
|
|
528
668
|
closed: boolean,
|
|
529
669
|
draw: DrawContext,
|
|
670
|
+
frame: Frame,
|
|
530
671
|
): string[] {
|
|
531
|
-
const { theme,
|
|
672
|
+
const { theme, truncate, live, showIds } = draw;
|
|
532
673
|
const lines: string[] = [];
|
|
533
|
-
const drawn: string[] = [];
|
|
534
|
-
let ticking = false;
|
|
535
|
-
const marked = new Map<string, string>();
|
|
536
674
|
for (const [i, { task, row }] of entries.entries()) {
|
|
537
675
|
const { older } = draw.bound.get(task.id) ?? history(undefined);
|
|
538
676
|
const children = this.children(task, draw);
|
|
@@ -552,28 +690,10 @@ export class TodoOverlay {
|
|
|
552
690
|
);
|
|
553
691
|
if (!fits) continue;
|
|
554
692
|
spare -= children.length;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
// A run waiting for a reply stands out; idle and running rows stay dim. The tree stays dim.
|
|
559
|
-
const childLine =
|
|
560
|
-
runState(r) === "waiting"
|
|
561
|
-
? theme.fg("dim", branch) + theme.fg("warning", runLine(r, now))
|
|
562
|
-
: theme.fg("dim", branch + runLine(r, now));
|
|
563
|
-
const whole = visibleWidth(childLine) <= width;
|
|
564
|
-
ticking = true;
|
|
565
|
-
// Only a row shown in full is claimed; a truncated one carries no marker.
|
|
566
|
-
if (whole && evidence === "screen") {
|
|
567
|
-
const line = childLine + this.marker(r.id);
|
|
568
|
-
marked.set(r.id, line);
|
|
569
|
-
lines.push(line);
|
|
570
|
-
} else {
|
|
571
|
-
lines.push(truncate(childLine));
|
|
572
|
-
if (whole && evidence === "inline") drawn.push(r.id);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
693
|
+
const indent = " ".repeat(row?.depth ?? 0);
|
|
694
|
+
for (const [j, r] of children.entries())
|
|
695
|
+
this.drawRun(lines, r, `${last ? " " : "│"} ${indent}${j === children.length - 1 ? "└" : "├"} `, draw, frame);
|
|
575
696
|
}
|
|
576
|
-
this.finishFrame(drawn, ticking, marked);
|
|
577
697
|
return lines;
|
|
578
698
|
}
|
|
579
699
|
|
|
@@ -596,7 +716,7 @@ export class TodoOverlay {
|
|
|
596
716
|
this.widgetRegistered = false;
|
|
597
717
|
this.tui = undefined;
|
|
598
718
|
this.uiCtx = undefined;
|
|
599
|
-
this.
|
|
719
|
+
this.state = undefined;
|
|
600
720
|
this.resetCompletedDisplayState();
|
|
601
721
|
}
|
|
602
722
|
}
|
package/src/view/live-runs.ts
CHANGED
|
@@ -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[] };
|