@bismawy/pi-arnative 0.11.1 → 0.13.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 +49 -6
- package/README.md +16 -6
- package/extensions/arnative.ts +214 -24
- package/extensions/autocompact.ts +659 -63
- package/extensions/budget.ts +37 -10
- package/extensions/footer.ts +611 -21
- package/extensions/model-heal.ts +14 -17
- package/extensions/render-cache.ts +638 -0
- package/extensions/timestamps.ts +3 -3
- package/extensions/todos.ts +74 -4
- package/extensions/tools.ts +246 -12
- package/extensions/ui-render-tweaks.ts +273 -1
- package/extensions/usage.ts +11 -7
- package/lib/list-picker.ts +19 -3
- package/lib/model-heal.ts +38 -12
- package/lib/patch.ts +26 -1
- package/lib/preset-store.ts +6 -1
- package/lib/status-widget.ts +5 -16
- package/lib/todos.ts +7 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.
|
|
3
|
+
## [0.13.0] - 2026-11-18
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **The byte-shed ceiling follows the proxy wall.** `SHED_TRIGGER_BYTES` was a fixed 900 KB, so a 1M-token model shed at roughly 12% of its window and lost context the token budget could still hold. `PI_ARNATIVE_BYTE_WALL_MB` now scales the trigger, target, and compaction ceilings (default `1`, unchanged behaviour). Set it to the wall your proxy accepts, for example `16` after raising nginx to `client_max_body_size 16m`. The footer label follows: `0.74MB/900KB` below 1 MB, `0.74MB/14.06MB` at a 16 MB wall (`extensions/autocompact.ts`, `extensions/footer.ts`).
|
|
7
|
+
- **`/arnative` pickers wrap at the top and bottom rows.** Navigation used to clamp, so a held arrow key stuck at the first or last row. The cursor now wraps like `/jev-eye`: up from the top lands on the last row, down from the last row lands on the top. Every submenu shares `ListPicker`, so one change covers them all (`lib/list-picker.ts`).
|
|
8
|
+
- **Render cache (`/arnative` → Render cache: `On`/`Off`, default `On`): reuse rendered transcript lines for idle frames.** Container-level render caching attaches to the `chatContainer` instance and patches `rebuildChatFromMessages`; known, settled transcript frames are served from a cached snapshot after checking child state (prior synthetic render-only benchmark: idle 15.23 ms → 0.77 ms per frame, streaming 10.46 ms → 6.43 ms), and the cache clears on `session_start`, `model_select`, and `session_compact` (`extensions/render-cache.ts`, `scripts/bench-render-cache.mjs`, `test/render-cache.test.ts`).
|
|
9
|
+
- **Auto-compact `Smart` now scales with Render cache.** With `Render cache: On`, windows ≥192k compact at **90%** of `contextWindow` (1M → ~943k tokens); with `Render cache: Off`, Smart keeps the conservative tiers (1M→20% · 512k→40% · 256k→80%); windows <192k still defer to pi core. The picker note in `/arnative` reflects the active state (`extensions/autocompact.ts`, `smartPercent`, `extensions/arnative.ts`).
|
|
10
|
+
- **Remote 1 MB byte protection is now silent and decoupled from `ctx.compact()`.** For `remote/*`, `remote-magpie/*`, and models that saw HTTP 413, payloads approaching ~900 KB are trimmed in-memory (with hysteresis down to ~760 KB; 820→680 KB after a 413) by dropping older images → older thinking blocks (keeping the latest turn intact) → bulky old tool outputs → old `toolCall` args → head turns. The transcript, UI, and `render-cache` stay untouched, and byte pressure alone never triggers session compaction anymore: only token thresholds do (`extensions/autocompact.ts`).
|
|
11
|
+
- **Footer payload pressure for byte-limited models (` x.xxMB/900KB` on the left row).** The cell renders beside the extension statuses, split by the row `|` separator, so the right metrics (speed, cache, tokens, cost) keep their slots. The byte count comes from the autocompact snapshot (messages plus measured overhead) for `remote/*`, `remote-magpie/*`, and models that saw HTTP 413. The denominator is the shed trigger (900KB), not the 1MB proxy wall: at 758KB the old `/1MB` label read 74% while the trim wall was already at 84%. Plain models never see the cell (`extensions/footer.ts`, `extensions/autocompact.ts`, `test/wire-bytes.test.ts`, `test/wire-bytes-left.test.ts`).
|
|
4
12
|
|
|
5
13
|
### Fixed
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
14
|
+
- Custom message renderers, unknown transcript components, and extension subclasses bypass the render cache. Nested content changes now appear without parent invalidation, while known Pi siblings remain cached and mouse hitbox heights stay current (`extensions/render-cache.ts`, `test/render-cache.test.ts`).
|
|
15
|
+
- Measure byte-limited message arrays as serialized JSON UTF-8, including Unicode, JSON escapes, and array separators. This replaces inaccurate structural sizing and object-identity caches, so oversized Unicode payloads trigger the byte guard on their first request (`extensions/autocompact.ts`, `test/wire-bytes.test.ts`).
|
|
16
|
+
- **`model-heal.ts` crash: `ReferenceError: DEBOUNCE_MS is not defined` exited pi.** The widget→notify refactor removed the `DEBOUNCE_MS` constant but left its use in the `models.json` `FSWatcher` debounce; a heal pass writing `models.json` crashed pi via uncaught exception. The constant is restored, the watcher now handles async `error` events (deleting the watched directory makes `fs.watch` emit an `EPERM` that no try/catch can intercept), and two regression tests drive the real extension in a child process so removing either the constant or the handler fails the suite (`extensions/model-heal.ts`, `test/model-heal-watcher.test.ts`, `test/fixtures/watcher-child.mjs`).
|
|
17
|
+
- **`renderCache` key order is pinned in `config.json`.** `KEY_ORDER` in `lib/preset-store.ts` now includes `renderCache` after `modelHeal`, so partial configs keep a stable order (`test/profile.test.ts`).
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
### Changed
|
|
20
|
+
- **Documented Render cache, Smart tiers, and `PI_ARNATIVE_BYTE_WALL_MB` in `README.md`.** Added the `Render cache` toggle (`On` by default), updated `Smart` auto-compact tiers (`90%` for `>= 192k` with Render cache `On`, conservative tiers with `Off`), summarized fixed-budget trade-offs and byte-wall scaling, and updated the `/arnative` shortcut and architecture tables (`README.md`).
|
|
21
|
+
- **The footer hourly rate renders `dim`.** `$19.98 (~$7.06/h)` painted both values the same, so the cost read as one number. The rate suffix now takes `dim` while the amount keeps `soft`; an active budget cap still paints the whole cell one alert colour (`extensions/footer.ts`, `test/footer-rate.test.ts`).
|
|
22
|
+
- Byte measurement is skipped for models without a byte wall. Byte-limited sessions use exact serialized JSON UTF-8 measurements; Pi clones the message array before each `context` event, so per-object caches do not stay warm across requests (`extensions/autocompact.ts`).
|
|
23
|
+
- **Render-cache width LRU holds 3 widths.** A 3-way width toggle (font-size steps, tmux pane alternation) thrashed the 2-slot LRU at ~710 us/render; 3 slots keep it warm at ~35 us/render (`extensions/render-cache.ts`, `test/render-cache.test.ts`).
|
|
24
|
+
- **Arnative notices now render as transcript notifies instead of the widget slot above the editor.** The old `setWidget` notice covered the prompt; `announce()` now emits a `notify` line that stays visible in scrollback without blocking anything (`lib/status-widget.ts`).
|
|
25
|
+
- **Tool box scroll indicators hold-to-repeat.** Holding left-click on a boxed tool's `↑ N more` / `↓ N more` border indicator auto-scrolls (250 ms delay, then every 90 ms) until release or the boundary (`extensions/tools.ts`).
|
|
26
|
+
|
|
27
|
+
## [0.12.0] - 2026-11-14
|
|
28
|
+
|
|
29
|
+
- Fix Todos auto-hide cancellation when a body click opens a finished task list.
|
|
30
|
+
- Fix Todos collapsing when clicking a `↑ 1 more` / `↓ 1 more` counter row that disappears after scrolling (`extensions/todos.ts`, `test/todos-widget.test.ts`).
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- **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`).
|
|
34
|
+
|
|
35
|
+
- **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`).
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
- **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`).
|
|
39
|
+
- **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`).
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
- **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`).
|
|
43
|
+
- **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`).
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
- **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`).
|
|
12
47
|
|
|
13
48
|
## [0.11.1] - 2026-11-13
|
|
14
49
|
|
|
@@ -44,6 +79,14 @@
|
|
|
44
79
|
- **Enter says Select, each footer names one exit, and Budget changes on Space.** The shared menu legend read `[Enter] Open` while the pickers read `Select`; it now says `Select` everywhere. The Footers legend drops the duplicate `[←] Back` and renames `[Esc] Revert` to `[Esc] Back`, because both keys already ran the same `back()`. The Budget screen moves its change action to Space (`[↑↓] Move [Space] Change [Esc] Back`) and Enter no longer changes a row; it stops calling Esc `Close` when it returns to `/arnative`. The Thinking list spells its number keys as `[0-6] Set level`, the provider delete prompt uses the arnative box instead of pi's stock confirm, and the Usage description names the active view, with its legend reading `[Space/Click] Show/Hide` and `[v] Next: <view>` stating where the key leads (`lib/shortcuts.ts`, `LEGEND_ROOT`/`LEGEND_MOVE`; `extensions/arnative.ts`, `footersPickerText`; `extensions/budget.ts`, `BUDGET_PICKER_TEXT`; `lib/provider.ts`, `THINKING_LEGEND`, `deleteProviderFlow`; `extensions/usage.ts`, the dashboard description; pinned in the list-picker, shortcuts, arnative, budget and usage self-checks).
|
|
45
80
|
- **The Usage dashboard drops two summary lines and groups the price table.** The Total row now shows the catalog estimate (`~$2.93`) when no provider reported a billed total, instead of a bare `-`. The `today · 7d · 30d` line and the separate estimate line under it are gone, and the detail line writes `$2.93 est.` without a second `~`. In the Prices view, models sit under their provider like the Provider view, the group row stays blank, and the rate columns gained a space. Rows follow the menu palette: a group row (provider or project) uses the plain text color, model and price rows are dim, the expand arrow is accent, and the selected row takes the soft accent. Project and Prices keep that same two-level shape: one group row, then its indented rows (`softOf` derives it from the theme accent, so a theme without the `accentSoft` token still renders; `extensions/usage.ts`, `UsageModalComponent`, `buildFlatRows`, the row and Total renderers; pinned in the usage self-check).
|
|
46
81
|
|
|
82
|
+
## [0.10.1] - 2026-11-11
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
- Manual Model heal shows a start notice and live progress for flags, catalogs, and thinking probes. Final results now include partial failures.
|
|
86
|
+
- Manual Model heal now cancels on session reload or replacement. Model refresh captures the current model before awaiting and uses the bound extension API.
|
|
87
|
+
- Model heal now respects the one-hour cooldown after a failed effort probe. Reordering thinking map keys no longer triggers another probe.
|
|
88
|
+
- Failed model catalogs now wait one hour before an automatic retry. Successful catalogs keep their six-hour TTL; forced heals and endpoint changes bypass the cooldown.
|
|
89
|
+
|
|
47
90
|
## [0.10.0] - 2026-11-08
|
|
48
91
|
|
|
49
92
|
### Added
|
package/README.md
CHANGED
|
@@ -24,7 +24,8 @@ pi-arnative replaces pi’s default terminal chrome with a unified visual interf
|
|
|
24
24
|
- Prometheus Textfile Export: On every `turn_end` (at most one write per minute, and only when the numbers changed) the usage summary is written as an exposition file to `~/.pi/agent/arnative/usage.prom` — point a textfile collector at that folder (`node_exporter --collector.textfile.directory=~/.pi/agent/arnative`) and the spend lands in Grafana next to the infra metrics; set `PI_ARNATIVE_EXPORT=0` to turn it off.
|
|
25
25
|
- Custom Providers: Interactive `/providers` wizard to probe endpoints, pick models, set thinking levels, edit the base URL, provider id or API key, and save OpenAI-, Anthropic-, Gemini-, or Ollama-compatible channels to `models.json` and `auth.json`.
|
|
26
26
|
- Model Heal: Background sync (`/model-heal`) that fills missing compat flags, `/models` token limits, and accepted reasoning effort levels in `models.json`.
|
|
27
|
-
- Auto-compact:
|
|
27
|
+
- Auto-compact: Triggers context compaction after a turn settles using Render-cache-aware Smart tiers or a fixed token budget, plus silent in-memory byte trimming for byte-capped proxies.
|
|
28
|
+
- Render Cache: Caches settled transcript components inside `chatContainer` so TUI redraws stay fast on large sessions (`On` by default).
|
|
28
29
|
|
|
29
30
|
<details>
|
|
30
31
|
<summary><b>Configuration & Presets</b></summary>
|
|
@@ -33,10 +34,16 @@ Saved to `~/.pi/agent/arnative/config.json` via `/arnative`:
|
|
|
33
34
|
|
|
34
35
|
- **Headers & Footers:** `Arnative (Full)` (default), `Arnative (Minimal)` (footer only; click head text or press `ctrl+alt+m` to toggle), or `Pi (system)`.
|
|
35
36
|
- **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`.
|
|
37
|
+
- **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
38
|
- **Animations:** 18 presets (`Arnative` default, `Pi (system)`, and alphabetical variants). Press `[g]` in the picker to toggle the Google gradient sweep.
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
39
|
+
- **Render cache:** `On` by default. Reuses rendered lines for settled Pi transcript components in `chatContainer`; streaming items, active animations, and custom or unknown renderers bypass the cache.
|
|
40
|
+
- **Auto-compact:** `Off` by default (extension trigger disabled; Pi core compaction stays in charge).
|
|
41
|
+
- **Smart:** Adapts to `Render cache` and `contextWindow`. With `Render cache: On`, windows `>= 192k` trigger at `90%` (`~180k` on `200k`, `~900k` on `1M`, `943,718` on `1,048,576`), while `< 192k` defers to Pi core. With `Render cache: Off`, `Smart` uses conservative tiers (`1M -> 20%`, `512k -> 40%`, `256k -> 80%`, `< 192k -> pi core`).
|
|
42
|
+
- **Fixed budgets (`100k` to `400k`):** Fire at one absolute token count on any window. A budget above a model's capacity does not expand it; Pi core (`reserveTokens`) and provider limits still apply first.
|
|
43
|
+
- **Trade-offs:** `Smart` retains raw history longer on large windows and avoids unnecessary summarization on short sessions. An earlier fixed budget such as `300k` shrinks prompts after compaction on 1M-window models, but pays an upfront summary cost and resets the prefix cache once; in a 6-turn GLM/Magpie coding A/B sample, `300k` broke even at request 5 and cost 16.1% less at configured rates, while a 2-turn ~250k test cost more than keeping the prefix cached. Thresholds are triggers, not hard caps.
|
|
44
|
+
- **Byte guard (`PI_ARNATIVE_BYTE_WALL_MB`):** For `remote/*`, `remote-magpie/*`, and models that saw HTTP 413, payloads approaching `900 KB` (at the default `1` MB wall) are trimmed in-memory before sending without triggering compaction or altering session history. Set `PI_ARNATIVE_BYTE_WALL_MB` before starting Pi to scale the ceiling (for example `16` for a `16m` proxy limit); the footer shows wire bytes on the left row.
|
|
45
|
+
- **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.
|
|
46
|
+
- **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
47
|
|
|
41
48
|
</details>
|
|
42
49
|
|
|
@@ -74,7 +81,7 @@ module deleted here is pruned from the installed copy (a stale entry point would
|
|
|
74
81
|
| `ctrl+alt+k` · `alt+k` | Scroll task list up |
|
|
75
82
|
| Click `[show]` / `[hide]` · `ctrl+o` | Toggle tool output box |
|
|
76
83
|
| `←` / `Esc` | Step back to parent menu / close active screen |
|
|
77
|
-
| `/arnative` | Settings menu (Themes, Headers, Footers, Animations, Auto-compact, Model heal, Providers, Usage, Budget) |
|
|
84
|
+
| `/arnative` | Settings menu (Themes, Headers, Footers, Animations, Render cache, Auto-compact, Model heal, Providers, Usage, Budget) |
|
|
78
85
|
| `/usage` | Token & cost dashboard |
|
|
79
86
|
| `/todos` | Full task list recap |
|
|
80
87
|
| `/providers` | Custom provider manager |
|
|
@@ -111,7 +118,10 @@ Bind `app.session.new` in `~/.pi/agent/keybindings.json`:
|
|
|
111
118
|
| `extensions/tools.ts` | Rounded tool boxes, spinners, duration, and `[show]` / `[hide]` toggles |
|
|
112
119
|
| `extensions/todos.ts` | `todo` tool, boxed widget above editor, and `/todos` screen |
|
|
113
120
|
| `extensions/animations.ts` | Spinner preset picker and live preview |
|
|
114
|
-
| `extensions/autocompact.ts` | Smart and fixed-budget context compaction |
|
|
121
|
+
| `extensions/autocompact.ts` | Smart and fixed-budget context compaction plus silent byte-wall shedding |
|
|
122
|
+
| `extensions/render-cache.ts` | Per-child and container transcript render cache for `chatContainer` |
|
|
123
|
+
| `extensions/budget.ts` | UTC day and rolling 30-day spend caps and footer warnings |
|
|
124
|
+
| `extensions/usage-export.ts` | Prometheus textfile metric export (`usage.prom`) |
|
|
115
125
|
| `extensions/model-heal.ts` | Automatic `models.json` heal triggers and `/model-heal` |
|
|
116
126
|
| `extensions/timestamps.ts` | Message timestamps and bubble backgrounds |
|
|
117
127
|
| `extensions/ui-render-tweaks.ts` | Contrast tweaks, selection styling, and UI polish |
|
package/extensions/arnative.ts
CHANGED
|
@@ -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, RENDER_CACHE_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 {
|
|
@@ -37,6 +37,12 @@ import {
|
|
|
37
37
|
} from "./autocompact.ts";
|
|
38
38
|
import { cancelManualHeal, healNow } from "./model-heal.ts";
|
|
39
39
|
import { MODEL_HEAL_CHOICES, MODEL_HEAL_KEY, activeModelHeal, setModelHeal, type ModelHealChoice } from "../lib/model-heal.ts";
|
|
40
|
+
import {
|
|
41
|
+
RENDER_CACHE_CHOICES,
|
|
42
|
+
activeRenderCache,
|
|
43
|
+
setRenderCache,
|
|
44
|
+
type RenderCacheChoice,
|
|
45
|
+
} from "./render-cache.ts";
|
|
40
46
|
import { LIST_LEGEND_LIVE, LIST_LEGEND_MOVE, LIST_LEGEND_ROOT, ListPicker, nameRows, rowText, type ListPickerText, type ListRow } from "../lib/list-picker.ts";
|
|
41
47
|
import { BACK_KEY_LABEL } from "../lib/shortcuts.ts";
|
|
42
48
|
import { openProviders } from "../lib/provider.ts";
|
|
@@ -59,7 +65,7 @@ export function menuRows(menus: Pick<ArnativeMenu, "label" | "description">[]):
|
|
|
59
65
|
/** Title of the settings menu, derived from `screenTitle` so the format lives in one place. */
|
|
60
66
|
export const MENU_TITLE = screenTitle("Settings");
|
|
61
67
|
/** One-line description under the menu title. */
|
|
62
|
-
export const MENU_DESC = "Themes, headers, footers, animations, auto-compact, providers, usage, budget";
|
|
68
|
+
export const MENU_DESC = "Themes, headers, footers, chatbox, animations, auto-compact, render, providers, usage, budget";
|
|
63
69
|
|
|
64
70
|
const THEMES_PICKER_TEXT: ListPickerText = {
|
|
65
71
|
title: screenTitle("Themes"),
|
|
@@ -222,6 +228,85 @@ const openHeaders = async (ctx: ExtensionCommandContext): Promise<boolean | void
|
|
|
222
228
|
return goBack === true;
|
|
223
229
|
};
|
|
224
230
|
|
|
231
|
+
const CHATBOX_PICKER_TEXT: ListPickerText = {
|
|
232
|
+
title: screenTitle("Chatbox"),
|
|
233
|
+
description: "Selection applies when confirmed — rounded arnative box or built-in editor.",
|
|
234
|
+
legend: "[↑↓] Preview [i] Icon [D] Dialog [Enter] Select [Esc] Back",
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const CHATBOX_NOTES: Record<ChatboxPreset, string> = {
|
|
238
|
+
"Pi (system)": "built-in top and bottom lines",
|
|
239
|
+
Arnative: "rounded arnative box with prompt & status placement",
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const chatboxRows = (): ListRow[] => CHATBOX_PRESETS.map((c) => ({ label: c, note: CHATBOX_NOTES[c] }));
|
|
243
|
+
|
|
244
|
+
export const chatboxSummary = (theme: { fg(c: string, t: string): string }): string[] => {
|
|
245
|
+
const dim = (s: string) => theme.fg("dim", s);
|
|
246
|
+
const txt = (s: string) => theme.fg("text", s);
|
|
247
|
+
const acc = (s: string) => theme.fg("accent", s);
|
|
248
|
+
const activeIcon = activeChatboxPrompt();
|
|
249
|
+
const icons = CHATBOX_PROMPTS.map((p) => (p === activeIcon ? acc(p) : dim(p))).join(" ");
|
|
250
|
+
const dialog = activeChatboxDialog();
|
|
251
|
+
const dialogTag = dialog === DEFAULT_CHATBOX_DIALOG ? ` ${dim("(default)")}` : "";
|
|
252
|
+
return [
|
|
253
|
+
`${dim("Box ")}${dim(" · ")}${txt(activeChatboxPreset())}`,
|
|
254
|
+
`${dim("Icon ")}${dim(" · ")}${icons}`,
|
|
255
|
+
`${dim("Dialog")}${dim(" · ")}${txt(dialog.toLowerCase())}${dialogTag}`,
|
|
256
|
+
];
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const openChatbox = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
260
|
+
const opened = activeChatboxPreset();
|
|
261
|
+
|
|
262
|
+
if (ctx.mode !== "tui") {
|
|
263
|
+
const labels = markedLabels(CHATBOX_PRESETS, opened);
|
|
264
|
+
const pick = await ctx.ui.select(CHATBOX_PICKER_TEXT.title, labels);
|
|
265
|
+
if (pick === undefined) return;
|
|
266
|
+
const name = CHATBOX_PRESETS[labels.indexOf(pick)]!;
|
|
267
|
+
setChatboxPreset(name);
|
|
268
|
+
ctx.ui.notify(`[arnative] Chatbox: ${name}`, "info");
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) =>
|
|
273
|
+
new ListPicker(
|
|
274
|
+
theme,
|
|
275
|
+
chatboxRows(),
|
|
276
|
+
opened,
|
|
277
|
+
{
|
|
278
|
+
preview: (name) => setChatboxPreset(name as ChatboxPreset),
|
|
279
|
+
revert: () => setChatboxPreset(opened),
|
|
280
|
+
done: () => {
|
|
281
|
+
announce(ctx.ui, `Chatbox: ${activeChatboxPreset()}.`);
|
|
282
|
+
done(false);
|
|
283
|
+
},
|
|
284
|
+
back: () => {
|
|
285
|
+
if (activeChatboxPreset() !== opened) setChatboxPreset(opened);
|
|
286
|
+
done(true);
|
|
287
|
+
},
|
|
288
|
+
press: (keyData) => {
|
|
289
|
+
if (matchesKey(keyData, "i") || keyData === "I") {
|
|
290
|
+
setChatboxPrompt(nextChatboxPrompt());
|
|
291
|
+
tui.requestRender();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (matchesKey(keyData, "d") || keyData === "D") {
|
|
295
|
+
setChatboxDialog(nextChatboxDialog());
|
|
296
|
+
tui.requestRender();
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
summary: () => chatboxSummary(theme),
|
|
300
|
+
requestRender: () => tui.requestRender(),
|
|
301
|
+
},
|
|
302
|
+
CHATBOX_PICKER_TEXT,
|
|
303
|
+
true,
|
|
304
|
+
ctx.thinkingLevel,
|
|
305
|
+
),
|
|
306
|
+
);
|
|
307
|
+
return goBack === true;
|
|
308
|
+
};
|
|
309
|
+
|
|
225
310
|
/** Animations picker. Unlike Themes/Headers/Footers the choice has a visible effect only
|
|
226
311
|
* while a tool runs, so there is nothing to preview live on the screen itself — the row
|
|
227
312
|
* previews the frames instead, and Enter installs the preset for the next run. */
|
|
@@ -286,20 +371,26 @@ const AUTOCOMPACT_PICKER_TEXT: ListPickerText = {
|
|
|
286
371
|
legend: LIST_LEGEND_MOVE,
|
|
287
372
|
};
|
|
288
373
|
|
|
289
|
-
/** One note per row: Smart
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
374
|
+
/** One note per row: Smart reflects Render cache state, a manual budget its window-independence. */
|
|
375
|
+
function autoCompactNotes(): Record<AutoCompactChoice, string> {
|
|
376
|
+
return {
|
|
377
|
+
Off: "never — pi's own compaction stays in charge",
|
|
378
|
+
Smart:
|
|
379
|
+
activeRenderCache() === "On"
|
|
380
|
+
? "90% of window (≥192k) · <192k→pi core"
|
|
381
|
+
: "by window: 1M→20% · 512k→40% · 256k→80% · <192k→pi core",
|
|
382
|
+
"100k": "always above 100k tokens, any window",
|
|
383
|
+
"150k": "always above 150k tokens, any window",
|
|
384
|
+
"200k": "always above 200k tokens, any window",
|
|
385
|
+
"300k": "always above 300k tokens, any window",
|
|
386
|
+
"400k": "always above 400k tokens, any window",
|
|
387
|
+
};
|
|
388
|
+
}
|
|
299
389
|
|
|
300
390
|
/** Rows for the Auto-compact picker: the saved choice ends its row with a green ✓. */
|
|
301
391
|
export function autoCompactRows(opened: AutoCompactChoice): ListRow[] {
|
|
302
|
-
|
|
392
|
+
const notes = autoCompactNotes();
|
|
393
|
+
return AUTO_COMPACT_CHOICES.map((c) => ({ label: c, note: notes[c], chosen: c === opened }));
|
|
303
394
|
}
|
|
304
395
|
|
|
305
396
|
/** A plain (non-live) picker: the choice is committed by Enter, nothing previews. The
|
|
@@ -418,6 +509,62 @@ const openModelHeal = async (ctx: ExtensionCommandContext): Promise<boolean | vo
|
|
|
418
509
|
return goBack === true;
|
|
419
510
|
};
|
|
420
511
|
|
|
512
|
+
const RENDER_CACHE_PICKER_TEXT: ListPickerText = {
|
|
513
|
+
title: screenTitle("Render cache"),
|
|
514
|
+
description: "Cache settled chat messages and tool boxes so long sessions stay smooth across frames.",
|
|
515
|
+
legend: LIST_LEGEND_MOVE,
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const RENDER_CACHE_NOTES: Record<RenderCacheChoice, string> = {
|
|
519
|
+
On: "reuse rendered lines for finished messages and tool boxes (default)",
|
|
520
|
+
Off: "render every transcript component directly on each frame",
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
/** Rows for the Render cache picker: the saved choice ends its row with a green ✓. */
|
|
524
|
+
export function renderCacheRows(opened: RenderCacheChoice): ListRow[] {
|
|
525
|
+
return RENDER_CACHE_CHOICES.map((c) => ({ label: c, note: RENDER_CACHE_NOTES[c], chosen: c === opened }));
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const openRenderCache = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
529
|
+
const opened = activeRenderCache();
|
|
530
|
+
|
|
531
|
+
if (ctx.mode !== "tui") {
|
|
532
|
+
const labels = RENDER_CACHE_CHOICES.map((c) => (c === opened ? `${c} ✓` : c));
|
|
533
|
+
const pick = await ctx.ui.select(RENDER_CACHE_PICKER_TEXT.title, labels);
|
|
534
|
+
if (pick === undefined) return;
|
|
535
|
+
const choice = RENDER_CACHE_CHOICES[labels.indexOf(pick)]!;
|
|
536
|
+
setRenderCache(choice);
|
|
537
|
+
ctx.ui.notify(`[arnative] Render cache: ${choice}`, "info");
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) => {
|
|
542
|
+
const picker = new ListPicker(
|
|
543
|
+
theme,
|
|
544
|
+
renderCacheRows(opened),
|
|
545
|
+
opened,
|
|
546
|
+
{
|
|
547
|
+
preview: () => {},
|
|
548
|
+
revert: () => {},
|
|
549
|
+
done: () => {
|
|
550
|
+
const choice = RENDER_CACHE_CHOICES[picker.index]!;
|
|
551
|
+
setRenderCache(choice);
|
|
552
|
+
announce(ctx.ui, `Render cache: ${choice}.`);
|
|
553
|
+
done(false);
|
|
554
|
+
},
|
|
555
|
+
cancel: () => done(false),
|
|
556
|
+
back: () => done(true),
|
|
557
|
+
requestRender: () => tui.requestRender(),
|
|
558
|
+
},
|
|
559
|
+
RENDER_CACHE_PICKER_TEXT,
|
|
560
|
+
false,
|
|
561
|
+
ctx.thinkingLevel,
|
|
562
|
+
);
|
|
563
|
+
return picker;
|
|
564
|
+
});
|
|
565
|
+
return goBack === true;
|
|
566
|
+
};
|
|
567
|
+
|
|
421
568
|
export const MENUS: ArnativeMenu[] = [
|
|
422
569
|
{
|
|
423
570
|
value: "themes",
|
|
@@ -437,6 +584,12 @@ export const MENUS: ArnativeMenu[] = [
|
|
|
437
584
|
description: "choose the footer preset",
|
|
438
585
|
open: openFooters,
|
|
439
586
|
},
|
|
587
|
+
{
|
|
588
|
+
value: "chatbox",
|
|
589
|
+
label: "Chatbox",
|
|
590
|
+
description: "choose the input box preset",
|
|
591
|
+
open: openChatbox,
|
|
592
|
+
},
|
|
440
593
|
{
|
|
441
594
|
value: "animations",
|
|
442
595
|
label: "Animations",
|
|
@@ -455,6 +608,12 @@ export const MENUS: ArnativeMenu[] = [
|
|
|
455
608
|
description: "auto-fix models.json: compat flags, limits, thinking levels (on by default)",
|
|
456
609
|
open: openModelHeal,
|
|
457
610
|
},
|
|
611
|
+
{
|
|
612
|
+
value: "render",
|
|
613
|
+
label: "Render cache",
|
|
614
|
+
description: "cache settled transcript rows across frames (on by default)",
|
|
615
|
+
open: openRenderCache,
|
|
616
|
+
},
|
|
458
617
|
{
|
|
459
618
|
value: "providers",
|
|
460
619
|
label: "Providers",
|
|
@@ -564,7 +723,7 @@ export function shouldApplyDefaultTheme(
|
|
|
564
723
|
* set without starting a session. */
|
|
565
724
|
export function registerCommands(pi: Pick<ExtensionAPI, "registerCommand">): void {
|
|
566
725
|
pi.registerCommand("arnative", {
|
|
567
|
-
description: "Arnative settings menu: themes, headers, footers, animations, auto-compact, model heal, providers, usage, budget",
|
|
726
|
+
description: "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, render cache, providers, usage, budget",
|
|
568
727
|
getArgumentCompletions: arnativeCompletions,
|
|
569
728
|
handler: arnativeHandler,
|
|
570
729
|
});
|
|
@@ -583,10 +742,14 @@ export function recordProfile(): void {
|
|
|
583
742
|
[HEADER_PRESET_KEY]: activeHeaderPreset(),
|
|
584
743
|
[FOOTER_PRESET_KEY]: activeFooterPreset(),
|
|
585
744
|
[FOOTER_COST_KEY]: activeFooterCost() ? "on" : "off",
|
|
745
|
+
[CHATBOX_PRESET_KEY]: activeChatboxPreset(),
|
|
746
|
+
[CHATBOX_PROMPT_KEY]: activeChatboxPrompt(),
|
|
747
|
+
[CHATBOX_DIALOG_KEY]: activeChatboxDialog(),
|
|
586
748
|
[SPINNER_PRESET_KEY]: activeSpinnerPreset(),
|
|
587
749
|
[SPINNER_GRADIENT_KEY]: activeSpinnerGradient() ? "on" : "off",
|
|
588
750
|
[AUTO_COMPACT_KEY]: activeAutoCompact(),
|
|
589
751
|
[MODEL_HEAL_KEY]: activeModelHeal(),
|
|
752
|
+
[RENDER_CACHE_KEY]: activeRenderCache(),
|
|
590
753
|
[BUDGET_DAY_KEY]: activeBudgetDay() === undefined ? "" : String(activeBudgetDay()),
|
|
591
754
|
[BUDGET_MONTH_KEY]: activeBudgetMonth() === undefined ? "" : String(activeBudgetMonth()),
|
|
592
755
|
[BUDGET_ENFORCE_KEY]: activeBudgetEnforce() ? "on" : "off",
|
|
@@ -624,18 +787,22 @@ if (isMain(import.meta.url)) {
|
|
|
624
787
|
assert(rowText(labels[0]!) === "Themes · arnative themes only (all themes: /settings → Theme)", "menu row text format");
|
|
625
788
|
assert(labels[0]!.label === "Themes" && labels[0]!.note === "arnative themes only (all themes: /settings → Theme)", "menu row keeps label and note apart");
|
|
626
789
|
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}`);
|
|
790
|
+
assert(MENU_DESC === "Themes, headers, footers, chatbox, animations, auto-compact, render, providers, usage, budget", `the menu description is the pinned string, got ${MENU_DESC}`);
|
|
628
791
|
// Every menu row is reachable and the description names them all, so a new screen cannot
|
|
629
792
|
// be added to MENUS and forgotten in the copy a user reads first.
|
|
630
|
-
assert(MENUS.length ===
|
|
793
|
+
assert(MENUS.length === 11, "eleven settings screens");
|
|
631
794
|
{
|
|
632
795
|
const values = MENUS.map((m) => m.value);
|
|
633
796
|
assert(values.indexOf("heal") === values.indexOf("compact") + 1, "Model heal row sits right after Auto-compact");
|
|
797
|
+
assert(values.indexOf("render") === values.indexOf("heal") + 1, "Render cache row sits right after Model heal");
|
|
634
798
|
const heal = modelHealRows("Flags");
|
|
635
799
|
assert(heal.map((r) => r.label).join(",") === "Full,Flags,Off,Run now", "Model heal rows: three modes then Run now");
|
|
636
800
|
assert(heal.filter((r) => r.chosen).map((r) => r.label).join(",") === "Flags", "Model heal marks only the saved mode");
|
|
801
|
+
const rc = renderCacheRows("On");
|
|
802
|
+
assert(rc.map((r) => r.label).join(",") === "On,Off", "Render cache rows: On then Off");
|
|
803
|
+
assert(rc.filter((r) => r.chosen).map((r) => r.label).join(",") === "On", "Render cache marks only the saved mode");
|
|
637
804
|
}
|
|
638
|
-
for (const label of ["Themes", "Headers", "Footers", "Animations", "Auto-compact", "Providers", "Usage", "Budget"]) {
|
|
805
|
+
for (const label of ["Themes", "Headers", "Footers", "Chatbox", "Animations", "Auto-compact", "Render cache", "Providers", "Usage", "Budget"]) {
|
|
639
806
|
assert(MENUS.some((m) => m.label === label), `MENUS carries the ${label} screen`);
|
|
640
807
|
}
|
|
641
808
|
assert(/^Settings - Arnative/.test(MENU_TITLE), "title follows `<setting> - <extension>`");
|
|
@@ -648,6 +815,8 @@ if (isMain(import.meta.url)) {
|
|
|
648
815
|
assert(arnativeCompletions("he")![0]!.value === "headers", "headers menu has completions");
|
|
649
816
|
assert(arnativeCompletions("fo")![0]!.value === "footers", "footers menu has completions");
|
|
650
817
|
assert(MENUS.some((m) => m.value === "footers"), "footers menu registered");
|
|
818
|
+
assert(arnativeCompletions("ch")![0]!.value === "chatbox", "chatbox menu has completions");
|
|
819
|
+
assert(MENUS.some((m) => m.value === "chatbox"), "chatbox menu registered");
|
|
651
820
|
assert(arnativeCompletions("co")![0]!.value === "compact", "compact menu has completions");
|
|
652
821
|
assert(MENUS.some((m) => m.value === "compact"), "compact menu registered");
|
|
653
822
|
|
|
@@ -657,6 +826,8 @@ if (isMain(import.meta.url)) {
|
|
|
657
826
|
assert(acRows[1]!.chosen === true && acRows[0]!.chosen !== true, "the ✓ follows the saved choice");
|
|
658
827
|
assert(acRows.every((r) => r.note!.length > 0), "every Auto-compact row carries its note");
|
|
659
828
|
assert(autoCompactRows("Off")[0]!.chosen === true, "the marker moves when the saved choice changes");
|
|
829
|
+
assert(arnativeCompletions("re")![0]!.value === "render", "render cache menu has completions");
|
|
830
|
+
assert(MENUS.some((m) => m.value === "render"), "render cache menu registered");
|
|
660
831
|
assert(arnativeCompletions("pr")![0]!.value === "providers", "providers menu has completions");
|
|
661
832
|
assert(MENUS.some((m) => m.value === "providers"), "providers menu registered");
|
|
662
833
|
// Every slash command, and the one alias: `/providers` must land on the providers screen.
|
|
@@ -667,7 +838,7 @@ if (isMain(import.meta.url)) {
|
|
|
667
838
|
assert(typeof registered.get("providers")!.handler === "function", "/providers has a handler");
|
|
668
839
|
assert(MENUS.some((m) => m.value === "providers"), "/providers routes to a menu row that exists");
|
|
669
840
|
assert(
|
|
670
|
-
registered.get("arnative")!.description === "Arnative settings menu: themes, headers, footers, animations, auto-compact, model heal, providers, usage, budget",
|
|
841
|
+
registered.get("arnative")!.description === "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, render cache, providers, usage, budget",
|
|
671
842
|
"the /arnative command description names every screen: " + registered.get("arnative")!.description,
|
|
672
843
|
);
|
|
673
844
|
}
|
|
@@ -703,7 +874,9 @@ if (isMain(import.meta.url)) {
|
|
|
703
874
|
const previews: string[] = [];
|
|
704
875
|
let reverted = 0;
|
|
705
876
|
let done = 0;
|
|
706
|
-
|
|
877
|
+
// Wrap means one step down from the last row lands on the initial value, leaving
|
|
878
|
+
// nothing for Esc to revert, so the list carries a third row for this assertion.
|
|
879
|
+
const picker = new ListPicker(fakeTheme, nameRows(["arnative", "arnative-cyberpunk", "arnative-mono"]), "arnative", {
|
|
707
880
|
preview: (n) => previews.push(n),
|
|
708
881
|
revert: () => reverted++,
|
|
709
882
|
done: () => done++,
|
|
@@ -765,14 +938,14 @@ if (isMain(import.meta.url)) {
|
|
|
765
938
|
cancel: () => { menuCancelled = true; },
|
|
766
939
|
requestRender: () => {},
|
|
767
940
|
}, { title: MENU_TITLE, description: MENU_DESC, legend: LIST_LEGEND_ROOT }, false);
|
|
768
|
-
//
|
|
769
|
-
// be added to the copy too), and that one-liner no longer fits
|
|
770
|
-
const menuLines = mainPicker.render(
|
|
941
|
+
// 100 columns: the description names the screens (a tripwire — a screen added to MENUS must
|
|
942
|
+
// be added to the copy too), and that one-liner no longer fits 80.
|
|
943
|
+
const menuLines = mainPicker.render(100);
|
|
771
944
|
assert(menuLines.some((l) => l.includes(MENU_TITLE)), "the main menu renders its title");
|
|
772
945
|
assert(menuLines.some((l) => l.includes("[Esc] Close") && !l.includes("←")), "the root menu legend renders without a back key");
|
|
773
946
|
assert(menuLines.some((l) => l.includes(MENU_DESC)), "the main menu renders the description under the title");
|
|
774
947
|
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) ===
|
|
948
|
+
assert(menuLines.every((l) => visibleWidth(l) === 100), "main menu lines fit the width");
|
|
776
949
|
// The pinned /arnative layout: `→ Themes · note`, every `·` in one column (skill rule 10).
|
|
777
950
|
const plainMenu = menuLines.map(stripAnsi);
|
|
778
951
|
const row0 = menuLines.map(stripAnsi).find((l) => l.includes("→ Themes"))!;
|
|
@@ -865,6 +1038,23 @@ if (isMain(import.meta.url)) {
|
|
|
865
1038
|
assert(footerLines.filter((l) => l.includes("Arnative (")).length === 2, "both arnative footer presets are selectable");
|
|
866
1039
|
assert(/\[c\] Cost (on|off)/.test(footersPickerText().legend), "footers legend advertises the cost switch and its live state");
|
|
867
1040
|
|
|
1041
|
+
// Chatbox reuses the same picker with summary rows (Box/Icon/Dialog), Pi (system) first and Arnative second.
|
|
1042
|
+
assert(CHATBOX_PRESETS[0] === "Pi (system)" && CHATBOX_PRESETS[1] === "Arnative", "chatbox presets list Pi (system) then Arnative");
|
|
1043
|
+
assert(CHATBOX_DIALOGS.includes(activeChatboxDialog()), "active chatbox dialog is valid");
|
|
1044
|
+
const chatboxTagTheme = { fg: (c: string, t: string) => `<${c}>${t}</${c}>` };
|
|
1045
|
+
const chatboxTagged = chatboxSummary(chatboxTagTheme);
|
|
1046
|
+
assert(chatboxTagged.some((l) => l.includes("<dim>Box </dim><dim> · </dim><text>")), "chatbox summary renders dim Box label and separator");
|
|
1047
|
+
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 |");
|
|
1048
|
+
const expectedDialogTag = activeChatboxDialog() === DEFAULT_CHATBOX_DIALOG ? " <dim>(default)</dim>" : "";
|
|
1049
|
+
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");
|
|
1050
|
+
const chatboxPicker = new ListPicker(fakeTheme, chatboxRows(), "Arnative", { preview: () => {}, revert: () => {}, done: () => {}, requestRender: () => {}, summary: () => chatboxSummary(fakeTheme) }, CHATBOX_PICKER_TEXT);
|
|
1051
|
+
const chatboxLines = chatboxPicker.render(84);
|
|
1052
|
+
assert(chatboxLines.some((l) => l.includes(screenTitle("Chatbox"))), "chatbox picker title");
|
|
1053
|
+
assert(chatboxLines.some((l) => l.includes("Box · Arnative")), "chatbox picker shows Box summary");
|
|
1054
|
+
assert(chatboxLines.some((l) => l.includes("→ Arnative")), "chatbox picker cursors the active preset");
|
|
1055
|
+
assert(chatboxLines.some((l) => l.includes(" Pi (system)")), "chatbox picker lists the built-in preset");
|
|
1056
|
+
assert(CHATBOX_PICKER_TEXT.legend.includes("[i] Icon [D] Dialog"), "chatbox legend advertises [i] Icon and [D] Dialog");
|
|
1057
|
+
|
|
868
1058
|
// Animations picker: "Pi (system)" carries a note AND renders "(system)" in dim
|
|
869
1059
|
const animPicker = new ListPicker(
|
|
870
1060
|
{ fg: (c, t) => `<${c}>${t}</${c}>`, bold: (t) => `<bold>${t}</bold>` },
|