gentle-pi 3.2.1 → 3.4.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/README.md +63 -59
- package/assets/orchestrator-delegation.md +1 -1
- package/docs/assets/brand/gentle-shell-banner.gif +0 -0
- package/docs/assets/diagrams/odd-workflow.svg +74 -0
- package/docs/assets/features/agents-view.png +0 -0
- package/docs/assets/features/changes-view.png +0 -0
- package/docs/assets/features/command-palette.png +0 -0
- package/docs/assets/features/profiles-routing.png +0 -0
- package/docs/gentle-shell.md +52 -15
- package/docs/readme-reference.md +67 -7
- package/docs/review-integration.md +22 -17
- package/extensions/ask-user-question.ts +210 -0
- package/extensions/gentle-agents.ts +93 -18
- package/extensions/gentle-ai.ts +180 -37
- package/extensions/gentle-shell.ts +476 -39
- package/extensions/gentle-todo.ts +19 -1
- package/extensions/quiet-tools.ts +28 -5
- package/extensions/startup-banner.ts +25 -10
- package/lib/agents-view.ts +41 -14
- package/lib/agents-widget.ts +84 -13
- package/lib/animation-policy.ts +52 -0
- package/lib/background-cache-warming.ts +38 -0
- package/lib/command-palette-catalog.ts +2 -0
- package/lib/double-esc-cancel-policy.ts +138 -0
- package/lib/inprocess-reviewer.ts +297 -0
- package/lib/native-review-cli.ts +50 -10
- package/lib/odd-runtime-delegation-gate.ts +88 -0
- package/lib/questionnaire/questionnaire-view.ts +603 -0
- package/lib/questionnaire/schema.ts +82 -0
- package/lib/questionnaire/validate.ts +141 -0
- package/lib/review-candidate-view-owner.ts +20 -5
- package/lib/review-candidate-view.ts +9 -2
- package/lib/review-host-relay.ts +256 -171
- package/lib/review-integration-v2.ts +114 -27
- package/lib/shell-bar.ts +163 -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 +118 -16
- package/lib/shell-sidebar.ts +16 -0
- package/lib/shell-todo.ts +7 -1
- package/lib/shell-usage-view.ts +103 -12
- package/lib/shell-usage.ts +120 -6
- package/package.json +1 -1
- package/runtime/native-review-cli.mjs +49 -9
- package/runtime/review-integration-v2.mjs +114 -27
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/maintainer/provider-relay-matrix.mjs +118 -47
- package/scripts/verify-package-files.mjs +3 -4
- 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/animation-policy.test.ts +42 -0
- package/tests/ask-user-question.test.ts +435 -0
- package/tests/background-cache-warming.test.ts +60 -0
- package/tests/background-subagents.test.ts +68 -0
- package/tests/command-palette.test.ts +10 -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 +599 -7
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-installer.test.ts +47 -47
- package/tests/gentle-ai.test.ts +125 -9
- package/tests/gentle-shell.test.ts +1149 -24
- package/tests/gentle-todo.test.ts +17 -4
- package/tests/inprocess-reviewer.test.ts +460 -0
- package/tests/maintainer/provider-relay.maintest.ts +101 -143
- package/tests/native-review-capability-contract.test.ts +34 -1
- package/tests/native-review-parity.test.ts +19 -0
- 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 -17
- package/tests/questionnaire-schema.test.ts +274 -0
- package/tests/questionnaire-view.test.ts +446 -0
- package/tests/rdd-status-line.test.ts +21 -4
- package/tests/review-candidate-owner-retry.test.ts +63 -0
- package/tests/review-candidate-view.test.ts +15 -0
- package/tests/review-controller-native-routing.test.ts +86 -0
- package/tests/review-host-relay-routing.test.ts +77 -0
- package/tests/review-host-relay.test.ts +297 -299
- package/tests/review-integration-v2-forward.test.ts +61 -0
- package/tests/review-integration-v2.test.ts +146 -1
- package/tests/review-ledger-contract.test.ts +1 -2
- package/tests/review-relay-transport-agent.test.ts +129 -26
- package/tests/review-risk-assessment.test.ts +104 -0
- 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 +200 -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 +301 -8
- 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/tests/shell-usage.test.ts +129 -0
- package/tests/skill-collision-prefixes.test.ts +1 -1
- package/tests/startup-banner.test.ts +93 -2
- package/docs/assets/brand/gentle-pi-banner.png +0 -0
- package/lib/opaque-pi-reviewer-adapter.ts +0 -404
- package/skills/release/SKILL.md +0 -137
- package/tests/opaque-pi-reviewer-adapter.test.ts +0 -410
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
CHANGE_STATUS,
|
|
11
11
|
ChangesTracker,
|
|
12
12
|
WorktreeChangesTracker,
|
|
13
|
+
RootBranchLabels,
|
|
14
|
+
UNKNOWN_BRANCH,
|
|
15
|
+
foreignRootBranch,
|
|
13
16
|
parseWorktrees,
|
|
14
17
|
changesSummary,
|
|
15
18
|
emptyChanges,
|
|
@@ -19,6 +22,7 @@ import {
|
|
|
19
22
|
changesModel,
|
|
20
23
|
snapshotChanges,
|
|
21
24
|
type ChangedFile,
|
|
25
|
+
type GitResult,
|
|
22
26
|
} from "../lib/shell-changes.ts";
|
|
23
27
|
|
|
24
28
|
// The changes view shows the working tree against HEAD, new files included,
|
|
@@ -72,6 +76,16 @@ test("parsePorcelain reads NUL-separated status entries including renames and un
|
|
|
72
76
|
);
|
|
73
77
|
});
|
|
74
78
|
|
|
79
|
+
test("parsePorcelain drops embedded-repository markers, never a real file", () => {
|
|
80
|
+
// Git reports a nested .git directory (an embedded/foreign repository, the
|
|
81
|
+
// live evidence's ~/work/NaN-builders inside ~/work) as one directory-shaped
|
|
82
|
+
// "?? path/" line, never expanded into files, even with --untracked-files=all.
|
|
83
|
+
// Treating that line as a changed file creates a phantom entry for whatever
|
|
84
|
+
// ancestor repository happens to contain the nested one.
|
|
85
|
+
const raw = ["?? NaN-builders/", "?? notes.md", " M lib/a.ts"].join("\0") + "\0";
|
|
86
|
+
assert.deepEqual([...parsePorcelain(raw).entries()], [["notes.md", CHANGE_STATUS.UNTRACKED], ["lib/a.ts", CHANGE_STATUS.MODIFIED]]);
|
|
87
|
+
});
|
|
88
|
+
|
|
75
89
|
test("snapshotChanges merges status with counts and keeps untracked files without counts", () => {
|
|
76
90
|
const files = snapshotChanges({
|
|
77
91
|
numstat: "4\t2\tlib/a.ts\n",
|
|
@@ -265,6 +279,114 @@ test("worktree porcelain preserves unusual directory names and detached fallback
|
|
|
265
279
|
assert.deepEqual(parseWorktrees("worktree /a\nbranch strange\0HEAD abc\0detached\0\0"), [{ root: "/a\nbranch strange" }]);
|
|
266
280
|
});
|
|
267
281
|
|
|
282
|
+
// A GitRunner that cannot even ask (root removed, git missing, the runner
|
|
283
|
+
// itself rejecting) must reject foreignRootBranch too -- never resolve to the
|
|
284
|
+
// same undefined a genuinely detached HEAD produces. Swallowing the two into
|
|
285
|
+
// one shape is exactly the bug: the caller has no way left to tell "asked and
|
|
286
|
+
// there is no branch" from "could not ask at all".
|
|
287
|
+
test("foreignRootBranch propagates a GitRunner failure instead of reporting detached", async () => {
|
|
288
|
+
const failing = async (): Promise<GitResult> => { throw new Error("git unavailable"); };
|
|
289
|
+
await assert.rejects(() => foreignRootBranch(failing), /git unavailable/);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test("foreignRootBranch still reports a genuine detached HEAD as undefined, not a failure", async () => {
|
|
293
|
+
const detached = async (args: string[]): Promise<GitResult> => (args[0] === "symbolic-ref" ? { stdout: "", code: 1 } : { stdout: "deadbeef\n", code: 0 });
|
|
294
|
+
assert.equal(await foreignRootBranch(detached), undefined);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// C3 (odd/tasks/usage-click-and-changes-attribution.md): a root registered by
|
|
298
|
+
// the session but absent from a single `git worktree list` scan -- because it
|
|
299
|
+
// belongs to a different Git clone entirely, e.g. an inner repository nested
|
|
300
|
+
// inside an outer one -- must not default to "detached". It must be asked
|
|
301
|
+
// directly, and "no commits yet" must read differently from a real branch.
|
|
302
|
+
test("a root missing from worktree list resolves its own branch instead of defaulting to detached", async (t) => {
|
|
303
|
+
const scenarios: Array<{ name: string; symbolic: { stdout: string; code: number }; verify: { stdout: string; code: number }; expected: string | undefined }> = [
|
|
304
|
+
{ name: "a normal branch on a foreign clone", symbolic: { stdout: "feature\n", code: 0 }, verify: { stdout: "deadbeef\n", code: 0 }, expected: "feature" },
|
|
305
|
+
{ name: "an unborn branch (no commits yet)", symbolic: { stdout: "main\n", code: 0 }, verify: { stdout: "", code: 1 }, expected: "no commits yet" },
|
|
306
|
+
{ name: "a genuinely detached HEAD", symbolic: { stdout: "", code: 1 }, verify: { stdout: "deadbeef\n", code: 0 }, expected: undefined },
|
|
307
|
+
];
|
|
308
|
+
for (const scenario of scenarios) {
|
|
309
|
+
await t.test(scenario.name, async () => {
|
|
310
|
+
const calls: string[][] = [];
|
|
311
|
+
const tracker = new WorktreeChangesTracker(
|
|
312
|
+
async () => ({ stdout: "", code: 0 }), // /foreign never appears in this clone's own worktree list
|
|
313
|
+
() => async (args) => {
|
|
314
|
+
calls.push(args);
|
|
315
|
+
if (args[0] === "status") return { stdout: "?? changed.ts\0", code: 0 };
|
|
316
|
+
if (args[0] === "symbolic-ref") return scenario.symbolic;
|
|
317
|
+
if (args[0] === "rev-parse") return scenario.verify;
|
|
318
|
+
return { stdout: "", code: 0 };
|
|
319
|
+
},
|
|
320
|
+
undefined,
|
|
321
|
+
() => ["/foreign"],
|
|
322
|
+
);
|
|
323
|
+
await tracker.start();
|
|
324
|
+
assert.deepEqual(tracker.worktrees.map((tree) => [tree.root, tree.branch]), [["/foreign", scenario.expected]]);
|
|
325
|
+
assert.ok(calls.some((args) => args[0] === "symbolic-ref"), "a root absent from worktree list must be asked directly");
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// The direct per-root ask (for a root missing from worktree list) can fail on
|
|
331
|
+
// its own -- root gone, git unavailable -- independently of the change scan
|
|
332
|
+
// that already found real files. That failure must label the root
|
|
333
|
+
// UNKNOWN_BRANCH, distinct from "detached", and must never drop the
|
|
334
|
+
// already-captured changes.
|
|
335
|
+
test("a root missing from worktree list keeps its changes and reads UNKNOWN_BRANCH when the direct ask fails", async () => {
|
|
336
|
+
const tracker = new WorktreeChangesTracker(
|
|
337
|
+
async () => ({ stdout: "", code: 0 }),
|
|
338
|
+
() => async (args) => {
|
|
339
|
+
if (args[0] === "status") return { stdout: "?? changed.ts\0", code: 0 };
|
|
340
|
+
if (args[0] === "diff") return { stdout: "", code: 0 };
|
|
341
|
+
throw new Error("git unavailable"); // symbolic-ref / rev-parse: the direct branch ask
|
|
342
|
+
},
|
|
343
|
+
undefined,
|
|
344
|
+
() => ["/foreign"],
|
|
345
|
+
);
|
|
346
|
+
await tracker.start();
|
|
347
|
+
assert.deepEqual(tracker.worktrees.map((tree) => [tree.root, tree.branch]), [["/foreign", UNKNOWN_BRANCH]]);
|
|
348
|
+
assert.equal(tracker.worktrees[0]!.model.files.length, 1, "a failed branch lookup must not drop the root's real changes");
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// A root already described by the same clone's own worktree list is trusted
|
|
352
|
+
// as-is: a real "detached" marker there is already 100% accurate, so no
|
|
353
|
+
// redundant per-root call is needed (and none happens).
|
|
354
|
+
test("a root already described by worktree list is trusted without a redundant lookup", async () => {
|
|
355
|
+
const calls: string[][] = [];
|
|
356
|
+
const tracker = new WorktreeChangesTracker(
|
|
357
|
+
async () => ({ stdout: "worktree /known\0detached\0\0", code: 0 }),
|
|
358
|
+
() => async (args) => {
|
|
359
|
+
calls.push(args);
|
|
360
|
+
return { stdout: args[0] === "status" ? "?? changed.ts\0" : "", code: 0 };
|
|
361
|
+
},
|
|
362
|
+
undefined,
|
|
363
|
+
() => ["/known"],
|
|
364
|
+
);
|
|
365
|
+
await tracker.start();
|
|
366
|
+
assert.deepEqual(tracker.worktrees.map((tree) => [tree.root, tree.branch]), [["/known", undefined]]);
|
|
367
|
+
assert.ok(!calls.some((args) => args[0] === "symbolic-ref"), "a known worktree-list entry must not trigger a fallback call");
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// The live evidence: an outer repo (~/work, no commits) whose ONLY change is
|
|
371
|
+
// the embedded inner repository (~/work/NaN-builders) itself must never show
|
|
372
|
+
// up as a phantom tree once the embedded-repo marker is filtered out of its
|
|
373
|
+
// own file list -- it never had a real file to show in the first place.
|
|
374
|
+
test("an outer ancestor whose only change is the embedded inner repository is never a phantom tree", async () => {
|
|
375
|
+
const tracker = new WorktreeChangesTracker(
|
|
376
|
+
async () => ({ stdout: "", code: 0 }), // neither root belongs to the other's clone
|
|
377
|
+
(root) => async (args) => {
|
|
378
|
+
if (args[0] !== "status") return { stdout: "", code: 0 };
|
|
379
|
+
// The outer root's only "change" is the nested repo directory marker;
|
|
380
|
+
// the inner root has a real file of its own.
|
|
381
|
+
return { stdout: root === "/outer" ? "?? NaN-builders/\0" : "?? jpg-png-converter.md\0", code: 0 };
|
|
382
|
+
},
|
|
383
|
+
undefined,
|
|
384
|
+
() => ["/outer", "/outer/NaN-builders"],
|
|
385
|
+
);
|
|
386
|
+
await tracker.start();
|
|
387
|
+
assert.deepEqual(tracker.worktrees.map((tree) => tree.root), ["/outer/NaN-builders"]);
|
|
388
|
+
});
|
|
389
|
+
|
|
268
390
|
test("registered roots remain scannable during metadata discovery failure", async () => {
|
|
269
391
|
let code = 128;
|
|
270
392
|
const tracker = new WorktreeChangesTracker(async () => ({ stdout: "worktree /repo\0\0", code }), () => async (args) => ({ stdout: args[0] === "status" ? "?? new.ts\0" : "", code: 0 }), undefined, () => ["/repo"]);
|
|
@@ -356,3 +478,58 @@ test("ChangesTracker counts the lines of untracked files, which git numstat leav
|
|
|
356
478
|
assert.equal(model.added, 3);
|
|
357
479
|
assert.deepEqual(counted, ["notes.md", "empty.md"]);
|
|
358
480
|
});
|
|
481
|
+
|
|
482
|
+
// The session-evidence tracker behind /gentle:changes knows roots, never
|
|
483
|
+
// branches. The overlay decorates its trees with each root's own HEAD state,
|
|
484
|
+
// resolved once per root and reported back so the view can repaint; until git
|
|
485
|
+
// answers the tree shows no branch (the view's "detached" fallback), and a
|
|
486
|
+
// genuinely detached HEAD stays that way.
|
|
487
|
+
test("RootBranchLabels decorates session trees with each root's branch once git answers", async () => {
|
|
488
|
+
const calls = new Map<string, string[][]>();
|
|
489
|
+
const answers: Record<string, { symbolic: { stdout: string; code: number }; verify: { stdout: string; code: number } }> = {
|
|
490
|
+
"/repo": { symbolic: { stdout: "feature\n", code: 0 }, verify: { stdout: "deadbeef\n", code: 0 } },
|
|
491
|
+
"/fresh": { symbolic: { stdout: "main\n", code: 0 }, verify: { stdout: "", code: 1 } },
|
|
492
|
+
"/pinned": { symbolic: { stdout: "", code: 1 }, verify: { stdout: "deadbeef\n", code: 0 } },
|
|
493
|
+
};
|
|
494
|
+
let changed = 0;
|
|
495
|
+
const labels = new RootBranchLabels((root) => async (args) => {
|
|
496
|
+
calls.set(root, [...(calls.get(root) ?? []), args]);
|
|
497
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
498
|
+
return args[0] === "symbolic-ref" ? answers[root]!.symbolic : answers[root]!.verify;
|
|
499
|
+
}, () => changed++);
|
|
500
|
+
const trees = Object.keys(answers).map((root) => ({ root, model: changesModel([]) }));
|
|
501
|
+
const first = labels.decorate(trees);
|
|
502
|
+
assert.deepEqual(first.map((tree) => tree.branch), [undefined, undefined, undefined], "nothing is labelled before git answers");
|
|
503
|
+
await labels.settled();
|
|
504
|
+
assert.equal(changed, 3, "each resolved root asks the view to repaint once");
|
|
505
|
+
const second = labels.decorate(trees);
|
|
506
|
+
assert.deepEqual(second.map((tree) => tree.branch), ["feature", "no commits yet", undefined]);
|
|
507
|
+
labels.decorate(trees);
|
|
508
|
+
await labels.settled();
|
|
509
|
+
assert.deepEqual([...calls.values()].map((list) => list.length), [2, 2, 1], "one resolution per root, never per decorate call");
|
|
510
|
+
assert.equal(changed, 3);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// A root that could not even be asked (removed, git unavailable, the runner
|
|
514
|
+
// itself rejecting) must read UNKNOWN_BRANCH -- never the same undefined a
|
|
515
|
+
// genuine detached HEAD produces, and never silently stay unlabelled forever.
|
|
516
|
+
test("RootBranchLabels labels a root UNKNOWN_BRANCH when it could not be asked, distinct from a real detached HEAD", async () => {
|
|
517
|
+
let changed = 0;
|
|
518
|
+
const labels = new RootBranchLabels((root) => async () => {
|
|
519
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
520
|
+
if (root === "/gone") throw new Error("root removed");
|
|
521
|
+
return { stdout: "", code: 1 };
|
|
522
|
+
}, () => changed++);
|
|
523
|
+
const trees = [
|
|
524
|
+
{ root: "/gone", model: changesModel([]) },
|
|
525
|
+
{ root: "/detached", model: changesModel([]) },
|
|
526
|
+
];
|
|
527
|
+
labels.decorate(trees);
|
|
528
|
+
await labels.settled();
|
|
529
|
+
assert.deepEqual(
|
|
530
|
+
labels.decorate(trees).map((tree) => tree.branch),
|
|
531
|
+
[UNKNOWN_BRANCH, undefined],
|
|
532
|
+
"a failed ask reads UNKNOWN_BRANCH; a real detached HEAD still reads undefined (the view's detached fallback)",
|
|
533
|
+
);
|
|
534
|
+
assert.equal(changed, 2, "a failed ask still resolves and asks the view to repaint, instead of hanging forever");
|
|
535
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { HOVER_ROLE, paintHoverable } from "../lib/shell-hover.ts";
|
|
4
|
+
|
|
5
|
+
const theme = {
|
|
6
|
+
fg(role: string, text: string) {
|
|
7
|
+
return `<${role}>${text}</${role}>`;
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
test("paintHoverable paints the shared hover role only while hovered", () => {
|
|
12
|
+
assert.equal(paintHoverable(theme, "refresh", true), `<${HOVER_ROLE}>refresh</${HOVER_ROLE}>`);
|
|
13
|
+
assert.equal(paintHoverable(theme, "refresh", false), "refresh");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("paintHoverable falls back to an idle role when given one", () => {
|
|
17
|
+
assert.equal(paintHoverable(theme, "refresh", false, "dim"), "<dim>refresh</dim>");
|
|
18
|
+
assert.equal(paintHoverable(theme, "refresh", true, "dim"), `<${HOVER_ROLE}>refresh</${HOVER_ROLE}>`, "hover always wins over the idle role");
|
|
19
|
+
});
|
|
@@ -128,6 +128,26 @@ test("framePromptLines keeps the editor scroll indicators inside the frame", ()
|
|
|
128
128
|
for (const line of lines) assert.equal(visibleWidth(line), width);
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
+
test("framePromptLines shows an explicit escHint on the bottom rule, overriding the editor's own scroll indicator", () => {
|
|
132
|
+
const width = 40;
|
|
133
|
+
const inner = width - 2;
|
|
134
|
+
const bottom = `─── ↓ 3 more ${"─".repeat(inner - 13)}`;
|
|
135
|
+
const lines = framePromptLines(
|
|
136
|
+
["─".repeat(inner), ` x${" ".repeat(inner - 2)}`, bottom],
|
|
137
|
+
width,
|
|
138
|
+
options({ fg: (_c, t) => t, escHint: "esc again to cancel" }),
|
|
139
|
+
);
|
|
140
|
+
assert.match(stripAnsi(lines[2]), /^╰─ esc again to cancel ─+╯$/);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("framePromptLines falls back to the scroll indicator when no escHint is set", () => {
|
|
144
|
+
const width = 40;
|
|
145
|
+
const inner = width - 2;
|
|
146
|
+
const bottom = `─── ↓ 3 more ${"─".repeat(inner - 13)}`;
|
|
147
|
+
const lines = framePromptLines(["─".repeat(inner), ` x${" ".repeat(inner - 2)}`, bottom], width, options({ fg: (_c, t) => t }));
|
|
148
|
+
assert.match(stripAnsi(lines[2]), /^╰─ ↓ 3 more ─+╯$/);
|
|
149
|
+
});
|
|
150
|
+
|
|
131
151
|
test("withPromptHint places a dim hint after the cursor on an empty editor line", () => {
|
|
132
152
|
const inner = 38;
|
|
133
153
|
const line = ` ${CURSOR}${" ".repeat(inner - 2)}`;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { Container, Spacer, TuiAltScreen, type Component } from "@earendil-works/pi-tui";
|
|
4
|
+
import { createChatViewport } from "../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/chat-viewport.js";
|
|
5
|
+
import { installSidebar } from "../lib/shell-sidebar-layout.ts";
|
|
6
|
+
import { sidebarHeader, sidebarPart } from "../lib/shell-sidebar.ts";
|
|
7
|
+
|
|
8
|
+
// End-to-end through pi-tui's real alt-screen renderer and Pi's real chat
|
|
9
|
+
// viewport: the unit fixtures elsewhere hand-build layout nodes, which is how
|
|
10
|
+
// two earlier attempts at this row passed their tests and still failed live.
|
|
11
|
+
const theme = { fg: (_color: string, text: string) => text, bold: (text: string) => text };
|
|
12
|
+
const strip = (text: string) => text.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").replace(/\x1b\][^\x07]*\x07/g, "").replace(/\s+$/, "");
|
|
13
|
+
const lines = (rows: string[]): Component => ({ render: () => rows, invalidate() {} });
|
|
14
|
+
|
|
15
|
+
async function renderViewport(columns: number, rows: number, sidebar: boolean): Promise<string[]> {
|
|
16
|
+
const terminal = {
|
|
17
|
+
start() {}, stop() {}, async drainInput() {}, write() {},
|
|
18
|
+
get columns() { return columns; }, get rows() { return rows; },
|
|
19
|
+
moveBy() {}, hideCursor() {}, showCursor() {}, clearLine() {}, clearFromCursor() {}, clearScreen() {}, setTitle() {}, setProgress() {},
|
|
20
|
+
kittyProtocolActive: false, getBufferedInput() { return ""; }, hasPendingInput() { return false; },
|
|
21
|
+
} as never;
|
|
22
|
+
const above = new Container();
|
|
23
|
+
above.addChild(new Spacer(1)); // Pi adds a spacer above the editor when no widget is shown
|
|
24
|
+
const footer = new Container();
|
|
25
|
+
const viewport = createChatViewport({
|
|
26
|
+
document: lines(Array.from({ length: 12 }, (_, i) => `transcript ${i + 1}`)),
|
|
27
|
+
pendingMessages: new Container(), status: new Container(), widgetsAbove: above,
|
|
28
|
+
editor: lines(["╭─ editor ─╮", "│ prompt │", "╰──────────╯"]),
|
|
29
|
+
widgetsBelow: new Container(), footer, scrollbar: "auto",
|
|
30
|
+
});
|
|
31
|
+
const tui = new TuiAltScreen(terminal, false);
|
|
32
|
+
tui.setLayoutRoot(viewport.root);
|
|
33
|
+
if (sidebar) {
|
|
34
|
+
footer.addChild(sidebarPart(tui, "footer", lines(["BOTTOM BAR"]), { render: () => ["Status card"], invalidate() {} }));
|
|
35
|
+
sidebarHeader(tui, { render: (width: number) => [`HEADER ${width}`], invalidate() {} });
|
|
36
|
+
installSidebar(tui, theme);
|
|
37
|
+
} else {
|
|
38
|
+
footer.addChild(lines(["BOTTOM BAR"]));
|
|
39
|
+
}
|
|
40
|
+
tui.start();
|
|
41
|
+
tui.requestRender(true);
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
43
|
+
tui.stop();
|
|
44
|
+
return ((tui as unknown as { previousScreen: string[] }).previousScreen ?? []).map(strip);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
test("fullscreen with the sidebar leaves no blank row between the editor and the terminal edge", async () => {
|
|
48
|
+
const screen = await renderViewport(140, 24, true);
|
|
49
|
+
assert.equal(screen[0], "HEADER 138", "the header owns the first row");
|
|
50
|
+
assert.match(screen[screen.length - 1] ?? "", /^╰/, `the editor's bottom border sits on the last row, got ${JSON.stringify(screen.slice(-3))}`);
|
|
51
|
+
assert.ok(screen.some((row) => row.startsWith("╭─ editor")), "the editor is still painted");
|
|
52
|
+
assert.ok(screen.some((row) => row.includes("Status card")), "the rail is still painted");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("fullscreen without the sidebar keeps Pi's bottom bar on the last row", async () => {
|
|
56
|
+
const screen = await renderViewport(140, 24, false);
|
|
57
|
+
assert.equal(screen[screen.length - 1], "BOTTOM BAR");
|
|
58
|
+
assert.match(screen[screen.length - 2] ?? "", /^╰/);
|
|
59
|
+
});
|