pi-sage 0.2.9 → 0.2.10

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.
@@ -378,8 +378,10 @@ async function runSettingsWizard(ctx: ExtensionCommandContext): Promise<void> {
378
378
  ctx.ui.notify(`Saved Sage settings to ${target}`, "info");
379
379
  };
380
380
 
381
+ let rootSelectionIndex = 0;
382
+
381
383
  while (true) {
382
- const action = await selectScrollable(ctx, "Sage settings", [
384
+ const rootOptions = [
383
385
  `Enabled: ${onOff(draft.enabled)}`,
384
386
  `Autonomous mode: ${onOff(draft.autonomousEnabled)}`,
385
387
  `Explicit requests bypass soft limits: ${onOff(draft.explicitRequestAlwaysAllowed)}`,
@@ -401,13 +403,18 @@ async function runSettingsWizard(ctx: ExtensionCommandContext): Promise<void> {
401
403
  `Cost cap/session: ${draft.maxEstimatedCostPerSession ?? "(none)"}`,
402
404
  `Save scope: ${scope}`,
403
405
  "Test Sage call"
404
- ]);
406
+ ];
407
+
408
+ const action = await selectScrollable(ctx, "Sage settings", rootOptions, 10, rootSelectionIndex);
405
409
 
406
410
  if (!action) {
407
411
  ctx.ui.notify("Sage settings closed (changes are saved immediately)", "info");
408
412
  return;
409
413
  }
410
414
 
415
+ const selectedIndex = rootOptions.indexOf(action);
416
+ if (selectedIndex >= 0) rootSelectionIndex = selectedIndex;
417
+
411
418
  if (action === "Test Sage call") {
412
419
  await runSettingsTestCall(ctx, draft);
413
420
  continue;
@@ -721,7 +728,8 @@ async function selectScrollable(
721
728
  ctx: HasUIContext,
722
729
  title: string,
723
730
  options: string[],
724
- maxVisible = 10
731
+ maxVisible = 10,
732
+ initialSelectedIndex = 0
725
733
  ): Promise<string | undefined> {
726
734
  if (options.length === 0) return undefined;
727
735
 
@@ -744,6 +752,8 @@ async function selectScrollable(
744
752
  noMatch: (text) => theme.fg("warning", text)
745
753
  });
746
754
 
755
+ selectList.setSelectedIndex(initialSelectedIndex);
756
+
747
757
  selectList.onSelect = (item) => done(item.value);
748
758
  selectList.onCancel = () => done(undefined);
749
759
  container.addChild(selectList);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-sage",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Interactive-only advisory Sage extension for Pi",