gentle-pi 3.2.1 → 3.3.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/docs/gentle-shell.md +27 -14
- package/docs/readme-reference.md +41 -7
- package/docs/review-integration.md +22 -17
- package/extensions/gentle-agents.ts +85 -17
- package/extensions/gentle-ai.ts +123 -21
- package/extensions/gentle-shell.ts +379 -31
- package/extensions/gentle-todo.ts +19 -1
- package/lib/agents-view.ts +41 -14
- package/lib/agents-widget.ts +84 -13
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/double-esc-cancel-policy.ts +138 -0
- package/lib/inprocess-reviewer.ts +260 -0
- package/lib/native-review-cli.ts +14 -0
- package/lib/odd-runtime-delegation-gate.ts +88 -0
- package/lib/review-host-relay.ts +246 -171
- package/lib/review-integration-v2.ts +110 -26
- package/lib/shell-bar.ts +150 -75
- package/lib/shell-card.ts +19 -9
- package/lib/shell-changes-view.ts +43 -5
- package/lib/shell-changes.ts +92 -5
- package/lib/shell-hover.ts +39 -0
- package/lib/shell-prompt.ts +10 -1
- package/lib/shell-sidebar-layout.ts +111 -15
- package/lib/shell-sidebar.ts +16 -0
- package/lib/shell-todo.ts +7 -1
- package/lib/shell-usage-view.ts +98 -10
- package/package.json +1 -1
- package/runtime/native-review-cli.mjs +14 -0
- package/runtime/review-integration-v2.mjs +110 -26
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/maintainer/provider-relay-matrix.mjs +118 -47
- package/scripts/verify-package-files.mjs +3 -3
- package/tests/agents-grouping.test.ts +75 -18
- package/tests/agents-view.test.ts +28 -18
- package/tests/agents-widget.test.ts +100 -12
- package/tests/command-palette.test.ts +1 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +176 -138
- package/tests/double-esc-cancel-policy.test.ts +194 -0
- package/tests/gentle-agents.test.ts +528 -5
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-installer.test.ts +47 -47
- package/tests/gentle-ai.test.ts +69 -5
- package/tests/gentle-shell.test.ts +795 -23
- package/tests/gentle-todo.test.ts +17 -4
- package/tests/inprocess-reviewer.test.ts +368 -0
- package/tests/maintainer/provider-relay.maintest.ts +101 -143
- package/tests/native-review-capability-contract.test.ts +19 -1
- package/tests/odd-runtime-delegation-gate.test.ts +212 -0
- package/tests/orchestrator-rdd-ownership.test.ts +3 -3
- package/tests/package-manifest.test.ts +6 -6
- package/tests/review-host-relay-routing.test.ts +77 -0
- package/tests/review-host-relay.test.ts +277 -300
- package/tests/review-integration-v2-forward.test.ts +61 -0
- package/tests/review-integration-v2.test.ts +116 -1
- package/tests/review-relay-transport-agent.test.ts +22 -24
- package/tests/runtime-harness.mjs +11 -0
- package/tests/session-changes-shell.test.ts +27 -0
- package/tests/session-worktree-registry.test.ts +41 -0
- package/tests/shell-bar.test.ts +192 -124
- package/tests/shell-card.test.ts +5 -3
- package/tests/shell-changes-view.test.ts +47 -0
- package/tests/shell-changes.test.ts +177 -0
- package/tests/shell-hover.test.ts +19 -0
- package/tests/shell-prompt.test.ts +20 -0
- package/tests/shell-sidebar-fullscreen.test.ts +59 -0
- package/tests/shell-sidebar-layout.test.ts +243 -5
- package/tests/shell-sidebar.test.ts +25 -1
- package/tests/shell-todo.test.ts +36 -0
- package/tests/shell-usage-view.test.ts +120 -1
- package/lib/opaque-pi-reviewer-adapter.ts +0 -404
- package/tests/opaque-pi-reviewer-adapter.test.ts +0 -410
package/tests/shell-bar.test.ts
CHANGED
|
@@ -2,17 +2,18 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
4
4
|
import {
|
|
5
|
+
buildShellHeaderModel,
|
|
5
6
|
formatCost,
|
|
6
7
|
formatTokens,
|
|
7
8
|
gaugeTone,
|
|
8
9
|
renderGauge,
|
|
9
10
|
renderShellBar,
|
|
11
|
+
renderShellHeaderBar,
|
|
10
12
|
renderShellSidebarBar,
|
|
11
13
|
shellEnabled,
|
|
12
14
|
type ShellBarModel,
|
|
13
15
|
type ShellBarTheme,
|
|
14
16
|
} from "../lib/shell-bar.ts";
|
|
15
|
-
import { parseNanQuota } from "../lib/shell-usage.ts";
|
|
16
17
|
|
|
17
18
|
// The Gentle Shell bar replaces pi's three-line footer with one line of
|
|
18
19
|
// segments. Rendering is pure so it can be verified without a TUI.
|
|
@@ -53,28 +54,6 @@ function model(overrides: Partial<ShellBarModel> = {}): ShellBarModel {
|
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
// The grouped NaN fixture the panel test uses, so both surfaces are asserted
|
|
57
|
-
// against the same payload, the same order and the same percentages.
|
|
58
|
-
const GROUPED_NAN_QUOTA = {
|
|
59
|
-
periodEnd: "2026-10-01T00:00:00.000Z",
|
|
60
|
-
models: [
|
|
61
|
-
{ model: "glm5.3-flash", cap: 2_000_000_000, tokensUsed: 200_000_000 },
|
|
62
|
-
{ model: "glm5.3", cap: 3_000_000_000, tokensUsed: 0, periodEnd: "2026-10-17T05:53:20.000Z" },
|
|
63
|
-
{ model: "glm5.2", cap: 3_000_000_000, tokensUsed: 0, periodEnd: "2026-10-17T05:53:20.000Z" },
|
|
64
|
-
{ model: "deepseek-v4-flash", cap: 3_000_000_000, tokensUsed: 300_000_000 },
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// The sidebar prints the card body between its borders; the Usage rows are the
|
|
69
|
-
// metered block between the Usage heading and Integrations, minus the context
|
|
70
|
-
// meter, which is not a subscription allowance.
|
|
71
|
-
function sidebarUsageRows(lines: string[]): string[] {
|
|
72
|
-
const body = lines.filter((line) => line.startsWith("│ ")).map((line) => line.slice(2, -2).trim());
|
|
73
|
-
const start = body.indexOf("Usage");
|
|
74
|
-
const end = body.indexOf("Integrations");
|
|
75
|
-
return body.slice(start + 1, end).filter((line) => /[▰▱]/.test(line) && !line.startsWith("Context"));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
57
|
test("renderGauge fills cells proportionally to the percentage", () => {
|
|
79
58
|
assert.equal(renderGauge(45, 8), "▰▰▰▰▱▱▱▱");
|
|
80
59
|
assert.equal(renderGauge(0, 8), "▱▱▱▱▱▱▱▱");
|
|
@@ -158,57 +137,9 @@ test("renderShellBar meters the model the session is using inside a multi-model
|
|
|
158
137
|
assert.doesNotMatch(glm, /deepseek-v4-flash ▰/);
|
|
159
138
|
const [other] = renderShellBar(model({ modelId: "deepseek-v4-flash", usage }), plainTheme, 200);
|
|
160
139
|
assert.match(other, /deepseek-v4-flash ▰▱▱▱▱▱▱▱ 18%$/);
|
|
161
|
-
const sidebar = renderShellSidebarBar(model({ modelId: "glm5.3-flash", usage }), plainTheme, 60).join("\n");
|
|
162
|
-
assert.match(sidebar, /glm5\.3-flash +▰▱▱▱▱▱▱▱ +10%/, "the sidebar lists the session model's own allowance");
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// The sidebar is the surface that never needs opening, so a provider with
|
|
166
|
-
// per-model allowances shows the panel's model rows there too — most consumed
|
|
167
|
-
// family first, its models inside it — and leaves the aggregate totals and the
|
|
168
|
-
// reset dates to the bar and the panel.
|
|
169
|
-
test("sidebar groups the NaN allowances by subscription without totals or resets", () => {
|
|
170
|
-
const usage = parseNanQuota(GROUPED_NAN_QUOTA, 0);
|
|
171
|
-
const lines = renderShellSidebarBar(model({ modelId: "glm5.3-flash", usage }), plainTheme, 60);
|
|
172
|
-
const rows = sidebarUsageRows(lines);
|
|
173
|
-
assert.deepEqual(rows.map((row) => row.replace(/\s*[▰▱].*$/, "")), ["deepseek-v4-flash", "glm5.3-flash"]);
|
|
174
|
-
assert.deepEqual(rows.map((row) => Number.parseInt(row.match(/(\d+)%$/)![1] ?? "", 10)), [10, 10]);
|
|
175
|
-
assert.equal(rows.some((row) => / 0%$/.test(row)), false, "a window that consumed nothing only spends space");
|
|
176
|
-
assert.equal(lines.join("\n").includes("total"), false, "an aggregate row only costs space");
|
|
177
|
-
assert.equal(lines.join("\n").includes("resets in"), false, "the reset dates belong to the panel");
|
|
178
|
-
for (const width of [24, 46, 60]) {
|
|
179
|
-
assert.ok(renderShellSidebarBar(model({ usage }), plainTheme, width).every((line) => visibleWidth(line) <= width));
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test("sidebar treats one metered NaN allowance as a per-model provider", () => {
|
|
184
|
-
const usage = parseNanQuota({
|
|
185
|
-
periodEnd: "2026-10-01T00:00:00.000Z",
|
|
186
|
-
models: [{ model: "glm5.3-flash", cap: 2_000_000_000, tokensUsed: 400_000_000, windowHours: 4, windowTokens: 400_000_000, windowTokensUsed: 120_000_000, windowResetsAt: 1_788_620_161 }],
|
|
187
|
-
}, 0);
|
|
188
|
-
const lines = renderShellSidebarBar(model({ modelId: "glm5.3-flash", usage }), plainTheme, 60);
|
|
189
|
-
const rows = sidebarUsageRows(lines).map((row) => row.replace(/\s+/g, " "));
|
|
190
|
-
// A single allowance is still the panel's rows, not the bar's one-line meter:
|
|
191
|
-
// the rolling window it reports is a row of its own here too, and the reset
|
|
192
|
-
// stays in the panel.
|
|
193
|
-
assert.deepEqual(rows, ["glm5.3-flash ▰▰▱▱▱▱▱▱ 20%", "glm5.3-flash 4h ▰▰▱▱▱▱▱▱ 30%"]);
|
|
194
|
-
assert.equal(lines.join("\n").includes("resets in"), false);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test("sidebar keeps one aggregate line for a provider without raw allowances", () => {
|
|
198
|
-
const usage = {
|
|
199
|
-
provider: "openai-codex",
|
|
200
|
-
plan: "pro",
|
|
201
|
-
fetchedAt: 0,
|
|
202
|
-
limits: [{ name: "codex", limitReached: false, windows: [
|
|
203
|
-
{ label: "5h", usedPercent: 62, windowSeconds: 18_000, resetAt: null },
|
|
204
|
-
{ label: "week", usedPercent: 31, windowSeconds: 604_800, resetAt: null },
|
|
205
|
-
] }],
|
|
206
|
-
};
|
|
207
|
-
const lines = renderShellSidebarBar(model({ usage }), plainTheme, 60);
|
|
208
|
-
assert.deepEqual(sidebarUsageRows(lines), ["codex 5h ▰▰▰▰▰▱▱▱ 62% · week 31%"]);
|
|
209
140
|
});
|
|
210
141
|
|
|
211
|
-
test("
|
|
142
|
+
test("renderShellBar keeps its own zero-window contract independent of the sidebar", () => {
|
|
212
143
|
const usage = {
|
|
213
144
|
provider: "openai-codex",
|
|
214
145
|
plan: "pro",
|
|
@@ -218,58 +149,9 @@ test("sidebar drops an aggregate allowance that consumed nothing", () => {
|
|
|
218
149
|
{ label: "week", usedPercent: 0, windowSeconds: 604_800, resetAt: null },
|
|
219
150
|
] }],
|
|
220
151
|
};
|
|
221
|
-
const lines = renderShellSidebarBar(model({ usage }), plainTheme, 60);
|
|
222
|
-
assert.deepEqual(sidebarUsageRows(lines), []);
|
|
223
|
-
const text = lines.join("\n");
|
|
224
|
-
assert.match(text, /Usage/);
|
|
225
|
-
assert.match(text, /Context/);
|
|
226
|
-
assert.match(text, /Cost/);
|
|
227
|
-
// The bar keeps its own contract: only the sidebar gives zero rows the boot.
|
|
228
152
|
assert.match(renderShellBar(model({ usage }), plainTheme, 200)[0], /codex 5h ▱▱▱▱▱▱▱▱ 0% · week 0%$/);
|
|
229
153
|
});
|
|
230
154
|
|
|
231
|
-
test("sidebar keeps the Usage group when nothing was consumed", () => {
|
|
232
|
-
const usage = parseNanQuota({
|
|
233
|
-
periodEnd: "2026-10-01T00:00:00.000Z",
|
|
234
|
-
models: [
|
|
235
|
-
{ model: "glm5.3", cap: 3_000_000_000, tokensUsed: 0 },
|
|
236
|
-
{ model: "glm5.2", cap: 3_000_000_000, tokensUsed: 0 },
|
|
237
|
-
],
|
|
238
|
-
}, 0);
|
|
239
|
-
const lines = renderShellSidebarBar(model({ usage }), plainTheme, 60);
|
|
240
|
-
const text = lines.join("\n");
|
|
241
|
-
assert.deepEqual(sidebarUsageRows(lines), []);
|
|
242
|
-
assert.match(text, /Usage/);
|
|
243
|
-
assert.match(text, /Context/);
|
|
244
|
-
assert.match(text, /Cost/);
|
|
245
|
-
assert.match(text, /Integrations/);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
test("sidebar hides exactly the rows that would print 0%, rounding included", () => {
|
|
249
|
-
// The row's own rounding is the only threshold: a fraction below half a
|
|
250
|
-
// percent is a 0% row and leaves; half a percent keeps its row and prints 1%.
|
|
251
|
-
const usage = (usedPercent: number) => ({
|
|
252
|
-
provider: "openai-codex",
|
|
253
|
-
plan: "pro",
|
|
254
|
-
fetchedAt: 0,
|
|
255
|
-
limits: [{ name: "codex", limitReached: false, windows: [{ label: "5h", usedPercent, windowSeconds: 18_000, resetAt: null }] }],
|
|
256
|
-
});
|
|
257
|
-
assert.deepEqual(sidebarUsageRows(renderShellSidebarBar(model({ usage: usage(0.4) }), plainTheme, 60)), []);
|
|
258
|
-
assert.deepEqual(sidebarUsageRows(renderShellSidebarBar(model({ usage: usage(0.5) }), plainTheme, 60)), ["codex 5h ▱▱▱▱▱▱▱▱ 1%"]);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
test("sidebar reads a limit without windows as nothing to draw, not as zero consumption", () => {
|
|
262
|
-
const usage = {
|
|
263
|
-
provider: "openai-codex",
|
|
264
|
-
plan: "pro",
|
|
265
|
-
fetchedAt: 0,
|
|
266
|
-
limits: [{ name: "codex", limitReached: false, windows: [] }],
|
|
267
|
-
};
|
|
268
|
-
const lines = renderShellSidebarBar(model({ usage }), plainTheme, 60);
|
|
269
|
-
assert.deepEqual(sidebarUsageRows(lines), []);
|
|
270
|
-
assert.match(lines.join("\n"), /Cost/);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
155
|
test("renderShellBar shows an unknown context as a question mark after compaction", () => {
|
|
274
156
|
const [line] = renderShellBar(model({ contextPercent: null }), plainTheme, 160);
|
|
275
157
|
assert.match(line, /ctx ▱▱▱▱▱▱▱▱ \?%/);
|
|
@@ -326,13 +208,20 @@ test("shellEnabled honors GENTLE_PI_SHELL=0", () => {
|
|
|
326
208
|
assert.equal(shellEnabled({ GENTLE_PI_SHELL: "false" }), false);
|
|
327
209
|
});
|
|
328
210
|
|
|
329
|
-
test("
|
|
211
|
+
test("renderShellSidebarBar paints the Status card frame with border and the title with accent", () => {
|
|
212
|
+
const lines = renderShellSidebarBar(model(), taggedTheme, 46);
|
|
213
|
+
assert.match(lines[0], /^<border>╭<\/border>/);
|
|
214
|
+
assert.match(lines[0], /<accent>✿ Status<\/accent>/);
|
|
215
|
+
assert.match(lines[lines.length - 1], /^<border>╰<\/border>/);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("sidebar unifies project, captured changes and integrations in one frame", () => {
|
|
330
219
|
const data = model({ changes: { files: 2, added: 7, deleted: 3, notice: "capture warning" }, statuses: ["MCP connected"] });
|
|
331
220
|
const lines = renderShellSidebarBar(data, plainTheme, 46);
|
|
332
221
|
const text = lines.join("\n");
|
|
333
222
|
assert.equal(lines.filter((line) => line.startsWith("╭")).length, 1);
|
|
334
223
|
let previous = -1;
|
|
335
|
-
for (const heading of ["Status", "Project", "Changes", "
|
|
224
|
+
for (const heading of ["Status", "Project", "Changes", "Integrations"]) {
|
|
336
225
|
const index = text.indexOf(heading);
|
|
337
226
|
assert.ok(index > previous, heading);
|
|
338
227
|
previous = index;
|
|
@@ -340,7 +229,7 @@ test("sidebar unifies project, captured changes, usage and integrations in one f
|
|
|
340
229
|
assert.match(text, /2 files.*\+7.*−3/);
|
|
341
230
|
assert.match(text, /capture warning/);
|
|
342
231
|
assert.match(text, /\/gentle:changes/);
|
|
343
|
-
assert.match(text, /
|
|
232
|
+
assert.match(text, /main/);
|
|
344
233
|
for (const width of [1, 8, 24, 46]) assert.ok(renderShellSidebarBar(data, plainTheme, width).every((line) => visibleWidth(line) <= width));
|
|
345
234
|
const empty = renderShellSidebarBar(model(), plainTheme, 46).join("\n");
|
|
346
235
|
assert.match(empty, /No captured changes/);
|
|
@@ -359,3 +248,182 @@ test("sidebar profile wraps long names without changing the compact bar", () =>
|
|
|
359
248
|
}
|
|
360
249
|
assert.deepEqual(renderShellBar(active, plainTheme, 120), renderShellBar(base, plainTheme, 120));
|
|
361
250
|
});
|
|
251
|
+
|
|
252
|
+
test("sidebar Status card drops Model, Effort, Context, Cost and Usage, keeping Project, Changes and Integrations", () => {
|
|
253
|
+
const usage = {
|
|
254
|
+
provider: "openai-codex",
|
|
255
|
+
plan: "pro",
|
|
256
|
+
fetchedAt: 0,
|
|
257
|
+
limits: [{ name: "codex", limitReached: false, windows: [{ label: "5h", usedPercent: 62, windowSeconds: 18_000, resetAt: null }] }],
|
|
258
|
+
};
|
|
259
|
+
const data = model({ profile: "team", sessionName: "session", usage, changes: { files: 1, added: 2, deleted: 1 }, statuses: ["MCP connected"] });
|
|
260
|
+
const text = renderShellSidebarBar(data, plainTheme, 60).join("\n");
|
|
261
|
+
assert.doesNotMatch(text, /Usage/);
|
|
262
|
+
assert.doesNotMatch(text, /Model/);
|
|
263
|
+
assert.doesNotMatch(text, /Effort/);
|
|
264
|
+
assert.doesNotMatch(text, /Context/);
|
|
265
|
+
assert.doesNotMatch(text, /Cost/);
|
|
266
|
+
assert.doesNotMatch(text, /\$9\.49/);
|
|
267
|
+
assert.doesNotMatch(text, /codex 5h/);
|
|
268
|
+
for (const heading of ["Status", "Project", "Changes", "Integrations"]) assert.match(text, new RegExp(heading));
|
|
269
|
+
assert.match(text, /Branch.*main/);
|
|
270
|
+
assert.match(text, /Session.*session/);
|
|
271
|
+
assert.match(text, /Profile.*team/);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// The live header row above the fullscreen rail: identity on the left (brand,
|
|
275
|
+
// location, model · effort · profile), the per-frame counters right-aligned
|
|
276
|
+
// (context gauge, cost). Never the working/thinking state or extension
|
|
277
|
+
// statuses — those stay in the prompt and the Status card.
|
|
278
|
+
|
|
279
|
+
test("buildShellHeaderModel keeps only the header's fields from the bar model", () => {
|
|
280
|
+
const header = buildShellHeaderModel(model({ profile: "team", statuses: ["MCP: 3 servers"] }));
|
|
281
|
+
assert.deepEqual(header, {
|
|
282
|
+
cwd: "~/work/gentle-pi",
|
|
283
|
+
branch: "main",
|
|
284
|
+
dirty: undefined,
|
|
285
|
+
modelId: "gpt-5.5",
|
|
286
|
+
effort: "medium",
|
|
287
|
+
profile: "team",
|
|
288
|
+
contextPercent: 45,
|
|
289
|
+
costTotal: 9.49,
|
|
290
|
+
subscription: true,
|
|
291
|
+
usage: undefined,
|
|
292
|
+
});
|
|
293
|
+
assert.ok(!("statuses" in header), "extension statuses never reach the header");
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test("renderShellHeaderBar draws the brand, identity, and right-aligned counters (plus the standing usage segment) in one line", () => {
|
|
297
|
+
const header = buildShellHeaderModel(model({ profile: "team" }));
|
|
298
|
+
const { text: line } = renderShellHeaderBar(header, plainTheme, 120);
|
|
299
|
+
const left = "✿ Gentle Shell ⟡ ~/work/gentle-pi main ⟡ gpt-5.5 · medium · team";
|
|
300
|
+
const right = "ctx ▰▰▰▰▱▱▱▱ 45% ⟡ $9.49 sub ⟡ usage";
|
|
301
|
+
assert.equal(line, left + " ".repeat(120 - visibleWidth(left) - visibleWidth(right)) + right);
|
|
302
|
+
assert.equal(visibleWidth(line), 120);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
test("renderShellHeaderBar never shows working state or extension statuses", () => {
|
|
306
|
+
const header = buildShellHeaderModel(model({ statuses: ["MCP: 3 servers", "working…"] }));
|
|
307
|
+
const { text: line } = renderShellHeaderBar(header, plainTheme, 120);
|
|
308
|
+
assert.doesNotMatch(line, /MCP: 3 servers/);
|
|
309
|
+
assert.doesNotMatch(line, /working/);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test("renderShellHeaderBar colors the brand bold and by role", () => {
|
|
313
|
+
const bolding = { fg: (color: string, text: string) => `<${color}>${text}</${color}>`, bold: (text: string) => `**${text}**` };
|
|
314
|
+
const header = buildShellHeaderModel(model());
|
|
315
|
+
const { text: line } = renderShellHeaderBar(header, bolding, 120);
|
|
316
|
+
assert.match(line, /<accent>\*\*✿ Gentle Shell\*\*<\/accent>/);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test("renderShellHeaderBar drops the profile, then the effort, then the whole location before the right group", () => {
|
|
320
|
+
const withProfile = buildShellHeaderModel(model({ profile: "team" }));
|
|
321
|
+
const { text: wide } = renderShellHeaderBar(withProfile, plainTheme, 120);
|
|
322
|
+
assert.match(wide, /gpt-5\.5 · medium · team/);
|
|
323
|
+
assert.match(wide, /~\/work\/gentle-pi main/);
|
|
324
|
+
assert.match(wide, /ctx ▰▰▰▰▱▱▱▱ 45% ⟡ \$9\.49 sub ⟡ usage$/);
|
|
325
|
+
|
|
326
|
+
// 100 cols: the profile no longer fits, but effort and location still do.
|
|
327
|
+
const { text: noProfile } = renderShellHeaderBar(withProfile, plainTheme, 100);
|
|
328
|
+
assert.doesNotMatch(noProfile, /team/);
|
|
329
|
+
assert.match(noProfile, /gpt-5\.5 · medium/);
|
|
330
|
+
assert.match(noProfile, /~\/work\/gentle-pi main/);
|
|
331
|
+
assert.equal(visibleWidth(noProfile), 100);
|
|
332
|
+
|
|
333
|
+
// 90 cols: effort goes too, only the bare model id remains next to location.
|
|
334
|
+
const { text: noEffort } = renderShellHeaderBar(withProfile, plainTheme, 90);
|
|
335
|
+
assert.doesNotMatch(noEffort, /medium/);
|
|
336
|
+
assert.doesNotMatch(noEffort, /team/);
|
|
337
|
+
assert.match(noEffort, /gpt-5\.5/);
|
|
338
|
+
assert.match(noEffort, /~\/work\/gentle-pi main/);
|
|
339
|
+
assert.equal(visibleWidth(noEffort), 90);
|
|
340
|
+
|
|
341
|
+
// 82 cols: the whole location segment goes; brand and model survive with the counters.
|
|
342
|
+
const { text: noLocation } = renderShellHeaderBar(withProfile, plainTheme, 82);
|
|
343
|
+
assert.doesNotMatch(noLocation, /~\/work\/gentle-pi/);
|
|
344
|
+
assert.match(noLocation, /gpt-5\.5/);
|
|
345
|
+
assert.match(noLocation, /✿ Gentle Shell/);
|
|
346
|
+
assert.match(noLocation, /ctx ▰▰▰▰▱▱▱▱ 45% ⟡ \$9\.49 sub ⟡ usage$/);
|
|
347
|
+
assert.equal(visibleWidth(noLocation), 82);
|
|
348
|
+
|
|
349
|
+
// 60 cols: even the standing usage segment is gone now; brand+model and ctx/cost survive.
|
|
350
|
+
const { text: noUsage } = renderShellHeaderBar(withProfile, plainTheme, 60);
|
|
351
|
+
assert.doesNotMatch(noUsage, /~\/work\/gentle-pi/);
|
|
352
|
+
assert.doesNotMatch(noUsage, /usage/);
|
|
353
|
+
assert.match(noUsage, /gpt-5\.5/);
|
|
354
|
+
assert.match(noUsage, /✿ Gentle Shell/);
|
|
355
|
+
assert.match(noUsage, /ctx ▰▰▰▰▱▱▱▱ 45% ⟡ \$9\.49 sub$/);
|
|
356
|
+
assert.equal(visibleWidth(noUsage), 60);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
test("renderShellHeaderBar returns an empty string only once the brand itself cannot fit", () => {
|
|
360
|
+
assert.equal(renderShellHeaderBar(buildShellHeaderModel(model()), plainTheme, 3).text, "");
|
|
361
|
+
assert.match(renderShellHeaderBar(buildShellHeaderModel(model()), plainTheme, 40).text, /✿ Gentle Shell/);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// T8: the usage segment. It rides after cost in the right group, shows every
|
|
365
|
+
// window of the active provider's main limit, and degrades (gauges, then
|
|
366
|
+
// secondary windows, then the whole segment) before ctx/cost is ever touched.
|
|
367
|
+
|
|
368
|
+
const USAGE_TWO_WINDOWS = {
|
|
369
|
+
provider: "openai-codex",
|
|
370
|
+
plan: "pro",
|
|
371
|
+
fetchedAt: 0,
|
|
372
|
+
limits: [{ name: "codex", limitReached: false, windows: [
|
|
373
|
+
{ label: "5h", usedPercent: 26, windowSeconds: 18_000, resetAt: null },
|
|
374
|
+
{ label: "week", usedPercent: 12, windowSeconds: 604_800, resetAt: null },
|
|
375
|
+
] }],
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
test("renderShellHeaderBar shows every usage window with its gauge and the shortcut hint, after cost", () => {
|
|
379
|
+
const header = buildShellHeaderModel(model({ usage: USAGE_TWO_WINDOWS }));
|
|
380
|
+
const { text, usageSpan } = renderShellHeaderBar(header, plainTheme, 140, "alt+u");
|
|
381
|
+
assert.match(text, /\$9\.49 sub ⟡ usage 5h ▰▰▱▱▱▱▱▱ 26% · week ▰▱▱▱▱▱▱▱ 12% · alt\+u$/);
|
|
382
|
+
assert.ok(usageSpan);
|
|
383
|
+
assert.equal(text.slice(usageSpan.start, usageSpan.end), "usage 5h ▰▰▱▱▱▱▱▱ 26% · week ▰▱▱▱▱▱▱▱ 12% · alt+u");
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
test("renderShellHeaderBar shows 'usage · <shortcut>' with no data, and drops the hint when the shortcut is disabled", () => {
|
|
387
|
+
const withHint = renderShellHeaderBar(buildShellHeaderModel(model({ usage: undefined })), plainTheme, 140, "alt+u");
|
|
388
|
+
assert.match(withHint.text, /usage · alt\+u$/);
|
|
389
|
+
const noHint = renderShellHeaderBar(buildShellHeaderModel(model({ usage: undefined })), plainTheme, 140, undefined);
|
|
390
|
+
assert.match(noHint.text, /usage$/);
|
|
391
|
+
assert.doesNotMatch(noHint.text, /alt\+u/);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test("renderShellHeaderBar degrades the usage segment (gauges, then secondary windows, then the whole segment) before touching ctx/cost", () => {
|
|
395
|
+
const header = buildShellHeaderModel(model({ usage: USAGE_TWO_WINDOWS }));
|
|
396
|
+
const full = renderShellHeaderBar(header, plainTheme, 140, "alt+u").text;
|
|
397
|
+
assert.match(full, /5h ▰▰▱▱▱▱▱▱ 26% · week ▰▱▱▱▱▱▱▱ 12%/);
|
|
398
|
+
|
|
399
|
+
// 100 cols: the gauges no longer fit, but both windows still show as text
|
|
400
|
+
// (a positive match on the bare "5h 26% · week 12%" run rules out any
|
|
401
|
+
// gauge glyph sneaking in between them; ctx's own gauge is unrelated).
|
|
402
|
+
const noGauges = renderShellHeaderBar(header, plainTheme, 100, "alt+u").text;
|
|
403
|
+
assert.match(noGauges, /usage 5h 26% · week 12% · alt\+u$/);
|
|
404
|
+
assert.match(noGauges, /ctx ▰▰▰▰▱▱▱▱ 45% ⟡ \$9\.49 sub/, "ctx/cost are untouched while usage still degrades");
|
|
405
|
+
assert.equal(visibleWidth(noGauges), 100);
|
|
406
|
+
|
|
407
|
+
// 80 cols: only the first window remains.
|
|
408
|
+
const primaryOnly = renderShellHeaderBar(header, plainTheme, 80, "alt+u").text;
|
|
409
|
+
assert.match(primaryOnly, /usage 5h 26% · alt\+u$/);
|
|
410
|
+
assert.doesNotMatch(primaryOnly, /week/);
|
|
411
|
+
assert.match(primaryOnly, /ctx ▰▰▰▰▱▱▱▱ 45% ⟡ \$9\.49 sub/);
|
|
412
|
+
assert.equal(visibleWidth(primaryOnly), 80);
|
|
413
|
+
|
|
414
|
+
// 70 cols: the whole usage segment is gone, ctx/cost remain intact.
|
|
415
|
+
const noUsage = renderShellHeaderBar(header, plainTheme, 70, "alt+u").text;
|
|
416
|
+
assert.doesNotMatch(noUsage, /usage/);
|
|
417
|
+
assert.match(noUsage, /ctx ▰▰▰▰▱▱▱▱ 45% ⟡ \$9\.49 sub$/);
|
|
418
|
+
assert.equal(visibleWidth(noUsage), 70);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
test("renderShellHeaderBar's usage span always points at the usage text, not ctx/cost", () => {
|
|
422
|
+
const header = buildShellHeaderModel(model({ usage: USAGE_TWO_WINDOWS }));
|
|
423
|
+
for (const width of [140, 100, 90]) {
|
|
424
|
+
const { text, usageSpan } = renderShellHeaderBar(header, plainTheme, width, "alt+u");
|
|
425
|
+
if (!usageSpan) continue;
|
|
426
|
+
assert.match(text.slice(usageSpan.start, usageSpan.end), /^usage/);
|
|
427
|
+
assert.equal(usageSpan.end, visibleWidth(text), "the usage segment always ends at the right edge");
|
|
428
|
+
}
|
|
429
|
+
});
|
package/tests/shell-card.test.ts
CHANGED
|
@@ -54,10 +54,12 @@ test("renderCard collapses to the frame and the first body line with an expand h
|
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
test("renderCard uses the card tone across the full frame while preserving content roles", () => {
|
|
57
|
+
// INFO paints the rose frame: the rounded border in the plain border role,
|
|
58
|
+
// the title in accent — the same look every sidebar card already used.
|
|
57
59
|
const info = renderCard(card(), taggedTheme, 80, { expanded: true });
|
|
58
|
-
assert.match(info[0], /^<
|
|
59
|
-
assert.match(info[1], /^<
|
|
60
|
-
assert.match(info[info.length - 1], /^<
|
|
60
|
+
assert.match(info[0], /^<border>╭<\/border><border>─ <\/border><accent>✿ Gentle AI<\/accent> <muted>·<\/muted> <muted>review preflight<\/muted><border> ─+<\/border><border>╮<\/border>$/);
|
|
61
|
+
assert.match(info[1], /^<border>│<\/border> <text>.*<border>│<\/border>$/);
|
|
62
|
+
assert.match(info[info.length - 1], /^<border>╰<\/border><border>─+╯<\/border>$/);
|
|
61
63
|
|
|
62
64
|
const warning = renderCard(card({ tone: CARD_TONE.WARNING, subtitle: undefined }), taggedTheme, 80, { expanded: true });
|
|
63
65
|
assert.match(warning[0], /^<warning>╭<\/warning>/);
|
|
@@ -62,6 +62,30 @@ function mouseButton(type: TuiMouseEvent["type"], button: TuiMouseEvent["button"
|
|
|
62
62
|
return { type, button, x, y, screenX: x, screenY: y, width: 80, height, shift: false, alt: false, ctrl: false };
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// H1 (odd/tasks/usage-click-and-changes-attribution.md): the same shared
|
|
66
|
+
// hover role every other clickable surface uses, and it never overrides the
|
|
67
|
+
// already-selected row's own role.
|
|
68
|
+
test("WorktreeChangesView paints the shared hover role over an unselected row, never the selected one", async () => {
|
|
69
|
+
const trees = ["/main", "/linked"].map((root) => ({ root, branch: root === "/main" ? "main" : undefined, model: changesModel([file("same.ts", 1, 0)]) }));
|
|
70
|
+
const component = new WorktreeChangesView(trees, {
|
|
71
|
+
theme: taggedTheme, rows: 10,
|
|
72
|
+
loadDiff: async () => "",
|
|
73
|
+
onOpen: () => {},
|
|
74
|
+
onClose: () => {}, requestRender() {}, onRefresh() {},
|
|
75
|
+
});
|
|
76
|
+
component.render(80);
|
|
77
|
+
// Row y=1 is the selected group header (/main, index 0); row y=2 is /linked's header.
|
|
78
|
+
const hoverOther = component.handleMouse(mouseButton("move", "none", 3, 2, 10));
|
|
79
|
+
assert.deepEqual(hoverOther, { handled: true, render: true });
|
|
80
|
+
assert.match(component.render(80)[2]!, /<warning>[^<]*detached/, "hovering the unselected row paints the shared hover role");
|
|
81
|
+
assert.doesNotMatch(component.render(80)[1]!, /<warning>/, "the selected row keeps its own role");
|
|
82
|
+
|
|
83
|
+
const hoverSelected = component.handleMouse(mouseButton("move", "none", 3, 1, 10));
|
|
84
|
+
assert.deepEqual(hoverSelected, { handled: true, render: true });
|
|
85
|
+
assert.doesNotMatch(component.render(80)[1]!, /<warning>/, "hovering the selected row still never paints the hover role");
|
|
86
|
+
assert.doesNotMatch(component.render(80)[2]!, /<warning>/, "leaving the other row clears its hover");
|
|
87
|
+
});
|
|
88
|
+
|
|
65
89
|
test("worktree accordion keeps groups and nested files beside a framed lazy diff", async () => {
|
|
66
90
|
const trees = ["/main", "/linked"].map((root) => ({ root, branch: root === "/main" ? "main" : undefined, model: changesModel([file("same.ts", 1, 0)]) }));
|
|
67
91
|
const loaded: string[] = [];
|
|
@@ -503,6 +527,29 @@ test("ChangesView opens the selected file and closes on escape or q", async () =
|
|
|
503
527
|
assert.equal(events.filter((event) => event === "close").length, 2);
|
|
504
528
|
});
|
|
505
529
|
|
|
530
|
+
// H1 (odd/tasks/usage-click-and-changes-attribution.md): the same shared
|
|
531
|
+
// hover role every other clickable surface uses, and it never overrides the
|
|
532
|
+
// already-selected row's own role.
|
|
533
|
+
test("ChangesView paints the shared hover role over an unselected file row, never the selected one", async () => {
|
|
534
|
+
const { view: component } = view({ theme: taggedTheme });
|
|
535
|
+
await settle();
|
|
536
|
+
component.render(80);
|
|
537
|
+
// Row y=1 is the selected file (lib/a.ts, index 0); row y=2 is lib/b.ts.
|
|
538
|
+
const hoverOther = component.handleMouse(mouseButton("move", "none", 3, 2, 12));
|
|
539
|
+
assert.deepEqual(hoverOther, { handled: true, render: true });
|
|
540
|
+
assert.match(component.render(80)[2]!, /<warning>[^<]*lib\/b\.ts/, "the hovered, unselected row paints the shared hover role");
|
|
541
|
+
assert.doesNotMatch(component.render(80)[1]!, /<warning>/, "the selected row keeps its own role instead");
|
|
542
|
+
|
|
543
|
+
const hoverSelected = component.handleMouse(mouseButton("move", "none", 3, 1, 12));
|
|
544
|
+
assert.deepEqual(hoverSelected, { handled: true, render: true });
|
|
545
|
+
assert.doesNotMatch(component.render(80)[1]!, /<warning>/, "hovering the selected row still never paints the hover role");
|
|
546
|
+
assert.doesNotMatch(component.render(80)[2]!, /<warning>/, "leaving lib/b.ts clears its hover paint");
|
|
547
|
+
|
|
548
|
+
const left = component.handleMouse(mouseButton("move", "none", 60, 1, 12)); // outside the list pane entirely
|
|
549
|
+
assert.deepEqual(left, { handled: true, render: true });
|
|
550
|
+
assert.doesNotMatch(component.render(80).join("\n"), /<warning>/, "moving off the list clears any hover");
|
|
551
|
+
});
|
|
552
|
+
|
|
506
553
|
test("ChangesView click selects a file without opening it", async () => {
|
|
507
554
|
const { view: component, events } = view();
|
|
508
555
|
await settle();
|