@firstpick/pi-package-webui 0.10.1 → 0.10.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 (55) hide show
  1. package/DEVELOPMENT.md +41 -19
  2. package/README.md +13 -3
  3. package/TECHNICAL.md +16 -2
  4. package/bin/pi-webui.mjs +257 -76
  5. package/index.ts +1 -256
  6. package/lib/append-system-selection.mjs +311 -0
  7. package/lib/git-workflow-preferences.mjs +6 -0
  8. package/lib/trust-boundaries.mjs +37 -0
  9. package/package.json +1 -1
  10. package/public/app.js +162 -7
  11. package/public/index.html +5 -2
  12. package/public/service-worker.js +1 -1
  13. package/tests/append-system-http.test.mjs +622 -0
  14. package/tests/append-system-selection.test.mjs +259 -0
  15. package/tests/append-system-selector-static.test.mjs +95 -0
  16. package/tests/boot-failure-diagnostics.test.mjs +2 -2
  17. package/tests/codex-fast-mode-static.test.mjs +2 -2
  18. package/tests/common-options-submenus-interaction-static.test.mjs +4 -0
  19. package/tests/common-options-submenus-markup-static.test.mjs +2 -1
  20. package/tests/composer-action-grid-reorder-static.test.mjs +2 -2
  21. package/tests/control-visibility-static.test.mjs +2 -2
  22. package/tests/controls-layout-static.test.mjs +2 -2
  23. package/tests/events-tree-context-menu-static.test.mjs +2 -2
  24. package/tests/fast-mode-client-static.test.mjs +1 -1
  25. package/tests/feature-decision-output-popup-static.test.mjs +1 -1
  26. package/tests/file-viewer-image-static.test.mjs +2 -2
  27. package/tests/guided-git-activation-static.test.mjs +10 -3
  28. package/tests/guided-git-fallback-runtime.test.mjs +46 -21
  29. package/tests/guided-git-fallback-ui-static.test.mjs +3 -3
  30. package/tests/intercom-conversation-viewer-static.test.mjs +2 -2
  31. package/tests/main-output-loading-static.test.mjs +2 -2
  32. package/tests/middle-button-drag-scroll-static.test.mjs +2 -2
  33. package/tests/mobile-continuity-tablet-static.test.mjs +2 -2
  34. package/tests/mobile-foundation-static.test.mjs +2 -2
  35. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  36. package/tests/mobile-static.test.mjs +3 -2
  37. package/tests/native-parity-harness.test.mjs +7 -0
  38. package/tests/open-issue-wizard-static.test.mjs +1 -1
  39. package/tests/optional-feature-prompt-impact-static.test.mjs +2 -2
  40. package/tests/persistent-ui-layout-static.test.mjs +2 -2
  41. package/tests/prompt-input-vertical-scroll-static.test.mjs +2 -2
  42. package/tests/questionnaire-dialog.test.mjs +2 -2
  43. package/tests/resource-tui-extension.test.mjs +4 -18
  44. package/tests/session-sampling-ui-static.test.mjs +2 -2
  45. package/tests/side-panel-section-height-removal-static.test.mjs +2 -2
  46. package/tests/subagent-observability-static.test.mjs +2 -2
  47. package/tests/syntax-highlighting-static.test.mjs +2 -2
  48. package/tests/terminal-tab-prompt-tooltip-static.test.mjs +147 -0
  49. package/tests/terminal-tab-workspace-static.test.mjs +1 -1
  50. package/tests/theme-customizer-static.test.mjs +1 -1
  51. package/tests/windows-drive-cwd-picker-static.test.mjs +2 -2
  52. package/lib/tui-model-profile-selector.mjs +0 -183
  53. package/lib/tui-resource-selector.mjs +0 -173
  54. package/tests/tui-model-profile-selector.test.mjs +0 -102
  55. package/tests/tui-resource-selector.test.mjs +0 -74
@@ -34,6 +34,13 @@ function writeBranchArtifact() {
34
34
  mkdirSync(directory, { recursive: true });
35
35
  writeFileSync(join(directory, "staged-branch-name.txt"), "feat/native-root-artifacts\\n");
36
36
  }
