@firstpick/pi-package-webui 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +31 -9
  2. package/bin/pi-webui-launcher.mjs +23 -12
  3. package/bin/pi-webui.mjs +729 -93
  4. package/index.ts +266 -1
  5. package/lib/agent-run-adapters.mjs +500 -0
  6. package/lib/agent-run-protocol.mjs +262 -0
  7. package/lib/agent-run-registry.mjs +339 -0
  8. package/lib/git-workflow-preferences.mjs +18 -28
  9. package/lib/intercom-conversations.mjs +491 -0
  10. package/lib/intercom-transcript-filter.mjs +99 -0
  11. package/lib/resource-selection.mjs +140 -0
  12. package/lib/trust-boundaries.mjs +2 -0
  13. package/lib/ui-layout-settings.mjs +172 -28
  14. package/lib/update/package-layout.mjs +50 -0
  15. package/lib/update/plan.mjs +11 -0
  16. package/package.json +2 -2
  17. package/public/app.js +2276 -419
  18. package/public/index.html +142 -72
  19. package/public/service-worker.js +2 -1
  20. package/public/stream-output-controller.mjs +15 -0
  21. package/public/styles.css +764 -92
  22. package/public/syntax-highlight.mjs +622 -0
  23. package/tests/agent-run-adapters.test.mjs +217 -0
  24. package/tests/agent-run-launcher.test.mjs +41 -0
  25. package/tests/agent-run-protocol.test.mjs +82 -0
  26. package/tests/agent-run-registry.test.mjs +102 -0
  27. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  28. package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
  29. package/tests/browser/controls-layout.spec.mjs +122 -0
  30. package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
  31. package/tests/browser/interaction-continuity.spec.mjs +161 -0
  32. package/tests/browser/intercom-conversation-viewer.spec.mjs +355 -0
  33. package/tests/browser/mobile-foundation.spec.mjs +26 -0
  34. package/tests/browser/model-search-focus.spec.mjs +96 -0
  35. package/tests/browser/optimistic-prompt.spec.mjs +22 -0
  36. package/tests/browser/persistent-ui-layout.spec.mjs +285 -66
  37. package/tests/browser/resource-profiles.spec.mjs +200 -0
  38. package/tests/browser/subagent-observability.spec.mjs +116 -0
  39. package/tests/codex-fast-mode-static.test.mjs +7 -6
  40. package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
  41. package/tests/common-options-submenus-markup-static.test.mjs +1 -0
  42. package/tests/component-update-api-static.test.mjs +2 -1
  43. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  44. package/tests/composer-skill-tag-layout.test.mjs +32 -2
  45. package/tests/control-deck-component-updates-static.test.mjs +6 -0
  46. package/tests/control-deck-side-panels-static.test.mjs +68 -0
  47. package/tests/controls-layout-static.test.mjs +22 -0
  48. package/tests/fast-mode-client-static.test.mjs +2 -2
  49. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  50. package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
  51. package/tests/file-tree-git-ignored-static.test.mjs +152 -0
  52. package/tests/file-tree-search-layout-static.test.mjs +2 -1
  53. package/tests/file-viewer-image-static.test.mjs +69 -0
  54. package/tests/fixtures/fake-pi.mjs +147 -12
  55. package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
  56. package/tests/git-panel-file-preview-static.test.mjs +5 -5
  57. package/tests/git-panel-live-updates-static.test.mjs +3 -3
  58. package/tests/git-workflow-preferences.test.mjs +55 -6
  59. package/tests/http-endpoints-harness.test.mjs +295 -14
  60. package/tests/intercom-conversation-viewer-static.test.mjs +105 -0
  61. package/tests/intercom-conversations-http.test.mjs +252 -0
  62. package/tests/intercom-conversations.test.mjs +374 -0
  63. package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
  64. package/tests/intercom-tag-layout-static.test.mjs +46 -0
  65. package/tests/intercom-transcript-filter.test.mjs +98 -0
  66. package/tests/main-output-loading-static.test.mjs +59 -0
  67. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  68. package/tests/mobile-compact-layout.test.mjs +2 -3
  69. package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
  70. package/tests/mobile-foundation-static.test.mjs +3 -3
  71. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  72. package/tests/mobile-static.test.mjs +76 -42
  73. package/tests/native-parity.test.mjs +8 -7
  74. package/tests/open-issue-wizard-static.test.mjs +2 -2
  75. package/tests/optional-feature-migration-frontend.test.mjs +5 -5
  76. package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
  77. package/tests/persistent-ui-layout-static.test.mjs +13 -13
  78. package/tests/questionnaire-dialog.test.mjs +3 -3
  79. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  80. package/tests/resource-defaults-helper.test.mjs +60 -6
  81. package/tests/resource-selection.test.mjs +114 -0
  82. package/tests/resource-tui-extension.test.mjs +23 -0
  83. package/tests/session-sampling-ui-static.test.mjs +3 -3
  84. package/tests/side-panel-context-menu-static.test.mjs +1 -1
  85. package/tests/side-panel-resize-static.test.mjs +26 -16
  86. package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
  87. package/tests/side-panel-section-reorder-static.test.mjs +16 -70
  88. package/tests/stream-output-controller.test.mjs +8 -0
  89. package/tests/stream-output-isolation-static.test.mjs +2 -2
  90. package/tests/streaming-ui-coupling.test.mjs +5 -0
  91. package/tests/subagent-gate-visibility.test.mjs +2 -1
  92. package/tests/subagent-launch-slots.test.mjs +1 -1
  93. package/tests/subagent-observability-static.test.mjs +32 -0
  94. package/tests/subagent-reliability-integration.test.mjs +183 -0
  95. package/tests/subagent-workflow-section-static.test.mjs +67 -0
  96. package/tests/subagents-helper.test.mjs +548 -5
  97. package/tests/syntax-highlight.test.mjs +235 -0
  98. package/tests/syntax-highlighting-static.test.mjs +84 -0
  99. package/tests/terminal-tabs-resize-static.test.mjs +35 -0
  100. package/tests/theme-customizer-static.test.mjs +5 -5
  101. package/tests/thinking-format-parser.test.mjs +64 -0
  102. package/tests/ui-layout-settings.test.mjs +104 -32
  103. package/tests/update-api-harness.test.mjs +24 -10
  104. package/tests/update-package-layout.test.mjs +38 -0
  105. package/tests/update-plan.test.mjs +11 -1
  106. package/tests/webui-settings-locking.test.mjs +33 -3
  107. package/webui-rpc-helper.mjs +700 -89
