@bismawy/pi-arnative 0.13.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.
@@ -24,16 +24,25 @@ 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, RENDER_CACHE_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";
@@ -43,29 +52,49 @@ import {
43
52
  setRenderCache,
44
53
  type RenderCacheChoice,
45
54
  } from "./render-cache.ts";
46
- import { LIST_LEGEND_LIVE, LIST_LEGEND_MOVE, LIST_LEGEND_ROOT, ListPicker, nameRows, rowText, type ListPickerText, type ListRow } from "../lib/list-picker.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";
47
56
  import { BACK_KEY_LABEL } from "../lib/shortcuts.ts";
48
57
  import { openProviders } from "../lib/provider.ts";
49
58
  import { openUsage } from "./usage.ts";
50
59
  import { SHORTCUT_OPEN_ARNATIVE } from "../lib/shortcuts.ts";
51
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
+
52
75
  export interface ArnativeMenu {
53
76
  value: string;
54
77
  label: string;
55
78
  description: string;
79
+ group: MenuGroup;
56
80
  /** Returns `true` when the screen asked to step back to the menu (`←`). */
57
81
  open: (ctx: ExtensionCommandContext) => Promise<boolean | void>;
58
82
  }
59
83
 
60
84
  /** Menu rows: `Label · description` (same rhythm as /jev-eye's menu). */
61
- export function menuRows(menus: Pick<ArnativeMenu, "label" | "description">[]): ListRow[] {
85
+ export function menuRows(menus: { label: string; description: string }[]): ListRow[] {
62
86
  return menus.map((m) => ({ label: m.label, note: m.description }));
63
87
  }
64
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
+
65
94
  /** Title of the settings menu, derived from `screenTitle` so the format lives in one place. */
66
95
  export const MENU_TITLE = screenTitle("Settings");
67
96
  /** One-line description under the menu title. */
68
- export const MENU_DESC = "Themes, headers, footers, chatbox, animations, auto-compact, render, providers, usage, budget";
97
+ export const MENU_DESC = "Themes, headers, footers, chatbox, animations, auto-compact, render, payload, providers, usage, budget";
69
98
 
70
99
  const THEMES_PICKER_TEXT: ListPickerText = {
71
100
  title: screenTitle("Themes"),
@@ -565,91 +594,271 @@ const openRenderCache = async (ctx: ExtensionCommandContext): Promise<boolean |
565
594
  return goBack === true;
566
595
  };
567
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
+
568
727
  export const MENUS: ArnativeMenu[] = [
569
728
  {
570
729
  value: "themes",
571
730
  label: "Themes",
572
731
  description: "arnative themes only (all themes: /settings → Theme)",
732
+ group: "Appearance",
573
733
  open: openThemes,
574
734
  },
575
735
  {
576
736
  value: "headers",
577
737
  label: "Headers",
578
738
  description: "choose the header preset",
739
+ group: "Appearance",
579
740
  open: openHeaders,
580
741
  },
581
742
  {
582
743
  value: "footers",
583
744
  label: "Footers",
584
745
  description: "choose the footer preset",
746
+ group: "Appearance",
585
747
  open: openFooters,
586
748
  },
587
749
  {
588
750
  value: "chatbox",
589
751
  label: "Chatbox",
590
752
  description: "choose the input box preset",
753
+ group: "Appearance",
591
754
  open: openChatbox,
592
755
  },
593
756
  {
594
757
  value: "animations",
595
758
  label: "Animations",
596
759
  description: "choose the working spinner",
760
+ group: "Appearance",
597
761
  open: openAnimations,
598
762
  },
599
763
  {
600
764
  value: "compact",
601
765
  label: "Auto-compact",
602
766
  description: "smart by window or a fixed token budget (off by default)",
767
+ group: "Performance",
603
768
  open: openAutoCompact,
604
769
  },
605
- {
606
- value: "heal",
607
- label: "Model heal",
608
- description: "auto-fix models.json: compat flags, limits, thinking levels (on by default)",
609
- open: openModelHeal,
610
- },
611
770
  {
612
771
  value: "render",
613
772
  label: "Render cache",
614
773
  description: "cache settled transcript rows across frames (on by default)",
774
+ group: "Performance",
615
775
  open: openRenderCache,
616
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,
783
+ },
617
784
  {
618
785
  value: "providers",
619
786
  label: "Providers",
620
787
  description: "custom endpoints: endpoint, key, name — the rest is automatic",
788
+ group: "Models",
621
789
  open: openProviders,
622
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
+ },
623
798
  {
624
799
  value: "usage",
625
800
  label: "Usage",
626
801
  description: "open the token & cost dashboard (same as /usage)",
802
+ group: "Spend",
627
803
  open: openUsage,
628
804
  },
629
805
  {
630
806
  value: "budget",
631
807
  label: "Budget",
632
808
  description: "warn-only spend caps on today / 30d; enforce on blocks the next turn",
809
+ group: "Spend",
633
810
  open: openBudget,
634
811
  },
635
812
  ];
636
813
 
637
- /** The settings menu and the loop that gives `←` its meaning: a screen returning `true`
638
- * reopens this menu, anything else ends navigation. `startLabel` is the row to open on,
639
- * so a screen left with `←` (or a direct subcommand) resumes where the user was. */
640
- async function openMainMenu(ctx: ExtensionCommandContext, startLabel?: string): Promise<void> {
641
- const rows = menuRows(MENUS);
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]);
642
849
  if (ctx.mode !== "tui") {
643
850
  // No custom components (RPC/headless): a title-only picker, no description row.
644
851
  const labels = rows.map(rowText);
645
852
  const pick = await ctx.ui.select(MENU_TITLE, labels);
646
853
  if (pick === undefined) return;
647
- await MENUS[labels.indexOf(pick)]!.open(ctx);
854
+ await openCategoryMenu(ctx, MENU_CATEGORIES[labels.indexOf(pick)]!);
648
855
  return;
649
856
  }
