@firstpick/pi-package-webui 0.8.2 → 0.8.4
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/README.md +76 -19
- package/bin/pi-webui.mjs +864 -140
- package/lib/WEBUI_TUI_NATIVE_PARITY.json +26 -0
- package/lib/git-workflow-preferences.mjs +246 -19
- package/lib/optional-feature-catalog.mjs +29 -0
- package/lib/optional-feature-migration.mjs +410 -0
- package/lib/session-summary-core.mjs +320 -0
- package/lib/session-summary-preferences.mjs +267 -0
- package/lib/thinking-stream-recovery.mjs +156 -0
- package/lib/ui-layout-settings.mjs +254 -0
- package/package.json +5 -40
- package/public/app.js +2898 -92
- package/public/index.html +77 -14
- package/public/service-worker.js +1 -1
- package/public/styles.css +669 -2
- package/session-summary.ts +403 -0
- package/tests/aur-review-widget-static.test.mjs +3 -2
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/composer-action-grid-reorder.spec.mjs +303 -0
- package/tests/browser/feature-decision-output-popup.spec.mjs +156 -0
- package/tests/browser/interaction-continuity.spec.mjs +29 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +744 -0
- package/tests/browser/session-summary.spec.mjs +271 -0
- package/tests/codex-fast-mode-static.test.mjs +10 -9
- package/tests/composer-action-grid-reorder-static.test.mjs +63 -0
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/feature-decision-output-popup-static.test.mjs +172 -0
- package/tests/fixtures/fake-pi.mjs +51 -1
- package/tests/git-workflow-preferences.test.mjs +4 -2
- package/tests/http-endpoints-harness.test.mjs +507 -4
- package/tests/interaction-state-stability-static.test.mjs +3 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +118 -103
- package/tests/native-parity-harness.test.mjs +9 -1
- package/tests/native-parity.test.mjs +23 -1
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +72 -0
- package/tests/optional-feature-migration.test.mjs +142 -0
- package/tests/persistent-ui-layout-static.test.mjs +267 -0
- package/tests/questionnaire-dialog.test.mjs +511 -0
- package/tests/queue-edit-reorder-static.test.mjs +1 -0
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/session-summary-core.test.mjs +491 -0
- package/tests/session-summary-preferences.test.mjs +103 -0
- package/tests/side-panel-resize-static.test.mjs +1 -0
- package/tests/side-panel-section-reorder-static.test.mjs +3 -3
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/thinking-stream-recovery.test.mjs +88 -0
- package/tests/ui-layout-settings.test.mjs +92 -0
- package/tests/webui-settings-locking.test.mjs +159 -0
|
@@ -56,6 +56,32 @@
|
|
|
56
56
|
"currentBehavior": "Catalog-gated exact command routing and the Options menu open a browser-native reviewed policy editor backed by localhost-only revision-protected GET/POST routes; it never starts an agent turn.",
|
|
57
57
|
"targetBehavior": "Keep browser and Pi TUI setup aligned with the canonical strict policy validator, deny defaults, explicit normalized review, and stale-write protection."
|
|
58
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"id": "/summary",
|
|
61
|
+
"kind": "slash-command",
|
|
62
|
+
"category": "native-command",
|
|
63
|
+
"title": "Session summary viewer and refresh",
|
|
64
|
+
"command": { "name": "summary", "description": "Open the latest Markdown session summary or generate one" },
|
|
65
|
+
"webStatus": "implemented",
|
|
66
|
+
"priority": "P1",
|
|
67
|
+
"sensitive": true,
|
|
68
|
+
"guards": ["confirmation"],
|
|
69
|
+
"currentBehavior": "Catalog-gated header and composer actions open a non-blocking sanitized Markdown overlay; an unconfigured first click opens setup, and configured refreshes use the active tab only while preserving the latest successful result on failure.",
|
|
70
|
+
"targetBehavior": "Keep browser and TUI summary display branch-aware, bounded, tab-scoped, and explicit about configured provider usage."
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "/summary-setup",
|
|
74
|
+
"kind": "slash-command",
|
|
75
|
+
"category": "native-command",
|
|
76
|
+
"title": "Session summary setup",
|
|
77
|
+
"command": { "name": "summary-setup", "description": "Configure persistent session titles and Markdown summaries" },
|
|
78
|
+
"webStatus": "implemented",
|
|
79
|
+
"priority": "P1",
|
|
80
|
+
"sensitive": true,
|
|
81
|
+
"guards": ["confirmation"],
|
|
82
|
+
"currentBehavior": "Catalog-gated exact routing and Common Pi options open a browser-native model, reasoning, prompts, cadence, automatic-generation, privacy-scope, and context-injection editor; a disclosure confirmation is required before private global persistence and immediate first generation.",
|
|
83
|
+
"targetBehavior": "Keep browser and Pi TUI setup aligned with the canonical session-summary preference schema, fixed privacy scope, and explicit privacy/cost confirmation."
|
|
84
|
+
},
|
|
59
85
|
{
|
|
60
86
|
"id": "/model",
|
|
61
87
|
"kind": "slash-command",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { mkdir, readFile, rename,
|
|
1
|
+
import { mkdir, open, readFile, readdir, rename, rm, rmdir } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
4
5
|
import { normalizeSubagentLaunchSlots } from "./subagent-launch-slots.mjs";
|
|
6
|
+
import { normalizeUiLayout } from "./ui-layout-settings.mjs";
|
|
5
7
|
import { normalizeOutputMode, OUTPUT_MODE_NORMAL } from "./webui-output-mode.mjs";
|
|
6
8
|
|
|
7
9
|
export const GIT_WORKFLOW_SETUP_VERSION = 1;
|
|
@@ -24,8 +26,10 @@ export function supportedGitWorkflowThinkingLevels(model) {
|
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
const WEBUI_SETTINGS_VERSION =
|
|
29
|
+
const WEBUI_SETTINGS_VERSION = 6;
|
|
28
30
|
const WEBUI_SETTINGS_FILE_ENV = "PI_WEBUI_SETTINGS_FILE";
|
|
31
|
+
const WEBUI_SETTINGS_LOCK_TIMEOUT_MS = 2_000;
|
|
32
|
+
const WEBUI_SETTINGS_LOCK_RETRY_MS = 25;
|
|
29
33
|
export const WEBUI_SIDE_PANEL_WIDTH_MIN_PX = 320;
|
|
30
34
|
export const WEBUI_SIDE_PANEL_WIDTH_MAX_PX = 4096;
|
|
31
35
|
const webuiSettingsUpdateQueues = new Map();
|
|
@@ -112,6 +116,10 @@ export function gitWorkflowPreferencesSummary(preferences) {
|
|
|
112
116
|
|
|
113
117
|
export function webuiSettingsFile(env = process.env) {
|
|
114
118
|
if (env[WEBUI_SETTINGS_FILE_ENV]) return path.resolve(String(env[WEBUI_SETTINGS_FILE_ENV]).replace(/^~(?=$|[\\/])/, homedir()));
|
|
119
|
+
return path.join(homedir(), ".pi", "webui", "settings.json");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function legacyWebuiSettingsFile(env = process.env) {
|
|
115
123
|
const configRoot = env.XDG_CONFIG_HOME || path.join(homedir(), ".config");
|
|
116
124
|
return path.join(configRoot, "pi-webui", "settings.json");
|
|
117
125
|
}
|
|
@@ -169,24 +177,236 @@ export function normalizeWebuiSettings(value) {
|
|
|
169
177
|
gitWorkflow: normalizeGitWorkflowPreferences(source.gitWorkflow),
|
|
170
178
|
resourceDefaults: normalizeResourceDefaults(source.resourceDefaults),
|
|
171
179
|
interfacePreferences: normalizeInterfacePreferences(source.interfacePreferences),
|
|
180
|
+
uiLayout: normalizeUiLayout(source.uiLayout),
|
|
172
181
|
subagentLaunchSlots: normalizeSubagentLaunchSlots(source.subagentLaunchSlots),
|
|
173
182
|
};
|
|
174
183
|
}
|
|
175
184
|
|
|
176
|
-
|
|
185
|
+
function settingsReadError(storageFile, error) {
|
|
186
|
+
const wrapped = new Error(`Cannot read Pi Web UI settings at ${storageFile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
187
|
+
wrapped.code = "WEBUI_SETTINGS_READ_FAILED";
|
|
188
|
+
wrapped.cause = error;
|
|
189
|
+
return wrapped;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function readRawWebuiSettings(storageFile, { missing = {} } = {}) {
|
|
193
|
+
let text;
|
|
194
|
+
try {
|
|
195
|
+
text = await readFile(storageFile, "utf8");
|
|
196
|
+
} catch (error) {
|
|
197
|
+
if (error?.code === "ENOENT") return missing;
|
|
198
|
+
throw settingsReadError(storageFile, error);
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
const parsed = JSON.parse(text);
|
|
202
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new TypeError("settings must contain a JSON object");
|
|
203
|
+
return parsed;
|
|
204
|
+
} catch (error) {
|
|
205
|
+
throw settingsReadError(storageFile, error);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function isDefaultSettingsTarget(storageFile, env = process.env) {
|
|
210
|
+
return !env[WEBUI_SETTINGS_FILE_ENV] && path.resolve(storageFile) === path.resolve(webuiSettingsFile(env));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function ensurePrivateSettingsDirectory(storageFile) {
|
|
214
|
+
await mkdir(path.dirname(storageFile), { recursive: true, mode: 0o700 });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function lockDirectoryFor(storageFile) {
|
|
218
|
+
return `${storageFile}.lock`;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function lockOwnerIsDead(pid) {
|
|
222
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) return false;
|
|
177
223
|
try {
|
|
178
|
-
|
|
224
|
+
process.kill(pid, 0);
|
|
225
|
+
return false;
|
|
179
226
|
} catch (error) {
|
|
180
|
-
|
|
181
|
-
throw new Error(`Cannot read Pi Web UI settings at ${storageFile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
227
|
+
return error?.code === "ESRCH";
|
|
182
228
|
}
|
|
183
229
|
}
|
|
184
230
|
|
|
231
|
+
async function readSettingsLockRecords(lockDirectory) {
|
|
232
|
+
const names = (await readdir(lockDirectory)).filter((name) => name.endsWith(".json")).sort();
|
|
233
|
+
return Promise.all(names.map(async (name) => {
|
|
234
|
+
const recordFile = path.join(lockDirectory, name);
|
|
235
|
+
try {
|
|
236
|
+
const value = JSON.parse(await readFile(recordFile, "utf8"));
|
|
237
|
+
const valid = Number.isSafeInteger(value?.pid)
|
|
238
|
+
&& value.pid > 0
|
|
239
|
+
&& typeof value?.token === "string"
|
|
240
|
+
&& value.token.length > 0
|
|
241
|
+
&& ["pending", "active"].includes(value?.state);
|
|
242
|
+
return { ...value, name, recordFile, valid };
|
|
243
|
+
} catch {
|
|
244
|
+
return { name, recordFile, valid: false };
|
|
245
|
+
}
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async function writeSettingsLockRecord(recordFile, value) {
|
|
250
|
+
const temporaryFile = `${recordFile}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
251
|
+
let handle;
|
|
252
|
+
try {
|
|
253
|
+
handle = await open(temporaryFile, "wx", 0o600);
|
|
254
|
+
await handle.writeFile(`${JSON.stringify(value)}\n`, "utf8");
|
|
255
|
+
await handle.sync();
|
|
256
|
+
await handle.close();
|
|
257
|
+
handle = undefined;
|
|
258
|
+
await rename(temporaryFile, recordFile);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
await handle?.close().catch(() => {});
|
|
261
|
+
await rm(temporaryFile, { force: true }).catch(() => {});
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async function releaseSettingsLock(lockDirectory, recordFile) {
|
|
267
|
+
await rm(recordFile, { force: true });
|
|
268
|
+
await rmdir(lockDirectory).catch((error) => {
|
|
269
|
+
if (error?.code !== "ENOENT" && error?.code !== "ENOTEMPTY" && error?.code !== "EEXIST") throw error;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export async function withWebuiSettingsLock(storageFile, operation, {
|
|
274
|
+
timeoutMs = WEBUI_SETTINGS_LOCK_TIMEOUT_MS,
|
|
275
|
+
retryMs = WEBUI_SETTINGS_LOCK_RETRY_MS,
|
|
276
|
+
} = {}) {
|
|
277
|
+
await ensurePrivateSettingsDirectory(storageFile);
|
|
278
|
+
const lockDirectory = lockDirectoryFor(storageFile);
|
|
279
|
+
await mkdir(lockDirectory, { mode: 0o700 }).catch((error) => {
|
|
280
|
+
if (error?.code !== "EEXIST") throw error;
|
|
281
|
+
});
|
|
282
|
+
const token = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
283
|
+
const recordFile = path.join(lockDirectory, `${token}.json`);
|
|
284
|
+
const ownRecord = { pid: process.pid, token, state: "pending" };
|
|
285
|
+
let handle;
|
|
286
|
+
try {
|
|
287
|
+
handle = await open(recordFile, "wx", 0o600);
|
|
288
|
+
await handle.writeFile(`${JSON.stringify(ownRecord)}\n`, "utf8");
|
|
289
|
+
await handle.sync();
|
|
290
|
+
await handle.close();
|
|
291
|
+
handle = undefined;
|
|
292
|
+
} catch (error) {
|
|
293
|
+
await handle?.close().catch(() => {});
|
|
294
|
+
await rm(recordFile, { force: true }).catch(() => {});
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const deadline = Date.now() + Math.max(0, timeoutMs);
|
|
299
|
+
let acquired = false;
|
|
300
|
+
try {
|
|
301
|
+
while (!acquired) {
|
|
302
|
+
let records = await readSettingsLockRecords(lockDirectory);
|
|
303
|
+
let removedDeadOwner = false;
|
|
304
|
+
for (const record of records) {
|
|
305
|
+
if (record.valid && lockOwnerIsDead(record.pid)) {
|
|
306
|
+
await rm(record.recordFile, { force: true });
|
|
307
|
+
removedDeadOwner = true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (removedDeadOwner) continue;
|
|
311
|
+
|
|
312
|
+
const active = records.filter((record) => record.valid && record.state === "active");
|
|
313
|
+
if (active.length === 1 && active[0].token === token) {
|
|
314
|
+
acquired = true;
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
if (active.length === 0 && records[0]?.token === token && records[0]?.valid) {
|
|
318
|
+
ownRecord.state = "active";
|
|
319
|
+
await writeSettingsLockRecord(recordFile, ownRecord);
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (Date.now() >= deadline) {
|
|
323
|
+
const timeoutError = new Error("Timed out waiting for the Pi Web UI settings lock");
|
|
324
|
+
timeoutError.code = "WEBUI_SETTINGS_LOCK_TIMEOUT";
|
|
325
|
+
throw timeoutError;
|
|
326
|
+
}
|
|
327
|
+
await delay(Math.max(1, Math.min(retryMs, deadline - Date.now())));
|
|
328
|
+
}
|
|
329
|
+
return await operation();
|
|
330
|
+
} finally {
|
|
331
|
+
await releaseSettingsLock(lockDirectory, recordFile);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function syncDirectoryBestEffort(directory) {
|
|
336
|
+
let handle;
|
|
337
|
+
try {
|
|
338
|
+
handle = await open(directory, "r");
|
|
339
|
+
await handle.sync();
|
|
340
|
+
} catch {
|
|
341
|
+
// Directory fsync is unsupported on some platforms/filesystems.
|
|
342
|
+
} finally {
|
|
343
|
+
await handle?.close().catch(() => {});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async function writePrivateAtomicSettings(storageFile, value) {
|
|
348
|
+
await ensurePrivateSettingsDirectory(storageFile);
|
|
349
|
+
const temporaryFile = path.join(
|
|
350
|
+
path.dirname(storageFile),
|
|
351
|
+
`.${path.basename(storageFile)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`,
|
|
352
|
+
);
|
|
353
|
+
let handle;
|
|
354
|
+
try {
|
|
355
|
+
handle = await open(temporaryFile, "wx", 0o600);
|
|
356
|
+
await handle.writeFile(`${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
357
|
+
await handle.sync();
|
|
358
|
+
await handle.close();
|
|
359
|
+
handle = undefined;
|
|
360
|
+
await rename(temporaryFile, storageFile);
|
|
361
|
+
await syncDirectoryBestEffort(path.dirname(storageFile));
|
|
362
|
+
} catch (error) {
|
|
363
|
+
await handle?.close().catch(() => {});
|
|
364
|
+
await rm(temporaryFile, { force: true }).catch(() => {});
|
|
365
|
+
throw error;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export async function migrateLegacyWebuiSettings(targetFile, legacyFile) {
|
|
370
|
+
if (path.resolve(targetFile) === path.resolve(legacyFile)) return false;
|
|
371
|
+
try {
|
|
372
|
+
await readFile(targetFile, "utf8");
|
|
373
|
+
return false;
|
|
374
|
+
} catch (error) {
|
|
375
|
+
if (error?.code !== "ENOENT") throw settingsReadError(targetFile, error);
|
|
376
|
+
}
|
|
377
|
+
let legacy;
|
|
378
|
+
try {
|
|
379
|
+
legacy = await readRawWebuiSettings(legacyFile, { missing: null });
|
|
380
|
+
} catch {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
if (!legacy) return false;
|
|
384
|
+
return withWebuiSettingsLock(targetFile, async () => {
|
|
385
|
+
try {
|
|
386
|
+
await readFile(targetFile, "utf8");
|
|
387
|
+
return false;
|
|
388
|
+
} catch (error) {
|
|
389
|
+
if (error?.code !== "ENOENT") throw settingsReadError(targetFile, error);
|
|
390
|
+
}
|
|
391
|
+
const { settings, persistLaunchSlots, persistedUiLayout } = mergeWebuiSettings(legacy, {});
|
|
392
|
+
const persisted = { ...settings, uiLayout: persistedUiLayout };
|
|
393
|
+
if (!persistLaunchSlots) delete persisted.subagentLaunchSlots;
|
|
394
|
+
await writePrivateAtomicSettings(targetFile, persisted);
|
|
395
|
+
return true;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async function ensureDefaultSettingsMigration(storageFile, env = process.env) {
|
|
400
|
+
if (!isDefaultSettingsTarget(storageFile, env)) return false;
|
|
401
|
+
return migrateLegacyWebuiSettings(storageFile, legacyWebuiSettingsFile(env));
|
|
402
|
+
}
|
|
403
|
+
|
|
185
404
|
export async function readWebuiSettings(storageFile = webuiSettingsFile(), { reportInvalidOutputMode = false } = {}) {
|
|
405
|
+
await ensureDefaultSettingsMigration(storageFile);
|
|
186
406
|
const raw = await readRawWebuiSettings(storageFile);
|
|
187
407
|
const normalized = normalizeWebuiSettings(raw);
|
|
188
408
|
if (reportInvalidOutputMode && raw.outputModeDefault !== undefined && normalized.outputModeDefault !== raw.outputModeDefault) {
|
|
189
|
-
console.warn(`Invalid persisted Web UI output mode ${JSON.stringify(raw.outputModeDefault)}
|
|
409
|
+
console.warn(`Invalid persisted Web UI output mode ${JSON.stringify(raw.outputModeDefault)}; using ${OUTPUT_MODE_NORMAL}.`);
|
|
190
410
|
}
|
|
191
411
|
return normalized;
|
|
192
412
|
}
|
|
@@ -214,6 +434,9 @@ function mergeWebuiSettings(rawCurrent, patch) {
|
|
|
214
434
|
interfacePreferences: patchValue.interfacePreferences
|
|
215
435
|
? { ...current.interfacePreferences, ...patchValue.interfacePreferences }
|
|
216
436
|
: current.interfacePreferences,
|
|
437
|
+
uiLayout: Object.hasOwn(patchValue, "uiLayout")
|
|
438
|
+
? normalizeUiLayout(patchValue.uiLayout)
|
|
439
|
+
: current.uiLayout,
|
|
217
440
|
};
|
|
218
441
|
if (persistLaunchSlots) {
|
|
219
442
|
source.subagentLaunchSlots = hasLaunchSlotPatch
|
|
@@ -224,17 +447,18 @@ function mergeWebuiSettings(rawCurrent, patch) {
|
|
|
224
447
|
delete source.subagentLaunchSlots;
|
|
225
448
|
source.version = Math.max(WEBUI_SETTINGS_VERSION, Number.isInteger(raw.version) ? raw.version : 0);
|
|
226
449
|
}
|
|
227
|
-
|
|
450
|
+
const settings = normalizeWebuiSettings(source);
|
|
451
|
+
const persistedUiLayout = !Object.hasOwn(patchValue, "uiLayout") && raw.uiLayout !== undefined
|
|
452
|
+
? raw.uiLayout
|
|
453
|
+
: settings.uiLayout;
|
|
454
|
+
return { settings, persistLaunchSlots, persistedUiLayout };
|
|
228
455
|
}
|
|
229
456
|
|
|
230
457
|
async function writeMergedWebuiSettings(rawCurrent, patch, storageFile) {
|
|
231
|
-
const { settings, persistLaunchSlots } = mergeWebuiSettings(rawCurrent, patch);
|
|
232
|
-
const persisted = { ...settings };
|
|
458
|
+
const { settings, persistLaunchSlots, persistedUiLayout } = mergeWebuiSettings(rawCurrent, patch);
|
|
459
|
+
const persisted = { ...settings, uiLayout: persistedUiLayout };
|
|
233
460
|
if (!persistLaunchSlots) delete persisted.subagentLaunchSlots;
|
|
234
|
-
await
|
|
235
|
-
const temporaryFile = `${storageFile}.${process.pid}.${Date.now()}.tmp`;
|
|
236
|
-
await writeFile(temporaryFile, `${JSON.stringify(persisted, null, 2)}\n`, { mode: 0o600 });
|
|
237
|
-
await rename(temporaryFile, storageFile);
|
|
461
|
+
await writePrivateAtomicSettings(storageFile, persisted);
|
|
238
462
|
return settings;
|
|
239
463
|
}
|
|
240
464
|
|
|
@@ -246,11 +470,14 @@ export function updateWebuiSettings(updater, storageFile = webuiSettingsFile())
|
|
|
246
470
|
const queueKey = path.resolve(storageFile);
|
|
247
471
|
const previous = webuiSettingsUpdateQueues.get(queueKey) || Promise.resolve();
|
|
248
472
|
const currentUpdate = previous.catch(() => {}).then(async () => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
473
|
+
await ensureDefaultSettingsMigration(storageFile);
|
|
474
|
+
return withWebuiSettingsLock(storageFile, async () => {
|
|
475
|
+
const rawCurrent = await readRawWebuiSettings(storageFile);
|
|
476
|
+
const current = normalizeWebuiSettings(rawCurrent);
|
|
477
|
+
const patch = await updater(current);
|
|
478
|
+
if (patch === undefined) return current;
|
|
479
|
+
return writeMergedWebuiSettings(rawCurrent, patch, storageFile);
|
|
480
|
+
});
|
|
254
481
|
});
|
|
255
482
|
webuiSettingsUpdateQueues.set(queueKey, currentUpdate);
|
|
256
483
|
return currentUpdate.finally(() => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const entries = [
|
|
2
|
+
["bangCommandAutocomplete", "@firstpick/pi-extension-bang-command-autocomplete", "^0.2.2"],
|
|
3
|
+
["fishUserBash", "@firstpick/pi-extension-fish-user-bash", "^0.2.2"],
|
|
4
|
+
["btwCommand", "@firstpick/pi-extension-btw", "^0.1.4"],
|
|
5
|
+
["gitWorkflow", "@firstpick/pi-prompts-git-pr", "^0.1.5"],
|
|
6
|
+
["releaseNpm", "@firstpick/pi-extension-release-npm", "^0.4.4"],
|
|
7
|
+
["releaseAur", "@firstpick/pi-extension-release-aur", "^0.1.8"],
|
|
8
|
+
["aurReview", "@firstpick/pi-extension-aur-review", "^0.1.1"],
|
|
9
|
+
["workflows", "@firstpick/pi-extension-workflows", "^0.1.7"],
|
|
10
|
+
["safetyGuard", "@firstpick/pi-extension-safety-guard", "^0.2.6"],
|
|
11
|
+
["tuiSkillsCommand", "@firstpick/pi-extension-setup-skills", "^0.1.9"],
|
|
12
|
+
["todoProgressWidget", "@firstpick/pi-extension-todo-progress", "^0.2.9"],
|
|
13
|
+
["tuiToolsCommand", "@firstpick/pi-extension-tools", "^0.1.7"],
|
|
14
|
+
["remoteWebui", "@firstpick/pi-package-remote-webui", "^0.1.8"],
|
|
15
|
+
["questionnaire", "@firstpick/pi-package-questionnaire", "^0.1.0"],
|
|
16
|
+
["naturalConversation", "@firstpick/pi-package-natural-conversation", "^0.1.4"],
|
|
17
|
+
["gitFooterStatus", "@firstpick/pi-extension-git-footer-status", "^0.4.3"],
|
|
18
|
+
["statsCommand", "@firstpick/pi-extension-stats", "^0.2.9"],
|
|
19
|
+
["codexFastMode", "@firstpick/pi-extension-codex-fast-mode", "^0.1.0"],
|
|
20
|
+
["themeBundle", "@firstpick/pi-themes-bundle", "^0.1.5"],
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const OPTIONAL_FEATURE_CATALOG = Object.freeze(entries.map(([featureId, packageName, expectedSpec]) => Object.freeze({
|
|
24
|
+
featureId,
|
|
25
|
+
packageName,
|
|
26
|
+
expectedSpec,
|
|
27
|
+
})));
|
|
28
|
+
|
|
29
|
+
export const OPTIONAL_FEATURE_BY_ID = new Map(OPTIONAL_FEATURE_CATALOG.map((feature) => [feature.featureId, feature]));
|