@@ -34,9 +34,33 @@ const root = await mkdtemp(path.join(tmpdir(), "pi-webui-git-preferences-"));
34
34
  const settingsFile = path.join(root, "settings.json");
35
35
 
36
36
  try {
37
- await writeFile(settingsFile, `${JSON.stringify({ version: 1, remoteAuthEnabled: true }, null, 2)}\n`, "utf8");
37
+ const completeV1Layout = {
38
+ version: 1,
39
+ sidePanel: {
40
+ sectionOrder: ["files", "controls", "git"],
41
+ collapsedSectionIds: ["git"],
42
+ hiddenSectionIds: ["files"],
43
+ collapsed: true,
44
+ },
45
+ composerActions: {
46
+ order: ["new", "git", "send"],
47
+ grid: { version: 2, columns: 12, positions: { new: 0, git: 1, send: 10 } },
48
+ },
49
+ footerScopedModelOrder: ["fake/model"],
50
+ terminalTabs: {
51
+ layout: "left",
52
+ customGroups: { version: 1, groups: [{ id: "group-1", title: "Group 1", tabIds: ["tab-a"] }] },
53
+ },
54
+ fileViewerWidth: 560,
55
+ };
56
+ await writeFile(settingsFile, `${JSON.stringify({
57
+ version: 6,
58
+ remoteAuthEnabled: true,
59
+ interfacePreferences: { sidePanelWidth: 612 },
60
+ uiLayout: completeV1Layout,
61
+ }, null, 2)}\n`, "utf8");
38
62
  const migrated = await readWebuiSettings(settingsFile);
39
- assert.equal(migrated.version, 6);
63
+ assert.equal(migrated.version, 8);
40
64
  assert.equal(migrated.remoteAuthEnabled, true, "legacy Remote PIN state should survive schema migration");
41
65
  assert.equal(migrated.outputModeDefault, "normal", "legacy settings should default browser output to normal");
42
66
  assert.equal(isGitWorkflowSetupComplete(migrated.gitWorkflow), false);
@@ -45,10 +69,31 @@ try {
45
69
  assert.equal(migrated.gitWorkflow.stagingPolicy, "review");
46
70
  assert.equal(migrated.gitWorkflow.reviewProcessEnabled, true, "legacy settings should preserve the existing review-process behavior");
47
71
  assert.equal(migrated.gitWorkflow.generation.thinkingLevel, "low");
48
- assert.equal(migrated.uiLayout.version, 1);
49
- assert.equal(migrated.uiLayout.sidePanel.sectionOrder, null);
72
+ assert.equal(migrated.uiLayout.version, 2);
73
+ assert.equal(migrated.uiLayout.sidePanel.placement, "right");
74
+ assert.deepEqual(migrated.uiLayout.sidePanel.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: [] });
75
+ assert.deepEqual(migrated.uiLayout.sidePanel.collapsedSectionIds, ["git"]);
76
+ assert.deepEqual(migrated.uiLayout.sidePanel.hiddenSectionIds, ["files"]);
77
+ assert.deepEqual(migrated.uiLayout.sidePanel.collapsedPanels, { left: false, right: true });
78
+ assert.deepEqual(migrated.uiLayout.sidePanel.panelWidths, { left: 384, right: 612 }, "legacy width must seed the migrated right width");
79
+ await writeFile(path.join(root, "width-only.json"), `${JSON.stringify({ version: 6, interfacePreferences: { sidePanelWidth: 700 } })}\n`, "utf8");
80
+ assert.deepEqual(
81
+ (await readWebuiSettings(path.join(root, "width-only.json"))).uiLayout.sidePanel.panelWidths,
82
+ { left: 384, right: 700 },
83
+ "legacy width-only settings must seed v2 even without a v1 uiLayout envelope",
84
+ );
85
+ assert.deepEqual(migrated.uiLayout.composerActions, completeV1Layout.composerActions);
86
+ assert.deepEqual(migrated.uiLayout.footerScopedModelOrder, completeV1Layout.footerScopedModelOrder);
87
+ assert.deepEqual(migrated.uiLayout.terminalTabs, { ...completeV1Layout.terminalTabs, sidebarWidth: null });
88
+ assert.equal(migrated.uiLayout.fileViewerWidth, 560);
50
89
 
51
- await writeFile(settingsFile, `${JSON.stringify({ version: 4, remoteAuthEnabled: true, outputModeDefault: "unsupported" }, null, 2)}\n`, "utf8");
90
+ await writeFile(settingsFile, `${JSON.stringify({
91
+ version: 6,
92
+ remoteAuthEnabled: true,
93
+ outputModeDefault: "unsupported",
94
+ interfacePreferences: { sidePanelWidth: 612 },
95
+ uiLayout: completeV1Layout,
96
+ }, null, 2)}\n`, "utf8");
52
97
  assert.equal((await readWebuiSettings(settingsFile)).outputModeDefault, "normal", "invalid persisted output modes must fail closed to normal");
53
98
 
54
99
  const saved = await writeGitWorkflowPreferences({
@@ -82,7 +127,11 @@ try {
82
127
  assert.equal(partiallyUpdated.reviewProcessEnabled, false, "partial updates should preserve the review-process choice");
83
128
 
84
129
  const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
85
- assert.equal(persisted.version, 6);
130
+ assert.equal(persisted.version, 8);
131
+ assert.equal(persisted.uiLayout.version, 2, "the first unrelated locked write must persist the migrated v2 envelope");
132
+ assert.deepEqual(persisted.uiLayout.sidePanel.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: [] });
133
+ assert.deepEqual(persisted.uiLayout.composerActions, completeV1Layout.composerActions, "unchanged v1 composer fields must survive persistence");
134
+ assert.deepEqual(persisted.uiLayout.terminalTabs, { ...completeV1Layout.terminalTabs, sidebarWidth: null }, "unchanged v1 terminal fields must survive persistence while new width state defaults safely");
86
135
  assert.equal(persisted.remoteAuthEnabled, true);
87
136
  assert.equal(persisted.outputModeDefault, "compact-v1", "output-mode default should persist beside existing Web UI settings");
88
137
  assert.equal(persisted.gitWorkflow.generation.provider, "fake");
@@ -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");
@@ -243,6 +246,33 @@ const voiceProvider = createServer(async (req, res) => {
243
246
  await new Promise((resolve) => voiceProvider.listen(0, "127.0.0.1", resolve));
244
247
  const voiceProviderPort = voiceProvider.address().port;
245
248
 
249
+ const startupRegistryNow = Date.now();
250
+ const startupRegistryProducers = ["startup-running", "startup-stale", "startup-lost", "startup-done"];
251
+ for (const [producerId, status, updatedAt] of [
252
+ ["startup-running", "running", startupRegistryNow],
253
+ ["startup-stale", "stale", startupRegistryNow - 60_000],
254
+ ["startup-lost", "running", startupRegistryNow - 180_000],
255
+ ["startup-done", "done", startupRegistryNow - 5_000],
256
+ ]) {
257
+ const terminal = status === "done";
258
+ await agentRunRegistry.writeRecord(producerId, {
259
+ version: 1,
260
+ instanceId: producerId,
261
+ runId: `${producerId}-run`,
262
+ parentSessionId: null,
263
+ launcher: "sdk",
264
+ provider: "webui-registry",
265
+ origin: "startup-regression-fixture",
266
+ name: producerId,
267
+ status,
268
+ startedAt: updatedAt - 1_000,
269
+ updatedAt,
270
+ endedAt: terminal ? updatedAt : null,
271
+ capabilities: { open: false, refresh: false, cancel: false, steer: false },
272
+ outputRef: { kind: "none" },
273
+ }, { recordId: `${producerId}-record` });
274
+ }
275
+
246
276
  const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "0.0.0.0", "--port", String(port), "--pi", fakePiCli], {
247
277
  stdio: ["ignore", "pipe", "pipe"],
248
278
  env: {
@@ -253,6 +283,7 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "0.
253
283
  GIT_COMMITTER_EMAIL: "pi-webui-test@example.invalid",
254
284
  PATH: `${fakeOpenBinDir}${path.delimiter}${process.env.PATH || ""}`,
255
285
  PI_CODING_AGENT_DIR: workflowPolicyAgentDir,
286
+ XDG_STATE_HOME: agentRunStateHome,
256
287
  PI_WEBUI_SETTINGS_FILE: settingsFile,
257
288
  PI_SESSION_SUMMARY_CONFIG_FILE: sessionSummaryConfigFile,
258
289
  PI_WEBUI_RPC_SUPERVISOR: "1",
@@ -466,6 +497,13 @@ try {
466
497
  assert.equal(health.body.piRunning, true, "fake pi RPC process should be attached and running");
467
498
  assert.match(health.body.piVersion, /^\d+\.\d+\.\d+/, "health metadata should expose the installed Pi version");
468
499
 
500
+ const startupSubagents = await request("127.0.0.1", "/api/subagents");
501
+ const startupExternalAgents = startupSubagents.body?.data?.groups
502
+ ?.find((group) => group.id === "external")?.runs
503
+ ?.flatMap((run) => run.agents.map((agent) => ({ name: agent.name, status: agent.status }))) || [];
504
+ assert.deepEqual(startupExternalAgents, [{ name: "startup-running", status: "running" }], "startup should attach only active registry agents, not pre-existing stale, lost, or completed records");
505
+ await Promise.all(startupRegistryProducers.map((producer) => rm(path.join(agentRunRegistry.paths.root, producer), { recursive: true, force: true })));
506
+
469
507
  const managedThemesResponse = await request("127.0.0.1", "/api/themes");
470
508
  assert.equal(managedThemesResponse.status, 200, managedThemesResponse.body?.error);
471
509
  assert.equal(managedThemesResponse.body?.data?.source, "@firstpick/pi-themes-bundle");
@@ -772,8 +810,8 @@ try {
772
810
  const initialInterfacePreferences = await request("127.0.0.1", "/api/interface-preferences");
773
811
  assert.equal(initialInterfacePreferences.status, 200);
774
812
  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);
813
+ assert.equal(initialInterfacePreferences.body?.data?.layout?.version, 2);
814
+ assert.deepEqual(initialInterfacePreferences.body?.data?.layout?.sidePanel?.sectionLayout, { order: null, leftSectionIds: null });
777
815
  assert.match(initialInterfacePreferences.body?.data?.layoutRevision || "", /^[a-f0-9]{64}$/);
778
816
  assert.equal(Object.hasOwn(initialInterfacePreferences.body?.data || {}, "path"), false, "preference responses must not disclose the user's settings-file path");
779
817
  const initialLayoutRevision = initialInterfacePreferences.body.data.layoutRevision;
@@ -801,50 +839,69 @@ try {
801
839
  sidePanelWidth: 620,
802
840
  expectedLayoutRevision: initialLayoutRevision,
803
841
  layout: {
804
- version: 1,
805
- sidePanel: { sectionOrder: ["files", "controls", "git"], collapsedSectionIds: ["git"], hiddenSectionIds: [], collapsed: false },
842
+ version: 2,
843
+ sidePanel: {
844
+ placement: "both",
845
+ sectionLayout: { order: ["files", "controls", "git"], leftSectionIds: ["files"] },
846
+ collapsedSectionIds: ["git"],
847
+ hiddenSectionIds: [],
848
+ collapsedPanels: { left: false, right: false },
849
+ panelWidths: { left: 384, right: 620 },
850
+ },
806
851
  composerActions: { order: ["new", "git", "send"], grid: { version: 2, columns: 12, positions: { new: 0, git: 1, send: 10 } } },
807
852
  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"] }] } },
853
+ terminalTabs: { layout: "left", customGroups: { version: 1, groups: [{ id: "group-1", title: "Group 1", tabIds: ["tab-a", "tab-b"] }] }, sidebarWidth: 288 },
809
854
  fileViewerWidth: 560,
810
855
  },
811
856
  },
812
857
  });
813
858
  assert.equal(savedLayout.status, 200, savedLayout.body?.error);
814
859
  assert.equal(savedLayout.body?.data?.preferences?.sidePanelWidth, 620);
860
+ assert.equal(savedLayout.body?.data?.layout?.sidePanel?.panelWidths?.right, 620, "one locked PUT must expose matching v2 right and legacy widths");
861
+ assert.deepEqual(savedLayout.body?.data?.layout?.sidePanel?.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: ["files"] });
815
862
  assert.deepEqual(savedLayout.body?.data?.layout?.composerActions?.order, ["new", "git", "send"]);
816
863
  assert.equal(savedLayout.body?.data?.layout?.terminalTabs?.layout, "left");
864
+ assert.equal(savedLayout.body?.data?.layout?.terminalTabs?.sidebarWidth, 288);
817
865
  assert.notEqual(savedLayout.body?.data?.layoutRevision, initialLayoutRevision);
818
866
  assert.equal(JSON.stringify(savedLayout.body).includes(settingsFile), false, "successful layout responses must not disclose the settings path");
819
867
  const savedLayoutRevision = savedLayout.body.data.layoutRevision;
820
868
  const persistedLayoutSettings = JSON.parse(await readFile(settingsFile, "utf8"));
821
- assert.equal(persistedLayoutSettings.version, 6);
869
+ assert.equal(persistedLayoutSettings.version, 8);
870
+ assert.equal(persistedLayoutSettings.interfacePreferences.sidePanelWidth, 620);
871
+ assert.equal(persistedLayoutSettings.uiLayout.sidePanel.panelWidths.right, 620, "the v2 right width and legacy mirror must persist atomically");
822
872
  assert.equal(persistedLayoutSettings.uiLayout.fileViewerWidth, 560);
823
873
  assert.deepEqual(persistedLayoutSettings.uiLayout.composerActions.grid.positions, { new: 0, git: 1, send: 10 });
824
874
 
825
875
  const staleLayout = await request("127.0.0.1", "/api/interface-preferences", {
826
876
  method: "PUT",
827
- body: { expectedLayoutRevision: initialLayoutRevision, layout: { sidePanel: { collapsed: true } } },
877
+ body: { expectedLayoutRevision: initialLayoutRevision, layout: { sidePanel: { collapsedPanels: { right: true } } } },
828
878
  });
829
879
  assert.equal(staleLayout.status, 409, "stale layout revisions must be rejected without mutation");
830
880
  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);
881
+ assert.equal((await request("127.0.0.1", "/api/interface-preferences")).body?.data?.layout?.sidePanel?.collapsedPanels?.right, false);
832
882
 
833
883
  const partialLayout = await request("127.0.0.1", "/api/interface-preferences", {
834
884
  method: "PUT",
835
- body: { expectedLayoutRevision: savedLayoutRevision, layout: { sidePanel: { collapsed: true }, fileViewerWidth: null } },
885
+ body: { expectedLayoutRevision: savedLayoutRevision, layout: { sidePanel: { collapsedPanels: { right: true } }, fileViewerWidth: null } },
836
886
  });
837
887
  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");
888
+ assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.collapsedPanels, { left: false, right: true });
889
+ assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: ["files"] }, "partial layout patches must preserve omitted fields");
890
+ assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.panelWidths, { left: 384, right: 620 });
840
891
  assert.equal(partialLayout.body?.data?.layout?.fileViewerWidth, null);
