@firstpick/pi-package-webui 0.8.8 → 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 (39) hide show
  1. package/README.md +5 -0
  2. package/bin/pi-webui-rpc-supervisor.mjs +4 -1
  3. package/bin/pi-webui.mjs +5 -1
  4. package/lib/rpc-supervisor-protocol.mjs +6 -1
  5. package/package.json +1 -1
  6. package/public/app.js +426 -101
  7. package/public/index.html +27 -13
  8. package/public/service-worker.js +1 -1
  9. package/public/styles.css +741 -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 +4 -1
  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 +32 -18
  29. package/tests/open-issue-wizard-static.test.mjs +1 -1
  30. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  31. package/tests/questionnaire-dialog.test.mjs +3 -3
  32. package/tests/rpc-supervisor-host.test.mjs +18 -1
  33. package/tests/rpc-supervisor-protocol.test.mjs +5 -0
  34. package/tests/session-sampling-ui-static.test.mjs +3 -3
  35. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  36. package/tests/side-panel-section-reorder-static.test.mjs +23 -10
  37. package/tests/streaming-ui-coupling.test.mjs +8 -0
  38. package/tests/terminal-tab-workspace-static.test.mjs +15 -1
  39. 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");
@@ -1015,6 +1020,10 @@ assert.match(app, /let networkStatusLoaded = false;/, "Remote WebUI QR auto-popu
1015
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");
1016
1021
  assert.match(app, /remoteAuthToggle: \$\("#remoteAuthToggle"\)/, "Remote WebUI controls should bind the remote PIN auth toggle");
1017
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");
1018
1027
  assert.match(app, /remoteWebuiCommand\(enable \? "authOn" : "authOff"/, "remote PIN auth toggle should dispatch through the Remote WebUI package command");
1019
1028
  assert.match(server, /webuiSettingsFile,[\s\S]*from "\.\.\/lib\/git-workflow-preferences\.mjs"/, "server should use the shared Pi Web UI settings persistence module");
1020
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");
@@ -1490,7 +1499,7 @@ assert.match(app, /function footerBranchOptionLabel\(branch = \{\}\)[\s\S]*clean
1490
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");
1491
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");
1492
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");
1493
- 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");
1494
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");
1495
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");
1496
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");
@@ -1499,7 +1508,7 @@ assert.match(app, /let footerBranchCreateDraft = \{ type: "", name: "" \}/, "new
1499
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");
1500
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");
1501
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");
1502
- 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");
1503
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");
1504
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");
1505
1514
  assert.match(css, /\.git-worktree-base-option:has\(input:checked\)[\s\S]*border-color:/, "the selected worktree base should be visibly highlighted");
@@ -1519,8 +1528,10 @@ assert.match(app, /const summary = make\("div", "workspace-dashboard-summary-row
1519
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");
1520
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");
1521
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");
1522
- 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");
1523
- 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");
1524
1535
  assert.match(app, /elements\.newTabWorktreeButton\?\.addEventListener\("click", \(\) => openBranchWorktreePicker\(\)\)/, "new-tab menu branch worktree item should open the picker");
1525
1536
  assert.match(app, /\{ kind: "Git", label: "Branch worktree"[\s\S]*openBranchWorktreePicker\(\)/, "command palette should include branch worktree actions");
1526
1537
  assert.match(app, /dashboardAction\("Branch worktree", \(\) => openBranchWorktreePicker\(\), "worktree"\)/, "workspace dashboard should expose a branch worktree action");
@@ -1896,17 +1907,20 @@ assert.match(app, /\/api\/action-feedback not found; falling back to a normal pr
1896
1907
  assert.match(app, /actionFeedbackSteerMessage\(item\)/, "live action feedback should be sent as steering while the agent is running");
1897
1908
  assert.match(app, /function addTransientMessage\(\{ role = "notice"/, "frontend should render transient command output into the transcript");
1898
1909
  assert.match(app, /addTransientMessage\(\{ role: "extension", title: "extension output"/, "extension notify output should appear in the transcript, not only the event log");
1899
- 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");
1900
1911
  assert.match(app, /return "Agent is running: ";/, "active agent indicator should use the requested headline wording");
1901
1912
  assert.doesNotMatch(app, /"agent running"/, "active agent indicator should not render a separate title/header label");
1902
1913
  assert.doesNotMatch(app, /runIndicatorTimestamp/, "active agent indicator should not render a separate live timestamp header");
1903
- 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");
1904
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");
1905
- 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");
1906
- 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");
1907
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");
1908
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");
1909
- 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");
1910
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");
1911
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");
1912
1926
  assert.match(app, /runIndicatorShowsElapsed\(\) \? `\$\{detail\} · run time/, "active agent indicator should label elapsed run time instead of showing a bare counter");
@@ -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
 
@@ -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");
@@ -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");
@@ -28,13 +28,23 @@ assert.match(
28
28
  );
29
29
  assert.match(
30
30
  app,
31
- /function moveSidePanelSectionRelative\(fromId, targetRecord, insertBefore\)[\s\S]*parent\.insertBefore\(sourceRecord\.section, targetRecord\.section\)[\s\S]*targetRecord\.section\.nextSibling[\s\S]*persistSidePanelSectionOrder\(\)/,
32
- "reordering should move the complete section before or after its target and persist immediately",
31
+ /function isSidePanelSectionReorderingEnabled\(\) \{\n\s+return !isMobileView\(\) \|\| sidePanelSectionEditMode;[\s\S]*function moveSidePanelSectionRelative\(fromId, targetRecord, insertBefore\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\)\) return false;[\s\S]*parent\.insertBefore\(sourceRecord\.section, targetRecord\.section\)[\s\S]*targetRecord\.section\.nextSibling[\s\S]*persistSidePanelSectionOrder\(\)/,
32
+ "desktop reordering should stay enabled while mobile reordering fails closed outside Edit mode",
33
+ );
34
+ assert.match(
35
+ app,
36
+ /function moveSidePanelSectionByOffset\(sectionId, offset\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\)\) return false;/,
37
+ "keyboard reordering should follow the desktop-always/mobile-Edit gate",
38
+ );
39
+ assert.match(
40
+ app,
41
+ /function beginSidePanelSectionPointerDrag\(event, sectionId\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\) \|\| event\.button !== 0/,
42
+ "pointer and touch dragging should follow the responsive reorder gate",
33
43
  );
34
44
  assert.match(
35
45
  app,
36
46
  /function updateSidePanelSectionPointerDrag\(event\)[\s\S]*Math\.hypot[\s\S]*SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX[\s\S]*sidePanelSectionToggleFromPoint[\s\S]*getBoundingClientRect\(\)[\s\S]*moveSidePanelSectionRelative/,
37
- "pointer dragging should activate only after the threshold and use header midpoint placement",
47
+ "edit-mode pointer dragging should activate only after the threshold and use header midpoint placement",
38
48
  );
39
49
  assert.match(
40
50
  app,
@@ -43,8 +53,8 @@ assert.match(
43
53
  );
44
54
  assert.match(
45
55
  app,
46
- /function bindSidePanelSectionToggles\(\)[\s\S]*Date\.now\(\) < sidePanelSectionSuppressClickUntil[\s\S]*event\.altKey[\s\S]*event\.key !== "ArrowUp"[\s\S]*moveSidePanelSectionByOffset[\s\S]*beginSidePanelSectionPointerDrag/,
47
- "section headers should retain click toggling while supporting Alt+Arrow keyboard and pointer reordering",
56
+ /function bindSidePanelSectionToggles\(\)[\s\S]*Date\.now\(\) < sidePanelSectionSuppressClickUntil[\s\S]*!isSidePanelSectionReorderingEnabled\(\) \|\| !event\.altKey[\s\S]*event\.key !== "ArrowUp"[\s\S]*moveSidePanelSectionByOffset[\s\S]*beginSidePanelSectionPointerDrag/,
57
+ "section headers should retain click toggling while the responsive gate controls Alt+Arrow and pointer reordering",
48
58
  );
49
59
  assert.match(
50
60
  app,
@@ -58,11 +68,14 @@ assert.match(
58
68
  );
59
69
  assert.match(
60
70
  css,
61
- /\.side-panel-section-toggle\[data-side-panel-section-toggle\][\s\S]*cursor: grab[\s\S]*touch-action: none[\s\S]*\.side-panel-section\.dragging[\s\S]*cursor: grabbing[\s\S]*\.drag-over-before[\s\S]*\.drag-over-after/,
62
- "section headers should expose model-picker-style grab, dragging, and insertion-marker affordances",
71
+ /\.side-panel-edit-button \{\n\s+display: none;[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\] \{\n\s+cursor: grab;\n\s+touch-action: none;\n\s+user-select: none;\n\}[\s\S]*?@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\) \{[\s\S]*?\.side-panel-edit-button \{ display: inline-flex;[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\] \{\n\s+border-color:[\s\S]*?box-shadow:[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-label::before \{/,
72
+ "desktop should keep drag capture without edit highlighting while mobile restores Edit and its visual affordance",
63
73
  );
64
- assert.match(html, /styles\.css\?v=104/, "changed side-panel styles should advance the stylesheet revision");
65
- assert.match(html, /app\.js\?v=120/, "changed side-panel behavior should advance the app revision");
66
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81"/, "changed browser assets should advance the PWA cache identity");
74
+ assert.match(html, /id="sidePanelEditButton"[^>]*aria-controls="sidePanel"[^>]*aria-pressed="false"[^>]*aria-label="Edit Control Deck section order"[\s\S]*side-panel-edit-button-label">Edit</, "mobile Control Deck should retain an accessible Edit toggle");
75
+ assert.match(app, /function setSidePanelSectionEditMode\(enabled\)[\s\S]*const next = isMobileView\(\) && !!enabled;[\s\S]*classList\.toggle\("section-edit-mode", reorderingEnabled\)[\s\S]*aria-pressed[\s\S]*"Done" : "Edit"[\s\S]*aria-keyshortcuts/, "mobile Edit state and always-enabled desktop reorder affordances should stay synchronized");
76
+ assert.match(app, /function setSidePanelCollapsed\(collapsed,[\s\S]*if \(collapsed\) setSidePanelSectionEditMode\(false\);/, "closing the Control Deck should leave transient edit mode");
77
+ assert.match(html, /styles\.css\?v=107/, "changed side-panel styles should advance the stylesheet revision");
78
+ assert.match(html, /app\.js\?v=121/, "changed side-panel behavior should advance the app revision");
79
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "changed browser assets should advance the PWA cache identity");
67
80
 
68
81
  console.log("side-panel-section-reorder-static.test.mjs passed");
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
5
5
 
6
6
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
7
  const app = await readFile(join(root, "public", "app.js"), "utf8");
8
+ const styles = await readFile(join(root, "public", "styles.css"), "utf8");
8
9
  const transcriptRenderer = await readFile(join(root, "public", "transcript-renderer.mjs"), "utf8");
9
10
 
10
11
  const SELF_CONTAINED_THEORY_TITLES = new Map([
@@ -85,6 +86,7 @@ assertDocTheory(8, "steer prompt");
85
86
 
86
87
  const syncLiveTodoProgressWidgetFromText = findFunctionBody(app, "syncLiveTodoProgressWidgetFromText");
87
88
  const scheduleLiveWidgetRender = findFunctionBody(app, "scheduleLiveWidgetRender");
89
+ const appendOptimisticUserPrompt = findFunctionBody(app, "appendOptimisticUserPrompt");
88
90
  const handleMessageUpdate = findFunctionBody(app, "handleMessageUpdate");
89
91
  const scrollChatToBottom = findFunctionBody(app, "scrollChatToBottom");
90
92
  const stripTodoProgressLines = findFunctionBody(app, "stripTodoProgressLines");
@@ -126,6 +128,12 @@ assert.match(
126
128
  "disabling todo-progress should still suppress the optional widget renderer itself",
127
129
  );
128
130
 
131
+ assert.match(styles, /\.chat \{[\s\S]*?display:\s*flex;[\s\S]*?flex-direction:\s*column;/, "the transcript should retain a stable vertical flow as composer geometry changes");
132
+ assert.match(styles, /\.chat > \.message:first-of-type \{ margin-top:\s*0; \}/, "settled transcript cards should stay top-anchored while the prompt textarea auto-resizes");
133
+ assert.doesNotMatch(styles, /\.chat > \.message:first-of-type \{ margin-top:\s*auto; \}/, "short transcripts must not follow the moving composer edge while the user types");
134
+ assert.match(appendOptimisticUserPrompt, /renderAllMessages\(\);[\s\S]*?scrollChatToBottom\(\{ force:\s*true \}\);/, "submitting a prompt should explicitly resume bottom-follow for the new turn");
135
+ assert.doesNotMatch(appendOptimisticUserPrompt, /if \(autoFollowChat \|\| isChatNearBottom\(\)\)/, "a paused reader position should not leave a newly submitted turn off-screen");
136
+
129
137
  futureInvariant("theory #1: message_update streaming hot path must not call immediate scroll/layout work", () => {
130
138
  assert.doesNotMatch(handleMessageUpdate, /scrollChatToBottom\s*\(/, "handleMessageUpdate should schedule/coalesce follow-scroll instead of calling scrollChatToBottom() directly");
131
139
  });
@@ -38,6 +38,7 @@ const sources = [
38
38
  ].join("\n");
39
39
  const terminalTabMetaSource = appFunctionSource("terminalTabMeta", "terminalTabGitTooltip");
40
40
  const renderTerminalTabGroupSource = appFunctionSource("renderTerminalTabGroup", "updateTerminalTabGroupOpenState");
41
+ const renderSubagentTerminalTabGroupSource = appFunctionSource("renderSubagentTerminalTabGroup", "openSubagentOutput");
41
42
 
42
43
  const context = {
43
44
  normalizeDisplayPath: (value) => String(value || "").replace(/\\/g, "/"),
@@ -51,6 +52,7 @@ const context = {
51
52
  tabWorkflowModeActive: (tab) => tab.workflowMode === true,
52
53
  workflowRunningCountForTab: (id) => id === "tab-1" ? 2 : 0,
53
54
  terminalDisplayGroupTitle: () => "Workspace group",
55
+ isMobileView: () => false,
54
56
  };
55
57
 
56
58
  const results = vm.runInNewContext(`
@@ -90,9 +92,21 @@ assert.doesNotMatch(terminalTabMetaSource, /\bpid\b/i, "compact tab metadata sho
90
92
  assert.equal(app.match(/applyStyledTooltip\(button, terminalTabTooltip\(tab\)/g)?.length, 2, "single and grouped-item tabs should share one tooltip formatter");
91
93
  assert.match(renderTerminalTabGroupSource, /applyStyledTooltip\(button, terminalTabGroupTooltip\(group, groupTitle\), \{ ariaLabel: false, description: true, placement: "right", variant: "workspace", targetKey: `terminal-group:\$\{group\.key\}:switch` \}\)/, "group hover disclosure should use the shared floating tooltip layer with stable semantic identity to the right of its trigger");
92
94
  assert.doesNotMatch(renderTerminalTabGroupSource, /terminal-tab-group-summary|menu\.append\(summary\)/, "group hover disclosure should not render an in-flow summary that shifts group menu items");
95
+ assert.match(renderTerminalTabGroupSource, /dropdown: true[\s\S]*button\.addEventListener\("click", \(\) => \{[\s\S]*if \(isMobileView\(\)\)[\s\S]*toggleOpenTerminalTabGroup\(group\.key\)[\s\S]*switchTab\(activeGroupTab\.id\)/, "mobile terminal group titles should toggle their dropdown while desktop titles keep switching terminals");
96
+ assert.match(renderSubagentTerminalTabGroupSource, /dropdown: true[\s\S]*button\.addEventListener\("click", \(\) => \{[\s\S]*if \(isMobileView\(\)\)[\s\S]*toggleOpenTerminalTabGroup\(group\.key\)[\s\S]*activateSubagentTerminalView\(activeView\.id\)/, "mobile subagent group titles should toggle their dropdown while desktop titles keep switching views");
97
+ assert.equal((`${renderTerminalTabGroupSource}\n${renderSubagentTerminalTabGroupSource}`.match(/event\.pointerType === "touch"/g) || []).length, 4, "touch pointer enter and leave should not compete with explicit dropdown taps");
98
+ assert.match(renderTerminalTabGroupSource, /menu\.id = `terminalTabGroupMenu\$\{\+\+terminalTabGroupMenuSerial\}`[\s\S]*button\.setAttribute\("aria-controls", menu\.id\)/, "regular terminal dropdown buttons should own their generated group list");
99
+ assert.match(renderSubagentTerminalTabGroupSource, /menu\.id = `terminalTabGroupMenu\$\{\+\+terminalTabGroupMenuSerial\}`[\s\S]*button\.setAttribute\("aria-controls", menu\.id\)/, "subagent dropdown buttons should own their generated group list");
100
+ assert.match(styles, /\.terminal-tab-group-dropdown-indicator \{[\s\S]*display:\s*none;[\s\S]*\.terminal-tab-group-button\[aria-expanded="true"\] \.terminal-tab-group-dropdown-indicator[\s\S]*rotate\(180deg\)/, "group buttons should expose a stateful dropdown indicator");
101
+ assert.match(styles, /\.terminal-tab-group-button \{\n\s+width:\s*100%;\n\s+min-width:\s*0;[\s\S]*\.terminal-tab-group-dropdown-indicator \{ display:\s*inline-grid; \}/, "mobile terminal groups should show the dropdown indicator and retain a full-width trigger");
102
+ assert.match(styles, /\.terminal-tab-group:hover:not\(\.menu-open\) \.terminal-tab-group-menu,[\s\S]*\.terminal-tab-group:focus-within:not\(\.menu-open\) \.terminal-tab-group-menu \{\n\s+display:\s*none;/, "mobile focus and latched hover should not keep a toggled-closed group visible");
103
+ assert.match(app, /if \(activeDrawerModal\.surface === elements\.terminalTabsShell && openTerminalTabGroupKey\)[\s\S]*event\.stopPropagation\(\)[\s\S]*clearOpenTerminalTabGroup\(openTerminalTabGroupKey, \{ force: true \}\)[\s\S]*terminal-tab-group-button/, "Escape should close a mobile group dropdown before closing the terminal drawer");
104
+ assert.match(app, /if \(tabId === activeTabId\) \{\n\s+clearOpenTerminalTabGroup\(null, \{ force: true \}\);\n\s+setMobileTabsExpanded\(false\);/, "selecting the already-active regular group member should close the mobile group and drawer");
105
+ assert.match(app, /async function activateSubagentTerminalView\(viewId\)[\s\S]*clearOpenTerminalTabGroup\(null, \{ force: true \}\);\n\s+setMobileTabsExpanded\(false\);/, "selecting a subagent group member should close the mobile group and drawer");
106
+ assert.match(app, /lines\.push\(isMobileView\(\) \? "Tap to open group terminals" : "Click to switch · Drop tabs here to add"\)/, "group accessible descriptions should match mobile dropdown and desktop switch behavior");
93
107
  assert.match(app, /footerTooltipNode\.setAttribute\("role", "tooltip"\)/, "the shared visual tooltip should expose tooltip semantics");
94
108
  assert.match(app, /document\.addEventListener\("keydown", \(event\) => \{[\s\S]*event\.key === "Escape" && footerTooltipTarget[\s\S]*hideFooterTooltip\(footerTooltipTarget\)[\s\S]*\}, true\)/, "Escape should dismiss both hover- and focus-triggered tooltips from the document capture phase");
95
- assert.match(app, /data-tooltip-variant"\) === "workspace" && !node\.matches\(":focus-visible"\)/, "touch focus should not flash the large workspace tooltip while keyboard focus remains supported");
109
+ assert.match(app, /node\.addEventListener\("focus", \(\) => \{[\s\S]*?!node\.matches\(":focus-visible"\)[\s\S]*?showFooterTooltip\(node\)/, "touch focus should not flash styled tooltips while keyboard focus remains supported");
96
110
  assert.match(app, /styled-tooltip-description[\s\S]*aria-describedby/, "detailed tab tooltip text should be available as an accessible description");
97
111
  assert.match(styles, /footer-floating-tooltip\[data-variant="workspace"\][\s\S]*line-height: 1\.52/, "workspace tooltips should use the readable visual variant");
98
112
  assert.doesNotMatch(styles, /terminal-tab-group-summary/, "group tooltip styling should not reserve in-flow menu space");
@@ -34,7 +34,7 @@ assert.match(html, /role="alert" hidden>[\s\S]*Replace this exact target\?/, "ov
34
34
 
35
35
  assert.match(app, /from "\.\/theme-contract\.mjs"/, "frontend should consume the shared browser-safe theme contract");
36
36
  assert.match(serviceWorker, /"\/theme-contract\.mjs"/, "the PWA app shell should cache the startup-critical theme contract");
37
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
37
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
38
38
  assert.match(pkg, /node --check public\/theme-contract\.mjs/, "the package check should syntax-check the startup-critical theme contract");
39
39
  assert.match(app, /function themeDraftFromCatalog\(theme, name = theme\?\.name\)[\s\S]*colors: cloneThemeDraft\(theme\?\.colors \|\| \{\}\)/, "catalog metadata should be projected into a schema-only editable draft");
40
40
  assert.match(app, /for \(const \{ name, label \} of group\.tokens\)/, "visual controls should render from the exact shared token inventory");