37
+ function generationProfile(message) {
38
+ const prefix = "--firstpick-webui-generation-profile=";
39
+ const token = String(message || "").split(/\\s+/u).find((part) => part.startsWith(prefix));
40
+ if (!token) return null;
41
+ try { return JSON.parse(Buffer.from(token.slice(prefix.length), "base64url").toString("utf8")); }
42
+ catch { return null; }
43
+ }
37
44
  function failNativeCommand(command, error, notificationError = error) {
38
45
  const commandName = String(command.message || "").split(/\\s+/u, 1)[0].replace(/^\\//u, "");
39
46
  send({
@@ -54,7 +61,16 @@ createInterface({ input: process.stdin }).on("line", async (line) => {
54
61
  let command;
55
62
  try { command = JSON.parse(line); } catch { return; }
56
63
  if (!command?.id || !command?.type) return;
57
- log({ type: command.type, modelId: command.modelId, level: command.level, message: command.message, activeModel: activeModel.id });
64
+ const profile = generationProfile(command.message);
65
+ log({
66
+ type: command.type,
67
+ modelId: command.modelId,
68
+ level: command.level,
69
+ message: command.message,
70
+ activeModel: activeModel.id,
71
+ generationModel: profile?.modelId,
72
+ generationThinkingLevel: profile?.thinkingLevel,
73
+ });
58
74
  const response = { type: "response", id: command.id, command: command.type, success: true };
59
75
  switch (command.type) {
60
76
  case "get_state":
@@ -84,7 +100,7 @@ createInterface({ input: process.stdin }).on("line", async (line) => {
84
100
  case "prompt":
85
101
  if (scenario === "process-loss") process.exit(12);
86
102
  if (scenario === "concurrent" || scenario === "cancellation") await new Promise((resolve) => setTimeout(resolve, 150));
87
- if (scenario === "provider-failure" && activeModel.id === "primary") {
103
+ if (scenario === "provider-failure" && profile?.modelId === "primary") {
88
104
  failNativeCommand(command, "FIRSTPICK_GUIDED_GIT_PROVIDER_FAILURE: active model generation failed", "The active model provider failed");
89
105
  send(response);
90
106
  break;
@@ -116,7 +132,7 @@ createInterface({ input: process.stdin }).on("line", async (line) => {
116
132
  }
117
133
  if (!["unsafe-stale-artifact", "cancellation"].includes(scenario)) {
118
134
  if (String(command.message || "").startsWith("/git-branch-name")) writeBranchArtifact();
119
- else writeCommitArtifacts(activeModel.id);
135
+ else writeCommitArtifacts(profile?.modelId || activeModel.id);
120
136
  }
121
137
  send({ ...response, data: { output: "native extension command completed" } });
122
138
  break;
@@ -238,7 +254,7 @@ try {
238
254
  await runScenario("success", async ({ request, readLog, cwd }) => {
239
255
  const result = await request("/api/git-workflow/generate", { method: "POST", body: { kind: "commit" } });
240
256
  assert.equal(result.status, 200);
241
- assert.equal(result.body.data.message, "/git-staged-msg en auto");
257
+ assert.match(result.body.data.message, /^\/git-staged-msg en auto --firstpick-webui-generation-profile=/u);
242
258
  assert.equal(result.body.data.fallbackUsed, false);
243
259
  assert.equal(await readFile(path.join(cwd, "dev", "COMMIT", "staged-commit-short.txt"), "utf8"), "feat: primary native generation\n");
244
260
  const correlated = await request(`/api/git-workflow/message?generationId=${encodeURIComponent(result.body.data.generationId)}`);
@@ -246,9 +262,11 @@ try {
246
262
  const log = await readLog();
247
263
  assert.ok(log.some((entry) => entry.type === "get_commands"));
248
264
  assert.equal(log.filter((entry) => entry.type === "prompt").length, 1);
249
- const primary = log.findIndex((entry) => entry.type === "set_model" && entry.modelId === "primary");
250
- const restore = log.findIndex((entry) => entry.type === "set_model" && entry.modelId === "original");
251
- assert.ok(primary >= 0 && restore > primary, "the active model must be restored after native artifact verification");
265
+ const prompt = log.find((entry) => entry.type === "prompt");
266
+ assert.equal(prompt.activeModel, "original", "generation must not change the parent session model");
267
+ assert.equal(prompt.generationModel, "primary");
268
+ assert.equal(prompt.generationThinkingLevel, "low");
269
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level").length, 0);
252
270
  });
253
271
 
254
272
  await runScenario("oversized-success", async ({ request, readLog, cwd }) => {
@@ -261,9 +279,9 @@ try {
261
279
  assert.equal(correlated.status, 200);
262
280
  assert.equal(correlated.body.data.ready, true);
263
281
  const log = await readLog();
264
- assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["primary"]);
265
- assert.equal(log.filter((entry) => entry.type === "set_model" && entry.modelId === "fallback").length, 0);
266
- assert.equal(log.filter((entry) => entry.type === "set_model" && entry.modelId === "original").length, 1);
282
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.generationModel), ["primary"]);
283
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["original"]);
284
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level").length, 0);
267
285
  });
268
286
 
269
287
  await runScenario("nested-cwd", async ({ request, cwd, tabCwd }) => {
@@ -293,9 +311,10 @@ try {
293
311
  assert.equal(result.body.data.fallbackUsed, true);
294
312
  assert.equal(await readFile(path.join(cwd, "dev", "COMMIT", "staged-commit-short.txt"), "utf8"), "feat: fallback native generation\n");
295
313
  const log = await readLog();
296
- assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["primary", "fallback"]);
297
- assert.equal(log.filter((entry) => entry.type === "set_model" && entry.modelId === "fallback").length, 1);
298
- assert.equal(log.filter((entry) => entry.type === "set_model" && entry.modelId === "original").length, 1);
314
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.generationModel), ["primary", "fallback"]);
315
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.generationThinkingLevel), ["low", "off"]);
316
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["original", "original"]);
317
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level").length, 0);
299
318
  });
300
319
 
301
320
  for (const [scenario, kind, expectedError] of [
@@ -312,8 +331,9 @@ try {
312
331
  assert.match(result.body.error, expectedError);
313
332
  if (scenario === "above-capture-input") assert.doesNotMatch(result.body.error, /message files? to be refreshed/iu);
314
333
  const log = await readLog();
315
- assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["primary"]);
316
- assert.equal(log.filter((entry) => entry.type === "set_model" && entry.modelId === "fallback").length, 0);
334
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.generationModel), ["primary"]);
335
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["original"]);
336
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level").length, 0);
317
337
  });
318
338
  }
319
339
 
@@ -325,16 +345,18 @@ try {
325
345
  assert.equal(cancelled.body.data.cancelled, true);
326
346
  assert.notEqual((await generation).status, 200);
327
347
  const log = await readLog();
328
- assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["primary"]);
329
- assert.equal(log.filter((entry) => entry.type === "set_model" && entry.modelId === "fallback").length, 0);
348
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.generationModel), ["primary"]);
349
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["original"]);
350
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level").length, 0);
330
351
  });
