@firstpick/pi-package-webui 0.9.0 → 0.9.2

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 (75) hide show
  1. package/README.md +236 -24
  2. package/bin/pi-webui-launcher.mjs +23 -12
  3. package/bin/pi-webui.mjs +493 -65
  4. package/lib/agent-run-adapters.mjs +500 -0
  5. package/lib/agent-run-protocol.mjs +262 -0
  6. package/lib/agent-run-registry.mjs +339 -0
  7. package/lib/app-runner-terminal.mjs +40 -0
  8. package/lib/git-workflow-preferences.mjs +11 -4
  9. package/lib/trust-boundaries.mjs +2 -0
  10. package/lib/ui-layout-settings.mjs +172 -28
  11. package/lib/update/package-layout.mjs +50 -0
  12. package/lib/update/plan.mjs +11 -0
  13. package/package.json +2 -2
  14. package/public/app.js +1376 -337
  15. package/public/index.html +113 -68
  16. package/public/service-worker.js +1 -1
  17. package/public/styles.css +371 -93
  18. package/tests/agent-run-adapters.test.mjs +217 -0
  19. package/tests/agent-run-launcher.test.mjs +41 -0
  20. package/tests/agent-run-protocol.test.mjs +82 -0
  21. package/tests/agent-run-registry.test.mjs +102 -0
  22. package/tests/app-runner-terminal-static.test.mjs +28 -0
  23. package/tests/app-runner-terminal.test.mjs +65 -0
  24. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  25. package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
  26. package/tests/browser/controls-layout.spec.mjs +122 -0
  27. package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
  28. package/tests/browser/interaction-continuity.spec.mjs +159 -0
  29. package/tests/browser/mobile-foundation.spec.mjs +26 -0
  30. package/tests/browser/model-search-focus.spec.mjs +96 -0
  31. package/tests/browser/optimistic-prompt.spec.mjs +22 -0
  32. package/tests/browser/persistent-ui-layout.spec.mjs +224 -66
  33. package/tests/browser/subagent-observability.spec.mjs +87 -0
  34. package/tests/chat-scroll-intent-static.test.mjs +1 -1
  35. package/tests/codex-fast-mode-static.test.mjs +2 -2
  36. package/tests/component-update-api-static.test.mjs +2 -1
  37. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  38. package/tests/control-deck-component-updates-static.test.mjs +2 -0
  39. package/tests/control-deck-side-panels-static.test.mjs +68 -0
  40. package/tests/controls-layout-static.test.mjs +22 -0
  41. package/tests/fast-mode-client-static.test.mjs +1 -1
  42. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  43. package/tests/file-tree-git-ignored-static.test.mjs +152 -0
  44. package/tests/file-tree-search-layout-static.test.mjs +2 -1
  45. package/tests/fixtures/fake-pi.mjs +43 -7
  46. package/tests/footer-provider-usage-visual-static.test.mjs +10 -8
  47. package/tests/git-workflow-preferences.test.mjs +55 -6
  48. package/tests/http-endpoints-harness.test.mjs +173 -14
  49. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  50. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  51. package/tests/mobile-foundation-static.test.mjs +3 -3
  52. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  53. package/tests/mobile-static.test.mjs +18 -5
  54. package/tests/open-issue-wizard-static.test.mjs +2 -2
  55. package/tests/persistent-ui-layout-static.test.mjs +13 -13
  56. package/tests/questionnaire-dialog.test.mjs +3 -3
  57. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  58. package/tests/session-sampling-ui-static.test.mjs +3 -3
  59. package/tests/side-panel-context-menu-static.test.mjs +1 -1
  60. package/tests/side-panel-resize-static.test.mjs +26 -16
  61. package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
  62. package/tests/side-panel-section-reorder-static.test.mjs +16 -70
  63. package/tests/subagent-gate-visibility.test.mjs +2 -1
  64. package/tests/subagent-launch-slots.test.mjs +1 -1
  65. package/tests/subagent-observability-static.test.mjs +32 -0
  66. package/tests/subagent-reliability-integration.test.mjs +161 -0
  67. package/tests/subagents-helper.test.mjs +344 -4
  68. package/tests/terminal-tabs-resize-static.test.mjs +35 -0
  69. package/tests/theme-customizer-static.test.mjs +1 -1
  70. package/tests/ui-layout-settings.test.mjs +104 -32
  71. package/tests/update-api-harness.test.mjs +24 -10
  72. package/tests/update-package-layout.test.mjs +38 -0
  73. package/tests/update-plan.test.mjs +11 -1
  74. package/tests/webui-settings-locking.test.mjs +33 -3
  75. package/webui-rpc-helper.mjs +417 -28
@@ -7,6 +7,7 @@ import path from "node:path";
7
7
  import { setTimeout as delay } from "node:timers/promises";
8
8
  import { dirname, join } from "node:path";
9
9
  import { fileURLToPath, pathToFileURL } from "node:url";
10
+ import { AgentRunRegistry } from "../lib/agent-run-registry.mjs";
10
11
  import { terminateProcessTree } from "../lib/process-tree.mjs";
11
12
  import { deriveSupervisorRecoveryToken } from "../lib/rpc-supervisor-protocol.mjs";
12
13
  import { readSupervisorState, supervisorPaths, supervisorPidIsAlive } from "../lib/rpc-supervisor-state.mjs";
@@ -131,6 +132,8 @@ const cwd = await mkdtemp(path.join(tmpdir(), "pi-webui-http-harness-"));
131
132
  const harnessSideEffectsRoot = await mkdtemp(path.join(tmpdir(), "pi-webui-http-harness-side-effects-"));
132
133
  const settingsFile = path.join(harnessSideEffectsRoot, "webui-settings.json");
133
134
  const workflowPolicyAgentDir = path.join(harnessSideEffectsRoot, "agent");
135
+ const agentRunStateHome = path.join(harnessSideEffectsRoot, "state");
136
+ const agentRunRegistry = new AgentRunRegistry({ agentDir: workflowPolicyAgentDir, port, stateHome: agentRunStateHome });
134
137
  const managedThemePackageRoot = path.join(workflowPolicyAgentDir, "npm", "node_modules", "@firstpick", "pi-themes-bundle");
135
138
  const managedThemeDir = path.join(managedThemePackageRoot, "themes");
136
139
  const workflowPolicyFile = path.join(workflowPolicyAgentDir, "workflow-policy.json");
@@ -253,6 +256,7 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "0.
253
256
  GIT_COMMITTER_EMAIL: "pi-webui-test@example.invalid",
254
257
  PATH: `${fakeOpenBinDir}${path.delimiter}${process.env.PATH || ""}`,
255
258
  PI_CODING_AGENT_DIR: workflowPolicyAgentDir,
259
+ XDG_STATE_HOME: agentRunStateHome,
256
260
  PI_WEBUI_SETTINGS_FILE: settingsFile,
257
261
  PI_SESSION_SUMMARY_CONFIG_FILE: sessionSummaryConfigFile,
258
262
  PI_WEBUI_RPC_SUPERVISOR: "1",
