@bismawy/pi-arnative 0.11.0 → 0.12.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 CHANGED
@@ -10,6 +10,32 @@
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.12.0] - 2026-11-14
14
+
15
+ - Fix Todos auto-hide cancellation when a body click opens a finished task list.
16
+ - Fix Todos collapsing when clicking a `↑ 1 more` / `↓ 1 more` counter row that disappears after scrolling (`extensions/todos.ts`, `test/todos-widget.test.ts`).
17
+
18
+ ### Added
19
+ - **Auto-scroll when holding left-click on Todos `↑ N more` / `↓ N more` counter rows.** Holding a counter row past 250 ms repeats the scroll every 90 ms until mouse release or the list boundary, while a quick click still scrolls one row (`extensions/todos.ts`, `test/todos-widget.test.ts`).
20
+
21
+ - **Expanded `[show]` tool boxes now cap their viewport height with clickable `↑ N more` / `↓ N more` border scroll indicators in `primary`, and single-clicking anywhere on a boxed tool toggles expand/collapse.** Expanding a large tool output no longer fills the entire terminal (`6-12` body lines scaled to terminal height); clicking `↑ N more` or `↓ N more` on the top or bottom border scrolls up or down, and single-clicking text or borders on the box toggles `[show]`/`[hide]` on synthesized `click` (`clickCount === 1`) so drag and double-click text selection keep working (`extensions/tools.ts`).
22
+
23
+ ### Added
24
+ - **Chatbox preset menu (`/arnative chatbox`) with `Box` (`Arnative` default vs `Pi (system)`), `[i] Icon` cycling (`❯`, `>`, `›`, `▸`, `→`, `\uf44f`, `\udb82\udf79`, `\uf51b`, `\udb80\udf7d`, `\uf120`, `\uf489`, `\udb80\udd7a`), and `[D] Dialog` status placement (`Left`, `Center`, `Right`, `Inside`, `Outside`).** `Arnative` renders the rounded input box with the selected prompt icon (`primary` while actively typing, `dim` after 3s idle, with 2 trailing spaces on Nerd Font PUA glyphs so wide icons never crowd the text) and clickable `↑ N more` / `↓ N more` scroll indicators painted in `primary`, trims Pi's leading `Spacer(1)` in `widgetContainerAbove` so chatbox/notices/widgets sit without an extra blank row above them, and renders all five status dialog positions relative to the chatbox (`Left`/`Center`/`Right` on the top border, `Inside` on line 1 right corner, `Outside` left-aligned above the editor with breathing space above/below and inline notices beside it). Choices persist in `config.json` as `chatboxPreset`, `chatboxPrompt`, and `chatboxDialog` (`lib/preset-store.ts`, `lib/list-picker.ts`, `extensions/footer.ts`, `extensions/arnative.ts`, `test/profile.test.ts`).
25
+ - **Custom collapsed Thinking label (`\uec21 Thinking...`) when running `pi-arnative`.** Replaces Pi default label with `\uec21` in `dim`, `Thinking...` in `dim` italic, and loops `.` → `..` → `...` while that thinking run is actively streaming. Once the run ends the label states what happened instead of claiming to think: `\uec21 Thought for 3s` (`3s` under a minute, `1m 23s` above), still `dim` italic, with one duration kept per run so a later run after a tool call times itself (`extensions/ui-render-tweaks.ts`, `formatThinkingElapsed`, `ThinkingLabelComponent`, `patchThinkingInAssistantMessage`; `extensions/timestamps.ts` keeps the timestamp off both labels; pinned in the ui-render-tweaks self-check and `test/patch-reload.test.ts`).
26
+
27
+ ### Fixed
28
+ - **Model heal caches synced channels and probed efforts locally instead of re-running on fixed timers or external catalog refreshes.** Per-model `compat` flags now land in `modelOverrides` so external writers that replace `models[]` (such as Magpie) leave healed flags intact. Automatic `healMeta` and `healEffort` runs keep successful results cached in `model-heal.json` until a new model ID, changed endpoint, or changed effort map appears (failed checks still retry after 1h, and `/model-heal` still forces all passes). Effort cache lookup also matches model IDs case-insensitively and stops re-probing legacy identity entries (`lib/model-heal.ts`, `healFlags`, `healMeta`, `healEffort`, `findEffort`, `metaFresh`; pinned in `test/model-heal-cache.test.ts`).
29
+ - **The providers nested under a project are dim, like every other row under a group.** In `/usage` → **Project**, an expanded project listed its providers in the plain text color while the Provider and Prices views already dimmed their children, so a folder's contents read as another group heading. The child rows now take `dim`; the project row keeps `text` and the expand arrow keeps the accent (`extensions/usage.ts`, the `resting` paint in `render`).
30
+
31
+ ### Changed
32
+ - **Budget screen labels (`Today`, `30d`, `Total`) now use `dim` while the spend values beside them stay in the default `text` color.** Added `[R] Reset` in `/arnative` -> Budget to reset `budgetDay`, `budgetMonth`, and `budgetEnforce` back to `off` (`extensions/budget.ts`, `resetBudget`, `BudgetModalComponent`).
33
+
34
+ ## [0.11.1] - 2026-11-13
35
+
36
+ ### Fixed
37
+ - **A reselect keeps the thinking levels a probe paid for.** Selecting or re-probing a provider's models reserialized every `auto` model through `mergeLevels`, which carried only its level, so `wireModels` dropped the stored `thinkingLevelMap` and the model went back to offering every level. `mergeLevels` now carries the probed map with the level, and the reselect path is pinned in the provider self-check (`lib/provider.ts`, `mergeLevels`).
38
+
13
39
  ## [0.11.0] - 2026-11-13
