@bismawy/pi-arnative 0.12.0 → 0.14.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 +43 -6
- package/README.md +13 -4
- package/extensions/arnative.ts +374 -68
- package/extensions/autocompact.ts +772 -64
- package/extensions/budget.ts +4 -3
- package/extensions/footer.ts +43 -39
- package/extensions/model-heal.ts +14 -17
- package/extensions/render-cache.ts +638 -0
- package/extensions/tools.ts +52 -2
- package/extensions/ui-render-tweaks.ts +23 -7
- package/extensions/usage.ts +3 -4
- package/lib/color.ts +34 -0
- package/lib/list-picker.ts +20 -12
- package/lib/patch.ts +26 -1
- package/lib/preset-store.ts +10 -1
- package/lib/status-widget.ts +5 -16
- package/lib/usage-store.ts +4 -5
- package/package.json +49 -49
- package/themes/arnative-blossom.json +9 -9
- package/themes/arnative-crimson.json +10 -10
- package/themes/arnative-cyberpunk.json +9 -9
- package/themes/arnative-dracula.json +9 -9
- package/themes/arnative-earthy.json +10 -10
- package/themes/arnative-garden.json +10 -10
- package/themes/arnative-gruvbox.json +10 -10
- package/themes/arnative-lemonade.json +9 -9
- package/themes/arnative-magical.json +9 -9
- package/themes/arnative-matrix.json +9 -9
- package/themes/arnative-neutral.json +9 -9
- package/themes/arnative-nord.json +8 -8
- package/themes/arnative-zinc.json +9 -9
- package/themes/arnative.json +9 -9
- package/themes/gen-themes.mjs +43 -15
package/extensions/arnative.ts
CHANGED
|
@@ -24,42 +24,77 @@ import {
|
|
|
24
24
|
setSpinnerGradient,
|
|
25
25
|
setSpinnerPreset,
|
|
26
26
|
} from "./animations.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";
|
|
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, PAYLOAD_LIMIT_KEY, RENDER_CACHE_KEY, ensureChoices } from "../lib/preset-store.ts";
|
|
28
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 {
|
|
32
32
|
AUTO_COMPACT_CHOICES,
|
|
33
33
|
AUTO_COMPACT_KEY,
|
|
34
|
+
PAYLOAD_LIMIT_PRESETS,
|
|
34
35
|
activeAutoCompact,
|
|
36
|
+
activePayloadLimit,
|
|
37
|
+
ceilingsForMb,
|
|
38
|
+
envByteWallOverride,
|
|
39
|
+
parsePayloadLimit,
|
|
40
|
+
payloadLimitMb,
|
|
41
|
+
savedPayloadLimit,
|
|
35
42
|
setAutoCompact,
|
|
43
|
+
setPayloadLimit,
|
|
36
44
|
type AutoCompactChoice,
|
|
45
|
+
type PayloadLimitPreset,
|
|
37
46
|
} from "./autocompact.ts";
|
|
38
47
|
import { cancelManualHeal, healNow } from "./model-heal.ts";
|
|
39
48
|
import { MODEL_HEAL_CHOICES, MODEL_HEAL_KEY, activeModelHeal, setModelHeal, type ModelHealChoice } from "../lib/model-heal.ts";
|
|
40
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
RENDER_CACHE_CHOICES,
|
|
51
|
+
activeRenderCache,
|
|
52
|
+
setRenderCache,
|
|
53
|
+
type RenderCacheChoice,
|
|
54
|
+
} from "./render-cache.ts";
|
|
55
|
+
import { INPUT_LEGEND, InputPicker, LIST_LEGEND_LIVE, LIST_LEGEND_MOVE, LIST_LEGEND_ROOT, ListPicker, nameRows, rowText, type ListPickerText, type ListRow } from "../lib/list-picker.ts";
|
|
41
56
|
import { BACK_KEY_LABEL } from "../lib/shortcuts.ts";
|
|
42
57
|
import { openProviders } from "../lib/provider.ts";
|
|
43
58
|
import { openUsage } from "./usage.ts";
|
|
44
59
|
import { SHORTCUT_OPEN_ARNATIVE } from "../lib/shortcuts.ts";
|
|
45
60
|
|
|
61
|
+
export type MenuGroup = "Appearance" | "Performance" | "Models" | "Spend";
|
|
62
|
+
|
|
63
|
+
export interface MenuCategory {
|
|
64
|
+
label: MenuGroup;
|
|
65
|
+
description: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const MENU_CATEGORIES: readonly MenuCategory[] = [
|
|
69
|
+
{ label: "Appearance", description: "themes, headers, footers, chatbox, animations" },
|
|
70
|
+
{ label: "Performance", description: "auto-compact, render cache, payload limit" },
|
|
71
|
+
{ label: "Models", description: "custom providers, model heal" },
|
|
72
|
+
{ label: "Spend", description: "usage dashboard, budget caps" },
|
|
73
|
+
];
|
|
74
|
+
|
|
46
75
|
export interface ArnativeMenu {
|
|
47
76
|
value: string;
|
|
48
77
|
label: string;
|
|
49
78
|
description: string;
|
|
79
|
+
group: MenuGroup;
|
|
50
80
|
/** Returns `true` when the screen asked to step back to the menu (`←`). */
|
|
51
81
|
open: (ctx: ExtensionCommandContext) => Promise<boolean | void>;
|
|
52
82
|
}
|
|
53
83
|
|
|
54
84
|
/** Menu rows: `Label · description` (same rhythm as /jev-eye's menu). */
|
|
55
|
-
export function menuRows(menus:
|
|
85
|
+
export function menuRows(menus: { label: string; description: string }[]): ListRow[] {
|
|
56
86
|
return menus.map((m) => ({ label: m.label, note: m.description }));
|
|
57
87
|
}
|
|
58
88
|
|
|
89
|
+
/** Items belonging to a single root category in display order. */
|
|
90
|
+
export function categoryMenus(group: MenuGroup, menus: readonly ArnativeMenu[] = MENUS): ArnativeMenu[] {
|
|
91
|
+
return menus.filter((m) => m.group === group);
|
|
92
|
+
}
|
|
93
|
+
|
|
59
94
|
/** Title of the settings menu, derived from `screenTitle` so the format lives in one place. */
|
|
60
95
|
export const MENU_TITLE = screenTitle("Settings");
|
|
61
96
|
/** One-line description under the menu title. */
|
|
62
|
-
export const MENU_DESC = "Themes, headers, footers, chatbox, animations, auto-compact, providers, usage, budget";
|
|
97
|
+
export const MENU_DESC = "Themes, headers, footers, chatbox, animations, auto-compact, render, payload, providers, usage, budget";
|
|
63
98
|
|
|
64
99
|
const THEMES_PICKER_TEXT: ListPickerText = {
|
|
65
100
|
title: screenTitle("Themes"),
|
|
@@ -365,20 +400,26 @@ const AUTOCOMPACT_PICKER_TEXT: ListPickerText = {
|
|
|
365
400
|
legend: LIST_LEGEND_MOVE,
|
|
366
401
|
};
|
|
367
402
|
|
|
368
|
-
/** One note per row: Smart
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
403
|
+
/** One note per row: Smart reflects Render cache state, a manual budget its window-independence. */
|
|
404
|
+
function autoCompactNotes(): Record<AutoCompactChoice, string> {
|
|
405
|
+
return {
|
|
406
|
+
Off: "never — pi's own compaction stays in charge",
|
|
407
|
+
Smart:
|
|
408
|
+
activeRenderCache() === "On"
|
|
409
|
+
? "90% of window (≥192k) · <192k→pi core"
|
|
410
|
+
: "by window: 1M→20% · 512k→40% · 256k→80% · <192k→pi core",
|
|
411
|
+
"100k": "always above 100k tokens, any window",
|
|
412
|
+
"150k": "always above 150k tokens, any window",
|
|
413
|
+
"200k": "always above 200k tokens, any window",
|
|
414
|
+
"300k": "always above 300k tokens, any window",
|
|
415
|
+
"400k": "always above 400k tokens, any window",
|
|
416
|
+
};
|
|
417
|
+
}
|
|
378
418
|
|
|
379
419
|
/** Rows for the Auto-compact picker: the saved choice ends its row with a green ✓. */
|
|
380
420
|
export function autoCompactRows(opened: AutoCompactChoice): ListRow[] {
|
|
381
|
-
|
|
421
|
+
const notes = autoCompactNotes();
|
|
422
|
+
return AUTO_COMPACT_CHOICES.map((c) => ({ label: c, note: notes[c], chosen: c === opened }));
|
|
382
423
|
}
|
|
383
424
|
|
|
384
425
|
/** A plain (non-live) picker: the choice is committed by Enter, nothing previews. The
|
|
@@ -497,85 +538,327 @@ const openModelHeal = async (ctx: ExtensionCommandContext): Promise<boolean | vo
|
|
|
497
538
|
return goBack === true;
|
|
498
539
|
};
|
|
499
540
|
|
|
541
|
+
const RENDER_CACHE_PICKER_TEXT: ListPickerText = {
|
|
542
|
+
title: screenTitle("Render cache"),
|
|
543
|
+
description: "Cache settled chat messages and tool boxes so long sessions stay smooth across frames.",
|
|
544
|
+
legend: LIST_LEGEND_MOVE,
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
const RENDER_CACHE_NOTES: Record<RenderCacheChoice, string> = {
|
|
548
|
+
On: "reuse rendered lines for finished messages and tool boxes (default)",
|
|
549
|
+
Off: "render every transcript component directly on each frame",
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
/** Rows for the Render cache picker: the saved choice ends its row with a green ✓. */
|
|
553
|
+
export function renderCacheRows(opened: RenderCacheChoice): ListRow[] {
|
|
554
|
+
return RENDER_CACHE_CHOICES.map((c) => ({ label: c, note: RENDER_CACHE_NOTES[c], chosen: c === opened }));
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const openRenderCache = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
558
|
+
const opened = activeRenderCache();
|
|
559
|
+
|
|
560
|
+
if (ctx.mode !== "tui") {
|
|
561
|
+
const labels = RENDER_CACHE_CHOICES.map((c) => (c === opened ? `${c} ✓` : c));
|
|
562
|
+
const pick = await ctx.ui.select(RENDER_CACHE_PICKER_TEXT.title, labels);
|
|
563
|
+
if (pick === undefined) return;
|
|
564
|
+
const choice = RENDER_CACHE_CHOICES[labels.indexOf(pick)]!;
|
|
565
|
+
setRenderCache(choice);
|
|
566
|
+
ctx.ui.notify(`[arnative] Render cache: ${choice}`, "info");
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) => {
|
|
571
|
+
const picker = new ListPicker(
|
|
572
|
+
theme,
|
|
573
|
+
renderCacheRows(opened),
|
|
574
|
+
opened,
|
|
575
|
+
{
|
|
576
|
+
preview: () => {},
|
|
577
|
+
revert: () => {},
|
|
578
|
+
done: () => {
|
|
579
|
+
const choice = RENDER_CACHE_CHOICES[picker.index]!;
|
|
580
|
+
setRenderCache(choice);
|
|
581
|
+
announce(ctx.ui, `Render cache: ${choice}.`);
|
|
582
|
+
done(false);
|
|
583
|
+
},
|
|
584
|
+
cancel: () => done(false),
|
|
585
|
+
back: () => done(true),
|
|
586
|
+
requestRender: () => tui.requestRender(),
|
|
587
|
+
},
|
|
588
|
+
RENDER_CACHE_PICKER_TEXT,
|
|
589
|
+
false,
|
|
590
|
+
ctx.thinkingLevel,
|
|
591
|
+
);
|
|
592
|
+
return picker;
|
|
593
|
+
});
|
|
594
|
+
return goBack === true;
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
const PAYLOAD_CUSTOM_LABEL = "Custom";
|
|
598
|
+
|
|
599
|
+
const PAYLOAD_PRESET_NOTES: Record<PayloadLimitPreset, string> = {
|
|
600
|
+
Off: "disabled — send full history (may hit HTTP 413 on strict proxies)",
|
|
601
|
+
"1 MB": "safe default for standard 1 MB reverse proxies (trims at 900 KB)",
|
|
602
|
+
"4 MB": "small raised proxy limit (trims at 3.5 MB)",
|
|
603
|
+
"8 MB": "medium proxy limit (trims at 7.0 MB)",
|
|
604
|
+
"16 MB": "recommended for 1M-context models on 16 MB proxies (trims at 14.1 MB)",
|
|
605
|
+
"32 MB": "high ceiling for image-heavy sessions (trims at 28.1 MB)",
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
function payloadPickerText(): ListPickerText {
|
|
609
|
+
const envOverride = envByteWallOverride();
|
|
610
|
+
const description = envOverride
|
|
611
|
+
? `Max HTTP request size for remote models (env PI_ARNATIVE_BYTE_WALL_MB=${payloadLimitMb(envOverride)} active now; picking overrides it).`
|
|
612
|
+
: "Max HTTP request size for remote models; older images, thinking, and tool outputs trim above it.";
|
|
613
|
+
return {
|
|
614
|
+
title: screenTitle("Payload limit"),
|
|
615
|
+
description,
|
|
616
|
+
legend: LIST_LEGEND_MOVE,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/** Rows for the Payload limit picker: presets plus Custom MB; the active value carries a green ✓. */
|
|
621
|
+
export function payloadLimitRows(opened: string): ListRow[] {
|
|
622
|
+
const isPreset = (PAYLOAD_LIMIT_PRESETS as readonly string[]).includes(opened);
|
|
623
|
+
const customNote = isPreset
|
|
624
|
+
? "enter any limit in MB (e.g. 11, 24, 100)"
|
|
625
|
+
: `current: ${opened} — enter any limit in MB (1–1024)`;
|
|
626
|
+
return [
|
|
627
|
+
...PAYLOAD_LIMIT_PRESETS.map((c) => ({ label: c, note: PAYLOAD_PRESET_NOTES[c], chosen: c === opened })),
|
|
628
|
+
{ label: PAYLOAD_CUSTOM_LABEL, note: customNote, chosen: !isPreset },
|
|
629
|
+
];
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function applyPayloadChoice(ctx: ExtensionCommandContext, choice: string): void {
|
|
633
|
+
const applied = setPayloadLimit(choice);
|
|
634
|
+
const ceilings = applied === "Off" ? null : ceilingsForMb(payloadLimitMb(applied) ?? 1);
|
|
635
|
+
const detail = ceilings ? ` (trims at ${(ceilings.shedTriggerBytes / 1024 / 1024).toFixed(2)} MB)` : " (trimming disabled)";
|
|
636
|
+
announce(ctx.ui, `Payload limit: ${applied}${detail}.`);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const openPayloadLimit = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
640
|
+
for (;;) {
|
|
641
|
+
const opened = activePayloadLimit();
|
|
642
|
+
const isPreset = (PAYLOAD_LIMIT_PRESETS as readonly string[]).includes(opened);
|
|
643
|
+
const cursor = isPreset ? opened : PAYLOAD_CUSTOM_LABEL;
|
|
644
|
+
const pickerText = payloadPickerText();
|
|
645
|
+
|
|
646
|
+
if (ctx.mode !== "tui") {
|
|
647
|
+
const labels = [...PAYLOAD_LIMIT_PRESETS.map((c) => (c === opened ? `${c} ✓` : c)), isPreset ? PAYLOAD_CUSTOM_LABEL : `${PAYLOAD_CUSTOM_LABEL} (${opened}) ✓`];
|
|
648
|
+
const pick = await ctx.ui.select(pickerText.title, labels);
|
|
649
|
+
if (pick === undefined) return;
|
|
650
|
+
const index = labels.indexOf(pick);
|
|
651
|
+
if (index < PAYLOAD_LIMIT_PRESETS.length) {
|
|
652
|
+
applyPayloadChoice(ctx, PAYLOAD_LIMIT_PRESETS[index]!);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
const currentMb = payloadLimitMb(opened);
|
|
656
|
+
const raw = await ctx.ui.input("Payload limit (MB, 1–1024, or Off)", currentMb ? String(currentMb) : "16");
|
|
657
|
+
if (raw === undefined) return;
|
|
658
|
+
const parsed = parsePayloadLimit(raw);
|
|
659
|
+
if (!parsed) {
|
|
660
|
+
ctx.ui.notify("[arnative] Enter a number between 1 and 1024 MB (e.g. 11 or 16), or Off.", "warning");
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
applyPayloadChoice(ctx, parsed);
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
let pickCustom = false;
|
|
668
|
+
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) => {
|
|
669
|
+
const picker = new ListPicker(
|
|
670
|
+
theme,
|
|
671
|
+
payloadLimitRows(opened),
|
|
672
|
+
cursor,
|
|
673
|
+
{
|
|
674
|
+
preview: () => {},
|
|
675
|
+
revert: () => {},
|
|
676
|
+
done: () => {
|
|
677
|
+
if (picker.index === PAYLOAD_LIMIT_PRESETS.length) {
|
|
678
|
+
pickCustom = true;
|
|
679
|
+
} else {
|
|
680
|
+
applyPayloadChoice(ctx, PAYLOAD_LIMIT_PRESETS[picker.index]!);
|
|
681
|
+
}
|
|
682
|
+
done(false);
|
|
683
|
+
},
|
|
684
|
+
cancel: () => done(false),
|
|
685
|
+
back: () => done(true),
|
|
686
|
+
requestRender: () => tui.requestRender(),
|
|
687
|
+
},
|
|
688
|
+
pickerText,
|
|
689
|
+
false,
|
|
690
|
+
ctx.thinkingLevel,
|
|
691
|
+
);
|
|
692
|
+
return picker;
|
|
693
|
+
});
|
|
694
|
+
if (goBack === true) return true;
|
|
695
|
+
if (!pickCustom) return false;
|
|
696
|
+
|
|
697
|
+
const currentMb = payloadLimitMb(opened);
|
|
698
|
+
const raw = await ctx.ui.custom<string | null>((tui, theme, _kb, done) =>
|
|
699
|
+
new InputPicker(
|
|
700
|
+
theme,
|
|
701
|
+
{
|
|
702
|
+
title: screenTitle("Payload limit"),
|
|
703
|
+
description: "Enter a number between 1 and 1024 MB (e.g. 11 or 16), or Off.",
|
|
704
|
+
legend: INPUT_LEGEND,
|
|
705
|
+
},
|
|
706
|
+
currentMb ? String(currentMb) : "",
|
|
707
|
+
{
|
|
708
|
+
done: (v) => done(v),
|
|
709
|
+
cancel: () => done(null),
|
|
710
|
+
requestRender: () => tui.requestRender(),
|
|
711
|
+
},
|
|
712
|
+
"16",
|
|
713
|
+
ctx.thinkingLevel,
|
|
714
|
+
),
|
|
715
|
+
);
|
|
716
|
+
if (raw === null) continue;
|
|
717
|
+
const parsed = parsePayloadLimit(raw);
|
|
718
|
+
if (!parsed) {
|
|
719
|
+
ctx.ui.notify("[arnative] Enter a number between 1 and 1024 MB (e.g. 11 or 16), or Off.", "warning");
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
applyPayloadChoice(ctx, parsed);
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
|
|
500
727
|
export const MENUS: ArnativeMenu[] = [
|
|
501
728
|
{
|
|
502
729
|
value: "themes",
|
|
503
730
|
label: "Themes",
|
|
504
731
|
description: "arnative themes only (all themes: /settings → Theme)",
|
|
732
|
+
group: "Appearance",
|
|
505
733
|
open: openThemes,
|
|
506
734
|
},
|
|
507
735
|
{
|
|
508
736
|
value: "headers",
|
|
509
737
|
label: "Headers",
|
|
510
738
|
description: "choose the header preset",
|
|
739
|
+
group: "Appearance",
|
|
511
740
|
open: openHeaders,
|
|
512
741
|
},
|
|
513
742
|
{
|
|
514
743
|
value: "footers",
|
|
515
744
|
label: "Footers",
|
|
516
745
|
description: "choose the footer preset",
|
|
746
|
+
group: "Appearance",
|
|
517
747
|
open: openFooters,
|
|
518
748
|
},
|
|
519
749
|
{
|
|
520
750
|
value: "chatbox",
|
|
521
751
|
label: "Chatbox",
|
|
522
752
|
description: "choose the input box preset",
|
|
753
|
+
group: "Appearance",
|
|
523
754
|
open: openChatbox,
|
|
524
755
|
},
|
|
525
756
|
{
|
|
526
757
|
value: "animations",
|
|
527
758
|
label: "Animations",
|
|
528
759
|
description: "choose the working spinner",
|
|
760
|
+
group: "Appearance",
|
|
529
761
|
open: openAnimations,
|
|
530
762
|
},
|
|
531
763
|
{
|
|
532
764
|
value: "compact",
|
|
533
765
|
label: "Auto-compact",
|
|
534
766
|
description: "smart by window or a fixed token budget (off by default)",
|
|
767
|
+
group: "Performance",
|
|
535
768
|
open: openAutoCompact,
|
|
536
769
|
},
|
|
537
770
|
{
|
|
538
|
-
value: "
|
|
539
|
-
label: "
|
|
540
|
-
description: "
|
|
541
|
-
|
|
771
|
+
value: "render",
|
|
772
|
+
label: "Render cache",
|
|
773
|
+
description: "cache settled transcript rows across frames (on by default)",
|
|
774
|
+
group: "Performance",
|
|
775
|
+
open: openRenderCache,
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
value: "payload",
|
|
779
|
+
label: "Payload limit",
|
|
780
|
+
description: "max HTTP request size for remote proxies (1 MB by default)",
|
|
781
|
+
group: "Performance",
|
|
782
|
+
open: openPayloadLimit,
|
|
542
783
|
},
|
|
543
784
|
{
|
|
544
785
|
value: "providers",
|
|
545
786
|
label: "Providers",
|
|
546
787
|
description: "custom endpoints: endpoint, key, name — the rest is automatic",
|
|
788
|
+
group: "Models",
|
|
547
789
|
open: openProviders,
|
|
548
790
|
},
|
|
791
|
+
{
|
|
792
|
+
value: "heal",
|
|
793
|
+
label: "Model heal",
|
|
794
|
+
description: "auto-fix models.json: compat flags, limits, thinking levels (on by default)",
|
|
795
|
+
group: "Models",
|
|
796
|
+
open: openModelHeal,
|
|
797
|
+
},
|
|
549
798
|
{
|
|
550
799
|
value: "usage",
|
|
551
800
|
label: "Usage",
|
|
552
801
|
description: "open the token & cost dashboard (same as /usage)",
|
|
802
|
+
group: "Spend",
|
|
553
803
|
open: openUsage,
|
|
554
804
|
},
|
|
555
805
|
{
|
|
556
806
|
value: "budget",
|
|
557
807
|
label: "Budget",
|
|
558
808
|
description: "warn-only spend caps on today / 30d; enforce on blocks the next turn",
|
|
809
|
+
group: "Spend",
|
|
559
810
|
open: openBudget,
|
|
560
811
|
},
|
|
561
812
|
];
|
|
562
813
|
|
|
563
|
-
/**
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
814
|
+
/** Submenu for one category; returns `true` when the user presses `←` to return to the root menu. */
|
|
815
|
+
async function openCategoryMenu(ctx: ExtensionCommandContext, category: MenuCategory, startLabel?: string): Promise<boolean> {
|
|
816
|
+
const items = categoryMenus(category.label);
|
|
817
|
+
const rows = menuRows(items);
|
|
818
|
+
if (ctx.mode !== "tui") {
|
|
819
|
+
const labels = rows.map(rowText);
|
|
820
|
+
const pick = await ctx.ui.select(screenTitle(category.label), labels);
|
|
821
|
+
if (pick === undefined) return false;
|
|
822
|
+
await items[labels.indexOf(pick)]!.open(ctx);
|
|
823
|
+
return false;
|
|
824
|
+
}
|
|
825
|
+
let cursor = startLabel;
|
|
826
|
+
for (;;) {
|
|
827
|
+
const choice = await ctx.ui.custom<{ index?: number; back?: boolean }>((tui, theme, _kb, done) => {
|
|
828
|
+
const picker = new ListPicker(theme, rows, cursor, {
|
|
829
|
+
preview: () => {},
|
|
830
|
+
revert: () => {},
|
|
831
|
+
done: () => done({ index: picker.index }),
|
|
832
|
+
cancel: () => done({ back: false }),
|
|
833
|
+
back: () => done({ back: true }),
|
|
834
|
+
requestRender: () => tui.requestRender(),
|
|
835
|
+
}, { title: screenTitle(category.label), description: category.description[0]!.toUpperCase() + category.description.slice(1), legend: LIST_LEGEND_MOVE }, false, ctx.thinkingLevel);
|
|
836
|
+
return picker;
|
|
837
|
+
});
|
|
838
|
+
if (choice.index === undefined) return choice.back === true;
|
|
839
|
+
const menu = items[choice.index]!;
|
|
840
|
+
cursor = menu.label;
|
|
841
|
+
if ((await menu.open(ctx)) !== true) return false;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/** The 4-category settings menu. Selecting a category opens its submenu; `←` steps back
|
|
846
|
+
* up one level (screen → category → root) and remembers the last row at each level. */
|
|
847
|
+
async function openMainMenu(ctx: ExtensionCommandContext, startGroup?: MenuGroup, startItem?: string): Promise<void> {
|
|
848
|
+
const rows = menuRows([...MENU_CATEGORIES]);
|
|
568
849
|
if (ctx.mode !== "tui") {
|
|
569
850
|
// No custom components (RPC/headless): a title-only picker, no description row.
|
|
570
851
|
const labels = rows.map(rowText);
|
|
571
852
|
const pick = await ctx.ui.select(MENU_TITLE, labels);
|
|
572
853
|
if (pick === undefined) return;
|
|
573
|
-
await
|
|
854
|
+
await openCategoryMenu(ctx, MENU_CATEGORIES[labels.indexOf(pick)]!);
|
|
574
855
|
return;
|
|
575
856
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
857
|
+
if (startGroup && startItem) {
|
|
858
|
+
const cat = MENU_CATEGORIES.find((c) => c.label === startGroup);
|
|
859
|
+
if (cat && (await openCategoryMenu(ctx, cat, startItem)) !== true) return;
|
|
860
|
+
}
|
|
861
|
+
let cursor: string | undefined = startGroup;
|
|
579
862
|
for (;;) {
|
|
580
863
|
const index = await ctx.ui.custom<number | null>((tui, theme, _kb, done) => {
|
|
581
864
|
const picker = new ListPicker(theme, rows, cursor, {
|
|
@@ -591,9 +874,9 @@ async function openMainMenu(ctx: ExtensionCommandContext, startLabel?: string):
|
|
|
591
874
|
return picker;
|
|
592
875
|
});
|
|
593
876
|
if (index === null || index === undefined) return;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
if (
|
|
877
|
+
const category = MENU_CATEGORIES[index]!;
|
|
878
|
+
cursor = category.label;
|
|
879
|
+
if ((await openCategoryMenu(ctx, category)) !== true) return;
|
|
597
880
|
}
|
|
598
881
|
}
|
|
599
882
|
|
|
@@ -611,9 +894,10 @@ export async function arnativeHandler(args: string, ctx: ExtensionCommandContext
|
|
|
611
894
|
ctx.ui.notify(`[arnative] Unknown menu "${sub}". Menus: ${MENUS.map((m) => m.value).join(" | ")}`, "warning");
|
|
612
895
|
return;
|
|
613
896
|
}
|
|
614
|
-
// A direct subcommand behaves like a menu row: `←` drops into
|
|
897
|
+
// A direct subcommand behaves like a menu row: `←` drops into its category on that row,
|
|
615
898
|
// so `/arnative usage` + `←` is not a dead key.
|
|
616
|
-
|
|
899
|
+
const menu = MENUS[index]!;
|
|
900
|
+
if ((await menu.open(ctx)) === true) await openMainMenu(ctx, menu.group, menu.label);
|
|
617
901
|
}
|
|
618
902
|
|
|
619
903
|
export function arnativeCompletions(prefix: string): AutocompleteItem[] | null {
|
|
@@ -649,7 +933,7 @@ export function shouldApplyDefaultTheme(
|
|
|
649
933
|
* set without starting a session. */
|
|
650
934
|
export function registerCommands(pi: Pick<ExtensionAPI, "registerCommand">): void {
|
|
651
935
|
pi.registerCommand("arnative", {
|
|
652
|
-
description: "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, providers, usage, budget",
|
|
936
|
+
description: "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, render cache, payload limit, providers, usage, budget",
|
|
653
937
|
getArgumentCompletions: arnativeCompletions,
|
|
654
938
|
handler: arnativeHandler,
|
|
655
939
|
});
|
|
@@ -674,7 +958,9 @@ export function recordProfile(): void {
|
|
|
674
958
|
[SPINNER_PRESET_KEY]: activeSpinnerPreset(),
|
|
675
959
|
[SPINNER_GRADIENT_KEY]: activeSpinnerGradient() ? "on" : "off",
|
|
676
960
|
[AUTO_COMPACT_KEY]: activeAutoCompact(),
|
|
961
|
+
[PAYLOAD_LIMIT_KEY]: savedPayloadLimit(),
|
|
677
962
|
[MODEL_HEAL_KEY]: activeModelHeal(),
|
|
963
|
+
[RENDER_CACHE_KEY]: activeRenderCache(),
|
|
678
964
|
[BUDGET_DAY_KEY]: activeBudgetDay() === undefined ? "" : String(activeBudgetDay()),
|
|
679
965
|
[BUDGET_MONTH_KEY]: activeBudgetMonth() === undefined ? "" : String(activeBudgetMonth()),
|
|
680
966
|
[BUDGET_ENFORCE_KEY]: activeBudgetEnforce() ? "on" : "off",
|
|
@@ -712,18 +998,31 @@ if (isMain(import.meta.url)) {
|
|
|
712
998
|
assert(rowText(labels[0]!) === "Themes · arnative themes only (all themes: /settings → Theme)", "menu row text format");
|
|
713
999
|
assert(labels[0]!.label === "Themes" && labels[0]!.note === "arnative themes only (all themes: /settings → Theme)", "menu row keeps label and note apart");
|
|
714
1000
|
assert(MENU_TITLE === "Settings - Arnative\u2819", `the menu title is the pinned string, got ${MENU_TITLE}`);
|
|
715
|
-
assert(MENU_DESC === "Themes, headers, footers, chatbox, animations, auto-compact, providers, usage, budget", `the menu description is the pinned string, got ${MENU_DESC}`);
|
|
1001
|
+
assert(MENU_DESC === "Themes, headers, footers, chatbox, animations, auto-compact, render, payload, providers, usage, budget", `the menu description is the pinned string, got ${MENU_DESC}`);
|
|
716
1002
|
// Every menu row is reachable and the description names them all, so a new screen cannot
|
|
717
1003
|
// be added to MENUS and forgotten in the copy a user reads first.
|
|
718
|
-
assert(MENUS.length ===
|
|
1004
|
+
assert(MENUS.length === 12, "twelve settings screens");
|
|
719
1005
|
{
|
|
720
|
-
const
|
|
721
|
-
assert(
|
|
1006
|
+
const catRows = menuRows([...MENU_CATEGORIES]);
|
|
1007
|
+
assert(catRows.map((r) => r.label).join(",") === "Appearance,Performance,Models,Spend", "root menu lists the four categories in order");
|
|
1008
|
+
const totalGrouped = MENU_CATEGORIES.reduce((n, c) => n + categoryMenus(c.label).length, 0);
|
|
1009
|
+
assert(totalGrouped === MENUS.length, "every menu item belongs to one of the four categories");
|
|
1010
|
+
const perf = categoryMenus("Performance");
|
|
1011
|
+
assert(perf.map((m) => m.value).join(",") === "compact,render,payload", "Performance group lists Auto-compact, Render cache, Payload limit in order");
|
|
722
1012
|
const heal = modelHealRows("Flags");
|
|
723
1013
|
assert(heal.map((r) => r.label).join(",") === "Full,Flags,Off,Run now", "Model heal rows: three modes then Run now");
|
|
724
1014
|
assert(heal.filter((r) => r.chosen).map((r) => r.label).join(",") === "Flags", "Model heal marks only the saved mode");
|
|
1015
|
+
const rc = renderCacheRows("On");
|
|
1016
|
+
assert(rc.map((r) => r.label).join(",") === "On,Off", "Render cache rows: On then Off");
|
|
1017
|
+
assert(rc.filter((r) => r.chosen).map((r) => r.label).join(",") === "On", "Render cache marks only the saved mode");
|
|
1018
|
+
const pl = payloadLimitRows("16 MB");
|
|
1019
|
+
assert(pl.map((r) => r.label).join(",") === "Off,1 MB,4 MB,8 MB,16 MB,32 MB,Custom", "Payload limit rows list presets then Custom");
|
|
1020
|
+
assert(pl.filter((r) => r.chosen).map((r) => r.label).join(",") === "16 MB", "Payload limit marks the active preset");
|
|
1021
|
+
const plCustom = payloadLimitRows("11 MB");
|
|
1022
|
+
assert(plCustom.filter((r) => r.chosen).map((r) => r.label).join(",") === "Custom", "Payload limit marks Custom when a non-preset MB is active");
|
|
1023
|
+
assert(plCustom[plCustom.length - 1]!.note!.includes("11 MB"), "Custom row displays the active custom MB");
|
|
725
1024
|
}
|
|
726
|
-
for (const label of ["Themes", "Headers", "Footers", "Chatbox", "Animations", "Auto-compact", "Providers", "Usage", "Budget"]) {
|
|
1025
|
+
for (const label of ["Themes", "Headers", "Footers", "Chatbox", "Animations", "Auto-compact", "Render cache", "Payload limit", "Providers", "Usage", "Budget"]) {
|
|
727
1026
|
assert(MENUS.some((m) => m.label === label), `MENUS carries the ${label} screen`);
|
|
728
1027
|
}
|
|
729
1028
|
assert(/^Settings - Arnative/.test(MENU_TITLE), "title follows `<setting> - <extension>`");
|
|
@@ -747,6 +1046,10 @@ if (isMain(import.meta.url)) {
|
|
|
747
1046
|
assert(acRows[1]!.chosen === true && acRows[0]!.chosen !== true, "the ✓ follows the saved choice");
|
|
748
1047
|
assert(acRows.every((r) => r.note!.length > 0), "every Auto-compact row carries its note");
|
|
749
1048
|
assert(autoCompactRows("Off")[0]!.chosen === true, "the marker moves when the saved choice changes");
|
|
1049
|
+
assert(arnativeCompletions("re")![0]!.value === "render", "render cache menu has completions");
|
|
1050
|
+
assert(MENUS.some((m) => m.value === "render"), "render cache menu registered");
|
|
1051
|
+
assert(arnativeCompletions("pa")![0]!.value === "payload", "payload limit menu has completions");
|
|
1052
|
+
assert(MENUS.some((m) => m.value === "payload"), "payload limit menu registered");
|
|
750
1053
|
assert(arnativeCompletions("pr")![0]!.value === "providers", "providers menu has completions");
|
|
751
1054
|
assert(MENUS.some((m) => m.value === "providers"), "providers menu registered");
|
|
752
1055
|
// Every slash command, and the one alias: `/providers` must land on the providers screen.
|
|
@@ -757,7 +1060,7 @@ if (isMain(import.meta.url)) {
|
|
|
757
1060
|
assert(typeof registered.get("providers")!.handler === "function", "/providers has a handler");
|
|
758
1061
|
assert(MENUS.some((m) => m.value === "providers"), "/providers routes to a menu row that exists");
|
|
759
1062
|
assert(
|
|
760
|
-
registered.get("arnative")!.description === "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, providers, usage, budget",
|
|
1063
|
+
registered.get("arnative")!.description === "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, render cache, payload limit, providers, usage, budget",
|
|
761
1064
|
"the /arnative command description names every screen: " + registered.get("arnative")!.description,
|
|
762
1065
|
);
|
|
763
1066
|
}
|
|
@@ -793,7 +1096,9 @@ if (isMain(import.meta.url)) {
|
|
|
793
1096
|
const previews: string[] = [];
|
|
794
1097
|
let reverted = 0;
|
|
795
1098
|
let done = 0;
|
|
796
|
-
|
|
1099
|
+
// Wrap means one step down from the last row lands on the initial value, leaving
|
|
1100
|
+
// nothing for Esc to revert, so the list carries a third row for this assertion.
|
|
1101
|
+
const picker = new ListPicker(fakeTheme, nameRows(["arnative", "arnative-cyberpunk", "arnative-mono"]), "arnative", {
|
|
797
1102
|
preview: (n) => previews.push(n),
|
|
798
1103
|
revert: () => reverted++,
|
|
799
1104
|
done: () => done++,
|
|
@@ -803,11 +1108,11 @@ if (isMain(import.meta.url)) {
|
|
|
803
1108
|
assert(lines[0]!.startsWith("╭") && lines[lines.length - 1]!.startsWith("╰"), "picker framed");
|
|
804
1109
|
assert(lines.every((l) => visibleWidth(l) === 50), "picker lines fit width 50");
|
|
805
1110
|
assert(lines.some((l) => l.includes(screenTitle("Themes"))), "picker renders the configured title");
|
|
806
|
-
assert(lines.some((l) => l.includes("
|
|
807
|
-
assert(!lines.some((l) => l.includes("●")), "no redundant ● column next to the
|
|
1111
|
+
assert(lines.some((l) => l.includes("❯ arnative")), "the cursor marks the live value");
|
|
1112
|
+
assert(!lines.some((l) => l.includes("●")), "no redundant ● column next to the ❯ cursor");
|
|
808
1113
|
picker.handleInput("\x1b[B"); // down
|
|
809
1114
|
assert(previews.length === 1 && previews[0] === "arnative-cyberpunk", "move previews immediately");
|
|
810
|
-
assert(picker.render(50).some((l) => l.includes("
|
|
1115
|
+
assert(picker.render(50).some((l) => l.includes("❯ arnative-cyberpunk")), "the cursor follows the preview");
|
|
811
1116
|
picker.handleInput("\r"); // enter
|
|
812
1117
|
assert(done === 1 && reverted === 0, "Enter keeps (no revert)");
|
|
813
1118
|
picker.handleInput("\x1b[B");
|
|
@@ -848,54 +1153,55 @@ if (isMain(import.meta.url)) {
|
|
|
848
1153
|
// setting, only Enter opens a row. `reverted` proves it.
|
|
849
1154
|
let menuReverts = 0;
|
|
850
1155
|
let menuCancelled = false;
|
|
851
|
-
const
|
|
1156
|
+
const categoryRows = menuRows([...MENU_CATEGORIES]);
|
|
1157
|
+
const mainPicker = new ListPicker(fakeTheme, categoryRows, undefined, {
|
|
852
1158
|
preview: () => {},
|
|
853
1159
|
revert: () => { menuReverts++; },
|
|
854
1160
|
done: () => {},
|
|
855
1161
|
cancel: () => { menuCancelled = true; },
|
|
856
1162
|
requestRender: () => {},
|
|
857
1163
|
}, { title: MENU_TITLE, description: MENU_DESC, legend: LIST_LEGEND_ROOT }, false);
|
|
858
|
-
//
|
|
859
|
-
// be added to the copy too), and that one-liner no longer fits
|
|
860
|
-
const menuLines = mainPicker.render(
|
|
1164
|
+
// 120 columns: the description names the screens (a tripwire — a screen added to MENUS must
|
|
1165
|
+
// be added to the copy too), and that one-liner no longer fits 100.
|
|
1166
|
+
const menuLines = mainPicker.render(120);
|
|
861
1167
|
assert(menuLines.some((l) => l.includes(MENU_TITLE)), "the main menu renders its title");
|
|
862
1168
|
assert(menuLines.some((l) => l.includes("[Esc] Close") && !l.includes("←")), "the root menu legend renders without a back key");
|
|
863
1169
|
assert(menuLines.some((l) => l.includes(MENU_DESC)), "the main menu renders the description under the title");
|
|
864
1170
|
assert(menuLines.findIndex((l) => l.includes(MENU_TITLE)) < menuLines.findIndex((l) => l.includes(MENU_DESC)), "description sits below the title");
|
|
865
|
-
assert(menuLines.every((l) => visibleWidth(l) ===
|
|
866
|
-
// The pinned /arnative layout:
|
|
1171
|
+
assert(menuLines.every((l) => visibleWidth(l) === 120), "main menu lines fit the width");
|
|
1172
|
+
// The pinned /arnative layout: `❯ Appearance · themes, headers…`, every `·` in one column.
|
|
867
1173
|
const plainMenu = menuLines.map(stripAnsi);
|
|
868
|
-
const row0 = menuLines.map(stripAnsi).find((l) => l.includes("
|
|
869
|
-
// The row is `│
|
|
1174
|
+
const row0 = menuLines.map(stripAnsi).find((l) => l.includes("❯ Appearance"))!;
|
|
1175
|
+
// The row is `│ ❯ <label padded to the widest label><divider><note>`: assert the shape,
|
|
870
1176
|
// not a literal run of spaces, so adding a wider screen cannot break the layout test.
|
|
871
|
-
const widest = Math.max(...
|
|
1177
|
+
const widest = Math.max(...MENU_CATEGORIES.map((c) => c.label.length));
|
|
872
1178
|
assert(
|
|
873
|
-
row0.startsWith(`│
|
|
1179
|
+
row0.startsWith(`│ ❯ ${"Appearance".padEnd(widest)}${ROW_DIVIDER}themes, headers, footers`),
|
|
874
1180
|
`menu row layout, got ${JSON.stringify(row0)}`,
|
|
875
1181
|
);
|
|
876
1182
|
assert(plainMenu.filter((l) => l.includes(ROW_DIVIDER)).every((l) => l.indexOf(ROW_DIVIDER) === row0.indexOf(ROW_DIVIDER)), "every divider sits in one column");
|
|
877
1183
|
assert(
|
|
878
|
-
plainMenu.some((l) => l.startsWith(`│ ${"
|
|
1184
|
+
plainMenu.some((l) => l.startsWith(`│ ${"Performance".padEnd(widest)}${ROW_DIVIDER}`)),
|
|
879
1185
|
"unselected rows indent to the marker column",
|
|
880
1186
|
);
|
|
881
1187
|
|
|
882
1188
|
// A menu opened with a `current` row starts there. The handler passes the row it last
|
|
883
1189
|
// used, so a submenu reopened by `←` lands back on that row instead of jumping to the
|
|
884
1190
|
// top of the list — the cursor is the user's place, not the component's business.
|
|
885
|
-
const resumed = new ListPicker(fakeTheme,
|
|
1191
|
+
const resumed = new ListPicker(fakeTheme, categoryRows, "Models", {
|
|
886
1192
|
preview: () => {},
|
|
887
1193
|
revert: () => {},
|
|
888
1194
|
done: () => {},
|
|
889
1195
|
requestRender: () => {},
|
|
890
1196
|
}, { title: MENU_TITLE, description: MENU_DESC, legend: LIST_LEGEND_ROOT }, false);
|
|
891
1197
|
const resumedRows = resumed.render(60).map(stripAnsi);
|
|
892
|
-
assert(resumedRows.some((l) => l.startsWith("│
|
|
893
|
-
assert(!resumedRows.some((l) => l.startsWith("│
|
|
1198
|
+
assert(resumedRows.some((l) => l.startsWith("│ ❯ Models")), "the menu reopens on the row it was left on");
|
|
1199
|
+
assert(!resumedRows.some((l) => l.startsWith("│ ❯ Appearance")), "and not on the first row");
|
|
894
1200
|
|
|
895
1201
|
// The box border follows the session's thinking level (theme `thinking*` slot), so the
|
|
896
1202
|
// menu reads as belonging to the active model.
|
|
897
1203
|
const tagged = { fg: (c: string, t: string) => `<${c}>${t}</>`, bold: (t: string) => `<bold>${t}</bold>` };
|
|
898
|
-
const thinkingPicker = new ListPicker(tagged,
|
|
1204
|
+
const thinkingPicker = new ListPicker(tagged, categoryRows, undefined, {
|
|
899
1205
|
preview: () => {},
|
|
900
1206
|
revert: () => {},
|
|
901
1207
|
done: () => {},
|
|
@@ -914,13 +1220,13 @@ if (isMain(import.meta.url)) {
|
|
|
914
1220
|
"no frame glyph is left on accentSoft",
|
|
915
1221
|
);
|
|
916
1222
|
// The chosen row's label takes the `accentSoft` token (bold), never a hand-written colour; the
|
|
917
|
-
//
|
|
1223
|
+
// `❯` marker stays on `accent` so the cursor is still findable when the theme has no accentSoft.
|
|
918
1224
|
assert(
|
|
919
|
-
taggedLines.some((l) => l.includes("<accent
|
|
1225
|
+
taggedLines.some((l) => l.includes("<accent>❯ </><accentSoft><bold>")),
|
|
920
1226
|
"the chosen label is the accentSoft token in bold",
|
|
921
1227
|
);
|
|
922
|
-
assert(taggedLines.some((l) => l.includes("<accent
|
|
923
|
-
const offPicker = new ListPicker(tagged,
|
|
1228
|
+
assert(taggedLines.some((l) => l.includes("<accent>❯ ")), "the ❯ marker keeps the accent voice");
|
|
1229
|
+
const offPicker = new ListPicker(tagged, categoryRows, undefined, {
|
|
924
1230
|
preview: () => {},
|
|
925
1231
|
revert: () => {},
|
|
926
1232
|
done: () => {},
|
|
@@ -942,7 +1248,7 @@ if (isMain(import.meta.url)) {
|
|
|
942
1248
|
const headerPicker = new ListPicker(fakeTheme, nameRows(HEADER_PRESETS), "Arnative (Full)", { preview: () => {}, revert: () => {}, done: () => {}, requestRender: () => {} }, HEADERS_PICKER_TEXT);
|
|
943
1249
|
const headerLines = headerPicker.render(50);
|
|
944
1250
|
assert(headerLines.some((l) => l.includes(screenTitle("Headers"))), "headers picker title");
|
|
945
|
-
assert(headerLines.some((l) => l.includes("
|
|
1251
|
+
assert(headerLines.some((l) => l.includes("❯ Arnative (Full)")), "headers picker cursors the active preset");
|
|
946
1252
|
assert(headerLines.some((l) => l.includes(" Pi (system)")), "headers picker lists the built-in preset");
|
|
947
1253
|
|
|
948
1254
|
// Footers reuses the same picker too.
|
|
@@ -950,7 +1256,7 @@ if (isMain(import.meta.url)) {
|
|
|
950
1256
|
const footerPicker = new ListPicker(fakeTheme, nameRows(FOOTER_PRESETS), "Pi (system)", { preview: () => {}, revert: () => {}, done: () => {}, requestRender: () => {} }, footersPickerText());
|
|
951
1257
|
const footerLines = footerPicker.render(50);
|
|
952
1258
|
assert(footerLines.some((l) => l.includes(screenTitle("Footers"))), "footers picker title");
|
|
953
|
-
assert(footerLines.some((l) => l.includes("
|
|
1259
|
+
assert(footerLines.some((l) => l.includes("❯ Pi (system)")), "footers picker cursors the active preset");
|
|
954
1260
|
assert(footerLines.some((l) => l.includes("Arnative (Minimal)")), "footers picker lists the minimal preset");
|
|
955
1261
|
assert(footerLines.filter((l) => l.includes("Arnative (")).length === 2, "both arnative footer presets are selectable");
|
|
956
1262
|
assert(/\[c\] Cost (on|off)/.test(footersPickerText().legend), "footers legend advertises the cost switch and its live state");
|
|
@@ -968,7 +1274,7 @@ if (isMain(import.meta.url)) {
|
|
|
968
1274
|
const chatboxLines = chatboxPicker.render(84);
|
|
969
1275
|
assert(chatboxLines.some((l) => l.includes(screenTitle("Chatbox"))), "chatbox picker title");
|
|
970
1276
|
assert(chatboxLines.some((l) => l.includes("Box · Arnative")), "chatbox picker shows Box summary");
|
|
971
|
-
assert(chatboxLines.some((l) => l.includes("
|
|
1277
|
+
assert(chatboxLines.some((l) => l.includes("❯ Arnative")), "chatbox picker cursors the active preset");
|
|
972
1278
|
assert(chatboxLines.some((l) => l.includes(" Pi (system)")), "chatbox picker lists the built-in preset");
|
|
973
1279
|
assert(CHATBOX_PICKER_TEXT.legend.includes("[i] Icon [D] Dialog"), "chatbox legend advertises [i] Icon and [D] Dialog");
|
|
974
1280
|
|
|
@@ -1027,14 +1333,14 @@ if (isMain(import.meta.url)) {
|
|
|
1027
1333
|
marked: (label) => chosen.has(label),
|
|
1028
1334
|
}, { title: screenTitle("Providers"), description: "pick models", legend: "[Space] Toggle" }, false);
|
|
1029
1335
|
const multiLines = multiPicker.render(50).map(stripAnsi);
|
|
1030
|
-
assert(multiLines.some((l) => l.includes("
|
|
1336
|
+
assert(multiLines.some((l) => l.includes("❯ [x] a")), "a checked row shows [x] behind the cursor");
|
|
1031
1337
|
assert(multiLines.some((l) => l.includes("[ ] b")), "unchecked rows show [ ]");
|
|
1032
1338
|
multiPicker.handleInput(" ");
|
|
1033
1339
|
assert(picked[0] === "a" && !chosen.has("a"), "Space toggles the row under the cursor");
|
|
1034
1340
|
multiPicker.handleInput("\x1b[B");
|
|
1035
1341
|
multiPicker.handleInput(" ");
|
|
1036
1342
|
assert(chosen.has("b"), "Space toggles the row the cursor moved to");
|
|
1037
|
-
assert(multiPicker.render(50).map(stripAnsi).some((l) => l.includes("
|
|
1343
|
+
assert(multiPicker.render(50).map(stripAnsi).some((l) => l.includes("❯ [x] b")), "the check follows the cursor");
|
|
1038
1344
|
mainPicker.handleInput(" ");
|
|
1039
1345
|
assert(chosen.has("b") && picked.length === 2, "a screen without the toggle hook ignores Space");
|
|
1040
1346
|
|