@firstpick/pi-package-webui 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +10 -4
  2. package/bin/pi-webui.mjs +696 -69
  3. package/lib/git-workflow-preferences.mjs +16 -0
  4. package/lib/git-worktrees.mjs +43 -4
  5. package/lib/queue-mutation.mjs +109 -0
  6. package/lib/scoped-models.mjs +19 -0
  7. package/lib/webui-workspaces.mjs +265 -0
  8. package/package.json +4 -2
  9. package/public/app.js +2074 -188
  10. package/public/index.html +105 -4
  11. package/public/service-worker.js +1 -1
  12. package/public/styles.css +618 -73
  13. package/public/voice-conversation.mjs +1 -1
  14. package/tests/boot-failure-diagnostics.test.mjs +2 -2
  15. package/tests/codex-fast-mode-static.test.mjs +56 -0
  16. package/tests/compaction-mutation-contract.test.mjs +166 -0
  17. package/tests/compaction-resume-harness.test.mjs +113 -2
  18. package/tests/compaction-static.test.mjs +5 -0
  19. package/tests/composer-skill-tag-layout.test.mjs +70 -0
  20. package/tests/cwd-footer-reliability-static.test.mjs +5 -0
  21. package/tests/fast-mode-client-static.test.mjs +8 -8
  22. package/tests/file-selection-overlay-static.test.mjs +21 -0
  23. package/tests/file-viewer-search-static.test.mjs +65 -0
  24. package/tests/fixtures/fake-pi.mjs +216 -43
  25. package/tests/git-panel-file-preview-static.test.mjs +20 -5
  26. package/tests/git-workflow-preferences.test.mjs +8 -0
  27. package/tests/guided-git-publication-backend-static.test.mjs +40 -0
  28. package/tests/http-endpoints-harness.test.mjs +422 -2
  29. package/tests/mobile-static.test.mjs +111 -42
  30. package/tests/native-parity.test.mjs +1 -1
  31. package/tests/open-issue-wizard-static.test.mjs +1 -1
  32. package/tests/queue-edit-reorder-static.test.mjs +101 -0
  33. package/tests/queue-mutation-contract.test.mjs +143 -0
  34. package/tests/scoped-models.test.mjs +42 -0
  35. package/tests/side-panel-resize-static.test.mjs +8 -1
  36. package/tests/subagents-helper.test.mjs +216 -3
  37. package/tests/terminal-tab-workspace-static.test.mjs +4 -2
  38. package/tests/webui-workspaces-harness.test.mjs +223 -0
  39. package/tests/webui-workspaces.test.mjs +106 -0
  40. package/tests/workspace-save-load-static.test.mjs +69 -0
  41. package/webui-rpc-helper.mjs +300 -41
@@ -36,21 +36,21 @@ function appFunctionSource(name, nextName) {
36
36
  }
37
37
  const nativeExportPayload = await readFile(join(root, "lib", "native-export-payload.mjs"), "utf8");
38
38
  const companionDependencies = {
39
- "@firstpick/pi-extension-bang-command-autocomplete": "^0.2.1",
40
- "@firstpick/pi-extension-btw": "^0.1.3",
41
- "@firstpick/pi-extension-fish-user-bash": "^0.2.1",
42
- "@firstpick/pi-extension-git-footer-status": "^0.4.1",
43
- "@firstpick/pi-extension-release-aur": "^0.1.7",
44
- "@firstpick/pi-extension-release-npm": "^0.4.3",
45
- "@firstpick/pi-extension-safety-guard": "^0.2.5",
46
- "@firstpick/pi-extension-setup-skills": "^0.1.8",
47
- "@firstpick/pi-extension-stats": "^0.2.8",
48
- "@firstpick/pi-extension-todo-progress": "^0.2.8",
49
- "@firstpick/pi-extension-tools": "^0.1.6",
50
- "@firstpick/pi-extension-workflows": "^0.1.4",
51
- "@firstpick/pi-package-remote-webui": "^0.1.6",
52
- "@firstpick/pi-prompts-git-pr": "^0.1.4",
53
- "@firstpick/pi-themes-bundle": "^0.1.4",
39
+ "@firstpick/pi-extension-bang-command-autocomplete": "^0.2.2",
40
+ "@firstpick/pi-extension-btw": "^0.1.4",
41
+ "@firstpick/pi-extension-fish-user-bash": "^0.2.2",
42
+ "@firstpick/pi-extension-git-footer-status": "^0.4.3",
43
+ "@firstpick/pi-extension-release-aur": "^0.1.8",
44
+ "@firstpick/pi-extension-release-npm": "^0.4.4",
45
+ "@firstpick/pi-extension-safety-guard": "^0.2.6",
46
+ "@firstpick/pi-extension-setup-skills": "^0.1.9",
47
+ "@firstpick/pi-extension-stats": "^0.2.9",
48
+ "@firstpick/pi-extension-todo-progress": "^0.2.9",
49
+ "@firstpick/pi-extension-tools": "^0.1.7",
50
+ "@firstpick/pi-extension-workflows": "^0.1.7",
51
+ "@firstpick/pi-package-remote-webui": "^0.1.8",
52
+ "@firstpick/pi-prompts-git-pr": "^0.1.5",
53
+ "@firstpick/pi-themes-bundle": "^0.1.5",
54
54
  };
55
55
 
56
56
  assert.match(html, /viewport-fit=cover/, "viewport should opt into safe-area-aware full-screen layout");
