@firstpick/pi-package-webui 0.9.0 → 0.9.2
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 +236 -24
- package/bin/pi-webui-launcher.mjs +23 -12
- package/bin/pi-webui.mjs +493 -65
- package/lib/agent-run-adapters.mjs +500 -0
- package/lib/agent-run-protocol.mjs +262 -0
- package/lib/agent-run-registry.mjs +339 -0
- package/lib/app-runner-terminal.mjs +40 -0
- package/lib/git-workflow-preferences.mjs +11 -4
- package/lib/trust-boundaries.mjs +2 -0
- package/lib/ui-layout-settings.mjs +172 -28
- package/lib/update/package-layout.mjs +50 -0
- package/lib/update/plan.mjs +11 -0
- package/package.json +2 -2
- package/public/app.js +1376 -337
- package/public/index.html +113 -68
- package/public/service-worker.js +1 -1
- package/public/styles.css +371 -93
- package/tests/agent-run-adapters.test.mjs +217 -0
- package/tests/agent-run-launcher.test.mjs +41 -0
- package/tests/agent-run-protocol.test.mjs +82 -0
- package/tests/agent-run-registry.test.mjs +102 -0
- package/tests/app-runner-terminal-static.test.mjs +28 -0
- package/tests/app-runner-terminal.test.mjs +65 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
- package/tests/browser/controls-layout.spec.mjs +122 -0
- package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
- package/tests/browser/interaction-continuity.spec.mjs +159 -0
- package/tests/browser/mobile-foundation.spec.mjs +26 -0
- package/tests/browser/model-search-focus.spec.mjs +96 -0
- package/tests/browser/optimistic-prompt.spec.mjs +22 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +224 -66
- package/tests/browser/subagent-observability.spec.mjs +87 -0
- package/tests/chat-scroll-intent-static.test.mjs +1 -1
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/component-update-api-static.test.mjs +2 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +2 -0
- package/tests/control-deck-side-panels-static.test.mjs +68 -0
- package/tests/controls-layout-static.test.mjs +22 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-tree-git-ignored-static.test.mjs +152 -0
- package/tests/file-tree-search-layout-static.test.mjs +2 -1
- package/tests/fixtures/fake-pi.mjs +43 -7
- package/tests/footer-provider-usage-visual-static.test.mjs +10 -8
- package/tests/git-workflow-preferences.test.mjs +55 -6
- package/tests/http-endpoints-harness.test.mjs +173 -14
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- 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 +18 -5
- package/tests/open-issue-wizard-static.test.mjs +2 -2
- package/tests/persistent-ui-layout-static.test.mjs +13 -13
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-context-menu-static.test.mjs +1 -1
- package/tests/side-panel-resize-static.test.mjs +26 -16
- package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
- package/tests/side-panel-section-reorder-static.test.mjs +16 -70
- package/tests/subagent-gate-visibility.test.mjs +2 -1
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +32 -0
- package/tests/subagent-reliability-integration.test.mjs +161 -0
- package/tests/subagents-helper.test.mjs +344 -4
- package/tests/terminal-tabs-resize-static.test.mjs +35 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/ui-layout-settings.test.mjs +104 -32
- package/tests/update-api-harness.test.mjs +24 -10
- package/tests/update-package-layout.test.mjs +38 -0
- package/tests/update-plan.test.mjs +11 -1
- package/tests/webui-settings-locking.test.mjs +33 -3
- package/webui-rpc-helper.mjs +417 -28
|
@@ -26,7 +26,7 @@ export function supportedGitWorkflowThinkingLevels(model) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const WEBUI_SETTINGS_VERSION =
|
|
29
|
+
const WEBUI_SETTINGS_VERSION = 7;
|
|
30
30
|
const WEBUI_SETTINGS_FILE_ENV = "PI_WEBUI_SETTINGS_FILE";
|
|
31
31
|
const WEBUI_SETTINGS_LOCK_TIMEOUT_MS = 2_000;
|
|
32
32
|
const WEBUI_SETTINGS_LOCK_RETRY_MS = 25;
|
|
@@ -172,6 +172,12 @@ function normalizedSettingsVersion(value) {
|
|
|
172
172
|
|
|
173
173
|
export function normalizeWebuiSettings(value) {
|
|
174
174
|
const source = settingsObject(value);
|
|
175
|
+
const interfacePreferences = normalizeInterfacePreferences(source.interfacePreferences);
|
|
176
|
+
const legacyLayoutSource = source.uiLayout === undefined
|
|
177
|
+
&& interfacePreferences.sidePanelWidth !== null
|
|
178
|
+
&& (!Number.isInteger(source.version) || source.version < WEBUI_SETTINGS_VERSION)
|
|
179
|
+
? { version: 1 }
|
|
180
|
+
: source.uiLayout;
|
|
175
181
|
return {
|
|
176
182
|
...source,
|
|
177
183
|
version: normalizedSettingsVersion(source),
|
|
@@ -179,8 +185,8 @@ export function normalizeWebuiSettings(value) {
|
|
|
179
185
|
outputModeDefault: normalizeOutputMode(source.outputModeDefault, OUTPUT_MODE_NORMAL),
|
|
180
186
|
gitWorkflow: normalizeGitWorkflowPreferences(source.gitWorkflow),
|
|
181
187
|
resourceDefaults: normalizeResourceDefaults(source.resourceDefaults),
|
|
182
|
-
interfacePreferences
|
|
183
|
-
uiLayout: normalizeUiLayout(
|
|
188
|
+
interfacePreferences,
|
|
189
|
+
uiLayout: normalizeUiLayout(legacyLayoutSource, { legacySidePanelWidth: interfacePreferences.sidePanelWidth }),
|
|
184
190
|
subagentLaunchSlots: normalizeSubagentLaunchSlots(source.subagentLaunchSlots),
|
|
185
191
|
};
|
|
186
192
|
}
|
|
@@ -466,7 +472,8 @@ function mergeWebuiSettings(rawCurrent, patch) {
|
|
|
466
472
|
source.version = Math.max(WEBUI_SETTINGS_VERSION, Number.isInteger(raw.version) ? raw.version : 0);
|
|
467
473
|
}
|
|
468
474
|
const settings = normalizeWebuiSettings(source);
|
|
469
|
-
const
|
|
475
|
+
const rawLayoutVersion = Number.isInteger(raw.uiLayout?.version) ? raw.uiLayout.version : 0;
|
|
476
|
+
const persistedUiLayout = !Object.hasOwn(patchValue, "uiLayout") && rawLayoutVersion > settings.uiLayout.version
|
|
470
477
|
? raw.uiLayout
|
|
471
478
|
: settings.uiLayout;
|
|
472
479
|
return { settings, persistLaunchSlots, persistedUiLayout };
|
package/lib/trust-boundaries.mjs
CHANGED
|
@@ -17,6 +17,8 @@ export const LOCALHOST_ONLY_POST_ROUTES = new Map([
|
|
|
17
17
|
["/api/remote-auth/settings", "Remote PIN authentication settings are only allowed from localhost"],
|
|
18
18
|
["/api/workflow-policy", "Workflow policy setup is only allowed from localhost"],
|
|
19
19
|
["/api/subagents/config", "Saving subagent launch-slot configuration is only allowed from localhost"],
|
|
20
|
+
["/api/subagents/cancel", "Cancelling subagent runs is only allowed from localhost"],
|
|
21
|
+
["/api/subagents/dismiss", "Dismissing retained subagent runs is only allowed from localhost"],
|
|
20
22
|
["/api/recovery/plan", "Opening recovery plans is only allowed from localhost"],
|
|
21
23
|
["/api/restart", "Restart is only allowed from localhost"],
|
|
22
24
|
["/api/update", "Updating Pi from the Web UI is only allowed from localhost"],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
|
|
3
|
-
export const UI_LAYOUT_VERSION =
|
|
3
|
+
export const UI_LAYOUT_VERSION = 2;
|
|
4
4
|
export const UI_LAYOUT_REQUEST_MAX_BYTES = 32 * 1024;
|
|
5
5
|
export const UI_LAYOUT_LIMITS = Object.freeze({
|
|
6
6
|
idLength: 256,
|
|
@@ -9,12 +9,20 @@ export const UI_LAYOUT_LIMITS = Object.freeze({
|
|
|
9
9
|
groups: 32,
|
|
10
10
|
gridColumns: 24,
|
|
11
11
|
gridSlots: 4096,
|
|
12
|
+
panelWidthMin: 320,
|
|
13
|
+
panelWidthMax: 4096,
|
|
14
|
+
panelWidthDefault: 384,
|
|
12
15
|
fileViewerWidthMin: 384,
|
|
13
16
|
fileViewerWidthMax: 4096,
|
|
17
|
+
terminalTabsSidebarWidthMin: 208,
|
|
18
|
+
terminalTabsSidebarWidthMax: 4096,
|
|
14
19
|
});
|
|
15
20
|
|
|
21
|
+
const LEGACY_UI_LAYOUT_VERSION = 1;
|
|
16
22
|
const UNSAFE_OBJECT_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
17
23
|
const TERMINAL_TAB_LAYOUTS = new Set(["top", "left"]);
|
|
24
|
+
const CONTROL_DECK_PLACEMENTS = new Set(["right", "left", "both"]);
|
|
25
|
+
const SIDES = ["left", "right"];
|
|
18
26
|
|
|
19
27
|
function objectValue(value) {
|
|
20
28
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
@@ -57,21 +65,85 @@ function nullable(value, validate) {
|
|
|
57
65
|
return value === null ? null : validate(value);
|
|
58
66
|
}
|
|
59
67
|
|
|
68
|
+
function validatePlacement(value) {
|
|
69
|
+
if (!CONTROL_DECK_PLACEMENTS.has(value)) invalid("layout.sidePanel.placement must be right, left, both, or null");
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function validateSectionLayout(value) {
|
|
74
|
+
const source = objectValue(value);
|
|
75
|
+
if (!source) invalid("layout.sidePanel.sectionLayout must be an object or null");
|
|
76
|
+
assertOnlyKeys(source, new Set(["order", "leftSectionIds"]), "layout.sidePanel.sectionLayout");
|
|
77
|
+
if (!own(source, "order") || !own(source, "leftSectionIds")) {
|
|
78
|
+
invalid("layout.sidePanel.sectionLayout must include order and leftSectionIds together");
|
|
79
|
+
}
|
|
80
|
+
const order = nullable(source.order, (entry) => boundedUniqueStringList(entry, "layout.sidePanel.sectionLayout.order"));
|
|
81
|
+
const leftSectionIds = nullable(source.leftSectionIds, (entry) => boundedUniqueStringList(entry, "layout.sidePanel.sectionLayout.leftSectionIds"));
|
|
82
|
+
if ((order === null) !== (leftSectionIds === null)) {
|
|
83
|
+
invalid("layout.sidePanel.sectionLayout order and leftSectionIds must both be arrays or both be null");
|
|
84
|
+
}
|
|
85
|
+
if (order !== null) {
|
|
86
|
+
const orderIds = new Set(order);
|
|
87
|
+
if (leftSectionIds.some((id) => !orderIds.has(id))) {
|
|
88
|
+
invalid("layout.sidePanel.sectionLayout.leftSectionIds entries must occur in order");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { order, leftSectionIds };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function validateBooleanSides(value, label, { partial = false } = {}) {
|
|
95
|
+
const source = objectValue(value);
|
|
96
|
+
if (!source) invalid(`${label} must be an object or null`);
|
|
97
|
+
assertOnlyKeys(source, new Set(SIDES), label);
|
|
98
|
+
if (partial && Object.keys(source).length === 0) invalid(`${label} must name at least one side`);
|
|
99
|
+
const result = {};
|
|
100
|
+
for (const side of SIDES) {
|
|
101
|
+
if (!partial || own(source, side)) {
|
|
102
|
+
const state = source[side] ?? null;
|
|
103
|
+
if (state !== null && typeof state !== "boolean") invalid(`${label}.${side} must be a boolean or null`);
|
|
104
|
+
result[side] = state;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function validatePanelWidth(value, label) {
|
|
111
|
+
if (!Number.isFinite(value) || value < UI_LAYOUT_LIMITS.panelWidthMin || value > UI_LAYOUT_LIMITS.panelWidthMax) {
|
|
112
|
+
invalid(`${label} must be between ${UI_LAYOUT_LIMITS.panelWidthMin} and ${UI_LAYOUT_LIMITS.panelWidthMax} pixels or null`);
|
|
113
|
+
}
|
|
114
|
+
return Math.round(value);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function validatePanelWidths(value, { partial = false } = {}) {
|
|
118
|
+
const source = objectValue(value);
|
|
119
|
+
if (!source) invalid("layout.sidePanel.panelWidths must be an object or null");
|
|
120
|
+
assertOnlyKeys(source, new Set(SIDES), "layout.sidePanel.panelWidths");
|
|
121
|
+
if (partial && Object.keys(source).length === 0) invalid("layout.sidePanel.panelWidths must name at least one side");
|
|
122
|
+
const result = {};
|
|
123
|
+
for (const side of SIDES) {
|
|
124
|
+
if (!partial || own(source, side)) {
|
|
125
|
+
result[side] = nullable(source[side] ?? null, (entry) => validatePanelWidth(entry, `layout.sidePanel.panelWidths.${side}`));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
|
|
60
131
|
function validateSidePanel(value, { partial = false } = {}) {
|
|
61
132
|
const source = objectValue(value);
|
|
62
133
|
if (!source) invalid("layout.sidePanel must be an object or null");
|
|
63
|
-
const fields = new Set(["
|
|
134
|
+
const fields = new Set(["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"]);
|
|
64
135
|
assertOnlyKeys(source, fields, "layout.sidePanel");
|
|
65
136
|
if (partial && Object.keys(source).length === 0) invalid("layout.sidePanel must name at least one field");
|
|
66
137
|
const result = {};
|
|
67
|
-
|
|
138
|
+
if (!partial || own(source, "placement")) result.placement = nullable(source.placement ?? null, validatePlacement);
|
|
139
|
+
if (!partial || own(source, "sectionLayout")) result.sectionLayout = nullable(source.sectionLayout ?? null, validateSectionLayout);
|
|
140
|
+
for (const field of ["collapsedSectionIds", "hiddenSectionIds"]) {
|
|
68
141
|
if (!partial || own(source, field)) result[field] = nullable(source[field] ?? null, (entry) => boundedUniqueStringList(entry, `layout.sidePanel.${field}`));
|
|
69
142
|
}
|
|
70
|
-
if (!partial || own(source, "
|
|
71
|
-
|
|
72
|
-
if (collapsed !== null && typeof collapsed !== "boolean") invalid("layout.sidePanel.collapsed must be a boolean or null");
|
|
73
|
-
result.collapsed = collapsed;
|
|
143
|
+
if (!partial || own(source, "collapsedPanels")) {
|
|
144
|
+
result.collapsedPanels = nullable(source.collapsedPanels ?? null, (entry) => validateBooleanSides(entry, "layout.sidePanel.collapsedPanels", { partial }));
|
|
74
145
|
}
|
|
146
|
+
if (!partial || own(source, "panelWidths")) result.panelWidths = nullable(source.panelWidths ?? null, (entry) => validatePanelWidths(entry, { partial }));
|
|
75
147
|
return result;
|
|
76
148
|
}
|
|
77
149
|
|
|
@@ -146,7 +218,7 @@ function validateCustomGroups(value) {
|
|
|
146
218
|
function validateTerminalTabs(value, { partial = false } = {}) {
|
|
147
219
|
const source = objectValue(value);
|
|
148
220
|
if (!source) invalid("layout.terminalTabs must be an object or null");
|
|
149
|
-
assertOnlyKeys(source, new Set(["layout", "customGroups"]), "layout.terminalTabs");
|
|
221
|
+
assertOnlyKeys(source, new Set(["layout", "customGroups", "sidebarWidth"]), "layout.terminalTabs");
|
|
150
222
|
if (partial && Object.keys(source).length === 0) invalid("layout.terminalTabs must name at least one field");
|
|
151
223
|
const result = {};
|
|
152
224
|
if (!partial || own(source, "layout")) {
|
|
@@ -155,23 +227,40 @@ function validateTerminalTabs(value, { partial = false } = {}) {
|
|
|
155
227
|
result.layout = layout;
|
|
156
228
|
}
|
|
157
229
|
if (!partial || own(source, "customGroups")) result.customGroups = nullable(source.customGroups ?? null, validateCustomGroups);
|
|
230
|
+
if (!partial || own(source, "sidebarWidth")) {
|
|
231
|
+
result.sidebarWidth = nullable(source.sidebarWidth ?? null, (width) => validateBoundedWidth(
|
|
232
|
+
width,
|
|
233
|
+
"layout.terminalTabs.sidebarWidth",
|
|
234
|
+
UI_LAYOUT_LIMITS.terminalTabsSidebarWidthMin,
|
|
235
|
+
UI_LAYOUT_LIMITS.terminalTabsSidebarWidthMax,
|
|
236
|
+
));
|
|
237
|
+
}
|
|
158
238
|
return result;
|
|
159
239
|
}
|
|
160
240
|
|
|
161
|
-
function
|
|
162
|
-
if (!Number.isFinite(value) || value <
|
|
163
|
-
invalid(`layout.fileViewerWidth must be between ${UI_LAYOUT_LIMITS.fileViewerWidthMin} and ${UI_LAYOUT_LIMITS.fileViewerWidthMax} pixels or null`);
|
|
164
|
-
}
|
|
241
|
+
function validateBoundedWidth(value, label, min, max) {
|
|
242
|
+
if (!Number.isFinite(value) || value < min || value > max) invalid(`${label} must be between ${min} and ${max} pixels or null`);
|
|
165
243
|
return Math.round(value);
|
|
166
244
|
}
|
|
167
245
|
|
|
246
|
+
function validateFileViewerWidth(value) {
|
|
247
|
+
return validateBoundedWidth(value, "layout.fileViewerWidth", UI_LAYOUT_LIMITS.fileViewerWidthMin, UI_LAYOUT_LIMITS.fileViewerWidthMax);
|
|
248
|
+
}
|
|
249
|
+
|
|
168
250
|
export function defaultUiLayout() {
|
|
169
251
|
return {
|
|
170
252
|
version: UI_LAYOUT_VERSION,
|
|
171
|
-
sidePanel: {
|
|
253
|
+
sidePanel: {
|
|
254
|
+
placement: null,
|
|
255
|
+
sectionLayout: { order: null, leftSectionIds: null },
|
|
256
|
+
collapsedSectionIds: null,
|
|
257
|
+
hiddenSectionIds: null,
|
|
258
|
+
collapsedPanels: { left: null, right: null },
|
|
259
|
+
panelWidths: { left: null, right: null },
|
|
260
|
+
},
|
|
172
261
|
composerActions: { order: null, grid: null },
|
|
173
262
|
footerScopedModelOrder: null,
|
|
174
|
-
terminalTabs: { layout: null, customGroups: null },
|
|
263
|
+
terminalTabs: { layout: null, customGroups: null, sidebarWidth: null },
|
|
175
264
|
fileViewerWidth: null,
|
|
176
265
|
};
|
|
177
266
|
}
|
|
@@ -184,21 +273,12 @@ function softField(validate, fallback = null) {
|
|
|
184
273
|
}
|
|
185
274
|
}
|
|
186
275
|
|
|
187
|
-
|
|
188
|
-
const source = objectValue(value);
|
|
189
|
-
const defaults = defaultUiLayout();
|
|
190
|
-
if (!source || source.version !== UI_LAYOUT_VERSION) return defaults;
|
|
191
|
-
const sidePanel = objectValue(source.sidePanel);
|
|
276
|
+
function normalizeSharedLayoutFields(source, sidePanel) {
|
|
192
277
|
const composerActions = objectValue(source.composerActions);
|
|
193
278
|
const terminalTabs = objectValue(source.terminalTabs);
|
|
194
279
|
return {
|
|
195
280
|
version: UI_LAYOUT_VERSION,
|
|
196
|
-
sidePanel
|
|
197
|
-
sectionOrder: softField(() => nullable(sidePanel?.sectionOrder ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.sectionOrder"))),
|
|
198
|
-
collapsedSectionIds: softField(() => nullable(sidePanel?.collapsedSectionIds ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.collapsedSectionIds"))),
|
|
199
|
-
hiddenSectionIds: softField(() => nullable(sidePanel?.hiddenSectionIds ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.hiddenSectionIds"))),
|
|
200
|
-
collapsed: typeof sidePanel?.collapsed === "boolean" ? sidePanel.collapsed : null,
|
|
201
|
-
},
|
|
281
|
+
sidePanel,
|
|
202
282
|
composerActions: {
|
|
203
283
|
order: softField(() => nullable(composerActions?.order ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.composerActions.order"))),
|
|
204
284
|
grid: softField(() => nullable(composerActions?.grid ?? null, validateGrid)),
|
|
@@ -207,11 +287,68 @@ export function normalizeUiLayout(value) {
|
|
|
207
287
|
terminalTabs: {
|
|
208
288
|
layout: TERMINAL_TAB_LAYOUTS.has(terminalTabs?.layout) ? terminalTabs.layout : null,
|
|
209
289
|
customGroups: softField(() => nullable(terminalTabs?.customGroups ?? null, validateCustomGroups)),
|
|
290
|
+
sidebarWidth: softField(() => nullable(terminalTabs?.sidebarWidth ?? null, (width) => validateBoundedWidth(
|
|
291
|
+
width,
|
|
292
|
+
"uiLayout.terminalTabs.sidebarWidth",
|
|
293
|
+
UI_LAYOUT_LIMITS.terminalTabsSidebarWidthMin,
|
|
294
|
+
UI_LAYOUT_LIMITS.terminalTabsSidebarWidthMax,
|
|
295
|
+
))),
|
|
210
296
|
},
|
|
211
297
|
fileViewerWidth: softField(() => nullable(source.fileViewerWidth ?? null, validateFileViewerWidth)),
|
|
212
298
|
};
|
|
213
299
|
}
|
|
214
300
|
|
|
301
|
+
function normalizeSideValues(source, validate, fallback) {
|
|
302
|
+
const record = objectValue(source);
|
|
303
|
+
return Object.fromEntries(SIDES.map((side) => [side, softField(() => nullable(record?.[side] ?? null, (value) => validate(value, side)), fallback)]));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function normalizeVersionTwo(source) {
|
|
307
|
+
const sidePanel = objectValue(source.sidePanel);
|
|
308
|
+
return normalizeSharedLayoutFields(source, {
|
|
309
|
+
placement: CONTROL_DECK_PLACEMENTS.has(sidePanel?.placement) ? sidePanel.placement : null,
|
|
310
|
+
sectionLayout: softField(
|
|
311
|
+
() => sidePanel?.sectionLayout == null ? defaultUiLayout().sidePanel.sectionLayout : validateSectionLayout(sidePanel.sectionLayout),
|
|
312
|
+
defaultUiLayout().sidePanel.sectionLayout,
|
|
313
|
+
),
|
|
314
|
+
collapsedSectionIds: softField(() => nullable(sidePanel?.collapsedSectionIds ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.collapsedSectionIds"))),
|
|
315
|
+
hiddenSectionIds: softField(() => nullable(sidePanel?.hiddenSectionIds ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.hiddenSectionIds"))),
|
|
316
|
+
collapsedPanels: normalizeSideValues(sidePanel?.collapsedPanels, (value, side) => {
|
|
317
|
+
if (typeof value !== "boolean") invalid(`uiLayout.sidePanel.collapsedPanels.${side} must be a boolean or null`);
|
|
318
|
+
return value;
|
|
319
|
+
}, null),
|
|
320
|
+
panelWidths: normalizeSideValues(sidePanel?.panelWidths, (value, side) => validatePanelWidth(value, `uiLayout.sidePanel.panelWidths.${side}`), null),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function migrateVersionOne(source, legacySidePanelWidth) {
|
|
325
|
+
const sidePanel = objectValue(source.sidePanel);
|
|
326
|
+
const order = softField(() => nullable(sidePanel?.sectionOrder ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.sectionOrder")));
|
|
327
|
+
const rightWidth = softField(
|
|
328
|
+
() => validatePanelWidth(legacySidePanelWidth, "interfacePreferences.sidePanelWidth"),
|
|
329
|
+
UI_LAYOUT_LIMITS.panelWidthDefault,
|
|
330
|
+
);
|
|
331
|
+
return normalizeSharedLayoutFields(source, {
|
|
332
|
+
placement: "right",
|
|
333
|
+
sectionLayout: order === null ? { order: null, leftSectionIds: null } : { order, leftSectionIds: [] },
|
|
334
|
+
collapsedSectionIds: softField(() => nullable(sidePanel?.collapsedSectionIds ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.collapsedSectionIds"))),
|
|
335
|
+
hiddenSectionIds: softField(() => nullable(sidePanel?.hiddenSectionIds ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.sidePanel.hiddenSectionIds"))),
|
|
336
|
+
collapsedPanels: {
|
|
337
|
+
left: false,
|
|
338
|
+
right: typeof sidePanel?.collapsed === "boolean" ? sidePanel.collapsed : false,
|
|
339
|
+
},
|
|
340
|
+
panelWidths: { left: UI_LAYOUT_LIMITS.panelWidthDefault, right: rightWidth },
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function normalizeUiLayout(value, { legacySidePanelWidth = null } = {}) {
|
|
345
|
+
const source = objectValue(value);
|
|
346
|
+
if (!source) return defaultUiLayout();
|
|
347
|
+
if (source.version === UI_LAYOUT_VERSION) return normalizeVersionTwo(source);
|
|
348
|
+
if (source.version === LEGACY_UI_LAYOUT_VERSION) return migrateVersionOne(source, legacySidePanelWidth);
|
|
349
|
+
return defaultUiLayout();
|
|
350
|
+
}
|
|
351
|
+
|
|
215
352
|
export function validateUiLayoutPatch(value) {
|
|
216
353
|
const source = objectValue(value);
|
|
217
354
|
if (!source) invalid("layout must be an object");
|
|
@@ -234,9 +371,16 @@ export function mergeUiLayout(current, patch) {
|
|
|
234
371
|
const value = validateUiLayoutPatch(patch);
|
|
235
372
|
const merged = { ...base };
|
|
236
373
|
if (own(value, "sidePanel")) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
374
|
+
if (value.sidePanel === null) {
|
|
375
|
+
merged.sidePanel = defaultUiLayout().sidePanel;
|
|
376
|
+
} else {
|
|
377
|
+
merged.sidePanel = { ...base.sidePanel, ...value.sidePanel };
|
|
378
|
+
for (const field of ["collapsedPanels", "panelWidths"]) {
|
|
379
|
+
if (own(value.sidePanel, field) && value.sidePanel[field] !== null) {
|
|
380
|
+
merged.sidePanel[field] = { ...base.sidePanel[field], ...value.sidePanel[field] };
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
240
384
|
}
|
|
241
385
|
if (own(value, "composerActions")) merged.composerActions = value.composerActions === null ? defaultUiLayout().composerActions : value.composerActions;
|
|
242
386
|
if (own(value, "footerScopedModelOrder")) merged.footerScopedModelOrder = value.footerScopedModelOrder;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
function pathApi(platform) {
|
|
4
|
+
return platform === "win32" ? path.win32 : path.posix;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function exactPathInside(api, root, candidate) {
|
|
8
|
+
const relative = api.relative(api.resolve(root), api.resolve(candidate));
|
|
9
|
+
return relative === "" || (!relative.startsWith(`..${api.sep}`) && relative !== ".." && !api.isAbsolute(relative));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function sameExactPath(api, left, right) {
|
|
13
|
+
return exactPathInside(api, left, right) && exactPathInside(api, right, left);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Return the installation root that owns the nearest node_modules containing a package. */
|
|
17
|
+
export function packageOwnerRoot(packageRoot, { platform = process.platform } = {}) {
|
|
18
|
+
const api = pathApi(platform);
|
|
19
|
+
const resolved = api.resolve(String(packageRoot || ""));
|
|
20
|
+
if (!packageRoot) return "";
|
|
21
|
+
let cursor = resolved;
|
|
22
|
+
while (true) {
|
|
23
|
+
if (api.basename(cursor).toLowerCase() === "node_modules") return api.dirname(cursor);
|
|
24
|
+
const parent = api.dirname(cursor);
|
|
25
|
+
if (parent === cursor) return resolved;
|
|
26
|
+
cursor = parent;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Prove that a resolver-selected bundled package belongs to the Web UI package
|
|
32
|
+
* installation. Supports both package-local nesting and npm's normal hoisted
|
|
33
|
+
* sibling layout while refusing explicit, PATH, unrelated, and opaque roots.
|
|
34
|
+
*/
|
|
35
|
+
export function bundledPackageOwnership({ hostPackageRoot = "", packageRoot = "", source = "" } = {}, { platform = process.platform } = {}) {
|
|
36
|
+
if (source !== "bundled" || !hostPackageRoot || !packageRoot) return null;
|
|
37
|
+
const api = pathApi(platform);
|
|
38
|
+
const hostRoot = api.resolve(hostPackageRoot);
|
|
39
|
+
const bundledRoot = api.resolve(packageRoot);
|
|
40
|
+
const nested = exactPathInside(api, api.join(hostRoot, "node_modules"), bundledRoot);
|
|
41
|
+
const hostOwnerRoot = packageOwnerRoot(hostRoot, { platform });
|
|
42
|
+
const bundledOwnerRoot = packageOwnerRoot(bundledRoot, { platform });
|
|
43
|
+
const hoisted = Boolean(hostOwnerRoot && bundledOwnerRoot && sameExactPath(api, hostOwnerRoot, bundledOwnerRoot));
|
|
44
|
+
if (!nested && !hoisted) return null;
|
|
45
|
+
return Object.freeze({
|
|
46
|
+
ownerRoot: bundledOwnerRoot,
|
|
47
|
+
packageRoot: bundledRoot,
|
|
48
|
+
layout: nested ? "nested" : "hoisted",
|
|
49
|
+
});
|
|
50
|
+
}
|
package/lib/update/plan.mjs
CHANGED
|
@@ -114,6 +114,17 @@ export async function createUpdatePlan({
|
|
|
114
114
|
return Object.freeze({ ...unsigned, digest });
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
export function assertActionableUpdatePlan(plan) {
|
|
118
|
+
if (Array.isArray(plan?.targets) && plan.targets.length > 0) return true;
|
|
119
|
+
const refusals = Array.isArray(plan?.refusals) ? plan.refusals.map((item) => clean(item?.id)).filter(Boolean) : [];
|
|
120
|
+
const error = new Error(refusals.length
|
|
121
|
+
? `Update plan has no accepted targets; automatic update was refused for: ${refusals.join(", ")}.`
|
|
122
|
+
: "Update plan has no accepted targets.");
|
|
123
|
+
error.code = "UPDATE_PLAN_NO_TARGETS";
|
|
124
|
+
error.statusCode = 409;
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
|
|
117
128
|
export function assertUpdatePlanDigest(plan, suppliedDigest) {
|
|
118
129
|
const expected = digestUpdatePlan(plan);
|
|
119
130
|
if (!/^[a-f0-9]{64}$/.test(clean(suppliedDigest)) || suppliedDigest !== plan?.digest || suppliedDigest !== expected) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-package-webui#readme",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"pi-webui": "./bin/pi-webui-launcher.mjs"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"check": "node --check public/app.js && node --check public/middle-button-drag-scroll.mjs && node --check public/stream-output-controller.mjs && node --check public/theme-contract.mjs && node --check public/transcript-renderer.mjs && node --check public/mobile-shell-state.mjs && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-launcher.mjs && node --check bin/pi-webui-update-supervisor.mjs && node --check lib/update/supervisor.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/workspace-files-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
|
|
33
|
+
"check": "node --check public/app.js && node --check lib/app-runner-terminal.mjs && node --check public/middle-button-drag-scroll.mjs && node --check public/stream-output-controller.mjs && node --check public/theme-contract.mjs && node --check public/transcript-renderer.mjs && node --check public/mobile-shell-state.mjs && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-launcher.mjs && node --check bin/pi-webui-update-supervisor.mjs && node --check lib/update/supervisor.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/workspace-files-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
|
|
34
34
|
"test": "node tests/run-all.mjs",
|
|
35
35
|
"test:browser": "playwright test"
|
|
36
36
|
},
|