@firstpick/pi-package-webui 0.9.2 → 0.9.3

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 (77) hide show
  1. package/README.md +13 -7
  2. package/bin/pi-webui.mjs +256 -39
  3. package/index.ts +266 -1
  4. package/lib/git-workflow-preferences.mjs +8 -25
  5. package/lib/intercom-conversations.mjs +491 -0
  6. package/lib/intercom-transcript-filter.mjs +99 -0
  7. package/lib/resource-selection.mjs +140 -0
  8. package/package.json +2 -2
  9. package/public/app.js +1025 -115
  10. package/public/index.html +31 -6
  11. package/public/service-worker.js +2 -1
  12. package/public/stream-output-controller.mjs +15 -0
  13. package/public/styles.css +394 -0
  14. package/public/syntax-highlight.mjs +622 -0
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/interaction-continuity.spec.mjs +34 -0
  17. package/tests/browser/intercom-conversation-viewer.spec.mjs +355 -0
  18. package/tests/browser/persistent-ui-layout.spec.mjs +61 -0
  19. package/tests/browser/resource-profiles.spec.mjs +200 -0
  20. package/tests/browser/subagent-observability.spec.mjs +29 -0
  21. package/tests/codex-fast-mode-static.test.mjs +7 -6
  22. package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
  23. package/tests/common-options-submenus-markup-static.test.mjs +1 -0
  24. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  25. package/tests/composer-skill-tag-layout.test.mjs +32 -2
  26. package/tests/control-deck-component-updates-static.test.mjs +4 -0
  27. package/tests/controls-layout-static.test.mjs +3 -3
  28. package/tests/fast-mode-client-static.test.mjs +2 -2
  29. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  30. package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
  31. package/tests/file-viewer-image-static.test.mjs +69 -0
  32. package/tests/fixtures/fake-pi.mjs +105 -6
  33. package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
  34. package/tests/git-panel-file-preview-static.test.mjs +5 -5
  35. package/tests/git-panel-live-updates-static.test.mjs +3 -3
  36. package/tests/git-workflow-preferences.test.mjs +4 -4
  37. package/tests/http-endpoints-harness.test.mjs +124 -2
  38. package/tests/intercom-conversation-viewer-static.test.mjs +105 -0
  39. package/tests/intercom-conversations-http.test.mjs +252 -0
  40. package/tests/intercom-conversations.test.mjs +374 -0
  41. package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
  42. package/tests/intercom-tag-layout-static.test.mjs +46 -0
  43. package/tests/intercom-transcript-filter.test.mjs +98 -0
  44. package/tests/main-output-loading-static.test.mjs +59 -0
  45. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  46. package/tests/mobile-compact-layout.test.mjs +2 -3
  47. package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
  48. package/tests/mobile-foundation-static.test.mjs +3 -3
  49. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  50. package/tests/mobile-static.test.mjs +63 -39
  51. package/tests/native-parity.test.mjs +8 -7
  52. package/tests/open-issue-wizard-static.test.mjs +1 -1
  53. package/tests/optional-feature-migration-frontend.test.mjs +5 -5
  54. package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
  55. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  56. package/tests/questionnaire-dialog.test.mjs +3 -3
  57. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  58. package/tests/resource-defaults-helper.test.mjs +60 -6
  59. package/tests/resource-selection.test.mjs +114 -0
  60. package/tests/resource-tui-extension.test.mjs +23 -0
  61. package/tests/session-sampling-ui-static.test.mjs +3 -3
  62. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  63. package/tests/stream-output-controller.test.mjs +8 -0
  64. package/tests/stream-output-isolation-static.test.mjs +2 -2
  65. package/tests/streaming-ui-coupling.test.mjs +5 -0
  66. package/tests/subagent-gate-visibility.test.mjs +1 -1
  67. package/tests/subagent-launch-slots.test.mjs +1 -1
  68. package/tests/subagent-observability-static.test.mjs +3 -3
  69. package/tests/subagent-reliability-integration.test.mjs +23 -1
  70. package/tests/subagent-workflow-section-static.test.mjs +67 -0
  71. package/tests/subagents-helper.test.mjs +204 -1
  72. package/tests/syntax-highlight.test.mjs +235 -0
  73. package/tests/syntax-highlighting-static.test.mjs +84 -0
  74. package/tests/theme-customizer-static.test.mjs +5 -5
  75. package/tests/thinking-format-parser.test.mjs +64 -0
  76. package/tests/webui-settings-locking.test.mjs +1 -1
  77. package/webui-rpc-helper.mjs +291 -69