@@ -175,10 +175,18 @@ assert.match(html, /id="codexUsageBox"/, "side panel should expose Codex subscri
175
175
  assert.match(html, /data-side-panel-section="codex-usage"/, "Codex usage should live in a collapsible side-panel section");
176
176
  assert.match(html, /data-side-panel-section="subagents"[\s\S]*class="side-panel-section-label">Subagents<\/span>[\s\S]*id="subagentCountBadge"[\s\S]*class="subagents-help"[\s\S]*<code>subagent<\/code>[\s\S]*<code>subagent_gate<\/code>[\s\S]*bounded retries or a success quorum[\s\S]*id="subagentsBox"/, "side panel should explain ordinary delegation and retry-gate workflows with a live count");
177
177
  assert.match(html, /id="subagentOpenModeSelect"[\s\S]*<option value="overlay">Overlay<\/option>[\s\S]*<option value="tab">Tab \/ terminal<\/option>[\s\S]*id="subagentOpenModeStatus"/, "Subagents should offer a browser-persisted overlay or terminal-tab opening choice");
178
+ const subagentCancelDialogHtml = html.match(/<dialog id="subagentCancelDialog"[\s\S]*?<\/dialog>/)?.[0] || "";
179
+ assert.match(subagentCancelDialogHtml, /id="subagentCancelDialogTitle">Cancel subagent<[\s\S]*id="subagentCancelDialogSubtitle"/, "subagent cancellation should use a titled dialog with dynamic target context");
180
+ assert.match(subagentCancelDialogHtml, /<select id="subagentCancelReason">[\s\S]*<option value="" selected>No reason<\/option>[\s\S]*Wrong model\/provider\/thinking effort[\s\S]*Wrong agent or task[\s\S]*Taking too long[\s\S]*Wrong approach or direction[\s\S]*Output no longer needed[\s\S]*Started by mistake[\s\S]*<option value="Other">Other<\/option>/, "subagent cancellation should offer every approved optional reason");
181
+ assert.match(subagentCancelDialogHtml, /<textarea id="subagentCancelNote"[^>]*placeholder="Optional note for the parent agent"/, "subagent cancellation should offer the optional parent note field");
182
+ assert.doesNotMatch(subagentCancelDialogHtml, /<(?:select|textarea) id="subagentCancel(?:Reason|Note)"[^>]*\brequired\b/, "subagent cancellation reason and note must remain optional");
183
+ assert.match(subagentCancelDialogHtml, /id="subagentCancelSubmitButton" class="danger" type="submit">Cancel subagent<\/button>[\s\S]*id="subagentCancelKeepRunningButton"|id="subagentCancelKeepRunningButton"[\s\S]*id="subagentCancelSubmitButton" class="danger" type="submit">Cancel subagent/, "subagent cancellation should expose danger submit and keep-running controls");
184
+ assert.match(html, /id="subagentTerminalView"[\s\S]*id="subagentTerminalCancelButton" class="danger"[^>]*hidden>Cancel…<\/button>/, "subagent terminal headers should include a hidden-until-running cancel control");
178
185
  assert.match(html, /id="subagentLaunchSlots"[\s\S]*id="subagentLaunchSlotsTitle">Agent models<[\s\S]*id="subagentLaunchSlotScope"[\s\S]*<option value="user">User default<\/option>[\s\S]*<option value="project">This project<\/option>[\s\S]*id="subagentLaunchSlotRoles"[\s\S]*id="subagentLaunchSlotsSave"[\s\S]*Save agent models[\s\S]*id="subagentLaunchSlotsReload"[\s\S]*Reload active tab/, "Subagents should expose a separate scoped Agent models editor before the live monitor");
179
186
  assert.match(html, /id="subagentLaunchSlotsInherit"[^>]*hidden[^>]*>Use user defaults<\/button>/, "project launch-slot overrides should expose an explicit inheritance reset");
180
187
  assert.match(html, /id="subagentLaunchSlotScope"[^>]*aria-describedby="subagentLaunchSlotScopeStatus"/, "scope selection should use stable scope help rather than dynamic live status as its accessible description");
181
188
  assert.match(html, /id="subagentLaunchSlotsAnnouncer"[^>]*aria-live="polite"[^>]*aria-atomic="true"/, "launch-slot additions and removals should have a dedicated live announcement");
189
+ assert.match(css, /\.subagent-launch-slots-reload-actions span \{\s*flex: 1 1 auto;\s*min-width: min\(12rem, 100%\);/, "narrow launch-slot reload prompts should size from their content instead of reserving a tall fixed flex basis");
182
190
  assert.match(html, /id="subagentTerminalView"[\s\S]*Subagent · view only[\s\S]*id="subagentTerminalTranscript"[\s\S]*id="subagentTerminalStatus"[^>]*aria-live="off"[\s\S]*id="subagentTerminalInput"[^>]*placeholder="View only — send messages from the parent terminal"[^>]*disabled[\s\S]*Use its parent terminal to interact with the run/, "dedicated subagent tabs should expose a view-only transcript, non-announcing routine status, and disabled input");
183
191
  assert.doesNotMatch(html, /id="subagentOverlayDialog"/, "subagent output should not use a blocking modal dialog");
184
192
  assert.match(html, /data-side-panel-section="session"[\s\S]*data-side-panel-section="subagents"[\s\S]*data-side-panel-section="queue"/, "Subagents should appear between Session and Queue in the side panel");
@@ -371,8 +379,14 @@ assert.match(css, /body\.pi-run-active:not\(\.mobile-keyboard-open\) \.composer-
371
379
  assert.match(css, /#promptInput \{[\s\S]*?min-height:\s*calc\(1\.5em \+ 1\.8rem\)/, "prompt input should default to a compact single-line height");
372
380
  assert.match(css, /#promptInput \{[\s\S]*?overflow-y:\s*hidden/, "prompt input should be JS-resized instead of showing a scrollbar by default");
373
381
  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");
382
+ assert.match(css, /\.composer-context-tags \{[^}]*width:\s*calc\(100% - 4\.5rem\);[^}]*min-width:\s*0;[^}]*pointer-events:\s*none;/, "context tags should claim the available prompt-frame width while leaving empty overlay space clickable through to the prompt");
383
+ assert.match(css, /\.composer-busy-mode-tag,[\s\S]*?\.composer-workflow-mode-chip \{\s*pointer-events:\s*auto;/, "interactive context chips should remain clickable through the pointer-transparent full-width overlay");
384
+ assert.match(css, /\.composer-skill-tags \{[^}]*flex:\s*1 1 0;[^}]*overflow:\s*hidden;/, "skill tag strips should use the true leftover context-tag width without squeezing sibling chips");
374
385
  assert.match(css, /\.composer-busy-mode-tag \{[\s\S]*?var\(--ctp-crust\)/, "busy prompt behavior tag should use an opaque base background");
375
- assert.match(css, /\.composer-skill-tag \{[\s\S]*?var\(--ctp-crust\)/, "skill tags should use an opaque base background");
386
+ assert.match(css, /\.composer-skill-tag \{[^}]*flex:\s*0 0 auto;[\s\S]*?var\(--ctp-crust\)/, "skill tags should preserve their natural chip widths inside the responsive strip");
387
+ assert.doesNotMatch(app, /SKILL_TAG_MAX_VISIBLE/, "skill tag visibility should not remain capped at a fixed count");
388
+ assert.match(app, /function fitSessionSkillTags\(\)[\s\S]*?availableWidth = container\.clientWidth[\s\S]*?maxOverflowDigits = String\(tags\.length\)\.length[\s\S]*?requiredWidth <= availableWidth \+ 0\.5/, "skill tags should fit their visible count to the measured input width with bounded overflow-chip measurements");
389
+ assert.match(app, /function installSessionSkillTagResizeHandling\(\)[\s\S]*?new ResizeObserver\(scheduleSessionSkillTagLayout\)[\s\S]*?observe\(container\.parentElement\)/, "skill tag fitting should rerun when the composer tag strip changes width");
376
390
  assert.match(css, /\.composer-feature-category-tag \{[\s\S]*?var\(--ctp-crust\)[\s\S]*?\.composer-feature-category-tag\.complex-feature \{[\s\S]*?var\(--ctp-mauve\)[\s\S]*?\.composer-feature-category-tag\[hidden\]/, "feature category tags should use the existing composer-tag frame with a distinct complex state and hidden default");
377
391
  assert.match(css, /button\.composer-skill-tag:hover,[\s\S]*?button\.composer-skill-tag:focus-visible/, "skill tags should be styled as clickable controls");
378
392
  assert.match(css, /\.extension-dialog\.skill-editor-dialog \{[\s\S]*?--skill-editor-size:\s*min\(152rem[\s\S]*?width:\s*var\(--skill-editor-size\);[\s\S]*?height:\s*var\(--skill-editor-size\);[\s\S]*?aspect-ratio:\s*1 \/ 1/, "skill editor should use a square viewport-bounded modal layout");
@@ -383,6 +397,9 @@ assert.match(css, /\.file-viewer-editor \{[\s\S]*?overflow-x:\s*hidden;[\s\S]*?o
383
397
  assert.match(css, /\.composer-busy-mode-menu \{[\s\S]*?bottom:\s*calc\(100% \+ 0\.22rem\);[\s\S]*?background:\s*var\(--ctp-crust\)/, "busy prompt behavior dropdown should expand above the tag with an opaque background");
384
398
  assert.match(css, /\.sticky-user-prompt-button \{[\s\S]*?grid-template-columns:\s*auto minmax\(0, 1fr\) auto/, "last-user-prompt jump control should render as a fixed transcript header");
385
399
  assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\)[\s\S]*?\.sticky-user-prompt-button \{\n\s+grid-template-columns:\s*minmax\(0, 1fr\) auto;\n\s+min-height:\s*36px;[\s\S]*?\.sticky-user-prompt-text \{[\s\S]*?font-size:\s*var\(--text-xs\)/, "mobile last-user-prompt card should preserve compact height while respecting the text floor");
400
+ assert.match(html, /id="followUpQueueTrigger"[^>]*aria-controls="followUpQueueOverlay"[\s\S]*id="followUpQueueOverlay"[\s\S]*id="followUpQueueStatus"[^>]*aria-live="polite"/, "mobile composer should expose the accessible queued follow-up trigger and overlay");
401
+ assert.match(css, /\.follow-up-queue-overlay \{[\s\S]*bottom:\s*calc\(100% \+ 0\.42rem\)[\s\S]*var\(--visual-viewport-height, 100dvh\)[\s\S]*body\.mobile-keyboard-open \.follow-up-queue-trigger:not\(\[hidden\]\) \{ display: inline-flex; \}/, "mobile queue overlay should float above the composer, fit the visual viewport, and keep its trigger usable with the keyboard open");
402
+ assert.doesNotMatch(app, /nextQueuedFollowUpPrompt|sticky-user-follow-up-prompt|Next follow-up prompt:/, "the mobile sticky prompt control should not duplicate a queued follow-up preview");
386
403
  assert.match(css, /\.message\.extension,[\s\S]*?\.message\.native/, "extension and native command output should have visible transcript styling");
387
404
  assert.match(app, /const FEATURE_CATEGORY_STATUS_KEY = "feature-category";[\s\S]*const featureCategoryByTab = new Map\(\)/, "feature category status should use a dedicated per-tab transport key and state map");
388
405
  assert.match(app, /function normalizeFeatureCategory\(value\) \{\s+return value === "lightweight-feature" \|\| value === "complex-feature" \? value : "";/, "feature category normalization should accept only the two approved exact labels");
@@ -530,16 +547,17 @@ assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-dialo
530
547
  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");
531
548
  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");
532
549
  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");
533
- assert.match(html, /class="terminal-sidebar-actions"[^>]*aria-label="Tab and workspace actions"[\s\S]*id="splitTabButton"[\s\S]*>Split<\/span>[\s\S]*id="commandPaletteButton"[\s\S]*>Commands<\/span>[\s\S]*id="workspaceDashboardToggleButton"[\s\S]*>Overview<\/span>/, "tab, command, and workspace actions should share one labeled sidebar toolbar");
534
- 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]*?min-height:\s*3\.55rem;/, "left-sidebar actions should render as an equal-width three-button toolbar with readable touch targets");
535
- 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-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 command and overview tooltips should render above the full toolbar without clipping");
536
- assert.match(css, /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");
550
+ assert.match(html, /class="terminal-sidebar-actions"[^>]*aria-label="Tab and workspace actions"[\s\S]*id="splitTabButton"[\s\S]*>Split<\/span>[\s\S]*id="workspaceSaveButton"[\s\S]*>Save workspace<\/span>[\s\S]*id="commandPaletteButton"[\s\S]*>Commands<\/span>[\s\S]*id="workspaceDashboardToggleButton"[\s\S]*>Overview<\/span>/, "tab, save, command, and workspace actions should share one labeled sidebar toolbar");
551
+ assert.match(css, /body\.terminal-tabs-left \.terminal-sidebar-actions \{[\s\S]*?display:\s*grid;[\s\S]*?grid-template-columns:\s*repeat\(4, minmax\(0, 1fr\)\);[\s\S]*?body\.terminal-tabs-left \.terminal-sidebar-actions > button \{[\s\S]*?min-height:\s*3\.55rem;/, "left-sidebar actions should render as an equal-width four-button toolbar with readable touch targets");
552
+ 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");
553
+ 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");
537
554
  assert.match(css, /terminal-split-button\[aria-pressed="true"\] \.terminal-sidebar-action-label-split[\s\S]*?display:\s*none;[\s\S]*?terminal-split-button\[aria-pressed="true"\] \.terminal-sidebar-action-label-unsplit[\s\S]*?display:\s*block;/, "split toolbar label should change to Unsplit with the pressed state");
538
555
  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");
539
556
  assert.match(css, /body\.terminal-tabs-left \.terminal-tabs \{[\s\S]*?flex-direction:\s*column/, "terminal tabs left layout should stack tabs vertically");
540
557
  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");
541
558
  assert.match(css, /body\.terminal-tabs-left \.terminal-new-tab-menu \.composer-publish-menu-panel \{[\s\S]*?inset:\s*0 auto auto 100%;[\s\S]*?padding-left:\s*var\(--terminal-left-dropdown-bridge\)/, "left-sidebar new-tab dropdown should include a hover bridge so it does not vanish between button and dropdown");
542
559
  assert.match(css, /\.terminal-new-tab-menu \.composer-publish-menu-panel \{[\s\S]*?inset:\s*100% 0 auto auto;[\s\S]*?padding-top:\s*0\.38rem/, "new-tab dropdown should reuse the shared composer panel and open below the tab bar");
560
+ assert.match(css, /\.terminal-tabs > \.terminal-new-tab-menu:only-child \.composer-publish-menu-panel \{\s*inset:\s*100% auto auto 0;/, "zero-tab new-tab dropdown should align to the left edge instead of extending off-screen");
543
561
  assert.match(css, /\.terminal-new-tab-menu \.composer-publish-menu-item \{[\s\S]*?color:\s*var\(--ctp-pink\)/, "new-tab dropdown items should reuse shared composer menu items with a tab-specific color");
544
562
  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");
545
563
  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");
@@ -603,7 +621,7 @@ assert.match(app, /async function loadMissingGitUntrackedContent\(entry[\s\S]*?\
603
621
  assert.match(app, /function updateGitChangesCurrentFileHeader\(\)[\s\S]*?querySelectorAll\("\.git-diff-file\[data-git-diff-file\]"\)/, "git changes modal should derive the sticky current-file header from visible file cards");
604
622
  assert.match(app, /function renderGitChangesFileList\(parsedSections, untracked\)[\s\S]*dataset\.gitChangesJumpFile = item\.path[\s\S]*git-changes-file-jump-meta/, "git changes modal should render jump buttons for each changed file");
605
623
  assert.match(app, /gitChangesBody\?\.addEventListener\("click"[\s\S]*data-git-changes-jump-file[\s\S]*scrollIntoView\(\{ block: "start", behavior: "smooth" \}\)/, "git changes file jump buttons should scroll to their diff cards");
606
- assert.match(server, /async function readGitUntrackedEntry\(root, file\)[\s\S]*?content: binary \? "" : buffer\.toString\("utf8"\)/, "server should include complete text contents for untracked files");
624
+ assert.match(server, /async function readGitUntrackedEntry\(root, file, \{ maxBytes = Number\.POSITIVE_INFINITY \} = \{\}\)[\s\S]*?content: binary \? "" : buffer\.toString\("utf8"\)/, "server should include complete text contents for untracked files");
607
625
  assert.match(server, /url\.pathname === "\/api\/git-changes\/untracked-file" && req\.method === "GET"/, "server should expose a focused untracked-file content endpoint for stale path-only payload fallbacks");
608
626
  assert.match(server, /async function readGitChanges\(cwd\)[\s\S]*?const diffArgs = \["diff", "--no-ext-diff"[\s\S]*?"--unified=0"[\s\S]*?\["diff", "--cached"/, "server should collect compact staged and unstaged git diffs for the changes modal");
609
627
  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");
@@ -762,7 +780,8 @@ assert.match(app, /resizePromptInput\(\);\nrestoreSidePanelWidthPreference\(\);\
762
780
  assert.match(app, /elements\.promptInput\.addEventListener\("focus", \(\) => \{\n\s+syncMobileChatToBottomForInput\(\);/, "focusing mobile input should scroll output to bottom");
763
781
  assert.match(app, /navigator\.serviceWorker\.register\("\/service-worker\.js"\)/, "PWA service worker should be registered by the app");
764
782
  assert.match(app, /function serverStartCommandText\(\)[\s\S]*return `pi-webui\$\{currentPortArg\(\)\}`/, "PWA/offline shell should build a pathless pi-webui recovery command");
765
- assert.match(app, /async function createFirstTerminalTabFromChosenDirectory\(\)/, "frontend should prompt for the first terminal cwd when no tabs exist");
783
+ assert.match(app, /async function createFirstTerminalTabFromChosenDirectory\(\)/, "frontend should define the first-terminal cwd prompt");
784
+ assert.match(app, /async function initializeTabs\(\)[\s\S]*?if \(!saved\.length\) await createFirstTerminalTabFromChosenDirectory\(\)/, "frontend should still prompt for the first terminal cwd when no saved workspace can be loaded");
766
785
  assert.match(app, /Choose CWD for first terminal/, "frontend should title the first-terminal cwd picker clearly");
767
786
  assert.match(app, /Pi Web UI server is offline/, "PWA/offline shell should clearly report backend-down state");
768
787
  assert.match(app, /navigator\.clipboard\.writeText\(text\)/, "backend-offline recovery panel should copy the start command when possible");
@@ -832,6 +851,15 @@ assert.match(
832
851
  );
833
852
  assert.match(app, /function renderCodexUsage\(\)/, "frontend should render Codex usage buckets in the side panel");
834
853
  assert.match(app, /function renderSubagents\(\)[\s\S]*subagentTabsWithRunningAgents\(\)[\s\S]*totalGates[\s\S]*renderSubagentTabGroup\(tab\)/, "frontend should group running subagents and retained retry gates by terminal and session");
854
+ assert.match(app, /function renderSubagents\(\)[\s\S]*latestSubagents\?\.runningAgents[\s\S]*subagentCountBadge\.textContent = String\(totalAgents\)/, "the subagent count badge should count running agents only, not retained rows or gates");
855
+ assert.match(app, /function renderSubagentRun\(tab, run\)[\s\S]*subagentRunStateLabel\(run\)[\s\S]*Dismiss finished run[\s\S]*dismissSubagentRun\(tab, run\)/, "terminal subagent rows should show retained state badges and dismiss only terminal runs");
856
+ assert.match(app, /function renderSubagentRun\(tab, run\)[\s\S]*subagentRunCanCancel\(run\)[\s\S]*openSubagentCancelDialog\(tab, run\)/, "running subagent rows should route cancel through the shared dialog");
857
+ assert.match(app, /function renderSubagentOverlayWidget\(\)[\s\S]*openSubagentCancelDialog\(tab, selection\.run, agent\)[\s\S]*subagent-overlay-cancel-action/, "running overlays should route cancel through the shared dialog");
858
+ assert.match(app, /subagentTerminalCancelButton[\s\S]*openSubagentCancelDialog\(view\.tab \|\| \{ tabId: view\.parentTabId, tabTitle: view\.parentTitle \}, view\.run, view\.data\?\.agent \|\| view\.agent\)/, "running terminal headers should route cancel through the shared dialog");
859
+ assert.match(app, /function openSubagentCancelDialog\(tab, run, agent = null\)[\s\S]*agentCount[\s\S]*The entire run will be stopped[\s\S]*subagentCancelDialog\.showModal\(\)[\s\S]*async function submitSubagentCancel\(\)[\s\S]*api\("\/api\/subagents\/cancel", \{[\s\S]*method: "POST",[\s\S]*scoped: false,[\s\S]*tab: selection\.tabId,[\s\S]*runId: selection\.runId/, "the shared cancel dialog should honestly describe and submit whole-run cancellation with optional reason/note data");
860
+ assert.doesNotMatch(app, /body: \{\n\s+tab: selection\.tabId,\n\s+runId: selection\.runId,\n\s+\.\.\.\(selection\.agentId/, "the frontend must not imply unsupported per-agent cancellation in its request contract");
861
+ assert.match(app, /async function dismissSubagentRun\(tab, run\)[\s\S]*api\("\/api\/subagents\/dismiss", \{[\s\S]*method: "POST",[\s\S]*scoped: false,[\s\S]*body: \{ tab: tab\.tabId, runId: run\.id \}/, "finished-run dismiss controls should call the owning tab endpoint");
862
+ assert.match(app, /function materializeRetainedSubagentTerminalViews\(\)[\s\S]*restoreKey = `\$\{tab\.tabId\}\\u0000\$\{tab\.sessionFile[\s\S]*run\?\.status === "running"[\s\S]*ensureSubagentTerminalView/, "terminal mode should materialize restored retained agent views once per parent session identity without touching overlay mode");
835
863
  assert.match(app, /from "\.\/subagent-launch-slot-state\.mjs"[\s\S]*function renderSubagentLaunchSlots\(\)[\s\S]*function loadSubagentLaunchSlotConfig\([\s\S]*\/api\/subagents\/config/, "launch-slot configuration should have its own browser state and API loader");
836
864
  assert.match(app, /function subagentLaunchSlotThinkingForModel\(model\)[\s\S]*modelThinkingLevels/, "launch-slot thinking choices should come from the selected model metadata");
837
865
  assert.match(app, /function renderSubagentLaunchSlotCard\(role, slots\)[\s\S]*Default \/ inherit[\s\S]*"Add slot"[\s\S]*Remove/, "role cards should render independent same-role slots and inheritance controls");
@@ -848,7 +876,7 @@ assert.match(server, /WEBUI_SUBAGENT_GATE_LIMIT[\s\S]*rawGate\.attempts[\s\S]*fa
848
876
  assert.match(server, /function normalizeWebuiSubagentOutput\(value, selection\)[\s\S]*model: normalizeWebuiSubagentText\(rawAgent\.model, 240\)[\s\S]*thinking: normalizeWebuiSubagentText\(rawAgent\.thinking, 40\)/, "server should preserve model and reasoning metadata in selected child output");
849
877
  assert.match(server, /function normalizeWebuiSubagentSource\(value\) \{[\s\S]*value === "foreground" \|\| value === "workflow"[\s\S]*function normalizeWebuiSubagentPayload\(value\)[\s\S]*source: normalizeWebuiSubagentSource\(rawRun\.source\)[\s\S]*function normalizeWebuiSubagentOutput\(value, selection\)[\s\S]*source: normalizeWebuiSubagentSource\(selection\.run\?\.source \|\| value\.source\)/, "server should preserve workflow source in overview and selected-output normalization");
850
878
  assert.match(app, /function subagentExecutionFacts\(agent = \{\}\)[\s\S]*model \$\{model \|\| "unknown"\}[\s\S]*reasoning \$\{thinking \|\| "unknown"\}/, "subagent metadata should use one honest model/reasoning formatter with unknown fallbacks");
851
- assert.match(app, /function subagentSourceLabel\(source = ""\) \{[\s\S]*source === "foreground" \|\| source === "workflow"[\s\S]*function subagentOverlayStateFacts\(data = subagentOverlayData\)[\s\S]*subagentSourceLabel\(data\?\.source \|\| subagentOverlaySelection\?\.run\?\.source\)[\s\S]*function renderSubagentTerminalView\(\)[\s\S]*subagentSourceLabel\(view\.data\?\.source \|\| view\.run\?\.source\)[\s\S]*function renderSubagentTerminalTab\(view\)[\s\S]*subagentSourceLabel\(view\.data\?\.source \|\| view\.run\?\.source\)[\s\S]*function renderSubagentAgent\(tab, run, agent\)[\s\S]*subagentSourceLabel\(run\?\.source\)/, "one source-label helper should keep workflow rows, overlays, and virtual tabs honest");
879
+ assert.match(app, /function subagentSourceLabel\(source = ""\) \{[\s\S]*source === "foreground" \|\| source === "workflow"[\s\S]*function subagentOverlayStateFacts\(data = subagentOverlayData\)[\s\S]*subagentSourceLabel\(data\?\.source \|\| run\.source\)[\s\S]*function renderSubagentTerminalView\(\)[\s\S]*subagentSourceLabel\(view\.data\?\.source \|\| view\.run\?\.source\)[\s\S]*function renderSubagentTerminalTab\(view\)[\s\S]*subagentSourceLabel\(view\.data\?\.source \|\| view\.run\?\.source\)[\s\S]*function renderSubagentAgent\(tab, run, agent\)[\s\S]*subagentSourceLabel\(run\?\.source\)/, "one source-label helper should keep workflow rows, overlays, and virtual tabs honest");
852
880
  assert.match(app, /function renderSubagentAgent\(tab, run, agent\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "Subagents side-panel rows should show model and reasoning effort");
853
881
  assert.match(app, /function subagentOverlayStateFacts\(data = subagentOverlayData\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "subagent overlays should show model and reasoning effort");
854
882
  assert.match(app, /function renderSubagentTerminalView\(\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "dedicated subagent terminal views should show model and reasoning effort");
@@ -904,7 +932,7 @@ assert.doesNotMatch(subagentTerminalCloseSource, /\bapi\(|closeTerminalTabs\(|cl
904
932
  assert.match(app, /function renderSubagentTerminalTab\(view\)[\s\S]*terminal-tab-subagent[\s\S]*subagent: true[\s\S]*closeSubagentTerminalTab\(view\.id\)/, "virtual tabs should be marked as subagents and have a view-only close action");
905
933
  assert.match(app, /function subagentTerminalViewId\(tab, run, agent\)[\s\S]*JSON\.stringify\(\[tab\?\.tabId[\s\S]*run\?\.id[\s\S]*agent\?\.id/, "virtual child tabs should be uniquely keyed by parent terminal, run, and child agent");
906
934
  assert.match(app, /SUBAGENT_OVERLAY_REFRESH_MS = 1000/, "subagent overlay should poll selected live output at a fast cadence");
907
- assert.match(app, /function createMessageBubble\(message,[\s\S]*renderContent\(body, message\.content, \{ markdown: message\.role === "assistant" \}\)[\s\S]*function appendMessage\(message, options = \{\}\)[\s\S]*createMessageBubble\(message, options\)/, "main transcript output should use the reusable message bubble renderer");
935
+ assert.match(app, /function createMessageBubble\(message,[\s\S]*renderContent\(body, message\.content, \{ markdown: message\.role === "assistant" \|\| message\.role === "custom" \}\)[\s\S]*function appendMessage\(message, options = \{\}\)[\s\S]*createMessageBubble\(message, options\)/, "main transcript output should use the reusable message bubble renderer");
908
936
  const subagentTranscriptMessagesSource = appFunctionSource("subagentOverlayTranscriptMessages", "subagentOverlayToolArguments");
909
937
  assert.ok(subagentTranscriptMessagesSource.includes("message.role === \"assistant\" || message.role === \"toolResult\""), "subagent overlays should retain structured assistant and tool-result entries");
910
938
  const subagentToolArgumentsSource = appFunctionSource("subagentOverlayToolArguments", "subagentOverlayTranscriptDisplayMessages");
@@ -997,7 +1025,40 @@ assert.match(app, /chip\.key === "git"[\s\S]*setFooterBranchPickerOpen\(!footerB
997
1025
  assert.match(app, /chip\.key === "worktree"[\s\S]*setFooterBranchPickerOpen\(!footerBranchPickerOpen\)[\s\S]*Click to manage branch worktrees/, "worktree footer chip should open the branch worktree picker");
998
1026
  assert.match(app, /function footerPayloadWithLiveModel\(payload\)[\s\S]*const worktreeLabel = gitWorkspaceBadgeLabel\(workspace\)[\s\S]*key: "worktree"/, "git footer payload should inject a live worktree chip from tab metadata");
999
1027
  assert.match(app, /function renderFooterBranchPicker\(\)[\s\S]*Git branches & worktrees[\s\S]*renderFooterWorktreeList\(state\)[\s\S]*renderFooterBranchOption\(branch, state\)/, "git branch picker should render branch worktree controls and local branch choices");
1000
- assert.match(app, /function renderFooterBranchOption\(branch, state = footerBranchPickerState\)[\s\S]*openFooterBranchOption\(branch, state\)[\s\S]*footer-branch-advanced-action[\s\S]*applyFooterGitBranch\(branch\.name\)/, "branch rows should prefer worktree open/create while keeping an advanced in-place switch action");
1028
+ assert.match(app, /function renderFooterBranchOption\(branch, state = footerBranchPickerState\)[\s\S]*openFooterBranchOption\(branch, state\)[\s\S]*footer-branch-advanced-action[\s\S]*applyFooterGitBranch\(branch\.name, \{ switchingKey: branch\.key \}\)/, "branch rows should prefer worktree open/create while keeping an advanced in-place switch action");
1029
+ const branchPickerRenderKeySource = appFunctionSource("footerBranchPickerRenderKey", "gitFooterPickerStateKey");
1030
+ const branchPickerKeySandbox = { footerBranchPickerOpen: true, footerBranchPickerState: { loading: true, branches: [] } };
1031
+ const loadingBranchPickerKey = vm.runInNewContext(`${branchPickerRenderKeySource}\nfooterBranchPickerRenderKey()`, branchPickerKeySandbox);
1032
+ branchPickerKeySandbox.footerBranchPickerState = { loading: false, branches: [{ name: "main" }] };
1033
+ const loadedBranchPickerKey = vm.runInNewContext("footerBranchPickerRenderKey()", branchPickerKeySandbox);
1034
+ assert.notEqual(loadingBranchPickerKey, loadedBranchPickerKey, "branch picker render key should change when asynchronous branch data replaces loading state");
1035
+ assert.match(appFunctionSource("gitFooterPickerStateKey", "updateGitFooterChipNodeValue"), /footerBranchPickerRenderKey\(\)/, "git footer cache identity should include live branch picker state so the first opening rerenders when loading finishes");
1036
+ const branchSwitchAvailabilitySource = appFunctionSource("footerBranchSwitchAvailability", "renderFooterBranchOption");
1037
+ const branchSwitchAvailability = JSON.parse(vm.runInNewContext(`${branchSwitchAvailabilitySource}\nJSON.stringify({
1038
+ switching: footerBranchSwitchAvailability({ name: "feat/demo" }, { loading: true, switching: "origin/main" }, ""),
1039
+ loading: footerBranchSwitchAvailability({ name: "feat/demo" }, { loading: true, switching: "" }, ""),
1040
+ mainWorktree: footerBranchSwitchAvailability({ name: "feat/demo", mainWorktree: true }, {}, "/repo"),
1041
+ otherWorktree: footerBranchSwitchAvailability({ name: "feat/demo", mainWorktree: false }, {}, "/repo-worktrees/demo"),
1042
+ available: footerBranchSwitchAvailability({ name: "feat/demo" }, {}, ""),
1043
+ })`));
1044
+ assert.equal(branchSwitchAvailability.switching.label, "Action running…", "running branch mutations should expose their exact disabled category");
1045
+ assert.match(branchSwitchAvailability.switching.reason, /origin\/main is still running/, "running branch mutations should name the active branch action");
1046
+ assert.equal(branchSwitchAvailability.loading.label, "Refreshing…", "branch metadata loading should expose a distinct disabled category");
1047
+ assert.match(branchSwitchAvailability.loading.reason, /information finishes loading/, "branch metadata loading should explain when switching becomes available");
1048
+ assert.equal(branchSwitchAvailability.mainWorktree.label, "In main worktree", "main-worktree occupancy should expose a distinct disabled category");
1049
+ assert.match(branchSwitchAvailability.mainWorktree.reason, /main worktree at \/repo/, "main-worktree occupancy should identify the exact checkout path");
1050
+ assert.equal(branchSwitchAvailability.otherWorktree.label, "In another worktree", "secondary-worktree occupancy should expose a distinct disabled category");
1051
+ assert.match(branchSwitchAvailability.otherWorktree.reason, /another worktree at \/repo-worktrees\/demo/, "secondary-worktree occupancy should identify the exact checkout path");
1052
+ assert.deepEqual(branchSwitchAvailability.available, { disabled: false, label: "Switch here", reason: "" }, "unoccupied idle branches should keep Switch here enabled");
1053
+ assert.match(app, /function footerGitBranchKey\(item = \{\}\)[\s\S]*return item\.remote \? `remote:\$\{item\.remoteRef\}` : `local:\$\{item\.name\}`/, "remote branch rows should use their exact remote ref, not local name, as their deduplication identity");
1054
+ assert.match(app, /function normalizeFooterGitBranches\(data = \{\}\)[\s\S]*const remoteRef = cleanFooterPayloadText\(item\?\.remoteRef, "", 4000\);[\s\S]*if \(remote && !remoteRef\) continue;[\s\S]*remoteRef: remote \? remoteRef : "",[\s\S]*remoteName: remote \? cleanStatusText\(item\?\.remoteName\) : "",[\s\S]*displayName: remote \? cleanFooterPayloadText\(item\?\.displayName, remoteRef, 4000\) : name,[\s\S]*const key = footerGitBranchKey\(branch\);[\s\S]*if \(seen\.has\(key\)\) continue;/, "branch normalization should sanitize and retain explicit remote metadata while deduplicating by remote identity");
1055
+ assert.match(app, /function footerBranchOptionLabel\(branch = \{\}\)[\s\S]*cleanStatusText\(branch\.displayName\) \|\| cleanStatusText\(branch\.name\)/, "remote branch rows should visibly prefer the advertised exact remote ref label");
1056
+ 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");
1057
+ 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");
1058
+ 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");
1059
+ 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");
1060
+ 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");
1061
+ 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");
1001
1062
  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");
1002
1063
  assert.match(app, /function renderFooterBranchCreateForm\(state = footerBranchPickerState\)[\s\S]*footer-branch-create-dropdown-inputfield[\s\S]*footer-branch-type-suggestions[\s\S]*footer-branch-create-input-field[\s\S]*Create branch worktree/, "branch worktree creation should use a styled editable suggestions dropdown plus input field instead of a browser prompt");
1003
1064
  assert.match(app, /let footerBranchCreateDraft = \{ type: "", name: "" \}/, "new branch creation should not default the editable type prefix to feat");
@@ -1012,7 +1073,8 @@ assert.match(app, /submitButton\.dataset\.tooltip = footerBranchCreateTooltip\(b
1012
1073
  assert.match(css, /\.footer-branch-create-submit\[data-tooltip\]::after \{[\s\S]*?content:\s*attr\(data-tooltip\);[\s\S]*?white-space:\s*pre-wrap;[\s\S]*?overflow-wrap:\s*anywhere;/, "create branch button tooltip should be styled and support detailed multiline copy");
1013
1074
  assert.match(app, /submitButton\.disabled = false;[\s\S]*submitButton\.classList\.toggle\("footer-branch-create-submit-disabled", submitDisabled\);[\s\S]*submitButton\.setAttribute\("aria-disabled", submitDisabled \? "true" : "false"\)/, "branch creation should use aria-disabled styling so the tooltip is not dimmed by disabled button opacity");
1014
1075
  assert.match(css, /\.footer-branch-create-submit-disabled \{[\s\S]*?cursor:\s*not-allowed;[\s\S]*?color:\s*rgba\(166, 227, 161, 0\.58\);/, "greyed branch create button should use a class instead of disabled opacity");
1015
- assert.match(app, /Loading existing local branches and worktrees… Worktree creation is available once branch data loads\./, "branch picker loading copy should make clear that worktree creation is gated on branch metadata");
1076
+ assert.match(app, /Loading local and fetched remote branches and worktrees… Worktree creation is available once branch data loads\./, "branch picker loading copy should accurately describe local and fetched remote branch metadata");
1077
+ assert.match(app, /No other local or fetched remote branches available\.[\s\S]*Fetch to list remote branches, or create a branch worktree from origin\/main or the current workspace HEAD to continue\./, "branch picker empty copy should explain how fetched remote branches become available");
1016
1078
  assert.match(css, /\.footer-model-picker\.footer-branch-picker \{[\s\S]*?overflow:\s*visible;[\s\S]*?max-height:\s*none;/, "branch picker should not force scrolling just to see the open type suggestions dropdown");
1017
1079
  assert.match(css, /\.footer-branch-type-suggestions \{[\s\S]*?grid-template-columns:\s*repeat\(3,[\s\S]*?max-height:\s*none;[\s\S]*?overflow:\s*visible;/, "branch type suggestions should render as a styled multi-column dropdown without internal scrolling");
1018
1080
  assert.match(css, /\.footer-branch-option-row \{[\s\S]*?grid-template-columns:\s*minmax\(0, 1fr\) auto/, "branch rows should lay out primary worktree action and advanced switch separately");
@@ -1035,7 +1097,8 @@ assert.match(server, /url\.pathname === "\/api\/git-branches"[\s\S]*readGitBranc
1035
1097
  assert.match(server, /url\.pathname === "\/api\/git-worktrees" && req\.method === "POST"[\s\S]*createGitWorktreeTab\(tab, body\)/, "server should expose git worktree creation for branch tabs");
1036
1098
  assert.match(server, /url\.pathname === "\/api\/git-worktrees\/open" && req\.method === "POST"[\s\S]*openExistingGitWorktreeTab\(tab, body\)/, "server should expose existing git worktree opening for branch tabs");
1037
1099
  assert.match(server, /url\.pathname === "\/api\/git-worktrees" && req\.method === "DELETE"[\s\S]*requireLocalhost\(req, "Removing Git worktrees is only allowed from localhost"\)[\s\S]*removeGitWorktreeForTab\(tab, body\)/, "server should guard destructive git worktree removal behind localhost and confirmation");
1038
- assert.match(server, /url\.pathname === "\/api\/git-branch"[\s\S]*switchGitBranch\(tab\.cwd, body\.branch, \{ create: body\.create === true \}\)/, "server should expose advanced git branch switching and creation for the footer picker");
1100
+ assert.match(server, /url\.pathname === "\/api\/git-branch"[\s\S]*const remoteRef = requestedRemoteRef\(body\);[\s\S]*switchGitBranch\(tab\.cwd, body\.branch, \{ create: body\.create === true, remoteRef \}\)/, "server should preserve optional exact remote-ref intent for advanced footer branch switching");
1101
+ assert.match(server, /runGitReadCommandDetailed\(root, \["for-each-ref", "--format=%\(refname\)%09%\(symref\)"[\s\S]*remoteBranchesTruncated: remoteData\.truncated === true[\s\S]*item\.remote !== true && item\.name === targetBranch/, "server branch listing should parse full remote refs, expose truncation, and keep local branch guards local-only");
1039
1102
  assert.match(server, /async function switchGitBranch[\s\S]*BRANCH_CHECKED_OUT_ELSEWHERE[\s\S]*const args = create \? \["switch", "-c", targetBranch\] : \["switch", targetBranch\]/, "server branch switching should refuse branches checked out in another worktree before git switch");
1040
1103
  assert.match(app, /let latestStats = null/, "default footer should retain session stats for token and context display");
1041
1104
  assert.match(app, /async function refreshStats\(tabContext = activeTabContext\(\)\)[\s\S]*api\("\/api\/stats"/, "default footer should fetch session stats");
@@ -1200,7 +1263,7 @@ assert.match(app, /if \(key === "pi-remote-webui"\) return "remoteWebui"/, "opti
1200
1263
  assert.match(app, /REMOTE_WEBUI_CONTROLS_PAYLOAD_TYPE = "firstpick\.pi-package-remote-webui\.controls"/, "Remote WebUI package should announce browser controls through a package-owned status payload");
1201
1264
  assert.match(app, /function combineIdenticalDuplicateCommands\(commands\)[\s\S]*duplicateGroups[\s\S]*duplicateCount: group\.length/, "identical duplicate RPC commands should be combined into one visible command entry");
1202
1265
  assert.match(app, /if \(kind === "prompt" && attachments\.length === 0\) message = resolveRpcSlashCommandMessage\(message, \{ tabId: targetTabId \}\)/, "manual targeted slash prompts should resolve combined duplicate command aliases from their captured target tab before reaching Pi RPC");
1203
- assert.match(app, /if \(!isOptionalFeatureEnabled\("todoProgressWidget"\)\) return String\(text \|\| ""\)/, "todo progress line stripping should only run when the todo feature is detected and enabled");
1266
+ assert.match(app, /if \(!isOptionalFeatureDetected\("todoProgressWidget"\)\) return String\(text \|\| ""\)/, "todo progress line stripping should keep transport filtering active whenever the todo feature is detected");
1204
1267
  assert.match(app, /const releasePrompt = detectedReleasePrompt && isOptionalFeatureEnabled\(detectedReleasePrompt\.featureId\) \? detectedReleasePrompt : null/, "release confirmation dialogs should use specialized rendering only when their release optional feature is enabled");
1205
1268
  assert.match(app, /case "webui_tab_reloaded":[\s\S]*resetOptionalFeatureAvailability\(\)/, "optional feature state should reset when the RPC tab reloads resources");
1206
1269
  assert.match(app, /function runPublishWorkflow\(command\)[\s\S]*resolveAvailableCommandName\(commandName, \{ rpcOnly: true \}\)/, "publish workflow launch should guard on loaded slash commands, including duplicate-suffixed RPC command names");
@@ -1243,6 +1306,16 @@ assert.match(app, /async function runGitMessagePrompt\([\s\S]*\/api\/git-workflo
1243
1306
  assert.match(app, /async function runGitBranchNamePrompt\([\s\S]*\/api\/git-workflow\/generate"[\s\S]*kind: "branch"/, "guided git workflow should generate branch names with the configured model and effort");
1244
1307
  assert.match(app, /async function acceptCurrentGitStaging\([\s\S]*summary\?\.staged[\s\S]*No staged files are available/, "review staging should require a non-empty current staged set");
1245
1308
  assert.match(app, /function gitWorkflowRequest\([\s\S]*response\.hint \? `\\n\\nHint:/, "guided git failures should show actionable backend hints");
1309
+ assert.match(app, /function gitWorkflowRequest\([\s\S]*if \(response\.code\) failure\.code = response\.code;[\s\S]*if \(response\.hint\) failure\.hint = response\.hint;[\s\S]*if \(response\.data\) failure\.data = response\.data;[\s\S]*throw failure;/, "guided git request failures should preserve the structured backend code, hint, and process result");
1310
+ assert.match(app, /async function pushGitWorkflow\([\s\S]*if \(error\?\.code === "NO_REMOTE"\) \{[\s\S]*await publishGitWorkflowRepository\(tabId, error\)/, "guided git push should offer GitHub publication only for structured NO_REMOTE failures");
1311
+ assert.match(app, /async function publishGitWorkflowRepository\(tabId, failure\)[\s\S]*Publish this repository to GitHub with the authenticated GitHub CLI \(gh\) account instead\?[\s\S]*if \(!publishRequested\) return false;[\s\S]*repoName = promptGitPublishRepoName\(tabId\);[\s\S]*if \(!repoName\) return false;[\s\S]*visibility = promptGitPublishVisibility\(repoName\);[\s\S]*if \(!visibility\) return false;/, "guided git publication should ask to publish, then require a repository name and explicit visibility before continuing");
1312
+ assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*const confirmed = await appConfirmText\(\[[\s\S]*Repository name: \$\{repoName\}[\s\S]*Visibility: \$\{visibility\}[\s\S]*Branch to push: \$\{branch\}[\s\S]*Resulting remote: origin[\s\S]*if \(!confirmed\) return false;[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/publish", \{ body: \{ repoName, visibility, confirmed: true \}/, "guided git publication should require a final summary confirmation before the confirmed publish request");
1313
+ assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*Published \$\{result\.repoName \|\| repoName\} as \$\{result\.visibility \|\| visibility\}\.[\s\S]*Remote: \$\{result\.remote \|\| "origin"\}[\s\S]*Branch: \$\{result\.branch \|\| branch\}[\s\S]*scheduleRefreshFooter\(\)/, "successful publication should report branch/remote metadata and refresh the footer");
1314
+ assert.match(app, /function promptGitPublishRepoName\(tabId = activeTabId\) \{\n\s+const targetTab = tabs\.find\(\(tab\) => tab\.id === tabId\) \|\| activeTab\(\);\n\s+const value = window\.prompt\("GitHub repository name to create", defaultGitInitRepoName\(targetTab\)\);[\s\S]*return cleanGitHubRepoNameInput\(value\);/, "publication should prefill the repository name from the publishing tab's workspace directory and validate it with the existing client rules");
1315
+ assert.match(app, /async function publishGitWorkflowRepository\(tabId, failure\)[\s\S]*const branch = failure\?\.data\?\.branch \|\| gitFooterCurrentBranch\(\) \|\| "the current branch";[\s\S]*repoName = promptGitPublishRepoName\(tabId\);/, "publication confirmation should prefer the server-reported branch and resolve the repository-name default from the publishing tab");
1316
+ assert.match(app, /function promptGitPublishVisibility\(repoName\) \{\n\s+const value = window\.prompt\(`Visibility for GitHub repository \$\{repoName\} — type public or private \(no default\)`, ""\);/, "visibility must be typed with no preselected default");
1317
+ assert.match(app, /function cleanGitPublishVisibilityInput\(value\)[\s\S]*if \(visibility !== "public" && visibility !== "private"\)[\s\S]*nothing was published/, "publication visibility must be exactly public or private");
1318
+ assert.doesNotMatch(app, /visibility = "(?:public|private)"/, "publication visibility should never be defaulted in the frontend");
1246
1319
  assert.match(server, /async function gitAddAllPayload\([\s\S]*platform\(\) === "win32"[\s\S]*findWindowsReservedGitPath\([\s\S]*windowsReservedGitPathFailure\(/, "guided git add should preflight Windows-reserved untracked paths before staging");
1247
1320
  assert.match(app, /Pre-commit verification reminder[\s\S]*Continue with this commit/, "configured verification reminders should run before committing");
1248
1321
  assert.match(server, /async function startGitWorkflowGeneration\([\s\S]*set_model[\s\S]*setThinkingLevelForTab[\s\S]*type: "prompt"/, "server should apply the configured generation profile before prompting Pi");
@@ -1301,7 +1374,7 @@ assert.match(app, /const ACTION_FEEDBACK_REACTIONS = \{/, "frontend should defin
1301
1374
  assert.match(app, /message\?\.role === "assistant" \|\| message\?\.role === "toolExecution" \|\| message\?\.role === "toolResult" \|\| message\?\.role === "bashExecution"/, "frontend should allow reactions on final assistant output as well as actions");
1302
1375
  assert.match(app, /function renderActionFeedbackControls\(/, "frontend should render per-message reaction controls");
1303
1376
  assert.match(app, /function toolResultPreviewText\(message, lineLimit = 10\)/, "tool results should derive a ten-line collapsed preview");
1304
- assert.match(app, /function renderToolExecution\(parent, message\)[\s\S]*?WEBUI_TOOL_RENDERERS/, "paired tool cards should use the browser-side built-in tool renderer registry");
1377
+ 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");
1305
1378
  assert.match(app, /appendToolRawDetails\(parent, tool\)/, "paired tool cards should keep a safe raw-data expander for debugging renderer mismatches");
1306
1379
  assert.match(app, /function toolStateMeta\(tool\)/, "tool cards should expose consistent status and elapsed metadata across built-in renderers");
1307
1380
  assert.match(app, /const TOOL_LIVE_UPDATE_THROTTLE_MS = 80/, "live tool cards should coalesce rapid partial updates before re-rendering");
@@ -1367,7 +1440,7 @@ assert.doesNotMatch(app, /Preparing tool call:/, "tool-call streaming should no
1367
1440
  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");
1368
1441
  assert.match(app, /function renderMarkdownInto\(parent, text\)/, "assistant output should have a browser-native Markdown renderer");
1369
1442
  assert.match(app, /safeMarkdownLinkHref\(url\)/, "Markdown links should be sanitized before rendering");
1370
- assert.match(app, /renderContent\(body, message\.content, \{ markdown: message\.role === "assistant" \}\)/, "final assistant output should render through the Markdown path");
1443
+ assert.match(app, /renderContent\(body, message\.content, \{ markdown: message\.role === "assistant" \|\| message\.role === "custom" \}\)/, "final assistant output should render through the Markdown path");
1371
1444
  assert.match(app, /const hideMessageHeader = message\.role === "assistant" && !isCollapsibleOutput/, "assistant final-output cards should hide the redundant role header");
1372
1445
  assert.match(app, /api\("\/api\/action-feedback", \{ method: "POST"/, "queued action feedback should post to the server after the run is idle");
1373
1446
  assert.match(app, /function postQueuedFeedback\(tabId, items, tabContext = activeTabContext\(tabId\)\)/, "queued feedback should have a backward-compatible submit path");
@@ -1490,7 +1563,7 @@ assert.match(app, /function renderBtwComposerForm\(\)[\s\S]*?form\.requestSubmit
1490
1563
  assert.match(app, /function makeBtwTransferIcon\(\)[\s\S]*?class", "btw-transfer-icon"[\s\S]*?function transferBtwContextToMain\(button, \{ transferMode = "full" \} = \{\}\)[\s\S]*?`\/btw-transfer \$\{encoded\}`[\s\S]*?streamingBehavior: "steer"[\s\S]*?Summarize & Steer/, "/btw widget should expose full-context and summary transfer actions that send steering context during active runs");
1491
1564
  assert.match(app, /async function sendPrompt\(kind = "prompt", explicitMessage, \{ targetTabId = activeTabId, throwOnError = false, streamingBehavior \} = \{\}\)[\s\S]*?if \(targetWasBusy\) body\.streamingBehavior = streamingBehavior \|\| busyBehavior/, "prompt sending should support a per-call streaming behavior override");
1492
1565
  assert.match(app, /function appendOptimisticUserPrompt\([\s\S]*?role: "user"[\s\S]*?transient: true/, "new prompts should be appended to the transcript optimistically before routing finishes");
1493
- assert.match(app, /if \(startsRun\) \{\n\s+markTabWorkingLocally\(targetTabId\);\n\s+if \(isCurrentTabContext\(tabContext\)\) \{\n\s+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");
1566
+ assert.match(app, /if \(startsRun\) \{\n\s+promptRoutingTabs\.add\(targetTabId\);\n\s+markTabWorkingLocally\(targetTabId\);\n\s+if \(isCurrentTabContext\(tabContext\)\) \{\n\s+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");
1494
1567
  assert.match(app, /if \(startsRun && isCurrentTabContext\(tabContext\)\) setRunIndicatorActivity\("Routing complete; starting agent…"\);/, "prepared prompts should transition from routing to agent-start progress before dispatch");
1495
1568
  assert.match(app, /function runPublishWorkflow\(command\)[\s\S]*?sendPrompt\("prompt", `\/\$\{resolvedCommandName\}\$\{commandRest\}`\)/, "Publish workflows should send resolved slash commands directly without replacing the draft");
1496
1569
  assert.match(app, /async function runNativeCommandMenu\(command\)[\s\S]*?await handleNativeSlashSelectorCommand\(command\)/, "skills/tools command menu should open native selector dialogs directly");
@@ -1575,10 +1648,6 @@ assert.match(app, /function updateStickyUserPromptButton\(/, "last user prompt h
1575
1648
  assert.match(app, /function jumpToStickyUserPrompt\(/, "last user prompt header should jump to its source message");
1576
1649
  assert.match(app, /data-user-prompt/, "user prompt messages should be marked for sticky prompt navigation");
1577
1650
  assert.match(app, /function resetChatOutput\(\)[\s\S]*?stickyUserPromptButton/, "chat rerenders should preserve the sticky user prompt control inside the transcript scroller");
1578
- assert.match(app, /function nextQueuedFollowUpPrompt\(tabId = activeTabId\)/, "sticky prompt header should derive the next queued follow-up prompt for display");
1579
- assert.match(app, /sticky-user-follow-up-prompt[\s\S]*Next follow-up/, "sticky prompt header should render the next follow-up under the last user prompt");
1580
- assert.match(app, /function renderQueue\(event\)[\s\S]*updateStickyUserPromptButton\(\)/, "queue updates should refresh the sticky last-user-prompt header");
1581
- assert.match(css, /\.sticky-user-follow-up-prompt \{[\s\S]*?grid-column:\s*1 \/ -1/, "next follow-up should render below the sticky last-user-prompt row");
1582
1651
  assert.match(app, /LAST_USER_PROMPT_STORAGE_KEY/, "last user prompt should be cached so compaction cannot remove the sticky prompt preview");
1583
1652
  assert.match(app, /function syncLastUserPromptFromMessages\(messages = latestMessages\)/, "message refresh should preserve the latest user prompt across compacted transcripts");
1584
1653
  assert.match(app, /dataset\.compacted/, "sticky prompt should expose a compacted fallback state when its source message was summarized away");
@@ -1623,7 +1692,7 @@ assert.match(app, /case "webui_connected":[\s\S]*?featureCategoryByTab\.delete\(
1623
1692
  assert.match(app, /async function reconcileForegroundState\(reason = "resume"\)[\s\S]*?refreshTabs\(\)[\s\S]*?ensureActiveEventStream\(tabContext\)[\s\S]*?refreshAll\(tabContext\)/, "foreground reconciliation should refresh tabs plus active transcript after mobile backgrounding");
1624
1693
  assert.match(app, /document\.addEventListener\("visibilitychange"[\s\S]*?scheduleForegroundReconcile\("visibility resume", 0\)/, "returning to a hidden mobile tab should force a server snapshot refresh");
1625
1694
  assert.match(app, /window\.addEventListener\("pageshow", \(\) => scheduleForegroundReconcile\("page show", 0\)\)/, "BFCache or PWA page resume should force a server snapshot refresh");
1626
- assert.match(app, /async function refreshMessages\(tabContext = activeTabContext\(\)\)[\s\S]*?if \(!isCurrentTabContext\(tabContext\)\) return;/, "message refreshes should not render after the user switches tabs");
1695
+ assert.match(app, /async function refreshMessages\(tabContext = activeTabContext\(\), \{ authoritative = false \} = \{\}\)[\s\S]*?if \(!isCurrentTabContext\(tabContext\)\) return;/, "message refreshes should not render after the user switches tabs");
1627
1696
  assert.match(app, /function tabIndicator\(tab\)/, "frontend should derive idle, working, blocked, and work-done tab indicator states");
1628
1697
  assert.match(app, /pendingBlockerCount > 0[\s\S]*?state: "blocked"/, "frontend should show blocked tabs when extension UI blockers are pending");
1629
1698
  assert.match(app, /const EXTENSION_UI_BLOCKING_METHODS = new Set\(\["select", "confirm", "input", "editor"\]\)/, "frontend should share blocking extension UI method detection for dialogs and notifications");
@@ -1741,10 +1810,10 @@ assert.match(server, /delete process\.env\.PI_WEBUI_RESTORE_TABS/, "server shoul
1741
1810
  assert.match(server, /if \(sessionFile && !options\.noSession\) piArgs\.push\("--session", sessionFile\)/, "restored tabs should resume previous session files");
1742
1811
  assert.doesNotMatch(server, /args\.push\("--name"/, "Web UI tab titles should not be forwarded as Pi CLI --name flags because older bundled Pi CLIs reject them");
1743
1812
  assert.match(server, /const closedRestorableTabs = \[\]/, "server should track recently closed tabs separately from restart restore descriptors");
1744
- assert.match(server, /async function closeTab\(id\)[\s\S]*?rememberClosedRestorableTab\(tab, restorableState\)/, "closing a tab should capture its session before stopping RPC for detailed closed-tab status");
1813
+ assert.match(server, /async function closeTab\(id, \{ allowLast = false \} = \{\}\)[\s\S]*?rememberClosedRestorableTab\(tab, restorableState\)/, "closing a tab should capture its session before stopping RPC for detailed closed-tab status");
1745
1814
  assert.match(server, /async function restorableTabsForRestart\(\)[\s\S]*?return mergeRestorableTabDescriptors\(liveDescriptors\)/, "server restart should restore only currently open tabs");
1746
1815
  assert.doesNotMatch(server, /return mergeRestorableTabDescriptors\(liveDescriptors,\s*closedRestorableTabs\)/, "server restart should not restore closed tabs");
1747
- assert.match(server, /async function closeTabs\(ids\)[\s\S]*?if \(targetTabs\.length >= tabs\.size\) \{\n\s+await createTab/, "bulk tab close should create a replacement before closing every current tab");
1816
+ assert.match(server, /async function closeTabs\(ids, \{ allowEmpty = false \} = \{\}\)[\s\S]*?if \(!allowEmpty && targetTabs\.length >= tabs\.size\) \{\n\s+await createTab/, "bulk tab close should preserve replacement-tab behavior unless an explicit close-all requests the workspace-load empty state");
1748
1817
  assert.match(server, /url\.pathname === "\/api\/tabs\/close" && req\.method === "POST"[\s\S]*?closedIds: closed\.map\(\(tab\) => tab\.id\)/, "server should expose a bulk close-tabs endpoint");
1749
1818
  assert.match(server, /function rememberTabState\(tab, state\)/, "server should cache last-known tab state for restart-safe session restoration");
1750
1819
  assert.match(server, /sessionFile: tabRestorableSessionFile\(tab\)/, "tab metadata should expose cached session files for health/status restore descriptors");
@@ -1861,7 +1930,7 @@ assert.match(server, /writeFile\(tmpFile, body\.content[\s\S]*?rename\(tmpFile,
1861
1930
  assert.match(server, /url\.pathname === "\/api\/themes" && req\.method === "GET"/, "server should expose GET /api/themes");
1862
1931
  assert.match(server, /readBundledThemes\(\)/, "server should read bundled theme JSON files for the browser");
1863
1932
  assert.match(server, /"apple-touch-icon\.png", "icon-192\.png"/, "server should serve the conventional apple touch icon path");
1864
- assert.match(server, /"fast-output-live\.mjs", "subagent-launch-slot-state\.mjs", "voice-conversation\.mjs"/, "server should serve the launch-slot state module imported by the browser app");
1933
+ assert.match(server, /"fast-output-live\.mjs", "subagent-launch-slot-state\.mjs", "subagent-gate-visibility\.mjs", "workflow-status-stack\.mjs", "voice-conversation\.mjs"/, "server should serve browser modules imported by the app");
1865
1934
  assert.match(server, /"catppuccin-mocha-background\.png", "matrix-background\.webp", "manifest\.webmanifest", "service-worker\.js"/, "server should serve theme background images as static assets");
1866
1935
  assert.match(server, /\["\.webmanifest", "application\/manifest\+json; charset=utf-8"\]/, "server should serve manifest with the correct MIME type");
1867
1936
  assert.match(server, /\["\.png", "image\/png"\]/, "server should serve PWA PNG icons with the correct MIME type");
@@ -1908,7 +1977,7 @@ for (const [name, range] of Object.entries(companionDependencies)) {
1908
1977
  assert.equal(pkg.optionalDependencies?.[name], range, `webui package should optionally depend on ${name}`);
1909
1978
  assert.equal(pkg.dependencies?.[name], undefined, `webui package should not require optional companion ${name}`);
1910
1979
  assert.equal(lock.packages?.[""]?.optionalDependencies?.[name], range, `package-lock root should optionally depend on ${name}`);
1911
- assert.equal(lock.packages?.[""]?.dependencies?.[name], undefined, `package-lock root should not require optional companion ${name}`);
1980
+ assert.equal(lock.packages?.[""]?.dependencies?.[name], undefined, `package-lock root should not promote optional companion ${name} to a required dependency`);
1912
1981
  assert.ok(lock.packages?.[`node_modules/${name}`], `package-lock should include resolved optional companion ${name}`);
1913
1982
  }
1914
1983
  assert.equal(pkg.bundledDependencies, undefined, "webui optional companion packages should not be bundled into the tarball");
@@ -1974,7 +2043,7 @@ assert.match(app, /streamRawText = "";\n streamThinkingRawText = "";\n resetSt
1974
2043
 
1975
2044
  // --- Performance: delta transcript fetch (P1-1) ---
1976
2045
  assert.match(app, /function mergeMessagesDelta\(previous, data\)[\s\S]*?messagesLookEqual\(previous\[since\], data\.messages\[0\]\)/, "delta merges must verify the one-message overlap before applying");
1977
- assert.match(app, /async function refreshMessages\(tabContext = activeTabContext\(\)\)[\s\S]*?\/api\/messages\?since=/, "message refreshes should request transcript deltas");
2046
+ assert.match(app, /async function refreshMessages\(tabContext = activeTabContext\(\), \{ authoritative = false \} = \{\}\)[\s\S]*?\/api\/messages\?since=/, "message refreshes should request transcript deltas");
1978
2047
  assert.match(app, /if \(!nextMessages\) \{[\s\S]*?api\("\/api\/messages", \{ tabId: tabContext\.tabId \}\)/, "delta failures must fall back to a full transcript fetch");
1979
2048
  assert.match(server, /function applyMessagesSinceParam\(response, url\)/, "server should slice get_messages results for \\?since= requests");
1980
2049
  assert.match(app, /const messageStaticSignatureCache = new WeakMap\(\);/, "static message signatures should be cached by object identity");
@@ -1988,6 +2057,6 @@ assert.match(app, /\(event\.ctrlKey \|\| event\.metaKey\) && !event\.altKey && !
1988
2057
  assert.match(app, /function focusChatSearchMatch\(\)[\s\S]*?details\.open = true;[\s\S]*?scrollIntoView/, "navigating to a search match should expand collapsed tool output and scroll to the bubble");
1989
2058
  assert.match(app, /autoFollowChat = false;\n lastChatProgrammaticScrollAt = performance\.now\(\);/, "search navigation must not fight chat auto-follow");
1990
2059
  assert.match(css, /\.message\.search-current \{/, "current search match should have a highlight style");
1991
- assert.match(css, /\.chat-search-bar \{/, "transcript search bar should be styled");
2060
+ assert.match(css, /\.chat-search-bar,\n\.file-viewer-search-bar \{/, "transcript search bar should be styled");
1992
2061
 
1993
2062
  console.log("mobile static checks passed");
@@ -189,7 +189,7 @@ assert.match(server, /async function cycleTabModel\(tab, direction = "forward"\)
189
189
  assert.match(server, /url\.pathname === "\/api\/model-cycle" && req\.method === "POST"/, "server should expose model-cycle endpoint for shortcuts");
190
190
  assert.match(server, /case "\/api\/thinking-cycle":[\s\S]*?type: "cycle_thinking_level"/, "server should expose thinking-cycle endpoint for shortcuts");
191
191
  assert.match(server, /async function setThinkingLevelForTab\(tab, level, \{ allowPending = true \} = \{\}\)[\s\S]*?stateIsBusyForSettings\(stateResult\.data\)[\s\S]*?tab\.pendingThinkingLevel = level/, "server should queue side-panel thinking changes while a tab is running");
192
- assert.match(server, /function eventForTabClients\(tab, event\)[\s\S]*?responseWithPendingThinking\(tab, event\)[\s\S]*?tabId: tab\.id/, "server should decorate SSE state responses with pending thinking before broadcasting to clients");
192
+ assert.match(server, /function eventForTabClients\(tab, event\)[\s\S]*?const decorated = event\?\.type === "queue_update"[\s\S]*?responseWithPendingThinking\(tab, decorated\)[\s\S]*?tabId: tab\.id/, "server should apply pending-thinking decoration to the source-decorated SSE event and retain its tab id");
193
193
  assert.match(server, /tab\.pendingThinkingLevel = level;\n\s+broadcastPendingThinkingState\(tab, stateResult\.data\)/, "server should broadcast queued thinking state after assigning the pending level");
194
194
  assert.match(server, /const pendingThinkingResponse = await applyPendingThinkingBeforePrompt\(tab\)/, "server should apply queued thinking level before the next prompt");
195
195
  assert.match(app, /pendingThinkingLevel[\s\S]*?next prompt/, "frontend should show queued thinking changes as applying on the next prompt");
@@ -68,7 +68,7 @@ assert.match(server, /"issue-wizard-state\.mjs"/, "the static allowlist must con
68
68
  assert.match(server, /"issue-bot-client\.mjs"/, "the static allowlist must serve the browser client module");
69
69
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
70
70
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
71
- assert.match(serviceWorker, /pi-webui-pwa-v48/, "the PWA cache name must change with the new static module");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v50/, "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
 
@@ -0,0 +1,101 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import vm from "node:vm";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const [html, css, app] = await Promise.all([
9
+ readFile(join(root, "public", "index.html"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "public", "app.js"), "utf8"),
12
+ ]);
13
+
14
+ assert.match(
15
+ html,
16
+ /id="followUpQueueTrigger"[^>]*aria-controls="followUpQueueOverlay"[^>]*aria-expanded="false"[\s\S]*id="followUpQueueTriggerCount"[\s\S]*id="followUpQueueOverlay"[^>]*aria-label="Queued follow-ups"[\s\S]*id="followUpQueueRows"[\s\S]*id="followUpQueueStatus"[^>]*role="status"[^>]*aria-live="polite"/,
17
+ "the composer should expose a count trigger and accessible non-modal follow-up queue overlay",
18
+ );
19
+ assert.match(css, /\.follow-up-queue-overlay \{[\s\S]*position:\s*absolute;[\s\S]*bottom:\s*calc\(100% \+ 0\.42rem\);[\s\S]*max-height:\s*min\(32rem, calc\(var\(--visual-viewport-height, 100dvh\) - 2rem\)\)/, "the queue overlay should float upward without changing composer layout and be bounded by the visual viewport");
20
+ assert.match(css, /body\.mobile-keyboard-open \.follow-up-queue-trigger:not\(\[hidden\]\) \{ display: inline-flex; \}/, "the queue trigger should remain usable while the mobile keyboard is open");
21
+ assert.match(css, /@media \(prefers-reduced-motion: reduce\) \{[\s\S]*\.follow-up-queue-overlay,[\s\S]*\.follow-up-queue-row \{ transition: none; \}/, "the queue overlay should suppress motion for reduced-motion users");
22
+
23
+ const normalizeStart = app.indexOf("function normalizeQueuedMessages(event) {");
24
+ const normalizeEnd = app.indexOf("\nfunction queuedSnapshotForTab", normalizeStart);
25
+ assert.ok(normalizeStart >= 0 && normalizeEnd > normalizeStart, "queue normalization should remain independently testable");
26
+ const normalizeSource = app.slice(normalizeStart, normalizeEnd);
27
+ const compactionSnapshot = JSON.parse(vm.runInNewContext(`${normalizeSource}\nJSON.stringify(normalizeQueuedMessages({ source: "webui-compaction", revision: 7, draining: true, steering: ["steer"], followUp: ["first", "second"] }))`));
28
+ assert.deepEqual(compactionSnapshot, {
29
+ source: "webui-compaction",
30
+ revision: 7,
31
+ draining: true,
32
+ steering: ["steer"],
33
+ followUp: ["first", "second"],
34
+ }, "frontend queue normalization should retain compaction source, revision, draining state, and both queue arrays");
35
+
36
+ const mutationBodyStart = app.indexOf("function queueMutationBody(snapshot, operation) {");
37
+ const mutationBodyEnd = app.indexOf("\nfunction applyAuthoritativeQueuedSnapshot", mutationBodyStart);
38
+ assert.ok(mutationBodyStart >= 0 && mutationBodyEnd > mutationBodyStart, "queue mutation request construction should remain independently testable");
39
+ const mutationBodySource = app.slice(mutationBodyStart, mutationBodyEnd);
40
+ const compactionMutation = JSON.parse(vm.runInNewContext(`${mutationBodySource}\nJSON.stringify(queueMutationBody({ source: "webui-compaction", revision: 3, steering: ["steer"], followUp: ["one", "two"] }, { type: "move", from: 1, to: 0, expectedText: "two" }))`));
41
+ assert.deepEqual(compactionMutation, {
42
+ source: "webui-compaction",
43
+ kind: "followUp",
44
+ revision: 3,
45
+ expected: { steering: ["steer"], followUp: ["one", "two"] },
46
+ operation: { type: "move", from: 1, to: 0, expectedText: "two" },
47
+ }, "compaction moves should use the B1 source-aware, revisioned full-snapshot mutation contract");
48
+ const runtimeMutation = JSON.parse(vm.runInNewContext(`${mutationBodySource}\nJSON.stringify(queueMutationBody({ source: "pi-runtime", steering: [], followUp: ["old"] }, { type: "edit", index: 0, expectedText: "old", text: "new" }))`));
49
+ assert.equal(Object.hasOwn(runtimeMutation, "revision"), false, "Pi-runtime mutations must omit the compaction-only revision field");
50
+ assert.deepEqual(runtimeMutation.expected, { steering: [], followUp: ["old"] }, "Pi-runtime mutations should send the complete B1 expected snapshot");
51
+
52
+ const draftHelperStart = app.indexOf("function preservedFocusedFollowUpQueueDraft(draft, followUps) {");
53
+ const draftHelperEnd = app.indexOf("\nfunction focusedFollowUpQueueDraft", draftHelperStart);
54
+ assert.ok(draftHelperStart >= 0 && draftHelperEnd > draftHelperStart, "queue draft preservation should remain independently testable");
55
+ const draftHelperSource = app.slice(draftHelperStart, draftHelperEnd);
56
+ const draftDecisions = JSON.parse(vm.runInNewContext(`${draftHelperSource}
57
+ JSON.stringify({
58
+ preserve: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "unsaved second", selectionStart: 3, selectionEnd: 10 }, ["first", "second"]),
59
+ targetChanged: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "unsaved second", selectionStart: 3, selectionEnd: 10 }, ["first", "server replacement"]),
60
+ indexChanged: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "unsaved second" }, ["second", "first"]),
61
+ clean: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "second" }, ["first", "second"]),
62
+ })`));
63
+ assert.deepEqual(draftDecisions.preserve, { index: 1, value: "unsaved second", selectionStart: 3, selectionEnd: 10 }, "an SSE queue update should preserve the focused dirty draft only when its same authoritative item remains at its index");
64
+ assert.equal(draftDecisions.targetChanged, null, "an authoritative replacement at the focused index must discard the old draft instead of carrying it across a conflict");
65
+ assert.equal(draftDecisions.indexChanged, null, "a reordered target must not retain a dirty draft at the old index");
66
+ assert.equal(draftDecisions.clean, null, "unchanged focused text should not be treated as a dirty draft");
67
+
68
+ const renderTargetStart = app.indexOf("function queuedSnapshotTargetsCurrentTab(tabContext, currentTabId = activeTabId, currentTabs = tabs) {");
69
+ const renderTargetEnd = app.indexOf("\nfunction setFollowUpQueueOpen", renderTargetStart);
70
+ assert.ok(renderTargetStart >= 0 && renderTargetEnd > renderTargetStart, "late queue response targeting should remain independently testable");
71
+ const renderTargetSource = app.slice(renderTargetStart, renderTargetEnd);
72
+ const renderTargets = JSON.parse(vm.runInNewContext(`${renderTargetSource}
73
+ JSON.stringify({
74
+ returnedToOrigin: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4, sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, "A", [{ id: "A", sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }]),
75
+ anotherTabActive: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4, sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, "B", [{ id: "A", sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, { id: "B" }]),
76
+ originClosed: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4 }, "A", []),
77
+ sessionReplaced: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4, sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, "A", [{ id: "A", sessionFile: "/sessions/replacement.jsonl", startedAt: "start-replacement" }]),
78
+ })`));
79
+ assert.equal(renderTargets.returnedToOrigin, true, "a late A mutation response should render after A→B→A when A is active again");
80
+ assert.equal(renderTargets.anotherTabActive, false, "a late A mutation response must not repaint active tab B");
81
+ assert.equal(renderTargets.originClosed, false, "a late response must not render after its originating tab closes");
82
+ assert.equal(renderTargets.sessionReplaced, false, "a late response must not render after the authoritative tab session changes");
83
+
84
+ assert.match(app, /async function mutateQueuedFollowUp\([\s\S]*const tabContext = queueTabContext\(tabId\)[\s\S]*api\("\/api\/queue\/mutate", \{ method: "POST", body: queueMutationBody\(snapshot, operation\), tabId \}\)[\s\S]*if \(result\.queue\) applyAuthoritativeQueuedSnapshot\(tabContext, result\.queue\)[\s\S]*error\?\.statusCode === 409[\s\S]*refreshed the authoritative queue/, "queue mutations should use the single B1 endpoint and refresh the authoritative snapshot after conflicts");
85
+ assert.match(app, /function applyAuthoritativeQueuedSnapshot\([\s\S]*latestQueuedMessagesByTab\.set\(tabContext\.tabId, snapshot\)[\s\S]*if \(queuedSnapshotTargetsCurrentTab\(tabContext\)\) renderQueue/, "late mutation responses should render only their active originating tab while caching every authoritative result");
86
+ assert.match(app, /function renderQueue\(event\)[\s\S]*latestQueuedMessagesByTab\.set\(tabId, snapshot\)[\s\S]*if \(tabId && tabId !== activeTabId\) return;/, "deferred queue rendering must cache but never repaint an unrelated active tab");
87
+ assert.match(app, /const followUpQueueMutationsInFlightByTab = new Set\(\)[\s\S]*function syncFollowUpQueueMutationControls\([\s\S]*textarea\.disabled = locked \|\| draining[\s\S]*control\.disabled = locked \|\| draining[\s\S]*function setFollowUpQueueMutationInFlight/, "in-flight and draining states should lock editable queue controls per tab");
88
+
89
+ assert.match(app, /const textarea = make\("textarea", "follow-up-queue-textarea"\)[\s\S]*textarea\.dataset\.followUpQueueAuthoritativeText = item[\s\S]*textarea\.addEventListener\("blur", \(\) => \{[\s\S]*followUpQueueSuppressBlurFor[\s\S]*saveQueuedFollowUpText\(index, item, textarea\.value\)[\s\S]*\(event\.ctrlKey \|\| event\.metaKey\)[\s\S]*event\.key === "Enter"[\s\S]*event\.key !== "Escape"[\s\S]*textarea\.value = item/, "queue rows should be editable by default and avoid blur-saving the focused draft during an authoritative rerender");
90
+ assert.match(app, /row\.draggable = false;[\s\S]*dragHandle\.draggable = !unavailable;[\s\S]*row\.addEventListener\("dragstart", \(event\) => \{[\s\S]*event\.target\?\.closest\?\.\("\.follow-up-queue-drag-handle"\) !== dragHandle[\s\S]*application\/x-pi-webui-follow-up[\s\S]*row\.addEventListener\("dragover"[\s\S]*event\.stopPropagation\(\)[\s\S]*row\.addEventListener\("drop"[\s\S]*type: "move", from: drag\.index, to: index/, "native drag/drop should begin only from its visible handle, persist the final-index permutation, and isolate row drag events");
91
+ assert.match(app, /function handleComposerDragOver\(event\) \{\n\s*if \(event\.target\?\.closest\?\.\("#followUpQueueOverlay"\) \|\| !isFileDrag\(event\)\) return;[\s\S]*function handleComposerDrop\(event\) \{\n\s*if \(event\.target\?\.closest\?\.\("#followUpQueueOverlay"\) \|\| !isFileDrag\(event\)\) return;/, "composer attachment drops should ignore queue-row drag events");
92
+ assert.match(app, /Moved queued follow-up \$\{operation\.from \+ 1\} to position \$\{operation\.to \+ 1\}[\s\S]*Move queued follow-up \$\{index \+ 1\} up[\s\S]*Move queued follow-up \$\{index \+ 1\} down/, "move controls should provide labelled keyboard/touch parity and live reorder announcements");
93
+ assert.match(app, /setFollowUpQueueOpen\(false, \{ restoreFocus: true \}\)/, "outside close and Escape should request queue-focus restoration");
94
+ assert.match(app, /function setFollowUpQueueOpen\([\s\S]*followUpQueueRestoreFocus[\s\S]*requestAnimationFrame\(\(\) => focusTarget\?\.focus\(\{ preventScroll: true \}\)\)/, "queue close should restore focus to the saved trigger context");
95
+ assert.match(app, /function setFollowUpQueueOpen[\s\S]*setComposerActionsOpen\(false\)[\s\S]*setPublishMenuOpen\(false\)[\s\S]*setNativeCommandMenuOpen\(false\)[\s\S]*setAppRunnerMenuOpen\(false\)[\s\S]*setOptionsMenuOpen\(false\)[\s\S]*setConversationVoiceMenuOpen\(false\)[\s\S]*setBusyPromptBehaviorMenuOpen\(false\)[\s\S]*setNewTabMenuOpen\(false\)/, "opening the queue should close competing dropdown surfaces");
96
+ assert.match(app, /function renderFollowUpQueueOverlay\(\) \{\n\s*if \(deferUiRenderDuringPointerActivation\("follow-up-queue", renderFollowUpQueueOverlay\)\) return;/, "queue rendering should defer during pointer activation");
97
+ assert.match(app, /function switchTab\(tabId\)[\s\S]*setFollowUpQueueOpen\(false\)[\s\S]*setFollowUpQueueStatus\(""\)/, "switching tabs should close queue UI and clear its tab-local status before the new context renders");
98
+ assert.match(app, /renderQueueGroup\("Follow-up", followUp, "follow-up", \{ removable: snapshot\.source === "pi-runtime", tabId \}\)/, "Control Deck removal must stay gated to Pi-runtime snapshots");
99
+ assert.doesNotMatch(app, /nextQueuedFollowUpPrompt|sticky-user-follow-up-prompt|Next follow-up prompt:/, "the sticky last/current prompt control must no longer expose queued follow-up preview content");
100
+
101
+ console.log("queue edit/reorder static tests passed");