331
352
 
332
353
  await runScenario("process-loss", async ({ request, readLog }) => {
333
354
  const result = await request("/api/git-workflow/generate", { method: "POST", body: { kind: "commit" } });
334
355
  assert.notEqual(result.status, 200);
335
356
  const log = await readLog();
336
- assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["primary"]);
337
- assert.equal(log.filter((entry) => entry.type === "set_model" && entry.modelId === "fallback").length, 0);
357
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.generationModel), ["primary"]);
358
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["original"]);
359
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level").length, 0);
338
360
  });
339
361
 
340
362
  await runScenario("prompt-only", async ({ request, readLog }) => {
@@ -342,7 +364,7 @@ try {
342
364
  assert.equal(result.status, 409);
343
365
  assert.match(result.body.error, /extension command.*Same-named prompt templates are not used/iu);
344
366
  const log = await readLog();
345
- assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "prompt").length, 0);
367
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level" || entry.type === "prompt").length, 0);
346
368
  });
347
369
 
348
370
  await runScenario("concurrent", async ({ request, readLog }) => {
@@ -351,7 +373,10 @@ try {
351
373
  request("/api/git-workflow/generate", { method: "POST", body: { kind: "commit" } }),
352
374
  ]);
353
375
  assert.deepEqual([left.status, right.status].sort((a, b) => a - b), [200, 409]);
354
- assert.equal((await readLog()).filter((entry) => entry.type === "prompt").length, 1);
376
+ const log = await readLog();
377
+ assert.equal(log.filter((entry) => entry.type === "prompt").length, 1);
378
+ assert.deepEqual(log.filter((entry) => entry.type === "prompt").map((entry) => entry.activeModel), ["original"]);
379
+ assert.equal(log.filter((entry) => entry.type === "set_model" || entry.type === "set_thinking_level").length, 0);
355
380
  });
