@firstpick/pi-package-webui 0.9.7 → 0.9.8

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 (55) hide show
  1. package/README.md +7 -3
  2. package/bin/pi-webui.mjs +114 -25
  3. package/index.ts +2 -1
  4. package/lib/optional-feature-catalog.mjs +1 -1
  5. package/package.json +1 -1
  6. package/public/app.js +629 -98
  7. package/public/guided-git-command-state.mjs +175 -1
  8. package/public/index.html +12 -9
  9. package/public/service-worker.js +1 -1
  10. package/public/styles.css +133 -31
  11. package/public/transcript-renderer.mjs +62 -0
  12. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  13. package/tests/browser/footer-model-advanced-layout.spec.mjs +512 -0
  14. package/tests/browser/guided-git-extension-command.spec.mjs +180 -0
  15. package/tests/browser/guided-git-fallback.spec.mjs +68 -3
  16. package/tests/browser/interaction-continuity.spec.mjs +33 -0
  17. package/tests/codex-fast-mode-static.test.mjs +2 -2
  18. package/tests/compaction-static.test.mjs +1 -1
  19. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  20. package/tests/control-visibility-static.test.mjs +3 -3
  21. package/tests/controls-layout-static.test.mjs +3 -3
  22. package/tests/events-tree-context-menu-static.test.mjs +3 -3
  23. package/tests/fast-mode-client-static.test.mjs +1 -1
  24. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  25. package/tests/file-viewer-image-static.test.mjs +3 -3
  26. package/tests/fixtures/fake-pi.mjs +34 -3
  27. package/tests/git-footer-context-menu-static.test.mjs +103 -1
  28. package/tests/guided-git-activation-http.test.mjs +194 -0
  29. package/tests/guided-git-activation-static.test.mjs +80 -0
  30. package/tests/guided-git-activation.test.mjs +244 -0
  31. package/tests/guided-git-fallback-runtime.test.mjs +1 -0
  32. package/tests/guided-git-fallback-ui-static.test.mjs +2 -2
  33. package/tests/guided-git-message-reliability-static.test.mjs +2 -1
  34. package/tests/guided-git-optional-feature.test.mjs +31 -0
  35. package/tests/http-endpoints-harness.test.mjs +3 -0
  36. package/tests/interaction-state-stability-static.test.mjs +1 -1
  37. package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
  38. package/tests/main-output-loading-static.test.mjs +11 -9
  39. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  40. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  41. package/tests/mobile-foundation-static.test.mjs +3 -3
  42. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  43. package/tests/mobile-static.test.mjs +85 -4
  44. package/tests/open-issue-wizard-static.test.mjs +1 -1
  45. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  46. package/tests/prompt-input-vertical-scroll-static.test.mjs +6 -6
  47. package/tests/prompt-routing-input-clear-static.test.mjs +1 -1
  48. package/tests/questionnaire-dialog.test.mjs +3 -3
  49. package/tests/session-sampling-ui-static.test.mjs +3 -3
  50. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  51. package/tests/subagent-observability-static.test.mjs +2 -2
  52. package/tests/syntax-highlighting-static.test.mjs +3 -3
  53. package/tests/tab-close-continuity-static.test.mjs +2 -0
  54. package/tests/theme-customizer-static.test.mjs +1 -1
  55. package/tests/thinking-block-grouping.test.mjs +79 -0
