@firstpick/pi-package-webui 0.8.7 → 0.8.9

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 (41) hide show
  1. package/README.md +5 -0
  2. package/bin/pi-webui-rpc-supervisor.mjs +4 -1
  3. package/bin/pi-webui.mjs +9 -1
  4. package/lib/rpc-supervisor-protocol.mjs +6 -1
  5. package/package.json +1 -1
  6. package/public/app.js +679 -128
  7. package/public/index.html +49 -13
  8. package/public/service-worker.js +1 -1
  9. package/public/styles.css +836 -16
  10. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  11. package/tests/browser/interaction-continuity.spec.mjs +58 -0
  12. package/tests/browser/mobile-foundation.spec.mjs +363 -5
  13. package/tests/browser/optimistic-prompt.spec.mjs +24 -10
  14. package/tests/browser/persistent-ui-layout.spec.mjs +2 -0
  15. package/tests/browser/side-panel-section-reorder.spec.mjs +16 -1
  16. package/tests/codex-fast-mode-static.test.mjs +2 -2
  17. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  18. package/tests/fast-mode-client-static.test.mjs +1 -1
  19. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  20. package/tests/file-tree-search-layout-static.test.mjs +261 -0
  21. package/tests/fixtures/fake-pi.mjs +6 -2
  22. package/tests/http-endpoints-harness.test.mjs +6 -2
  23. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  24. package/tests/mobile-compact-layout.test.mjs +60 -0
  25. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  26. package/tests/mobile-foundation-static.test.mjs +12 -12
  27. package/tests/mobile-phone-experience-static.test.mjs +2 -2
  28. package/tests/mobile-static.test.mjs +226 -21
  29. package/tests/open-issue-wizard-static.test.mjs +1 -1
  30. package/tests/optional-feature-migration-frontend.test.mjs +4 -0
  31. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  32. package/tests/prompt-routing-tab-status.test.mjs +8 -0
  33. package/tests/questionnaire-dialog.test.mjs +3 -3
  34. package/tests/rpc-supervisor-host.test.mjs +18 -1
  35. package/tests/rpc-supervisor-protocol.test.mjs +5 -0
  36. package/tests/session-sampling-ui-static.test.mjs +3 -3
  37. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  38. package/tests/side-panel-section-reorder-static.test.mjs +23 -10
  39. package/tests/streaming-ui-coupling.test.mjs +8 -0
  40. package/tests/terminal-tab-workspace-static.test.mjs +15 -1
  41. package/tests/theme-customizer-static.test.mjs +1 -1