841
892
  assert.deepEqual(partialLayout.body?.data?.layout?.composerActions?.order, ["new", "git", "send"]);
842
893
 
843
894
  const invalidLayoutBodies = [
844
- { layout: { sidePanel: { collapsed: false } } },
895
+ { layout: { sidePanel: { collapsedPanels: { right: false } } } },
896
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { version: 1, sidePanel: { collapsed: false } } },
897
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { placement: "center" } } },
898
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { sectionLayout: { order: ["files", "files"], leftSectionIds: [] } } } },
899
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { sectionLayout: { order: ["files"], leftSectionIds: ["git"] } } } },
900
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { sidePanel: { panelWidths: { right: 100 } } } },
845
901
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { composerActions: { order: ["send"] } } },
846
902
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { unknown: true } },
847
903
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { terminalTabs: { layout: "bottom" } } },
904
+ { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { terminalTabs: { sidebarWidth: 100 } } },
848
905
  { expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { fileViewerWidth: 1 } },
849
906
  { sidePanelWidth: 700, unexpected: true },
850
907
  {},
@@ -1179,7 +1236,7 @@ try {
1179
1236
  assert.equal(savedUserLaunchSlots.body?.data?.reloadRequired, true, "a changed save must require active-tab reload before helper guidance changes");
1180
1237
  assert.deepEqual(savedUserLaunchSlots.body?.data?.roles?.reviewer, userLaunchDraft.reviewer, "same-role launch slots must retain independent explicit model specs");
1181
1238
  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");
1239
+ assert.equal(persistedLaunchSlots.version, 8, "launch-slot persistence should retain the current private WebUI settings envelope");
1183
1240
  assert.deepEqual(persistedLaunchSlots.subagentLaunchSlots?.user?.roles?.reviewer, userLaunchDraft.reviewer);
1184
1241
 
1185
1242
  const inheritedProjectLaunchSlots = await request("127.0.0.1", `/api/subagents/config?tab=${encodeURIComponent(tabId)}&scope=project`);
@@ -1409,6 +1466,84 @@ try {
1409
1466
  const invalidResourceScope = await request("127.0.0.1", `/api/tools?tab=${encodeURIComponent(tabId)}&scope=project`);
1410
1467
  assert.equal(invalidResourceScope.status, 400, "resource selectors should reject unsupported scope values");
1411
1468
 
1469
+ const modelToolsBefore = await request("127.0.0.1", `/api/tools?tab=${encodeURIComponent(tabId)}&scope=model&provider=fake&modelId=fake-model`);
1470
+ assert.equal(modelToolsBefore.status, 200, modelToolsBefore.body?.error);
1471
+ assert.equal(modelToolsBefore.body?.data?.scope, "model");
1472
+ assert.equal(modelToolsBefore.body?.data?.configured, false, "an exact model without a saved profile should inherit");
1473
+ assert.equal(modelToolsBefore.body?.data?.source, "global", "the model scope should resolve through the saved global default");
1474
+ assert.deepEqual(modelToolsBefore.body?.data?.tools?.map((tool) => [tool.name, tool.enabled]), [["read", true], ["bash", false]]);
1475
+ assert.deepEqual(modelToolsBefore.body?.data?.models?.map((model) => [model.provider, model.id]), [["fake", "fake-model"]], "the model scope should expose exact authenticated models");
1476
+
1477
+ const missingModelIdentity = await request("127.0.0.1", `/api/tools?tab=${encodeURIComponent(tabId)}&scope=model`);
1478
+ assert.equal(missingModelIdentity.status, 400, "model scope must require an exact provider and modelId");
1479
+ const unknownModelIdentity = await request("127.0.0.1", `/api/tools?tab=${encodeURIComponent(tabId)}&scope=model&provider=fake&modelId=other-model`);
1480
+ assert.equal(unknownModelIdentity.status, 400, "model scope must reject models outside the authenticated registry");
1481
+
1482
+ const saveModelTools = await request("127.0.0.1", "/api/tools", {
1483
+ method: "POST",
1484
+ body: { tab: tabId, scope: "model", provider: "fake", modelId: "fake-model", enabledTools: ["bash"] },
1485
+ });
1486
+ assert.equal(saveModelTools.status, 200, saveModelTools.body?.error);
1487
+ assert.equal(saveModelTools.body?.data?.configured, true);
1488
+ assert.deepEqual(saveModelTools.body?.data?.tools?.map((tool) => [tool.name, tool.enabled]), [["read", false], ["bash", true]]);
1489
+
1490
+ const settingsWithModelProfile = JSON.parse(await readFile(settingsFile, "utf8"));
1491
+ const modelProfile = settingsWithModelProfile.resourceDefaults?.modelProfiles?.find((profile) => profile.provider === "fake" && profile.modelId === "fake-model");
1492
+ assert.deepEqual(modelProfile?.tools?.enabledTools, ["bash"], "the exact model profile should persist under the v8 envelope");
1493
+ modelProfile.tools.enabledTools.push("future-tool");
1494
+ await writeFile(settingsFile, `${JSON.stringify(settingsWithModelProfile, null, 2)}\n`, "utf8");
1495
+
1496
+ const saveModelToolsAgain = await request("127.0.0.1", "/api/tools", {
1497
+ method: "POST",
1498
+ body: { tab: tabId, scope: "model", provider: "fake", modelId: "fake-model", enabledTools: ["read"] },
1499
+ });
1500
+ assert.equal(saveModelToolsAgain.status, 200, saveModelToolsAgain.body?.error);
1501
+ const persistedModelProfile = JSON.parse(await readFile(settingsFile, "utf8")).resourceDefaults?.modelProfiles?.find((profile) => profile.provider === "fake" && profile.modelId === "fake-model");
1502
+ assert.deepEqual(persistedModelProfile?.tools?.enabledTools, ["read", "future-tool"], "model-scope saves should preserve defaults for tools unavailable in the active tab");
1503
+
1504
+ const sessionToolsAfterModel = await request("127.0.0.1", `/api/tools?tab=${encodeURIComponent(tabId)}&scope=session`);
1505
+ assert.deepEqual(sessionToolsAfterModel.body?.data?.tools?.map((tool) => [tool.name, tool.enabled]), [["read", false], ["bash", true]], "saving a model tool default must not rewrite the current session");
1506
+
1507
+ const saveModelSkills = await request("127.0.0.1", "/api/skills", {
1508
+ method: "POST",
1509
+ body: { tab: tabId, scope: "model", provider: "fake", modelId: "fake-model", enabledSkills: ["code-security"] },
1510
+ });
1511
+ assert.equal(saveModelSkills.status, 200, saveModelSkills.body?.error);
1512
+ assert.deepEqual(saveModelSkills.body?.data?.skills?.map((skill) => [skill.name, skill.enabled]), [["repo-explorer", false], ["code-security", true]]);
1513
+
1514
+ const inheritModelTools = await request("127.0.0.1", "/api/tools", {
1515
+ method: "POST",
1516
+ body: { tab: tabId, scope: "model", provider: "fake", modelId: "fake-model", inherit: true },
1517
+ });
1518
+ assert.equal(inheritModelTools.status, 200, inheritModelTools.body?.error);
1519
+ assert.equal(inheritModelTools.body?.data?.configured, false, "model inherit should clear only the tool selection");
1520
+ const profileAfterToolInherit = JSON.parse(await readFile(settingsFile, "utf8")).resourceDefaults?.modelProfiles?.find((profile) => profile.provider === "fake" && profile.modelId === "fake-model");
1521
+ assert.equal(profileAfterToolInherit?.tools?.enabledTools, null, "model tool inherit should reset to null while retaining the skill selection");
1522
+ assert.deepEqual(profileAfterToolInherit?.skills?.enabledSkills, ["code-security"]);
1523
+
1524
+ const inheritModelSkills = await request("127.0.0.1", "/api/skills", {
1525
+ method: "POST",
1526
+ body: { tab: tabId, scope: "model", provider: "fake", modelId: "fake-model", inherit: true },
1527
+ });
1528
+ assert.equal(inheritModelSkills.status, 200, inheritModelSkills.body?.error);
1529
+ const profilesAfterFullInherit = JSON.parse(await readFile(settingsFile, "utf8")).resourceDefaults?.modelProfiles || [];
1530
+ assert.deepEqual(profilesAfterFullInherit, [], "a profile with both resources inherited should be removed");
1531
+
1532
+ const inheritGlobalTools = await request("127.0.0.1", "/api/tools", {
1533
+ method: "POST",
1534
+ body: { tab: tabId, scope: "global", inherit: true },
1535
+ });
1536
+ assert.equal(inheritGlobalTools.status, 200, inheritGlobalTools.body?.error);
1537
+ assert.equal(inheritGlobalTools.body?.data?.configured, false, "global inherit should clear the saved default");
1538
+ assert.equal(JSON.parse(await readFile(settingsFile, "utf8")).resourceDefaults?.tools?.enabledTools, null);
1539
+
1540
+ const inheritSessionTools = await request("127.0.0.1", "/api/tools", {
1541
+ method: "POST",
1542
+ body: { tab: tabId, scope: "session", inherit: true },
1543
+ });
1544
+ assert.equal(inheritSessionTools.status, 200, inheritSessionTools.body?.error);
1545
+ assert.deepEqual(inheritSessionTools.body?.data?.tools?.map((tool) => [tool.name, tool.enabled]), [["read", true], ["bash", true]], "session inherit should recompute the inherited selection immediately");
1546
+
1412
1547
  const workflowRpc = await waitForSseEvent(
1413
1548
  tabId,
1414
1549
  (event) => event.type === "extension_ui_request" && event.method === "setWidget" && event.widgetKey === "workflow:rpc",
@@ -1462,6 +1597,17 @@ try {
1462
1597
  await request("127.0.0.1", `/api/tabs/${encodeURIComponent(otherArtifactTab.body?.data?.tab?.id)}`, { method: "DELETE" });
1463
1598
  await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture document artifact clear" } });
1464
1599
 
1600
+ const oldHelperFixture = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents old-helper" } });
1601
+ assert.equal(oldHelperFixture.status, 200, "old-helper compatibility fixture should be accepted");
1602
+ let oldHelperOverview;
1603
+ for (let attempt = 0; attempt < 20; attempt++) {
1604
+ oldHelperOverview = await request("127.0.0.1", "/api/subagents");
1605
+ if (oldHelperOverview.body?.data?.totalAgents === 2) break;
1606
+ await delay(50);
1607
+ }
1608
+ assert.equal(oldHelperOverview.body?.data?.version, 2, "a new server must project an old v1-only helper status into the v2 overview");
1609
+ assert.equal(oldHelperOverview.body?.data?.groups?.find((group) => group.tabId === tabId)?.runs?.[0]?.agents?.length, 2);
1610
+
1465
1611
  const subagentFixtureStart = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents running" } });
1466
1612
  assert.equal(subagentFixtureStart.status, 200, "subagent fixture status should be accepted");
1467
1613
  let subagentsResponse;
@@ -1521,9 +1667,84 @@ try {
1521
1667
  content: [{ type: "text", text: "# Fixture README" }],
1522
1668
  },
1523
1669
  ], "subagent output endpoint should preserve normalized structured transcript roles, order, IDs, and tool metadata");
1670
+ const canonicalHelperOutput = await request("127.0.0.1", `/api/subagents/output?group=${encodeURIComponent(`tab:${tabId}`)}&run=fixture-run&agent=fixture-run%3A0`);
1671
+ assert.equal(canonicalHelperOutput.status, 200, "the v2 output route should dispatch an opaque helper-owned handle");
1672
+ assert.equal(canonicalHelperOutput.body?.data?.agent?.name, "reviewer");
1524
1673
  const unknownSubagentOutput = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=missing&agent=missing`);
1525
1674
  assert.equal(unknownSubagentOutput.status, 404, "subagent output endpoint should reject untracked selections");
1526
1675
 
1676
+ const registryNow = Date.now();
1677
+ await agentRunRegistry.writeRecord("duplicate-provider", {
1678
+ version: 1, instanceId: "fixture-run:0", runId: "fixture-run", parentSessionId: "fake-session",
1679
+ launcher: "custom", provider: "webui-registry", name: "duplicate observer", status: "running",
1680
+ startedAt: registryNow - 2000, updatedAt: registryNow, endedAt: null,
1681
+ capabilities: { open: false, refresh: false, cancel: false, steer: false }, outputRef: { kind: "none" },
1682
+ }, { recordId: "duplicate-record" });
1683
+ await agentRunRegistry.writeRecord("external-provider", {
1684
+ version: 1, instanceId: "external-sdk", runId: "external-run", parentSessionId: null,
1685
+ launcher: "sdk", provider: "webui-registry", origin: "createAgentSession", name: "external SDK", status: "running",
1686
+ startedAt: registryNow - 1000, updatedAt: registryNow, endedAt: null,
1687
+ capabilities: { open: true, refresh: true, cancel: false, steer: false }, outputRef: { kind: "plain-log", id: "external-record" },
1688
+ }, { recordId: "external-record" });
1689
+ await agentRunRegistry.appendArtifactEvent("external-provider", "external-record", { type: "output", stream: "stdout", message: "bounded external output" });
1690
+ const corruptProducer = path.join(agentRunRegistry.paths.root, "corrupt-provider");
1691
+ await mkdir(corruptProducer, { recursive: true });
1692
+ await writeFile(path.join(corruptProducer, "corrupt-record.json"), "{not-json\n", { mode: 0o600 });
1693
+ const registryOverview = await request("127.0.0.1", "/api/subagents");
1694
+ assert.equal(registryOverview.status, 200, "registry reconciliation should isolate corrupt records");
1695
+ assert.equal(registryOverview.body?.data?.counts?.totalAgents, 3, "duplicate helper/registry identity should count once while an external agent adds one");
1696
+ assert.equal(registryOverview.body?.data?.counts?.byLauncher?.["pi-subagents"], 2);
1697
+ assert.equal(registryOverview.body?.data?.counts?.byLauncher?.sdk, 1);
1698
+ 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");
1699
+ assert.ok(registryOverview.body?.data?.diagnostics?.some((entry) => entry.code === "invalid-record"), "a corrupt registry record should yield only a bounded diagnostic");
1700
+ assert.equal(JSON.stringify(registryOverview.body).includes(harnessSideEffectsRoot), false, "registry overview payloads must not disclose host paths");
1701
+ const externalOutput = await request("127.0.0.1", "/api/subagents/output?group=external&run=external-run&agent=external-sdk");
1702
+ assert.equal(externalOutput.status, 200, "registry output should dispatch through its opaque server-owned record ID");
1703
+ assert.deepEqual(externalOutput.body?.data?.agent?.recentOutput, ["bounded external output"]);
1704
+ assert.equal(JSON.stringify(externalOutput.body).includes(agentRunRegistry.paths.root), false, "registry output must not expose its private path");
1705
+ const unsupportedExternalCancel = await request("127.0.0.1", "/api/subagents/cancel", { method: "POST", body: { group: "external", runId: "external-run", agentId: "external-sdk" } });
1706
+ assert.equal(unsupportedExternalCancel.status, 409, "canonical actions must reject providers without the declared capability");
1707
+
1708
+ const registryDoneAt = Date.now();
1709
+ await agentRunRegistry.writeRecord("external-provider", {
1710
+ version: 1, instanceId: "external-sdk", runId: "external-run", parentSessionId: null,
1711
+ launcher: "sdk", provider: "webui-registry", origin: "createAgentSession", name: "external SDK", status: "done",
1712
+ startedAt: registryNow - 1000, updatedAt: registryDoneAt, endedAt: registryDoneAt,
1713
+ capabilities: { open: true, refresh: true, cancel: false, steer: false }, outputRef: { kind: "plain-log", id: "external-record" },
1714
+ }, { recordId: "external-record" });
1715
+ const terminalRegistryOverview = await request("127.0.0.1", "/api/subagents");
1716
+ assert.equal(terminalRegistryOverview.body?.data?.groups?.find((group) => group.id === "external")?.runs?.[0]?.status, "done", "terminal registry runs should remain visible until dismissed");
1717
+ const dismissedExternal = await request("127.0.0.1", "/api/subagents/dismiss", {
1718
+ method: "POST",
1719
+ body: { group: "external", runId: "external-run", agentId: "external-sdk" },
1720
+ });
1721
+ assert.equal(dismissedExternal.status, 200, `terminal registry projection should be dismissible: ${dismissedExternal.body?.error || ""}`);
1722
+ assert.deepEqual(dismissedExternal.body?.data, { runId: "external-run", dismissed: true });
1723
+ const afterExternalDismiss = await request("127.0.0.1", "/api/subagents");
1724
+ assert.equal(afterExternalDismiss.body?.data?.groups?.some((group) => group.id === "external"), false, "dismissed external projections should disappear from groups");
1725
+ assert.equal(afterExternalDismiss.body?.data?.counts?.totalAgents, 2, "dismissed external projections should disappear from canonical counts");
1726
+ const retainedRegistrySnapshot = await agentRunRegistry.readRecords();
1727
+ assert.ok(retainedRegistrySnapshot.records.some((record) => record.instance.instanceId === "external-sdk"), "dismissal must not delete the producer-owned registry record");
1728
+ assert.deepEqual((await agentRunRegistry.readArtifact("external-record"))?.events?.map((event) => event.message), ["bounded external output"], "dismissal must not delete producer artifacts");
1729
+
1730
+ await agentRunRegistry.writeRecord("attached-provider", {
1731
+ version: 1, instanceId: "attached-session", runId: "attached-run", parentSessionId: null,
1732
+ launcher: "interactive", provider: "webui-registry", origin: "explicit-attach", name: "attached fixture", status: "stale",
1733
+ startedAt: registryNow - 70_000, updatedAt: registryNow - 60_000, endedAt: null,
1734
+ capabilities: { open: false, refresh: false, cancel: false, steer: false }, outputRef: { kind: "none" },
1735
+ }, { recordId: "attached-record" });
1736
+ const attachedOverview = await request("127.0.0.1", "/api/subagents");
1737
+ 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");
1738
+ const detachedAttachedSession = await request("127.0.0.1", "/api/subagents/dismiss", {
1739
+ method: "POST",
1740
+ body: { group: "external", runId: "attached-run", agentId: "attached-session" },
1741
+ });
1742
+ assert.equal(detachedAttachedSession.status, 200, `stale explicit attach projection should be detachable: ${detachedAttachedSession.body?.error || ""}`);
1743
+ const afterAttachedDetach = await request("127.0.0.1", "/api/subagents");
1744
+ 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");
1745
+ assert.ok((await agentRunRegistry.readRecords()).records.some((record) => record.instance.instanceId === "attached-session"), "detaching must not delete the persisted-session registry record");
1746
+ await Promise.all(["duplicate-provider", "external-provider", "attached-provider", "corrupt-provider"].map((producer) => rm(path.join(agentRunRegistry.paths.root, producer), { recursive: true, force: true })));
1747
+
1527
1748
  const dismissRunningSubagent = await request("127.0.0.1", "/api/subagents/dismiss", {
1528
1749
  method: "POST",
1529
1750
  body: { tab: tabId, runId: "fixture-run" },
@@ -3352,6 +3573,7 @@ try {
3352
3573
  const filesRoot = path.join(cwd, "files-fixture");
3353
3574
  const viewerRelative = "files-fixture/viewer.txt";
3354
3575
  const markdownRelative = "files-fixture/docs/readme.md";
3576
+ const imageRelative = "files-fixture/pixel.png";
3355
3577
  const binaryRelative = "files-fixture/binary.bin";
3356
3578
  const noDefaultRelative = "files-fixture/no-default.piunknown";
3357
3579
  const largeRelative = "files-fixture/large.txt";
@@ -3361,6 +3583,10 @@ try {
3361
3583
  const movedDirectoryRelative = "files-fixture/docs/move-dir";
3362
3584
  const deleteFileRelative = "files-fixture/delete-me.txt";
3363
3585
  const deleteDirectoryRelative = "files-fixture/delete-dir";
3586
+ const ignoredFileRelative = "files-fixture/ignored-note.txt";
3587
+ const ignoredDirectoryRelative = "files-fixture/ignored-output";
3588
+ const ignoredNestedFileRelative = "files-fixture/ignored-output/recursive-ignored-result.txt";
3589
+ const trackedPatternRelative = "files-fixture/tracked-pattern.txt";
3364
3590
  const depthEightFileRelative = "deep-search/f1/f2/f3/f4/f5/f6/depth-eight-file.txt";
3365
3591
  const depthEightDirectoryRelative = "deep-search/d1/d2/d3/d4/d5/d6/depth-eight-dir";
3366
3592
  const depthNineFileRelative = "deep-search/t1/t2/t3/t4/t5/t6/t7/too-deep-file.txt";
@@ -3370,6 +3596,8 @@ try {
3370
3596
  await mkdir(path.join(cwd, path.dirname(depthNineFileRelative)), { recursive: true });
3371
3597
  await writeFile(path.join(cwd, viewerRelative), "hello file viewer\nsecond line\n", "utf8");
3372
3598
  await writeFile(path.join(cwd, markdownRelative), "# File Viewer\n\nMarkdown preview support.\n", "utf8");
3599
+ const imageBytes = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=", "base64");
3600
+ await writeFile(path.join(cwd, imageRelative), imageBytes);
3373
3601
  await writeFile(path.join(cwd, noDefaultRelative), "unknown extension should use text/plain editor fallback\n", "utf8");
3374
3602
  await writeFile(path.join(cwd, depthEightFileRelative), "depth 8 search fixture\n", "utf8");
3375
3603
  await writeFile(path.join(cwd, depthNineFileRelative), "depth 9 search fixture\n", "utf8");
@@ -3381,19 +3609,54 @@ try {
3381
3609
  await writeFile(path.join(cwd, deleteFileRelative), "delete me\n", "utf8");
3382
3610
  await mkdir(path.join(cwd, deleteDirectoryRelative), { recursive: true });
3383
3611
  await writeFile(path.join(cwd, deleteDirectoryRelative, "nested.txt"), "nested delete\n", "utf8");
3612
+ await writeFile(path.join(cwd, ignoredFileRelative), "ignored file remains visible\n", "utf8");
3613
+ await mkdir(path.join(cwd, ignoredDirectoryRelative), { recursive: true });
3614
+ await writeFile(path.join(cwd, ignoredNestedFileRelative), "recursive ignored search fixture\n", "utf8");
3615
+ await writeFile(path.join(cwd, trackedPatternRelative), "tracked files remain normal\n", "utf8");
3616
+ if (gitAvailable) {
3617
+ const gitignorePath = path.join(cwd, ".gitignore");
3618
+ const gitignore = await readFile(gitignorePath, "utf8");
3619
+ 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");
3620
+ runGitFixture(["add", "-f", "--", trackedPatternRelative], cwd, "tracked ignore-pattern fixture should enter the Git index");
3621
+ }
3384
3622
 
3385
3623
  const fileTree = await request("127.0.0.1", `/api/files?tab=${encodeURIComponent(tabId)}&path=${encodeURIComponent("files-fixture")}`);
3386
3624
  assert.equal(fileTree.status, 200, `file tree endpoint should list workspace directories: ${fileTree.body?.error || ""}`);
3387
3625
  assert.equal(fileTree.body?.ok, true);
3388
3626
  const fileTreeEntries = fileTree.body?.data?.entries || [];
3389
3627
  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");
3628
+ const normalFileTreeEntry = fileTreeEntries.find((entry) => entry.name === "viewer.txt");
3629
+ assert.equal(normalFileTreeEntry?.type, "file", "file tree should identify regular files");
3630
+ assert.equal(normalFileTreeEntry?.gitIgnored, undefined, "ordinary file tree entries should omit the Git-ignore decoration");
3631
+ if (gitAvailable) {
3632
+ const ignoredFileEntry = fileTreeEntries.find((entry) => entry.path === ignoredFileRelative);
3633
+ const ignoredDirectoryEntry = fileTreeEntries.find((entry) => entry.path === ignoredDirectoryRelative);
3634
+ assert.equal(ignoredFileEntry?.type, "file", "ignored files should remain present in file tree responses");
3635
+ assert.equal(ignoredFileEntry?.gitIgnored, true, "Git-ignored files should be decorated");
3636
+ assert.equal(ignoredDirectoryEntry?.type, "directory", "ignored directories should remain present in file tree responses");
3637
+ assert.equal(ignoredDirectoryEntry?.gitIgnored, true, "Git-ignored directories should be decorated");
3638
+ assert.equal(fileTreeEntries.find((entry) => entry.path === trackedPatternRelative)?.gitIgnored, undefined, "tracked files that match an ignore pattern should remain normal");
3639
+ }
3391
3640
 
3392
3641
  const fileSearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("readme")}`);
3393
3642
  assert.equal(fileSearch.status, 200, `file search endpoint should search workspace files: ${fileSearch.body?.error || ""}`);
3394
3643
  assert.equal(fileSearch.body?.ok, true);
3395
3644
  const fileSearchEntries = fileSearch.body?.data?.entries || [];
3396
3645
  assert.equal(fileSearchEntries.find((entry) => entry.path === markdownRelative)?.type, "file", "file search should find matching files recursively");
3646
+ assert.equal(fileSearchEntries.find((entry) => entry.path === markdownRelative)?.gitIgnored, undefined, "ordinary search results should omit the Git-ignore decoration");
3647
+
3648
+ if (gitAvailable) {
3649
+ const ignoredSearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("ignored")}`);
3650
+ assert.equal(ignoredSearch.status, 200, `file search should retain Git-ignored entries: ${ignoredSearch.body?.error || ""}`);
3651
+ const ignoredSearchEntries = ignoredSearch.body?.data?.entries || [];
3652
+ assert.equal(ignoredSearchEntries.find((entry) => entry.path === ignoredFileRelative)?.gitIgnored, true, "ignored file search results should be decorated");
3653
+ assert.equal(ignoredSearchEntries.find((entry) => entry.path === ignoredDirectoryRelative)?.gitIgnored, true, "ignored directory search results should be decorated");
3654
+ assert.equal(ignoredSearchEntries.find((entry) => entry.path === ignoredNestedFileRelative)?.gitIgnored, true, "recursive search should descend into and decorate ignored directories");
3655
+
3656
+ const trackedPatternSearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("tracked-pattern")}`);
3657
+ assert.equal(trackedPatternSearch.status, 200, "tracked ignore-pattern search should be accepted");
3658
+ assert.equal(trackedPatternSearch.body?.data?.entries?.find((entry) => entry.path === trackedPatternRelative)?.gitIgnored, undefined, "tracked search results that match an ignore pattern should remain normal");
3659
+ }
3397
3660
 
