@ftrdotdev/pi-tui 0.7.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 +225 -0
- package/README.md +5 -0
- package/package.json +18 -15
- package/src/activity-service.test.ts +97 -0
- package/src/activity.test.ts +1 -1
- package/src/activity.ts +38 -0
- package/src/chrome/budget.test.ts +345 -0
- package/src/chrome/budget.ts +220 -0
- package/src/chrome/declarations.ts +303 -0
- package/src/chrome/facts.test.ts +165 -0
- package/src/chrome/facts.ts +267 -0
- package/src/chrome/frame.ts +45 -0
- package/src/chrome/laws.test.ts +231 -0
- package/src/chrome/port.test.ts +164 -0
- package/src/chrome/port.ts +67 -0
- package/src/chrome/service-provider.test.ts +383 -0
- package/src/chrome/service-provider.ts +55 -0
- package/src/commands/git-execution.test.ts +5 -2
- package/src/commands/git-execution.ts +27 -15
- package/src/commands/git-status.test.ts +47 -15
- package/src/commands/git-status.ts +83 -31
- package/src/components/bordered-box.test.ts +12 -15
- package/src/components/bordered-box.ts +11 -7
- package/src/components/define-component.ts +1 -1
- package/src/components/index.ts +7 -0
- package/src/components/row-list.test.ts +310 -0
- package/src/components/row-list.ts +272 -0
- package/src/config.test.ts +118 -3
- package/src/config.ts +50 -42
- package/src/frame/box-frame.test.ts +53 -7
- package/src/harness-policy.test.ts +47 -0
- package/src/icons.test.ts +19 -0
- package/src/icons.ts +50 -31
- package/src/index.test.ts +135 -0
- package/src/index.ts +118 -119
- package/src/layers.test.ts +94 -0
- package/src/layers.ts +92 -0
- package/src/runtime-service.test.ts +218 -0
- package/src/runtime-service.ts +103 -0
- package/src/runtime.test.ts +165 -66
- package/src/runtime.ts +127 -93
- package/src/session-lifecycle-service.test.ts +95 -0
- package/src/session-lifecycle.test.ts +77 -0
- package/src/session-lifecycle.ts +21 -0
- package/src/state.test.ts +132 -3
- package/src/state.ts +43 -13
- package/src/telemetry-service.test.ts +250 -0
- package/src/telemetry.test.ts +322 -0
- package/src/telemetry.ts +130 -23
- package/src/ui/editor-tint.test.ts +58 -45
- package/src/ui/editor-tint.ts +1 -1
- package/src/ui/editor.ts +117 -53
- package/src/ui/footer.test.ts +349 -120
- package/src/ui/footer.ts +147 -124
- package/src/ui/header.test.ts +203 -223
- package/src/ui/header.ts +32 -96
- package/src/ui/preview.test.ts +73 -70
- package/src/ui/preview.ts +48 -33
- package/src/ui/render-helpers.test.ts +82 -13
- package/src/ui/render-helpers.ts +110 -122
- package/src/ui/settings-command.test.ts +70 -11
- package/src/ui/settings-command.ts +30 -45
- package/src/ui/theme-color.test.ts +4 -3
- package/src/usage-totals-service.test.ts +230 -0
- package/src/usage-totals-service.ts +59 -0
- package/src/utils.test.ts +46 -50
- package/src/utils.ts +41 -239
- package/src/vim/editor-host.test.ts +201 -75
- package/src/vim/editor-state.ts +2 -2
- package/src/vim/mode-indicator.test.ts +6 -5
- package/src/vim/mode-indicator.ts +13 -9
- package/src/vim/selection-render.ts +8 -4
- package/src/vim/text-model.test.ts +52 -14
- package/src/vim/text-model.ts +1 -1
- package/src/vim/vim-router.test.ts +3 -0
- package/src/vim/vim-router.ts +1 -1
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
// Surface declarations: what each surface may show, in the order it gives
|
|
2
|
+
// things up. The declaration list is the single statement of a surface's
|
|
3
|
+
// fields, their legible floors and their degradation rules.
|
|
4
|
+
import type { FactId, SurfaceId } from "./facts.ts";
|
|
5
|
+
import { FACTS } from "./facts.ts";
|
|
6
|
+
|
|
7
|
+
export type Degradation = "drop" | "truncate" | "drop-then-truncate";
|
|
8
|
+
|
|
9
|
+
export interface SegmentDeclaration {
|
|
10
|
+
/** Segment id, unique within a surface. */
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly fact: FactId;
|
|
13
|
+
/** Which declared line of the surface. */
|
|
14
|
+
readonly line: number;
|
|
15
|
+
/** Total order within the surface; the higher priority survives. */
|
|
16
|
+
readonly priority: number;
|
|
17
|
+
/** Legible floor. */
|
|
18
|
+
readonly minWidth: number;
|
|
19
|
+
readonly degradation: Degradation;
|
|
20
|
+
/** Which end of the line the segment hugs. */
|
|
21
|
+
readonly align: "left" | "right";
|
|
22
|
+
/** The join text before this segment when its group already has one. */
|
|
23
|
+
readonly separator: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SurfaceDescriptor {
|
|
27
|
+
readonly id: SurfaceId;
|
|
28
|
+
readonly lifetime: "process" | "session" | "turn" | "frame";
|
|
29
|
+
readonly lines: number;
|
|
30
|
+
/** Wide-width ceiling = default-enabled fields on fitted lines. */
|
|
31
|
+
readonly maxFields: number;
|
|
32
|
+
/** Lines that are wrapped, never fitted, and never counted against `maxFields`. */
|
|
33
|
+
readonly unfittedLines?: readonly number[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const SURFACES: Record<SurfaceId, SurfaceDescriptor> = {
|
|
37
|
+
footer: { id: "footer", lifetime: "session", lines: 3, maxFields: 10, unfittedLines: [3] },
|
|
38
|
+
header: { id: "header", lifetime: "process", lines: 1, maxFields: 1 },
|
|
39
|
+
notify: { id: "notify", lifetime: "turn", lines: 1, maxFields: 3 },
|
|
40
|
+
border: { id: "border", lifetime: "frame", lines: 1, maxFields: 3 },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const DECLARATIONS: Record<SurfaceId, readonly SegmentDeclaration[]> = {
|
|
44
|
+
footer: [
|
|
45
|
+
{
|
|
46
|
+
id: "contextOccupancy",
|
|
47
|
+
fact: "contextOccupancy",
|
|
48
|
+
line: 1,
|
|
49
|
+
priority: 14,
|
|
50
|
+
minWidth: 8,
|
|
51
|
+
degradation: "drop",
|
|
52
|
+
align: "right",
|
|
53
|
+
separator: " ",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "cwd",
|
|
57
|
+
fact: "cwd",
|
|
58
|
+
line: 1,
|
|
59
|
+
priority: 13,
|
|
60
|
+
minWidth: 8,
|
|
61
|
+
degradation: "truncate",
|
|
62
|
+
align: "left",
|
|
63
|
+
separator: " ",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "workTimer",
|
|
67
|
+
fact: "workTimer",
|
|
68
|
+
line: 1,
|
|
69
|
+
priority: 12,
|
|
70
|
+
minWidth: 4,
|
|
71
|
+
degradation: "truncate",
|
|
72
|
+
align: "left",
|
|
73
|
+
separator: " ",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "gitBranch",
|
|
77
|
+
fact: "gitBranch",
|
|
78
|
+
line: 1,
|
|
79
|
+
priority: 11,
|
|
80
|
+
minWidth: 6,
|
|
81
|
+
degradation: "truncate",
|
|
82
|
+
align: "left",
|
|
83
|
+
separator: " ",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "gitStatus",
|
|
87
|
+
fact: "gitStatus",
|
|
88
|
+
line: 1,
|
|
89
|
+
priority: 10,
|
|
90
|
+
minWidth: 8,
|
|
91
|
+
degradation: "drop-then-truncate",
|
|
92
|
+
align: "left",
|
|
93
|
+
separator: " ",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "modelIdentity",
|
|
97
|
+
fact: "modelIdentity",
|
|
98
|
+
line: 2,
|
|
99
|
+
priority: 9,
|
|
100
|
+
minWidth: 10,
|
|
101
|
+
degradation: "truncate",
|
|
102
|
+
align: "left",
|
|
103
|
+
separator: " ",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: "tokenCounts",
|
|
107
|
+
fact: "tokenCounts",
|
|
108
|
+
line: 2,
|
|
109
|
+
priority: 8,
|
|
110
|
+
minWidth: 8,
|
|
111
|
+
degradation: "truncate",
|
|
112
|
+
align: "right",
|
|
113
|
+
separator: " | ",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: "cost",
|
|
117
|
+
fact: "cost",
|
|
118
|
+
line: 2,
|
|
119
|
+
priority: 7,
|
|
120
|
+
minWidth: 6,
|
|
121
|
+
degradation: "drop",
|
|
122
|
+
align: "right",
|
|
123
|
+
separator: " | ",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "workSplit",
|
|
127
|
+
fact: "workSplit",
|
|
128
|
+
line: 1,
|
|
129
|
+
priority: 6,
|
|
130
|
+
minWidth: 6,
|
|
131
|
+
degradation: "drop",
|
|
132
|
+
align: "left",
|
|
133
|
+
separator: " ",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: "thinking",
|
|
137
|
+
fact: "thinking",
|
|
138
|
+
line: 2,
|
|
139
|
+
priority: 5,
|
|
140
|
+
minWidth: 5,
|
|
141
|
+
degradation: "drop",
|
|
142
|
+
align: "left",
|
|
143
|
+
separator: " · ",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "gitCommit",
|
|
147
|
+
fact: "gitCommit",
|
|
148
|
+
line: 1,
|
|
149
|
+
priority: 4,
|
|
150
|
+
minWidth: 4,
|
|
151
|
+
degradation: "drop",
|
|
152
|
+
align: "left",
|
|
153
|
+
separator: " ",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "runtime",
|
|
157
|
+
fact: "runtime",
|
|
158
|
+
line: 1,
|
|
159
|
+
priority: 3,
|
|
160
|
+
minWidth: 4,
|
|
161
|
+
degradation: "drop",
|
|
162
|
+
align: "left",
|
|
163
|
+
separator: " ",
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "extensionStatuses",
|
|
167
|
+
fact: "extensionStatuses",
|
|
168
|
+
line: 3,
|
|
169
|
+
priority: 2,
|
|
170
|
+
minWidth: 5,
|
|
171
|
+
degradation: "drop",
|
|
172
|
+
align: "left",
|
|
173
|
+
separator: " ",
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
header: [
|
|
177
|
+
{
|
|
178
|
+
id: "version",
|
|
179
|
+
fact: "version",
|
|
180
|
+
line: 0,
|
|
181
|
+
priority: 1,
|
|
182
|
+
minWidth: 12,
|
|
183
|
+
degradation: "drop",
|
|
184
|
+
align: "left",
|
|
185
|
+
separator: " ",
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
notify: [
|
|
189
|
+
{
|
|
190
|
+
id: "turnTps",
|
|
191
|
+
fact: "turnTps",
|
|
192
|
+
line: 1,
|
|
193
|
+
priority: 9,
|
|
194
|
+
minWidth: 8,
|
|
195
|
+
degradation: "drop",
|
|
196
|
+
align: "left",
|
|
197
|
+
separator: " | ",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
id: "turnTtft",
|
|
201
|
+
fact: "turnTtft",
|
|
202
|
+
line: 1,
|
|
203
|
+
priority: 8,
|
|
204
|
+
minWidth: 8,
|
|
205
|
+
degradation: "drop",
|
|
206
|
+
align: "left",
|
|
207
|
+
separator: " | ",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: "turnStalls",
|
|
211
|
+
fact: "turnStalls",
|
|
212
|
+
line: 1,
|
|
213
|
+
priority: 7,
|
|
214
|
+
minWidth: 8,
|
|
215
|
+
degradation: "drop",
|
|
216
|
+
align: "left",
|
|
217
|
+
separator: " | ",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "turnDuration",
|
|
221
|
+
fact: "turnDuration",
|
|
222
|
+
line: 1,
|
|
223
|
+
priority: 6,
|
|
224
|
+
minWidth: 4,
|
|
225
|
+
degradation: "drop",
|
|
226
|
+
align: "left",
|
|
227
|
+
separator: " | ",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "turnTokens",
|
|
231
|
+
fact: "turnTokens",
|
|
232
|
+
line: 1,
|
|
233
|
+
priority: 5,
|
|
234
|
+
minWidth: 6,
|
|
235
|
+
degradation: "drop",
|
|
236
|
+
align: "left",
|
|
237
|
+
separator: " | ",
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
id: "turnCostRate",
|
|
241
|
+
fact: "turnCostRate",
|
|
242
|
+
line: 1,
|
|
243
|
+
priority: 4,
|
|
244
|
+
minWidth: 6,
|
|
245
|
+
degradation: "drop",
|
|
246
|
+
align: "left",
|
|
247
|
+
separator: " | ",
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
border: [
|
|
251
|
+
{
|
|
252
|
+
id: "editorStatus",
|
|
253
|
+
fact: "workState",
|
|
254
|
+
line: 0,
|
|
255
|
+
priority: 3,
|
|
256
|
+
minWidth: 4,
|
|
257
|
+
degradation: "drop-then-truncate",
|
|
258
|
+
align: "left",
|
|
259
|
+
separator: " · ",
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
id: "vimMode",
|
|
263
|
+
fact: "vimMode",
|
|
264
|
+
line: 0,
|
|
265
|
+
priority: 2,
|
|
266
|
+
minWidth: 1,
|
|
267
|
+
degradation: "truncate",
|
|
268
|
+
align: "left",
|
|
269
|
+
separator: " · ",
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: "scrollHint",
|
|
273
|
+
fact: "scrollHint",
|
|
274
|
+
line: 0,
|
|
275
|
+
priority: 1,
|
|
276
|
+
minWidth: 5,
|
|
277
|
+
degradation: "drop",
|
|
278
|
+
align: "left",
|
|
279
|
+
separator: " · ",
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/** The narrow law's threshold: below it, each declared line keeps one field. */
|
|
285
|
+
export const NARROW_WIDTH = 40;
|
|
286
|
+
|
|
287
|
+
/** The per-line field cap a planner passes to the engine (`undefined` when wide). */
|
|
288
|
+
export function narrowCap(width: number): 1 | undefined {
|
|
289
|
+
return width < NARROW_WIDTH ? 1 : undefined;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function declarationsFor(surface: SurfaceId): readonly SegmentDeclaration[] {
|
|
293
|
+
return DECLARATIONS[surface];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function declaredFacts(surface: SurfaceId): readonly FactId[] {
|
|
297
|
+
return declarationsFor(surface).map((declaration) => declaration.fact);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** The surface's declared facts whose registry default is on, in declaration order. */
|
|
301
|
+
export function defaultEnabledFacts(surface: SurfaceId): readonly FactId[] {
|
|
302
|
+
return declaredFacts(surface).filter((fact) => FACTS[fact].defaultEnabled);
|
|
303
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { assert, it } from "@effect/vitest";
|
|
2
|
+
import { DECLARATIONS, defaultEnabledFacts, declarationsFor, SURFACES } from "./declarations.ts";
|
|
3
|
+
import type { FactId, FactRecord, SurfaceId } from "./facts.ts";
|
|
4
|
+
import { FACTS, QUANTITY_EXCEPTIONS, factsFor } from "./facts.ts";
|
|
5
|
+
|
|
6
|
+
const SURFACE_IDS: readonly SurfaceId[] = ["footer", "header", "notify", "border"];
|
|
7
|
+
|
|
8
|
+
/** One declared segment by surface and id, or a readable failure. */
|
|
9
|
+
const declaration = (surface: SurfaceId, id: string) => {
|
|
10
|
+
const found = declarationsFor(surface).find((entry) => entry.id === id);
|
|
11
|
+
assert.ok(found, `expected a ${surface} declaration for "${id}", got none`);
|
|
12
|
+
return found;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
it("every fact has exactly one owning surface", () => {
|
|
16
|
+
// Arrange: the registry.
|
|
17
|
+
const facts: readonly FactRecord[] = Object.values(FACTS);
|
|
18
|
+
|
|
19
|
+
// Act: read every record.
|
|
20
|
+
// Assert: the declared set is complete and each record is coherent.
|
|
21
|
+
assert.strictEqual(facts.length, 23);
|
|
22
|
+
for (const fact of facts) {
|
|
23
|
+
assert.ok(SURFACE_IDS.includes(fact.owner), `${fact.id}: unknown owner ${fact.owner}`);
|
|
24
|
+
assert.strictEqual(
|
|
25
|
+
FACTS[fact.id as FactId].id,
|
|
26
|
+
fact.id,
|
|
27
|
+
`${fact.id}: record key and id disagree`,
|
|
28
|
+
);
|
|
29
|
+
if (fact.key !== undefined) {
|
|
30
|
+
assert.strictEqual(typeof fact.label, "string", `${fact.id}: a key needs a label`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("no quantity is owned by two facts unless the exception is declared", () => {
|
|
36
|
+
// Arrange: the registry and the declared exceptions.
|
|
37
|
+
const facts: readonly FactRecord[] = Object.values(FACTS);
|
|
38
|
+
|
|
39
|
+
// Act: group facts by their user-visible quantity.
|
|
40
|
+
const byQuantity = new Map<string, FactId[]>();
|
|
41
|
+
for (const fact of facts) {
|
|
42
|
+
byQuantity.set(fact.quantity, [...(byQuantity.get(fact.quantity) ?? []), fact.id]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Assert: exactly three declared exceptions, each coherent.
|
|
46
|
+
assert.strictEqual(QUANTITY_EXCEPTIONS.length, 3);
|
|
47
|
+
assert.deepStrictEqual(
|
|
48
|
+
QUANTITY_EXCEPTIONS.map((entry) => entry.quantity),
|
|
49
|
+
["tokens", "cost", "duration"],
|
|
50
|
+
);
|
|
51
|
+
assert.deepStrictEqual(
|
|
52
|
+
QUANTITY_EXCEPTIONS.map((entry) => [...entry.facts]),
|
|
53
|
+
[
|
|
54
|
+
["contextOccupancy", "tokenCounts", "turnTokens"],
|
|
55
|
+
["cost", "turnCostRate"],
|
|
56
|
+
["workTimer", "turnDuration"],
|
|
57
|
+
],
|
|
58
|
+
);
|
|
59
|
+
for (const entry of QUANTITY_EXCEPTIONS) {
|
|
60
|
+
for (const fact of entry.facts) {
|
|
61
|
+
const record = FACTS[fact];
|
|
62
|
+
assert.ok(record, `expected a fact "${fact}", got undefined`);
|
|
63
|
+
assert.strictEqual(
|
|
64
|
+
record.quantity,
|
|
65
|
+
entry.quantity,
|
|
66
|
+
`${fact}: declared ${entry.quantity} but records ${record.quantity}`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const declared = new Set<string>(QUANTITY_EXCEPTIONS.map((entry) => entry.quantity));
|
|
71
|
+
for (const [quantity, owners] of byQuantity) {
|
|
72
|
+
if (owners.length >= 2) {
|
|
73
|
+
assert.ok(declared.has(quantity), `duplicate quantity "${quantity}" is undeclared`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("a fact is declared on its owner and nowhere else", () => {
|
|
79
|
+
// Arrange: the declarations and the registry.
|
|
80
|
+
assert.strictEqual(declaration("footer", "cwd").fact, "cwd");
|
|
81
|
+
assert.strictEqual(declaration("border", "editorStatus").fact, "workState");
|
|
82
|
+
assert.strictEqual(declaration("header", "version").fact, "version");
|
|
83
|
+
assert.strictEqual(declaration("notify", "turnTps").fact, "turnTps");
|
|
84
|
+
|
|
85
|
+
// Act: every declared fact, by surface.
|
|
86
|
+
const seen = new Map<FactId, SurfaceId>();
|
|
87
|
+
for (const surface of SURFACE_IDS) {
|
|
88
|
+
const declarations = DECLARATIONS[surface] ?? [];
|
|
89
|
+
const priorities = new Set<number>();
|
|
90
|
+
for (const entry of declarations) {
|
|
91
|
+
const record = FACTS[entry.fact];
|
|
92
|
+
assert.ok(record, `${surface}/${entry.id}: unknown fact ${entry.fact}`);
|
|
93
|
+
assert.strictEqual(
|
|
94
|
+
record.owner,
|
|
95
|
+
surface,
|
|
96
|
+
`${surface}/${entry.id}: fact ${entry.fact} is owned by ${record.owner}`,
|
|
97
|
+
);
|
|
98
|
+
assert.strictEqual(
|
|
99
|
+
seen.get(entry.fact),
|
|
100
|
+
undefined,
|
|
101
|
+
`${entry.fact}: declared on ${seen.get(entry.fact)} and ${surface}`,
|
|
102
|
+
);
|
|
103
|
+
seen.set(entry.fact, surface);
|
|
104
|
+
assert.ok(
|
|
105
|
+
!priorities.has(entry.priority),
|
|
106
|
+
`${surface}/${entry.id}: priority ${entry.priority} is not unique`,
|
|
107
|
+
);
|
|
108
|
+
priorities.add(entry.priority);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("each surface lists its declarations in descending priority", () => {
|
|
114
|
+
// Assert: declaration order is the composer's output order, so the whole
|
|
115
|
+
// list must read highest priority first; priorities are globally unique.
|
|
116
|
+
for (const surface of SURFACE_IDS) {
|
|
117
|
+
const priorities = (DECLARATIONS[surface] ?? []).map((entry) => entry.priority);
|
|
118
|
+
for (let index = 1; index < priorities.length; index += 1) {
|
|
119
|
+
assert.ok(priorities[index - 1]! > priorities[index]!, `${surface}: priorities must descend`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("each surface's declared ceiling equals its default-enabled field count", () => {
|
|
125
|
+
// Arrange: every surface and its default-enabled fitted facts.
|
|
126
|
+
const fittedDefaultCount = (surface: SurfaceId): number => {
|
|
127
|
+
const unfitted = new Set(SURFACES[surface]?.unfittedLines ?? []);
|
|
128
|
+
const declared = declarationsFor(surface).filter((entry) => !unfitted.has(entry.line));
|
|
129
|
+
return defaultEnabledFacts(surface).filter((fact) =>
|
|
130
|
+
declared.some((entry) => entry.fact === fact),
|
|
131
|
+
).length;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Act/Assert: the declared constant is the derived count, and the named
|
|
135
|
+
// ceilings are the design's.
|
|
136
|
+
assert.strictEqual(SURFACES.footer?.maxFields, 10);
|
|
137
|
+
assert.strictEqual(SURFACES.notify?.maxFields, 3);
|
|
138
|
+
assert.strictEqual(SURFACES.border?.maxFields, 3);
|
|
139
|
+
assert.strictEqual(SURFACES.header?.maxFields, 1);
|
|
140
|
+
for (const surface of SURFACE_IDS) {
|
|
141
|
+
assert.strictEqual(
|
|
142
|
+
SURFACES[surface].maxFields,
|
|
143
|
+
fittedDefaultCount(surface),
|
|
144
|
+
`${surface}: maxFields drifted from the default-enabled field count`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
assert.deepStrictEqual(
|
|
148
|
+
factsFor("footer").map((fact) => fact.id),
|
|
149
|
+
[
|
|
150
|
+
"cwd",
|
|
151
|
+
"gitBranch",
|
|
152
|
+
"gitStatus",
|
|
153
|
+
"gitCommit",
|
|
154
|
+
"runtime",
|
|
155
|
+
"workTimer",
|
|
156
|
+
"workSplit",
|
|
157
|
+
"contextOccupancy",
|
|
158
|
+
"tokenCounts",
|
|
159
|
+
"cost",
|
|
160
|
+
"modelIdentity",
|
|
161
|
+
"thinking",
|
|
162
|
+
"extensionStatuses",
|
|
163
|
+
],
|
|
164
|
+
);
|
|
165
|
+
});
|