@@ -772,8 +776,8 @@ try {
772
776
  const initialInterfacePreferences = await request("127.0.0.1", "/api/interface-preferences");
773
777
  assert.equal(initialInterfacePreferences.status, 200);
774
778
  assert.equal(initialInterfacePreferences.body?.data?.preferences?.sidePanelWidth, null, "a user without a saved width should receive the default preference");
775
- assert.equal(initialInterfacePreferences.body?.data?.layout?.version, 1);
776
- assert.equal(initialInterfacePreferences.body?.data?.layout?.sidePanel?.sectionOrder, null);
779
+ assert.equal(initialInterfacePreferences.body?.data?.layout?.version, 2);
780
+ assert.deepEqual(initialInterfacePreferences.body?.data?.layout?.sidePanel?.sectionLayout, { order: null, leftSectionIds: null });
777
781
  assert.match(initialInterfacePreferences.body?.data?.layoutRevision || "", /^[a-f0-9]{64}$/);
778
782
  assert.equal(Object.hasOwn(initialInterfacePreferences.body?.data || {}, "path"), false, "preference responses must not disclose the user's settings-file path");
779
783
  const initialLayoutRevision = initialInterfacePreferences.body.data.layoutRevision;
@@ -801,50 +805,69 @@ try {
801
805
  sidePanelWidth: 620,
802
806
  expectedLayoutRevision: initialLayoutRevision,
803
807
  layout: {
804
- version: 1,
805
- sidePanel: { sectionOrder: ["files", "controls", "git"], collapsedSectionIds: ["git"], hiddenSectionIds: [], collapsed: false },
808
+ version: 2,
809
+ sidePanel: {
810
+ placement: "both",
811
+ sectionLayout: { order: ["files", "controls", "git"], leftSectionIds: ["files"] },
812
+ collapsedSectionIds: ["git"],
813
+ hiddenSectionIds: [],
814
+ collapsedPanels: { left: false, right: false },
815
+ panelWidths: { left: 384, right: 620 },
816
+ },
806
817
  composerActions: { order: ["new", "git", "send"], grid: { version: 2, columns: 12, positions: { new: 0, git: 1, send: 10 } } },
807
818
  footerScopedModelOrder: ["openai-codex/gpt-5.6-sol"],
808
- terminalTabs: { layout: "left", customGroups: { version: 1, groups: [{ id: "group-1", title: "Group 1", tabIds: ["tab-a", "tab-b"] }] } },
819
+ terminalTabs: { layout: "left", customGroups: { version: 1, groups: [{ id: "group-1", title: "Group 1", tabIds: ["tab-a", "tab-b"] }] }, sidebarWidth: 288 },
809
820
  fileViewerWidth: 560,
810
821
  },
811
822
  },
812
823
  });
813
824
  assert.equal(savedLayout.status, 200, savedLayout.body?.error);
814
825
  assert.equal(savedLayout.body?.data?.preferences?.sidePanelWidth, 620);
826
+ assert.equal(savedLayout.body?.data?.layout?.sidePanel?.panelWidths?.right, 620, "one locked PUT must expose matching v2 right and legacy widths");
827
+ assert.deepEqual(savedLayout.body?.data?.layout?.sidePanel?.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: ["files"] });
815
828
  assert.deepEqual(savedLayout.body?.data?.layout?.composerActions?.order, ["new", "git", "send"]);
816
829
  assert.equal(savedLayout.body?.data?.layout?.terminalTabs?.layout, "left");
830
+ assert.equal(savedLayout.body?.data?.layout?.terminalTabs?.sidebarWidth, 288);
817
831
  assert.notEqual(savedLayout.body?.data?.layoutRevision, initialLayoutRevision);
818
832
  assert.equal(JSON.stringify(savedLayout.body).includes(settingsFile), false, "successful layout responses must not disclose the settings path");
819
833
  const savedLayoutRevision = savedLayout.body.data.layoutRevision;
820
834
  const persistedLayoutSettings = JSON.parse(await readFile(settingsFile, "utf8"));
821
- assert.equal(persistedLayoutSettings.version, 6);
835
+ assert.equal(persistedLayoutSettings.version, 7);
836
+ assert.equal(persistedLayoutSettings.interfacePreferences.sidePanelWidth, 620);
837
+ assert.equal(persistedLayoutSettings.uiLayout.sidePanel.panelWidths.right, 620, "the v2 right width and legacy mirror must persist atomically");
822
838
  assert.equal(persistedLayoutSettings.uiLayout.fileViewerWidth, 560);
823
839
  assert.deepEqual(persistedLayoutSettings.uiLayout.composerActions.grid.positions, { new: 0, git: 1, send: 10 });
824
840
 
825
841
  const staleLayout = await request("127.0.0.1", "/api/interface-preferences", {
826
842
  method: "PUT",
827
- body: { expectedLayoutRevision: initialLayoutRevision, layout: { sidePanel: { collapsed: true } } },
843
+ body: { expectedLayoutRevision: initialLayoutRevision, layout: { sidePanel: { collapsedPanels: { right: true } } } },
828
844
  });
829
845
  assert.equal(staleLayout.status, 409, "stale layout revisions must be rejected without mutation");
830
846
  assert.equal(JSON.stringify(staleLayout.body).includes(settingsFile), false, "conflict errors must not disclose the settings path");
831
- assert.equal((await request("127.0.0.1", "/api/interface-preferences")).body?.data?.layout?.sidePanel?.collapsed, false);
847
+ assert.equal((await request("127.0.0.1", "/api/interface-preferences")).body?.data?.layout?.sidePanel?.collapsedPanels?.right, false);
832
848
 
833
849
  const partialLayout = await request("127.0.0.1", "/api/interface-preferences", {
834
850
  method: "PUT",
835
- body: { expectedLayoutRevision: savedLayoutRevision, layout: { sidePanel: { collapsed: true }, fileViewerWidth: null } },
851
+ body: { expectedLayoutRevision: savedLayoutRevision, layout: { sidePanel: { collapsedPanels: { right: true } }, fileViewerWidth: null } },
836
852
  });
837
853
  assert.equal(partialLayout.status, 200, partialLayout.body?.error);
838
- assert.equal(partialLayout.body?.data?.layout?.sidePanel?.collapsed, true);
839
- assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.sectionOrder, ["files", "controls", "git"], "partial layout patches must preserve omitted fields");
854
+ assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.collapsedPanels, { left: false, right: true });
855
+ assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: ["files"] }, "partial layout patches must preserve omitted fields");
856
+ assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.panelWidths, { left: 384, right: 620 });
840
857
  assert.equal(partialLayout.body?.data?.layout?.fileViewerWidth, null);
841
858
  assert.deepEqual(partialLayout.body?.data?.layout?.composerActions?.order, ["new", "git", "send"]);
842
859
 
843
860
  const invalidLayoutBodies = [
844
- { layout: { sidePanel: { collapsed: false } } },
861
+ { layout: { sidePanel: { collapsedPanels: { right: false } } } },
862
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { version: 1, sidePanel: { collapsed: false } } },
863
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { placement: "center" } } },
864
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { sectionLayout: { order: ["files", "files"], leftSectionIds: [] } } } },
865
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { sectionLayout: { order: ["files"], leftSectionIds: ["git"] } } } },
866
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { panelWidths: { right: 100 } } } },
845
867
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { composerActions: { order: ["send"] } } },
846
868
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { unknown: true } },
847
869
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { terminalTabs: { layout: "bottom" } } },
870
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { terminalTabs: { sidebarWidth: 100 } } },
848
871
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { fileViewerWidth: 1 } },
849
872
  { sidePanelWidth: 700, unexpected: true },
850
873
  {},