650
- // Same picker as the submenus, so the description row under the title is rendered by
651
- // one component instead of two dialogs that could drift apart.
652
- let cursor = startLabel;
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;
653
862
  for (;;) {
654
863
  const index = await ctx.ui.custom<number | null>((tui, theme, _kb, done) => {
655
864
  const picker = new ListPicker(theme, rows, cursor, {
@@ -665,9 +874,9 @@ async function openMainMenu(ctx: ExtensionCommandContext, startLabel?: string):
665
874
  return picker;
666
875
  });
667
876
  if (index === null || index === undefined) return;
668
- cursor = rows[index]!.label;
669
- const wantsBack = await MENUS[index]!.open(ctx);
670
- if (wantsBack !== true) return;
877
+ const category = MENU_CATEGORIES[index]!;
878
+ cursor = category.label;
879
+ if ((await openCategoryMenu(ctx, category)) !== true) return;
671
880
  }
672
881
  }
673
882
 
@@ -685,9 +894,10 @@ export async function arnativeHandler(args: string, ctx: ExtensionCommandContext
685
894
  ctx.ui.notify(`[arnative] Unknown menu "${sub}". Menus: ${MENUS.map((m) => m.value).join(" | ")}`, "warning");
686
895
  return;
687
896
  }
688
- // A direct subcommand behaves like a menu row: `←` drops into the menu on that row,
897
+ // A direct subcommand behaves like a menu row: `←` drops into its category on that row,
689
898
  // so `/arnative usage` + `←` is not a dead key.
690
- if ((await MENUS[index]!.open(ctx)) === true) await openMainMenu(ctx, MENUS[index]!.label);
899
+ const menu = MENUS[index]!;
900
+ if ((await menu.open(ctx)) === true) await openMainMenu(ctx, menu.group, menu.label);
691
901
  }
692
902
 