3398
3661
  const directorySearch = await request("127.0.0.1", `/api/files/search?tab=${encodeURIComponent(tabId)}&q=${encodeURIComponent("docs")}`);
3399
3662
  assert.equal(directorySearch.status, 200, `file search endpoint should search directories: ${directorySearch.body?.error || ""}`);
@@ -3419,6 +3682,13 @@ try {
3419
3682
  assert.equal(markdownContent.status, 200, `markdown file should open in WebUI: ${markdownContent.body?.error || ""}`);
3420
3683
  assert.equal(markdownContent.body?.data?.language, "markdown", "markdown files should get markdown viewer support metadata");
3421
3684
 
3685
+ const imageContent = await request("127.0.0.1", `/api/files/content?tab=${encodeURIComponent(tabId)}&path=${encodeURIComponent(imageRelative)}`);
3686
+ assert.equal(imageContent.status, 200, `supported images should open in WebUI: ${imageContent.body?.error || ""}`);
3687
+ assert.equal(imageContent.body?.data?.kind, "image", "image responses should identify their viewer kind");
3688
+ assert.equal(imageContent.body?.data?.mimeType, "image/png", "image responses should expose an allowlisted MIME type");
3689
+ assert.equal(imageContent.body?.data?.data, imageBytes.toString("base64"), "image responses should preserve the bounded file bytes as base64");
3690
+ assert.equal(imageContent.body?.data?.content, undefined, "image responses should not reinterpret binary bytes as editable text");
3691
+
3422
3692
  const emptyDefaultOpen = await request("127.0.0.1", "/api/files/open-default", { method: "POST", body: { tab: tabId, path: "" } });
3423
3693
  assert.equal(emptyDefaultOpen.status, 400, "default editor opens should reject empty paths instead of opening the workspace root");
3424
3694
  assert.match(String(emptyDefaultOpen.body?.error || ""), /Path to open is required/i);
@@ -3773,6 +4043,17 @@ try {
3773
4043
  });
3774
4044
  assert.equal(remoteLaunchSlotSave.status, 403, "launch-slot saves must be localhost-only before the request body is processed");
3775
4045
 
4046
+ const remoteSubagentCancel = await request(lan, "/api/subagents/cancel", {
4047
+ method: "POST",
4048
+ body: { tab: tabId, runId: "remote-request-must-not-dispatch" },
4049
+ });
4050
+ assert.equal(remoteSubagentCancel.status, 403, "subagent cancellation must be localhost-only before helper dispatch");
4051
+ const remoteSubagentDismiss = await request(lan, "/api/subagents/dismiss", {
4052
+ method: "POST",
4053
+ body: { tab: tabId, runId: "remote-request-must-not-dispatch" },
4054
+ });
4055
+ assert.equal(remoteSubagentDismiss.status, 403, "subagent dismissal must be localhost-only before helper dispatch");
4056
+
3776
4057
  const remoteFileOpenDefault = await request(lan, "/api/files/open-default", {
3777
4058
  method: "POST",
3778
4059
  body: { tab: tabId, path: viewerRelative },