@bismawy/pi-arnative 0.16.1 → 0.18.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.
Files changed (61) hide show
  1. package/README.md +25 -16
  2. package/extensions/index.ts +41 -0
  3. package/lib/active-clock.ts +91 -0
  4. package/lib/ansi.ts +40 -78
  5. package/lib/box.ts +49 -68
  6. package/lib/chatbox.ts +371 -0
  7. package/lib/color.ts +3 -31
  8. package/lib/compat.ts +0 -60
  9. package/lib/edit-diff.ts +199 -0
  10. package/{extensions → lib/features}/arnative.ts +96 -423
  11. package/{extensions/autocompact.ts → lib/features/auto-compact.ts} +30 -327
  12. package/{extensions → lib/features}/budget.ts +17 -242
  13. package/lib/features/footer.ts +2232 -0
  14. package/{extensions/section-headers.ts → lib/features/headers.ts} +38 -49
  15. package/{extensions → lib/features}/model-heal.ts +5 -28
  16. package/lib/features/progress-group.ts +1557 -0
  17. package/{extensions → lib/features}/render-cache.ts +113 -161
  18. package/{extensions → lib/features}/timestamps.ts +18 -94
  19. package/{extensions → lib/features}/todos.ts +44 -158
  20. package/lib/features/tools.ts +1202 -0
  21. package/lib/features/ui-render-tweaks.ts +606 -0
  22. package/lib/features/usage.ts +786 -0
  23. package/lib/format.ts +22 -4
  24. package/lib/git-status.ts +164 -0
  25. package/lib/list-picker.ts +1 -127
  26. package/lib/model-heal.ts +70 -162
  27. package/lib/patch.ts +0 -63
  28. package/lib/preset-store.ts +17 -133
  29. package/lib/provider-store.ts +573 -0
  30. package/lib/provider.ts +52 -851
  31. package/lib/runtime.ts +209 -0
  32. package/lib/shortcuts.ts +8 -58
  33. package/lib/spinner.ts +88 -162
  34. package/lib/status-widget.ts +4 -30
  35. package/lib/todos.ts +20 -143
  36. package/lib/usage-pricing.ts +143 -0
  37. package/lib/usage-store.ts +44 -378
  38. package/package.json +5 -6
  39. package/themes/arnative-blossom.json +0 -0
  40. package/themes/arnative-crimson.json +0 -0
  41. package/themes/arnative-cyberpunk.json +0 -0
  42. package/themes/arnative-dracula.json +0 -0
  43. package/themes/arnative-earthy.json +0 -0
  44. package/themes/arnative-garden.json +0 -0
  45. package/themes/arnative-gruvbox.json +0 -0
  46. package/themes/arnative-lemonade.json +0 -0
  47. package/themes/arnative-magical.json +0 -0
  48. package/themes/arnative-matrix.json +0 -0
  49. package/themes/arnative-neutral.json +0 -0
  50. package/themes/arnative-nord.json +0 -0
  51. package/themes/arnative-zinc.json +0 -0
  52. package/themes/arnative.json +0 -0
  53. package/CHANGELOG.md +0 -683
  54. package/extensions/animations.ts +0 -242
  55. package/extensions/footer.ts +0 -2617
  56. package/extensions/tools.ts +0 -2231
  57. package/extensions/ui-render-tweaks.ts +0 -1005
  58. package/extensions/usage-export.ts +0 -283
  59. package/extensions/usage.ts +0 -1406
  60. package/lib/check.ts +0 -21
  61. package/themes/gen-themes.mjs +0 -715
package/lib/format.ts CHANGED
@@ -6,20 +6,38 @@ export function capitalize(s: string): string {
6
6
  return s ? s.charAt(0).toUpperCase() + s.slice(1) : "";
7
7
  }
8
8
 