@@ -1179,7 +1202,7 @@ try {
1179
1202
  assert.equal(savedUserLaunchSlots.body?.data?.reloadRequired, true, "a changed save must require active-tab reload before helper guidance changes");
1180
1203
  assert.deepEqual(savedUserLaunchSlots.body?.data?.roles?.reviewer, userLaunchDraft.reviewer, "same-role launch slots must retain independent explicit model specs");
1181
1204
  const persistedLaunchSlots = JSON.parse(await readFile(settingsFile, "utf8"));
1182
- assert.equal(persistedLaunchSlots.version, 6, "launch-slot persistence should retain the current private WebUI settings envelope");
1205
+ assert.equal(persistedLaunchSlots.version, 7, "launch-slot persistence should retain the current private WebUI settings envelope");
1183
1206
  assert.deepEqual(persistedLaunchSlots.subagentLaunchSlots?.user?.roles?.reviewer, userLaunchDraft.reviewer);
1184
1207
 
1185
1208
  const inheritedProjectLaunchSlots = await request("127.0.0.1", `/api/subagents/config?tab=${encodeURIComponent(tabId)}&scope=project`);
@@ -1462,6 +1485,17 @@ try {
1462
1485
  await request("127.0.0.1", `/api/tabs/${encodeURIComponent(otherArtifactTab.body?.data?.tab?.id)}`, { method: "DELETE" });
1463
1486
  await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture document artifact clear" } });
1464
1487
 
1488
+ const oldHelperFixture = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents old-helper" } });
1489
+ assert.equal(oldHelperFixture.status, 200, "old-helper compatibility fixture should be accepted");
1490
+ let oldHelperOverview;
1491
+ for (let attempt = 0; attempt < 20; attempt++) {
1492
+ oldHelperOverview = await request("127.0.0.1", "/api/subagents");
1493
+ if (oldHelperOverview.body?.data?.totalAgents === 2) break;
1494
+ await delay(50);
1495
+ }
1496
+ assert.equal(oldHelperOverview.body?.data?.version, 2, "a new server must project an old v1-only helper status into the v2 overview");
1497
+ assert.equal(oldHelperOverview.body?.data?.groups?.find((group) => group.tabId === tabId)?.runs?.[0]?.agents?.length, 2);
1498
+
1465
1499
  const subagentFixtureStart = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents running" } });
1466
1500
  assert.equal(subagentFixtureStart.status, 200, "subagent fixture status should be accepted");
1467
1501
  let subagentsResponse;
@@ -1521,9 +1555,84 @@ try {
1521
1555
  content: [{ type: "text", text: "# Fixture README" }],
1522
1556
  },
1523
1557
  ], "subagent output endpoint should preserve normalized structured transcript roles, order, IDs, and tool metadata");
