@firstpick/pi-package-webui 0.11.1 → 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 (309) hide show
  1. package/DEVELOPMENT.md +151 -12
  2. package/README.md +34 -6
  3. package/TECHNICAL.md +75 -8
  4. package/bin/pi-webui.mjs +5390 -11423
  5. package/index.ts +10 -3
  6. package/lib/component-update-state.mjs +2 -2
  7. package/lib/git-workflow-preference-values.mjs +122 -0
  8. package/lib/git-workflow-preferences.mjs +35 -563
  9. package/lib/package-updates.mjs +260 -0
  10. package/lib/rpc-supervisor-client.mjs +8 -4
  11. package/lib/server/app-runners.mjs +1667 -0
  12. package/lib/server/codex-fast-mode.mjs +161 -0
  13. package/lib/server/conversation-mode.mjs +218 -0
  14. package/lib/server/conversation-voice.mjs +318 -0
  15. package/lib/server/extension-ui-requests.mjs +114 -0
  16. package/lib/server/git-generation.mjs +459 -0
  17. package/lib/server/git-mutations.mjs +1827 -0
  18. package/lib/server/git-reads.mjs +608 -0
  19. package/lib/server/git-worktree-sessions.mjs +408 -0
  20. package/lib/server/helper-requests.mjs +82 -0
  21. package/lib/server/no-project-workspaces.mjs +103 -0
  22. package/lib/server/rpc-transports.mjs +394 -0
  23. package/lib/server/settings-store.mjs +544 -0
  24. package/lib/server/sse-delivery.mjs +138 -0
  25. package/lib/server/workspace-files.mjs +563 -0
  26. package/lib/update/supervisor.mjs +4 -0
  27. package/lib/webui-workspaces.mjs +2 -0
  28. package/package.json +4 -4
  29. package/public/activity-agents-controller.mjs +269 -0
  30. package/public/activity-events-controller.mjs +236 -0
  31. package/public/activity-intercom-controller.mjs +627 -0
  32. package/public/activity-queue-controller.mjs +534 -0
  33. package/public/activity-todo-view.mjs +89 -0
  34. package/public/activity-usage-controller.mjs +589 -0
  35. package/public/app.js +3761 -3886
  36. package/public/conversation-overview.css +84 -0
  37. package/public/conversation-overview.mjs +193 -0
  38. package/public/draft-conversations.mjs +135 -0
  39. package/public/focused-composer-controls.css +111 -0
  40. package/public/focused-composer-controls.mjs +143 -0
  41. package/public/focused-composer-disclosure.mjs +223 -0
  42. package/public/focused-shell-adapter.css +264 -0
  43. package/public/focused-shell-adapter.mjs +257 -0
  44. package/public/index.html +137 -80
  45. package/public/model-catalog-order.mjs +63 -0
  46. package/public/platform-event-stream.mjs +64 -0
  47. package/public/project-artifact-controller.mjs +218 -0
  48. package/public/project-file-viewer-controller.mjs +383 -0
  49. package/public/project-git-tools-controller.mjs +181 -0
  50. package/public/project-runners-controller.mjs +220 -0
  51. package/public/service-worker.js +52 -1
  52. package/public/session-attention-scheduler.mjs +182 -0
  53. package/public/session-composer-store.mjs +56 -0
  54. package/public/session-context.mjs +51 -0
  55. package/public/session-extension-requests.mjs +63 -0
  56. package/public/session-shelf-state.mjs +151 -0
  57. package/public/session-shelves.css +171 -0
  58. package/public/session-shelves.mjs +95 -0
  59. package/public/settings-navigation-controller.mjs +249 -0
  60. package/public/settings-navigation.css +61 -0
  61. package/public/settings-resource-controller.mjs +232 -0
  62. package/public/settings-workspace.css +19 -0
  63. package/public/settings-workspace.mjs +175 -0
  64. package/public/shell-actions.mjs +87 -0
  65. package/public/shell-attention-inbox.css +72 -0
  66. package/public/shell-attention-inbox.mjs +198 -0
  67. package/public/shell-context-actions.css +61 -0
  68. package/public/shell-context-actions.mjs +168 -0
  69. package/public/shell-inspector-resize.mjs +124 -0
  70. package/public/shell-navigation-resize.mjs +107 -0
  71. package/public/shell-navigation.mjs +127 -0
  72. package/public/shell-preferences.mjs +108 -0
  73. package/public/shell-surfaces.mjs +99 -0
  74. package/public/shell-tools-launcher.css +97 -0
  75. package/public/shell-tools-launcher.mjs +222 -0
  76. package/public/shell-view-host.mjs +115 -0
  77. package/public/shell-workspace.css +266 -0
  78. package/public/shell-workspace.mjs +402 -0
  79. package/public/sidebar-update-menu.css +190 -0
  80. package/public/sidebar-update-menu.mjs +512 -0
  81. package/public/styles.css +320 -169
  82. package/public/subagent-launch-slot-state.mjs +2 -2
  83. package/public/themed-selects.css +156 -0
  84. package/public/workspace-choices.mjs +104 -0
  85. package/tests/activity-agents-controller.test.mjs +652 -0
  86. package/tests/activity-events-controller.test.mjs +511 -0
  87. package/tests/app-runner-terminal-static.test.mjs +3 -3
  88. package/tests/append-system-http.test.mjs +7 -6
  89. package/tests/append-system-selector-static.test.mjs +6 -6
  90. package/tests/aur-review-widget-static.test.mjs +11 -3
  91. package/tests/boot-failure-diagnostics.test.mjs +8 -3
  92. package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
  93. package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
  94. package/tests/browser/activity-owner-integration.spec.mjs +201 -0
  95. package/tests/browser/activity-queue-controller.spec.mjs +405 -0
  96. package/tests/browser/activity-section-picker.spec.mjs +294 -0
  97. package/tests/browser/activity-todo-view.spec.mjs +60 -0
  98. package/tests/browser/activity-usage-controller.spec.mjs +416 -0
  99. package/tests/browser/compact-layout-integration.spec.mjs +58 -0
  100. package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
  101. package/tests/browser/composer-disclosure.spec.mjs +389 -0
  102. package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
  103. package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
  104. package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
  105. package/tests/browser/control-visibility.spec.mjs +5 -0
  106. package/tests/browser/controls-layout.spec.mjs +21 -2
  107. package/tests/browser/conversation-overview.spec.mjs +251 -0
  108. package/tests/browser/draft-conversations.spec.mjs +276 -0
  109. package/tests/browser/empty-startup-fixture.mjs +135 -0
  110. package/tests/browser/empty-startup.spec.mjs +282 -0
  111. package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
  112. package/tests/browser/focused-composer-more.spec.mjs +127 -0
  113. package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
  114. package/tests/browser/focused-navigation-fixture.mjs +32 -0
  115. package/tests/browser/focused-project-activity.spec.mjs +111 -0
  116. package/tests/browser/focused-shell-integration.spec.mjs +208 -0
  117. package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
  118. package/tests/browser/folder-picker-layout.spec.mjs +302 -0
  119. package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
  120. package/tests/browser/git-setup-cancel.spec.mjs +251 -0
  121. package/tests/browser/guided-git-fallback.spec.mjs +40 -21
  122. package/tests/browser/inspector-header.spec.mjs +221 -0
  123. package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
  124. package/tests/browser/inspector-resize.spec.mjs +227 -0
  125. package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
  126. package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
  127. package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
  128. package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
  129. package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
  130. package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
  131. package/tests/browser/interaction-continuity.spec.mjs +50 -26
  132. package/tests/browser/interaction-model-picker.spec.mjs +86 -0
  133. package/tests/browser/last-terminal-close.spec.mjs +280 -0
  134. package/tests/browser/mobile-foundation.spec.mjs +172 -20
  135. package/tests/browser/model-catalog-groups.spec.mjs +104 -0
  136. package/tests/browser/more-row-menus.spec.mjs +258 -0
  137. package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
  138. package/tests/browser/no-project-conversation.spec.mjs +113 -0
  139. package/tests/browser/optimistic-prompt.spec.mjs +3 -0
  140. package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
  141. package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
  142. package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
  143. package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
  144. package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
  145. package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
  146. package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
  147. package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
  148. package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
  149. package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
  150. package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
  151. package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
  152. package/tests/browser/project-artifact-controller.spec.mjs +324 -0
  153. package/tests/browser/project-artifact-integration.spec.mjs +103 -0
  154. package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
  155. package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
  156. package/tests/browser/session-fixture.mjs +118 -0
  157. package/tests/browser/session-ownership.spec.mjs +175 -0
  158. package/tests/browser/session-shelves-integration.spec.mjs +219 -0
  159. package/tests/browser/session-shelves.spec.mjs +340 -0
  160. package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
  161. package/tests/browser/session-summary.spec.mjs +17 -12
  162. package/tests/browser/settings-complete-home.spec.mjs +463 -0
  163. package/tests/browser/settings-entrypoint.spec.mjs +104 -0
  164. package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
  165. package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
  166. package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
  167. package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
  168. package/tests/browser/shell-ownership.spec.mjs +398 -0
  169. package/tests/browser/shell-rollout-fixture.mjs +259 -0
  170. package/tests/browser/shell-rollout.spec.mjs +357 -0
  171. package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
  172. package/tests/browser/shell-workspace.spec.mjs +433 -0
  173. package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
  174. package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
  175. package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
  176. package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
  177. package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
  178. package/tests/browser/stream-output-isolation.spec.mjs +6 -3
  179. package/tests/browser/themed-selects.spec.mjs +297 -0
  180. package/tests/browser/thread-start-flow.spec.mjs +481 -0
  181. package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
  182. package/tests/browser/ui-polish-features.spec.mjs +85 -0
  183. package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
  184. package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
  185. package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
  186. package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
  187. package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
  188. package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
  189. package/tests/browser/windows-drive-parent.spec.mjs +4 -2
  190. package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
  191. package/tests/codex-fast-mode-static.test.mjs +16 -11
  192. package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
  193. package/tests/codex-usage-source.test.mjs +4 -3
  194. package/tests/component-update-api-static.test.mjs +2 -2
  195. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  196. package/tests/control-deck-component-updates-static.test.mjs +9 -4
  197. package/tests/control-visibility-static.test.mjs +3 -3
  198. package/tests/controls-layout-static.test.mjs +5 -5
  199. package/tests/conversation-overview-adapter.test.mjs +100 -0
  200. package/tests/document-artifact-static.test.mjs +2 -1
  201. package/tests/draft-conversations.test.mjs +205 -0
  202. package/tests/empty-startup-launcher.test.mjs +197 -0
  203. package/tests/events-tree-context-menu-static.test.mjs +22 -18
  204. package/tests/fake-pi-session-ownership.test.mjs +302 -0
  205. package/tests/fast-mode-client-static.test.mjs +1 -1
  206. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  207. package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
  208. package/tests/file-viewer-image-static.test.mjs +15 -11
  209. package/tests/file-viewer-search-static.test.mjs +5 -5
  210. package/tests/fixtures/fake-pi.mjs +41 -9
  211. package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
  212. package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
  213. package/tests/git-footer-context-menu-static.test.mjs +1 -1
  214. package/tests/git-panel-file-preview-static.test.mjs +41 -48
  215. package/tests/git-panel-live-updates-static.test.mjs +2 -1
  216. package/tests/git-workflow-dispatch.test.mjs +66 -0
  217. package/tests/git-workflow-preferences.test.mjs +9 -1
  218. package/tests/guided-git-activation-static.test.mjs +14 -11
  219. package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
  220. package/tests/guided-git-message-reliability-static.test.mjs +10 -6
  221. package/tests/guided-git-publication-backend-static.test.mjs +16 -11
  222. package/tests/http-endpoints-harness.test.mjs +21 -9
  223. package/tests/interaction-state-stability-static.test.mjs +4 -3
  224. package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
  225. package/tests/intercom-tag-layout-static.test.mjs +13 -12
  226. package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
  227. package/tests/main-output-loading-static.test.mjs +4 -4
  228. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  229. package/tests/mobile-compact-layout.test.mjs +2 -2
  230. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  231. package/tests/mobile-foundation-static.test.mjs +10 -7
  232. package/tests/mobile-phone-experience-static.test.mjs +3 -2
  233. package/tests/mobile-static.test.mjs +173 -135
  234. package/tests/model-catalog-order.test.mjs +103 -0
  235. package/tests/native-parity.test.mjs +6 -4
  236. package/tests/native-session-choice-owner.test.mjs +102 -0
  237. package/tests/native-update-lifecycle.test.mjs +10 -5
  238. package/tests/no-project-http-harness.test.mjs +328 -0
  239. package/tests/no-project-navigation.test.mjs +54 -0
  240. package/tests/no-project-workspaces.test.mjs +77 -0
  241. package/tests/open-issue-wizard-static.test.mjs +1 -1
  242. package/tests/optional-feature-migration-frontend.test.mjs +4 -4
  243. package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
  244. package/tests/package-updates.test.mjs +630 -0
  245. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  246. package/tests/platform-event-stream.test.mjs +253 -0
  247. package/tests/project-file-viewer-controller.test.mjs +652 -0
  248. package/tests/project-git-tools-adapter.test.mjs +103 -0
  249. package/tests/project-git-tools-controller.test.mjs +577 -0
  250. package/tests/project-runners-controller.test.mjs +453 -0
  251. package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
  252. package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
  253. package/tests/questionnaire-dialog.test.mjs +6 -6
  254. package/tests/queue-edit-reorder-static.test.mjs +48 -51
  255. package/tests/rpc-supervisor-host.test.mjs +4 -1
  256. package/tests/safety-guard-auto-review-static.test.mjs +1 -1
  257. package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
  258. package/tests/server-app-runners.test.mjs +536 -0
  259. package/tests/server-codex-fast-mode.test.mjs +346 -0
  260. package/tests/server-conversation-mode.test.mjs +386 -0
  261. package/tests/server-conversation-voice.test.mjs +426 -0
  262. package/tests/server-extension-ui-requests.test.mjs +357 -0
  263. package/tests/server-git-generation.test.mjs +558 -0
  264. package/tests/server-git-mutations.test.mjs +729 -0
  265. package/tests/server-git-reads.test.mjs +381 -0
  266. package/tests/server-git-worktree-sessions.test.mjs +502 -0
  267. package/tests/server-helper-requests.test.mjs +364 -0
  268. package/tests/server-rpc-transports.test.mjs +553 -0
  269. package/tests/server-settings-store.test.mjs +132 -0
  270. package/tests/server-shell-rollout.test.mjs +478 -0
  271. package/tests/server-sse-delivery.test.mjs +410 -0
  272. package/tests/server-workspace-files.test.mjs +546 -0
  273. package/tests/session-attention-scheduler.test.mjs +514 -0
  274. package/tests/session-composer-store.test.mjs +153 -0
  275. package/tests/session-context.test.mjs +134 -0
  276. package/tests/session-extension-requests.test.mjs +193 -0
  277. package/tests/session-ownership-adapter.test.mjs +130 -0
  278. package/tests/session-sampling-ui-static.test.mjs +10 -4
  279. package/tests/session-send-lifetime.test.mjs +140 -0
  280. package/tests/session-shelf-state.test.mjs +348 -0
  281. package/tests/session-shelves-adapter.test.mjs +79 -0
  282. package/tests/session-summary-lifetime.test.mjs +54 -0
  283. package/tests/settings-resource-controller.test.mjs +548 -0
  284. package/tests/shell-action-adapter.test.mjs +169 -0
  285. package/tests/shell-actions.test.mjs +182 -0
  286. package/tests/shell-navigation.test.mjs +348 -0
  287. package/tests/shell-preferences.test.mjs +367 -0
  288. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  289. package/tests/stream-output-isolation-static.test.mjs +1 -1
  290. package/tests/subagent-gate-visibility.test.mjs +1 -1
  291. package/tests/subagent-launch-slot-state.test.mjs +2 -2
  292. package/tests/subagent-launch-slots-static.test.mjs +1 -1
  293. package/tests/subagent-observability-static.test.mjs +2 -2
  294. package/tests/subagent-reliability-integration.test.mjs +13 -30
  295. package/tests/syntax-highlighting-static.test.mjs +3 -3
  296. package/tests/tab-close-continuity-static.test.mjs +1 -1
  297. package/tests/tab-metadata-ordering.test.mjs +99 -0
  298. package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
  299. package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
  300. package/tests/terminal-tab-workspace-static.test.mjs +5 -4
  301. package/tests/terminal-tabs-resize-static.test.mjs +1 -1
  302. package/tests/theme-customizer-static.test.mjs +1 -1
  303. package/tests/thread-display-title.test.mjs +44 -0
  304. package/tests/update-api-harness.test.mjs +15 -14
  305. package/tests/update-tab-restore-harness.test.mjs +3 -0
  306. package/tests/webui-settings-locking.test.mjs +2 -2
  307. package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
  308. package/tests/workspace-choices.test.mjs +114 -0
  309. package/tests/workspace-save-load-static.test.mjs +7 -4