693
903
  export function arnativeCompletions(prefix: string): AutocompleteItem[] | null {
@@ -723,7 +933,7 @@ export function shouldApplyDefaultTheme(
723
933
  * set without starting a session. */
724
934
  export function registerCommands(pi: Pick<ExtensionAPI, "registerCommand">): void {
725
935
  pi.registerCommand("arnative", {
726
- description: "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, render cache, providers, usage, budget",
936
+ description: "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, render cache, payload limit, providers, usage, budget",
727
937
  getArgumentCompletions: arnativeCompletions,
728
938
  handler: arnativeHandler,
729
939
  });
@@ -748,6 +958,7 @@ export function recordProfile(): void {
748
958
  [SPINNER_PRESET_KEY]: activeSpinnerPreset(),
749
959
  [SPINNER_GRADIENT_KEY]: activeSpinnerGradient() ? "on" : "off",
750
960
  [AUTO_COMPACT_KEY]: activeAutoCompact(),
961
+ [PAYLOAD_LIMIT_KEY]: savedPayloadLimit(),
751
962
  [MODEL_HEAL_KEY]: activeModelHeal(),
752
963
  [RENDER_CACHE_KEY]: activeRenderCache(),
753
964
  [BUDGET_DAY_KEY]: activeBudgetDay() === undefined ? "" : String(activeBudgetDay()),
@@ -787,22 +998,31 @@ if (isMain(import.meta.url)) {
787
998
  assert(rowText(labels[0]!) === "Themes · arnative themes only (all themes: /settings → Theme)", "menu row text format");
788
999
  assert(labels[0]!.label === "Themes" && labels[0]!.note === "arnative themes only (all themes: /settings → Theme)", "menu row keeps label and note apart");
789
1000
  assert(MENU_TITLE === "Settings - Arnative\u2819", `the menu title is the pinned string, got ${MENU_TITLE}`);
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}`);
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}`);
791
1002
  // Every menu row is reachable and the description names them all, so a new screen cannot
792
1003
  // be added to MENUS and forgotten in the copy a user reads first.
793
- assert(MENUS.length === 11, "eleven settings screens");
1004
+ assert(MENUS.length === 12, "twelve settings screens");
794
1005
  {
795
- const values = MENUS.map((m) => m.value);
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");
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");
798
1012
  const heal = modelHealRows("Flags");
799
1013
  assert(heal.map((r) => r.label).join(",") === "Full,Flags,Off,Run now", "Model heal rows: three modes then Run now");
800
1014
  assert(heal.filter((r) => r.chosen).map((r) => r.label).join(",") === "Flags", "Model heal marks only the saved mode");
801
1015
  const rc = renderCacheRows("On");
802
1016
  assert(rc.map((r) => r.label).join(",") === "On,Off", "Render cache rows: On then Off");
803
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");
804
1024
  }
805
- for (const label of ["Themes", "Headers", "Footers", "Chatbox", "Animations", "Auto-compact", "Render cache", "Providers", "Usage", "Budget"]) {
1025
+ for (const label of ["Themes", "Headers", "Footers", "Chatbox", "Animations", "Auto-compact", "Render cache", "Payload limit", "Providers", "Usage", "Budget"]) {
806
1026
  assert(MENUS.some((m) => m.label === label), `MENUS carries the ${label} screen`);
807
1027
  }
808
1028
  assert(/^Settings - Arnative/.test(MENU_TITLE), "title follows `<setting> - <extension>`");
@@ -828,6 +1048,8 @@ if (isMain(import.meta.url)) {
828
1048
  assert(autoCompactRows("Off")[0]!.chosen === true, "the marker moves when the saved choice changes");
829
1049
  assert(arnativeCompletions("re")![0]!.value === "render", "render cache menu has completions");
830
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");
831
1053
  assert(arnativeCompletions("pr")![0]!.value === "providers", "providers menu has completions");
832
1054
  assert(MENUS.some((m) => m.value === "providers"), "providers menu registered");
833
1055
  // Every slash command, and the one alias: `/providers` must land on the providers screen.
@@ -838,7 +1060,7 @@ if (isMain(import.meta.url)) {
838
1060
  assert(typeof registered.get("providers")!.handler === "function", "/providers has a handler");
839
1061
  assert(MENUS.some((m) => m.value === "providers"), "/providers routes to a menu row that exists");
840
1062
  assert(
841
- registered.get("arnative")!.description === "Arnative settings menu: themes, headers, footers, chatbox, animations, auto-compact, model heal, render cache, 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",
842
1064
  "the /arnative command description names every screen: " + registered.get("arnative")!.description,
843
1065
  );
844
1066
  }
@@ -886,11 +1108,11 @@ if (isMain(import.meta.url)) {
886
1108
  assert(lines[0]!.startsWith("╭") && lines[lines.length - 1]!.startsWith("╰"), "picker framed");
887
1109
  assert(lines.every((l) => visibleWidth(l) === 50), "picker lines fit width 50");
888
1110
  assert(lines.some((l) => l.includes(screenTitle("Themes"))), "picker renders the configured title");
889
- assert(lines.some((l) => l.includes("→ arnative")), "the cursor marks the live value");
890
- assert(!lines.some((l) => l.includes("●")), "no redundant ● column next to the → cursor");
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");
891
1113
  picker.handleInput("\x1b[B"); // down
892
1114
  assert(previews.length === 1 && previews[0] === "arnative-cyberpunk", "move previews immediately");
893
- assert(picker.render(50).some((l) => l.includes("→ arnative-cyberpunk")), "the cursor follows the preview");
1115
+ assert(picker.render(50).some((l) => l.includes("❯ arnative-cyberpunk")), "the cursor follows the preview");
894
1116
  picker.handleInput("\r"); // enter
895
1117
  assert(done === 1 && reverted === 0, "Enter keeps (no revert)");
896
1118
  picker.handleInput("\x1b[B");
@@ -931,54 +1153,55 @@ if (isMain(import.meta.url)) {
931
1153
  // setting, only Enter opens a row. `reverted` proves it.
932
1154
  let menuReverts = 0;
933
1155
  let menuCancelled = false;
934
- const mainPicker = new ListPicker(fakeTheme, labels, undefined, {
1156
+ const categoryRows = menuRows([...MENU_CATEGORIES]);
1157
+ const mainPicker = new ListPicker(fakeTheme, categoryRows, undefined, {
935
1158
  preview: () => {},
936
1159
  revert: () => { menuReverts++; },
937
1160
  done: () => {},
938
1161
  cancel: () => { menuCancelled = true; },
939
1162
  requestRender: () => {},
940
1163
  }, { title: MENU_TITLE, description: MENU_DESC, legend: LIST_LEGEND_ROOT }, false);
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);
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);
944
1167
  assert(menuLines.some((l) => l.includes(MENU_TITLE)), "the main menu renders its title");
945
1168
  assert(menuLines.some((l) => l.includes("[Esc] Close") && !l.includes("←")), "the root menu legend renders without a back key");
946
1169
  assert(menuLines.some((l) => l.includes(MENU_DESC)), "the main menu renders the description under the title");
947
1170
  assert(menuLines.findIndex((l) => l.includes(MENU_TITLE)) < menuLines.findIndex((l) => l.includes(MENU_DESC)), "description sits below the title");
948
- assert(menuLines.every((l) => visibleWidth(l) === 100), "main menu lines fit the width");
949
- // The pinned /arnative layout: `→ Themes · note`, every `·` in one column (skill rule 10).
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.
950
1173
  const plainMenu = menuLines.map(stripAnsi);
951
- const row0 = menuLines.map(stripAnsi).find((l) => l.includes("→ Themes"))!;
952
- // The row is `│ → <label padded to the widest label><divider><note>`: assert the shape,
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,
953
1176
  // not a literal run of spaces, so adding a wider screen cannot break the layout test.
954
- const widest = Math.max(...MENUS.map((m) => m.label.length));
1177
+ const widest = Math.max(...MENU_CATEGORIES.map((c) => c.label.length));
955
1178
  assert(
956
- row0.startsWith(`│ → ${"Themes".padEnd(widest)}${ROW_DIVIDER}arnative themes only`),
1179
+ row0.startsWith(`│ ❯ ${"Appearance".padEnd(widest)}${ROW_DIVIDER}themes, headers, footers`),
957
1180
  `menu row layout, got ${JSON.stringify(row0)}`,
958
1181
  );
959
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");
960
1183
  assert(
961
- plainMenu.some((l) => l.startsWith(`│ ${"Headers".padEnd(widest)}${ROW_DIVIDER}`)),
1184
+ plainMenu.some((l) => l.startsWith(`│ ${"Performance".padEnd(widest)}${ROW_DIVIDER}`)),
962
1185
  "unselected rows indent to the marker column",
963
1186
  );
964
1187
 
965
1188
  // A menu opened with a `current` row starts there. The handler passes the row it last
966
1189
  // used, so a submenu reopened by `←` lands back on that row instead of jumping to the
967
1190
  // top of the list — the cursor is the user's place, not the component's business.
968
- const resumed = new ListPicker(fakeTheme, labels, "Usage", {
1191
+ const resumed = new ListPicker(fakeTheme, categoryRows, "Models", {
969
1192
  preview: () => {},
970
1193
  revert: () => {},
971
1194
  done: () => {},
972
1195
  requestRender: () => {},
973
1196
  }, { title: MENU_TITLE, description: MENU_DESC, legend: LIST_LEGEND_ROOT }, false);
974
1197
  const resumedRows = resumed.render(60).map(stripAnsi);
975
- assert(resumedRows.some((l) => l.startsWith("│ → Usage")), "the menu reopens on the row it was left on");
976
- assert(!resumedRows.some((l) => l.startsWith("│ → Themes")), "and not on the first row");
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");
977
1200
 
978
1201
  // The box border follows the session's thinking level (theme `thinking*` slot), so the
979
1202
  // menu reads as belonging to the active model.
980
1203
  const tagged = { fg: (c: string, t: string) => `<${c}>${t}</>`, bold: (t: string) => `<bold>${t}</bold>` };
981
- const thinkingPicker = new ListPicker(tagged, labels, undefined, {
1204
+ const thinkingPicker = new ListPicker(tagged, categoryRows, undefined, {
982
1205
  preview: () => {},
983
1206
  revert: () => {},
984
1207
  done: () => {},
@@ -997,13 +1220,13 @@ if (isMain(import.meta.url)) {
997
1220
  "no frame glyph is left on accentSoft",
998
1221
  );
999
1222
  // The chosen row's label takes the `accentSoft` token (bold), never a hand-written colour; the
1000
- // `→` marker stays on `accent` so the cursor is still findable when the theme has no accentSoft.
1223
+ // `❯` marker stays on `accent` so the cursor is still findable when the theme has no accentSoft.
1001
1224
  assert(
1002
- taggedLines.some((l) => l.includes("<accent>→ </><accentSoft><bold>")),
1225
+ taggedLines.some((l) => l.includes("<accent>❯ </><accentSoft><bold>")),
1003
1226
  "the chosen label is the accentSoft token in bold",
1004
1227
  );
1005
- assert(taggedLines.some((l) => l.includes("<accent>→ ")), "the → marker keeps the accent voice");
1006
- const offPicker = new ListPicker(tagged, labels, undefined, {
1228
+ assert(taggedLines.some((l) => l.includes("<accent>❯ ")), "the ❯ marker keeps the accent voice");
1229
+ const offPicker = new ListPicker(tagged, categoryRows, undefined, {
1007
1230
  preview: () => {},
1008
1231
  revert: () => {},
1009
1232
  done: () => {},
@@ -1025,7 +1248,7 @@ if (isMain(import.meta.url)) {
1025
1248
  const headerPicker = new ListPicker(fakeTheme, nameRows(HEADER_PRESETS), "Arnative (Full)", { preview: () => {}, revert: () => {}, done: () => {}, requestRender: () => {} }, HEADERS_PICKER_TEXT);
1026
1249
  const headerLines = headerPicker.render(50);
1027
1250
  assert(headerLines.some((l) => l.includes(screenTitle("Headers"))), "headers picker title");
1028
- assert(headerLines.some((l) => l.includes("→ Arnative (Full)")), "headers picker cursors the active preset");
1251
+ assert(headerLines.some((l) => l.includes("❯ Arnative (Full)")), "headers picker cursors the active preset");
1029
1252
  assert(headerLines.some((l) => l.includes(" Pi (system)")), "headers picker lists the built-in preset");
1030
1253
 
1031
1254
  // Footers reuses the same picker too.
@@ -1033,7 +1256,7 @@ if (isMain(import.meta.url)) {
1033
1256
  const footerPicker = new ListPicker(fakeTheme, nameRows(FOOTER_PRESETS), "Pi (system)", { preview: () => {}, revert: () => {}, done: () => {}, requestRender: () => {} }, footersPickerText());
1034
1257
  const footerLines = footerPicker.render(50);
1035
1258
  assert(footerLines.some((l) => l.includes(screenTitle("Footers"))), "footers picker title");
1036
- assert(footerLines.some((l) => l.includes("→ Pi (system)")), "footers picker cursors the active preset");
1259
+ assert(footerLines.some((l) => l.includes("❯ Pi (system)")), "footers picker cursors the active preset");
1037
1260
  assert(footerLines.some((l) => l.includes("Arnative (Minimal)")), "footers picker lists the minimal preset");
1038
1261
  assert(footerLines.filter((l) => l.includes("Arnative (")).length === 2, "both arnative footer presets are selectable");
1039
1262
  assert(/\[c\] Cost (on|off)/.test(footersPickerText().legend), "footers legend advertises the cost switch and its live state");
@@ -1051,7 +1274,7 @@ if (isMain(import.meta.url)) {
1051
1274
  const chatboxLines = chatboxPicker.render(84);
1052
1275
  assert(chatboxLines.some((l) => l.includes(screenTitle("Chatbox"))), "chatbox picker title");
1053
1276
  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");
1277
+ assert(chatboxLines.some((l) => l.includes("❯ Arnative")), "chatbox picker cursors the active preset");
1055
1278
  assert(chatboxLines.some((l) => l.includes(" Pi (system)")), "chatbox picker lists the built-in preset");
1056
1279
  assert(CHATBOX_PICKER_TEXT.legend.includes("[i] Icon [D] Dialog"), "chatbox legend advertises [i] Icon and [D] Dialog");
1057
1280
 
@@ -1110,14 +1333,14 @@ if (isMain(import.meta.url)) {
1110
1333
  marked: (label) => chosen.has(label),
1111
1334
  }, { title: screenTitle("Providers"), description: "pick models", legend: "[Space] Toggle" }, false);
1112
1335
  const multiLines = multiPicker.render(50).map(stripAnsi);
1113
- assert(multiLines.some((l) => l.includes("→ [x] a")), "a checked row shows [x] behind the cursor");
1336
+ assert(multiLines.some((l) => l.includes("❯ [x] a")), "a checked row shows [x] behind the cursor");
1114
1337
  assert(multiLines.some((l) => l.includes("[ ] b")), "unchecked rows show [ ]");
1115
1338
  multiPicker.handleInput(" ");
1116
1339
  assert(picked[0] === "a" && !chosen.has("a"), "Space toggles the row under the cursor");
1117
1340
  multiPicker.handleInput("\x1b[B");
1118
1341
  multiPicker.handleInput(" ");
1119
1342
  assert(chosen.has("b"), "Space toggles the row the cursor moved to");
1120
- assert(multiPicker.render(50).map(stripAnsi).some((l) => l.includes("→ [x] b")), "the check follows the cursor");
1343
+ assert(multiPicker.render(50).map(stripAnsi).some((l) => l.includes("❯ [x] b")), "the check follows the cursor");
1121
1344
  mainPicker.handleInput(" ");
1122
1345
  assert(chosen.has("b") && picked.length === 2, "a screen without the toggle hook ignores Space");
1123
1346