14
40
 
15
41
  ### Added
package/README.md CHANGED
@@ -33,10 +33,11 @@ Saved to `~/.pi/agent/arnative/config.json` via `/arnative`:
33
33
 
34
34
  - **Headers & Footers:** `Arnative (Full)` (default), `Arnative (Minimal)` (footer only; click head text or press `ctrl+alt+m` to toggle), or `Pi (system)`.
35
35
  - **Footer cost:** off by default. Press `[c]` in the Footers picker to add the session's cost (`$0.42`, `~$0.42` when no provider reported a billed total) to the metrics row; the choice is stored as `footerCost` in `config.json`.
36
+ - **Chatbox:** `Arnative` (default: rounded box with configurable prompt icon `❯`, `>`, `›`, `▸`, `→`, `\uf44f`, `\udb82\udf79`, `\uf51b`, `\udb80\udf7d`, `\uf120`, `\uf489`, or `\udb80\udd7a` cycled with `[i]`, painted `primary` while typing and `dim` after 3s idle) or `Pi (system)` (built-in top and bottom lines), plus `[D]` to position the working status dialog (`Left`, `Center`, `Right`, `Inside`, `Outside`).
36
37
  - **Animations:** 18 presets (`Arnative` default, `Pi (system)`, and alphabetical variants). Press `[g]` in the picker to toggle the Google gradient sweep.
37
38
  - **Auto-compact:** Off by default. **Smart** tiers trigger near ~200k tokens (`≥768k→20%`, `≥384k→40%`, `≥192k→80%`, `<192k→pi core`), or pick a fixed budget (`100k` to `400k`).
38
- - **Model heal:** **Full** (default: offline compat flags, `GET /models` limits with a 6h TTL, reasoning effort probe with a 24h TTL, and a failed fetch of either retried after 1h), **Flags** (offline only), or **Off**. Hand-edited fields are never overwritten. `/model-heal` forces every pass, warns that thinking probes can use paid tokens, and shows the stage it is in.
39
- - **Task list (`todo`):** Stored per session in `~/.pi/agent/arnative/todos/<session-id>.json` (uninstall `@juicesharp/rpiv-todo` first to avoid tool name conflict). Click `[click to expand]` / `[click to collapse]` or press `ctrl+alt+o` (`alt+o`) to toggle; click `↑`/`↓` counters or press `ctrl+alt+j`/`k` (`alt+j`/`k`) to scroll. Auto-hides 30s after completion (set `PI_ARNATIVE_TODO_HIDE_MS` to override, `0` for immediate hide; expanding pauses the timer).
39
+ - **Model heal:** **Full** (default: offline compat flags, `GET /models` limits and reasoning effort probes cached locally until new models appear, with failed fetches retried after 1h), **Flags** (offline only), or **Off**. Hand-edited fields are never overwritten. `/model-heal` forces every pass, warns that thinking probes can use paid tokens, and shows the stage it is in.
40
+ - **Task list (`todo`):** Stored per session in `~/.pi/agent/arnative/todos/<session-id>.json` (uninstall `@juicesharp/rpiv-todo` first to avoid tool name conflict). Click `[show]` / `[hide]` (or single-click anywhere on the box) or press `ctrl+alt+o` (`alt+o`) to toggle; click `↑`/`↓` counters or press `ctrl+alt+j`/`k` (`alt+j`/`k`) to scroll. Auto-hides 30s after completion (set `PI_ARNATIVE_TODO_HIDE_MS` to override, `0` for immediate hide; expanding pauses the timer).
40
41
 
41
42
  </details>
