pi-sage 0.2.5 → 0.2.6

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.
@@ -372,7 +372,7 @@ async function runSettingsWizard(ctx: ExtensionCommandContext): Promise<void> {
372
372
  let scope: SettingsScope = loaded.source === "global" ? "global" : "project";
373
373
 
374
374
  while (true) {
375
- const action = await ctx.ui.select("Sage settings", [
375
+ const action = await selectPaged(ctx, "Sage settings", [
376
376
  `Enabled: ${onOff(draft.enabled)}`,
377
377
  `Autonomous mode: ${onOff(draft.autonomousEnabled)}`,
378
378
  `Explicit requests bypass soft limits: ${onOff(draft.explicitRequestAlwaysAllowed)}`,
@@ -556,7 +556,7 @@ async function pickModel(ctx: ExtensionContext, currentModel: string): Promise<s
556
556
  })
557
557
  ];
558
558
 
559
- const providerChoice = await ctx.ui.select("Choose Sage model provider", providerOptions);
559
+ const providerChoice = await selectPaged(ctx, "Choose Sage model provider", providerOptions);
560
560
  if (!providerChoice) return undefined;
561
561
 
562
562
  if (providerChoice.startsWith(MODEL_INHERIT_VALUE)) {
@@ -587,7 +587,7 @@ async function pickModel(ctx: ExtensionContext, currentModel: string): Promise<s
587
587
  modelOptionMap.set(option, composite);
588
588
  }
589
589
 
590
- const modelChoice = await ctx.ui.select(`Choose Sage model (${provider})`, modelOptions);
590
+ const modelChoice = await selectPaged(ctx, `Choose Sage model (${provider})`, modelOptions);
591
591
  if (!modelChoice) return undefined;
592
592
  if (modelChoice === "← Back to providers") continue;
593
593
 
@@ -662,6 +662,48 @@ function resolveModelSpec(
662
662
  return { modelArg: `${first.provider}/${first.id}`, reason: "first available fallback" };
663
663
  }
664
664
 
665
+ type HasUIContext = { ui: ExtensionContext["ui"] };
666
+
667
+ async function selectPaged(
668
+ ctx: HasUIContext,
669
+ title: string,
670
+ options: string[],
671
+ pageSize = 10
672
+ ): Promise<string | undefined> {
673
+ if (options.length <= pageSize) {
674
+ return await ctx.ui.select(title, options);
675
+ }
676
+
677
+ let page = 0;
678
+ const totalPages = Math.max(1, Math.ceil(options.length / pageSize));
679
+ const PREV = "← Previous page";
680
+ const NEXT = "→ Next page";
681
+
682
+ while (true) {
683
+ const start = page * pageSize;
684
+ const end = Math.min(start + pageSize, options.length);
685
+ const pageOptions = options.slice(start, end);
686
+
687
+ if (page > 0) pageOptions.push(PREV);
688
+ if (page < totalPages - 1) pageOptions.push(NEXT);
689
+
690
+ const selected = await ctx.ui.select(`${title} (${start + 1}-${end} of ${options.length})`, pageOptions);
691
+ if (!selected) return undefined;
692
+
693
+ if (selected === PREV && page > 0) {
694
+ page -= 1;
695
+ continue;
696
+ }
697
+
698
+ if (selected === NEXT && page < totalPages - 1) {
699
+ page += 1;
700
+ continue;
701
+ }
702
+
703
+ return selected;
704
+ }
705
+ }
706
+
665
707
  function onOff(value: boolean): string {
666
708
  return value ? "on" : "off";
667
709
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-sage",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Interactive-only advisory Sage extension for Pi",