@@ -155,7 +155,7 @@ assert.match(html, /id="pathPickerClearSearchButton"[^>]*hidden[^>]*>Clear<\/but
155
155
  assert.match(app, /function fileTreeGitStatusForEntry\(entry = \{\}\) \{\s+return fileTreeState\.gitStatusByPath\.get\(normalizeFileTreePath\(entry\.path \|\| ""\)\) \|\| null;\s+\}/, "file tree rendering should use the refreshed Git-status snapshot instead of stale status embedded in cached entries");
156
156
  assert.match(app, /function fileTreeExpander\(expanded = false\)[\s\S]*make\("span", "file-tree-expander", expanded \? "▾" : "▸"\)[\s\S]*aria-hidden/, "file tree arrows should be visual children rather than separate buttons");
157
157
  assert.match(app, /function appendFileTreeEntry\(parent, entry, depth = 0\)[\s\S]*button\.append\([\s\S]*isDirectory \? fileTreeExpander\(expanded\)[\s\S]*file-tree-name[\s\S]*button\.addEventListener\("click"[\s\S]*toggleFileTreeDirectory\(path\)[\s\S]*item\.append\(button, fileTreeOverflowButton\(entry\)\)/, "each directory arrow and label should share one expansion button");
158
- assert.match(app, /function appendFileSearchEntry\(parent, entry\)[\s\S]*button\.append\([\s\S]*isDirectory \? fileTreeExpander\(false\)[\s\S]*button\.addEventListener\("click"[\s\S]*revealFileTreeEntry\(entry\)[\s\S]*item\.append\(button, fileTreeOverflowButton\(entry\)\)/, "directory search results should also combine their arrow and label action");
158
+ assert.match(app, /function appendFileSearchEntry\(parent, entry\)[\s\S]*button\.append\([\s\S]*isDirectory \? fileTreeExpander\(expanded\)[\s\S]*button\.addEventListener\("click"[\s\S]*toggleFileTreeDirectory\(path\)[\s\S]*item\.append\(button, fileTreeOverflowButton\(entry\)\)/, "directory search results should combine their arrow and label action while toggling in place");
159
159
  assert.match(css, /\.file-tree-node \{[\s\S]*grid-template-columns: minmax\(0, 1fr\) auto[\s\S]*\.file-tree-item \{[\s\S]*grid-template-columns: auto auto minmax\(0, 1fr\) auto auto/, "file tree layout should reserve one row button plus the overflow action while keeping the arrow inside the row button");
160
160
  assert.match(app, /confirmLabel: activeAgentTabs\.length \? "Close and stop work" : count === 1 \? "Close tab" : "Close tabs"/, "single-tab confirmation should use singular close wording");
161
161
  assert.match(html, /data-side-panel-section="git"[\s\S]*class="side-panel-section-label">Git<[\s\S]*id="gitPanelCountBadge"[\s\S]*id="gitPanelGroups"[\s\S]*aria-label="Git repositories"[\s\S]*id="gitPanelContextMenu"[\s\S]*role="menu"/, "side panel should expose a collapsed, globally deduplicated Git repository list with a count and dedicated action menu");
@@ -457,8 +457,8 @@ assert.match(css, /button, select, input \{ min-height: 44px; \}/, "base control
457
457
  assert.match(css, /\.composer-row button \{\n\s+width:\s*100%;\n\s+min-height:\s*44px/, "mobile composer buttons should retain compact layout with 44px footer hit areas");
458
458
  assert.match(css, /\.composer-abort-button,\n\.composer-row button\.primary \{[\s\S]*?min-width:/, "Abort and Send should share stable bottom-row sizing");
459
459
  assert.match(css, /\.composer-abort-button\.long-pressing::after[\s\S]*?animation:\s*abort-long-press-fill var\(--abort-long-press-duration, 3000ms\) linear forwards/, "Abort should expose a visible 3-second long-press progress affordance");
460
- assert.match(css, /body\.pi-run-active:not\(\.mobile-keyboard-open\) \.composer-abort-button:not\(\[hidden\]\) \{\n\s+order:\s*1;\n\s+grid-column:\s*span 2;/, "active mobile runs should move Abort to the top row");
461
- assert.match(css, /body\.pi-run-active:not\(\.mobile-keyboard-open\) \.composer-actions-button \{ order:\s*4; \}[\s\S]*?body\.pi-run-active:not\(\.mobile-keyboard-open\) \.composer-btw-button:not\(\[hidden\]\) \{\n\s+order:\s*5;\n\s+grid-column:\s*span 2;[\s\S]*?body\.pi-run-active:not\(\.mobile-keyboard-open\) \.composer-row button\.primary \{\n\s+order:\s*6;\n\s+grid-column:\s*span 2;/, "active mobile runs should keep Actions, /btw, and Send on the bottom row");
460
+ assert.match(css, /body\.mobile-composer-disclosure \.composer-row \{[\s\S]*?grid-template-columns:\s*repeat\(5, minmax\(0, 1fr\)\)/, "mobile composer should reserve one compact row for primary run controls");
461
+ assert.match(css, /body\.mobile-composer-disclosure\.pi-run-active:not\(\.mobile-keyboard-open\) \.composer-row > #abortButton \{ order:\s*1; \}[\s\S]*?#steerButton \{ order:\s*2; \}[\s\S]*?#followUpButton \{ order:\s*3; \}[\s\S]*?\.composer-actions-button \{ order:\s*4; \}[\s\S]*?#sendButton \{ order:\s*5; \}/, "active mobile runs should keep Abort, Steer, Follow-up, More, and Send on one ordered row");
462
462
  assert.match(css, /#promptInput \{[\s\S]*?min-height:\s*calc\(1\.5em \+ 1\.8rem\)/, "prompt input should default to a compact single-line height");
463
463
  assert.match(css, /#promptInput \{[\s\S]*?overflow-y:\s*hidden/, "prompt input should be JS-resized instead of showing a scrollbar by default");
464
464
  assert.match(css, /\.composer-context-tags \{[\s\S]*?top:\s*-0\.48rem;[\s\S]*?left:\s*0\.75rem;/, "busy prompt behavior and skill tags should sit at the top-left of the input frame");
@@ -625,10 +625,11 @@ assert.match(css, /\.composer-actions-panel > \.composer-options-menu \.composer
625
625
  assert.match(css, /\.composer-actions-panel > \.composer-publish-menu \.composer-auto-height-menu-panel \{[\s\S]*?height:\s*auto;[\s\S]*?max-height:\s*none;[\s\S]*?overflow:\s*visible;[\s\S]*?overflow-y:\s*visible;/, "mobile content-height menus should grow with their active commands without an internal scrollbar");
626
626
  assert.match(css, /\.composer-native-command-menu-item \{[\s\S]*?color:\s*var\(--ctp-mauve\)/, "skills/tools command menu items should be styled separately from publish actions");
627
627
  assert.match(css, /\.composer-actions-panel > \.composer-publish-menu[\s\S]*?grid-column: span 1/, "Publish and command menu buttons should fit beside Git workflow in mobile actions");
628
- assert.match(css, /\.composer-actions-panel[\s\S]*?bottom:\s*calc\(100% \+ 0\.42rem\)/, "mobile composer actions should open as an above-composer sheet");
628
+ assert.match(css, /body\.mobile-composer-disclosure \.composer-actions-panel \{[\s\S]*?position:\s*fixed;[\s\S]*?inset:\s*0;[\s\S]*?width:\s*100vw;[\s\S]*?height:\s*var\(--visual-viewport-height, 100dvh\);[\s\S]*?max-height:\s*none;/, "mobile composer actions should open as a full-screen visual-viewport overlay");
629
629
  assert.match(css, /body\.composer-actions-open \.composer-actions-panel \{ display: grid; \}/, "composer actions panel should only open when toggled");
630
630
  assert.match(css, /\.terminal-tabs-toggle-button \{ display: none; \}/, "terminal tab toggle should be hidden outside mobile CSS");
631
- assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.terminal-command-palette-button,\n\s+\.terminal-dashboard-button \{[\s\S]*?display:\s*inline-grid;/, "mobile header should keep the command palette button visible beside the dashboard button");
631
+ assert.match(html, /id="terminalTabsDrawerContent"[^>]*aria-label="Terminal navigation"[\s\S]*class="terminal-sidebar-actions"[^>]*aria-label="Tab and workspace actions"[\s\S]*id="closeAllTabsButton"/, "mobile terminal disclosure should group canonical tabs and workspace actions in one labelled drawer");
632
+ assert.match(html, /id="terminalTabsBackdrop"[^>]*aria-label="Close terminal navigation"[^>]*hidden/, "mobile terminal drawer should expose an accessible backdrop close target");
632
633
  assert.match(css, /\.command-palette-close-button \{[\s\S]*?min-width:\s*44px;[\s\S]*?min-height:\s*44px/, "command palette close button should meet touch-target sizing by default");
633
634
  assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-dialog \{[\s\S]*?width:\s*min\(100vw - 0\.5rem, 42rem\)[\s\S]*?\.command-palette-list \{[\s\S]*?align-content:\s*start;[\s\S]*?grid-auto-rows:\s*max-content;[\s\S]*?scrollbar-gutter:\s*auto;[\s\S]*?\.command-palette-item \{[\s\S]*?grid-template-columns:\s*minmax\(3\.4rem, 0\.26fr\) minmax\(0, 1fr\);[\s\S]*?min-height:\s*2\.72rem;/, "mobile command palette results should keep text-height rows and use compact two-column cards");
634
635
  assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-item-kind \{[\s\S]*?font-size:\s*var\(--text-xs\);[\s\S]*?\.command-palette-item-label \{ font-size:\s*0\.82rem; \}[\s\S]*?\.command-palette-item-description \{ font-size:\s*var\(--text-xs\); \}/, "mobile command palette result text should respect the typography floor");
@@ -652,8 +653,9 @@ assert.match(css, /\.terminal-new-tab-menu \.composer-publish-menu-item \{[\s\S]
652
653
  assert.match(css, /\.terminal-close-all-button \{[\s\S]*?color:\s*var\(--ctp-red\)/, "close-all tabs action should render as a top-right destructive tab action");
653
654
  assert.match(css, /\.terminal-tabs\.terminal-tabs-dense \{[\s\S]*?flex-wrap:\s*wrap/, "large terminal tab sets should wrap into a readable dense tab strip");
654
655
  assert.match(css, /\.terminal-tab-group-close \{[\s\S]*?border-left-color/, "terminal tab groups should style their close button distinctly");
655
- assert.match(css, /body\.mobile-tabs-expanded \.terminal-tabs \{ display: flex; \}/, "mobile tabs should expand only when toggled");
656
- assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\) \{[\s\S]*?\.terminal-tabs \{\n\s+position:\s*absolute;[\s\S]*?top:\s*calc\(100% \+ 0\.35rem\);[\s\S]*?overscroll-behavior:\s*contain;[\s\S]*?-webkit-overflow-scrolling:\s*touch;/, "expanded mobile tabs should overlay below the header with contained touch scrolling");
656
+ assert.match(css, /body\.mobile-tabs-expanded \.terminal-tabs-shell \{[\s\S]*?position:\s*fixed;[\s\S]*?top:\s*0;[\s\S]*?right:\s*0;[\s\S]*?left:\s*0;[\s\S]*?width:\s*100vw;[\s\S]*?height:\s*var\(--visual-viewport-height, 100dvh\);[\s\S]*?border-radius:\s*0;/, "expanded mobile terminal navigation should fill the visual viewport");
657
+ assert.match(css, /body\.mobile-tabs-expanded \.terminal-tabs-backdrop:not\(\[hidden\]\) \{[\s\S]*?position:\s*fixed;[\s\S]*?z-index:\s*121;[\s\S]*?backdrop-filter:\s*blur\(4px\)/, "expanded mobile terminal navigation should dim the inactive surface behind it");
658
+ assert.match(css, /body\.mobile-tabs-expanded \.terminal-tabs \{[\s\S]*?position:\s*static;[\s\S]*?flex-direction:\s*column;[\s\S]*?overflow-y:\s*auto;/, "expanded full-screen mobile terminal tabs should use the canonical vertical interaction model");
657
659
  assert.match(css, /\.terminal-tab-activity-indicator/, "terminal tabs should expose per-tab agent activity indicators");
658
660
  assert.match(css, /\.terminal-tab-app-runner-indicator \{[\s\S]*?terminal-tab-app-runner-pulse/, "terminal tabs should expose animated app-runner indicators");
659
661
  assert.match(css, /\.terminal-tab\.app-runner-running,\n\.terminal-tab-group-item\.app-runner-running/, "terminal tabs and grouped items should mark running app runners");
@@ -670,11 +672,14 @@ assert.match(css, /\.terminal-tab\.activity-blocked[\s\S]*?rgba\(250, 179, 135/,
670
672
  assert.match(css, /\.terminal-tab\.activity-blocked > \.terminal-tab-button \.terminal-tab-activity-indicator[\s\S]*?background:\s*var\(--ctp-peach\)/, "blocked tab indicator dots should be orange");
671
673
  assert.doesNotMatch(css, /\.terminal-tab\.activity-(?:working|blocked|done)\s+\.terminal-tab-activity-indicator/, "group status styling should not cascade into child tabs in the group menu");
672
674
  assert.match(css, /\.terminal-tab\.activity-done/, "completed unseen work should have a distinct tab style");
673
- assert.match(css, /\.terminal-tabs[\s\S]*?position:\s*absolute/, "expanded mobile tabs should overlay instead of consuming transcript space");
675
+ assert.match(app, /function setMobileTabsExpanded\(expanded, \{ restoreFocus = false \} = \{\}\)[\s\S]*?setComposerActionsOpen\(false\)[\s\S]*?terminalTabsBackdrop\.hidden = !mobileTabsExpanded[\s\S]*?focusReturn\.focus/, "mobile terminal drawer should coordinate competing surfaces, backdrop state, and focus return");
674
676
  assert.match(css, /body\.mobile-keyboard-open \.terminal-tabs-shell,[\s\S]*?body\.mobile-keyboard-open \.widget-area,[\s\S]*?body\.mobile-keyboard-open \.statusbar/, "mobile keyboard mode should hide header, widgets, and footer");
675
677
  assert.match(css, /body\.mobile-keyboard-open \.composer-actions-button,[\s\S]*?body\.mobile-keyboard-open \.composer-actions-panel/, "mobile keyboard mode should hide the secondary actions sheet while keeping active-run controls available");
676
678
  assert.match(css, /\.server-offline-panel/, "PWA/offline shell should style a backend-offline recovery panel");
677
- assert.match(css, /body:not\(\.pi-run-active\):not\(\.mobile-keyboard-open\) \.composer-row button\.primary \{ grid-column: span 2; \}[\s\S]*?body:not\(\.pi-run-active\):not\(\.mobile-keyboard-open\) \.composer-btw-button\[hidden\] \+ button\.primary \{ grid-column: span 4; \}/, "idle mobile composer should keep Actions, /btw, and Send on one compact row with a hidden-button fallback");
679
+ assert.match(html, /id="composerActionsPanel"[^>]*aria-label="More composer actions"[\s\S]*Session &amp; workspace[\s\S]*Tools &amp; commands[\s\S]*Context &amp; modes/, "secondary mobile composer controls should be grouped in task order");
680
+ assert.match(app, /function syncMobileComposerDisclosureLayout\(\)[\s\S]*?isMobileView\(\) && !isMobileShellV2Active\(\)[\s\S]*?composerActionsPanel\.append\(node\)/, "legacy mobile should reuse canonical secondary composer controls inside the expandable panel");
681
+ assert.match(css, /body\.mobile-composer-disclosure:not\(\.pi-run-active\):not\(\.mobile-keyboard-open\) \.composer-row > \.composer-actions-button \{[\s\S]*?grid-column:\s*span 2;[\s\S]*?#sendButton \{[\s\S]*?grid-column:\s*span 3;/, "idle mobile composer should show only More and Send beneath the prompt and attachment row");
682
+ assert.match(css, /body\.mobile-composer-disclosure\.mobile-keyboard-open \.composer-row \{[\s\S]*?repeat\(4,[\s\S]*?body\.mobile-composer-disclosure\.mobile-keyboard-open \.composer-actions-button,[\s\S]*?display:\s*none !important/, "keyboard-open mobile composer should retain primary run controls while hiding secondary disclosure chrome");
678
683
  assert.match(css, /\[hidden\] \{ display: none !important; \}/, "hidden controls should not occupy layout space or be overridden by component display styles");
679
684
  assert.match(css, /\.statusbar-tui-footer \{[\s\S]*?gap:\s*0/, "default TUI-like footer should reduce statusbar chrome around the compact line");
680
685
  assert.match(css, /\.statusbar-git-footer \{[\s\S]*?--footer-chip-min-width:\s*7\.6rem;[\s\S]*?gap:\s*0\.58rem/, "enabled git-footer extension should keep styled spacing and one shared minimal chip width token");
@@ -707,8 +712,182 @@ assert.match(server, /"\/api\/git-operation\/resolve-with-agent"[\s\S]*openGitCo
707
712
  assert.match(app, /async function pullGitChangesDialog\(\)[\s\S]*api\("\/api\/git-changes\/pull", \{ method: "POST"/, "git changes modal should post to the pull endpoint from the Pull button");
708
713
  assert.match(app, /async function pullGitFooterSync\(tabId = activeTabId\)[\s\S]*api\("\/api\/git-changes\/pull", \{ method: "POST", body: \{ remote: "origin" \}, tabId \}\)[\s\S]*requestGitFooterWebuiPayload\(tabContext, \{ force: true \}\)/, "incoming-only footer Sync should pull directly from origin and refresh the footer payload");
709
714
  assert.doesNotMatch(app.match(/async function pullGitFooterSync[\s\S]*?\n\}/)?.[0] || "", /git-workflow\/push|appConfirmText/, "the direct footer pull path should neither push nor open a confirmation");
710
- assert.match(app, /async function pushGitFooterSync\(tabId = activeTabId, syncValue = ""\)[\s\S]*api\("\/api\/git-workflow\/push", \{ method: "POST", body: \{\}, tabId \}\)[\s\S]*response\.code === "NON_FAST_FORWARD"[\s\S]*forceWithLease: true, confirmed: true/, "outgoing footer Sync should preserve confirmed push and guarded force-with-lease fallback behavior");
711
- assert.match(app, /chip\.key === "sync" && visible\("webui-sync-push"\)[\s\S]*syncAction === "pull"[\s\S]*pullGitFooterSync\(tabId\)[\s\S]*syncAction === "push"[\s\S]*pushGitFooterSync\(tabId, chip\.value\)/, "footer Sync should route incoming and outgoing states to their respective actions");
715
+ assert.match(html, /id="gitPullErrorDialog"[\s\S]*aria-labelledby="gitPullErrorDialogTitle"[\s\S]*id="gitPullErrorOutput"[\s\S]*id="gitPullErrorRecovery"[^>]*hidden[\s\S]*id="gitPullErrorReviewButton"[\s\S]*id="gitPullErrorRebaseButton"[\s\S]*id="gitPullErrorMergeButton"[\s\S]*id="gitPullErrorCopyButton"[\s\S]*id="gitPullErrorCloseButton"/, "footer pull failures should use a labelled native dialog with review, rebase, merge, copy, and close actions");
716
+ assert.match(css, /\.extension-dialog\.git-pull-error-dialog[\s\S]*\.git-pull-error-output \{[\s\S]*user-select: text;[\s\S]*white-space: pre-wrap;[\s\S]*\.git-pull-error-recovery-actions \{[\s\S]*flex-wrap: wrap;/, "Git pull error output and recovery actions should remain readable, selectable, and responsive");
717
+ assert.match(app, /function gitFailureDisplayText\(response[\s\S]*result\.stderr = ""[\s\S]*formatGitCommandResult\(result\)[\s\S]*seen\.has\(key\)/, "Git pull error formatting should remove exact duplicate stderr while retaining unique command details");
718
+ assert.match(app, /function openGitPullErrorDialog\(message, \{ code = "", tabId = null, syncValue = "" \} = \{\}\)[\s\S]*code === "DIVERGED"[\s\S]*This does not mean conflicts exist[\s\S]*gitPullErrorRecovery\.hidden = !diverged[\s\S]*gitPullErrorCloseButton\?\.classList\.toggle\("primary", !diverged\)[\s\S]*gitPullErrorDialog\.showModal\(\)/, "DIVERGED pull errors should explain conflict uncertainty and expose native recovery actions while standard errors retain a primary Close action");
719
+ assert.match(app, /async function integrateGitPullDivergence\(mode\)[\s\S]*appConfirmText[\s\S]*danger: !merge[\s\S]*gitFooterSyncInFlightByTab\.add\(tabId\)[\s\S]*\/api\/git-changes\/integrate[\s\S]*body: \{ mode, confirmed: true \}[\s\S]*gitPullErrorContext\.requestId !== requestId[\s\S]*response\.code === "CONFLICTS"[\s\S]*openGitChangesDialog\(tabId\)[\s\S]*freshAheadValue[\s\S]*gitFooterSyncInFlightByTab\.delete\(tabId\)/, "merge and rebase recovery should require confirmation, reject stale responses, serialize per-tab mutations, use fresh ahead counts, and route actual conflicts to Git Changes");
720
+ assert.match(app, /function reviewGitPullDivergence\(\)[\s\S]*closeGitPullErrorDialog\(\)[\s\S]*openGitChangesDialog\(tabId\)/, "review recovery should open Git Changes without integrating");
721
+ assert.match(app, /async function copyGitPullErrorOutput\(\)[\s\S]*copyText\(gitPullErrorText\)[\s\S]*Error output copied to the clipboard/, "Git pull error dialog should copy the complete displayed output");
722
+ assert.match(app, /async function pullGitFooterSync[\s\S]*if \(!response\.ok\)[\s\S]*gitFailureDisplayText\(response[\s\S]*openGitPullErrorDialog\(message, \{ code: response\.code \|\| "", tabId, syncValue \}\)/, "footer pull failures should route structured, deduplicated details into the native dialog");
723
+
724
+ const gitFailureDisplayStart = app.indexOf("function gitFailureDisplayText(");
725
+ const gitFailureDisplayEnd = app.indexOf("\nfunction setGitPullErrorBusy(", gitFailureDisplayStart);
726
+ assert.ok(gitFailureDisplayStart >= 0 && gitFailureDisplayEnd > gitFailureDisplayStart, "Git failure display formatter should remain a standalone helper");
727
+ const gitFailureDisplayContext = {
728
+ formatGitCommandResult(result) {
729
+ const lines = [`$ ${result?.command || "git"}`];
730
+ if (result?.stdout?.trim()) lines.push("", result.stdout.trim());
731
+ if (result?.stderr?.trim()) lines.push("", result.stderr.trim());
732
+ if (result?.exitCode !== 0) lines.push("", `[exit: ${result?.exitCode}]`);
733
+ return lines.join("\n");
734
+ },
735
+ };
736
+ vm.runInNewContext(`${app.slice(gitFailureDisplayStart, gitFailureDisplayEnd)}\nthis.formatFailure = gitFailureDisplayText;`, gitFailureDisplayContext);
737
+ const repeatedStderr = "fatal: Not possible to fast-forward, aborting.";
738
+ const deduplicatedPullError = gitFailureDisplayContext.formatFailure({
739
+ error: repeatedStderr,
740
+ hint: "Local and remote branches have diverged.",
741
+ data: { command: "git pull --ff-only origin", stderr: repeatedStderr, stdout: "", exitCode: 128 },
742
+ });
743
+ assert.equal(deduplicatedPullError.split(repeatedStderr).length - 1, 1, "identical pull stderr should appear exactly once");
744
+ assert.match(deduplicatedPullError, /git pull --ff-only origin[\s\S]*\[exit: 128\]/, "deduplication should preserve command and exit details");
745
+
746
+ const gitPullErrorDialogStart = app.indexOf("function setGitPullErrorBusy(");
747
+ const gitPullErrorDialogEnd = app.indexOf("\nasync function pullGitFooterSync(", gitPullErrorDialogStart);
748
+ assert.ok(gitPullErrorDialogStart >= 0 && gitPullErrorDialogEnd > gitPullErrorDialogStart, "Git pull error dialog helpers should remain isolated from the pull request helper");
749
+ const copiedPullErrors = [];
750
+ const integrationRequests = [];
751
+ const integrationConfirmations = [];
752
+ const reviewedPullTabs = [];
753
+ const refreshedPullTabs = [];
754
+ const resumedPushes = [];
755
+ let integrationResponse = { ok: true, data: { changes: { summary: { ahead: 2 } } } };
756
+ const nativePullErrorDialog = { open: false, showModal() { this.open = true; }, close() { this.open = false; }, setAttribute() {} };
757
+ const nativePullErrorTitle = { textContent: "" };
758
+ const nativePullErrorDescription = { textContent: "" };
759
+ const nativePullErrorOutput = { textContent: "" };
760
+ const nativePullErrorStatus = { textContent: "", classList: { add() {}, remove() {} } };
761
+ const nativePullErrorRecovery = { hidden: true };
762
+ const nativePullErrorButton = () => ({ disabled: false, focus() {}, classList: { toggle() {} } });
763
+ const nativePullErrorMergeButton = nativePullErrorButton();
764
+ const nativePullErrorRebaseButton = nativePullErrorButton();
765
+ const nativePullErrorReviewButton = nativePullErrorButton();
766
+ const nativePullErrorCopyButton = nativePullErrorButton();
767
+ const nativePullErrorCloseButton = nativePullErrorButton();
768
+ const gitPullErrorDialogContext = {
769
+ gitPullErrorText: "",
770
+ gitPullErrorContext: { code: "", tabId: null, syncValue: "", busy: false, requestId: 0 },
771
+ activeTabId: "tab-pull",
772
+ tabs: [{ id: "tab-pull", title: "feature/sync" }, { id: "tab-rebase", title: "feature/rebase" }],
773
+ gitFooterSyncInFlightByTab: new Set(),
774
+ elements: {
775
+ gitPullErrorDialog: nativePullErrorDialog,
776
+ gitPullErrorDialogTitle: nativePullErrorTitle,
777
+ gitPullErrorDialogDescription: nativePullErrorDescription,
778
+ gitPullErrorOutput: nativePullErrorOutput,
779
+ gitPullErrorStatus: nativePullErrorStatus,
780
+ gitPullErrorRecovery: nativePullErrorRecovery,
781
+ gitPullErrorMergeButton: nativePullErrorMergeButton,
782
+ gitPullErrorRebaseButton: nativePullErrorRebaseButton,
783
+ gitPullErrorReviewButton: nativePullErrorReviewButton,
784
+ gitPullErrorCopyButton: nativePullErrorCopyButton,
785
+ gitPullErrorCloseButton: nativePullErrorCloseButton,
786
+ },
787
+ window: { alert() { throw new Error("native dialog should avoid alert fallback"); } },
788
+ queueMicrotask: (callback) => callback(),
789
+ copyText: async (text) => copiedPullErrors.push(text),
790
+ addEvent() {},
791
+ gitFooterCurrentBranch: () => "feature/sync",
792
+ appConfirmText: async (message, options) => { integrationConfirmations.push({ message, options }); return true; },
793
+ api: async (path, options) => { integrationRequests.push({ path, options }); return integrationResponse; },
794
+ gitFailureDisplayText: () => "integration conflict output",
795
+ openGitChangesDialog: (tabId) => reviewedPullTabs.push(tabId),
796
+ activeTabContext: (tabId) => ({ tabId }),
797
+ isCurrentTabContext: () => false,
798
+ renderFooter() {},
799
+ requestGitFooterWebuiPayload: (context) => refreshedPullTabs.push(context.tabId),
800
+ gitFooterSyncCounts: () => ({ ahead: 1, behind: 0 }),
801
+ pushGitFooterSync: async (tabId, value) => resumedPushes.push({ tabId, value }),
802
+ };
803
+ vm.runInNewContext(`${app.slice(gitPullErrorDialogStart, gitPullErrorDialogEnd)}\nthis.openPullError = openGitPullErrorDialog; this.copyPullError = copyGitPullErrorOutput; this.reviewPullError = reviewGitPullDivergence; this.integratePullError = integrateGitPullDivergence;`, gitPullErrorDialogContext);
804
+ gitPullErrorDialogContext.openPullError("network unavailable\n\ncheck the connection", { code: "DIVERGED", tabId: "tab-pull", syncValue: "⇡1 · ⇣2" });
805
+ assert.equal(nativePullErrorDialog.open, true, "Git pull error dialog should open natively");
806
+ assert.equal(nativePullErrorTitle.textContent, "Branches diverged", "DIVERGED popup should use a specific title");
807
+ assert.match(nativePullErrorDescription.textContent, /does not mean conflicts exist/, "DIVERGED popup should distinguish divergence from conflicts");
808
+ assert.equal(nativePullErrorRecovery.hidden, false, "DIVERGED popup should reveal recovery actions");
809
+ assert.equal(integrationRequests.length, 0, "opening divergence recovery must not mutate Git state");
810
+ assert.equal(nativePullErrorOutput.textContent, "network unavailable\n\ncheck the connection", "Git pull error dialog should display complete output");
811
+ await gitPullErrorDialogContext.copyPullError();
812
+ assert.deepEqual(copiedPullErrors, ["network unavailable\n\ncheck the connection"], "Git pull error copy action should preserve the complete output");
813
+ assert.equal(nativePullErrorStatus.textContent, "Error output copied to the clipboard.", "Git pull error dialog should announce copy success");
814
+ gitPullErrorDialogContext.reviewPullError();
815
+ assert.deepEqual(reviewedPullTabs, ["tab-pull"], "Review changes should open Git Changes for the originating tab");
816
+ assert.equal(integrationRequests.length, 0, "Review changes must remain non-mutating");
817
+
818
+ gitPullErrorDialogContext.openPullError("diverged", { code: "DIVERGED", tabId: "tab-pull", syncValue: "⇡1 · ⇣2" });
819
+ assert.equal(await gitPullErrorDialogContext.integratePullError("merge"), true, "confirmed merge recovery should succeed");
820
+ assert.deepEqual(JSON.parse(JSON.stringify(integrationRequests[0])), { path: "/api/git-changes/integrate", options: { method: "POST", body: { mode: "merge", confirmed: true }, tabId: "tab-pull" } }, "merge recovery should use the confirmed integration contract");
821
+ assert.equal(integrationConfirmations[0].options.confirmLabel, "Merge changes", "merge recovery should be the primary confirmed action");
822
+ assert.equal(integrationConfirmations[0].options.danger, false, "merge confirmation should use the normal primary style");
823
+ assert.deepEqual(refreshedPullTabs, ["tab-pull"], "successful integration should refresh the originating footer");
824
+ assert.deepEqual(resumedPushes, [{ tabId: "tab-pull", value: "⇡2" }], "successful integration should resume the existing confirmed push flow with the fresh outgoing count");
825
+
826
+ integrationResponse = { ok: false, code: "CONFLICTS", error: "conflicts created", data: { command: "git rebase @{upstream}", exitCode: 1 } };
827
+ gitPullErrorDialogContext.openPullError("diverged", { code: "DIVERGED", tabId: "tab-rebase", syncValue: "⇡2 · ⇣1" });
828
+ assert.equal(await gitPullErrorDialogContext.integratePullError("rebase"), false, "conflicted rebase recovery should stop");
829
+ assert.deepEqual(JSON.parse(JSON.stringify(integrationRequests[1].options.body)), { mode: "rebase", confirmed: true }, "rebase recovery should use the confirmed integration contract");
830
+ assert.equal(integrationConfirmations[1].options.confirmLabel, "Rebase commits", "rebase should remain an explicit alternative");
831
+ assert.equal(integrationConfirmations[1].options.danger, true, "rebase confirmation should warn that local commit IDs will be rewritten");
832
+ assert.deepEqual(reviewedPullTabs, ["tab-pull", "tab-rebase"], "actual conflicts should open the existing Git Changes panel");
833
+ assert.equal(resumedPushes.length, 1, "conflicted integration must not continue to push");
834
+
835
+ const pullGitFooterSyncStart = app.indexOf("async function pullGitFooterSync(");
836
+ const pullGitFooterSyncEnd = app.indexOf("\nasync function pullThenPushGitFooterSync(", pullGitFooterSyncStart);
837
+ assert.ok(pullGitFooterSyncStart >= 0 && pullGitFooterSyncEnd > pullGitFooterSyncStart, "footer pull should remain a standalone async frontend helper");
838
+ const pullGitFooterSyncSource = app.slice(pullGitFooterSyncStart, pullGitFooterSyncEnd);
839
+ const pullFailureEvents = [];
840
+ const pullFailureDialogs = [];
841
+ const pullFailureContext = {
842
+ gitFooterSyncInFlightByTab: new Set(),
843
+ activeTabContext: (tabId) => ({ tabId }),
844
+ hideFooterTooltip() {},
845
+ isCurrentTabContext: () => false,
846
+ renderFooter() {},
847
+ api: async () => ({ ok: false, code: "DIVERGED", error: "duplicated raw error", hint: "diverged", data: {} }),
848
+ gitFailureDisplayText: () => "deduplicated pull error",
849
+ addEvent: (message, level) => pullFailureEvents.push({ message, level }),
850
+ requestGitFooterWebuiPayload() {},
851
+ openGitPullErrorDialog: (message, options) => pullFailureDialogs.push({ message, options }),
852
+ };
853
+ vm.runInNewContext(`${pullGitFooterSyncSource}\nthis.runPullGitFooterSync = pullGitFooterSync;`, pullFailureContext);
854
+ assert.equal(await pullFailureContext.runPullGitFooterSync("tab-pull", { syncValue: "⇡1 · ⇣2" }), false, "failed footer pull should report failure to ordered Sync");
855
+ assert.deepEqual(pullFailureEvents, [{ message: "deduplicated pull error", level: "error" }], "failed footer pull should keep only deduplicated output in the event log");
856
+ assert.deepEqual(JSON.parse(JSON.stringify(pullFailureDialogs)), [{ message: "deduplicated pull error", options: { code: "DIVERGED", tabId: "tab-pull", syncValue: "⇡1 · ⇣2" } }], "failed footer pull should preserve structured recovery context");
857
+ assert.match(app, /async function pushGitFooterSync\(tabId = activeTabId, syncValue = ""\)[\s\S]*api\("\/api\/git-workflow\/push", \{ method: "POST", body: \{\}, tabId \}\)[\s\S]*response\.code === "NON_FAST_FORWARD"[\s\S]*recoverWithPullFirst = true[\s\S]*gitFooterSyncInFlightByTab\.delete\(tabId\)[\s\S]*pullThenPushGitFooterSync\(tabId, syncValue\)/, "non-fast-forward footer pushes should release their mutation lock before entering pull-first recovery");
858
+ const pushGitFooterSyncStart = app.indexOf("async function pushGitFooterSync(");
859
+ const pushGitFooterSyncEnd = app.indexOf("\nfunction renderGitFooterPayloadMeta(", pushGitFooterSyncStart);
860
+ assert.ok(pushGitFooterSyncStart >= 0 && pushGitFooterSyncEnd > pushGitFooterSyncStart, "footer push should remain a standalone async frontend helper");
861
+ const pushRecoveryRequests = [];
862
+ const pushRecoveryEvents = [];
863
+ const pushRecoveryCalls = [];
864
+ const pushRecoveryInFlight = new Set();
865
+ const pushRecoveryContext = {
866
+ activeTabId: "tab-push",
867
+ gitFooterSyncInFlightByTab: pushRecoveryInFlight,
868
+ gitFooterSyncCounts: () => ({ ahead: 2, behind: 0 }),
869
+ activeTabContext: (tabId) => ({ tabId }),
870
+ tabs: [{ id: "tab-push", title: "feature/push-recovery" }],
871
+ hideFooterTooltip() {},
872
+ gitFooterCurrentBranch: () => "feature/push-recovery",
873
+ appConfirmText: async () => true,
874
+ isCurrentTabContext: () => false,
875
+ renderFooter() {},
876
+ api: async (path, options) => {
877
+ pushRecoveryRequests.push({ path, options });
878
+ return { ok: false, code: "NON_FAST_FORWARD", error: "remote contains new commits" };
879
+ },
880
+ addEvent: (message, level) => pushRecoveryEvents.push({ message, level }),
881
+ requestGitFooterWebuiPayload() {},
882
+ formatGitCommandResult: () => "",
883
+ pullThenPushGitFooterSync: async (tabId, value) => pushRecoveryCalls.push({ tabId, value, locked: pushRecoveryInFlight.has(tabId) }),
884
+ };
885
+ vm.runInNewContext(`${app.slice(pushGitFooterSyncStart, pushGitFooterSyncEnd)}\nthis.runPushGitFooterSync = pushGitFooterSync;`, pushRecoveryContext);
886
+ await pushRecoveryContext.runPushGitFooterSync("tab-push", "⇡2");
887
+ assert.deepEqual(JSON.parse(JSON.stringify(pushRecoveryRequests)), [{ path: "/api/git-workflow/push", options: { method: "POST", body: {}, tabId: "tab-push" } }], "footer Push should not offer or attempt force-with-lease after a non-fast-forward rejection");
888
+ assert.deepEqual(JSON.parse(JSON.stringify(pushRecoveryCalls)), [{ tabId: "tab-push", value: "⇡2", locked: false }], "footer Push should hand non-fast-forward recovery to the existing pull-then-push workflow after unlocking the tab");
889
+ assert.deepEqual(pushRecoveryEvents, [{ message: "Push found incoming commits. Starting pull-first recovery.", level: "info" }], "footer Push should explain the switch to pull-first recovery");
890
+ assert.match(app, /chip\.key === "sync" && visible\("webui-sync-push"\)[\s\S]*syncAction === "pull"[\s\S]*pullGitFooterSync\(tabId\)[\s\S]*syncAction === "pull-push"[\s\S]*pullThenPushGitFooterSync\(tabId, chip\.value\)[\s\S]*syncAction === "push"[\s\S]*pushGitFooterSync\(tabId, chip\.value\)/, "footer Sync should route incoming, diverged, and outgoing states to their respective actions");
712
891
  const gitFooterSyncRoutingSource = appFunctionSource("gitFooterSyncCounts", "gitFooterCurrentBranch");
713
892
  const gitFooterSyncRouting = JSON.parse(vm.runInNewContext(`${gitFooterSyncRoutingSource}\nJSON.stringify({
714
893
  incoming: gitFooterSyncAction({ key: "sync", value: "⇣2" }),
@@ -717,7 +896,23 @@ const gitFooterSyncRouting = JSON.parse(vm.runInNewContext(`${gitFooterSyncRouti
717
896
  unavailable: gitFooterSyncAction({ key: "sync", value: "no upstream" }),
718
897
  other: gitFooterSyncAction({ key: "changes", value: "⇣2" }),
719
898
  })`));
720
- assert.deepEqual(gitFooterSyncRouting, { incoming: "pull", outgoing: "push", diverged: "push", unavailable: "", other: "" }, "Sync routing should pull only incoming-only state and preserve push handling whenever outgoing commits exist");
899
+ assert.deepEqual(gitFooterSyncRouting, { incoming: "pull", outgoing: "push", diverged: "pull-push", unavailable: "", other: "" }, "Sync routing should pull before pushing whenever incoming and outgoing commits both exist");
900
+ const pullThenPushGitFooterSyncStart = app.indexOf("async function pullThenPushGitFooterSync(");
901
+ const pullThenPushGitFooterSyncEnd = app.indexOf("\nasync function pushGitFooterSync(", pullThenPushGitFooterSyncStart);
902
+ assert.ok(pullThenPushGitFooterSyncStart >= 0 && pullThenPushGitFooterSyncEnd > pullThenPushGitFooterSyncStart, "pull-then-push Sync should remain a standalone async frontend helper");
903
+ const pullThenPushGitFooterSyncSource = app.slice(pullThenPushGitFooterSyncStart, pullThenPushGitFooterSyncEnd);
904
+ const orderedSyncCalls = [];
905
+ const orderedSyncContext = {
906
+ pullGitFooterSync: async (tabId) => { orderedSyncCalls.push(`pull:${tabId}`); return true; },
907
+ pushGitFooterSync: async (tabId, value) => { orderedSyncCalls.push(`push:${tabId}:${value}`); },
908
+ };
909
+ vm.runInNewContext(`${pullThenPushGitFooterSyncSource}\nthis.runPullThenPushGitFooterSync = pullThenPushGitFooterSync;`, orderedSyncContext);
910
+ await orderedSyncContext.runPullThenPushGitFooterSync("tab-sync", "⇡1 · ⇣2");
911
+ assert.deepEqual(orderedSyncCalls, ["pull:tab-sync", "push:tab-sync:⇡1 · ⇣2"], "combined Sync should await pull before push");
912
+ orderedSyncCalls.length = 0;
913
+ orderedSyncContext.pullGitFooterSync = async (tabId) => { orderedSyncCalls.push(`pull:${tabId}`); return false; };
914
+ await orderedSyncContext.runPullThenPushGitFooterSync("tab-sync", "⇡1 · ⇣2");
915
+ assert.deepEqual(orderedSyncCalls, ["pull:tab-sync"], "combined Sync should skip push when pull fails or cannot start");
721
916
  assert.match(app, /function gitDiffDisplayLine\(row, side\)[\s\S]*`-\$\{text\}`[\s\S]*`\+\$\{text\}`/, "git changes modal should render changed lines with +/- prefixes");
722
917
  assert.match(app, /function gitUntrackedEntryToDiffFile\(entry\)[\s\S]*?renderRowLimit:\s*Number\.POSITIVE_INFINITY[\s\S]*?type: "added"/, "untracked files should render as complete added-file diffs without the row preview cap");
723
918
  assert.match(app, /async function loadMissingGitUntrackedContent\(entry[\s\S]*?\/api\/git-changes\/untracked-file\?path=/, "untracked path-only payloads should fetch complete file contents instead of rendering as empty files");
@@ -825,6 +1020,10 @@ assert.match(app, /let networkStatusLoaded = false;/, "Remote WebUI QR auto-popu
825
1020
  assert.match(app, /const hadNetworkStatus = networkStatusLoaded;[\s\S]*if \(!hadNetworkStatus\) \{\n\s+remoteQrAutoPopupShown = true;\n\s+return;\n\s+\}[\s\S]*if \(!wasOpen && !remoteQrAutoPopupShown && isLocalWebuiBrowserOrigin\(\)\)/, "Remote WebUI QR should auto-open only after network access transitions open, not on initial refresh");
826
1021
  assert.match(app, /remoteAuthToggle: \$\("#remoteAuthToggle"\)/, "Remote WebUI controls should bind the remote PIN auth toggle");
827
1022
  assert.match(html, /id="networkControlField"[^>]*hidden/, "Remote WebUI browser controls should be hidden until the optional package is loaded and enabled");
1023
+ assert.match(html, /id="showRemoteQrButton"[^>]*hidden>Open QR-Code<\/button>/, "Remote WebUI side-panel controls should include the Open QR-Code button");
1024
+ assert.doesNotMatch(css, /#networkControlField\s+#showRemoteQrButton\s*\{[^}]*display:\s*none/, "Remote WebUI styles should not override the Open QR-Code button's runtime visibility");
1025
+ assert.match(app, /showRemoteQrButton\.hidden = !open;[\s\S]*?showRemoteQrButton\.disabled = rebinding \|\| !open;[\s\S]*?showRemoteQrButton\.textContent = "Open QR-Code";/, "Open QR-Code should keep the existing remote-open and rebinding availability rules");
1026
+ assert.match(app, /showRemoteQrButton\?\.addEventListener\("click", \(\) => showRemoteWebuiQrPopupFromNetwork\(\)/, "Open QR-Code should open the existing Remote WebUI QR popup");
828
1027
  assert.match(app, /remoteWebuiCommand\(enable \? "authOn" : "authOff"/, "remote PIN auth toggle should dispatch through the Remote WebUI package command");
829
1028
  assert.match(server, /webuiSettingsFile,[\s\S]*from "\.\.\/lib\/git-workflow-preferences\.mjs"/, "server should use the shared Pi Web UI settings persistence module");
830
1029
  assert.match(server, /const persistedStartupSettings = await readWebuiSettings\(undefined, \{ reportInvalidOutputMode: true \}\);[\s\S]*?let persistedRemoteAuthEnabled = persistedStartupSettings\.remoteAuthEnabled === true;/, "server should load the saved Remote PIN auth preference before startup");
@@ -1300,7 +1499,7 @@ assert.match(app, /function footerBranchOptionLabel\(branch = \{\}\)[\s\S]*clean
1300
1499
  assert.match(app, /function footerBranchOptionDetail\(branch, state, \{ selected, worktreePath \} = \{\}\)[\s\S]*if \(branch\.remote\) return `remote-only · creates local branch \$\{branch\.name\} tracking \$\{branch\.remoteRef\}`;/, "remote branch rows should visibly describe the local tracking branch they create");
1301
1500
  assert.match(app, /function renderFooterBranchOption\(branch, state = footerBranchPickerState\)[\s\S]*remote-only[\s\S]*Remote-only branch \$\{branch\.remoteRef\}: create local branch \$\{branch\.name\} tracking it[\s\S]*Advanced: git switch --track -c \$\{branch\.name\} \$\{branch\.remoteRef\} in this checkout/, "remote branch rows should expose remote-only state and exact-ref tracking actions in visible and accessible text");
1302
1501
  assert.match(app, /function openFooterBranchOption\(branch, state = footerBranchPickerState\)[\s\S]*if \(branch\.remote\) return createFooterGitBranchWorktree\(branch\.name, \{ skipConfirm: true, chooseBase: false, remoteRef: branch\.remoteRef/, "remote primary actions should forward the advertised exact remote ref to tracking-worktree creation");
1303
- assert.match(app, /async function createFooterGitBranchWorktree\(branch = footerBranchCreateName\(\), \{[\s\S]*const response = trackedRemoteRef[\s\S]*\? await api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, remoteRef: trackedRemoteRef, sessionMode: "fork-current", openTab: true \}, tabId \}\)[\s\S]*: await api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, baseRef, sessionMode: "fork-current", openTab: true \}, tabId \}\)/, "remote worktree creation should submit the exact remote ref while local creation retains its base-ref request shape");
1502
+ assert.match(app, /async function createFooterGitBranchWorktree\(branch = footerBranchCreateName\(\), \{[\s\S]*const response = trackedRemoteRef[\s\S]*\? await api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, remoteRef: trackedRemoteRef, sessionMode: "fork-current", openTab: false \}, tabId \}\)[\s\S]*: await api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, baseRef, sessionMode: "fork-current", openTab: false \}, tabId \}\)/, "remote and local worktree creation should preserve their exact refs while deferring tab opening until after creation");
1304
1503
  assert.match(app, /async function applyFooterGitBranch\(branch, \{[\s\S]*const response = trackedRemoteRef[\s\S]*\? await api\("\/api\/git-branch", \{ method: "POST", body: \{ branch: branchName, create, remoteRef: trackedRemoteRef \}, tabId \}\)[\s\S]*: await api\("\/api\/git-branch", \{ method: "POST", body: \{ branch: branchName, create \}, tabId \}\)/, "remote in-place switching should submit the exact remote ref while local switching retains its request shape");
1305
1504
  assert.match(app, /function footerBranchOptionDetail\(branch, state,[\s\S]*state\.switchingKey \? state\.switchingKey === branch\.key[\s\S]*switchingKey: branch\.key/, "branch busy state should use the exact local-or-remote row identity instead of a collision-prone display label");
1306
1505
  assert.match(app, /GIT_BRANCH_TYPE_SUGGESTIONS = \["feat", "fix", "change", "perf", "test", "chore", "refactor", "docs", "style", "build", "ci", "revert"\]/, "new branch creation should reuse the conventional type suggestions from /git-staged-msg");
@@ -1309,7 +1508,7 @@ assert.match(app, /let footerBranchCreateDraft = \{ type: "", name: "" \}/, "new
1309
1508
  assert.match(app, /function footerBranchCreateType\(value = footerBranchCreateDraft\.type\) \{\n\s+return slugifyGitBranchPart\(value\);\n\}/, "branch type suggestions should not restrict or default custom user-entered prefixes");
1310
1509
  assert.match(app, /const slash = make\("span", "footer-branch-create-slash", "\/"\)/, "branch creation should visibly separate the prefix and user input with a slash");
1311
1510
  assert.match(app, /function gitWorktreeCreateCommandDisplay\(branch, state = footerBranchPickerState, baseRef = "origin\/main"\)[\s\S]*git worktree add -b[\s\S]*preview\.textContent = gitWorktreeCreateCommandDisplay\(branchName \|\| footerBranchCreatePreviewName\(\), state\)/, "branch worktree creation should preview the default origin/main start point");
1312
- assert.match(app, /function footerBranchCreateTooltip\(branchName = footerBranchCreateName\(\), state = footerBranchPickerState\)[\s\S]*A branch worktree is a separate checkout for parallel changes\.[\s\S]*origin\/main \(default\)[\s\S]*does not switch this tab's branch, commit, push, or delete anything[\s\S]*ignored dependencies such as node_modules or \.venv are not copied/, "create worktree button should explain the base choice and worktree behavior");
1511
+ assert.match(app, /function footerBranchCreateTooltip\(branchName = footerBranchCreateName\(\), state = footerBranchPickerState\)[\s\S]*A branch worktree is a separate checkout for parallel changes\.[\s\S]*origin\/main \(default\)[\s\S]*creates the worktree, then asks whether to open and switch to it in a separate Pi tab[\s\S]*does not switch this tab's branch, commit, push, or delete anything[\s\S]*ignored dependencies such as node_modules or \.venv are not copied/, "create worktree button should explain the base choice and post-creation switch choice");
1313
1512
  assert.match(html, /id="gitWorktreeBaseDialog"[\s\S]*id="gitWorktreeBaseOriginMain"[^>]*value="origin\/main" checked[\s\S]*id="gitWorktreeBaseCurrentHead"[^>]*value="HEAD"[\s\S]*id="gitWorktreeBaseCreateButton"/, "worktree creation should present an origin/main-default base picker with a current-HEAD alternative");
1314
1513
  assert.match(app, /function chooseGitWorktreeBase\(branch\)[\s\S]*gitWorktreeBaseOriginMain\.checked = true[\s\S]*gitWorktreeBaseCurrentHead\.checked = false/, "the worktree base picker should reset to origin/main for every creation");
1315
1514
  assert.match(css, /\.git-worktree-base-option:has\(input:checked\)[\s\S]*border-color:/, "the selected worktree base should be visibly highlighted");
@@ -1329,8 +1528,10 @@ assert.match(app, /const summary = make\("div", "workspace-dashboard-summary-row
1329
1528
  assert.match(css, /\.workspace-dashboard \{[\s\S]*?gap:\s*0\.52rem;[\s\S]*?padding:\s*0\.62rem 0\.78rem 0\.56rem;/, "workspace dashboard shell should use compact desktop spacing");
1330
1529
  assert.match(css, /\.workspace-dashboard-metric \{[\s\S]*?min-height:\s*3\.75rem;[\s\S]*?padding:\s*0\.48rem 0\.52rem;/, "workspace dashboard metrics should remain readable without tall cards");
1331
1530
  assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.workspace-dashboard-metrics \{ grid-template-columns: repeat\(2, minmax\(0, 1fr\)\); \}[\s\S]*?@media \(max-width: 480px\) \{\s*\.workspace-dashboard-metrics \{ grid-template-columns: 1fr; \}/, "workspace dashboard metrics should stay compact on tablets and stack on narrow phones");
1332
- assert.match(app, /async function createFooterGitBranchWorktree\(branch = footerBranchCreateName\(\)[\s\S]*chooseGitWorktreeBase\(branchName\)[\s\S]*api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, baseRef, sessionMode: "fork-current", openTab: true \}/, "new footer branch worktrees should ask for and submit the selected base ref");
1333
- assert.match(app, /async function openFooterGitWorktree\(path,[\s\S]*api\("\/api\/git-worktrees\/open", \{ method: "POST", body: \{ path: worktreePath, sessionMode: "fork-current", openTab: true \}/, "existing worktree actions should call the worktree open endpoint");
1531
+ assert.match(app, /async function createFooterGitBranchWorktree\(branch = footerBranchCreateName\(\)[\s\S]*chooseGitWorktreeBase\(branchName\)[\s\S]*api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, baseRef, sessionMode: "fork-current", openTab: false \}/, "new footer branch worktrees should ask for and submit the selected base ref without opening a tab early");
1532
+ assert.match(app, /async function confirmSwitchToCreatedFooterGitWorktree\(payload = \{\}, branchName = ""\)[\s\S]*payload\.created !== true[\s\S]*title: "Switch to new worktree\?"[\s\S]*switch to it now\?[\s\S]*confirmLabel: "Switch to worktree"[\s\S]*danger: false/, "newly created worktrees should prompt with a non-danger action before switching tabs");
1533
+ assert.match(app, /if \(payload\.created\) \{[\s\S]*openWorktreeResponseTab\(response, \{ branchName, action: "create" \}\)[\s\S]*confirmSwitchToCreatedFooterGitWorktree\(payload, branchName\)[\s\S]*openFooterGitWorktree\(worktreePath, \{ branchName, tabContext, skipConfirm: true, announce: false \}\)[\s\S]*\} else \{[\s\S]*openFooterGitWorktree\(worktreePath, \{ branchName, tabContext, skipConfirm: true \}\)/, "creation should switch only after acceptance while existing-worktree results retain automatic opening");
1534
+ assert.match(app, /async function openFooterGitWorktree\(path,[\s\S]*api\("\/api\/git-worktrees\/open", \{ method: "POST", body: \{ path: worktreePath, sessionMode: "fork-current", openTab: true \}/, "accepted and existing worktree actions should call the worktree open endpoint");
1334
1535
  assert.match(app, /elements\.newTabWorktreeButton\?\.addEventListener\("click", \(\) => openBranchWorktreePicker\(\)\)/, "new-tab menu branch worktree item should open the picker");
1335
1536
  assert.match(app, /\{ kind: "Git", label: "Branch worktree"[\s\S]*openBranchWorktreePicker\(\)/, "command palette should include branch worktree actions");
1336
1537
  assert.match(app, /dashboardAction\("Branch worktree", \(\) => openBranchWorktreePicker\(\), "worktree"\)/, "workspace dashboard should expose a branch worktree action");
@@ -1706,17 +1907,20 @@ assert.match(app, /\/api\/action-feedback not found; falling back to a normal pr
1706
1907
  assert.match(app, /actionFeedbackSteerMessage\(item\)/, "live action feedback should be sent as steering while the agent is running");
1707
1908
  assert.match(app, /function addTransientMessage\(\{ role = "notice"/, "frontend should render transient command output into the transcript");
1708
1909
  assert.match(app, /addTransientMessage\(\{ role: "extension", title: "extension output"/, "extension notify output should appear in the transcript, not only the event log");
1709
- assert.match(app, /function renderRunIndicator\(/, "frontend should render a transcript-level active agent indicator");
1910
+ assert.match(app, /function renderRunIndicator\(/, "frontend should render an active agent indicator");
1710
1911
  assert.match(app, /return "Agent is running: ";/, "active agent indicator should use the requested headline wording");
1711
1912
  assert.doesNotMatch(app, /"agent running"/, "active agent indicator should not render a separate title/header label");
1712
1913
  assert.doesNotMatch(app, /runIndicatorTimestamp/, "active agent indicator should not render a separate live timestamp header");
1713
- assert.match(app, /runIndicatorBubble = make\("article", "message runIndicator run-indicator-message streaming"\)/, "active agent indicator should use a dedicated streaming transcript card");
1914
+ assert.match(app, /runIndicatorBubble = make\("article", "message runIndicator run-indicator-message streaming"\)/, "active agent indicator should retain its dedicated streaming-card appearance");
1915
+ assert.match(html, /id="chat" class="chat" aria-live="polite"[\s\S]*?<\/div>\s*<div id="runIndicatorHost" class="run-indicator-host"><\/div>/, "active agent indicator should have a dedicated host immediately after the transcript");
1916
+ assert.match(css, /\.run-indicator-host\s*\{[\s\S]*?padding: 0 1rem 1rem;/, "the dedicated run-indicator host should preserve the transcript card inset");
1714
1917
  assert.match(app, /function standaloneLiveTranscriptBubbles\(\)[\s\S]*?streamThinkingBubble[\s\S]*?streamToolCallBubble[\s\S]*?streamBubble[\s\S]*?compactThinkingBubble[\s\S]*?compactTextBubble/, "transcript reconciliation should identify standalone live-tail bubbles that must stay mounted");
1715
- assert.match(app, /function resetChatOutput\(\)[\s\S]*?liveBubbles = standaloneLiveTranscriptBubbles\(\)[\s\S]*?preservedNodes[\s\S]*?child === runIndicatorBubble \|\| liveBubbles\.has\(child\)[\s\S]*?transcriptRenderer\.replaceChildren\(elements\.chat, \.\.\.preservedNodes\)/, "transcript resets should reconcile through the coordinator while preserving live output and the run indicator");
1716
- assert.match(app, /function appendChatMessageBubble\(bubble, \{ liveTail = false \} = \{\}\)[\s\S]*?child === runIndicatorBubble \|\| \(!liveTail && liveBubbles\.has\(child\)\)[\s\S]*?insertBefore\(bubble, tailAnchor\)/, "reconciled history should insert before the stable live transcript tail while new live output stays chronological");
1918
+ assert.match(app, /function resetChatOutput\(\)[\s\S]*?liveBubbles = standaloneLiveTranscriptBubbles\(\)[\s\S]*?preservedNodes[\s\S]*?child === elements\.stickyUserPromptButton \|\| liveBubbles\.has\(child\)[\s\S]*?transcriptRenderer\.replaceChildren\(elements\.chat, \.\.\.preservedNodes\)/, "transcript resets should reconcile through the coordinator while preserving only transcript-owned live output");
1919
+ assert.match(app, /function appendChatMessageBubble\(bubble, \{ liveTail = false \} = \{\}\)[\s\S]*?!liveTail && liveBubbles\.has\(child\)[\s\S]*?insertBefore\(bubble, tailAnchor\)/, "reconciled history should preserve the stable live transcript tail while new live output stays chronological");
1717
1920
  assert.match(app, /appendChatMessageBubble\(created\.bubble, \{ liveTail: streaming \|\| message\?\.live === true \}\)/, "streaming thinking, assistant text, and live tools should append after earlier live output");
1718
1921
  assert.match(app, /setChatScrollTopInstant\(Math\.min\(previousScrollTop, elements\.chat\.scrollHeight\)\)/, "paused-reader scroll restoration should bypass smooth scrolling to avoid a down-then-back animation");
1719
- assert.match(app, /function ensureRunIndicatorBubble\(\)[\s\S]*?!runIndicatorBubble \|\| !runIndicatorText \|\| !runIndicatorMeta[\s\S]*?elements\.chat\.lastElementChild !== runIndicatorBubble/, "active agent indicator should reuse the existing bubble across transcript re-renders instead of recreating it");
1922
+ assert.match(app, /function ensureRunIndicatorBubble\(\)[\s\S]*?!runIndicatorBubble \|\| !runIndicatorText \|\| !runIndicatorMeta[\s\S]*?runIndicatorBubble\.parentElement !== elements\.runIndicatorHost[\s\S]*?elements\.runIndicatorHost\.replaceChildren\(runIndicatorBubble\)/, "active agent indicator should reuse its existing bubble in the dedicated status host");
1923
+ assert.doesNotMatch(app, /elements\.chat\.(?:append|insertBefore)\(runIndicatorBubble/, "the active agent indicator must never be mounted in the transcript");
1720
1924
  assert.match(app, /const headline = runIndicatorHeadline\(\);\n\s+if \(runIndicatorText\.textContent !== headline\) runIndicatorText\.textContent = headline;/, "active agent indicator should avoid redundant headline DOM writes that can flicker");
1721
1925
  assert.match(app, /const meta = runIndicatorShowsElapsed\(\) \? `\$\{detail\} · run time[\s\S]*?if \(runIndicatorMeta\.textContent !== meta\) runIndicatorMeta\.textContent = meta;/, "active agent indicator should avoid redundant metadata DOM writes except elapsed changes");
1722
1926
  assert.match(app, /runIndicatorShowsElapsed\(\) \? `\$\{detail\} · run time/, "active agent indicator should label elapsed run time instead of showing a bare counter");
@@ -2195,6 +2399,7 @@ assert.match(server, /function optionalFeaturePackageStatus\(featureId, cwd = op
2195
2399
  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");
2196
2400
  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");
2197
2401
  assert.match(server, /function configuredAgentNpmRoot\(\)/, "status discovery should consider Pi's agent npm root for legacy or hoisted packages");
2402
+ assert.match(server, /function packageNodeModulesPath\(nodeModulesRoot, packageName\)[\s\S]*path\.join\(nodeModulesRoot,[\s\S]*split\("\/"\)/, "status discovery should map scoped npm package names into node_modules paths");
2198
2403
  assert.match(server, /resolveInstalledPackageSubpath\(nodeModulesRef\.packageName, nodeModulesRef\.subpath\)/, "started Web UI resource resolution should support configured package resources");
2199
2404
  assert.match(server, /url\.pathname === "\/api\/optional-features" && req\.method === "GET"/, "server should expose optional feature package status endpoint");
2200
2405
  assert.match(server, /url\.pathname === "\/api\/optional-feature-install" && req\.method === "POST"/, "server should preserve the optional feature single-install endpoint");
@@ -68,7 +68,7 @@ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server
68
68
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
69
69
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
70
70
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
71
- assert.match(serviceWorker, /pi-webui-pwa-v81/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v84/, "the PWA cache name must change with browser wiring updates");
72
72
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
73
73
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
74
74
 
@@ -31,6 +31,9 @@ assert.match(surfaceSource, /Checking optional features…[\s\S]*elapsed[\s\S]*C
31
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
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
33
  assert.match(surfaceSource, /started safely without optional companions[\s\S]*Recheck/, "degraded startup should remain core-safe and recheckable");
34
+ assert.match(surfaceSource, /noticeDismissKey[\s\S]*optionalFeatureMigrationDismissedNoticeKey === noticeDismissKey[\s\S]*surface\.hidden = true/, "a dismissed degraded snapshot should stay hidden for the current page lifetime");
35
+ assert.match(surfaceSource, /optional-feature-migration-dismiss[\s\S]*aria-label", "Close optional feature startup notice"/, "degraded startup should expose an accessible dismiss button");
36
+ assert.match(app, /function dismissOptionalFeatureMigrationNotice\(\)[\s\S]*optionalFeatureMigrationDismissedNoticeKey = key[\s\S]*renderOptionalFeatureMigrationSurface\(\)/, "the degraded dismiss action should hide the current snapshot through the existing renderer");
34
37
  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
38
  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
39
  assert.match(surfaceSource, /optionalFeatureMigrationCompletionIsDismissed\(snapshot\)[\s\S]*surface\.hidden = true[\s\S]*phase === "complete"[\s\S]*dismissOptionalFeatureMigrationCompletion/, "dismissing a completed migration should hide the complete surface, not only its restart notice");
@@ -71,6 +74,7 @@ assert.match(surfaceSource, /readyCanAutoDismiss[\s\S]*scheduleOptionalFeatureRe
71
74
 
72
75
  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");
73
76
  assert.match(css, /\.optional-feature-migration-card:focus-visible/, "focused completion summary should have a visible focus treatment");
77
+ assert.match(css, /\.optional-feature-migration-card\.phase-degraded[\s\S]*padding-right:[^;]+;[\s\S]*\.optional-feature-migration-dismiss \{[\s\S]*position: absolute;[\s\S]*top:[^;]+;[\s\S]*right:[^;]+;/, "the degraded popup should reserve space for a top-right dismiss button");
74
78
 
75
79
  assert.match(readme, /read-only startup audit/i, "README should document startup auditing");
76
80
  assert.match(readme, /--migrate-optional-features[\s\S]*--migration-dry-run/, "README should document explicit unattended migration and dry-run flags");
@@ -271,8 +271,8 @@ assert.match(
271
271
 
272
272
  // --- Coherent browser asset revisions --------------------------------------
273
273
 
274
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=104/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=120"/, "the boot loader should request the updated app module revision");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "changed browser assets should advance the PWA cache identity");
275
+ assert.match(html, /styles\.css\?v=107/, "the page should request the updated layout stylesheet revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=121"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -98,11 +98,19 @@ const routingAdd = sendSource.indexOf("promptRoutingTabs.add(targetTabId);");
98
98
  const workingMark = sendSource.indexOf("markTabWorkingLocally(targetTabId);");
99
99
  const responseApply = sendSource.indexOf("applyResponseTab(response);");
100
100
  const successDelete = sendSource.indexOf("promptRoutingTabs.delete(targetTabId);", responseApply);
101
+ const nativeResponseBranch = sendSource.indexOf('if (response?.command === "native_slash_command"', responseApply);
101
102
  const catchStart = sendSource.indexOf("} catch (error)", successDelete);
102
103
  const failureDelete = sendSource.indexOf("promptRoutingTabs.delete(targetTabId);", catchStart);
103
104
  const idleMark = sendSource.indexOf("markTabIdleLocally(targetTabId);", catchStart);
104
105
  assert.ok(routingAdd >= 0 && routingAdd < workingMark, "fresh prompts should enter routing protection before rendering working state");
105
106
  assert.ok(responseApply >= 0 && successDelete > responseApply && successDelete < catchStart, "successful routing protection should end only after applying the server handoff response");
107
+ assert.ok(successDelete < nativeResponseBranch, "all accepted prompts, including extension commands, should release routing ownership before native-command special cases");
106
108
  assert.ok(failureDelete > catchStart && failureDelete < idleMark, "failed routing should clear protection before restoring idle state");
107
109
 
110
+ const abortSource = functionSource("abortActiveRun");
111
+ const abortRequest = abortSource.indexOf('await api("/api/abort"');
112
+ const abortRoutingDelete = abortSource.indexOf("promptRoutingTabs.delete(tabContext.tabId);", abortRequest);
113
+ const abortStateChecks = abortSource.indexOf("scheduleAbortStateChecks(tabContext);", abortRoutingDelete);
114
+ assert.ok(abortRequest >= 0 && abortRoutingDelete > abortRequest && abortRoutingDelete < abortStateChecks, "a successful abort should release local routing ownership before canonical state checks");
115
+
108
116
  console.log("prompt routing tab-status checks passed");
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
504
504
  assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
505
505
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
506
506
 
507
- assert.match(html, /styles\.css\?v=104/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=120/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81"/, "questionnaire public assets need a coherent PWA cache revision");
507
+ assert.match(html, /styles\.css\?v=107/, "questionnaire CSS needs the current stylesheet revision");
508
+ assert.match(html, /app\.js\?v=121/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -1,4 +1,5 @@
1
1
  import assert from "node:assert/strict";
2
+ import { createHash } from "node:crypto";
2
3
  import { createConnection, createServer } from "node:net";
3
4
  import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
4
5
  import { tmpdir } from "node:os";
@@ -9,6 +10,7 @@ import {
9
10
  RPC_SUPERVISOR_CHILD_ARG_LIMIT,
10
11
  RPC_SUPERVISOR_EVENT_RING_MAX_BYTES,
11
12
  RPC_SUPERVISOR_REQUEST_DEDUPE_LIMIT,
13
+ deriveSupervisorRecoveryToken,
12
14
  } from "../lib/rpc-supervisor-protocol.mjs";
13
15
  import {
14
16
  RpcSupervisorClient,
@@ -123,7 +125,13 @@ try {
123
125
  client = await discoverStartAttachRpcSupervisor({
124
126
  agentDir,
125
127
  port,
126
- environment: { ...process.env, FAKE_PI_LOG_FILE: logFile, RAW_PI_LOG: rawLogFile },
128
+ environment: {
129
+ ...process.env,
130
+ FAKE_PI_LOG_FILE: logFile,
131
+ RAW_PI_LOG: rawLogFile,
132
+ PI_WEBUI_RECOVERY_URL: `http://127.0.0.1:${port}/api/recovery/plan`,
133
+ PI_WEBUI_RECOVERY_TOKEN: "server-ephemeral-recovery-token",
134
+ },
127
135
  startupTimeoutMs: 10_000,
128
136
  });
129
137
  const created = await client.createTab({
@@ -160,6 +168,15 @@ try {
160
168
  await delay(60);
161
169
  const logged = (await readFile(logFile, "utf8")).split("\n").filter(Boolean).map(JSON.parse);
162
170
  assert.equal(logged.filter((entry) => entry.direction === "command" && entry.message === "dedupe me").length, 1, "duplicate request IDs must not write to Pi twice");
171
+ const startupState = await readSupervisorState(await supervisorPaths({ agentDir, port }));
172
+ const expectedRecoveryDigest = createHash("sha256").update(deriveSupervisorRecoveryToken(startupState.token)).digest("hex");
173
+ const startupEntry = logged.find((entry) => entry.direction === "startup" && entry.cwd === work);
174
+ assert.equal(startupEntry?.recoveryTokenDigest, expectedRecoveryDigest, "managed Pi children must receive the stable derived recovery credential");
175
+ assert.notEqual(
176
+ startupEntry?.recoveryTokenDigest,
177
+ createHash("sha256").update("server-ephemeral-recovery-token").digest("hex"),
178
+ "managed Pi children must not retain the server process's restart-scoped credential",
179
+ );
163
180
 
164
181
  const rawCommand = {
165
182
  type: "raw_round_trip",
@@ -6,6 +6,7 @@ import {
6
6
  RPC_SUPERVISOR_PROTOCOL,
7
7
  RpcSupervisorProtocolError,
8
8
  constantTimeTokenEqual,
9
+ deriveSupervisorRecoveryToken,
9
10
  encodeFrame,
10
11
  frameReader,
11
12
  protocolCompatible,
@@ -20,6 +21,10 @@ const attach = validateClientFrame({
20
21
  assert.equal(attach.token, "private-token", "attach validation must retain the private token for authentication");
21
22
  assert.equal(constantTimeTokenEqual("same", "same"), true);
22
23
  assert.equal(constantTimeTokenEqual("same", "different"), false);
24
+ const recoveryToken = deriveSupervisorRecoveryToken("private-token");
25
+ assert.equal(recoveryToken, deriveSupervisorRecoveryToken("private-token"), "recovery credentials must remain stable across server reattachment");
26
+ assert.notEqual(recoveryToken, "private-token", "the lower-privilege recovery credential must not expose the supervisor credential");
27
+ assert.notEqual(recoveryToken, deriveSupervisorRecoveryToken("other-private-token"));
23
28
  assert.equal(protocolCompatible({ major: RPC_SUPERVISOR_PROTOCOL.major, minor: 0 }), true, "older minor versions remain attach-compatible for actionable recovery");
24
29
  assert.equal(protocolCurrent({ major: RPC_SUPERVISOR_PROTOCOL.major, minor: 0 }), false, "older detached supervisors must be detectable after a server-only restart");
25
30
  assert.equal(protocolCurrent(RPC_SUPERVISOR_PROTOCOL), true);
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
57
57
  assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
58
58
  assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
59
59
  assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
60
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81"/, "native-control assets should advance the cache identity");
60
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "native-control assets should advance the cache identity");
61
61
  assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
62
- assert.match(html, /styles\.css\?v=104/, "the changed stylesheet should have a new revision");
63
- assert.match(html, /app\.js\?v=120/, "the changed app module should have a new revision");
62
+ assert.match(html, /styles\.css\?v=107/, "the changed stylesheet should have a new revision");
63
+ assert.match(html, /app\.js\?v=121/, "the changed app module should have a new revision");
64
64
 
65
65
  // --- Browser state behavior -------------------------------------------------
66
66
 
@@ -27,8 +27,8 @@ assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHe
27
27
  assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["sectionOrder", "collapsedSectionIds", "hiddenSectionIds", "collapsed"\];/, "the browser durable layout field list should omit section heights");
28
28
  assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
29
29
  assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
30
- assert.match(html, /styles\.css\?v=104/, "removing section resize styles should advance the stylesheet revision");
31
- assert.match(html, /app\.js\?v=120/, "removing section resize behavior should advance the app revision");
32
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81"/, "removing browser assets should advance the PWA cache identity");
30
+ assert.match(html, /styles\.css\?v=107/, "removing section resize styles should advance the stylesheet revision");
31
+ assert.match(html, /app\.js\?v=121/, "removing section resize behavior should advance the app revision");
32
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "removing browser assets should advance the PWA cache identity");
33
33
 
34
34
  console.log("side-panel-section-height-removal-static.test.mjs passed");