42
43
 
@@ -24,8 +24,8 @@ import {
24
24
  setSpinnerGradient,
25
25
  setSpinnerPreset,
26
26
  } from "./animations.ts";
27
- import { FOOTER_COST_KEY, FOOTER_PRESET_KEY, HEADER_PRESET_KEY, BUDGET_DAY_KEY, BUDGET_ENFORCE_KEY, BUDGET_MONTH_KEY, ensureChoices } from "../lib/preset-store.ts";
28
- import { FOOTER_PRESETS, activeFooterCost, activeFooterPreset, setFooterCost, setFooterPreset, type FooterPreset } from "./footer.ts";
27
+ import { CHATBOX_DIALOG_KEY, CHATBOX_PRESET_KEY, CHATBOX_PROMPT_KEY, FOOTER_COST_KEY, FOOTER_PRESET_KEY, HEADER_PRESET_KEY, BUDGET_DAY_KEY, BUDGET_ENFORCE_KEY, BUDGET_MONTH_KEY, ensureChoices } from "../lib/preset-store.ts";
28
+ import { CHATBOX_DIALOGS, CHATBOX_PRESETS, CHATBOX_PROMPTS, DEFAULT_CHATBOX_DIALOG, FOOTER_PRESETS, activeChatboxDialog, activeChatboxPreset, activeChatboxPrompt, activeFooterCost, activeFooterPreset, nextChatboxDialog, nextChatboxPrompt, setChatboxDialog, setChatboxPreset, setChatboxPrompt, setFooterCost, setFooterPreset, type ChatboxPreset, type FooterPreset } from "./footer.ts";
29
29
  import { activeBudgetDay, activeBudgetEnforce, activeBudgetMonth, openBudget } from "./budget.ts";
30
30
  import { HEADER_PRESETS, activeHeaderPreset, setHeaderPreset, type HeaderPreset } from "./section-headers.ts";
31
31
  import {
@@ -59,7 +59,7 @@ export function menuRows(menus: Pick<ArnativeMenu, "label" | "description">[]):
59
59
  /** Title of the settings menu, derived from `screenTitle` so the format lives in one place. */
60
60
  export const MENU_TITLE = screenTitle("Settings");
61
61
  /** One-line description under the menu title. */
62
- export const MENU_DESC = "Themes, headers, footers, animations, auto-compact, providers, usage, budget";
62
+ export const MENU_DESC = "Themes, headers, footers, chatbox, animations, auto-compact, providers, usage, budget";
63
63
 
64
64
  const THEMES_PICKER_TEXT: ListPickerText = {
65
65
  title: screenTitle("Themes"),
@@ -222,6 +222,85 @@ const openHeaders = async (ctx: ExtensionCommandContext): Promise<boolean | void
222
222
  return goBack === true;
223
223
  };
224
224
 
225
+ const CHATBOX_PICKER_TEXT: ListPickerText = {
226
+ title: screenTitle("Chatbox"),
227
+ description: "Selection applies when confirmed — rounded arnative box or built-in editor.",
228
+ legend: "[↑↓] Preview [i] Icon [D] Dialog [Enter] Select [Esc] Back",
229
+ };
230
+
231
+ const CHATBOX_NOTES: Record<ChatboxPreset, string> = {
232
+ "Pi (system)": "built-in top and bottom lines",
233
+ Arnative: "rounded arnative box with prompt & status placement",
234
+ };
235
+
236
+ export const chatboxRows = (): ListRow[] => CHATBOX_PRESETS.map((c) => ({ label: c, note: CHATBOX_NOTES[c] }));
237
+
238
+ export const chatboxSummary = (theme: { fg(c: string, t: string): string }): string[] => {
239
+ const dim = (s: string) => theme.fg("dim", s);
240
+ const txt = (s: string) => theme.fg("text", s);
241
+ const acc = (s: string) => theme.fg("accent", s);
242
+ const activeIcon = activeChatboxPrompt();
243
+ const icons = CHATBOX_PROMPTS.map((p) => (p === activeIcon ? acc(p) : dim(p))).join(" ");
244
+ const dialog = activeChatboxDialog();
245
+ const dialogTag = dialog === DEFAULT_CHATBOX_DIALOG ? ` ${dim("(default)")}` : "";
246
+ return [
247
+ `${dim("Box ")}${dim(" · ")}${txt(activeChatboxPreset())}`,
248
+ `${dim("Icon ")}${dim(" · ")}${icons}`,
249
+ `${dim("Dialog")}${dim(" · ")}${txt(dialog.toLowerCase())}${dialogTag}`,
250
+ ];
251
+ };
252
+
253
+ const openChatbox = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
254
+ const opened = activeChatboxPreset();
255
+
256
+ if (ctx.mode !== "tui") {
257
+ const labels = markedLabels(CHATBOX_PRESETS, opened);
258
+ const pick = await ctx.ui.select(CHATBOX_PICKER_TEXT.title, labels);
259
+ if (pick === undefined) return;
260
+ const name = CHATBOX_PRESETS[labels.indexOf(pick)]!;
261
+ setChatboxPreset(name);
262
+ ctx.ui.notify(`[arnative] Chatbox: ${name}`, "info");
263
+ return;
264
+ }
265
+
266
+ const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) =>
267
+ new ListPicker(
268
+ theme,
269
+ chatboxRows(),
270
+ opened,
271
+ {
272
+ preview: (name) => setChatboxPreset(name as ChatboxPreset),
273
+ revert: () => setChatboxPreset(opened),
274
+ done: () => {
275
+ announce(ctx.ui, `Chatbox: ${activeChatboxPreset()}.`);
276
+ done(false);
277
+ },
278
+ back: () => {
279
+ if (activeChatboxPreset() !== opened) setChatboxPreset(opened);
280
+ done(true);
281
+ },
282
+ press: (keyData) => {
283
+ if (matchesKey(keyData, "i") || keyData === "I") {
284
+ setChatboxPrompt(nextChatboxPrompt());
285
+ tui.requestRender();
286
+ return;
287
+ }
288
+ if (matchesKey(keyData, "d") || keyData === "D") {
289
+ setChatboxDialog(nextChatboxDialog());
290
+ tui.requestRender();
291
+ }
292
+ },
293
+ summary: () => chatboxSummary(theme),
294
+ requestRender: () => tui.requestRender(),
295
+ },
296
+ CHATBOX_PICKER_TEXT,
297
+ true,
298
+ ctx.thinkingLevel,
299
+ ),
300
+ );
301
+ return goBack === true;
302
+ };
303
+
225
304
  /** Animations picker. Unlike Themes/Headers/Footers the choice has a visible effect only
226
305
  * while a tool runs, so there is nothing to preview live on the screen itself — the row
227
306
  * previews the frames instead, and Enter installs the preset for the next run. */
