@firstpick/pi-package-webui 0.8.3 → 0.8.5

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.
Files changed (35) hide show
  1. package/README.md +67 -16
  2. package/bin/pi-webui.mjs +777 -131
  3. package/lib/WEBUI_TUI_NATIVE_PARITY.json +26 -0
  4. package/lib/optional-feature-catalog.mjs +29 -0
  5. package/lib/optional-feature-migration.mjs +410 -0
  6. package/lib/session-summary-core.mjs +320 -0
  7. package/lib/session-summary-preferences.mjs +267 -0
  8. package/package.json +5 -42
  9. package/public/app.js +1325 -51
  10. package/public/index.html +43 -1
  11. package/public/service-worker.js +1 -1
  12. package/public/styles.css +345 -1
  13. package/session-summary.ts +403 -0
  14. package/tests/aur-review-widget-static.test.mjs +3 -2
  15. package/tests/boot-failure-diagnostics.test.mjs +2 -2
  16. package/tests/browser/session-summary.spec.mjs +271 -0
  17. package/tests/codex-fast-mode-static.test.mjs +10 -9
  18. package/tests/composer-action-grid-reorder-static.test.mjs +2 -2
  19. package/tests/fast-mode-client-static.test.mjs +1 -1
  20. package/tests/feature-decision-output-popup-static.test.mjs +1 -1
  21. package/tests/http-endpoints-harness.test.mjs +429 -3
  22. package/tests/mobile-continuity-tablet-static.test.mjs +2 -2
  23. package/tests/mobile-foundation-static.test.mjs +2 -2
  24. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  25. package/tests/mobile-static.test.mjs +91 -92
  26. package/tests/native-parity-harness.test.mjs +9 -1
  27. package/tests/native-parity.test.mjs +23 -1
  28. package/tests/open-issue-wizard-static.test.mjs +1 -1
  29. package/tests/optional-feature-migration-frontend.test.mjs +75 -0
  30. package/tests/optional-feature-migration.test.mjs +142 -0
  31. package/tests/persistent-ui-layout-static.test.mjs +2 -2
  32. package/tests/questionnaire-dialog.test.mjs +2 -2
  33. package/tests/session-summary-core.test.mjs +491 -0
  34. package/tests/session-summary-preferences.test.mjs +103 -0
  35. package/tests/side-panel-section-reorder-static.test.mjs +2 -2
@@ -24,13 +24,17 @@ const [pkgRaw, html, css, app, server, extension, readme, startScript, manifestR
24
24
  ]);
25
25
  const pkg = JSON.parse(pkgRaw);
26
26
  const manifest = JSON.parse(manifestRaw);
27
- const lock = JSON.parse(await readFile(join(root, "package-lock.json"), "utf8"));
28
27
  const helper = await readFile(join(root, "webui-rpc-helper.mjs"), "utf8");
29
28
  const codexAuth = await readFile(join(root, "lib", "codex-usage-auth.mjs"), "utf8");
29
+ const optionalFeatureCatalog = await readFile(join(root, "lib", "optional-feature-catalog.mjs"), "utf8");
30
30
 
31
31
  function appFunctionSource(name, nextName) {
32
32
  const start = app.indexOf(`function ${name}(`);
33
- const end = app.indexOf(`\nfunction ${nextName}(`, start);
33
+ const nextStarts = [
34
+ app.indexOf(`\nfunction ${nextName}(`, start),
35
+ app.indexOf(`\nasync function ${nextName}(`, start),
36
+ ].filter((index) => index > start);
37
+ const end = nextStarts.length ? Math.min(...nextStarts) : -1;
34
38
  assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
35
39
  return app.slice(start, end);
36
40
  }
