pi-todo-ledger 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/configuration.md +9 -5
- package/docs/overlay.md +35 -11
- package/package.json +1 -1
- package/src/config.ts +1 -1
- package/src/index.ts +3 -3
- package/src/locales/de.json +4 -1
- package/src/locales/en.json +4 -1
- package/src/locales/es.json +4 -1
- package/src/locales/fr.json +4 -1
- package/src/locales/pt-BR.json +4 -1
- package/src/locales/pt.json +4 -1
- package/src/locales/ru.json +4 -1
- package/src/locales/uk.json +4 -1
- package/src/locales/zh-TW.json +4 -1
- package/src/locales/zh.json +4 -1
- package/src/todo-overlay.ts +74 -36
package/README.md
CHANGED
|
@@ -117,9 +117,9 @@ Without one, the extension reads `rpiv-todo/config.json` from the same directori
|
|
|
117
117
|
|
|
118
118
|
| Setting | What it does | Default |
|
|
119
119
|
| --- | --- | --- |
|
|
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"` |
|
|
120
|
+
| `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
121
|
| `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
|
|
122
|
+
| `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
123
|
| `guidance` | Replaces the built-in instructions the extension gives the model about the todo list (`promptSnippet`, `promptGuidelines`). Needs `/reload`. | built-ins |
|
|
124
124
|
|
|
125
125
|
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
|
@@ -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:
|
|
@@ -42,9 +42,11 @@ Rows come in this order, until the row budget runs out:
|
|
|
42
42
|
4. completed tasks from the current turn, only if rows are left after the run rows;
|
|
43
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.
|
|
44
44
|
|
|
45
|
+
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
|
+
|
|
45
47
|
`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
48
|
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.
|
|
49
|
+
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
50
|
|
|
49
51
|
## Anatomy of a row
|
|
50
52
|
|
|
@@ -56,7 +58,8 @@ The full view (`"view": "full"`) draws the whole dependency tree:
|
|
|
56
58
|
├─ ○ #3 API
|
|
57
59
|
├─ ○ #4 Check API
|
|
58
60
|
├─ ○ #5 UI
|
|
59
|
-
|
|
61
|
+
├─ ⏸ #2 Approve waits Pat
|
|
62
|
+
└─ ctrl+shift+t collapse
|
|
60
63
|
```
|
|
61
64
|
|
|
62
65
|
- **Heading** — `● Todos (done/total)` in the accent color while any task is
|
|
@@ -122,16 +125,37 @@ completed. At the start of the next agent turn, every completed row that has
|
|
|
122
125
|
already been displayed is hidden from later renders. Reloading or compacting the
|
|
123
126
|
session resets that tracking, so a fresh session shows the full list again.
|
|
124
127
|
|
|
125
|
-
##
|
|
128
|
+
## Switching views
|
|
129
|
+
|
|
130
|
+
`ctrl+shift+t` steps the panel through three states, always in this order:
|
|
131
|
+
|
|
132
|
+
1. focus view;
|
|
133
|
+
2. full view;
|
|
134
|
+
3. collapsed: the heading and one dim hint row, `└─ ctrl+shift+t focus`.
|
|
135
|
+
|
|
136
|
+
The panel starts in the state `view` names, `"focus"` unless you set `"full"`,
|
|
137
|
+
and the next press continues the cycle from there: from `"full"` it goes to
|
|
138
|
+
collapsed, then focus, then full again. The chosen state holds until the next
|
|
139
|
+
press or the end of the session.
|
|
140
|
+
|
|
141
|
+
Each state shows a dim hint naming the key and the next state: `ctrl+shift+t
|
|
142
|
+
full`, `ctrl+shift+t collapse`, `ctrl+shift+t focus` (`完整`, `收合`, `焦點` in
|
|
143
|
+
zh-TW). In the focus and full views the hint ends the summary row after a ` · `.
|
|
144
|
+
It is the first thing cut when the row is too narrow. With nothing to summarize,
|
|
145
|
+
the hint takes its own closing `└─` row, and only when the row budget has a row
|
|
146
|
+
to spare, so it never pushes a task out. The hint always shows the configured
|
|
147
|
+
key.
|
|
126
148
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
the
|
|
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
|
|
151
|
+
claims the run rows it actually paints, as described under
|
|
152
|
+
[Worker runs under a task](#worker-runs-under-a-task).
|
|
130
153
|
|
|
131
154
|
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
|
|
155
|
+
[configuration.md](./configuration.md#collapsekey). With `"off"` no hint is
|
|
156
|
+
shown. If the shortcut is set to `"off"` while the panel is collapsed, the
|
|
157
|
+
collapsed row becomes a static `collapsed` label rather than advertising an
|
|
158
|
+
unbindable key.
|
|
135
159
|
|
|
136
160
|
## `/todos`
|
|
137
161
|
|
|
@@ -155,7 +179,7 @@ tasks. Tombstoned tasks are never listed.
|
|
|
155
179
|
|
|
156
180
|
## Localization
|
|
157
181
|
|
|
158
|
-
The overlay heading, both summary rows, the
|
|
182
|
+
The overlay heading, both summary rows, the key hint, the `/todos`
|
|
159
183
|
section headers, and the status words all localize through
|
|
160
184
|
[`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n)
|
|
161
185
|
when that package is installed. Bundled locales: `de`, `en`, `es`, `fr`, `pt`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-todo-ledger",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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
|
@@ -200,7 +200,7 @@ export default function (
|
|
|
200
200
|
pi.events.emit(CHANGED_EVENT, toChangedEvent(id, getState(id)));
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
//
|
|
203
|
+
// Cycle hotkey for the todo overlay (focus → full → collapsed). The key is resolved once at
|
|
204
204
|
// factory scope from config (register-once contract: a config change needs
|
|
205
205
|
// `/reload` to re-bind, same as lane-switcher's env hotkey) and the binding is
|
|
206
206
|
// skipped entirely when collapseKey is "off". The handler closes over the
|
|
@@ -211,10 +211,10 @@ export default function (
|
|
|
211
211
|
const collapseKey = resolveCollapseKey();
|
|
212
212
|
if (collapseKey !== COLLAPSE_KEY_OFF) {
|
|
213
213
|
pi.registerShortcut(collapseKey as KeyId, {
|
|
214
|
-
description: "
|
|
214
|
+
description: "Cycle the todo overlay: focus, full, collapsed",
|
|
215
215
|
handler: (ctx) => {
|
|
216
216
|
if (!ctx.hasUI || !todoOverlay?.isRegistered()) return;
|
|
217
|
-
todoOverlay.
|
|
217
|
+
todoOverlay.cycleView();
|
|
218
218
|
},
|
|
219
219
|
});
|
|
220
220
|
}
|
package/src/locales/de.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Noch keine Todos. Bitte den Agenten, welche hinzuzufügen!",
|
package/src/locales/en.json
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
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": ", ",
|
|
12
15
|
|
package/src/locales/es.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Sin tareas aún. ¡Pídele al agente que añada algunas!",
|
package/src/locales/fr.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Pas encore de tâches. Demandez à l'agent d'en ajouter !",
|
package/src/locales/pt-BR.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Nenhuma tarefa ainda. Peça ao agente para adicionar algumas!",
|
package/src/locales/pt.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Sem tarefas ainda. Peça ao agente para adicionar algumas!",
|
package/src/locales/ru.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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
|
|
|
14
17
|
"command.no_todos": "Задач пока нет. Попросите агента добавить!",
|
package/src/locales/uk.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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
|
|
|
14
17
|
"command.no_todos": "Завдань поки немає. Попросіть агента додати!",
|
package/src/locales/zh-TW.json
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
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": "、",
|
|
11
14
|
"command.no_todos": "目前沒有待辦事項。",
|
package/src/locales/zh.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
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": "、",
|
|
14
17
|
|
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,6 +25,7 @@ import {
|
|
|
25
25
|
COLLAPSE_KEY_OFF,
|
|
26
26
|
getMaxWidgetLines,
|
|
27
27
|
getView,
|
|
28
|
+
type OverlayView,
|
|
28
29
|
resolveCollapseKey,
|
|
29
30
|
} from "./config.ts";
|
|
30
31
|
import { formatStatusLabel, t } from "./state/i18n-bridge.ts";
|
|
@@ -47,10 +48,17 @@ 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 = ", ";
|
|
53
54
|
|
|
55
|
+
/** What the panel shows: one of the two views, or the two-line collapsed state. */
|
|
56
|
+
type PanelState = OverlayView | "collapsed";
|
|
57
|
+
/** The cycle key's order, from any starting state. */
|
|
58
|
+
const NEXT_STATE: Record<PanelState, PanelState> = { focus: "full", full: "collapsed", collapsed: "focus" };
|
|
59
|
+
/** English names of the state the key goes to next, as the hint shows them. */
|
|
60
|
+
const NEXT_STATE_NAME: Record<PanelState, string> = { focus: "focus", full: "full", collapsed: "collapse" };
|
|
61
|
+
|
|
54
62
|
/** What one frame's row drawing needs, shared by the full and focus views. */
|
|
55
63
|
interface DrawContext {
|
|
56
64
|
theme: Theme;
|
|
@@ -70,7 +78,8 @@ export class TodoOverlay {
|
|
|
70
78
|
private completedTaskIdsPendingHide = new Set<number>();
|
|
71
79
|
private hiddenCompletedTaskIds = new Set<number>();
|
|
72
80
|
private lastNextId: number | undefined;
|
|
73
|
-
|
|
81
|
+
/** Set by the cycle key; until then the panel follows the configured `view`. */
|
|
82
|
+
private state?: PanelState;
|
|
74
83
|
|
|
75
84
|
private previous: string[] = [];
|
|
76
85
|
private claimed: string[] = [];
|
|
@@ -251,16 +260,46 @@ export class TodoOverlay {
|
|
|
251
260
|
this.tui?.requestRender();
|
|
252
261
|
}
|
|
253
262
|
|
|
254
|
-
|
|
255
|
-
this.
|
|
263
|
+
private current(): PanelState {
|
|
264
|
+
return this.state ?? getView();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** Step the panel to the next state: focus → full → collapsed → focus. */
|
|
268
|
+
cycleView(): void {
|
|
269
|
+
this.state = NEXT_STATE[this.current()];
|
|
256
270
|
// 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
|
|
271
|
+
if (this.state === "collapsed") this.finishFrame([]);
|
|
272
|
+
// Forced full redraw on every height step, mirroring the
|
|
259
273
|
// lane-dock's requestRender(shapeChanged); distinct from the non-forced
|
|
260
274
|
// requestRender() refresh paths in update()/hideCompletedTasksFromPreviousTurn().
|
|
261
275
|
this.tui?.requestRender(true);
|
|
262
276
|
}
|
|
263
277
|
|
|
278
|
+
/**
|
|
279
|
+
* The dim key hint naming the next state, e.g. `ctrl+shift+t full`, or
|
|
280
|
+
* undefined when the key is "off". The key is resolved per render; a config
|
|
281
|
+
* edit needs /reload to re-bind the actual shortcut.
|
|
282
|
+
*/
|
|
283
|
+
private keyHint(): string | undefined {
|
|
284
|
+
const key = resolveCollapseKey();
|
|
285
|
+
if (key === COLLAPSE_KEY_OFF) return undefined;
|
|
286
|
+
const next = NEXT_STATE[this.current()];
|
|
287
|
+
const name = t(`overlay.next.${next}`, NEXT_STATE_NAME[next]);
|
|
288
|
+
return t("overlay.keyHint", OVERLAY_KEY_HINT).replace(/\{(key|next)\}/g, (_m, k: string) => (k === "key" ? key : name));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The closing `└─` row: the summary, then ` · ` and the key hint when both fit
|
|
293
|
+
* the width (the hint is cut first), or the hint alone.
|
|
294
|
+
*/
|
|
295
|
+
private closingRow(draw: DrawContext, summary: string | undefined, hint: string | undefined): string {
|
|
296
|
+
const { theme, width, truncate } = draw;
|
|
297
|
+
const row = (text: string) => `${theme.fg("dim", "└─")} ${theme.fg("dim", text)}`;
|
|
298
|
+
if (summary === undefined) return truncate(row(hint ?? ""));
|
|
299
|
+
const both = hint ? row(`${summary} · ${hint}`) : undefined;
|
|
300
|
+
return both && visibleWidth(both) <= width ? both : truncate(row(summary));
|
|
301
|
+
}
|
|
302
|
+
|
|
264
303
|
isRegistered(): boolean {
|
|
265
304
|
return this.widgetRegistered;
|
|
266
305
|
}
|
|
@@ -315,7 +354,7 @@ export class TodoOverlay {
|
|
|
315
354
|
const hasRuns = [...bound.values()].some((h) => h.runs.length > 0);
|
|
316
355
|
// Ask the host only when some todo has bound runs and the tree is shown.
|
|
317
356
|
const live =
|
|
318
|
-
hasRuns &&
|
|
357
|
+
hasRuns && this.current() !== "collapsed" ? liveRows(this.query) : undefined;
|
|
319
358
|
|
|
320
359
|
const plan = planView(overlayTasks);
|
|
321
360
|
// Keep completed rows in their old slots; fill open slots in display order before budgeting.
|
|
@@ -340,22 +379,16 @@ export class TodoOverlay {
|
|
|
340
379
|
`${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, headingText)}${graph}`,
|
|
341
380
|
);
|
|
342
381
|
|
|
343
|
-
// Collapsed view: just the heading + a dim "└─"
|
|
344
|
-
// trailing spacer. Short-circuit before the budget math and the
|
|
345
|
-
// display tracking — nothing is shown to track, and skipping the
|
|
346
|
-
// when nothing is rendered is correctness, not optimization. The
|
|
347
|
-
// the resolved key into the {key} placeholder (per-render, like the row
|
|
348
|
-
// budget); a config edit needs /reload to re-bind the actual shortcut. The
|
|
382
|
+
// 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
|
|
349
386
|
// "off" sentinel is reachable here mid-session (config edited after the
|
|
350
387
|
// shortcut was bound and the overlay collapsed) — render a static collapsed
|
|
351
|
-
// label instead of
|
|
352
|
-
if (this.collapsed) {
|
|
388
|
+
// label instead of advertising an unbound key.
|
|
389
|
+
if (this.current() === "collapsed") {
|
|
353
390
|
this.finishFrame([]);
|
|
354
|
-
const
|
|
355
|
-
const hint =
|
|
356
|
-
key === COLLAPSE_KEY_OFF
|
|
357
|
-
? t("overlay.collapsed", OVERLAY_COLLAPSED)
|
|
358
|
-
: t("overlay.expandHint", OVERLAY_EXPAND_HINT).replace("{key}", key);
|
|
391
|
+
const hint = this.keyHint() ?? t("overlay.collapsed", OVERLAY_COLLAPSED);
|
|
359
392
|
return this.withTrailingSpacer([
|
|
360
393
|
heading,
|
|
361
394
|
truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", hint)}`),
|
|
@@ -382,7 +415,7 @@ export class TodoOverlay {
|
|
|
382
415
|
evidence: this.evidence(),
|
|
383
416
|
};
|
|
384
417
|
const body =
|
|
385
|
-
|
|
418
|
+
this.current() === "full"
|
|
386
419
|
? this.fullBody(overlayState, plan, bodyBudget, draw)
|
|
387
420
|
: this.focusBody(overlayTasks, plan, bodyBudget, draw);
|
|
388
421
|
|
|
@@ -407,16 +440,20 @@ export class TodoOverlay {
|
|
|
407
440
|
bodyBudget: number,
|
|
408
441
|
draw: DrawContext,
|
|
409
442
|
): string[] {
|
|
410
|
-
const { theme, truncate } = draw;
|
|
411
443
|
const layout = selectOverlayLayout(overlayState, bodyBudget);
|
|
412
444
|
const overflow = layout.hiddenCompleted + layout.truncatedTail;
|
|
413
|
-
const
|
|
445
|
+
const hint = this.keyHint();
|
|
446
|
+
// 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);
|
|
448
|
+
const hintRow = overflow === 0 && hint !== undefined && needed < bodyBudget;
|
|
449
|
+
const spare = bodyBudget - layout.visible.length - Number(overflow > 0 || hintRow);
|
|
414
450
|
const lines = this.drawTasks(
|
|
415
451
|
layout.visible.map((task) => ({ task, row: plan.rows.get(task.id) })),
|
|
416
452
|
spare,
|
|
417
|
-
overflow === 0,
|
|
453
|
+
overflow === 0 && !hintRow,
|
|
418
454
|
draw,
|
|
419
455
|
);
|
|
456
|
+
if (hintRow) lines.push(this.closingRow(draw, undefined, hint));
|
|
420
457
|
if (overflow === 0) return lines;
|
|
421
458
|
|
|
422
459
|
const overflowParts: string[] = [];
|
|
@@ -433,9 +470,7 @@ export class TodoOverlay {
|
|
|
433
470
|
overflowParts.length > 0
|
|
434
471
|
? `+${overflow} ${more} (${overflowParts.join(", ")})`
|
|
435
472
|
: `+${overflow} ${more}`;
|
|
436
|
-
lines.push(
|
|
437
|
-
truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", summary)}`),
|
|
438
|
-
);
|
|
473
|
+
lines.push(this.closingRow(draw, summary, hint));
|
|
439
474
|
return lines;
|
|
440
475
|
}
|
|
441
476
|
|
|
@@ -451,7 +486,6 @@ export class TodoOverlay {
|
|
|
451
486
|
bodyBudget: number,
|
|
452
487
|
draw: DrawContext,
|
|
453
488
|
): string[] {
|
|
454
|
-
const { theme, truncate } = draw;
|
|
455
489
|
const inProgress = plan.ordered.filter((t) => t.status === "in_progress");
|
|
456
490
|
const pending = plan.ordered.filter((t) => t.status === "pending");
|
|
457
491
|
const completed = overlayTasks.filter((t) => t.status === "completed");
|
|
@@ -468,11 +502,16 @@ export class TodoOverlay {
|
|
|
468
502
|
if (n <= spare) spare -= n;
|
|
469
503
|
}
|
|
470
504
|
const done = completed.slice(0, spare);
|
|
471
|
-
return { core, done, spare: slots - core.length - done.length };
|
|
505
|
+
return { core, done, spare: slots - core.length - done.length, left: spare - done.length };
|
|
472
506
|
};
|
|
473
507
|
let shown = fit(bodyBudget);
|
|
474
508
|
let summarized = shown.core.length + shown.done.length < total;
|
|
475
509
|
if (summarized) shown = fit(bodyBudget - 1);
|
|
510
|
+
// With nothing to summarize, the hint takes its own row only when one is spare;
|
|
511
|
+
// one row less leaves the same layout then.
|
|
512
|
+
const hint = this.keyHint();
|
|
513
|
+
const hintRow = !summarized && hint !== undefined && shown.left > 0;
|
|
514
|
+
if (hintRow) shown = { ...shown, spare: shown.spare - 1 };
|
|
476
515
|
|
|
477
516
|
const openIds = new Set(plan.ordered.map((t) => t.id));
|
|
478
517
|
const flat = (task: Task): PlanRow | undefined => {
|
|
@@ -488,9 +527,10 @@ export class TodoOverlay {
|
|
|
488
527
|
const lines = this.drawTasks(
|
|
489
528
|
[...shown.core, ...shown.done].map((task) => ({ task, row: flat(task) })),
|
|
490
529
|
shown.spare,
|
|
491
|
-
!summarized,
|
|
530
|
+
!summarized && !hintRow,
|
|
492
531
|
draw,
|
|
493
532
|
);
|
|
533
|
+
if (hintRow) lines.push(this.closingRow(draw, undefined, hint));
|
|
494
534
|
if (!summarized) return lines;
|
|
495
535
|
|
|
496
536
|
const isShown = new Set([...shown.core, ...shown.done]);
|
|
@@ -505,9 +545,7 @@ export class TodoOverlay {
|
|
|
505
545
|
.filter(([n]) => n > 0)
|
|
506
546
|
.map(([n, status]) => `${n} ${formatStatusLabel(status)}`);
|
|
507
547
|
const summary = `+${parts.join(t("overlay.separator", OVERLAY_SEPARATOR))}`;
|
|
508
|
-
lines.push(
|
|
509
|
-
truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", summary)}`),
|
|
510
|
-
);
|
|
548
|
+
lines.push(this.closingRow(draw, summary, hint));
|
|
511
549
|
return lines;
|
|
512
550
|
}
|
|
513
551
|
|
|
@@ -596,7 +634,7 @@ export class TodoOverlay {
|
|
|
596
634
|
this.widgetRegistered = false;
|
|
597
635
|
this.tui = undefined;
|
|
598
636
|
this.uiCtx = undefined;
|
|
599
|
-
this.
|
|
637
|
+
this.state = undefined;
|
|
600
638
|
this.resetCompletedDisplayState();
|
|
601
639
|
}
|
|
602
640
|
}
|