9
- // Model label pieces: titlecased id (or the given name) + capitalized provider.
9
+ // Model label pieces: clean model name + capitalized provider with optional route segment
10
+ // (e.g. "Gemini 4 Neon" + "Magpie/agy-cli" for remote/agy-cli/gemini-4-neon).
10
11
  export function modelDisplayParts(model?: { id?: string; name?: string; provider?: string }): { name: string; provider: string } {
11
12
  if (!model) return { name: "No Model", provider: "" };
13
+ const baseProvider = capitalize(model.provider || "");
14
+ const idParts = (model.id || "").split("/").filter(Boolean);
15
+ const prefixParts = idParts.length > 1 ? idParts.slice(0, -1) : [];
16
+ let route = "";
17
+ if (prefixParts.length > 0) {
18
+ if (prefixParts[0]!.toLowerCase() === "remote" && prefixParts.length > 1) {
19
+ route = prefixParts[1]!;
20
+ } else {
21
+ const kept = prefixParts.slice(0, 2);
22
+ route = kept.length === 1 && kept[0]!.toLowerCase() === baseProvider.toLowerCase() ? "" : kept.join("/");
23
+ }
24
+ }
25
+
12
26
  let name = model.name || model.id || "Model";
13
- const provider = capitalize(model.provider || "");
14
27
  if (name === model.id) {
15
- name = name
28
+ const leaf = idParts[idParts.length - 1] || name;
29
+ name = leaf
16
30
  .split(/[-_]/)
17
31
  .map((w) => capitalize(w))
18
32
  .join(" ");
33
+ } else {
34
+ // Magpie / proxy names append verbose metadata with " · " (e.g. "Gemini 4 Neon · Antigravity (local agy CLI) · Remote").
35
+ name = name.split(" · ")[0]!.trim() || name;
19
36
  }
20
- if (provider && name.toLowerCase().endsWith(`(${provider.toLowerCase()})`)) {
37
+ if (baseProvider && name.toLowerCase().endsWith(`(${baseProvider.toLowerCase()})`)) {
21
38
  name = name.slice(0, name.lastIndexOf("(")).trim();
22
39
  }
40
+ const provider = baseProvider && route ? `${baseProvider}/${route}` : baseProvider || route;
23
41
  return { name, provider };
24
42
  }
25
43
 
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Git repository status, diff-stat formatting, and cwd shortening for the footer.
3
+ */
4
+ import { execFile } from "node:child_process";
5
+ import { readFileSync, statSync } from "node:fs";
6
+ import { dirname, join, resolve } from "node:path";
7
+
8
+ export type GitInfo = {
9
+ branch: string;
10
+ tag: string | null;
11
+ uncommitted: number | null;
12
+ added: number | null;
13
+ removed: number | null;
14
+ ahead: number;
15
+ behind: number;
16
+ } | null;
17
+
18
+ export type RunResult = { ok: boolean; out: string };
19
+
20
+ /** Run a subprocess and distinguish exit 0 from failure so callers never invent a clean
21
+ * tree when git is absent or the repo is not owned by the user. */
22
+ export function run(cmd: string, args: string[], cwd: string): Promise<RunResult> {
23
+ return new Promise((resolvePromise) => {
24
+ execFile(cmd, args, { cwd, timeout: 2000 }, (err, stdout) => {
25
+ resolvePromise({ ok: !err, out: String(stdout).trim() });
26
+ });
27
+ });
28
+ }
29
+
30
+ /**
31
+ * The branch, straight from `.git/HEAD` — the same trick pi's own footer uses.
32
+ * Reading the ref needs no binary and no ownership check, so a fresh user sees
33
+ * the branch even without git on PATH.
34
+ */
35
+ export function branchFromDisk(cwd: string): string | null {
36
+ for (let dir = resolve(cwd); ; ) {
37
+ try {
38
+ const dotGit = join(dir, ".git");
39
+ const gitDir = statSync(dotGit).isDirectory()
40
+ ? dotGit
41
+ : resolve(dir, readFileSync(dotGit, "utf8").trim().replace(/^gitdir:\s*/, ""));
42
+ const head = readFileSync(join(gitDir, "HEAD"), "utf8").trim();
43
+ const ref = /^ref:\s+refs\/heads\/(.+)$/.exec(head);
44
+ return ref ? ref[1]! : "detached";
45
+ } catch (e) {
46
+ if ((e as NodeJS.ErrnoException).code !== "ENOENT") return null;
47
+ }
48
+ const parent = dirname(dir);
49
+ if (parent === dir) return null;
50
+ dir = parent;
51
+ }
52
+ }
53
+
54
+ /** Sum `git diff --numstat` output: `added<TAB>removed<TAB>path` per line. A `-`
55
+ * marks a binary file — skipped, not counted as 0. */
56
+ export function sumNumstat(out: string): { added: number; removed: number } {
57
+ let added = 0;
58
+ let removed = 0;
59
+ for (const line of out.split("\n")) {
60
+ const [a, r] = line.split("\t");
61
+ if (!/^\d+$/.test(a ?? "") || !/^\d+$/.test(r ?? "")) continue;
62
+ added += Number(a);
63
+ removed += Number(r);
64
+ }
65
+ return { added, removed };
66
+ }
67
+
68
+ /** Parsed `git status --porcelain=v2 --branch`: branch, upstream sync, and change count in one call. */
69
+ export function parsePorcelainV2(out: string): { ahead: number; behind: number; uncommitted: number } {
70
+ let ahead = 0;
71
+ let behind = 0;
72
+ let uncommitted = 0;
73
+ for (const line of out.split(/\r?\n/)) {
74
+ if (line.startsWith("# branch.ab ")) {
75
+ const m = /^# branch\.ab \+(\d+) -(\d+)$/.exec(line);
76
+ if (m) {
77
+ ahead = Number(m[1]);
78
+ behind = Number(m[2]);
79
+ }
80
+ } else if (line.startsWith("# ") || line === "") {
81
+ continue;
82
+ } else {
83
+ uncommitted++;
84
+ }
85
+ }
86
+ return { ahead, behind, uncommitted };
87
+ }
88
+
89
+ /** Row-1 git segment: branch(+sync), tag, worktree state. */
90
+ export function gitParts(
91
+ info: GitInfo,
92
+ acc: (t: string) => string,
93
+ soft: (t: string) => string,
94
+ ): string[] {
95
+ if (!info) return [];
96
+ const branch = `${acc("\uf126")} ${soft(info.branch)}${info.ahead > 0 ? ` ${soft(`↑${info.ahead}`)}` : ""}${info.behind > 0 ? ` ${soft(`↓${info.behind}`)}` : ""}`;
97
+ const parts = [branch];
98
+ if (info.tag !== null) parts.push(`${acc("\uf02b")} ${soft(info.tag)}`);
99
+ if (info.uncommitted !== null) parts.push(`${acc("\uf172")} ${info.uncommitted > 0 ? soft(`~${info.uncommitted}`) : soft("clean")}`);
100
+ return parts;
101
+ }
102
+
103
+ /** Working-tree diff vs HEAD as `+500 -100`, or `""` when clean or unavailable. */
104
+ export function formatDiffStat(
105
+ info: GitInfo,
106
+ acc: (t: string) => string,
107
+ pos: (t: string) => string,
108
+ neg: (t: string) => string,
109
+ ): string {
110
+ if (!info || info.added === null || info.removed === null) return "";
111
+ if (info.added + info.removed === 0) return "";
112
+ return `${acc("\uf4d2")} ${pos(`+${info.added}`)} ${neg(`-${info.removed}`)}`;
113
+ }
114
+
115
+ /** Keep the last 2 path segments so deep working directories stay single-line. */
116
+ export function shortenCwd(raw: string): string {
117
+ const p = (raw || "").trim();
118
+ if (!p) return p;
119
+ const drive = p.match(/^[A-Za-z]:/);
120
+ const body = drive ? p.slice(2) : p;
121
+ const parts = body.replace(/\\/g, "/").replace(/\/+$/, "").split("/").filter(Boolean);
122
+ if (parts.length <= 2) return p;
123
+ const head = drive ? `${drive[0]}/\u2026/` : p.startsWith("/") ? "\u2026/" : "\u2026";
124
+ return head + parts.slice(-2).join("/");
125
+ }
126
+
127
+ /** The tag `git describe --tags --abbrev=0` would print for HEAD, or null. Cached per
128
+ * (cwd, branch): a tag only moves on a checkout or a new tag, so one call per branch
129
+ * switch is enough — re-running it on every tool call was the most expensive part of the refresh. */
130
+ const tagByBranch = new Map<string, string | null>();
131
+ async function tagFor(cwd: string, branch: string): Promise<string | null> {
132
+ const key = `${cwd}\0${branch}`;
133
+ if (tagByBranch.has(key)) return tagByBranch.get(key) ?? null;
134
+ const tag = await run("git", ["describe", "--tags", "--abbrev=0"], cwd);
135
+ const value = tag.ok && tag.out ? tag.out : null;
136
+ tagByBranch.set(key, value);
137
+ return value;
138
+ }
139
+
140
+ /** Collect git status, tag, upstream ahead/behind, and working-tree diff stat for `cwd`.
141
+ * Two git calls per refresh: `status --porcelain=v2 --branch` answers branch sync and the
142
+ * change count together, `diff --numstat` the line counts; the tag is read once per branch. */
143
+ export async function collectGitInfo(cwd: string): Promise<GitInfo> {
144
+ const branch = branchFromDisk(cwd);
145
+ if (!branch) return null;
146
+ const [status, numstat] = await Promise.all([
147
+ run("git", ["status", "--porcelain=v2", "--branch"], cwd),
148
+ run("git", ["diff", "HEAD", "--numstat"], cwd),
149
+ ]);
150
+ const parsed = status.ok ? parsePorcelainV2(status.out) : { ahead: 0, behind: 0, uncommitted: null as number | null };
151
+ // An unborn HEAD (a repo with no commit yet) makes `diff HEAD` fail; compare the
152
+ // working tree against the canonical empty tree so a staged first commit still counts.
153
+ const numstat2 = numstat.ok ? numstat : await run("git", ["diff", "--numstat", "4b825dc642cb6eb9a060e54bf8d69288fbee4904"], cwd);
154
+ const { added, removed } = sumNumstat(numstat2.out);
155
+ return {
156
+ branch,
157
+ tag: await tagFor(cwd, branch),
158
+ uncommitted: parsed.uncommitted,
159
+ added: numstat2.ok ? added : null,
160
+ removed: numstat2.ok ? removed : null,
161
+ ahead: parsed.ahead,
162
+ behind: parsed.behind,
163
+ };
164
+ }
@@ -6,8 +6,7 @@
6
6
  */
7
7
  import { Input, matchesKey, truncateToWidth, visibleWidth, type Component, type Focusable } from "@earendil-works/pi-tui";
8
8
  import { softOf, thinkingColorOf } from "./ansi.ts";
9
- import { renderScreen, screenTitle, type ScreenText } from "./box.ts";
10
- import { assert, isMain } from "./check.ts";
9
+ import { renderScreen, type ScreenText } from "./box.ts";
11
10
  import { ROW_DIVIDER } from "./format.ts";
12
11
  import { LEGEND_LIVE, LEGEND_MOVE, LEGEND_ROOT, matchesBack } from "./shortcuts.ts";
13
12
 
@@ -390,128 +389,3 @@ export class InputPicker implements Component, Focusable {
390
389
  /* the editor holds nothing that outlives the screen */
391
390
  }
392
391
  }