@@ -54,7 +54,7 @@ assert.match(readme, /fallback model and its own reasoning effort[\s\S]*tries th
54
54
  assert.match(technical, /## Guided Git generation profiles[\s\S]*strict one-retry policy[\s\S]*model and reasoning effort are restored[\s\S]*dead Pi process cannot run the fallback/i, "technical reference should document configuration and operational limits");
55
55
  assert.match(development, /### Fallback browser\/runtime contract[\s\S]*fallbackUsed: true[\s\S]*webui_git_workflow_generation_fallback_started[\s\S]*never sends a retry/, "development guide should preserve the response/event and browser ownership contract");
56
56
 
57
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the changed browser app should use the next query revision");
58
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132";/, "the PWA cache identity should advance with browser behavior");
57
+ assert.match(html, /data-app-src="\/app\.js\?v=172"/, "the changed browser app should use the next query revision");
58
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139";/, "the PWA cache identity should advance with browser behavior");
59
59
 
60
60
  console.log("guided-git-fallback-ui-static.test.mjs passed");
@@ -15,7 +15,7 @@ assert.match(server, /async function createGitWorkflowMessageGeneration\(tab, ge
15
15
  assert.match(server, /generationId: record\.generationId/, "generation dispatch must return one server-owned correlation ID across every kind and both attempts");
16
16
  assert.match(server, /tab\.gitWorkflowArtifactGeneration = record\.artifactGeneration/, "the artifact generation record must be owned by the originating tab");
17
17
  assert.match(server, /case "\/api\/git-workflow\/message"[\s\S]*generationId[\s\S]*tab\?\.gitWorkflowArtifactGeneration/, "fresh message reads must resolve the correlated generation from the requested tab");
18
- assert.match(server, /readGitWorkflowMessages\(cwd, \{ generationId = "", generation = null \} = \{\}\)[\s\S]*generation\.cwd !== messageCwd[\s\S]*!generation\.terminal[\s\S]*!generation\.successful/, "message readiness must reject wrong identity, active attempts, and terminal failure");
18
+ assert.match(server, /readGitWorkflowMessages\(cwd, \{ generationId = "", generation = null \} = \{\}\)[\s\S]*generation\.cwd !== messageCwd[\s\S]*!generation\.terminal[\s\S]*running: true[\s\S]*!generation\.successful/, "message readiness must reject wrong identity and terminal failure while identifying an active attempt");
19
19
  assert.match(server, /gitMessageArtifactPairReadiness\(generation\.baseline, pair\)[\s\S]*GIT_WORKFLOW_MESSAGE_PAIR_SETTLE_MS[\s\S]*sameGitMessageArtifactPair\(pair, settledPair\)/, "the backend must require both changed artifacts and a stable settled pair");
20
20
  assert.doesNotMatch(app, /newestMtime \+ 10000 < currentWorkflow\.messageRequestedAt/, "freshness must not use the previous wall-clock/mtime tolerance");
21
21
 
@@ -25,6 +25,7 @@ assert.match(app, /function acceptGitWorkflowGenerationCorrelation[\s\S]*generat
25
25
  assert.match(app, /const loadKey = `\$\{expectedRunId\}:\$\{expectedGenerationId \|\| "preview"\}`[\s\S]*existing\?\.key === loadKey[\s\S]*return existing\.promise/, "duplicate timer/resume/agent_end wakeups must reuse one poll promise");
26
26
  assert.match(app, /gitWorkflowMessageLoadIsCurrent\(tabId, expectedRunId, expectedGenerationId\)/, "poll results must be guarded by tab, run, and generation identity");
27
27
  assert.match(app, /GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS = 30_000[\s\S]*GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS/, "fresh message polling must be adaptive and bounded");
28
+ assert.match(app, /message\.running === true\) deadline = Date\.now\(\) \+ GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS/, "an active fallback generation must renew the artifact-settle deadline instead of forcing manual preview");
28
29
  assert.match(app, /\?generationId=\$\{encodeURIComponent\(expectedGenerationId\)\}/, "fresh commit reads must send the correlation ID to the backend");
29
30
  assert.match(app, /branch-name\$\{query\}[\s\S]*pr-description\$\{query\}/, "fresh branch and PR reads must also send exact generation IDs");
30
31
  assert.match(app, /message\.ready === false[\s\S]*message\.expired[\s\S]*Regenerate/, "pending and expired generation states must remain actionable");
@@ -0,0 +1,31 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { readFile } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { OPTIONAL_FEATURE_BY_ID, OPTIONAL_FEATURE_CATALOG } from "../lib/optional-feature-catalog.mjs";
7
+
8
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
9
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
10
+ const extensionManifest = JSON.parse(await readFile(join(root, "..", "pi-extension-git-guided-workflow", "package.json"), "utf8"));
11
+
12
+ test("Optional Features installs the Guided Git extension that bundles its prompt companion", () => {
13
+ assert.deepEqual(OPTIONAL_FEATURE_BY_ID.get("gitWorkflow"), {
14
+ featureId: "gitWorkflow",
15
+ packageName: "@firstpick/pi-extension-git-guided-workflow",
16
+ expectedSpec: "^0.1.0",
17
+ });
18
+ assert.equal(OPTIONAL_FEATURE_BY_ID.has("gitGuidedWorkflow"), false, "one package install should own the complete Guided Git feature");
19
+ assert.equal(new Set(OPTIONAL_FEATURE_CATALOG.map(({ featureId }) => featureId)).size, OPTIONAL_FEATURE_CATALOG.length);
20
+ assert.equal(new Set(OPTIONAL_FEATURE_CATALOG.map(({ packageName }) => packageName)).size, OPTIONAL_FEATURE_CATALOG.length);
21
+
22
+ assert.equal(extensionManifest.dependencies?.["@firstpick/pi-prompts-git-pr"], "^0.1.6");
23
+ assert.deepEqual(extensionManifest.bundledDependencies, ["@firstpick/pi-prompts-git-pr"]);
24
+ assert.deepEqual(extensionManifest.pi?.prompts, ["./node_modules/@firstpick/pi-prompts-git-pr/prompts"]);
25
+
26
+ assert.match(app, /id: "gitWorkflow"[\s\S]*packageName: "@firstpick\/pi-extension-git-guided-workflow"[\s\S]*capabilityLabel: "\/git-guided-workflow"/u);
27
+ assert.match(app, /\["git-guided-workflow", "gitWorkflow"\][\s\S]*\["git-staged-msg", "gitWorkflow"\]/u);
28
+ assert.match(app, /optionalFeatureAvailability\.gitWorkflow = hasAvailableCommand\("git-guided-workflow"\) \|\| hasAvailableCommand\("git-staged-msg"\);/u);
29
+ assert.match(app, /case "git-workflow": return true;/u, "the browser-owned setup must not depend on a removed prompt command");
30
+ assert.match(app, /case "git-workflow": return openNativeGitWorkflowSetupDialog\(\);/u, "Setup must open the Guided Git workflow dialog");
31
+ });
@@ -1316,6 +1316,9 @@ try {
1316
1316
  const optionalFeatures = await request("127.0.0.1", "/api/optional-features");
1317
1317
  assert.equal(optionalFeatures.status, 200, "optional feature status should load");
1318
1318
  assert.equal(optionalFeatures.body?.data?.features?.length, 20, "the explicit server catalog should expose every allowlisted feature");
1319
+ const guidedGitFeature = optionalFeatures.body?.data?.features?.find((feature) => feature.featureId === "gitWorkflow");
1320
+ assert.equal(guidedGitFeature?.packageName, "@firstpick/pi-extension-git-guided-workflow", "Optional Features must install the extension that bundles the prompt companion");
1321
+ assert.equal(guidedGitFeature?.expectedSpec, "^0.1.0");
1319
1322
  const aurReviewFeature = optionalFeatures.body?.data?.features?.find((feature) => feature.featureId === "aurReview");
1320
1323
  assert.equal(aurReviewFeature?.expectedSpec, "^0.1.1", "status should expose the catalog-owned compatibility spec");
1321
1324
  assert.equal(aurReviewFeature?.installed, true, "workspace discovery should find the local pi-extension-aur-review sibling without an npm dependency");
@@ -186,7 +186,7 @@ const coordinatedTextPoint = functionBody("textPoint", renderer);
186
186
  const logMutation = functionBody("logMutation", renderer);
187
187
 
188
188
  // Coordinator import and initialization.
189
- assert.match(app, /import \{ createTranscriptRenderer \} from "\.\/transcript-renderer\.mjs";/, "app must import the transcript mutation coordinator module");
189
+ assert.match(app, /import \{ createTranscriptRenderer, groupConsecutiveThinkingItems, groupConsecutiveThinkingMessages \} from "\.\/transcript-renderer\.mjs";/, "app must import the transcript mutation coordinator and thinking-group helpers");
190
190
  assert.match(app, /const transcriptRenderer = createTranscriptRenderer\(\{[\s\S]*?chat: elements\.chat[\s\S]*?contextKey: \(\) => chatTextSelectionContextKey\(\)[\s\S]*?\}\);/, "the coordinator must be initialized once against #chat with the transcript context key");
191
191
  assert.doesNotMatch(renderer, /^\s*import\s/m, "the transcript renderer must stay dependency-free");
192
192
  assert.match(renderer, /export function createTranscriptRenderer\(/, "the coordinator must be the module's exported factory");
@@ -95,9 +95,9 @@ assert.match(css, /\.composer-intercom-tag:hover,[\s\S]*\.composer-intercom-tag:
95
95
  assert.match(css, /\.extension-dialog\.intercom-conversation-dialog \{[\s\S]*width: min\(76rem,[\s\S]*height: min\(54rem,/, "the viewer should use a large in-app modal");
96
96
  assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.composer-intercom-tag \{ min-height: 44px;[\s\S]*\.extension-dialog\.intercom-conversation-dialog[\s\S]*width: calc\(100vw - 0\.7rem\)/, "tags and the dialog should remain reachable on narrow and coarse-pointer layouts");
97
97
 
98
- assert.match(html, /\/styles\.css\?v=137/, "the stylesheet URL should advance for the bounded conversation tags");
99
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the guarded app URL should advance for current browser wiring");
100
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "the PWA cache identity should advance with browser assets");
98
+ assert.match(html, /\/styles\.css\?v=142/, "the stylesheet URL should advance for the bounded conversation tags");
99
+ assert.match(html, /data-app-src="\/app\.js\?v=172"/, "the guarded app URL should advance for current browser wiring");
100
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "the PWA cache identity should advance with browser assets");
101
101
 
102
102
  assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
103
103
  assert.match(technical, /## Agent conversation viewer[\s\S]*Attachments, tool calls and results, thinking, stdout\/stderr, filesystem paths, raw session records/i, "the advanced guide should document privacy exclusions");
@@ -22,8 +22,8 @@ function sourceBetween(startMarker, endMarker, label) {
22
22
 
23
23
  assert.match(
24
24
  html,
25
- /id="mainOutputLoading" class="main-output-loading" role="status" aria-live="polite" aria-atomic="true" aria-controls="chat" hidden>[\s\S]*?main-output-loading-spinner[\s\S]*?Loading agent output…[\s\S]*?<div id="chat" class="chat" aria-live="polite" aria-busy="false">/,
26
- "the main output should own an inline, accessible loading status before the transcript",
25
+ /class="main-output-surface">[\s\S]*?id="mainOutputLoading" class="main-output-loading" role="status" aria-live="polite" aria-atomic="true" aria-controls="chat" hidden>[\s\S]*?main-output-loading-spinner[\s\S]*?Loading agent output…[\s\S]*?<div id="chat" class="chat" aria-live="polite" aria-busy="false">/,
26
+ "the main output surface should own an accessible loading status over the transcript",
27
27
  );
28
28
  assert.doesNotMatch(html, /<dialog[^>]+id="mainOutputLoading"/, "loading feedback must not use a popup dialog");
29
29
  assert.match(app, /mainOutputLoading: \$\("#mainOutputLoading"\)/, "the browser should bind the inline status element");
@@ -42,17 +42,19 @@ assert.match(refreshMessages, /const loadingRequest = beginMainOutputLoading\(ta
42
42
  assert.match(refreshMessages, /finally \{\s*finishMainOutputLoading\(loadingRequest\);\s*\}/, "success, failure, and stale responses should all clear their request token");
43
43
  assert.match(app, /activeTabId = nextTabId;\s*renderMainOutputLoading\(\);/, "tab changes should immediately reconcile stale and current request visibility");
44
44
 
45
- assert.match(css, /\.main-output-loading\[hidden\] \{ display: none !important; \}/, "hidden loading feedback should not consume layout space");
46
- assert.match(css, /\.main-output-loading \{[\s\S]*?pointer-events: none;[\s\S]*?font-size: var\(--text-xs\)/, "the inline status should remain compact and non-blocking");
45
+ assert.match(css, /\.main-output-loading\[hidden\] \{ display: none !important; \}/, "hidden loading feedback should not render");
46
+ assert.match(css, /\.main-output-surface \{[\s\S]*?position: relative;[\s\S]*?flex: 1 1 auto;[\s\S]*?min-height: 0;/, "the transcript and loading status should share one stable layout surface");
47
+ assert.match(css, /\.main-output-loading \{[\s\S]*?position: absolute;[\s\S]*?left: 50%;[\s\S]*?transform: translateX\(-50%\);[\s\S]*?pointer-events: none;/, "the loading status should overlay the transcript without changing its layout");
48
+ assert.match(css, /\.main-output-loading \{[\s\S]*?font-size: var\(--text-xs\)/, "the loading status should remain compact");
47
49
  assert.match(css, /\.main-output-loading-spinner \{[\s\S]*?animation: main-output-loading-spin 780ms linear infinite/, "the status should include a visible spinner animation");
48
50
  assert.match(css, /@keyframes main-output-loading-spin/, "the spinner should have a local animation contract");
49
51
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)[\s\S]*?animation-duration: 1ms !important;[\s\S]*?animation-iteration-count: 1 !important;/, "the existing reduced-motion policy should stop repeated spinner motion");
50
- assert.match(css, /body\.terminal-tabs-left \.main-output-loading,[\s\S]*?body\.terminal-tabs-left \.chat \{ grid-row: 4; \}/, "sidebar tab placement should keep the status inside the transcript grid row");
51
- assert.match(css, /body\.subagent-terminal-active \.main-output-loading,/, "main-output loading feedback should stay hidden in the dedicated subagent view");
52
+ assert.match(css, /body\.terminal-tabs-left \.main-output-surface \{ grid-row: 4; \}/, "sidebar tab placement should keep the stable output surface in the transcript grid row");
53
+ assert.match(css, /body\.subagent-terminal-active \.main-output-surface,/, "the main output surface should stay hidden in the dedicated subagent view");
52
54
 
53
- assert.match(html, /styles\.css\?v=137/, "the stylesheet cache query should advance");
54
- assert.match(html, /app\.js\?v=166/, "the app cache query should advance");
55
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "the PWA cache identity should advance with browser assets");
55
+ assert.match(html, /styles\.css\?v=142/, "the stylesheet cache query should advance");
56
+ assert.match(html, /app\.js\?v=172/, "the app cache query should advance");
57
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "the PWA cache identity should advance with browser assets");
56
58
  assert.match(readme, /Loading agent output/, "user documentation should describe the visible loading feedback");
57
59
  assert.match(development, /main output loading/i, "developer documentation should preserve the request-ownership contract");
58
60
 
@@ -16,9 +16,9 @@ assert.match(app, /import \{ installMiddleButtonDragScroll \} from "\.\/middle-b
16
16
  assert.match(app, /installMiddleButtonDragScroll\(\{[\s\S]*onDirection: \(\{ target, offsetY \}\)[\s\S]*noteChatUserScrollIntent\(\{ type: "middle-drag", deltaY: offsetY \}\)/, "chat auto-scroll direction should feed the existing follow/pause intent state");
17
17
  assert.match(app, /event\?\.type === "middle-drag"\) return event\.deltaY > 0;/, "moving below the press point should be recognized as intent to read later chat output");
18
18
  assert.match(css, /body\.middle-button-auto-scrolling,[\s\S]*cursor: all-scroll !important;[\s\S]*user-select: none !important;/, "active automatic scrolling should expose a directional-scroll affordance and suppress accidental selection");
19
- assert.match(html, /styles\.css\?v=137/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=166/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
19
+ assert.match(html, /styles\.css\?v=142/, "changed drag-scroll styles should advance the stylesheet revision");
20
+ assert.match(html, /app\.js\?v=172/, "changed drag-scroll wiring should advance the app revision");
21
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
22
22
  assert.match(JSON.parse(packageJson).scripts.check, /node --check public\/middle-button-drag-scroll\.mjs/, "the package check should parse the startup-critical controller module");
23
23
 
24
24
  console.log("middle-button-drag-scroll-static.test.mjs passed");
@@ -47,9 +47,9 @@ assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-nav[\s\S]*?widt
47
47
  assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-surface[\s\S]*?width: min\(30rem, 72vw\)/, "tablet inspector must be a bounded right-side sheet");
48
48
  assert.match(css, /html\[data-tablet-shell="v2"\] \.file-viewer-pane[\s\S]*?position: fixed[\s\S]*?inset: 0/, "tablet files must default to full-screen replacement");
49
49
  assert.match(css, /and \(pointer: coarse\)[\s\S]*?min-height: 44px/, "coarse tablet pointers must retain the 44px target floor");
50
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "continuity/tablet assets need a coherent cache identity");
51
- assert.match(html, /styles\.css\?v=137/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=166/, "continuity app logic must have a coherent HTML revision");
50
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "continuity/tablet assets need a coherent cache identity");
51
+ assert.match(html, /styles\.css\?v=142/, "tablet CSS must have a coherent HTML revision");
52
+ assert.match(html, /app\.js\?v=172/, "continuity app logic must have a coherent HTML revision");
53
53
  assert.match(technical, /tabletShell=v2[\s\S]*tabletShell=legacy/, "technical reference should document tablet preview and rollback");
54
54
 
55
55
  console.log("mobile-continuity-tablet-static.test.mjs passed");
@@ -37,9 +37,9 @@ assert.match(pkg.scripts.check, /node --check public\/transcript-renderer\.mjs/,
37
37
  assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server must serve typed startup modules from the public asset boundary");
38
38
  assert.match(serviceWorker, /"\/mobile-shell-state\.mjs"/, "the PWA shell must cache the new startup module");
39
39
  assert.match(serviceWorker, /"\/transcript-renderer\.mjs"/, "the PWA shell must cache the transcript startup module");
40
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "the cache identity must change with the startup graph");
41
- assert.match(html, /styles\.css\?v=137/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=166/, "the app revision must change with continuity/tablet wiring");
40
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "the cache identity must change with the startup graph");
41
+ assert.match(html, /styles\.css\?v=142/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
+ assert.match(html, /app\.js\?v=172/, "the app revision must change with continuity/tablet wiring");
43
43
  assert.match(serviceWorker, /const APP_SHELL_NETWORK_TIMEOUT_MS = 8_000;[\s\S]*?event\.waitUntil\([\s\S]*?cache\.put\(request, response\.clone\(\)\)[\s\S]*?return networkResponse;/, "runtime cache writes must extend the event lifetime without blocking bounded network responses");
44
44
  assert.match(serviceWorker, /MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1"/, "the service worker must use a versioned active-client navigation message");
45
45
  assert.match(serviceWorker, /client\.postMessage\(\{ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target \}\)/, "existing clients must receive only a validated target message");
@@ -60,6 +60,6 @@ assert.match(css, /data-mobile-presentation="essential"/, "Essential presentatio
60
60
  assert.match(css, /html\[data-mobile-shell="v2"\] body\.mobile-keyboard-open \.widget-area,[\s\S]*?\.composer-actions-button \{ display: block !important; \}/, "v2 keyboard mode must keep run widgets and the actions entry available");
61
61
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)/, "reduced-motion behavior is required");
62
62
  assert.match(css, /@media \(forced-colors: active\)/, "forced-color affordances are required");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");
@@ -310,6 +310,22 @@ assert.equal(
310
310
  "side-panel section panels should be hidden by default",
311
311
  );
312
312
  assert.match(html, /id="jumpToLatestButton"/, "chat should expose a jump-to-latest control for non-forced streaming");
313
+ assert.match(
314
+ html,
315
+ /<div class="main-output-surface">[\s\S]*?<div id="chat"[\s\S]*?<\/div>\s*<button id="jumpToLatestButton"[\s\S]*?<\/button>\s*<\/div>\s*<div id="runIndicatorHost"/,
316
+ "jump-to-latest should overlay the output surface above the separate run indicator",
317
+ );
318
+ assert.match(
319
+ css,
320
+ /\.jump-to-latest-button \{[\s\S]*?position: absolute;[\s\S]*?z-index: 14;[\s\S]*?bottom: 0\.75rem;[\s\S]*?left: 50%;[\s\S]*?transform: translateX\(-50%\);/,
321
+ "jump-to-latest should stay centered in the top overlay layer without taking a layout row",
322
+ );
323
+ assert.match(
324
+ css,
325
+ /\.jump-to-latest-button:hover \{[\s\S]*?transform: translateX\(-50%\) translateY\(-1px\);[\s\S]*?\.jump-to-latest-button:active \{[\s\S]*?transform: translateX\(-50%\) translateY\(0\);/,
326
+ "jump-to-latest hover and press feedback should preserve horizontal centering",
327
+ );
328
+ assert.doesNotMatch(css, /terminal-tabs-left \.jump-to-latest-button \{ grid-row:/, "sidebar terminal layout should not assign the overlay its own row");
313
329
  assert.match(html, /id="stickyUserPromptButton"/, "chat should expose a fixed last-user-prompt jump control");
314
330
  assert.match(html, /id="feedbackTray"/, "chat should expose a queued action-feedback tray");
315
331
  assert.match(html, /id="sendFeedbackButton"/, "action feedback should be submittable after the agent finishes");
@@ -1269,7 +1285,7 @@ const clearFinishedContext = {
1269
1285
  async api(path, options) { clearFinishedCalls.push({ path, options }); },
1270
1286
  async refreshSubagents() { clearFinishedRefreshes += 1; },
1271
1287
  scheduleRefreshSubagents() {},
1272
- addEvent(message, level) { clearFinishedEvents.push({ message, level }); },
1288
+ addEvent(message, level, options = {}) { clearFinishedEvents.push({ message, level, options }); },
1273
1289
  };
1274
1290
  vm.runInNewContext(`${app.slice(clearFinishedSourceStart, clearFinishedSourceEnd)}\nthis.runClearFinishedSubagentRuns = clearFinishedSubagentRuns;`, clearFinishedContext);
1275
1291
  await clearFinishedContext.runClearFinishedSubagentRuns();
@@ -1280,10 +1296,73 @@ assert.deepEqual(JSON.parse(JSON.stringify(clearFinishedCalls)), [
1280
1296
  ], "clear-finished should call the existing dismiss endpoint only for visible terminal ordinary runs");
1281
1297
  assert.equal(clearFinishedRefreshes, 1, "clear-finished should refresh the overview once after all dismissals");
1282
1298
  assert.equal(clearFinishedContext.subagentsClearingFinished, false, "clear-finished should always release its in-flight guard");
1283
- assert.deepEqual(clearFinishedEvents, [{ message: "cleared 3 finished subagent runs", level: "info" }]);
1299
+ assert.deepEqual(clearFinishedEvents, [{ message: "cleared 3 finished subagent runs", level: "info", options: {} }]);
1284
1300
  clearFinishedContext.latestSubagents = { tabs: [{ tabId: "tab-c", runs: [{ id: "done-c", status: "done", source: "async" }] }] };
1285
1301
  await clearFinishedContext.runClearFinishedSubagentRuns({ automatic: true });
1286
- assert.deepEqual(clearFinishedEvents.at(-1), { message: "auto-cleared 1 finished subagent run", level: "info" }, "automatic clearing should identify its action without changing terminal-run selection semantics");
1302
+ assert.deepEqual(JSON.parse(JSON.stringify(clearFinishedEvents.at(-1))), {
1303
+ message: "auto-cleared",
1304
+ level: "info",
1305
+ options: {
1306
+ aggregateKey: "subagent-auto-clear",
1307
+ aggregateIncrement: 1,
1308
+ aggregateSingular: "finished subagent run",
1309
+ aggregatePlural: "finished subagent runs",
1310
+ },
1311
+ }, "automatic clearing should use one keyed event whose cleared-run counter can accumulate");
1312
+ const addEventSource = appFunctionSource("addEvent", "closeEventTreeContextMenu");
1313
+ assert.match(addEventSource, /eventAggregateKey === stableAggregateKey[\s\S]*eventAggregateCount[\s\S]*priorAggregate\?\.remove\(\)[\s\S]*eventLog\.prepend\(line\)/, "keyed events should replace their prior row, retain a cumulative count, and return to the top of the log");
1314
+ assert.match(addEventSource, /aggregateCount === 1 \? aggregateSingular : aggregatePlural/, "aggregate rows should keep singular and plural summaries accurate");
1315
+ const aggregateEventLog = {
1316
+ children: [],
1317
+ prepend(node) {
1318
+ node.parent = this;
1319
+ this.children.unshift(node);
1320
+ },
1321
+ get lastElementChild() { return this.children.at(-1) || null; },
1322
+ };
1323
+ function aggregateEventNode(_tag, className = "", text = "") {
1324
+ return {
1325
+ className,
1326
+ dataset: {},
1327
+ children: [],
1328
+ attributes: {},
1329
+ textContent: text,
1330
+ classList: { contains: (value) => className.split(/\s+/).includes(value) },
1331
+ append(...children) {
1332
+ this.children.push(...children);
1333
+ this.textContent += children.map((child) => child?.textContent || "").join("");
1334
+ },
1335
+ setAttribute(name, value) { this.attributes[name] = String(value); },
1336
+ addEventListener() {},
1337
+ remove() {
1338
+ if (!this.parent) return;
1339
+ this.parent.children = this.parent.children.filter((child) => child !== this);
1340
+ this.parent = null;
1341
+ },
1342
+ };
1343
+ }
1344
+ const aggregateEventContext = {
1345
+ elements: { eventLog: aggregateEventLog },
1346
+ make: aggregateEventNode,
1347
+ applyEventFilter() {},
1348
+ jumpToChatEvent() {},
1349
+ showNoticeToast() {},
1350
+ noteUnreadEvent() {},
1351
+ };
1352
+ vm.runInNewContext(`${addEventSource}\nthis.runAddEvent = addEvent;`, aggregateEventContext);
1353
+ const aggregateOptions = {
1354
+ aggregateKey: "subagent-auto-clear",
1355
+ aggregateIncrement: 1,
1356
+ aggregateSingular: "finished subagent run",
1357
+ aggregatePlural: "finished subagent runs",
1358
+ };
1359
+ aggregateEventContext.runAddEvent("auto-cleared", "info", aggregateOptions);
1360
+ aggregateEventContext.runAddEvent("unrelated event", "info");
1361
+ aggregateEventContext.runAddEvent("auto-cleared", "info", { ...aggregateOptions, aggregateIncrement: 2 });
1362
+ assert.equal(aggregateEventLog.children.length, 2, "repeated keyed events should occupy one row alongside unrelated events");
1363
+ assert.equal(aggregateEventLog.children[0].dataset.eventAggregateCount, "3", "the keyed row should accumulate the supplied run counts");
1364
+ assert.equal(aggregateEventLog.children[0].children[0].children[1].textContent, "auto-cleared 3 finished subagent runs", "the keyed row should show its current cumulative count");
1365
+ assert.equal(aggregateEventLog.children[1].children[0].children[1].textContent, "unrelated event", "updating a keyed row should not remove unrelated history");
1287
1366
  assert.match(app, /function materializeRetainedSubagentTerminalViews\(\)[\s\S]*subagentOverviewGroups\(\)[\s\S]*restoreKey = `\$\{tab\.tabId\}\\u0000\$\{tab\.sessionFile[\s\S]*tab\.displayRuns[\s\S]*\["queued", "running", "stale"\]\.includes\(subagentAgentStatus\(run\)\)[\s\S]*ensureSubagentTerminalView/, "terminal mode should materialize only ungated restored retained agent views once per parent session identity without touching overlay mode");
1288
1367
  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");
1289
1368
  assert.match(app, /function subagentLaunchSlotThinkingForModel\(model\)[\s\S]*modelThinkingLevels/, "launch-slot thinking choices should come from the selected model metadata");
@@ -1759,7 +1838,8 @@ assert.match(app, /if \(!isOptionalFeatureDetected\("todoProgressWidget"\)\) ret
1759
1838
  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");
1760
1839
  assert.match(app, /case "webui_tab_reloaded":[\s\S]*resetOptionalFeatureAvailability\(\)/, "optional feature state should reset when the RPC tab reloads resources");
1761
1840
  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");
1762
- assert.match(app, /if \(!isOptionalFeatureEnabled\("gitWorkflow"\)\)/, "guided git workflow should guard on enabled /git-staged-msg feature");
1841
+ assert.match(app, /function guidedGitPromptCompanionAvailable\(tabId\)[\s\S]*hasLoadedRpcCommand\("git-staged-msg", \{ tabId \}\)/, "guided Git must guard the full browser workflow on the originating tab's prompt companion");
1842
+ assert.match(app, /function launchGuidedGitWorkflow\(tabId = activeTabId\)[\s\S]*resolveAvailableCommandName\("git-guided-workflow", \{ tabId, rpcOnly: true \}\)/, "guided Git visible entry points should prefer the tab-local extension command");
1763
1843
  assert.doesNotMatch(html, /gitWorkflowProcessSelect/, "guided git workflow should not expose process selection as a dropdown");
1764
1844
  assert.match(app, /const GIT_WORKFLOW_PROCESSES = \[[\s\S]*value: "stage", label: "Stage"[\s\S]*value: "message", label: "Message"[\s\S]*value: "commit", label: "Commit"[\s\S]*value: "push", label: "Push"/, "guided git workflow should define Stage/Message/Commit/Push process buttons");
1765
1845
  assert.match(app, /function selectGitWorkflowProcess\(processValue, tabId = gitWorkflowActionTabId\(\)\)[\s\S]*process === "commit"[\s\S]*loadGitWorkflowMessage\(\{ requireFresh: false, runId, tabId \}\)/, "guided git workflow process buttons should jump to Commit by loading current generated message files");
@@ -2362,6 +2442,7 @@ assert.match(extension, /if \(openTabSources\.length > 0\) return mergeRestorabl
2362
2442
  assert.match(extension, /return mergeRestorableTabsFromStatusSources\(\[statusData\?\.restorableTabs, existing\.restorableTabs\], options\)/, "launcher should use restorableTabs only as a legacy fallback");
2363
2443
  assert.match(extension, /env\.PI_WEBUI_RESTORE_FILE = \(await createRestoreFile\(agentDir, restoreTabs\)\)\.file/, "launcher should pass restorable tabs through a private read-once file");
2364
2444
  assert.match(extension, /pi\.registerCommand\("webui-start"/, "extension should expose the canonical /webui-start command");
2445
+ assert.match(extension, /const child = spawn\(nodeExecutable, args, \{/, "/webui-start should use Node instead of treating a standalone Pi executable as a JavaScript runtime");
2365
2446
  assert.match(extension, /pi\.registerCommand\("webui-tree-navigate"/, "extension should expose the internal Web UI tree navigation command");
2366
2447
  assert.match(extension, /ctx\.navigateTree\(payload\.entryId/, "internal Web UI tree command should call the native session tree navigation API");
2367
2448
  assert.doesNotMatch(extension, /pi\.registerCommand\("start-webui"/, "extension should not expose the older /start-webui alias");
@@ -68,7 +68,7 @@ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server
68
68
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
69
69
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
70
70
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
71
- assert.match(serviceWorker, /pi-webui-pwa-v132/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v139/, "the PWA cache name must change with browser wiring updates");
72
72
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
73
73
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
74
74
 
@@ -271,8 +271,8 @@ assert.match(
271
271
 
272
272
  // --- Coherent browser asset revisions --------------------------------------
273
273
 
274
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=137/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the boot loader should request the updated app module revision");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "changed browser assets should advance the PWA cache identity");
275
+ assert.match(html, /styles\.css\?v=142/, "the page should request the updated layout stylesheet revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=172"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -16,11 +16,11 @@ const resizeEnd = app.indexOf("\nfunction updateComposerModeButtons", resizeStar
16
16
  assert.ok(resizeStart >= 0 && resizeEnd > resizeStart, "resizePromptInput should remain inspectable");
17
17
  const resizePromptInput = app.slice(resizeStart, resizeEnd);
18
18
 
19
- assert.match(css, /#promptInput \{[\s\S]*max-height: min\(25vh, 10rem\);[\s\S]*overflow-y: auto;[\s\S]*overscroll-behavior-y: contain;/, "the prompt should retain bounded growth with native vertical scrolling as its CSS fallback");
20
- assert.match(resizePromptInput, /input\.style\.height = "auto";[\s\S]*Math\.min\(input\.scrollHeight, maxHeight\)[\s\S]*input\.style\.overflowY = "auto";/, "every auto-resize pass should preserve vertical scrolling after the height cap is reached or growth stalls");
21
- assert.doesNotMatch(resizePromptInput, /overflowY[^\n]+"hidden"/, "auto-resizing must not disable the prompt's vertical overflow fallback");
22
- assert.match(html, /styles\.css\?v=137/, "the page should request the scroll-enabled stylesheet revision");
23
- assert.match(html, /app\.js\?v=166/, "the page should request the scroll-enabled app revision");
24
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "the PWA cache identity should advance with the prompt scroll assets");
19
+ assert.match(css, /#promptInput \{[\s\S]*--prompt-input-block-chrome: calc\(1\.8rem \+ 2px\);[\s\S]*max-height: calc\(6lh \+ var\(--prompt-input-block-chrome\)\);[\s\S]*overflow-y: auto;[\s\S]*overscroll-behavior-y: contain;/, "the prompt should show six complete lines before native vertical scrolling begins");
20
+ assert.match(resizePromptInput, /input\.style\.height = "auto";[\s\S]*borderTopWidth[\s\S]*borderBottomWidth[\s\S]*naturalHeight = input\.scrollHeight \+ borderBlock[\s\S]*isCapped \? "auto" : "hidden"/, "auto-resizing should include the textarea borders and enable vertical scrolling only after the six-line cap");
21
+ assert.doesNotMatch(resizePromptInput, /input\.style\.overflowY = "auto";/, "auto-resizing must not force a scrollbar below the six-line cap");
22
+ assert.match(html, /styles\.css\?v=142/, "the page should request the six-line prompt stylesheet revision");
23
+ assert.match(html, /app\.js\?v=172/, "the page should request the current app revision");
24
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "the PWA cache identity should advance with the prompt scroll assets");
25
25
 
26
26
  console.log("prompt-input-vertical-scroll-static.test.mjs passed");
@@ -24,7 +24,7 @@ const requestIndex = sendSource.indexOf('await api("/api/prompt"');
24
24
  assert.ok(clearIndex >= 0, "sendPrompt should clear the captured input-backed draft");
25
25
  assert.ok(routingIndex >= 0 && clearIndex < routingIndex, "the submitted prompt should be cleared before routing progress starts");
26
26
  assert.ok(requestIndex >= 0 && clearIndex < requestIndex, "the submitted prompt should be cleared before the prompt request starts");
27
- assert.match(sendSource, /catch \(error\) \{\n\s+restorePromptInputAfterRoutingError\(inputMessage,/, "a routing failure should restore the sent input when no replacement draft exists");
27
+ assert.match(sendSource, /catch \(error\) \{\n\s+(?:if \(guidedGitPermitGranted\) guidedGitLaunchPermits\.clearTab\(targetTabId\);\n\s+)?restorePromptInputAfterRoutingError\(inputMessage,/, "a routing failure should revoke any activation permit and restore the sent input when no replacement draft exists");
28
28
 
29
29
  const successStart = sendSource.indexOf("applyResponseTab(response);");
30
30
  const catchStart = sendSource.indexOf("} catch (error)", successStart);
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
504
504
  assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
505
505
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
506
506
 
507
- assert.match(html, /styles\.css\?v=137/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=166/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "questionnaire public assets need a coherent PWA cache revision");
507
+ assert.match(html, /styles\.css\?v=142/, "questionnaire CSS needs the current stylesheet revision");
508
+ assert.match(html, /app\.js\?v=172/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
57
57
  assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
58
58
  assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
59
59
  assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
60
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "native-control assets should advance the cache identity");
60
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "native-control assets should advance the cache identity");
61
61
  assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
62
- assert.match(html, /styles\.css\?v=137/, "the changed stylesheet should have a new revision");
63
- assert.match(html, /app\.js\?v=166/, "the changed app module should have a new revision");
62
+ assert.match(html, /styles\.css\?v=142/, "the changed stylesheet should have a new revision");
63
+ assert.match(html, /app\.js\?v=172/, "the changed app module should have a new revision");
64
64
 
65
65
  // --- Browser state behavior -------------------------------------------------
66
66
 
@@ -27,8 +27,8 @@ assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHe
27
27
  assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
28
28
  assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
29
29
  assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
30
- assert.match(html, /styles\.css\?v=137/, "removing section resize styles should advance the stylesheet revision");
31
- assert.match(html, /app\.js\?v=166/, "removing section resize behavior should advance the app revision");
32
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "removing browser assets should advance the PWA cache identity");
30
+ assert.match(html, /styles\.css\?v=142/, "removing section resize styles should advance the stylesheet revision");
31
+ assert.match(html, /app\.js\?v=172/, "removing section resize behavior should advance the app revision");
32
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "removing browser assets should advance the PWA cache identity");
33
33
 
34
34
  console.log("side-panel-section-height-removal-static.test.mjs passed");
@@ -28,7 +28,7 @@ assert.match(app, /const SUBAGENT_ASYNC_WIDGET_KEY = "subagent-async"[\s\S]*case
28
28
  assert.match(app, /for \(const \[key, value\] of widgets\)[\s\S]*if \(key === SUBAGENT_ASYNC_WIDGET_KEY\) continue;/, "stale cached async-status widgets should remain hidden defensively");
29
29
  assert.match(css, /\.subagent-source-badge[\s\S]*text-overflow: ellipsis[\s\S]*@media \(max-width: 720px\)/, "source badges should remain compact and responsive");
30
30
  assert.match(html, /Managed and registered Pi agent runs[\s\S]*External agents/, "help should explain managed, registered, and external groups");
31
- assert.match(html, /styles\.css\?v=137[\s\S]*app\.js\?v=166/, "browser assets should use the current subagent-observability revisions");
32
- assert.match(worker, /pi-webui-pwa-v132/, "PWA cache identity should advance with subagent widget suppression");
31
+ assert.match(html, /styles\.css\?v=142[\s\S]*app\.js\?v=172/, "browser assets should use the current subagent-observability revisions");
32
+ assert.match(worker, /pi-webui-pwa-v139/, "PWA cache identity should advance with subagent widget suppression");
33
33
 
34
34
  console.log("subagent-observability-static.test.mjs passed");
@@ -60,9 +60,9 @@ assert.match(css, /\.markdown-code \.syntax-comment \{[^}]*font-style: italic;/,
60
60
 
61
61
  // --- Offline/PWA startup closure and coherent revisions ---
62
62
  assert.match(serviceWorker, /"\/syntax-highlight\.mjs",/, "the eagerly imported tokenizer must be part of the offline app shell");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "adding a startup module should advance the PWA cache identity");
64
- assert.match(html, /styles\.css\?v=137/, "new token styles should advance the stylesheet revision");
65
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "new renderer wiring should advance the app module revision");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "adding a startup module should advance the PWA cache identity");
64
+ assert.match(html, /styles\.css\?v=142/, "new token styles should advance the stylesheet revision");
65
+ assert.match(html, /data-app-src="\/app\.js\?v=172"/, "new renderer wiring should advance the app module revision");
66
66
  assert.match(pkg, /node --check public\/syntax-highlight\.mjs/, "the package check should syntax-check the startup-critical tokenizer");
67
67
 
68
68
  const appShell = serviceWorker.slice(serviceWorker.indexOf("const APP_SHELL"), serviceWorker.indexOf("];", serviceWorker.indexOf("const APP_SHELL")));
@@ -19,5 +19,7 @@ assert.match(app, /const closingTerminalTabIds = new Set\(\)/, "the frontend sho
19
19
  assert.match(schedule, /closingTerminalTabIds\.has\(tabContext\.tabId\)/, "continuity refreshes should skip tabs that are intentionally closing");
20
20
  assert.match(schedule, /if \(!isCurrentTabContext\(tabContext\) \|\| closingTerminalTabIds\.has\(tabContext\.tabId\)\) return;[\s\S]*continuity refresh failed/, "an in-flight refresh rejected by intentional shutdown should not produce a false error");
21
21
  assert.match(closeTabs, /for \(const id of targetIds\) closingTerminalTabIds\.add\(id\);[\s\S]*finally \{\s*for \(const id of targetIds\) closingTerminalTabIds\.delete\(id\);/, "the close lifecycle should mark every target before the request and always clear the marker afterward");
22
+ assert.match(closeTabs, /addEvent\(`closed \$\{closedIds\.length \|\| targetTabs\.length\} terminal \$\{closedIds\.length === 1 \? "tab" : "tabs"\}`, "info"\)/, "successful terminal tab closure should be recorded as information rather than a warning");
23
+ assert.doesNotMatch(closeTabs, /addEvent\(`closed [^`]+`, "warn"\)/, "successful terminal tab closure should never be classified as a warning");
22
24
 
23
25
  console.log("tab-close-continuity-static.test.mjs passed");
@@ -34,7 +34,7 @@ assert.match(html, /role="alert" hidden>[\s\S]*Replace this exact target\?/, "ov
34
34
 
35
35
  assert.match(app, /from "\.\/theme-contract\.mjs"/, "frontend should consume the shared browser-safe theme contract");
36
36
  assert.match(serviceWorker, /"\/theme-contract\.mjs"/, "the PWA app shell should cache the startup-critical theme contract");
37
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
37
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v139"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
38
38
  assert.match(pkg, /node --check public\/theme-contract\.mjs/, "the package check should syntax-check the startup-critical theme contract");
39
39
  assert.match(app, /function themeDraftFromCatalog\(theme, name = theme\?\.name\)[\s\S]*colors: cloneThemeDraft\(theme\?\.colors \|\| \{\}\)/, "catalog metadata should be projected into a schema-only editable draft");
40
40
  assert.match(app, /for \(const \{ name, label \} of group\.tokens\)/, "visual controls should render from the exact shared token inventory");
@@ -0,0 +1,79 @@
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 { groupConsecutiveThinkingItems, groupConsecutiveThinkingMessages } from "../public/transcript-renderer.mjs";
6
+
7
+ function thinking(content, timestamp) {
8
+ return { role: "thinking", title: "thinking", content, thinking: content, timestamp };
9
+ }
10
+
11
+ const first = thinking("inspect the renderer", "2026-08-23T13:00:00Z");
12
+ assert.equal(groupConsecutiveThinkingMessages([first])[0], first, "a single thinking message should retain its identity");
13
+
14
+ const grouped = groupConsecutiveThinkingMessages([
15
+ first,
16
+ thinking("confirm the display order", "2026-08-23T13:00:01Z"),
17
+ thinking("verify the final state", "2026-08-23T13:00:02Z"),
18
+ ]);
19
+ assert.equal(grouped.length, 1, "adjacent thinking messages should render as one transcript message");
20
+ assert.equal(grouped[0].thinking, "inspect the renderer\n\nconfirm the display order\n\nverify the final state", "grouped thinking should remain chronological and readable");
21
+ assert.equal(grouped[0].content, grouped[0].thinking, "copy and rendering paths should receive the same grouped text");
22
+ assert.equal(grouped[0].timestamp, first.timestamp, "the grouped message should keep the first block's stable metadata");
23
+ assert.equal(grouped[0].thinkingSegmentCount, 3, "the aggregate should retain its source segment count");
24
+
25
+ const toolCall = { role: "toolCall", toolName: "read", content: {} };
26
+ const separated = groupConsecutiveThinkingMessages([
27
+ thinking("before the tool"),
28
+ toolCall,
29
+ thinking("after the tool"),
30
+ thinking("still after the tool"),
31
+ ]);
32
+ assert.deepEqual(separated.map((message) => message.role), ["thinking", "toolCall", "thinking"], "non-thinking transcript messages should remain hard grouping boundaries");
33
+ assert.equal(separated[0].thinking, "before the tool");
34
+ assert.equal(separated[2].thinking, "after the tool\n\nstill after the tool");
35
+
36
+ const nonTextThinking = { role: "thinking", content: { provider: "opaque" } };
37
+ assert.deepEqual(
38
+ groupConsecutiveThinkingMessages([thinking("before"), nonTextThinking, thinking("after")]),
39
+ [thinking("before"), nonTextThinking, thinking("after")],
40
+ "non-text thinking payloads should not be stringified or merged",
41
+ );
42
+
43
+ function assistantItem(index, content) {
44
+ return {
45
+ message: { role: "assistant", timestamp: `2026-08-23T13:00:0${index}Z`, content: [{ type: "thinking", thinking: content }] },
46
+ messageIndex: index,
47
+ order: index,
48
+ };
49
+ }
50
+
51
+ const separateAssistantMessages = [
52
+ assistantItem(1, "first assistant message"),
53
+ assistantItem(2, "second assistant message"),
54
+ assistantItem(3, "third assistant message"),
55
+ ];
56
+ const groupedItems = groupConsecutiveThinkingItems(separateAssistantMessages, (item) => {
57
+ const part = item.message.content[0];
58
+ return thinking(part.thinking, item.message.timestamp);
59
+ });
60
+ assert.equal(groupedItems.length, 1, "thinking-only assistant messages should collapse after transcript ordering");
61
+ assert.equal(groupedItems[0].message.thinking, "first assistant message\n\nsecond assistant message\n\nthird assistant message");
62
+ assert.equal(groupedItems[0].thinkingGroupSourceCount, 3, "the transcript aggregate should retain its source item count");
63
+
64
+ const finalOutputItem = { message: { role: "assistant", content: [{ type: "text", text: "answer" }] }, messageIndex: 4, order: 4 };
65
+ const itemBoundary = groupConsecutiveThinkingItems(
66
+ [assistantItem(1, "before"), finalOutputItem, assistantItem(2, "after")],
67
+ (item) => item.message.content[0]?.type === "thinking" ? thinking(item.message.content[0].thinking) : null,
68
+ );
69
+ assert.deepEqual(itemBoundary.map((item) => item.message.role), ["assistant", "assistant", "assistant"], "a rendered final-output item should keep separate thinking runs apart");
70
+
71
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
72
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
73
+ assert.match(app, /import \{ createTranscriptRenderer, groupConsecutiveThinkingItems, groupConsecutiveThinkingMessages \} from "\.\/transcript-renderer\.mjs";/, "the browser should import both grouping helpers from the transcript renderer");
74
+ assert.match(app, /function assistantDisplayMessages\(message\)[\s\S]*?const displayMessages = assistantDisplayMessagesWithoutFailure[\s\S]*?return groupConsecutiveThinkingMessages\(failure \? \[\.\.\.displayMessages, failure\] : displayMessages\);/, "assistant display projection should group adjacent thinking inside one assistant message");
75
+ assert.match(app, /function transcriptItemThinkingMessage\(item\)[\s\S]*?assistantDisplayMessages\(message\)[\s\S]*?displayMessages\.length !== 1[\s\S]*?role !== "thinking"/, "only transcript items that render as one thinking card should be eligible for cross-message grouping");
76
+ assert.match(app, /function groupConsecutiveThinkingTranscriptItems\(items\)[\s\S]*?groupConsecutiveThinkingItems\(items, transcriptItemThinkingMessage\)[\s\S]*?transcriptKey: `thinking-group:\$\{sourceKey\}`/, "cross-message groups should receive one stable transcript identity");
77
+ assert.match(app, /const groupedThinking = compactOutputActive\(\) \? ordered : groupConsecutiveThinkingTranscriptItems\(ordered\);[\s\S]*?groupWorkflowStatusTranscriptItems\(groupedThinking, toolResults\)/, "normal transcripts should group thinking after complete chronological ordering");
78
+
79
+ console.log("thinking-block-grouping.test.mjs passed");