@zyro-sec/app 0.0.0-stage → 1.0.0

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 (1360) hide show
  1. package/AGENTS.md +234 -0
  2. package/README.md +106 -2
  3. package/bunfig.toml +3 -0
  4. package/component-tests/activity-chips.spec.ts +47 -0
  5. package/component-tests/browser-pane-restore.spec.ts +1294 -0
  6. package/component-tests/browser-pane.spec.ts +2338 -0
  7. package/component-tests/browser-settings.spec.ts +315 -0
  8. package/component-tests/browser-site-chooser.spec.ts +628 -0
  9. package/component-tests/components-lab.spec.ts +24 -0
  10. package/component-tests/composer.spec.ts +876 -0
  11. package/component-tests/debug-bar.spec.ts +237 -0
  12. package/component-tests/dialog-popups.spec.ts +49 -0
  13. package/component-tests/file-icon.spec.ts +14 -0
  14. package/component-tests/focus-rescue.fixture.tsx +30 -0
  15. package/component-tests/focus-rescue.spec.ts +83 -0
  16. package/component-tests/focus-ring.spec.ts +112 -0
  17. package/component-tests/fork-dialog.spec.ts +61 -0
  18. package/component-tests/grow.fixture.tsx +42 -0
  19. package/component-tests/grow.spec.ts +74 -0
  20. package/component-tests/image-preview.spec.ts +157 -0
  21. package/component-tests/input-surfaces.spec.ts +351 -0
  22. package/component-tests/line-comment.spec.ts +118 -0
  23. package/component-tests/list.spec.ts +7 -0
  24. package/component-tests/model-picker.spec.ts +45 -0
  25. package/component-tests/new-session-wordmark.spec.ts +135 -0
  26. package/component-tests/open-in-border.spec.ts +18 -0
  27. package/component-tests/pairing.spec.ts +40 -0
  28. package/component-tests/panel-sidebar-side.spec.ts +103 -0
  29. package/component-tests/plugin-graph.spec.ts +61 -0
  30. package/component-tests/plugin-host.fixture.tsx +995 -0
  31. package/component-tests/plugin-host.spec.ts +2362 -0
  32. package/component-tests/presence.fixture.tsx +59 -0
  33. package/component-tests/presence.spec.ts +104 -0
  34. package/component-tests/session-containment.fixture.tsx +79 -0
  35. package/component-tests/session-containment.spec.ts +145 -0
  36. package/component-tests/session-location-missing.spec.ts +52 -0
  37. package/component-tests/session-question-dock.spec.ts +1655 -0
  38. package/component-tests/sources-experiment.spec.ts +98 -0
  39. package/component-tests/ssh-reconnect.spec.ts +97 -0
  40. package/component-tests/subagent-bar.spec.ts +29 -0
  41. package/component-tests/terminal.spec.ts +148 -0
  42. package/component-tests/timeline-detail.spec.ts +311 -0
  43. package/component-tests/timeline-virtualizer.fixture.tsx +272 -0
  44. package/component-tests/timeline-virtualizer.spec.ts +269 -0
  45. package/component-tests/toast.spec.ts +23 -0
  46. package/component-tests/tooltip.spec.ts +169 -0
  47. package/component-tests/websearch.spec.ts +86 -0
  48. package/e2e/AGENTS.md +25 -0
  49. package/e2e/QUARANTINE.md +12 -0
  50. package/e2e/regression/background-read-failure.spec.ts +43 -0
  51. package/e2e/regression/btw-sidebar.spec.ts +339 -0
  52. package/e2e/regression/command-palette.spec.ts +822 -0
  53. package/e2e/regression/composer.spec.ts +1727 -0
  54. package/e2e/regression/directory-picker.spec.ts +133 -0
  55. package/e2e/regression/home.spec.ts +779 -0
  56. package/e2e/regression/mcp-workspace-toggle.spec.ts +695 -0
  57. package/e2e/regression/menu-scrollbars.spec.ts +78 -0
  58. package/e2e/regression/mobile-composer-submit-focus.spec.ts +88 -0
  59. package/e2e/regression/mobile-model-pickers.spec.ts +433 -0
  60. package/e2e/regression/mobile-plugin-drawers.spec.ts +194 -0
  61. package/e2e/regression/mobile-plugins.spec.ts +309 -0
  62. package/e2e/regression/mobile-session-options.spec.ts +101 -0
  63. package/e2e/regression/mobile-session.spec.ts +442 -0
  64. package/e2e/regression/mobile-timeline-scroll.spec.ts +919 -0
  65. package/e2e/regression/multi-server.spec.ts +498 -0
  66. package/e2e/regression/new-session.spec.ts +1666 -0
  67. package/e2e/regression/panel-edges.spec.ts +79 -0
  68. package/e2e/regression/patch-border.spec.ts +69 -0
  69. package/e2e/regression/patch-sticky-header.spec.ts +320 -0
  70. package/e2e/regression/review.spec.ts +2397 -0
  71. package/e2e/regression/session-header.spec.ts +1020 -0
  72. package/e2e/regression/session-location-sync.spec.ts +412 -0
  73. package/e2e/regression/session-notice-truncation.spec.ts +92 -0
  74. package/e2e/regression/session-panel-scrollbar.spec.ts +46 -0
  75. package/e2e/regression/session-queue.spec.ts +1704 -0
  76. package/e2e/regression/session-request-docks.spec.ts +719 -0
  77. package/e2e/regression/session-summary.spec.ts +1092 -0
  78. package/e2e/regression/session-timeline-accessibility.spec.ts +216 -0
  79. package/e2e/regression/session-timeline-locale-projection.spec.ts +24 -0
  80. package/e2e/regression/session-timeline-reducer-projection.spec.ts +53 -0
  81. package/e2e/regression/session-timeline-tool-projection.spec.ts +94 -0
  82. package/e2e/regression/session-websearch-dock.spec.ts +122 -0
  83. package/e2e/regression/settings-search.spec.ts +516 -0
  84. package/e2e/regression/settings-wsl.spec.ts +433 -0
  85. package/e2e/regression/settings.spec.ts +2901 -0
  86. package/e2e/regression/shell-panel-spacing.spec.ts +95 -0
  87. package/e2e/regression/side-panels.spec.ts +524 -0
  88. package/e2e/regression/subagent-child-navigation.spec.ts +540 -0
  89. package/e2e/regression/tabs.spec.ts +3294 -0
  90. package/e2e/regression/terminal.spec.ts +691 -0
  91. package/e2e/regression/timeline-cache.spec.ts +798 -0
  92. package/e2e/regression/timeline-geometry.spec.ts +1204 -0
  93. package/e2e/regression/timeline-history.spec.ts +1073 -0
  94. package/e2e/regression/timeline-stream.spec.ts +3409 -0
  95. package/e2e/regression/whats-new.spec.ts +242 -0
  96. package/e2e/reproduction/timeline-suspense/index.html +34 -0
  97. package/e2e/reproduction/timeline-suspense/main.tsx +335 -0
  98. package/e2e/reproduction/timeline-suspense/playwright.config.ts +34 -0
  99. package/e2e/reproduction/timeline-suspense/timeline-suspense.repro.ts +182 -0
  100. package/e2e/reproduction/timeline-suspense/vite.config.ts +7 -0
  101. package/e2e/screenshots/session-project-menu.png +0 -0
  102. package/e2e/service-worker/cache.spec.ts +573 -0
  103. package/e2e/service-worker/playwright.config.ts +14 -0
  104. package/e2e/stability/README.md +61 -0
  105. package/e2e/stability/adverse.spec.ts +279 -0
  106. package/e2e/stability/environment-matrix.spec.ts +128 -0
  107. package/e2e/stability/file-matrix.spec.ts +133 -0
  108. package/e2e/stability/file-mutation.spec.ts +126 -0
  109. package/e2e/stability/fixture.test.ts +80 -0
  110. package/e2e/stability/interaction.spec.ts +232 -0
  111. package/e2e/stability/lifecycle.spec.ts +175 -0
  112. package/e2e/stability/oracle-browser.spec.ts +81 -0
  113. package/e2e/stability/oracle.test.ts +388 -0
  114. package/e2e/stability/playwright.config.ts +31 -0
  115. package/e2e/stability/scroll-interaction.spec.ts +520 -0
  116. package/e2e/stability/shell-matrix.spec.ts +299 -0
  117. package/e2e/stability/tool-mutation.spec.ts +58 -0
  118. package/e2e/stability/tools.spec.ts +232 -0
  119. package/e2e/stability/transition-matrix.spec.ts +214 -0
  120. package/e2e/tsconfig.json +11 -0
  121. package/e2e/user-story/model-selection-flow.spec.ts +216 -0
  122. package/e2e/utils/app-direction.fixture.tsx +105 -0
  123. package/e2e/utils/app-direction.html +25 -0
  124. package/e2e/utils/app.ts +227 -0
  125. package/e2e/utils/command-palette.ts +62 -0
  126. package/e2e/utils/console.ts +23 -0
  127. package/e2e/utils/direction.ts +28 -0
  128. package/e2e/utils/drafts.ts +52 -0
  129. package/e2e/utils/errors.ts +14 -0
  130. package/e2e/utils/markdown-sessions.ts +120 -0
  131. package/e2e/utils/mock-api.ts +570 -0
  132. package/e2e/utils/mock-server.ts +1726 -0
  133. package/e2e/utils/notifications.ts +51 -0
  134. package/e2e/utils/persistent-pty.ts +546 -0
  135. package/e2e/utils/prompt-motion.ts +116 -0
  136. package/e2e/utils/serve.ts +65 -0
  137. package/e2e/utils/session-fixture.ts +472 -0
  138. package/e2e/utils/settings-wsl.fixture.tsx +416 -0
  139. package/e2e/utils/settings-wsl.html +27 -0
  140. package/e2e/utils/side-panel.ts +41 -0
  141. package/e2e/utils/sse-transport.ts +352 -0
  142. package/e2e/utils/terminal.ts +31 -0
  143. package/e2e/utils/timeline.ts +1141 -0
  144. package/e2e/utils/visual-stability/analyzer.ts +259 -0
  145. package/e2e/utils/visual-stability/capture.ts +57 -0
  146. package/e2e/utils/visual-stability/index.ts +15 -0
  147. package/e2e/utils/visual-stability/invariant.ts +113 -0
  148. package/e2e/utils/visual-stability/model.ts +47 -0
  149. package/e2e/utils/visual-stability/probe.ts +261 -0
  150. package/e2e/utils/visual-stability/regions.ts +18 -0
  151. package/e2e/utils/visual-stability/reporter.ts +71 -0
  152. package/e2e/utils/visual-stability/scenario.ts +21 -0
  153. package/e2e/utils/visual-stability.ts +52 -0
  154. package/e2e/utils/waits.ts +25 -0
  155. package/e2e/utils/windows-menu.fixture.tsx +99 -0
  156. package/e2e/utils/windows-menu.html +22 -0
  157. package/e2e/utils/workspace.ts +222 -0
  158. package/happydom.ts +77 -0
  159. package/index.html +29 -0
  160. package/manifest.json +36 -0
  161. package/package.json +91 -4
  162. package/perf/README.md +190 -0
  163. package/perf/composer.bench.ts +107 -0
  164. package/perf/desktop.bench.ts +22 -0
  165. package/perf/diff.bench.ts +104 -0
  166. package/perf/docks.bench.ts +109 -0
  167. package/perf/fixtures/composer.ts +166 -0
  168. package/perf/fixtures/diffs.ts +165 -0
  169. package/perf/fixtures/drag.ts +73 -0
  170. package/perf/fixtures/events.ts +106 -0
  171. package/perf/fixtures/home.ts +274 -0
  172. package/perf/fixtures/mock.ts +118 -0
  173. package/perf/fixtures/review.ts +33 -0
  174. package/perf/fixtures/scripts.ts +37 -0
  175. package/perf/fixtures/storage.ts +29 -0
  176. package/perf/fixtures/tabs.ts +21 -0
  177. package/perf/fixtures/timeline.ts +458 -0
  178. package/perf/home.bench.ts +74 -0
  179. package/perf/model-picker.bench.ts +168 -0
  180. package/perf/navigation.bench.ts +310 -0
  181. package/perf/question.bench.ts +85 -0
  182. package/perf/review.bench.ts +109 -0
  183. package/perf/send.bench.ts +54 -0
  184. package/perf/stream.bench.ts +108 -0
  185. package/perf/subagent-pill.bench.ts +348 -0
  186. package/perf/tabs.bench.ts +229 -0
  187. package/perf/timeline.bench.ts +167 -0
  188. package/playwright.components.config.ts +7 -0
  189. package/playwright.config.ts +85 -0
  190. package/public/_headers +28 -0
  191. package/public/assets/Inter.ttf +0 -0
  192. package/public/assets/JetBrainsMonoNerdFontMono-Bold.woff2 +0 -0
  193. package/public/assets/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
  194. package/public/oc-theme-preload.js +33 -0
  195. package/src/app.tsx +142 -0
  196. package/src/components-lab/browser.tsx +745 -0
  197. package/src/components-lab/catalog.test.ts +58 -0
  198. package/src/components-lab/catalog.ts +195 -0
  199. package/src/components-lab/dialog-story-runtime.tsx +840 -0
  200. package/src/components-lab/focus-rings.stories.tsx +710 -0
  201. package/src/components-lab/focus-visibility.stories.tsx +2669 -0
  202. package/src/components-lab/force-focus.ts +52 -0
  203. package/src/components-lab/inspector.css +28 -0
  204. package/src/components-lab/lab.tsx +114 -0
  205. package/src/components-lab/machine.test.ts +177 -0
  206. package/src/components-lab/machine.ts +229 -0
  207. package/src/components-lab/motion.test.ts +17 -0
  208. package/src/components-lab/motion.ts +100 -0
  209. package/src/composer/adapter.ts +151 -0
  210. package/src/composer/attachments/attachments.css +123 -0
  211. package/src/composer/attachments/attachments.ts +363 -0
  212. package/src/composer/attachments/destination.ts +81 -0
  213. package/src/composer/attachments/upload-machine.ts +185 -0
  214. package/src/composer/attachments/uploads.test.ts +127 -0
  215. package/src/composer/attachments/uploads.tsx +228 -0
  216. package/src/composer/client-slash-command.test.ts +20 -0
  217. package/src/composer/client-slash-command.ts +28 -0
  218. package/src/composer/commands.tsx +175 -0
  219. package/src/composer/comment-focus-machine.test.ts +112 -0
  220. package/src/composer/comment-focus-machine.ts +141 -0
  221. package/src/composer/comment-note.test.ts +82 -0
  222. package/src/composer/comment-note.ts +127 -0
  223. package/src/composer/comments.test.ts +109 -0
  224. package/src/composer/comments.tsx +279 -0
  225. package/src/composer/composer-touch.stories.tsx +298 -0
  226. package/src/composer/composer.stories.tsx +765 -0
  227. package/src/composer/composer.tsx +244 -0
  228. package/src/composer/dropzone.tsx +92 -0
  229. package/src/composer/editor/actions.test.ts +176 -0
  230. package/src/composer/editor/actions.ts +191 -0
  231. package/src/composer/editor/dom.test.ts +168 -0
  232. package/src/composer/editor/dom.ts +274 -0
  233. package/src/composer/editor/editor.css +101 -0
  234. package/src/composer/editor/editor.tsx +1764 -0
  235. package/src/composer/editor/interaction.test.ts +13 -0
  236. package/src/composer/editor/interaction.ts +838 -0
  237. package/src/composer/editor/machine.test.ts +47 -0
  238. package/src/composer/editor/machine.ts +63 -0
  239. package/src/composer/editor/mention-search-machine.test.ts +111 -0
  240. package/src/composer/editor/mention-search-machine.ts +226 -0
  241. package/src/composer/editor/quote-comment.stories.tsx +133 -0
  242. package/src/composer/editor/quote-comment.tsx +191 -0
  243. package/src/composer/history/entry.test.ts +100 -0
  244. package/src/composer/history/entry.ts +140 -0
  245. package/src/composer/history/store.ts +83 -0
  246. package/src/composer/machine.test.ts +459 -0
  247. package/src/composer/machine.ts +561 -0
  248. package/src/composer/media.ts +18 -0
  249. package/src/composer/model-chip-machine.test.ts +96 -0
  250. package/src/composer/model-chip-machine.ts +82 -0
  251. package/src/composer/model-label.test.ts +177 -0
  252. package/src/composer/model-label.ts +120 -0
  253. package/src/composer/model.ts +683 -0
  254. package/src/composer/persistence.tsx +163 -0
  255. package/src/composer/prompt-parts.ts +52 -0
  256. package/src/composer/prompt-status-machine.test.ts +76 -0
  257. package/src/composer/prompt-status-machine.ts +48 -0
  258. package/src/composer/prompt.test.ts +320 -0
  259. package/src/composer/prompt.ts +334 -0
  260. package/src/composer/quote-comment-machine.test.ts +154 -0
  261. package/src/composer/quote-comment-machine.ts +211 -0
  262. package/src/composer/quote-position.ts +32 -0
  263. package/src/composer/quote-source.ts +48 -0
  264. package/src/composer/reload-machine.ts +51 -0
  265. package/src/composer/request.test.ts +360 -0
  266. package/src/composer/request.ts +245 -0
  267. package/src/composer/retry.test.ts +107 -0
  268. package/src/composer/retry.ts +63 -0
  269. package/src/composer/schema.test.ts +317 -0
  270. package/src/composer/schema.ts +424 -0
  271. package/src/composer/selection.ts +354 -0
  272. package/src/composer/session-match.test.ts +20 -0
  273. package/src/composer/session-match.ts +18 -0
  274. package/src/composer/state.ts +271 -0
  275. package/src/composer/submission-state.ts +3 -0
  276. package/src/composer/submit.test.ts +1785 -0
  277. package/src/composer/submit.ts +1073 -0
  278. package/src/composer/suggestions/machine.test.ts +420 -0
  279. package/src/composer/suggestions/machine.ts +573 -0
  280. package/src/composer/types.ts +60 -0
  281. package/src/desktop.ts +25 -0
  282. package/src/entry.tsx +119 -0
  283. package/src/env.d.ts +41 -0
  284. package/src/home/home.standalone.stories.tsx +260 -0
  285. package/src/home/machine.test.ts +286 -0
  286. package/src/home/machine.ts +344 -0
  287. package/src/home/model.ts +162 -0
  288. package/src/home/projects/actions.tsx +189 -0
  289. package/src/home/projects/add.ts +10 -0
  290. package/src/home/projects/browse-view.tsx +264 -0
  291. package/src/home/projects/browse.tsx +33 -0
  292. package/src/home/projects/controller.tsx +109 -0
  293. package/src/home/projects/file-manager.ts +26 -0
  294. package/src/home/projects/import-machine.test.ts +117 -0
  295. package/src/home/projects/import-machine.ts +133 -0
  296. package/src/home/projects/landing.tsx +77 -0
  297. package/src/home/projects/menu.tsx +70 -0
  298. package/src/home/projects/region.tsx +63 -0
  299. package/src/home/projects/reveal.ts +39 -0
  300. package/src/home/projects/start.ts +114 -0
  301. package/src/home/projects/view.css +79 -0
  302. package/src/home/projects/view.tsx +763 -0
  303. package/src/home/route.tsx +177 -0
  304. package/src/home/scroll.ts +180 -0
  305. package/src/home/sessions/alt-hold.test.ts +45 -0
  306. package/src/home/sessions/alt-hold.ts +20 -0
  307. package/src/home/sessions/archive.test.ts +51 -0
  308. package/src/home/sessions/archive.ts +25 -0
  309. package/src/home/sessions/controller.tsx +669 -0
  310. package/src/home/sessions/delete-dialog.stories.tsx +70 -0
  311. package/src/home/sessions/index.test.ts +171 -0
  312. package/src/home/sessions/index.ts +60 -0
  313. package/src/home/sessions/load-machine.test.ts +223 -0
  314. package/src/home/sessions/load-machine.ts +430 -0
  315. package/src/home/sessions/open.test.ts +16 -0
  316. package/src/home/sessions/open.ts +18 -0
  317. package/src/home/sessions/queries.ts +95 -0
  318. package/src/home/sessions/records.test.ts +85 -0
  319. package/src/home/sessions/records.ts +58 -0
  320. package/src/home/sessions/region.tsx +66 -0
  321. package/src/home/sessions/row-machine.test.ts +203 -0
  322. package/src/home/sessions/row-machine.ts +365 -0
  323. package/src/home/sessions/search-machine.test.ts +117 -0
  324. package/src/home/sessions/search-machine.ts +181 -0
  325. package/src/home/sessions/search.ts +218 -0
  326. package/src/home/sessions/view.css +101 -0
  327. package/src/home/sessions/view.tsx +1123 -0
  328. package/src/home/start/command-palette.tsx +88 -0
  329. package/src/index.css +419 -0
  330. package/src/index.ts +5 -0
  331. package/src/new-session/brick-breaker-machine.test.ts +120 -0
  332. package/src/new-session/brick-breaker-machine.ts +110 -0
  333. package/src/new-session/brick-breaker.tsx +551 -0
  334. package/src/new-session/commands.tsx +61 -0
  335. package/src/new-session/composer-adapter.ts +309 -0
  336. package/src/new-session/draft.standalone.stories.tsx +214 -0
  337. package/src/new-session/layout.ts +2 -0
  338. package/src/new-session/location/dialog.css +204 -0
  339. package/src/new-session/location/dialog.standalone.stories.tsx +122 -0
  340. package/src/new-session/location/dialog.tsx +677 -0
  341. package/src/new-session/location/machine.test.ts +180 -0
  342. package/src/new-session/location/machine.ts +239 -0
  343. package/src/new-session/machine.test.ts +344 -0
  344. package/src/new-session/machine.ts +293 -0
  345. package/src/new-session/mcp.ts +132 -0
  346. package/src/new-session/pin-board-machine.test.ts +116 -0
  347. package/src/new-session/pin-board-machine.ts +188 -0
  348. package/src/new-session/pin-board.tsx +1072 -0
  349. package/src/new-session/pin-quads.ts +252 -0
  350. package/src/new-session/pin-sound.ts +193 -0
  351. package/src/new-session/project/controller.ts +111 -0
  352. package/src/new-session/project/selector.test.tsx +101 -0
  353. package/src/new-session/project/selector.tsx +108 -0
  354. package/src/new-session/route.tsx +115 -0
  355. package/src/new-session/screen.tsx +107 -0
  356. package/src/new-session/view.tsx +424 -0
  357. package/src/new-session/wordmark-machine.test.ts +236 -0
  358. package/src/new-session/wordmark-machine.ts +237 -0
  359. package/src/new-session/wordmark.css +71 -0
  360. package/src/new-session/wordmark.stories.tsx +109 -0
  361. package/src/new-session/wordmark.tsx +1222 -0
  362. package/src/new-session/workspace/branch-machine.test.ts +243 -0
  363. package/src/new-session/workspace/branch-machine.ts +233 -0
  364. package/src/new-session/workspace/checkout-machine.test.ts +73 -0
  365. package/src/new-session/workspace/checkout-machine.ts +69 -0
  366. package/src/new-session/workspace/controller.test.ts +82 -0
  367. package/src/new-session/workspace/controller.ts +291 -0
  368. package/src/new-session/workspace/selector.tsx +230 -0
  369. package/src/providers/catalog/console-settle.ts +80 -0
  370. package/src/providers/catalog/console.test.ts +21 -0
  371. package/src/providers/catalog/console.ts +37 -0
  372. package/src/providers/catalog/integrations.ts +30 -0
  373. package/src/providers/catalog/order.ts +10 -0
  374. package/src/providers/catalog/plugin.ts +15 -0
  375. package/src/providers/catalog/providers.ts +111 -0
  376. package/src/providers/catalog/settle-machine.test.ts +123 -0
  377. package/src/providers/catalog/settle-machine.ts +109 -0
  378. package/src/providers/connect/chatgpt-usage-limit.stories.tsx +25 -0
  379. package/src/providers/connect/chatgpt-usage-limit.tsx +83 -0
  380. package/src/providers/connect/chatgpt-welcome.stories.tsx +23 -0
  381. package/src/providers/connect/chatgpt-welcome.tsx +37 -0
  382. package/src/providers/connect/console.tsx +67 -0
  383. package/src/providers/connect/controller.ts +672 -0
  384. package/src/providers/connect/dialog-machine.test.ts +654 -0
  385. package/src/providers/connect/dialog-machine.ts +875 -0
  386. package/src/providers/connect/dialog.standalone.stories.tsx +187 -0
  387. package/src/providers/connect/dialog.tsx +1564 -0
  388. package/src/providers/connect/form-machine.test.ts +200 -0
  389. package/src/providers/connect/form-machine.ts +419 -0
  390. package/src/providers/connect/go-upsell-hero-art.test.ts +194 -0
  391. package/src/providers/connect/go-upsell-hero-art.ts +749 -0
  392. package/src/providers/connect/go-upsell-hero-machine.test.ts +88 -0
  393. package/src/providers/connect/go-upsell-hero-machine.ts +68 -0
  394. package/src/providers/connect/go-upsell-hero.tsx +17 -0
  395. package/src/providers/connect/machine.test.ts +513 -0
  396. package/src/providers/connect/machine.ts +644 -0
  397. package/src/providers/connect/mcp-dialog.stories.tsx +89 -0
  398. package/src/providers/connect/mcp-dialog.tsx +316 -0
  399. package/src/providers/connect/mcp-machine.test.ts +239 -0
  400. package/src/providers/connect/mcp-machine.ts +328 -0
  401. package/src/providers/connect/mcp-sign-in.tsx +112 -0
  402. package/src/providers/connect/mcp.tsx +298 -0
  403. package/src/providers/connect/models.css +71 -0
  404. package/src/providers/connect/remote.test.ts +50 -0
  405. package/src/providers/connect/remote.tsx +10 -0
  406. package/src/providers/connect/step-actions.tsx +18 -0
  407. package/src/providers/connect/tip.tsx +110 -0
  408. package/src/providers/connect/usage-exceeded.tsx +62 -0
  409. package/src/providers/custom-managed-provider.svg +31 -0
  410. package/src/providers/models/agent.test.ts +25 -0
  411. package/src/providers/models/agent.ts +7 -0
  412. package/src/providers/models/configured.ts +33 -0
  413. package/src/providers/models/details.tsx +168 -0
  414. package/src/providers/models/manage.css +97 -0
  415. package/src/providers/models/manage.standalone.stories.tsx +59 -0
  416. package/src/providers/models/manage.tsx +170 -0
  417. package/src/providers/models/models.test.ts +55 -0
  418. package/src/providers/models/models.tsx +279 -0
  419. package/src/providers/models/provider-group.tsx +293 -0
  420. package/src/providers/models/search.test.ts +13 -0
  421. package/src/providers/models/search.ts +20 -0
  422. package/src/providers/models/select-dialog-machine.test.ts +455 -0
  423. package/src/providers/models/select-dialog-machine.ts +702 -0
  424. package/src/providers/models/select-dialog.css +240 -0
  425. package/src/providers/models/select-dialog.standalone.stories.tsx +225 -0
  426. package/src/providers/models/select-dialog.tsx +1359 -0
  427. package/src/providers/models/selection-machine.test.ts +290 -0
  428. package/src/providers/models/selection-machine.ts +408 -0
  429. package/src/providers/models/selection.tsx +787 -0
  430. package/src/providers/models/speed.test.ts +17 -0
  431. package/src/providers/models/speed.ts +17 -0
  432. package/src/providers/models/tooltip.tsx +152 -0
  433. package/src/providers/models/unpaid.standalone.stories.tsx +76 -0
  434. package/src/providers/models/unpaid.tsx +199 -0
  435. package/src/providers/models/variant.test.ts +79 -0
  436. package/src/providers/models/variant.ts +74 -0
  437. package/src/providers/opencode-logo.tsx +17 -0
  438. package/src/runtime/animated-presence.ts +66 -0
  439. package/src/runtime/array-move.test.ts +19 -0
  440. package/src/runtime/array-move.ts +8 -0
  441. package/src/runtime/i18n/am.ts +1409 -0
  442. package/src/runtime/i18n/ar.ts +1560 -0
  443. package/src/runtime/i18n/az.ts +1481 -0
  444. package/src/runtime/i18n/bg.ts +1491 -0
  445. package/src/runtime/i18n/bn.ts +1477 -0
  446. package/src/runtime/i18n/br.ts +1527 -0
  447. package/src/runtime/i18n/bs.ts +1561 -0
  448. package/src/runtime/i18n/ca.ts +1523 -0
  449. package/src/runtime/i18n/cs.ts +1520 -0
  450. package/src/runtime/i18n/da.ts +1527 -0
  451. package/src/runtime/i18n/de.ts +1517 -0
  452. package/src/runtime/i18n/desktop-native.test.ts +84 -0
  453. package/src/runtime/i18n/desktop-native.ts +366 -0
  454. package/src/runtime/i18n/dv.ts +1519 -0
  455. package/src/runtime/i18n/dz.ts +1504 -0
  456. package/src/runtime/i18n/el.ts +1509 -0
  457. package/src/runtime/i18n/en.ts +1560 -0
  458. package/src/runtime/i18n/es.ts +1583 -0
  459. package/src/runtime/i18n/et.ts +1456 -0
  460. package/src/runtime/i18n/fa.ts +1470 -0
  461. package/src/runtime/i18n/fi.ts +1472 -0
  462. package/src/runtime/i18n/fo.ts +1469 -0
  463. package/src/runtime/i18n/fr.ts +1543 -0
  464. package/src/runtime/i18n/he.ts +1455 -0
  465. package/src/runtime/i18n/hi.ts +1475 -0
  466. package/src/runtime/i18n/hr.ts +1506 -0
  467. package/src/runtime/i18n/hu.ts +1492 -0
  468. package/src/runtime/i18n/hy.ts +1478 -0
  469. package/src/runtime/i18n/id.ts +1541 -0
  470. package/src/runtime/i18n/is.ts +1468 -0
  471. package/src/runtime/i18n/it.ts +1517 -0
  472. package/src/runtime/i18n/ja.ts +1484 -0
  473. package/src/runtime/i18n/ka.ts +1476 -0
  474. package/src/runtime/i18n/km.ts +1461 -0
  475. package/src/runtime/i18n/ko.ts +1469 -0
  476. package/src/runtime/i18n/language.test.ts +35 -0
  477. package/src/runtime/i18n/language.tsx +468 -0
  478. package/src/runtime/i18n/lo.ts +1454 -0
  479. package/src/runtime/i18n/lt.ts +1529 -0
  480. package/src/runtime/i18n/lv.ts +1509 -0
  481. package/src/runtime/i18n/machine.test.ts +148 -0
  482. package/src/runtime/i18n/machine.ts +164 -0
  483. package/src/runtime/i18n/mk.ts +1488 -0
  484. package/src/runtime/i18n/mn.ts +1485 -0
  485. package/src/runtime/i18n/ms.ts +1480 -0
  486. package/src/runtime/i18n/my.ts +1489 -0
  487. package/src/runtime/i18n/ne.ts +1478 -0
  488. package/src/runtime/i18n/nl.ts +1491 -0
  489. package/src/runtime/i18n/no.ts +1536 -0
  490. package/src/runtime/i18n/pa.ts +1478 -0
  491. package/src/runtime/i18n/pl.ts +1540 -0
  492. package/src/runtime/i18n/ro.ts +1511 -0
  493. package/src/runtime/i18n/ru.ts +1596 -0
  494. package/src/runtime/i18n/si.ts +1477 -0
  495. package/src/runtime/i18n/sk.ts +1526 -0
  496. package/src/runtime/i18n/sl.ts +1527 -0
  497. package/src/runtime/i18n/sq.ts +1480 -0
  498. package/src/runtime/i18n/sr.ts +1502 -0
  499. package/src/runtime/i18n/sv.ts +1478 -0
  500. package/src/runtime/i18n/tg.ts +1493 -0
  501. package/src/runtime/i18n/th.ts +1505 -0
  502. package/src/runtime/i18n/tk.ts +1472 -0
  503. package/src/runtime/i18n/tr.ts +1550 -0
  504. package/src/runtime/i18n/uk.ts +1598 -0
  505. package/src/runtime/i18n/ur.ts +1488 -0
  506. package/src/runtime/i18n/uz.ts +1490 -0
  507. package/src/runtime/i18n/vi.ts +1473 -0
  508. package/src/runtime/i18n/zh.ts +1474 -0
  509. package/src/runtime/i18n/zht.ts +1468 -0
  510. package/src/runtime/persistence/README.md +151 -0
  511. package/src/runtime/persistence/base64.ts +11 -0
  512. package/src/runtime/persistence/consumers.test.ts +168 -0
  513. package/src/runtime/persistence/drafts-machine.test.ts +214 -0
  514. package/src/runtime/persistence/drafts-machine.ts +385 -0
  515. package/src/runtime/persistence/drafts.test.ts +515 -0
  516. package/src/runtime/persistence/drafts.ts +687 -0
  517. package/src/runtime/persistence/equality.ts +9 -0
  518. package/src/runtime/persistence/namespace-machine.test.ts +232 -0
  519. package/src/runtime/persistence/namespace-machine.ts +304 -0
  520. package/src/runtime/persistence/namespace.test.ts +304 -0
  521. package/src/runtime/persistence/namespace.ts +126 -0
  522. package/src/runtime/persistence/persist-machine.test.ts +185 -0
  523. package/src/runtime/persistence/persist-machine.ts +192 -0
  524. package/src/runtime/persistence/persist.test.ts +243 -0
  525. package/src/runtime/persistence/persist.ts +159 -0
  526. package/src/runtime/persistence/schema.test.ts +208 -0
  527. package/src/runtime/persistence/schema.ts +130 -0
  528. package/src/runtime/persistence/storage-machine.test.ts +61 -0
  529. package/src/runtime/persistence/storage-machine.ts +57 -0
  530. package/src/runtime/persistence/storage.test.ts +70 -0
  531. package/src/runtime/persistence/storage.ts +707 -0
  532. package/src/runtime/platform/base-path-router.tsx +66 -0
  533. package/src/runtime/platform/base-path.test.ts +50 -0
  534. package/src/runtime/platform/base-path.ts +28 -0
  535. package/src/runtime/platform/drag-out.test.ts +58 -0
  536. package/src/runtime/platform/drag-out.ts +53 -0
  537. package/src/runtime/platform/external-link.tsx +21 -0
  538. package/src/runtime/platform/keyboard.ts +41 -0
  539. package/src/runtime/platform/platform.tsx +185 -0
  540. package/src/runtime/platform/pwa.ts +50 -0
  541. package/src/runtime/platform/web.ts +63 -0
  542. package/src/runtime/plugin/app-links.test.ts +17 -0
  543. package/src/runtime/plugin/app-links.ts +88 -0
  544. package/src/runtime/plugin/attach-machine.test.ts +174 -0
  545. package/src/runtime/plugin/attach-machine.ts +152 -0
  546. package/src/runtime/plugin/attachment.ts +15 -0
  547. package/src/runtime/plugin/builtins.ts +15 -0
  548. package/src/runtime/plugin/closed-tabs-view.tsx +315 -0
  549. package/src/runtime/plugin/closed-tabs.test.ts +82 -0
  550. package/src/runtime/plugin/closed-tabs.ts +196 -0
  551. package/src/runtime/plugin/commands.test.ts +23 -0
  552. package/src/runtime/plugin/commands.tsx +86 -0
  553. package/src/runtime/plugin/composer-write-machine.test.ts +151 -0
  554. package/src/runtime/plugin/composer-write-machine.ts +111 -0
  555. package/src/runtime/plugin/deferred-menu-machine.test.ts +127 -0
  556. package/src/runtime/plugin/deferred-menu-machine.ts +163 -0
  557. package/src/runtime/plugin/dialog-machine.test.ts +62 -0
  558. package/src/runtime/plugin/dialog-machine.ts +81 -0
  559. package/src/runtime/plugin/dialogs.stories.tsx +66 -0
  560. package/src/runtime/plugin/dialogs.tsx +177 -0
  561. package/src/runtime/plugin/embed-flight-machine.test.ts +350 -0
  562. package/src/runtime/plugin/embed-flight-machine.ts +468 -0
  563. package/src/runtime/plugin/embed-geometry.test.ts +18 -0
  564. package/src/runtime/plugin/embed-geometry.ts +19 -0
  565. package/src/runtime/plugin/embed-snapshot-machine.test.ts +242 -0
  566. package/src/runtime/plugin/embed-snapshot-machine.ts +267 -0
  567. package/src/runtime/plugin/embeds.tsx +773 -0
  568. package/src/runtime/plugin/extension-plugins.tsx +299 -0
  569. package/src/runtime/plugin/hmr.tsx +33 -0
  570. package/src/runtime/plugin/host-apis.tsx +1315 -0
  571. package/src/runtime/plugin/host-layout-machine.test.ts +214 -0
  572. package/src/runtime/plugin/host-layout-machine.ts +269 -0
  573. package/src/runtime/plugin/host.tsx +1106 -0
  574. package/src/runtime/plugin/instance-machine.test.ts +387 -0
  575. package/src/runtime/plugin/instance-machine.ts +409 -0
  576. package/src/runtime/plugin/ipc-machine.test.ts +172 -0
  577. package/src/runtime/plugin/ipc-machine.ts +213 -0
  578. package/src/runtime/plugin/ipc.test.ts +166 -0
  579. package/src/runtime/plugin/ipc.ts +220 -0
  580. package/src/runtime/plugin/link-check-machine.test.ts +115 -0
  581. package/src/runtime/plugin/link-check-machine.ts +142 -0
  582. package/src/runtime/plugin/link-check.ts +82 -0
  583. package/src/runtime/plugin/located-machine.test.ts +124 -0
  584. package/src/runtime/plugin/located-machine.ts +125 -0
  585. package/src/runtime/plugin/located.ts +82 -0
  586. package/src/runtime/plugin/machine.test.ts +222 -0
  587. package/src/runtime/plugin/machine.ts +318 -0
  588. package/src/runtime/plugin/menubar-items.ts +28 -0
  589. package/src/runtime/plugin/mobile.tsx +199 -0
  590. package/src/runtime/plugin/module.test.ts +57 -0
  591. package/src/runtime/plugin/module.ts +64 -0
  592. package/src/runtime/plugin/mounted-session.ts +420 -0
  593. package/src/runtime/plugin/new-tab-machine.test.ts +207 -0
  594. package/src/runtime/plugin/new-tab-machine.ts +240 -0
  595. package/src/runtime/plugin/pane-drag-machine.test.ts +217 -0
  596. package/src/runtime/plugin/pane-drag-machine.ts +263 -0
  597. package/src/runtime/plugin/pane-drag.tsx +290 -0
  598. package/src/runtime/plugin/panel-keys.ts +15 -0
  599. package/src/runtime/plugin/panel-menu.ts +29 -0
  600. package/src/runtime/plugin/panel-trigger.tsx +180 -0
  601. package/src/runtime/plugin/panels.tsx +733 -0
  602. package/src/runtime/plugin/plugin-gui-machine.test.ts +186 -0
  603. package/src/runtime/plugin/plugin-gui-machine.ts +178 -0
  604. package/src/runtime/plugin/plugins.tsx +137 -0
  605. package/src/runtime/plugin/prompt-gate.test.ts +113 -0
  606. package/src/runtime/plugin/prompt-gate.ts +36 -0
  607. package/src/runtime/plugin/render.tsx +348 -0
  608. package/src/runtime/plugin/root.tsx +141 -0
  609. package/src/runtime/plugin/server-shell.tsx +113 -0
  610. package/src/runtime/plugin/servers.tsx +270 -0
  611. package/src/runtime/plugin/session-store-machine.test.ts +82 -0
  612. package/src/runtime/plugin/session-store-machine.ts +140 -0
  613. package/src/runtime/plugin/settings-page-view.tsx +53 -0
  614. package/src/runtime/plugin/settings-pages.ts +23 -0
  615. package/src/runtime/plugin/side-region.tsx +635 -0
  616. package/src/runtime/plugin/startup.ts +107 -0
  617. package/src/runtime/plugin/store-machine.test.ts +69 -0
  618. package/src/runtime/plugin/store-machine.ts +139 -0
  619. package/src/runtime/plugin/stores.ts +339 -0
  620. package/src/runtime/plugin/tab-strip-scroll.test.ts +40 -0
  621. package/src/runtime/plugin/tab-strip-scroll.ts +130 -0
  622. package/src/runtime/plugin/titlebar-items.css +20 -0
  623. package/src/runtime/plugin/titlebar-items.stories.tsx +97 -0
  624. package/src/runtime/plugin/titlebar-items.tsx +96 -0
  625. package/src/runtime/plugin/ui.tsx +292 -0
  626. package/src/runtime/plugin/web-href.test.ts +11 -0
  627. package/src/runtime/plugin/web-href.ts +10 -0
  628. package/src/runtime/polyfills.test.ts +61 -0
  629. package/src/runtime/polyfills.ts +39 -0
  630. package/src/runtime/presence-machine.test.ts +260 -0
  631. package/src/runtime/presence-machine.ts +329 -0
  632. package/src/runtime/presence.ts +165 -0
  633. package/src/runtime/server/api.test.ts +64 -0
  634. package/src/runtime/server/api.ts +58 -0
  635. package/src/runtime/server/client.test.ts +131 -0
  636. package/src/runtime/server/client.tsx +308 -0
  637. package/src/runtime/server/current.tsx +55 -0
  638. package/src/runtime/server/data.test.ts +440 -0
  639. package/src/runtime/server/data.ts +286 -0
  640. package/src/runtime/server/errors.test.ts +151 -0
  641. package/src/runtime/server/errors.ts +135 -0
  642. package/src/runtime/server/global-sync/bootstrap.test.ts +179 -0
  643. package/src/runtime/server/global-sync/bootstrap.ts +96 -0
  644. package/src/runtime/server/global-sync/child-store.test.ts +47 -0
  645. package/src/runtime/server/global-sync/child-store.ts +206 -0
  646. package/src/runtime/server/global-sync/machine.test.ts +96 -0
  647. package/src/runtime/server/global-sync/machine.ts +84 -0
  648. package/src/runtime/server/global-sync/types.ts +46 -0
  649. package/src/runtime/server/global-sync/utils.test.ts +154 -0
  650. package/src/runtime/server/global-sync/utils.ts +165 -0
  651. package/src/runtime/server/health-machine.test.ts +227 -0
  652. package/src/runtime/server/health-machine.ts +357 -0
  653. package/src/runtime/server/health.test.ts +169 -0
  654. package/src/runtime/server/health.ts +236 -0
  655. package/src/runtime/server/image.test.ts +214 -0
  656. package/src/runtime/server/image.ts +40 -0
  657. package/src/runtime/server/loopback.test.ts +17 -0
  658. package/src/runtime/server/loopback.ts +22 -0
  659. package/src/runtime/server/machine.test.ts +162 -0
  660. package/src/runtime/server/machine.ts +275 -0
  661. package/src/runtime/server/media.ts +88 -0
  662. package/src/runtime/server/persistence.test.ts +117 -0
  663. package/src/runtime/server/persistence.ts +105 -0
  664. package/src/runtime/server/plugin-machine.test.ts +128 -0
  665. package/src/runtime/server/plugin-machine.ts +170 -0
  666. package/src/runtime/server/refcount.test.ts +30 -0
  667. package/src/runtime/server/refcount.ts +37 -0
  668. package/src/runtime/server/registry.test.ts +152 -0
  669. package/src/runtime/server/registry.tsx +363 -0
  670. package/src/runtime/server/request-queue-machine.test.ts +151 -0
  671. package/src/runtime/server/request-queue-machine.ts +307 -0
  672. package/src/runtime/server/request-queue.test.ts +315 -0
  673. package/src/runtime/server/request-queue.ts +173 -0
  674. package/src/runtime/server/runtime.tsx +396 -0
  675. package/src/runtime/server/scope.test.ts +52 -0
  676. package/src/runtime/server/scope.ts +69 -0
  677. package/src/runtime/server/scoped-cache.test.ts +72 -0
  678. package/src/runtime/server/scoped-cache.ts +119 -0
  679. package/src/runtime/server/server-sync/connection.ts +34 -0
  680. package/src/runtime/server/server-sync/endpoint-machine.test.ts +87 -0
  681. package/src/runtime/server/server-sync/endpoint-machine.ts +62 -0
  682. package/src/runtime/server/server-sync/machine.test.ts +86 -0
  683. package/src/runtime/server/server-sync/machine.ts +70 -0
  684. package/src/runtime/server/session-index.ts +23 -0
  685. package/src/runtime/server/sync.tsx +206 -0
  686. package/src/runtime/server/types.ts +151 -0
  687. package/src/servers/connect/browser.ts +15 -0
  688. package/src/servers/connect/connect.fixture.tsx +222 -0
  689. package/src/servers/connect/controller.ts +237 -0
  690. package/src/servers/connect/dialog.stories.tsx +67 -0
  691. package/src/servers/connect/dialog.tsx +255 -0
  692. package/src/servers/connect/machine.test.ts +487 -0
  693. package/src/servers/connect/machine.ts +427 -0
  694. package/src/servers/connect/method.tsx +31 -0
  695. package/src/servers/connect/pairing.test.ts +67 -0
  696. package/src/servers/connect/pairing.ts +134 -0
  697. package/src/servers/connect/redeem.ts +50 -0
  698. package/src/servers/connect/scanner-machine.test.ts +114 -0
  699. package/src/servers/connect/scanner-machine.ts +164 -0
  700. package/src/servers/connect/scanner.css +47 -0
  701. package/src/servers/connect/scanner.tsx +173 -0
  702. package/src/servers/connect/screen.css +108 -0
  703. package/src/servers/connect/screen.stories.tsx +63 -0
  704. package/src/servers/connect/screen.tsx +164 -0
  705. package/src/servers/registry/add-menu.tsx +62 -0
  706. package/src/servers/registry/controller.test.ts +26 -0
  707. package/src/servers/registry/controller.ts +86 -0
  708. package/src/servers/registry/label.tsx +23 -0
  709. package/src/servers/registry/management.test.ts +40 -0
  710. package/src/servers/registry/management.ts +17 -0
  711. package/src/servers/registry/plugin-row.tsx +57 -0
  712. package/src/servers/registry/row-items.tsx +18 -0
  713. package/src/servers/registry/row-menu.tsx +152 -0
  714. package/src/servers/registry/row.stories.tsx +51 -0
  715. package/src/servers/registry/row.tsx +47 -0
  716. package/src/session/commands/dialog-jump-to-message.tsx +197 -0
  717. package/src/session/commands/export-machine.test.ts +99 -0
  718. package/src/session/commands/export-machine.ts +117 -0
  719. package/src/session/commands/export-session.tsx +108 -0
  720. package/src/session/commands/export.test.ts +105 -0
  721. package/src/session/commands/export.ts +89 -0
  722. package/src/session/commands/fork-dialog.stories.tsx +68 -0
  723. package/src/session/commands/fork-dialog.tsx +198 -0
  724. package/src/session/commands/jump-to-message-machine.test.ts +123 -0
  725. package/src/session/commands/jump-to-message-machine.ts +161 -0
  726. package/src/session/commands/jump-to-message.stories.tsx +226 -0
  727. package/src/session/commands/jump-to-message.tsx +161 -0
  728. package/src/session/commands/machine.test.ts +305 -0
  729. package/src/session/commands/machine.ts +272 -0
  730. package/src/session/commands/rename-session.ts +31 -0
  731. package/src/session/commands/use-session-commands.tsx +813 -0
  732. package/src/session/composer/activity-chips.css +242 -0
  733. package/src/session/composer/activity-chips.stories.tsx +280 -0
  734. package/src/session/composer/activity-chips.tsx +485 -0
  735. package/src/session/composer/adapter.ts +74 -0
  736. package/src/session/composer/composer-docks.stories.tsx +278 -0
  737. package/src/session/composer/composer-lane.css +93 -0
  738. package/src/session/composer/composer-lane.tsx +45 -0
  739. package/src/session/composer/controller.ts +86 -0
  740. package/src/session/composer/focus-machine.test.ts +285 -0
  741. package/src/session/composer/focus-machine.ts +212 -0
  742. package/src/session/composer/focus.tsx +161 -0
  743. package/src/session/composer/free-limit-panel.standalone.stories.tsx +45 -0
  744. package/src/session/composer/free-limit-panel.tsx +133 -0
  745. package/src/session/composer/go-limit-tray.tsx +137 -0
  746. package/src/session/composer/location-missing-machine.test.ts +97 -0
  747. package/src/session/composer/location-missing-machine.ts +144 -0
  748. package/src/session/composer/location-missing.css +73 -0
  749. package/src/session/composer/location-missing.standalone.stories.tsx +161 -0
  750. package/src/session/composer/location-missing.tsx +193 -0
  751. package/src/session/composer/plugin-pills.tsx +215 -0
  752. package/src/session/composer/queue-machine.test.ts +565 -0
  753. package/src/session/composer/queue-machine.ts +934 -0
  754. package/src/session/composer/queue-panel-machine.test.ts +121 -0
  755. package/src/session/composer/queue-panel-machine.ts +229 -0
  756. package/src/session/composer/queue-panel.css +10 -0
  757. package/src/session/composer/queue-panel.stories.tsx +86 -0
  758. package/src/session/composer/queue-panel.tsx +314 -0
  759. package/src/session/composer/queue.test.ts +314 -0
  760. package/src/session/composer/queue.ts +610 -0
  761. package/src/session/composer/recovery-story.tsx +38 -0
  762. package/src/session/composer/region.tsx +689 -0
  763. package/src/session/composer/selection.test.ts +28 -0
  764. package/src/session/composer/selection.ts +28 -0
  765. package/src/session/composer/session-composer-region-controller.ts +28 -0
  766. package/src/session/composer/session-composer-region.tsx +115 -0
  767. package/src/session/composer/shell-panel-machine.test.ts +261 -0
  768. package/src/session/composer/shell-panel-machine.ts +338 -0
  769. package/src/session/composer/shell-panel.ts +181 -0
  770. package/src/session/composer/spring-height-machine.test.ts +380 -0
  771. package/src/session/composer/spring-height-machine.ts +489 -0
  772. package/src/session/composer/spring-height.tsx +586 -0
  773. package/src/session/composer/subagent-bar.tsx +116 -0
  774. package/src/session/composer/timeline-actions.ts +49 -0
  775. package/src/session/composer/todo-pill.css +32 -0
  776. package/src/session/composer/todo-pill.stories.tsx +158 -0
  777. package/src/session/composer/todo-pill.tsx +157 -0
  778. package/src/session/composer/todos.ts +43 -0
  779. package/src/session/delete-machine.test.ts +83 -0
  780. package/src/session/delete-machine.ts +128 -0
  781. package/src/session/fork-machine.test.ts +152 -0
  782. package/src/session/fork-machine.ts +169 -0
  783. package/src/session/fork.ts +164 -0
  784. package/src/session/handoff-machine.test.ts +262 -0
  785. package/src/session/handoff-machine.ts +256 -0
  786. package/src/session/handoff.ts +112 -0
  787. package/src/session/header/drag-area.tsx +86 -0
  788. package/src/session/header/fit-machine.test.ts +143 -0
  789. package/src/session/header/fit-machine.ts +95 -0
  790. package/src/session/header/fit.ts +134 -0
  791. package/src/session/header/separator.tsx +22 -0
  792. package/src/session/header/session-header-actions.stories.tsx +45 -0
  793. package/src/session/header/session-header-actions.tsx +89 -0
  794. package/src/session/header/session-header.tsx +12 -0
  795. package/src/session/header/session-working-indicator.tsx +44 -0
  796. package/src/session/helpers.ts +42 -0
  797. package/src/session/list.test.ts +64 -0
  798. package/src/session/list.ts +18 -0
  799. package/src/session/message-id-from-hash.test.ts +10 -0
  800. package/src/session/message-id-from-hash.ts +8 -0
  801. package/src/session/model.ts +150 -0
  802. package/src/session/preparing-composer.tsx +72 -0
  803. package/src/session/question-switch.stories.tsx +380 -0
  804. package/src/session/requests/auto-approve-machine.test.ts +345 -0
  805. package/src/session/requests/auto-approve-machine.ts +247 -0
  806. package/src/session/requests/auto-approve.ts +274 -0
  807. package/src/session/requests/background.ts +312 -0
  808. package/src/session/requests/elicitation-controller.ts +129 -0
  809. package/src/session/requests/elicitation-machine.test.ts +209 -0
  810. package/src/session/requests/elicitation-machine.ts +277 -0
  811. package/src/session/requests/job-list.test.ts +18 -0
  812. package/src/session/requests/model.ts +348 -0
  813. package/src/session/requests/permission-machine.test.ts +130 -0
  814. package/src/session/requests/permission-machine.ts +105 -0
  815. package/src/session/requests/question-controller.ts +130 -0
  816. package/src/session/requests/question-keys.test.ts +106 -0
  817. package/src/session/requests/question-keys.ts +81 -0
  818. package/src/session/requests/question-machine.test.ts +257 -0
  819. package/src/session/requests/question-machine.ts +293 -0
  820. package/src/session/requests/question-motion.ts +26 -0
  821. package/src/session/requests/question-state.ts +21 -0
  822. package/src/session/requests/question-switch-machine.test.ts +114 -0
  823. package/src/session/requests/question-switch-machine.ts +130 -0
  824. package/src/session/requests/session-elicitation-dock.css +49 -0
  825. package/src/session/requests/session-elicitation-dock.tsx +223 -0
  826. package/src/session/requests/session-permission-dock.tsx +108 -0
  827. package/src/session/requests/session-question-dock-classic.tsx +726 -0
  828. package/src/session/requests/session-question-dock-experimental.tsx +1510 -0
  829. package/src/session/requests/session-question-dock.tsx +15 -0
  830. package/src/session/requests/session-request-tree.test.ts +119 -0
  831. package/src/session/requests/session-request-tree.ts +87 -0
  832. package/src/session/requests/session-websearch-dock.css +61 -0
  833. package/src/session/requests/session-websearch-dock.tsx +112 -0
  834. package/src/session/requests/steer-background.test.ts +66 -0
  835. package/src/session/requests/steer-background.ts +28 -0
  836. package/src/session/requests/websearch-machine.test.ts +425 -0
  837. package/src/session/requests/websearch-machine.ts +627 -0
  838. package/src/session/requests/websearch.ts +152 -0
  839. package/src/session/resolution-machine.test.ts +414 -0
  840. package/src/session/resolution-machine.ts +330 -0
  841. package/src/session/revert-machine.test.ts +365 -0
  842. package/src/session/revert-machine.ts +345 -0
  843. package/src/session/revert.ts +340 -0
  844. package/src/session/route-error.tsx +73 -0
  845. package/src/session/route.tsx +299 -0
  846. package/src/session/screen-layout.ts +147 -0
  847. package/src/session/screen.tsx +625 -0
  848. package/src/session/search.ts +3 -0
  849. package/src/session/server-unavailable-panel.standalone.stories.tsx +88 -0
  850. package/src/session/server-unavailable-panel.tsx +86 -0
  851. package/src/session/session-domain.test.ts +57 -0
  852. package/src/session/session-domain.ts +33 -0
  853. package/src/session/session-frame.tsx +28 -0
  854. package/src/session/session-identity-header.css +142 -0
  855. package/src/session/session-identity-header.tsx +674 -0
  856. package/src/session/session-layout.ts +73 -0
  857. package/src/session/session-model-helpers.test.ts +29 -0
  858. package/src/session/session-model-helpers.ts +33 -0
  859. package/src/session/session-panel-width.test.ts +25 -0
  860. package/src/session/session-panel-width.ts +58 -0
  861. package/src/session/session-read-menu-item.tsx +54 -0
  862. package/src/session/session-reference-menu.tsx +106 -0
  863. package/src/session/session-resolution.ts +141 -0
  864. package/src/session/session-screen.stories.tsx +363 -0
  865. package/src/session/sizing-machine.test.ts +89 -0
  866. package/src/session/sizing-machine.ts +74 -0
  867. package/src/session/story-model.tsx +420 -0
  868. package/src/session/timeline/background-work.stories.tsx +27 -0
  869. package/src/session/timeline/cache-machine.test.ts +50 -0
  870. package/src/session/timeline/cache-machine.ts +37 -0
  871. package/src/session/timeline/cache.ts +200 -0
  872. package/src/session/timeline/cold-mount.test.ts +162 -0
  873. package/src/session/timeline/cold-mount.ts +179 -0
  874. package/src/session/timeline/controller-projection.test.ts +305 -0
  875. package/src/session/timeline/controller-projection.ts +131 -0
  876. package/src/session/timeline/controller.tsx +467 -0
  877. package/src/session/timeline/cursor-machine.test.ts +398 -0
  878. package/src/session/timeline/cursor-machine.ts +433 -0
  879. package/src/session/timeline/cursor.ts +207 -0
  880. package/src/session/timeline/follow.ts +40 -0
  881. package/src/session/timeline/header-actions-machine.test.ts +126 -0
  882. package/src/session/timeline/header-actions-machine.ts +204 -0
  883. package/src/session/timeline/history-machine.test.ts +304 -0
  884. package/src/session/timeline/history-machine.ts +296 -0
  885. package/src/session/timeline/inline-quotes.ts +4 -0
  886. package/src/session/timeline/interaction.ts +474 -0
  887. package/src/session/timeline/machine.test.ts +290 -0
  888. package/src/session/timeline/machine.ts +271 -0
  889. package/src/session/timeline/message-timeline.tsx +779 -0
  890. package/src/session/timeline/model.test.ts +393 -0
  891. package/src/session/timeline/model.ts +201 -0
  892. package/src/session/timeline/observe-element-offset.test.ts +323 -0
  893. package/src/session/timeline/observe-element-offset.ts +106 -0
  894. package/src/session/timeline/projection.ts +7 -0
  895. package/src/session/timeline/quote-background.ts +141 -0
  896. package/src/session/timeline/quote-highlight.ts +203 -0
  897. package/src/session/timeline/quote-machine.test.ts +277 -0
  898. package/src/session/timeline/quote-machine.ts +360 -0
  899. package/src/session/timeline/quote-text.ts +332 -0
  900. package/src/session/timeline/quote.stories.tsx +88 -0
  901. package/src/session/timeline/quote.tsx +547 -0
  902. package/src/session/timeline/reconnect-machine.test.ts +115 -0
  903. package/src/session/timeline/reconnect-machine.ts +130 -0
  904. package/src/session/timeline/search-bar.css +19 -0
  905. package/src/session/timeline/search-bar.stories.tsx +122 -0
  906. package/src/session/timeline/search-bar.tsx +94 -0
  907. package/src/session/timeline/search-controller.ts +364 -0
  908. package/src/session/timeline/search-machine.test.ts +320 -0
  909. package/src/session/timeline/search-machine.ts +342 -0
  910. package/src/session/timeline/selected-effect.ts +19 -0
  911. package/src/session/timeline/sources.stories.tsx +352 -0
  912. package/src/session/timeline/sync-machine.ts +265 -0
  913. package/src/session/timeline/turn-diff-machine.ts +115 -0
  914. package/src/session/timeline/turn-diffs.test.ts +178 -0
  915. package/src/session/timeline/turn-diffs.ts +67 -0
  916. package/src/session/timeline/virtual-items.ts +3 -0
  917. package/src/session/timeline/virtualizer.tsx +1321 -0
  918. package/src/session/timeline/voice-delegation.test.ts +69 -0
  919. package/src/session/timeline/voice-delegation.ts +38 -0
  920. package/src/session/title.ts +15 -0
  921. package/src/session/usage-exceeded-dialogs.test.ts +41 -0
  922. package/src/session/usage-exceeded-dialogs.tsx +158 -0
  923. package/src/session/viewed-machine.test.ts +27 -0
  924. package/src/session/viewed-machine.ts +24 -0
  925. package/src/settings/about/about.tsx +199 -0
  926. package/src/settings/about/animated-wordmark.tsx +85 -0
  927. package/src/settings/about/anomaly-brush.svg +1 -0
  928. package/src/settings/about/contributors.test.ts +17 -0
  929. package/src/settings/about/contributors.ts +27 -0
  930. package/src/settings/about/legal.svg +9 -0
  931. package/src/settings/about/machine.test.ts +90 -0
  932. package/src/settings/about/machine.ts +119 -0
  933. package/src/settings/about/notices/apache-2.0.txt +201 -0
  934. package/src/settings/about/notices/betteroffice-notice.txt +2 -0
  935. package/src/settings/about/notices/crates.ts +770 -0
  936. package/src/settings/about/notices/dialog.tsx +113 -0
  937. package/src/settings/about/notices/fonts/OFL-1.1.txt +91 -0
  938. package/src/settings/about/notices/fonts.ts +107 -0
  939. package/src/settings/about/notices/notices.ts +37 -0
  940. package/src/settings/appearance/appearance.tsx +176 -0
  941. package/src/settings/command.tsx +29 -0
  942. package/src/settings/experimental/experimental.tsx +93 -0
  943. package/src/settings/extension-load-machine.test.ts +117 -0
  944. package/src/settings/extension-load-machine.ts +158 -0
  945. package/src/settings/extension-load.tsx +85 -0
  946. package/src/settings/general/behavior.ts +102 -0
  947. package/src/settings/general/controllers.test.ts +56 -0
  948. package/src/settings/general/controllers.ts +271 -0
  949. package/src/settings/general/general.tsx +404 -0
  950. package/src/settings/general/interface-mode.css +261 -0
  951. package/src/settings/general/interface-mode.tsx +190 -0
  952. package/src/settings/general/machine.test.ts +188 -0
  953. package/src/settings/general/machine.ts +224 -0
  954. package/src/settings/general/sound-preview-machine.test.ts +114 -0
  955. package/src/settings/general/sound-preview-machine.ts +109 -0
  956. package/src/settings/keybinds/keybinds.tsx +624 -0
  957. package/src/settings/keybinds/machine.test.ts +142 -0
  958. package/src/settings/keybinds/machine.ts +149 -0
  959. package/src/settings/keybinds/migration.ts +42 -0
  960. package/src/settings/list.tsx +10 -0
  961. package/src/settings/model.test.ts +249 -0
  962. package/src/settings/model.tsx +685 -0
  963. package/src/settings/models/machine.test.ts +123 -0
  964. package/src/settings/models/machine.ts +161 -0
  965. package/src/settings/models/models.tsx +285 -0
  966. package/src/settings/navigation.tsx +223 -0
  967. package/src/settings/notifications/notifications.tsx +160 -0
  968. package/src/settings/pages.ts +33 -0
  969. package/src/settings/palette.ts +44 -0
  970. package/src/settings/providers/account-actions.ts +112 -0
  971. package/src/settings/providers/account-name.tsx +46 -0
  972. package/src/settings/providers/accounts.test.ts +29 -0
  973. package/src/settings/providers/accounts.ts +11 -0
  974. package/src/settings/providers/console-extensions.test.ts +103 -0
  975. package/src/settings/providers/console-extensions.ts +110 -0
  976. package/src/settings/providers/console-link.tsx +121 -0
  977. package/src/settings/providers/extensions.tsx +425 -0
  978. package/src/settings/providers/machine.test.ts +270 -0
  979. package/src/settings/providers/machine.ts +357 -0
  980. package/src/settings/providers/plugin-update-machine.test.ts +155 -0
  981. package/src/settings/providers/plugin-update-machine.ts +151 -0
  982. package/src/settings/providers/providers.tsx +702 -0
  983. package/src/settings/rename-machine.test.ts +123 -0
  984. package/src/settings/rename-machine.ts +167 -0
  985. package/src/settings/rename.ts +120 -0
  986. package/src/settings/route.test.ts +117 -0
  987. package/src/settings/route.ts +160 -0
  988. package/src/settings/row.tsx +21 -0
  989. package/src/settings/scroller.ts +6 -0
  990. package/src/settings/search-catalog.ts +319 -0
  991. package/src/settings/search-empty.tsx +87 -0
  992. package/src/settings/search-field.tsx +101 -0
  993. package/src/settings/search-index.ts +193 -0
  994. package/src/settings/search-machine.test.ts +249 -0
  995. package/src/settings/search-machine.ts +308 -0
  996. package/src/settings/search-results.test.ts +151 -0
  997. package/src/settings/search-results.ts +75 -0
  998. package/src/settings/search-reveal.ts +76 -0
  999. package/src/settings/search.css +168 -0
  1000. package/src/settings/search.tsx +283 -0
  1001. package/src/settings/server-scope.tsx +12 -0
  1002. package/src/settings/servers/inventory.test.ts +50 -0
  1003. package/src/settings/servers/inventory.ts +100 -0
  1004. package/src/settings/servers/machine.test.ts +148 -0
  1005. package/src/settings/servers/machine.ts +176 -0
  1006. package/src/settings/servers/servers.tsx +178 -0
  1007. package/src/settings/servers/switcher.tsx +77 -0
  1008. package/src/settings/servers/unavailable.tsx +99 -0
  1009. package/src/settings/settings.css +2478 -0
  1010. package/src/settings/shell.standalone.stories.tsx +60 -0
  1011. package/src/settings/shell.tsx +434 -0
  1012. package/src/settings/surface.tsx +297 -0
  1013. package/src/settings/tab-header.ts +12 -0
  1014. package/src/settings/timeline-detail.css +334 -0
  1015. package/src/settings/timeline-detail.stories.tsx +54 -0
  1016. package/src/settings/timeline-detail.tsx +221 -0
  1017. package/src/settings/workspaces/delete-machine.test.ts +298 -0
  1018. package/src/settings/workspaces/delete-machine.ts +392 -0
  1019. package/src/settings/workspaces/project-extensions.tsx +537 -0
  1020. package/src/settings/workspaces/project-folder-missing.tsx +29 -0
  1021. package/src/settings/workspaces/project-lsp.test.ts +65 -0
  1022. package/src/settings/workspaces/project-lsp.ts +31 -0
  1023. package/src/settings/workspaces/project-machine.test.ts +285 -0
  1024. package/src/settings/workspaces/project-machine.ts +374 -0
  1025. package/src/settings/workspaces/project-model.ts +201 -0
  1026. package/src/settings/workspaces/project-options.tsx +81 -0
  1027. package/src/settings/workspaces/project-row.tsx +121 -0
  1028. package/src/settings/workspaces/project.css +397 -0
  1029. package/src/settings/workspaces/project.tsx +266 -0
  1030. package/src/settings/workspaces/projects.tsx +199 -0
  1031. package/src/settings/workspaces/queries.ts +66 -0
  1032. package/src/settings/workspaces/workspaces.tsx +705 -0
  1033. package/src/shell/commands/command-search.tsx +41 -0
  1034. package/src/shell/commands/command.test.ts +118 -0
  1035. package/src/shell/commands/command.tsx +584 -0
  1036. package/src/shell/commands/desktop-menu.test.ts +48 -0
  1037. package/src/shell/commands/desktop-menu.ts +322 -0
  1038. package/src/shell/commands/desktop.tsx +27 -0
  1039. package/src/shell/commands/dialog.css +263 -0
  1040. package/src/shell/commands/dialog.standalone.stories.tsx +247 -0
  1041. package/src/shell/commands/dialog.tsx +318 -0
  1042. package/src/shell/commands/highlight-machine.test.ts +64 -0
  1043. package/src/shell/commands/highlight-machine.ts +54 -0
  1044. package/src/shell/commands/key-sequence.tsx +38 -0
  1045. package/src/shell/commands/keymap.test.ts +219 -0
  1046. package/src/shell/commands/keymap.ts +275 -0
  1047. package/src/shell/commands/palette.ts +466 -0
  1048. package/src/shell/commands/safe-triangle.ts +64 -0
  1049. package/src/shell/commands/search-machine.test.ts +218 -0
  1050. package/src/shell/commands/search-machine.ts +274 -0
  1051. package/src/shell/commands/search.ts +136 -0
  1052. package/src/shell/commands/session-search.tsx +111 -0
  1053. package/src/shell/commands/suspend-machine.test.ts +59 -0
  1054. package/src/shell/commands/suspend-machine.ts +46 -0
  1055. package/src/shell/deep-links/deep-links.ts +65 -0
  1056. package/src/shell/deep-links/machine.test.ts +67 -0
  1057. package/src/shell/deep-links/machine.ts +67 -0
  1058. package/src/shell/errors/description.test.ts +32 -0
  1059. package/src/shell/errors/description.ts +32 -0
  1060. package/src/shell/errors/error.tsx +515 -0
  1061. package/src/shell/errors/machine.test.ts +178 -0
  1062. package/src/shell/errors/machine.ts +217 -0
  1063. package/src/shell/layout/helpers.test.ts +76 -0
  1064. package/src/shell/layout/helpers.ts +78 -0
  1065. package/src/shell/layout/project-avatar-state.ts +157 -0
  1066. package/src/shell/layout/project-icon.tsx +31 -0
  1067. package/src/shell/layout/project-icons.tsx +34 -0
  1068. package/src/shell/layout/session-tab-avatar.tsx +28 -0
  1069. package/src/shell/mobile-drawer.css +90 -0
  1070. package/src/shell/mobile-drawer.tsx +53 -0
  1071. package/src/shell/mobile-panel-drawer.css +34 -0
  1072. package/src/shell/mobile-panel-drawer.tsx +98 -0
  1073. package/src/shell/notifications/coordinator.ts +160 -0
  1074. package/src/shell/notifications/focus-lock-machine.test.ts +79 -0
  1075. package/src/shell/notifications/focus-lock-machine.ts +76 -0
  1076. package/src/shell/notifications/machine.test.ts +297 -0
  1077. package/src/shell/notifications/machine.ts +313 -0
  1078. package/src/shell/notifications/notification.test.ts +28 -0
  1079. package/src/shell/notifications/notification.tsx +526 -0
  1080. package/src/shell/notifications/sound.ts +113 -0
  1081. package/src/shell/notifications/toast.tsx +53 -0
  1082. package/src/shell/palette-menu.css +105 -0
  1083. package/src/shell/panel-motion-machine.test.ts +167 -0
  1084. package/src/shell/panel-motion-machine.ts +217 -0
  1085. package/src/shell/panel-motion.test.ts +26 -0
  1086. package/src/shell/panel-motion.ts +435 -0
  1087. package/src/shell/project-navigation.ts +21 -0
  1088. package/src/shell/routes/routes.tsx +140 -0
  1089. package/src/shell/routes/session-reference-lookup-machine.test.ts +111 -0
  1090. package/src/shell/routes/session-reference-lookup-machine.ts +86 -0
  1091. package/src/shell/routes/session-ui-navigate-machine.test.ts +124 -0
  1092. package/src/shell/routes/session-ui-navigate-machine.ts +127 -0
  1093. package/src/shell/routes/session-ui-provider.tsx +267 -0
  1094. package/src/shell/routes/session.test.ts +46 -0
  1095. package/src/shell/routes/session.ts +30 -0
  1096. package/src/shell/search-list.css +366 -0
  1097. package/src/shell/shell.tsx +340 -0
  1098. package/src/shell/sidebar-peek-machine.test.ts +240 -0
  1099. package/src/shell/sidebar-peek-machine.ts +331 -0
  1100. package/src/shell/sidebar-peek.css +28 -0
  1101. package/src/shell/sidebar-peek.ts +482 -0
  1102. package/src/shell/sidebar-toggle.tsx +255 -0
  1103. package/src/shell/state/helpers.ts +69 -0
  1104. package/src/shell/state/intent-machine.test.ts +155 -0
  1105. package/src/shell/state/intent-machine.ts +216 -0
  1106. package/src/shell/state/layout.test.ts +169 -0
  1107. package/src/shell/state/layout.tsx +794 -0
  1108. package/src/shell/state/scoped-machine.test.ts +69 -0
  1109. package/src/shell/state/scoped-machine.ts +77 -0
  1110. package/src/shell/state/scroll-machine.test.ts +109 -0
  1111. package/src/shell/state/scroll-machine.ts +94 -0
  1112. package/src/shell/state/scroll.test.ts +83 -0
  1113. package/src/shell/state/scroll.ts +124 -0
  1114. package/src/shell/state/session-preferences.ts +62 -0
  1115. package/src/shell/state/session-tabs.test.ts +188 -0
  1116. package/src/shell/state/session-tabs.ts +257 -0
  1117. package/src/shell/tabs/closed.ts +83 -0
  1118. package/src/shell/tabs/hydration-machine.test.ts +98 -0
  1119. package/src/shell/tabs/hydration-machine.ts +115 -0
  1120. package/src/shell/tabs/memory.ts +41 -0
  1121. package/src/shell/tabs/navigation-switch.ts +75 -0
  1122. package/src/shell/tabs/pins.test.ts +68 -0
  1123. package/src/shell/tabs/pins.ts +194 -0
  1124. package/src/shell/tabs/preview-machine.test.ts +89 -0
  1125. package/src/shell/tabs/preview-machine.ts +46 -0
  1126. package/src/shell/tabs/preview.test.ts +153 -0
  1127. package/src/shell/tabs/preview.ts +102 -0
  1128. package/src/shell/tabs/project-sessions.ts +60 -0
  1129. package/src/shell/tabs/promotion-machine.test.ts +203 -0
  1130. package/src/shell/tabs/promotion-machine.ts +194 -0
  1131. package/src/shell/tabs/schema.ts +86 -0
  1132. package/src/shell/tabs/tabs.test.ts +331 -0
  1133. package/src/shell/tabs/tabs.tsx +927 -0
  1134. package/src/shell/time.test.ts +23 -0
  1135. package/src/shell/time.ts +31 -0
  1136. package/src/shell/titlebar/auto-tab-groups.test.ts +76 -0
  1137. package/src/shell/titlebar/auto-tab-groups.ts +88 -0
  1138. package/src/shell/titlebar/auto-tab-sections.tsx +207 -0
  1139. package/src/shell/titlebar/history-machine.test.ts +184 -0
  1140. package/src/shell/titlebar/history-machine.ts +149 -0
  1141. package/src/shell/titlebar/history.ts +64 -0
  1142. package/src/shell/titlebar/inbox-branch-machine.test.ts +146 -0
  1143. package/src/shell/titlebar/inbox-branch-machine.ts +265 -0
  1144. package/src/shell/titlebar/inbox-card.stories.tsx +197 -0
  1145. package/src/shell/titlebar/inbox-list.stories.tsx +342 -0
  1146. package/src/shell/titlebar/inbox-model.ts +539 -0
  1147. package/src/shell/titlebar/inbox-settle-machine.test.ts +108 -0
  1148. package/src/shell/titlebar/inbox-settle-machine.ts +141 -0
  1149. package/src/shell/titlebar/inbox-working.test.ts +26 -0
  1150. package/src/shell/titlebar/inbox-working.ts +22 -0
  1151. package/src/shell/titlebar/inbox.tsx +985 -0
  1152. package/src/shell/titlebar/mobile-tabs-machine.test.ts +105 -0
  1153. package/src/shell/titlebar/mobile-tabs-machine.ts +102 -0
  1154. package/src/shell/titlebar/navigation-story.tsx +207 -0
  1155. package/src/shell/titlebar/pinned-area.css +164 -0
  1156. package/src/shell/titlebar/pinned-area.tsx +629 -0
  1157. package/src/shell/titlebar/project-session-row.tsx +334 -0
  1158. package/src/shell/titlebar/recent-sessions-model.test.ts +657 -0
  1159. package/src/shell/titlebar/recent-sessions-model.ts +469 -0
  1160. package/src/shell/titlebar/recent-sessions.tsx +1415 -0
  1161. package/src/shell/titlebar/recent-view-menu.tsx +147 -0
  1162. package/src/shell/titlebar/recent-view.test.ts +99 -0
  1163. package/src/shell/titlebar/recent-view.ts +183 -0
  1164. package/src/shell/titlebar/recently-closed-tabs-menu.css +25 -0
  1165. package/src/shell/titlebar/recently-closed-tabs-menu.tsx +260 -0
  1166. package/src/shell/titlebar/route-machine.test.ts +259 -0
  1167. package/src/shell/titlebar/route-machine.ts +206 -0
  1168. package/src/shell/titlebar/route-sync.ts +191 -0
  1169. package/src/shell/titlebar/session-events.test.ts +23 -0
  1170. package/src/shell/titlebar/session-events.ts +41 -0
  1171. package/src/shell/titlebar/session-rename-dialog-machine.test.ts +151 -0
  1172. package/src/shell/titlebar/session-rename-dialog-machine.ts +159 -0
  1173. package/src/shell/titlebar/sidebar-customized.standalone.stories.tsx +16 -0
  1174. package/src/shell/titlebar/sidebar-customized.tsx +747 -0
  1175. package/src/shell/titlebar/sidebar-pins.tsx +462 -0
  1176. package/src/shell/titlebar/sidebar-sessions.test.ts +96 -0
  1177. package/src/shell/titlebar/sidebar-sessions.ts +29 -0
  1178. package/src/shell/titlebar/sidebar-view-menu.tsx +191 -0
  1179. package/src/shell/titlebar/sidebar-view.test.ts +185 -0
  1180. package/src/shell/titlebar/sidebar-view.ts +208 -0
  1181. package/src/shell/titlebar/tab-group-drag-machine.ts +1479 -0
  1182. package/src/shell/titlebar/tab-groups-ui.tsx +1246 -0
  1183. package/src/shell/titlebar/tab-groups.css +269 -0
  1184. package/src/shell/titlebar/tab-groups.test.ts +667 -0
  1185. package/src/shell/titlebar/tab-groups.ts +496 -0
  1186. package/src/shell/titlebar/tab-hints-machine.test.ts +97 -0
  1187. package/src/shell/titlebar/tab-hints-machine.ts +79 -0
  1188. package/src/shell/titlebar/tab-load-machine.test.ts +178 -0
  1189. package/src/shell/titlebar/tab-load-machine.ts +233 -0
  1190. package/src/shell/titlebar/tab-nav.css +581 -0
  1191. package/src/shell/titlebar/tab-nav.tsx +891 -0
  1192. package/src/shell/titlebar/tab-order.test.ts +22 -0
  1193. package/src/shell/titlebar/tab-order.ts +24 -0
  1194. package/src/shell/titlebar/tab-popover-machine.test.ts +79 -0
  1195. package/src/shell/titlebar/tab-popover-machine.ts +92 -0
  1196. package/src/shell/titlebar/tab-popover.css +129 -0
  1197. package/src/shell/titlebar/tab-popover.tsx +144 -0
  1198. package/src/shell/titlebar/tab-rename-machine.test.ts +206 -0
  1199. package/src/shell/titlebar/tab-rename-machine.ts +297 -0
  1200. package/src/shell/titlebar/tab-strip.standalone.stories.tsx +19 -0
  1201. package/src/shell/titlebar/tab-strip.tsx +1228 -0
  1202. package/src/shell/titlebar/tab-title.test.ts +14 -0
  1203. package/src/shell/titlebar/tab-title.ts +6 -0
  1204. package/src/shell/titlebar/titlebar.css +197 -0
  1205. package/src/shell/titlebar/titlebar.tsx +1075 -0
  1206. package/src/shell/titlebar/windows-menu.test.ts +20 -0
  1207. package/src/shell/titlebar/windows-menu.tsx +193 -0
  1208. package/src/sst-env.d.ts +12 -0
  1209. package/src/theme-preload.test.ts +56 -0
  1210. package/src/tips/model.ts +155 -0
  1211. package/src/tips/queue.test.ts +43 -0
  1212. package/src/tips/queue.ts +46 -0
  1213. package/src/usage/dialog.css +8 -0
  1214. package/src/usage/dialog.standalone.stories.tsx +137 -0
  1215. package/src/usage/dialog.tsx +570 -0
  1216. package/src/usage/format.ts +39 -0
  1217. package/src/usage/limits.test.ts +141 -0
  1218. package/src/usage/limits.ts +189 -0
  1219. package/src/usage/machine.test.ts +128 -0
  1220. package/src/usage/machine.ts +159 -0
  1221. package/src/usage/model.tsx +55 -0
  1222. package/src/voice/call-machine.test.ts +245 -0
  1223. package/src/voice/call-machine.ts +327 -0
  1224. package/src/voice/call.ts +362 -0
  1225. package/src/voice/composer.tsx +300 -0
  1226. package/src/voice/context.tsx +152 -0
  1227. package/src/voice/coordination.test.ts +58 -0
  1228. package/src/voice/fixtures/history.ts +51 -0
  1229. package/src/voice/gate-machine.test.ts +91 -0
  1230. package/src/voice/gate-machine.ts +148 -0
  1231. package/src/voice/handoff.test.ts +35 -0
  1232. package/src/voice/handoff.ts +20 -0
  1233. package/src/voice/machine.test.ts +303 -0
  1234. package/src/voice/machine.ts +349 -0
  1235. package/src/voice/messages.test.ts +49 -0
  1236. package/src/voice/messages.ts +15 -0
  1237. package/src/voice/panel-machine.test.ts +106 -0
  1238. package/src/voice/panel-machine.ts +167 -0
  1239. package/src/voice/protocol.ts +62 -0
  1240. package/src/voice/replies.ts +71 -0
  1241. package/src/voice/reply-machine.test.ts +290 -0
  1242. package/src/voice/reply-machine.ts +303 -0
  1243. package/src/voice/search.test.ts +35 -0
  1244. package/src/voice/search.ts +134 -0
  1245. package/src/voice/spec.ts +114 -0
  1246. package/src/voice/tail-machine.test.ts +124 -0
  1247. package/src/voice/tail-machine.ts +155 -0
  1248. package/src/voice/tail.ts +55 -0
  1249. package/src/voice/tools.test.ts +320 -0
  1250. package/src/voice/tools.ts +336 -0
  1251. package/src/voice/transport-machine.test.ts +295 -0
  1252. package/src/voice/transport-machine.ts +338 -0
  1253. package/src/voice/transport.test.ts +295 -0
  1254. package/src/voice/transport.ts +313 -0
  1255. package/src/voice/voice.css +84 -0
  1256. package/src/workspaces/create.test.ts +120 -0
  1257. package/src/workspaces/create.ts +23 -0
  1258. package/src/workspaces/files/artifact.test.ts +103 -0
  1259. package/src/workspaces/files/artifact.ts +74 -0
  1260. package/src/workspaces/files/content-cache-accounting.test.ts +79 -0
  1261. package/src/workspaces/files/content-cache.ts +74 -0
  1262. package/src/workspaces/files/content-machine.test.ts +269 -0
  1263. package/src/workspaces/files/content-machine.ts +243 -0
  1264. package/src/workspaces/files/model.tsx +423 -0
  1265. package/src/workspaces/files/path.test.ts +76 -0
  1266. package/src/workspaces/files/path.ts +143 -0
  1267. package/src/workspaces/files/tree-machine.test.ts +300 -0
  1268. package/src/workspaces/files/tree-machine.ts +286 -0
  1269. package/src/workspaces/files/tree-store.ts +142 -0
  1270. package/src/workspaces/files/types.ts +85 -0
  1271. package/src/workspaces/files/view-cache.ts +164 -0
  1272. package/src/workspaces/files/watcher.test.ts +114 -0
  1273. package/src/workspaces/files/watcher.ts +42 -0
  1274. package/src/workspaces/inventory.test.ts +151 -0
  1275. package/src/workspaces/inventory.ts +64 -0
  1276. package/src/workspaces/location-machine.test.ts +135 -0
  1277. package/src/workspaces/location-machine.ts +159 -0
  1278. package/src/workspaces/location.tsx +111 -0
  1279. package/src/workspaces/path-key.ts +5 -0
  1280. package/src/workspaces/paths.test.ts +193 -0
  1281. package/src/workspaces/paths.ts +123 -0
  1282. package/src/workspaces/selection/combobox-machine.test.ts +286 -0
  1283. package/src/workspaces/selection/combobox-machine.ts +331 -0
  1284. package/src/workspaces/selection/dialog.css +234 -0
  1285. package/src/workspaces/selection/dialog.standalone.stories.tsx +66 -0
  1286. package/src/workspaces/selection/dialog.tsx +867 -0
  1287. package/src/workspaces/selection/domain.test.ts +603 -0
  1288. package/src/workspaces/selection/domain.ts +609 -0
  1289. package/src/workspaces/selection/picker.test.ts +37 -0
  1290. package/src/workspaces/selection/picker.tsx +77 -0
  1291. package/src/workspaces/selection/policy.ts +8 -0
  1292. package/src/workspaces/selection/queue-machine.test.ts +116 -0
  1293. package/src/workspaces/selection/queue-machine.ts +203 -0
  1294. package/src/workspaces/selection/tree-machine.test.ts +293 -0
  1295. package/src/workspaces/selection/tree-machine.ts +506 -0
  1296. package/test-browser/animated-presence-state.test.ts +134 -0
  1297. package/test-browser/auto-scroll.test.ts +111 -0
  1298. package/test-browser/browser-pane-model.test.ts +522 -0
  1299. package/test-browser/child-store-eviction.test.ts +86 -0
  1300. package/test-browser/command-palette-search.test.ts +157 -0
  1301. package/test-browser/command-palette.test.ts +262 -0
  1302. package/test-browser/composer-attachment-errors.test.tsx +140 -0
  1303. package/test-browser/composer-attachment-ownership.test.tsx +132 -0
  1304. package/test-browser/composer-drag-cancel.test.tsx +41 -0
  1305. package/test-browser/composer-file-search.test.ts +183 -0
  1306. package/test-browser/composer-ime.test.ts +58 -0
  1307. package/test-browser/composer-submit-loading.test.ts +235 -0
  1308. package/test-browser/composer-write-batch.test.ts +201 -0
  1309. package/test-browser/draft-history-cache.test.ts +139 -0
  1310. package/test-browser/elicitation-dock.test.ts +110 -0
  1311. package/test-browser/file-tree-store.test.ts +113 -0
  1312. package/test-browser/fixtures/model-selection.ts +646 -0
  1313. package/test-browser/message-page-publication.test.ts +46 -0
  1314. package/test-browser/model-selection.test.ts +25 -0
  1315. package/test-browser/motion-dom.test.ts +367 -0
  1316. package/test-browser/motion-spring.test.ts +75 -0
  1317. package/test-browser/pane-drag.test.tsx +136 -0
  1318. package/test-browser/panel-motion.test.ts +398 -0
  1319. package/test-browser/persisted-consumers.test.ts +40 -0
  1320. package/test-browser/playwright-config.test.ts +72 -0
  1321. package/test-browser/plugin-catalog.test.ts +67 -0
  1322. package/test-browser/plugin-link-check.test.ts +102 -0
  1323. package/test-browser/plugin-migrations.test.ts +170 -0
  1324. package/test-browser/plugin-primitives.test.ts +616 -0
  1325. package/test-browser/plugin-server-stream.test.ts +88 -0
  1326. package/test-browser/presence.test.ts +236 -0
  1327. package/test-browser/project-avatar-hover.test.ts +143 -0
  1328. package/test-browser/prompt-motion.test.ts +10 -0
  1329. package/test-browser/prompt-persistence.test.ts +312 -0
  1330. package/test-browser/prompt-scope.test.ts +15 -0
  1331. package/test-browser/provider-catalog.test.ts +54 -0
  1332. package/test-browser/pwa-route.test.ts +96 -0
  1333. package/test-browser/question-dock.test.ts +128 -0
  1334. package/test-browser/schema-persistence.test.ts +294 -0
  1335. package/test-browser/selected-effect.test.ts +36 -0
  1336. package/test-browser/server-connection-sync.test.ts +34 -0
  1337. package/test-browser/server-notification-state.test.ts +662 -0
  1338. package/test-browser/session-activity-elapsed.test.ts +62 -0
  1339. package/test-browser/session-background.test.ts +377 -0
  1340. package/test-browser/session-message-handoffs.test.ts +118 -0
  1341. package/test-browser/session-resolution.test.ts +385 -0
  1342. package/test-browser/settings-keybinds.test.ts +196 -0
  1343. package/test-browser/shell-panel.test.ts +219 -0
  1344. package/test-browser/sidebar-peek.test.ts +149 -0
  1345. package/test-browser/solid-router-cleanup.test.ts +66 -0
  1346. package/test-browser/solid-runtime.test.ts +95 -0
  1347. package/test-browser/solid-virtual.test.ts +249 -0
  1348. package/test-browser/ssh-composer.test.ts +41 -0
  1349. package/test-browser/ssh-health.test.ts +142 -0
  1350. package/test-browser/theme-preload.test.ts +9 -0
  1351. package/test-browser/timeline-cache.test.ts +571 -0
  1352. package/test-browser/timeline-projection.test.ts +363 -0
  1353. package/test-browser/toast-owner.test.ts +66 -0
  1354. package/test-browser/websearch-request.test.ts +277 -0
  1355. package/tsconfig.json +35 -0
  1356. package/vite.config.ts +62 -0
  1357. package/vite.icons.test.ts +133 -0
  1358. package/vite.icons.ts +65 -0
  1359. package/vite.js +142 -0
  1360. package/vite.pwa.ts +69 -0