@@ -437,6 +516,12 @@ export const MENUS: ArnativeMenu[] = [
437
516
  description: "choose the footer preset",
438
517
  open: openFooters,
439
518
  },
519
+ {
520
+ value: "chatbox",
521
+ label: "Chatbox",
522
+ description: "choose the input box preset",
523
+ open: openChatbox,
524
+ },
440
525
  {
441
526
  value: "animations",
442
527
  label: "Animations",
@@ -564,7 +649,7 @@ export function shouldApplyDefaultTheme(
564
649
  * set without starting a session. */
565
650
  export function registerCommands(pi: Pick<ExtensionAPI, "registerCommand">): void {
566
651
  pi.registerCommand("arnative", {
567
- description: "Arnative settings menu: themes, headers, footers, animations, auto-compact, model heal, providers, usage, budget",
652
+ description: "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, providers, usage, budget",
568
653
  getArgumentCompletions: arnativeCompletions,
569
654
  handler: arnativeHandler,
570
655
  });
@@ -583,6 +668,9 @@ export function recordProfile(): void {
583
668
  [HEADER_PRESET_KEY]: activeHeaderPreset(),
584
669
  [FOOTER_PRESET_KEY]: activeFooterPreset(),
585
670
  [FOOTER_COST_KEY]: activeFooterCost() ? "on" : "off",
671
+ [CHATBOX_PRESET_KEY]: activeChatboxPreset(),
672
+ [CHATBOX_PROMPT_KEY]: activeChatboxPrompt(),
673
+ [CHATBOX_DIALOG_KEY]: activeChatboxDialog(),
586
674
  [SPINNER_PRESET_KEY]: activeSpinnerPreset(),
587
675
  [SPINNER_GRADIENT_KEY]: activeSpinnerGradient() ? "on" : "off",
588
676
  [AUTO_COMPACT_KEY]: activeAutoCompact(),
@@ -624,10 +712,10 @@ if (isMain(import.meta.url)) {
624
712
  assert(rowText(labels[0]!) === "Themes · arnative themes only (all themes: /settings → Theme)", "menu row text format");
625
713
  assert(labels[0]!.label === "Themes" && labels[0]!.note === "arnative themes only (all themes: /settings → Theme)", "menu row keeps label and note apart");
626
714
  assert(MENU_TITLE === "Settings - Arnative\u2819", `the menu title is the pinned string, got ${MENU_TITLE}`);
627
- assert(MENU_DESC === "Themes, headers, footers, animations, auto-compact, providers, usage, budget", `the menu description is the pinned string, got ${MENU_DESC}`);
715
+ assert(MENU_DESC === "Themes, headers, footers, chatbox, animations, auto-compact, providers, usage, budget", `the menu description is the pinned string, got ${MENU_DESC}`);
628
716
  // Every menu row is reachable and the description names them all, so a new screen cannot
629
717
  // be added to MENUS and forgotten in the copy a user reads first.
630
- assert(MENUS.length === 9, "nine settings screens");
718
+ assert(MENUS.length === 10, "ten settings screens");
631
719
  {
632
720
  const values = MENUS.map((m) => m.value);
633
721
  assert(values.indexOf("heal") === values.indexOf("compact") + 1, "Model heal row sits right after Auto-compact");
@@ -635,7 +723,7 @@ if (isMain(import.meta.url)) {
635
723
  assert(heal.map((r) => r.label).join(",") === "Full,Flags,Off,Run now", "Model heal rows: three modes then Run now");
636
724
  assert(heal.filter((r) => r.chosen).map((r) => r.label).join(",") === "Flags", "Model heal marks only the saved mode");
637
725
  }
638
- for (const label of ["Themes", "Headers", "Footers", "Animations", "Auto-compact", "Providers", "Usage", "Budget"]) {
726
+ for (const label of ["Themes", "Headers", "Footers", "Chatbox", "Animations", "Auto-compact", "Providers", "Usage", "Budget"]) {
639
727
  assert(MENUS.some((m) => m.label === label), `MENUS carries the ${label} screen`);
640
728
  }
641
729
  assert(/^Settings - Arnative/.test(MENU_TITLE), "title follows `<setting> - <extension>`");
@@ -648,6 +736,8 @@ if (isMain(import.meta.url)) {
648
736
  assert(arnativeCompletions("he")![0]!.value === "headers", "headers menu has completions");
649
737
  assert(arnativeCompletions("fo")![0]!.value === "footers", "footers menu has completions");
650
738
  assert(MENUS.some((m) => m.value === "footers"), "footers menu registered");
739
+ assert(arnativeCompletions("ch")![0]!.value === "chatbox", "chatbox menu has completions");
740
+ assert(MENUS.some((m) => m.value === "chatbox"), "chatbox menu registered");
651
741
  assert(arnativeCompletions("co")![0]!.value === "compact", "compact menu has completions");
652
742
  assert(MENUS.some((m) => m.value === "compact"), "compact menu registered");
653
743
 
@@ -667,7 +757,7 @@ if (isMain(import.meta.url)) {
667
757
  assert(typeof registered.get("providers")!.handler === "function", "/providers has a handler");
668
758
  assert(MENUS.some((m) => m.value === "providers"), "/providers routes to a menu row that exists");
669
759
  assert(
670
- registered.get("arnative")!.description === "Arnative settings menu: themes, headers, footers, animations, auto-compact, model heal, providers, usage, budget",
760
+ registered.get("arnative")!.description === "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, providers, usage, budget",
671
761
  "the /arnative command description names every screen: " + registered.get("arnative")!.description,
672
762
  );
673
763
  }
@@ -765,14 +855,14 @@ if (isMain(import.meta.url)) {
765
855
  cancel: () => { menuCancelled = true; },
766
856
  requestRender: () => {},
767
857
  }, { title: MENU_TITLE, description: MENU_DESC, legend: LIST_LEGEND_ROOT }, false);
768
- // 80 columns: the description names the screens (a tripwire — a screen added to MENUS must
769
- // be added to the copy too), and that one-liner no longer fits 60.
770
- const menuLines = mainPicker.render(80);
858
+ // 100 columns: the description names the screens (a tripwire — a screen added to MENUS must
859
+ // be added to the copy too), and that one-liner no longer fits 80.
860
+ const menuLines = mainPicker.render(100);
771
861
  assert(menuLines.some((l) => l.includes(MENU_TITLE)), "the main menu renders its title");
772
862
  assert(menuLines.some((l) => l.includes("[Esc] Close") && !l.includes("←")), "the root menu legend renders without a back key");
773
863
  assert(menuLines.some((l) => l.includes(MENU_DESC)), "the main menu renders the description under the title");
774
864
  assert(menuLines.findIndex((l) => l.includes(MENU_TITLE)) < menuLines.findIndex((l) => l.includes(MENU_DESC)), "description sits below the title");
775
- assert(menuLines.every((l) => visibleWidth(l) === 80), "main menu lines fit the width");
865
+ assert(menuLines.every((l) => visibleWidth(l) === 100), "main menu lines fit the width");
776
866
  // The pinned /arnative layout: `→ Themes · note`, every `·` in one column (skill rule 10).
777
867
  const plainMenu = menuLines.map(stripAnsi);
778
868
  const row0 = menuLines.map(stripAnsi).find((l) => l.includes("→ Themes"))!;
@@ -865,6 +955,23 @@ if (isMain(import.meta.url)) {
865
955
  assert(footerLines.filter((l) => l.includes("Arnative (")).length === 2, "both arnative footer presets are selectable");
866
956
  assert(/\[c\] Cost (on|off)/.test(footersPickerText().legend), "footers legend advertises the cost switch and its live state");
867
957
 
958
+ // Chatbox reuses the same picker with summary rows (Box/Icon/Dialog), Pi (system) first and Arnative second.
959
+ assert(CHATBOX_PRESETS[0] === "Pi (system)" && CHATBOX_PRESETS[1] === "Arnative", "chatbox presets list Pi (system) then Arnative");
960
+ assert(CHATBOX_DIALOGS.includes(activeChatboxDialog()), "active chatbox dialog is valid");
961
+ const chatboxTagTheme = { fg: (c: string, t: string) => `<${c}>${t}</${c}>` };
962
+ const chatboxTagged = chatboxSummary(chatboxTagTheme);
963
+ assert(chatboxTagged.some((l) => l.includes("<dim>Box </dim><dim> · </dim><text>")), "chatbox summary renders dim Box label and separator");
964
+ assert(chatboxTagged.some((l) => l.startsWith("<dim>Icon </dim><dim> · </dim>") && l.includes(`<accent>${activeChatboxPrompt()}</accent>`) && l.includes(" ") && !l.includes("|")), "chatbox summary highlights the active icon in accent with double spacing and no |");
965
+ const expectedDialogTag = activeChatboxDialog() === DEFAULT_CHATBOX_DIALOG ? " <dim>(default)</dim>" : "";
966
+ assert(chatboxTagged.some((l) => l === `<dim>Dialog</dim><dim> · </dim><text>${activeChatboxDialog().toLowerCase()}</text>${expectedDialogTag}`), "chatbox summary renders dim Dialog label, separator, and default tag");
967
+ const chatboxPicker = new ListPicker(fakeTheme, chatboxRows(), "Arnative", { preview: () => {}, revert: () => {}, done: () => {}, requestRender: () => {}, summary: () => chatboxSummary(fakeTheme) }, CHATBOX_PICKER_TEXT);
968
+ const chatboxLines = chatboxPicker.render(84);
969
+ assert(chatboxLines.some((l) => l.includes(screenTitle("Chatbox"))), "chatbox picker title");
970
+ assert(chatboxLines.some((l) => l.includes("Box · Arnative")), "chatbox picker shows Box summary");
971
+ assert(chatboxLines.some((l) => l.includes("→ Arnative")), "chatbox picker cursors the active preset");
972
+ assert(chatboxLines.some((l) => l.includes(" Pi (system)")), "chatbox picker lists the built-in preset");
973
+ assert(CHATBOX_PICKER_TEXT.legend.includes("[i] Icon [D] Dialog"), "chatbox legend advertises [i] Icon and [D] Dialog");
974
+
868
975
  // Animations picker: "Pi (system)" carries a note AND renders "(system)" in dim
869
976
  const animPicker = new ListPicker(
870
977
  { fg: (c, t) => `<${c}>${t}</${c}>`, bold: (t) => `<bold>${t}</bold>` },
@@ -86,6 +86,12 @@ export function setBudgetEnforce(on: boolean): void {
86
86
  saveChoice(BUDGET_ENFORCE_KEY, on ? "on" : "off");
87
87
  }
88
88
 
89
+ export function resetBudget(): void {
90
+ setBudgetDay(undefined);
91
+ setBudgetMonth(undefined);
92
+ setBudgetEnforce(false);
93
+ }
94
+
89
95
  /** The next cap choice after `current` (unset reads as 0); past the largest choice it wraps to off. */
90
96
  export function nextCap(current: number | undefined): number {
91
97
  const cur = current ?? 0;
@@ -188,7 +194,7 @@ export function budgetLevelNow(): BudgetLevel {
188
194
  const BUDGET_PICKER_TEXT: ListPickerText = {
189
195
  title: screenTitle("Budget"),
190
196
  description: "Warn-only caps on the UTC day and the rolling 30d — enforce on blocks the next turn.",
191
- legend: "[↑↓] Move [Space] Change [Esc] Back",
197
+ legend: "[↑↓] Move [Space] Change [R] Reset [Esc] Back",
192
198
  };
193
199
 
194
200
  const ENFORCE_ON_NOTE = "on — blocks the next turn over a cap";
@@ -275,7 +281,7 @@ export function budgetWindows(spend: BudgetSpend | null, caps: { day?: number; m
275
281
  class BudgetModalComponent implements Component {
276
282
  private readonly theme: { fg(c: string, t: string): string; bold?(t: string): string };
277
283
  private readonly rows: ListRow[];
278
- private readonly hooks: { change(index: number): void; done(back: boolean): void; requestRender(): void };
284
+ private readonly hooks: { change(index: number): void; reset(): void; done(back: boolean): void; requestRender(): void };
279
285
  private readonly text: ListPickerText;
280
286
  private readonly edge: (s: string) => string;
281
287
  private selected = 0;
@@ -283,7 +289,7 @@ class BudgetModalComponent implements Component {
283
289
  constructor(
284
290
  theme: { fg(c: string, t: string): string; bold?(t: string): string },
285
291
  rows: ListRow[],
286
- hooks: { change(index: number): void; done(back: boolean): void; requestRender(): void },
292
+ hooks: { change(index: number): void; reset(): void; done(back: boolean): void; requestRender(): void },
287
293
  text: ListPickerText,
288
294
  thinkingLevel?: string,
289
295
  ) {
@@ -324,6 +330,11 @@ class BudgetModalComponent implements Component {
324
330
  if (matchesKey(keyData, "space")) {
325
331
  this.hooks.change(this.selected);
326
332
  this.hooks.requestRender();
333
+ return;
334
+ }
335
+ if (keyData === "R" || matchesKey(keyData, "r")) {
336
+ this.hooks.reset();
337
+ this.hooks.requestRender();
327
338
  }
328
339
  }
329
340
 
@@ -346,7 +357,7 @@ class BudgetModalComponent implements Component {
346
357
  const capText = (w: BudgetWindow): string => (w.cap !== undefined && w.cap > 0 ? `${formatCost(w.total)} of ${formatCost(w.cap)}` : "");
347
358
  const partW = Math.max(0, ...windows.map((w) => visibleWidth(capText(w))));
348
359
  for (const w of windows) {
349
- const label = th.fg("text", w.label.padEnd(5));
360
+ const label = dim(w.label.padEnd(5));
350
361
  if (w.unknown) {
351
362
  body.push(`${label} · ${dim("unknown — no day buckets yet")}`);
352
363
  continue;
@@ -364,7 +375,7 @@ class BudgetModalComponent implements Component {
364
375
  // The estimated part of both windows, once: an estimate-only provider shows $0 billed
365
376
  // per window, so the total is the only place the guess is summed.
366
377
  const estimated = (spend?.estimatedToday ?? 0) + (spend?.estimatedMonth ?? 0);
367
- if (estimated > 0) body.push(`${dim(`Total · ${formatCost(estimated)} est.`)}`);
378
+ if (estimated > 0) body.push(`${dim("Total")} · ${th.fg("text", `${formatCost(estimated)} est.`)}`);
368
379
  body.push("");
369
380
 
370
381
  // Editable rows — the same rows the headless picker offers.
@@ -405,6 +416,11 @@ export async function openBudget(ctx: ExtensionCommandContext): Promise<boolean
405
416
  announce(ctx.ui, `Budget: ${rowText(budgetRows()[index]!)}.`);
406
417
  tui.requestRender();
407
418
  },
419
+ reset: () => {
420
+ resetBudget();
421
+ announce(ctx.ui, "Budget reset to defaults.");
422
+ tui.requestRender();
423
+ },
408
424
  done: (back) => done(back),
409
425
  requestRender: () => tui.requestRender(),
410
426
  },
@@ -589,7 +605,7 @@ if (isMain(import.meta.url)) {
589
605
  BUDGET_PICKER_TEXT.description === "Warn-only caps on the UTC day and the rolling 30d — enforce on blocks the next turn.",
590
606
  "the Budget screen description is pinned",
591
607
  );
592
- assert(BUDGET_PICKER_TEXT.legend === "[↑↓] Move [Space] Change [Esc] Back", "the Budget legend is pinned");
608
+ assert(BUDGET_PICKER_TEXT.legend === "[↑↓] Move [Space] Change [R] Reset [Esc] Back", "the Budget legend is pinned");
593
609
  assert(rowText(rows[0]!) === "Day cap · $5.00", "the headless row text is pinned: " + rowText(rows[0]!));
594
610
 
595
611
  // The dashboard: the two spend-vs-cap windows, pure and pinned.
@@ -603,10 +619,11 @@ if (isMain(import.meta.url)) {
603
619
  // The modal render: status bars above the editable rows, through the shared screen frame.
604
620
  const modalTheme = { fg: (_c: string, t: string) => t, bold: (t: string) => t };
605
621
  const changed: number[] = [];
622
+ let resets = 0;
606
623
  const modal = new BudgetModalComponent(
607
624
  modalTheme as never,
608
625
  budgetRows(),
609
- { change: (i) => void changed.push(i), done: () => {}, requestRender: () => {} },
626
+ { change: (i) => void changed.push(i), reset: () => void resets++, done: () => {}, requestRender: () => {} },
610
627
  BUDGET_PICKER_TEXT as never,
611
628
  );
612
629
  const rendered = modal.render(80).map((l) => l.replace(/\x1b\[[0-9;]*m/g, ""));
@@ -618,6 +635,9 @@ if (isMain(import.meta.url)) {
618
635
  modal.handleInput("\x1b[B"); // down
619
636
  modal.handleInput(" "); // space
620
637
  assert(changed.length === 1 && changed[0] === 1, "down+space changes the second row (30d cap), not the first");
638
+ modal.handleInput("R");
639
+ modal.handleInput("r");
640
+ assert(resets === 2, "R/r triggers budget reset");
621
641
  assert(modal.render(40).length > 0, "the modal renders on a narrow terminal");
622
642
 
623
643
  // Both windows capped: the bars share one column however long the spend-of-cap text is.
@@ -633,14 +653,18 @@ if (isMain(import.meta.url)) {
633
653
  // truncate the render.
634
654
  const calls: { slot: string; text: string }[] = [];
635
655
  const slotTheme = { fg: (c: string, t: string) => (calls.push({ slot: c, text: t }), t), bold: (t: string) => t };
636
- const slotModal = new BudgetModalComponent(slotTheme as never, budgetRows(), { change: () => {}, done: () => {}, requestRender: () => {} }, BUDGET_PICKER_TEXT as never);
656
+ const slotModal = new BudgetModalComponent(slotTheme as never, budgetRows(), { change: () => {}, reset: () => {}, done: () => {}, requestRender: () => {} }, BUDGET_PICKER_TEXT as never);
637
657
  slotModal.render(80); // today OVER (120% of $5), 30d OK (60% of $10)
658
+ assert(calls.find((c) => c.text === "Today")?.slot === "dim", "Today label uses dim");
659
+ assert(calls.find((c) => c.text === "30d ")?.slot === "dim", "30d label uses dim");
638
660
  assert(calls.find((c) => c.text === "OVER")?.slot === "error", "OVER paints with the theme's error slot");
639
661
  assert(calls.find((c) => c.text === "OK")?.slot === "accent", "OK paints with the theme's accent slot");
640
662
  setBudgetMonth(7); // 30d $6 of $7 = 85% → WARN
641
663
  slotModal.render(80);
642
664
  assert(calls.filter((c) => c.text === "WARN").pop()?.slot === "warning", "WARN paints with the theme's warning slot");
643
- setBudgetMonth(undefined);
665
+ setBudgetEnforce(true);
666
+ resetBudget();
667
+ assert(activeBudgetDay() === undefined && activeBudgetMonth() === undefined && activeBudgetEnforce() === false, "resetBudget clears caps and enforce");
644
668
 
645
669
  // An estimated-cost entry adds the `Total · $X est.` line under the windows.
646
670
  writeFileSync(
@@ -648,8 +672,11 @@ if (isMain(import.meta.url)) {
648
672
  JSON.stringify({ message: { role: "assistant", provider: "google", model: "m", timestamp: Date.now(), usage: { input: 1, output: 1, cost: { total: 2 } } } }) + "\n",
649
673
  );
650
674
  resetUsageCache();
651
- const estRendered = modal.render(80).map((l) => l.replace(/\x1b\[[0-9;]*m/g, ""));
675
+ calls.length = 0;
676
+ const estRendered = slotModal.render(80).map((l) => l.replace(/\x1b\[[0-9;]*m/g, ""));
652
677
  assert(estRendered.some((l) => l.includes("Total · $4.00 est.")), "the estimated total line renders: " + estRendered.filter((l) => l.includes("Total")).join(" | "));
678
+ assert(calls.find((c) => c.text === "Total")?.slot === "dim", "Total label uses dim");
679
+ assert(calls.find((c) => c.text === "$4.00 est.")?.slot === "text", "Total value beside label uses default text color");
653
680
  rmSync(join(fixture, "sessions", "p", "e.jsonl"));
654
681
  resetUsageCache();
655
682