356
381
  } finally {
357
382
  await rm(temporaryRoot, { recursive: true, force: true });
@@ -51,10 +51,10 @@ assert.match(app, /generationKind: "commit"[\s\S]*generationKind: "branch"[\s\S]
51
51
  assert.match(app, /branch-name\$\{query\}[\s\S]*pr-description\$\{query\}/, "branch and PR artifact reads should send their exact generation IDs");
52
52
 
53
53
  assert.match(readme, /fallback model and its own reasoning effort[\s\S]*tries the fallback once[\s\S]*stopped Pi process do not trigger fallback/i, "README should explain the optional fallback and essential limits");
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");
54
+ assert.match(technical, /## Guided Git generation profiles[\s\S]*strict one-retry policy[\s\S]*active model and reasoning effort remain unchanged[\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=182"/, "the changed browser app should use the next query revision");
58
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153";/, "the PWA cache identity should advance with browser behavior");
57
+ assert.match(html, /data-app-src="\/app\.js\?v=183"/, "the changed browser app should use the next query revision");
58
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154";/, "the PWA cache identity should advance with browser behavior");
59
59
 
60
60
  console.log("guided-git-fallback-ui-static.test.mjs passed");
@@ -97,8 +97,8 @@ assert.match(css, /\.extension-dialog\.intercom-conversation-dialog \{[\s\S]*wid
97
97
  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");
98
98
 
99
99
  assert.match(html, /\/styles\.css\?v=152/, "the stylesheet URL should advance for the bounded conversation tags");
100
- assert.match(html, /data-app-src="\/app\.js\?v=182"/, "the guarded app URL should advance for current browser wiring");
101
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "the PWA cache identity should advance with browser assets");
100
+ assert.match(html, /data-app-src="\/app\.js\?v=183"/, "the guarded app URL should advance for current browser wiring");
101
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "the PWA cache identity should advance with browser assets");
102
102
 
103
103
  assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
104
104
  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");
@@ -59,8 +59,8 @@ assert.match(css, /body\.terminal-tabs-left \.main-output-surface \{ grid-row: 4
59
59
  assert.match(css, /body\.subagent-terminal-active \.main-output-surface,[\s\S]*body\.subagent-terminal-active \.main-output-loading,/, "dedicated subagent output should hide the main transcript and its loading status");
60
60
 
61
61
  assert.match(html, /styles\.css\?v=152/, "the stylesheet cache query should advance");
62
- assert.match(html, /app\.js\?v=182/, "the app cache query should advance");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "the PWA cache identity should advance with browser assets");
62
+ assert.match(html, /app\.js\?v=183/, "the app cache query should advance");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "the PWA cache identity should advance with browser assets");
64
64
  assert.match(readme, /Loading conversation history/, "user documentation should describe the plain-language loading feedback");
65
65
  assert.match(development, /main output loading/i, "developer documentation should preserve the request-ownership contract");
66
66
 
@@ -17,8 +17,8 @@ assert.match(app, /installMiddleButtonDragScroll\(\{[\s\S]*onDirection: \(\{ tar
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
19
  assert.match(html, /styles\.css\?v=152/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=182/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
20
+ assert.match(html, /app\.js\?v=183/, "changed drag-scroll wiring should advance the app revision");
21
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154";[\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-v153"/, "continuity/tablet assets need a coherent cache identity");
50
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "continuity/tablet assets need a coherent cache identity");
51
51
  assert.match(html, /styles\.css\?v=152/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=182/, "continuity app logic must have a coherent HTML revision");
52
+ assert.match(html, /app\.js\?v=183/, "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-v153"/, "the cache identity must change with the startup graph");
40
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "the cache identity must change with the startup graph");
41
41
  assert.match(html, /styles\.css\?v=152/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=182/, "the app revision must change with continuity/tablet wiring");
42
+ assert.match(html, /app\.js\?v=183/, "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-v153"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");
@@ -1895,9 +1895,10 @@ assert.match(app, /function cleanGitPublishVisibilityInput\(value\)[\s\S]*if \(v
1895
1895
  assert.doesNotMatch(app, /visibility = "(?:public|private)"/, "publication visibility should never be defaulted in the frontend");
1896
1896
  assert.match(server, /async function gitAddAllPayload\([\s\S]*platform\(\) === "win32"[\s\S]*findWindowsReservedGitPath\([\s\S]*windowsReservedGitPathFailure\(/, "guided git add should preflight Windows-reserved untracked paths before staging");
1897
1897
  assert.match(app, /Pre-commit verification reminder[\s\S]*Continue with this commit/, "configured verification reminders should run before committing");
1898
- assert.match(server, /async function startGitWorkflowGeneration\([\s\S]*set_model[\s\S]*setThinkingLevelForTab[\s\S]*type: "prompt"/, "server should apply the configured generation profile before prompting Pi");
1898
+ assert.match(server, /function gitWorkflowGenerationProfileArgument\(profile\)[\s\S]*--firstpick-webui-generation-profile=/, "server should encode the configured generation profile for the native extension command");
1899
+ assert.match(server, /async function dispatchGitWorkflowGenerationAttempt\([\s\S]*record\.message = gitWorkflowGenerationPrompt\(record\.kind, record\.preferences, record\.nativeCommandName, profile\)[\s\S]*type: "prompt"/, "server should dispatch the configured generation profile without changing the tab profile");
1899
1900
  assert.match(server, /function consumeGitWorkflowGenerationEvent\(tab, event[\s\S]*event\?\.type !== "agent_settled"[\s\S]*settleGitWorkflowGeneration\(tab, record, settlement\)/, "server should settle the owned Guided Git attempt only after agent settlement");
1900
- assert.match(server, /async function finishGitWorkflowGeneration\(tab, record[\s\S]*restoreGitWorkflowGenerationProfile\(tab, record\)/, "server should restore the active tab model and effort after Guided Git generation finishes");
1901
+ assert.match(server, /async function finishGitWorkflowGeneration\(tab, record[\s\S]*if \(tab\.gitWorkflowGeneration === record\) tab\.gitWorkflowGeneration = null;/, "server should finish Guided Git generation without restoring or changing the active tab model and effort");
1901
1902
  assert.match(server, /case "\/api\/git-workflow\/branch-name": \{[\s\S]*generationId[\s\S]*readGitWorkflowBranchName\(cwd, \{ generationId/, "server should expose exactly correlated generated branch-name loading for the guided PR workflow");
1902
1903
  assert.match(server, /case "\/api\/git-workflow\/branch":[\s\S]*createGitWorkflowBranchWorktree\(tab, body\)/, "server should route guided PR branch creation through worktree tabs");
1903
1904
  assert.match(server, /async function createGitWorkflowBranchWorktree\(tab, body = \{\}\)[\s\S]*expectedStagedContentHashFromBody\(body\)[\s\S]*snapshotGitWorkflowBranchState\(root, tab\.cwd, expectedStagedContentHash\)[\s\S]*applyGitWorkflowBranchStateToWorktree\(snapshot, worktreePath\)[\s\S]*openWorktreeResultForTab\(tab, createdResult/, "guided PR worktree creation should verify and copy exact staged state before opening the worktree tab");
@@ -9,6 +9,7 @@ import {
9
9
  guardsForNativeCommand,
10
10
  isLocalAddress,
11
11
  isLocalRequest,
12
+ isLoopbackHostAuthority,
12
13
  LOCALHOST_ONLY_POST_ROUTES,
13
14
  remoteShellTrustWarning,
14
15
  requireLocalhost,
@@ -39,6 +40,12 @@ assert.equal(isLocalAddress("::1"), true);
39
40
  assert.equal(isLocalAddress("192.168.1.50"), false);
40
41
  assert.equal(isLocalRequest(localReq), true);
41
42
  assert.equal(isLocalRequest(remoteReq), false);
43
+ for (const authority of ["localhost", "localhost:8080", "LOCALHOST.", "127.0.0.1", "127.42.0.1:65535", "[::1]", "[0:0:0:0:0:0:0:1]:8080"]) {
44
+ assert.equal(isLoopbackHostAuthority(authority), true, `${authority} should be accepted as a loopback Host authority`);
45
+ }
46
+ for (const authority of ["", "attacker.example", "attacker.example:8080", "128.0.0.1", "127.0.0.1.attacker.example", "127.1", "[::ffff:127.0.0.1]", "[::1]:65536", "localhost:bad"]) {
47
+ assert.equal(isLoopbackHostAuthority(authority), false, `${authority || "an empty Host"} should be rejected as a loopback Host authority`);
48
+ }
42
49
 
43
50
  assert.throws(() => requireLocalhost(remoteReq, "blocked"), (error) => error.statusCode === 403);
44
51
  assert.throws(() => requireLocalhostRoute(remoteReq, "/api/update"), (error) => error.statusCode === 403);
@@ -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-v153/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v154/, "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
 
@@ -61,7 +61,7 @@ assert.match(readme, /\+.*initial system prompt[\s\S]*?\+\.\.\..*session is runn
61
61
  assert.match(technical, /prompt-impact indicators[\s\S]*?tool schemas and ordinary user or tool messages are not counted/i, "technical reference should state the measurement boundary");
62
62
  assert.match(development, /reports\/pi-default-system-prompt-evaluation\.md[\s\S]*?promptImpact/, "contributor guide should identify the evidence source and catalog field");
63
63
  assert.match(html, /styles\.css\?v=152/, "indicator styles should advance the stylesheet revision");
64
- assert.match(html, /app\.js\?v=182/, "indicator rendering should advance the app revision");
65
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "browser asset changes should advance the PWA cache identity");
64
+ assert.match(html, /app\.js\?v=183/, "indicator rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "browser asset changes should advance the PWA cache identity");
66
66
 
67
67
  console.log("optional-feature-prompt-impact-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-v153"/, "changed browser assets should advance the PWA cache identity");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "changed browser assets should advance the PWA cache identity");
275
275
  assert.match(html, /styles\.css\?v=152/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=182"/, "the boot loader should request the updated app module revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=183"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -20,7 +20,7 @@ assert.match(css, /#promptInput \{[\s\S]*--prompt-input-block-chrome: calc\(1\.8
20
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
21
  assert.doesNotMatch(resizePromptInput, /input\.style\.overflowY = "auto";/, "auto-resizing must not force a scrollbar below the six-line cap");
22
22
  assert.match(html, /styles\.css\?v=152/, "the page should request the six-line prompt stylesheet revision");
23
- assert.match(html, /app\.js\?v=182/, "the page should request the current app revision");
24
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "the PWA cache identity should advance with the prompt scroll assets");
23
+ assert.match(html, /app\.js\?v=183/, "the page should request the current app revision");
24
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "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");
@@ -505,7 +505,7 @@ assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/
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
507
  assert.match(html, /styles\.css\?v=152/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=182/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "questionnaire public assets need a coherent PWA cache revision");
508
+ assert.match(html, /app\.js\?v=183/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -2,23 +2,9 @@ import assert from "node:assert/strict";
2
2
  import { readFile } from "node:fs/promises";
3
3
 
4
4
  const source = await readFile(new URL("../index.ts", import.meta.url), "utf8");
5
- assert.match(source, /pi\.registerCommand\("tools"/);
6
- assert.match(source, /pi\.registerCommand\("skills"/);
7
- assert.doesNotMatch(
8
- source,
9
- /const runtimeToolBaseline\s*=\s*normalizeResourceNameList\(pi\.getActiveTools\(\)\)/,
10
- "extension action methods must not run while the extension factory is loading",
11
- );
12
- assert.match(source, /const runtimeTools = \(\): string\[\] => runtimeToolBaseline \?\?=/, "the tool baseline should be captured lazily after runtime binding");
13
- assert.match(source, /ctx\.mode !== "tui"/);
14
- assert.match(source, /pi\.on\("model_select"/);
15
- assert.match(source, /await recompute\(ctx, event\.model\)/, "model selection should immediately recompute exact-model resources");
16
- assert.match(source, /"Session only", "Global default", "Model default"/);
17
- assert.match(source, /"Use inherited defaults"/);
18
- assert.match(source, /selectTuiModelProfile\(ctx, \{/, "exact-model profiles should use the shared searchable model picker");
19
- assert.match(source, /selectTuiResources\(ctx, \{/, "resource lists should use the shared keyboard-driven selector");
20
- assert.match(source, /preserveUnavailableResourceNames\(/);
21
- assert.match(source, /setExactModelProfile\(/);
22
- assert.match(source, /skill\.disableModelInvocation !== true/);
5
+
6
+ assert.doesNotMatch(source, /pi\.registerCommand\("tools"/, "the tools extension must own /tools");
7
+ assert.doesNotMatch(source, /pi\.registerCommand\("skills"/, "the skills extension must own /skills");
8
+ assert.doesNotMatch(source, /registerTuiResourceController/, "WebUI must not manage TUI tool or skill state");
23
9
 
24
10
  console.log("resource-tui-extension.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-v153"/, "native-control assets should advance the cache identity");
60
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "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
62
  assert.match(html, /styles\.css\?v=152/, "the changed stylesheet should have a new revision");
63
- assert.match(html, /app\.js\?v=182/, "the changed app module should have a new revision");
63
+ assert.match(html, /app\.js\?v=183/, "the changed app module should have a new revision");
64
64
 
65
65
  // --- Browser state behavior -------------------------------------------------
66
66
 
@@ -28,7 +28,7 @@ assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLa
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
30
  assert.match(html, /styles\.css\?v=152/, "removing section resize styles should advance the stylesheet revision");
31
- assert.match(html, /app\.js\?v=182/, "removing section resize behavior should advance the app revision");
32
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "removing browser assets should advance the PWA cache identity");
31
+ assert.match(html, /app\.js\?v=183/, "removing section resize behavior should advance the app revision");
32
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "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=152[\s\S]*app\.js\?v=182/, "browser assets should use the current subagent-observability revisions");
32
- assert.match(worker, /pi-webui-pwa-v153/, "PWA cache identity should advance with subagent widget suppression");
31
+ assert.match(html, /styles\.css\?v=152[\s\S]*app\.js\?v=183/, "browser assets should use the current subagent-observability revisions");
32
+ assert.match(worker, /pi-webui-pwa-v154/, "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-v153"/, "adding a startup module should advance the PWA cache identity");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "adding a startup module should advance the PWA cache identity");
64
64
  assert.match(html, /styles\.css\?v=152/, "new token styles should advance the stylesheet revision");
65
- assert.match(html, /data-app-src="\/app\.js\?v=182"/, "new renderer wiring should advance the app module revision");
65
+ assert.match(html, /data-app-src="\/app\.js\?v=183"/, "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")));
@@ -0,0 +1,147 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import vm from "node:vm";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
9
+
10
+ function appFunctionSource(name, nextName) {
11
+ const start = app.indexOf(`function ${name}(`);
12
+ const end = app.indexOf(`\nfunction ${nextName}(`, start);
13
+ assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
14
+ return app.slice(start, end);
15
+ }
16
+
17
+ function appFunctionToMarker(name, marker) {
18
+ const start = app.indexOf(`function ${name}(`);
19
+ const end = app.indexOf(marker, start);
20
+ assert.ok(start >= 0 && end > start, `${name} should remain extractable for behavioral tests`);
21
+ return app.slice(start, end);
22
+ }
23
+
24
+ const promptSource = appFunctionSource("terminalTabPromptTooltip", "terminalTabGroupRepresentedTab");
25
+ const representedTabSource = appFunctionSource("terminalTabGroupRepresentedTab", "terminalTabTooltip");
26
+ const tabTooltipSource = appFunctionSource("terminalTabTooltip", "terminalTabGroupStatusTooltip");
27
+ const groupTooltipSource = appFunctionSource("terminalTabGroupTooltip", "appendTerminalTabContent");
28
+ const regularRendererSource = appFunctionSource("renderTerminalTab", "renderTerminalTabGroupItem");
29
+ const groupedItemRendererSource = appFunctionSource("renderTerminalTabGroupItem", "shouldRenderTerminalTabGroup");
30
+ const collapsedGroupRendererSource = appFunctionSource("renderTerminalTabGroup", "updateTerminalTabGroupOpenState");
31
+ const stripAnsiSource = appFunctionToMarker("stripAnsi", "\n\nconst ANSI_16_COLORS");
32
+ const cleanTooltipSource = appFunctionToMarker("cleanTooltipText", "\n\nconst TOOLTIP_HOVER_DELAY_MS");
33
+ const applyStyledTooltipSource = appFunctionSource("applyStyledTooltip", "applyFooterTooltip");
34
+
35
+ const promptResults = vm.runInNewContext(`
36
+ ${promptSource}
37
+ const exactBound = "/" + "a".repeat(4095);
38
+ ({
39
+ positive: terminalTabPromptTooltip({ prompt: { kind: "append-system", path: "/home/user/.pi/agent/minimal/APPEND_SYSTEM.md" } }),
40
+ textOnly: terminalTabPromptTooltip({ prompt: { kind: "append-system", path: "/tmp/<prompt>&.md" } }),
41
+ exactBound: terminalTabPromptTooltip({ prompt: { kind: "append-system", path: exactBound } }),
42
+ nullPrompt: terminalTabPromptTooltip({ prompt: null }),
43
+ missingPrompt: terminalTabPromptTooltip({}),
44
+ wrongKind: terminalTabPromptTooltip({ prompt: { kind: "system", path: "/tmp/APPEND_SYSTEM.md" } }),
45
+ relativePath: terminalTabPromptTooltip({ prompt: { kind: "append-system", path: "relative/APPEND_SYSTEM.md" } }),
46
+ oversizedPath: terminalTabPromptTooltip({ prompt: { kind: "append-system", path: "/" + "a".repeat(4096) } }),
47
+ multilinePath: terminalTabPromptTooltip({ prompt: { kind: "append-system", path: "/tmp/prompt\\ncontent" } }),
48
+ extraField: terminalTabPromptTooltip({ prompt: { kind: "append-system", path: "/tmp/APPEND_SYSTEM.md", content: "secret" } }),
49
+ commandOnly: terminalTabPromptTooltip({ command: "pi --append-system-prompt /tmp/APPEND_SYSTEM.md" }),
50
+ });
51
+ `);
52
+
53
+ assert.equal(promptResults.positive, "Append-system prompt: /home/user/.pi/agent/minimal/APPEND_SYSTEM.md", "a valid tab-local descriptor should produce the exact approved label");
54
+ assert.equal(promptResults.textOnly, "Append-system prompt: /tmp/<prompt>&.md", "the helper should return text without interpreting markup-like path characters");
55
+ assert.equal(promptResults.exactBound.length, "Append-system prompt: ".length + 4096, "the server's 4,096-character path boundary should remain usable");
56
+ for (const [name, result] of Object.entries(promptResults).filter(([name]) => !["positive", "textOnly", "exactBound"].includes(name))) {
57
+ assert.equal(result, "", `${name} must not add an append-system tooltip line`);
58
+ }
59
+
60
+ const tooltipResults = vm.runInNewContext(`
61
+ ${promptSource}
62
+ ${representedTabSource}
63
+ ${tabTooltipSource}
64
+ ${groupTooltipSource}
65
+ const activeTabId = "tab-active";
66
+ const defaultTab = { id: "tab-default", title: "Default", running: true, cwd: "/workspace/default", prompt: null };
67
+ const activeTab = { id: "tab-active", title: "Active", running: true, cwd: "/workspace/active", prompt: { kind: "append-system", path: "/visible/active/APPEND_SYSTEM.md" } };
68
+ const inactiveTab = { id: "tab-inactive", title: "Inactive", running: true, cwd: "/workspace/inactive", prompt: { kind: "append-system", path: "/visible/inactive/APPEND_SYSTEM.md" } };
69
+ ({
70
+ regular: terminalTabTooltip(activeTab),
71
+ defaultTab: terminalTabTooltip(defaultTab),
72
+ group: terminalTabGroupTooltip({ custom: true, tabs: [inactiveTab, activeTab] }, "Prompt group"),
73
+ });
74
+ `, {
75
+ normalizeDisplayPath: (value) => String(value || ""),
76
+ tabIndicator: () => ({ label: "Idle", state: "idle" }),
77
+ terminalTabGitTooltip: () => "",
78
+ terminalTabActiveTooltip: () => "",
79
+ terminalDisplayGroupTitle: () => "Group",
80
+ terminalTabGroupWorkspaceTooltip: () => "Working folder: /workspace",
81
+ terminalTabGroupStatusTooltip: () => "2 idle",
82
+ terminalTabGroupActiveTooltip: () => "",
83
+ isMobileView: () => false,
84
+ });
85
+
86
+ assert.match(tooltipResults.regular, /Working folder: \/workspace\/active\nAppend-system prompt: \/visible\/active\/APPEND_SYSTEM\.md\nClick to switch/, "regular tooltips should preserve working-folder and action lines around the new prompt line");
87
+ assert.doesNotMatch(tooltipResults.defaultTab, /Append-system prompt:/, "default tabs should keep their existing tooltip lines unchanged");
88
+ assert.match(tooltipResults.group, /Append-system prompt: \/visible\/active\/APPEND_SYSTEM\.md/, "a collapsed group should show its active represented tab's descriptor");
89
+ assert.doesNotMatch(tooltipResults.group, /\/visible\/inactive\/APPEND_SYSTEM\.md/, "a collapsed group must not borrow another group member's descriptor");
90
+
91
+ const styledTooltipResults = vm.runInNewContext(`
92
+ ${promptSource}
93
+ ${stripAnsiSource}
94
+ ${cleanTooltipSource}
95
+ let styledTooltipDescriptionSerial = 0;
96
+ ${applyStyledTooltipSource}
97
+ function tooltipNode() {
98
+ const attributes = new Map();
99
+ return {
100
+ attributes,
101
+ children: [],
102
+ dataset: {},
103
+ id: "",
104
+ append(child) { this.children.push(child); },
105
+ getAttribute(name) { return attributes.get(name) || null; },
106
+ removeAttribute(name) { attributes.delete(name); },
107
+ setAttribute(name, value) { attributes.set(name, String(value)); },
108
+ };
109
+ }
110
+ const promptTooltip = terminalTabPromptTooltip({ prompt: { kind: "append-system", path: "/tmp/prompt two/APPEND_SYSTEM.md" } });
111
+ const promptNode = tooltipNode();
112
+ applyStyledTooltip(promptNode, promptTooltip, { ariaLabel: false, description: true, preserveInternalSpaces: true });
113
+ const ordinaryNode = tooltipNode();
114
+ applyStyledTooltip(ordinaryNode, "Ordinary repeated\\twhitespace", { ariaLabel: true });
115
+ ({
116
+ promptTooltip,
117
+ promptData: promptNode.getAttribute("data-tooltip"),
118
+ promptDescribedBy: promptNode.getAttribute("aria-describedby"),
119
+ promptDescriptionId: promptNode.children[0]?.id,
120
+ promptDescriptionText: promptNode.children[0]?.textContent,
121
+ preservedCleanup: cleanTooltipText("\\u001b[31m Keep spaces\\r\\n\\n\\nTail\\tlabel \\u001b[0m", { preserveInternalSpaces: true }),
122
+ ordinaryData: ordinaryNode.getAttribute("data-tooltip"),
123
+ ordinaryAriaLabel: ordinaryNode.getAttribute("aria-label"),
124
+ });
125
+ `, {
126
+ bindStyledTooltipEvents: () => {},
127
+ make: (_tag, className, text) => ({ className, id: "", textContent: text || "" }),
128
+ });
129
+
130
+ const consecutiveSpaceTooltip = "Append-system prompt: /tmp/prompt two/APPEND_SYSTEM.md";
131
+ assert.equal(styledTooltipResults.promptTooltip, consecutiveSpaceTooltip, "the descriptor formatter must retain consecutive spaces in a valid path");
132
+ assert.equal(styledTooltipResults.promptData, consecutiveSpaceTooltip, "the styled tooltip data attribute must retain consecutive path spaces");
133
+ assert.equal(styledTooltipResults.promptDescriptionText, consecutiveSpaceTooltip, "the aria-describedby text must retain consecutive path spaces");
134
+ assert.equal(styledTooltipResults.promptDescribedBy, styledTooltipResults.promptDescriptionId, "the preserved description text must remain connected to its trigger");
135
+ assert.equal(styledTooltipResults.preservedCleanup, "Keep spaces\n\nTail label", "space preservation must retain ANSI stripping, CR/LF normalization, newline bounds, trimming, and non-space whitespace cleanup");
136
+ assert.equal(styledTooltipResults.ordinaryData, "Ordinary repeated whitespace", "ordinary styled tooltips must keep the default repeated-whitespace collapse");
137
+ assert.equal(styledTooltipResults.ordinaryAriaLabel, "Ordinary repeated whitespace", "ordinary tooltip accessibility labels must keep the default sanitizer behavior");
138
+
139
+ assert.match(regularRendererSource, /applyStyledTooltip\(button, terminalTabTooltip\(tab\), \{[^}]*preserveInternalSpaces: true/, "regular tabs should explicitly preserve valid prompt-path spaces");
140
+ assert.match(groupedItemRendererSource, /applyStyledTooltip\(button, terminalTabTooltip\(tab\), \{[^}]*preserveInternalSpaces: true/, "grouped tab items should explicitly preserve valid prompt-path spaces");
141
+ assert.match(collapsedGroupRendererSource, /const activeGroupTab = terminalTabGroupRepresentedTab\(groupTabs\)[\s\S]*applyStyledTooltip\(button, terminalTabGroupTooltip\(group, groupTitle\), \{[^}]*preserveInternalSpaces: true/, "collapsed groups should use the same represented-tab selection and explicit space preservation for their styled tooltip");
142
+ assert.equal(app.match(/applyStyledTooltip\(button, terminalTabTooltip\(tab\)/g)?.length, 2, "regular and grouped-item call sites should continue sharing terminalTabTooltip");
143
+ assert.doesNotMatch(promptSource, /\bsettings\b|appendSystemPromptPath|\.command\b|piArgs/, "prompt display must not infer state from global settings or tab commands");
144
+ assert.doesNotMatch(`${promptSource}\n${tabTooltipSource}\n${groupTooltipSource}`, /\bfetch\s*\(|nativeCommandApi|XMLHttpRequest|FileReader|\/api\/.*file/i, "tooltip rendering must not load prompt files or contents");
145
+ assert.doesNotMatch(`${regularRendererSource}\n${groupedItemRendererSource}\n${collapsedGroupRendererSource}`, /\.innerHTML\s*=/, "tab tooltip call sites should retain attribute/text-only rendering");
146
+
147
+ console.log("terminal tab prompt tooltip static tests passed");
@@ -90,7 +90,7 @@ assert.match(results.group, /^Tooltip group · 2 tabs\nWorkspaces: projects\/pi-
90
90
  assert.match(results.group, /Click to switch · Drop tabs here to add$/, "group hover summary should preserve the drop-target affordance");
91
91
  assert.doesNotMatch(terminalTabMetaSource, /\bpid\b/i, "compact tab metadata should not expose the process PID");
92
92
  assert.equal(app.match(/applyStyledTooltip\(button, terminalTabTooltip\(tab\)/g)?.length, 2, "single and grouped-item tabs should share one tooltip formatter");
93
- assert.match(renderTerminalTabGroupSource, /applyStyledTooltip\(button, terminalTabGroupTooltip\(group, groupTitle\), \{ ariaLabel: false, description: true, placement: "right", variant: "workspace", targetKey: `terminal-group:\$\{group\.key\}:switch` \}\)/, "group hover disclosure should use the shared floating tooltip layer with stable semantic identity to the right of its trigger");
93
+ assert.match(renderTerminalTabGroupSource, /applyStyledTooltip\(button, terminalTabGroupTooltip\(group, groupTitle\), \{ ariaLabel: false, description: true, placement: "right", preserveInternalSpaces: true, variant: "workspace", targetKey: `terminal-group:\$\{group\.key\}:switch` \}\)/, "group hover disclosure should use the shared floating tooltip layer with stable semantic identity to the right of its trigger while preserving valid prompt-path spaces");
94
94
  assert.doesNotMatch(renderTerminalTabGroupSource, /terminal-tab-group-summary|menu\.append\(summary\)/, "group hover disclosure should not render an in-flow summary that shifts group menu items");
95
95
  assert.match(renderTerminalTabGroupSource, /dropdown: true[\s\S]*button\.addEventListener\("click", \(\) => \{[\s\S]*if \(isMobileView\(\)\)[\s\S]*toggleOpenTerminalTabGroup\(group\.key\)[\s\S]*switchTab\(activeGroupTab\.id\)/, "mobile terminal group titles should toggle their dropdown while desktop titles keep switching terminals");
96
96
  assert.match(renderSubagentTerminalTabGroupSource, /dropdown: true[\s\S]*button\.addEventListener\("click", \(\) => \{[\s\S]*if \(isMobileView\(\)\)[\s\S]*toggleOpenTerminalTabGroup\(group\.key\)[\s\S]*activateSubagentTerminalView\(activeView\.id\)/, "mobile subagent group titles should toggle their dropdown while desktop titles keep switching views");