1558
+ const canonicalHelperOutput = await request("127.0.0.1", `/api/subagents/output?group=${encodeURIComponent(`tab:${tabId}`)}&run=fixture-run&agent=fixture-run%3A0`);
1559
+ assert.equal(canonicalHelperOutput.status, 200, "the v2 output route should dispatch an opaque helper-owned handle");
1560
+ assert.equal(canonicalHelperOutput.body?.data?.agent?.name, "reviewer");
1524
1561
  const unknownSubagentOutput = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=missing&agent=missing`);
1525
1562
  assert.equal(unknownSubagentOutput.status, 404, "subagent output endpoint should reject untracked selections");
1526
1563
 
1564
+ const registryNow = Date.now();
1565
+ await agentRunRegistry.writeRecord("duplicate-provider", {
1566
+ version: 1, instanceId: "fixture-run:0", runId: "fixture-run", parentSessionId: "fake-session",
1567
+ launcher: "custom", provider: "webui-registry", name: "duplicate observer", status: "running",
1568
+ startedAt: registryNow - 2000, updatedAt: registryNow, endedAt: null,
1569
+ capabilities: { open: false, refresh: false, cancel: false, steer: false }, outputRef: { kind: "none" },
1570
+ }, { recordId: "duplicate-record" });
1571
+ await agentRunRegistry.writeRecord("external-provider", {
1572
+ version: 1, instanceId: "external-sdk", runId: "external-run", parentSessionId: null,
1573
+ launcher: "sdk", provider: "webui-registry", origin: "createAgentSession", name: "external SDK", status: "running",
1574
+ startedAt: registryNow - 1000, updatedAt: registryNow, endedAt: null,
1575
+ capabilities: { open: true, refresh: true, cancel: false, steer: false }, outputRef: { kind: "plain-log", id: "external-record" },
1576
+ }, { recordId: "external-record" });
1577
+ await agentRunRegistry.appendArtifactEvent("external-provider", "external-record", { type: "output", stream: "stdout", message: "bounded external output" });
1578
+ const corruptProducer = path.join(agentRunRegistry.paths.root, "corrupt-provider");
1579
+ await mkdir(corruptProducer, { recursive: true });
1580
+ await writeFile(path.join(corruptProducer, "corrupt-record.json"), "{not-json\n", { mode: 0o600 });
1581
+ const registryOverview = await request("127.0.0.1", "/api/subagents");
1582
+ assert.equal(registryOverview.status, 200, "registry reconciliation should isolate corrupt records");
1583
+ assert.equal(registryOverview.body?.data?.counts?.totalAgents, 3, "duplicate helper/registry identity should count once while an external agent adds one");
1584
+ assert.equal(registryOverview.body?.data?.counts?.byLauncher?.["pi-subagents"], 2);
1585
+ assert.equal(registryOverview.body?.data?.counts?.byLauncher?.sdk, 1);
1586
+ assert.equal(registryOverview.body?.data?.groups?.find((group) => group.id === "external")?.runs?.[0]?.agents?.[0]?.instanceId, "external-sdk", "an unmatched parent must group under External agents");
1587
+ assert.ok(registryOverview.body?.data?.diagnostics?.some((entry) => entry.code === "invalid-record"), "a corrupt registry record should yield only a bounded diagnostic");
1588
+ assert.equal(JSON.stringify(registryOverview.body).includes(harnessSideEffectsRoot), false, "registry overview payloads must not disclose host paths");
1589
+ const externalOutput = await request("127.0.0.1", "/api/subagents/output?group=external&run=external-run&agent=external-sdk");
1590
+ assert.equal(externalOutput.status, 200, "registry output should dispatch through its opaque server-owned record ID");
1591
+ assert.deepEqual(externalOutput.body?.data?.agent?.recentOutput, ["bounded external output"]);
1592
+ assert.equal(JSON.stringify(externalOutput.body).includes(agentRunRegistry.paths.root), false, "registry output must not expose its private path");
1593
+ const unsupportedExternalCancel = await request("127.0.0.1", "/api/subagents/cancel", { method: "POST", body: { group: "external", runId: "external-run", agentId: "external-sdk" } });
1594
+ assert.equal(unsupportedExternalCancel.status, 409, "canonical actions must reject providers without the declared capability");
1595
+
1596
+ const registryDoneAt = Date.now();
1597
+ await agentRunRegistry.writeRecord("external-provider", {
1598
+ version: 1, instanceId: "external-sdk", runId: "external-run", parentSessionId: null,
1599
+ launcher: "sdk", provider: "webui-registry", origin: "createAgentSession", name: "external SDK", status: "done",
1600
+ startedAt: registryNow - 1000, updatedAt: registryDoneAt, endedAt: registryDoneAt,
1601
+ capabilities: { open: true, refresh: true, cancel: false, steer: false }, outputRef: { kind: "plain-log", id: "external-record" },
1602
+ }, { recordId: "external-record" });
1603
+ const terminalRegistryOverview = await request("127.0.0.1", "/api/subagents");
1604
+ assert.equal(terminalRegistryOverview.body?.data?.groups?.find((group) => group.id === "external")?.runs?.[0]?.status, "done", "terminal registry runs should remain visible until dismissed");
1605
+ const dismissedExternal = await request("127.0.0.1", "/api/subagents/dismiss", {
1606
+ method: "POST",
1607
+ body: { group: "external", runId: "external-run", agentId: "external-sdk" },
1608
+ });
1609
+ assert.equal(dismissedExternal.status, 200, `terminal registry projection should be dismissible: ${dismissedExternal.body?.error || ""}`);
1610
+ assert.deepEqual(dismissedExternal.body?.data, { runId: "external-run", dismissed: true });
1611
+ const afterExternalDismiss = await request("127.0.0.1", "/api/subagents");
1612
+ assert.equal(afterExternalDismiss.body?.data?.groups?.some((group) => group.id === "external"), false, "dismissed external projections should disappear from groups");
1613
+ assert.equal(afterExternalDismiss.body?.data?.counts?.totalAgents, 2, "dismissed external projections should disappear from canonical counts");
1614
+ const retainedRegistrySnapshot = await agentRunRegistry.readRecords();
1615
+ assert.ok(retainedRegistrySnapshot.records.some((record) => record.instance.instanceId === "external-sdk"), "dismissal must not delete the producer-owned registry record");
1616
+ assert.deepEqual((await agentRunRegistry.readArtifact("external-record"))?.events?.map((event) => event.message), ["bounded external output"], "dismissal must not delete producer artifacts");
1617
+
1618
+ await agentRunRegistry.writeRecord("attached-provider", {
1619
+ version: 1, instanceId: "attached-session", runId: "attached-run", parentSessionId: null,
1620
+ launcher: "interactive", provider: "webui-registry", origin: "explicit-attach", name: "attached fixture", status: "stale",
1621
+ startedAt: registryNow - 70_000, updatedAt: registryNow - 60_000, endedAt: null,
1622
+ capabilities: { open: false, refresh: false, cancel: false, steer: false }, outputRef: { kind: "none" },
1623
+ }, { recordId: "attached-record" });
1624
+ const attachedOverview = await request("127.0.0.1", "/api/subagents");
1625
+ assert.equal(attachedOverview.body?.data?.groups?.find((group) => group.id === "external")?.runs?.find((run) => run.id === "attached-run")?.status, "stale", "explicit attached sessions should remain visibly stale until manually detached");
1626
+ const detachedAttachedSession = await request("127.0.0.1", "/api/subagents/dismiss", {
1627
+ method: "POST",
1628
+ body: { group: "external", runId: "attached-run", agentId: "attached-session" },
1629
+ });
1630
+ assert.equal(detachedAttachedSession.status, 200, `stale explicit attach projection should be detachable: ${detachedAttachedSession.body?.error || ""}`);
1631
+ const afterAttachedDetach = await request("127.0.0.1", "/api/subagents");
1632
+ assert.equal(afterAttachedDetach.body?.data?.groups?.some((group) => group.runs?.some((run) => run.id === "attached-run")), false, "detached attached-session projections should disappear from the overview");
1633
+ assert.ok((await agentRunRegistry.readRecords()).records.some((record) => record.instance.instanceId === "attached-session"), "detaching must not delete the persisted-session registry record");
1634
+ await Promise.all(["duplicate-provider", "external-provider", "attached-provider", "corrupt-provider"].map((producer) => rm(path.join(agentRunRegistry.paths.root, producer), { recursive: true, force: true })));
1635
+
1527
1636
  const dismissRunningSubagent = await request("127.0.0.1", "/api/subagents/dismiss", {
1528
1637
  method: "POST",
1529
1638
  body: { tab: tabId, runId: "fixture-run" },
@@ -3361,6 +3470,10 @@ try {
3361
3470
  const movedDirectoryRelative = "files-fixture/docs/move-dir";
3362
3471
  const deleteFileRelative = "files-fixture/delete-me.txt";
3363
3472
  const deleteDirectoryRelative = "files-fixture/delete-dir";
3473
+ const ignoredFileRelative = "files-fixture/ignored-note.txt";
3474
+ const ignoredDirectoryRelative = "files-fixture/ignored-output";
3475
+ const ignoredNestedFileRelative = "files-fixture/ignored-output/recursive-ignored-result.txt";
3476
+ const trackedPatternRelative = "files-fixture/tracked-pattern.txt";
3364
3477
  const depthEightFileRelative = "deep-search/f1/f2/f3/f4/f5/f6/depth-eight-file.txt";
3365
3478
  const depthEightDirectoryRelative = "deep-search/d1/d2/d3/d4/d5/d6/depth-eight-dir";
3366
3479
  const depthNineFileRelative = "deep-search/t1/t2/t3/t4/t5/t6/t7/too-deep-file.txt";
@@ -3381,19 +3494,54 @@ try {
3381
3494
  await writeFile(path.join(cwd, deleteFileRelative), "delete me\n", "utf8");
3382
3495
  await mkdir(path.join(cwd, deleteDirectoryRelative), { recursive: true });
3383
3496
  await writeFile(path.join(cwd, deleteDirectoryRelative, "nested.txt"), "nested delete\n", "utf8");
3497
+ await writeFile(path.join(cwd, ignoredFileRelative), "ignored file remains visible\n", "utf8");
3498
+ await mkdir(path.join(cwd, ignoredDirectoryRelative), { recursive: true });
3499
+ await writeFile(path.join(cwd, ignoredNestedFileRelative), "recursive ignored search fixture\n", "utf8");
3500
+ await writeFile(path.join(cwd, trackedPatternRelative), "tracked files remain normal\n", "utf8");
3501
+ if (gitAvailable) {
3502
+ const gitignorePath = path.join(cwd, ".gitignore");
3503
+ const gitignore = await readFile(gitignorePath, "utf8");
3504
+ await writeFile(gitignorePath, `${gitignore.replace(/\n?$/, "\n")}/files-fixture/ignored-note.txt\n/files-fixture/ignored-output/\n/files-fixture/tracked-pattern.txt\n`, "utf8");
3505
+ runGitFixture(["add", "-f", "--", trackedPatternRelative], cwd, "tracked ignore-pattern fixture should enter the Git index");
3506
+ }
3384
3507
 
3385
3508
  const fileTree = await request("127.0.0.1", `/api/files?tab=${encodeURIComponent(tabId)}&path=${encodeURIComponent("files-fixture")}`);
3386
3509
  assert.equal(fileTree.status, 200, `file tree endpoint should list workspace directories: ${fileTree.body?.error || ""}`);
3387
3510
  assert.equal(fileTree.body?.ok, true);
3388
3511
  const fileTreeEntries = fileTree.body?.data?.entries || [];
3389
3512
  assert.equal(fileTreeEntries.find((entry) => entry.name === "docs")?.type, "directory", "file tree should identify subdirectories");
3390
- assert.equal(fileTreeEntries.find((entry) => entry.name === "viewer.txt")?.type, "file", "file tree should identify regular files");
3513
+ const normalFileTreeEntry = fileTreeEntries.find((entry) => entry.name === "viewer.txt");
3514
+ assert.equal(normalFileTreeEntry?.type, "file", "file tree should identify regular files");
3515
+ assert.equal(normalFileTreeEntry?.gitIgnored, undefined, "ordinary file tree entries should omit the Git-ignore decoration");
3516
+ if (gitAvailable) {
3517
+ const ignoredFileEntry = fileTreeEntries.find((entry) => entry.path === ignoredFileRelative);
3518
+ const ignoredDirectoryEntry = fileTreeEntries.find((entry) => entry.path === ignoredDirectoryRelative);
3519
+ assert.equal(ignoredFileEntry?.type, "file", "ignored files should remain present in file tree responses");
3520
+ assert.equal(ignoredFileEntry?.gitIgnored, true, "Git-ignored files should be decorated");
3521
+ assert.equal(ignoredDirectoryEntry?.type, "directory", "ignored directories should remain present in file tree responses");
3522
+ assert.equal(ignoredDirectoryEntry?.gitIgnored, true, "Git-ignored directories should be decorated");
3523
+ assert.equal(fileTreeEntries.find((entry) => entry.path === trackedPatternRelative)?.gitIgnored, undefined, "tracked files that match an ignore pattern should remain normal");
3524
+ }
3391
3525
 
3392
3526
  const fileSearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("readme")}`);
