@firstpick/pi-package-webui 0.11.0 → 0.11.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 (318) hide show
  1. package/DEVELOPMENT.md +181 -12
  2. package/README.md +41 -9
  3. package/TECHNICAL.md +91 -8
  4. package/bin/pi-webui.mjs +5432 -11428
  5. package/index.ts +10 -3
  6. package/lib/codex-cli-usage.mjs +232 -0
  7. package/lib/codex-usage-auth.mjs +39 -3
  8. package/lib/codex-usage-source.mjs +36 -0
  9. package/lib/component-update-state.mjs +2 -2
  10. package/lib/git-workflow-preference-values.mjs +122 -0
  11. package/lib/git-workflow-preferences.mjs +35 -563
  12. package/lib/package-updates.mjs +260 -0
  13. package/lib/rpc-supervisor-client.mjs +8 -4
  14. package/lib/server/app-runners.mjs +1667 -0
  15. package/lib/server/codex-fast-mode.mjs +161 -0
  16. package/lib/server/conversation-mode.mjs +218 -0
  17. package/lib/server/conversation-voice.mjs +318 -0
  18. package/lib/server/extension-ui-requests.mjs +114 -0
  19. package/lib/server/git-generation.mjs +459 -0
  20. package/lib/server/git-mutations.mjs +1827 -0
  21. package/lib/server/git-reads.mjs +608 -0
  22. package/lib/server/git-worktree-sessions.mjs +408 -0
  23. package/lib/server/helper-requests.mjs +82 -0
  24. package/lib/server/no-project-workspaces.mjs +103 -0
  25. package/lib/server/rpc-transports.mjs +394 -0
  26. package/lib/server/settings-store.mjs +544 -0
  27. package/lib/server/sse-delivery.mjs +138 -0
  28. package/lib/server/workspace-files.mjs +563 -0
  29. package/lib/update/supervisor.mjs +4 -0
  30. package/lib/webui-workspaces.mjs +2 -0
  31. package/package.json +5 -5
  32. package/public/activity-agents-controller.mjs +269 -0
  33. package/public/activity-events-controller.mjs +236 -0
  34. package/public/activity-intercom-controller.mjs +627 -0
  35. package/public/activity-queue-controller.mjs +534 -0
  36. package/public/activity-todo-view.mjs +89 -0
  37. package/public/activity-usage-controller.mjs +589 -0
  38. package/public/app.js +3761 -3878
  39. package/public/conversation-overview.css +84 -0
  40. package/public/conversation-overview.mjs +193 -0
  41. package/public/draft-conversations.mjs +135 -0
  42. package/public/focused-composer-controls.css +111 -0
  43. package/public/focused-composer-controls.mjs +143 -0
  44. package/public/focused-composer-disclosure.mjs +223 -0
  45. package/public/focused-shell-adapter.css +264 -0
  46. package/public/focused-shell-adapter.mjs +257 -0
  47. package/public/index.html +137 -80
  48. package/public/model-catalog-order.mjs +63 -0
  49. package/public/platform-event-stream.mjs +64 -0
  50. package/public/project-artifact-controller.mjs +218 -0
  51. package/public/project-file-viewer-controller.mjs +383 -0
  52. package/public/project-git-tools-controller.mjs +181 -0
  53. package/public/project-runners-controller.mjs +220 -0
  54. package/public/service-worker.js +52 -1
  55. package/public/session-attention-scheduler.mjs +182 -0
  56. package/public/session-composer-store.mjs +56 -0
  57. package/public/session-context.mjs +51 -0
  58. package/public/session-extension-requests.mjs +63 -0
  59. package/public/session-shelf-state.mjs +151 -0
  60. package/public/session-shelves.css +171 -0
  61. package/public/session-shelves.mjs +95 -0
  62. package/public/settings-navigation-controller.mjs +249 -0
  63. package/public/settings-navigation.css +61 -0
  64. package/public/settings-resource-controller.mjs +232 -0
  65. package/public/settings-workspace.css +19 -0
  66. package/public/settings-workspace.mjs +175 -0
  67. package/public/shell-actions.mjs +87 -0
  68. package/public/shell-attention-inbox.css +72 -0
  69. package/public/shell-attention-inbox.mjs +198 -0
  70. package/public/shell-context-actions.css +61 -0
  71. package/public/shell-context-actions.mjs +168 -0
  72. package/public/shell-inspector-resize.mjs +124 -0
  73. package/public/shell-navigation-resize.mjs +107 -0
  74. package/public/shell-navigation.mjs +127 -0
  75. package/public/shell-preferences.mjs +108 -0
  76. package/public/shell-surfaces.mjs +99 -0
  77. package/public/shell-tools-launcher.css +97 -0
  78. package/public/shell-tools-launcher.mjs +222 -0
  79. package/public/shell-view-host.mjs +115 -0
  80. package/public/shell-workspace.css +266 -0
  81. package/public/shell-workspace.mjs +402 -0
  82. package/public/sidebar-update-menu.css +190 -0
  83. package/public/sidebar-update-menu.mjs +512 -0
  84. package/public/styles.css +320 -169
  85. package/public/subagent-launch-slot-state.mjs +2 -2
  86. package/public/theme-contract.mjs +1 -1
  87. package/public/themed-selects.css +156 -0
  88. package/public/workspace-choices.mjs +104 -0
  89. package/tests/activity-agents-controller.test.mjs +652 -0
  90. package/tests/activity-events-controller.test.mjs +511 -0
  91. package/tests/app-runner-terminal-static.test.mjs +3 -3
  92. package/tests/append-system-http.test.mjs +7 -6
  93. package/tests/append-system-selector-static.test.mjs +6 -6
  94. package/tests/aur-review-widget-static.test.mjs +11 -3
  95. package/tests/boot-failure-diagnostics.test.mjs +8 -3
  96. package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
  97. package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
  98. package/tests/browser/activity-owner-integration.spec.mjs +201 -0
  99. package/tests/browser/activity-queue-controller.spec.mjs +405 -0
  100. package/tests/browser/activity-section-picker.spec.mjs +294 -0
  101. package/tests/browser/activity-todo-view.spec.mjs +60 -0
  102. package/tests/browser/activity-usage-controller.spec.mjs +416 -0
  103. package/tests/browser/compact-layout-integration.spec.mjs +58 -0
  104. package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
  105. package/tests/browser/composer-disclosure.spec.mjs +389 -0
  106. package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
  107. package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
  108. package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
  109. package/tests/browser/control-visibility.spec.mjs +5 -0
  110. package/tests/browser/controls-layout.spec.mjs +21 -2
  111. package/tests/browser/conversation-overview.spec.mjs +251 -0
  112. package/tests/browser/draft-conversations.spec.mjs +276 -0
  113. package/tests/browser/empty-startup-fixture.mjs +135 -0
  114. package/tests/browser/empty-startup.spec.mjs +282 -0
  115. package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
  116. package/tests/browser/focused-composer-more.spec.mjs +127 -0
  117. package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
  118. package/tests/browser/focused-navigation-fixture.mjs +32 -0
  119. package/tests/browser/focused-project-activity.spec.mjs +111 -0
  120. package/tests/browser/focused-shell-integration.spec.mjs +208 -0
  121. package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
  122. package/tests/browser/folder-picker-layout.spec.mjs +302 -0
  123. package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
  124. package/tests/browser/git-setup-cancel.spec.mjs +251 -0
  125. package/tests/browser/guided-git-fallback.spec.mjs +40 -21
  126. package/tests/browser/inspector-header.spec.mjs +221 -0
  127. package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
  128. package/tests/browser/inspector-resize.spec.mjs +227 -0
  129. package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
  130. package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
  131. package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
  132. package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
  133. package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
  134. package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
  135. package/tests/browser/interaction-continuity.spec.mjs +50 -26
  136. package/tests/browser/interaction-model-picker.spec.mjs +86 -0
  137. package/tests/browser/last-terminal-close.spec.mjs +280 -0
  138. package/tests/browser/mobile-foundation.spec.mjs +172 -20
  139. package/tests/browser/model-catalog-groups.spec.mjs +104 -0
  140. package/tests/browser/more-row-menus.spec.mjs +258 -0
  141. package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
  142. package/tests/browser/no-project-conversation.spec.mjs +113 -0
  143. package/tests/browser/optimistic-prompt.spec.mjs +3 -0
  144. package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
  145. package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
  146. package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
  147. package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
  148. package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
  149. package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
  150. package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
  151. package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
  152. package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
  153. package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
  154. package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
  155. package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
  156. package/tests/browser/project-artifact-controller.spec.mjs +324 -0
  157. package/tests/browser/project-artifact-integration.spec.mjs +103 -0
  158. package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
  159. package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
  160. package/tests/browser/session-fixture.mjs +118 -0
  161. package/tests/browser/session-ownership.spec.mjs +175 -0
  162. package/tests/browser/session-shelves-integration.spec.mjs +219 -0
  163. package/tests/browser/session-shelves.spec.mjs +340 -0
  164. package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
  165. package/tests/browser/session-summary.spec.mjs +17 -12
  166. package/tests/browser/settings-complete-home.spec.mjs +463 -0
  167. package/tests/browser/settings-entrypoint.spec.mjs +104 -0
  168. package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
  169. package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
  170. package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
  171. package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
  172. package/tests/browser/shell-ownership.spec.mjs +398 -0
  173. package/tests/browser/shell-rollout-fixture.mjs +259 -0
  174. package/tests/browser/shell-rollout.spec.mjs +357 -0
  175. package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
  176. package/tests/browser/shell-workspace.spec.mjs +433 -0
  177. package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
  178. package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
  179. package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
  180. package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
  181. package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
  182. package/tests/browser/stream-output-isolation.spec.mjs +6 -3
  183. package/tests/browser/themed-selects.spec.mjs +297 -0
  184. package/tests/browser/thread-start-flow.spec.mjs +481 -0
  185. package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
  186. package/tests/browser/ui-polish-features.spec.mjs +85 -0
  187. package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
  188. package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
  189. package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
  190. package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
  191. package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
  192. package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
  193. package/tests/browser/windows-drive-parent.spec.mjs +4 -2
  194. package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
  195. package/tests/codex-cli-usage.test.mjs +189 -0
  196. package/tests/codex-fast-mode-static.test.mjs +16 -11
  197. package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
  198. package/tests/codex-usage-auth.test.mjs +168 -9
  199. package/tests/codex-usage-http.test.mjs +124 -0
  200. package/tests/codex-usage-source.test.mjs +146 -0
  201. package/tests/component-update-api-static.test.mjs +2 -2
  202. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  203. package/tests/control-deck-component-updates-static.test.mjs +9 -4
  204. package/tests/control-visibility-static.test.mjs +3 -3
  205. package/tests/controls-layout-static.test.mjs +5 -5
  206. package/tests/conversation-overview-adapter.test.mjs +100 -0
  207. package/tests/document-artifact-static.test.mjs +2 -1
  208. package/tests/draft-conversations.test.mjs +205 -0
  209. package/tests/empty-startup-launcher.test.mjs +197 -0
  210. package/tests/events-tree-context-menu-static.test.mjs +22 -18
  211. package/tests/fake-pi-session-ownership.test.mjs +302 -0
  212. package/tests/fast-mode-client-static.test.mjs +1 -1
  213. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  214. package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
  215. package/tests/file-viewer-image-static.test.mjs +15 -11
  216. package/tests/file-viewer-search-static.test.mjs +5 -5
  217. package/tests/fixtures/fake-codex-app-server.mjs +61 -0
  218. package/tests/fixtures/fake-pi.mjs +41 -9
  219. package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
  220. package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
  221. package/tests/git-footer-context-menu-static.test.mjs +1 -1
  222. package/tests/git-panel-file-preview-static.test.mjs +41 -48
  223. package/tests/git-panel-live-updates-static.test.mjs +2 -1
  224. package/tests/git-workflow-dispatch.test.mjs +66 -0
  225. package/tests/git-workflow-preferences.test.mjs +9 -1
  226. package/tests/guided-git-activation-static.test.mjs +14 -11
  227. package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
  228. package/tests/guided-git-message-reliability-static.test.mjs +10 -6
  229. package/tests/guided-git-publication-backend-static.test.mjs +16 -11
  230. package/tests/http-endpoints-harness.test.mjs +29 -9
  231. package/tests/interaction-state-stability-static.test.mjs +4 -3
  232. package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
  233. package/tests/intercom-tag-layout-static.test.mjs +13 -12
  234. package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
  235. package/tests/main-output-loading-static.test.mjs +4 -4
  236. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  237. package/tests/mobile-compact-layout.test.mjs +2 -2
  238. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  239. package/tests/mobile-foundation-static.test.mjs +10 -7
  240. package/tests/mobile-phone-experience-static.test.mjs +3 -2
  241. package/tests/mobile-static.test.mjs +173 -135
  242. package/tests/model-catalog-order.test.mjs +103 -0
  243. package/tests/native-parity.test.mjs +6 -4
  244. package/tests/native-session-choice-owner.test.mjs +102 -0
  245. package/tests/native-update-lifecycle.test.mjs +10 -5
  246. package/tests/no-project-http-harness.test.mjs +328 -0
  247. package/tests/no-project-navigation.test.mjs +54 -0
  248. package/tests/no-project-workspaces.test.mjs +77 -0
  249. package/tests/open-issue-wizard-static.test.mjs +1 -1
  250. package/tests/optional-feature-migration-frontend.test.mjs +4 -4
  251. package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
  252. package/tests/package-updates.test.mjs +630 -0
  253. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  254. package/tests/platform-event-stream.test.mjs +253 -0
  255. package/tests/project-file-viewer-controller.test.mjs +652 -0
  256. package/tests/project-git-tools-adapter.test.mjs +103 -0
  257. package/tests/project-git-tools-controller.test.mjs +577 -0
  258. package/tests/project-runners-controller.test.mjs +453 -0
  259. package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
  260. package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
  261. package/tests/questionnaire-dialog.test.mjs +6 -6
  262. package/tests/queue-edit-reorder-static.test.mjs +48 -51
  263. package/tests/rpc-supervisor-host.test.mjs +4 -1
  264. package/tests/safety-guard-auto-review-static.test.mjs +1 -1
  265. package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
  266. package/tests/server-app-runners.test.mjs +536 -0
  267. package/tests/server-codex-fast-mode.test.mjs +346 -0
  268. package/tests/server-conversation-mode.test.mjs +386 -0
  269. package/tests/server-conversation-voice.test.mjs +426 -0
  270. package/tests/server-extension-ui-requests.test.mjs +357 -0
  271. package/tests/server-git-generation.test.mjs +558 -0
  272. package/tests/server-git-mutations.test.mjs +729 -0
  273. package/tests/server-git-reads.test.mjs +381 -0
  274. package/tests/server-git-worktree-sessions.test.mjs +502 -0
  275. package/tests/server-helper-requests.test.mjs +364 -0
  276. package/tests/server-rpc-transports.test.mjs +553 -0
  277. package/tests/server-settings-store.test.mjs +132 -0
  278. package/tests/server-shell-rollout.test.mjs +478 -0
  279. package/tests/server-sse-delivery.test.mjs +410 -0
  280. package/tests/server-workspace-files.test.mjs +546 -0
  281. package/tests/session-attention-scheduler.test.mjs +514 -0
  282. package/tests/session-composer-store.test.mjs +153 -0
  283. package/tests/session-context.test.mjs +134 -0
  284. package/tests/session-extension-requests.test.mjs +193 -0
  285. package/tests/session-ownership-adapter.test.mjs +130 -0
  286. package/tests/session-sampling-ui-static.test.mjs +10 -4
  287. package/tests/session-send-lifetime.test.mjs +140 -0
  288. package/tests/session-shelf-state.test.mjs +348 -0
  289. package/tests/session-shelves-adapter.test.mjs +79 -0
  290. package/tests/session-summary-lifetime.test.mjs +54 -0
  291. package/tests/settings-resource-controller.test.mjs +548 -0
  292. package/tests/shell-action-adapter.test.mjs +169 -0
  293. package/tests/shell-actions.test.mjs +182 -0
  294. package/tests/shell-navigation.test.mjs +348 -0
  295. package/tests/shell-preferences.test.mjs +367 -0
  296. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  297. package/tests/stream-output-isolation-static.test.mjs +1 -1
  298. package/tests/subagent-gate-visibility.test.mjs +1 -1
  299. package/tests/subagent-launch-slot-state.test.mjs +2 -2
  300. package/tests/subagent-launch-slots-static.test.mjs +1 -1
  301. package/tests/subagent-observability-static.test.mjs +2 -2
  302. package/tests/subagent-reliability-integration.test.mjs +13 -30
  303. package/tests/syntax-highlighting-static.test.mjs +3 -3
  304. package/tests/tab-close-continuity-static.test.mjs +1 -1
  305. package/tests/tab-metadata-ordering.test.mjs +99 -0
  306. package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
  307. package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
  308. package/tests/terminal-tab-workspace-static.test.mjs +5 -4
  309. package/tests/terminal-tabs-resize-static.test.mjs +1 -1
  310. package/tests/theme-contract.test.mjs +10 -3
  311. package/tests/theme-customizer-static.test.mjs +1 -1
  312. package/tests/thread-display-title.test.mjs +44 -0
  313. package/tests/update-api-harness.test.mjs +15 -14
  314. package/tests/update-tab-restore-harness.test.mjs +3 -0
  315. package/tests/webui-settings-locking.test.mjs +2 -2
  316. package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
  317. package/tests/workspace-choices.test.mjs +114 -0
  318. package/tests/workspace-save-load-static.test.mjs +7 -4
