@firstpick/pi-package-webui 0.8.5 → 0.8.6

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 (47) hide show
  1. package/README.md +23 -1
  2. package/bin/pi-webui.mjs +375 -30
  3. package/index.ts +8 -1
  4. package/lib/git-workflow-preferences.mjs +3 -0
  5. package/lib/session-summary-core.mjs +4 -3
  6. package/lib/trust-boundaries.mjs +13 -0
  7. package/lib/workspace-session-summaries.mjs +400 -0
  8. package/package.json +2 -2
  9. package/public/app.js +1197 -267
  10. package/public/index.html +76 -3
  11. package/public/service-worker.js +3 -1
  12. package/public/stream-output-controller.mjs +327 -0
  13. package/public/styles.css +249 -70
  14. package/public/theme-contract.mjs +244 -0
  15. package/session-summary.ts +164 -4
  16. package/tests/aur-review-widget-static.test.mjs +2 -1
  17. package/tests/browser/interaction-continuity.spec.mjs +2 -2
  18. package/tests/browser/session-summary.spec.mjs +131 -3
  19. package/tests/browser/stream-output-isolation.spec.mjs +510 -0
  20. package/tests/codex-fast-mode-static.test.mjs +1 -1
  21. package/tests/composer-action-grid-reorder-static.test.mjs +1 -1
  22. package/tests/fast-mode-client-static.test.mjs +2 -1
  23. package/tests/fixtures/fake-pi.mjs +203 -2
  24. package/tests/git-workflow-preferences.test.mjs +7 -1
  25. package/tests/guided-git-aur-review.test.mjs +4 -3
  26. package/tests/http-endpoints-harness.test.mjs +207 -6
  27. package/tests/mobile-continuity-tablet-static.test.mjs +1 -1
  28. package/tests/mobile-foundation-static.test.mjs +2 -3
  29. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  30. package/tests/mobile-static.test.mjs +62 -29
  31. package/tests/native-parity.test.mjs +1 -1
  32. package/tests/open-issue-wizard-static.test.mjs +2 -3
  33. package/tests/persistent-ui-layout-static.test.mjs +1 -1
  34. package/tests/questionnaire-dialog.test.mjs +1 -1
  35. package/tests/remote-auth-settings-harness.test.mjs +9 -0
  36. package/tests/session-summary-core.test.mjs +183 -1
  37. package/tests/side-panel-section-reorder-static.test.mjs +1 -1
  38. package/tests/stream-lifecycle-core.test.mjs +134 -0
  39. package/tests/stream-output-controller.test.mjs +252 -0
  40. package/tests/stream-output-isolation-static.test.mjs +89 -0
  41. package/tests/streaming-ui-coupling.test.mjs +50 -0
  42. package/tests/subagent-gate-visibility.test.mjs +1 -1
  43. package/tests/subagent-launch-slots-static.test.mjs +1 -1
  44. package/tests/theme-contract.test.mjs +104 -0
  45. package/tests/theme-customizer-static.test.mjs +82 -0
  46. package/tests/theme-scheme-mode.test.mjs +15 -0
  47. package/tests/workspace-session-summaries.test.mjs +288 -0
@@ -102,13 +102,23 @@ assert.match(html, /id="terminalTabsLayoutStatus"/, "terminal-tabs layout select
102
102
  assert.match(html, /id="nativeCommandDialog"/, "native slash selector UI should have a dedicated dialog");
103
103
  assert.match(html, /id="optionsWorkflowSetupButton"[^>]*data-command="\/workflow-setup"[^>]*hidden[\s\S]*Workflow Permission Setup/, "Common Pi options should expose catalog-gated Workflow Permission Setup");
104
104
  assert.match(html, /id="optionsSummarySetupButton"[^>]*data-command="\/summary-setup"[^>]*hidden[\s\S]*Session Summary Setup/, "Common Pi options should expose catalog-gated Session Summary Setup");
105
- assert.match(html, /id="summaryHeaderButton"[^>]*aria-label="Open session summary"[^>]*hidden[\s\S]*id="summaryActionButton"[^>]*data-composer-action-id="summary"[^>]*hidden/, "catalog-gated summary actions should exist in both the terminal header and mobile composer sheet");
105
+ assert.doesNotMatch(html, /id="summary(?:Header|Action)Button"/, "workspace-level session summary launchers should be removed");
106
106
  assert.match(html, /id="sessionSummaryOverlay"[^>]*role="dialog"[^>]*aria-modal="false"[^>]*aria-labelledby="sessionSummaryOverlayTitle"[^>]*hidden[\s\S]*id="sessionSummaryOverlayBody"[\s\S]*id="sessionSummaryOverlayCopyButton"[\s\S]*id="sessionSummaryOverlayRefreshButton"/, "session summary should use a labelled non-modal Markdown overlay with copy and refresh actions");
107
107
  assert.doesNotMatch(html, /<dialog[^>]*id="sessionSummaryOverlay"/, "session summary overlay must remain non-blocking rather than modal");
108
108
  assert.match(html, /id="optionsSafetyGuardSetupButton"[\s\S]*data-command="\/safety-guard-setup"[\s\S]*Safety Guard Setup/, "Common Pi options should expose native Safety Guard Setup");
109
109
  assert.match(html, /id="optionsGitWorkflowSetupButton"[\s\S]*data-command="\/git-workflow-setup"[\s\S]*Guided Git Setup/, "Common Pi options should expose native Guided Git Setup");
110
110
  assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\[[^\]]*"summary"[^\]]*"summary-setup"[^\]]*"workflow-setup"[^\]]*\]\)/, "exact /summary, /summary-setup, and /workflow-setup should be browser-native selector commands");