3393
3527
  assert.equal(fileSearch.status, 200, `file search endpoint should search workspace files: ${fileSearch.body?.error || ""}`);
3394
3528
  assert.equal(fileSearch.body?.ok, true);
3395
3529
  const fileSearchEntries = fileSearch.body?.data?.entries || [];
3396
3530
  assert.equal(fileSearchEntries.find((entry) => entry.path === markdownRelative)?.type, "file", "file search should find matching files recursively");
3531
+ assert.equal(fileSearchEntries.find((entry) => entry.path === markdownRelative)?.gitIgnored, undefined, "ordinary search results should omit the Git-ignore decoration");
3532
+
3533
+ if (gitAvailable) {
3534
+ const ignoredSearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("ignored")}`);
3535
+ assert.equal(ignoredSearch.status, 200, `file search should retain Git-ignored entries: ${ignoredSearch.body?.error || ""}`);
3536
+ const ignoredSearchEntries = ignoredSearch.body?.data?.entries || [];
3537
+ assert.equal(ignoredSearchEntries.find((entry) => entry.path === ignoredFileRelative)?.gitIgnored, true, "ignored file search results should be decorated");
3538
+ assert.equal(ignoredSearchEntries.find((entry) => entry.path === ignoredDirectoryRelative)?.gitIgnored, true, "ignored directory search results should be decorated");
3539
+ assert.equal(ignoredSearchEntries.find((entry) => entry.path === ignoredNestedFileRelative)?.gitIgnored, true, "recursive search should descend into and decorate ignored directories");
3540
+
3541
+ const trackedPatternSearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("tracked-pattern")}`);
3542
+ assert.equal(trackedPatternSearch.status, 200, "tracked ignore-pattern search should be accepted");
3543
+ assert.equal(trackedPatternSearch.body?.data?.entries?.find((entry) => entry.path === trackedPatternRelative)?.gitIgnored, undefined, "tracked search results that match an ignore pattern should remain normal");
3544
+ }
3397
3545
 