@@ -2,13 +2,14 @@ import assert from "node:assert/strict";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import vm from "node:vm";
5
+ import { normalizeQueuedMessages, queueMutationBody, preservedFocusedFollowUpQueueDraft, createActivityQueueController } from "../public/activity-queue-controller.mjs";
6
6
 
7
7
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
- const [html, css, app] = await Promise.all([
8
+ const [html, css, app, queue] = await Promise.all([
9
9
  readFile(join(root, "public", "index.html"), "utf8"),
10
10
  readFile(join(root, "public", "styles.css"), "utf8"),
11
11
  readFile(join(root, "public", "app.js"), "utf8"),
12
+ readFile(join(root, "public", "activity-queue-controller.mjs"), "utf8"),
12
13
  ]);
13
14
 
14
15
  assert.match(
@@ -25,11 +26,7 @@ assert.match(css, /body:not\(\.mobile-keyboard-open\) \.composer-input-row:has\(
25
26
  assert.match(css, /body\.mobile-keyboard-open \.follow-up-queue-trigger:not\(\[hidden\]\) \{ display: inline-flex; \}/, "the queue trigger should remain usable while the mobile keyboard is open");
26
27
  assert.match(css, /@media \(prefers-reduced-motion: reduce\) \{[\s\S]*\.follow-up-queue-overlay,[\s\S]*\.follow-up-queue-row \{ transition: none; \}/, "the queue overlay should suppress motion for reduced-motion users");
27
28
 
28
- const normalizeStart = app.indexOf("function normalizeQueuedMessages(event) {");
29
- const normalizeEnd = app.indexOf("\nfunction queuedSnapshotForTab", normalizeStart);
30
- assert.ok(normalizeStart >= 0 && normalizeEnd > normalizeStart, "queue normalization should remain independently testable");
31
- const normalizeSource = app.slice(normalizeStart, normalizeEnd);
32
- const compactionSnapshot = JSON.parse(vm.runInNewContext(`${normalizeSource}\nJSON.stringify(normalizeQueuedMessages({ source: "webui-compaction", revision: 7, draining: true, steering: ["steer"], followUp: ["first", "second"] }))`));
29
+ const compactionSnapshot = normalizeQueuedMessages({ source: "webui-compaction", revision: 7, draining: true, steering: ["steer"], followUp: ["first", "second"] });
33
30
  assert.deepEqual(compactionSnapshot, {
34
31
  source: "webui-compaction",
35
32
  revision: 7,
@@ -38,11 +35,7 @@ assert.deepEqual(compactionSnapshot, {
38
35
  followUp: ["first", "second"],
39
36
  }, "frontend queue normalization should retain compaction source, revision, draining state, and both queue arrays");
40
37
 
41
- const mutationBodyStart = app.indexOf("function queueMutationBody(snapshot, operation) {");
42
- const mutationBodyEnd = app.indexOf("\nfunction applyAuthoritativeQueuedSnapshot", mutationBodyStart);
43
- assert.ok(mutationBodyStart >= 0 && mutationBodyEnd > mutationBodyStart, "queue mutation request construction should remain independently testable");
44
- const mutationBodySource = app.slice(mutationBodyStart, mutationBodyEnd);
45
- const compactionMutation = JSON.parse(vm.runInNewContext(`${mutationBodySource}\nJSON.stringify(queueMutationBody({ source: "webui-compaction", revision: 3, steering: ["steer"], followUp: ["one", "two"] }, { type: "move", from: 1, to: 0, expectedText: "two" }))`));
38
+ const compactionMutation = queueMutationBody({ source: "webui-compaction", revision: 3, steering: ["steer"], followUp: ["one", "two"] }, { type: "move", from: 1, to: 0, expectedText: "two" });
46
39
  assert.deepEqual(compactionMutation, {
47
40
  source: "webui-compaction",
48
41
  kind: "followUp",
@@ -50,61 +43,65 @@ assert.deepEqual(compactionMutation, {
50
43
  expected: { steering: ["steer"], followUp: ["one", "two"] },
51
44
  operation: { type: "move", from: 1, to: 0, expectedText: "two" },
52
45
  }, "compaction moves should use the B1 source-aware, revisioned full-snapshot mutation contract");
53
- const runtimeMutation = JSON.parse(vm.runInNewContext(`${mutationBodySource}\nJSON.stringify(queueMutationBody({ source: "pi-runtime", steering: [], followUp: ["old"] }, { type: "edit", index: 0, expectedText: "old", text: "new" }))`));
46
+ const runtimeMutation = queueMutationBody({ source: "pi-runtime", steering: [], followUp: ["old"] }, { type: "edit", index: 0, expectedText: "old", text: "new" });
54
47
  assert.equal(Object.hasOwn(runtimeMutation, "revision"), false, "Pi-runtime mutations must omit the compaction-only revision field");
55
48
  assert.deepEqual(runtimeMutation.expected, { steering: [], followUp: ["old"] }, "Pi-runtime mutations should send the complete B1 expected snapshot");
56
- const deleteMutation = JSON.parse(vm.runInNewContext(`${mutationBodySource}\nJSON.stringify(queueMutationBody({ source: "webui-compaction", revision: 4, steering: ["steer"], followUp: ["remove me"] }, { type: "delete", index: 0, expectedText: "remove me" }))`));
49
+ const deleteMutation = queueMutationBody({ source: "webui-compaction", revision: 4, steering: ["steer"], followUp: ["remove me"] }, { type: "delete", index: 0, expectedText: "remove me" });
57
50
  assert.deepEqual(deleteMutation.operation, { type: "delete", index: 0, expectedText: "remove me" }, "queue deletion should use the same source-aware full-snapshot mutation contract");
58
51
 
59
- const draftHelperStart = app.indexOf("function preservedFocusedFollowUpQueueDraft(draft, followUps) {");
60
- const draftHelperEnd = app.indexOf("\nfunction focusedFollowUpQueueDraft", draftHelperStart);
61
- assert.ok(draftHelperStart >= 0 && draftHelperEnd > draftHelperStart, "queue draft preservation should remain independently testable");
62
- const draftHelperSource = app.slice(draftHelperStart, draftHelperEnd);
63
- const draftDecisions = JSON.parse(vm.runInNewContext(`${draftHelperSource}
64
- JSON.stringify({
52
+ const draftDecisions = {
65
53
  preserve: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "unsaved second", selectionStart: 3, selectionEnd: 10 }, ["first", "second"]),
66
54
  targetChanged: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "unsaved second", selectionStart: 3, selectionEnd: 10 }, ["first", "server replacement"]),
67
55
  indexChanged: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "unsaved second" }, ["second", "first"]),
68
56
  clean: preservedFocusedFollowUpQueueDraft({ index: 1, authoritativeText: "second", value: "second" }, ["first", "second"]),
69
- })`));
57
+ };
70
58
  assert.deepEqual(draftDecisions.preserve, { index: 1, value: "unsaved second", selectionStart: 3, selectionEnd: 10 }, "an SSE queue update should preserve the focused dirty draft only when its same authoritative item remains at its index");
71
59
  assert.equal(draftDecisions.targetChanged, null, "an authoritative replacement at the focused index must discard the old draft instead of carrying it across a conflict");
72
60
  assert.equal(draftDecisions.indexChanged, null, "a reordered target must not retain a dirty draft at the old index");
73
61
  assert.equal(draftDecisions.clean, null, "unchanged focused text should not be treated as a dirty draft");
74
62
 
75
- const renderTargetStart = app.indexOf("function queuedSnapshotTargetsCurrentTab(tabContext, currentTabId = activeTabId, currentTabs = tabs) {");
76
- const renderTargetEnd = app.indexOf("\nfunction setFollowUpQueueOpen", renderTargetStart);
77
- assert.ok(renderTargetStart >= 0 && renderTargetEnd > renderTargetStart, "late queue response targeting should remain independently testable");
78
- const renderTargetSource = app.slice(renderTargetStart, renderTargetEnd);
79
- const renderTargets = JSON.parse(vm.runInNewContext(`${renderTargetSource}
80
- JSON.stringify({
81
- returnedToOrigin: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4, sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, "A", [{ id: "A", sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }]),
82
- anotherTabActive: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4, sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, "B", [{ id: "A", sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, { id: "B" }]),
83
- originClosed: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4 }, "A", []),
84
- sessionReplaced: queuedSnapshotTargetsCurrentTab({ tabId: "A", generation: 4, sessionFile: "/sessions/a.jsonl", startedAt: "start-a" }, "A", [{ id: "A", sessionFile: "/sessions/replacement.jsonl", startedAt: "start-replacement" }]),
85
- })`));
86
- assert.equal(renderTargets.returnedToOrigin, true, "a late A mutation response should render after A→B→A when A is active again");
87
- assert.equal(renderTargets.anotherTabActive, false, "a late A mutation response must not repaint active tab B");
88
- assert.equal(renderTargets.originClosed, false, "a late response must not render after its originating tab closes");
89
- assert.equal(renderTargets.sessionReplaced, false, "a late response must not render after the authoritative tab session changes");
63
+ // Exercise the actual owner with late responses across navigation and replacement.
64
+ for (const state of ["returned", "background", "closed", "replaced"]) {
65
+ let foreground = "A", generation = 1, lifetime = 1, live = true, resolve;
66
+ const cache = new Map([["A", normalizeQueuedMessages({ followUp: ["old"] })]]);
67
+ const target = (tabId = foreground) => ({ tabId, generation, lifetime });
68
+ const alive = context => live && context.lifetime === lifetime;
69
+ const painted = [];
70
+ const owner = createActivityQueueController({
71
+ document: { defaultView: { requestAnimationFrame: () => 1, cancelAnimationFrame() {} } }, nodes: {},
72
+ api: () => new Promise(done => { resolve = done; }), getContext: target,
73
+ isAlive: alive, isCurrent: context => context.tabId === foreground && context.generation === generation,
74
+ getSnapshot: id => cache.get(id), setSnapshot: (id, snapshot) => cache.set(id, snapshot),
75
+ onProjectionChange: () => painted.push(foreground),
76
+ });
77
+ const pending = owner.mutate({ type: "edit", index: 0, expectedText: "old", text: "new" });
78
+ foreground = "B"; generation++;
79
+ if (state === "returned") { foreground = "A"; generation++; }
80
+ if (state === "closed") live = false;
81
+ if (state === "replaced") lifetime++;
82
+ resolve({ data: { mutated: true, queue: { followUp: ["new"] } } });
83
+ await pending;
84
+ assert.equal(cache.get("A").followUp[0], ["closed", "replaced"].includes(state) ? "old" : "new", state);
85
+ assert.deepEqual(painted, state === "returned" ? ["A"] : [], state);
86
+ owner.dispose();
87
+ }
90
88
 
91
- assert.match(app, /async function mutateQueuedFollowUp\([\s\S]*const tabContext = queueTabContext\(tabId\)[\s\S]*api\("\/api\/queue\/mutate", \{ method: "POST", body: queueMutationBody\(snapshot, operation\), tabId \}\)[\s\S]*if \(result\.queue\) applyAuthoritativeQueuedSnapshot\(tabContext, result\.queue\)[\s\S]*error\?\.statusCode === 409[\s\S]*refreshed the authoritative queue/, "queue mutations should use the single B1 endpoint and refresh the authoritative snapshot after conflicts");
92
- assert.match(app, /function applyAuthoritativeQueuedSnapshot\([\s\S]*latestQueuedMessagesByTab\.set\(tabContext\.tabId, snapshot\)[\s\S]*if \(queuedSnapshotTargetsCurrentTab\(tabContext\)\) renderQueue/, "late mutation responses should render only their active originating tab while caching every authoritative result");
93
- assert.match(app, /function renderQueue\(event\)[\s\S]*latestQueuedMessagesByTab\.set\(tabId, snapshot\)[\s\S]*if \(tabId && tabId !== activeTabId\) return;/, "deferred queue rendering must cache but never repaint an unrelated active tab");
94
- assert.match(app, /const followUpQueueMutationsInFlightByTab = new Set\(\)[\s\S]*function syncFollowUpQueueMutationControls\([\s\S]*textarea\.disabled = locked \|\| draining[\s\S]*control\.disabled = locked \|\| draining[\s\S]*function setFollowUpQueueMutationInFlight/, "in-flight and draining states should lock editable queue controls per tab");
95
-
96
- assert.match(app, /const textarea = make\("textarea", "follow-up-queue-textarea"\)[\s\S]*textarea\.dataset\.followUpQueueAuthoritativeText = item[\s\S]*textarea\.addEventListener\("blur", \(\) => \{[\s\S]*followUpQueueSuppressBlurFor[\s\S]*saveQueuedFollowUpText\(index, item, textarea\.value\)[\s\S]*\(event\.ctrlKey \|\| event\.metaKey\)[\s\S]*event\.key === "Enter"[\s\S]*event\.key !== "Escape"[\s\S]*textarea\.value = item/, "queue rows should be editable by default and avoid blur-saving the focused draft during an authoritative rerender");
97
- assert.match(app, /row\.draggable = false;[\s\S]*dragHandle\.draggable = !unavailable;[\s\S]*row\.addEventListener\("dragstart", \(event\) => \{[\s\S]*event\.target\?\.closest\?\.\("\.follow-up-queue-drag-handle"\) !== dragHandle[\s\S]*application\/x-pi-webui-follow-up[\s\S]*row\.addEventListener\("dragover"[\s\S]*event\.stopPropagation\(\)[\s\S]*row\.addEventListener\("drop"[\s\S]*type: "move", from: drag\.index, to: index/, "native drag/drop should begin only from its visible handle, persist the final-index permutation, and isolate row drag events");
98
- assert.match(app, /function handleComposerDragOver\(event\) \{\n\s*if \(event\.target\?\.closest\?\.\("#followUpQueueOverlay"\) \|\| !isFileDrag\(event\)\) return;[\s\S]*function handleComposerDrop\(event\) \{\n\s*if \(event\.target\?\.closest\?\.\("#followUpQueueOverlay"\) \|\| !isFileDrag\(event\)\) return;/, "composer attachment drops should ignore queue-row drag events");
99
- assert.match(app, /Moved queued follow-up \$\{operation\.from \+ 1\} to position \$\{operation\.to \+ 1\}[\s\S]*Move queued follow-up \$\{index \+ 1\} up[\s\S]*Move queued follow-up \$\{index \+ 1\} down/, "move controls should provide labelled keyboard/touch parity and live reorder announcements");
100
- assert.match(app, /const remove = make\("button", "follow-up-queue-remove-button", "Remove"\)[\s\S]*type: "delete", index, expectedText: message/, "every composer queue row should expose an accessible remove control backed by the unified mutation contract");
89
+ assert.match(app, /createActivityQueueController\(\{[\s\S]*isCurrent: isCurrentProjectTarget,[\s\S]*isAlive: isAliveProjectTarget,[\s\S]*setSnapshot: \(tabId, snapshot\) => latestQueuedMessagesByTab\.set/, "the app must supply real lifetime guards and its single queue cache");
90
+ assert.match(queue, /api\("\/api\/queue\/mutate", \{ method: "POST", body: queueMutationBody\(snapshot, operation\), tabId: context\.tabId \}\)[\s\S]*if \(!alive\(context\)\) return false;[\s\S]*error\?\.statusCode === 409[\s\S]*refreshed the authoritative queue/, "mutations retain exact origin, lifetime checks and conflict refresh");
91
+ assert.match(queue, /function ingest\(event\)[\s\S]*setSnapshot\(context\.tabId, normalizeQueuedMessages\(event\)\)[\s\S]*if \(current\(context\)\) render\(\)/, "ingestion caches before foreground rendering");
92
+ assert.match(queue, /control\.disabled = locked \|\| draining/, "in-flight and draining states lock mutation controls");
93
+ assert.match(queue, /textarea\.dataset\.followUpQueueAuthoritativeText = item[\s\S]*textarea === suppressBlurFor[\s\S]*saveText\(index, item, textarea\.value, context\)[\s\S]*event\.ctrlKey \|\| event\.metaKey[\s\S]*textarea\.value = item/, "edits retain dirty drafts and keyboard save/cancel");
94
+ assert.match(queue, /row\.draggable = false;[\s\S]*dragHandle\.draggable = !unavailable;[\s\S]*application\/x-pi-webui-follow-up[\s\S]*type: "move", from: source\.index, to: index/, "dragging uses handles and final indexes");
95
+ assert.match(app, /function handleComposerDragOver\(event\) \{\n\s*if \(event\.target\?\.closest\?\.\("#followUpQueueOverlay"\) \|\| !isFileDrag\(event\)\) return;[\s\S]*function handleComposerDrop\(event\) \{\n\s*if \(event\.target\?\.closest\?\.\("#followUpQueueOverlay"\) \|\| !isFileDrag\(event\)\) return;/, "attachment drops ignore queue drags");
96
+ assert.match(queue, /Moved queued follow-up[\s\S]*Move queued follow-up \$\{index \+ 1\} up[\s\S]*Move queued follow-up \$\{index \+ 1\} down/, "move controls retain accessible announcements and keyboard/touch actions");
97
+ assert.match(queue, /follow-up-queue-remove-button[\s\S]*remove\(index, item, context\)/, "overlay rows retain removal");
101
98
  assert.match(css, /\.follow-up-queue-remove-button \{[\s\S]*color:\s*var\(--ctp-red\)/, "queue removal should have a distinct destructive visual treatment");
102
99
  assert.match(app, /setFollowUpQueueOpen\(false, \{ restoreFocus: true \}\)/, "outside close and Escape should request queue-focus restoration");
103
- assert.match(app, /function setFollowUpQueueOpen\([\s\S]*followUpQueueRestoreFocus[\s\S]*requestAnimationFrame\(\(\) => focusTarget\?\.focus\(\{ preventScroll: true \}\)\)/, "queue close should restore focus to the saved trigger context");
104
- assert.match(app, /function setFollowUpQueueOpen[\s\S]*setComposerActionsOpen\(false\)[\s\S]*setPublishMenuOpen\(false\)[\s\S]*setNativeCommandMenuOpen\(false\)[\s\S]*setAppRunnerMenuOpen\(false\)[\s\S]*setOptionsMenuOpen\(false\)[\s\S]*setConversationVoiceMenuOpen\(false\)[\s\S]*setBusyPromptBehaviorMenuOpen\(false\)[\s\S]*setNewTabMenuOpen\(false\)/, "opening the queue should close competing dropdown surfaces");
105
- assert.match(app, /function renderFollowUpQueueOverlay\(\) \{\n\s*if \(deferUiRenderDuringPointerActivation\("follow-up-queue", renderFollowUpQueueOverlay\)\) return;/, "queue rendering should defer during pointer activation");
106
- assert.match(app, /function switchTab\(tabId\)[\s\S]*setFollowUpQueueOpen\(false\)[\s\S]*setFollowUpQueueStatus\(""\)/, "switching tabs should close queue UI and clear its tab-local status before the new context renders");
107
- assert.match(app, /renderQueueGroup\("Follow-up", followUp, "follow-up", \{ removable: !snapshot\.draining, tabId \}\)/, "Control Deck removal should support every mutable queue source");
100
+ assert.match(queue, /restoreFocusTarget[\s\S]*target\?\.focus\(\{ preventScroll: true \}\)/, "closing restores captured focus");
101
+ assert.match(app, /onBeforeOpen\(\) \{[\s\S]*setComposerActionsOpen\(false\)[\s\S]*setPublishMenuOpen\(false\)[\s\S]*setNativeCommandMenuOpen\(false\)[\s\S]*setAppRunnerMenuOpen\(false\)[\s\S]*setOptionsMenuOpen\(false\)[\s\S]*setConversationVoiceMenuOpen\(false\)[\s\S]*setBusyPromptBehaviorMenuOpen\(false\)[\s\S]*closeDraftWorkspacePicker\(\)/, "opening closes competing dropdown surfaces");
102
+ assert.match(queue, /defer\("follow-up-queue", renderOverlay\)/, "queue rendering defers during pointer activation");
103
+ assert.match(app, /function switchTab\(tabId\)[\s\S]*setFollowUpQueueOpen\(false\)[\s\S]*activityQueue\.setStatus\(""\)/, "tab switching closes and clears queue UI");
104
+ assert.match(queue, /renderQueueGroup\("Follow-up", followUp, "follow-up", \{ removable: !snapshot\.draining, context \}\)/, "deck removal supports every mutable source");
108
105
  assert.doesNotMatch(app, /nextQueuedFollowUpPrompt|sticky-user-follow-up-prompt|Next follow-up prompt:/, "the sticky last/current prompt control must no longer expose queued follow-up preview content");
109
106
 
110
107
  console.log("queue edit/reorder static tests passed");
@@ -26,7 +26,8 @@ import {
26
26
 
27
27
  const root = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
28
28
  const fakePi = path.join(root, "tests", "fixtures", "fake-pi.mjs");
29
- const work = await mkdtemp(path.join(tmpdir(), "pi-webui-rpc-supervisor-host-"));
29
+ // Nested fixture owners must fit the Unix-domain socket pathname limit.
30
+ const work = await mkdtemp(path.join(tmpdir(), "pi-rpc-"));
30
31
  const effectRoot = path.join(work, "effect");
31
32
  await mkdir(effectRoot);
32
33
  const agentDir = path.join(work, "agent");
@@ -403,6 +404,8 @@ try {
403
404
  await replayClient.shutdown();
404
405
  await delay(200);
405
406
  assert.equal(await readSupervisorState(paths), null, "a matching supervisor shutdown must remove private state");
407
+ await assert.rejects(replayClient.detach(), { code: "RPC_SUPERVISOR_DISCONNECTED" },
408
+ "requests after the supervisor exits must carry the code the Web UI shutdown treats as benign");
406
409
 
407
410
  // A host that loses its state race must leave the new incarnation untouched.
408
411
  const safeAgentDir = path.join(work, "instance-safe-agent");
@@ -16,7 +16,7 @@ assert.match(dialog, /nativeSettingSelect\("Review model"[\s\S]*nativeSettingSel
16
16
  assert.match(dialog, /data\.modelThinkingLevels\?\.\[selectedModelKey\]/, "thinking options should come from the server's per-model support map");
17
17
  assert.match(dialog, /controls\.autoReviewModel\.select\.disabled = !models\.length[\s\S]*controls\.autoReviewThinking\.select\.disabled = !selectedAvailable/, "model and thinking selectors should remain configurable before auto-review is enabled");
18
18
  assert.match(dialog, /model and thinking can still be preselected before enabling auto-review/, "disabled auto-review state should explain that model setup remains available");
19
- assert.match(dialog, /Unavailable: no authenticated Pi models are available[\s\S]*Unavailable: select one of the authenticated models from this active tab/, "dialog should explain model-unavailable states");
19
+ assert.match(dialog, /Unavailable: no authenticated Pi models are available[\s\S]*Unavailable: select one of the authenticated models from this active thread/, "dialog should explain model-unavailable states");
20
20
  assert.match(dialog, /const collectConfig = \(\) =>[\s\S]*autoReview: \{[\s\S]*enabled: controls\.autoReview\.input\.checked[\s\S]*provider:[\s\S]*modelId:[\s\S]*thinkingLevel:/, "collection should persist the canonical nested autoReview shape");
21
21
  assert.match(dialog, /const applyConfig = \(value\) =>[\s\S]*controls\.autoReview\.input\.checked = value\?\.autoReview\?\.enabled === true[\s\S]*syncAutoReviewControls/, "application and reset should restore auto-review controls and availability state");
22
22
  assert.match(dialog, /addNativeCommandAction\("Reset defaults"[\s\S]*applyConfig\(defaults\)/, "reset should apply canonical defaults");
@@ -143,7 +143,7 @@ function createHarness() {
143
143
  const hostValue = (value, fallback = undefined) => (value === undefined ? fallback : JSON.parse(JSON.stringify(value)));
144
144
 
145
145
  const context = {
146
- console,
146
+ console, AbortSignal,
147
147
  document: mockDocument,
148
148
  elements,
149
149
  SAMPLING_PARAMETER_CATALOG,
@@ -179,6 +179,12 @@ function createHarness() {
179
179
  let samplingParametersRequestSerial = 0;
180
180
  let activeTabId = "tab-a";
181
181
  function activeTabContext(tabId = activeTabId) { return { tabId: tabId || null, generation: 0 }; }
182
+ function isCurrentTabContext(context) { return context.tabId === activeTabId && context.generation === 0; }
183
+ const focusedShell = null;
184
+ const sessionContext = {
185
+ captureLifetime: tabId => ({ tabId, generation: 0 }),
186
+ isLifetimeCurrent: target => target.generation === 0,
187
+ };
182
188
  ${samplingBlock}
183
189
  globalThis.samplingHarness = {
184
190
  setActiveTab(value) { activeTabId = value; },