@ftrdotdev/pi-tracker 0.3.0 → 0.5.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/src/ui.test.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import { assert, it } from "@effect/vitest";
2
2
  import type { Theme } from "@earendil-works/pi-coding-agent";
3
+ import { visibleWidth } from "@earendil-works/pi-tui";
4
+ import { orderedItems } from "./deps.ts";
3
5
  import { TodoItem, TodoList, TrackerState } from "./domain.ts";
4
6
  import {
5
7
  makeTrackerOverlay,
6
8
  makeTrackerWidget,
9
+ planWidgetItems,
7
10
  renderTrackerWidget,
8
11
  type TrackerOverlayHandle,
9
12
  type TrackerUiAction,
13
+ type WidgetRow,
10
14
  } from "./ui.ts";
11
15
 
12
16
  /**
@@ -202,3 +206,262 @@ it("widget survives the setWidget bridge wrapper (render/invalidate handed off b
202
206
  assert.match(wrapper.render(40).join("\n"), /Work \(1\/2\)/);
203
207
  assert.deepStrictEqual(wrapper.render(40), lines);
204
208
  });
209
+
210
+ // --------------------------------------------------------------------------
211
+ // Widget collapse planning (lists larger than the row budget)
212
+ // --------------------------------------------------------------------------
213
+
214
+ /** A list of `count` items; the first `done` items are done. */
215
+ const listOfCount = (count: number, done: number): TodoList =>
216
+ new TodoList({
217
+ id: 1,
218
+ name: "Work",
219
+ nextItemId: count + 1,
220
+ items: Array.from(
221
+ { length: count },
222
+ (_, index) => new TodoItem({ id: index + 1, text: `item ${index + 1}`, done: index < done }),
223
+ ),
224
+ });
225
+
226
+ /**
227
+ * A list whose item `i + 1` has ids `1..n`, dependency set `deps[i]`, and is
228
+ * done when `i` is in `done`.
229
+ */
230
+ const listWithDeps = (
231
+ deps: ReadonlyArray<readonly string[]>,
232
+ done: readonly number[] = [],
233
+ ): TodoList =>
234
+ new TodoList({
235
+ id: 1,
236
+ name: "Work",
237
+ nextItemId: deps.length + 1,
238
+ items: deps.map(
239
+ (itemDeps, index) =>
240
+ new TodoItem({
241
+ id: index + 1,
242
+ text: `item ${index + 1}`,
243
+ done: done.includes(index),
244
+ deps: itemDeps,
245
+ }),
246
+ ),
247
+ });
248
+
249
+ const stateWith = (list: TodoList): TrackerState =>
250
+ new TrackerState({ lists: [list], activeListId: list.id, nextListId: 2 });
251
+
252
+ const shownIndexes = (rows: readonly WidgetRow[]): number[] =>
253
+ rows.flatMap((row) => (row.kind === "item" ? [row.index] : []));
254
+
255
+ const ellipsisCount = (rows: readonly WidgetRow[]): number =>
256
+ rows.filter((row) => row.kind === "ellipsis").length;
257
+
258
+ it("planner returns every item with no ellipsis when the list fits", () => {
259
+ const plan = planWidgetItems(listOfCount(3, 1), 12);
260
+ assert.deepStrictEqual(shownIndexes(plan), [0, 1, 2]);
261
+ assert.strictEqual(ellipsisCount(plan), 0);
262
+ });
263
+
264
+ it("planner keeps the first item, the current item, and the last item inside the budget", () => {
265
+ // The first 12 items are done, so item 13 (index 12) is current.
266
+ const plan = planWidgetItems(listOfCount(30, 12), 12);
267
+ const shown = shownIndexes(plan);
268
+
269
+ assert.isAtMost(plan.length, 12);
270
+ assert.include(shown, 0);
271
+ assert.include(shown, 12);
272
+ assert.include(shown, 29);
273
+ // The window leaves a hidden gap on each side of itself.
274
+ assert.strictEqual(ellipsisCount(plan), 2);
275
+ });
276
+
277
+ it("planner omits the leading ellipsis when the window touches the first item", () => {
278
+ // Nothing is done, so item 1 (index 0) is current and the window starts there.
279
+ const plan = planWidgetItems(listOfCount(30, 0), 12);
280
+ const shown = shownIndexes(plan);
281
+
282
+ assert.deepStrictEqual(shown.slice(0, 2), [0, 1]);
283
+ assert.include(shown, 29);
284
+ assert.strictEqual(ellipsisCount(plan), 1);
285
+ });
286
+
287
+ it("planner follows the current item as work progresses", () => {
288
+ const early = planWidgetItems(listOfCount(40, 3), 12);
289
+ const late = planWidgetItems(listOfCount(40, 35), 12);
290
+
291
+ assert.include(shownIndexes(early), 3);
292
+ assert.include(shownIndexes(late), 35);
293
+ // The window moves with the current item, so each plan hides the other's
294
+ // current position.
295
+ assert.equal(shownIndexes(early).includes(35), false);
296
+ assert.equal(shownIndexes(late).includes(3), false);
297
+ });
298
+
299
+ it("planner anchors the last item when every item is done", () => {
300
+ const plan = planWidgetItems(listOfCount(30, 30), 12);
301
+ assert.include(shownIndexes(plan), 0);
302
+ assert.include(shownIndexes(plan), 29);
303
+ assert.isAtMost(plan.length, 12);
304
+ });
305
+
306
+ it("planner emits an ellipsis between rendered items only when items are hidden", () => {
307
+ // Property: each gap between consecutive rendered items is at least two
308
+ // indexes wide, and every such gap has exactly one ellipsis row.
309
+ for (const done of [0, 5, 17, 29]) {
310
+ const plan = planWidgetItems(listOfCount(30, done), 12);
311
+ const shown = shownIndexes(plan);
312
+ let expectedEllipses = 0;
313
+ for (let i = 1; i < shown.length; i += 1) {
314
+ if (shown[i]! > shown[i - 1]! + 1) expectedEllipses += 1;
315
+ }
316
+ assert.strictEqual(ellipsisCount(plan), expectedEllipses, `done=${done}`);
317
+ }
318
+ });
319
+
320
+ it("widget renders a vertical ellipsis and hides collapsed items", () => {
321
+ const list = listOfCount(30, 5);
322
+ const text = renderTrackerWidget(stateWith(list), identityTheme, 60).join("\n");
323
+
324
+ assert.match(text, /⋮/);
325
+ // The rendered item rows stay within the budget instead of printing all 30.
326
+ const itemLines = text.split("\n").filter((line) => /item \d+/.test(line));
327
+ assert.isAtMost(itemLines.length, 12);
328
+ });
329
+
330
+ // --------------------------------------------------------------------------
331
+ // Current item marker
332
+ // --------------------------------------------------------------------------
333
+
334
+ it("marks the current item (first not-done) with a filled circle", () => {
335
+ // Item 1 is done, so item 2 is the current item.
336
+ const text = renderTrackerWidget(stateWith(listOfCount(4, 1)), identityTheme, 40).join("\n");
337
+
338
+ assert.match(text, /● item 2/);
339
+ assert.match(text, /○ item 3/);
340
+ assert.match(text, /✓ item 1/);
341
+ // Only the current item carries the filled circle.
342
+ assert.equal(text.includes("● item 1"), false);
343
+ assert.equal(text.includes("● item 3"), false);
344
+ });
345
+
346
+ it("marks no item as current when every item is done", () => {
347
+ const text = renderTrackerWidget(stateWith(listOfCount(3, 3)), identityTheme, 40).join("\n");
348
+ assert.equal(text.includes("●"), false);
349
+ });
350
+
351
+ // --------------------------------------------------------------------------
352
+ // Readiness markers and derived order
353
+ // --------------------------------------------------------------------------
354
+
355
+ it("marks the first ready item as current, not the first open item", () => {
356
+ // Item 1 is done; item 2 waits for item 3, so item 2 is blocked and item 3
357
+ // is the first ready item.
358
+ const text = renderTrackerWidget(
359
+ stateWith(listWithDeps([[], ["Work:3"], []], [0])),
360
+ identityTheme,
361
+ 40,
362
+ ).join("\n");
363
+
364
+ assert.match(text, /● item 3/);
365
+ assert.match(text, /⊘ item 2/);
366
+ assert.match(text, /✓ item 1/);
367
+ });
368
+
369
+ it("renders a blocked item with the blocked glyph", () => {
370
+ const text = renderTrackerWidget(
371
+ stateWith(listWithDeps([[], ["Work:1"]])),
372
+ identityTheme,
373
+ 40,
374
+ ).join("\n");
375
+
376
+ assert.match(text, /⊘ item 2/);
377
+ });
378
+
379
+ it("starts every item text at the same column, whatever the marker", () => {
380
+ // Item 1 is done, item 2 waits for item 4 (blocked), items 3 and 4 are ready.
381
+ const text = renderTrackerWidget(
382
+ stateWith(listWithDeps([[], ["Work:4"], [], []], [0])),
383
+ identityTheme,
384
+ 40,
385
+ ).join("\n");
386
+
387
+ const lines = text.split("\n").filter((line) => /item \d+/.test(line));
388
+ const columns = lines.map((line) => visibleWidth(line.slice(0, line.indexOf("item"))));
389
+
390
+ // Every marker state is on screen: done, current ready, other ready, blocked.
391
+ assert.isAtLeast(lines.length, 4);
392
+ assert.match(text, /✓ item 1/);
393
+ assert.match(text, /● item 3/);
394
+ assert.match(text, /○ item 4/);
395
+ assert.match(text, /⊘ item 2/);
396
+ // Every marker is padded to the same two columns, so the text column is
397
+ // flush even for the blocked rows.
398
+ assert.strictEqual(new Set(columns).size, 1);
399
+ });
400
+
401
+ it("renders items in dependency order, not stored order", () => {
402
+ // Item 1 waits for item 2, so item 2 renders first.
403
+ const text = renderTrackerWidget(
404
+ stateWith(listWithDeps([["Work:2"], []])),
405
+ identityTheme,
406
+ 40,
407
+ ).join("\n");
408
+
409
+ assert.isBelow(text.indexOf("item 2"), text.indexOf("item 1"));
410
+ });
411
+
412
+ it("a dependency-free list renders exactly as before", () => {
413
+ const text = renderTrackerWidget(stateWith(listOfCount(3, 1)), identityTheme, 40).join("\n");
414
+
415
+ assert.match(text, /✓ item 1/);
416
+ assert.match(text, /● item 2/);
417
+ assert.match(text, /○ item 3/);
418
+ notContain(text, "⊘");
419
+ });
420
+
421
+ it("planner anchors on the first ready item, not the first open item", () => {
422
+ // Item 1 is done; item 2 waits for item 30. The first open item is item 2
423
+ // and the first ready item is item 3.
424
+ const list = new TodoList({
425
+ id: 1,
426
+ name: "Work",
427
+ nextItemId: 31,
428
+ items: Array.from(
429
+ { length: 30 },
430
+ (_, index) =>
431
+ new TodoItem({
432
+ id: index + 1,
433
+ text: `item ${index + 1}`,
434
+ done: index === 0,
435
+ deps: index === 1 ? ["Work:30"] : [],
436
+ }),
437
+ ),
438
+ });
439
+ // Item 2 sits last in the derived order, after everything it waits for.
440
+ const ordered = { name: list.name, items: orderedItems(list) };
441
+
442
+ // A one-row budget shows the anchor alone, so the shown index is the window
443
+ // centre: position 1 is item 3, the first ready item.
444
+ assert.deepStrictEqual(shownIndexes(planWidgetItems(ordered, 1)), [1]);
445
+ });
446
+
447
+ it("annotates a blocked item in the overlay items pane", () => {
448
+ const h = makeOverlay(stateWith(listWithDeps([[], ["Work:1"]])));
449
+
450
+ const text = h.overlay.render(80).join("\n");
451
+
452
+ assert.match(text, /item 2/);
453
+ assert.match(text, /\(blocked by #Work:1\)/);
454
+ });
455
+
456
+ it("annotates a done item whose dependency is open again in the overlay", () => {
457
+ // Item 2 is done while item 1, which it waits for, is open: the state a
458
+ // reopen or a dependency edit produces. The row is not "blocked", so it
459
+ // says what it waits on.
460
+ const h = makeOverlay(stateWith(listWithDeps([[], ["Work:1"]], [1])));
461
+
462
+ const text = h.overlay.render(80).join("\n");
463
+
464
+ assert.match(text, /item 2/);
465
+ assert.match(text, /\(waiting on #Work:1\)/);
466
+ notContain(text, "blocked by");
467
+ });
package/src/ui.ts CHANGED
@@ -1,13 +1,24 @@
1
1
  import type { Theme } from "@earendil-works/pi-coding-agent";
2
2
  import type { Component } from "@earendil-works/pi-tui";
3
- import { Key, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
3
+ import { Key, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
4
4
  import { makeBorderedBox } from "@ftrdotdev/pi-tui";
5
- import type { TodoList, TrackerState } from "./domain.ts";
5
+ import {
6
+ firstReadyIndex,
7
+ orderedItems,
8
+ readiness,
9
+ type DependencyItem,
10
+ type DependencyList,
11
+ type DependencyListView,
12
+ } from "./deps.ts";
13
+ import type { TodoItem, TodoList, TrackerState } from "./domain.ts";
6
14
  import type { UpdateItemPatch } from "./store.ts";
7
15
 
8
16
  const MAX_LISTS = 8;
9
17
  const MAX_ITEMS = 12;
10
18
 
19
+ /** Marker field width in columns. Every glyph is padded to it, so text is flush. */
20
+ const MARKER_WIDTH = 2;
21
+
11
22
  const clamp = (value: number, min: number, max: number): number =>
12
23
  Math.min(Math.max(value, min), max);
13
24
 
@@ -29,18 +40,160 @@ const widgetLabel =
29
40
  );
30
41
  };
31
42
 
43
+ /** One planned widget row: an item (by 0-based index) or a collapse marker. */
44
+ export type WidgetRow =
45
+ | { readonly kind: "item"; readonly index: number }
46
+ | { readonly kind: "ellipsis" };
47
+
48
+ /**
49
+ * A list's items in derived display order, plus the readiness of each. All
50
+ * three rendering surfaces (widget, `list` output, overlay) iterate the array
51
+ * returned here, so the order and the annotations always agree.
52
+ */
53
+ export const displayList = <T extends DependencyItem>(
54
+ list: DependencyListView<T>,
55
+ ): { readonly list: DependencyListView<T>; readonly ready: ReturnType<typeof readiness> } => {
56
+ const ordered = { name: list.name, items: orderedItems(list) };
57
+ return { list: ordered, ready: readiness(ordered) };
58
+ };
59
+
60
+ /**
61
+ * A marker field of a fixed width: `✓` for a done item, `●` for the current
62
+ * (first ready) item, `⊘` for a blocked one, `○` for any other open item.
63
+ * `visibleWidth` supplies the padding, so the field stays flush even if a
64
+ * marker is ever wider than one column.
65
+ */
66
+ const itemMarker = (item: TodoItem, blocked: boolean, isCurrent: boolean, theme: Theme): string => {
67
+ const [glyph, color] = item.done
68
+ ? (["✓", "success"] as const)
69
+ : isCurrent
70
+ ? (["●", "accent"] as const)
71
+ : blocked
72
+ ? (["⊘", "dim"] as const)
73
+ : (["○", "dim"] as const);
74
+ return theme.fg(color, glyph + " ".repeat(Math.max(0, MARKER_WIDTH - visibleWidth(glyph))));
75
+ };
76
+
77
+ /** `#Work:1, #Work:2`, or `?` for a reference that does not resolve. */
78
+ const blockerRefs = (blockers: readonly string[]): string =>
79
+ blockers.map((ref) => (ref === "?" ? "?" : `#${ref}`)).join(", ");
80
+
81
+ /** The blocked annotation both the overlay and the `list` output share. */
82
+ export const blockedSuffix = (blockers: readonly string[]): string =>
83
+ blockers.length === 0 ? "" : ` (blocked by ${blockerRefs(blockers)})`;
84
+
85
+ /**
86
+ * The annotation for a done item whose dependencies are not all done. A
87
+ * reopened prerequisite or a dependency edit can produce this state. The
88
+ * wording is not "blocked", because the item is finished: it names what is
89
+ * still open.
90
+ */
91
+ export const waitingSuffix = (blockers: readonly string[]): string =>
92
+ blockers.length === 0 ? "" : ` (waiting on ${blockerRefs(blockers)})`;
93
+
94
+ /**
95
+ * The annotation for one row: a done item waits, an open item is blocked. One
96
+ * helper, so every surface words the same state the same way.
97
+ */
98
+ export const readinessSuffix = (done: boolean, blockers: readonly string[]): string =>
99
+ done ? waitingSuffix(blockers) : blockedSuffix(blockers);
100
+
101
+ /** Emit visible indices in order, inserting one `⋮` row per gap. */
102
+ const emitWidgetRows = (visible: ReadonlySet<number>): WidgetRow[] => {
103
+ const sorted = [...visible].sort((a, b) => a - b);
104
+ const rows: WidgetRow[] = [];
105
+ let previous: number | undefined;
106
+ for (const index of sorted) {
107
+ // A gap means rendered items are not adjacent in the list, so at least
108
+ // one item is hidden between them and the ellipsis is warranted.
109
+ if (previous !== undefined && index > previous + 1) rows.push({ kind: "ellipsis" });
110
+ rows.push({ kind: "item", index });
111
+ previous = index;
112
+ }
113
+ return rows;
114
+ };
115
+
116
+ /** Total planned rows: one per item, plus one ellipsis row per hidden gap. */
117
+ const plannedRowCount = (visible: ReadonlySet<number>): number => {
118
+ const sorted = [...visible].sort((a, b) => a - b);
119
+ let rows = sorted.length;
120
+ for (let i = 1; i < sorted.length; i += 1) {
121
+ if (sorted[i]! > sorted[i - 1]! + 1) rows += 1;
122
+ }
123
+ return rows;
124
+ };
125
+
126
+ /**
127
+ * Plan the widget's item rows when the list has more items than fit.
128
+ *
129
+ * The plan keeps three anchors visible: the first item, the last item, and the
130
+ * current one (the first ready item, or the last item when nothing is ready).
131
+ * It then grows a window outward from the current item until the row budget
132
+ * runs out. Items outside the window collapse into a `⋮` row. A gap produces
133
+ * an ellipsis row only when the items on either side are not adjacent, so `⋮`
134
+ * never appears where nothing is hidden. When every item fits, the plan returns
135
+ * all of them in order.
136
+ *
137
+ * Rows index `list.items` as given, so pass the display order (see
138
+ * `orderedItems`).
139
+ *
140
+ * `maxRows` counts item rows and ellipsis rows together. Tight budgets drop
141
+ * the anchors before the current item. Adding an index never lowers the row
142
+ * count, so a candidate that overflows stays out, but a later candidate can
143
+ * still fill a gap at no cost.
144
+ */
145
+ export const planWidgetItems = (list: DependencyList, maxRows: number): WidgetRow[] => {
146
+ const items = list.items;
147
+ const total = items.length;
148
+ if (total === 0 || maxRows <= 0) return [];
149
+ if (total <= maxRows) return items.map((_, index) => ({ kind: "item", index }));
150
+
151
+ // The window needs a center even when nothing can be picked up, so fall back
152
+ // to the first open item (a fully blocked list should show its blocked work,
153
+ // not its tail) and then to the last item when every item is done.
154
+ const firstOpen = items.findIndex((item) => !item.done);
155
+ const current = firstReadyIndex(list) ?? (firstOpen === -1 ? total - 1 : firstOpen);
156
+
157
+ // The current item always shows; the anchors join it when the budget
158
+ // allows. At total > maxRows the current item alone never overflows.
159
+ const visible = new Set<number>([current]);
160
+ for (const anchor of [0, total - 1]) {
161
+ if (visible.has(anchor)) continue;
162
+ visible.add(anchor);
163
+ if (plannedRowCount(visible) > maxRows) visible.delete(anchor);
164
+ }
165
+
166
+ // Grow outward from the current item, right before left at each distance,
167
+ // so the window follows remaining work first. Skip candidates that do not
168
+ // fit: a later one may still fill a gap between visible items at no cost.
169
+ const maxDistance = Math.max(current, total - 1 - current);
170
+ for (let distance = 1; distance <= maxDistance; distance += 1) {
171
+ for (const index of [current + distance, current - distance]) {
172
+ if (index < 0 || index >= total || visible.has(index)) continue;
173
+ visible.add(index);
174
+ if (plannedRowCount(visible) > maxRows) visible.delete(index);
175
+ }
176
+ }
177
+ return emitWidgetRows(visible);
178
+ };
179
+
32
180
  /** The item lines inside the widget frame, rendered per width so they stay flush. */
33
181
  const widgetRows =
34
182
  (list: TodoList, theme: Theme) =>
35
183
  (_width: number): string[] => {
36
184
  const rows: string[] = [];
37
- for (const item of list.items.slice(0, MAX_ITEMS)) {
38
- const check = item.done ? theme.fg("success", "✓ ") : theme.fg("dim", "○ ");
185
+ const view = displayList(list);
186
+ const current = firstReadyIndex(view.list);
187
+ for (const row of planWidgetItems(view.list, MAX_ITEMS)) {
188
+ if (row.kind === "ellipsis") {
189
+ rows.push(theme.fg("dim", " ⋮"));
190
+ continue;
191
+ }
192
+ const item = view.list.items[row.index]!;
193
+ const blocked = (view.ready[row.index]?.blockers.length ?? 0) > 0;
194
+ const marker = itemMarker(item, blocked, row.index === current, theme);
39
195
  const text = item.done ? theme.fg("muted", theme.strikethrough(item.text)) : item.text;
40
- rows.push(` ${check}${text}`);
41
- }
42
- if (list.items.length > MAX_ITEMS) {
43
- rows.push(theme.fg("dim", ` ... ${list.items.length - MAX_ITEMS} more`));
196
+ rows.push(` ${marker}${text}`);
44
197
  }
45
198
  return rows;
46
199
  };
@@ -240,12 +393,14 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
240
393
  } else if (activeListFor.items.length === 0) {
241
394
  lines.push(truncateToWidth(` ${theme.fg("dim", "No items — press a to add")}`, width));
242
395
  } else {
243
- for (const [index, item] of activeListFor.items.slice(0, MAX_ITEMS).entries()) {
396
+ const view = displayList(activeListFor);
397
+ for (const [index, item] of view.list.items.slice(0, MAX_ITEMS).entries()) {
244
398
  const selected = mode === "items" && index === itemIndex;
245
399
  const prefix = selected ? theme.fg("accent", "→ ") : " ";
246
- const check = item.done ? theme.fg("success", "✓") : theme.fg("dim", "○");
400
+ const blocker = readinessSuffix(item.done, view.ready[index]?.blockers ?? []);
401
+ const check = itemMarker(item, blocker !== "", false, theme);
247
402
  const text = item.done ? theme.fg("muted", theme.strikethrough(item.text)) : item.text;
248
- lines.push(truncateToWidth(`${prefix}${check} ${text}`, width));
403
+ lines.push(truncateToWidth(`${prefix}${check}${text}${blocker}`, width));
249
404
  }
250
405
  if (activeListFor.items.length > MAX_ITEMS) {
251
406
  lines.push(
@@ -369,7 +524,9 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
369
524
  }
370
525
  return false;
371
526
  }
372
- const items = list.items;
527
+ // The items pane renders in derived order, so the cursor indexes that
528
+ // array and every action reads the item's own id.
529
+ const items = orderedItems(list);
373
530
  if (matchesKey(data, Key.up)) {
374
531
  if (items.length > 0) itemIndex = (itemIndex - 1 + items.length) % items.length;
375
532
  return true;
@@ -383,7 +540,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
383
540
  if (!item) return true;
384
541
  void runAction({
385
542
  type: "updateItem",
386
- itemId: `${list.name}:${itemIndex + 1}`,
543
+ itemId: `${list.name}:${item.id}`,
387
544
  patch: { done: !item.done },
388
545
  });
389
546
  return true;
@@ -397,7 +554,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
397
554
  if (!item) return true;
398
555
  input = {
399
556
  kind: "editItem",
400
- itemId: `${list.name}:${itemIndex + 1}`,
557
+ itemId: `${list.name}:${item.id}`,
401
558
  buffer: item.text,
402
559
  };
403
560
  return true;
@@ -405,7 +562,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
405
562
  if (data === "r") {
406
563
  const item = items[itemIndex];
407
564
  if (!item) return true;
408
- void runAction({ type: "removeItem", itemId: `${list.name}:${itemIndex + 1}` });
565
+ void runAction({ type: "removeItem", itemId: `${list.name}:${item.id}` });
409
566
  return true;
410
567
  }
411
568
  if (data === "n") {