@@ -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=115/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=132/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v94";[\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=123/, "changed drag-scroll styles should advance the stylesheet revision");
20
+ assert.match(html, /app\.js\?v=146/, "changed drag-scroll wiring should advance the app revision");
21
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108";[\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");
@@ -4,11 +4,10 @@ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
- const [html, css, app, readme, technical] = await Promise.all([
7
+ const [html, css, app, technical] = await Promise.all([
8
8
  readFile(join(root, "public", "index.html"), "utf8"),
9
9
  readFile(join(root, "public", "styles.css"), "utf8"),
10
10
  readFile(join(root, "public", "app.js"), "utf8"),
11
- readFile(join(root, "README.md"), "utf8"),
12
11
  readFile(join(root, "TECHNICAL.md"), "utf8"),
13
12
  ]);
14
13
 
@@ -54,7 +53,7 @@ assert.match(app, /function isSidePanelSectionReorderingEnabled\(\) \{\n\s+retur
54
53
  assert.match(css, /\.side-panel-edit-button \{\n\s+display:\s*none;[\s\S]*?\.side-panel-section-toggle\[data-side-panel-section-toggle\] \{\n\s+cursor:\s*pointer;\n\s+touch-action:\s*manipulation;[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\] \{[\s\S]*?cursor:\s*grab;[\s\S]*?touch-action:\s*none;[\s\S]*?@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\) \{[\s\S]*?\.side-panel-edit-button \{ display:\s*inline-flex;/, "desktop should hide Edit while mobile restores it and switches section headers to drag capture in Edit mode");
55
54
  assert.match(css, /body\.mobile-composer-disclosure\.mobile-keyboard-open \.composer-row \{[\s\S]*?repeat\(4,[\s\S]*?body\.mobile-composer-disclosure\.mobile-keyboard-open \.composer-actions-button,[\s\S]*?display:\s*none !important/, "keyboard-open mode should retain primary controls and suppress secondary chrome");
56
55
 
57
- assert.match(readme, /On a phone, tap the current terminal name to open full-screen terminal navigation[\s\S]*Grouped terminals use their title as a dropdown[\s\S]*tap \*\*More\*\* to open[\s\S]*in a full-screen overlay[\s\S]*Git footer \*\*Details\*\* opens full-screen with refresh inside and a top `−` button[\s\S]*Hover-only tooltips stay hidden on touch controls[\s\S]*\*\*Control Deck\*\*[\s\S]*tap \*\*Edit\*\*[\s\S]*tap \*\*Done\*\*/, "README should explain the full-screen mobile paths and explicit Control Deck editing");
56
+ assert.match(technical, /On a phone, tap the current terminal name to open full-screen terminal navigation[\s\S]*Grouped terminals use their title as a dropdown[\s\S]*Tap \*\*More\*\*[\s\S]*Git footer \*\*Details\*\* opens full-screen[\s\S]*Hover-only tooltips stay hidden[\s\S]*tap \*\*Edit\*\*[\s\S]*tap \*\*Done\*\*/, "technical reference should explain the full-screen mobile paths and explicit Control Deck editing");
58
57
  assert.match(technical, /## Mobile layout[\s\S]*open full-screen terminal navigation[\s\S]*regular or subagent terminal-group title is a dropdown button[\s\S]*Git footer \*\*Details\*\* opens as a full-screen legacy-mobile overlay[\s\S]*Tap \*\*More\*\* to open[\s\S]*accessible top-right `−` control[\s\S]*Control Deck section reordering is always enabled on desktop[\s\S]*`Alt\+ArrowUp` \/ `Alt\+ArrowDown`[\s\S]*Mobile keeps the transient \*\*Edit\*\* \/ \*\*Done\*\* mode[\s\S]*Touch pointers do not schedule hover-only tooltips[\s\S]*Tablet layout, desktop tab placement/, "technical reference should document always-on desktop reordering and transient mobile Edit mode");
59
58
 
60
59
  console.log("mobile compact layout contracts passed");
@@ -4,12 +4,12 @@ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
- const [app, html, css, serviceWorker, readme] = await Promise.all([
7
+ const [app, html, css, serviceWorker, technical] = await Promise.all([
8
8
  readFile(join(root, "public", "app.js"), "utf8"),
9
9
  readFile(join(root, "public", "index.html"), "utf8"),
10
10
  readFile(join(root, "public", "styles.css"), "utf8"),
11
11
  readFile(join(root, "public", "service-worker.js"), "utf8"),
12
- readFile(join(root, "README.md"), "utf8"),
12
+ readFile(join(root, "TECHNICAL.md"), "utf8"),
13
13
  ]);
14
14
 
15
15
  assert.match(app, /MOBILE_CONTINUITY_STORAGE_KEY = "pi-webui-mobile-continuity-v1"/, "continuity state must be browser-scoped and versioned");
@@ -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-v94"/, "continuity/tablet assets need a coherent cache identity");
51
- assert.match(html, /styles\.css\?v=115/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=132/, "continuity app logic must have a coherent HTML revision");
53
- assert.match(readme, /tabletShell=v2/, "tablet preview and rollback must be documented");
50
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "continuity/tablet assets need a coherent cache identity");
51
+ assert.match(html, /styles\.css\?v=123/, "tablet CSS must have a coherent HTML revision");
52
+ assert.match(html, /app\.js\?v=146/, "continuity app logic must have a coherent HTML revision");
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-v94"/, "the cache identity must change with the startup graph");
41
- assert.match(html, /styles\.css\?v=115/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=132/, "the app revision must change with continuity/tablet wiring");
40
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "the cache identity must change with the startup graph");
41
+ assert.match(html, /styles\.css\?v=123/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
+ assert.match(html, /app\.js\?v=146/, "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-v94"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");
@@ -5,7 +5,7 @@ import { dirname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
7
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
- const [pkgRaw, html, css, app, server, extension, readme, startScript, manifestRaw, serviceWorker, appleIcon, icon192, icon512, matrixBackground, mochaBackground] = await Promise.all([
8
+ const [pkgRaw, html, css, app, server, extension, readme, technical, development, startScript, manifestRaw, serviceWorker, appleIcon, icon192, icon512, matrixBackground, mochaBackground] = await Promise.all([
9
9
  readFile(join(root, "package.json"), "utf8"),
10
10
  readFile(join(root, "public", "index.html"), "utf8"),
11
11
  readFile(join(root, "public", "styles.css"), "utf8"),
@@ -13,6 +13,8 @@ const [pkgRaw, html, css, app, server, extension, readme, startScript, manifestR
13
13
  readFile(join(root, "bin", "pi-webui.mjs"), "utf8").then((value) => value.replace(/\r\n/g, "\n")),
14
14
  readFile(join(root, "index.ts"), "utf8"),
15
15
  readFile(join(root, "README.md"), "utf8"),
16
+ readFile(join(root, "TECHNICAL.md"), "utf8"),
17
+ readFile(join(root, "DEVELOPMENT.md"), "utf8"),
16
18
  readFile(join(root, "dev", "scripts", "start-webui.sh"), "utf8"),
17
19
  readFile(join(root, "public", "manifest.webmanifest"), "utf8"),
18
20
  readFile(join(root, "public", "service-worker.js"), "utf8"),
@@ -194,13 +196,13 @@ assert.match(css, /\.git-side-panel-repository[\s\S]*\.git-side-panel-file[\s\S]
194
196
  assert.match(server, /async function readGitPanel\(cwd\)[\s\S]*GIT_PANEL_HISTORY_LIMIT[\s\S]*"status", "--porcelain=v1", "-z"[\s\S]*"--numstat", "-z"/, "server should build compact bounded local Git snapshots without full file contents");
195
197
  assert.match(server, /async function readGitCommit\(cwd, requestedHash\)[\s\S]*\^\[a-f0-9\][\s\S]*"show", "--format="/, "commit inspection should require a full hash and use a bounded read-only Git show");
196
198
  assert.match(server, /"\/api\/git-changes\/stage-all"[\s\S]*stageAllGitChanges[\s\S]*"\/api\/git-changes\/unstage-all"[\s\S]*unstageAllGitChanges/, "server should expose repository-wide stage and unstage mutations");
197
- assert.match(readme, /side-panel \*\*Git\*\* section[\s\S]*five-minute cache window[\s\S]*confirmed discard\/delete actions[\s\S]*latest 30 commits/, "README should document Git panel grouping, refresh, actions, and history behavior");
199
+ assert.match(technical, /side-panel \*\*Git\*\* section[\s\S]*five-minute cache window[\s\S]*confirmed discard\/delete actions[\s\S]*latest 30 commits/, "technical reference should document Git panel grouping, refresh, actions, and history behavior");
198
200
  assert.match(html, /id="optionalFeaturesBox"/, "side panel should expose optional feature status and controls");
199
201
  assert.match(html, /class="optional-features-description[\s\S]*href="https:\/\/github\.com\/Firstp1ck\/pi-coding-agent-forge\/issues\/new"[\s\S]*open a GitHub issue/, "optional features should link users to GitHub issues for additional feature requests");
200
202
  assert.doesNotMatch(html, /id="btwOverlayDialog"/, "/btw should not use a blocking modal overlay");
201
203
  assert.match(html, /id="codexUsageBox"/, "side panel should expose Codex subscription usage status");
202
204
  assert.match(html, /data-side-panel-section="codex-usage"/, "Codex usage should live in a collapsible side-panel section");
203
- 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");
205
+ 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]*Managed and registered Pi agent runs appear here[\s\S]*External agents[\s\S]*id="subagentsBox"/, "side panel should explain managed and registered agent visibility with a live count");
204
206
  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");
205
207
  assert.match(html, /class="subagents-status-row"[\s\S]*id="subagentsAutoClearButton"[^>]*aria-pressed="false"[^>]*>Auto-Clear<\/button>[\s\S]*id="subagentsStatus"[\s\S]*id="subagentsClearFinishedButton"[^>]*disabled[^>]*>Clear finished<\/button>/, "Subagents should expose selectable auto-clear and manual clear controls beside its live status");
206
208
  const subagentCancelDialogHtml = html.match(/<dialog id="subagentCancelDialog"[\s\S]*?<\/dialog>/)?.[0] || "";
@@ -265,7 +267,7 @@ assert.deepEqual(Object.fromEntries(Object.entries(telemetryCardElements).map(([
265
267
  }, "terminal telemetry cards should render only normalized telemetry values");
266
268
  assert.match(css, /\.subagent-terminal-card-list\s*\{[\s\S]*?display:\s*grid;[\s\S]*?grid-template-columns:\s*repeat\(auto-fit,\s*minmax\(/, "telemetry cards should wrap responsively through a grid rather than require a fixed row");
267
269
  assert.match(css, /@media\s*\([^)]*max-width[^)]*\)\s*\{[\s\S]*?\.subagent-terminal-card-list\s*\{[\s\S]*?grid-template-columns:\s*minmax\(0,\s*1fr\)/, "narrow viewports should collapse telemetry cards without horizontal overflow");
268
- assert.match(readme, /exactly six telemetry cards: PI, measured token speed, context, model, effort, and input\/output tokens from a bounded recent session scan; unavailable or legacy evidence remains `—` or `unknown` rather than an estimate/, "README should document each subagent telemetry card, bounded scan scope, and honest unknown behavior");
270
+ assert.match(technical, /exactly six telemetry cards: PI, measured token speed, context, model, effort, and input\/output tokens from a bounded recent session scan[\s\S]*Unavailable or legacy evidence remains `—` or `unknown` rather than being estimated/, "technical reference should document each subagent telemetry card, bounded scan scope, and honest unknown behavior");
269
271
  assert.doesNotMatch(html, /id="subagentOverlayDialog"/, "subagent output should not use a blocking modal dialog");
270
272
  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");
271
273
  assert.match(html, /data-side-panel-section="sampling"[\s\S]*class="side-panel-section-label">Sampling parameters<\/span>[\s\S]*id="samplingParametersSupport"[\s\S]*id="samplingParametersControls"[\s\S]*id="samplingParametersPreserved"[\s\S]*id="applySamplingParametersButton"[\s\S]*id="resetSamplingParametersButton"[\s\S]*id="samplingParametersStatus"/, "Sampling parameters should be a labelled side-panel section with native controls, hidden-key preservation status, apply/reset actions, and live status");
@@ -1075,7 +1077,7 @@ assert.match(server, /async function closeNetworkAccess\(\)/, "server should exp
1075
1077
  assert.match(server, /url\.pathname === "\/api\/network\/close" && req\.method === "POST"/, "server should route network close requests");
1076
1078
  assert.match(server, /server\.closeAllConnections\?\.\(\)/, "network rebind should force-close long-lived clients so close-to-localhost can complete");
1077
1079
  assert.match(server, /connection: "close"/, "network rebind API responses should not hold keep-alive sockets open");
1078
- assert.match(readme, /toggles to "Close for network"/, "README should document the close-network toggle");
1080
+ assert.match(technical, /toggles to "Close for network"/, "technical reference should document the close-network toggle");
1079
1081
  assert.match(app, /window\.visualViewport/, "app should listen to VisualViewport for keyboard/viewport updates");
1080
1082
  assert.match(html, /<textarea id="promptInput"[^>]*autofocus/, "prompt composer should autofocus for new Web UI/app launches");
1081
1083
  assert.match(app, /function syncMobileChatToBottomForInput\(\)/, "mobile input focus should force the output view to the latest message");
@@ -1147,7 +1149,8 @@ assert.match(app, /async function refreshQuestionnaireFeatureAvailability[\s\S]*
1147
1149
  assert.match(app, /async function setToolManagedOptionalFeatureEnabled\(feature, enabled\)[\s\S]*\/api\/tools\?scope=session[\s\S]*enabledTools[\s\S]*scope: "session"[\s\S]*\/api\/tools/, "the questionnaire row toggle should update the active session tool allowlist while preserving other tool states");
1148
1150
  assert.match(app, /detected && feature\.manageWith === "tools"[\s\S]*action\.textContent = enabled \? "Disable" : "Enable"[\s\S]*setToolManagedOptionalFeatureEnabled/, "loaded questionnaire access should expose a dedicated enable or disable action");
1149
1151
  assert.match(app, /if \(detected && feature\.setup\)[\s\S]*"optional-feature-action setup", "Setup"[\s\S]*openOptionalFeatureSetup/, "detected configurable optional features should expose a separate Setup action");
1150
- assert.match(app, /case "tools": return openNativeToolsSelector\(\)/, "Native questionnaires Setup should open the browser-native Tools Setup dialog");
1152
+ assert.match(app, /case "skills": return openNativeSkillsSelector\(\)/, "TUI Skills command Setup should open the browser-native Skills Setup dialog");
1153
+ assert.match(app, /case "tools": return openNativeToolsSelector\(\)/, "TUI Tools command Setup should open the browser-native Tools Setup dialog");
1151
1154
  assert.match(app, /function setSidePanelSectionCollapsed\(record, collapsed/, "side panel sections should have explicit collapse/expand behavior");
1152
1155
  assert.match(
1153
1156
  app,
@@ -1166,9 +1169,29 @@ assert.match(
1166
1169
  );
1167
1170
  assert.match(app, /function renderCodexUsage\(\)/, "frontend should render Codex usage buckets in the side panel");
1168
1171
  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");
1169
- assert.match(app, /function renderSubagents\(\)[\s\S]*latestSubagents\?\.runningAgents[\s\S]*subagentCountBadge\.textContent = String\(totalAgents\)/, "the subagent count badge should count running agents once while retry-gated attempts render only inside their gate");
1172
+ assert.match(app, /function renderSubagents\(\)[\s\S]*activeTabs\.reduce\(\(count, tab\) => count \+ Number\(tab\.runningAgents \|\| 0\), 0\)[\s\S]*subagentCountBadge\.textContent = String\(totalAgents\)/, "the subagent count badge should derive visible agent totals without counting workflow containers or retry-gated attempts twice");
1173
+ const workflowControllerSource = appFunctionSource("subagentIsWorkflowController", "subagentCapabilities");
1174
+ const workflowRenderSource = appFunctionSource("renderSubagentWorkflow", "renderSubagentAgent");
1170
1175
  const compactSubagentAgentSource = appFunctionSource("renderSubagentAgent", "renderSubagentRun");
1171
1176
  const compactSubagentRunSource = appFunctionSource("renderSubagentRun", "subagentGateStatusLabel");
1177
+ assert.match(workflowControllerSource, /name \|\| ""[\s\S]*launcher === "pi-subagents"[\s\S]*function subagentRunAgents[\s\S]*function subagentRunAgentCounts/, "pi-subagents workflow controllers should be recognized separately from model-powered agents and excluded from agent counts");
1178
+ const workflowCountContext = {
1179
+ subagentAgentStatus(run, agent) { return String(agent?.status || run?.status || "running").toLowerCase(); },
1180
+ };
1181
+ vm.runInNewContext(`${workflowControllerSource}\nthis.isWorkflowController = subagentIsWorkflowController; this.workflowAgents = subagentRunAgents; this.workflowCounts = subagentRunAgentCounts;`, workflowCountContext);
1182
+ const syntheticWorkflowRun = {
1183
+ launcher: "pi-subagents",
1184
+ status: "running",
1185
+ agents: [
1186
+ { id: "run:workflow", name: "workflow", status: "running" },
1187
+ { id: "run:worker", name: "worker", status: "running", model: "openai-codex/gpt-5.6-sol", thinking: "high" },
1188
+ ],
1189
+ };
1190
+ assert.equal(workflowCountContext.isWorkflowController(syntheticWorkflowRun, syntheticWorkflowRun.agents[0]), true, "the model-less pi-subagents workflow row should be treated as the workflow controller");
1191
+ assert.deepEqual(JSON.parse(JSON.stringify(workflowCountContext.workflowAgents(syntheticWorkflowRun).map((agent) => agent.name))), ["worker"], "only actual child agents should remain in the workflow agent list");
1192
+ assert.deepEqual(JSON.parse(JSON.stringify(workflowCountContext.workflowCounts([syntheticWorkflowRun]))), { total: 1, running: 1, stale: 0 }, "workflow controllers should be count-neutral while their children retain lifecycle counts");
1193
+ assert.equal(workflowCountContext.isWorkflowController(syntheticWorkflowRun, { name: "workflow", launcher: "pi-subagents", model: "provider/real-model", thinking: "high" }), false, "a real model-powered agent named workflow must remain an agent row");
1194
+ assert.match(workflowRenderSource, /const status = subagentWorkflowPresentationStatus\(run, agents\);[\s\S]*make\("details", `subagent-workflow[\s\S]*details\.open = !collapsedSubagentWorkflowRunKeys\.has\(key\)[\s\S]*make\("summary", "subagent-workflow-header"\)[\s\S]*renderSubagentAgent\(tab, entry\.run, entry\.agent\)/, "workflow controllers should render as stateful native disclosure headers using the aggregate lifecycle while preserving each child run");
1172
1195
  assert.match(compactSubagentAgentSource, /const \[model, thinking\] = subagentExecutionValues\(agent\)[\s\S]*identity\.append\([\s\S]*"subagent-agent-name", name[\s\S]*"subagent-agent-inline-meta", `· \$\{model\} · \$\{thinking\}`[\s\S]*row\.append\(dot, identity, open\)/, "side-panel agent rows should show type, provider\/model, and thinking effort on one compact line");
1173
1196
  assert.doesNotMatch(compactSubagentAgentSource, /subagent-agent-meta|subagentExecutionFacts|subagentSourceLabel|subagentRunElapsed|currentTool/, "side-panel agent rows should leave all other execution metadata to the selected subagent view");
1174
1197
  assert.doesNotMatch(compactSubagentRunSource, /subagent-run-(?:header|title|meta|state)|`Run \$\{/, "side-panel run groups should not repeat IDs, metadata headers, or state badges");
@@ -1200,7 +1223,8 @@ const closeSubagentTerminalGroupSource = app.slice(closeSubagentTerminalGroupSta
1200
1223
  assert.match(closeSubagentTerminalGroupSource, /subagentTerminalViews\.delete\(view\.id\)[\s\S]*renderTabs\(\)/, "closing a workspace subagent group should remove its view tabs as one UI operation");
1201
1224
  assert.doesNotMatch(closeSubagentTerminalGroupSource, /cancel|\/api\/subagents/, "closing a workspace subagent group must not stop its child runs");
1202
1225
  assert.match(css, /\.subagent-tab-title \{[\s\S]*container-type: inline-size;[\s\S]*flex: 1 1 0;[\s\S]*min-width: 0;[\s\S]*\.subagent-tab-title strong \{[\s\S]*font-size: clamp\(0\.64rem, calc\(0\.5rem \+ 0\.65cqi\), 0\.78rem\);[\s\S]*\.subagent-tab-count \{[\s\S]*flex: 0 0 auto;[\s\S]*white-space: nowrap;/, "subagent titles should scale with their available inline width while summary badges stay fixed and text can still truncate");
1203
- assert.match(css, /\.subagent-agent-list \{[\s\S]*gap: 0\.16rem;[\s\S]*\.subagent-agent-row \{[\s\S]*min-height: 1\.75rem;[\s\S]*background: transparent;[\s\S]*\.subagent-agent-identity \{[\s\S]*display: flex;[\s\S]*white-space: nowrap;[\s\S]*\.subagent-agent-inline-meta \{[\s\S]*text-overflow: ellipsis;[\s\S]*white-space: nowrap;[\s\S]*\.subagent-run \{[\s\S]*grid-template-columns: minmax\(0, 1fr\) auto;[\s\S]*border: 0;/, "the inline subagent monitor should keep type, model, and effort in compact flat rows without overflow");
1226
+ assert.match(css, /\.subagent-agent-list \{[\s\S]*gap: 0\.16rem;[\s\S]*\.subagent-agent-row \{[\s\S]*min-height: 1\.75rem;[\s\S]*background: transparent;[\s\S]*\.subagent-agent-identity \{[\s\S]*display: flex;[\s\S]*white-space: nowrap;[\s\S]*\.subagent-agent-inline-meta \{[\s\S]*text-overflow: ellipsis;[\s\S]*white-space: nowrap;[\s\S]*\.subagent-run \{[\s\S]*grid-template-columns: minmax\(0, 1fr\) auto;[\s\S]*border: 0;/, "the inline subagent monitor should keep type, model, and effort in compact rows without overflow");
1227
+ assert.match(css, /\.subagent-workflow \{[\s\S]*\.subagent-workflow-header \{[\s\S]*list-style: none;[\s\S]*\.subagent-workflow:not\(\[open\]\)[\s\S]*\.subagent-workflow-agents \{[\s\S]*border-left:/, "workflow disclosures should have a distinct collapsible header and visually nested child-agent section");
1204
1228
  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");
1205
1229
  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");
1206
1230
  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");
@@ -1600,10 +1624,10 @@ assert.match(app, /id: "btwCommand"[\s\S]*?@firstpick\/pi-extension-btw/, "optio
1600
1624
  assert.match(app, /BTW_OUTPUT_WIDGET_KEY = "btw:output"[\s\S]*function renderBtwOutputWidget/, "Web UI should render structured /btw output widgets");
1601
1625
  assert.match(app, /if \(key\.startsWith\("btw:"\)\) return "btwCommand"/, "extension widget routing should associate /btw widgets with the optional feature");
1602
1626
  assert.match(app, /id: "safetyGuard"[\s\S]*?@firstpick\/pi-extension-safety-guard/, "optional features should include the safety guard companion");
1603
- assert.match(app, /id: "tuiSkillsCommand"[\s\S]*?@firstpick\/pi-extension-setup-skills/, "optional features should include the TUI skills command companion");
1604
- assert.match(app, /id: "tuiToolsCommand"[\s\S]*?@firstpick\/pi-extension-tools/, "optional features should include the TUI tools command companion");
1627
+ assert.match(app, /id: "tuiSkillsCommand"[\s\S]*?@firstpick\/pi-extension-setup-skills[\s\S]*?setup: "skills"/, "optional features should expose Skills Setup from the TUI skills command companion");
1628
+ assert.match(app, /id: "tuiToolsCommand"[\s\S]*?@firstpick\/pi-extension-tools[\s\S]*?setup: "tools"/, "optional features should expose Tools Setup from the TUI tools command companion");
1605
1629
  assert.match(app, /id: "remoteWebui"[\s\S]*?@firstpick\/pi-package-remote-webui/, "optional features should include the Remote WebUI companion");
1606
- assert.match(app, /id: "questionnaire"[\s\S]*?@firstpick\/pi-package-questionnaire[\s\S]*?capabilityLabel: "questionnaire tool in \/tools"[\s\S]*?manageWith: "tools"[\s\S]*?setup: "tools"/, "optional features should include the native questionnaire package with session access control and a Tools Setup entry point");
1630
+ assert.match(app, /id: "questionnaire"[\s\S]*?@firstpick\/pi-package-questionnaire[\s\S]*?capabilityLabel: "questionnaire tool in \/tools"[\s\S]*?manageWith: "tools"/, "optional features should include the native questionnaire package with direct session access control");
1607
1631
  assert.match(app, /id: "naturalConversation"[\s\S]*?@firstpick\/pi-package-natural-conversation[\s\S]*?capabilityLabel: "\/talk, \/voice, or \/conversation"/, "optional features should include the capability-detected Natural Conversation shell");
1608
1632
  assert.match(app, /NATURAL_CONVERSATION_COMMAND_NAMES = \["talk", "voice", "conversation"\]/, "frontend should detect Natural Conversation only from RPC-visible command aliases");
1609
1633
  assert.match(app, /const conversationModeByTab = new Map\(\)/, "frontend should track Natural Conversation state per terminal tab");
@@ -2062,7 +2086,7 @@ assert.match(app, /\/api\/skills\?scope=\$\{encodeURIComponent\(scope\)\}[\s\S]*
2062
2086
  assert.match(server, /writeWebuiSettings\(\{ resourceDefaults: \{ tools: \{ enabledTools \} \} \}\)[\s\S]*writeWebuiSettings\(\{ resourceDefaults: \{ skills: \{ enabledSkills \} \} \}\)/, "server should persist global tool and skill defaults in the shared Web UI settings file");
2063
2087
  assert.match(helper, /const saved = lastBranchConfig\(ctx, TOOLS_CONFIG_TYPE\)\?\.enabledTools;[\s\S]*const selected = Array\.isArray\(saved\) \? saved : inherited/, "session tool entries should take precedence over global defaults");
2064
2088
  assert.match(helper, /const saved = lastBranchConfig\(ctx, SKILLS_CONFIG_TYPE\)\?\.disabledSkills;[\s\S]*if \(Array\.isArray\(saved\)\)/, "session skill entries should take precedence over global defaults");
2065
- assert.match(readme, /Session only[\s\S]*Global default/, "README should document resource selector scopes");
2089
+ assert.match(technical, /Session only[\s\S]*Global default/, "technical reference should document resource selector scopes");
2066
2090
  assert.match(app, /const tags = Array\.isArray\(item\.tags\)[\s\S]*?item\.badge, \.\.\.tags/, "native selector filtering should include extra resource tags");
2067
2091
  assert.match(app, /publishMenuContainer\?\.addEventListener\("pointerenter", \(\) => \{[\s\S]*?setPublishMenuOpen\(true\);[\s\S]*?\}\)/, "Publish menu should expand on hover");
2068
2092
  assert.match(app, /publishMenuContainer\?\.addEventListener\("pointerleave", \(\) => setPublishMenuOpen\(false\)\)/, "Publish menu should collapse after hover leaves");
@@ -2168,7 +2192,7 @@ assert.match(app, /WARNING: \$\{activeAgentTabs\.length\}[\s\S]*?still running o
2168
2192
  assert.match(app, /elements\.closeAllTabsButton\.addEventListener\("click", \(\) => closeAllTerminalTabs\(\)\)/, "close-all tabs button should be wired in JS");
2169
2193
  assert.match(app, /const groups = tabCwdGroups\(\);[\s\S]*?for \(const group of groups\) \{\n\s+if \(shouldRenderTerminalTabGroup\(group, groups\.length\)\)[\s\S]*?renderTerminalTabGroup\(group, groups\.length\)[\s\S]*?for \(const tab of group\.tabs\) elements\.tabBar\.append\(renderTerminalTab\(tab\)\);/, "terminal tabs should render groups with group count and ungrouped tabs when grouping is skipped");
2170
2194
  assert.match(app, /const subagentGroups = subagentTerminalViewGroups\(\)[\s\S]*renderSubagentTerminalTabGroup\(group\)[\s\S]*renderSubagentTerminalTab\(group\.views\[0\]\)/, "open subagent views should render as first-class virtual tabs, grouped by parent workspace when siblings exist");
2171
- assert.match(readme, /Tracked subagent output[\s\S]*dedicated \*\*Subagent\*\* terminal tab[\s\S]*view-only[\s\S]*close without stopping or interrupting/, "README should document the selectable view-only child terminal behavior");
2195
+ assert.match(technical, /Tracked subagent output[\s\S]*dedicated \*\*Subagent\*\* terminal tab[\s\S]*read-only[\s\S]*does not stop or interrupt/, "technical reference should document the selectable read-only child terminal behavior");
2172
2196
  assert.match(app, /let tabSeenCompletionSerials = new Map\(\)/, "frontend should track which tab completions have been seen");
2173
2197
  assert.match(app, /let activeTabGeneration = 0/, "frontend should version active-tab UI state to reject stale async work");
2174
2198
  assert.match(app, /function isCurrentTabContext\(context\)/, "frontend should identify stale active-tab refresh contexts");
@@ -2439,32 +2463,32 @@ assert.match(server, /function configuredScopedModelPatterns\(cwd = options\.cwd
2439
2463
  assert.match(server, /readJsonFileIfExists\(path\.join\(cwd, "\.pi", "settings\.json"\)\)/, "server should read project-local scoped-model settings from active tab cwd");
2440
2464
  assert.match(server, /resolveScopedModelsFromPatterns\(patterns, response\.data\?\.models/, "server should resolve scoped patterns against available models");
2441
2465
  assert.match(server, /writeFile\(tmpFile[\s\S]*?rename\(tmpFile, storageFile\)/, "server should persist fast picks with an atomic temp-file rename");
2442
- assert.match(readme, /Automatic tab naming from the first prompt/, "README should describe automatic terminal-tab naming");
2443
- assert.match(readme, /Feedback reactions \(`👍`, `👎`, `\?`\) on final assistant output plus tool\/bash action cards/, "README should describe final-output and action feedback reactions");
2444
- assert.match(readme, /POST \/api\/action-feedback\?tab=<tabId>/, "README should document the action-feedback endpoint");
2445
- assert.match(readme, /`@` file\/path references with live suggestions/, "README should describe @ file/path reference autocomplete");
2446
- assert.match(readme, /optional `@firstpick\/pi-extension-bang-command-autocomplete` companion[\s\S]*GET \/api\/bang-suggestions\?tab=<tabId>&query=<command>/, "README should document optional bang-command autocomplete and its endpoint");
2447
- assert.match(readme, /optional `@firstpick\/pi-extension-fish-user-bash` companion/, "README should document optional fish user-bash integration");
2448
- assert.match(readme, /GET \/api\/path-suggestions\?tab=<tabId>&query=<path>/, "README should document the path-suggestions endpoint");
2449
- assert.match(readme, /GET \/api\/optional-features/, "README should document optional feature status endpoint");
2450
- assert.match(readme, /POST \/api\/optional-feature-install/, "README should document optional feature install endpoint");
2451
- assert.match(readme, /POST \/api\/optional-feature-install-batch[\s\S]*bounded allowlisted[\s\S]*sequentially/, "README should document the bounded sequential batch endpoint");
2452
- assert.match(readme, /\*\*Install all\*\*[\s\S]*\*\*Install missing\*\*[\s\S]*missing\/unregistered[\s\S]*one confirmation[\s\S]*continues after failures/, "README should document bulk control scope and partial-failure behavior");
2453
- assert.match(readme, /pi install npm:@firstpick\/pi-extension-stats[\s\S]*Re-running the same `pi install npm:<package>` command is the supported update path/, "README should document separate manual Pi package installation and updates");
2454
- assert.match(readme, /server-persisted fast picks/, "README should describe server-persisted fast picks");
2455
- assert.match(readme, /`\/btw` side-question output widgets with optional context transfer\/live steering, browser notifications when a tab needs an extension UI response, and an optional side-panel toggle for agent-done notifications/, "README should describe /btw, blocked-tab, and agent-done notifications");
2456
- assert.match(readme, /blocked-tab browser notifications, and optional agent-done notifications require browser service-worker\/notification support/, "README should document notification requirements");
2457
- assert.match(readme, /Side-panel theme picker backed by optional `@firstpick\/pi-themes-bundle` themes plus Pi-native project\/global custom themes/, "README should describe bundled and custom theme selection");
2458
- assert.match(readme, /## Optional companion packages/, "README should document optional Web UI companion packages");
2459
- assert.match(readme, /Web UI tabs load enabled resources resolved from normal Pi settings/, "README should document Pi-settings-based optional feature loading");
2460
- assert.match(readme, /legacy\/hoisted package files without either a Pi settings entry or an enabled top-level resource remain installable/i, "README should document migration handling for physically present but unregistered packages");
2461
- assert.match(readme, /excluding the Web UI package itself from re-loading/, "README should document Web UI self-loading duplicate prevention");
2462
- assert.match(readme, /checks loaded Pi capabilities directly through RPC-visible commands, tools, themes, and live widget events/, "README should document capability-based startup checks");
2463
- assert.match(readme, /side panel separately reports physical installation and Pi registration/, "README should document distinct installed and registered optional feature status");
2464
- assert.match(readme, /per-row \*\*Install\*\* or \*\*Update\*\* action[\s\S]*batch has one confirmation[\s\S]*bounded diagnostics/, "README should document per-row and bulk warning/result behavior");
2465
- assert.match(readme, /Natural Conversation Mode shell[\s\S]*\/talk[\s\S]*read-only/, "README should document the optional Natural Conversation WebUI shell");
2466
- assert.match(readme, /\.\/dev\/scripts\/start-webui\.sh --dev --cwd \/path\/to\/project/, "README should document the dev helper launcher");
2467
- assert.match(readme, /register that package with Pi from its absolute local path[\s\S]*resolved from Pi settings rather than the Web UI manifest/, "README should document local companion registration through Pi settings");
2466
+ assert.match(technical, /automatic naming from the first prompt/i, "technical reference should describe automatic terminal-tab naming");
2467
+ assert.match(development, /Feedback reactions \(`👍`, `👎`, `\?`\) on final assistant output plus tool\/bash action cards/, "development guide should describe final-output and action feedback reactions");
2468
+ assert.match(development, /POST \/api\/action-feedback\?tab=<tabId>/, "development guide should document the action-feedback endpoint");
2469
+ assert.match(development, /`@` file\/path references with live suggestions/, "development guide should describe @ file/path reference autocomplete");
2470
+ assert.match(development, /optional `@firstpick\/pi-extension-bang-command-autocomplete` companion[\s\S]*GET \/api\/bang-suggestions\?tab=<tabId>&query=<command>/, "development guide should document optional bang-command autocomplete and its endpoint");
2471
+ assert.match(development, /optional `@firstpick\/pi-extension-fish-user-bash` companion/, "development guide should document optional fish user-bash integration");
2472
+ assert.match(development, /GET \/api\/path-suggestions\?tab=<tabId>&query=<path>/, "development guide should document the path-suggestions endpoint");
2473
+ assert.match(development, /GET \/api\/optional-features/, "development guide should document optional feature status endpoint");
2474
+ assert.match(development, /POST \/api\/optional-feature-install/, "development guide should document optional feature install endpoint");
2475
+ assert.match(development, /POST \/api\/optional-feature-install-batch[\s\S]*bounded allowlisted[\s\S]*sequentially/, "development guide should document the bounded sequential batch endpoint");
2476
+ assert.match(technical, /\*\*Install all\*\*[\s\S]*\*\*Install missing\*\*[\s\S]*missing or unregistered[\s\S]*one confirmation[\s\S]*continue after individual failures/, "technical reference should document bulk control scope and partial-failure behavior");
2477
+ assert.match(technical, /pi install npm:@firstpick\/pi-extension-stats[\s\S]*Re-running the same `pi install npm:<package>` command is the supported update path/, "technical reference should document separate manual Pi package installation and updates");
2478
+ assert.match(development, /server-persisted fast picks/, "development guide should describe server-persisted fast picks");
2479
+ assert.match(development, /`\/btw` side-question output widgets with optional context transfer\/live steering, browser notifications when a tab needs an extension UI response, and an optional side-panel toggle for agent-done notifications/, "development guide should describe /btw, blocked-tab, and agent-done notifications");
2480
+ assert.match(development, /blocked-tab browser notifications, and optional agent-done notifications require browser service-worker\/notification support/, "development guide should document notification requirements");
2481
+ assert.match(development, /Side-panel theme picker backed by optional `@firstpick\/pi-themes-bundle` themes plus Pi-native project\/global custom themes/, "development guide should describe bundled and custom theme selection");
2482
+ assert.match(development, /## Optional companion packages/, "development guide should document optional Web UI companion packages");
2483
+ assert.match(development, /Web UI tabs load enabled resources resolved from normal Pi settings/, "development guide should document Pi-settings-based optional feature loading");
2484
+ assert.match(development, /legacy\/hoisted package files without either a Pi settings entry or an enabled top-level resource remain installable/i, "development guide should document migration handling for physically present but unregistered packages");
2485
+ assert.match(development, /excluding the Web UI package itself from re-loading/, "development guide should document Web UI self-loading duplicate prevention");
2486
+ assert.match(development, /checks loaded Pi capabilities directly through RPC-visible commands, tools, themes, and live widget events/, "development guide should document capability-based startup checks");
2487
+ assert.match(development, /side panel separately reports physical installation and Pi registration/, "development guide should document distinct installed and registered optional feature status");
2488
+ assert.match(development, /per-row \*\*Install\*\* or \*\*Update\*\* action[\s\S]*batch has one confirmation[\s\S]*bounded diagnostics/, "development guide should document per-row and bulk warning/result behavior");
2489
+ assert.match(development, /Natural Conversation Mode shell[\s\S]*\/talk[\s\S]*read-only/, "development guide should document the optional Natural Conversation WebUI shell");
2490
+ assert.match(development, /\.\/dev\/scripts\/start-webui\.sh --dev --cwd \/path\/to\/project/, "development guide should document the dev helper launcher");
2491
+ assert.match(development, /register that package with Pi from its absolute local path[\s\S]*resolved from Pi settings rather than the Web UI manifest/, "development guide should document local companion registration through Pi settings");
2468
2492
  assert.match(startScript, /--dev\)/, "start-webui.sh should accept a --dev flag");
2469
2493
  assert.match(startScript, /local_pi_webui_bin\(\)/, "start-webui.sh should resolve this checkout's local server entrypoint");
2470
2494
  assert.match(startScript, /candidate="\$\(package_root\)\/bin\/pi-webui\.mjs"/, "start-webui.sh should resolve the package-root bin from dev/scripts");
@@ -173,13 +173,14 @@ assert.match(server, /url\.pathname === "\/api\/tools" && req\.method === "GET"/
173
173
  assert.match(server, /url\.pathname === "\/api\/tools" && req\.method === "POST"/, "server should expose POST /api/tools for native /tools updates");
174
174
  assert.match(server, /url\.pathname === "\/api\/skills" && req\.method === "GET"/, "server should expose GET /api/skills for native /skills");
175
175
  assert.match(server, /url\.pathname === "\/api\/skills" && req\.method === "POST"/, "server should expose POST /api/skills for native /skills updates");
176
- assert.match(server, /function requireResourceScope\(value\)[\s\S]*scope !== "session" && scope !== "global"/, "resource APIs should accept only session and global scopes");
177
- assert.match(server, /writeWebuiSettings\(\{ resourceDefaults: \{ tools: \{ enabledTools \} \} \}\)/, "global tool choices should persist in Web UI settings");
178
- assert.match(server, /writeWebuiSettings\(\{ resourceDefaults: \{ skills: \{ enabledSkills \} \} \}\)/, "global skill choices should persist in Web UI settings");
179
- assert.match(app, /function nativeResourceScopeControl\(scope,[\s\S]*Session only[\s\S]*Global default/, "Tools and Skills Setup should expose session/global scope choices");
180
- assert.match(app, /body: \{ enabledTools: \[\.\.\.enabledTools\], scope \}/, "Tools Setup should submit its selected persistence scope");
181
- assert.match(app, /body: \{ enabledSkills: \[\.\.\.enabledSkills\], scope \}/, "Skills Setup should submit its selected persistence scope");
182
- assert.match(app, /Future sessions inherit it; this session is unchanged\./, "global selector feedback should explain precedence");
176
+ assert.match(server, /function requireResourceScope\(value\)[\s\S]*scope !== "session" && scope !== "global" && scope !== "model"/, "resource APIs should accept session, global, and model scopes");
177
+ assert.match(server, /updateWebuiSettings\([\s\S]*resourceDefaults[\s\S]*tools[\s\S]*enabledTools/, "global tool choices should persist through the locked Web UI settings updater");
178
+ assert.match(server, /updateWebuiSettings\([\s\S]*resourceDefaults[\s\S]*skills[\s\S]*enabledSkills/, "global skill choices should persist through the locked Web UI settings updater");
179
+ assert.match(app, /function nativeResourceScopeControl\(scope,[\s\S]*Session only[\s\S]*Global default[\s\S]*Model default/, "Tools and Skills Setup should expose session/global/model scope choices");
180
+ assert.match(app, /const body = \{ enabledTools: \[\.\.\.enabledTools\], scope \};/, "Tools Setup should submit its selected persistence scope");
181
+ assert.match(app, /const body = \{ enabledSkills: \[\.\.\.enabledSkills\], scope \};/, "Skills Setup should submit its selected persistence scope");
182
+ assert.match(app, /Unpinned active tools update immediately; pinned tools are unchanged\./, "global selector feedback should explain live precedence");
183
+ assert.match(app, /aria-pressed/, "resource toggles should expose their enabled state programmatically");
183
184
  assert.match(app, /const HIDDEN_COMMAND_NAMES = new Set\(\["webui-tree-navigate", "webui-helper"\]\)/, "frontend should hide Web UI internal helper commands");
184
185
  assert.match(app, /"scoped-models", "tools", "skills"/, "frontend native selector commands should include /tools and /skills");
185
186
  assert.match(app, /return match \? match\[1\]\.toLowerCase\(\) : ""/, "frontend native slash command matching should be case-insensitive");
@@ -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-v94/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v108/, "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
 
@@ -4,11 +4,11 @@ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
- const [app, html, css, readme] = await Promise.all([
7
+ const [app, html, css, technical] = await Promise.all([
8
8
  readFile(join(root, "public", "app.js"), "utf8"),
9
9
  readFile(join(root, "public", "index.html"), "utf8"),
10
10
  readFile(join(root, "public", "styles.css"), "utf8"),
11
- readFile(join(root, "README.md"), "utf8"),
11
+ readFile(join(root, "TECHNICAL.md"), "utf8"),
12
12
  ]);
13
13
 
14
14
  function sourceBetween(startMarker, endMarker) {
@@ -76,8 +76,8 @@ assert.match(css, /\.optional-feature-migration-surface[\s\S]*\.optional-feature
76
76
  assert.match(css, /\.optional-feature-migration-card:focus-visible/, "focused completion summary should have a visible focus treatment");
77
77
  assert.match(css, /\.optional-feature-migration-card\.phase-degraded[\s\S]*padding-right:[^;]+;[\s\S]*\.optional-feature-migration-dismiss \{[\s\S]*position: absolute;[\s\S]*top:[^;]+;[\s\S]*right:[^;]+;/, "the degraded popup should reserve space for a top-right dismiss button");
78
78
 
79
- assert.match(readme, /read-only startup audit/i, "README should document startup auditing");
80
- assert.match(readme, /--migrate-optional-features[\s\S]*--migration-dry-run/, "README should document explicit unattended migration and dry-run flags");
81
- assert.match(readme, /Retry failed[\s\S]*Copy commands[\s\S]*Recheck/i, "README should document migration troubleshooting actions");
79
+ assert.match(technical, /read-only startup audit/i, "technical reference should document startup auditing");
80
+ assert.match(technical, /--migrate-optional-features[\s\S]*--migration-dry-run/, "technical reference should document explicit unattended migration and dry-run flags");
81
+ assert.match(technical, /Retry failed[\s\S]*Copy commands[\s\S]*Recheck/i, "technical reference should document migration troubleshooting actions");
82
82
 
83
83
  console.log("optional feature migration frontend static tests passed");
@@ -0,0 +1,29 @@
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
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [app, readme, technical] = await Promise.all([
8
+ readFile(join(root, "public", "app.js"), "utf8"),
9
+ readFile(join(root, "README.md"), "utf8"),
10
+ readFile(join(root, "TECHNICAL.md"), "utf8"),
11
+ ]);
12
+
13
+ function optionalFeatureBlock(featureId) {
14
+ const match = app.match(new RegExp(`\\{\\n\\s+id: "${featureId}",[\\s\\S]*?\\n\\s+\\},`));
15
+ assert.ok(match, `optional feature ${featureId} should remain declared`);
16
+ return match[0];
17
+ }
18
+
19
+ assert.match(optionalFeatureBlock("tuiSkillsCommand"), /setup: "skills"/, "TUI Skills command should expose a Setup action");
20
+ assert.match(optionalFeatureBlock("tuiToolsCommand"), /setup: "tools"/, "TUI Tools command should expose a Setup action");
21
+ assert.doesNotMatch(optionalFeatureBlock("questionnaire"), /setup:/, "Native questionnaires should use direct Enable/Disable controls without an unrelated Setup action");
22
+ assert.doesNotMatch(app, /Use Setup to manage session and global tool defaults\./, "tool-managed optional features should not refer users to a removed Setup action");
23
+ assert.match(app, /function optionalFeatureSetupAvailable\(feature\)[\s\S]*?case "skills": return hasLoadedRpcCommand\("skills"\);[\s\S]*?case "tools":/, "resource Setup actions should require their loaded RPC commands");
24
+ assert.match(app, /function openOptionalFeatureSetup\(feature\)[\s\S]*?case "skills": return openNativeSkillsSelector\(\);[\s\S]*?case "tools": return openNativeToolsSelector\(\);/, "resource Setup actions should open the browser-native selectors");
25
+ assert.match(app, /if \(detected && feature\.setup\)[\s\S]*?"optional-feature-action setup", "Setup"[\s\S]*?openOptionalFeatureSetup\(feature\)/, "loaded configurable optional features should render a Setup button");
26
+ assert.match(readme, /TUI Skills command[\s\S]*TUI Tools command[\s\S]*Setup/, "README should identify the Optional features entry points");
27
+ assert.match(technical, /TUI Skills command[\s\S]*TUI Tools command[\s\S]*Skills Setup and Tools Setup/, "technical reference should document both setup targets");
28
+
29
+ console.log("optional-feature-resource-setup-static.test.mjs passed");
@@ -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-v94"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=115/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=132"/, "the boot loader should request the updated app module revision");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "changed browser assets should advance the PWA cache identity");
275
+ assert.match(html, /styles\.css\?v=123/, "the page should request the updated layout stylesheet revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=146"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
504
504
  assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
505
505
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
506
506
 
507
- assert.match(html, /styles\.css\?v=115/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=132/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v94"/, "questionnaire public assets need a coherent PWA cache revision");
507
+ assert.match(html, /styles\.css\?v=123/, "questionnaire CSS needs the current stylesheet revision");
508
+ assert.match(html, /app\.js\?v=146/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -179,7 +179,7 @@ try {
179
179
  const disableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: false } });
180
180
  assert.equal(disableAuth.status, 200);
181
181
  const savedAfterDisable = JSON.parse(await readFile(settingsFile, "utf8"));
182
- assert.equal(savedAfterDisable.version, 7, "Web UI settings should retain the current private settings envelope version");
182
+ assert.equal(savedAfterDisable.version, 8, "Web UI settings should retain the current private settings envelope version");
183
183
  assert.equal(savedAfterDisable.remoteAuthEnabled, false, "disabling Remote PIN auth should persist the off preference");
184
184
  assert.equal(savedAfterDisable.gitWorkflow?.generation?.modelId, "fake-model", "Remote PIN updates should preserve guided Git preferences");
185
185
 
@@ -27,13 +27,18 @@ const previousSettingsFile = process.env.PI_WEBUI_SETTINGS_FILE;
27
27
  process.env.PI_WEBUI_SETTINGS_FILE = settingsFile;
28
28
 
29
29
  try {
30
- await writeFile(settingsFile, `${JSON.stringify({
31
- version: 3,
30
+ const settingsPayload = {
31
+ version: 8,
32
32
  resourceDefaults: {
33
33
  tools: { enabledTools: ["read", "write"] },
34
34
  skills: { enabledSkills: ["skill-a", "skill-c"] },
35
+ modelProfiles: [
36
+ { provider: "provider", modelId: "model-a", tools: { enabledTools: ["bash"] }, skills: { enabledSkills: ["skill-b"] } },
37
+ { provider: "provider", modelId: "model-b", tools: { enabledTools: ["write"] }, skills: { enabledSkills: [] } },
38
+ ],
35
39
  },
36
- }, null, 2)}\n`, "utf8");
40
+ };
41
+ await writeFile(settingsFile, "{ invalid settings\n", "utf8");
37
42
 
38
43
  const extensionHandlers = new Map();
39
44
  const registeredCommands = new Map();
@@ -43,6 +48,7 @@ try {
43
48
  let activeTools = ["read", "bash", "write"];
44
49
  let branchEntries = [];
45
50
  let availableSkills = [];
51
+ let runtimeReady = false;
46
52
 
47
53
  const pi = {
48
54
  events: bus,
@@ -55,15 +61,22 @@ try {
55
61
  getAllTools() {
56
62
  return ["read", "bash", "write"].map((name) => ({ name, description: `${name} tool`, sourceInfo: { source: "builtin" } }));
57
63
  },
58
- getActiveTools() { return [...activeTools]; },
64
+ getActiveTools() {
65
+ assert.equal(runtimeReady, true, "extension action methods must not run while the extension factory is loading");
66
+ return [...activeTools];
67
+ },
59
68
  setActiveTools(names) { activeTools = [...names]; },
60
- appendEntry(customType, data) { appendedEntries.push({ customType, data }); },
69
+ appendEntry(customType, data) {
70
+ appendedEntries.push({ customType, data });
71
+ branchEntries.push({ type: "custom", customType, data });
72
+ },
61
73
  };
62
74
 
63
75
  const ctx = {
64
76
  mode: "rpc",
65
77
  hasUI: true,
66
78
  cwd: root,
79
+ model: { provider: "provider", id: "unconfigured" },
67
80
  sessionManager: {
68
81
  getBranch() { return branchEntries; },
69
82
  },
@@ -79,6 +92,7 @@ try {
79
92
  };
80
93
 
81
94
  webuiRpcHelper(pi);
95
+ runtimeReady = true;
82
96
  const helperCommand = registeredCommands.get("webui-helper");
83
97
  assert.ok(helperCommand?.handler, "resource defaults test requires the hidden helper command");
84
98
 
@@ -93,6 +107,11 @@ try {
93
107
  }
94
108
 
95
109
  for (const handler of extensionHandlers.get("session_start") || []) await handler({ reason: "startup" }, ctx);
110
+ assert.deepEqual(activeTools, ["read", "bash", "write"], "an initial settings-read failure must leave Pi's runtime tools unchanged");
111
+ assert.ok(notifications.some((entry) => /tools and skills remain unchanged/i.test(entry.message)), "initial settings failure should emit a bounded warning");
112
+
113
+ await writeFile(settingsFile, `${JSON.stringify(settingsPayload, null, 2)}\n`, "utf8");
114
+ for (const handler of extensionHandlers.get("session_start") || []) await handler({ reason: "settings-restored" }, ctx);
96
115
  availableSkills = ["skill-a", "skill-b", "skill-c"];
97
116
  assert.deepEqual(activeTools, ["read", "write"], "a new session should inherit the global tool allowlist");
98
117
  assert.deepEqual(
@@ -113,9 +132,44 @@ try {
113
132
  "session skill choices should override the global default",
114
133
  );
115
134
 
135
+ branchEntries = [];
136
+ ctx.model = { provider: "provider", id: "model-a" };
137
+ for (const handler of extensionHandlers.get("model_select") || []) await handler({ model: ctx.model, source: "set" }, ctx);
138
+ assert.deepEqual(activeTools, ["bash"], "model selection should immediately apply the exact tool profile");
139
+ assert.deepEqual((await runHelper("skills-state")).enabledSkills, ["skill-b"], "model selection should immediately apply the exact skill profile");
140
+
141
+ await writeFile(settingsFile, "{ invalid settings\n", "utf8");
142
+ ctx.model = { provider: "provider", id: "model-b" };
143
+ for (const handler of extensionHandlers.get("model_select") || []) await handler({ model: ctx.model, source: "set" }, ctx);
144
+ assert.deepEqual(activeTools, ["bash"], "a later settings-read failure must retain the last safely applied tools");
145
+ assert.deepEqual((await runHelper("skills-state")).enabledSkills, ["skill-b"], "a later settings-read failure must retain the last safely applied skills");
146
+ await writeFile(settingsFile, `${JSON.stringify(settingsPayload, null, 2)}\n`, "utf8");
147
+ ctx.model = { provider: "provider", id: "model-a" };
148
+
116
149
  await runHelper("tools-set", { enabledTools: ["read"] });
150
+ ctx.model = { provider: "provider", id: "model-b" };
151
+ for (const handler of extensionHandlers.get("model_select") || []) await handler({ model: ctx.model, source: "set" }, ctx);
152
+ assert.deepEqual(activeTools, ["read"], "a session-pinned tool selection should survive model changes");
153
+ assert.deepEqual((await runHelper("skills-state")).enabledSkills, [], "an unpinned skill selection should follow the new model independently");
154
+ const blockedSkill = await (extensionHandlers.get("input") || [])[0]({ text: "/skill:skill-a" }, ctx);
155
+ assert.deepEqual(blockedSkill, { action: "handled" }, "an explicit invocation of a model-disabled skill should be blocked");
156
+
157
+ await runHelper("tools-set", { mode: "inherit" });
158
+ assert.deepEqual(activeTools, ["write"], "unpinning tools should immediately restore the active model profile");
117
159
  await runHelper("skills-set", { enabledSkills: ["skill-a", "skill-c"] });
118
- assert.deepEqual(appendedEntries.map((entry) => entry.customType), ["webui-tools-config", "webui-skills-config"], "session updates should remain branch-persisted");
160
+ const filteredPrompt = await (extensionHandlers.get("before_agent_start") || [])[0]({
161
+ systemPrompt: "The following skills provide guidance.\n<available_skills>\nold\n</available_skills>\n",
162
+ systemPromptOptions: {
163
+ skills: [
164
+ { name: "skill-a", description: "normal", filePath: "/tmp/a/SKILL.md" },
165
+ { name: "skill-c", description: "user only", filePath: "/tmp/c/SKILL.md", disableModelInvocation: true },
166
+ ],
167
+ },
168
+ }, ctx);
169
+ assert.doesNotMatch(filteredPrompt.systemPrompt, /skill-c/, "disableModelInvocation skills must not be exposed to automatic model invocation");
170
+ assert.deepEqual(appendedEntries.map((entry) => entry.customType), ["webui-tools-config", "webui-tools-config", "webui-skills-config"], "session updates and inherit resets should remain branch-persisted");
171
+ assert.deepEqual(appendedEntries[0].data, { version: 2, mode: "explicit", enabledTools: ["read"] });
172
+ assert.deepEqual(appendedEntries[1].data, { version: 2, mode: "inherit" });
119
173
 
120
174
  for (const handler of extensionHandlers.get("session_shutdown") || []) await handler({ reason: "quit" }, ctx);
121
175
  console.log("resource-defaults-helper.test.mjs passed");