@@ -0,0 +1,2338 @@
1
+ import type { Locator, Page } from "@playwright/test"
2
+ import { expect, sourceURL, story } from "../../stories/playwright/story"
3
+
4
+ const source = (path: string) => sourceURL(new URL(path, import.meta.url))
5
+
6
+ const modules = {
7
+ fixture: source("../../gui-plugins/src/browser/panel.fixture.tsx"),
8
+ embeds: source("../src/runtime/plugin/embeds.tsx"),
9
+ links: source("../src/runtime/plugin/app-links.ts"),
10
+ panelMotion: source("../src/shell/panel-motion.ts"),
11
+ language: source("../src/runtime/i18n/language.tsx"),
12
+ }
13
+
14
+ // Panel motion reads `navigator.platform` on each drag, so a test pins the platform whose behaviour it covers.
15
+ const pinPlatform = (page: Page, platform: string) =>
16
+ page.evaluate((value) => {
17
+ Object.defineProperty(navigator, "platform", { value, configurable: true })
18
+ }, platform)
19
+
20
+ story.beforeEach(async ({ mount, page }) => {
21
+ // Any story loads the app styles; the fixture mounts the pane beside it on the real host embeds.
22
+ await mount("ui-line-comment--editor")
23
+ await mountPane(page)
24
+ await expect(page.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
25
+ })
26
+
27
+ async function mountPane(page: Page) {
28
+ await page.evaluate(async (modules) => {
29
+ const [{ mountBrowserPane }, { createEmbeds }, { appLinkRoute, createAppLinks }, panelMotion, language] = await Promise.all([
30
+ import(modules.fixture),
31
+ import(modules.embeds),
32
+ import(modules.links),
33
+ import(modules.panelMotion),
34
+ import(modules.language),
35
+ ])
36
+
37
+ mountBrowserPane({
38
+ createEmbeds,
39
+ createAppLinks,
40
+ appLinkRoute,
41
+ panelMotion,
42
+ LanguageProvider: language.LanguageProvider,
43
+ UiI18nBridge: language.UiI18nBridge,
44
+ useLanguage: language.useLanguage,
45
+ })
46
+ }, modules)
47
+ }
48
+
49
+ story("reviews the actual application target only after a trusted click", async ({ page }) => {
50
+ const sanitizer = sourceURL(new URL("../../session-ui/src/components/markdown-cache.tsx", import.meta.url))
51
+ const url = "obsidian://open?vault=test&file=report"
52
+ await page.evaluate(async ({ sanitizer, url }) => {
53
+ const { enableMarkdownAppLinks, sanitizeMarkdown } = await import(sanitizer)
54
+ const row = document.createElement("div")
55
+ row.dataset.paneRow = ""
56
+ row.innerHTML = sanitizeMarkdown(`<a href="${url}">Misleading title</a>`)
57
+ enableMarkdownAppLinks(row)
58
+ document.querySelector('[data-testid="browser-pane-fixture"]')?.prepend(row)
59
+ row.querySelector("a")?.click()
60
+ }, { sanitizer, url })
61
+ const pane = page.locator("#browser-panel")
62
+ await expect(pane.getByText(url)).toHaveCount(0)
63
+ const link = page.getByRole("link", { name: "Misleading title" })
64
+ await link.hover()
65
+ await page.mouse.down()
66
+ await link.evaluate((node) => node.replaceWith(node.cloneNode(true)))
67
+ await page.mouse.up()
68
+ await expect(pane.getByText(url)).toHaveCount(0)
69
+ await link.click({ button: "middle" })
70
+ await link.click({ modifiers: ["Shift"] })
71
+ await link.hover()
72
+ await page.mouse.down()
73
+ await link.evaluate(node => { node.dataset.appLink = "obsidian:changed" })
74
+ await page.mouse.up()
75
+ await expect(pane.getByText("obsidian:changed")).toHaveCount(0)
76
+ await expect(pane.getByRole("button", { name: "Open", exact: true })).toHaveCount(0)
77
+ await link.evaluate((node, url) => { node.dataset.appLink = url }, url)
78
+ await link.press("Enter")
79
+ await expect(pane.getByRole("status").filter({ hasText: "From the conversation" })).toContainText(url)
80
+ await expect(pane.getByRole("button", { name: "Open", exact: true })).toBeVisible()
81
+ // A synthetic press on the guarded button cannot answer the review, even after a real Enter on the link.
82
+ await pane.getByRole("button", { name: "Open", exact: true }).evaluate((button: HTMLElement) => button.click())
83
+ await expect(pane.getByText(url)).toBeVisible()
84
+ // A fresh notice reuses the bar but not the earlier notice's press or activation time.
85
+ await link.click()
86
+ const open = pane.getByRole("button", { name: "Open", exact: true })
87
+ await open.click()
88
+ await expect(pane.getByText(url)).toBeVisible()
89
+ const longest = "obsidian://open?file=".padEnd(200, "W")
90
+ await pane.evaluate(node => { node.style.width = "320px" })
91
+ await link.evaluate((node, value) => { node.dataset.appLink = value }, longest)
92
+ await link.press("Enter")
93
+ await expect(pane.getByText(longest)).toBeVisible()
94
+ await expect(open).toBeVisible()
95
+ // A font or width that doesn't fit five lines downgrades the same notice without changing its target.
96
+ await pane.evaluate(node => { node.style.width = "240px" })
97
+ await expect(pane.getByRole("button", { name: "Copy link", exact: true })).toBeVisible()
98
+ await expect(open).toHaveCount(0)
99
+ })
100
+
101
+ story("accepts an assistive activation of the focused link, not a synthetic or unfocused one", async ({ page }) => {
102
+ const sanitizer = sourceURL(new URL("../../session-ui/src/components/markdown-cache.tsx", import.meta.url))
103
+ // A phone link keeps its href, so Chromium activates it on Enter.
104
+ const url = "tel:+15555550100"
105
+ await page.evaluate(async ({ sanitizer, url }) => {
106
+ const { enableMarkdownAppLinks, sanitizeMarkdown } = await import(sanitizer)
107
+ const row = document.createElement("div")
108
+ row.dataset.paneRow = ""
109
+ row.innerHTML = sanitizeMarkdown(`<a href="${url}">Assistive link</a> <a href="https://example.invalid/">Other</a>`)
110
+ enableMarkdownAppLinks(row)
111
+ document.querySelector('[data-testid="browser-pane-fixture"]')?.prepend(row)
112
+ // A screen reader's default action is a trusted click with no press. Chromium sends the same one for Enter on a
113
+ // live link when nothing handles the key, so keep the app's own Enter handling out of the way.
114
+ window.addEventListener(
115
+ "keydown",
116
+ (event) => {
117
+ if (event.key !== "Enter" || !document.body.dataset.assistive) return
118
+ event.stopImmediatePropagation()
119
+
120
+ if (document.body.dataset.assistive === "unfocused") row.querySelectorAll("a")[1]?.focus()
121
+ },
122
+ true,
123
+ )
124
+ }, { sanitizer, url })
125
+ const pane = page.locator("#browser-panel")
126
+ const link = page.getByRole("link", { name: "Assistive link" })
127
+ await link.focus()
128
+ await link.evaluate((node) => node.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true, detail: 0 })))
129
+ await page.evaluate(() => { document.body.dataset.assistive = "unfocused" })
130
+ await link.focus()
131
+ await page.keyboard.press("Enter")
132
+ await expect(page.getByRole("link", { name: "Other" })).toBeFocused()
133
+ await expect(pane.getByText(url)).toHaveCount(0)
134
+ await page.evaluate(() => { document.body.dataset.assistive = "focused" })
135
+ await link.focus()
136
+ await page.keyboard.press("Enter")
137
+ await expect(pane.getByRole("status").filter({ hasText: "From the conversation" })).toContainText(url)
138
+ })
139
+
140
+ story("reviews an application link that carries download, and leaves a web download to the document", async ({ page }) => {
141
+ const sanitizer = sourceURL(new URL("../../session-ui/src/components/markdown-cache.tsx", import.meta.url))
142
+ await page.evaluate(async (sanitizer) => {
143
+ const { enableMarkdownAppLinks, sanitizeMarkdown } = await import(sanitizer)
144
+ const row = document.createElement("div")
145
+ row.dataset.paneRow = ""
146
+ row.dataset.testid = "download-links"
147
+ row.innerHTML = sanitizeMarkdown(
148
+ '<a download href="mailto:download@example.invalid?attach=fixture">Mail</a> <a download href="obsidian://open?vault=download">Vault</a> <a download href="https://example.invalid/report.csv">Report</a>',
149
+ )
150
+ enableMarkdownAppLinks(row)
151
+ // A reviewed click never reaches here. Record the ones left to the document, and keep the fixture page in place.
152
+ row.addEventListener("click", (event) => {
153
+ row.dataset.passed = `${row.dataset.passed ?? ""}${event.target instanceof Element ? event.target.textContent : ""}`
154
+ event.preventDefault()
155
+ })
156
+ document.querySelector('[data-testid="browser-pane-fixture"]')?.prepend(row)
157
+ }, sanitizer)
158
+ const notice = page.locator("#browser-panel").getByRole("status").filter({ hasText: "From the conversation" })
159
+ const mail = page.getByRole("link", { name: "Mail" })
160
+ await expect(mail).not.toHaveAttribute("download")
161
+ // The attribute put back after sanitizing does not take the link past the host either: a mail link with an
162
+ // attachment is only copied.
163
+ await mail.evaluate((node) => node.setAttribute("download", ""))
164
+ await mail.click()
165
+ await expect(page.locator("body")).toHaveAttribute("data-copy", "mailto:download@example.invalid?attach=fixture")
166
+ await expect(notice).toHaveCount(0)
167
+ await page.getByRole("link", { name: "Vault" }).click()
168
+ await expect(notice).toContainText("obsidian://open?vault=download")
169
+ await page.getByRole("link", { name: "Report" }).click()
170
+ await expect(page.getByTestId("download-links")).toHaveAttribute("data-passed", "Report")
171
+ await expect(notice).toContainText("obsidian://open?vault=download")
172
+ })
173
+
174
+ story("opens a mail link in the system mail app, never in the pane", async ({ page }) => {
175
+ const sanitizer = sourceURL(new URL("../../session-ui/src/components/markdown-cache.tsx", import.meta.url))
176
+ const url = "mailto:hello@example.invalid?subject=Report"
177
+ await page.evaluate(async ({ sanitizer, url }) => {
178
+ const { enableMarkdownAppLinks, sanitizeMarkdown } = await import(sanitizer)
179
+ const row = document.createElement("div")
180
+ row.dataset.paneRow = ""
181
+ row.innerHTML = sanitizeMarkdown(`<a href="${url}">Write to us</a>`)
182
+ enableMarkdownAppLinks(row)
183
+ // A click the host does not take would navigate the fixture page away.
184
+ row.addEventListener("click", (event) => event.preventDefault())
185
+ document.querySelector('[data-testid="browser-pane-fixture"]')?.prepend(row)
186
+ }, { sanitizer, url })
187
+ await page.getByRole("link", { name: "Write to us" }).click()
188
+ await expect(page.locator("body")).toHaveAttribute("data-mail", url)
189
+ await expect(page.locator("#browser-panel").getByText(url)).toHaveCount(0)
190
+ await expect(page.locator("#browser-panel").getByRole("status").filter({ hasText: "From the conversation" })).toHaveCount(0)
191
+ })
192
+
193
+ story("moves the native page when a fixed-size pane changes position", async ({ page }) => {
194
+ const native = page.getByTestId("native-Alpha")
195
+ const x = Number(await native.getAttribute("data-x"))
196
+ const calls = Number(await native.getAttribute("data-layout-calls"))
197
+ await page.locator("#browser-panel").evaluate((pane) => {
198
+ pane.style.translate = "-12px"
199
+ pane.style.translate = "-24px"
200
+ pane.style.translate = "-39px"
201
+ })
202
+ await expect(native).toHaveAttribute("data-x", String(x - 39))
203
+ await expect(native).toHaveAttribute("data-layout-calls", String(calls + 1))
204
+ })
205
+
206
+ story("reconnects the observation spine after its panel reattaches", async ({ page }) => {
207
+ const native = page.getByTestId("native-Alpha")
208
+ const x = Number(await native.getAttribute("data-x"))
209
+
210
+ const detached = await page.locator("#browser-panel").evaluateHandle((box) => {
211
+ const marker = document.createComment("panel slot")
212
+ box.replaceWith(marker)
213
+ const fragment = document.createDocumentFragment()
214
+ fragment.append(box)
215
+
216
+ return { marker, fragment }
217
+ })
218
+
219
+ await expect(native).toHaveAttribute("data-visible", "false")
220
+ await detached.evaluate(({ marker, fragment }) => { marker.replaceWith(fragment) })
221
+ await expect(native).toHaveAttribute("data-visible", "true")
222
+ await page.locator("#browser-panel").evaluate((box) => { box.parentElement!.style.translate = "-31px" })
223
+ await expect(native).toHaveAttribute("data-x", String(x - 31))
224
+ })
225
+
226
+ story("a spinner inside a persistent floating surface does not measure the pane each frame", async ({ page }) => {
227
+ const native = page.getByTestId("native-Alpha")
228
+
229
+ const reads = await page.locator("#browser-panel").evaluate(async (panel) => {
230
+ const box = panel.querySelector<HTMLElement>('[data-component="browser-preview"] > :first-child')!
231
+ const rect = box.getBoundingClientRect.bind(box)
232
+ const count = { reads: 0 }
233
+ box.getBoundingClientRect = () => {
234
+ count.reads++
235
+
236
+ return rect()
237
+ }
238
+
239
+ const surface = document.createElement("div")
240
+ surface.dataset.floatingOverlay = ""
241
+ const spinner = document.createElement("span")
242
+ const style = document.createElement("style")
243
+ style.textContent = "@keyframes fixture-spin { to { transform: rotate(1turn) } }"
244
+ spinner.style.cssText = "display:block; animation:fixture-spin 100ms linear infinite"
245
+ surface.append(style, spinner)
246
+ document.body.append(surface)
247
+ const cycle = () => new Promise<void>(resolve => spinner.addEventListener("animationiteration", () => resolve(), { once: true }))
248
+ await cycle()
249
+ const initial = count.reads
250
+ await cycle()
251
+ const total = count.reads - initial
252
+ surface.remove()
253
+
254
+ return total
255
+ })
256
+
257
+ expect(reads).toBe(0)
258
+ await expect(native).toHaveAttribute("data-visible", "true")
259
+ })
260
+
261
+ story("stops measuring the pane once a finite animation ends or is cancelled", async ({ page }) => {
262
+ const native = page.getByTestId("native-Alpha")
263
+ const x = Number(await native.getAttribute("data-x"))
264
+
265
+ const reads = await page.locator("#browser-panel").evaluate(async (panel) => {
266
+ const box = panel.querySelector<HTMLElement>('[data-component="browser-preview"] > :first-child')!
267
+ const rect = box.getBoundingClientRect.bind(box)
268
+ const count = { reads: 0 }
269
+ box.getBoundingClientRect = () => {
270
+ count.reads++
271
+
272
+ return rect()
273
+ }
274
+
275
+ const frames = (n: number) =>
276
+ new Promise<void>((resolve) => {
277
+ const step = (left: number) => (left ? requestAnimationFrame(() => step(left - 1)) : resolve())
278
+ step(n)
279
+ })
280
+
281
+ const idle = async () => {
282
+ const before = count.reads
283
+ await frames(10)
284
+
285
+ return count.reads - before
286
+ }
287
+
288
+ const finished = panel.parentElement!.animate([{ translate: "0" }, { translate: "-20px" }], { duration: 120, fill: "forwards" })
289
+ await finished.finished
290
+ await frames(2)
291
+ const afterFinish = await idle()
292
+ const cancelled = panel.parentElement!.animate([{ translate: "-20px" }, { translate: "-60px" }], { duration: 5_000 })
293
+ await frames(3)
294
+ cancelled.cancel()
295
+ await frames(2)
296
+ const afterCancel = await idle()
297
+
298
+ return { afterFinish, afterCancel, measured: count.reads > 0 }
299
+ })
300
+
301
+ expect(reads).toEqual({ afterFinish: 0, afterCancel: 0, measured: true })
302
+ await expect(native).toHaveAttribute("data-x", String(x - 20))
303
+ })
304
+
305
+ story("does not measure when the pane's own still enters or leaves its box", async ({ page }) => {
306
+ const reads = await page.locator("#browser-panel").evaluate(async (panel) => {
307
+ const box = panel.querySelector<HTMLElement>('[data-component="browser-preview"] > :first-child')!
308
+ const rect = box.getBoundingClientRect.bind(box)
309
+ const count = { reads: 0 }
310
+ box.getBoundingClientRect = () => {
311
+ count.reads++
312
+
313
+ return rect()
314
+ }
315
+
316
+ const frames = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))
317
+ const still = document.createElement("div")
318
+ still.className = "absolute inset-0 pointer-events-none"
319
+ box.prepend(still)
320
+ await frames()
321
+ still.remove()
322
+ await frames()
323
+
324
+ return count.reads
325
+ })
326
+
327
+ expect(reads).toBe(0)
328
+ })
329
+
330
+ story("hides the page when a portalled surface grows over it by a text edit alone", async ({ page }) => {
331
+ const native = page.getByTestId("native-Alpha")
332
+ await page.emulateMedia({ reducedMotion: "reduce" })
333
+
334
+ const text = await page.locator("#browser-panel").evaluateHandle((panel) => {
335
+ const pane = panel.querySelector<HTMLElement>('[data-component="browser-preview"] > :first-child')!.getBoundingClientRect()
336
+ // A portal's wrapper keeps its size while the fixed surface inside it grows, as a toast region's does.
337
+ const wrapper = document.createElement("div")
338
+ const surface = document.createElement("div")
339
+ surface.dataset.floatingOverlay = ""
340
+ surface.style.cssText = `position:fixed; top:${pane.top + 8}px; left:${pane.left - 40}px; white-space:pre; font:16px monospace`
341
+ const text = document.createTextNode("x")
342
+ surface.append(text)
343
+ wrapper.append(surface)
344
+ document.body.append(wrapper)
345
+
346
+ return text
347
+ })
348
+
349
+ await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))))
350
+ await expect(native).toHaveAttribute("data-visible", "true")
351
+ await text.evaluate((node) => { node.data = "x".repeat(400) })
352
+ await expect(native).toHaveAttribute("data-visible", "false")
353
+ })
354
+
355
+ story("covers the page with unmarked portalled surfaces but not tooltips or transparent wrappers", async ({ page }) => {
356
+ const native = page.getByTestId("native-Alpha")
357
+
358
+ const portal = await page.locator("#browser-panel").evaluateHandle((panel) => {
359
+ const pane = panel.querySelector<HTMLElement>('[data-component="browser-preview"] > :first-child')!.getBoundingClientRect()
360
+ const box = `position:fixed; top:${pane.top + 8}px; left:${pane.left + 8}px; width:120px; height:60px`
361
+ const tooltip = document.createElement("div")
362
+ tooltip.innerHTML = `<div style="${box}" role="tooltip">Tip</div>`
363
+ const wrapper = document.createElement("div")
364
+ wrapper.style.cssText = "position:fixed; inset:0; pointer-events:none"
365
+ document.body.append(tooltip, wrapper)
366
+ const surface = document.createElement("div")
367
+ surface.innerHTML = `<div style="${box}; background:Canvas; pointer-events:auto">Unmarked menu</div>`
368
+
369
+ return { surface, wrapper }
370
+ })
371
+
372
+ await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))))
373
+ await expect(native).toHaveAttribute("data-visible", "true")
374
+ await portal.evaluate(({ surface }) => document.body.append(surface))
375
+ await expect(native).toHaveAttribute("data-visible", "false")
376
+ await portal.evaluate(({ surface, wrapper }) => wrapper.append(surface.firstElementChild!))
377
+ await expect(native).toHaveAttribute("data-visible", "false")
378
+ await portal.evaluate(({ wrapper }) => wrapper.replaceChildren())
379
+ await expect(native).toHaveAttribute("data-visible", "true")
380
+ })
381
+
382
+ story("covers the page with an app dialog's backdrop for as long as the backdrop is there", async ({ mount, page }) => {
383
+ // The fixture reports no open dialog to the embeds, and the dialog was portalled before the pane: only the marked
384
+ // backdrop itself covers the page, independent of the dialog stack's open state, which ends as the exit starts.
385
+ await mount("ui-dialog--with-popups")
386
+ await expect(page.getByRole("dialog", { name: "Popups" })).toBeVisible()
387
+ await mountPane(page)
388
+ const native = page.getByTestId("native-Alpha")
389
+ await expect(native).toHaveAttribute("data-layout-calls", /[1-9]/)
390
+ await expect(page.locator('[data-component="dialog-overlay"]')).toHaveCount(1)
391
+ await expect(native).toHaveAttribute("data-visible", "false")
392
+ await page.keyboard.press("Escape")
393
+ await expect(page.locator('[data-component="dialog-overlay"]')).toHaveCount(0)
394
+ await expect(native).toHaveAttribute("data-visible", "true")
395
+ })
396
+
397
+ story("tracks a fixed-size pane through a sibling resize, ancestor scroll and animation", async ({ page }) => {
398
+ const pane = page.locator("#browser-panel")
399
+ const native = page.getByTestId("native-Alpha")
400
+ const x = Number(await native.getAttribute("data-x"))
401
+
402
+ const row = await pane.evaluateHandle((box) => {
403
+ const scroller = document.createElement("div")
404
+ const spacer = document.createElement("div")
405
+ const rect = box.getBoundingClientRect()
406
+ scroller.style.cssText = `display:flex; overflow:auto; width:${rect.width}px; height:${rect.height}px`
407
+ box.style.flex = `0 0 ${rect.width}px`
408
+ spacer.style.flex = "0 0 32px"
409
+ box.replaceWith(scroller)
410
+ scroller.append(spacer, box)
411
+
412
+ return { spacer, scroller }
413
+ })
414
+
415
+ await expect(native).toHaveAttribute("data-x", String(x + 32))
416
+ await row.evaluate(({ spacer }) => { spacer.style.flexBasis = "48px" })
417
+ await expect(native).toHaveAttribute("data-x", String(x + 48))
418
+ await row.evaluate(({ scroller }) => { scroller.scrollLeft = 19 })
419
+ await expect(native).toHaveAttribute("data-x", String(x + 29))
420
+ const motion = await row.evaluateHandle(({ scroller }) => scroller.animate([{ translate: "0" }, { translate: "-64px" }], { duration: 220, fill: "forwards" }))
421
+ await motion.evaluate(animation => animation.finished.then(() => undefined))
422
+ await expect(native).toHaveAttribute("data-x", String(x - 35))
423
+ await motion.evaluate(animation => animation.cancel())
424
+ await expect(native).toHaveAttribute("data-x", String(x + 29))
425
+ })
426
+
427
+ story("hides a native page when another takes the pane, the pane hides, or it unmounts", async ({ page }) => {
428
+ const root = page.getByTestId("browser-pane-fixture")
429
+ const alpha = root.getByTestId("native-Alpha")
430
+ const beta = root.getByTestId("native-Beta")
431
+ await root.getByRole("button", { name: "Beta", exact: true }).click()
432
+ await expect(beta).toHaveAttribute("data-visible", "true")
433
+ await expect(alpha).toHaveAttribute("data-visible", "false")
434
+ await root.getByRole("button", { name: "Empty", exact: true }).click()
435
+ await expect(root.locator("#browser-panel")).toHaveCount(0)
436
+ await expect(beta).toHaveAttribute("data-visible", "false")
437
+ await root.getByRole("button", { name: "Alpha", exact: true }).click()
438
+ await expect(alpha).toHaveAttribute("data-visible", "true")
439
+ await root.getByRole("button", { name: "Toggle Review tab", exact: true }).click()
440
+ await expect(alpha).toHaveAttribute("data-visible", "false")
441
+ await root.getByRole("button", { name: "Toggle Review tab", exact: true }).click()
442
+ await expect(alpha).toHaveAttribute("data-visible", "true")
443
+ await root.getByRole("button", { name: "Unmount pane", exact: true }).click()
444
+ await expect(alpha).toHaveAttribute("data-visible", "false")
445
+ })
446
+
447
+ story("hides the native view immediately while the pane stays mounted", async ({ page }) => {
448
+ const root = page.getByTestId("browser-pane-fixture")
449
+ const toggle = root.getByRole("button", { name: "Toggle Review tab", exact: true })
450
+ await expect(toggle).toBeEnabled()
451
+
452
+ // Read in the same task as the click so a deferred animation-frame hide cannot pass.
453
+ const visible = await toggle.evaluate((element) => {
454
+ element.dispatchEvent(new MouseEvent("click", { bubbles: true }))
455
+
456
+ return document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible")
457
+ })
458
+
459
+ expect(visible).toBe("false")
460
+ await expect(root.locator("#browser-panel")).toHaveCount(1)
461
+ await toggle.click()
462
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
463
+ })
464
+
465
+ story("updates the selected match while the same find field stays focused", async ({ page }) => {
466
+ const pane = page.locator("#browser-panel")
467
+ await pane.getByRole("button", { name: "Browser options" }).click()
468
+ await page.getByRole("menuitem", { name: "Find in page" }).click()
469
+ const field = pane.getByRole("searchbox", { name: "Find in page" })
470
+ await field.fill("landmark")
471
+ const count = pane.getByRole("search").getByRole("status")
472
+ await expect(count).toHaveText("1 of 3")
473
+ await field.press("Enter")
474
+ await expect(count).toHaveText("2 of 3")
475
+ await expect(field).toBeFocused()
476
+ await field.press("Escape")
477
+ await expect(field).toHaveCount(0)
478
+ })
479
+
480
+ story("paints a still of the page in place of the native view while a panel moves", async ({ page }) => {
481
+ const root = page.getByTestId("browser-pane-fixture")
482
+ const motion = root.getByRole("button", { name: "Toggle panel motion", exact: true })
483
+ const pane = root.getByRole("button", { name: "Toggle Review tab", exact: true })
484
+ const native = root.getByTestId("native-Alpha")
485
+ const still = root.locator("#browser-panel img")
486
+
487
+ // Read in the same task as the click: a native view left up for even one frame floats over the moving app.
488
+ const visible = await motion.evaluate((element) => {
489
+ element.dispatchEvent(new MouseEvent("click", { bubbles: true }))
490
+
491
+ return document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible")
492
+ })
493
+
494
+ expect(visible).toBe("false")
495
+ // A close: the page flies out as a still of itself rather than a blank box.
496
+ await expect(still).toBeVisible()
497
+ await pane.click()
498
+ await expect(still).toBeVisible()
499
+ await motion.click()
500
+ await expect(still).toHaveCount(0)
501
+
502
+ // An open shows the still the close left, until the flight lands and the page is back.
503
+ await motion.click()
504
+ await pane.click()
505
+ await expect(still).toBeVisible()
506
+ await expect(native).toHaveAttribute("data-visible", "false")
507
+ await motion.click()
508
+ await expect(native).toHaveAttribute("data-visible", "true")
509
+ await expect(still).toHaveCount(0)
510
+ })
511
+
512
+ story("paints a still of the page in place of the native view while a resize handle is dragged", async ({ page }) => {
513
+ const root = page.getByTestId("browser-pane-fixture")
514
+ const handle = root.getByTestId("pane-resize-handle")
515
+ const native = root.getByTestId("native-Alpha")
516
+ const still = root.locator("#browser-panel img")
517
+ await pinPlatform(page, "Linux x86_64")
518
+
519
+ // On Linux a native view's bounds land on screen frames before the DOM around it, so one left up through a drag jumps
520
+ // against its pane on every move. A click on the handle moves nothing and must not blink the page out. Read in the
521
+ // same task as each event, so a view hidden and shown again before the next frame cannot pass.
522
+ const visible = await handle.evaluate((element) => {
523
+ const read = () => document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible")
524
+ const box = element.getBoundingClientRect()
525
+ const at = { bubbles: true, pointerId: 1, clientX: box.x + box.width / 2, clientY: box.y + box.height / 2 }
526
+ element.dispatchEvent(new PointerEvent("pointerdown", { ...at, button: 0 }))
527
+ document.dispatchEvent(new PointerEvent("pointerup", at))
528
+ const click = read()
529
+ element.dispatchEvent(new PointerEvent("pointerdown", { ...at, button: 0 }))
530
+ const pressed = read()
531
+ document.dispatchEvent(new PointerEvent("pointermove", { ...at, clientX: at.clientX - 40 }))
532
+
533
+ return { click, pressed, dragging: read() }
534
+ })
535
+
536
+ expect(visible).toEqual({ click: "true", pressed: "true", dragging: "false" })
537
+ await expect(still).toBeVisible()
538
+ await handle.evaluate((element) => {
539
+ const box = element.getBoundingClientRect()
540
+ document.dispatchEvent(
541
+ new PointerEvent("pointerup", { bubbles: true, pointerId: 1, clientX: box.x, clientY: box.y }),
542
+ )
543
+ })
544
+ await expect(native).toHaveAttribute("data-visible", "true")
545
+ await expect(still).toHaveCount(0)
546
+ })
547
+
548
+ for (const platform of ["MacIntel", "Win32"]) {
549
+ story(`keeps the native view live through a press, a drag and the release of a resize handle on ${platform}`, async ({ page }) => {
550
+ const root = page.getByTestId("browser-pane-fixture")
551
+ const handle = root.getByTestId("pane-resize-handle")
552
+ const native = root.getByTestId("native-Alpha")
553
+ const still = root.locator("#browser-panel img")
554
+ await pinPlatform(page, platform)
555
+ const box = await handle.boundingBox()
556
+
557
+ if (!box) throw new Error("Missing pane resize handle")
558
+ const at = { x: box.x + box.width / 2, y: box.y + box.height / 2 }
559
+ const width = Number(await native.getAttribute("data-width"))
560
+ const calls = (await native.getAttribute("data-layout-calls")) ?? ""
561
+
562
+ // macOS and Windows put a native view's bounds and the DOM around it on the same frame, so the page keeps laying
563
+ // out through the drag instead of hiding behind a still, which blanks the box until the still paints. Every change
564
+ // of the view's visibility is recorded, so one hidden and shown again before the next frame cannot pass.
565
+ const flips = await native.evaluateHandle((element) => {
566
+ const flips: (string | null)[] = []
567
+ new MutationObserver((records) => flips.push(...records.map((record) => record.oldValue))).observe(element, {
568
+ attributeFilter: ["data-visible"],
569
+ attributeOldValue: true,
570
+ })
571
+
572
+ return flips
573
+ })
574
+
575
+ const frames = () =>
576
+ page.evaluate(() => new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))))
577
+
578
+ // A real press: the handle takes the pointer, and main hears nothing until it moves.
579
+ await page.mouse.move(at.x, at.y)
580
+ await page.mouse.down()
581
+ await expect(handle).toHaveAttribute("data-dragging", "")
582
+ await frames()
583
+ await expect(native).toHaveAttribute("data-layout-calls", calls)
584
+
585
+ // Main gets the bounds of every move.
586
+ for (const moved of [10, 20, 30, 40]) {
587
+ await page.mouse.move(at.x - moved, at.y)
588
+ await expect(native).toHaveAttribute("data-width", String(width - moved))
589
+ }
590
+
591
+ await expect(still).toHaveCount(0)
592
+ await page.mouse.up()
593
+ await expect(handle).not.toHaveAttribute("data-dragging")
594
+ await frames()
595
+ await expect(native).toHaveAttribute("data-width", String(width - 40))
596
+ await expect(still).toHaveCount(0)
597
+ expect(await flips.jsonValue()).toEqual([])
598
+ })
599
+ }
600
+
601
+ story("shows the native view again when the window loses focus mid-drag", async ({ page }) => {
602
+ const root = page.getByTestId("browser-pane-fixture")
603
+ const handle = root.getByTestId("pane-resize-handle")
604
+ const native = root.getByTestId("native-Alpha")
605
+ const still = root.locator("#browser-panel img")
606
+ await pinPlatform(page, "Linux x86_64")
607
+
608
+ // Alt+Tab mid-drag delivers no pointerup; the page must not stay locked behind a still.
609
+ await handle.evaluate((element) => {
610
+ const box = element.getBoundingClientRect()
611
+ const at = { bubbles: true, pointerId: 1, clientX: box.x + box.width / 2, clientY: box.y + box.height / 2 }
612
+ element.dispatchEvent(new PointerEvent("pointerdown", { ...at, button: 0 }))
613
+ document.dispatchEvent(new PointerEvent("pointermove", { ...at, clientX: at.clientX - 40 }))
614
+ })
615
+ await expect(native).toHaveAttribute("data-visible", "false")
616
+ await expect(handle).toHaveAttribute("data-dragging", "")
617
+
618
+ await handle.evaluate(() => window.dispatchEvent(new FocusEvent("blur")))
619
+ await expect(native).toHaveAttribute("data-visible", "true")
620
+ await expect(still).toHaveCount(0)
621
+ await expect(handle).not.toHaveAttribute("data-dragging")
622
+ expect(await handle.evaluate(() => document.body.style.userSelect)).toBe("")
623
+ })
624
+
625
+ story("never flies a still of a page the tab has navigated away from", async ({ page }) => {
626
+ const root = page.getByTestId("browser-pane-fixture")
627
+ const motion = root.getByRole("button", { name: "Toggle panel motion", exact: true })
628
+ const native = root.getByTestId("native-Alpha")
629
+ const still = root.locator("#browser-panel img")
630
+ await motion.click()
631
+ await expect(still).toBeVisible()
632
+ await motion.click()
633
+ await expect(native).toHaveAttribute("data-visible", "true")
634
+ await expect(still).toHaveCount(0)
635
+
636
+ await root.getByRole("button", { name: "Hold capture", exact: true }).click()
637
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
638
+ await address.fill("https://example.com/")
639
+ await address.press("Enter")
640
+ await expect(address).toHaveValue("https://example.com/")
641
+ await expect(native).toHaveAttribute("data-visible", "true")
642
+ await motion.click()
643
+ await expect(native).toHaveAttribute("data-visible", "false")
644
+ await expect(still).toHaveCount(0)
645
+ // The new page's own still stands in once it arrives.
646
+ await root.getByRole("button", { name: "Release capture", exact: true }).click()
647
+ await expect(still).toBeVisible()
648
+ })
649
+
650
+ story("refreshes page stills by the window's focus, not the document's", async ({ page }) => {
651
+ const root = page.getByTestId("browser-pane-fixture")
652
+ const captures = async () => Number((await root.getByText(/^Captures: \d+$/).textContent())?.split(": ")[1])
653
+ await page.clock.install()
654
+ await expect(root.getByText(/^Captures: [1-9]/)).toBeVisible()
655
+
656
+ // Main reports the window unfocused while this document keeps focus: stills follow the window, so they stop.
657
+ await root.getByRole("button", { name: "Blur window", exact: true }).click()
658
+ const paused = await captures()
659
+ await page.clock.runFor(120_000)
660
+ expect(await captures()).toBe(paused)
661
+
662
+ // Focus coming back to the window, even straight into the embed, which never focuses this document, takes a fresh
663
+ // still at once.
664
+ await root.getByRole("button", { name: "Focus window", exact: true }).click()
665
+ await page.clock.runFor(10)
666
+ await expect(root.getByText(`Captures: ${paused + 1}`, { exact: true })).toBeVisible()
667
+ })
668
+
669
+ story("keeps a still of the page under floating content that covers it", async ({ page }) => {
670
+ const root = page.getByTestId("browser-pane-fixture")
671
+ const still = root.locator("#browser-panel img")
672
+ const native = root.getByTestId("native-Alpha")
673
+ // Reduced motion lands panels at once, so the pane keeps no flight still and captures only for the cover.
674
+ await page.emulateMedia({ reducedMotion: "reduce" })
675
+ await root.getByRole("button", { name: "Hold capture", exact: true }).click()
676
+ await root.getByRole("button", { name: "Toggle popover", exact: true }).click()
677
+ await expect(root.getByText("Captures: 1", { exact: true })).toBeVisible()
678
+ // The native page stays up until its still is ready, so the pane never shows blank.
679
+ await expect(native).toHaveAttribute("data-visible", "true")
680
+ await expect(still).toHaveCount(0)
681
+
682
+ // Main hides the native page at once, so the pane hides it only after a frame has presented the still.
683
+ const order = await native.evaluateHandle((element) => {
684
+ const events: string[] = []
685
+ new PerformanceObserver((list) => {
686
+ if (list.getEntries().length > 0) events.push("still presented")
687
+ }).observe({ type: "element" })
688
+ new MutationObserver(() => {
689
+ if (element.getAttribute("data-visible") === "false") events.push("page hidden")
690
+ }).observe(element, { attributeFilter: ["data-visible"] })
691
+
692
+ return events
693
+ })
694
+
695
+ await root.getByRole("button", { name: "Release capture", exact: true }).click()
696
+ await expect(native).toHaveAttribute("data-visible", "false")
697
+ await expect(still).toBeVisible()
698
+ expect(await order.jsonValue()).toEqual(["still presented", "page hidden"])
699
+
700
+ await root.getByRole("button", { name: "Toggle popover", exact: true }).click()
701
+ await expect(native).toHaveAttribute("data-visible", "true")
702
+ await expect(still).toHaveCount(0)
703
+ await expect(root.getByText("Captures: 1", { exact: true })).toBeVisible()
704
+ })
705
+
706
+ story("covers the page with its warm still only once the capture is back, and through the thaw", async ({ page }) => {
707
+ const root = page.getByTestId("browser-pane-fixture")
708
+ const still = root.locator("#browser-panel img")
709
+ const native = root.getByTestId("native-Alpha")
710
+ const popover = root.getByRole("button", { name: "Toggle popover", exact: true })
711
+ // Without reduced motion the pane keeps a still of the page for flights, which can cover the page at once.
712
+ await expect(root.getByText(/^Captures: [1-9]/)).toBeVisible()
713
+ const captures = Number((await root.getByText(/^Captures: \d+$/).textContent())?.split(": ")[1])
714
+ await root.getByRole("button", { name: "Hold capture", exact: true }).click()
715
+ await popover.click()
716
+ await expect(root.getByText(`Captures: ${captures + 1}`, { exact: true })).toBeVisible()
717
+ // Main captures only a visible view: hiding it while the capture is out returns no fresh still.
718
+ await expect(still).toHaveCount(1)
719
+ await expect(native).toHaveAttribute("data-visible", "true")
720
+ await root.getByRole("button", { name: "Release capture", exact: true }).click()
721
+ await expect(native).toHaveAttribute("data-visible", "false")
722
+ await popover.click()
723
+ await expect(native).toHaveAttribute("data-visible", "true")
724
+
725
+ // A capture that returns nothing still leaves the warm still over the hidden page, and over the page while it
726
+ // paints again after the cover ends.
727
+ // The fixture's controls below the pane sit outside the viewport.
728
+ await root.getByRole("button", { name: "Fail capture", exact: true }).evaluate((element: HTMLElement) => element.click())
729
+ await popover.click()
730
+ await expect(native).toHaveAttribute("data-visible", "false")
731
+ await expect(still).toHaveCount(1)
732
+
733
+ const frames = await popover.evaluate(async (button) => {
734
+ const samples: [string | null, number][] = []
735
+
736
+ const read = (): [string | null, number] => [
737
+ document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible") ?? null,
738
+ document.querySelectorAll("#browser-panel img").length,
739
+ ]
740
+
741
+ button.dispatchEvent(new MouseEvent("click", { bubbles: true }))
742
+ await new Promise<void>((resolve) => {
743
+ const step = () => {
744
+ samples.push(read())
745
+
746
+ if (samples.length < 60 && (samples.at(-1)?.[1] ?? 0) > 0) return requestAnimationFrame(step)
747
+ resolve()
748
+ }
749
+
750
+ requestAnimationFrame(step)
751
+ })
752
+
753
+ return samples
754
+ })
755
+
756
+ expect(frames.filter(([visible, stills]) => visible === "false" && stills === 0)).toEqual([])
757
+ expect(frames.some(([visible, stills]) => visible === "true" && stills > 0)).toBe(true)
758
+ await expect(still).toHaveCount(0)
759
+ })
760
+
761
+ story(
762
+ "freezes on the latest capture when floating content closes and reopens before a capture lands",
763
+ async ({ page }) => {
764
+ const root = page.getByTestId("browser-pane-fixture")
765
+ const popover = root.getByRole("button", { name: "Toggle popover", exact: true })
766
+ const still = root.locator("#browser-panel img")
767
+ const native = root.getByTestId("native-Alpha")
768
+ await page.emulateMedia({ reducedMotion: "reduce" })
769
+ await root.getByRole("button", { name: "Hold capture", exact: true }).click()
770
+ await popover.click()
771
+ await expect(root.getByText("Captures: 1", { exact: true })).toBeVisible()
772
+ await popover.click()
773
+ await expect(page.locator("[data-popper-positioner]")).toHaveCount(0)
774
+ // The pane measures the overlap on the next animation frame; nothing on screen changes while the capture is held.
775
+ await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))))
776
+ await popover.click()
777
+ await expect(root.getByText("Captures: 2", { exact: true })).toBeVisible()
778
+
779
+ // Both captures land in order; the first one belongs to the cover that already closed.
780
+ await root.getByRole("button", { name: "Release capture", exact: true }).click()
781
+ await expect(native).toHaveAttribute("data-visible", "false")
782
+ await expect(still).toBeVisible()
783
+ // The fixture draws each capture a pixel wider: the second one is 5 pixels wide.
784
+ await expect(still).toHaveJSProperty("naturalWidth", 5)
785
+ },
786
+ )
787
+
788
+ story("keeps a still of the page under an open dialog instead of blanking the pane", async ({ page }) => {
789
+ const root = page.getByTestId("browser-pane-fixture")
790
+ const still = root.locator("#browser-panel img")
791
+ const native = root.getByTestId("native-Alpha")
792
+ const toggle = root.getByRole("button", { name: "Toggle dialog", exact: true })
793
+ await root.getByRole("button", { name: "Hold capture", exact: true }).click()
794
+
795
+ // Read in the same task as the click: the page must not hide before its still exists.
796
+ const visible = await toggle.evaluate((element) => {
797
+ element.dispatchEvent(new MouseEvent("click", { bubbles: true }))
798
+
799
+ return document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible")
800
+ })
801
+
802
+ expect(visible).toBe("true")
803
+ await expect(root.getByText("Captures: 1", { exact: true })).toBeVisible()
804
+ await expect(native).toHaveAttribute("data-visible", "true")
805
+ await expect(still).toHaveCount(0)
806
+
807
+ await root.getByRole("button", { name: "Release capture", exact: true }).click()
808
+ await expect(native).toHaveAttribute("data-visible", "false")
809
+ await expect(still).toBeVisible()
810
+
811
+ await toggle.click()
812
+ await expect(native).toHaveAttribute("data-visible", "true")
813
+ await expect(still).toHaveCount(0)
814
+ await expect(root.getByText("Captures: 1", { exact: true })).toBeVisible()
815
+ })
816
+
817
+ story("hides the native page under a dialog even when its still never arrives", async ({ page }) => {
818
+ const root = page.getByTestId("browser-pane-fixture")
819
+ const native = root.getByTestId("native-Alpha")
820
+ const toggle = root.getByRole("button", { name: "Toggle dialog", exact: true })
821
+ await page.clock.install()
822
+ await root.getByRole("button", { name: "Hold capture", exact: true }).click()
823
+ await toggle.click()
824
+ await page.clock.runFor(100)
825
+ await expect(native).toHaveAttribute("data-visible", "true")
826
+
827
+ // The capture never settles: after its timeout the page hides over the box background instead of the dialog.
828
+ await page.clock.runFor(5_000)
829
+ await expect(native).toHaveAttribute("data-visible", "false")
830
+ await expect(root.locator("#browser-panel img")).toHaveCount(0)
831
+
832
+ await toggle.click()
833
+ await page.clock.runFor(100)
834
+ await expect(native).toHaveAttribute("data-visible", "true")
835
+ })
836
+
837
+ story("comments on a picked element over a still of the page", async ({ page }) => {
838
+ const root = page.getByTestId("browser-pane-fixture")
839
+ await root.getByRole("combobox", { name: "Picked element scenario" }).selectOption("zoomed")
840
+ const picker = commentTool(root)
841
+ await picker.click()
842
+ await expect(picker.picking).toBeAttached()
843
+ await expect(picker.button).toHaveAttribute("aria-pressed", "true")
844
+ await expect(root.getByText("Picker: on", { exact: true })).toBeVisible()
845
+ await expect(root.getByText("Session getter reads: 0", { exact: true })).toBeVisible()
846
+ await expect(root.getByRole("status")).toHaveText(
847
+ "Click part of the page to comment on it. Press Escape to cancel.",
848
+ )
849
+
850
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
851
+ await expect(picker.picking).toHaveCount(0)
852
+ await expect(picker.button).toHaveAttribute("aria-pressed", "false")
853
+ const editor = root.locator('[data-slot="browser-comment-editor"] textarea')
854
+ await expect(editor).toBeFocused()
855
+ await expect(editor).toHaveAttribute("placeholder", "Add an optional comment...")
856
+ await expect(editor).toHaveAccessibleName("Comment on this part of the page")
857
+ await expect(root.getByText("Session getter reads: 0", { exact: true })).toBeVisible()
858
+ await expect(root.locator('[data-slot="browser-comment-editor"]')).toContainText("button.primary")
859
+ // The spotlight frames the picked element in surface pixels.
860
+ await expect(root.locator('[data-slot="browser-comment-spotlight"]')).toHaveCSS("left", "38.4px")
861
+ await expect(root.locator('[data-slot="browser-comment-spotlight"]')).toHaveCSS("width", "128px")
862
+ // The native page hides behind its still so the editor can float over it.
863
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "false")
864
+ await expect(root.locator("#browser-panel img")).toBeVisible()
865
+
866
+ await editor.fill("Make this the primary colour")
867
+ await root.getByRole("button", { name: "Add comment", exact: true }).click()
868
+ await expect(root.getByTestId("fixture-comments")).toHaveText("button.primary @e7: Make this the primary colour")
869
+ await expect(root.locator('[data-component="browser-comment"]')).toHaveCount(0)
870
+ await expect(root.getByText("Highlights: clear", { exact: true })).toBeVisible()
871
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
872
+ await expect(root.getByTestId("fixture-comment-metadata")).toContainText('selector \\"main > button.primary\\"')
873
+ await expect(root.getByTestId("fixture-comment-metadata")).toContainText("accessible name")
874
+
875
+ // The pane stays mounted when Beta is routed, and its picker then listens to Beta's page.
876
+ await root.getByRole("button", { name: "Beta", exact: true }).click()
877
+ await expect(root.getByTestId("native-Beta")).toHaveAttribute("data-visible", "true")
878
+ await picker.click()
879
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
880
+ await expect(editor).toBeFocused()
881
+ await editor.fill("Beta's button too")
882
+ await editor.press("Enter")
883
+ await expect(root.getByTestId("fixture-comments").getByRole("listitem")).toHaveText([
884
+ "button.primary @e7: Make this the primary colour",
885
+ "button.primary @e7: Beta's button too",
886
+ ])
887
+ })
888
+
889
+ story("cancels the picker and a comment with Escape", async ({ page }) => {
890
+ const root = page.getByTestId("browser-pane-fixture")
891
+ const picker = commentTool(root)
892
+ await picker.click()
893
+ await expect(picker.picking).toBeAttached()
894
+ await page.keyboard.press("Escape")
895
+ await expect(picker.picking).toHaveCount(0)
896
+ await expect(root.getByText("Picker: off", { exact: true })).toBeVisible()
897
+
898
+ await picker.click()
899
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
900
+ const editor = root.locator('[data-slot="browser-comment-editor"] textarea')
901
+ await expect(editor).toBeFocused()
902
+ await editor.press("Escape")
903
+ await expect(root.locator('[data-component="browser-comment"]')).toHaveCount(0)
904
+ await expect(root.getByTestId("fixture-comments")).toHaveText("")
905
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
906
+ })
907
+
908
+ story("leaves the picker off and Escape to the app when main never answers", async ({ page }) => {
909
+ const root = page.getByTestId("browser-pane-fixture")
910
+ const picker = commentTool(root)
911
+ await root.getByRole("button", { name: "Drop picker requests", exact: true }).click()
912
+ await picker.click()
913
+ await expect(picker.picking).toHaveCount(0)
914
+
915
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
916
+ await address.click()
917
+ await expect(address).toBeFocused()
918
+ await address.press("Escape")
919
+ await expect(address).not.toBeFocused()
920
+ })
921
+
922
+ story("replaces an open page note with the comment for an element picked meanwhile", async ({ page }) => {
923
+ const root = page.getByTestId("browser-pane-fixture")
924
+ await addPage(page, root)
925
+ await expect(root.locator('[data-slot="browser-comment-editor"] textarea')).toBeFocused()
926
+
927
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
928
+ await expect(root.locator('[data-component="browser-comment"]')).toHaveCount(1)
929
+ await expect(root.locator('[data-slot="browser-comment-editor"]')).toContainText("button.primary")
930
+ })
931
+
932
+ story("cleans up the originating session's picker and comment after a session switch", async ({ page }) => {
933
+ const root = page.getByTestId("browser-pane-fixture")
934
+ const picker = commentTool(root)
935
+ await picker.click()
936
+ await expect(root.getByText("Picker Alpha: on", { exact: true })).toBeVisible()
937
+ await root.getByRole("button", { name: "Beta", exact: true }).click()
938
+ await expect(root.getByTestId("native-Beta")).toHaveAttribute("data-visible", "true")
939
+ await expect(root.getByText("Picker Alpha: off", { exact: true })).toBeVisible()
940
+ await expect(picker.picking).toHaveCount(0)
941
+
942
+ await root.getByRole("button", { name: "Alpha", exact: true }).click()
943
+ await picker.click()
944
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
945
+ await expect(root.locator('[data-slot="browser-comment-editor"] textarea')).toBeFocused()
946
+ await root.getByRole("button", { name: "Beta", exact: true }).click()
947
+ await expect(root.locator('[data-component="browser-comment"]')).toHaveCount(0)
948
+ await expect(root.getByText("Highlights: clear", { exact: true })).toBeVisible()
949
+ await expect(root.getByText("Highlight owners: Alpha", { exact: true })).toBeVisible()
950
+ })
951
+
952
+ story("ends the native picker and highlight when the pane unmounts", async ({ page }) => {
953
+ const root = page.getByTestId("browser-pane-fixture")
954
+ const picker = commentTool(root)
955
+ await picker.click()
956
+ await expect(root.getByText("Picker: on", { exact: true })).toBeVisible()
957
+ await root.getByRole("button", { name: "Unmount pane", exact: true }).click()
958
+ await expect(root.locator("#browser-panel")).toHaveCount(0)
959
+ await expect(root.getByText("Picker: off", { exact: true })).toBeVisible()
960
+
961
+ await root.getByRole("button", { name: "Alpha", exact: true }).click()
962
+ await picker.click()
963
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
964
+ await expect(root.locator('[data-slot="browser-comment-editor"] textarea')).toBeFocused()
965
+ await root.getByRole("button", { name: "Unmount pane", exact: true }).click()
966
+ await expect(root.locator("#browser-panel")).toHaveCount(0)
967
+ await expect(root.getByText("Highlights: clear", { exact: true })).toBeVisible()
968
+ })
969
+
970
+ story("keeps a comment draft but drops its ref when the page navigates", async ({ page }) => {
971
+ const root = page.getByTestId("browser-pane-fixture")
972
+ await commentTool(root).click()
973
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
974
+ const editor = root.locator('[data-slot="browser-comment-editor"] textarea')
975
+ await editor.fill("Still misaligned after the reload")
976
+ await root.getByRole("button", { name: "Load current page", exact: true }).click()
977
+ await expect(editor).toHaveValue("Still misaligned after the reload")
978
+ await editor.press("Enter")
979
+ await expect(root.getByTestId("fixture-comments")).toHaveText(
980
+ "button.primary (no ref): Still misaligned after the reload",
981
+ )
982
+ })
983
+
984
+ story("grows the compact comment upward without flipping and keeps its actions inside the page", async ({ page }) => {
985
+ const root = page.getByTestId("browser-pane-fixture")
986
+ await root.getByRole("combobox", { name: "Picked element scenario" }).selectOption("low")
987
+ await commentTool(root).click()
988
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
989
+ const editor = root.locator('[data-slot="browser-comment-editor"]')
990
+ const field = editor.locator("textarea")
991
+ await expect(editor).toHaveCSS("width", "320px")
992
+ await expect(field).toBeFocused()
993
+ await page.evaluate(() => document.fonts.ready.then(() => undefined))
994
+ const opening = await editor.boundingBox()
995
+
996
+ if (!opening) throw new Error("Missing opening annotation")
997
+ await field.fill("A line of feedback\n".repeat(6))
998
+ await expect(field).toHaveCSS("height", "140px")
999
+ // The field lays out before ResizeObserver repositions its parent.
1000
+ await expect
1001
+ .poll(async () => {
1002
+ const grown = await editor.boundingBox()
1003
+
1004
+ return !!grown && grown.y < opening.y && Math.abs(grown.y + grown.height - opening.y - opening.height) < 0.5
1005
+ })
1006
+ .toBe(true)
1007
+ await field.fill("A line of feedback\n".repeat(30))
1008
+ await expect(field).toHaveCSS("height", "160px")
1009
+ expect(await field.evaluate((element) => element.scrollHeight > element.clientHeight)).toBe(true)
1010
+ await expect
1011
+ .poll(async () => {
1012
+ const surface = await root.locator('[data-component="browser-comment"]').boundingBox()
1013
+ const box = await editor.boundingBox()
1014
+
1015
+ return !!surface && !!box && box.y >= surface.y && box.y + box.height <= surface.y + surface.height
1016
+ })
1017
+ .toBe(true)
1018
+ const submit = editor.getByRole("button", { name: "Add comment", exact: true })
1019
+ await submit.scrollIntoViewIfNeeded()
1020
+ await expect(submit).toBeInViewport()
1021
+ // Near the surface's top, growth stops at the opening bottom rather than pushing the card down.
1022
+ await field.press("Escape")
1023
+ await root.getByRole("combobox", { name: "Picked element scenario" }).selectOption("default")
1024
+ await commentTool(root).click()
1025
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
1026
+ await expect(field).toBeFocused()
1027
+ const nearTop = await editor.boundingBox()
1028
+
1029
+ if (!nearTop) throw new Error("Missing near-top annotation")
1030
+ await field.fill("A line of feedback\n".repeat(30))
1031
+ await expect
1032
+ .poll(() => field.evaluate((element) => element.clientHeight < 160 && element.scrollHeight > element.clientHeight))
1033
+ .toBe(true)
1034
+ await expect
1035
+ .poll(async () => {
1036
+ const box = await editor.boundingBox()
1037
+
1038
+ return !!box && Math.abs(box.y + box.height - nearTop.y - nearTop.height) < 0.5
1039
+ })
1040
+ .toBe(true)
1041
+ // A narrow, short pane still keeps the compact editor and action within its surface.
1042
+ await root.locator("#browser-panel").evaluate((element) => {
1043
+ const container = element.parentElement
1044
+
1045
+ if (!container) throw new Error("Missing pane container")
1046
+ container.style.width = "280px"
1047
+ container.style.height = "150px"
1048
+ })
1049
+ await expect(editor).toHaveCSS("width", "262px")
1050
+ await expect
1051
+ .poll(async () => {
1052
+ const surface = await root.locator('[data-component="browser-comment"]').boundingBox()
1053
+ const box = await editor.boundingBox()
1054
+
1055
+ return !!surface && !!box && box.y >= surface.y && box.y + box.height <= surface.y + surface.height
1056
+ })
1057
+ .toBe(true)
1058
+ await expect(submit).toBeInViewport()
1059
+ })
1060
+
1061
+ story(
1062
+ "wraps the selector, attaches elements without comments, and cancels only empty drafts on clickaway",
1063
+ async ({ page }) => {
1064
+ const root = page.getByTestId("browser-pane-fixture")
1065
+ const scenario = root.getByRole("combobox", { name: "Picked element scenario" })
1066
+ const picker = commentTool(root)
1067
+ const editor = root.locator('[data-slot="browser-comment-editor"]')
1068
+ const overlay = root.locator('[data-component="browser-comment"]')
1069
+ await scenario.selectOption("long")
1070
+ await root.evaluate((element) => element.setAttribute("dir", "rtl"))
1071
+ await picker.click()
1072
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
1073
+ const preview = editor.locator('[data-slot="line-comment-v2-preview"] [dir="ltr"]')
1074
+ const selector = `main > section[data-label="إعدادات"] > ${".nested-selector".repeat(24)} > button.primary`
1075
+ await expect(preview).toHaveText(selector)
1076
+ await expect(preview).toHaveAttribute("dir", "ltr")
1077
+ await expect(preview).toHaveCSS("unicode-bidi", "isolate")
1078
+ await expect(preview).toHaveCSS("-webkit-line-clamp", "2")
1079
+ await expect(preview).toHaveCSS("height", "40px")
1080
+ await preview.hover()
1081
+ await expect(page.getByRole("tooltip")).toHaveText(selector)
1082
+ await editor.locator("textarea").press("Enter")
1083
+ await expect(overlay).toHaveCount(0)
1084
+ const comments = root.getByTestId("fixture-comments").getByRole("listitem")
1085
+ await expect(comments).toHaveText(["button.primary @e7:"])
1086
+
1087
+ await scenario.selectOption("default")
1088
+ await picker.click()
1089
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
1090
+ await editor.getByRole("button", { name: "Add to session", exact: true }).click()
1091
+ await expect(overlay).toHaveCount(0)
1092
+ await expect(comments).toHaveText(["button.primary @e7:", "button.primary @e7:"])
1093
+ expect(JSON.parse(await root.getByTestId("fixture-comment-metadata").innerText())).toEqual(
1094
+ [selector, "main > button.primary"].map((value) =>
1095
+ expect.objectContaining({
1096
+ type: "note",
1097
+ label: "button.primary",
1098
+ title: value,
1099
+ subtitle: "Browser annotation",
1100
+ comment: "",
1101
+ subject: `the "button.primary" element in browser tab tab_11111111-1111-1111-1111-111111111111 at https://alpha.example/ (role button; accessible name "Save changes"; selector ${JSON.stringify(value)})`,
1102
+ live: {
1103
+ href: "tab_11111111-1111-1111-1111-111111111111#e7",
1104
+ subject: `the "button.primary" element in browser tab tab_11111111-1111-1111-1111-111111111111 at https://alpha.example/ (role button; accessible name "Save changes"; selector ${JSON.stringify(value)}; browser ref @e7, usable as ref in any browser tool including browser.evaluate until the page navigates)`,
1105
+ },
1106
+ }),
1107
+ ),
1108
+ )
1109
+
1110
+ await scenario.selectOption("fallback")
1111
+ await picker.click()
1112
+ await root.getByRole("button", { name: "Pick element", exact: true }).click()
1113
+ await expect(preview).toHaveText("button.primary")
1114
+ await editor.locator("textarea").fill("Keep this feedback")
1115
+ await overlay.click({ position: { x: 620, y: 290 } })
1116
+ await expect(editor.locator("textarea")).toHaveValue("Keep this feedback")
1117
+ await editor.locator("textarea").fill("")
1118
+ await overlay.click({ position: { x: 620, y: 290 } })
1119
+ await expect(overlay).toHaveCount(0)
1120
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1121
+ await expect(comments).toHaveText(["button.primary @e7:", "button.primary @e7:"])
1122
+ },
1123
+ )
1124
+
1125
+ story("shows the empty state over a blank native page and restores navigation", async ({ page }) => {
1126
+ const root = page.getByTestId("browser-pane-fixture")
1127
+ await root.getByRole("button", { name: "Blank page", exact: true }).click()
1128
+ await expect(root.getByText("Open a page", { exact: true })).toBeVisible()
1129
+ await expect(root.getByText("Preview your app, read docs, or browse the web.", { exact: true })).toBeVisible()
1130
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "false")
1131
+ await expect(root.getByRole("button", { name: "Reload", exact: true })).toBeDisabled()
1132
+
1133
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1134
+ await address.fill("https://example.com/")
1135
+ await expect(root.getByText("Open a page", { exact: true })).toBeVisible()
1136
+ await address.press("Enter")
1137
+ await expect(address).not.toBeFocused()
1138
+ await expect(root.getByText("Open a page", { exact: true })).toBeHidden()
1139
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1140
+ await expect(root.getByRole("button", { name: "Reload", exact: true })).toBeEnabled()
1141
+ })
1142
+
1143
+ story("keeps Stop available and hides the empty state while a blank page loads", async ({ page }) => {
1144
+ const root = page.getByTestId("browser-pane-fixture")
1145
+ await root.getByRole("button", { name: "Loading page", exact: true }).click()
1146
+ await expect(root.getByText("Open a page", { exact: true })).toBeHidden()
1147
+ await root.getByRole("button", { name: "Stop", exact: true }).click()
1148
+ await expect(root.getByText("Open a page", { exact: true })).toBeVisible()
1149
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "false")
1150
+ })
1151
+
1152
+ story("keeps the submitted URL visible until the browser reports navigation", async ({ page }) => {
1153
+ const root = page.getByTestId("browser-pane-fixture")
1154
+ await root.getByRole("button", { name: "Blank page", exact: true }).click()
1155
+ await root.getByRole("button", { name: "Delay navigation", exact: true }).click()
1156
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1157
+ await address.fill("https://example.com/")
1158
+ await address.press("Enter")
1159
+ await expect(address).not.toBeFocused()
1160
+ await expect(address).toHaveValue("https://example.com/")
1161
+ await expect(root.getByText("Open a page", { exact: true })).toBeHidden()
1162
+
1163
+ // Focusing and leaving the field before the browser reports keeps the submitted address.
1164
+ await address.focus()
1165
+ await expect(address).toHaveValue("https://example.com/")
1166
+ await address.press("Escape")
1167
+ await expect(address).not.toBeFocused()
1168
+ await expect(address).toHaveValue("https://example.com/")
1169
+ await expect(root.getByText("Open a page", { exact: true })).toBeHidden()
1170
+
1171
+ await root.getByRole("button", { name: "Complete navigation", exact: true }).click()
1172
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1173
+ await expect(address).toHaveValue("https://example.com/")
1174
+
1175
+ await address.fill("https://unsubmitted.example/")
1176
+ await root.getByRole("button", { name: "Delay navigation", exact: true }).click()
1177
+ await expect(address).toHaveValue("https://example.com/")
1178
+ })
1179
+
1180
+ story("restores the current URL each time the same submitted navigation is blocked", async ({ page }) => {
1181
+ const root = page.getByTestId("browser-pane-fixture")
1182
+ await root.getByRole("button", { name: "Delay navigation", exact: true }).click()
1183
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1184
+
1185
+ for (const submission of [1, 2]) {
1186
+ await story.step(`blocked submission ${submission}`, async () => {
1187
+ await address.fill("https://blocked.example/")
1188
+ await address.press("Enter")
1189
+ await expect(address).toHaveValue("https://blocked.example/")
1190
+ await root.getByRole("button", { name: "Block navigation", exact: true }).click()
1191
+ await expect(root.getByRole("alert")).toHaveText("Only web pages can open here.")
1192
+ await expect(address).toHaveValue("https://alpha.example/")
1193
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1194
+ })
1195
+ }
1196
+ })
1197
+
1198
+ story("explains why a typed address cannot open instead of searching for it", async ({ page }) => {
1199
+ const root = page.getByTestId("browser-pane-fixture")
1200
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1201
+
1202
+ for (const [typed, reason] of [
1203
+ ["ftp://example.com", "Only web pages can open here."],
1204
+ ["https://user:pass@example.com", "Addresses with a user name or password can't open here."],
1205
+ ]) {
1206
+ await address.fill(typed)
1207
+ await address.press("Enter")
1208
+ await expect(root.getByRole("alert")).toHaveText(reason)
1209
+ await expect(address).toHaveValue("https://alpha.example/")
1210
+ }
1211
+ })
1212
+
1213
+ story("shows a themed failure state for only the failed tab and allows retry", async ({ page }) => {
1214
+ const root = page.getByTestId("browser-pane-fixture")
1215
+ await root.getByRole("button", { name: "Failed page", exact: true }).click()
1216
+ // The page area alone explains a load that failed: what happened in plain words, what to do, and Chromium's code
1217
+ // small under it. Nothing is raised above the page beside it.
1218
+ const failure = root.locator('[data-component="browser-failure"]')
1219
+ await expect(failure.getByRole("heading", { name: "This site can't be reached", exact: true })).toBeVisible()
1220
+ await expect(failure.getByText("Check the address for typing mistakes. If it is right, the site may be down.", { exact: true })).toBeVisible()
1221
+ await expect(failure.getByText("ERR_CONNECTION_REFUSED", { exact: true })).toBeVisible()
1222
+ await expect(root.getByRole("alert")).toHaveCount(0)
1223
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "false")
1224
+ await expect(root.getByRole("combobox", { name: "Browser address", exact: true })).toHaveValue(
1225
+ "https://alpha.example/",
1226
+ )
1227
+
1228
+ await root.getByRole("button", { name: "Beta", exact: true }).click()
1229
+ await expect(root.getByText("This site can't be reached", { exact: true })).toBeHidden()
1230
+ await expect(root.getByTestId("native-Beta")).toHaveAttribute("data-visible", "true")
1231
+ await root.getByRole("button", { name: "Alpha", exact: true }).click()
1232
+ await expect(root.getByText("This site can't be reached", { exact: true })).toBeVisible()
1233
+
1234
+ await failure.getByRole("button", { name: "Reload", exact: true }).click()
1235
+ await expect(root.getByText("This site can't be reached", { exact: true })).toBeHidden()
1236
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1237
+ })
1238
+
1239
+ story("a command that did not work says what was tried above the page and offers it again", async ({ page }) => {
1240
+ const root = page.getByTestId("browser-pane-fixture")
1241
+ await root.getByRole("button", { name: "Fail next command", exact: true }).click()
1242
+ await root.getByRole("button", { name: "Reload", exact: true }).click()
1243
+ const notice = root.locator('[data-component="browser-failure-bar"]')
1244
+ // Main's own message never reaches the person, and neither does the app's generic failure text.
1245
+ await expect(notice.getByRole("alert")).toHaveText("Couldn't reload this page.")
1246
+ await expect(root.getByText("Request failed", { exact: true })).toHaveCount(0)
1247
+ await expect(root.getByText("did not finish starting")).toHaveCount(0)
1248
+ // The page stays where it was; trying again sends the same command, which takes the notice away.
1249
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1250
+ await notice.getByRole("button", { name: "Try again", exact: true }).click()
1251
+ await expect(notice).toHaveCount(0)
1252
+ })
1253
+
1254
+ story("returns a failed tab to the empty state when an empty URL is submitted", async ({ page }) => {
1255
+ const root = page.getByTestId("browser-pane-fixture")
1256
+ await root.getByRole("button", { name: "Failed page", exact: true }).click()
1257
+ await expect(root.getByText("This site can't be reached", { exact: true })).toBeVisible()
1258
+ await root.getByRole("button", { name: "Delay navigation", exact: true }).click()
1259
+
1260
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1261
+ await address.fill("")
1262
+ await address.press("Enter")
1263
+ await expect(address).not.toBeFocused()
1264
+ await expect(address).toHaveValue("")
1265
+ await root.getByRole("button", { name: "Load current page", exact: true }).click()
1266
+ await expect(root.getByRole("button", { name: "Stop", exact: true })).toBeEnabled()
1267
+ await root.getByRole("button", { name: "Complete navigation", exact: true }).click()
1268
+ await expect(root.getByText("This site can't be reached", { exact: true })).toBeHidden()
1269
+ await expect(root.getByText("Open a page", { exact: true })).toBeVisible()
1270
+ await expect(root.getByRole("button", { name: "Reload", exact: true })).toBeDisabled()
1271
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "false")
1272
+ })
1273
+
1274
+ story("selects the full URL when the address field gains focus", async ({ page }) => {
1275
+ const root = page.getByTestId("browser-pane-fixture")
1276
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1277
+ await address.click()
1278
+ await expect(address).toHaveJSProperty("selectionStart", 0)
1279
+ await expect(address).toHaveJSProperty("selectionEnd", "https://alpha.example/".length)
1280
+ await address.pressSequentially("https://example.com/")
1281
+ await expect(address).toHaveValue("https://example.com/")
1282
+ await address.press("Enter")
1283
+ await expect(address).not.toBeFocused()
1284
+ await address.focus()
1285
+ await expect(address).toHaveJSProperty("selectionStart", 0)
1286
+ await expect(address).toHaveJSProperty("selectionEnd", "https://example.com/".length)
1287
+ // A click on the focused field places the caret instead of selecting the URL again.
1288
+ await address.press("ArrowRight")
1289
+ await address.click()
1290
+ await expect
1291
+ .poll(() => address.evaluate((input: HTMLInputElement) => input.selectionStart === input.selectionEnd))
1292
+ .toBe(true)
1293
+ })
1294
+
1295
+ story("draws only the address at rest when focus leaves the window with the field selected", async ({ page }) => {
1296
+ const root = page.getByTestId("browser-pane-fixture")
1297
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1298
+ await address.click()
1299
+ // Chromium blurs the field when the window or the native page takes focus, and the field keeps its full selection.
1300
+ await address.evaluate((input: HTMLInputElement) => {
1301
+ input.dispatchEvent(new FocusEvent("blur"))
1302
+ input.select()
1303
+ })
1304
+ await expect(address).toHaveJSProperty("selectionStart", 0)
1305
+ await expect(address).toHaveJSProperty("selectionEnd", "https://alpha.example/".length)
1306
+ await page.mouse.move(0, 0)
1307
+
1308
+ // Computed ::selection styles do not report the default highlight, so compare the input's own paint with the
1309
+ // selection collapsed. The drawn address is hidden: a selection layer can change how its text is antialiased.
1310
+ await page.addStyleTag({ content: '[data-slot="browser-address-display"] { visibility: hidden }' })
1311
+ const field = root.locator('[data-component="browser-address"]')
1312
+ const selected = (await field.screenshot()).toString("base64")
1313
+ await address.evaluate((input: HTMLInputElement) => input.setSelectionRange(0, 0))
1314
+ const collapsed = (await field.screenshot()).toString("base64")
1315
+
1316
+ const changed = await page.evaluate(
1317
+ async (shots) => {
1318
+ const pixels = await Promise.all(
1319
+ shots.map(async (data) => {
1320
+ const image = new Image()
1321
+ image.src = `data:image/png;base64,${data}`
1322
+ await image.decode()
1323
+ const canvas = new OffscreenCanvas(image.width, image.height)
1324
+ canvas.getContext("2d")?.drawImage(image, 0, 0)
1325
+
1326
+ return canvas.getContext("2d")?.getImageData(0, 0, image.width, image.height).data ?? new Uint8ClampedArray()
1327
+ }),
1328
+ )
1329
+
1330
+ return Array.from({ length: (pixels[0]?.length ?? 0) / 4 }, (_, index) => index * 4).filter((offset) =>
1331
+ [0, 1, 2].some((channel) => pixels[0]?.[offset + channel] !== pixels[1]?.[offset + channel]),
1332
+ ).length
1333
+ },
1334
+ [selected, collapsed],
1335
+ )
1336
+
1337
+ expect(changed).toBe(0)
1338
+ })
1339
+
1340
+ story("keeps the current page visible while a submitted URL loads", async ({ page }) => {
1341
+ const root = page.getByTestId("browser-pane-fixture")
1342
+ await root.getByRole("button", { name: "Delay navigation", exact: true }).click()
1343
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1344
+ await address.fill("https://example.com/")
1345
+ await address.press("Enter")
1346
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1347
+ await expect(address).toHaveValue("https://example.com/")
1348
+
1349
+ await root.getByRole("button", { name: "Load current page", exact: true }).click()
1350
+ await expect(root.getByRole("button", { name: "Stop", exact: true })).toBeEnabled()
1351
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1352
+ await root.getByRole("button", { name: "Complete navigation", exact: true }).click()
1353
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1354
+ await expect(address).toHaveValue("https://example.com/")
1355
+ })
1356
+
1357
+ story("keeps the current page and restores its URL when an empty address is submitted", async ({ page }) => {
1358
+ const root = page.getByTestId("browser-pane-fixture")
1359
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1360
+ await address.fill("")
1361
+ await address.press("Enter")
1362
+ await expect(address).not.toBeFocused()
1363
+ await expect(address).toHaveValue("https://alpha.example/")
1364
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1365
+ await expect(root.getByText("Open a page", { exact: true })).toBeHidden()
1366
+ await expect(root.getByRole("button", { name: "Reload", exact: true })).toBeEnabled()
1367
+ })
1368
+
1369
+ story("lists the typed text with visited pages, and opens the first row: the page the typing completes, else the text", async ({ page }) => {
1370
+ const root = page.getByTestId("browser-pane-fixture")
1371
+ await root.getByRole("button", { name: "Seed history", exact: true }).click()
1372
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1373
+ await address.click()
1374
+ await address.pressSequentially("localhost")
1375
+ const options = page.getByRole("listbox", { name: "Suggestions" }).getByRole("option")
1376
+ // The page whose address begins with the text is first and chosen; the search for the text follows it.
1377
+ await expect(options).toHaveCount(2)
1378
+ await expect(options.first()).toHaveAttribute("aria-selected", "true")
1379
+ await expect(address).toHaveValue("localhost:5173/settings")
1380
+ // Arrow keys that pick IME candidates leave the list alone.
1381
+ await address.dispatchEvent("keydown", { key: "ArrowDown", isComposing: true })
1382
+ await expect(options.first()).toHaveAttribute("aria-selected", "true")
1383
+ await address.press("Enter")
1384
+ await expect(address).toHaveValue("http://localhost:5173/settings")
1385
+
1386
+ // Words that only match a page list it below the search for them, which is first and chosen; a step down opens it.
1387
+ await address.click()
1388
+ await address.pressSequentially("color format")
1389
+ await expect(options).toHaveCount(2)
1390
+ await expect(options.first()).toHaveAttribute("aria-selected", "true")
1391
+ await expect(options.first()).toHaveText("color format-Google Search")
1392
+ await address.press("Enter")
1393
+ await expect(address).toHaveValue("https://www.google.com/search?q=color%20format")
1394
+ await address.click()
1395
+ await address.pressSequentially("color format")
1396
+ await address.press("ArrowDown")
1397
+ await expect(options.nth(1)).toHaveAttribute("aria-selected", "true")
1398
+ await address.press("Enter")
1399
+ await expect(address).toHaveValue("https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Colors/Color_format_converter")
1400
+ })
1401
+
1402
+ story("finds imported pages by their words, completes the site a host begins, and forgets a page on Shift+Delete", async ({ page }) => {
1403
+ const root = page.getByTestId("browser-pane-fixture")
1404
+ await root.getByRole("button", { name: "Seed imported history", exact: true }).click()
1405
+ await expect(root.getByText("Main history: 59", { exact: true })).toBeVisible()
1406
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1407
+ const options = page.getByRole("listbox", { name: "Suggestions" }).getByRole("option")
1408
+ const addresses = () => options.locator('[data-slot="browser-page-row-url"]')
1409
+
1410
+ // Main answers after the field shows the text: under the search for it, the list fills with the best matches of 59
1411
+ // pages, the most visited first, and a word found only inside another ("prune") last.
1412
+ await address.click()
1413
+ await address.pressSequentially("rune")
1414
+ await expect(addresses()).toHaveText([
1415
+ "Google Search",
1416
+ "github.com/anomalyco/rune-desktop",
1417
+ "github.com/anomalyco/rune-desktop/pulls",
1418
+ "docs.rune.example/guide/getting-started",
1419
+ "github.com/anomalyco/rune-desktop/issues/128",
1420
+ "github.com/runelabs/rune-lang",
1421
+ ])
1422
+ await expect(options.nth(1).locator("mark")).toHaveText(["rune", "Rune", "rune"])
1423
+ // The search row is the typed text itself, so it draws no match.
1424
+ await expect(options.first().locator("mark")).toHaveCount(0)
1425
+ await expect(options.first()).toHaveAttribute("aria-selected", "true")
1426
+ // Imported pages have no icon of their own: the globe stands in, and none is fetched.
1427
+ await expect(options.locator("img")).toHaveCount(0)
1428
+
1429
+ // Both words, in either order, wherever each starts a part of the address.
1430
+ await address.fill("")
1431
+ await address.pressSequentially("desk anom")
1432
+ await expect(addresses()).toHaveText([
1433
+ "Google Search",
1434
+ "github.com/anomalyco/rune-desktop",
1435
+ "github.com/anomalyco/rune-desktop/pulls",
1436
+ "github.com/anomalyco/rune-desktop/issues/128",
1437
+ ])
1438
+
1439
+ // Shift+Delete forgets the chosen page, in main's history too; on the typed text's row the key is the field's own.
1440
+ await address.fill("")
1441
+ await address.pressSequentially("rune")
1442
+ await expect(options).toHaveCount(6)
1443
+ await address.press("Shift+Delete")
1444
+ await expect(root.getByText("Main history: 59", { exact: true })).toBeVisible()
1445
+ await address.press("ArrowDown")
1446
+ await address.press("Shift+Delete")
1447
+ // The row that takes its place is the chosen one, and the field shows its address.
1448
+ await expect(addresses().nth(1)).toHaveText("github.com/anomalyco/rune-desktop/pulls")
1449
+ await expect(options.nth(1)).toHaveAttribute("aria-selected", "true")
1450
+ await expect(address).toHaveValue("https://github.com/anomalyco/rune-desktop/pulls")
1451
+ await expect(root.getByText("Main history: 58", { exact: true })).toBeVisible()
1452
+
1453
+ // Text that begins a host completes its site, which Enter opens.
1454
+ await address.fill("")
1455
+ await address.pressSequentially("gith")
1456
+ await expect(addresses().first()).toHaveText("github.com/")
1457
+ await expect(options.first()).toHaveAttribute("aria-selected", "true")
1458
+ await address.press("Enter")
1459
+ await expect(address).toHaveValue("https://github.com/")
1460
+ })
1461
+
1462
+ story("keeps the first row chosen and moves through the list with Chrome's keys", async ({ page }) => {
1463
+ const root = page.getByTestId("browser-pane-fixture")
1464
+ await root.getByRole("button", { name: "Seed imported history", exact: true }).click()
1465
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1466
+ const list = page.getByRole("listbox", { name: "Suggestions" })
1467
+ const options = list.getByRole("option")
1468
+ const addresses = options.locator('[data-slot="browser-page-row-url"]')
1469
+ const selection = () => address.evaluate((input: HTMLInputElement) => input.value.slice(input.selectionStart ?? 0, input.selectionEnd ?? 0))
1470
+ // The places of the chosen rows: always exactly one while the list is open.
1471
+ const chosen = () => options.evaluateAll((rows) => rows.flatMap((row, place) => (row.getAttribute("aria-selected") === "true" ? [place] : [])))
1472
+
1473
+ // The typed text completes to the site: the rest of its address is in the field, selected, and its row is chosen.
1474
+ await address.click()
1475
+ await address.pressSequentially("gith")
1476
+ await expect(address).toHaveValue("github.com")
1477
+ await expect.poll(selection).toBe("ub.com")
1478
+ await expect(addresses.first()).toHaveText("github.com/")
1479
+ await expect(options.nth(1)).toHaveText("gith-Google Search")
1480
+ await expect(options).toHaveCount(6)
1481
+ await expect.poll(chosen).toEqual([0])
1482
+
1483
+ // Backspace removes the completed part only; deleting never completes, so the typed text is first and chosen.
1484
+ await address.press("Backspace")
1485
+ await expect(address).toHaveValue("gith")
1486
+ await expect(options.first()).toHaveText("gith-Google Search")
1487
+ await expect(addresses.nth(1)).toHaveText("github.com/")
1488
+ await expect.poll(chosen).toEqual([0])
1489
+ // The next character completes again, and typing goes on through the selected part.
1490
+ await address.pressSequentially("ub")
1491
+ await expect(address).toHaveValue("github.com")
1492
+ await expect.poll(selection).toBe(".com")
1493
+
1494
+ // Down and Up choose a row and put its text in the field; past either end the choice goes around.
1495
+ await address.press("ArrowDown")
1496
+ await expect(address).toHaveValue("github")
1497
+ await expect.poll(chosen).toEqual([1])
1498
+ await address.press("ArrowUp")
1499
+ await expect(address).toHaveValue("https://github.com")
1500
+ await address.press("ArrowUp")
1501
+ await expect.poll(chosen).toEqual([5])
1502
+ await expect(address).toHaveValue(/^https:\/\/github\.com\/.+/)
1503
+ // Tab moves as Down does while the list is open, and keeps the focus in the field.
1504
+ await address.press("Tab")
1505
+ await expect.poll(chosen).toEqual([0])
1506
+ await address.press("Tab")
1507
+ await expect.poll(chosen).toEqual([1])
1508
+ await expect(address).toBeFocused()
1509
+
1510
+ // Escape undoes one thing at a time: the row's text, the list, the typed text, then the focus.
1511
+ await address.press("Escape")
1512
+ await expect(address).toHaveValue("github.com")
1513
+ await expect.poll(selection).toBe(".com")
1514
+ await expect.poll(chosen).toEqual([0])
1515
+ await address.press("Escape")
1516
+ await expect(list).toBeHidden()
1517
+ await expect(address).toHaveValue("github")
1518
+ await address.press("Escape")
1519
+ await expect(address).toHaveValue("https://alpha.example/")
1520
+ await expect.poll(selection).toBe("https://alpha.example/")
1521
+ await expect(address).toBeFocused()
1522
+ await address.press("Escape")
1523
+ await expect(address).not.toBeFocused()
1524
+
1525
+ // A caret that leaves the end takes the completed address into the text: the page stays first, and nothing is selected.
1526
+ await address.focus()
1527
+ await address.pressSequentially("gith")
1528
+ await expect.poll(selection).toBe("ub.com")
1529
+ await address.press("ArrowRight")
1530
+ await expect(address).toHaveValue("github.com")
1531
+ await expect.poll(selection).toBe("")
1532
+ await expect(addresses.first()).toHaveText("github.com/")
1533
+ await expect(options.nth(1)).toHaveText("github.com-Google Search")
1534
+
1535
+ // A click opens the row it is on, chosen or not.
1536
+ await options.nth(2).click()
1537
+ await expect(address).toHaveValue(/^https:\/\/github\.com\/.+/)
1538
+ await expect(address).not.toBeFocused()
1539
+ })
1540
+
1541
+ story("keeps the address bar working, and says so, while main's history cannot be read or cleared", async ({ page }) => {
1542
+ const root = page.getByTestId("browser-pane-fixture")
1543
+ await root.getByRole("button", { name: "Seed history", exact: true }).click()
1544
+ await root.getByRole("button", { name: "Seed imported history", exact: true }).click()
1545
+ await root.getByRole("button", { name: "History away", exact: true }).click()
1546
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1547
+ const options = page.getByRole("listbox", { name: "Suggestions" }).getByRole("option")
1548
+
1549
+ // Main rejects every question. The list still has the typed text and the window's own last pages.
1550
+ await address.click()
1551
+ await address.pressSequentially("localhost")
1552
+ await expect(options).toHaveCount(2)
1553
+ await expect(address).toHaveValue("localhost:5173/settings")
1554
+ // The imported pages are out of reach, so their words find only the search for them, which Enter opens.
1555
+ await address.fill("")
1556
+ await address.pressSequentially("rune")
1557
+ await expect(options).toHaveText(["rune-Google Search"])
1558
+ await address.press("Enter")
1559
+ await expect(address).toHaveValue("https://www.google.com/search?q=rune")
1560
+
1561
+ // Clearing empties the window's list at once and says that main's history stayed.
1562
+ const clear = async () => {
1563
+ await root.getByRole("button", { name: "Browser options", exact: true }).click()
1564
+ await page.getByRole("menuitem", { name: "More tools", exact: true }).click()
1565
+ await page.getByRole("menuitem", { name: "Clear history", exact: true }).click()
1566
+ }
1567
+
1568
+ await clear()
1569
+ await expect(root.getByText("Couldn't clear the history. Try again.", { exact: true })).toBeVisible()
1570
+ await expect(root.getByText("Main history: 59", { exact: true })).toBeVisible()
1571
+ // The item stays although the window's list is empty: main's history is still there to clear once it is back.
1572
+ await root.getByRole("button", { name: "History away", exact: true }).click()
1573
+ await clear()
1574
+ await expect(root.getByText("Main history: 0", { exact: true })).toBeVisible()
1575
+ })
1576
+
1577
+ story("lists recent pages on a blank tab and opens one", async ({ page }) => {
1578
+ const root = page.getByTestId("browser-pane-fixture")
1579
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
1580
+ await root.getByRole("button", { name: "Seed history", exact: true }).click()
1581
+ await root.getByRole("button", { name: "Blank page", exact: true }).click()
1582
+ await expect(root.getByText("Recent", { exact: true })).toBeVisible()
1583
+ // The globe at the field's start belongs to the field: a click there focuses it.
1584
+ await expect(address).not.toBeFocused()
1585
+ await root.locator('[data-component="browser-address"]').click({ position: { x: 16, y: 14 } })
1586
+ await expect(address).toBeFocused()
1587
+ await address.blur()
1588
+
1589
+ await root.getByRole("button", { name: /^Settings - Preview/ }).click()
1590
+ await expect(address).toHaveValue("http://localhost:5173/settings")
1591
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1592
+ // The opened page owns the field afterwards: an edit that is never submitted shows its URL again.
1593
+ await address.click()
1594
+ await address.fill("unsubmitted")
1595
+ await address.blur()
1596
+ await expect(address).toHaveValue("http://localhost:5173/settings")
1597
+ })
1598
+
1599
+ story("keeps a page note editable beside a tiny viewport and attaches it to the session", async ({ page }) => {
1600
+ const { root, viewport, width, height } = viewportControls(page)
1601
+ await viewport.click()
1602
+ await width.fill("8")
1603
+ await height.fill("8")
1604
+ await expectSize(root.getByTestId("native-Alpha"), 8, 8)
1605
+ await addPage(page, root)
1606
+ const editor = root.locator('[data-slot="browser-comment-editor"] textarea')
1607
+ await editor.click()
1608
+ await editor.fill("Check the header layout")
1609
+ await addPage(page, root)
1610
+ // The menu gives the keyboard back to its button a task after it closes, and would take it from an editor focused
1611
+ // in that task: the Enter below would then open the menu again.
1612
+ await expect(root.getByRole("button", { name: "Browser options", exact: true })).toBeFocused()
1613
+ await expect(editor).toHaveValue("Check the header layout")
1614
+ await editor.press("Enter")
1615
+ await expect(root.getByTestId("fixture-comments").getByRole("listitem")).toHaveText([/: Check the header layout$/])
1616
+ })
1617
+
1618
+ story("adds the whole page to the session and keeps the draft when the button is pressed again", async ({ page }) => {
1619
+ const root = page.getByTestId("browser-pane-fixture")
1620
+ await addPage(page, root)
1621
+ const editor = root.locator('[data-slot="browser-comment-editor"] textarea')
1622
+ await editor.click()
1623
+ await editor.fill("Check the header layout")
1624
+ await addPage(page, root)
1625
+ // As above: the menu's button has the keyboard again before the editor takes it.
1626
+ await expect(root.getByRole("button", { name: "Browser options", exact: true })).toBeFocused()
1627
+ await expect(editor).toHaveValue("Check the header layout")
1628
+ await editor.press("Enter")
1629
+ await expect(root.getByTestId("fixture-comments").getByRole("listitem")).toHaveText([/: Check the header layout$/])
1630
+ })
1631
+
1632
+ story("shows the page's cookies in the site information and clears them", async ({ page }) => {
1633
+ const root = page.getByTestId("browser-pane-fixture")
1634
+ await root.getByRole("button", { name: "Site information", exact: true }).click()
1635
+ const site = page.getByRole("dialog")
1636
+ await site.getByRole("button", { name: "Site settings", exact: true }).click()
1637
+ // The row is "Cookies and site data", so its count needs no more words.
1638
+ await expect(site.getByText("3 cookies", { exact: true })).toBeVisible()
1639
+ await site.getByRole("button", { name: "Clear", exact: true }).click()
1640
+ await expect(site.getByText("0 cookies", { exact: true })).toBeVisible()
1641
+ })
1642
+
1643
+ story("site information opens on the site and its connection, with the rest one step away", async ({ page }) => {
1644
+ const root = page.getByTestId("browser-pane-fixture")
1645
+ await root.getByRole("button", { name: "Site information", exact: true }).click()
1646
+ const site = page.getByRole("dialog")
1647
+ // First: where the person is and whether the connection is private. Nothing about cookies or agents yet.
1648
+ await expect(site).toContainText("alpha.example")
1649
+ await expect(site).toContainText("Connection is secure")
1650
+ await expect(site).not.toContainText(/cookie/i)
1651
+ const settings = site.getByRole("button", { name: "Site settings", exact: true })
1652
+ await settings.click()
1653
+ // Second: everything else, with the way back holding the keyboard.
1654
+ await expect(site.getByRole("button", { name: "Back", exact: true })).toBeFocused()
1655
+ await expect(site.getByText("3 cookies", { exact: true })).toBeVisible()
1656
+ await expect(site).toContainText("You stay signed in.")
1657
+ await expect(site.getByRole("button", { name: "Clear saved files for this site", exact: true })).toBeEnabled()
1658
+ await expect(site).toContainText("Agents you allow can use this page")
1659
+ // Escape steps back one view, then closes.
1660
+ await page.keyboard.press("Escape")
1661
+ await expect(settings).toBeFocused()
1662
+ await expect(site).not.toContainText(/cookie/i)
1663
+ await page.keyboard.press("Escape")
1664
+ await expect(site).toBeHidden()
1665
+ })
1666
+
1667
+ story("says a failed cookie read failed and reads again on retry", async ({ page }) => {
1668
+ const root = page.getByTestId("browser-pane-fixture")
1669
+ await root.getByRole("button", { name: "Fail next site read", exact: true }).click()
1670
+ await root.getByRole("button", { name: "Site information", exact: true }).click()
1671
+ const site = page.getByRole("dialog")
1672
+ await site.getByRole("button", { name: "Site settings", exact: true }).click()
1673
+ await expect(site.getByText("Could not read site data.", { exact: true })).toBeVisible()
1674
+ const retry = site.getByRole("button", { name: "Try again", exact: true })
1675
+ await expect(retry).toBeEnabled()
1676
+ await retry.click()
1677
+ await expect(site.getByText("3 cookies", { exact: true })).toBeVisible()
1678
+ await expect(site.getByRole("button", { name: "Clear", exact: true })).toBeEnabled()
1679
+ })
1680
+
1681
+ story("Browser options keeps its original hand-off target until dismissed", async ({ page }) => {
1682
+ const root = page.getByTestId("browser-pane-fixture")
1683
+ await root.getByRole("button", { name: "Browser options" }).click()
1684
+ await page.getByRole("menuitem", { name: "More tools", exact: true }).click()
1685
+ const handoff = page.getByRole("menuitem", { name: "Open in default browser" })
1686
+ await expect(handoff).toBeVisible()
1687
+ await root.getByRole("button", { name: "Blank page", includeHidden: true }).dispatchEvent("click")
1688
+ await expect(handoff).toBeVisible()
1689
+ await handoff.click()
1690
+ await expect(root.getByText("External:", { exact: true })).toBeAttached()
1691
+ })
1692
+
1693
+ story("Browser options says why a disabled hand-off is unavailable", async ({ page }) => {
1694
+ const root = page.getByTestId("browser-pane-fixture")
1695
+ await root.getByRole("button", { name: "Blank page", includeHidden: true }).dispatchEvent("click")
1696
+ await root.getByRole("button", { name: "Browser options" }).click()
1697
+ await page.getByRole("menuitem", { name: "More tools", exact: true }).click()
1698
+ await expect(page.getByRole("menuitem", { name: "Open in default browser" })).toBeDisabled()
1699
+ await expect(page.getByRole("menu").getByText("This page can't open in your default browser", { exact: true })).toBeVisible()
1700
+ })
1701
+
1702
+ function viewportControls(page: Page) {
1703
+ const root = page.getByTestId("browser-pane-fixture")
1704
+
1705
+ const controls = root.getByRole("region", { name: "Viewport", exact: true })
1706
+ const options = root.getByRole("button", { name: "Browser options", exact: true })
1707
+
1708
+ return {
1709
+ root,
1710
+ controls,
1711
+ // The toolbar's toggle is under Browser options > More tools. The menu gives the keyboard back to its button a
1712
+ // task after it closes, so the click waits for that: a control focused before then would lose the keyboard.
1713
+ viewport: {
1714
+ click: async () => {
1715
+ await options.click()
1716
+ await page.getByRole("menuitem", { name: "More tools", exact: true }).click()
1717
+ await page.getByRole("menuitem", { name: /^Toggle browser toolbar/ }).click()
1718
+ await expect(options).toBeFocused()
1719
+ },
1720
+ },
1721
+ preset: controls.getByRole("button", { name: "Device preset", exact: true }),
1722
+ option: (name: string) => page.getByRole("menuitemradio", { name, exact: true }),
1723
+ moreDevices: page.getByRole("menuitem", { name: "More devices", exact: true }),
1724
+ width: controls.getByLabel("Viewport width in CSS pixels", { exact: true }),
1725
+ height: controls.getByLabel("Viewport height in CSS pixels", { exact: true }),
1726
+ scale: controls.getByRole("button", { name: "Preview scale", exact: true }),
1727
+ rotate: controls.getByRole("button", { name: "Rotate viewport", exact: true }),
1728
+ }
1729
+ }
1730
+
1731
+ function resizePane(root: Locator, width: number) {
1732
+ return root.locator("#browser-panel").evaluate((pane, width) => {
1733
+ if (!pane.parentElement) throw new Error("Missing pane container")
1734
+ pane.parentElement.style.width = `${width}px`
1735
+ }, width)
1736
+ }
1737
+
1738
+ async function expectSize(native: Locator, width: number, height: number) {
1739
+ await expect(native).toHaveAttribute("data-width", String(width))
1740
+ await expect(native).toHaveAttribute("data-height", String(height))
1741
+ }
1742
+
1743
+ story("zooms the page from the browser options in view and keeps its zoom in the address field", async ({ page }) => {
1744
+ const { root, controls, viewport, preset, option, scale } = viewportControls(page)
1745
+ await viewport.click()
1746
+ await preset.click()
1747
+ await option("Samsung Galaxy S26").click()
1748
+ await expect(preset).toHaveText("Samsung Galaxy S26")
1749
+ const options = root.getByRole("button", { name: "Browser options", exact: true })
1750
+ await options.click()
1751
+ await page.getByRole("menuitem", { name: /^Zoom in/ }).click()
1752
+ await expect(root.getByText("Zoom: 110", { exact: true })).toBeVisible()
1753
+ await expect(controls.getByRole("status")).toContainText("The page is using the pane size because page zoom changed.")
1754
+ await expect(preset).toBeDisabled()
1755
+ await expect(preset).toHaveText("Responsive")
1756
+ await expect(scale).toBeDisabled()
1757
+ // The menu covered the page with a still; it closes so the zoomed page shows at once.
1758
+ await expect(page.getByRole("menu")).toBeHidden()
1759
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1760
+
1761
+ const zoom = root.getByRole("button", { name: "110%", exact: true })
1762
+ await expect(zoom).toBeVisible()
1763
+ await zoom.click()
1764
+ await expect(root.getByText("Zoom: 100", { exact: true })).toBeVisible()
1765
+ await expect(zoom).toBeHidden()
1766
+ await expect(preset).toBeEnabled()
1767
+ })
1768
+
1769
+ story("restores the full pane when the toolbar closes and keeps the selected device on reopen", async ({ page }) => {
1770
+ const { root, controls, viewport, preset, option, moreDevices, width, height } = viewportControls(page)
1771
+
1772
+ const native = root.getByTestId("native-Alpha")
1773
+
1774
+ const fullWidth = await native.getAttribute("data-width")
1775
+
1776
+ const fullHeight = await native.getAttribute("data-height")
1777
+
1778
+ if (!fullWidth || !fullHeight) throw new Error("Missing native page bounds")
1779
+
1780
+ await viewport.click()
1781
+ await preset.press("ArrowDown")
1782
+ const menu = page.getByRole("menu")
1783
+ await expect(option("Responsive")).toBeChecked()
1784
+ await expect(menu.getByRole("menuitemradio")).toHaveText([
1785
+ "Responsive",
1786
+ "Samsung Galaxy S26",
1787
+ "iPhone 18 Pro",
1788
+ "iPad / iPad Air 11″",
1789
+ "Laptop",
1790
+ "Desktop",
1791
+ ])
1792
+ // The rows show before the menu has the keyboard: until its first row is focused, a key still goes to the trigger.
1793
+ await expect(option("Responsive")).toBeFocused()
1794
+ await page.keyboard.press("End")
1795
+ await expect(moreDevices).toBeFocused()
1796
+ await page.keyboard.press("ArrowRight")
1797
+ const mini = option("iPad mini")
1798
+ await mini.click()
1799
+ await expect(preset).toHaveText("iPad mini")
1800
+ await expect(preset).toBeFocused()
1801
+ await expect(native).not.toHaveAttribute("data-width", fullWidth)
1802
+ await viewport.click()
1803
+ await expect(controls).toBeHidden()
1804
+ await expect(native).toHaveAttribute("data-width", fullWidth)
1805
+ await expect(native).toHaveAttribute("data-height", fullHeight)
1806
+ await expect(root.getByRole("separator", { name: "Resize viewport width" })).toBeHidden()
1807
+ await viewport.click()
1808
+ await expect(preset).toHaveText("iPad mini")
1809
+ await expect(width).toHaveValue("756")
1810
+ await expect(height).toHaveValue("1158")
1811
+ // Matching the preset's dimensions by hand still counts as Custom.
1812
+ await width.fill("700")
1813
+ await width.fill("756")
1814
+ await expect(preset).toHaveText("Custom")
1815
+ await preset.click()
1816
+ await expect(option("Custom")).toBeChecked()
1817
+ await moreDevices.hover()
1818
+ await expect(mini).not.toBeChecked()
1819
+ })
1820
+
1821
+ story("fits an exact viewport while resizing and rejects invalid edits", async ({ page }) => {
1822
+ const { root, viewport, preset, option, scale, width, height } = viewportControls(page)
1823
+
1824
+ const native = root.getByTestId("native-Alpha")
1825
+ await viewport.click()
1826
+ await expect(width).toHaveValue("624")
1827
+ await width.fill("1248")
1828
+ await expect(scale).toHaveText("Fit - 50%")
1829
+ await expect(width).toBeFocused()
1830
+ await height.fill("5")
1831
+ // Chromium needs whole native pixels: round the fitted height up.
1832
+ await expectSize(native, 624, 3)
1833
+ await expect(height).toBeFocused()
1834
+
1835
+ await resizePane(root, 328)
1836
+ await expect(scale).toHaveText("Fit - 25%")
1837
+ await expectSize(native, 312, 2)
1838
+ await expect(width).toHaveValue("1248")
1839
+ await expect(height).toHaveValue("5")
1840
+
1841
+ for (const edit of ["", "4097"]) {
1842
+ await width.fill(edit)
1843
+ await expect(width).toHaveValue(edit)
1844
+ await expect(width).toHaveAttribute("aria-invalid", "true")
1845
+ await expect(width).toHaveAccessibleDescription("Use whole numbers from 1 to 4096 for width and height.")
1846
+ await expectSize(native, 312, 2)
1847
+ }
1848
+
1849
+ await width.blur()
1850
+ await expect(width).toHaveValue("1248")
1851
+ await expect(width).not.toHaveAttribute("aria-invalid", "true")
1852
+ await preset.click()
1853
+ await option("Responsive").click()
1854
+ await expect(preset).toHaveText("Responsive")
1855
+ await expect(width).toHaveValue("312")
1856
+ await expect(scale).toHaveText("Fit - 100%")
1857
+ await resizePane(root, 640)
1858
+ await expect(width).toHaveValue("624")
1859
+ await expect(native).toHaveAttribute("data-width", "624")
1860
+ })
1861
+
1862
+ story("resizes a device with the RTL side grip by pointer and keyboard", async ({ page }) => {
1863
+ const { root, viewport, preset, option, scale, width, height } = viewportControls(page)
1864
+ await root.evaluate((element) => element.setAttribute("dir", "rtl"))
1865
+ await viewport.click()
1866
+ await preset.click()
1867
+ await option("Samsung Galaxy S26").click()
1868
+ await scale.click()
1869
+ await option("50%").click()
1870
+ await expectSize(root.getByTestId("native-Alpha"), 180, 390)
1871
+ const grip = root.getByRole("separator", { name: "Resize viewport width", exact: true })
1872
+
1873
+ const box = await grip.boundingBox()
1874
+
1875
+ if (!box) throw new Error("Missing viewport resize grip")
1876
+ const x = box.x + box.width / 2
1877
+
1878
+ const y = box.y + box.height / 2
1879
+ await page.mouse.move(x, y)
1880
+ await page.mouse.down()
1881
+ await page.mouse.move(x - 12, y)
1882
+ // Both edges move 12 screen pixels, or 24 guest CSS pixels each at 50% scale.
1883
+ await expect(width).toHaveValue("408")
1884
+ await expect(height).toHaveValue("780")
1885
+ await expect(preset).toHaveText("Custom")
1886
+ await expectSize(root.getByTestId("native-Alpha"), 204, 390)
1887
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1888
+ await expect(root.locator('img[elementtiming="embed-snapshot"]')).toHaveCount(0)
1889
+ await page.mouse.up()
1890
+
1891
+ const bottomGrip = root.getByRole("separator", { name: "Resize viewport height", exact: true })
1892
+
1893
+ await expect(grip).toHaveCSS("outline-style", "none")
1894
+ await bottomGrip.press("Shift+Tab")
1895
+ await expect(grip).toBeFocused()
1896
+ await expect(grip).toHaveCSS("outline-offset", "-2px")
1897
+ await grip.press("Shift+ArrowRight")
1898
+ await expect(width).toHaveValue("398")
1899
+
1900
+ await page.keyboard.press("Tab")
1901
+ await expect(bottomGrip).toBeFocused()
1902
+ await expect(bottomGrip).toHaveCSS("outline-offset", "-2px")
1903
+ })
1904
+
1905
+ story("pins the responsive dimensions when a manual preview scale is selected", async ({ page }) => {
1906
+ const { root, viewport, preset, option, scale, width, height } = viewportControls(page)
1907
+
1908
+ const native = root.getByTestId("native-Alpha")
1909
+ await viewport.click()
1910
+ await expect(width).toHaveValue("624")
1911
+ const responsiveHeight = await height.inputValue()
1912
+ await expect(scale).toHaveText("Fit - 100%")
1913
+ await scale.click()
1914
+ const menu = page.getByRole("menu")
1915
+ await expect(menu.getByRole("menuitemradio")).toHaveText([
1916
+ "Fit to pane",
1917
+ "50%",
1918
+ "75%",
1919
+ "100%",
1920
+ "125%",
1921
+ "150%",
1922
+ "200%",
1923
+ ])
1924
+ const fit = option("Fit to pane")
1925
+ await expect(fit).toBeChecked()
1926
+ const double = option("200%")
1927
+ await double.click()
1928
+ await resizePane(root, 400)
1929
+ await expect(scale).toHaveText("200%")
1930
+ await expect(preset).toHaveText("Custom")
1931
+ await expect(width).toHaveValue("624")
1932
+ await expect(height).toHaveValue(responsiveHeight)
1933
+
1934
+ await width.fill("120")
1935
+ await height.fill("80")
1936
+ await expectSize(native, 240, 160)
1937
+ await scale.click()
1938
+ await expect(double).toBeChecked()
1939
+ await fit.click()
1940
+ await expect(scale).toHaveText("Fit - 100%")
1941
+ await expectSize(native, 120, 80)
1942
+ })
1943
+
1944
+ story("keeps the selected device and its rotated viewport with its browser tab", async ({ page }) => {
1945
+ const { root, viewport, preset, moreDevices, option, width, height, scale, rotate } = viewportControls(page)
1946
+
1947
+ const switchTab = root.getByRole("button", { name: "Switch browser tab", exact: true })
1948
+ await viewport.click()
1949
+ await scale.click()
1950
+ await option("50%").click()
1951
+ await preset.click()
1952
+ await moreDevices.hover()
1953
+ const pixel = option("Pixel 10")
1954
+ await pixel.click()
1955
+ await expect(preset).toHaveText("Pixel 10")
1956
+ await rotate.click()
1957
+ await expectSize(root.getByTestId("native-Alpha"), 462, 206)
1958
+
1959
+ await switchTab.click()
1960
+ await expect(root.getByTestId("native-Second")).toHaveAttribute("data-visible", "true")
1961
+ await expect(preset).toHaveText("Responsive")
1962
+ await width.fill("200")
1963
+ await height.fill("180")
1964
+ const second = root.getByTestId("native-Second")
1965
+ await expectSize(second, 200, 180)
1966
+ await expect(scale).toHaveText("Fit - 100%")
1967
+
1968
+ // Wrapping the toolbar moves the centered native view on both axes without changing its size.
1969
+ await page.evaluate(() => document.fonts.ready.then(() => undefined))
1970
+
1971
+ const embed = root.locator('[data-component="browser-preview"] > div:first-child')
1972
+
1973
+ const wide = await embed.boundingBox()
1974
+ await resizePane(root, 320)
1975
+ const narrow = await embed.boundingBox()
1976
+
1977
+ if (!wide || !narrow) throw new Error("Missing preview bounds")
1978
+ expect(narrow.x).toBeLessThan(wide.x)
1979
+ expect(narrow.y).toBeGreaterThan(wide.y)
1980
+ await expect(second).toHaveAttribute("data-x", String(Math.round(narrow.x)))
1981
+ await expect(second).toHaveAttribute("data-y", String(Math.round(narrow.y)))
1982
+ await expectSize(second, 200, 180)
1983
+
1984
+ await switchTab.click()
1985
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
1986
+ await expect(width).toHaveValue("924")
1987
+ await expect(height).toHaveValue("412")
1988
+ await expect(preset).toHaveText("Pixel 10")
1989
+ await expect(scale).toHaveText("50%")
1990
+ await preset.click()
1991
+ await moreDevices.hover()
1992
+ await expect(pixel).toBeChecked()
1993
+ })
1994
+
1995
+ story("the zoom row sits on the lines the other rows use, and Left and Right move between its buttons", async ({ page }) => {
1996
+ const root = page.getByTestId("browser-pane-fixture")
1997
+ await root.getByRole("button", { name: "Browser options", exact: true }).click()
1998
+ await expect(page.getByRole("menuitem", { name: "Zoom in", exact: true })).toBeVisible()
1999
+ await page.evaluate(() => document.fonts.ready.then(() => undefined))
2000
+
2001
+ const edges = await page.evaluate(() => {
2002
+ const menu = document.querySelector('[data-component="menu-v2-content"]')
2003
+ const group = menu?.querySelector('[role="group"][aria-labelledby]')
2004
+
2005
+ const label = (text: string) => {
2006
+ const node = [...(menu?.querySelectorAll('[data-slot="menu-v2-item-content"]') ?? [])].find((item) => item.textContent?.trim() === text)?.firstChild
2007
+ const range = document.createRange()
2008
+
2009
+ if (node) range.selectNodeContents(node)
2010
+
2011
+ return range.getBoundingClientRect()
2012
+ }
2013
+
2014
+ const right = (selector: string) => menu?.querySelector(selector)?.getBoundingClientRect().right
2015
+
2016
+ return {
2017
+ labels: ["Zoom", "Copy link", "More tools"].map((text) => label(text).left),
2018
+ tops: ["Zoom", "100%"].map((text) => label(text).top),
2019
+ trailing: [right('[aria-label="Zoom in"]'), right('[data-component="keybind-v2"]'), right('[data-slot="menu-v2-item-chevron"]')],
2020
+ heights: [group, group?.previousElementSibling].map((row) => row?.getBoundingClientRect().height),
2021
+ }
2022
+ })
2023
+
2024
+ expect(Math.abs(edges.labels[0]! - edges.labels[1]!)).toBeLessThan(0.5)
2025
+ expect(Math.abs(edges.labels[0]! - edges.labels[2]!)).toBeLessThan(0.5)
2026
+ expect(Math.abs(edges.tops[0]! - edges.tops[1]!)).toBeLessThan(0.5)
2027
+ expect(Math.abs(edges.trailing[0]! - edges.trailing[1]!)).toBeLessThan(0.5)
2028
+ expect(Math.abs(edges.trailing[0]! - edges.trailing[2]!)).toBeLessThan(0.5)
2029
+ expect(edges.heights[0]).toBe(edges.heights[1])
2030
+
2031
+ // At 100% there is nothing to reset, so that button is skipped. Down walks the row's buttons in order, as it walks
2032
+ // every item.
2033
+ await page.getByRole("menuitem", { name: "Zoom out", exact: true }).focus()
2034
+ await page.keyboard.press("ArrowRight")
2035
+ await expect(page.getByRole("menuitem", { name: "Zoom in", exact: true })).toBeFocused()
2036
+ await page.keyboard.press("ArrowRight")
2037
+ await expect(page.getByRole("menuitem", { name: "Zoom in", exact: true })).toBeFocused()
2038
+ await page.keyboard.press("ArrowLeft")
2039
+ await expect(page.getByRole("menuitem", { name: "Zoom out", exact: true })).toBeFocused()
2040
+ await page.keyboard.press("ArrowDown")
2041
+ await page.keyboard.press("ArrowDown")
2042
+ await expect(page.getByRole("menuitem", { name: "Copy link", exact: true })).toBeFocused()
2043
+ })
2044
+
2045
+ story("shows a page dialog in the pane instead of the page, and answers it with Escape", async ({ page }) => {
2046
+ const root = page.getByTestId("browser-pane-fixture")
2047
+ const native = root.getByTestId("native-Alpha")
2048
+ // The fixture's controls sit below the pane, outside the viewport.
2049
+ await root.getByRole("button", { name: "Page confirm", exact: true }).evaluate((element: HTMLElement) => element.click())
2050
+ const dialog = page.getByRole("alertdialog", { name: "alpha.example says" })
2051
+ await expect(dialog).toContainText("Discard the draft?")
2052
+ await expect(dialog).toContainText("1 more waiting")
2053
+ await expect(dialog.getByRole("checkbox", { name: "Stop this page from showing more messages" })).toBeVisible()
2054
+ // A page blocked in a dialog draws nothing: the native view hides, and the dialog sits over the page's box.
2055
+ await expect(native).toHaveAttribute("data-visible", "false")
2056
+ await expect(dialog.getByRole("button", { name: "OK", exact: true })).toBeFocused()
2057
+ await page.keyboard.press("Escape")
2058
+ await expect(dialog).toBeHidden()
2059
+ await expect(root.getByText('Answers: [{"kind":"dialog","accept":false,"text":"","stop":false}]', { exact: true })).toBeVisible()
2060
+ await expect(native).toHaveAttribute("data-visible", "true")
2061
+ })
2062
+
2063
+ story("asks for a site's permission in a bar while the page stays usable", async ({ page }) => {
2064
+ const root = page.getByTestId("browser-pane-fixture")
2065
+ await root.getByRole("button", { name: "Permission request", exact: true }).evaluate((element: HTMLElement) => element.click())
2066
+ const bar = root.getByRole("alertdialog", { name: "Site permission request" })
2067
+ await expect(bar).toContainText("alpha.example wants to show notifications.")
2068
+ await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true")
2069
+ const always = bar.getByRole("button", { name: "Always allow", exact: true })
2070
+ const answered = root.getByText('Answers: [{"kind":"permission","allow":true,"remember":true}]', { exact: true })
2071
+ // A page can make the bar appear under a click the user is making: a press right after it appears does nothing.
2072
+ await always.click()
2073
+ await expect(bar).toBeVisible()
2074
+ await expect(root.getByText("Answers: []", { exact: true })).toBeVisible()
2075
+ // Once the bar has been there long enough to read, a new press answers it.
2076
+ await expect(async () => {
2077
+ await always.click({ timeout: 1_000 })
2078
+ await expect(answered).toBeVisible({ timeout: 200 })
2079
+ }).toPass()
2080
+ await expect(bar).toBeHidden()
2081
+ })
2082
+
2083
+ story("starts the bar's input protection over when the page asks again", async ({ page }) => {
2084
+ const root = page.getByTestId("browser-pane-fixture")
2085
+ await root.getByRole("button", { name: "Permission request", exact: true }).evaluate((element: HTMLElement) => element.click())
2086
+ const bar = root.getByRole("alertdialog", { name: "Site permission request" })
2087
+ const once = bar.getByRole("button", { name: "Allow this time", exact: true })
2088
+ await expect(once).toBeVisible()
2089
+ // The delay is the contract: let the first appearance's run out, so only a restart can refuse the next press.
2090
+ await page.waitForTimeout(600)
2091
+ // The page asks again: the same bar shows anew, so a press at once does nothing.
2092
+ await root.getByRole("button", { name: "Repeat permission request", exact: true }).evaluate((element: HTMLElement) => element.click())
2093
+ await once.click()
2094
+ await expect(bar).toBeVisible()
2095
+ await expect(root.getByText("Answers: []", { exact: true })).toBeVisible()
2096
+ await expect(async () => {
2097
+ await once.click({ timeout: 1_000 })
2098
+ await expect(root.getByText('Answers: [{"kind":"permission","allow":true,"remember":false}]', { exact: true })).toBeVisible({
2099
+ timeout: 200,
2100
+ })
2101
+ }).toPass()
2102
+ })
2103
+
2104
+ story("an agent's show request gives its page's permission bar no press that was on its way to the person's", async ({ page }) => {
2105
+ const root = page.getByTestId("browser-pane-fixture")
2106
+ await root.getByRole("button", { name: "Permission request", exact: true }).evaluate((element: HTMLElement) => element.click())
2107
+ const bar = root.getByRole("alertdialog", { name: "Site permission request" })
2108
+ const once = bar.getByRole("button", { name: "Allow this time", exact: true })
2109
+ await expect(bar).toContainText("alpha.example wants to show notifications.")
2110
+ // The person's bar has been there long enough to answer, so only the change of tab can refuse the next press.
2111
+ await page.waitForTimeout(600)
2112
+ const target = (await once.boundingBox())!
2113
+ // The agent shows its own page, whose first request has the same kind and number as the one on screen. The press
2114
+ // lands where the person's Allow was, at once.
2115
+ await root.getByRole("button", { name: "Agent shows a page that asks", exact: true }).evaluate((element: HTMLElement) => element.click())
2116
+ await page.mouse.click(target.x + target.width / 2, target.y + target.height / 2)
2117
+ await expect(root.getByText("Answers: []", { exact: true })).toBeVisible()
2118
+ await expect(bar).toContainText("second.example wants to use your camera.")
2119
+ // The tab's answers take no input while its page is held back, then a new press answers the request on screen, in its tab.
2120
+ await expect(async () => {
2121
+ await once.click({ timeout: 1_000 })
2122
+ await expect(root.getByText('Answered in: ["Second"]', { exact: true })).toBeVisible({ timeout: 200 })
2123
+ }).toPass()
2124
+ })
2125
+
2126
+ story("an agent's show request leaves the keyboard where the person types, and its tab's bar answers no key or click meanwhile", async ({ page }) => {
2127
+ const root = page.getByTestId("browser-pane-fixture")
2128
+ const address = root.getByRole("combobox", { name: "Browser address", exact: true })
2129
+ await address.click()
2130
+ await page.keyboard.type("exa")
2131
+ await expect(address).toHaveValue(/exa$/)
2132
+
2133
+ // In the page, in one task: the show request, then at once the keys and clicks that would answer its bar. Escape
2134
+ // and the close button answer "not now", which nothing but the reveal's guard holds back.
2135
+ const held = await root.getByRole("button", { name: "Agent shows a page that asks", exact: true }).evaluate((show: HTMLElement) => {
2136
+ show.click()
2137
+ const bar = document.querySelector<HTMLElement>('[data-component="browser-prompt"]')
2138
+ const buttons = Array.from(bar?.querySelectorAll("button") ?? [])
2139
+ buttons[0]?.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }))
2140
+ buttons.forEach((button) => button.click())
2141
+
2142
+ return buttons.length
2143
+ })
2144
+
2145
+ expect(held).toBeGreaterThan(1)
2146
+ const bar = root.getByRole("alertdialog", { name: "Site permission request" })
2147
+ await expect(bar).toContainText("second.example wants to use your camera.")
2148
+ await expect(root.getByText("Answers: []", { exact: true })).toBeVisible()
2149
+
2150
+ // The person was typing an address: the rest of it goes to the address field, not to the window or the composer.
2151
+ await expect(address).toBeFocused()
2152
+ await page.keyboard.type("mple")
2153
+ await expect(address).toHaveValue(/mple$/)
2154
+ await expect(root.getByRole("textbox", { name: "Composer stand-in" })).toHaveValue("")
2155
+ })
2156
+
2157
+ story("takes the keyboard from the window for a dialog and gives it back where it was", async ({ page }) => {
2158
+ const root = page.getByTestId("browser-pane-fixture")
2159
+ const composer = root.getByRole("textbox", { name: "Composer stand-in" })
2160
+ await composer.focus()
2161
+ await root.getByRole("button", { name: "Page confirm", exact: true }).evaluate((element: HTMLElement) => element.click())
2162
+ const dialog = page.getByRole("alertdialog", { name: "alpha.example says" })
2163
+ await expect(dialog.getByRole("button", { name: "OK", exact: true })).toBeFocused()
2164
+ await page.keyboard.press("Escape")
2165
+ await expect(dialog).toBeHidden()
2166
+ await expect(composer).toBeFocused()
2167
+ })
2168
+
2169
+ story("asks again for an agent's request without offering to keep the answer, and says why", async ({ page }) => {
2170
+ const root = page.getByTestId("browser-pane-fixture")
2171
+ await root.getByRole("button", { name: "Agent permission request", exact: true }).evaluate((element: HTMLElement) => element.click())
2172
+ const bar = root.getByRole("alertdialog", { name: "Site permission request" })
2173
+ await expect(bar).toContainText("alpha.example wants to use your microphone.")
2174
+ await expect(bar).toContainText("The agent is working in this tab. Your answer applies this one time.")
2175
+ await expect(bar.getByRole("button", { name: "Always allow", exact: true })).toHaveCount(0)
2176
+ await expect(bar.getByRole("button", { name: "Allow this time", exact: true })).toBeVisible()
2177
+ // Enter on the bar never grants: focus starts on the refusing button.
2178
+ await bar.getByRole("button", { name: "Block", exact: true }).focus()
2179
+ await expect(async () => {
2180
+ await page.keyboard.press("Enter")
2181
+ await expect(root.getByText('Answers: [{"kind":"permission","allow":false,"remember":false}]', { exact: true })).toBeVisible({
2182
+ timeout: 200,
2183
+ })
2184
+ }).toPass()
2185
+ })
2186
+
2187
+ story("asks for a page's prompt text and sends what the user typed", async ({ page }) => {
2188
+ const root = page.getByTestId("browser-pane-fixture")
2189
+ await root.getByRole("button", { name: "Page prompt", exact: true }).evaluate((element: HTMLElement) => element.click())
2190
+ const dialog = page.getByRole("alertdialog", { name: "alpha.example says" })
2191
+ await expect(dialog).toContainText("Name the copy")
2192
+ const field = dialog.getByRole("textbox", { name: "Your answer" })
2193
+ await expect(field).toHaveValue("Draft")
2194
+ await expect(field).toHaveAttribute("maxlength", "2000")
2195
+ await field.fill("Final copy")
2196
+ const answered = root.getByText('Answers: [{"kind":"dialog","accept":true,"text":"Final copy","stop":false}]', { exact: true })
2197
+ await expect(async () => {
2198
+ await field.press("Enter")
2199
+ await expect(answered).toBeVisible({ timeout: 200 })
2200
+ }).toPass()
2201
+ await expect(dialog).toBeHidden()
2202
+ })
2203
+
2204
+ // What the key test below records in the story's window.
2205
+ declare global {
2206
+ interface Window {
2207
+ keyLog: KeyboardEvent[]
2208
+ keyBehind: string[]
2209
+ }
2210
+ }
2211
+
2212
+ story("keeps the keys inside a page prompt, and leaves them to the window once the keyboard is elsewhere", async ({ page }) => {
2213
+ const root = page.getByTestId("browser-pane-fixture")
2214
+ // Each key as the window saw it first, and whether its default was cancelled once every handler had seen it.
2215
+ await page.evaluate(() => {
2216
+ const log: KeyboardEvent[] = []
2217
+ // Keys the window's own handlers behind the prompt would see, as the composer's and the zoom's do.
2218
+ const behind: string[] = []
2219
+ Object.assign(window, { keyLog: log, keyBehind: behind })
2220
+ window.addEventListener("keydown", (event) => log.push(event), { capture: true })
2221
+ window.addEventListener("keydown", (event) => behind.push(event.key))
2222
+ })
2223
+ const behind = () => page.evaluate(() => window.keyBehind.splice(0))
2224
+
2225
+ const log = () =>
2226
+ page.evaluate(() =>
2227
+ window.keyLog
2228
+ .splice(0)
2229
+ .filter((event) => !["Control", "Alt", "Shift", "Meta"].includes(event.key))
2230
+ .map((event) => `${event.key}:${event.defaultPrevented ? "prevented" : "default"}`),
2231
+ )
2232
+
2233
+ await root.getByRole("button", { name: "Page prompt", exact: true }).evaluate((element: HTMLElement) => element.click())
2234
+ const dialog = page.getByRole("alertdialog", { name: "alpha.example says" })
2235
+ const field = dialog.getByRole("textbox", { name: "Your answer" })
2236
+ await expect(field).toBeFocused()
2237
+ await field.press("End")
2238
+ await page.keyboard.type(" two")
2239
+ await log()
2240
+
2241
+ // Reload, the agent switch, find, close and new tab, zoom and history do nothing here.
2242
+ for (const chord of ["Control+r", "Control+.", "Control+f", "Control+w", "Control+t", "Control+Equal", "Alt+ArrowLeft", "F5"])
2243
+ await page.keyboard.press(chord)
2244
+ expect(await log()).toEqual(["r", ".", "f", "w", "t", "=", "ArrowLeft", "F5"].map((key) => `${key}:prevented`))
2245
+ // Editing keys edit the field as they do anywhere.
2246
+ await page.keyboard.press("Control+a")
2247
+ await page.keyboard.press("ArrowRight")
2248
+ await page.keyboard.press("Backspace")
2249
+ expect(await log()).toEqual(["a:default", "ArrowRight:default", "Backspace:default"])
2250
+ await expect(field).toHaveValue("Draft tw")
2251
+ await expect(dialog).toBeVisible()
2252
+ // None of them went past the prompt to the window's handlers.
2253
+ expect(await behind()).toEqual([])
2254
+
2255
+ // With the keyboard in the composer, its keys are the app's and the prompt stays open.
2256
+ await root.getByRole("textbox", { name: "Composer stand-in" }).focus()
2257
+ await page.keyboard.press("Control+r")
2258
+ expect(await log()).toEqual(["r:default"])
2259
+ expect(await behind()).toEqual(["Control", "r"])
2260
+ await expect(dialog).toBeVisible()
2261
+
2262
+ await field.focus()
2263
+ await expect(async () => {
2264
+ await field.press("Enter")
2265
+ await expect(root.getByText('Answers: [{"kind":"dialog","accept":true,"text":"Draft tw","stop":false}]', { exact: true })).toBeVisible({
2266
+ timeout: 200,
2267
+ })
2268
+ }).toPass()
2269
+ })
2270
+
2271
+ story("asks for a site's sign-in with its realm, says the last one failed, and keeps nothing on cancel", async ({ page }) => {
2272
+ const root = page.getByTestId("browser-pane-fixture")
2273
+ await root.getByRole("button", { name: "Sign-in request", exact: true }).evaluate((element: HTMLElement) => element.click())
2274
+ const dialog = page.getByRole("alertdialog", { name: "Sign in to intranet.alpha.example" })
2275
+ // The realm sits in its sentence inside directional isolates.
2276
+ await expect(dialog).toContainText(/The site says: “\u2068Staff area\u2069”/)
2277
+ await expect(dialog.getByRole("alert")).toBeVisible()
2278
+ const user = dialog.getByRole("textbox", { name: "User name" })
2279
+ await expect(user).toBeFocused()
2280
+ await expect(user).toHaveAttribute("maxlength", "1024")
2281
+ await user.fill("demo")
2282
+ await dialog.getByLabel("Password").fill("secret")
2283
+ await page.keyboard.press("Escape")
2284
+ await expect(dialog).toBeHidden()
2285
+ await expect(root.getByText('Answers: [{"kind":"dismiss"}]', { exact: true })).toBeVisible()
2286
+ })
2287
+
2288
+ story("the options menu lists everyday actions first and the rest under More tools, where each still runs", async ({ page }) => {
2289
+ const root = page.getByTestId("browser-pane-fixture")
2290
+ await root.getByRole("button", { name: "Seed history", exact: true }).click()
2291
+ await root.getByRole("button", { name: "Seed imported history", exact: true }).click()
2292
+ await expect(root.getByText(/^Visits: \S/)).toBeVisible()
2293
+ await expect(root.getByText("Main history: 59", { exact: true })).toBeVisible()
2294
+ await root.getByRole("button", { name: "Browser options", exact: true }).click()
2295
+ // Find, the zoom row (out, the zoom itself, in), Copy link and Add page; then More tools; then settings.
2296
+ await expect(page.getByRole("menu").first().getByRole("menuitem")).toHaveText([
2297
+ /^Find in page/,
2298
+ "",
2299
+ "100%",
2300
+ "",
2301
+ "Copy link",
2302
+ "Add page to session",
2303
+ "More tools",
2304
+ "Browser settings",
2305
+ ])
2306
+ await expect(page.getByRole("group", { name: "Zoom", exact: true }).getByRole("menuitem")).toHaveCount(3)
2307
+ await page.getByRole("menuitem", { name: "More tools", exact: true }).click()
2308
+ await expect(page.getByRole("menu", { name: "More tools", exact: true }).getByRole("menuitem")).toHaveText([
2309
+ /^Toggle browser toolbar/,
2310
+ "Open in default browser",
2311
+ /^Reload without saved files/,
2312
+ "Clear history",
2313
+ ])
2314
+ // Clearing forgets the window's last pages and main's history, imported pages included.
2315
+ await page.getByRole("menuitem", { name: "Clear history", exact: true }).click()
2316
+ await expect(root.getByText("Visits:", { exact: true })).toBeVisible()
2317
+ await expect(root.getByText("Main history: 0", { exact: true })).toBeVisible()
2318
+ // Neither has a button in the bar.
2319
+ await expect(root.getByRole("button", { name: "Add page to session", exact: true })).toHaveCount(0)
2320
+ await expect(root.getByRole("button", { name: "Toggle browser toolbar", exact: true })).toHaveCount(0)
2321
+ })
2322
+
2323
+ // The comment tool is a button in the bar. While it waits for a pick, the pane also says so in a status line for
2324
+ // assistive technology, which these cases read.
2325
+ function commentTool(root: Locator) {
2326
+ const button = root.getByRole("button", { name: "Comment on part of the page", exact: true })
2327
+
2328
+ return {
2329
+ button,
2330
+ click: () => button.click(),
2331
+ picking: root.getByText("Click part of the page to comment on it. Press Escape to cancel.", { exact: true }),
2332
+ }
2333
+ }
2334
+
2335
+ async function addPage(page: Page, root: Locator) {
2336
+ await root.getByRole("button", { name: "Browser options", exact: true }).click()
2337
+ await page.getByRole("menuitem", { name: "Add page to session", exact: true }).click()
2338
+ }