393
-
394
- // Self-check: `node lib/list-picker.ts`
395
- if (isMain(import.meta.url)) {
396
- assert(LIST_LEGEND_ROOT === "[↑↓] Move [Enter] Select [Esc] Close", "root legend pinned, no ← behind the root menu");
397
- assert(LIST_LEGEND_MOVE === "[↑↓] Move [Enter] Select [Esc] Back", "move legend pinned: Esc is Back where a parent exists");
398
- assert(LIST_LEGEND_LIVE === "[↑↓] Preview [Enter] Select [Esc] Back", "live legend pinned: Esc drops the preview and steps out");
399
- const fakeTheme = { fg: (_c: string, t: string) => t, bold: (t: string) => t };
400
- const quiet = (): void => undefined;
401
- const picker = new ListPicker(fakeTheme, nameRows(["a", "b"]), "a", { preview: quiet, revert: quiet, done: quiet, requestRender: quiet }, { title: screenTitle("Test"), description: "d", legend: "l" }, false);
402
- const lines = picker.render(50);
403
- assert(lines[0]!.startsWith("╭") && lines[lines.length - 1]!.startsWith("╰"), "picker framed");
404
- assert(lines.every((l) => visibleWidth(l) === 50), "picker lines fit width 50");
405
- assert(lines.some((l) => l.includes("❯ a")), "the cursor marks the selection");
406
-
407
- // The chosen marker: ✓ ends the saved row only, colored by the theme's success slot.
408
- const chosenPicker = new ListPicker(
409
- fakeTheme,
410
- [{ label: "a" }, { label: "b", note: "nb", chosen: true }],
411
- "b",
412
- { preview: quiet, revert: quiet, done: quiet, requestRender: quiet },
413
- { title: screenTitle("Test"), description: "d", legend: "l" },
414
- false,
415
- );
416
- const chosenLines = chosenPicker.render(50);
417
- assert(chosenLines.some((l) => l.includes("nb ✓")), "a chosen row ends with the ✓ marker");
418
- assert(chosenLines.every((l) => !l.includes("a ✓")), "unchosen rows carry no marker");
419
-
420
- // `←` behavior is owned by the screen: a parent gets the back call, `false` swallows
421
- // the key (a fill screen keeps its work), and a root menu closes like Esc.
422
- const keyLeft = "\x1b[D";
423
- let backCalls = 0;
424
- let closedByBack = false;
425
- const backPicker = new ListPicker(fakeTheme, nameRows(["a"]), "a", { preview: quiet, revert: quiet, done: quiet, cancel: quiet, requestRender: quiet, back: () => { backCalls++; } }, { title: screenTitle("Test"), description: "d", legend: "l" }, false);
426
- backPicker.handleInput(keyLeft);
427
- assert(backCalls === 1 && closedByBack === false, "a parent screen receives ← as back");
428
- let closed = "none";
429
- const noBackPicker = new ListPicker(fakeTheme, nameRows(["a"]), "a", { preview: quiet, revert: quiet, done: () => { closed = "done"; }, cancel: () => { closed = "cancel"; }, requestRender: quiet }, { title: screenTitle("Test"), description: "d", legend: "l" }, false);
430
- noBackPicker.handleInput(keyLeft);
431
- assert(closed === "cancel", "a root menu closes on ← like Esc");
432
- let fillClosed = "none";
433
- const fillPicker = new ListPicker(fakeTheme, nameRows(["a"]), "a", { preview: quiet, revert: quiet, done: () => { fillClosed = "done"; }, cancel: () => { fillClosed = "cancel"; }, requestRender: quiet, back: false }, { title: screenTitle("Test"), description: "d", legend: "l" }, false);
434
- fillPicker.handleInput(keyLeft);
435
- fillPicker.handleInput("\x1bOD");
436
- assert(fillClosed === "none", "a fill screen swallows ← entirely");
437
-
438
- // A long list scrolls: 10 rows visible, the cursor always inside the window, and one
439
- // frame height whether the cursor sits at the top or the bottom.
440
- const many = nameRows(Array.from({ length: 25 }, (_, i) => `m${i}`));
441
- const scrolled = new ListPicker(fakeTheme, many, "m0", { preview: quiet, revert: quiet, done: quiet, requestRender: quiet }, { title: screenTitle("Test"), description: "d", legend: "l" }, false, undefined, 10);
442
- const countItems = (ls: string[]): number => ls.filter((l) => /m\d/.test(l)).length;
443
- let frame = scrolled.render(50);
444
- assert(countItems(frame) === 10, "a scrolled list shows exactly 10 model rows");
445
- assert(frame.some((l) => l.includes("↓ 15 more")) && !frame.some((l) => l.includes("↑")), "the top of the list announces only what is below");
446
- for (let i = 0; i < 14; i++) scrolled.handleInput("\x1b[B");
447
- frame = scrolled.render(50);
448
- assert(countItems(frame) === 10, "still 10 rows after scrolling");
449
- assert(frame.some((l) => l.includes("↑ 9 more")) && frame.some((l) => l.includes("↓ 6 more")), "both ends announce their hidden rows");
450
- assert(frame.some((l) => l.includes("❯ m14")), "the cursor row stays visible");
451
- scrolled.handleInput("\x1b[B");
452
- const frameNext = scrolled.render(50);
453
- assert(frameNext.length === frame.length && countItems(frameNext) === 10, "the frame height stays constant while scrolling inside the list");
454
- for (let i = 0; i < 9; i++) scrolled.handleInput("\x1b[B");
455
- frame = scrolled.render(50);
456
- assert(frame.some((l) => l.includes("❯ m24")) && frame.some((l) => l.includes("↑ 15 more")) && !frame.some((l) => l.includes("↓")), "the bottom of the list announces only what is above");
457
- // Wrap at both edges, matching the /jev-eye picker: a held key never sticks.
458
- scrolled.handleInput("\x1b[B");
459
- assert(scrolled.render(50).some((l) => l.includes("❯ m0")), "↓ at the last row wraps to the top");
460
- scrolled.handleInput("\x1b[A");
461
- assert(scrolled.render(50).some((l) => l.includes("❯ m24")), "↑ at the top row wraps to the last row");
462
- const short = new ListPicker(fakeTheme, nameRows(["a", "b"]), "a", { preview: quiet, revert: quiet, done: quiet, requestRender: quiet }, { title: screenTitle("Test"), description: "d", legend: "l" }, false, undefined, 10);
463
- assert(!short.render(50).some((l) => l.includes("more")), "a short list shows no scroll indicators");
464
-
465
- // The text field: the pi-tui editor drives, the arnative box frames it.
466
- let submitted: string | null | undefined;
467
- let inputCancelled = false;
468
- const field = new InputPicker(fakeTheme, { title: screenTitle("Provider"), description: "Endpoint API — the base URL", legend: INPUT_LEGEND }, "", {
469
- done: (v) => { submitted = v; },
470
- cancel: () => { inputCancelled = true; },
471
- requestRender: quiet,
472
- }, "https://api.example.com/v1");
473
- field.focused = true;
474
- const fieldLines = field.render(60);
475
- // CSI and every APC wrapper (`\x1b_…\x07`): pi-tui 0.87 emitted only `_pi:c`, 1.4 adds
476
- // `_pi:fc`/`_pi:/fc` around the placeholder — a narrow strip left escapes glued to the
477
- // text and failed the include on CI's newer version.
478
- const plain = (s: string): string => s.replace(/\x1b\[[0-9;]*[A-Za-z]/g, "").replace(/\x1b_.*?\x07/g, "");
479
- assert(fieldLines[0]!.startsWith("╭") && fieldLines[1]!.includes("Provider - Arnative"), "the input renders in the arnative box");
480
- assert(fieldLines.some((l) => plain(l).includes("> https://api.example.com/v1")), "an empty field shows its dim placeholder");
481
- assert(fieldLines.some((l) => l.includes(INPUT_LEGEND)), "the input legend is pinned");
482
- for (const ch of "https://x.io") field.handleInput(ch);
483
- field.handleInput("\x1b[D");
484
- field.handleInput("io");
485
- assert(field.getValue() === "https://x.iioo", "typing with a moved cursor edits at the cursor");
486
- field.handleInput("\r");
487
- assert(submitted === "https://x.iioo", "Enter submits the value");
488
- assert(!inputCancelled, "Enter is not a cancel");
489
- field.handleInput("\x1b");
490
- assert(inputCancelled, "Esc cancels the field");
491
- // The Thinking flow: / starts typing, every key is text, Enter keeps the filter, then commands act on it.
492
- const hits: string[] = [];
493
- const filtered = new ListPicker(fakeTheme, [{ label: "river/ds-v4" }, { label: "auto/glm" }], undefined, { preview: () => {}, revert: () => {}, done: () => hits.push("done"), requestRender: () => {}, toggle: () => hits.push("toggle"), press: (k) => { if (/^[0-9]$/.test(k)) hits.push("press " + k); }, search: "models" }, { title: "T", description: "d", legend: "l" }, false);
494
- filtered.handleInput("r");
495
- assert(filtered.index === 0, "a letter outside typing does not filter");
496
- filtered.handleInput("/");
497
- for (const ch of "River 7") filtered.handleInput(ch);
498
- assert(hits.join() === "" && filtered.index === -1, "while typing, Space and digits are text");
499
- filtered.handleInput("\x7f");
500
- for (const ch of "ds4") filtered.handleInput(ch);
501
- assert(filtered.index === 0 && hits.join() === "", "the filter is fuzzy and ignores spaces: river ds4 finds river/ds-v4");
502
- filtered.handleInput("\r");
503
- filtered.handleInput("0");
504
- filtered.handleInput(" ");
505
- assert(hits.join() === "press 0,toggle" && filtered.index === 0, "Enter ends typing without saving, then keys are commands on the match");
506
- filtered.handleInput("/");
507
- filtered.handleInput("\x1b");
508
- assert(hits.join() === "press 0,toggle", "Esc while typing ends typing and keeps the filter, so the screen stays open");
509
- filtered.handleInput("\x1b");
510
- assert(hits.join().endsWith("done"), "a second Esc, outside typing, leaves the screen");
511
-
512
- const summarized = new ListPicker(fakeTheme, nameRows(["a", "b"]), "a", { preview: quiet, revert: quiet, done: quiet, requestRender: quiet, summary: () => ["Box · a"] }, { title: "T", description: "d", legend: "l" }, false);
513
- const sumLines = summarized.render(40).map(plain);
514
- assert(sumLines.some((l) => l.includes("Box · a")) && sumLines.indexOf(sumLines.find((l) => l.includes("Box · a"))!) < sumLines.indexOf(sumLines.find((l) => l.includes("❯ a"))!), "summary renders above the picker rows");
515
-
516
- console.log("list-picker.ts self-check OK");
517
- }