3398
3546
  const directorySearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("docs")}`);
3399
3547
  assert.equal(directorySearch.status, 200, `file search endpoint should search directories: ${directorySearch.body?.error || ""}`);
@@ -3773,6 +3921,17 @@ try {
3773
3921
  });
3774
3922
  assert.equal(remoteLaunchSlotSave.status, 403, "launch-slot saves must be localhost-only before the request body is processed");
3775
3923
 
3924
+ const remoteSubagentCancel = await request(lan, "/api/subagents/cancel", {
3925
+ method: "POST",
3926
+ body: { tab: tabId, runId: "remote-request-must-not-dispatch" },
3927
+ });
3928
+ assert.equal(remoteSubagentCancel.status, 403, "subagent cancellation must be localhost-only before helper dispatch");
3929
+ const remoteSubagentDismiss = await request(lan, "/api/subagents/dismiss", {
3930
+ method: "POST",
3931
+ body: { tab: tabId, runId: "remote-request-must-not-dispatch" },
3932
+ });
3933
+ assert.equal(remoteSubagentDismiss.status, 403, "subagent dismissal must be localhost-only before helper dispatch");
3934
+
3776
3935
  const remoteFileOpenDefault = await request(lan, "/api/files/open-default", {
3777
3936
  method: "POST",
3778
3937
  body: { tab: tabId, path: viewerRelative },
@@ -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=107/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=121/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84";[\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=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");
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-v84"/, "continuity/tablet assets need a coherent cache identity");
51
- assert.match(html, /styles\.css\?v=107/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=121/, "continuity app logic must have a coherent HTML revision");
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
53
  assert.match(readme, /tabletShell=v2/, "tablet preview and rollback must be documented");
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-v84"/, "the cache identity must change with the startup graph");
41
- assert.match(html, /styles\.css\?v=107/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=121/, "the app revision must change with continuity/tablet wiring");
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");
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-v84"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v94"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");
@@ -83,7 +83,7 @@ assert.match(html, /id="sessionControlsTitle">Active session<[\s\S]*class="contr
83
83
  assert.match(html, /class="control-action-row">[\s\S]*id="modelSelect"[\s\S]*id="setModelButton"[^>]*>Apply<\/button>[\s\S]*id="thinkingSelect"[\s\S]*id="setThinkingButton"[^>]*>Apply<\/button>/, "model and thinking controls should keep their apply actions beside the selection");
84
84
  assert.match(css, /\.control-group-header[\s\S]*\.control-scope-badge[\s\S]*\.control-action-row/, "Controls should visually separate group headers, scope badges, and compact action rows");
85
85
  assert.match(html, /<label for="themeSelect"[^>]*id="themeControlLabel"[^>]*>Theme<\/label>/, "theme selector should be labeled in side-panel controls");
86
- assert.match(html, /id="themeSearchInput"[\s\S]*id="themeSelect"[\s\S]*id="themeSearchResults"/, "side-panel theme selector should expose searchable theme results");
86
+ assert.match(html, /id="themeControlLabel"[\s\S]*id="themeSelect"[\s\S]*id="themeSearchInput"[\s\S]*id="themeSearchResults"/, "side-panel theme selector should keep the compact control row before its expandable search results");
87
87
  assert.match(html, /id="backgroundInput"[^>]*type="file"[^>]*accept="image\/png,image\/jpeg,image\/webp,image\/gif"/, "side panel should expose an image picker for custom backgrounds");
88
88
  assert.match(html, /id="backgroundClearButton"[\s\S]*?>×<\/button>/, "side-panel background control should expose an X remove button");
89
89
  assert.match(html, /id="serverActionSelect"[\s\S]*<option value="restart">Restart Server<\/option>[\s\S]*<option value="stop">Stop Server<\/option>/, "side panel should expose restart and stop server actions in a dropdown");
@@ -97,7 +97,7 @@ assert.match(html, /<option value="xhigh">xhigh<\/option>\s*<option value="max">
97
97
  assert.match(app, /const SETTINGS_THINKING_OPTIONS = \["off", "minimal", "low", "medium", "high", "xhigh", "max"\]/, "native settings should expose every Pi thinking effort");
98
98
  assert.match(app, /return levels\.length \? levels : \["off", "minimal", "low", "medium", "high", "xhigh", "max"\]/, "footer thinking picker fallback should include max effort");
99
99
  assert.match(server, /const THINKING_LEVELS = \["off", "minimal", "low", "medium", "high", "xhigh", "max"\]/, "server should accept Pi's max thinking effort");
100
- assert.match(html, /id="terminalTabsLayoutSelect"[\s\S]*<option value="left">Left sidebar<\/option>/, "side panel controls should expose a terminal-tabs layout selector");
100
+ assert.match(html, /id="terminalTabsLayoutSelect"[\s\S]*<option value="left">Sidebar<\/option>/, "side panel controls should expose a terminal-tabs layout selector");
101
101
  assert.match(html, /id="terminalTabsLayoutStatus"/, "terminal-tabs layout selector should expose status text");
102
102
  assert.match(html, /id="nativeCommandDialog"/, "native slash selector UI should have a dedicated dialog");
103
103
  assert.match(html, /id="optionsWorkflowSetupButton"[^>]*data-command="\/workflow-setup"[^>]*hidden[\s\S]*Workflow Permission Setup/, "Common Pi options should expose catalog-gated Workflow Permission Setup");
@@ -633,7 +633,7 @@ assert.match(html, /id="terminalTabsBackdrop"[^>]*aria-label="Close terminal nav
633
633
  assert.match(css, /\.command-palette-close-button \{[\s\S]*?min-width:\s*44px;[\s\S]*?min-height:\s*44px/, "command palette close button should meet touch-target sizing by default");
634
634
  assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-dialog \{[\s\S]*?width:\s*min\(100vw - 0\.5rem, 42rem\)[\s\S]*?\.command-palette-list \{[\s\S]*?align-content:\s*start;[\s\S]*?grid-auto-rows:\s*max-content;[\s\S]*?scrollbar-gutter:\s*auto;[\s\S]*?\.command-palette-item \{[\s\S]*?grid-template-columns:\s*minmax\(3\.4rem, 0\.26fr\) minmax\(0, 1fr\);[\s\S]*?min-height:\s*2\.72rem;/, "mobile command palette results should keep text-height rows and use compact two-column cards");
635
635
  assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-item-kind \{[\s\S]*?font-size:\s*var\(--text-xs\);[\s\S]*?\.command-palette-item-label \{ font-size:\s*0\.82rem; \}[\s\S]*?\.command-palette-item-description \{ font-size:\s*var\(--text-xs\); \}/, "mobile command palette result text should respect the typography floor");
636
- assert.match(css, /body\.terminal-tabs-left \.chat-panel \{[\s\S]*?grid-template-columns:\s*clamp\(13rem, 18vw, 19rem\) minmax\(0, 1fr\)/, "terminal tabs left layout should split the chat panel into a sidebar and transcript area");
636
+ assert.match(css, /body\.terminal-tabs-left \.chat-panel \{[\s\S]*?grid-template-columns:\s*minmax\(13rem, var\(--terminal-tabs-sidebar-width\)\) minmax\(0, 1fr\)/, "terminal tabs left layout should split the chat panel into a resizable sidebar and transcript area");
637
637
  assert.match(css, /body\.terminal-tabs-left \.terminal-tabs-shell \{[\s\S]*?grid-column:\s*1;[\s\S]*?grid-row:\s*1 \/ -1;[\s\S]*?flex-direction:\s*column/, "terminal tabs left layout should turn the top tab strip into a vertical sidebar");
638
638
  assert.match(html, /class="terminal-sidebar-actions"[^>]*aria-label="Tab and workspace actions"[\s\S]*id="workspaceSaveButton"[^>]*aria-label="Save workspace"[\s\S]*id="commandPaletteButton"[^>]*aria-label="Open command palette"[\s\S]*id="workspaceDashboardToggleButton"[^>]*aria-label="Show workspace overview"/, "save, command, and workspace actions should share one accessibly labelled sidebar toolbar");
639
639
  assert.doesNotMatch(html, /id="splitTabButton"|class="terminal-split-button"/, "the global terminal-header Split control should be removed");
@@ -1144,7 +1144,10 @@ assert.match(app, /function renderOptionalFeaturePanel\(\)/, "side panel should
1144
1144
  assert.match(app, /const OPTIONAL_FEATURE_SECTIONS = \[[\s\S]*label: "Composer & commands"[\s\S]*label: "Workflows & releases"[\s\S]*label: "Safety & access"[\s\S]*label: "UI widgets & native parity"[\s\S]*featureIds: \[[^\]]*"questionnaire"[\s\S]*label: "Conversation"/, "optional features should be grouped into five type subsections with questionnaires under native parity");
1145
1145
  assert.match(app, /function renderOptionalFeatureSection\(section, features\)[\s\S]*optional-feature-section[\s\S]*optional-feature-section-title[\s\S]*optional-feature-section-list/, "optional feature panel should render subsection headers and lists");
1146
1146
  assert.match(app, /async function refreshQuestionnaireFeatureAvailability[\s\S]*\/api\/tools\?scope=session[\s\S]*tool\?\.name === "questionnaire"/, "questionnaire availability should be detected from the active Pi tab's loaded tool capability");
1147
- assert.match(app, /detected && feature\.manageWith === "tools"[\s\S]*action\.textContent = "Tools…"[\s\S]*openNativeToolsSelector/, "loaded questionnaire access should be managed through the native Tools selector instead of a cosmetic WebUI disable toggle");
1147
+ 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
+ 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
+ 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");
1148
1151
  assert.match(app, /function setSidePanelSectionCollapsed\(record, collapsed/, "side panel sections should have explicit collapse/expand behavior");
1149
1152
  assert.match(
1150
1153
  app,
@@ -1600,7 +1603,7 @@ assert.match(app, /id: "safetyGuard"[\s\S]*?@firstpick\/pi-extension-safety-guar
1600
1603
  assert.match(app, /id: "tuiSkillsCommand"[\s\S]*?@firstpick\/pi-extension-setup-skills/, "optional features should include the TUI skills command companion");
1601
1604
  assert.match(app, /id: "tuiToolsCommand"[\s\S]*?@firstpick\/pi-extension-tools/, "optional features should include the TUI tools command companion");
1602
1605
  assert.match(app, /id: "remoteWebui"[\s\S]*?@firstpick\/pi-package-remote-webui/, "optional features should include the Remote WebUI companion");
1603
- 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 and delegate access control to Tools");
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");
1604
1607
  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");
1605
1608
  assert.match(app, /NATURAL_CONVERSATION_COMMAND_NAMES = \["talk", "voice", "conversation"\]/, "frontend should detect Natural Conversation only from RPC-visible command aliases");
1606
1609
  assert.match(app, /const conversationModeByTab = new Map\(\)/, "frontend should track Natural Conversation state per terminal tab");
@@ -1914,12 +1917,22 @@ assert.doesNotMatch(app, /runIndicatorTimestamp/, "active agent indicator should
1914
1917
  assert.match(app, /runIndicatorBubble = make\("article", "message runIndicator run-indicator-message streaming"\)/, "active agent indicator should retain its dedicated streaming-card appearance");
1915
1918
  assert.match(html, /id="chat" class="chat" aria-live="polite"[\s\S]*?<\/div>\s*<div id="runIndicatorHost" class="run-indicator-host"><\/div>/, "active agent indicator should have a dedicated host immediately after the transcript");
1916
1919
  assert.match(css, /\.run-indicator-host\s*\{[\s\S]*?padding: 0 1rem 1rem;/, "the dedicated run-indicator host should preserve the transcript card inset");
1920
+ assert.match(css, /\.run-indicator-row\s*\{[\s\S]*?flex-wrap:\s*nowrap;[\s\S]*?overflow:\s*hidden;[\s\S]*?\.run-indicator-meta\s*\{[\s\S]*?min-width:\s*0;[\s\S]*?text-overflow:\s*ellipsis;[\s\S]*?white-space:\s*nowrap;/, "changing run activity text should stay on one clipped line without resizing the status card");
1917
1921
  assert.match(app, /function standaloneLiveTranscriptBubbles\(\)[\s\S]*?streamThinkingBubble[\s\S]*?streamToolCallBubble[\s\S]*?streamBubble[\s\S]*?compactThinkingBubble[\s\S]*?compactTextBubble/, "transcript reconciliation should identify standalone live-tail bubbles that must stay mounted");
1918
1922
  assert.match(app, /function resetChatOutput\(\)[\s\S]*?liveBubbles = standaloneLiveTranscriptBubbles\(\)[\s\S]*?preservedNodes[\s\S]*?child === elements\.stickyUserPromptButton \|\| liveBubbles\.has\(child\)[\s\S]*?transcriptRenderer\.replaceChildren\(elements\.chat, \.\.\.preservedNodes\)/, "transcript resets should reconcile through the coordinator while preserving only transcript-owned live output");
1919
1923
  assert.match(app, /function appendChatMessageBubble\(bubble, \{ liveTail = false \} = \{\}\)[\s\S]*?!liveTail && liveBubbles\.has\(child\)[\s\S]*?insertBefore\(bubble, tailAnchor\)/, "reconciled history should preserve the stable live transcript tail while new live output stays chronological");
1920
1924
  assert.match(app, /appendChatMessageBubble\(created\.bubble, \{ liveTail: streaming \|\| message\?\.live === true \}\)/, "streaming thinking, assistant text, and live tools should append after earlier live output");
1921
1925
  assert.match(app, /setChatScrollTopInstant\(Math\.min\(previousScrollTop, elements\.chat\.scrollHeight\)\)/, "paused-reader scroll restoration should bypass smooth scrolling to avoid a down-then-back animation");
1922
1926
  assert.match(app, /function ensureRunIndicatorBubble\(\)[\s\S]*?!runIndicatorBubble \|\| !runIndicatorText \|\| !runIndicatorMeta[\s\S]*?runIndicatorBubble\.parentElement !== elements\.runIndicatorHost[\s\S]*?elements\.runIndicatorHost\.replaceChildren\(runIndicatorBubble\)/, "active agent indicator should reuse its existing bubble in the dedicated status host");
1927
+ assert.match(app, /function tabsRenderSnapshotSignature\(tabList = \[\]\)[\s\S]*?const tabsRenderChanged = previousTabsRenderSignature !== tabsRenderSnapshotSignature\(nextTabs\);[\s\S]*?if \(tabsChanged\) \{[\s\S]*?syncTabMetadata\(tabs\);[\s\S]*?if \(tabsRenderChanged \|\| activeTabId !== previousActiveTabId \|\| selectStored\) renderTabs\(\);[\s\S]*?else syncTabPolling\(\);/, "unchanged background-tab polling should not rebuild terminal chrome or disturb the followed transcript");
1928
+ assert.match(app, /function updateSessionSummaryForTab\([\s\S]*?if \(previous && tabsSnapshotSignature\(previous\) === tabsSnapshotSignature\(normalized\)\) return previous;/, "unchanged session-summary metadata should not schedule another terminal-strip render");
1929
+ assert.match(app, /function updateStickyUserPromptButton\(\)[\s\S]*?const renderSignature = JSON\.stringify\([\s\S]*?button\.dataset\.renderSignature === renderSignature\) return;[\s\S]*?button\.replaceChildren\(\.\.\.children\);/, "focus reconciliation should preserve unchanged sticky-prompt children instead of disturbing chat scroll anchoring");
1930
+ assert.match(app, /let tabStateCache = new Map\(\);[\s\S]*?let tabStatsCache = new Map\(\);[\s\S]*?let tabWorkspaceCache = new Map\(\);[\s\S]*?function cachedStateForTabSwitch[\s\S]*?latestStats = activeTabId \? tabStatsCache\.get\(activeTabId\)[\s\S]*?latestWorkspace = activeTabId \? tabWorkspaceCache\.get\(activeTabId\)[\s\S]*?restoreComposerActionSlotLayout\(\);/, "terminal switching should restore cached run, context, workspace, and composer geometry before repainting");
1931
+ assert.match(app, /const activityState = tab\?\.running && pendingExtensionUiRequestCount > 0[\s\S]*?pendingExtensionUiRequestCount,[\s\S]*?activityState,/, "tab polling should compare rendered activity state instead of volatile lifecycle metadata");
1932
+ assert.match(app, /const statusText = sidebarPresentation[\s\S]*?controlDeckPlacementStatus\.textContent !== statusText/, "foreground layout reconciliation should not rewrite unchanged Control Deck status text");
1933
+ assert.match(app, /const optionsSignature = JSON\.stringify\(matchingModels\.map[\s\S]*?modelSelect\.dataset\.optionsSignature !== optionsSignature/, "foreground model refreshes should preserve an unchanged model selector DOM");
1934
+ assert.match(app, /function renderSessionSummaryControls\(\)[\s\S]*?renderSignature === sessionSummaryControlsRenderSignature\) return;[\s\S]*?sessionSummaryControlsRenderSignature = renderSignature;/, "foreground command refreshes should not schedule unchanged session-summary tab chrome");
1935
+ assert.match(app, /const previousCatalog = commandCatalogsByTab\.get\(tabContext\.tabId\);[\s\S]*?tabsSnapshotSignature\(previousCatalog\) !== tabsSnapshotSignature\(catalog\)\) scheduleTabsRender\(\);/, "foreground command refreshes should retain unchanged terminal controls");
1923
1936
  assert.doesNotMatch(app, /elements\.chat\.(?:append|insertBefore)\(runIndicatorBubble/, "the active agent indicator must never be mounted in the transcript");
1924
1937
  assert.match(app, /const headline = runIndicatorHeadline\(\);\n\s+if \(runIndicatorText\.textContent !== headline\) runIndicatorText\.textContent = headline;/, "active agent indicator should avoid redundant headline DOM writes that can flicker");
1925
1938
  assert.match(app, /const meta = runIndicatorShowsElapsed\(\) \? `\$\{detail\} · run time[\s\S]*?if \(runIndicatorMeta\.textContent !== meta\) runIndicatorMeta\.textContent = meta;/, "active agent indicator should avoid redundant metadata DOM writes except elapsed changes");
