@firstpick/pi-package-webui 0.8.6 → 0.8.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.
- package/README.md +18 -606
- package/bin/pi-webui-launcher.mjs +22 -0
- package/bin/pi-webui-update-supervisor.mjs +86 -0
- package/bin/pi-webui.mjs +558 -524
- package/index.ts +8 -5
- package/lib/component-update-state.mjs +21 -0
- package/lib/git-workflow-preferences.mjs +17 -2
- package/lib/optional-feature-catalog.mjs +1 -0
- package/lib/sampling-parameter-capabilities.mjs +160 -0
- package/lib/session-summary-preferences.mjs +16 -1
- package/lib/subagent-launch-slots.mjs +14 -2
- package/lib/trust-boundaries.mjs +3 -0
- package/lib/update/executor.mjs +99 -0
- package/lib/update/journal.mjs +175 -0
- package/lib/update/owners.mjs +70 -0
- package/lib/update/plan.mjs +134 -0
- package/lib/update/resolver.mjs +168 -0
- package/lib/update/supervisor.mjs +238 -0
- package/lib/update/verify.mjs +52 -0
- package/lib/update-commands.mjs +25 -13
- package/lib/webui-workspaces.mjs +17 -1
- package/package.json +4 -4
- package/public/app.js +1290 -82
- package/public/index.html +124 -48
- package/public/middle-button-drag-scroll.mjs +154 -0
- package/public/sampling-parameter-controls.mjs +361 -0
- package/public/service-worker.js +3 -1
- package/public/styles.css +417 -1
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-deck-component-updates.spec.mjs +20 -22
- package/tests/browser/middle-button-drag-scroll.spec.mjs +145 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +68 -23
- package/tests/browser/sampling-tooltip.spec.mjs +228 -0
- package/tests/browser/update-reconnect.spec.mjs +92 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/common-options-submenus-interaction-static.test.mjs +172 -0
- package/tests/common-options-submenus-markup-static.test.mjs +152 -0
- package/tests/component-update-api-static.test.mjs +22 -61
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +13 -237
- package/tests/durable-rpc-supervisor-harness.test.mjs +3 -1
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +49 -0
- package/tests/fixtures/fake-pi.mjs +66 -0
- package/tests/fixtures/update/tree-timeout-descendant.mjs +6 -0
- package/tests/fixtures/update/tree-timeout-parent.mjs +11 -0
- package/tests/git-footer-context-menu-static.test.mjs +58 -0
- package/tests/http-endpoints-harness.test.mjs +68 -18
- package/tests/middle-button-drag-scroll-static.test.mjs +24 -0
- package/tests/middle-button-drag-scroll.test.mjs +170 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +4 -4
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +23 -21
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +9 -5
- package/tests/persistent-ui-layout-static.test.mjs +13 -2
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +34 -0
- package/tests/rpc-supervisor-host.test.mjs +11 -2
- package/tests/safety-guard-auto-review-harness.test.mjs +117 -0
- package/tests/safety-guard-auto-review-static.test.mjs +34 -0
- package/tests/sampling-native-controls-user-flow.test.mjs +752 -0
- package/tests/sampling-parameter-capabilities.test.mjs +167 -0
- package/tests/sampling-parameter-controls.test.mjs +241 -0
- package/tests/session-sampling-helper.test.mjs +228 -0
- package/tests/session-sampling-http.test.mjs +168 -0
- package/tests/session-sampling-ui-static.test.mjs +370 -0
- package/tests/session-summary-core.test.mjs +24 -11
- package/tests/side-panel-section-height-removal-static.test.mjs +34 -0
- package/tests/side-panel-section-reorder-static.test.mjs +3 -3
- package/tests/staged-content-hash-contract.test.mjs +52 -11
- package/tests/subagent-launch-slots.test.mjs +18 -1
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/ui-layout-settings.test.mjs +18 -1
- package/tests/update-api-harness.test.mjs +111 -0
- package/tests/update-commands.test.mjs +15 -45
- package/tests/update-executor-process-tree-harness.test.mjs +22 -0
- package/tests/update-journal-harness.test.mjs +59 -0
- package/tests/update-lock-multiprocess-harness.test.mjs +46 -0
- package/tests/update-owners.test.mjs +27 -0
- package/tests/update-plan.test.mjs +58 -0
- package/tests/update-resolver.test.mjs +56 -0
- package/tests/update-supervisor-harness.test.mjs +57 -0
- package/tests/update-tab-restore-harness.test.mjs +24 -0
- package/tests/update-verify.test.mjs +31 -0
- package/tests/workspace-files-live-updates-static.test.mjs +13 -4
- package/webui-rpc-helper.mjs +119 -0
|
@@ -54,7 +54,7 @@ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFas
|
|
|
54
54
|
assert.match(readme, /### Compact live output mode[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "README should document Compact mode with the stable wire identifier");
|
|
55
55
|
assert.match(readme, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "README should separately document subscription Fast mode and its cost semantics");
|
|
56
56
|
// Intent preserved: browser-asset changes must advance the coherent cache tuple.
|
|
57
|
-
assert.match(serviceWorker, /pi-webui-pwa-
|
|
58
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
57
|
+
assert.match(serviceWorker, /pi-webui-pwa-v81/, "PWA cache identity should be bumped for changed browser assets");
|
|
58
|
+
assert.match(html, /data-app-src="\/app\.js\?v=120"/, "browser module URL should be cache-busted for Fast-mode wiring");
|
|
59
59
|
|
|
60
60
|
console.log("codex-fast-mode-static.test.mjs passed");
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
8
|
+
|
|
9
|
+
function functionBody(name) {
|
|
10
|
+
const signature = new RegExp(`function\\s+${name}\\s*\\(`, "m");
|
|
11
|
+
const match = signature.exec(app);
|
|
12
|
+
assert.ok(match, `${name} should remain a standalone Common Pi options helper`);
|
|
13
|
+
let parenDepth = 0;
|
|
14
|
+
let openBrace = -1;
|
|
15
|
+
for (let index = match.index + match[0].length - 1; index < app.length; index += 1) {
|
|
16
|
+
const char = app[index];
|
|
17
|
+
if (char === "(") parenDepth += 1;
|
|
18
|
+
else if (char === ")") parenDepth -= 1;
|
|
19
|
+
else if (char === "{" && parenDepth === 0) {
|
|
20
|
+
openBrace = index;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
assert.notEqual(openBrace, -1, `${name} body should open`);
|
|
25
|
+
let depth = 0;
|
|
26
|
+
for (let index = openBrace; index < app.length; index += 1) {
|
|
27
|
+
const char = app[index];
|
|
28
|
+
if (char === "{") depth += 1;
|
|
29
|
+
else if (char === "}") {
|
|
30
|
+
depth -= 1;
|
|
31
|
+
if (depth === 0) return app.slice(openBrace + 1, index);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
assert.fail(`${name} body should close`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function occurrences(pattern) {
|
|
38
|
+
return app.match(new RegExp(pattern, "g"))?.length ?? 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// --- Seam contract: submenu structure is discovered through stable data attributes ---
|
|
42
|
+
assert.match(app, /const OPTIONS_SUBMENU_GROUP_SELECTOR = "\[data-options-submenu\]";/, "submenu groups should use the structure worker's stable data attribute seam");
|
|
43
|
+
assert.match(app, /const OPTIONS_SUBMENU_TRIGGER_SELECTOR = "\[data-options-submenu-trigger\]";/, "group triggers should use the shared trigger seam");
|
|
44
|
+
assert.match(app, /const OPTIONS_SUBMENU_PANEL_SELECTOR = "\[data-options-submenu-panel\]";/, "group panels should use the shared panel seam");
|
|
45
|
+
assert.match(app, /const OPTIONS_SUBMENU_BACK_SELECTOR = "\[data-options-submenu-back\]";/, "mobile Back affordances should use the shared back seam");
|
|
46
|
+
assert.match(app, /const OPTIONS_SUBMENU_LEFT_CLASS = "opens-left";/, "viewport placement should use the structure worker's opens-left CSS hook");
|
|
47
|
+
assert.match(app, /let openOptionsSubmenuGroup = null;/, "exactly one submenu group may be tracked as open");
|
|
48
|
+
|
|
49
|
+
const submenuPanel = functionBody("optionsSubmenuPanel");
|
|
50
|
+
assert.match(submenuPanel, /aria-controls[\s\S]*document\.getElementById\(controlledId\)[\s\S]*OPTIONS_SUBMENU_PANEL_SELECTOR[\s\S]*'\[role="menu"\]'/, "panels should resolve via aria-controls with structural fallbacks");
|
|
51
|
+
|
|
52
|
+
// --- One open submenu and root-close cleanup ---
|
|
53
|
+
const setSubmenuOpen = functionBody("setOptionsSubmenuOpen");
|
|
54
|
+
assert.match(setSubmenuOpen, /if \(shouldOpen\) \{\s*for \(const sibling of optionsSubmenuGroups\(\)\) \{\s*if \(sibling !== group\) setOptionsSubmenuOpen\(sibling, false\);/, "opening one group should close every sibling group");
|
|
55
|
+
assert.match(setSubmenuOpen, /const shouldOpen = !!open && !trigger\?\.disabled && !trigger\?\.hidden && !group\.hidden;/, "hidden or disabled group triggers must not open");
|
|
56
|
+
assert.match(setSubmenuOpen, /trigger\?\.setAttribute\("aria-expanded", shouldOpen \? "true" : "false"\)/, "aria-expanded should stay synchronized with submenu state");
|
|
57
|
+
assert.match(setSubmenuOpen, /if \(panel\) panel\.hidden = !shouldOpen;/, "closed submenu panels should be hidden and unfocusable");
|
|
58
|
+
assert.match(setSubmenuOpen, /if \(shouldOpen && focusFirstItem\) focusOptionsMenuItem\(optionsSubmenuItems\(group\)\[0\]\);/, "opening with keyboard/tap intent should focus the first submenu item");
|
|
59
|
+
assert.match(setSubmenuOpen, /if \(!shouldOpen && restoreFocus\) focusOptionsMenuItem\(trigger\);/, "closing a submenu should restore focus to its trigger");
|
|
60
|
+
assert.match(setSubmenuOpen, /scheduleMobileDropdownScrollBoundsUpdate\(\);/, "submenu state changes should refresh bounded mobile dropdown heights");
|
|
61
|
+
|
|
62
|
+
const setMenuOpen = functionBody("setOptionsMenuOpen");
|
|
63
|
+
assert.match(setMenuOpen, /if \(optionsMenuOpen\) syncOptionsSubmenuAvailability\(\);\s*else closeOptionsSubmenus\(\);/, "opening the root should resync availability and closing it should reset nested state");
|
|
64
|
+
|
|
65
|
+
const closeSubmenus = functionBody("closeOptionsSubmenus");
|
|
66
|
+
assert.match(closeSubmenus, /for \(const group of optionsSubmenuGroups\(\)\) setOptionsSubmenuOpen\(group, false\);\s*openOptionsSubmenuGroup = null;/, "closing the root menu should close every nested group");
|
|
67
|
+
assert.match(closeSubmenus, /if \(restoreFocus && previous\) focusOptionsMenuItem\(optionsSubmenuTrigger\(previous\)\);/, "an explicit close may restore focus to the previously open trigger");
|
|
68
|
+
|
|
69
|
+
// --- Dynamic empty-group hiding ---
|
|
70
|
+
const syncAvailability = functionBody("syncOptionsSubmenuAvailability");
|
|
71
|
+
assert.match(syncAvailability, /if \(optionsSubmenuSyncing\) return;/, "availability synchronization should be re-entrancy safe");
|
|
72
|
+
assert.match(syncAvailability, /const unavailable = !available;[\s\S]*if \(group\.hidden !== unavailable\) group\.hidden = unavailable;[\s\S]*if \(trigger\.hidden !== unavailable\) trigger\.hidden = unavailable;[\s\S]*if \(trigger\.disabled !== unavailable\) trigger\.disabled = unavailable;/, "groups without visible children should be hidden and unfocusable without retriggering the attribute observer on unchanged state");
|
|
73
|
+
assert.match(syncAvailability, /if \(!available && openOptionsSubmenuGroup === group\) setOptionsSubmenuOpen\(group, false\);/, "an open group that loses every child should close");
|
|
74
|
+
|
|
75
|
+
const hasVisibleActions = functionBody("optionsSubmenuHasVisibleActions");
|
|
76
|
+
assert.match(hasVisibleActions, /!item\.hidden && !item\.disabled && item\.getAttribute\("aria-hidden"\) !== "true"/, "child visibility should follow hidden/disabled/aria-hidden state");
|
|
77
|
+
const actionItems = functionBody("optionsSubmenuActionItems");
|
|
78
|
+
assert.match(actionItems, /const back = optionsSubmenuBackButton\(group\);[\s\S]*filter\(\(item\) => item !== back\)/, "the Back affordance must not count as a visible group action");
|
|
79
|
+
const submenuItems = functionBody("optionsSubmenuItems");
|
|
80
|
+
assert.match(submenuItems, /const back = optionsSubmenuBackButton\(group\);[\s\S]*filter\(\(item\) => item !== back/, "arrow entry should focus the first action rather than the mobile-only Back item");
|
|
81
|
+
|
|
82
|
+
// --- Desktop pointer behavior and viewport direction ---
|
|
83
|
+
const initialize = functionBody("initializeOptionsSubmenus");
|
|
84
|
+
assert.match(initialize, /group\.addEventListener\("pointerenter", \(event\) => \{\s*if \(event\.pointerType === "touch" \|\| optionsSubmenuUsesDrillIn\(\)\) return;\s*setOptionsSubmenuOpen\(group, true\);/, "hover flyouts should be desktop-only and never required on touch");
|
|
85
|
+
assert.match(initialize, /group\.addEventListener\("pointerleave", \(event\) => \{[\s\S]*if \(group\.contains\(document\.activeElement\)\) return;\s*setOptionsSubmenuOpen\(group, false\);/, "pointer leave should not close a group that still holds focus");
|
|
86
|
+
assert.match(initialize, /elements\.optionsMenu\.addEventListener\("click", handleOptionsSubmenuClick\);/, "submenu open state should be click-driven");
|
|
87
|
+
assert.match(initialize, /elements\.optionsMenu\.addEventListener\("keydown", handleOptionsMenuKeydown\);/, "keyboard navigation should be bound to the root menu panel");
|
|
88
|
+
assert.match(initialize, /new MutationObserver\(\(\) => syncOptionsSubmenuAvailability\(\)\)[\s\S]*attributeFilter: \["hidden", "disabled", "aria-hidden"\]/, "conditional child visibility changes should resynchronize group availability");
|
|
89
|
+
assert.match(initialize, /window\.addEventListener\("resize", \(\) => \{\s*if \(openOptionsSubmenuGroup\) updateOptionsSubmenuPlacement\(openOptionsSubmenuGroup\);/, "viewport changes should re-evaluate submenu placement");
|
|
90
|
+
assert.match(initialize, /if \(!elements\.optionsMenu \|\| !groups\.length\) return;/, "the interaction layer should no-op when no submenu groups exist");
|
|
91
|
+
|
|
92
|
+
const placement = functionBody("updateOptionsSubmenuPlacement");
|
|
93
|
+
assert.match(placement, /if \(optionsSubmenuUsesDrillIn\(\)\) \{[\s\S]*classList\.remove\(OPTIONS_SUBMENU_LEFT_CLASS\)/, "drill-in layouts should not carry desktop flyout direction");
|
|
94
|
+
assert.match(placement, /const flipLeft = panelWidth > 0 && spaceRight < panelWidth && anchorRect\.left > spaceRight;/, "flyouts should flip left only when the right edge cannot fit the panel");
|
|
95
|
+
assert.match(placement, /group\.classList\.toggle\(OPTIONS_SUBMENU_LEFT_CLASS, flipLeft\);\s*panel\.classList\.toggle\(OPTIONS_SUBMENU_LEFT_CLASS, flipLeft\);/, "direction state should be exposed on the group and the panel");
|
|
96
|
+
|
|
97
|
+
const drillIn = functionBody("optionsSubmenuUsesDrillIn");
|
|
98
|
+
assert.match(drillIn, /if \(isMobileView\(\)\) return true;[\s\S]*OPTIONS_SUBMENU_DRILL_IN_QUERY/, "narrow and coarse-pointer viewports should use tap-driven drill-in");
|
|
99
|
+
assert.match(app, /const OPTIONS_SUBMENU_DRILL_IN_QUERY = "\(hover: none\), \(pointer: coarse\)";/, "drill-in detection should cover hover-less and coarse pointers");
|
|
100
|
+
|
|
101
|
+
// --- Equal-width selections and overflow-only font fitting ---
|
|
102
|
+
assert.match(app, /const OPTIONS_MENU_LABEL_MIN_FONT_SIZE_PX = 12;/, "automatic label fitting should retain a readable minimum font size");
|
|
103
|
+
const fitLabels = functionBody("fitOptionsMenuLabels");
|
|
104
|
+
assert.match(fitLabels, /style\.removeProperty\(OPTIONS_MENU_LABEL_FONT_SIZE_PROPERTY\)[\s\S]*const availableWidth = label\.clientWidth;[\s\S]*const requiredWidth = label\.scrollWidth;/, "each fit pass should restore the natural size before measuring real overflow");
|
|
105
|
+
assert.match(fitLabels, /if \(availableWidth <= 0 \|\| requiredWidth <= availableWidth \+ 0\.5\) continue;/, "labels that already fit should keep their natural font size");
|
|
106
|
+
assert.match(fitLabels, /Math\.max\([\s\S]*OPTIONS_MENU_LABEL_MIN_FONT_SIZE_PX,[\s\S]*baseFontSize \* \(availableWidth \/ requiredWidth\) \* 98/, "overflowing labels should shrink proportionally without crossing the readable minimum");
|
|
107
|
+
assert.match(fitLabels, /style\.setProperty\(OPTIONS_MENU_LABEL_FONT_SIZE_PROPERTY, `\$\{fittedFontSize\}px`\)/, "fitted labels should use the CSS font-size hook without changing button padding");
|
|
108
|
+
const scheduleLabelFit = functionBody("scheduleOptionsMenuLabelFit");
|
|
109
|
+
assert.match(scheduleLabelFit, /window\.cancelAnimationFrame\(optionsMenuLabelFitFrame\)[\s\S]*window\.requestAnimationFrame\([\s\S]*fitOptionsMenuLabels\(\)/, "label measurement should be coalesced until after layout");
|
|
110
|
+
assert.match(setMenuOpen, /if \(optionsMenuOpen\) scheduleOptionsMenuLabelFit\(\);/, "opening the root should fit visible labels");
|
|
111
|
+
assert.match(setSubmenuOpen, /if \(shouldOpen\) scheduleOptionsMenuLabelFit\(\);/, "opening a child panel should fit newly visible labels");
|
|
112
|
+
assert.match(initialize, /rootMenuContainer\?\.addEventListener\("pointerenter", scheduleOptionsMenuLabelFit\);[\s\S]*rootMenuContainer\?\.addEventListener\("focusin", scheduleOptionsMenuLabelFit\);/, "CSS hover/focus-opened root menus should also fit their visible labels");
|
|
113
|
+
assert.match(initialize, /window\.addEventListener\("resize", \(\) => \{[\s\S]*scheduleOptionsMenuLabelFit\(\);/, "viewport changes should refit visible labels");
|
|
114
|
+
|
|
115
|
+
// --- Tap-driven drill-in and Back behavior ---
|
|
116
|
+
const click = functionBody("handleOptionsSubmenuClick");
|
|
117
|
+
assert.match(click, /const back = event\.target\?\.closest\?\.\(OPTIONS_SUBMENU_BACK_SELECTOR\);[\s\S]*setOptionsSubmenuOpen\(back\.closest\(OPTIONS_SUBMENU_GROUP_SELECTOR\), false, \{ restoreFocus: true \}\);/, "Back should return to the root page and restore trigger focus");
|
|
118
|
+
assert.match(click, /const shouldOpen = openOptionsSubmenuGroup !== group;\s*setOptionsSubmenuOpen\(group, shouldOpen, \{ focusFirstItem: shouldOpen \}\);/, "tapping a group trigger should toggle its page and focus its first item");
|
|
119
|
+
assert.match(click, /event\.preventDefault\(\);\s*event\.stopPropagation\(\);/, "trigger and Back activation must not fall through to action handling");
|
|
120
|
+
|
|
121
|
+
// --- Keyboard navigation, nested Escape, focus restoration ---
|
|
122
|
+
const keydown = functionBody("handleOptionsMenuKeydown");
|
|
123
|
+
assert.match(keydown, /const items = panelGroup \? optionsSubmenuItems\(panelGroup\) : optionsMenuRootItems\(\);/, "arrow navigation should stay inside the focused level");
|
|
124
|
+
assert.match(keydown, /if \(event\.key === "ArrowDown" \|\| event\.key === "ArrowUp"\) \{\s*event\.preventDefault\(\);\s*moveOptionsMenuFocus\(items, index, event\.key === "ArrowDown" \? 1 : -1\);/, "Down/Up should move focus within the current level");
|
|
125
|
+
assert.match(keydown, /if \(event\.key === "Home" \|\| event\.key === "End"\) \{\s*event\.preventDefault\(\);\s*focusOptionsMenuItem\(event\.key === "Home" \? items\[0\] : items\[items\.length - 1\]\);/, "Home/End should jump to the first/last item of the current level");
|
|
126
|
+
assert.match(keydown, /if \(event\.key === "ArrowRight"\) \{[\s\S]*optionsSubmenuTrigger\(group\) === target[\s\S]*setOptionsSubmenuOpen\(group, true, \{ focusFirstItem: true \}\);/, "Right should enter a group and focus its first item");
|
|
127
|
+
assert.match(keydown, /if \(event\.key === "ArrowLeft"\) \{\s*if \(!panelGroup\) return;\s*event\.preventDefault\(\);\s*setOptionsSubmenuOpen\(panelGroup, false, \{ restoreFocus: true \}\);/, "Left should leave a group and restore focus to its trigger");
|
|
128
|
+
assert.match(keydown, /if \(panelGroup \|\| openOptionsSubmenuGroup\) \{[\s\S]*event\.preventDefault\(\);\s*event\.stopPropagation\(\);[\s\S]*if \(panelGroup\) setOptionsSubmenuOpen\(panelGroup, false, \{ restoreFocus: true \}\);\s*else closeOptionsSubmenus\(\{ restoreFocus: true \}\);/, "Escape should close only the deepest open level and keep the root menu open");
|
|
129
|
+
assert.match(keydown, /closeOptionsSubmenus\(\);\s*focusOptionsMenuItem\(elements\.optionsMenuButton\);/, "Escape at root level should defer to the root close handler and restore focus to the menu button");
|
|
130
|
+
|
|
131
|
+
const moveFocus = functionBody("moveOptionsMenuFocus");
|
|
132
|
+
assert.match(moveFocus, /\(currentIndex \+ offset \+ items\.length\) % items\.length/, "arrow navigation should wrap within the level");
|
|
133
|
+
|
|
134
|
+
const rootItems = functionBody("optionsMenuRootItems");
|
|
135
|
+
assert.match(rootItems, /filter\(\(item\) => !isOptionsSubmenuPanelItem\(item\) && isVisibleOptionsMenuItem\(item\)\)/, "root navigation should skip submenu children and invisible items");
|
|
136
|
+
const visibleItem = functionBody("isVisibleOptionsMenuItem");
|
|
137
|
+
assert.match(visibleItem, /if \(!item \|\| item\.hidden \|\| item\.disabled\) return false;[\s\S]*aria-hidden[\s\S]*!item\.closest\?\.\("\[hidden\]"\)/, "items inside hidden groups should never receive focus");
|
|
138
|
+
|
|
139
|
+
assert.match(app, /elements\.optionsMenuButton\.addEventListener\("keydown", \(event\) => \{\s*if \(event\.key !== "ArrowDown" && event\.key !== "ArrowUp"\) return;[\s\S]*setOptionsMenuOpen\(true\);[\s\S]*focusOptionsMenuItem\(event\.key === "ArrowDown" \? items\[0\] : items\[items\.length - 1\]\);/, "Down/Up on the root trigger should open the menu and enter it");
|
|
140
|
+
assert.match(app, /initializeOptionsSubmenus\(\);/, "the submenu interaction layer should be initialized with the other composer menu listeners");
|
|
141
|
+
|
|
142
|
+
// --- Preservation: existing action handlers keep their identity and stay unduplicated ---
|
|
143
|
+
for (const [id, handler] of [
|
|
144
|
+
["optionsCommandPaletteButton", "openCommandPalette\\(\\)"],
|
|
145
|
+
["optionsConversationModeButton", "toggleNaturalConversationMode\\(\\)"],
|
|
146
|
+
["optionsResumeButton", 'runNativeCommandMenu\\("/resume"\\)'],
|
|
147
|
+
["optionsReloadButton", 'runNativeCommandMenu\\("/reload"\\)'],
|
|
148
|
+
["optionsRemoteButton", 'runNativeCommandMenu\\("/remote"\\)'],
|
|
149
|
+
["optionsNameButton", 'runNativeCommandMenu\\("/name"\\)'],
|
|
150
|
+
["optionsCloneButton", 'runNativeCommandMenu\\("/clone"\\)'],
|
|
151
|
+
["optionsSettingsButton", 'runNativeCommandMenu\\("/settings"\\)'],
|
|
152
|
+
["optionsSummarySetupButton", 'runNativeCommandMenu\\("/summary-setup"\\)'],
|
|
153
|
+
["optionsWorkflowSetupButton", 'runNativeCommandMenu\\("/workflow-setup"\\)'],
|
|
154
|
+
["optionsSafetyGuardSetupButton", 'runNativeCommandMenu\\("/safety-guard-setup"\\)'],
|
|
155
|
+
["optionsGitWorkflowSetupButton", 'runNativeCommandMenu\\("/git-workflow-setup"\\)'],
|
|
156
|
+
["optionsExportButton", 'runNativeCommandMenu\\("/export"\\)'],
|
|
157
|
+
["optionsForkButton", 'runNativeCommandMenu\\("/fork"\\)'],
|
|
158
|
+
["optionsTreeButton", 'runNativeCommandMenu\\("/tree"\\)'],
|
|
159
|
+
["optionsStatsButton", "openStatsOverlay\\(\\{ refresh: true \\}\\)"],
|
|
160
|
+
["optionsFooterVisibilityButton", "openGitFooterVisibilityDialog"],
|
|
161
|
+
]) {
|
|
162
|
+
assert.match(app, new RegExp(`elements\\.${id}\\??\\.addEventListener\\("click", [^\\n]*${handler}`), `${id} should keep its existing action handler`);
|
|
163
|
+
assert.equal(occurrences(`elements\\.${id}\\??\\.addEventListener\\("click"`), 1, `${id} should be bound exactly once`);
|
|
164
|
+
assert.equal(occurrences(` ${id}: \\$\\("#${id}"\\),`), 1, `${id} should keep exactly one element reference`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
assert.equal(occurrences('elements\\.optionsMenu\\.addEventListener\\("click"'), 1, "the submenu delegate should be bound exactly once");
|
|
168
|
+
assert.equal(occurrences('elements\\.optionsMenu\\.addEventListener\\("keydown"'), 1, "the submenu key handler should be bound exactly once");
|
|
169
|
+
assert.equal(occurrences("function initializeOptionsSubmenus\\(\\)"), 1, "the initializer should be defined exactly once");
|
|
170
|
+
assert.equal(occurrences("\\ninitializeOptionsSubmenus\\(\\);\\n"), 1, "the initializer should be invoked exactly once");
|
|
171
|
+
|
|
172
|
+
console.log("common options submenus interaction static checks passed");
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const [html, css] = await Promise.all([
|
|
8
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
9
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const actionContract = {
|
|
13
|
+
optionsCommandPaletteButton: { label: "Command Palette" },
|
|
14
|
+
optionsSettingsButton: { label: "Settings", command: "/settings" },
|
|
15
|
+
optionsConversationModeButton: { label: "Start Natural Conversation", command: "/talk", hidden: true },
|
|
16
|
+
optionsResumeButton: { label: "Resume Session", command: "/resume" },
|
|
17
|
+
optionsNameButton: { label: "Name Session", command: "/name" },
|
|
18
|
+
optionsCloneButton: { label: "Clone Session", command: "/clone" },
|
|
19
|
+
optionsForkButton: { label: "Fork", command: "/fork" },
|
|
20
|
+
optionsTreeButton: { label: "Tree", command: "/tree" },
|
|
21
|
+
optionsExportButton: { label: "Export", command: "/export" },
|
|
22
|
+
optionsSummarySetupButton: { label: "Session Summary Setup", command: "/summary-setup", hidden: true },
|
|
23
|
+
optionsGitWorkflowSetupButton: { label: "Guided Git Setup", command: "/git-workflow-setup" },
|
|
24
|
+
optionsWorkflowSetupButton: { label: "Workflow Permission Setup", command: "/workflow-setup", hidden: true },
|
|
25
|
+
optionsSafetyGuardSetupButton: { label: "Safety Guard Setup", command: "/safety-guard-setup", hidden: true },
|
|
26
|
+
optionsStatsButton: { label: "Stats Dashboard", command: "/stats-webui", hidden: true },
|
|
27
|
+
optionsFooterVisibilityButton: { label: "Git-footer Visibility", hidden: true },
|
|
28
|
+
optionsRemoteButton: { label: "Open Remote", command: "/remote", hidden: true },
|
|
29
|
+
optionsReloadButton: { label: "Reload Pi", command: "/reload" },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const groups = [
|
|
33
|
+
{
|
|
34
|
+
key: "session",
|
|
35
|
+
label: "Session",
|
|
36
|
+
triggerId: "optionsSessionSubmenuButton",
|
|
37
|
+
panelId: "optionsSessionSubmenu",
|
|
38
|
+
actions: ["optionsResumeButton", "optionsNameButton", "optionsCloneButton", "optionsForkButton", "optionsTreeButton", "optionsExportButton"],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: "feature-setup",
|
|
42
|
+
label: "Feature Setup",
|
|
43
|
+
triggerId: "optionsFeatureSetupSubmenuButton",
|
|
44
|
+
panelId: "optionsFeatureSetupSubmenu",
|
|
45
|
+
actions: ["optionsSummarySetupButton", "optionsGitWorkflowSetupButton"],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "safety-permissions",
|
|
49
|
+
label: "Safety & Permissions",
|
|
50
|
+
triggerId: "optionsSafetyPermissionsSubmenuButton",
|
|
51
|
+
panelId: "optionsSafetyPermissionsSubmenu",
|
|
52
|
+
actions: ["optionsWorkflowSetupButton", "optionsSafetyGuardSetupButton"],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "view-diagnostics",
|
|
56
|
+
label: "View & Diagnostics",
|
|
57
|
+
triggerId: "optionsViewDiagnosticsSubmenuButton",
|
|
58
|
+
panelId: "optionsViewDiagnosticsSubmenu",
|
|
59
|
+
actions: ["optionsStatsButton", "optionsFooterVisibilityButton"],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: "remote-system",
|
|
63
|
+
label: "Remote & System",
|
|
64
|
+
triggerId: "optionsRemoteSystemSubmenuButton",
|
|
65
|
+
panelId: "optionsRemoteSystemSubmenu",
|
|
66
|
+
actions: ["optionsRemoteButton", "optionsReloadButton"],
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
function escapeRegExp(value) {
|
|
71
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function buttonMarkup(id) {
|
|
75
|
+
const match = html.match(new RegExp(`<button\\b[^>]*\\bid="${escapeRegExp(id)}"[^>]*>[\\s\\S]*?<\\/button>`));
|
|
76
|
+
assert.ok(match, `${id} should exist as a button`);
|
|
77
|
+
return match[0];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const menuStart = html.indexOf('<div id="optionsMenu"');
|
|
81
|
+
const menuEnd = html.indexOf('<div id="appRunnerMenu"', menuStart);
|
|
82
|
+
assert.ok(menuStart >= 0 && menuEnd > menuStart, "the Common Pi options block should remain bounded by its stable IDs");
|
|
83
|
+
const menuMarkup = html.slice(menuStart, menuEnd);
|
|
84
|
+
assert.match(menuMarkup, /^<div id="optionsMenu"[^>]*role="menu"[^>]*aria-label="Common Pi options">/, "the root should remain a labelled menu");
|
|
85
|
+
|
|
86
|
+
const allActionIds = Object.keys(actionContract);
|
|
87
|
+
for (const [id, contract] of Object.entries(actionContract)) {
|
|
88
|
+
assert.equal((html.match(new RegExp(`\\bid="${escapeRegExp(id)}"`, "g")) || []).length, 1, `${id} should occur exactly once`);
|
|
89
|
+
const button = buttonMarkup(id);
|
|
90
|
+
assert.match(button, /\brole="menuitem"/, `${id} should retain menuitem semantics`);
|
|
91
|
+
assert.match(button, new RegExp(`<span>${escapeRegExp(contract.label)}<\\/span>`), `${id} should retain its label`);
|
|
92
|
+
if (contract.command) assert.match(button, new RegExp(`\\bdata-command="${escapeRegExp(contract.command)}"`), `${id} should retain ${contract.command}`);
|
|
93
|
+
else assert.doesNotMatch(button, /\bdata-command=/, `${id} should not gain a command contract`);
|
|
94
|
+
if (contract.hidden) assert.match(button, /\shidden(?:\s|>)/, `${id} should retain its conditional hidden default`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const firstGroupStart = menuMarkup.indexOf('<div class="composer-options-submenu"');
|
|
98
|
+
const rootQuickActionMarkup = menuMarkup.slice(0, firstGroupStart);
|
|
99
|
+
const rootQuickActions = allActionIds.filter((id) => rootQuickActionMarkup.includes(`id="${id}"`));
|
|
100
|
+
assert.deepEqual(rootQuickActions, ["optionsCommandPaletteButton", "optionsSettingsButton", "optionsConversationModeButton"], "only the three approved quick actions should remain at the root");
|
|
101
|
+
|
|
102
|
+
for (let index = 0; index < groups.length; index += 1) {
|
|
103
|
+
const group = groups[index];
|
|
104
|
+
const wrapperMarker = `<div class="composer-options-submenu" role="none" data-options-submenu="${group.key}">`;
|
|
105
|
+
const groupStart = menuMarkup.indexOf(wrapperMarker);
|
|
106
|
+
const nextStart = index + 1 < groups.length
|
|
107
|
+
? menuMarkup.indexOf(`<div class="composer-options-submenu" role="none" data-options-submenu="${groups[index + 1].key}">`, groupStart)
|
|
108
|
+
: menuMarkup.length;
|
|
109
|
+
assert.ok(groupStart >= 0 && nextStart > groupStart, `${group.label} should have one semantic group wrapper`);
|
|
110
|
+
const groupMarkup = menuMarkup.slice(groupStart, nextStart);
|
|
111
|
+
const trigger = buttonMarkup(group.triggerId);
|
|
112
|
+
|
|
113
|
+
assert.equal((html.match(new RegExp(`\\bid="${group.triggerId}"`, "g")) || []).length, 1, `${group.triggerId} should be stable and unique`);
|
|
114
|
+
assert.equal((html.match(new RegExp(`\\bid="${group.panelId}"`, "g")) || []).length, 1, `${group.panelId} should be stable and unique`);
|
|
115
|
+
assert.match(trigger, /\bclass="[^"]*composer-options-submenu-trigger[^"]*"/, `${group.label} should expose the trigger behavior hook`);
|
|
116
|
+
assert.match(trigger, /\brole="menuitem"/, `${group.label} trigger should be a menuitem`);
|
|
117
|
+
assert.match(trigger, /\baria-haspopup="menu"/, `${group.label} trigger should announce its submenu`);
|
|
118
|
+
assert.match(trigger, /\baria-expanded="false"/, `${group.label} trigger should start collapsed`);
|
|
119
|
+
assert.match(trigger, new RegExp(`\\baria-controls="${group.panelId}"`), `${group.label} trigger should control its panel`);
|
|
120
|
+
assert.match(trigger, /\bdata-options-submenu-trigger(?:\s|>)/, `${group.label} trigger should expose the JS hook`);
|
|
121
|
+
assert.match(trigger, new RegExp(`<span>${escapeRegExp(group.label)}<\\/span>`), `${group.label} trigger should retain the approved group label`);
|
|
122
|
+
assert.match(groupMarkup, new RegExp(`<div id="${group.panelId}" class="composer-options-submenu-panel" role="menu" aria-labelledby="${group.triggerId}" data-options-submenu-panel>`), `${group.label} panel should be labelled by its trigger`);
|
|
123
|
+
assert.match(groupMarkup, /class="[^"]*composer-options-submenu-back[^"]*"[^>]*role="menuitem"[^>]*data-options-submenu-back[\s\S]*?<span>Back<\/span>/, `${group.label} should contain an explicit Back menuitem`);
|
|
124
|
+
|
|
125
|
+
const actualActions = allActionIds
|
|
126
|
+
.filter((id) => groupMarkup.includes(`id="${id}"`))
|
|
127
|
+
.sort((left, right) => groupMarkup.indexOf(`id="${left}"`) - groupMarkup.indexOf(`id="${right}"`));
|
|
128
|
+
assert.deepEqual(actualActions, group.actions, `${group.label} should contain exactly its approved actions in order`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
assert.equal((menuMarkup.match(/\bdata-options-submenu="/g) || []).length, 5, "there should be exactly five submenu groups");
|
|
132
|
+
assert.equal((menuMarkup.match(/\bdata-options-submenu-back(?:\s|>)/g) || []).length, 5, "every group should have exactly one Back action");
|
|
133
|
+
assert.equal((menuMarkup.match(/\bdata-options-submenu-panel(?:\s|>)/g) || []).length, 5, "every group should have exactly one panel behavior hook");
|
|
134
|
+
|
|
135
|
+
assert.match(css, /\.composer-options-menu-panel\s*\{[\s\S]*?--composer-options-selection-width: min\(13\.5rem, calc\(100vw - 2rem\)\);[\s\S]*?width: var\(--composer-options-selection-width\);[\s\S]*?min-width: var\(--composer-options-selection-width\);[\s\S]*?max-width: var\(--composer-options-selection-width\);/, "the root dropdown should use one explicit shared selection width");
|
|
136
|
+
assert.match(css, /\.composer-options-submenu-panel\s*\{[\s\S]*?position: absolute;[\s\S]*?width: 100%;[\s\S]*?min-width: 100%;[\s\S]*?max-width: 100%;[\s\S]*?max-height: min\(60vh, 24rem\);[\s\S]*?overflow-y: auto;/, "desktop flyouts should match the root width and remain independently scroll-bounded");
|
|
137
|
+
assert.match(css, /\.composer-options-menu-item\s*\{[\s\S]*?box-sizing: border-box;[\s\S]*?width: 100%;[\s\S]*?min-width: 0;[\s\S]*?max-width: 100%;[\s\S]*?padding-inline: 0\.78rem;/, "every root and nested selection should fill the shared width with consistent side padding");
|
|
138
|
+
assert.match(css, /\.composer-options-menu-item > span:not\(\[aria-hidden="true"\]\):not\(\.composer-options-submenu-chevron\)\s*\{[\s\S]*?min-width: 0;[\s\S]*?font-size: var\(--options-menu-label-font-size, inherit\);[\s\S]*?white-space: nowrap;/, "menu labels should expose a bounded font-size fitting hook without changing side padding");
|
|
139
|
+
assert.match(css, /\.composer-options-submenu\.opens-left > \.composer-options-submenu-panel,[\s\S]*?\.composer-options-submenu-panel\.opens-left\s*\{[\s\S]*?inset-inline: auto calc\(100% \+ 0\.3rem\);/, "desktop flyouts should expose an opens-left viewport hook");
|
|
140
|
+
assert.match(css, /@media \(hover: hover\) and \(pointer: fine\)\s*\{[\s\S]*?\.composer-options-submenu:hover > \.composer-options-submenu-panel,[\s\S]*?\.composer-options-submenu:focus-within > \.composer-options-submenu-panel/, "fine pointers should receive hover/focus flyouts");
|
|
141
|
+
|
|
142
|
+
const drillInRuleIndex = css.indexOf(".composer-options-menu-panel.submenu-open");
|
|
143
|
+
const drillInMediaIndex = css.lastIndexOf("@media", drillInRuleIndex);
|
|
144
|
+
assert.ok(drillInRuleIndex > 0 && drillInMediaIndex > 0, "mobile drill-in rules should exist inside a media query");
|
|
145
|
+
const drillInCss = css.slice(drillInMediaIndex, css.indexOf(" .command-suggest {", drillInRuleIndex));
|
|
146
|
+
assert.match(drillInCss, /^@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\)/, "narrow and coarse-pointer layouts should share the drill-in contract");
|
|
147
|
+
assert.match(drillInCss, /\.composer-options-submenu-panel,[\s\S]*?position: absolute;[\s\S]*?inset: 0;[\s\S]*?max-height: 100%;[\s\S]*?overflow-y: auto;/, "mobile child pages should fill the bounded root panel and scroll internally");
|
|
148
|
+
assert.match(drillInCss, /\.composer-options-submenu-trigger,[\s\S]*?\.composer-options-submenu-panel > \.composer-options-menu-item\s*\{\s*min-height: 44px;/, "mobile triggers, Back actions, and child actions should meet the 44px target minimum");
|
|
149
|
+
assert.match(drillInCss, /\.composer-options-submenu-back\s*\{[\s\S]*?display: inline-flex;/, "mobile child pages should visibly expose their Back action");
|
|
150
|
+
assert.match(drillInCss, /\.composer-options-submenu:hover > \.composer-options-submenu-panel,[\s\S]*?display: none;[\s\S]*?aria-expanded="true"\] \+ \.composer-options-submenu-panel[\s\S]*?display: flex;/, "mobile drill-in should depend on explicit state rather than hover");
|
|
151
|
+
|
|
152
|
+
console.log("Common Pi options submenu markup and responsive CSS contract verified.");
|
|
@@ -3,65 +3,26 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const server
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
);
|
|
14
|
-
assert.match(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
assert.match(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
assert.match(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
assert.match(
|
|
30
|
-
server,
|
|
31
|
-
/async function resolveComponentUpdateTasks\(target\)[\s\S]*target === "pi"[\s\S]*resolvePiUpdateCommands\(\{ all: false \}\)[\s\S]*target === "webui"[\s\S]*currentWebuiComponentUpdateTask/,
|
|
32
|
-
"component resolution should keep Pi-only and WebUI-only paths separate",
|
|
33
|
-
);
|
|
34
|
-
assert.match(
|
|
35
|
-
server,
|
|
36
|
-
/async function currentWebuiComponentUpdateTask\(npmRuntime = \{\}\)[\s\S]*webuiComponentUpdateUnavailableReason\(\)[\s\S]*global Bun Web UI package[\s\S]*`\$\{WEBUI_PACKAGE\}@latest`[\s\S]*npmPrefixUpdateTask\("current Web UI package", installRoot, \[WEBUI_PACKAGE\], npmRuntime\)/,
|
|
37
|
-
"Web UI updates should refuse source mode and update only the Web UI package in supported Bun/npm topologies",
|
|
38
|
-
);
|
|
39
|
-
assert.match(
|
|
40
|
-
server,
|
|
41
|
-
/function webuiComponentUpdateUnavailableReason\(\)[\s\S]*webuiDevServer \|\| !String\(packageRoot\).*includes\("node_modules"\)[\s\S]*source or development checkout/,
|
|
42
|
-
"source and development checkouts should fail closed",
|
|
43
|
-
);
|
|
44
|
-
assert.match(
|
|
45
|
-
server,
|
|
46
|
-
/target === "webui"[\s\S]*let npmRuntime = \{\}[\s\S]*resolvePiUpdateCommands\(\{ all: false \}\)[\s\S]*preferredDirectories:[\s\S]*piInstallDirectory[\s\S]*catch[\s\S]*webui_component_update_npm_resolution_fallback[\s\S]*currentWebuiComponentUpdateTask\(npmRuntime\)/,
|
|
47
|
-
"the Web UI updater should prefer npm from the selected Pi installation and fall back when Pi resolution is unavailable",
|
|
48
|
-
);
|
|
49
|
-
assert.match(
|
|
50
|
-
server,
|
|
51
|
-
/url\.pathname === "\/api\/update" && req\.method === "POST"[\s\S]*runPiUpdateAndPrepareRestart\(\{ all: queryAll \|\| bodyAll \}\)[\s\S]*sendJson\(res, 200[\s\S]*shutdown\("api update", \{ preserveSessions: true \}\)/,
|
|
52
|
-
"the legacy update route should retain update-all selection, 200 completion, restart, and session preservation",
|
|
53
|
-
);
|
|
54
|
-
const targetedWebuiUpdater = server.match(/async function currentWebuiComponentUpdateTask\([^)]*\)[\s\S]*?\n}\n\nasync function resolveComponentUpdateTasks/)?.[0];
|
|
55
|
-
assert.ok(targetedWebuiUpdater, "the targeted Web UI updater source should be inspectable");
|
|
56
|
-
assert.doesNotMatch(
|
|
57
|
-
targetedWebuiUpdater,
|
|
58
|
-
/UPDATE_PACKAGE_NAMES|packagesPresentInInstallPrefix|optionalFeature|projectPackageRoot/,
|
|
59
|
-
"the targeted Web UI updater must not broaden into package-root or optional package updates",
|
|
60
|
-
);
|
|
61
|
-
assert.match(
|
|
62
|
-
server,
|
|
63
|
-
/catch \(error\) \{\n\s*updateStatusCache = null;\n\s*updateStatusCacheAt = 0;\n\s*componentUpdateState\.fail/,
|
|
64
|
-
"failed component updates should invalidate cached package status before publishing terminal state",
|
|
65
|
-
);
|
|
66
|
-
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const [server, state, launcher, activation, trust] = await Promise.all([
|
|
8
|
+
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
9
|
+
readFile(join(root, "lib", "component-update-state.mjs"), "utf8"),
|
|
10
|
+
readFile(join(root, "bin", "pi-webui-launcher.mjs"), "utf8"),
|
|
11
|
+
readFile(join(root, "bin", "pi-webui-update-supervisor.mjs"), "utf8"),
|
|
12
|
+
readFile(join(root, "lib", "trust-boundaries.mjs"), "utf8"),
|
|
13
|
+
]);
|
|
14
|
+
assert.match(state, /validateUpdatePlanRequest[\s\S]*targets must contain one or both exact values/);
|
|
15
|
+
assert.match(state, /validateUpdateApplyRequest[\s\S]*Apply accepts only transactionId and planDigest/);
|
|
16
|
+
assert.match(server, /url\.pathname === "\/api\/update\/plan"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdatePlanRequest[\s\S]*sendJson\(res, 201/);
|
|
17
|
+
assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdateApplyRequest[\s\S]*applyServerOwnedUpdate/);
|
|
18
|
+
assert.match(server, /assertUpdatePlanDigest\(journal\.plan, planDigest\)[\s\S]*acquireInstallLock\(agentDir\)/);
|
|
19
|
+
assert.match(server, /assertPlanIdentity\(target, active\)/);
|
|
20
|
+
assert.match(server, /probeCandidateRuntime\(serverEntry, \{ expectedVersion: target\.metadata\.webuiVersion, expectedPiVersion: target\.metadata\.piVersion \}\)/);
|
|
21
|
+
assert.match(server, /Legacy update mutation is disabled/);
|
|
22
|
+
assert.match(server, /optionalFeaturePackageStatuses\(options\.cwd\)[\s\S]*strategy: "pi-owned-optional"[\s\S]*optionalFeature: true/);
|
|
23
|
+
assert.match(trust, /"\/api\/update\/plan"[\s\S]*"\/api\/update\/apply"[\s\S]*"\/api\/update\/rollback"/);
|
|
24
|
+
assert.match(server, /updateTransactionRoute && req\.method === "GET"[\s\S]*requireLocalhost\(req, "Viewing update transactions is only allowed from localhost"\)/);
|
|
25
|
+
assert.doesNotMatch(server, /function resolveUpdateTasks|function projectPackageRootUpdateTasks|function npmGlobalPackageRootUpdateTask|function bunGlobalPackageRootUpdateTask/);
|
|
26
|
+
assert.match(launcher, /readRuntimePointer\(agentDir, "current"\)[\s\S]*pointer\?\.serverEntry \|\| bootstrapServer/);
|
|
27
|
+
assert.match(activation, /switchRuntimePointer[\s\S]*waitForHealth[\s\S]*rollbackRuntimePointer/);
|
|
67
28
|
console.log("component update API static tests passed");
|
|
@@ -56,8 +56,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
|
|
|
56
56
|
assert.match(app, /event\.key === COMPOSER_ACTION_ORDER_STORAGE_KEY\) restoreComposerActionOrder\(\)[\s\S]*event\.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY\) restoreComposerActionSlotLayout\(\)/, "other tabs should apply persisted composer order and sparse-layout changes");
|
|
57
57
|
assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
|
|
58
58
|
|
|
59
|
-
assert.match(html, /styles\.css\?v=
|
|
60
|
-
assert.match(html, /app\.js\?v=
|
|
61
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
59
|
+
assert.match(html, /styles\.css\?v=104/, "changed composer styles should advance the stylesheet revision");
|
|
60
|
+
assert.match(html, /app\.js\?v=120/, "changed composer behavior should advance the app revision");
|
|
61
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81"/, "changed browser assets should advance the PWA cache identity");
|
|
62
62
|
|
|
63
63
|
console.log("composer-action-grid-reorder-static.test.mjs passed");
|