@ftrdotdev/pi-tracker 0.8.0 → 0.9.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 +369 -0
- package/README.md +5 -0
- package/package.json +20 -16
- package/src/compaction/candidate.test.ts +66 -125
- package/src/compaction/classifier.test.ts +22 -2
- package/src/compaction/classifier.ts +35 -22
- package/src/compaction/completion.test.ts +24 -16
- package/src/compaction/completion.ts +1 -1
- package/src/compaction/decision-record.test.ts +1 -1
- package/src/compaction/decision-record.ts +1 -1
- package/src/compaction/digest.test.ts +34 -34
- package/src/compaction/footprint.ts +2 -4
- package/src/compaction/settings.test.ts +5 -1
- package/src/compaction/settings.ts +1 -1
- package/src/compaction/settle.test.ts +50 -10
- package/src/compaction/settle.ts +1 -1
- package/src/core/deps.test.ts +128 -109
- package/src/core/deps.ts +3 -2
- package/src/core/domain.test.ts +99 -68
- package/src/core/domain.ts +16 -10
- package/src/core/persistence.test.ts +18 -19
- package/src/core/persistence.ts +4 -3
- package/src/core/store.test.ts +129 -167
- package/src/core/store.ts +77 -57
- package/src/harness-collection.test.ts +75 -0
- package/src/index.test.ts +35 -30
- package/src/index.ts +45 -66
- package/src/layers.test.ts +101 -0
- package/src/layers.ts +46 -0
- package/src/presentation/tool-metadata.test.ts +36 -38
- package/src/presentation/tool-metadata.ts +127 -130
- package/src/presentation/ui.test.ts +67 -67
- package/src/presentation/ui.ts +22 -19
- package/src/presentation/vim-settings.test.ts +3 -0
- package/src/presentation/vim-settings.ts +1 -1
|
@@ -3,9 +3,19 @@
|
|
|
3
3
|
* contract, and the prompt-facing strings. Everything here is free of runtime
|
|
4
4
|
* state; behavior (execute and rendering) lives in index.ts.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
arr,
|
|
8
|
+
bool,
|
|
9
|
+
lit,
|
|
10
|
+
num,
|
|
11
|
+
obj,
|
|
12
|
+
oneOf,
|
|
13
|
+
opt,
|
|
14
|
+
str,
|
|
15
|
+
union,
|
|
16
|
+
type Schema,
|
|
17
|
+
type Static,
|
|
18
|
+
} from "@earendil-works/pi-schema";
|
|
9
19
|
import { dependentsOf, formatItemRef, parseItemRef, unsatisfiedDeps } from "../core/deps.ts";
|
|
10
20
|
import type { TodoItem, TodoList, TrackerState } from "../core/domain.ts";
|
|
11
21
|
import type { EncodedState } from "../core/persistence.ts";
|
|
@@ -23,6 +33,15 @@ export const TOOL_ACTIONS = [
|
|
|
23
33
|
|
|
24
34
|
export type TrackerToolAction = (typeof TOOL_ACTIONS)[number];
|
|
25
35
|
|
|
36
|
+
/**
|
|
37
|
+
* The action enum keeps an explicit `type: "string"`. Some providers reject an
|
|
38
|
+
* enum without a type, and TypeBox's `StringEnum` existed for that reason.
|
|
39
|
+
*/
|
|
40
|
+
const actionSchema: Schema<TrackerToolAction> = {
|
|
41
|
+
type: "string",
|
|
42
|
+
...oneOf(TOOL_ACTIONS, { description: "Tracker operation to perform" }),
|
|
43
|
+
};
|
|
44
|
+
|
|
26
45
|
export const TRACKER_TOOL_NAME = "tracker";
|
|
27
46
|
export const TRACKER_TOOL_LABEL = "Tracker";
|
|
28
47
|
|
|
@@ -30,96 +49,72 @@ export const TRACKER_TOOL_LABEL = "Tracker";
|
|
|
30
49
|
* How an item is declared when it is created: bare text, or an object that
|
|
31
50
|
* also carries the same-list items it must wait for.
|
|
32
51
|
*/
|
|
33
|
-
const depsSchema =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
52
|
+
const depsSchema = arr(str({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
53
|
+
description: "Same-list items that must be done before this one.",
|
|
54
|
+
});
|
|
37
55
|
|
|
38
56
|
/** The item-title cap. Enforced only at the tool input, never persisted. */
|
|
39
57
|
export const TITLE_LIMIT = 200;
|
|
40
58
|
|
|
41
|
-
const titleField =
|
|
59
|
+
const titleField = str({
|
|
42
60
|
description:
|
|
43
61
|
"Item title: one short action line (max 200 characters). Move longer detail into 'description'.",
|
|
44
62
|
});
|
|
45
63
|
|
|
46
|
-
const descriptionField =
|
|
64
|
+
const descriptionField = str({
|
|
47
65
|
description:
|
|
48
66
|
"Optional: the longer explanation of the item. Put the essential detail in the first paragraph.",
|
|
49
67
|
});
|
|
50
68
|
|
|
51
69
|
/** A declared reference: a path (optionally narrowed to a symbol or span) or a decision topic. */
|
|
52
|
-
const referenceSchema =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
kind: Type.Literal("decision"),
|
|
65
|
-
topic: Type.String({ description: "The decision the item depends on." }),
|
|
66
|
-
},
|
|
67
|
-
{ additionalProperties: false },
|
|
68
|
-
),
|
|
70
|
+
const referenceSchema = union([
|
|
71
|
+
obj({
|
|
72
|
+
kind: lit("path"),
|
|
73
|
+
path: str({ description: "The file path this item must read next." }),
|
|
74
|
+
symbol: opt(str({ description: "A symbol inside the path." })),
|
|
75
|
+
span: opt(str({ description: 'A line span, e.g. "12-14" or "12".' })),
|
|
76
|
+
}),
|
|
77
|
+
obj({
|
|
78
|
+
kind: lit("decision"),
|
|
79
|
+
topic: str({ description: "The decision the item depends on." }),
|
|
80
|
+
}),
|
|
69
81
|
]);
|
|
70
82
|
|
|
71
|
-
const refsSchema =
|
|
83
|
+
const refsSchema = arr(referenceSchema, {
|
|
72
84
|
description:
|
|
73
85
|
"Optional: the files, symbols, regions, or decisions this item must read after the completed item finishes.",
|
|
74
86
|
});
|
|
75
87
|
|
|
76
|
-
const producesSchema =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{ additionalProperties: false },
|
|
80
|
-
),
|
|
81
|
-
{ description: "Optional: every document this item will write." },
|
|
82
|
-
);
|
|
88
|
+
const producesSchema = arr(obj({ path: str({ description: "A document the item will write." }) }), {
|
|
89
|
+
description: "Optional: every document this item will write.",
|
|
90
|
+
});
|
|
83
91
|
|
|
84
92
|
/** One new item, as the strict item object both add paths accept. */
|
|
85
|
-
const ItemObjectSchema =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
// Item objects are strict: a typo inside one fails here.
|
|
94
|
-
{ additionalProperties: false },
|
|
95
|
-
);
|
|
93
|
+
const ItemObjectSchema = obj({
|
|
94
|
+
title: titleField,
|
|
95
|
+
description: opt(descriptionField),
|
|
96
|
+
refs: opt(refsSchema),
|
|
97
|
+
produces: opt(producesSchema),
|
|
98
|
+
deps: opt(depsSchema),
|
|
99
|
+
});
|
|
96
100
|
|
|
97
101
|
/** One `update_items` patch: the item id plus the fields to replace. */
|
|
98
|
-
const UpdatePatchSchema =
|
|
99
|
-
{
|
|
100
|
-
|
|
102
|
+
const UpdatePatchSchema = obj({
|
|
103
|
+
item_id: str({
|
|
104
|
+
description: 'The id of the item within list_id, as shown by the list action (e.g. "Work:2").',
|
|
105
|
+
}),
|
|
106
|
+
title: opt(str({ description: "Replacement title for the item." })),
|
|
107
|
+
description: opt(str({ description: "Replacement description for the item." })),
|
|
108
|
+
refs: opt(refsSchema),
|
|
109
|
+
produces: opt(producesSchema),
|
|
110
|
+
done: opt(bool({ description: "true marks the item done, false reopens it." })),
|
|
111
|
+
deps: opt(
|
|
112
|
+
arr(str({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
101
113
|
description:
|
|
102
|
-
|
|
114
|
+
"Replacement dependency set for this item. Pass [] to clear. Must not form a cycle.",
|
|
103
115
|
}),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Type.String({ description: "Replacement description for the item." }),
|
|
107
|
-
),
|
|
108
|
-
refs: Type.Optional(refsSchema),
|
|
109
|
-
produces: Type.Optional(producesSchema),
|
|
110
|
-
done: Type.Optional(
|
|
111
|
-
Type.Boolean({ description: "true marks the item done, false reopens it." }),
|
|
112
|
-
),
|
|
113
|
-
deps: Type.Optional(
|
|
114
|
-
Type.Array(Type.String({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
115
|
-
description:
|
|
116
|
-
"Replacement dependency set for this item. Pass [] to clear. Must not form a cycle.",
|
|
117
|
-
}),
|
|
118
|
-
),
|
|
119
|
-
},
|
|
120
|
-
// Patch objects are strict: a typo inside an item update fails here.
|
|
121
|
-
{ additionalProperties: false },
|
|
122
|
-
);
|
|
116
|
+
),
|
|
117
|
+
});
|
|
123
118
|
|
|
124
119
|
/** One item to add, as the tool accepts it. */
|
|
125
120
|
export type TrackerItemSpec = Static<typeof ItemObjectSchema>;
|
|
@@ -135,61 +130,63 @@ export type TrackerUpdatePatch = Static<typeof UpdatePatchSchema>;
|
|
|
135
130
|
* receives a precise, actionable error message instead of a generic schema
|
|
136
131
|
* rejection.
|
|
137
132
|
*/
|
|
138
|
-
export const TrackerToolParams =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
133
|
+
export const TrackerToolParams = obj(
|
|
134
|
+
{
|
|
135
|
+
action: actionSchema,
|
|
136
|
+
list_id: opt(
|
|
137
|
+
num({
|
|
138
|
+
description:
|
|
139
|
+
"List id, as shown by the list action. Required for delete_list, add_items, and for update_items' items={...} batch; optional for set_active (omit to deselect).",
|
|
140
|
+
}),
|
|
141
|
+
),
|
|
142
|
+
item_id: opt(
|
|
143
|
+
str({
|
|
144
|
+
description:
|
|
145
|
+
'Item id, as shown by the list action: listName:id (e.g. "Work:2"). Ids are permanent: removing an item does not change the other ids. Required for update_items (scalar form) and remove_item.',
|
|
146
|
+
}),
|
|
147
|
+
),
|
|
148
|
+
name: opt(str({ description: "Name for the new list. Required for create_list." })),
|
|
149
|
+
initial_items: opt(
|
|
150
|
+
arr(ItemObjectSchema, {
|
|
151
|
+
description:
|
|
152
|
+
"For create_list: initial items, each {title, description?, refs?, produces?, deps?}, added when the list is created.",
|
|
153
|
+
minItems: 1,
|
|
154
|
+
}),
|
|
155
|
+
),
|
|
156
|
+
activate: opt(
|
|
157
|
+
bool({
|
|
158
|
+
description:
|
|
159
|
+
"For create_list: switch the active list to the new list (defaults to true; pass false to keep the current active list).",
|
|
160
|
+
}),
|
|
161
|
+
),
|
|
162
|
+
title: opt(
|
|
163
|
+
str({
|
|
164
|
+
description: "For update_items: the replacement title for the item (max 200 characters).",
|
|
165
|
+
}),
|
|
166
|
+
),
|
|
167
|
+
description: opt(descriptionField),
|
|
168
|
+
refs: opt(refsSchema),
|
|
169
|
+
produces: opt(producesSchema),
|
|
170
|
+
done: opt(
|
|
171
|
+
bool({ description: "For update_items: true marks the item done, false reopens it." }),
|
|
172
|
+
),
|
|
173
|
+
deps: opt(
|
|
174
|
+
arr(str({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
175
|
+
description:
|
|
176
|
+
"For update_items: the replacement dependency set (same-list items that must be done first). Pass [] to clear. Must not form a cycle.",
|
|
177
|
+
}),
|
|
178
|
+
),
|
|
179
|
+
items: opt(
|
|
180
|
+
arr(union([ItemObjectSchema, UpdatePatchSchema]), {
|
|
181
|
+
description:
|
|
182
|
+
"For add_items: the item objects to add, each {title, description?, refs?, produces?, deps?}. For update_items: the item patches, each with an item_id.",
|
|
183
|
+
minItems: 1,
|
|
184
|
+
}),
|
|
185
|
+
),
|
|
186
|
+
},
|
|
187
|
+
// Unknown top-level fields are tolerated and reported by `validateTrackerCall`.
|
|
188
|
+
{ open: true },
|
|
189
|
+
);
|
|
193
190
|
|
|
194
191
|
export type TrackerToolParams = Static<typeof TrackerToolParams>;
|
|
195
192
|
|
|
@@ -484,15 +481,15 @@ export function validateTrackerCall(args: unknown): TrackerCallValidation {
|
|
|
484
481
|
/** Structured result payload attached to tool calls, consumed by the renderers. */
|
|
485
482
|
export interface TrackerToolDetails {
|
|
486
483
|
action: TrackerToolAction;
|
|
487
|
-
error?: string;
|
|
488
|
-
listId?: number;
|
|
484
|
+
error?: string | undefined;
|
|
485
|
+
listId?: number | undefined;
|
|
489
486
|
/** `listName:id`, as shown by the list action. */
|
|
490
|
-
itemId?: string;
|
|
491
|
-
list?: TodoList;
|
|
487
|
+
itemId?: string | undefined;
|
|
488
|
+
list?: TodoList | undefined;
|
|
492
489
|
/** Items affected by an add_items/update_items call, in creation/patch order. */
|
|
493
|
-
items?: TodoItem[];
|
|
490
|
+
items?: TodoItem[] | undefined;
|
|
494
491
|
/** Full state snapshot, only for the `list` action (for rendering). */
|
|
495
|
-
snapshot?: EncodedState;
|
|
492
|
+
snapshot?: EncodedState | undefined;
|
|
496
493
|
}
|
|
497
494
|
|
|
498
495
|
/**
|
|
@@ -586,7 +583,7 @@ export const doneMarkReminder = (
|
|
|
586
583
|
patches: readonly { readonly done?: boolean }[],
|
|
587
584
|
openRemaining?: number,
|
|
588
585
|
): string | null => {
|
|
589
|
-
const doneCount = patches.filter((patch) => patch.done
|
|
586
|
+
const doneCount = patches.filter((patch) => patch.done ?? false).length;
|
|
590
587
|
// Only the terminal batch — two or more done marks with nothing left open —
|
|
591
588
|
// is flagged. Batches that finish several items while other work remains are
|
|
592
589
|
// normal mid-turn progress and stay quiet. When the post-call open count is
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assert, it } from "@effect/vitest";
|
|
2
|
-
import
|
|
1
|
+
import { assert, it, vi } from "@effect/vitest";
|
|
2
|
+
import { themeDouble } from "@ftrdotdev/pi-test-kit";
|
|
3
3
|
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
4
4
|
import { VimRouter } from "@ftrdotdev/pi-tui";
|
|
5
5
|
import { Effect } from "effect";
|
|
@@ -17,32 +17,26 @@ import {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Identity theme: styles pass text through unchanged, so render output is
|
|
20
|
-
* plain text that assertions can search.
|
|
21
|
-
* `fg`, `bold`, `strikethrough` and `style`, which this stub covers.
|
|
20
|
+
* plain text that assertions can search.
|
|
22
21
|
*/
|
|
23
|
-
const identityTheme =
|
|
24
|
-
fg: (_color: string, text: string): string => text,
|
|
25
|
-
bold: (text: string): string => text,
|
|
26
|
-
strikethrough: (text: string): string => text,
|
|
27
|
-
style: (text: string): string => text,
|
|
28
|
-
} as unknown as Theme;
|
|
22
|
+
const identityTheme = themeDouble();
|
|
29
23
|
|
|
30
24
|
/** A realistic two-list state: Work is the active list. */
|
|
31
25
|
const twoListState = (): TrackerState =>
|
|
32
|
-
|
|
26
|
+
TrackerState.make({
|
|
33
27
|
lists: [
|
|
34
|
-
|
|
28
|
+
TodoList.make({
|
|
35
29
|
id: 1,
|
|
36
30
|
name: "Work",
|
|
37
31
|
items: [
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
TodoItem.make({ title: "write plan", done: true }),
|
|
33
|
+
TodoItem.make({ title: "implement tracker", done: false }),
|
|
40
34
|
],
|
|
41
35
|
}),
|
|
42
|
-
|
|
36
|
+
TodoList.make({
|
|
43
37
|
id: 2,
|
|
44
38
|
name: "Home",
|
|
45
|
-
items: [
|
|
39
|
+
items: [TodoItem.make({ title: "water plants", done: false })],
|
|
46
40
|
}),
|
|
47
41
|
],
|
|
48
42
|
activeListId: 1,
|
|
@@ -65,7 +59,7 @@ interface OverlayHarness {
|
|
|
65
59
|
|
|
66
60
|
/** Build a real `VimRouter` service gated on `enabled`. */
|
|
67
61
|
const vimRouter = (enabled: boolean): VimRouter["Service"] =>
|
|
68
|
-
Effect.
|
|
62
|
+
Effect.service(VimRouter).pipe(Effect.provide(VimRouter.make(() => enabled)), Effect.runSync);
|
|
69
63
|
|
|
70
64
|
/**
|
|
71
65
|
* Build an overlay over a scripted state. `onAction` mirrors the real
|
|
@@ -86,7 +80,11 @@ const makeOverlay = (
|
|
|
86
80
|
onAction: async (action) => {
|
|
87
81
|
actions.push(action);
|
|
88
82
|
if (action.type === "setActive") {
|
|
89
|
-
current =
|
|
83
|
+
current = TrackerState.make({
|
|
84
|
+
lists: current.lists,
|
|
85
|
+
activeListId: action.listId,
|
|
86
|
+
nextListId: current.nextListId,
|
|
87
|
+
});
|
|
90
88
|
}
|
|
91
89
|
return null;
|
|
92
90
|
},
|
|
@@ -96,22 +94,19 @@ const makeOverlay = (
|
|
|
96
94
|
return { overlay, actions };
|
|
97
95
|
};
|
|
98
96
|
|
|
99
|
-
/** Flush the microtask queue so fire-and-forget `runAction` continuations land. */
|
|
100
|
-
const flushAsync = (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0));
|
|
101
|
-
|
|
102
97
|
// --------------------------------------------------------------------------
|
|
103
98
|
// Interactive overlay: items pane follows the focused list
|
|
104
99
|
// --------------------------------------------------------------------------
|
|
105
100
|
|
|
106
101
|
it("overlay renders a multi-line description as separate lines", () => {
|
|
107
|
-
const list =
|
|
102
|
+
const list = TodoList.make({
|
|
108
103
|
id: 1,
|
|
109
104
|
name: "Work",
|
|
110
105
|
items: [
|
|
111
|
-
|
|
106
|
+
TodoItem.make({ id: 1, title: "multi", description: "first line\nsecond line", done: false }),
|
|
112
107
|
],
|
|
113
108
|
});
|
|
114
|
-
const h = makeOverlay(
|
|
109
|
+
const h = makeOverlay(TrackerState.make({ lists: [list], activeListId: 1, nextListId: 2 }));
|
|
115
110
|
const lines = h.overlay.render(80);
|
|
116
111
|
assert.equal(
|
|
117
112
|
lines.some((line) => line.includes("\n")),
|
|
@@ -147,9 +142,10 @@ it("enter commits the focused list as active and opens its items", async () => {
|
|
|
147
142
|
const h = makeOverlay(twoListState());
|
|
148
143
|
h.overlay.handleInput("\x1b[B"); // focus Home
|
|
149
144
|
h.overlay.handleInput("\r"); // commit
|
|
150
|
-
await flushAsync();
|
|
151
145
|
|
|
152
|
-
|
|
146
|
+
await vi.waitFor(() => {
|
|
147
|
+
assert.deepStrictEqual(h.actions, [{ type: "setActive", listId: 2 }]);
|
|
148
|
+
});
|
|
153
149
|
const text = h.overlay.render(80).join("\n");
|
|
154
150
|
assert.match(text, /Items — Home/);
|
|
155
151
|
assert.match(text, /water plants/);
|
|
@@ -268,18 +264,22 @@ it("widget renders the active list's items", () => {
|
|
|
268
264
|
});
|
|
269
265
|
|
|
270
266
|
it("widget renders nothing when no list is active (bridge hides it)", () => {
|
|
271
|
-
const state =
|
|
267
|
+
const state = TrackerState.make({
|
|
268
|
+
lists: twoListState().lists,
|
|
269
|
+
activeListId: null,
|
|
270
|
+
nextListId: twoListState().nextListId,
|
|
271
|
+
});
|
|
272
272
|
assert.deepStrictEqual(renderTrackerWidget(state, identityTheme, 40), []);
|
|
273
273
|
});
|
|
274
274
|
|
|
275
275
|
it("widget shows a dimmed description line truncated to the width", () => {
|
|
276
276
|
const description = "x".repeat(120);
|
|
277
|
-
const list =
|
|
277
|
+
const list = TodoList.make({
|
|
278
278
|
id: 1,
|
|
279
279
|
name: "Work",
|
|
280
|
-
items: [
|
|
280
|
+
items: [TodoItem.make({ id: 1, title: "long item", description, done: false })],
|
|
281
281
|
});
|
|
282
|
-
const state =
|
|
282
|
+
const state = TrackerState.make({ lists: [list], activeListId: 1, nextListId: 2 });
|
|
283
283
|
const width = 40;
|
|
284
284
|
const lines = renderTrackerWidget(state, identityTheme, width);
|
|
285
285
|
const text = lines.join("\n");
|
|
@@ -291,14 +291,14 @@ it("widget shows a dimmed description line truncated to the width", () => {
|
|
|
291
291
|
});
|
|
292
292
|
|
|
293
293
|
it("widget collapses a multi-line description into one line", () => {
|
|
294
|
-
const list =
|
|
294
|
+
const list = TodoList.make({
|
|
295
295
|
id: 1,
|
|
296
296
|
name: "Work",
|
|
297
297
|
items: [
|
|
298
|
-
|
|
298
|
+
TodoItem.make({ id: 1, title: "multi", description: "first line\nsecond line", done: false }),
|
|
299
299
|
],
|
|
300
300
|
});
|
|
301
|
-
const state =
|
|
301
|
+
const state = TrackerState.make({ lists: [list], activeListId: 1, nextListId: 2 });
|
|
302
302
|
const lines = renderTrackerWidget(state, identityTheme, 60);
|
|
303
303
|
assert.equal(
|
|
304
304
|
lines.some((line) => line.includes("\n")),
|
|
@@ -329,13 +329,12 @@ it("widget survives the setWidget bridge wrapper (render/invalidate handed off b
|
|
|
329
329
|
|
|
330
330
|
/** A list of `count` items; the first `done` items are done. */
|
|
331
331
|
const listOfCount = (count: number, done: number): TodoList =>
|
|
332
|
-
|
|
332
|
+
TodoList.make({
|
|
333
333
|
id: 1,
|
|
334
334
|
name: "Work",
|
|
335
335
|
nextItemId: count + 1,
|
|
336
|
-
items: Array.from(
|
|
337
|
-
{
|
|
338
|
-
(_, index) => new TodoItem({ id: index + 1, title: `item ${index + 1}`, done: index < done }),
|
|
336
|
+
items: Array.from({ length: count }, (_, index) =>
|
|
337
|
+
TodoItem.make({ id: index + 1, title: `item ${index + 1}`, done: index < done }),
|
|
339
338
|
),
|
|
340
339
|
});
|
|
341
340
|
|
|
@@ -347,23 +346,22 @@ const listWithDeps = (
|
|
|
347
346
|
deps: ReadonlyArray<readonly string[]>,
|
|
348
347
|
done: readonly number[] = [],
|
|
349
348
|
): TodoList =>
|
|
350
|
-
|
|
349
|
+
TodoList.make({
|
|
351
350
|
id: 1,
|
|
352
351
|
name: "Work",
|
|
353
352
|
nextItemId: deps.length + 1,
|
|
354
|
-
items: deps.map(
|
|
355
|
-
(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}),
|
|
353
|
+
items: deps.map((itemDeps, index) =>
|
|
354
|
+
TodoItem.make({
|
|
355
|
+
id: index + 1,
|
|
356
|
+
title: `item ${index + 1}`,
|
|
357
|
+
done: done.includes(index),
|
|
358
|
+
deps: itemDeps,
|
|
359
|
+
}),
|
|
362
360
|
),
|
|
363
361
|
});
|
|
364
362
|
|
|
365
363
|
const stateWith = (list: TodoList): TrackerState =>
|
|
366
|
-
|
|
364
|
+
TrackerState.make({ lists: [list], activeListId: list.id, nextListId: 2 });
|
|
367
365
|
|
|
368
366
|
const shownIndexes = (rows: readonly WidgetRow[]): number[] =>
|
|
369
367
|
rows.flatMap((row) => (row.kind === "item" ? [row.index] : []));
|
|
@@ -537,19 +535,17 @@ it("a dependency-free list renders exactly as before", () => {
|
|
|
537
535
|
it("planner anchors on the first ready item, not the first open item", () => {
|
|
538
536
|
// Item 1 is done; item 2 waits for item 30. The first open item is item 2
|
|
539
537
|
// and the first ready item is item 3.
|
|
540
|
-
const list =
|
|
538
|
+
const list = TodoList.make({
|
|
541
539
|
id: 1,
|
|
542
540
|
name: "Work",
|
|
543
541
|
nextItemId: 31,
|
|
544
|
-
items: Array.from(
|
|
545
|
-
{
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
deps: index === 1 ? ["Work:30"] : [],
|
|
552
|
-
}),
|
|
542
|
+
items: Array.from({ length: 30 }, (_, index) =>
|
|
543
|
+
TodoItem.make({
|
|
544
|
+
id: index + 1,
|
|
545
|
+
title: `item ${index + 1}`,
|
|
546
|
+
done: index === 0,
|
|
547
|
+
deps: index === 1 ? ["Work:30"] : [],
|
|
548
|
+
}),
|
|
553
549
|
),
|
|
554
550
|
});
|
|
555
551
|
// Item 2 sits last in the derived order, after everything it waits for.
|
|
@@ -585,11 +581,13 @@ it("annotates a done item whose dependency is open again in the overlay", () =>
|
|
|
585
581
|
it("paints the selected overlay row with the selection background", () => {
|
|
586
582
|
// Marker theme: `style()` records the background token so the test can see
|
|
587
583
|
// the selection paint without a real terminal theme.
|
|
588
|
-
const markerTheme = {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
options.bg ===
|
|
592
|
-
|
|
584
|
+
const markerTheme = themeDouble({
|
|
585
|
+
style: (text, options) => {
|
|
586
|
+
// Only a background token is marked; a concrete terminal color is not.
|
|
587
|
+
const bg = typeof options.bg === "string" ? options.bg : undefined;
|
|
588
|
+
return bg === undefined ? text : `[${bg}]${text}[/${bg}]`;
|
|
589
|
+
},
|
|
590
|
+
});
|
|
593
591
|
const overlay = makeTrackerOverlay({
|
|
594
592
|
getState: () => twoListState(),
|
|
595
593
|
theme: markerTheme,
|
|
@@ -622,8 +620,9 @@ const makeCopyOverlay = (): { overlay: TrackerOverlayHandle; copied: string[] }
|
|
|
622
620
|
it("copies the selected list and reports it (c in the lists pane)", async () => {
|
|
623
621
|
const { overlay, copied } = makeCopyOverlay();
|
|
624
622
|
overlay.handleInput("c");
|
|
625
|
-
await
|
|
626
|
-
|
|
623
|
+
await vi.waitFor(() => {
|
|
624
|
+
assert.deepStrictEqual(copied, ["Work"]);
|
|
625
|
+
});
|
|
627
626
|
assert.ok(overlay.render(80).some((line) => line.includes("Copied")));
|
|
628
627
|
});
|
|
629
628
|
|
|
@@ -631,9 +630,10 @@ it("copies the selected item reference and text (c in the items pane)", async ()
|
|
|
631
630
|
const { overlay, copied } = makeCopyOverlay();
|
|
632
631
|
overlay.handleInput("\t"); // switch to the items pane
|
|
633
632
|
overlay.handleInput("c");
|
|
634
|
-
await
|
|
635
|
-
|
|
636
|
-
|
|
633
|
+
await vi.waitFor(() => {
|
|
634
|
+
assert.strictEqual(copied.length, 1);
|
|
635
|
+
assert.match(copied[0]!, /^Work:\d+ /);
|
|
636
|
+
});
|
|
637
637
|
});
|
|
638
638
|
|
|
639
639
|
it("moves the selection on wheel events", () => {
|