@@ -46,7 +46,7 @@ assert.doesNotMatch(botClient, /OPENAI_API_KEY|GITHUB_APP_|PRIVATE_KEY/, "the br
46
46
 
47
47
  assert.match(html, /__PI_WEBUI_ISSUE_BOT_CONFIG__[\s\S]*?enabled: false/, "the page must expose only disabled-by-default public runtime configuration");
48
48
  assert.match(html, /id="openIssueButton"[\s\S]*?aria-controls="issueWizardDialog"/, "the persistent Control Deck action must target the dialog");
49
- assert.match(html, /<footer class="side-panel-footer">[\s\S]*?id="openIssueButton"/, "the action must stay outside scrolling Control Deck content");
49
+ assert.match(html, /<footer class="side-panel-footer" data-control-deck-shared-footer>[\s\S]*?id="openIssueButton"/, "the singleton action must stay outside scrolling Control Deck content while rehosting with the active shell");
50
50
  assert.match(html, /<dialog id="issueWizardDialog"[\s\S]*?aria-labelledby="issueWizardTitle"[\s\S]*?aria-describedby="issueWizardDescription"/, "the dialog must have an accessible name and description");
51
51
  for (const step of [1, 2, 3, 4, 5]) assert.match(html, new RegExp(`data-issue-wizard-page="${step}"`), `step ${step} markup must exist`);
52
52
  assert.match(html, /id="issueWizardStatus"[^>]*role="status"[^>]*aria-live="polite"/, "wizard progress must retain its accessible live region");
@@ -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-v84/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v94/, "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
 
@@ -14,7 +14,7 @@ const [html, app, serviceWorker] = await Promise.all([
14
14
 
15
15
  assert.match(
16
16
  app,
17
- /const UI_LAYOUT_SCHEMA_VERSION = 1;[\s\S]*const UI_LAYOUT_ENDPOINT = "\/api\/interface-preferences";/,
17
+ /const UI_LAYOUT_SCHEMA_VERSION = 2;[\s\S]*const UI_LAYOUT_ENDPOINT = "\/api\/interface-preferences";/,
18
18
  "the browser controller should target the accepted version-1 layout schema on the existing interface-preferences endpoint",
19
19
  );
20
20
  assert.match(
@@ -24,7 +24,7 @@ assert.match(
24
24
  );
25
25
  assert.match(
26
26
  app,
27
- /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["sectionOrder", "collapsedSectionIds", "hiddenSectionIds", "collapsed"\];/,
27
+ /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/,
28
28
  "Control Deck durable layout should contain only order, visibility, and collapse state",
29
29
  );
30
30
  for (const [constant, value] of [
@@ -68,12 +68,12 @@ assert.match(
68
68
  );
69
69
  assert.match(
70
70
  app,
71
- /function applyDurableUiLayoutSnapshot[\s\S]*!isDirty && !generationChanged && !durableUiLayoutInteractionActive\(field\)[\s\S]*applicable\[subfield\] = remote[\s\S]*applyDurableUiLayoutField\(field, applicable\)/,
71
+ /function applyDurableUiLayoutSnapshot[\s\S]*const activelyManipulated[\s\S]*!isDirty && !activelyManipulated && !generationChanged[\s\S]*applicable\[subfield\] = remote[\s\S]*applyDurableUiLayoutField\(field, applicable\)/,
72
72
  "non-dirty sibling subfields should still adopt authoritative server values",
73
73
  );
74
74
  assert.match(
75
75
  app,
76
- /function applyDurableUiLayoutSnapshot[\s\S]*!isDirty && !durableUiLayoutValuePresent\(remote\) && durableUiLayoutValuePresent\(local\)[\s\S]*markDurableUiLayoutDirty\(field, subfield\)/,
76
+ /function applyDurableUiLayoutSnapshot[\s\S]*const remotePresent = durableUiLayoutSubfieldValuePresent\(field, subfield, remote\)[\s\S]*!isDirty && !remotePresent && durableUiLayoutValuePresent\(local\)[\s\S]*markDurableUiLayoutDirty\(field, subfield\)/,
77
77
  "missing server subfields should migrate only their valid local values",
78
78
  );
79
79
  assert.match(
@@ -96,7 +96,7 @@ assert.match(
96
96
  );
97
97
  assert.match(
98
98
  app,
99
- /const UI_LAYOUT_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v3:";[\s\S]*function durableUiLayoutPendingMutationRecords\(\)[\s\S]*key\?\.startsWith\(UI_LAYOUT_PENDING_STORAGE_PREFIX\)[\s\S]*value\.version !== 3[\s\S]*function restoreDurableUiLayoutPendingJournal\(\)[\s\S]*candidate\.value[\s\S]*subfieldMutationIds[\s\S]*scheduleDurableUiLayoutSave\(\)/,
99
+ /const UI_LAYOUT_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v4:";[\s\S]*const UI_LAYOUT_LEGACY_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v3:";[\s\S]*function durableUiLayoutPendingMutationRecords\(\)[\s\S]*UI_LAYOUT_LEGACY_PENDING_STORAGE_PREFIX[\s\S]*!\[3, 4\]\.includes\(value\.version\)[\s\S]*function restoreDurableUiLayoutPendingJournal\(\)[\s\S]*candidate\.value[\s\S]*subfieldMutationIds[\s\S]*scheduleDurableUiLayoutSave\(\)/,
100
100
  "per-writer pending layout values should survive reload without one tab replacing another tab's journal",
101
101
  );
102
102
  assert.match(
@@ -121,7 +121,7 @@ assert.match(
121
121
  );
122
122
  assert.match(
123
123
  app,
124
- /async function flushDurableUiLayoutSave[\s\S]*body: \{ layout: patch, expectedLayoutRevision: durableLayoutRevision \}/,
124
+ /async function flushDurableUiLayoutSave[\s\S]*body: \{[\s\S]*layout: patch,[\s\S]*expectedLayoutRevision: durableLayoutRevision[\s\S]*\}/,
125
125
  "layout writes should submit the latest known opaque revision",
126
126
  );
127
127
  assert.match(
@@ -169,7 +169,7 @@ assert.match(
169
169
  // --- Every approved arrangement surface is durable -------------------------
170
170
 
171
171
  for (const [persistFunction, field, subfield] of [
172
- ["persistSidePanelSectionOrder", "sidePanel", "sectionOrder"],
172
+ ["persistSidePanelSectionOrder", "sidePanel", "sectionLayout"],
173
173
  ["persistSidePanelSectionState", "sidePanel", "collapsedSectionIds"],
174
174
  ["persistSidePanelSectionVisibility", "sidePanel", "hiddenSectionIds"],
175
175
  ["persistComposerActionOrder", "composerActions", null],
@@ -184,18 +184,18 @@ for (const [persistFunction, field, subfield] of [
184
184
  : `markDurableUiLayoutDirty\\("${field}"\\)`;
185
185
  assert.match(
186
186
  app,
187
- new RegExp(`function ${persistFunction}\\([^)]*\\) \\{[\\s\\S]*?${marker};\\s*\\n\\}`),
187
+ new RegExp(`(?:function ${persistFunction}\\([^)]*\\)|function persistControlDeckSectionLayout\\([^)]*\\)) \\{[\\s\\S]*?${marker};\\s*\\n\\}`),
188
188
  `${persistFunction} should mark only its owned durable layout value after writing the local cache`,
189
189
  );
190
190
  }
191
191
  assert.match(
192
192
  app,
193
- /localStorage\.setItem\(SIDE_PANEL_STORAGE_KEY, collapsed \? "1" : "0"\);[\s\S]{0,200}markDurableUiLayoutDirty\("sidePanel", "collapsed"\)/,
193
+ /localStorage\.setItem\(SIDE_PANEL_STORAGE_KEY, collapsed \? "1" : "0"\);[\s\S]{0,300}markDurableUiLayoutDirty\("sidePanel", "collapsedPanels"\)/,
194
194
  "Control Deck collapse state should be durable without dirtying sibling settings",
195
195
  );
196
196
  assert.match(
197
197
  app,
198
- /function restoreSidePanelState\(\)[\s\S]*setSidePanelCollapsed\(stored \?\? false, \{ persist: false \}\)/,
198
+ /function restoreSidePanelState\(\)[\s\S]*persist: false[\s\S]*side:/,
199
199
  "passive Control Deck restoration must not echo stale cache back to the server",
200
200
  );
201
201
  assert.doesNotMatch(
@@ -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-v84"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=107/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=121"/, "the boot loader should request the updated app module revision");
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");
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=107/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=121/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "questionnaire public assets need a coherent PWA cache revision");
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");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");