111
- assert.match(app, /function renderSessionSummaryControls\(\)[\s\S]*hasAvailableCommand\("summary", \{ tabId: activeTabId \}\)[\s\S]*hasAvailableCommand\("summary-setup", \{ tabId: activeTabId \}\)[\s\S]*button\.hidden = !available/, "summary controls should be active-tab command-catalog gated");
111
+ assert.match(app, /function createTerminalTabSessionSummaryButton\(tab\)[\s\S]*hasAvailableCommand\("summary", \{ tabId: tab\.id \}\)[\s\S]*setAttribute\("aria-busy"[\s\S]*openSessionSummaryForTab\(tab\.id, \{ focusReturnKey:/, "each terminal tab summary action should use that tab's command catalog, busy state, focus restoration, and direct target");
112
+ assert.match(app, /function renderTerminalTab\(tab\)[\s\S]*createTerminalTabActions\(tab\)[\s\S]*function renderTerminalTabGroupItem\(tab, group\)[\s\S]*createTerminalTabActions\(tab\)/, "regular and grouped Pi terminal tabs should render shared per-tab split and summary actions");
113
+ assert.match(app, /function createTerminalTabActions\(tab\)[\s\S]*createTerminalTabSplitButton\(tab\)[\s\S]*createTerminalTabSessionSummaryButton\(tab\)/, "each terminal action slot should place Split beside Summary");
114
+ assert.match(app, /function terminalTabControlKey\(node\)[\s\S]*terminal-tab-split-button[\s\S]*terminal-tab:\$\{tabId\}:split[\s\S]*terminal-tab-summary-button[\s\S]*terminal-tab:\$\{tabId\}:summary/, "per-tab split and summary actions should retain stable focus continuity keys");
115
+ assert.match(app, /\.terminal-tab-close, \.terminal-tab-actions, \.terminal-tab-group-add/, "per-tab actions should not initiate terminal-tab dragging");
116
+ assert.match(app, /function prefetchInactiveTabCommandCatalogs\(\)[\s\S]*refreshCommands\(activeTabContext\(tab\.id\)\)[\s\S]*function refreshTabs[\s\S]*prefetchInactiveTabCommandCatalogs\(\)/, "restored inactive tabs should fetch their own command catalogs without activation");
117
+ assert.match(app, /const focusReturnKey = sessionSummaryOverlayFocusReturnKey[\s\S]*querySelectorAll\("button"\)[\s\S]*terminalTabControlKey\(node\) === focusReturnKey/, "summary overlay focus restoration should resolve rerendered per-tab controls by continuity key");
118
+ assert.match(app, /sessionSummaryOverlayFocusReturnKey = focusReturnKey \|\| terminalTabControlKey\(sessionSummaryOverlayFocusReturn\)/, "summary overlay opening should preserve an explicit per-tab focus key or capture the active control key");
119
+ assert.match(app, /openNativeSessionSummarySetupDialog\(\{ initialData: response\.data, tabId, focusReturnKey \}\)[\s\S]*tabId: targetTabId/, "unconfigured summary setup and preference save should retain the clicked tab target and focus return identity");
120
+ assert.match(css, /\.terminal-tab-actions \{[\s\S]*flex: 0 0 2rem[\s\S]*flex-direction: column[\s\S]*\.terminal-tab-split-button,[\s\S]*\.terminal-tab-summary-button \{[\s\S]*flex: 1 1 50%[\s\S]*min-height: 0[\s\S]*\.terminal-tab-split-button:not\(:only-child\) \{[\s\S]*border-bottom:[\s\S]*\.terminal-tab-group-item > \.terminal-tab-actions[\s\S]*\.terminal-tab-close \{/, "Split and Summary should stack at half height without increasing the existing compact tab height");
121
+ assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.terminal-tab-actions,[\s\S]*\.terminal-tab-close \{[\s\S]*min-width: 44px/, "touch layouts should preserve the shared 44px action slot and separate close target");
112
122
  assert.match(app, /function normalizeSessionSummaryClientState\(value, previous = null, \{ resetProjection = false \} = \{\}\)[\s\S]*sessionChanged[\s\S]*resetProjection \|\| sessionChanged \? null : previous[\s\S]*inherited\?\.summaryMarkdown/, "frontend should preserve failure Markdown but clear it for session changes and explicit branch-state projections");
113
123
  assert.match(app, /function handleSessionSummaryEvent\(event\)[\s\S]*resetProjection: event\?\.kind === "state"/, "active-branch state events should reset the cached overlay projection");
114
124
  assert.match(app, /function renderSessionSummaryOverlay\(\)[\s\S]*renderMarkdown\(elements\.sessionSummaryOverlayBody, state\.summaryMarkdown\)/, "summary overlay should use the sanitized Markdown renderer");
@@ -620,12 +630,14 @@ assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-dialo
620
630
  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");
621
631
  assert.match(css, /body\.terminal-tabs-left \.chat-panel \{[\s\S]*?grid-template-columns:\s*clamp\(13rem, 18vw, 19rem\) minmax\(0, 1fr\)/, "terminal tabs left layout should split the chat panel into a sidebar and transcript area");
622
632
  assert.match(css, /body\.terminal-tabs-left \.terminal-tabs-shell \{[\s\S]*?grid-column:\s*1;[\s\S]*?grid-row:\s*1 \/ -1;[\s\S]*?flex-direction:\s*column/, "terminal tabs left layout should turn the top tab strip into a vertical sidebar");
623
- assert.match(html, /class="terminal-sidebar-actions"[^>]*aria-label="Tab and workspace actions"[\s\S]*id="splitTabButton"[^>]*aria-label="Split the active terminal to the right"[\s\S]*id="workspaceSaveButton"[^>]*aria-label="Save workspace"[\s\S]*id="commandPaletteButton"[^>]*aria-label="Open command palette"[\s\S]*id="workspaceDashboardToggleButton"[^>]*aria-label="Show workspace overview"/, "tab, save, command, and workspace actions should share one accessibly labelled sidebar toolbar");
633
+ assert.match(html, /class="terminal-sidebar-actions"[^>]*aria-label="Tab and workspace actions"[\s\S]*id="workspaceSaveButton"[^>]*aria-label="Save workspace"[\s\S]*id="commandPaletteButton"[^>]*aria-label="Open command palette"[\s\S]*id="workspaceDashboardToggleButton"[^>]*aria-label="Show workspace overview"/, "save, command, and workspace actions should share one accessibly labelled sidebar toolbar");
634
+ assert.doesNotMatch(html, /id="splitTabButton"|class="terminal-split-button"/, "the global terminal-header Split control should be removed");
624
635
  assert.doesNotMatch(html, /terminal-sidebar-action-label/, "left-sidebar action buttons should be icon-only without redundant visible labels");
625
- assert.match(css, /body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?display:\s*grid;[\s\S]*?grid-template-columns:\s*repeat\(5, minmax\(0, 1fr\)\);[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions > button \{[\s\S]*?place-items:\s*center;[\s\S]*?min-height:\s*2\.75rem;[\s\S]*?padding:\s*0\.42rem;/, "left-sidebar actions should render as compact equal-width icon buttons with 44px targets");
626
- assert.match(css, /@media \(min-width: 721px\) \{[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?z-index:\s*130;[\s\S]*?overflow:\s*visible;[\s\S]*?terminal-workspace-save-button\[data-tooltip\]::after,[\s\S]*?terminal-command-palette-button\[data-tooltip\]::after,[\s\S]*?terminal-dashboard-button\[data-tooltip\]::after \{[\s\S]*?bottom:\s*calc\(100% \+ 0\.62rem\);[\s\S]*?z-index:\s*220;[\s\S]*?width:\s*calc\(400% \+ 1\.26rem\);/, "left-sidebar save, command, and overview tooltips should render above the full toolbar without clipping");
627
- assert.match(css, /terminal-workspace-save-button\[data-tooltip\]::after \{\s+left:\s*calc\(-100% - 0\.42rem\);[\s\S]*?terminal-command-palette-button\[data-tooltip\]::after \{\s+left:\s*calc\(-200% - 0\.84rem\);[\s\S]*?terminal-dashboard-button\[data-tooltip\]::after \{\s+left:\s*calc\(-300% - 1\.26rem\);/, "left-sidebar tooltips should align to the toolbar edges from their individual buttons");
628
- assert.match(app, /elements\.splitTabButton\.setAttribute\("aria-pressed", canShowSplit \? "true" : "false"\);[\s\S]*?applyStyledTooltip\(elements\.splitTabButton, label, \{ ariaLabel: label \}\);/, "icon-only split action should expose its Split or Close state through accessibility text and the tooltip");
636
+ assert.match(css, /body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?display:\s*grid;[\s\S]*?grid-template-columns:\s*repeat\(3, minmax\(0, 1fr\)\);[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions > button \{[\s\S]*?place-items:\s*center;[\s\S]*?min-height:\s*2\.75rem;[\s\S]*?padding:\s*0\.42rem;/, "left-sidebar actions should render as three compact equal-width icon buttons with 44px targets");
637
+ assert.match(css, /@media \(min-width: 721px\) \{[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?z-index:\s*130;[\s\S]*?overflow:\s*visible;[\s\S]*?terminal-workspace-save-button\[data-tooltip\]::after,[\s\S]*?terminal-command-palette-button\[data-tooltip\]::after,[\s\S]*?terminal-dashboard-button\[data-tooltip\]::after \{[\s\S]*?bottom:\s*calc\(100% \+ 0\.62rem\);[\s\S]*?z-index:\s*220;[\s\S]*?width:\s*calc\(300% \+ 0\.84rem\);/, "left-sidebar save, command, and overview tooltips should render above the full toolbar without clipping");
638
+ assert.match(css, /terminal-workspace-save-button\[data-tooltip\]::after \{\s+left:\s*0;[\s\S]*?terminal-command-palette-button\[data-tooltip\]::after \{\s+left:\s*calc\(-100% - 0\.42rem\);[\s\S]*?terminal-dashboard-button\[data-tooltip\]::after \{\s+left:\s*calc\(-200% - 0\.84rem\);/, "left-sidebar tooltips should align to the toolbar edges from their individual buttons");
639
+ assert.match(app, /function updateTerminalSplitControls\(canShowSplit[\s\S]*terminal-tab-split-button[\s\S]*setAttribute\("aria-pressed", isOpenSplit \? "true" : "false"\)[\s\S]*terminal-tab:\$\{tabId\}:split/, "per-tab Split controls should expose open or close state through accessibility text and stable tooltips");
640
+ assert.match(app, /async function splitTerminalTab\(tabId[\s\S]*tabs\.find\(\(tab\) => tab\.id === tabId\)[\s\S]*sourceTab\.cwd[\s\S]*body: \{ cwd: resolvedCwd \}/, "per-tab Split should create the independent terminal from the clicked tab's working directory");
629
641
  assert.match(css, /body\.terminal-tabs-left \.terminal-close-all-button \{[\s\S]*?margin-top:\s*0;[\s\S]*?justify-content:\s*center;[\s\S]*?text-align:\s*center;/, "left-sidebar close-all action should remain a separate centered destructive row");
630
642
  assert.match(css, /body\.terminal-tabs-left \.terminal-tabs \{[\s\S]*?flex-direction:\s*column/, "terminal tabs left layout should stack tabs vertically");
631
643
  assert.match(css, /body\.terminal-tabs-left \.terminal-tab-group-menu \{[\s\S]*?inset:\s*0 auto auto 100%;[\s\S]*?padding-left:\s*var\(--terminal-left-dropdown-bridge\)/, "left-sidebar grouped tab menus should include a hover bridge so they do not vanish between button and dropdown");
@@ -689,6 +701,19 @@ assert.match(app, /"Resolve with agent"[\s\S]*api\("\/api\/git-operation\/resolv
689
701
  assert.match(server, /function gitConflictResolutionAgentPrompt\(operation\)[\s\S]*Conflicted files:[\s\S]*Do not continue, skip, abort, commit, reset, or push[\s\S]*diff-filter=U is empty/, "server should build a bounded conflict handoff with operation safety and verification instructions");
690
702
  assert.match(server, /"\/api\/git-operation\/resolve-with-agent"[\s\S]*openGitConflictResolutionAgentTab\(tab\)/, "server should expose conflict-resolution agent tab creation through the git operation routes");
691
703
  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");
704
+ 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");
705
+ 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");
706
+ 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");
707
+ 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");
708
+ const gitFooterSyncRoutingSource = appFunctionSource("gitFooterSyncCounts", "gitFooterCurrentBranch");
709
+ const gitFooterSyncRouting = JSON.parse(vm.runInNewContext(`${gitFooterSyncRoutingSource}\nJSON.stringify({
710
+ incoming: gitFooterSyncAction({ key: "sync", value: "⇣2" }),
711
+ outgoing: gitFooterSyncAction({ key: "sync", value: "⇡2" }),
712
+ diverged: gitFooterSyncAction({ key: "sync", value: "⇡1 · ⇣2" }),
713
+ unavailable: gitFooterSyncAction({ key: "sync", value: "no upstream" }),
714
+ other: gitFooterSyncAction({ key: "changes", value: "⇣2" }),
715
+ })`));
716
+ 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");
692
717
  assert.match(app, /function gitDiffDisplayLine\(row, side\)[\s\S]*`-\$\{text\}`[\s\S]*`\+\$\{text\}`/, "git changes modal should render changed lines with +/- prefixes");
693
718
  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");
694
719
  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");
@@ -701,7 +726,8 @@ assert.match(server, /async function readGitChanges\(cwd\)[\s\S]*?const diffArgs
701
726
  assert.match(server, /\["status", "--porcelain=2", "--branch", "--untracked-files=all"\][\s\S]*?summarizeGitPorcelainStatus\(porcelainStatusText\)/, "server should derive behind/ahead from locale-independent porcelain status so the Pull button activates after fetch");
702
727
  assert.match(server, /async function readGitIncomingChanges\(root, summary\)[\s\S]*?"HEAD\.\.@\{upstream\}"/, "server should collect incoming upstream diffs when remote commits are behind");
703
728
  assert.match(server, /url\.pathname === "\/api\/git-changes" && req\.method === "GET"/, "server should expose GET /api/git-changes for the changes modal");
704
- assert.match(server, /url\.pathname === "\/api\/git-changes\/pull" && req\.method === "POST"[\s\S]*?pullGitChanges\(tab\.cwd\)/, "server should expose POST /api/git-changes/pull for the changes modal Pull button");
729
+ assert.match(server, /async function pullGitChanges\(cwd, \{ remote \} = \{\}\)[\s\S]*?const pullArgs = \["pull", "--ff-only"\];[\s\S]*?remote === "origin"[\s\S]*?pullArgs\.push\("origin"\)[\s\S]*?runGuardedGitMutation\(pullArgs/, "server should allow the guarded pull endpoint to target origin explicitly");
730
+ assert.match(server, /url\.pathname === "\/api\/git-changes\/pull" && req\.method === "POST"[\s\S]*?pullGitChanges\(tab\.cwd, \{ remote: body\?\.remote \}\)/, "server should expose POST /api/git-changes/pull for modal and footer Pull actions");
705
731
  assert.match(css, /@media \(max-width: 1050px\)[\s\S]*?\.footer-line-meta \{[\s\S]*?display:\s*flex;[\s\S]*?flex-wrap:\s*wrap;[\s\S]*?\.footer-line-meta \.footer-meta \{[\s\S]*?flex:\s*1 1 var\(--footer-chip-min-width\);[\s\S]*?width:\s*auto;[\s\S]*?\.footer-workspace,\n\s+\.footer-model,\n\s+\.footer-thinking \{ grid-column:\s*auto; \}/, "narrow git-footer metadata should wrap like the top metric row instead of forcing a two-column grid");
706
732
  assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\)[\s\S]*?\.context-meter-bar \{ display:\s*none !important; \}/, "mobile should hide the WebUI context meter that appears after high context usage");
707
733
  assert.match(css, /\.footer-line-tui \{[\s\S]*?white-space:\s*nowrap/, "default Web UI footer should use a minimal TUI-like line");
@@ -768,8 +794,13 @@ assert.match(app, /const TERMINAL_TABS_LAYOUT_STORAGE_KEY = "pi-webui-terminal-t
768
794
  assert.match(app, /document\.body\.classList\.toggle\("terminal-tabs-left", next === "left"\)/, "terminal-tabs layout should toggle a body class for CSS layout");
769
795
  assert.match(app, /terminalTabsLayoutSelect\.addEventListener\("change"/, "terminal-tabs layout selector should update the browser layout immediately");
770
796
  assert.match(app, /async function initializeThemes\(\)/, "frontend should initialize bundled themes");
771
- assert.match(app, /api\("\/api\/themes", \{ scoped: false \}\)/, "theme loading should use the unscoped themes endpoint");
797
+ assert.match(app, /api\("\/api\/themes", \{ scoped: false \}\)/, "baseline theme loading should remain backward-compatible with the unscoped themes endpoint");
798
+ assert.match(app, /async function refreshThemeCatalog\(tabContext = activeTabContext\(\)\)[\s\S]*api\("\/api\/themes", \{ tabId: tabContext\.tabId \}\)/, "custom project theme discovery should refresh against the active tab context");
772
799
  assert.match(app, /function applyTheme\(theme/, "frontend should apply a selected theme to CSS variables");
800
+ assert.match(html, /id="themeCustomizeButton"[^>]*aria-controls="themeCustomizerDialog"/, "mobile theme controls should expose the accessible customizer launcher");
801
+ assert.match(css, /@media \(max-width: 720px\), \(pointer: coarse\) and \(hover: none\)[\s\S]*\.theme-customizer-dialog \{[\s\S]*width: 100vw[\s\S]*height: var\(--visual-viewport-height, 100dvh\)[\s\S]*\.theme-token-grid,[\s\S]*grid-template-columns: minmax\(0, 1fr\)/, "theme customizer should become a one-column visual-viewport-height editor on phones and coarse pointers");
802
+ assert.match(css, /\.theme-customizer-scroll \{[\s\S]*overflow-y: auto/, "the 51-token mobile customizer should scroll internally");
803
+ assert.match(css, /\.theme-token-swatch \{[^}]*width: 44px[^}]*height: 44px/, "theme color pickers should preserve 44px touch targets");
773
804
  assert.match(app, /const LOCAL_BACKGROUND_IMAGE_PATTERN = /, "frontend should restrict theme background images to local static URLs");
774
805
  assert.match(app, /"--theme-background-image": themeExportCssValue\(theme, "backgroundImage", "none", LOCAL_BACKGROUND_IMAGE_PATTERN\)/, "frontend should apply theme export background images to CSS variables");
775
806
  assert.match(app, /applyCustomBackgroundOverride\(\{ render: false \}\);/, "theme changes should preserve the user's custom background override");
@@ -1601,15 +1632,15 @@ assert.match(app, /function toolResultPreviewText\(message, lineLimit = 10\)/, "
1601
1632
  assert.match(app, /const WEBUI_TOOL_RENDERERS = \{[\s\S]*?function renderSingleToolExecution\(parent, message\)[\s\S]*?WEBUI_TOOL_RENDERERS[\s\S]*?function renderToolExecution\(parent, message\)[\s\S]*?renderSingleToolExecution\(parent, message\)/, "paired tool cards should use the browser-side built-in tool renderer registry");
1602
1633
  assert.match(app, /appendToolRawDetails\(parent, tool\)/, "paired tool cards should keep a safe raw-data expander for debugging renderer mismatches");
1603
1634
  assert.match(app, /function toolStateMeta\(tool\)/, "tool cards should expose consistent status and elapsed metadata across built-in renderers");
1604
- assert.match(app, /const TOOL_LIVE_UPDATE_THROTTLE_MS = 80/, "live tool cards should coalesce rapid partial updates before re-rendering");
1605
- const updateLiveToolCardSource = appFunctionSource("updateLiveToolCard", "cancelQueuedLiveToolRunRender");
1635
+ assert.doesNotMatch(app, /TOOL_LIVE_UPDATE_THROTTLE_MS|liveToolRenderQueue/, "superseded per-tool timers should not compete with the bounded stream controller");
1636
+ const updateLiveToolCardSource = appFunctionSource("updateLiveToolCard", "renderLiveToolRun");
1606
1637
  assert.match(updateLiveToolCardSource, /transcriptRenderer\.ownSurface\(body[\s\S]*?transcriptRenderer\.commitTranscriptMutation\(\{[\s\S]*?kind: "reconcile"[\s\S]*?transcriptRenderer\.replaceChildren\(body\)[\s\S]*?renderToolExecution\(body, message\)/, "live tool card updates should re-render the existing semantic body through the transcript coordinator");
1607
1638
  assert.match(app, /function applyToolExecutionBubbleState\(bubble, message\)[\s\S]*?bubble\.dataset\.toolStatus !== status[\s\S]*?bubble\.classList\.add\(nextClass\)[\s\S]*?bubble\.classList\.toggle\("error"/, "tool status classes should not be removed and re-added on every live update");
1608
1639
  assert.match(app, /function toolExecutionRenderSignature\(message\)[\s\S]*?normalizeToolExecution\(message\)[\s\S]*?toolRenderSignatureReplacer\(\)/, "tool cards should derive stable render signatures from normalized tool payloads");
1609
1640
  assert.match(app, /const nextRenderSignature = toolExecutionRenderSignature\(message\)[\s\S]*?bubble\._toolRenderSignature === nextRenderSignature[\s\S]*?return true;[\s\S]*?bubble\._toolRenderSignature = nextRenderSignature/, "live tool card updates should skip identical body re-renders");
1610
1641
  assert.match(app, /message\.role === "toolExecution"[\s\S]*?renderToolExecution\(body, message\);[\s\S]*?bubble\._toolRenderSignature = toolExecutionRenderSignature\(message\);/, "new tool cards should cache their initial render signature");
1611
- assert.match(app, /function scheduleLiveToolRunRender\(run[\s\S]*?liveToolRenderQueue\.set[\s\S]*?TOOL_LIVE_UPDATE_THROTTLE_MS/, "live tool update events should be queued and throttled for smoother browser output");
1612
- assert.match(app, /function handleToolExecutionUpdate\(event\)[\s\S]*?event\.partialResult[\s\S]*?scheduleLiveToolRunRender\(run, \{ scroll: false \}\)/, "live tool_execution_update events should update transcript-visible tool cards without replacing them per event");
1642
+ assert.match(app, /applyToolExecutionUpdate: \(event\) => \{\s+if \(!compactOutputActive\(\)\) applyTranscriptToolExecutionUpdate\(event\);/, "live tool updates should enter the bounded transcript controller sink");
1643
+ assert.match(app, /function applyTranscriptToolExecutionUpdate\(event\)[\s\S]*?event\.partialResult[\s\S]*?renderLiveToolRun\(run, \{ scroll: false \}\)/, "coalesced tool_execution_update events should update transcript-visible tool cards in the controller frame");
1613
1644
  assert.match(app, /function captureReusableToolCards\(\)[\s\S]*?\.message\.toolExecution\[data-tool-call-id\]/, "full transcript re-renders should capture existing tool cards before clearing the chat");
1614
1645
  assert.match(app, /function appendMessage\(message,[\s\S]*?reusableToolCards = null[\s\S]*?reuseToolExecutionBubble\(reusableToolCards, message/, "message rendering should reuse matching tool cards instead of replacing them during refreshes");
1615
1646
  assert.match(app, /function renderAllMessages\(\{ preserveScroll = false, forceRebuild = false \} = \{\}\)[\s\S]*?const reusableToolCards = captureReusableToolCards\(\);[\s\S]*?appendTranscriptMessage\(entry\.item\.message,[\s\S]*?reusableToolCards,/, "transcript refreshes should pass reusable tool cards through to item rendering");
@@ -1647,19 +1678,19 @@ assert.match(app, /function syncStreamingThinkingFromUpdate\(event, update[\s\S]
1647
1678
  assert.match(app, /function setStreamRawText\(text\)[\s\S]*?streamRawText = nextText;[\s\S]*?resetStreamDerivedTextCache\(\);/, "live assistant text should synchronize from partial messages through a cache-aware setter");
1648
1679
  assert.match(app, /const TODO_PROGRESS_LINE_REGEX = /, "frontend should recognize live todo progress lines that will be moved into the todo widget");
1649
1680
  assert.match(app, /function stripTodoProgressLines\(text, \{ streaming = false \} = \{\}\)/, "live Assistant output should strip todo-progress lines before rendering final-output text");
1650
- assert.match(app, /function syncLiveTodoProgressWidgetFromText\(text, tabId = activeTabId\)/, "live Assistant checklist text should update the todo-progress widget before tool execution events");
1651
- assert.match(app, /scheduleLiveTodoProgressWidgetSync\(streamRawText, event\.tabId \|\| activeTabId\)/, "streaming assistant text should feed the live todo-progress widget through the coalesced sync scheduler");
1681
+ assert.match(app, /function syncLiveTodoProgressWidgetFromText\(text, tabId = activeTabId\)/, "authoritative Assistant checklist text should remain convertible into the todo-progress widget");
1682
+ assert.doesNotMatch(app, /scheduleLiveTodoProgressWidgetSync\(streamRawText, event\.tabId \|\| activeTabId\)/, "raw streaming assistant text must not drive the todo-progress widget");
1652
1683
  assert.match(app, /function renderStreamingAssistantText\(\)[\s\S]*?const thinkingFormat = syncStreamingThinkingFormat\(\);[\s\S]*?const finalText = thinkingFormat\?\.hasThinkingFormat \? streamDerivedText\(\)\.finalText : streamRenderableAssistantText\(\);/, "streamed Assistant text should render cached derived output without directly rescanning raw stream text");
1653
1684
  assert.match(app, /function syncStreamingThinkingFormat\(\)[\s\S]*?const parsed = streamDerivedText\(\)\.thinkingFormat;[\s\S]*?setStreamingThinkingText\(thinking\)/, "tagged <think> streaming output should update the live thinking card from cached parse state instead of flashing raw tags");
1654
1685
  assert.match(app, /const finalText = thinkingFormat\?\.hasThinkingFormat \? streamDerivedText\(\)\.finalText : streamRenderableAssistantText\(\);/, "tagged <think> streaming output should render only final response text in the Assistant card");
1655
1686
  assert.match(app, /const STREAM_OUTPUT_HIDE_DELAY_MS = 300/, "stream output hiding should be debounced to prevent rapid flicker");
1656
- assert.match(app, /const STREAM_OUTPUT_TOOLCALL_GUARD_MS = 220/, "live assistant text should be briefly guarded so pre-tool-call text can be suppressed");
1687
+ assert.doesNotMatch(app, /STREAM_OUTPUT_TOOLCALL_GUARD_MS|scheduleStreamingAssistantTextRender/, "controller batching should be the only live assistant render scheduler");
1657
1688
  assert.match(app, /function scheduleStreamBubbleHide\([\s\S]*?STREAM_OUTPUT_MIN_VISIBLE_MS/, "stream output cards should observe a minimum visible duration before hiding");
1658
1689
  assert.match(app, /if \(finalText\) \{[\s\S]*?renderStreamingMarkdown\(streamText, finalText\);[\s\S]*?\} else \{\n\s+scheduleStreamBubbleHide\(\);/, "empty filtered stream output should schedule hide while visible stream output renders as Markdown");
1659
- assert.match(app, /scheduleStreamingAssistantTextRender\(\{ immediate: !!\(streamToolCallSeen \|\| streamBubble\) \}\);/, "live assistant text should wait briefly before showing unless it is already visible or follows a tool call");
1690
+ assert.match(app, /function handleMessageUpdate\(event\)[\s\S]*?renderStreamingAssistantText\(\);/, "controller-batched assistant text should render through the transcript-only sink without a second scheduler");
1660
1691
  assert.match(app, /streamToolCallSeen = true;\n\s+suppressStreamingAssistantTextBeforeToolCall\(\);/, "tool-call starts should remove pending assistant text from the live transcript");
1661
1692
  assert.match(app, /function renderStreamingToolCallCard\(\{ scroll = false \} = \{\}\)[\s\S]*?appendMessage\(message, \{ streaming: true, itemKey:[\s\S]*?transcriptRenderer\.ownSurface\(streamToolCallText[\s\S]*?transcriptRenderer\.updateTextSurface\(\{[\s\S]*?text: displayText/, "live tool-call cards should render and update their stable semantic arguments surface in place");
1662
- assert.match(app, /update\.type === "toolcall_delta"[\s\S]*?updateStreamingToolCallFromEvent\(event, \{ appendDelta: true \}\)[\s\S]*?Building tool call:/, "tool-call deltas should update visible streamed arguments instead of a static placeholder");
1693
+ assert.match(app, /update\.type === "toolcall_delta"[\s\S]*?updateStreamingToolCallFromEvent\(event, \{ appendDelta: true \}\)/, "tool-call deltas should update visible streamed arguments through the transcript-only sink");
1663
1694
  assert.match(app, /case "tool_execution_start":[\s\S]*?removeStreamingToolCallCard\(\)[\s\S]*?handleToolExecutionStart\(event\)/, "the streamed tool-call argument card should be removed when the real tool execution card starts");
1664
1695
  assert.doesNotMatch(app, /Preparing tool call:/, "tool-call streaming should no longer show only the static preparing placeholder");
1665
1696
  assert.match(app, /const created = appendMessage\(\{ role: "assistant", title: "final output"/, "live Assistant cards should be created only for final output text without a noisy Assistant label");
@@ -1687,7 +1718,7 @@ assert.match(app, /function ensureRunIndicatorBubble\(\)[\s\S]*?!runIndicatorBub
1687
1718
  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");
1688
1719
  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");
1689
1720
  assert.match(app, /runIndicatorShowsElapsed\(\) \? `\$\{detail\} · run time/, "active agent indicator should label elapsed run time instead of showing a bare counter");
1690
- assert.match(app, /case "agent_settled":[\s\S]*?clearRunIndicatorActivity\(\{ deferRemoval: !autoFollowChat \|\| !isChatNearBottom\(\) \}\);[\s\S]*?scheduleRefreshMessages\(\)/, "settlement should keep the tail height stable for readers above the live edge until canonical messages reconcile");
1721
+ assert.match(app, /case "agent_settled":(?:(?!case ")[\s\S])*?clearRunIndicatorActivity\(\{ deferRemoval: !autoFollowChat \|\| !isChatNearBottom\(\) \}\);(?:(?!case ")[\s\S])*?scheduleSemanticReconcile\(\{[^}]*messages: true/, "settlement should keep the tail height stable for readers above the live edge until the coalesced semantic reconciler refreshes canonical messages");
1691
1722
  assert.match(app, /Abort requested/, "abort feedback should clarify that Web UI is checking stop status");
1692
1723
  assert.match(app, /const ABORT_LONG_PRESS_MS = 3000/, "Abort long-press timing should be explicit");
1693
1724
  assert.match(app, /const ABORT_LONG_PRESS_TICK_MS = 100/, "Abort hold countdown should update visibly while held");
@@ -1716,7 +1747,7 @@ assert.match(app, /function clearRunIndicatorActivity[\s\S]*?clearRunIndicatorGr
1716
1747
  assert.match(app, /scheduleRunIndicatorGraceCheck\(tabContext = activeTabContext\(\)\)[\s\S]*?refreshState\(tabContext\)/, "stale local-only run indicators should re-check state after the start grace period");
1717
1748
  assert.match(app, /function scheduleAbortStateChecks\(/, "abort handling should poll state so the active indicator can clear after stop confirmation");
1718
1749
  assert.match(app, /case "tool_execution_start":[\s\S]*?suppressStreamingAssistantTextBeforeToolCall\(\)[\s\S]*?handleToolExecutionStart\(event\)[\s\S]*?setRunIndicatorActivity\(`Running tool:/, "tool execution should suppress pre-tool assistant text, then update the active agent indicator and live tool card");
1719
- assert.match(app, /case "tool_execution_update":[\s\S]*?handleToolExecutionUpdate\(event\)/, "tool execution updates should be handled as transcript output");
1750
+ assert.match(app, /applyToolExecutionUpdate: \(event\) => \{\s+if \(!compactOutputActive\(\)\) applyTranscriptToolExecutionUpdate\(event\);/, "tool execution updates should enter the transcript-only controller sink before lifecycle dispatch");
1720
1751
  assert.match(app, /case "auto_retry_start":[\s\S]*?addTransientMessage\(\{ role: "warn", title: "auto retry"/, "auto-retry starts should be transcript-visible warnings");
1721
1752
  assert.match(app, /function trackAutoRetryStateFromEvent\(event\)[\s\S]*?event\.type === "auto_retry_start"[\s\S]*?autoRetryingTabs\.add\(tabId\)[\s\S]*?suppressPendingAgentDoneNotificationsForTab\(tabId\)[\s\S]*?markTabWorkingLocally\(tabId\)/, "auto-retry starts should suppress misleading done notifications and keep the tab working");
1722
1753
  assert.match(app, /function notifyAgentDone[\s\S]*?agentDoneNotificationKeys\.add\(key\);\n\s+if \(isAutoRetryingTab\(tabId\)\) return;/, "agent-done notifications should be ignored while a tab is auto-retrying");
@@ -1762,7 +1793,7 @@ assert.match(app, /function renderBusyPromptBehaviorTag\(\)[\s\S]*?tag\.textCont
1762
1793
  assert.doesNotMatch(app, /Busy send: \$\{label\}/, "busy prompt behavior tag should not prefix the current mode label");
1763
1794
  assert.match(app, /function renderSessionSkillTags\(tabId = activeTabId\)[\s\S]*?filter\(\(entry\) => entry\.kinds\.has\("read"\)\)[\s\S]*?make\("button", classes\.join\(" "\), entry\.name\)[\s\S]*?openSkillEditor\(entry\)/, "skill tags should render as clickable buttons only after the full skill context was read");
1764
1795
  assert.ok(app.includes('normalized.match(/\\/skills\\/([^/]+)\\/SKILL\\.md$/i)'), "skill context tracking should require SKILL.md paths");
1765
- assert.match(app, /function trackSkillsFromToolInvocation\(tabId, toolName[\s\S]*?name\.toLowerCase\(\) !== "read"\) return;[\s\S]*?kind: "read"/, "skill context tracking should only follow read-tool invocations");
1796
+ assert.match(app, /function trackSkillsFromToolInvocation\(tabId, toolName[\s\S]*?name\.toLowerCase\(\) !== "read"\) return false;[\s\S]*?kind: "read"/, "skill context tracking should only follow read-tool invocations");
1766
1797
  assert.match(app, /function trackSkillUsage\(tabId, skillName[\s\S]*?persistSkillUsage\(\);[\s\S]*?renderSessionSkillTags\(tabId\)/, "skill tags should persist and live-update when a read skill is tracked");
1767
1798
  assert.match(app, /const SKILL_USAGE_STORAGE_KEY = "pi-webui-skill-usage-v1"/, "read skill tags should have browser storage for hard-refresh and restart restore");
1768
1799
  assert.match(app, /function persistSkillUsage\(\)[\s\S]*?localStorage\.setItem\(SKILL_USAGE_STORAGE_KEY/, "read skill tags should be persisted to browser storage");
@@ -1797,7 +1828,7 @@ assert.match(app, /function renderMessages\(messages\) \{\n\s+latestMessages = m
1797
1828
  assert.match(app, /if \(startsRun\) \{\n\s+promptRoutingTabs\.add\(targetTabId\);\n\s+markTabWorkingLocally\(targetTabId\);\n\s+if \(isCurrentTabContext\(tabContext\)\) \{\n\s+optimisticPromptId = appendOptimisticUserPrompt\(originalMessage, attachments\.length\);\n\s+setRunIndicatorActivity\(attachments\.length \? "Preparing attachments for routing…" : "Routing prompt to the selected agent…"\);/, "new runs should show the prompt and routing progress immediately in the target tab");
1798
1829
  assert.match(app, /if \(startsRun && isCurrentTabContext\(tabContext\)\) setRunIndicatorActivity\("Routing complete; starting agent…"\);/, "prepared prompts should transition from routing to agent-start progress before dispatch");
1799
1830
  assert.doesNotMatch(app, /applyResponseTab\(response\);\n\s+if \(startsRun\) promptRoutingTabs\.delete\(targetTabId\);/, "prompt acceptance alone should not clear pending launch continuity before Pi confirms the run");
1800
- assert.match(app, /case "agent_start":\n\s+promptRoutingTabs\.delete\(event\.tabId \|\| activeTabId\);/, "agent start should replace optimistic routing continuity with canonical streaming state");
1831
+ assert.match(app, /if \(event\?\.type === "agent_start"\) beginToolBoundaryRun\(event\);[\s\S]*?if \(!eventTargetsActiveTab\(event\)\)[\s\S]*?case "agent_start":\n\s+promptRoutingTabs\.delete\(event\.tabId \|\| activeTabId\);/, "agent start should establish run-scoped dedupe for active and inactive tabs before replacing optimistic routing continuity with canonical streaming state");
1801
1832
  assert.match(app, /else if \(promptRoutingTabs\.has\(activeTabId\)\) \{\n\s+renderRunIndicator/, "idle state snapshots should not hide the run indicator while an accepted prompt still awaits agent start");
1802
1833
  assert.match(app, /if \(state\.isStreaming && runIndicatorActivityIsRouting\(\)\) \{\n\s+runIndicatorActivity = "Agent run confirmed; waiting for first output or action…";/, "confirmed streaming state should replace stale routing copy without overwriting newer thinking or tool activity");
1803
1834
  assert.match(app, /function runPublishWorkflow\(command\)[\s\S]*?sendPrompt\("prompt", `\/\$\{resolvedCommandName\}\$\{commandRest\}`\)/, "Publish workflows should send resolved slash commands directly without replacing the draft");
@@ -1833,7 +1864,8 @@ assert.match(app, /optionsGitWorkflowSetupButton\?\.addEventListener\("click", \
1833
1864
  assert.match(extension, /registerCommand\("git-workflow-setup"[\s\S]*runGitWorkflowSetup/, "Pi extension should register the reusable /git-workflow-setup command");
1834
1865
  assert.match(app, /async function openNativeSafetyGuardSetupDialog\([\s\S]*\/api\/safety-guard\/config/, "Web UI should implement Safety Guard Setup with the canonical persisted config API");
1835
1866
  assert.match(server, /url\.pathname === "\/api\/safety-guard\/config" && req\.method === "GET"[\s\S]*url\.pathname === "\/api\/safety-guard\/config" && req\.method === "POST"/, "server should expose native safety guard config read and save endpoints");
1836
- assert.match(app, /async function openNativeGitWorkflowSetupDialog\([\s\S]*\/api\/git-workflow\/preferences/, "Web UI should implement Guided Git Setup with the persisted preferences API");
1867
+ assert.match(app, /async function openNativeGitWorkflowSetupDialog\([\s\S]*\/api\/git-workflow\/preferences[\s\S]*Manual review process[\s\S]*reviewProcessEnabled: controls\.reviewProcess\.select\.value === "enabled"/, "Web UI should persist the Guided Git review-process toggle through the preferences API");
1868
+ assert.match(extension, /Manual review process[\s\S]*reviewProcessEnabled: reviewProcess === "enabled"/, "Pi's reusable setup command should persist the same review-process choice");
1837
1869
  assert.match(app, /async function sendPrompt\(kind = "prompt", explicitMessage, \{ targetTabId = activeTabId, throwOnError = false, streamingBehavior \} = \{\}\)/, "prompt sending should accept direct messages that bypass the input field and optional target tab");
1838
1870
  assert.match(app, /const rawMessage = usesPromptInput \? elements\.promptInput\.value : explicitMessage/, "direct prompt sends should not read the input textarea");
1839
1871
  assert.match(app, /function clearPromptInputForRouting\(\{ usesPromptInput,[\s\S]*?if \(!usesPromptInput\) return;/, "direct prompt sends should preserve the input textarea draft");
@@ -2137,6 +2169,7 @@ assert.match(server, /type: "set_steering_mode"/, "server should expose steering
2137
2169
  assert.match(server, /type: "set_follow_up_mode"/, "server should expose follow-up queue-mode changes for native /settings");
2138
2170
  assert.match(server, /type: "set_auto_compaction"/, "server should expose auto-compaction changes for native /settings");
2139
2171
  assert.match(server, /@firstpick\/pi-themes-bundle/, "server should discover themes from the optional theme package");
2172
+ assert.match(server, /configuredAgentNpmRoot\(\), "node_modules", "@firstpick", "pi-themes-bundle", "themes"/, "server should discover themes installed in Pi's managed agent npm root");
2140
2173
  assert.match(server, /const OPTIONAL_FEATURE_PACKAGES = new Map\(OPTIONAL_FEATURE_CATALOG/, "server should derive install allowlisting from the optional feature catalog");
2141
2174
  assert.match(optionalFeatureCatalog, /\["bangCommandAutocomplete", "@firstpick\/pi-extension-bang-command-autocomplete"/, "catalog should allow installing the bang autocomplete optional feature");
2142
2175
  assert.match(optionalFeatureCatalog, /\["fishUserBash", "@firstpick\/pi-extension-fish-user-bash"/, "catalog should allow installing the fish user-bash optional feature");
@@ -2175,10 +2208,10 @@ assert.match(server, /Skill path is outside allowed Pi skill locations/, "explic
2175
2208
  assert.match(server, /writeFile\(tmpFile, body\.content[\s\S]*?rename\(tmpFile, skill\.filePath\)/, "skill file saves should use an atomic temp-file rename");
2176
2209
  assert.match(server, /url\.pathname === "\/api\/themes" && req\.method === "GET"/, "server should expose GET /api/themes");
2177
2210
  assert.match(server, /readBundledThemes\(\)/, "server should read bundled theme JSON files for the browser");
2178
- assert.match(server, /"apple-touch-icon\.png", "icon-192\.png"/, "server should serve the conventional apple touch icon path");
2179
- // Intent preserved: the static allowlist must include every app startup module, including the Phase 1 shell state.
2180
- assert.match(server, /"mobile-shell-state\.mjs", "issue-wizard-state\.mjs", "issue-bot-client\.mjs", "fast-output-live\.mjs"/, "server should serve browser modules imported by the app");
2181
- assert.match(server, /"catppuccin-mocha-background\.png", "matrix-background\.webp", "manifest\.webmanifest", "service-worker\.js"/, "server should serve theme background images as static assets");
2211
+ // public/ is the explicit browser boundary; flat, typed asset serving prevents a
2212
+ // newly imported module from drifting out of sync with a second name allowlist.
2213
+ assert.match(server, /const STATIC_PUBLIC_FILE_EXTENSIONS = new Set\(\["\.html", "\.css", "\.js", "\.mjs", "\.svg", "\.png", "\.webp", "\.webmanifest"\]\)/, "server should allow only supported public asset types");
2214
+ assert.match(server, /\^\[A-Za-z0-9\]\[A-Za-z0-9\._-\]\*\$[\s\S]*STATIC_PUBLIC_FILE_EXTENSIONS\.has\(path\.extname\(name\)\)/, "server should serve only safe flat file names from public");
2182
2215
  assert.match(server, /\["\.webmanifest", "application\/manifest\+json; charset=utf-8"\]/, "server should serve manifest with the correct MIME type");
2183
2216
  assert.match(server, /\["\.png", "image\/png"\]/, "server should serve PWA PNG icons with the correct MIME type");
2184
2217
  assert.match(server, /\["\.webp", "image\/webp"\]/, "server should serve Matrix WebP backgrounds with the correct MIME type");
@@ -2201,7 +2234,7 @@ assert.match(readme, /pi install npm:@firstpick\/pi-extension-stats[\s\S]*Re-run
2201
2234
  assert.match(readme, /server-persisted fast picks/, "README should describe server-persisted fast picks");
2202
2235
  assert.match(readme, /`\/btw` side-question output widgets with optional context transfer\/live steering, browser notifications when a tab needs an extension UI response, and an optional side-panel toggle for agent-done notifications/, "README should describe /btw, blocked-tab, and agent-done notifications");
2203
2236
  assert.match(readme, /blocked-tab browser notifications, and optional agent-done notifications require browser service-worker\/notification support/, "README should document notification requirements");
2204
- assert.match(readme, /Side-panel theme picker backed by optional `@firstpick\/pi-themes-bundle` themes when loaded/, "README should describe optional theme selection");
2237
+ assert.match(readme, /Side-panel theme picker backed by optional `@firstpick\/pi-themes-bundle` themes plus Pi-native project\/global custom themes/, "README should describe bundled and custom theme selection");
2205
2238
  assert.match(readme, /## Optional companion packages/, "README should document optional Web UI companion packages");
2206
2239
  assert.match(readme, /Web UI tabs load enabled resources resolved from normal Pi settings/, "README should document Pi-settings-based optional feature loading");
2207
2240
  assert.match(readme, /legacy\/hoisted package files without either a Pi settings entry or an enabled top-level resource remain installable/i, "README should document migration handling for physically present but unregistered packages");
@@ -2270,7 +2303,7 @@ assert.match(app, /if \(!nextMessages\) \{[\s\S]*?api\("\/api\/messages", \{ tab
2270
2303
  assert.match(server, /function applyMessagesSinceParam\(response, url\)/, "server should slice get_messages results for \\?since= requests");
2271
2304
  assert.match(app, /const messageStaticSignatureCache = new WeakMap\(\);/, "static message signatures should be cached by object identity");
2272
2305
  assert.match(app, /case "tool_execution_end":(?:(?!scheduleRefreshMessages)[\s\S])*?break;/, "tool completions must not trigger full transcript refreshes");
2273
- assert.match(app, /case "message_end":[\s\S]*?scheduleRefreshMessages\(\);/, "assistant message completion must still reconcile the transcript");
2306
+ assert.match(app, /case "message_end": \{(?:(?!case ")[\s\S])*?scheduleSemanticReconcile\(\{ messages: true, state: true, footerData: true \}, tabContext\);/, "assistant message completion must still reconcile the transcript, through the coalesced semantic scheduler");
2274
2307
 
2275
2308
  // --- UX: transcript search (P2-1) ---
2276
2309
  assert.match(html, /id="chatSearchBar"[\s\S]*?id="chatSearchInput"[\s\S]*?id="chatSearchPrevButton"[\s\S]*?id="chatSearchNextButton"[\s\S]*?id="chatSearchCloseButton"/, "transcript search bar markup should exist with navigation controls");
@@ -154,7 +154,7 @@ assert.match(server, /url\.pathname === "\/api\/workflow-policy" && req\.method
154
154
  assert.match(app, /\(name === "workflow-setup" \|\| name === "summary" \|\| name === "summary-setup"\) && !hasLoadedRpcCommand\(name\)[\s\S]*case "workflow-setup":[\s\S]*openNativeWorkflowSetupDialog\(\)/, "frontend should gate exact summary and setup commands on the active Pi tab's loaded extension catalog");
155
155
  assert.ok(app.includes('const summaryMatch = String(message || "").trim().match(/^\\/summary(?:\\s+(refresh))?$/i);'), "frontend should intercept only exact /summary and /summary refresh command forms");
156
156
  assert.match(app, /case "summary":[\s\S]*openSessionSummaryForTab\(activeTabId, \{ refresh: summaryMatch\?\.\[1\][\s\S]*case "summary-setup":[\s\S]*openNativeSessionSummarySetupDialog\(\)/, "frontend should route exact summary commands to the non-blocking overlay without normal prompt dispatch");
157
- assert.match(app, /async function openSessionSummaryForTab\(tabId = activeTabId, \{ refresh = false \} = \{\}\)[\s\S]*hasAvailableCommand\("summary", \{ tabId \}\)[\s\S]*preferences\?\.configured[\s\S]*openNativeSessionSummarySetupDialog[\s\S]*openSessionSummaryOverlay[\s\S]*requestSessionSummaryGeneration\(tabId, \{ refresh \}\)/, "frontend /summary action should remain catalog-gated, open setup when needed, and force exact refresh requests");
157
+ assert.match(app, /async function openSessionSummaryForTab\(tabId = activeTabId, \{ refresh = false, focusReturnKey = "" \} = \{\}\)[\s\S]*hasAvailableCommand\("summary", \{ tabId \}\)[\s\S]*preferences\?\.configured[\s\S]*openNativeSessionSummarySetupDialog[\s\S]*openSessionSummaryOverlay[\s\S]*requestSessionSummaryGeneration\(tabId, \{ refresh \}\)/, "frontend /summary action should remain catalog-gated, preserve focus restoration, open setup when needed, and force exact refresh requests");
158
158
  assert.match(app, /function normalizeSessionSummaryClientState\(value, previous = null, \{ resetProjection = false \} = \{\}\)[\s\S]*sessionChanged[\s\S]*resetProjection \|\| sessionChanged \? null : previous[\s\S]*function handleSessionSummaryEvent\(event\)[\s\S]*resetProjection: event\?\.kind === "state"/, "client projection should clear across session IDs and active-branch state events while preserving ordinary failure state");
159
159
  assert.match(app, /title: "Save session summary setup\?"[\s\S]*if \(!reviewed\) return;[\s\S]*confirmed: true[\s\S]*requestSessionSummaryGeneration/, "summary setup should require explicit privacy/cost confirmation before persistence and immediate first generation");
160
160
  assert.match(server, /args\.includes\(sessionSummaryExtensionPath\)[\s\S]*args\.push\("--extension", sessionSummaryExtensionPath\)/, "each WebUI child should explicitly receive the package-owned summary extension");
@@ -64,12 +64,11 @@ assert.match(css, /\.issue-wizard-choice-description,[\s\S]*\.issue-wizard-choic
64
64
  assert.match(css, /\.issue-wizard-submission-status\s*\{/, "persistent bot status needs dedicated styling");
65
65
  assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.issue-wizard-choice-grid/, "wizard choices must adapt for mobile");
66
66
 
67
- assert.match(server, /"issue-wizard-state\.mjs"/, "the static allowlist must continue serving the pure wizard module");
68
- assert.match(server, /"issue-bot-client\.mjs"/, "the static allowlist must serve the browser client module");
67
+ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server must serve typed wizard modules from the public asset boundary");
69
68
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
70
69
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
71
70
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
72
- assert.match(serviceWorker, /pi-webui-pwa-v72/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v74/, "the PWA cache name must change with browser wiring updates");
73
72
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
74
73
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
75
74
 
@@ -261,7 +261,7 @@ assert.match(
261
261
 
262
262
  // --- Coherent browser asset revisions --------------------------------------
263
263
 
264
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v72"/, "changed browser assets should advance the PWA cache identity");
264
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v74"/, "changed browser assets should advance the PWA cache identity");
265
265
  assert.match(html, /data-app-src="\/app\.js\?v=113"/, "the boot loader should request the updated app module revision");
266
266
 
267
267
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -506,6 +506,6 @@ assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*:
506
506
 
507
507
  assert.match(html, /styles\.css\?v=98/, "questionnaire CSS needs the current stylesheet revision");
508
508
  assert.match(html, /app\.js\?v=113/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v72"/, "questionnaire public assets need a coherent PWA cache revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v74"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -98,6 +98,7 @@ try {
98
98
  assert.equal(initialGitSetup.status, 200);
99
99
  assert.equal(initialGitSetup.body?.data?.configured, false, "guided Git should require first-time model setup");
100
100
  assert.equal(initialGitSetup.body?.data?.preferences?.stagingPolicy, "review", "review/select should be the safe staging default");
101
+ assert.equal(initialGitSetup.body?.data?.preferences?.reviewProcessEnabled, true, "manual review should remain enabled by default for compatibility");
101
102
  assert.equal(initialGitSetup.body?.data?.models?.[0]?.id, "fake-model");
102
103
 
103
104
  const unsupportedEffort = await request("/api/git-workflow/preferences", {
@@ -112,6 +113,12 @@ try {
112
113
  });
113
114
  assert.equal(invalidStagingPolicy.status, 400, "setup should reject invalid preference choices instead of silently normalizing them");
114
115
 
116
+ const invalidReviewProcess = await request("/api/git-workflow/preferences", {
117
+ method: "POST",
118
+ body: { preferences: { generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "off" }, reviewProcessEnabled: "disabled" } },
119
+ });
120
+ assert.equal(invalidReviewProcess.status, 400, "setup should require an explicit boolean review-process preference");
121
+
115
122
  const savedGitSetup = await request("/api/git-workflow/preferences", {
116
123
  method: "POST",
117
124
  body: {
@@ -119,6 +126,7 @@ try {
119
126
  generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "off", unavailablePolicy: "ask" },
120
127
  commit: { language: "de", defaultVariant: "long", scope: "required" },
121
128
  stagingPolicy: "review",
129
+ reviewProcessEnabled: false,
122
130
  deliveryMode: "ask",
123
131
  verificationPolicy: "ask",
124
132
  },
@@ -127,6 +135,7 @@ try {
127
135
  assert.equal(savedGitSetup.status, 200);
128
136
  assert.equal(savedGitSetup.body?.data?.configured, true);
129
137
  assert.equal(savedGitSetup.body?.data?.preferences?.commit?.language, "de");
138
+ assert.equal(savedGitSetup.body?.data?.preferences?.reviewProcessEnabled, false);
130
139
 
131
140
  const generation = await request("/api/git-workflow/generate", { method: "POST", body: { kind: "commit" } });
132
141
  assert.equal(generation.status, 200);
@@ -1,5 +1,5 @@
1
1
  import assert from "node:assert/strict";
2
- import { mkdtemp, rm } from "node:fs/promises";
2
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { writeSessionSummaryPreferences } from "../lib/session-summary-preferences.mjs";
@@ -98,6 +98,8 @@ assert.equal(latestSummaryState([{
98
98
  data: { ...baseState, result: { ...baseState.result, summaryMarkdown: escapedPersistedSummary } },
99
99
  }]).result.summaryMarkdown, escapedPersistedSummary, "persisted state validation uses the decoded Markdown bound");
100
100
  assert.equal(latestSummaryState([{ type: "custom", customType: SESSION_SUMMARY_STATE_TYPE, data: { version: 99 } }]), undefined);
101
+ const titlelessState = { ...baseState, result: { summaryMarkdown: "# Valid titleless summary" }, titleAppliedAtOrdinal: undefined };
102
+ assert.equal(latestSummaryState([{ type: "custom", customType: SESSION_SUMMARY_STATE_TYPE, data: titlelessState }]).result.summaryMarkdown, "# Valid titleless summary", "valid titleless generated states remain discoverable");
101
103
  assert.deepEqual(latestSummaryNameProvenance([
102
104
  { type: "custom", customType: SESSION_SUMMARY_NAME_PROVENANCE_TYPE, data: { version: 1, explicit: true } },
103
105
  { type: "custom", customType: SESSION_SUMMARY_NAME_PROVENANCE_TYPE, data: { version: 99, explicit: false } },
@@ -254,6 +256,7 @@ try {
254
256
  const api = {
255
257
  on(name, handler) { handlers.set(name, handler); },
256
258
  registerCommand(name, options) { commands.set(name, options); },
259
+ registerTool() {},
257
260
  registerEntryRenderer(name, renderer) { renderers.set(name, renderer); },
258
261
  sendMessage(message) {
259
262
  const id = `e${activeBranch.length + 1}`;
@@ -482,6 +485,185 @@ try {
482
485
  routingIds.add(calledOptions.sessionId);
483
486
  }
484
487
  assert.equal(routingIds.size, representativeCases.length, "each representative provider call gets a fresh routing ID");
488
+
489
+ // W2 integration: use pi-intercom's documented extension-channel contract.
490
+ class FakeChannel {
491
+ connected = true;
492
+ supported = true;
493
+ published = [];
494
+ peers = new Map();
495
+ snapshot() { return { connected: this.connected, supported: this.supported }; }
496
+ publish(payload, options) { this.published.push({ payload, options }); }
497
+ async listSessions() {
498
+ return [...this.peers.entries()].map(([id, value]) => ({ id, cwd: value.cwd, pid: value.pid }));
499
+ }
500
+ }
501
+
502
+ const testCwd = "/tmp/test-workspace-a";
503
+ const crossCwd = "/tmp/test-workspace-b";
504
+ const fakeChannel = new FakeChannel();
505
+ fakeChannel.peers.set("self-sender-1", { cwd: testCwd, pid: process.pid });
506
+ const w2Tools = new Map();
507
+ const w2Commands = new Map();
508
+ const w2Branch = [
509
+ { type: "message", id: "m1", message: { role: "user", content: "Work on feature" } },
510
+ { type: "custom", customType: SESSION_SUMMARY_STATE_TYPE, data: {
511
+ version: 1,
512
+ source: { sessionId: "s-self", leafId: "m1", fingerprint: "fp-self", entryCount: 1 },
513
+ result: { title: "Self Title", summaryMarkdown: "# Self Summary\n\nWorking on feature" },
514
+ generation: { provider: "fake", modelId: "fake", thinkingLevel: "low", promptRevision: "v1" },
515
+ generatedAt: "2026-08-05T00:00:00.000Z",
516
+ settledTurnOrdinal: 1,
517
+ } },
518
+ ];
519
+ let intercomRegistration;
520
+ const w2Api = {
521
+ events: {
522
+ emit(event, registration) {
523
+ if (event !== "intercom:extension-register") return;
524
+ intercomRegistration = registration;
525
+ registration.onReady(fakeChannel);
526
+ },
527
+ },
528
+ on(name, handler) { handlers.set(name, handler); },
529
+ registerCommand(name, options) { w2Commands.set(name, options); },
530
+ registerTool(tool) { w2Tools.set(tool.name, tool); },
531
+ registerEntryRenderer() {},
532
+ sendMessage() {},
533
+ appendEntry(customType, data) { w2Branch.push({ type: "custom", customType, data }); },
534
+ getSessionName() { return "Self Title"; },
535
+ };
536
+
537
+ createSessionSummaryExtension({ completeFn: fakeComplete })(w2Api);
538
+ assert.equal(w2Tools.has("workspace_session_summaries"), true, "workspace_session_summaries tool registered");
539
+ const workspaceTool = w2Tools.get("workspace_session_summaries");
540
+ assert.match(workspaceTool.promptSnippet, /same-CWD session summaries/);
541
+ assert.equal(Array.isArray(workspaceTool.promptGuidelines), true, "tool guidelines use the Pi array contract");
542
+ assert.match(workspaceTool.promptGuidelines.join("\n"), /intercom/);
543
+
544
+ const w2Ctx = {
545
+ cwd: testCwd,
546
+ sessionManager: {
547
+ getBranch: () => w2Branch.slice(),
548
+ getSessionId: () => "s-self",
549
+ getSessionFile: () => join(extensionTemp, "s-self.jsonl"),
550
+ },
551
+ };
552
+ await handlers.get("session_start")({ type: "session_start", reason: "startup" }, w2Ctx);
553
+ assert.equal(intercomRegistration.namespace, "firstpick/session-summary/v1");
554
+ assert.equal(intercomRegistration.ownerEligible, false);
555
+ assert.equal(typeof intercomRegistration.onEvent, "function");
556
+ assert.equal(fakeChannel.published.at(-1)?.options?.audience, "capable");
557
+ const initialPublicationCount = fakeChannel.published.length;
558
+ intercomRegistration.onEvent({ type: "session_joined", session: { id: "new-peer", cwd: testCwd } });
559
+ assert.equal(fakeChannel.published.length, initialPublicationCount + 1, "a joining capable peer triggers summary republication");
560
+ fakeChannel.connected = false;
561
+ intercomRegistration.onEvent({ type: "connection", connected: false, supported: false });
562
+ fakeChannel.connected = true;
563
+ intercomRegistration.onEvent({ type: "connection", connected: true, supported: true });
564
+ assert.equal(fakeChannel.published.length, initialPublicationCount + 2, "a supported reconnect republishes the current summary");
565
+
566
+ fakeChannel.peers.set("peer-same", { cwd: testCwd, pid: process.pid + 1 });
567
+ fakeChannel.peers.set("peer-cross", { cwd: crossCwd, pid: process.pid + 2 });
568
+ intercomRegistration.onEvent({ type: "message", fromSessionId: "peer-same", payload: {
569
+ version: 1,
570
+ sessionId: "s-peer-same",
571
+ cwd: testCwd,
572
+ title: "Peer Same Title",
573
+ summaryMarkdown: "Working on same CWD with secret sk-proj-123456789012345 and path /.pi/agent/sessions/secret.jsonl",
574
+ generatedAt: "2026-08-05T01:00:00.000Z",
575
+ } });
576
+ intercomRegistration.onEvent({ type: "message", fromSessionId: "peer-cross", payload: {
577
+ version: 1,
578
+ sessionId: "s-peer-cross",
579
+ cwd: crossCwd,
580
+ title: "Peer Cross Title",
581
+ summaryMarkdown: "Working on cross CWD",
582
+ generatedAt: "2026-08-05T01:00:00.000Z",
583
+ } });
584
+ intercomRegistration.onEvent({ type: "message", fromSessionId: "self-sender-1", payload: {
585
+ version: 1,
586
+ sessionId: "s-self",
587
+ cwd: testCwd,
588
+ title: "Self Payload",
589
+ summaryMarkdown: "Self payload should be excluded",
590
+ generatedAt: "2026-08-05T01:00:00.000Z",
591
+ } });
592
+
593
+ let toolResult = await workspaceTool.execute("call-1", {}, undefined, undefined, w2Ctx);
594
+ let toolText = toolResult.content[0].text;
595
+ assert.match(toolText, /Peer Same Title/);
596
+ assert.equal(toolText.includes("Peer Cross Title"), false, "cross-CWD live peer excluded");
597
+ assert.equal(toolText.includes("Self Payload"), false, "self live payload excluded");
598
+ assert.equal(toolText.includes("sk-proj-123456789012345"), false, "raw API secret redacted from tool output");
599
+ assert.match(toolText, /\[redacted secret\]/);
600
+ assert.equal(toolText.includes("/.pi/agent/sessions/secret.jsonl"), false, "private session path redacted from tool output");
601
+ assert.match(toolText, /\[private session path\]/);
602
+ intercomRegistration.onEvent({ type: "session_joined", session: { id: "peer-same", cwd: testCwd } });
603
+ toolResult = await workspaceTool.execute("call-replaced", {}, undefined, undefined, w2Ctx);
604
+ assert.equal(toolResult.content[0].text.includes("Peer Same Title"), false, "a stable sender-ID replacement invalidates the prior live summary until the replacement publishes");
605
+ intercomRegistration.onEvent({ type: "message", fromSessionId: "peer-same", payload: {
606
+ version: 1,
607
+ sessionId: "s-peer-same",
608
+ cwd: testCwd,
609
+ title: "Peer Same Title",
610
+ summaryMarkdown: "Replacement summary",
611
+ generatedAt: "2026-08-05T01:10:00.000Z",
612
+ } });
613
+
614
+ fakeChannel.peers.set("peer-malformed", { cwd: testCwd, pid: process.pid + 3 });
615
+ intercomRegistration.onEvent({ type: "message", fromSessionId: "peer-malformed", payload: { version: 99, sessionId: "s-bad" } });
616
+ toolResult = await workspaceTool.execute("call-2", {}, undefined, undefined, w2Ctx);
617
+ assert.equal(toolResult.content[0].text.includes("s-bad"), false, "malformed payload ignored");
618
+
619
+ fakeChannel.peers.delete("peer-same");
620
+ intercomRegistration.onEvent({ type: "session_left", sessionId: "peer-same" });
621
+ toolResult = await workspaceTool.execute("call-3", {}, undefined, undefined, w2Ctx);
622
+ assert.equal(toolResult.content[0].text.includes("Peer Same Title"), false, "disconnected peer removed");
623
+
624
+ const summaryCmd = w2Commands.get("summary");
625
+ await summaryCmd.handler("workspace", w2Ctx);
626
+ const workspaceDisplayEntry = w2Branch.findLast((entry) => entry.type === "custom" && entry.customType === SESSION_SUMMARY_DISPLAY_TYPE);
627
+ assert.equal(workspaceDisplayEntry.data.title, "Workspace session summaries");
628
+ assert.match(workspaceDisplayEntry.data.summaryMarkdown, /Workspace session summaries/);
629
+
630
+ fakeChannel.connected = false;
631
+ intercomRegistration.onEvent({ type: "connection", connected: false, supported: false });
632
+ toolResult = await workspaceTool.execute("call-4", {}, undefined, undefined, w2Ctx);
633
+ assert.match(toolResult.content[0].text, /Live peer status is unavailable/);
634
+
635
+ let fallbackRegisteredTool;
636
+ const noEventsApi = {
637
+ on() {},
638
+ registerCommand() {},
639
+ registerTool(tool) { fallbackRegisteredTool = tool; },
640
+ registerEntryRenderer() {},
641
+ getSessionName() { return "Self Title"; },
642
+ };
643
+ createSessionSummaryExtension({ completeFn: fakeComplete })(noEventsApi);
644
+ const customSessionDir = join(extensionTemp, "configured-session-dir");
645
+ await mkdir(customSessionDir);
646
+ const persistedPeerState = {
647
+ ...baseState,
648
+ source: { ...baseState.source, sessionId: "configured-peer" },
649
+ result: { title: "Configured session dir peer", summaryMarkdown: "# Persisted peer" },
650
+ };
651
+ await writeFile(join(customSessionDir, "configured-peer.jsonl"), [
652
+ JSON.stringify({ type: "session", version: 3, id: "configured-peer", timestamp: "2026-08-05T00:00:00.000Z", cwd: testCwd }),
653
+ JSON.stringify({ type: "custom", id: "peer0001", parentId: null, timestamp: "2026-08-05T00:01:00.000Z", customType: SESSION_SUMMARY_STATE_TYPE, data: persistedPeerState }),
654
+ ].join("\n") + "\n");
655
+ const fallbackCtx = {
656
+ ...w2Ctx,
657
+ sessionManager: {
658
+ ...w2Ctx.sessionManager,
659
+ getSessionFile: () => join(extensionTemp, "external", "s-self.jsonl"),
660
+ getSessionDir: () => customSessionDir,
661
+ },
662
+ };
663
+ const fallbackResult = await fallbackRegisteredTool.execute("call-5", {}, undefined, undefined, fallbackCtx);
664
+ assert.match(fallbackResult.content[0].text, /Live peer status is unavailable/);
665
+ assert.match(fallbackResult.content[0].text, /Configured session dir peer/, "configured session directory is preferred over the current session file parent");
666
+
485
667
  } finally {
486
668
  if (previousConfigFile === undefined) delete process.env.PI_SESSION_SUMMARY_CONFIG_FILE;
487
669
  else process.env.PI_SESSION_SUMMARY_CONFIG_FILE = previousConfigFile;
@@ -63,6 +63,6 @@ assert.match(
63
63
  );
64
64
  assert.match(html, /styles\.css\?v=98/, "changed side-panel styles should advance the stylesheet revision");
65
65
  assert.match(html, /app\.js\?v=113/, "changed side-panel behavior should advance the app revision");
66
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v72"/, "changed browser assets should advance the PWA cache identity");
66
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v74"/, "changed browser assets should advance the PWA cache identity");
67
67
 
68
68
  console.log("side-panel-section-reorder-static.test.mjs passed");