@@ -0,0 +1,453 @@
1
+ import assert from "node:assert/strict";
2
+ import { test } from "node:test";
3
+ import {
4
+ APP_RUNNER_CONTEXT_DEFAULT_LINES,
5
+ APP_RUNNER_CONTEXT_MAX_LINES,
6
+ createProjectRunnersController,
7
+ normalizeAppRunnerContextLineCount,
8
+ } from "../public/project-runners-controller.mjs";
9
+
10
+ const running = (id = "run-a") => ({ id, runnerId: "dev", status: "running", displayCommand: "npm run dev" });
11
+
12
+ function fixture() {
13
+ let target = { tabId: "a", lifetime: 1 };
14
+ const calls = [];
15
+ const notifications = [];
16
+ const renders = [];
17
+ const events = [];
18
+ const contextRefreshes = [];
19
+ const controller = createProjectRunnersController({
20
+ captureTarget: () => target,
21
+ isTargetCurrent: (captured) => captured.tabId === target.tabId && captured.lifetime === target.lifetime,
22
+ cleanStatusText: (text) => text.replaceAll("\u001b[31m", "").replaceAll("\n", " "),
23
+ api(path, options) {
24
+ let resolve;
25
+ let reject;
26
+ const pending = new Promise((accept, fail) => { resolve = accept; reject = fail; });
27
+ calls.push({ path, options, resolve: (data = {}) => resolve({ ok: true, data }), reject });
28
+ return pending;
29
+ },
30
+ onData: (...args) => notifications.push(args),
31
+ onRender: (options) => renders.push(options),
32
+ addEvent: (...args) => events.push(args),
33
+ onRefreshContext: (captured) => contextRefreshes.push(captured),
34
+ });
35
+ return {
36
+ controller, calls, notifications, renders, events, contextRefreshes,
37
+ target: () => target,
38
+ select(tabId, lifetime = 1) { target = { tabId, lifetime }; },
39
+ seed(run = running()) { controller.applyData("a", { activeRun: run }); },
40
+ };
41
+ }
42
+
43
+ test("merging preserves omitted run and metadata, while explicit null clears the run without rendering", () => {
44
+ const f = fixture();
45
+ const c = f.controller;
46
+ assert.deepEqual(c.getData("missing"), { runners: [], activeRun: null });
47
+ assert.equal(c.applyData(null, { activeRun: running() }), undefined);
48
+ const config = { path: ".pi-webui-runners.json" };
49
+ const runners = [{ id: "dev", label: "Dev" }];
50
+ const run = running();
51
+ c.applyData("a", { cwd: "/project", runners, customRunnerConfig: config, activeRun: run });
52
+ c.applyData("a", { runners: "invalid", cwd: "", customRunnerConfig: null });
53
+ assert.deepEqual(c.getData("a"), { cwd: "/project", runners, customRunnerConfig: config, activeRun: run });
54
+ assert.deepEqual(f.notifications[1], ["a", c.getData("a"), { hasActiveRun: false }]);
55
+ c.applyData("a", { activeRun: null, runners: [] });
56
+ assert.deepEqual(f.notifications[2][2], { hasActiveRun: true });
57
+ assert.equal(c.getData("a").activeRun, null);
58
+ assert.deepEqual(c.getData("a").runners, []);
59
+ c.applyData("b", { cwd: "/background", activeRun: running("run-b") });
60
+ assert.equal(c.getData("b").activeRun.id, "run-b");
61
+ assert.equal(c.getData("a").activeRun, null);
62
+ assert.deepEqual(f.renders, []);
63
+ assert.deepEqual(f.calls, []);
64
+ });
65
+
66
+ test("discovery and start construct actual requests and distinguish tab repainting", async () => {
67
+ const f = fixture();
68
+ const c = f.controller;
69
+ const discovery = c.refresh();
70
+ assert.deepEqual(f.calls[0].options, { tabId: "a" });
71
+ assert.equal(f.calls[0].path, "/api/app-runners");
72
+ f.calls[0].resolve({ cwd: "/project", runners: [{ id: "dev" }] });
73
+ assert.deepEqual(await discovery, { success: true, data: { cwd: "/project", runners: [{ id: "dev" }] } });
74
+ assert.deepEqual(f.renders, [{ tabs: false }]);
75
+ const start = c.start("dev");
76
+ assert.deepEqual(f.calls[1].options, { method: "POST", body: { runnerId: "dev" }, tabId: "a" });
77
+ assert.equal(f.calls[1].path, "/api/app-runner");
78
+ f.calls[1].resolve({ activeRun: running() });
79
+ assert.equal((await start).success, true);
80
+ assert.equal(c.getData("a").cwd, "/project");
81
+ assert.deepEqual(f.renders, [{ tabs: false }, { tabs: true }]);
82
+ assert.deepEqual(f.events, [["started npm run dev", "info"]]);
83
+ });
84
+
85
+ test("stop and clear target the captured run without adding its ID to the wire", async () => {
86
+ const f = fixture();
87
+ f.seed();
88
+ const stop = f.controller.stop("run-a");
89
+ assert.equal(f.calls[0].path, "/api/app-runner/stop");
90
+ assert.deepEqual(f.calls[0].options, { method: "POST", body: {}, tabId: "a" });
91
+ f.calls[0].resolve({ activeRun: { ...running(), status: "done" } });
92
+ assert.equal((await stop).success, true);
93
+ const clear = f.controller.clear("run-a");
94
+ assert.equal(f.calls[1].path, "/api/app-runner/clear");
95
+ assert.deepEqual(f.calls[1].options, { method: "POST", body: {}, tabId: "a" });
96
+ f.calls[1].resolve({ activeRun: null });
97
+ assert.equal((await clear).success, true);
98
+ assert.equal(f.controller.getData("a").activeRun, null);
99
+ assert.deepEqual(f.events, [["app runner stop requested", "warn"]]);
100
+ assert.deepEqual(f.renders, [{ tabs: true }, { tabs: true }]);
101
+ });
102
+
103
+ const actions = {
104
+ refresh: (c, target) => c.refresh(target),
105
+ start: (c, target) => c.start("dev", target),
106
+ stop: (c, target) => c.stop("run-a", target),
107
+ clear: (c, target) => c.clear("run-a", target),
108
+ input: (c, target) => c.sendInput({ runId: "run-a", text: "submitted" }, target),
109
+ context: (c, target) => c.transferContext({ runId: "run-a", lineCount: 7 }, target),
110
+ };
111
+
112
+ test("requests reject retired snapshots while same-run input acknowledgments survive SSE", async (t) => {
113
+ for (const [name, invoke] of Object.entries(actions)) {
114
+ for (const invalidation of ["retire", "sse", "replacement", "lifetime", "switch"]) {
115
+ await t.test(`${name}: ${invalidation}`, async () => {
116
+ const f = fixture();
117
+ f.seed();
118
+ f.controller.setInputDraft("a", "run-a", "submitted");
119
+ const pending = invoke(f.controller);
120
+ if (invalidation === "retire") {
121
+ f.controller.forgetTab("a");
122
+ f.seed(running("replacement"));
123
+ f.controller.setInputDraft("a", "run-a", "new lifetime draft");
124
+ } else if (invalidation === "replacement") {
125
+ f.seed(running("replacement"));
126
+ } else if (invalidation === "sse") {
127
+ f.controller.applyData("a", { activeRun: { ...running(), pendingLine: "new output" } });
128
+ } else {
129
+ f.select(invalidation === "switch" ? "b" : "a", 2);
130
+ }
131
+ const before = f.controller.getData("a");
132
+ const notificationCount = f.notifications.length;
133
+ f.calls[0].resolve({ activeRun: running("old-response"), delivery: "steer" });
134
+ if (name === "input" && invalidation === "sse") {
135
+ const result = await pending;
136
+ assert.equal(result.success, true);
137
+ assert.equal(result.inputDraftCleared, true);
138
+ assert.equal(f.controller.getData("a"), before);
139
+ assert.equal(f.notifications.length, notificationCount);
140
+ assert.equal(f.controller.getInputDraft("a", "run-a"), "");
141
+ assert.deepEqual(f.renders, [{ tabs: false }]);
142
+ assert.deepEqual(f.events, [["sent app runner input", "info"]]);
143
+ return;
144
+ }
145
+ assert.deepEqual(await pending, { success: false, reason: "stale" });
146
+ assert.equal(f.controller.getData("a"), before);
147
+ assert.equal(f.notifications.length, notificationCount);
148
+ assert.deepEqual(f.renders, []);
149
+ assert.deepEqual(f.events, []);
150
+ assert.deepEqual(f.contextRefreshes, []);
151
+ assert.equal(f.controller.getInputDraft("a", "run-a"), invalidation === "retire" ? "new lifetime draft" : "submitted");
152
+ });
153
+ }
154
+ }
155
+ });
156
+
157
+ test("later requests supersede discovery and start failures as well as successful results", async () => {
158
+ const f = fixture();
159
+ f.seed();
160
+ const oldDiscovery = f.controller.refresh();
161
+ const oldStart = f.controller.start("dev");
162
+ const latest = f.controller.refresh();
163
+ f.calls[2].resolve({ activeRun: running("latest") });
164
+ assert.equal((await latest).success, true);
165
+ f.calls[0].resolve({ activeRun: null });
166
+ f.calls[1].reject(new Error("superseded start failed"));
167
+ assert.deepEqual(await oldDiscovery, { success: false, reason: "stale" });
168
+ assert.deepEqual(await oldStart, { success: false, reason: "stale" });
169
+ assert.equal(f.controller.getData("a").activeRun.id, "latest");
170
+ assert.deepEqual(f.events, []);
171
+ assert.deepEqual(f.renders, [{ tabs: false }]);
172
+ });
173
+
174
+ test("a mutation supersedes a pending refresh before either finishes", async () => {
175
+ const f = fixture();
176
+ f.seed();
177
+ const refresh = f.controller.refresh();
178
+ const start = f.controller.start("dev");
179
+ f.calls[0].resolve({ activeRun: null });
180
+ assert.deepEqual(await refresh, { success: false, reason: "stale" });
181
+ assert.equal(f.controller.getData("a").activeRun.id, "run-a");
182
+ f.calls[1].resolve({ activeRun: running("next") });
183
+ assert.equal((await start).success, true);
184
+ assert.equal(f.controller.getData("a").activeRun.id, "next");
185
+ });
186
+
187
+ test("background data and drafts cannot supersede another tab's pending request", async () => {
188
+ const f = fixture();
189
+ f.seed();
190
+ f.controller.setInputDraft("a", "run-a", "submitted");
191
+ const pending = f.controller.sendInput({ runId: "run-a", text: "submitted" });
192
+ f.controller.applyData("b", { cwd: "/other", activeRun: running() });
193
+ f.controller.setInputDraft("b", "run-a", "background edit");
194
+ f.controller.forgetTab("unused");
195
+ f.calls[0].resolve({ activeRun: running() });
196
+ assert.equal((await pending).inputDraftCleared, true);
197
+ assert.equal(f.controller.getInputDraft("b", "run-a"), "background edit");
198
+ assert.equal(f.controller.getData("b").cwd, "/other");
199
+ });
200
+
201
+ test("invalid targets and stale run forms never dispatch or supersede a valid request", async () => {
202
+ const f = fixture();
203
+ f.seed();
204
+ const pending = f.controller.refresh();
205
+ for (const invoke of Object.values(actions)) {
206
+ assert.deepEqual(await invoke(f.controller, { tabId: "a", lifetime: 0 }), { success: false, reason: "target" });
207
+ assert.deepEqual(await invoke(f.controller, {}), { success: false, reason: "target" });
208
+ }
209
+ assert.deepEqual(await f.controller.start(""), { success: false, reason: "runner" });
210
+ assert.deepEqual(await f.controller.stop("old"), { success: false, reason: "run" });
211
+ assert.deepEqual(await f.controller.clear("old"), { success: false, reason: "run" });
212
+ assert.deepEqual(await f.controller.sendInput({ runId: "old", text: "wrong process" }), { success: false, reason: "run" });
213
+ assert.deepEqual(await f.controller.transferContext({ runId: "old", lineCount: 3 }), { success: false, reason: "run" });
214
+ assert.equal(f.calls.length, 1);
215
+ f.calls[0].resolve({ activeRun: running() });
216
+ assert.equal((await pending).success, true);
217
+ });
218
+
219
+ test("run identity is mandatory and input admission keeps the existing running/stopping rule", async () => {
220
+ const f = fixture();
221
+ for (const run of [null, { ...running(), status: "done" }, { ...running(), status: "error" }]) {
222
+ f.seed(run);
223
+ assert.deepEqual(await f.controller.sendInput({ runId: "run-a", text: "x" }), { success: false, reason: "run" });
224
+ }
225
+ f.seed();
226
+ assert.deepEqual(await f.controller.stop(), { success: false, reason: "run" });
227
+ assert.deepEqual(await f.controller.clear(), { success: false, reason: "run" });
228
+ f.seed({ ...running(), status: "done", stopping: true });
229
+ const pending = f.controller.sendInput({ runId: "run-a", text: "" });
230
+ f.calls[0].resolve();
231
+ assert.equal((await pending).success, true);
232
+ });
233
+
234
+ test("start errors construct terminal output from owned runner metadata and clean the message", async () => {
235
+ const f = fixture();
236
+ const runner = { id: "dev", kind: "npm", label: "Development", command: "npm", args: ["run", "dev"], displayCommand: "npm run dev" };
237
+ f.controller.applyData("a", { cwd: "/project", runners: [runner] });
238
+ const pending = f.controller.start("dev");
239
+ const error = new Error("\u001b[31mspawn failed\ntry again");
240
+ f.calls[0].reject(error);
241
+ assert.deepEqual(await pending, { success: false, reason: "error", error });
242
+ const run = f.controller.getData("a").activeRun;
243
+ assert.match(run.id, /^start-error:\d+$/);
244
+ assert.equal(run.startedAt, run.endedAt);
245
+ assert.ok(Number.isFinite(Date.parse(run.startedAt)));
246
+ assert.deepEqual({ ...run, id: "<id>", startedAt: "<time>", endedAt: "<time>" }, {
247
+ id: "<id>", runnerId: "dev", kind: "npm", label: "Development", command: "npm", args: ["run", "dev"],
248
+ displayCommand: "npm run dev", cwd: "/project", status: "error", startedAt: "<time>", endedAt: "<time>",
249
+ lineCount: 3, lines: ["$ npm run dev", "# failed to start app runner", "# spawn failed try again"],
250
+ });
251
+ assert.deepEqual(f.events, [["app runner failed: spawn failed try again", "error"]]);
252
+ assert.deepEqual(f.renders, [{ tabs: true }]);
253
+ assert.equal(f.notifications.at(-1)[2].hasActiveRun, true);
254
+ });
255
+
256
+ test("unknown runner failures retain fallback command, label, kind and empty args", async () => {
257
+ const f = fixture();
258
+ const pending = f.controller.start("missing");
259
+ f.calls[0].reject("unavailable");
260
+ assert.equal((await pending).success, false);
261
+ const run = f.controller.getData("a").activeRun;
262
+ assert.equal(run.displayCommand, "missing");
263
+ assert.equal(run.label, "App runner failed");
264
+ assert.equal(run.kind, "custom");
265
+ assert.equal(run.command, "");
266
+ assert.deepEqual(run.args, []);
267
+ });
268
+
269
+ test("input, Enter and EOF preserve the exact payload and clear only the submitted draft", async (t) => {
270
+ for (const [text, closeStdin, newline, event] of [
271
+ ["hello\nworld", false, true, "sent app runner input"],
272
+ ["", false, true, "sent app runner Enter"],
273
+ ["", true, false, "sent app runner EOF"],
274
+ ["last line", true, true, "sent app runner EOF"],
275
+ ]) {
276
+ await t.test(event + JSON.stringify(text), async () => {
277
+ const f = fixture();
278
+ f.seed();
279
+ f.controller.setInputDraft("a", "run-a", text);
280
+ f.controller.setInputDraft("a", "other", "keep other run");
281
+ const pending = f.controller.sendInput({ runId: "run-a", text, closeStdin });
282
+ assert.equal(f.calls[0].path, "/api/app-runner/input");
283
+ assert.deepEqual(f.calls[0].options, { method: "POST", body: { text, newline, closeStdin }, tabId: "a" });
284
+ const data = { activeRun: running() };
285
+ f.calls[0].resolve(data);
286
+ assert.deepEqual(await pending, { success: true, data, inputDraftCleared: true });
287
+ assert.equal(f.controller.getInputDraft("a", "run-a"), "");
288
+ assert.equal(f.controller.getInputDraft("a", "other"), "keep other run");
289
+ assert.deepEqual(f.renders, [{ tabs: false }]);
290
+ assert.deepEqual(f.events, [[event, "info"]]);
291
+ });
292
+ }
293
+ });
294
+
295
+ test("edits during a send survive, including edits that return to the submitted text", async (t) => {
296
+ for (const editedText of ["new draft", "submitted"]) {
297
+ await t.test(editedText, async () => {
298
+ const f = fixture();
299
+ f.seed();
300
+ f.controller.setInputDraft("a", "run-a", "submitted");
301
+ const pending = f.controller.sendInput({ runId: "run-a", text: "submitted" });
302
+ f.controller.setInputDraft("a", "run-a", "temporary edit");
303
+ f.controller.setInputDraft("a", "run-a", editedText);
304
+ f.calls[0].resolve({ activeRun: running() });
305
+ assert.equal((await pending).inputDraftCleared, false);
306
+ assert.equal(f.controller.getInputDraft("a", "run-a"), editedText);
307
+ });
308
+ }
309
+ });
310
+
311
+ test("drafts are scoped by both tab and run, survive data changes, and retirement removes only one tab", () => {
312
+ const f = fixture();
313
+ const c = f.controller;
314
+ for (const tab of ["a", "b", "a:run"]) {
315
+ c.setInputDraft(tab, "same", `${tab} input`);
316
+ c.setContextDraft(tab, "same", tab === "a" ? 14 : 27);
317
+ }
318
+ c.setInputDraft("a", "run:same", "separate key");
319
+ c.applyData("a", { activeRun: running("other") });
320
+ c.applyData("a", { activeRun: null });
321
+ assert.equal(c.getInputDraft("a", "same"), "a input");
322
+ assert.equal(c.getContextDraft("a", "same"), "14");
323
+ assert.equal(c.getInputDraft("a", "run:same"), "separate key");
324
+ c.forgetTab("a");
325
+ c.forgetTab("a");
326
+ assert.equal(c.getInputDraft("a", "same"), "");
327
+ assert.equal(c.getContextDraft("a", "same"), "80");
328
+ assert.deepEqual(c.getData("a"), { runners: [], activeRun: null });
329
+ assert.equal(c.getInputDraft("b", "same"), "b input");
330
+ assert.equal(c.getContextDraft("b", "same"), "27");
331
+ assert.equal(c.getInputDraft("a:run", "same"), "a:run input");
332
+ assert.deepEqual(f.calls, []);
333
+ assert.deepEqual(f.renders, []);
334
+ });
335
+
336
+ test("context normalization retains existing parsing and bounds", () => {
337
+ assert.equal(APP_RUNNER_CONTEXT_DEFAULT_LINES, 80);
338
+ assert.equal(APP_RUNNER_CONTEXT_MAX_LINES, 1000);
339
+ for (const [value, expected] of [[undefined, 80], [null, 80], ["", 80], ["bad", 80], ["17lines", 17], ["4.9", 4], [0, 1], [-20, 1], [9000, 1000]]) {
340
+ assert.equal(normalizeAppRunnerContextLineCount(value), expected);
341
+ }
342
+ });
343
+
344
+ test("context transfer uses bounded draft values and retains the captured target for refresh", async (t) => {
345
+ for (const [value, normalized, delivery] of [[0, 1, "steer"], [9000, 1000, "context"], [undefined, 23, "context"]]) {
346
+ await t.test(String(value), async () => {
347
+ const f = fixture();
348
+ f.seed({ ...running(), status: "done" });
349
+ const target = { ...f.target(), marker: "captured" };
350
+ f.controller.setContextDraft("a", "run-a", 23);
351
+ const pending = f.controller.transferContext({ runId: "run-a", lineCount: value }, target);
352
+ assert.equal(f.calls[0].path, "/api/app-runner/context");
353
+ assert.deepEqual(f.calls[0].options, { method: "POST", body: { lineCount: normalized }, tabId: "a" });
354
+ assert.equal(f.controller.getContextDraft("a", "run-a"), String(normalized));
355
+ f.controller.setContextDraft("a", "run-a", 51);
356
+ const data = { activeRun: { ...running(), status: "done", contextTransferred: true }, delivery, lineCount: 1 };
357
+ f.calls[0].resolve(data);
358
+ assert.deepEqual(await pending, { success: true, data });
359
+ assert.equal(f.controller.getData("a").activeRun.contextTransferred, true);
360
+ assert.equal(f.controller.getContextDraft("a", "run-a"), "51");
361
+ assert.deepEqual(f.renders, []);
362
+ assert.equal(f.contextRefreshes[0], target);
363
+ assert.deepEqual(f.events, [[delivery === "steer"
364
+ ? "sent last 1 app runner output lines as live steering context"
365
+ : "added last 1 app runner output lines to agent context", "info"]]);
366
+ });
367
+ }
368
+ });
369
+
370
+ test("context completion without an activeRun leaves owned run and metadata intact", async () => {
371
+ const f = fixture();
372
+ f.seed();
373
+ const count = f.notifications.length;
374
+ const pending = f.controller.transferContext({ runId: "run-a", lineCount: 10 });
375
+ f.calls[0].resolve({ activeRun: null });
376
+ assert.equal((await pending).success, true);
377
+ assert.equal(f.notifications.length, count);
378
+ assert.equal(f.controller.getData("a").activeRun.id, "run-a");
379
+ assert.deepEqual(f.events, [["added last 10 app runner output lines to agent context", "info"]]);
380
+ assert.equal(f.contextRefreshes.length, 1);
381
+ });
382
+
383
+ test("request errors retain existing event wording and preserve drafts and data", async (t) => {
384
+ for (const [name, message] of [
385
+ ["refresh", null], ["stop", "cannot perform action"], ["clear", "cannot perform action"],
386
+ ["input", "app runner input failed: cannot perform action"],
387
+ ["context", "app runner context transfer failed: cannot perform action"],
388
+ ]) {
389
+ await t.test(name, async () => {
390
+ const f = fixture();
391
+ f.seed();
392
+ f.controller.setInputDraft("a", "run-a", "submitted");
393
+ const before = f.controller.getData("a");
394
+ const pending = actions[name](f.controller);
395
+ const error = new Error("cannot perform action");
396
+ f.calls[0].reject(error);
397
+ assert.deepEqual(await pending, { success: false, reason: "error", error });
398
+ assert.equal(f.controller.getData("a"), before);
399
+ assert.equal(f.controller.getInputDraft("a", "run-a"), "submitted");
400
+ assert.deepEqual(f.renders, []);
401
+ assert.deepEqual(f.contextRefreshes, []);
402
+ assert.deepEqual(f.events, message ? [[message, "error"]] : []);
403
+ });
404
+ }
405
+ });
406
+
407
+ test("errors from retired requests produce no failure output or events", async (t) => {
408
+ for (const [name, invoke] of Object.entries(actions)) {
409
+ await t.test(name, async () => {
410
+ const f = fixture();
411
+ f.seed();
412
+ const pending = invoke(f.controller);
413
+ f.controller.forgetTab("a");
414
+ f.calls[0].reject(new Error("retired failure"));
415
+ assert.deepEqual(await pending, { success: false, reason: "stale" });
416
+ assert.deepEqual(f.controller.getData("a"), { runners: [], activeRun: null });
417
+ assert.deepEqual(f.events, []);
418
+ assert.deepEqual(f.renders, []);
419
+ });
420
+ }
421
+ });
422
+
423
+ test("explicit target is used instead of the currently selected tab", async () => {
424
+ const f = fixture();
425
+ f.seed();
426
+ const target = f.target();
427
+ f.select("b");
428
+ assert.deepEqual(await f.controller.start("dev", target), { success: false, reason: "target" });
429
+ assert.deepEqual(f.calls, []);
430
+ const pending = f.controller.start("dev");
431
+ assert.equal(f.calls[0].options.tabId, "b");
432
+ f.calls[0].resolve({ activeRun: running("run-b") });
433
+ assert.equal((await pending).success, true);
434
+ assert.equal(f.controller.getData("b").activeRun.id, "run-b");
435
+ assert.equal(f.controller.getData("a").activeRun.id, "run-a");
436
+ });
437
+
438
+
439
+ test("same-run output before stdin acknowledgment preserves a newer draft and newer output", async () => {
440
+ const f = fixture();
441
+ f.seed();
442
+ f.controller.setInputDraft("a", "run-a", "submitted");
443
+ const pending = f.controller.sendInput({ runId: "run-a", text: "submitted" });
444
+ f.controller.applyData("a", { activeRun: { ...running(), lines: ["echo:submitted"] } });
445
+ const currentData = f.controller.getData("a");
446
+ f.controller.setInputDraft("a", "run-a", "next command");
447
+ f.calls[0].resolve({ activeRun: { ...running(), lines: [] } });
448
+ const result = await pending;
449
+ assert.equal(result.success, true);
450
+ assert.equal(result.inputDraftCleared, false);
451
+ assert.equal(f.controller.getInputDraft("a", "run-a"), "next command");
452
+ assert.equal(f.controller.getData("a"), currentData);
453
+ });
@@ -19,8 +19,8 @@ const resizePromptInput = app.slice(resizeStart, resizeEnd);
19
19
  assert.match(css, /#promptInput \{[\s\S]*--prompt-input-block-chrome: calc\(1\.8rem \+ 2px\);[\s\S]*max-height: calc\(6lh \+ var\(--prompt-input-block-chrome\)\);[\s\S]*overflow-y: auto;[\s\S]*overscroll-behavior-y: contain;/, "the prompt should show six complete lines before native vertical scrolling begins");
20
20
  assert.match(resizePromptInput, /input\.style\.height = "auto";[\s\S]*borderTopWidth[\s\S]*borderBottomWidth[\s\S]*naturalHeight = input\.scrollHeight \+ borderBlock[\s\S]*isCapped \? "auto" : "hidden"/, "auto-resizing should include the textarea borders and enable vertical scrolling only after the six-line cap");
21
21
  assert.doesNotMatch(resizePromptInput, /input\.style\.overflowY = "auto";/, "auto-resizing must not force a scrollbar below the six-line cap");
22
- assert.match(html, /styles\.css\?v=154/, "the page should request the six-line prompt stylesheet revision");
23
- assert.match(html, /app\.js\?v=185/, "the page should request the current app revision");
24
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v156"/, "the PWA cache identity should advance with the prompt scroll assets");
22
+ assert.match(html, /styles\.css\?v=167/, "the page should request the six-line prompt stylesheet revision");
23
+ assert.match(html, /app\.js\?v=220/, "the page should request the current app revision");
24
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v200"/, "the PWA cache identity should advance with the prompt scroll assets");
25
25
 
26
26
  console.log("prompt-input-vertical-scroll-static.test.mjs passed");
@@ -15,7 +15,7 @@ function functionSource(name, nextName) {
15
15
 
16
16
  const clearSource = functionSource("clearPromptInputForRouting", "restorePromptInputAfterRoutingError");
17
17
  assert.match(clearSource, /if \(!usesPromptInput\) return;/, "programmatic prompt sends should preserve the visible draft");
18
- assert.match(clearSource, /tabDrafts\.set\(targetTabId, ""\);[\s\S]*elements\.promptInput\.value = "";[\s\S]*resizePromptInput\(\);[\s\S]*hideCommandSuggestions\(\);/, "input-backed sends should immediately clear their tab draft, textarea, and stale suggestions");
18
+ assert.match(clearSource, /composerStore\.setDraft\(targetTabId, ""\);[\s\S]*elements\.promptInput\.value = "";[\s\S]*resizePromptInput\(\);[\s\S]*hideCommandSuggestions\(\);/, "input-backed sends should immediately clear their tab draft, textarea, and stale suggestions");
19
19
 
20
20
  const sendSource = functionSource("sendPrompt", "hasQueuedDialogRequest");
21
21
  const clearIndex = sendSource.indexOf("clearPromptInputForRouting({ usesPromptInput, targetTabId, tabContext });");
@@ -24,7 +24,7 @@ const requestIndex = sendSource.indexOf('await api("/api/prompt"');
24
24
  assert.ok(clearIndex >= 0, "sendPrompt should clear the captured input-backed draft");
25
25
  assert.ok(routingIndex >= 0 && clearIndex < routingIndex, "the submitted prompt should be cleared before routing progress starts");
26
26
  assert.ok(requestIndex >= 0 && clearIndex < requestIndex, "the submitted prompt should be cleared before the prompt request starts");
27
- assert.match(sendSource, /catch \(error\) \{\n\s+(?:if \(guidedGitPermitGranted\) guidedGitLaunchPermits\.clearTab\(targetTabId\);\n\s+)?restorePromptInputAfterRoutingError\(inputMessage,/, "a routing failure should revoke any activation permit and restore the sent input when no replacement draft exists");
27
+ assert.match(sendSource, /catch \(error\) \{\s+if \(!sessionContext\.isLifetimeCurrent\(lifetime\)\) \{\s+if \(throwOnError\) throw error;\s+return;\s+\}\s+if \(guidedGitPermitGranted\) guidedGitLaunchPermits\.clearTab\(targetTabId\);\s+restorePromptInputAfterRoutingError\(inputMessage,/, "only a current-session routing failure may revoke its permit and restore the sent input");
28
28
 
29
29
  const successStart = sendSource.indexOf("applyResponseTab(response);");
30
30
  const catchStart = sendSource.indexOf("} catch (error)", successStart);
@@ -257,14 +257,14 @@ function inputHarness(prefill = "") {
257
257
 
258
258
  const cancelActiveExtensionDialogSource = functionSource("cancelActiveExtensionDialog");
259
259
  const makeCancelActiveExtensionDialog = new Function(
260
- "activeDialog",
260
+ "extensionRequests",
261
261
  "activeDialogCancel",
262
262
  `${cancelActiveExtensionDialogSource}; return cancelActiveExtensionDialog;`,
263
263
  );
264
264
  {
265
265
  let cancellationCount = 0;
266
266
  let responseSent = false;
267
- const cancelActiveExtensionDialog = makeCancelActiveExtensionDialog({ id: "active-request" }, () => {
267
+ const cancelActiveExtensionDialog = makeCancelActiveExtensionDialog({ active: { id: "active-request" } }, () => {
268
268
  if (responseSent) return false;
269
269
  responseSent = true;
270
270
  cancellationCount += 1;
@@ -276,7 +276,7 @@ const makeCancelActiveExtensionDialog = new Function(
276
276
  assert.equal(event.defaultPrevented, true, "native Escape cancellation must prevent the browser from closing method=dialog directly");
277
277
  assert.equal(cancellationCount, 1, "native Escape cancellation must send exactly once");
278
278
  const inactiveEvent = { defaultPrevented: false, preventDefault() { this.defaultPrevented = true; } };
279
- assert.equal(makeCancelActiveExtensionDialog(null, null)(inactiveEvent), false, "inactive dialogs must ignore stray cancel events");
279
+ assert.equal(makeCancelActiveExtensionDialog({ active: null }, null)(inactiveEvent), false, "inactive dialogs must ignore stray cancel events");
280
280
  assert.equal(inactiveEvent.defaultPrevented, false);
281
281
  }
282
282
  assert.match(app, /elements\.dialog\.addEventListener\("cancel", cancelActiveExtensionDialog\)/, "the native dialog cancel event must use the active response guard");
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
504
504
  assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
505
505
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
506
506
 
507
- assert.match(html, /styles\.css\?v=154/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=185/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v156"/, "questionnaire public assets need a coherent PWA cache revision");
507
+ assert.match(html, /styles\.css\?v=167/, "questionnaire CSS needs the current stylesheet revision");
508
+ assert.match(html, /app\.js\?v=220/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v200"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");