@zhuxixi/pi-agent-board 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +15 -8
- package/docs/SECTION_FOLDING.md +53 -0
- package/docs/superpowers/plans/2026-10-23-issue-222-attach-ready.md +290 -0
- package/docs/superpowers/plans/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup.md +256 -0
- package/docs/superpowers/plans/2026-11-03-cwd-favorites-full-pool.md +266 -0
- package/docs/superpowers/plans/2026-11-03-issue-266-alt-h-detach.md +467 -0
- package/docs/superpowers/plans/2026-11-04-issue-270-scenario-stdout-flush.md +584 -0
- package/docs/superpowers/plans/2026-11-05-issue-278-ctrl-g-external-editor.md +381 -0
- package/docs/superpowers/plans/2026-11-06-issue-280-frame-witness-delivery.md +430 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-attach-recovery.md +115 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-u1-u2-trial-guide.md +39 -0
- package/docs/superpowers/plans/2026-11-08-host-restart-model-override.md +894 -0
- package/docs/superpowers/plans/2026-11-08-issue-288-cap-floor.md +51 -0
- package/docs/superpowers/plans/2026-11-09-dashboard-fold-flake.md +166 -0
- package/docs/superpowers/plans/2026-11-09-issue-273-harness-console-log-exit.md +369 -0
- package/docs/superpowers/plans/2026-11-10-issue-258-board-selection-settle.md +760 -0
- package/docs/superpowers/plans/2026-11-13-issue-294-snapshot-resize-intent.md +590 -0
- package/docs/superpowers/plans/2026-11-16-greeting-title-poll.md +838 -0
- package/docs/superpowers/plans/2026-11-22-issue-297-compaction-mirror.md +797 -0
- package/docs/superpowers/plans/2026-11-23-issue-254-cursor-keep-position.md +663 -0
- package/docs/superpowers/plans/2026-11-23-issue-95-legacy-quarantine.md +320 -0
- package/docs/superpowers/specs/2026-10-23-issue-222-attach-ready-design.md +204 -0
- package/docs/superpowers/specs/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup-design.md +197 -0
- package/docs/superpowers/specs/2026-11-03-cwd-favorites-full-pool-design.md +106 -0
- package/docs/superpowers/specs/2026-11-03-issue-266-alt-h-detach-design.md +185 -0
- package/docs/superpowers/specs/2026-11-04-issue-270-scenario-stdout-flush-design.md +176 -0
- package/docs/superpowers/specs/2026-11-05-issue-278-ctrl-g-external-editor-design.md +185 -0
- package/docs/superpowers/specs/2026-11-07-issue-284-attach-recovery-design.md +166 -0
- package/docs/superpowers/specs/2026-11-08-host-restart-model-override-design.md +115 -0
- package/docs/superpowers/specs/2026-11-08-issue-288-cap-floor-design.md +86 -0
- package/docs/superpowers/specs/2026-11-09-dashboard-fold-flake-design.md +109 -0
- package/docs/superpowers/specs/2026-11-09-issue-273-harness-console-log-exit-design.md +182 -0
- package/docs/superpowers/specs/2026-11-10-issue-258-board-selection-settle-design.md +109 -0
- package/docs/superpowers/specs/2026-11-13-issue-294-snapshot-resize-intent-design.md +141 -0
- package/docs/superpowers/specs/2026-11-16-greeting-title-poll-design.md +174 -0
- package/docs/superpowers/specs/2026-11-22-issue-297-compaction-mirror-design.md +158 -0
- package/docs/superpowers/specs/2026-11-22-issue-95-legacy-quarantine-design.md +209 -0
- package/docs/superpowers/specs/2026-11-23-issue-254-cursor-keep-position-design.md +201 -0
- package/package.json +1 -1
- package/runner/pty-runner.mjs +526 -63
- package/runner/title-runner.mjs +33 -24
- package/src/commands/agent-board.ts +5 -1
- package/src/core/attach-detach.mjs +27 -0
- package/src/core/attach-frame-proof.mjs +897 -0
- package/src/core/attach-frame-reporter.mjs +738 -0
- package/src/core/attach-frame-stream.mjs +266 -0
- package/src/core/attach-pr-label.mjs +12 -0
- package/src/core/attach-recovery.mjs +239 -0
- package/src/core/attach-screen-owner.mjs +55 -0
- package/src/core/attach-view-proof.mjs +709 -0
- package/src/core/auto-state.mjs +6 -1
- package/src/core/cwd-stats.mjs +3 -1
- package/src/core/dashboard-prefs.mjs +31 -0
- package/src/core/derive.mjs +8 -1
- package/src/core/events.mjs +127 -1
- package/src/core/foreground-projection-cache.mjs +1 -0
- package/src/core/frame-witness-update.mjs +35 -0
- package/src/core/fullscreen-selection.mjs +60 -0
- package/src/core/host-protocol.mjs +13 -2
- package/src/core/hosted-frame-witness.mjs +60 -0
- package/src/core/paths.mjs +10 -3
- package/src/core/pty-attach-render.mjs +239 -0
- package/src/core/pty-kitty-images.mjs +237 -0
- package/src/core/rows.mjs +43 -7
- package/src/core/session-entries.mjs +82 -0
- package/src/core/session-launch-prefs.mjs +45 -0
- package/src/core/session-view.mjs +3 -63
- package/src/core/store.mjs +1 -0
- package/src/core/terminal-attach-client.mjs +199 -20
- package/src/core/terminal-attach-protocol.mjs +221 -7
- package/src/core/terminal-model.mjs +24 -3
- package/src/core/terminal-snapshot.mjs +10 -0
- package/src/core/title-flow.mjs +66 -0
- package/src/core/title.mjs +101 -0
- package/src/core/types.mjs +17 -0
- package/src/index.ts +85 -0
- package/src/runtime/service.mjs +87 -18
- package/src/ui/dashboard.ts +198 -44
- package/src/ui/pty-attach.ts +1462 -117
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
# Keep the Board Cursor in Place on Demote (issue #254) Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** After `h` (hold/unhold) or `d`+`y` (done) demotes a session, the dashboard cursor stays at the demoted row's visual slot instead of following the row into `ON HOLD`/`DONE`.
|
|
6
|
+
|
|
7
|
+
**Architecture:** A pure function `neighborAfterRemoval(orderedIds, removedIds, anchorId)` in `src/core/rows.mjs` computes the row that fills a vacated slot. `DashboardComponent` captures that anchor **before** the state command runs and applies it **after** `refresh()`, with an index-clamp fallback when the neighbor itself disappeared. Three call sites: `toggleHold`, `confirmDone`, `confirmDoneSelection`. Background-driven state migrations are untouched (they still follow).
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** TypeScript (`src/ui/dashboard.ts`), untyped ESM with JSDoc (`src/core/rows.mjs`), `node:test` + `assert/strict`, probe harness under `test-support/`.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-23-issue-254-cursor-keep-position-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Tabs for indentation; English comments and commit messages; conventional commit subjects with `(#N)` appended only when a PR exists.
|
|
16
|
+
- `src/core/rows.mjs` stays untyped JS with JSDoc `@param`/`@returns`; `tsconfig` has `allowJs` + `checkJs:false`.
|
|
17
|
+
- `dashboard.ts` imports from `../core/rows.mjs` through the existing named-import line — do not add a second import statement for the same module.
|
|
18
|
+
- Tests: `node:test` with `assert/strict`; anything touching the filesystem uses a temp dir (`mkdtempSync(join(tmpdir(), ...))`), never the host repo.
|
|
19
|
+
- Probes: `test-support/*.ts` run via `node --experimental-transform-types`, are excluded from `tsconfig`, construct the real `DashboardComponent` with `{ matches: () => false }` as keybindings, patch **both** `service.rows()` and `service.row(id)` when overriding row state, and print one JSON report with `console.log`.
|
|
20
|
+
- Never assign `selectedId` an id that is not in `orderedIds` — `refresh()` treats an invisible selection as "row vanished" and jumps to `orderedIds[0]`.
|
|
21
|
+
- No `git add -A`; stage the exact files named in each task.
|
|
22
|
+
- Acceptance IDs (`A1`–`A13`, `U1`) come from the spec; every task step names the IDs it proves.
|
|
23
|
+
|
|
24
|
+
## Review Focus
|
|
25
|
+
|
|
26
|
+
1. **Contiguous batch done at the end of the list** — nothing follows the block, so the cursor must land on the row above the block, not on a completed row from the block.
|
|
27
|
+
2. **Filter active during a demote** — the demoted row leaves the filtered result set; the cursor must land on the next surviving row, not jump to the top.
|
|
28
|
+
3. **Last row / only row** — last row selects the previous row; the only row stays selected (clamp path).
|
|
29
|
+
4. **Demoted row migrating into a folded section** — `refresh()` converts the selection into a section header; the anchor must restore a row selection and clear `selectedSection`.
|
|
30
|
+
5. **Failure paths** — `holdView` / `markCompleted` returning `{ok:false}`, and a batch that completed `0` rows, must leave the cursor exactly where it was.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### Task 1: `neighborAfterRemoval` pure function
|
|
35
|
+
|
|
36
|
+
**Files:**
|
|
37
|
+
- Modify: `src/core/rows.mjs:262-278` (insert after `nextVisibleIdAfterRemoval` and its JSDoc)
|
|
38
|
+
- Test: `test/rows.test.mjs` (append after the existing `nextVisibleIdAfterRemoval` test)
|
|
39
|
+
|
|
40
|
+
**Interfaces:**
|
|
41
|
+
- Consumes: nothing (pure, no imports).
|
|
42
|
+
- Produces: `neighborAfterRemoval(orderedIds: readonly string[], removedIds: Iterable<string>, anchorId: string): { neighborId: string | null, anchorIndex: number } | null` — `null` when `anchorId` is not in `orderedIds`.
|
|
43
|
+
|
|
44
|
+
- [ ] **Step 1: Write the failing test**
|
|
45
|
+
|
|
46
|
+
Append to `test/rows.test.mjs` (also add `neighborAfterRemoval` to the existing import list from `../src/core/rows.mjs`):
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
test("neighborAfterRemoval: same slot semantics as the delete helper (issue #254 A1)", () => {
|
|
50
|
+
const ids = ["a", "b", "c", "d"];
|
|
51
|
+
assert.deepEqual(neighborAfterRemoval(ids, ["b"], "b"), { neighborId: "c", anchorIndex: 1 }, "middle row -> next row");
|
|
52
|
+
assert.deepEqual(neighborAfterRemoval(ids, ["d"], "d"), { neighborId: "c", anchorIndex: 3 }, "last row -> previous row");
|
|
53
|
+
assert.deepEqual(neighborAfterRemoval(["a"], ["a"], "a"), { neighborId: null, anchorIndex: 0 }, "only row -> no neighbor, slot kept");
|
|
54
|
+
assert.equal(neighborAfterRemoval(ids, ["a"], "missing"), null, "unknown anchor -> null");
|
|
55
|
+
assert.deepEqual(
|
|
56
|
+
neighborAfterRemoval(ids, ["b", "c"], "b"),
|
|
57
|
+
{ neighborId: "d", anchorIndex: 1 },
|
|
58
|
+
"contiguous block -> first row after the block",
|
|
59
|
+
);
|
|
60
|
+
assert.deepEqual(
|
|
61
|
+
neighborAfterRemoval(ids, ["a", "b", "c", "d"], "a"),
|
|
62
|
+
{ neighborId: null, anchorIndex: 0 },
|
|
63
|
+
"every row removed -> no neighbor",
|
|
64
|
+
);
|
|
65
|
+
assert.deepEqual(
|
|
66
|
+
neighborAfterRemoval(["a", "b", "c"], new Set(["c"]), "c"),
|
|
67
|
+
{ neighborId: "b", anchorIndex: 2 },
|
|
68
|
+
"Set input works and block removal prefers the previous surviving row",
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- [ ] **Step 2: Run the test to verify it fails**
|
|
74
|
+
|
|
75
|
+
Run: `node --test test/rows.test.mjs`
|
|
76
|
+
Expected: FAIL — `neighborAfterRemoval is not a function` (module import resolves to `undefined`).
|
|
77
|
+
|
|
78
|
+
- [ ] **Step 3: Implement the function**
|
|
79
|
+
|
|
80
|
+
Insert **after** the closing brace of `nextVisibleIdAfterRemoval` in `src/core/rows.mjs`:
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
/**
|
|
84
|
+
* Issue #254: the row the board should select after `removedIds` leave their
|
|
85
|
+
* current positions. Mirrors the issue #147 delete semantics — the next visible
|
|
86
|
+
* row after the anchor's slot, else the previous one, else null — but works on
|
|
87
|
+
* the dashboard's already-filtered, already-folded order.
|
|
88
|
+
* @param {readonly string[]} orderedIds visible row ids in board order
|
|
89
|
+
* @param {Iterable<string>} removedIds ids that will leave their positions
|
|
90
|
+
* @param {string} anchorId the id whose slot must be kept
|
|
91
|
+
* @returns {{ neighborId: string | null, anchorIndex: number } | null} null when anchorId is not visible
|
|
92
|
+
*/
|
|
93
|
+
export function neighborAfterRemoval(orderedIds, removedIds, anchorId) {
|
|
94
|
+
const anchorIndex = orderedIds.indexOf(anchorId);
|
|
95
|
+
if (anchorIndex === -1) return null;
|
|
96
|
+
const removed = removedIds instanceof Set ? removedIds : new Set(removedIds);
|
|
97
|
+
for (let i = anchorIndex + 1; i < orderedIds.length; i += 1) {
|
|
98
|
+
if (!removed.has(orderedIds[i])) return { neighborId: orderedIds[i], anchorIndex };
|
|
99
|
+
}
|
|
100
|
+
for (let i = anchorIndex - 1; i >= 0; i -= 1) {
|
|
101
|
+
if (!removed.has(orderedIds[i])) return { neighborId: orderedIds[i], anchorIndex };
|
|
102
|
+
}
|
|
103
|
+
return { neighborId: null, anchorIndex };
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- [ ] **Step 4: Run the test to verify it passes**
|
|
108
|
+
|
|
109
|
+
Run: `node --test test/rows.test.mjs`
|
|
110
|
+
Expected: PASS, including the pre-existing `nextVisibleIdAfterRemoval: neighbor semantics (issue #147 A2)` test.
|
|
111
|
+
|
|
112
|
+
- [ ] **Step 5: Commit**
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
git add src/core/rows.mjs test/rows.test.mjs
|
|
116
|
+
git commit -m "feat(core): add neighborAfterRemoval for keeping the board slot (issue #254)"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### Task 2: Anchor plumbing + `h` (hold / unhold) entry
|
|
122
|
+
|
|
123
|
+
**Files:**
|
|
124
|
+
- Modify: `src/ui/dashboard.ts` (import line, a local type near the other type aliases, two private methods after `refresh()`, `toggleHold()` at ~1076-1087)
|
|
125
|
+
- Create: `test-support/dashboard-position-keep-probe.ts`
|
|
126
|
+
- Create: `test/dashboard-position-keep.test.mjs`
|
|
127
|
+
|
|
128
|
+
**Interfaces:**
|
|
129
|
+
- Consumes: `neighborAfterRemoval` from Task 1.
|
|
130
|
+
- Produces: private `capturePositionAnchor(id: string, removedIds?: string[]): PositionAnchor | null` and private `applyPositionAnchor(anchor: PositionAnchor | null): void`; probe report keys `holdMiddle`, `holdLast`, `holdOnly`, `unhold`, `holdFailed`, `holdFiltered`, `holdPeek`, `backgroundFollow`.
|
|
131
|
+
|
|
132
|
+
- [ ] **Step 1: Write the failing probe and test**
|
|
133
|
+
|
|
134
|
+
Create `test-support/dashboard-position-keep-probe.ts`:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Position-keep probe (issue #254): drive the hold / done gestures through the
|
|
138
|
+
// public handleInput() and report where the cursor lands. One run feeds every
|
|
139
|
+
// assertion in test/dashboard-position-keep.test.mjs.
|
|
140
|
+
// Run via `node --experimental-transform-types` (dashboard.ts uses TS
|
|
141
|
+
// parameter properties). Not typechecked (tsconfig excludes test-support).
|
|
142
|
+
import { mkdtempSync } from "node:fs";
|
|
143
|
+
import { tmpdir } from "node:os";
|
|
144
|
+
import { join } from "node:path";
|
|
145
|
+
import { createService } from "../src/runtime/service.mjs";
|
|
146
|
+
import { createView } from "../src/core/store.mjs";
|
|
147
|
+
import { DashboardComponent } from "../src/ui/dashboard.ts";
|
|
148
|
+
|
|
149
|
+
type Env = {
|
|
150
|
+
service: ReturnType<typeof createService>;
|
|
151
|
+
root: string;
|
|
152
|
+
dash: DashboardComponent;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const tui = {
|
|
156
|
+
terminal: { rows: 24, cols: 240, columns: 240, write: () => {} },
|
|
157
|
+
requestRender: () => {},
|
|
158
|
+
};
|
|
159
|
+
const theme = { fg: (_c: string, t: string) => t, bold: (t: string) => t, bg: (_c: string, t: string) => t };
|
|
160
|
+
|
|
161
|
+
type Priv = {
|
|
162
|
+
mode: string;
|
|
163
|
+
selectedId: string | null;
|
|
164
|
+
selectedSection: string | null;
|
|
165
|
+
peekId: string | null;
|
|
166
|
+
orderedIds: string[];
|
|
167
|
+
filterQuery: string;
|
|
168
|
+
flash: { text: string; level: string } | null;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
function priv(dash: DashboardComponent): Priv {
|
|
172
|
+
return dash as unknown as Priv;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Every scenario gets its own root: seeding goes through the real service
|
|
176
|
+
// commands (clearHoldView / holdView), so the disk state stays the source of
|
|
177
|
+
// truth and nothing has to be faked in the row view.
|
|
178
|
+
async function makeEnv(count: number): Promise<Env> {
|
|
179
|
+
const root = mkdtempSync(join(tmpdir(), "agentview-position-keep-"));
|
|
180
|
+
const ids = Array.from({ length: count }, (_, i) => `v${i + 1}`);
|
|
181
|
+
for (const id of ids) createView(root, { id, name: id, cwd: root });
|
|
182
|
+
const service = createService({
|
|
183
|
+
root,
|
|
184
|
+
runnerScript: "/no/runner.mjs",
|
|
185
|
+
piCommand: "pi",
|
|
186
|
+
piArgsPrefix: [],
|
|
187
|
+
defaultCwd: root,
|
|
188
|
+
launch: () => ({ pid: null, configPath: "/no/config.json" }),
|
|
189
|
+
launchHost: () => ({ pid: null, configPath: "/no/host-config.json" }),
|
|
190
|
+
launchTitle: () => ({ pid: null, configPath: "/no/title-config.json" }),
|
|
191
|
+
});
|
|
192
|
+
for (const id of ids) {
|
|
193
|
+
const res = await service.clearHoldView(id);
|
|
194
|
+
if (!res.ok) throw new Error(`seed idle failed for ${id}: ${res.error}`);
|
|
195
|
+
}
|
|
196
|
+
const dash = new DashboardComponent(tui as never, theme as never, { matches: () => false } as never, () => {}, {
|
|
197
|
+
service,
|
|
198
|
+
root,
|
|
199
|
+
defaultCwd: root,
|
|
200
|
+
availableModels: [],
|
|
201
|
+
currentModel: null,
|
|
202
|
+
currentThinkingLevel: "off",
|
|
203
|
+
} as never);
|
|
204
|
+
return { service, root, dash };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Point the cursor at a row without depending on navigation order. */
|
|
208
|
+
function select(dash: DashboardComponent, id: string): void {
|
|
209
|
+
priv(dash).selectedId = id;
|
|
210
|
+
priv(dash).selectedSection = null;
|
|
211
|
+
dash.refresh();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function waitFor(pred: () => boolean, ms = 5000): Promise<boolean> {
|
|
215
|
+
const start = Date.now();
|
|
216
|
+
while (Date.now() - start < ms) {
|
|
217
|
+
if (pred()) return true;
|
|
218
|
+
await new Promise((r) => setTimeout(r, 10));
|
|
219
|
+
}
|
|
220
|
+
return pred();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function cursor(dash: DashboardComponent, extra: Record<string, unknown> = {}): Record<string, unknown> {
|
|
224
|
+
const p = priv(dash);
|
|
225
|
+
return { selectedId: p.selectedId, orderedIds: [...p.orderedIds], mode: p.mode, ...extra };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const report: Record<string, unknown> = {};
|
|
229
|
+
|
|
230
|
+
// A2: h on a middle row keeps the slot; the row below takes the cursor.
|
|
231
|
+
{
|
|
232
|
+
const env = await makeEnv(5);
|
|
233
|
+
select(env.dash, "v3");
|
|
234
|
+
env.dash.handleInput("h");
|
|
235
|
+
await waitFor(() => priv(env.dash).selectedId === "v4");
|
|
236
|
+
report.holdMiddle = cursor(env.dash, { demotedId: "v3" });
|
|
237
|
+
env.dash.dispose();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// A3: h on the last row selects the previous row.
|
|
241
|
+
{
|
|
242
|
+
const env = await makeEnv(5);
|
|
243
|
+
select(env.dash, "v5");
|
|
244
|
+
env.dash.handleInput("h");
|
|
245
|
+
await waitFor(() => priv(env.dash).selectedId === "v4");
|
|
246
|
+
report.holdLast = cursor(env.dash, { demotedId: "v5" });
|
|
247
|
+
env.dash.dispose();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// A4: h on the only row keeps it selected.
|
|
251
|
+
{
|
|
252
|
+
const env = await makeEnv(1);
|
|
253
|
+
select(env.dash, "v1");
|
|
254
|
+
env.dash.handleInput("h");
|
|
255
|
+
await waitFor(() => priv(env.dash).flash !== null);
|
|
256
|
+
report.holdOnly = cursor(env.dash, { demotedId: "v1" });
|
|
257
|
+
env.dash.dispose();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// A6: unhold keeps the slot too — the cursor must not stay on the resumed row.
|
|
261
|
+
{
|
|
262
|
+
const env = await makeEnv(4);
|
|
263
|
+
await env.service.holdView("v3");
|
|
264
|
+
await env.service.holdView("v4");
|
|
265
|
+
env.dash.refresh();
|
|
266
|
+
select(env.dash, "v3");
|
|
267
|
+
env.dash.handleInput("h");
|
|
268
|
+
await waitFor(() => priv(env.dash).selectedId === "v4");
|
|
269
|
+
report.unhold = cursor(env.dash, { demotedId: "v3" });
|
|
270
|
+
env.dash.dispose();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// A8 (h branch): a rejected hold leaves the cursor alone.
|
|
274
|
+
{
|
|
275
|
+
const env = await makeEnv(4);
|
|
276
|
+
select(env.dash, "v3");
|
|
277
|
+
env.service.holdView = (() => Promise.resolve({ ok: false, error: "boom" })) as typeof env.service.holdView;
|
|
278
|
+
env.dash.handleInput("h");
|
|
279
|
+
await waitFor(() => priv(env.dash).flash !== null);
|
|
280
|
+
report.holdFailed = cursor(env.dash, { notice: priv(env.dash).flash?.text ?? null });
|
|
281
|
+
env.dash.dispose();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// A9: filtering hides the demoted row; the next surviving row takes the cursor.
|
|
285
|
+
{
|
|
286
|
+
const env = await makeEnv(5);
|
|
287
|
+
priv(env.dash).filterQuery = "s:idle";
|
|
288
|
+
env.dash.refresh();
|
|
289
|
+
select(env.dash, "v3");
|
|
290
|
+
env.dash.handleInput("h");
|
|
291
|
+
await waitFor(() => priv(env.dash).selectedId === "v4");
|
|
292
|
+
report.holdFiltered = cursor(env.dash, { demotedId: "v3" });
|
|
293
|
+
env.dash.dispose();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// A10: peek keeps its own target; the list cursor still moves to the slot.
|
|
297
|
+
{
|
|
298
|
+
const env = await makeEnv(5);
|
|
299
|
+
select(env.dash, "v3");
|
|
300
|
+
env.dash.handleInput(" "); // space opens peek
|
|
301
|
+
env.dash.handleInput("h");
|
|
302
|
+
await waitFor(() => priv(env.dash).selectedId === "v4");
|
|
303
|
+
report.holdPeek = cursor(env.dash, { peekId: priv(env.dash).peekId, demotedId: "v3" });
|
|
304
|
+
env.dash.dispose();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// A11: a background transition (not driven by the dashboard) still follows.
|
|
308
|
+
{
|
|
309
|
+
const env = await makeEnv(5);
|
|
310
|
+
select(env.dash, "v3");
|
|
311
|
+
await env.service.markCompleted("v3");
|
|
312
|
+
env.dash.refresh();
|
|
313
|
+
report.backgroundFollow = cursor(env.dash, { movedId: "v3" });
|
|
314
|
+
env.dash.dispose();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
console.log(JSON.stringify(report));
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Create `test/dashboard-position-keep.test.mjs`:
|
|
321
|
+
|
|
322
|
+
```javascript
|
|
323
|
+
import assert from "node:assert/strict";
|
|
324
|
+
import { execFileSync } from "node:child_process";
|
|
325
|
+
import { fileURLToPath } from "node:url";
|
|
326
|
+
import { join } from "node:path";
|
|
327
|
+
import test from "node:test";
|
|
328
|
+
|
|
329
|
+
const ROOT_DIR = fileURLToPath(new URL("../", import.meta.url));
|
|
330
|
+
const PROBE = join(ROOT_DIR, "test-support", "dashboard-position-keep-probe.ts");
|
|
331
|
+
|
|
332
|
+
// One probe run feeds every assertion below.
|
|
333
|
+
const report = JSON.parse(
|
|
334
|
+
execFileSync(process.execPath, ["--experimental-transform-types", PROBE], {
|
|
335
|
+
encoding: "utf8",
|
|
336
|
+
timeout: 120_000,
|
|
337
|
+
}),
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
test("A2: h on a middle row keeps the slot — the row below takes the cursor", () => {
|
|
341
|
+
assert.equal(report.holdMiddle.demotedId, "v3");
|
|
342
|
+
assert.equal(report.holdMiddle.selectedId, "v4", "cursor must not follow the demoted row");
|
|
343
|
+
assert.notEqual(report.holdMiddle.selectedId, report.holdMiddle.demotedId);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
test("A3: h on the last row selects the previous row", () => {
|
|
347
|
+
assert.equal(report.holdLast.selectedId, "v4");
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
test("A4: h on the only row keeps it selected", () => {
|
|
351
|
+
assert.equal(report.holdOnly.selectedId, "v1");
|
|
352
|
+
assert.deepEqual(report.holdOnly.orderedIds, ["v1"]);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
test("A6: unhold keeps the slot instead of staying on the resumed row", () => {
|
|
356
|
+
assert.equal(report.unhold.demotedId, "v3");
|
|
357
|
+
assert.equal(report.unhold.selectedId, "v4", "the resumed row must not keep the cursor");
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
test("A8 (h branch): a rejected hold leaves the cursor in place", () => {
|
|
361
|
+
assert.equal(report.holdFailed.selectedId, "v3");
|
|
362
|
+
assert.equal(report.holdFailed.notice, "boom");
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test("A9: filtering does not send the cursor to the top when the demoted row leaves the result", () => {
|
|
366
|
+
assert.equal(report.holdFiltered.selectedId, "v4");
|
|
367
|
+
assert.ok(!report.holdFiltered.orderedIds.includes(report.holdFiltered.demotedId), "held row leaves the s:idle filter");
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
test("A10: peek keeps its own target while the list cursor moves to the slot", () => {
|
|
371
|
+
assert.equal(report.holdPeek.mode, "peek");
|
|
372
|
+
assert.equal(report.holdPeek.peekId, "v3");
|
|
373
|
+
assert.equal(report.holdPeek.selectedId, "v4");
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
test("A11: background-driven transitions still follow the row", () => {
|
|
377
|
+
assert.equal(report.backgroundFollow.selectedId, "v3", "follow is the established behavior outside the demote commands");
|
|
378
|
+
});
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
- [ ] **Step 2: Run the probe test to verify it fails**
|
|
382
|
+
|
|
383
|
+
Run: `node --test test/dashboard-position-keep.test.mjs`
|
|
384
|
+
Expected: FAIL — `holdMiddle.selectedId` is `"v3"` (the cursor followed the held row); the later sections behave the same way.
|
|
385
|
+
|
|
386
|
+
- [ ] **Step 3: Add the anchor type and the import**
|
|
387
|
+
|
|
388
|
+
In `src/ui/dashboard.ts`:
|
|
389
|
+
|
|
390
|
+
1. Extend the existing rows import (line ~33) to:
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
import { filterRows, groupRowsByFolder, neighborAfterRemoval, rowState, stateGlyph } from "../core/rows.mjs";
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
2. Add the type next to the other local type aliases (`type ListTarget = ...`):
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
type PositionAnchor = { neighborId: string | null; anchorIndex: number };
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
- [ ] **Step 4: Add the two private methods**
|
|
403
|
+
|
|
404
|
+
Insert directly after `refresh()` (after its closing brace, before `private selectedRow()`):
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
/**
|
|
408
|
+
* Issue #254: the slot a demote command is about to vacate. Capture it BEFORE
|
|
409
|
+
* the state command runs — afterwards the row has already moved and the old
|
|
410
|
+
* position is only recoverable from the pre-mutation order.
|
|
411
|
+
*/
|
|
412
|
+
private capturePositionAnchor(id: string, removedIds: string[] = [id]): PositionAnchor | null {
|
|
413
|
+
return neighborAfterRemoval(this.orderedIds, removedIds, id);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Issue #254: apply a captured anchor after refresh(). Prefer the row that
|
|
418
|
+
* filled the slot, else clamp to the old index. Never assign an id that is no
|
|
419
|
+
* longer visible — refresh() would read it as "selected row vanished" and jump
|
|
420
|
+
* to the top of the list.
|
|
421
|
+
*/
|
|
422
|
+
private applyPositionAnchor(anchor: PositionAnchor | null): void {
|
|
423
|
+
if (!anchor) return;
|
|
424
|
+
const last = this.orderedIds.length - 1;
|
|
425
|
+
if (last < 0) return;
|
|
426
|
+
const neighbor = anchor.neighborId;
|
|
427
|
+
const target = neighbor && this.orderedIds.includes(neighbor)
|
|
428
|
+
? neighbor
|
|
429
|
+
: this.orderedIds[Math.min(anchor.anchorIndex, last)];
|
|
430
|
+
if (!target) return;
|
|
431
|
+
this.selectedId = target;
|
|
432
|
+
this.selectedSection = null;
|
|
433
|
+
this.prewarmSelected();
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
- [ ] **Step 5: Wire `toggleHold()`**
|
|
438
|
+
|
|
439
|
+
Replace the body's command-and-refresh block with (keep the guard lines above it unchanged):
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
// Issue #254: remember the slot before the state command moves the row.
|
|
443
|
+
const anchor = this.capturePositionAnchor(row.meta.id);
|
|
444
|
+
const run = holding ? this.deps.service.clearHoldView(row.meta.id) : this.deps.service.holdView(row.meta.id);
|
|
445
|
+
void Promise.resolve(run).then((res) => {
|
|
446
|
+
if (!res.ok) {
|
|
447
|
+
this.notice(res.error ?? (holding ? "Resume failed" : "Hold failed"), "error");
|
|
448
|
+
this.refresh();
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
this.notice(holding ? "Resumed — needs instructions" : "On hold", "info");
|
|
452
|
+
this.refresh();
|
|
453
|
+
this.applyPositionAnchor(anchor);
|
|
454
|
+
});
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
- [ ] **Step 6: Run the probe test to verify it passes**
|
|
458
|
+
|
|
459
|
+
Run: `node --test test/dashboard-position-keep.test.mjs`
|
|
460
|
+
Expected: PASS for A2, A3, A4, A6, A8 (h), A9, A10, A11.
|
|
461
|
+
|
|
462
|
+
- [ ] **Step 7: Run the typecheck and the existing dashboard suites**
|
|
463
|
+
|
|
464
|
+
Run: `npm run typecheck && node --test test/dashboard-delete-key.test.mjs test/dashboard-selection.test.mjs test/rows.test.mjs`
|
|
465
|
+
Expected: PASS, no type errors.
|
|
466
|
+
|
|
467
|
+
- [ ] **Step 8: Commit**
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
git add src/ui/dashboard.ts test-support/dashboard-position-keep-probe.ts test/dashboard-position-keep.test.mjs
|
|
471
|
+
git commit -m "feat(dashboard): keep the cursor in place when h demotes a row (issue #254)"
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
### Task 3: `d`+`y` and batch done entries
|
|
477
|
+
|
|
478
|
+
**Files:**
|
|
479
|
+
- Modify: `src/ui/dashboard.ts` (`confirmDone()` ~1056-1072, `confirmDoneSelection()` ~1089-1111)
|
|
480
|
+
- Modify: `test-support/dashboard-position-keep-probe.ts` (append three scenarios)
|
|
481
|
+
- Modify: `test/dashboard-position-keep.test.mjs` (append three tests)
|
|
482
|
+
|
|
483
|
+
**Interfaces:**
|
|
484
|
+
- Consumes: `capturePositionAnchor` / `applyPositionAnchor` from Task 2.
|
|
485
|
+
- Produces: probe report keys `doneMiddle`, `doneFailed`, `batchMiddle`, `batchEnd`, `batchAllSkipped`.
|
|
486
|
+
|
|
487
|
+
- [ ] **Step 1: Write the failing tests**
|
|
488
|
+
|
|
489
|
+
Append to the probe, immediately before `console.log(JSON.stringify(report));`:
|
|
490
|
+
|
|
491
|
+
```typescript
|
|
492
|
+
// A5: d+y on a middle row keeps the slot.
|
|
493
|
+
{
|
|
494
|
+
const env = await makeEnv(5);
|
|
495
|
+
select(env.dash, "v3");
|
|
496
|
+
env.dash.handleInput("d");
|
|
497
|
+
env.dash.handleInput("y");
|
|
498
|
+
await waitFor(() => priv(env.dash).selectedId === "v4");
|
|
499
|
+
report.doneMiddle = cursor(env.dash, { demotedId: "v3" });
|
|
500
|
+
env.dash.dispose();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// A8 (done branch): a rejected mark-completed leaves the cursor alone.
|
|
504
|
+
{
|
|
505
|
+
const env = await makeEnv(5);
|
|
506
|
+
select(env.dash, "v3");
|
|
507
|
+
env.service.markCompleted = (() => Promise.resolve({ ok: false, error: "boom" })) as typeof env.service.markCompleted;
|
|
508
|
+
env.dash.handleInput("d");
|
|
509
|
+
env.dash.handleInput("y");
|
|
510
|
+
await waitFor(() => priv(env.dash).flash !== null);
|
|
511
|
+
report.doneFailed = cursor(env.dash, { notice: priv(env.dash).flash?.text ?? null });
|
|
512
|
+
env.dash.dispose();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// A7: batch done selects the block's neighbour, never a completed id.
|
|
516
|
+
{
|
|
517
|
+
const env = await makeEnv(5);
|
|
518
|
+
select(env.dash, "v2");
|
|
519
|
+
env.dash.handleInput("m");
|
|
520
|
+
env.dash.handleInput(" ");
|
|
521
|
+
env.dash.handleInput("j");
|
|
522
|
+
env.dash.handleInput(" ");
|
|
523
|
+
env.dash.handleInput("d");
|
|
524
|
+
env.dash.handleInput("y");
|
|
525
|
+
await waitFor(() => priv(env.dash).selectedId === "v4");
|
|
526
|
+
report.batchMiddle = cursor(env.dash, { doneIds: ["v2", "v3"] });
|
|
527
|
+
env.dash.dispose();
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// A7 (block at the end): nothing follows the block, so the previous row wins.
|
|
531
|
+
{
|
|
532
|
+
const env = await makeEnv(5);
|
|
533
|
+
select(env.dash, "v4");
|
|
534
|
+
env.dash.handleInput("m");
|
|
535
|
+
env.dash.handleInput(" ");
|
|
536
|
+
env.dash.handleInput("j");
|
|
537
|
+
env.dash.handleInput(" ");
|
|
538
|
+
env.dash.handleInput("d");
|
|
539
|
+
env.dash.handleInput("y");
|
|
540
|
+
await waitFor(() => priv(env.dash).selectedId === "v3");
|
|
541
|
+
report.batchEnd = cursor(env.dash, { doneIds: ["v4", "v5"] });
|
|
542
|
+
env.dash.dispose();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// A13: a batch that completed nothing must not move the cursor.
|
|
546
|
+
{
|
|
547
|
+
const env = await makeEnv(5);
|
|
548
|
+
select(env.dash, "v2");
|
|
549
|
+
env.dash.handleInput("m");
|
|
550
|
+
env.dash.handleInput(" ");
|
|
551
|
+
env.dash.handleInput("j");
|
|
552
|
+
env.dash.handleInput(" ");
|
|
553
|
+
env.service.markCompletedMany = (() => Promise.resolve({ ok: true, completed: 0, skipped: 2, completedIds: [] })) as typeof env.service.markCompletedMany;
|
|
554
|
+
env.dash.handleInput("d");
|
|
555
|
+
env.dash.handleInput("y");
|
|
556
|
+
await waitFor(() => priv(env.dash).flash !== null);
|
|
557
|
+
report.batchAllSkipped = cursor(env.dash);
|
|
558
|
+
env.dash.dispose();
|
|
559
|
+
}
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
Append to `test/dashboard-position-keep.test.mjs`:
|
|
563
|
+
|
|
564
|
+
```javascript
|
|
565
|
+
test("A5: d+y on a middle row keeps the slot", () => {
|
|
566
|
+
assert.equal(report.doneMiddle.demotedId, "v3");
|
|
567
|
+
assert.equal(report.doneMiddle.selectedId, "v4");
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
test("A8 (done branch): a rejected mark-completed leaves the cursor in place", () => {
|
|
571
|
+
assert.equal(report.doneFailed.selectedId, "v3");
|
|
572
|
+
assert.equal(report.doneFailed.notice, "boom");
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
test("A7: batch done selects the row after the block, not a completed id", () => {
|
|
576
|
+
assert.equal(report.batchMiddle.selectedId, "v4");
|
|
577
|
+
assert.ok(!report.batchMiddle.doneIds.includes(report.batchMiddle.selectedId));
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
test("A7 (block at the end): the previous row wins when nothing follows", () => {
|
|
581
|
+
assert.equal(report.batchEnd.selectedId, "v3");
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
test("A13: a batch that completed nothing leaves the cursor alone", () => {
|
|
585
|
+
assert.equal(report.batchAllSkipped.selectedId, "v3");
|
|
586
|
+
});
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
- [ ] **Step 2: Run the probe test to verify it fails**
|
|
590
|
+
|
|
591
|
+
Run: `node --test test/dashboard-position-keep.test.mjs`
|
|
592
|
+
Expected: FAIL — `doneMiddle.selectedId`/`batchMiddle.selectedId` follow the demoted rows; `batchAllSkipped.selectedId` jumps to the anchor.
|
|
593
|
+
|
|
594
|
+
- [ ] **Step 3: Wire `confirmDone()`**
|
|
595
|
+
|
|
596
|
+
Replace the `onYes` body:
|
|
597
|
+
|
|
598
|
+
```typescript
|
|
599
|
+
onYes: () => {
|
|
600
|
+
// Issue #254: capture before the state command; apply only on success.
|
|
601
|
+
const anchor = this.capturePositionAnchor(row.meta.id);
|
|
602
|
+
void this.markCompleted(row).then((res) => {
|
|
603
|
+
if (!res.ok) this.notice(res.error ?? "Mark done failed", "error");
|
|
604
|
+
else this.notice("Marked done", "info");
|
|
605
|
+
this.refresh();
|
|
606
|
+
if (res.ok) this.applyPositionAnchor(anchor);
|
|
607
|
+
});
|
|
608
|
+
},
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
- [ ] **Step 4: Wire `confirmDoneSelection()`**
|
|
612
|
+
|
|
613
|
+
Replace the `onYes` body:
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
onYes: () => {
|
|
617
|
+
// Issue #254: anchor on the topmost selected row in board order —
|
|
618
|
+
// selectedIds is a Set in insertion order, so doneIds[0] is arbitrary.
|
|
619
|
+
const topmost = doneIds
|
|
620
|
+
.map((id) => this.orderedIds.indexOf(id))
|
|
621
|
+
.filter((index) => index >= 0)
|
|
622
|
+
.reduce((min, index) => (index < min ? index : min), Number.POSITIVE_INFINITY);
|
|
623
|
+
const anchor = Number.isFinite(topmost)
|
|
624
|
+
? this.capturePositionAnchor(this.orderedIds[topmost], doneIds)
|
|
625
|
+
: null;
|
|
626
|
+
void Promise.resolve(this.deps.service.markCompletedMany?.(doneIds) ?? { ok: true, completed: 0, skipped: doneIds.length, completedIds: [] }).then((res) => {
|
|
627
|
+
if (!res.ok) this.notice("Mark done failed", "error");
|
|
628
|
+
else this.notice(`Moved ${res.completed} to Done${res.skipped ? ` · skipped ${res.skipped}` : ""}`, "info");
|
|
629
|
+
this.refresh();
|
|
630
|
+
// A batch that completed nothing moved nothing — keep the cursor.
|
|
631
|
+
if (res.ok && res.completed > 0) this.applyPositionAnchor(anchor);
|
|
632
|
+
});
|
|
633
|
+
},
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
- [ ] **Step 5: Run the probe test to verify it passes**
|
|
637
|
+
|
|
638
|
+
Run: `node --test test/dashboard-position-keep.test.mjs`
|
|
639
|
+
Expected: PASS for all of A2–A11 and A13.
|
|
640
|
+
|
|
641
|
+
- [ ] **Step 6: Run the repository verification (A12)**
|
|
642
|
+
|
|
643
|
+
Run: `npm run verify`
|
|
644
|
+
Expected: PASS — typecheck, perf gate, full test suite, coverage thresholds (lines 85 / funcs 80 / branches 70), and `pack:dry`.
|
|
645
|
+
|
|
646
|
+
- [ ] **Step 7: Commit**
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
git add src/ui/dashboard.ts test-support/dashboard-position-keep-probe.ts test/dashboard-position-keep.test.mjs
|
|
650
|
+
git commit -m "feat(dashboard): keep the cursor in place for d+y and batch done (issue #254)"
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
---
|
|
654
|
+
|
|
655
|
+
## Self-Review
|
|
656
|
+
|
|
657
|
+
**Spec coverage:** A1 → Task 1. A2/A3/A4 → Task 2 steps 1-6. A5 → Task 3. A6 → Task 2. A7 → Task 3. A8 → Task 2 (h) + Task 3 (done). A9/A10/A11 → Task 2. A12 → Task 3 step 6. A13 → Task 3. U1 stays a post-merge manual check (optional, needs an installed build) — not a task.
|
|
658
|
+
|
|
659
|
+
**Placeholder scan:** no TBD/TODO; every code step carries the exact code; every test step carries the exact assertion.
|
|
660
|
+
|
|
661
|
+
**Type consistency:** `neighborAfterRemoval` returns `{ neighborId, anchorIndex } | null` in Task 1 and both consumers (`capturePositionAnchor`, `applyPositionAnchor`) read exactly those field names. `PositionAnchor` is defined once in Task 2 and reused in Task 3 without redefinition.
|
|
662
|
+
|
|
663
|
+
**Review Focus mapping:** contiguous block at the end → Task 3 `batchEnd`; filter active → Task 2 `holdFiltered`; last/only row → Task 2 `holdLast` / `holdOnly`; folded section → clamp path exercised by `applyPositionAnchor` (unit-covered behaviour via `anchorIndex` fallback in Task 1's unknown-neighbour case; the folded-section state itself is not probe-tested because folding requires a saved prefs file — documented as a known gap in the PR description); failure paths → Task 2 `holdFailed` + Task 3 `doneFailed` / `batchAllSkipped`.
|