@@ -97,9 +101,22 @@ assert.match(html, /id="terminalTabsLayoutSelect"[\s\S]*<option value="left">Lef
97
101
  assert.match(html, /id="terminalTabsLayoutStatus"/, "terminal-tabs layout selector should expose status text");
98
102
  assert.match(html, /id="nativeCommandDialog"/, "native slash selector UI should have a dedicated dialog");
99
103
  assert.match(html, /id="optionsWorkflowSetupButton"[^>]*data-command="\/workflow-setup"[^>]*hidden[\s\S]*Workflow Permission Setup/, "Common Pi options should expose catalog-gated Workflow Permission Setup");
104
+ assert.match(html, /id="optionsSummarySetupButton"[^>]*data-command="\/summary-setup"[^>]*hidden[\s\S]*Session Summary Setup/, "Common Pi options should expose catalog-gated Session Summary Setup");
105
+ assert.match(html, /id="summaryHeaderButton"[^>]*aria-label="Open session summary"[^>]*hidden[\s\S]*id="summaryActionButton"[^>]*data-composer-action-id="summary"[^>]*hidden/, "catalog-gated summary actions should exist in both the terminal header and mobile composer sheet");
106
+ assert.match(html, /id="sessionSummaryOverlay"[^>]*role="dialog"[^>]*aria-modal="false"[^>]*aria-labelledby="sessionSummaryOverlayTitle"[^>]*hidden[\s\S]*id="sessionSummaryOverlayBody"[\s\S]*id="sessionSummaryOverlayCopyButton"[\s\S]*id="sessionSummaryOverlayRefreshButton"/, "session summary should use a labelled non-modal Markdown overlay with copy and refresh actions");
107
+ assert.doesNotMatch(html, /<dialog[^>]*id="sessionSummaryOverlay"/, "session summary overlay must remain non-blocking rather than modal");
100
108
  assert.match(html, /id="optionsSafetyGuardSetupButton"[\s\S]*data-command="\/safety-guard-setup"[\s\S]*Safety Guard Setup/, "Common Pi options should expose native Safety Guard Setup");
101
109
  assert.match(html, /id="optionsGitWorkflowSetupButton"[\s\S]*data-command="\/git-workflow-setup"[\s\S]*Guided Git Setup/, "Common Pi options should expose native Guided Git Setup");
102
- assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\[[^\]]*"workflow-setup"[^\]]*\]\)/, "exact /workflow-setup should be a browser-native selector command");
110
+ assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\[[^\]]*"summary"[^\]]*"summary-setup"[^\]]*"workflow-setup"[^\]]*\]\)/, "exact /summary, /summary-setup, and /workflow-setup should be browser-native selector commands");
111
+ assert.match(app, /function renderSessionSummaryControls\(\)[\s\S]*hasAvailableCommand\("summary", \{ tabId: activeTabId \}\)[\s\S]*hasAvailableCommand\("summary-setup", \{ tabId: activeTabId \}\)[\s\S]*button\.hidden = !available/, "summary controls should be active-tab command-catalog gated");
112
+ assert.match(app, /function normalizeSessionSummaryClientState\(value, previous = null, \{ resetProjection = false \} = \{\}\)[\s\S]*sessionChanged[\s\S]*resetProjection \|\| sessionChanged \? null : previous[\s\S]*inherited\?\.summaryMarkdown/, "frontend should preserve failure Markdown but clear it for session changes and explicit branch-state projections");
113
+ assert.match(app, /function handleSessionSummaryEvent\(event\)[\s\S]*resetProjection: event\?\.kind === "state"/, "active-branch state events should reset the cached overlay projection");
114
+ assert.match(app, /function renderSessionSummaryOverlay\(\)[\s\S]*renderMarkdown\(elements\.sessionSummaryOverlayBody, state\.summaryMarkdown\)/, "summary overlay should use the sanitized Markdown renderer");
115
+ assert.match(app, /previous successful summary is preserved/, "summary overlay should explain failure preservation");
116
+ assert.match(app, /async function openNativeSessionSummarySetupDialog[\s\S]*Inject latest summary into main-agent context[\s\S]*nativeSettingsNote\("Privacy scope"[\s\S]*nativeSettingsNote\("Cost and provider behavior"/, "browser-native summary setup should expose the approved context, privacy, and cost controls");
117
+ assert.match(app, /addNativeCommandAction\("Save and generate"[\s\S]*confirmed: true[\s\S]*requestSessionSummaryGeneration/, "browser-native summary setup should confirm, persist, and immediately request the first generation");
118
+ assert.match(app, /sessionSummaryOverlayCopyButton[\s\S]*copyText\(state\.summaryMarkdown\)/, "summary copy should use the raw validated Markdown source");
119
+ assert.match(css, /\.session-summary-overlay \{[\s\S]*position: fixed[\s\S]*\.session-summary-overlay\[hidden\][\s\S]*@media \(max-width: 720px\)[\s\S]*\.session-summary-overlay/, "summary overlay should be visibly non-modal and responsive on mobile");
103
120
  assert.match(app, /function normalizedWorkflowPolicyList\(value\)[\s\S]*new Set[\s\S]*\.filter\(Boolean\)\)\]\.sort\(\)/, "workflow policy list fields should trim, deduplicate, and sort for the canonical preview");
104
121
  assert.match(app, /function parseWorkflowPolicyVerificationCommands\(value\)[\s\S]*JSON\.parse\(line\)[\s\S]*non-empty JSON string argv array[\s\S]*commands\.push\(command\)/, "workflow verification should accept one ordered JSON argv array per nonblank line");
105
122
  assert.match(app, /async function openNativeWorkflowSetupDialog\(\)[\s\S]*api\("\/api\/workflow-policy", \{ scoped: false \}\)[\s\S]*nativeSettingToggle\("Allow write"[\s\S]*nativeSettingToggle\("Allow shell"[\s\S]*nativeSettingToggle\("Allow network"[\s\S]*Exact normalized JSON preview/, "workflow setup should load the localhost policy API and render accessible permission controls plus an exact normalized preview");
@@ -107,7 +124,7 @@ assert.match(app, /Authorization ceiling[\s\S]*not blanket authority[\s\S]*Shell
107
124
  assert.match(app, /nativeSettingsDirty = workflowPolicyDraftSignature\(controls\) !== initialDraftSignature/, "workflow setup edits should participate in native dialog discard protection");
108
125
  assert.match(app, /addNativeCommandAction\("Reset to all deny"[\s\S]*applyDeniedWorkflowPolicyControls\(controls\)[\s\S]*controls\.write\.input\.focus\(\)/, "workflow setup should expose an explicit reset-to-all-deny action");
109
126
  assert.match(app, /title: "Save reviewed workflow permission ceiling\?"[\s\S]*Exact normalized JSON:[\s\S]*if \(!reviewed\) return;[\s\S]*api\("\/api\/workflow-policy", \{[\s\S]*body: \{ policy: policyToSave, expectedRevision: data\.revision \?\? null \}[\s\S]*No agent turn was started/, "workflow setup should require explicit normalized review before revision-protected save and report transient no-turn success");
110
- assert.match(app, /name === "workflow-setup" && !hasLoadedRpcCommand\(name\)[\s\S]*case "workflow-setup":[\s\S]*await openNativeWorkflowSetupDialog\(\)/, "workflow setup native routing should require the active Pi tab's loaded extension command catalog");
127
+ assert.match(app, /\(name === "workflow-setup" \|\| name === "summary" \|\| name === "summary-setup"\) && !hasLoadedRpcCommand\(name\)[\s\S]*case "summary":[\s\S]*await openSessionSummaryForTab[\s\S]*case "workflow-setup":[\s\S]*await openNativeWorkflowSetupDialog\(\)/, "native summary and setup routing should require the active Pi tab's loaded extension command catalog");
111
128
  assert.match(app, /function normalizeWorkflowPolicySuggestions\(value\)[\s\S]*if \(!value \|\| typeof value !== "object" \|\| Array\.isArray\(value\)\) return empty;[\s\S]*if \(!Array\.isArray\(group\) \|\| group\.some[\s\S]*return \[\];[\s\S]*shellAllowlist: normalizeStringGroup\(value\.shellAllowlist\)[\s\S]*networkAllowlist: normalizeStringGroup\(value\.networkAllowlist\)[\s\S]*verificationCommands: normalizeVerificationGroup\(value\.verificationCommands\)/, "workflow suggestions should defensively normalize each server-provided catalog group and render no fallback for malformed groups");
112
129
  assert.match(app, /const suggestions = normalizeWorkflowPolicySuggestions\(data\.suggestions\)[\s\S]*suggestionLabel: "Shell executable suggestions"[\s\S]*suggestionLabel: "Network host suggestions"[\s\S]*suggestionLabel: "Verification command suggestions"/, "all three workflow policy textareas should consume only GET-provided suggestions in labelled groups");
113
130
  const appendWorkflowPolicySuggestionSource = appFunctionSource("appendWorkflowPolicySuggestion", "workflowPolicySuggestionGroup");
@@ -605,7 +622,7 @@ assert.match(css, /body\.terminal-tabs-left \.chat-panel \{[\s\S]*?grid-template
605
622
  assert.match(css, /body\.terminal-tabs-left \.terminal-tabs-shell \{[\s\S]*?grid-column:\s*1;[\s\S]*?grid-row:\s*1 \/ -1;[\s\S]*?flex-direction:\s*column/, "terminal tabs left layout should turn the top tab strip into a vertical sidebar");
606
623
  assert.match(html, /class="terminal-sidebar-actions"[^>]*aria-label="Tab and workspace actions"[\s\S]*id="splitTabButton"[^>]*aria-label="Split the active terminal to the right"[\s\S]*id="workspaceSaveButton"[^>]*aria-label="Save workspace"[\s\S]*id="commandPaletteButton"[^>]*aria-label="Open command palette"[\s\S]*id="workspaceDashboardToggleButton"[^>]*aria-label="Show workspace overview"/, "tab, save, command, and workspace actions should share one accessibly labelled sidebar toolbar");
607
624
  assert.doesNotMatch(html, /terminal-sidebar-action-label/, "left-sidebar action buttons should be icon-only without redundant visible labels");
608
- assert.match(css, /body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?display:\s*grid;[\s\S]*?grid-template-columns:\s*repeat\(4, minmax\(0, 1fr\)\);[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions > button \{[\s\S]*?place-items:\s*center;[\s\S]*?min-height:\s*2\.75rem;[\s\S]*?padding:\s*0\.42rem;/, "left-sidebar actions should render as compact equal-width icon buttons with 44px targets");
625
+ assert.match(css, /body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?display:\s*grid;[\s\S]*?grid-template-columns:\s*repeat\(5, minmax\(0, 1fr\)\);[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions > button \{[\s\S]*?place-items:\s*center;[\s\S]*?min-height:\s*2\.75rem;[\s\S]*?padding:\s*0\.42rem;/, "left-sidebar actions should render as compact equal-width icon buttons with 44px targets");
609
626
  assert.match(css, /@media \(min-width: 721px\) \{[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?z-index:\s*130;[\s\S]*?overflow:\s*visible;[\s\S]*?terminal-workspace-save-button\[data-tooltip\]::after,[\s\S]*?terminal-command-palette-button\[data-tooltip\]::after,[\s\S]*?terminal-dashboard-button\[data-tooltip\]::after \{[\s\S]*?bottom:\s*calc\(100% \+ 0\.62rem\);[\s\S]*?z-index:\s*220;[\s\S]*?width:\s*calc\(400% \+ 1\.26rem\);/, "left-sidebar save, command, and overview tooltips should render above the full toolbar without clipping");
610
627
  assert.match(css, /terminal-workspace-save-button\[data-tooltip\]::after \{\s+left:\s*calc\(-100% - 0\.42rem\);[\s\S]*?terminal-command-palette-button\[data-tooltip\]::after \{\s+left:\s*calc\(-200% - 0\.84rem\);[\s\S]*?terminal-dashboard-button\[data-tooltip\]::after \{\s+left:\s*calc\(-300% - 1\.26rem\);/, "left-sidebar tooltips should align to the toolbar edges from their individual buttons");
611
628
  assert.match(app, /elements\.splitTabButton\.setAttribute\("aria-pressed", canShowSplit \? "true" : "false"\);[\s\S]*?applyStyledTooltip\(elements\.splitTabButton, label, \{ ariaLabel: label \}\);/, "icon-only split action should expose its Split or Close state through accessibility text and the tooltip");
@@ -815,9 +832,10 @@ assert.match(server, /if \(webuiDevServer\) env\.PI_WEBUI_DEV = "1";/, "server r
815
832
  assert.match(server, /async function piUpdateCommandSupportsAll\(command\)[\s\S]*runCommand\(command\.command, command\.args \|\| \[\][\s\S]*piUpdateHelpSupportsAll/, "server should check the selected Pi executable's update help");
816
833
  assert.match(server, /const supportsAll = all && await piUpdateCommandSupportsAll\(await resolveCommand\(\["update", "--help"\]\)\)[\s\S]*piUpdateCommandSteps\(\{ all, supportsAll \}\)/, "server should prefer --all only when the capability check succeeds");
817
834
  assert.match(server, /async function resolveUpdateTasks\(\{ all = false \} = \{\}\)[\s\S]*const piTasks = await resolvePiUpdateCommands\(\{ all \}\)[\s\S]*if \(!all\) return uniqueUpdateTasks\(piTasks\)[\s\S]*currentWebuiPackageUpdateTask\(npmRuntime\)[\s\S]*agentPackageRootUpdateTask\(npmRuntime\)[\s\S]*projectPackageRootUpdateTasks\(npmRuntime\)[\s\S]*npmGlobalPackageRootUpdateTask\(npmRuntime\)[\s\S]*bunGlobalPackageRootUpdateTask\(\)/, "server all-update should run the selected Pi plan plus detected local/global Pi package root tasks with install-aware npm resolution");
818
- assert.match(server, /const UPDATE_PACKAGE_NAMES = \[\.\.\.new Set\(\[[\s\S]*WEBUI_CONTROLLED_PACKAGES[\s\S]*OPTIONAL_FEATURE_PACKAGES\.values\(\)/, "package-inclusive updates should include Web UI controlled Optional Feature packages");
835
+ assert.match(server, /const OPTIONAL_FEATURE_PACKAGE_NAMES = new Set\(OPTIONAL_FEATURE_PACKAGES\.values\(\)\)[\s\S]*const UPDATE_PACKAGE_NAMES = \[\.\.\.CORE_UPDATE_PACKAGE_NAMES\]\.sort\(\)/, "direct package-root updates should target core packages while retaining the Optional Feature exclusion set");
836
+ assert.match(server, /function isWebuiOrPiPackageName\(packageName\)[\s\S]*OPTIONAL_FEATURE_PACKAGE_NAMES\.has\(name\)\) return false/, "direct npm and Bun update discovery should leave Optional Features under Pi management");
819
837
  assert.match(app, /const commandText = all \? '"pi update --all" when supported, otherwise "pi update --self" followed by "pi update --extensions"' : '"pi update --self"'/, "frontend update confirmation should describe capability selection and fallback");
820
- assert.match(app, /Optional Features, and detected Pi package roots/, "frontend all-update confirmation should describe optional-feature and detected-root coverage");
838
+ assert.match(app, /configured packages including Optional Features, and detected core Pi\/Web UI package roots/, "frontend all-update confirmation should distinguish Pi-managed Optional Features from direct core-root updates");
821
839
  assert.match(app, /api\(all \? "\/api\/update\?all=1" : "\/api\/update"/, "frontend all update should call the explicit all-mode endpoint");
822
840
  assert.match(html, /<option value="update-all">Update Pi \+ Packages &amp; Restart<\/option>/, "side panel should expose package-inclusive updates as a separate server action");
823
841
  assert.match(readme, /first checks the selected Pi executable's `pi update --help`[\s\S]*uses `pi update --all` when advertised[\s\S]*otherwise falls back/, "README should document the checked preferred and fallback update modes");
@@ -1326,11 +1344,21 @@ assert.match(app, /\["skills", "tuiSkillsCommand"\][\s\S]*\["tools", "tuiToolsCo
1326
1344
  assert.match(app, /function setNativeCommandMenuOpen\(open\)/, "frontend should track the skills/tools command menu open state separately from Publish");
1327
1345
  assert.match(app, /nativeSkillsButton\.hidden = !isOptionalFeatureEnabled\("tuiSkillsCommand"\)[\s\S]*nativeToolsButton\.hidden = !isOptionalFeatureEnabled\("tuiToolsCommand"\)/, "skills/tools menu items should be hidden by their optional feature toggles");
1328
1346
  assert.match(app, /function renderCommands\(\)/, "side-panel commands should be re-renderable from current optional feature state");
1329
- assert.match(app, /function installOptionalFeature\(featureId, \{ update = false \} = \{\}\)/, "optional features should expose install and update actions");
1347
+ const installOptionalFeatureSource = appFunctionSource("installOptionalFeature", "installOptionalFeatureBatch");
1348
+ const installOptionalFeatureBatchSource = appFunctionSource("installOptionalFeatureBatch", "runPublishWorkflow");
1349
+ assert.match(installOptionalFeatureSource, /featureId, \{ update = false \} = \{\}/, "optional features should expose per-row install and update actions");
1330
1350
  assert.match(app, /api\("\/api\/optional-features"/, "optional feature panel should fetch package install/update status from the backend");
1331
- assert.match(app, /packageStatus\?\.updateAvailable[\s\S]*action\.textContent = "Update…"/, "optional feature package drift should turn the install action into an update action");
1332
- assert.match(app, /optionalFeatureInstallMessages\.set\(featureId[\s\S]*waiting for package-manager output/, "optional feature installs should show running feedback while npm is active");
1333
- assert.match(app, /api\("\/api\/optional-feature-install"/, "optional feature install action should call the backend installer endpoint");
1351
+ assert.match(app, /function optionalFeatureNeedsInstall\(feature\)[\s\S]*status\.ready !== true[\s\S]*status\.resourceConflict !== true/, "bulk selection should exclude ready top-level resources and duplicate registration conflicts");
1352
+ assert.match(app, /packageStatus\?\.updateAvailable[\s\S]*action\.textContent = "Update…"/, "optional feature package drift should retain the per-row update action");
1353
+ assert.match(app, /function optionalFeatureManualInstallCommand\(feature\)[\s\S]*`pi install npm:\$\{feature\.packageName\}`/, "optional feature fallback commands should use the exact unpinned Pi npm source");
1354
+ assert.match(app, /function copyOptionalFeatureInstallCommand\(featureId\)[\s\S]*state\?\.command \|\| optionalFeatureManualInstallCommand\(feature\)/, "missing and unregistered rows should expose a copyable Pi fallback command before an install attempt");
1355
+ assert.match(installOptionalFeatureSource, /optionalFeatureManualInstallCommand\(feature\)[\s\S]*selected Pi CLI[\s\S]*api\("\/api\/optional-feature-install"/, "per-row install/update should describe and call the Pi-backed endpoint");
1356
+ assert.doesNotMatch(installOptionalFeatureSource, /npm install|Web UI package install root|npm command/i, "per-row optional feature copy should not claim that Web UI invokes npm directly");
1357
+ assert.match(app, /renderOptionalFeatureBatchToolbar\(\)[\s\S]*"Install all"[\s\S]*installOptionalFeatureBatch\(OPTIONAL_FEATURES/, "optional feature panel should expose Install all");
1358
+ assert.match(app, /function renderOptionalFeatureSection\(section, features\)[\s\S]*"Install missing"[\s\S]*installOptionalFeatureBatch\(features/, "each optional feature section should expose Install missing");
1359
+ assert.match(installOptionalFeatureBatchSource, /optionalFeatureBatchCandidates\(features\)[\s\S]*await appConfirmText\([\s\S]*api\("\/api\/optional-feature-install-batch"[\s\S]*for \(const feature of candidates\)[\s\S]*result\?\.ok === true[\s\S]*optionalFeatureInstallFailureFromBatchResult/, "bulk install should confirm once, call one backend batch, and settle every requested row independently");
1360
+ assert.match(installOptionalFeatureBatchSource, /Batch finished:[\s\S]*succeeded[\s\S]*failed|optional feature batch finished:[\s\S]*succeeded[\s\S]*failed/, "bulk install should expose bounded aggregate success/failure counts");
1361
+ assert.equal((installOptionalFeatureBatchSource.match(/confirmLabel: "Reload tab"/g) || []).length, 1, "bulk install should issue exactly one post-batch reload prompt");
1334
1362
  assert.match(app, /id: "btwCommand"[\s\S]*?@firstpick\/pi-extension-btw/, "optional features should include the /btw companion");
1335
1363
  assert.match(app, /BTW_OUTPUT_WIDGET_KEY = "btw:output"[\s\S]*function renderBtwOutputWidget/, "Web UI should render structured /btw output widgets");
1336
1364
  assert.match(app, /if \(key\.startsWith\("btw:"\)\) return "btwCommand"/, "extension widget routing should associate /btw widgets with the optional feature");
@@ -1810,7 +1838,7 @@ assert.match(app, /async function sendPrompt\(kind = "prompt", explicitMessage,
1810
1838
  assert.match(app, /const rawMessage = usesPromptInput \? elements\.promptInput\.value : explicitMessage/, "direct prompt sends should not read the input textarea");
1811
1839
  assert.match(app, /function clearPromptInputForRouting\(\{ usesPromptInput,[\s\S]*?if \(!usesPromptInput\) return;/, "direct prompt sends should preserve the input textarea draft");
1812
1840
  assert.match(app, /make\("button", "command-item"\)[\s\S]*?sendPrompt\("prompt", `\/\$\{command\.name\}`\)/, "side-panel command clicks should send the slash command directly");
1813
- assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "workflow-setup", "safety-guard-setup", "git-workflow-setup", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands, including workflow permission, safety, and Guided Git setup, into selector UIs");
1841
+ assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "summary", "summary-setup", "workflow-setup", "safety-guard-setup", "git-workflow-setup", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands, including session summary, workflow permission, safety, and Guided Git setup, into selector UIs");
1814
1842
  assert.match(app, /async function handleNativeSlashSelectorCommand\(message/, "frontend should intercept exact native slash commands before prompt forwarding");
1815
1843
  assert.match(app, /kind === "prompt" && attachments\.length === 0 && await handleNativeSlashSelectorCommand/, "prompt sending should open native selector dialogs before marking a run active");
1816
1844
  assert.match(app, /function openNativeModelSelector\(\)[\s\S]*?nativeCommandApi\("\/api\/models"\)/, "native /model selector should load models through the active tab API");
@@ -1976,10 +2004,11 @@ assert.ok(mochaBackground.length > 8000, "Catppuccin Mocha background image shou
1976
2004
 
1977
2005
  assert.match(server, /resolveCodexUsageAuth/, "server should use the lock-safe Codex OAuth compatibility adapter");
1978
2006
  assert.match(server, /DefaultPackageManager/, "server should use Pi's package resolver when controlling Web UI tab extension loading");
1979
- assert.match(server, /WEBUI_CONTROLLED_PACKAGES = new Set\(\[[\s\S]*WEBUI_PACKAGE[\s\S]*filter\(\(\[featureId\]\) => featureId !== NATURAL_CONVERSATION_FEATURE_ID\)/, "server should identify Web UI-controlled packages for de-duplicated feature loading while leaving Natural Conversation independently owned");
1980
- assert.match(server, /const args = \["--mode", "rpc", "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-themes"\]/, "Web UI tabs should disable implicit resource loading before adding curated resource paths");
1981
- assert.match(server, /normalPiResourcePathsForTab[\s\S]*WEBUI_CONTROLLED_PACKAGES\.has\(packageName\)[\s\S]*continue/, "Web UI tab resource resolution should exclude separately installed Web UI feature packages");
1982
- assert.match(server, /startedWebuiResourcePaths\(resourceType\)/, "Web UI tabs should load feature resources from the started Web UI package");
2007
+ assert.match(server, /WEBUI_RESOURCE_EXCLUDED_PACKAGES = new Set\(\[WEBUI_PACKAGE\]\)/, "server should exclude only the Web UI package itself from normal Pi resource loading");
2008
+ assert.match(server, /async function packageNameForResourcePath\(resourcePath\)[\s\S]*canonicalResourcePath = await realpath\(resourcePath\)[\s\S]*path\.dirname\(canonicalResourcePath\)/, "package ownership checks should canonicalize file symlinks before walking package ancestors");
2009
+ assert.match(server, /const args = \["--mode", "rpc", "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-themes"\]/, "Web UI tabs should disable implicit resource loading before adding resolved resource paths");
2010
+ assert.match(server, /normalPiResourcePathsForTab[\s\S]*WEBUI_RESOURCE_EXCLUDED_PACKAGES\.has\(packageName\)[\s\S]*continue/, "Web UI tab resource resolution should retain separately configured optional packages and prevent only self-loading duplication");
2011
+ assert.match(server, /startedWebuiResourcePaths\(resourceType\)/, "Web UI tabs should load Web UI-owned resources from the started package");
1983
2012
  assert.match(server, /resolveInstalledPackageSubpath\(nodeModulesRef\.packageName, nodeModulesRef\.subpath\)/, "Web UI should prefer workspace/global/package-root installed packages for node_modules manifest entries");
1984
2013
  assert.match(codexAuth, /CODEX_TOKEN_REFRESH_SKEW_MS = 5 \* 60 \* 1000/, "Codex OAuth credentials should refresh five minutes before expiry");
1985
2014
  assert.match(server, /catch \{[\s\S]*OpenAI Codex OAuth token refresh failed/, "Codex auth failures should be redacted before reaching clients");
@@ -2013,7 +2042,7 @@ assert.match(server, /scopedEvent = \{ \.\.\.scopedEvent,[\s\S]*?pendingExtensio
2013
2042
  assert.match(server, /function replayExtensionStatuses\(tab, client\)[\s\S]*method: "setStatus"/, "server should replay latest extension statuses on SSE reconnect");
2014
2043
  assert.match(server, /function replayExtensionWidgets\(tab, client\)[\s\S]*method: "setWidget"/, "server should replay latest extension widgets on SSE reconnect");
2015
2044
  assert.match(server, /function replayPendingExtensionUiRequests\(tab, client\)/, "server should be able to replay missed extension UI requests on SSE reconnect");
2016
- assert.match(server, /replayExtensionStatuses\(tab, client\);\n\s+replayExtensionWidgets\(tab, client\);\n\s+replayPendingExtensionUiRequests\(tab, client\)/, "SSE connections should replay extension statuses and widgets before pending blockers");
2045
+ assert.match(server, /replayExtensionStatuses\(tab, client\);\n\s+replayExtensionWidgets\(tab, client\);[\s\S]*?webui_session_summary[\s\S]*?replayPendingExtensionUiRequests\(tab, client\)/, "SSE connections should replay extension statuses, widgets, and the tab-scoped summary before pending blockers");
2017
2046
  assert.match(server, /pendingExtensionUiRequests: pendingExtensionUiRequestSummaries\(tab\)/, "detailed Web UI status should expose pending extension UI blockers");
2018
2047
  assert.match(server, /resolvePendingExtensionUiRequest\(tab, payload\.id\)/, "extension UI responses should clear the pending blocker cache");
2019
2048
  assert.match(server, /type: "webui_extension_ui_resolved"[\s\S]*?pendingExtensionUiRequestCount/, "extension UI responses should notify clients that a blocker resolved");
@@ -2108,15 +2137,15 @@ assert.match(server, /type: "set_steering_mode"/, "server should expose steering
2108
2137
  assert.match(server, /type: "set_follow_up_mode"/, "server should expose follow-up queue-mode changes for native /settings");
2109
2138
  assert.match(server, /type: "set_auto_compaction"/, "server should expose auto-compaction changes for native /settings");
2110
2139
  assert.match(server, /@firstpick\/pi-themes-bundle/, "server should discover themes from the optional theme package");
2111
- assert.match(server, /const OPTIONAL_FEATURE_PACKAGES = new Map/, "server should whitelist optional feature packages for install actions");
2112
- assert.match(server, /\["bangCommandAutocomplete", "@firstpick\/pi-extension-bang-command-autocomplete"\]/, "server should allow installing the bang autocomplete optional feature");
2113
- assert.match(server, /\["fishUserBash", "@firstpick\/pi-extension-fish-user-bash"\]/, "server should allow installing the fish user-bash optional feature");
2114
- assert.match(server, /\["btwCommand", "@firstpick\/pi-extension-btw"\]/, "server should allow installing the /btw optional feature");
2115
- assert.match(server, /\["safetyGuard", "@firstpick\/pi-extension-safety-guard"\]/, "server should allow installing the safety guard optional feature");
2116
- assert.match(server, /\["tuiSkillsCommand", "@firstpick\/pi-extension-setup-skills"\]/, "server should allow installing the TUI skills optional feature");
2117
- assert.match(server, /\["tuiToolsCommand", "@firstpick\/pi-extension-tools"\]/, "server should allow installing the TUI tools optional feature");
2118
- assert.match(server, /\["questionnaire", "@firstpick\/pi-package-questionnaire"\]/, "server should allow explicitly installing the native questionnaire optional feature");
2119
- assert.match(server, /\["naturalConversation", "@firstpick\/pi-package-natural-conversation"\]/, "server should know the standalone Natural Conversation package for status\/install guidance without making it WebUI-owned");
2140
+ assert.match(server, /const OPTIONAL_FEATURE_PACKAGES = new Map\(OPTIONAL_FEATURE_CATALOG/, "server should derive install allowlisting from the optional feature catalog");
2141
+ assert.match(optionalFeatureCatalog, /\["bangCommandAutocomplete", "@firstpick\/pi-extension-bang-command-autocomplete"/, "catalog should allow installing the bang autocomplete optional feature");
2142
+ assert.match(optionalFeatureCatalog, /\["fishUserBash", "@firstpick\/pi-extension-fish-user-bash"/, "catalog should allow installing the fish user-bash optional feature");
2143
+ assert.match(optionalFeatureCatalog, /\["btwCommand", "@firstpick\/pi-extension-btw"/, "catalog should allow installing the /btw optional feature");
2144
+ assert.match(optionalFeatureCatalog, /\["safetyGuard", "@firstpick\/pi-extension-safety-guard"/, "catalog should allow installing the safety guard optional feature");
2145
+ assert.match(optionalFeatureCatalog, /\["tuiSkillsCommand", "@firstpick\/pi-extension-setup-skills"/, "catalog should allow installing the TUI skills optional feature");
2146
+ assert.match(optionalFeatureCatalog, /\["tuiToolsCommand", "@firstpick\/pi-extension-tools"/, "catalog should allow installing the TUI tools optional feature");
2147
+ assert.match(optionalFeatureCatalog, /\["questionnaire", "@firstpick\/pi-package-questionnaire"/, "catalog should allow explicitly installing the native questionnaire optional feature");
2148
+ assert.match(optionalFeatureCatalog, /\["naturalConversation", "@firstpick\/pi-package-natural-conversation"/, "catalog should know the standalone Natural Conversation package for status and install guidance");
2120
2149
  assert.match(server, /const NATURAL_CONVERSATION_COMMAND_NAMES = \["talk", "voice", "conversation"\]/, "server should detect Natural Conversation from RPC-visible command aliases");
2121
2150
  assert.match(server, /function naturalConversationFeatureData\(tab[\s\S]*getCommandData\(tab, \{ annotateSkills: false \}\)[\s\S]*available[\s\S]*mode/, "server should expose a capability-based Natural Conversation feature snapshot");
2122
2151
  assert.match(server, /url\.pathname === "\/api\/features\/natural-conversation" && req\.method === "GET"[\s\S]*naturalConversationFeatureData\(tab\)/, "server should expose Natural Conversation feature metadata");
@@ -2126,18 +2155,18 @@ assert.match(server, /PI_VOICE_STT_URL[\s\S]*PI_VOICE_TTS_URL[\s\S]*GROQ_API_KEY
2126
2155
  assert.match(server, /function requireRemoteMicConsentForStt\(req, body = \{\}\)[\s\S]*remoteMicStreamingConsentAccepted/, "server STT fallback should require explicit remote microphone streaming consent for remote clients");
2127
2156
  assert.match(server, /function ensureNaturalConversationPromptSafety\(tab, command\)[\s\S]*setThinkingLevelForTab\(tab, "off"/, "server should force thinking off before WebUI prompts while conversation mode is active");
2128
2157
  assert.match(server, /function enforceNaturalConversationCommandAllowed\(tab, command\)[\s\S]*thinking is forced off[\s\S]*slash commands are blocked from the Web UI shell/, "server should block unsafe direct RPC\/WebUI commands while conversation mode is active");
2129
- assert.match(server, /function optionalFeaturePackageStatus\(featureId\)/, "server should report optional feature package install\/update status");
2130
- assert.match(server, /function installOptionalFeaturePackage\(featureId\)/, "server should provide optional feature package installation helper");
2131
- assert.match(server, /PI_WEBUI_OPTIONAL_FEATURE_INSTALL_ROOT/, "optional feature installs should support an explicit package-manager root override");
2132
- assert.match(server, /function configuredAgentNpmRoot\(\)/, "global Web UI launches should consider Pi's agent npm root for optional packages");
2133
- assert.match(server, /installRootDeclaresPackage\(.*?@firstpick\/pi-package-webui/s, "optional feature installs should reuse a node_modules parent that declares the Web UI package dependency");
2134
- assert.match(server, /installRootContainsPackage\(.*?@firstpick\/pi-package-webui/s, "global npm Web UI launches should also accept the prefix containing the Web UI package folder");
2135
- assert.match(server, /resolveInstalledPackageSubpath\(nodeModulesRef\.packageName, nodeModulesRef\.subpath\)/, "started Web UI resource resolution should fall back to globally installed sibling optional packages");
2136
- assert.match(server, /if \(webuiDevServer\) return installRoot/, "source-checkout Web UI launches should still use the checkout root for optional feature installs");
2137
- assert.match(server, /Could not determine a safe optional feature install root/, "optional feature installs should fail closed when no safe package root can be found");
2158
+ assert.match(server, /async function topLevelOptionalFeatureResourceIndex\(cwd = options\.cwd\)[\s\S]*metadata\?\.origin === "package"[\s\S]*packageNameForResourcePath/, "server should detect enabled top-level resources by owning package");
2159
+ assert.match(server, /function optionalFeaturePackageStatus\(featureId, cwd = options\.cwd, topLevelResourceIndex\)[\s\S]*installed[\s\S]*configured[\s\S]*locallyConfigured[\s\S]*resourceConflict[\s\S]*ready/, "server should report package registration, top-level availability, conflicts, and readiness separately");
2160
+ assert.match(server, /if \(beforeStatus\.locallyConfigured\)[\s\S]*load it twice[\s\S]*local-resource-conflict/, "server should block npm registration when a top-level resource already owns the optional feature");
2161
+ assert.match(server, /function installOptionalFeaturePackage\(featureId, cwd = options\.cwd\)[\s\S]*const source = `npm:\$\{packageName\}`[\s\S]*resolvePiCommand\(\["install", source\]\)/, "server should install and update optional features through the selected Pi CLI");
2162
+ assert.match(server, /function configuredAgentNpmRoot\(\)/, "status discovery should consider Pi's agent npm root for legacy or hoisted packages");
2163
+ assert.match(server, /resolveInstalledPackageSubpath\(nodeModulesRef\.packageName, nodeModulesRef\.subpath\)/, "started Web UI resource resolution should support configured package resources");
2138
2164
  assert.match(server, /url\.pathname === "\/api\/optional-features" && req\.method === "GET"/, "server should expose optional feature package status endpoint");
2139
- assert.match(server, /url\.pathname === "\/api\/optional-feature-install" && req\.method === "POST"/, "server should expose optional feature install endpoint");
2140
- assert.match(server, /requireLocalhostRoute\(req, url\.pathname\)/, "optional feature install endpoint should use shared localhost trust policy");
2165
+ assert.match(server, /url\.pathname === "\/api\/optional-feature-install" && req\.method === "POST"/, "server should preserve the optional feature single-install endpoint");
2166
+ assert.match(server, /url\.pathname === "\/api\/optional-feature-install-batch" && req\.method === "POST"[\s\S]*installOptionalFeaturePackages\(body\.featureIds, tab\.cwd\)/, "server should expose the sequential optional feature batch endpoint");
2167
+ assert.match(server, /function validateOptionalFeatureBatch\(featureIds\)[\s\S]*OPTIONAL_FEATURE_CATALOG\.length[\s\S]*seen\.has\(value\)/, "server batch validation should remain allowlisted, bounded, and deduplicated");
2168
+ assert.match(server, /async function installOptionalFeaturePackages\(featureIds, cwd = options\.cwd\)[\s\S]*for \(const featureId of requestedFeatureIds\)[\s\S]*catch \(error\)[\s\S]*succeeded[\s\S]*failed/, "server batch execution should be sequential and continue after per-feature failures");
2169
+ assert.match(server, /requireLocalhostRoute\(req, url\.pathname\)|requireLocalhost\(req, "Installing optional Web UI features is only allowed from localhost"\)/, "optional feature install endpoints should enforce localhost trust policy");
2141
2170
  assert.match(server, /url\.pathname === "\/api\/skill-file" && req\.method === "GET"[\s\S]*?getSkillFileData/, "server should expose GET /api/skill-file for editable skill content");
2142
2171
  assert.match(server, /url\.pathname === "\/api\/skill-file" && req\.method === "POST"[\s\S]*?requireLocalhostRoute\(req, url\.pathname\)[\s\S]*?saveSkillFileData/, "server should expose localhost-only POST /api/skill-file for saving skill content");
2143
2172
  assert.match(server, /function resolveEditableSkillFile\(tab, request = \{\}\)[\s\S]*?path\.basename\(skill\.filePath\) !== "SKILL\.md"/, "skill file API should validate that edits target resolved SKILL.md resources");
@@ -2166,20 +2195,23 @@ assert.match(readme, /optional `@firstpick\/pi-extension-fish-user-bash` compani
2166
2195
  assert.match(readme, /GET \/api\/path-suggestions\?tab=<tabId>&query=<path>/, "README should document the path-suggestions endpoint");
2167
2196
  assert.match(readme, /GET \/api\/optional-features/, "README should document optional feature status endpoint");
2168
2197
  assert.match(readme, /POST \/api\/optional-feature-install/, "README should document optional feature install endpoint");
2198
+ assert.match(readme, /POST \/api\/optional-feature-install-batch[\s\S]*bounded allowlisted[\s\S]*sequentially/, "README should document the bounded sequential batch endpoint");
2199
+ assert.match(readme, /\*\*Install all\*\*[\s\S]*\*\*Install missing\*\*[\s\S]*missing\/unregistered[\s\S]*one confirmation[\s\S]*continues after failures/, "README should document bulk control scope and partial-failure behavior");
2200
+ assert.match(readme, /pi install npm:@firstpick\/pi-extension-stats[\s\S]*Re-running the same `pi install npm:<package>` command is the supported update path/, "README should document separate manual Pi package installation and updates");
2169
2201
  assert.match(readme, /server-persisted fast picks/, "README should describe server-persisted fast picks");
2170
2202
  assert.match(readme, /`\/btw` side-question output widgets with optional context transfer\/live steering, browser notifications when a tab needs an extension UI response, and an optional side-panel toggle for agent-done notifications/, "README should describe /btw, blocked-tab, and agent-done notifications");
2171
2203
  assert.match(readme, /blocked-tab browser notifications, and optional agent-done notifications require browser service-worker\/notification support/, "README should document notification requirements");
2172
2204
  assert.match(readme, /Side-panel theme picker backed by optional `@firstpick\/pi-themes-bundle` themes when loaded/, "README should describe optional theme selection");
2173
2205
  assert.match(readme, /## Optional companion packages/, "README should document optional Web UI companion packages");
2174
- assert.match(readme, /curates Pi resources from the Web UI package that started the server/, "README should document started-package-based Web UI feature loading");
2175
- assert.match(readme, /Companion packages installed as global\/npm-prefix siblings/, "README should document global sibling companion discovery");
2176
- assert.match(readme, /avoiding duplicate loads while keeping global `pi-webui` launches working/, "README should document duplicate companion suppression");
2177
- assert.match(readme, /checks loaded Pi capabilities directly through RPC-visible commands and live widget events/, "README should document capability-based startup checks");
2178
- assert.match(readme, /side panel shows each optional feature as enabled, disabled, installed-but-not-loaded, update-available, or install-needed/, "README should document optional feature side-panel controls");
2179
- assert.match(readme, /Installing or updating a feature is an explicit, warned action with running\/failure feedback/, "README should document optional feature install and update warning behavior");
2206
+ assert.match(readme, /Web UI tabs load enabled resources resolved from normal Pi settings/, "README should document Pi-settings-based optional feature loading");
2207
+ assert.match(readme, /legacy\/hoisted package files without either a Pi settings entry or an enabled top-level resource remain installable/i, "README should document migration handling for physically present but unregistered packages");
2208
+ assert.match(readme, /excluding the Web UI package itself from re-loading/, "README should document Web UI self-loading duplicate prevention");
2209
+ assert.match(readme, /checks loaded Pi capabilities directly through RPC-visible commands, tools, themes, and live widget events/, "README should document capability-based startup checks");
2210
+ assert.match(readme, /side panel separately reports physical installation and Pi registration/, "README should document distinct installed and registered optional feature status");
2211
+ assert.match(readme, /per-row \*\*Install\*\* or \*\*Update\*\* action[\s\S]*batch has one confirmation[\s\S]*bounded diagnostics/, "README should document per-row and bulk warning/result behavior");
2180
2212
  assert.match(readme, /Natural Conversation Mode shell[\s\S]*\/talk[\s\S]*read-only/, "README should document the optional Natural Conversation WebUI shell");
2181
2213
  assert.match(readme, /\.\/dev\/scripts\/start-webui\.sh --dev --cwd \/path\/to\/project/, "README should document the dev helper launcher");
2182
- assert.match(readme, /sync-pi-package-symlinks\.sh[\s\S]*only one copy is loaded/, "README should document dev companion symlink setup");
2214
+ assert.match(readme, /register that package with Pi from its absolute local path[\s\S]*resolved from Pi settings rather than the Web UI manifest/, "README should document local companion registration through Pi settings");
2183
2215
  assert.match(startScript, /--dev\)/, "start-webui.sh should accept a --dev flag");
2184
2216
  assert.match(startScript, /local_pi_webui_bin\(\)/, "start-webui.sh should resolve this checkout's local server entrypoint");
2185
2217
  assert.match(startScript, /candidate="\$\(package_root\)\/bin\/pi-webui\.mjs"/, "start-webui.sh should resolve the package-root bin from dev/scripts");
@@ -2191,61 +2223,28 @@ assert.match(pkg.scripts?.test || "", /node tests\/run-all\.mjs/, "package test
2191
2223
  assert.ok(!pkg.files?.includes("start-webui.sh"), "npm package should not list the moved Bash dev helper at the package root");
2192
2224
  assert.ok(!pkg.files?.includes("start-webui.ps1"), "npm package should not list the moved PowerShell dev helper at the package root");
2193
2225
  assert.ok(!pkg.files?.some((entry) => entry === "dev/scripts" || entry.startsWith("dev/scripts/")), "npm package should not publish development helper scripts");
2194
- for (const [name, range] of Object.entries(companionDependencies)) {
2195
- assert.equal(pkg.optionalDependencies?.[name], range, `webui package should optionally depend on ${name}`);
2196
- assert.equal(pkg.dependencies?.[name], undefined, `webui package should not require optional companion ${name}`);
2197
- assert.equal(lock.packages?.[""]?.optionalDependencies?.[name], range, `package-lock root should optionally depend on ${name}`);
2198
- assert.equal(lock.packages?.[""]?.dependencies?.[name], undefined, `package-lock root should not promote optional companion ${name} to a required dependency`);
2199
- assert.ok(lock.packages?.[`node_modules/${name}`], `package-lock should include resolved optional companion ${name}`);
2226
+ for (const name of Object.keys(companionDependencies)) {
2227
+ assert.equal(pkg.optionalDependencies?.[name], undefined, `webui package should not optionally install companion ${name}`);
2228
+ assert.equal(pkg.dependencies?.[name], undefined, `webui package should not require companion ${name}`);
2200
2229
  }
2201
- assert.equal(pkg.bundledDependencies, undefined, "webui optional companion packages should not be bundled into the tarball");
2202
- assert.equal(pkg.optionalDependencies?.["@firstpick/pi-package-natural-conversation"], undefined, "webui package should not optionally depend on the standalone Natural Conversation package");
2203
- assert.equal(pkg.optionalDependencies?.["@firstpick/pi-package-questionnaire"], undefined, "webui package should not install questionnaires by default before the user chooses the optional feature");
2204
- assert.equal(pkg.optionalDependencies?.["@firstpick/pi-extension-aur-review"], undefined, "webui package should not reference the unpublished aur-review extension");
2205
- assert.equal(lock.packages?.["node_modules/@firstpick/pi-extension-aur-review"], undefined, "package lock should not retain an unpublished aur-review tarball");
2206
- assert.ok(!pkg.pi?.extensions?.some((entry) => String(entry).includes("pi-extension-aur-review")), "webui Pi manifest should not bundle the unpublished aur-review path");
2207
- assert.ok(!pkg.pi?.extensions?.some((entry) => String(entry).includes("pi-package-natural-conversation")), "webui Pi manifest should not load Natural Conversation directly; /talk must come from the standalone package");
2208
- assert.ok(pkg.pi?.extensions?.includes("./index.ts"), "webui Pi manifest should load its own extension");
2209
- for (const extensionPath of [
2210
- "node_modules/@firstpick/pi-extension-bang-command-autocomplete/index.ts",
2211
- "node_modules/@firstpick/pi-extension-fish-user-bash/index.ts",
2212
- "node_modules/@firstpick/pi-extension-git-footer-status/index.ts",
2213
- "node_modules/@firstpick/pi-extension-release-aur/index.ts",
2214
- "node_modules/@firstpick/pi-extension-release-npm/index.ts",
2215
- "node_modules/@firstpick/pi-extension-safety-guard/index.ts",
2216
- "node_modules/@firstpick/pi-extension-setup-skills/index.ts",
2217
- "node_modules/@firstpick/pi-extension-stats/index.ts",
2218
- "node_modules/@firstpick/pi-extension-todo-progress/index.ts",
2219
- "node_modules/@firstpick/pi-extension-tools/index.ts",
2220
- "node_modules/@firstpick/pi-package-questionnaire/index.ts",
2221
- ]) {
2222
- assert.ok(pkg.pi?.extensions?.includes(extensionPath), `webui Pi manifest should load ${extensionPath} when present`);
2223
- }
2224
- for (const siblingExtensionPath of [
2225
- "../pi-extension-bang-command-autocomplete/index.ts",
2226
- "../pi-extension-fish-user-bash/index.ts",
2227
- "../pi-extension-git-footer-status/index.ts",
2228
- "../pi-extension-release-aur/index.ts",
2229
- "../pi-extension-release-npm/index.ts",
2230
- "../pi-extension-safety-guard/index.ts",
2231
- "../pi-extension-setup-skills/index.ts",
2232
- "../pi-extension-stats/index.ts",
2233
- "../pi-extension-todo-progress/index.ts",
2234
- "../pi-extension-tools/index.ts",
2230
+ for (const name of [
2231
+ "@firstpick/pi-package-natural-conversation",
2232
+ "@firstpick/pi-package-questionnaire",
2233
+ "@firstpick/pi-extension-aur-review",
2235
2234
  ]) {
2236
- assert.ok(!pkg.pi?.extensions?.includes(siblingExtensionPath), `webui Pi manifest should avoid duplicate sibling load path ${siblingExtensionPath}`);
2235
+ assert.equal(pkg.optionalDependencies?.[name], undefined, `webui package should keep ${name} as a separate Pi package`);
2236
+ assert.equal(pkg.dependencies?.[name], undefined, `webui package should not require separate Pi package ${name}`);
2237
2237
  }
2238
+ assert.deepEqual(pkg.optionalDependencies, { "node-pty": "^1.1.0" }, "node-pty should be the sole optional Web UI runtime dependency");
2239
+ assert.equal(pkg.bundledDependencies, undefined, "webui optional companion packages should not be bundled into the tarball");
2240
+ assert.deepEqual(pkg.pi?.extensions, ["./index.ts", "./session-summary.ts"], "webui Pi manifest should load its core and focused session-summary extensions");
2241
+ assert.equal(pkg.pi?.skills, undefined, "webui Pi manifest should not own companion skills");
2242
+ assert.equal(pkg.pi?.prompts, undefined, "webui Pi manifest should not own companion prompts");
2243
+ assert.equal(pkg.pi?.themes, undefined, "webui Pi manifest should not own companion themes");
2238
2244
  assert.match(helper, /function installRpcUserBashSupport\(\)/, "Web UI RPC helper should patch RPC bash execution for user_bash events");
2239
2245
  assert.match(helper, /runner\?\.hasHandlers\?\.\("user_bash"\)[\s\S]*runner\.emitUserBash/, "Web UI RPC helper should emit user_bash before default bash execution");
2240
2246
  assert.match(helper, /eventResult\?\.operations[\s\S]*original\.call\(this, command, onChunk, nextOptions\)/, "Web UI RPC helper should pass extension-provided bash operations to Pi execution");
2241
2247
  assert.match(helper, /eventResult\?\.result[\s\S]*recordBashResult/, "Web UI RPC helper should preserve extension-provided bash results in session history");
2242
- assert.ok(pkg.pi?.skills?.includes("node_modules/@firstpick/pi-extension-release-aur/skills"), "webui Pi manifest should load release-aur nested skills when present");
2243
- assert.ok(pkg.pi?.skills?.includes("node_modules/@firstpick/pi-package-questionnaire/skills"), "webui Pi manifest should load questionnaire guidance only when the optional package is installed");
2244
- assert.ok(!pkg.pi?.skills?.includes("../pi-extension-release-aur/skills"), "webui Pi manifest should avoid duplicate release-aur sibling skills");
2245
- assert.ok(pkg.pi?.prompts?.includes("node_modules/@firstpick/pi-prompts-git-pr/prompts"), "webui Pi manifest should load guided-git nested prompts when present");
2246
- assert.ok(!pkg.pi?.prompts?.includes("../pi-package-prompts-git-pr/prompts"), "webui Pi manifest should avoid duplicate guided-git sibling prompts");
2247
- assert.ok(pkg.pi?.themes?.includes("node_modules/@firstpick/pi-themes-bundle/themes"), "webui Pi manifest should load nested bundled themes when present");
2248
- assert.ok(!pkg.pi?.themes?.includes("../pi-package-themes-bundle/themes"), "webui Pi manifest should avoid duplicate sibling bundled themes");
2249
2248
  assert.ok(pkg.scripts?.check?.includes("node --check public/app.js"), "check script should syntax-check app.js");
2250
2249
  assert.ok(pkg.scripts?.check?.includes("node tests/run-all.mjs"), "check script should run the shared test runner");
2251
2250
 
@@ -46,6 +46,8 @@ assert.throws(() => requireLocalhostRoute(remoteReq, "/api/component-update"), (
46
46
  assert.doesNotThrow(() => requireLocalhostRoute(localReq, "/api/update"));
47
47
  assert.doesNotThrow(() => requireLocalhostRoute(localReq, "/api/component-update"));
48
48
  assert.ok(LOCALHOST_ONLY_POST_ROUTES.has("/api/workflow-policy"), "workflow policy mutation must stay in the canonical localhost route registry");
49
+ assert.equal(LOCALHOST_ONLY_POST_ROUTES.has("/api/session-summary/preferences"), false, "authenticated remote clients are allowed to save summary setup after confirmation");
50
+ assert.equal(LOCALHOST_ONLY_POST_ROUTES.has("/api/session-summary/generate"), false, "authenticated remote clients are allowed to trigger summary generation");
49
51
 
50
52
  for (const pathname of LOCALHOST_ONLY_POST_ROUTES.keys()) {
51
53
  assert.match(pathname, /^\/api\//, `${pathname} should be an API route`);
@@ -57,6 +59,12 @@ for (const guard of parity.guardTaxonomy) {
57
59
 
58
60
  const exportGuards = guardsForNativeCommand("export", parity);
59
61
  assert.ok(exportGuards.includes("localhost"), "export should declare localhost guard in parity matrix");
62
+ for (const command of ["summary", "summary-setup"]) {
63
+ const guards = guardsForNativeCommand(command, parity);
64
+ assert.deepEqual(guards, ["confirmation"], `/${command} should require disclosure confirmation but remain available to authenticated remote clients`);
65
+ assert.equal(evaluateDispatchTrustGuards(guards, { isLocal: false, confirmed: false, networkOpen: true }).allowed, true, `/${command} transport dispatch should not add a localhost-only block`);
66
+ assert.equal(evaluateTrustGuards(guards, { isLocal: false, confirmed: false, networkOpen: true }).allowed, false, `/${command} full evaluation should require confirmation`);
67
+ }
60
68
 
61
69
  const exportDispatchLocal = evaluateDispatchTrustGuards(exportGuards, { isLocal: true, confirmed: false });
62
70
  const exportDispatchRemote = evaluateDispatchTrustGuards(exportGuards, { isLocal: false, confirmed: false, networkOpen: true });
@@ -132,7 +140,7 @@ for (const target of ["state", "tabs", "commands", "themes", "workspace"]) {
132
140
  }
133
141
 
134
142
  const slashCommands = nativeSlashCommandEntries(parity);
135
- assert.equal(slashCommands.length, 27);
143
+ assert.equal(slashCommands.length, 29);
136
144
  assert.equal(slashCommands[0].name, "settings");
137
145
  assert.equal(slashCommands.at(-1).name, "quit");
138
146
 
@@ -56,6 +56,8 @@ const requiredNativeCommands = [
56
56
  "safety-guard-setup",
57
57
  "git-workflow-setup",
58
58
  "workflow-setup",
59
+ "summary",
60
+ "summary-setup",
59
61
  "model",
60
62
  "theme",
61
63
  "scoped-models",
@@ -94,6 +96,14 @@ assert.equal(workflowSetupSurface.webStatus, "implemented", "/workflow-setup bro
94
96
  assert.equal(workflowSetupSurface.sensitive, true, "/workflow-setup should be tracked as a sensitive policy mutation");
95
97
  assert.deepEqual(workflowSetupSurface.guards, ["localhost", "confirmation"], "/workflow-setup should require both localhost and explicit confirmation guards");
96
98
 
99
+ for (const id of ["/summary", "/summary-setup"]) {
100
+ const surface = slashSurfaces.find((item) => item.id === id);
101
+ assert.ok(surface, `${id} should be represented in the native parity matrix`);
102
+ assert.equal(surface.webStatus, "implemented", `${id} browser-native support should be implemented`);
103
+ assert.equal(surface.sensitive, true, `${id} sends or configures provider-bound session data`);
104
+ assert.deepEqual(surface.guards, ["confirmation"], `${id} should use explicit setup/disclosure confirmation without a localhost-only restriction`);
105
+ }
106
+
97
107
  const selectorMatch = app.match(/const NATIVE_SELECTOR_COMMANDS = new Set\(\[(.*?)\]\)/s);
98
108
  assert.ok(selectorMatch, "frontend native selector command set should be discoverable");
99
109
  const frontendSelectorCommands = [...selectorMatch[1].matchAll(/"([^"]+)"/g)].map((match) => match[1]);
@@ -141,7 +151,19 @@ assert.match(server, /url\.pathname === "\/api\/auth-providers" && req\.method =
141
151
  assert.match(server, /url\.pathname === "\/api\/auth-logout" && req\.method === "POST"/, "server should expose localhost-only POST /api/auth-logout");
142
152
  assert.match(server, /url\.pathname === "\/api\/workflow-policy" && req\.method === "GET"[\s\S]*requireLocalhost\(req, "Workflow policy setup is only allowed from localhost\."\)/, "workflow policy reads should be localhost-only");
143
153
  assert.match(server, /url\.pathname === "\/api\/workflow-policy" && req\.method === "POST"[\s\S]*requireLocalhostRoute\(req, url\.pathname\)[\s\S]*requireWorkflowPolicyJsonRequest\(req\)[\s\S]*expectedRevision: body\.expectedRevision/, "workflow policy saves should be registry-guarded, same-origin JSON, and revision protected");
144
- assert.match(app, /name === "workflow-setup" && !hasLoadedRpcCommand\(name\)[\s\S]*case "workflow-setup":[\s\S]*openNativeWorkflowSetupDialog\(\)/, "frontend should gate exact /workflow-setup native routing on the active tab's loaded extension catalog");
154
+ assert.match(app, /\(name === "workflow-setup" \|\| name === "summary" \|\| name === "summary-setup"\) && !hasLoadedRpcCommand\(name\)[\s\S]*case "workflow-setup":[\s\S]*openNativeWorkflowSetupDialog\(\)/, "frontend should gate exact summary and setup commands on the active Pi tab's loaded extension catalog");
155
+ assert.ok(app.includes('const summaryMatch = String(message || "").trim().match(/^\\/summary(?:\\s+(refresh))?$/i);'), "frontend should intercept only exact /summary and /summary refresh command forms");
156
+ assert.match(app, /case "summary":[\s\S]*openSessionSummaryForTab\(activeTabId, \{ refresh: summaryMatch\?\.\[1\][\s\S]*case "summary-setup":[\s\S]*openNativeSessionSummarySetupDialog\(\)/, "frontend should route exact summary commands to the non-blocking overlay without normal prompt dispatch");
157
+ assert.match(app, /async function openSessionSummaryForTab\(tabId = activeTabId, \{ refresh = false \} = \{\}\)[\s\S]*hasAvailableCommand\("summary", \{ tabId \}\)[\s\S]*preferences\?\.configured[\s\S]*openNativeSessionSummarySetupDialog[\s\S]*openSessionSummaryOverlay[\s\S]*requestSessionSummaryGeneration\(tabId, \{ refresh \}\)/, "frontend /summary action should remain catalog-gated, open setup when needed, and force exact refresh requests");
158
+ assert.match(app, /function normalizeSessionSummaryClientState\(value, previous = null, \{ resetProjection = false \} = \{\}\)[\s\S]*sessionChanged[\s\S]*resetProjection \|\| sessionChanged \? null : previous[\s\S]*function handleSessionSummaryEvent\(event\)[\s\S]*resetProjection: event\?\.kind === "state"/, "client projection should clear across session IDs and active-branch state events while preserving ordinary failure state");
159
+ assert.match(app, /title: "Save session summary setup\?"[\s\S]*if \(!reviewed\) return;[\s\S]*confirmed: true[\s\S]*requestSessionSummaryGeneration/, "summary setup should require explicit privacy/cost confirmation before persistence and immediate first generation");
160
+ assert.match(server, /args\.includes\(sessionSummaryExtensionPath\)[\s\S]*args\.push\("--extension", sessionSummaryExtensionPath\)/, "each WebUI child should explicitly receive the package-owned summary extension");
161
+ assert.match(server, /url\.pathname === "\/api\/session-summary\/preferences" && req\.method === "GET"[\s\S]*url\.pathname === "\/api\/session-summary\/preferences" && req\.method === "PUT"[\s\S]*url\.pathname === "\/api\/session-summary\/generate" && req\.method === "POST"/, "server should expose authenticated tab-scoped preferences and generation routes");
162
+ assert.match(server, /function requireSessionSummaryJsonRequest\(req\)[\s\S]*application\/json[\s\S]*same-origin/, "summary mutations should fail closed on cross-origin-simple request shapes");
163
+ assert.match(server, /function publicSessionSummaryPreferences\(value\)[\s\S]*scope: "text-and-tool-names"[\s\S]*preferences: publicSessionSummaryPreferences\(storedPreferences\)/, "summary preference responses should project only approved bounded fields instead of exposing preserved unknown keys");
164
+ assert.match(server, /tab\.titleSource === "default" \|\| tab\.titleSource === "auto"[\s\S]*renameTab\(tab, details\.title, \{ source: "auto"/, "summary title bridge should preserve explicit tab names");
165
+ assert.match(server, /filterSessionSummaryTranscriptMessages[\s\S]*SESSION_SUMMARY_RPC_TYPE[\s\S]*SESSION_SUMMARY_DISPLAY_TYPE/, "summary control and display messages should remain outside the normal WebUI transcript");
166
+ assert.match(server, /const SESSION_SUMMARY_GENERATE_TIMEOUT_MS = 105 \* 1000[\s\S]*async function triggerSessionSummary[\s\S]*SESSION_SUMMARY_GENERATE_TIMEOUT_MS[\s\S]*status: "failure"[\s\S]*broadcastSessionSummaryState\(tab, "failure"\)[\s\S]*throw error/, "summary RPC dispatch should use the extension-scale timeout and broadcast bounded terminal failure before rethrowing");
145
167
  assert.match(app, /title: "Save reviewed workflow permission ceiling\?"[\s\S]*if \(!reviewed\) return;[\s\S]*body: \{ policy: policyToSave, expectedRevision: data\.revision \?\? null \}/, "frontend should explicitly confirm the normalized workflow policy before revision-protected save");
146
168
  assert.match(server, /url\.pathname === "\/api\/native-parity" && req\.method === "GET"/, "server should expose the native parity matrix for clients/tests");
147
169
  assert.match(server, /const NATIVE_DOWNLOAD_TOKEN_TTL_MS = 10 \* 60 \* 1000/, "native downloads should use short-lived tokens");
@@ -69,7 +69,7 @@ assert.match(server, /"issue-bot-client\.mjs"/, "the static allowlist must serve
69
69
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
70
70
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
71
71
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
72
- assert.match(serviceWorker, /pi-webui-pwa-v71/, "the PWA cache name must change with browser wiring updates");
72
+ assert.match(serviceWorker, /pi-webui-pwa-v72/, "the PWA cache name must change with browser wiring updates");
73
73
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
74
74
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
75
75
 
@@ -0,0 +1,75 @@
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, html, css, readme] = await Promise.all([
8
+ readFile(join(root, "public", "app.js"), "utf8"),
9
+ readFile(join(root, "public", "index.html"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "README.md"), "utf8"),
12
+ ]);
13
+
14
+ function sourceBetween(startMarker, endMarker) {
15
+ const start = app.indexOf(startMarker);
16
+ const end = app.indexOf(endMarker, start + startMarker.length);
17
+ assert.ok(start >= 0 && end > start, `expected ${startMarker} before ${endMarker}`);
18
+ return app.slice(start, end);
19
+ }
20
+
21
+ assert.match(html, /id="optionalFeatureMigrationSurface"[^>]*role="status"[^>]*aria-live="polite"[^>]*aria-atomic="false"/, "startup/migration feedback should have a polite non-atomic persistent status mount");
22
+ assert.match(html, /id="optionalFeatureMigrationDialog"[\s\S]*aria-labelledby="optionalFeatureMigrationDialogTitle"[\s\S]*id="optionalFeatureMigrationChooseDetails"[\s\S]*id="optionalFeatureMigrationConfirmButton"/, "migration should use one accessible combined confirmation with an optional Choose view");
23
+ assert.match(html, /id="optionalFeatureMigrationDialogError"[^>]*role="alert"/, "terminal dialog errors should be alerts");
24
+
25
+ const refreshSource = sourceBetween("async function refreshOptionalFeaturePackageStatuses", "function clearGitFooterPayloadState");
26
+ assert.match(refreshSource, /api\("\/api\/optional-features", \{ scoped: false \}\)/, "browser refresh should consume the cached server snapshot");
27
+ assert.doesNotMatch(refreshSource, /showDirectoryPicker|FileSystem|local-resource|node_modules|\.pi\/agent/, "browser refresh must not scan the host");
28
+
29
+ const surfaceSource = sourceBetween("function renderOptionalFeatureMigrationSurface", "function applyOptionalFeatureMigrationSnapshot");
30
+ assert.match(surfaceSource, /Checking optional features…[\s\S]*elapsed[\s\S]*Core ready/, "surface should expose checking elapsed time and a truthful ready summary");
31
+ assert.match(surfaceSource, /Previous optional features need migration[\s\S]*Migrate…[\s\S]*Later/, "action-required migration should expose Migrate and persisted Later actions");
32
+ assert.match(surfaceSource, /safely excluded[\s\S]*Copy recommended fix[\s\S]*Recheck/, "conflicts should explain safe exclusion using a recommended path-free fix and recheck");
33
+ assert.match(surfaceSource, /started safely without optional companions[\s\S]*Recheck/, "degraded startup should remain core-safe and recheckable");
34
+ assert.match(surfaceSource, /Migrating optional features[\s\S]*Retry failed[\s\S]*Copy commands[\s\S]*Restart tab/, "progress and recovery should expose the required sequential/retry/copy/deferred-restart actions");
35
+ assert.match(surfaceSource, /if \(optionalFeatureRestartNotice\.restartDeferred\)[\s\S]*Restart tab[\s\S]*else[\s\S]*Dismiss/, "a deferred restart action must remain persistent until restart succeeds");
36
+ assert.match(surfaceSource, /setAttribute\("role", "alert"\)/, "only conflict/partial terminal feedback should add alert semantics");
37
+ assert.match(surfaceSource, /optional-feature-migration-completion-summary[\s\S]*card\.focus/, "completion summary should receive focus once");
38
+ assert.doesNotMatch(surfaceSource, /percent|% complete/i, "package-manager progress must not fabricate percentages");
39
+
40
+ const dialogSource = sourceBetween("function renderOptionalFeatureMigrationDialog", "async function copyFailedOptionalFeatureCommands");
41
+ assert.match(dialogSource, /selectedByDefault === true[\s\S]*isOptionalFeatureDisabled/, "server defaults should be preselected while browser-disabled features stay unselected");
42
+ assert.match(dialogSource, /Previously enabled[\s\S]*Previously disabled[\s\S]*source:/, "expandable details should explain previous state and sanitized source kind");
43
+ assert.match(dialogSource, /This is the only confirmation before retry|only confirmation before Pi installs/i, "dialog copy should make the single confirmation boundary explicit");
44
+
45
+ const batchSource = sourceBetween("async function installOptionalFeatureBatch", "function runPublishWorkflow");
46
+ assert.match(batchSource, /body: \{ tab: activeTabId, featureIds, revision: optionalFeatureMigrationSnapshot\.revision, migration \}/, "every batch apply should send tab, cached revision, and migration intent");
47
+ assert.match(batchSource, /staleRevision[\s\S]*refreshOptionalFeaturePackageStatuses[\s\S]*refreshedSignature !== candidateSignature[\s\S]*optionalFeatureRevisionChurn/, "stale revisions should refetch, re-show on material candidate changes, retry silently once, and recover repeated churn without false failures");
48
+ assert.match(batchSource, /error\.optionalFeatureCandidatesChanged \|\| error\.optionalFeatureRevisionChurn[\s\S]*restoreOptionalFeatureInstallStates[\s\S]*reopen/, "candidate changes and repeated stale revisions should restore untouched rows and reopen the plan");
49
+ assert.match(batchSource, /for \(const feature of candidates\)[\s\S]*result\?\.ok === true[\s\S]*optionalFeatureInstallFailureFromBatchResult/, "partial batches should preserve and settle every per-feature terminal result");
50
+ assert.match(batchSource, /output\.slice\(-4000\)|slice\(-4000\)/, "localhost response output should remain bounded before entering activity/row feedback");
51
+ assert.match(batchSource, /restart\.autoRestarted \|\| restart\.restartDeferred[\s\S]*optionalFeatureRestartNotice/, "batch response restart fields should drive visible restart feedback");
52
+ assert.doesNotMatch(batchSource, /const reloadMessage|await appConfirmText\([^)]*Reload the active Pi tab/, "successful migration must not add a separate restart confirmation");
53
+
54
+ const eventSource = sourceBetween("function handleEvent(event)", "function connectEvents");
55
+ assert.match(eventSource, /webui_optional_feature_migration[\s\S]*applyOptionalFeatureMigrationSnapshot\(event\.snapshot\)/, "SSE migration snapshots should update reconnect-safe state");
56
+ assert.match(eventSource, /webui_optional_feature_restart_completed[\s\S]*webui_optional_feature_restart_deferred/, "SSE restart events should be consumed");
57
+ const progressRecoverySource = sourceBetween("function applyOptionalFeatureProgressStates", "function refreshOptionalFeatureMigrationElapsedText");
58
+ assert.match(progressRecoverySource, /progress\.restartDeferred === true[\s\S]*optionalFeatureRestartNotice/, "cached progress must rehydrate the deferred Restart action after a full browser reload");
59
+ assert.match(progressRecoverySource, /progress\.autoRestarted === true[\s\S]*optionalFeatureRestartNotice/, "cached progress should rehydrate the completed restart notice");
60
+ assert.match(app, /source\.onopen[\s\S]*refreshOptionalFeaturePackageStatuses\(\)/, "event-stream reconnect should recover the current cached server snapshot");
61
+ const timerSource = sourceBetween("function refreshOptionalFeatureMigrationElapsedText", "function optionalFeatureMigrationAction");
62
+ assert.doesNotMatch(timerSource, /renderOptionalFeatureMigrationSurface\(\)/, "elapsed ticks must not replace and re-announce the entire live region");
63
+ assert.match(timerSource, /querySelector\("\.optional-feature-migration-detail"\)/, "elapsed ticks should update only the detail node");
64
+ assert.match(app, /const OPTIONAL_FEATURE_READY_AUTO_DISMISS_MS = 5_000;/, "a successful startup audit should remain readable briefly before dismissal");
65
+ assert.match(timerSource, /scheduleOptionalFeatureReadyDismiss[\s\S]*setTimeout[\s\S]*optionalFeatureReadyDismissKey\(\) !== key \|\| optionalFeatureRestartNotice[\s\S]*surface\.hidden = true/, "ready feedback should auto-dismiss only while the same ready snapshot remains non-actionable");
66
+ assert.match(surfaceSource, /readyCanAutoDismiss[\s\S]*scheduleOptionalFeatureReadyDismiss\(readyCanAutoDismiss \? readyDismissKey : ""\)/, "rendering should schedule dismissal only for non-actionable ready feedback");
67
+
68
+ assert.match(css, /\.optional-feature-migration-surface[\s\S]*\.optional-feature-migration-dialog[\s\S]*@media \(max-width: 34rem\)/, "migration surfaces should have desktop and responsive styling");
69
+ assert.match(css, /\.optional-feature-migration-card:focus-visible/, "focused completion summary should have a visible focus treatment");
70
+
71
+ assert.match(readme, /read-only startup audit/i, "README should document startup auditing");
72
+ assert.match(readme, /--migrate-optional-features[\s\S]*--migration-dry-run/, "README should document explicit unattended migration and dry-run flags");
73
+ assert.match(readme, /Retry failed[\s\S]*Copy commands[\s\S]*Recheck/i, "README should document migration troubleshooting actions");
74
+
75
+ console.log("optional feature migration frontend static tests passed");