avtc-pi-settings-ui 1.0.5 → 1.0.7

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.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avtc-pi-settings-ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A schema-driven settings UI for pi extensions — define your settings, get a tabbed modal, a /<name>:settings command, and layered persistence.",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -23,13 +23,13 @@
23
23
  "lint:as-never": "node scripts/no-as-never.cjs src/ tests/ index.ts"
24
24
  },
25
25
  "dependencies": {
26
- "avtc-pi-logger": "^1.0.0",
26
+ "avtc-pi-logger": "^1.0.3",
27
27
  "minimatch": "^10.0.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@biomejs/biome": "^2.5.0",
31
- "@earendil-works/pi-coding-agent": "^0.80.6",
32
- "@earendil-works/pi-tui": "^0.80.6",
31
+ "@earendil-works/pi-coding-agent": "^0.80.10",
32
+ "@earendil-works/pi-tui": "^0.80.10",
33
33
  "@types/node": "^25.9.3",
34
34
  "jscpd": "^5.0.10",
35
35
  "knip": "^6.17.1",
@@ -83,12 +83,17 @@ function isEnabled(model: ModelLike, patterns: readonly string[]): boolean {
83
83
  * enabled-models patterns, each `[modelLabel(model), "provider/id"]`, with `["Default", null]`
84
84
  * prepended. When the registry was not captured, or enabled-models patterns are configured but
85
85
  * match nothing, the list degrades to `["Default", null]` (the modal still opens).
86
+ *
87
+ * Async because `modelRegistry.refresh()` is async on pi 0.80.8+ (it reloads models.json
88
+ * asynchronously). Awaiting it guarantees the subsequent synchronous `getAvailable()` reads
89
+ * the freshly loaded list rather than a stale one. On older pi (where refresh returned void)
90
+ * `await`-ing a non-promise is a no-op, so this is forward- and backward-compatible.
86
91
  */
87
- export function resolveModelPresets(): PresetPair[] {
92
+ export async function resolveModelPresets(): Promise<PresetPair[]> {
88
93
  const { modelRegistry } = getCapturedCtx();
89
94
  if (!modelRegistry) return [DEFAULT_PAIR];
90
95
 
91
- modelRegistry.refresh();
96
+ await modelRegistry.refresh();
92
97
  const all = modelRegistry.getAvailable();
93
98
  const patterns = readEnabledModelPatterns();
94
99
 
@@ -23,7 +23,7 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
23
23
  * and one active session (so one lastMessage), observed identically by every
24
24
  * subscriber. Listener unsubs are NOT shared: each subscribeToNotificationApi() call
25
25
  * owns its own local closure unsubs, so multiple subscribers (ui-components,
26
- * ask-user-question, feature-flow) don't clobber each other's cleanup.
26
+ * ask-user-question, featyard) don't clobber each other's cleanup.
27
27
  */
28
28
  interface NotificationForwardingState {
29
29
  requestAttention: ((source: string, detail?: string) => (() => void) | undefined) | null;
@@ -221,6 +221,18 @@ const stringType: TypeDefinition<string> = {
221
221
  errorMessage: "Select a value",
222
222
  };
223
223
 
224
+ /**
225
+ * The boolean choices, as `[label, value]` preset pairs (label equals value). The default
226
+ * `presets` for the `boolean` type — a consumer writes only `{ type: "boolean" }` and gets
227
+ * these without declaring `presets` (overridable per-setting: replace, not merge). Without
228
+ * them a boolean resolves to no presets, so the value picker would surface only the current
229
+ * value (e.g. just "False") with nothing to toggle to.
230
+ */
231
+ export const BOOLEAN_PRESETS = [
232
+ ["true", true],
233
+ ["false", false],
234
+ ] as const satisfies readonly PresetPair[];
235
+
224
236
  const booleanType: TypeDefinition<boolean> = {
225
237
  id: "boolean",
226
238
  valueType: "boolean",
@@ -230,6 +242,7 @@ const booleanType: TypeDefinition<boolean> = {
230
242
  return undefined;
231
243
  },
232
244
  format: (value) => String(value),
245
+ presets: BOOLEAN_PRESETS,
233
246
  supportsCustomValues: false,
234
247
  errorMessage: "Select true or false",
235
248
  };