@zyro-sec/gui-plugins 0.0.0-stage → 1.0.4

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 (1085) hide show
  1. package/AGENTS.md +116 -0
  2. package/README.md +874 -3
  3. package/bunfig.toml +3 -0
  4. package/happydom.ts +77 -0
  5. package/package.json +63 -4
  6. package/src/browser/activation-delay.ts +134 -0
  7. package/src/browser/address-machine.ts +468 -0
  8. package/src/browser/address.ts +111 -0
  9. package/src/browser/agent-rendering.ts +61 -0
  10. package/src/browser/analysis.ts +260 -0
  11. package/src/browser/artifact-link.ts +69 -0
  12. package/src/browser/artifact-links.ts +55 -0
  13. package/src/browser/artifact-preview.ts +61 -0
  14. package/src/browser/assets/viewport-device-chevron.svg +5 -0
  15. package/src/browser/assets/viewport-rotate.svg +7 -0
  16. package/src/browser/bar.css +562 -0
  17. package/src/browser/capture.ts +158 -0
  18. package/src/browser/cdp.ts +97 -0
  19. package/src/browser/child-targets.ts +30 -0
  20. package/src/browser/choices.tsx +42 -0
  21. package/src/browser/chromium.ts +3018 -0
  22. package/src/browser/comment.css +38 -0
  23. package/src/browser/comment.ts +98 -0
  24. package/src/browser/connection.ts +122 -0
  25. package/src/browser/default-browser.ts +59 -0
  26. package/src/browser/diagnostics-machine.ts +522 -0
  27. package/src/browser/diagnostics.ts +317 -0
  28. package/src/browser/dialog-machine.ts +268 -0
  29. package/src/browser/disk/contained-file.ts +43 -0
  30. package/src/browser/disk/handle-path.fixture.ts +99 -0
  31. package/src/browser/disk/handle-path.ts +122 -0
  32. package/src/browser/disk/index.ts +5 -0
  33. package/src/browser/disk/preview-scope.ts +90 -0
  34. package/src/browser/electron-address.fixture.ts +143 -0
  35. package/src/browser/electron-app-badge.fixture.ts +97 -0
  36. package/src/browser/electron-crash.fixture.ts +216 -0
  37. package/src/browser/electron-dialogs.fixture.ts +114 -0
  38. package/src/browser/electron-history.fixture.ts +61 -0
  39. package/src/browser/electron-icon.fixture.ts +145 -0
  40. package/src/browser/electron-import-choice.fixture.ts +58 -0
  41. package/src/browser/electron-links.fixture.ts +549 -0
  42. package/src/browser/electron-main.ts +85 -0
  43. package/src/browser/electron-media.fixture.ts +66 -0
  44. package/src/browser/electron-open.fixture.ts +351 -0
  45. package/src/browser/electron-page.fixture.ts +253 -0
  46. package/src/browser/electron-restore.fixture.ts +135 -0
  47. package/src/browser/electron-run.ts +184 -0
  48. package/src/browser/electron-sign-in-copy.fixture.ts +365 -0
  49. package/src/browser/electron-webauthn.fixture.ts +229 -0
  50. package/src/browser/electron-workers.fixture.ts +54 -0
  51. package/src/browser/errors.ts +175 -0
  52. package/src/browser/failure-view.tsx +92 -0
  53. package/src/browser/failure.ts +174 -0
  54. package/src/browser/field-value.ts +60 -0
  55. package/src/browser/file-choosers.ts +42 -0
  56. package/src/browser/file-verification.ts +18 -0
  57. package/src/browser/files.ts +134 -0
  58. package/src/browser/find-bar.tsx +80 -0
  59. package/src/browser/find-machine.ts +43 -0
  60. package/src/browser/history/earlier.ts +23 -0
  61. package/src/browser/history/index.ts +5 -0
  62. package/src/browser/history/ipc.ts +44 -0
  63. package/src/browser/history/match.ts +196 -0
  64. package/src/browser/history/page.ts +86 -0
  65. package/src/browser/history/search.ts +209 -0
  66. package/src/browser/history/store.ts +272 -0
  67. package/src/browser/history/suggest.ts +51 -0
  68. package/src/browser/history/visits.ts +59 -0
  69. package/src/browser/host-display.ts +32 -0
  70. package/src/browser/i18n/am.ts +42 -0
  71. package/src/browser/i18n/ar.ts +46 -0
  72. package/src/browser/i18n/az.ts +42 -0
  73. package/src/browser/i18n/bg.ts +42 -0
  74. package/src/browser/i18n/bn.ts +42 -0
  75. package/src/browser/i18n/br.ts +44 -0
  76. package/src/browser/i18n/bs.ts +43 -0
  77. package/src/browser/i18n/ca.ts +44 -0
  78. package/src/browser/i18n/cs.ts +44 -0
  79. package/src/browser/i18n/da.ts +42 -0
  80. package/src/browser/i18n/de.ts +43 -0
  81. package/src/browser/i18n/dv.ts +43 -0
  82. package/src/browser/i18n/dz.ts +42 -0
  83. package/src/browser/i18n/el.ts +44 -0
  84. package/src/browser/i18n/en.ts +455 -0
  85. package/src/browser/i18n/es.ts +44 -0
  86. package/src/browser/i18n/et.ts +42 -0
  87. package/src/browser/i18n/fa.ts +42 -0
  88. package/src/browser/i18n/fi.ts +42 -0
  89. package/src/browser/i18n/fo.ts +42 -0
  90. package/src/browser/i18n/fr.ts +45 -0
  91. package/src/browser/i18n/he.ts +43 -0
  92. package/src/browser/i18n/hi.ts +42 -0
  93. package/src/browser/i18n/hr.ts +43 -0
  94. package/src/browser/i18n/hu.ts +43 -0
  95. package/src/browser/i18n/hy.ts +42 -0
  96. package/src/browser/i18n/id.ts +42 -0
  97. package/src/browser/i18n/is.ts +42 -0
  98. package/src/browser/i18n/it.ts +44 -0
  99. package/src/browser/i18n/ja.ts +42 -0
  100. package/src/browser/i18n/ka.ts +42 -0
  101. package/src/browser/i18n/km.ts +42 -0
  102. package/src/browser/i18n/ko.ts +42 -0
  103. package/src/browser/i18n/lo.ts +42 -0
  104. package/src/browser/i18n/lt.ts +44 -0
  105. package/src/browser/i18n/lv.ts +43 -0
  106. package/src/browser/i18n/mk.ts +42 -0
  107. package/src/browser/i18n/mn.ts +42 -0
  108. package/src/browser/i18n/ms.ts +42 -0
  109. package/src/browser/i18n/my.ts +43 -0
  110. package/src/browser/i18n/ne.ts +42 -0
  111. package/src/browser/i18n/nl.ts +42 -0
  112. package/src/browser/i18n/no.ts +42 -0
  113. package/src/browser/i18n/pa.ts +42 -0
  114. package/src/browser/i18n/pl.ts +44 -0
  115. package/src/browser/i18n/ro.ts +43 -0
  116. package/src/browser/i18n/ru.ts +44 -0
  117. package/src/browser/i18n/si.ts +42 -0
  118. package/src/browser/i18n/sk.ts +44 -0
  119. package/src/browser/i18n/sl.ts +44 -0
  120. package/src/browser/i18n/sq.ts +43 -0
  121. package/src/browser/i18n/sr.ts +43 -0
  122. package/src/browser/i18n/sv.ts +42 -0
  123. package/src/browser/i18n/tg.ts +42 -0
  124. package/src/browser/i18n/th.ts +42 -0
  125. package/src/browser/i18n/tk.ts +42 -0
  126. package/src/browser/i18n/tr.ts +42 -0
  127. package/src/browser/i18n/uk.ts +44 -0
  128. package/src/browser/i18n/ur.ts +42 -0
  129. package/src/browser/i18n/uz.ts +42 -0
  130. package/src/browser/i18n/vi.ts +42 -0
  131. package/src/browser/i18n/zh.ts +42 -0
  132. package/src/browser/i18n/zht.ts +42 -0
  133. package/src/browser/icon-image.ts +110 -0
  134. package/src/browser/icon-samples.ts +110 -0
  135. package/src/browser/icon.ts +72 -0
  136. package/src/browser/import-prompt.tsx +265 -0
  137. package/src/browser/index.ts +97 -0
  138. package/src/browser/ipc.ts +304 -0
  139. package/src/browser/jobs-machine.ts +181 -0
  140. package/src/browser/jobs.ts +373 -0
  141. package/src/browser/keys.ts +109 -0
  142. package/src/browser/lighthouse.ts +103 -0
  143. package/src/browser/link.ts +19 -0
  144. package/src/browser/machine.ts +1522 -0
  145. package/src/browser/main-machine.ts +99 -0
  146. package/src/browser/main.ts +394 -0
  147. package/src/browser/media-gate.ts +131 -0
  148. package/src/browser/mobile-emulation.ts +121 -0
  149. package/src/browser/model-machine.ts +93 -0
  150. package/src/browser/model.ts +1173 -0
  151. package/src/browser/native-page-menu.ts +189 -0
  152. package/src/browser/navigation-deadline.ts +20 -0
  153. package/src/browser/navigation-turn.ts +118 -0
  154. package/src/browser/network.ts +140 -0
  155. package/src/browser/notice-actions.ts +52 -0
  156. package/src/browser/overlay-machine.ts +330 -0
  157. package/src/browser/page-find.ts +71 -0
  158. package/src/browser/page-icon.tsx +27 -0
  159. package/src/browser/page-log.ts +276 -0
  160. package/src/browser/page-machine.ts +329 -0
  161. package/src/browser/page-menu.ts +158 -0
  162. package/src/browser/page-prompts.ts +753 -0
  163. package/src/browser/pane-machine.ts +664 -0
  164. package/src/browser/pane.ts +1335 -0
  165. package/src/browser/panel.fixture.tsx +2046 -0
  166. package/src/browser/panel.stories.tsx +147 -0
  167. package/src/browser/panel.tsx +2029 -0
  168. package/src/browser/passkey-groups.ts +34 -0
  169. package/src/browser/picker-machine.ts +214 -0
  170. package/src/browser/plugin-tabs.ts +26 -0
  171. package/src/browser/policy.ts +439 -0
  172. package/src/browser/preview.ts +40 -0
  173. package/src/browser/profile/chromium.ts +198 -0
  174. package/src/browser/profile/compatibility.ts +177 -0
  175. package/src/browser/profile/cookie.ts +215 -0
  176. package/src/browser/profile/database.ts +116 -0
  177. package/src/browser/profile/electron-import.fixture.ts +43 -0
  178. package/src/browser/profile/electron-link.fixture.ts +137 -0
  179. package/src/browser/profile/extension-api/action.ts +276 -0
  180. package/src/browser/profile/extension-api/api.ts +112 -0
  181. package/src/browser/profile/extension-api/app-badge.js +19 -0
  182. package/src/browser/profile/extension-api/context-menus.ts +327 -0
  183. package/src/browser/profile/extension-api/cookies.ts +192 -0
  184. package/src/browser/profile/extension-api/event-page.ts +73 -0
  185. package/src/browser/profile/extension-api/frame-styles.js +46 -0
  186. package/src/browser/profile/extension-api/host.ts +291 -0
  187. package/src/browser/profile/extension-api/index.ts +119 -0
  188. package/src/browser/profile/extension-api/label.ts +4 -0
  189. package/src/browser/profile/extension-api/manifest.ts +76 -0
  190. package/src/browser/profile/extension-api/match-pattern.ts +98 -0
  191. package/src/browser/profile/extension-api/notifications.ts +100 -0
  192. package/src/browser/profile/extension-api/permissions.ts +51 -0
  193. package/src/browser/profile/extension-api/popup.ts +200 -0
  194. package/src/browser/profile/extension-api/preload.js +203 -0
  195. package/src/browser/profile/extension-api/resource.ts +36 -0
  196. package/src/browser/profile/extension-api/storage-sync.ts +167 -0
  197. package/src/browser/profile/extension-api/stubs.ts +152 -0
  198. package/src/browser/profile/extension-api/styles.ts +230 -0
  199. package/src/browser/profile/extension-api/tab-activity.ts +23 -0
  200. package/src/browser/profile/extension-api/tabs.ts +545 -0
  201. package/src/browser/profile/extension-api/web-navigation.ts +172 -0
  202. package/src/browser/profile/extension-api/worker-events.ts +114 -0
  203. package/src/browser/profile/extensions.ts +491 -0
  204. package/src/browser/profile/filter-startup.fixture.ts +111 -0
  205. package/src/browser/profile/filter-startup.ts +178 -0
  206. package/src/browser/profile/firefox.ts +119 -0
  207. package/src/browser/profile/history.ts +146 -0
  208. package/src/browser/profile/import.ts +37 -0
  209. package/src/browser/profile/index.ts +694 -0
  210. package/src/browser/profile/install.ts +131 -0
  211. package/src/browser/profile/integrity.ts +56 -0
  212. package/src/browser/profile/ipc.ts +306 -0
  213. package/src/browser/profile/link-machine.ts +183 -0
  214. package/src/browser/profile/link.ts +335 -0
  215. package/src/browser/profile/made-up-firefox.fixture.ts +67 -0
  216. package/src/browser/profile/previews.ts +70 -0
  217. package/src/browser/profile/probe.ts +43 -0
  218. package/src/browser/profile/range.ts +14 -0
  219. package/src/browser/profile/review.ts +38 -0
  220. package/src/browser/profile/safari.ts +77 -0
  221. package/src/browser/profile/serve.ts +117 -0
  222. package/src/browser/profile/sites.ts +74 -0
  223. package/src/browser/profile/sources.ts +682 -0
  224. package/src/browser/profiling-machine.ts +554 -0
  225. package/src/browser/profiling.ts +404 -0
  226. package/src/browser/prompt-gate.ts +41 -0
  227. package/src/browser/prompt-keys.ts +120 -0
  228. package/src/browser/prompt-machine.ts +242 -0
  229. package/src/browser/prompts.tsx +594 -0
  230. package/src/browser/refs.ts +65 -0
  231. package/src/browser/refusal-bar.tsx +163 -0
  232. package/src/browser/refusal-notice.ts +60 -0
  233. package/src/browser/remote-address.ts +1 -0
  234. package/src/browser/remote-preview.ts +56 -0
  235. package/src/browser/renderer.tsx +683 -0
  236. package/src/browser/restore.ts +77 -0
  237. package/src/browser/saved-tabs.ts +135 -0
  238. package/src/browser/scheme.ts +1 -0
  239. package/src/browser/session-guard.ts +94 -0
  240. package/src/browser/settings-view.ts +49 -0
  241. package/src/browser/settings.fixture.tsx +306 -0
  242. package/src/browser/settings.tsx +1036 -0
  243. package/src/browser/site-auth.ts +58 -0
  244. package/src/browser/site-chooser.fixture.tsx +222 -0
  245. package/src/browser/site-chooser.tsx +778 -0
  246. package/src/browser/site-keys.ts +35 -0
  247. package/src/browser/site-machine.ts +134 -0
  248. package/src/browser/site-permissions.ts +239 -0
  249. package/src/browser/site-search.ts +26 -0
  250. package/src/browser/snapshot.ts +440 -0
  251. package/src/browser/system-media.ts +80 -0
  252. package/src/browser/tab-openers.ts +65 -0
  253. package/src/browser/tabs.css +20 -0
  254. package/src/browser/viewport-controls-machine.ts +134 -0
  255. package/src/browser/viewport-controls.tsx +170 -0
  256. package/src/browser/viewport-handles.tsx +119 -0
  257. package/src/browser/viewport-layout.ts +24 -0
  258. package/src/browser/viewport-native.ts +99 -0
  259. package/src/browser/viewport-preset-menu.tsx +69 -0
  260. package/src/browser/viewport-presets.ts +28 -0
  261. package/src/browser/viewport-toolbar-machine.ts +94 -0
  262. package/src/browser/webauthn-gate.ts +222 -0
  263. package/src/browser/window-open.ts +143 -0
  264. package/src/browser/wire.ts +20 -0
  265. package/src/browser/workspace-file.ts +126 -0
  266. package/src/browser/workspace-pages.ts +156 -0
  267. package/src/btw/i18n/en.ts +12 -0
  268. package/src/btw/index.ts +31 -0
  269. package/src/btw/machine.ts +341 -0
  270. package/src/btw/model.ts +222 -0
  271. package/src/btw/panel.tsx +229 -0
  272. package/src/btw/renderer.tsx +125 -0
  273. package/src/context/catalog-machine.ts +153 -0
  274. package/src/context/catalog.ts +123 -0
  275. package/src/context/export.ts +57 -0
  276. package/src/context/format.ts +32 -0
  277. package/src/context/i18n/am.ts +31 -0
  278. package/src/context/i18n/ar.ts +31 -0
  279. package/src/context/i18n/az.ts +31 -0
  280. package/src/context/i18n/bg.ts +31 -0
  281. package/src/context/i18n/bn.ts +31 -0
  282. package/src/context/i18n/br.ts +31 -0
  283. package/src/context/i18n/bs.ts +31 -0
  284. package/src/context/i18n/ca.ts +31 -0
  285. package/src/context/i18n/cs.ts +31 -0
  286. package/src/context/i18n/da.ts +31 -0
  287. package/src/context/i18n/de.ts +31 -0
  288. package/src/context/i18n/dv.ts +31 -0
  289. package/src/context/i18n/dz.ts +31 -0
  290. package/src/context/i18n/el.ts +31 -0
  291. package/src/context/i18n/en.ts +31 -0
  292. package/src/context/i18n/es.ts +31 -0
  293. package/src/context/i18n/et.ts +31 -0
  294. package/src/context/i18n/fa.ts +31 -0
  295. package/src/context/i18n/fi.ts +31 -0
  296. package/src/context/i18n/fo.ts +31 -0
  297. package/src/context/i18n/fr.ts +31 -0
  298. package/src/context/i18n/he.ts +31 -0
  299. package/src/context/i18n/hi.ts +31 -0
  300. package/src/context/i18n/hr.ts +31 -0
  301. package/src/context/i18n/hu.ts +31 -0
  302. package/src/context/i18n/hy.ts +31 -0
  303. package/src/context/i18n/id.ts +31 -0
  304. package/src/context/i18n/is.ts +31 -0
  305. package/src/context/i18n/it.ts +31 -0
  306. package/src/context/i18n/ja.ts +31 -0
  307. package/src/context/i18n/ka.ts +31 -0
  308. package/src/context/i18n/km.ts +31 -0
  309. package/src/context/i18n/ko.ts +31 -0
  310. package/src/context/i18n/lo.ts +31 -0
  311. package/src/context/i18n/lt.ts +31 -0
  312. package/src/context/i18n/lv.ts +31 -0
  313. package/src/context/i18n/mk.ts +31 -0
  314. package/src/context/i18n/mn.ts +31 -0
  315. package/src/context/i18n/ms.ts +31 -0
  316. package/src/context/i18n/my.ts +31 -0
  317. package/src/context/i18n/ne.ts +31 -0
  318. package/src/context/i18n/nl.ts +31 -0
  319. package/src/context/i18n/no.ts +31 -0
  320. package/src/context/i18n/pa.ts +31 -0
  321. package/src/context/i18n/pl.ts +31 -0
  322. package/src/context/i18n/ro.ts +31 -0
  323. package/src/context/i18n/ru.ts +31 -0
  324. package/src/context/i18n/si.ts +31 -0
  325. package/src/context/i18n/sk.ts +31 -0
  326. package/src/context/i18n/sl.ts +31 -0
  327. package/src/context/i18n/sq.ts +31 -0
  328. package/src/context/i18n/sr.ts +31 -0
  329. package/src/context/i18n/sv.ts +31 -0
  330. package/src/context/i18n/tg.ts +31 -0
  331. package/src/context/i18n/th.ts +31 -0
  332. package/src/context/i18n/tk.ts +31 -0
  333. package/src/context/i18n/tr.ts +31 -0
  334. package/src/context/i18n/uk.ts +31 -0
  335. package/src/context/i18n/ur.ts +31 -0
  336. package/src/context/i18n/uz.ts +31 -0
  337. package/src/context/i18n/vi.ts +31 -0
  338. package/src/context/i18n/zh.ts +31 -0
  339. package/src/context/i18n/zht.ts +31 -0
  340. package/src/context/index.ts +71 -0
  341. package/src/context/indicator.tsx +199 -0
  342. package/src/context/machine.ts +271 -0
  343. package/src/context/renderer.tsx +72 -0
  344. package/src/context/tab.tsx +439 -0
  345. package/src/debug/bar.tsx +409 -0
  346. package/src/debug/contract.ts +45 -0
  347. package/src/debug/focus-machine.ts +84 -0
  348. package/src/debug/heap-machine.ts +229 -0
  349. package/src/debug/i18n/am.ts +50 -0
  350. package/src/debug/i18n/ar.ts +50 -0
  351. package/src/debug/i18n/az.ts +50 -0
  352. package/src/debug/i18n/bg.ts +53 -0
  353. package/src/debug/i18n/bn.ts +50 -0
  354. package/src/debug/i18n/br.ts +51 -0
  355. package/src/debug/i18n/bs.ts +52 -0
  356. package/src/debug/i18n/ca.ts +53 -0
  357. package/src/debug/i18n/cs.ts +52 -0
  358. package/src/debug/i18n/da.ts +51 -0
  359. package/src/debug/i18n/de.ts +50 -0
  360. package/src/debug/i18n/dv.ts +51 -0
  361. package/src/debug/i18n/dz.ts +52 -0
  362. package/src/debug/i18n/el.ts +54 -0
  363. package/src/debug/i18n/en.ts +50 -0
  364. package/src/debug/i18n/es.ts +52 -0
  365. package/src/debug/i18n/et.ts +50 -0
  366. package/src/debug/i18n/fa.ts +50 -0
  367. package/src/debug/i18n/fi.ts +50 -0
  368. package/src/debug/i18n/fo.ts +50 -0
  369. package/src/debug/i18n/fr.ts +52 -0
  370. package/src/debug/i18n/he.ts +50 -0
  371. package/src/debug/i18n/hi.ts +50 -0
  372. package/src/debug/i18n/hr.ts +52 -0
  373. package/src/debug/i18n/hu.ts +52 -0
  374. package/src/debug/i18n/hy.ts +52 -0
  375. package/src/debug/i18n/id.ts +51 -0
  376. package/src/debug/i18n/is.ts +50 -0
  377. package/src/debug/i18n/it.ts +52 -0
  378. package/src/debug/i18n/ja.ts +50 -0
  379. package/src/debug/i18n/ka.ts +50 -0
  380. package/src/debug/i18n/km.ts +50 -0
  381. package/src/debug/i18n/ko.ts +50 -0
  382. package/src/debug/i18n/lo.ts +50 -0
  383. package/src/debug/i18n/lt.ts +51 -0
  384. package/src/debug/i18n/lv.ts +50 -0
  385. package/src/debug/i18n/mk.ts +53 -0
  386. package/src/debug/i18n/mn.ts +52 -0
  387. package/src/debug/i18n/ms.ts +51 -0
  388. package/src/debug/i18n/my.ts +53 -0
  389. package/src/debug/i18n/ne.ts +50 -0
  390. package/src/debug/i18n/nl.ts +50 -0
  391. package/src/debug/i18n/no.ts +50 -0
  392. package/src/debug/i18n/pa.ts +50 -0
  393. package/src/debug/i18n/pl.ts +51 -0
  394. package/src/debug/i18n/ro.ts +52 -0
  395. package/src/debug/i18n/ru.ts +51 -0
  396. package/src/debug/i18n/si.ts +50 -0
  397. package/src/debug/i18n/sk.ts +52 -0
  398. package/src/debug/i18n/sl.ts +50 -0
  399. package/src/debug/i18n/sq.ts +52 -0
  400. package/src/debug/i18n/sr.ts +52 -0
  401. package/src/debug/i18n/sv.ts +51 -0
  402. package/src/debug/i18n/tg.ts +51 -0
  403. package/src/debug/i18n/th.ts +50 -0
  404. package/src/debug/i18n/tk.ts +51 -0
  405. package/src/debug/i18n/tr.ts +50 -0
  406. package/src/debug/i18n/uk.ts +50 -0
  407. package/src/debug/i18n/ur.ts +50 -0
  408. package/src/debug/i18n/uz.ts +51 -0
  409. package/src/debug/i18n/vi.ts +51 -0
  410. package/src/debug/i18n/zh.ts +49 -0
  411. package/src/debug/i18n/zht.ts +50 -0
  412. package/src/debug/index.ts +79 -0
  413. package/src/debug/main.ts +417 -0
  414. package/src/debug/memory-infra.ts +159 -0
  415. package/src/debug/memory-log.ts +65 -0
  416. package/src/debug/memory-machine.ts +151 -0
  417. package/src/debug/memory-record.ts +36 -0
  418. package/src/debug/motion-machine.ts +229 -0
  419. package/src/debug/motion.tsx +697 -0
  420. package/src/debug/options.ts +15 -0
  421. package/src/debug/renderer.tsx +185 -0
  422. package/src/debug/server-heap.ts +63 -0
  423. package/src/debug/signal.ts +13 -0
  424. package/src/details/config-action-machine.ts +107 -0
  425. package/src/details/config-file.ts +43 -0
  426. package/src/details/details.css +555 -0
  427. package/src/details/flyout-machine.ts +252 -0
  428. package/src/details/flyout-motion.ts +26 -0
  429. package/src/details/i18n/am.ts +68 -0
  430. package/src/details/i18n/ar.ts +71 -0
  431. package/src/details/i18n/az.ts +71 -0
  432. package/src/details/i18n/bg.ts +73 -0
  433. package/src/details/i18n/bn.ts +71 -0
  434. package/src/details/i18n/br.ts +71 -0
  435. package/src/details/i18n/bs.ts +72 -0
  436. package/src/details/i18n/ca.ts +72 -0
  437. package/src/details/i18n/cs.ts +71 -0
  438. package/src/details/i18n/da.ts +71 -0
  439. package/src/details/i18n/de.ts +73 -0
  440. package/src/details/i18n/dv.ts +73 -0
  441. package/src/details/i18n/dz.ts +72 -0
  442. package/src/details/i18n/el.ts +73 -0
  443. package/src/details/i18n/en.ts +71 -0
  444. package/src/details/i18n/es.ts +72 -0
  445. package/src/details/i18n/et.ts +72 -0
  446. package/src/details/i18n/fa.ts +71 -0
  447. package/src/details/i18n/fi.ts +71 -0
  448. package/src/details/i18n/fo.ts +72 -0
  449. package/src/details/i18n/fr.ts +73 -0
  450. package/src/details/i18n/he.ts +71 -0
  451. package/src/details/i18n/hi.ts +71 -0
  452. package/src/details/i18n/hr.ts +72 -0
  453. package/src/details/i18n/hu.ts +72 -0
  454. package/src/details/i18n/hy.ts +72 -0
  455. package/src/details/i18n/id.ts +71 -0
  456. package/src/details/i18n/is.ts +71 -0
  457. package/src/details/i18n/it.ts +73 -0
  458. package/src/details/i18n/ja.ts +71 -0
  459. package/src/details/i18n/ka.ts +72 -0
  460. package/src/details/i18n/km.ts +72 -0
  461. package/src/details/i18n/ko.ts +71 -0
  462. package/src/details/i18n/lo.ts +72 -0
  463. package/src/details/i18n/lt.ts +72 -0
  464. package/src/details/i18n/lv.ts +72 -0
  465. package/src/details/i18n/mk.ts +73 -0
  466. package/src/details/i18n/mn.ts +71 -0
  467. package/src/details/i18n/ms.ts +71 -0
  468. package/src/details/i18n/my.ts +72 -0
  469. package/src/details/i18n/ne.ts +71 -0
  470. package/src/details/i18n/nl.ts +71 -0
  471. package/src/details/i18n/no.ts +71 -0
  472. package/src/details/i18n/pa.ts +71 -0
  473. package/src/details/i18n/pl.ts +72 -0
  474. package/src/details/i18n/ro.ts +72 -0
  475. package/src/details/i18n/ru.ts +72 -0
  476. package/src/details/i18n/si.ts +71 -0
  477. package/src/details/i18n/sk.ts +71 -0
  478. package/src/details/i18n/sl.ts +73 -0
  479. package/src/details/i18n/sq.ts +71 -0
  480. package/src/details/i18n/sr.ts +72 -0
  481. package/src/details/i18n/sv.ts +72 -0
  482. package/src/details/i18n/tg.ts +71 -0
  483. package/src/details/i18n/th.ts +72 -0
  484. package/src/details/i18n/tk.ts +72 -0
  485. package/src/details/i18n/tr.ts +71 -0
  486. package/src/details/i18n/uk.ts +71 -0
  487. package/src/details/i18n/ur.ts +71 -0
  488. package/src/details/i18n/uz.ts +72 -0
  489. package/src/details/i18n/vi.ts +71 -0
  490. package/src/details/i18n/zh.ts +69 -0
  491. package/src/details/i18n/zht.ts +70 -0
  492. package/src/details/index.ts +71 -0
  493. package/src/details/location-menu.tsx +82 -0
  494. package/src/details/location-workspace.tsx +39 -0
  495. package/src/details/mcp-machine.ts +278 -0
  496. package/src/details/panel.tsx +27 -0
  497. package/src/details/paths.ts +17 -0
  498. package/src/details/popover-machine.ts +97 -0
  499. package/src/details/popover.tsx +179 -0
  500. package/src/details/renderer.tsx +99 -0
  501. package/src/details/server-panel.tsx +1632 -0
  502. package/src/details/service-load-machine.ts +246 -0
  503. package/src/details/workspace-menu.tsx +490 -0
  504. package/src/details/workspace-move-machine.ts +643 -0
  505. package/src/file/apps.ts +25 -0
  506. package/src/file/arrival-guard-machine.ts +59 -0
  507. package/src/file/artifact-toolbar.tsx +161 -0
  508. package/src/file/artifact-view-machine.ts +396 -0
  509. package/src/file/artifact-view.css +336 -0
  510. package/src/file/artifact-view.tsx +1031 -0
  511. package/src/file/artifact.ts +225 -0
  512. package/src/file/browser.stories.tsx +57 -0
  513. package/src/file/browser.tsx +502 -0
  514. package/src/file/context.ts +67 -0
  515. package/src/file/contract.ts +10 -0
  516. package/src/file/drag.ts +35 -0
  517. package/src/file/find.tsx +376 -0
  518. package/src/file/i18n/am.ts +56 -0
  519. package/src/file/i18n/ar.ts +64 -0
  520. package/src/file/i18n/az.ts +56 -0
  521. package/src/file/i18n/bg.ts +56 -0
  522. package/src/file/i18n/bn.ts +56 -0
  523. package/src/file/i18n/br.ts +58 -0
  524. package/src/file/i18n/bs.ts +58 -0
  525. package/src/file/i18n/ca.ts +58 -0
  526. package/src/file/i18n/cs.ts +60 -0
  527. package/src/file/i18n/da.ts +56 -0
  528. package/src/file/i18n/de.ts +56 -0
  529. package/src/file/i18n/dv.ts +56 -0
  530. package/src/file/i18n/dz.ts +56 -0
  531. package/src/file/i18n/el.ts +56 -0
  532. package/src/file/i18n/en.ts +63 -0
  533. package/src/file/i18n/es.ts +58 -0
  534. package/src/file/i18n/et.ts +56 -0
  535. package/src/file/i18n/fa.ts +56 -0
  536. package/src/file/i18n/fi.ts +56 -0
  537. package/src/file/i18n/fo.ts +56 -0
  538. package/src/file/i18n/fr.ts +58 -0
  539. package/src/file/i18n/he.ts +58 -0
  540. package/src/file/i18n/hi.ts +56 -0
  541. package/src/file/i18n/hr.ts +58 -0
  542. package/src/file/i18n/hu.ts +56 -0
  543. package/src/file/i18n/hy.ts +56 -0
  544. package/src/file/i18n/id.ts +56 -0
  545. package/src/file/i18n/is.ts +56 -0
  546. package/src/file/i18n/it.ts +58 -0
  547. package/src/file/i18n/ja.ts +56 -0
  548. package/src/file/i18n/ka.ts +56 -0
  549. package/src/file/i18n/km.ts +56 -0
  550. package/src/file/i18n/ko.ts +56 -0
  551. package/src/file/i18n/lo.ts +56 -0
  552. package/src/file/i18n/lt.ts +60 -0
  553. package/src/file/i18n/lv.ts +58 -0
  554. package/src/file/i18n/mk.ts +56 -0
  555. package/src/file/i18n/mn.ts +56 -0
  556. package/src/file/i18n/ms.ts +56 -0
  557. package/src/file/i18n/my.ts +56 -0
  558. package/src/file/i18n/ne.ts +56 -0
  559. package/src/file/i18n/nl.ts +56 -0
  560. package/src/file/i18n/no.ts +56 -0
  561. package/src/file/i18n/pa.ts +56 -0
  562. package/src/file/i18n/pl.ts +60 -0
  563. package/src/file/i18n/ro.ts +58 -0
  564. package/src/file/i18n/ru.ts +60 -0
  565. package/src/file/i18n/si.ts +56 -0
  566. package/src/file/i18n/sk.ts +60 -0
  567. package/src/file/i18n/sl.ts +60 -0
  568. package/src/file/i18n/sq.ts +56 -0
  569. package/src/file/i18n/sr.ts +58 -0
  570. package/src/file/i18n/sv.ts +56 -0
  571. package/src/file/i18n/tg.ts +56 -0
  572. package/src/file/i18n/th.ts +56 -0
  573. package/src/file/i18n/tk.ts +56 -0
  574. package/src/file/i18n/tr.ts +56 -0
  575. package/src/file/i18n/uk.ts +60 -0
  576. package/src/file/i18n/ur.ts +57 -0
  577. package/src/file/i18n/uz.ts +56 -0
  578. package/src/file/i18n/vi.ts +56 -0
  579. package/src/file/i18n/zh.ts +56 -0
  580. package/src/file/i18n/zht.ts +56 -0
  581. package/src/file/index.ts +76 -0
  582. package/src/file/label.tsx +22 -0
  583. package/src/file/link-exists-machine.ts +137 -0
  584. package/src/file/link-open-machine.ts +249 -0
  585. package/src/file/list.tsx +224 -0
  586. package/src/file/mobile.css +35 -0
  587. package/src/file/mobile.tsx +116 -0
  588. package/src/file/open-in-app-machine.ts +185 -0
  589. package/src/file/open-in-app.tsx +395 -0
  590. package/src/file/path.ts +43 -0
  591. package/src/file/picker-machine.ts +190 -0
  592. package/src/file/pierre-tree-machine.ts +679 -0
  593. package/src/file/pierre-tree.tsx +503 -0
  594. package/src/file/renderer.tsx +1030 -0
  595. package/src/file/resolve-link.ts +152 -0
  596. package/src/file/scroll-machine.ts +272 -0
  597. package/src/file/search-machine.ts +202 -0
  598. package/src/file/styles.ts +5 -0
  599. package/src/file/tabs.css +15 -0
  600. package/src/file/tree-focus.css +6 -0
  601. package/src/file/tree-model.ts +239 -0
  602. package/src/file/view.tsx +572 -0
  603. package/src/goal/goal.css +43 -0
  604. package/src/goal/i18n/en.ts +12 -0
  605. package/src/goal/icons/active.svg +13 -0
  606. package/src/goal/icons/complete.svg +4 -0
  607. package/src/goal/icons/paused.svg +4 -0
  608. package/src/goal/index.ts +9 -0
  609. package/src/goal/machine.ts +364 -0
  610. package/src/goal/renderer.tsx +287 -0
  611. package/src/icon-name.typecheck.ts +9 -0
  612. package/src/main.ts +35 -0
  613. package/src/microsoft-office/document.tsx +436 -0
  614. package/src/microsoft-office/document.worker.ts +360 -0
  615. package/src/microsoft-office/fonts-cjk.ts +3 -0
  616. package/src/microsoft-office/fonts.ts +75 -0
  617. package/src/microsoft-office/i18n/en.ts +22 -0
  618. package/src/microsoft-office/index.ts +7 -0
  619. package/src/microsoft-office/links.ts +22 -0
  620. package/src/microsoft-office/office-worker.ts +124 -0
  621. package/src/microsoft-office/pages-machine.ts +356 -0
  622. package/src/microsoft-office/pages.tsx +387 -0
  623. package/src/microsoft-office/paper.ts +2 -0
  624. package/src/microsoft-office/presentation.tsx +303 -0
  625. package/src/microsoft-office/presentation.worker.ts +373 -0
  626. package/src/microsoft-office/renderer.tsx +57 -0
  627. package/src/microsoft-office/sheet-activate.ts +35 -0
  628. package/src/microsoft-office/sheet-cells.ts +188 -0
  629. package/src/microsoft-office/sheet-frame-machine.ts +286 -0
  630. package/src/microsoft-office/sheet-frame.ts +158 -0
  631. package/src/microsoft-office/sheet-paint.ts +357 -0
  632. package/src/microsoft-office/sheet-pick-machine.ts +138 -0
  633. package/src/microsoft-office/sheet-pointer-machine.ts +169 -0
  634. package/src/microsoft-office/sheet-protocol.ts +88 -0
  635. package/src/microsoft-office/slide-fonts-machine.ts +290 -0
  636. package/src/microsoft-office/slide-fonts.ts +157 -0
  637. package/src/microsoft-office/slide-paint-machine.ts +322 -0
  638. package/src/microsoft-office/slide-protocol.ts +50 -0
  639. package/src/microsoft-office/slide-text.ts +334 -0
  640. package/src/microsoft-office/spreadsheet.tsx +1165 -0
  641. package/src/microsoft-office/spreadsheet.worker.ts +259 -0
  642. package/src/microsoft-office/word-images.ts +105 -0
  643. package/src/microsoft-office/word-layout-machine.ts +219 -0
  644. package/src/microsoft-office/word-paint-machine.ts +174 -0
  645. package/src/microsoft-office/word-protocol.ts +78 -0
  646. package/src/microsoft-office/word-text.ts +260 -0
  647. package/src/microsoft-office/worker-machine.ts +111 -0
  648. package/src/microsoft-office/worker-rpc-machine.ts +336 -0
  649. package/src/microsoft-office/worker-rpc.fixture.ts +90 -0
  650. package/src/microsoft-office/worker-rpc.ts +292 -0
  651. package/src/pairing/contract.ts +24 -0
  652. package/src/pairing/copy-machine.ts +107 -0
  653. package/src/pairing/dialog.stories.tsx +69 -0
  654. package/src/pairing/dispatch.ts +42 -0
  655. package/src/pairing/i18n/en.ts +28 -0
  656. package/src/pairing/icons/pair.svg +4 -0
  657. package/src/pairing/index.ts +5 -0
  658. package/src/pairing/machine.ts +869 -0
  659. package/src/pairing/main-machine.ts +239 -0
  660. package/src/pairing/main.ts +130 -0
  661. package/src/pairing/page.stories.tsx +108 -0
  662. package/src/pairing/page.tsx +486 -0
  663. package/src/pairing/remote.ts +7 -0
  664. package/src/pairing/renderer.tsx +66 -0
  665. package/src/renderer.ts +55 -0
  666. package/src/review/contract.ts +31 -0
  667. package/src/review/detail-machine.ts +250 -0
  668. package/src/review/folder-machine.ts +404 -0
  669. package/src/review/i18n/am.ts +23 -0
  670. package/src/review/i18n/ar.ts +35 -0
  671. package/src/review/i18n/az.ts +23 -0
  672. package/src/review/i18n/bg.ts +23 -0
  673. package/src/review/i18n/bn.ts +23 -0
  674. package/src/review/i18n/br.ts +27 -0
  675. package/src/review/i18n/bs.ts +26 -0
  676. package/src/review/i18n/ca.ts +27 -0
  677. package/src/review/i18n/cs.ts +29 -0
  678. package/src/review/i18n/da.ts +23 -0
  679. package/src/review/i18n/de.ts +23 -0
  680. package/src/review/i18n/dv.ts +24 -0
  681. package/src/review/i18n/dz.ts +24 -0
  682. package/src/review/i18n/el.ts +23 -0
  683. package/src/review/i18n/en.ts +28 -0
  684. package/src/review/i18n/es.ts +27 -0
  685. package/src/review/i18n/et.ts +23 -0
  686. package/src/review/i18n/fa.ts +23 -0
  687. package/src/review/i18n/fi.ts +23 -0
  688. package/src/review/i18n/fo.ts +23 -0
  689. package/src/review/i18n/fr.ts +27 -0
  690. package/src/review/i18n/he.ts +26 -0
  691. package/src/review/i18n/hi.ts +23 -0
  692. package/src/review/i18n/hr.ts +26 -0
  693. package/src/review/i18n/hu.ts +23 -0
  694. package/src/review/i18n/hy.ts +23 -0
  695. package/src/review/i18n/id.ts +24 -0
  696. package/src/review/i18n/is.ts +23 -0
  697. package/src/review/i18n/it.ts +27 -0
  698. package/src/review/i18n/ja.ts +23 -0
  699. package/src/review/i18n/ka.ts +23 -0
  700. package/src/review/i18n/km.ts +23 -0
  701. package/src/review/i18n/ko.ts +23 -0
  702. package/src/review/i18n/lo.ts +23 -0
  703. package/src/review/i18n/lt.ts +29 -0
  704. package/src/review/i18n/lv.ts +26 -0
  705. package/src/review/i18n/mk.ts +23 -0
  706. package/src/review/i18n/mn.ts +23 -0
  707. package/src/review/i18n/ms.ts +24 -0
  708. package/src/review/i18n/my.ts +24 -0
  709. package/src/review/i18n/ne.ts +23 -0
  710. package/src/review/i18n/nl.ts +23 -0
  711. package/src/review/i18n/no.ts +23 -0
  712. package/src/review/i18n/pa.ts +23 -0
  713. package/src/review/i18n/pl.ts +29 -0
  714. package/src/review/i18n/ro.ts +26 -0
  715. package/src/review/i18n/ru.ts +29 -0
  716. package/src/review/i18n/si.ts +23 -0
  717. package/src/review/i18n/sk.ts +29 -0
  718. package/src/review/i18n/sl.ts +29 -0
  719. package/src/review/i18n/sq.ts +24 -0
  720. package/src/review/i18n/sr.ts +27 -0
  721. package/src/review/i18n/sv.ts +23 -0
  722. package/src/review/i18n/tg.ts +23 -0
  723. package/src/review/i18n/th.ts +23 -0
  724. package/src/review/i18n/tk.ts +23 -0
  725. package/src/review/i18n/tr.ts +23 -0
  726. package/src/review/i18n/uk.ts +30 -0
  727. package/src/review/i18n/ur.ts +23 -0
  728. package/src/review/i18n/uz.ts +23 -0
  729. package/src/review/i18n/vi.ts +24 -0
  730. package/src/review/i18n/zh.ts +23 -0
  731. package/src/review/i18n/zht.ts +23 -0
  732. package/src/review/index.ts +138 -0
  733. package/src/review/init-git-machine.ts +152 -0
  734. package/src/review/kinds.ts +191 -0
  735. package/src/review/machine.ts +274 -0
  736. package/src/review/mobile.tsx +91 -0
  737. package/src/review/model.ts +1123 -0
  738. package/src/review/panel.stories.tsx +50 -0
  739. package/src/review/panel.tsx +516 -0
  740. package/src/review/parts.tsx +141 -0
  741. package/src/review/render-machine.ts +74 -0
  742. package/src/review/renderer.tsx +403 -0
  743. package/src/review/screen-machine.ts +199 -0
  744. package/src/review/scroll-machine.ts +265 -0
  745. package/src/review/settings.tsx +28 -0
  746. package/src/schemes.ts +9 -0
  747. package/src/sources/i18n/en.ts +3 -0
  748. package/src/sources/index.ts +4 -0
  749. package/src/sources/panel.tsx +36 -0
  750. package/src/sources/renderer.tsx +95 -0
  751. package/src/ssh/add-machine.ts +63 -0
  752. package/src/ssh/askpass.ts +94 -0
  753. package/src/ssh/bootstrap.ts +160 -0
  754. package/src/ssh/command.ts +243 -0
  755. package/src/ssh/contract.ts +89 -0
  756. package/src/ssh/controller.ts +345 -0
  757. package/src/ssh/cover.tsx +66 -0
  758. package/src/ssh/dialog-machine.ts +249 -0
  759. package/src/ssh/dialog.stories.tsx +348 -0
  760. package/src/ssh/dialog.tsx +236 -0
  761. package/src/ssh/i18n/am.ts +37 -0
  762. package/src/ssh/i18n/ar.ts +38 -0
  763. package/src/ssh/i18n/az.ts +43 -0
  764. package/src/ssh/i18n/bg.ts +42 -0
  765. package/src/ssh/i18n/bn.ts +41 -0
  766. package/src/ssh/i18n/br.ts +43 -0
  767. package/src/ssh/i18n/bs.ts +43 -0
  768. package/src/ssh/i18n/ca.ts +43 -0
  769. package/src/ssh/i18n/cs.ts +43 -0
  770. package/src/ssh/i18n/da.ts +43 -0
  771. package/src/ssh/i18n/de.ts +44 -0
  772. package/src/ssh/i18n/dv.ts +43 -0
  773. package/src/ssh/i18n/dz.ts +43 -0
  774. package/src/ssh/i18n/el.ts +45 -0
  775. package/src/ssh/i18n/en.ts +40 -0
  776. package/src/ssh/i18n/es.ts +43 -0
  777. package/src/ssh/i18n/et.ts +41 -0
  778. package/src/ssh/i18n/fa.ts +39 -0
  779. package/src/ssh/i18n/fi.ts +40 -0
  780. package/src/ssh/i18n/fo.ts +41 -0
  781. package/src/ssh/i18n/fr.ts +43 -0
  782. package/src/ssh/i18n/he.ts +37 -0
  783. package/src/ssh/i18n/hi.ts +40 -0
  784. package/src/ssh/i18n/hr.ts +43 -0
  785. package/src/ssh/i18n/hu.ts +43 -0
  786. package/src/ssh/i18n/hy.ts +41 -0
  787. package/src/ssh/i18n/id.ts +42 -0
  788. package/src/ssh/i18n/is.ts +40 -0
  789. package/src/ssh/i18n/it.ts +43 -0
  790. package/src/ssh/i18n/ja.ts +43 -0
  791. package/src/ssh/i18n/ka.ts +43 -0
  792. package/src/ssh/i18n/km.ts +41 -0
  793. package/src/ssh/i18n/ko.ts +40 -0
  794. package/src/ssh/i18n/lo.ts +39 -0
  795. package/src/ssh/i18n/lt.ts +41 -0
  796. package/src/ssh/i18n/lv.ts +42 -0
  797. package/src/ssh/i18n/mk.ts +43 -0
  798. package/src/ssh/i18n/mn.ts +41 -0
  799. package/src/ssh/i18n/ms.ts +40 -0
  800. package/src/ssh/i18n/my.ts +41 -0
  801. package/src/ssh/i18n/ne.ts +39 -0
  802. package/src/ssh/i18n/nl.ts +43 -0
  803. package/src/ssh/i18n/no.ts +42 -0
  804. package/src/ssh/i18n/pa.ts +40 -0
  805. package/src/ssh/i18n/pl.ts +42 -0
  806. package/src/ssh/i18n/ro.ts +44 -0
  807. package/src/ssh/i18n/ru.ts +42 -0
  808. package/src/ssh/i18n/si.ts +41 -0
  809. package/src/ssh/i18n/sk.ts +42 -0
  810. package/src/ssh/i18n/sl.ts +41 -0
  811. package/src/ssh/i18n/sq.ts +43 -0
  812. package/src/ssh/i18n/sr.ts +41 -0
  813. package/src/ssh/i18n/sv.ts +43 -0
  814. package/src/ssh/i18n/tg.ts +43 -0
  815. package/src/ssh/i18n/th.ts +38 -0
  816. package/src/ssh/i18n/tk.ts +41 -0
  817. package/src/ssh/i18n/tr.ts +42 -0
  818. package/src/ssh/i18n/uk.ts +40 -0
  819. package/src/ssh/i18n/ur.ts +40 -0
  820. package/src/ssh/i18n/uz.ts +43 -0
  821. package/src/ssh/i18n/vi.ts +42 -0
  822. package/src/ssh/i18n/zh.ts +36 -0
  823. package/src/ssh/i18n/zht.ts +36 -0
  824. package/src/ssh/index.ts +71 -0
  825. package/src/ssh/main-machine.ts +532 -0
  826. package/src/ssh/main.ts +75 -0
  827. package/src/ssh/name.ts +28 -0
  828. package/src/ssh/remote-cli.ts +137 -0
  829. package/src/ssh/renderer.tsx +254 -0
  830. package/src/ssh/row.tsx +97 -0
  831. package/src/ssh/ssh.css +35 -0
  832. package/src/ssh/state.ts +217 -0
  833. package/src/ssh/window-machine.ts +533 -0
  834. package/src/terminal/connection-machine.ts +285 -0
  835. package/src/terminal/connection.ts +112 -0
  836. package/src/terminal/dispatch.ts +44 -0
  837. package/src/terminal/focus-machine.ts +112 -0
  838. package/src/terminal/focus.ts +23 -0
  839. package/src/terminal/hover-label.ts +20 -0
  840. package/src/terminal/i18n/am.ts +28 -0
  841. package/src/terminal/i18n/ar.ts +28 -0
  842. package/src/terminal/i18n/az.ts +29 -0
  843. package/src/terminal/i18n/bg.ts +29 -0
  844. package/src/terminal/i18n/bn.ts +28 -0
  845. package/src/terminal/i18n/br.ts +29 -0
  846. package/src/terminal/i18n/bs.ts +29 -0
  847. package/src/terminal/i18n/ca.ts +28 -0
  848. package/src/terminal/i18n/cs.ts +28 -0
  849. package/src/terminal/i18n/da.ts +28 -0
  850. package/src/terminal/i18n/de.ts +29 -0
  851. package/src/terminal/i18n/dv.ts +28 -0
  852. package/src/terminal/i18n/dz.ts +28 -0
  853. package/src/terminal/i18n/el.ts +30 -0
  854. package/src/terminal/i18n/en.ts +30 -0
  855. package/src/terminal/i18n/es.ts +28 -0
  856. package/src/terminal/i18n/et.ts +28 -0
  857. package/src/terminal/i18n/fa.ts +28 -0
  858. package/src/terminal/i18n/fi.ts +29 -0
  859. package/src/terminal/i18n/fo.ts +28 -0
  860. package/src/terminal/i18n/fr.ts +29 -0
  861. package/src/terminal/i18n/he.ts +28 -0
  862. package/src/terminal/i18n/hi.ts +28 -0
  863. package/src/terminal/i18n/hr.ts +28 -0
  864. package/src/terminal/i18n/hu.ts +28 -0
  865. package/src/terminal/i18n/hy.ts +29 -0
  866. package/src/terminal/i18n/id.ts +28 -0
  867. package/src/terminal/i18n/is.ts +28 -0
  868. package/src/terminal/i18n/it.ts +28 -0
  869. package/src/terminal/i18n/ja.ts +29 -0
  870. package/src/terminal/i18n/ka.ts +29 -0
  871. package/src/terminal/i18n/km.ts +28 -0
  872. package/src/terminal/i18n/ko.ts +28 -0
  873. package/src/terminal/i18n/lo.ts +28 -0
  874. package/src/terminal/i18n/lt.ts +29 -0
  875. package/src/terminal/i18n/lv.ts +28 -0
  876. package/src/terminal/i18n/mk.ts +29 -0
  877. package/src/terminal/i18n/mn.ts +30 -0
  878. package/src/terminal/i18n/ms.ts +28 -0
  879. package/src/terminal/i18n/my.ts +29 -0
  880. package/src/terminal/i18n/ne.ts +28 -0
  881. package/src/terminal/i18n/nl.ts +28 -0
  882. package/src/terminal/i18n/no.ts +28 -0
  883. package/src/terminal/i18n/pa.ts +28 -0
  884. package/src/terminal/i18n/pl.ts +28 -0
  885. package/src/terminal/i18n/ro.ts +28 -0
  886. package/src/terminal/i18n/ru.ts +28 -0
  887. package/src/terminal/i18n/si.ts +28 -0
  888. package/src/terminal/i18n/sk.ts +28 -0
  889. package/src/terminal/i18n/sl.ts +28 -0
  890. package/src/terminal/i18n/sq.ts +29 -0
  891. package/src/terminal/i18n/sr.ts +28 -0
  892. package/src/terminal/i18n/sv.ts +28 -0
  893. package/src/terminal/i18n/tg.ts +29 -0
  894. package/src/terminal/i18n/th.ts +28 -0
  895. package/src/terminal/i18n/tk.ts +29 -0
  896. package/src/terminal/i18n/tr.ts +29 -0
  897. package/src/terminal/i18n/uk.ts +28 -0
  898. package/src/terminal/i18n/ur.ts +28 -0
  899. package/src/terminal/i18n/uz.ts +29 -0
  900. package/src/terminal/i18n/vi.ts +28 -0
  901. package/src/terminal/i18n/zh.ts +28 -0
  902. package/src/terminal/i18n/zht.ts +28 -0
  903. package/src/terminal/index.ts +74 -0
  904. package/src/terminal/inline-rename.ts +93 -0
  905. package/src/terminal/label.tsx +71 -0
  906. package/src/terminal/machine.ts +767 -0
  907. package/src/terminal/model.ts +661 -0
  908. package/src/terminal/pane-machine.ts +260 -0
  909. package/src/terminal/panel.tsx +280 -0
  910. package/src/terminal/props.ts +16 -0
  911. package/src/terminal/quote-machine.ts +381 -0
  912. package/src/terminal/quote.css +7 -0
  913. package/src/terminal/quote.tsx +218 -0
  914. package/src/terminal/rename-machine.ts +98 -0
  915. package/src/terminal/renderer.tsx +298 -0
  916. package/src/terminal/runtime-adapters.ts +34 -0
  917. package/src/terminal/surface-machine.ts +186 -0
  918. package/src/terminal/tab.tsx +112 -0
  919. package/src/terminal/terminal-key-event.ts +58 -0
  920. package/src/terminal/terminal.fixture.tsx +71 -0
  921. package/src/terminal/terminal.tsx +652 -0
  922. package/src/terminal/title.ts +41 -0
  923. package/src/terminal/writer.ts +87 -0
  924. package/src/updater/action.ts +37 -0
  925. package/src/updater/actions.tsx +110 -0
  926. package/src/updater/i18n/am.ts +40 -0
  927. package/src/updater/i18n/ar.ts +40 -0
  928. package/src/updater/i18n/az.ts +41 -0
  929. package/src/updater/i18n/bg.ts +40 -0
  930. package/src/updater/i18n/bn.ts +41 -0
  931. package/src/updater/i18n/br.ts +40 -0
  932. package/src/updater/i18n/bs.ts +41 -0
  933. package/src/updater/i18n/ca.ts +41 -0
  934. package/src/updater/i18n/cs.ts +41 -0
  935. package/src/updater/i18n/da.ts +40 -0
  936. package/src/updater/i18n/de.ts +41 -0
  937. package/src/updater/i18n/dv.ts +41 -0
  938. package/src/updater/i18n/dz.ts +42 -0
  939. package/src/updater/i18n/el.ts +42 -0
  940. package/src/updater/i18n/en.ts +42 -0
  941. package/src/updater/i18n/es.ts +40 -0
  942. package/src/updater/i18n/et.ts +40 -0
  943. package/src/updater/i18n/fa.ts +40 -0
  944. package/src/updater/i18n/fi.ts +41 -0
  945. package/src/updater/i18n/fo.ts +40 -0
  946. package/src/updater/i18n/fr.ts +41 -0
  947. package/src/updater/i18n/he.ts +40 -0
  948. package/src/updater/i18n/hi.ts +40 -0
  949. package/src/updater/i18n/hr.ts +41 -0
  950. package/src/updater/i18n/hu.ts +40 -0
  951. package/src/updater/i18n/hy.ts +41 -0
  952. package/src/updater/i18n/id.ts +41 -0
  953. package/src/updater/i18n/is.ts +40 -0
  954. package/src/updater/i18n/it.ts +40 -0
  955. package/src/updater/i18n/ja.ts +41 -0
  956. package/src/updater/i18n/ka.ts +40 -0
  957. package/src/updater/i18n/km.ts +40 -0
  958. package/src/updater/i18n/ko.ts +40 -0
  959. package/src/updater/i18n/lo.ts +40 -0
  960. package/src/updater/i18n/lt.ts +41 -0
  961. package/src/updater/i18n/lv.ts +40 -0
  962. package/src/updater/i18n/mk.ts +41 -0
  963. package/src/updater/i18n/mn.ts +40 -0
  964. package/src/updater/i18n/ms.ts +41 -0
  965. package/src/updater/i18n/my.ts +40 -0
  966. package/src/updater/i18n/ne.ts +40 -0
  967. package/src/updater/i18n/nl.ts +41 -0
  968. package/src/updater/i18n/no.ts +40 -0
  969. package/src/updater/i18n/pa.ts +40 -0
  970. package/src/updater/i18n/pl.ts +41 -0
  971. package/src/updater/i18n/ro.ts +41 -0
  972. package/src/updater/i18n/ru.ts +40 -0
  973. package/src/updater/i18n/si.ts +40 -0
  974. package/src/updater/i18n/sk.ts +41 -0
  975. package/src/updater/i18n/sl.ts +40 -0
  976. package/src/updater/i18n/sq.ts +40 -0
  977. package/src/updater/i18n/sr.ts +41 -0
  978. package/src/updater/i18n/sv.ts +40 -0
  979. package/src/updater/i18n/tg.ts +41 -0
  980. package/src/updater/i18n/th.ts +40 -0
  981. package/src/updater/i18n/tk.ts +40 -0
  982. package/src/updater/i18n/tr.ts +40 -0
  983. package/src/updater/i18n/uk.ts +40 -0
  984. package/src/updater/i18n/ur.ts +40 -0
  985. package/src/updater/i18n/uz.ts +41 -0
  986. package/src/updater/i18n/vi.ts +41 -0
  987. package/src/updater/i18n/zh.ts +40 -0
  988. package/src/updater/i18n/zht.ts +40 -0
  989. package/src/updater/index.ts +94 -0
  990. package/src/updater/log.ts +41 -0
  991. package/src/updater/machine.ts +919 -0
  992. package/src/updater/main.ts +138 -0
  993. package/src/updater/platform.ts +160 -0
  994. package/src/updater/renderer.tsx +203 -0
  995. package/src/updater/section.tsx +65 -0
  996. package/src/updater/web-driver.ts +200 -0
  997. package/src/updater/web-machine.ts +222 -0
  998. package/src/updater/web.tsx +103 -0
  999. package/src/updater/whats-new-machine.ts +97 -0
  1000. package/src/updater/whats-new.stories.tsx +38 -0
  1001. package/src/updater/whats-new.tsx +304 -0
  1002. package/src/updater/window-machine.ts +73 -0
  1003. package/src/wsl/add-machine.ts +56 -0
  1004. package/src/wsl/contract.ts +104 -0
  1005. package/src/wsl/dialog-machine.ts +322 -0
  1006. package/src/wsl/dialog.css +372 -0
  1007. package/src/wsl/dialog.tsx +492 -0
  1008. package/src/wsl/i18n/am.ts +53 -0
  1009. package/src/wsl/i18n/ar.ts +55 -0
  1010. package/src/wsl/i18n/az.ts +57 -0
  1011. package/src/wsl/i18n/bg.ts +58 -0
  1012. package/src/wsl/i18n/bn.ts +56 -0
  1013. package/src/wsl/i18n/br.ts +58 -0
  1014. package/src/wsl/i18n/bs.ts +58 -0
  1015. package/src/wsl/i18n/ca.ts +58 -0
  1016. package/src/wsl/i18n/cs.ts +57 -0
  1017. package/src/wsl/i18n/da.ts +57 -0
  1018. package/src/wsl/i18n/de.ts +59 -0
  1019. package/src/wsl/i18n/dv.ts +58 -0
  1020. package/src/wsl/i18n/dz.ts +59 -0
  1021. package/src/wsl/i18n/el.ts +57 -0
  1022. package/src/wsl/i18n/en.ts +55 -0
  1023. package/src/wsl/i18n/es.ts +58 -0
  1024. package/src/wsl/i18n/et.ts +55 -0
  1025. package/src/wsl/i18n/fa.ts +56 -0
  1026. package/src/wsl/i18n/fi.ts +57 -0
  1027. package/src/wsl/i18n/fo.ts +56 -0
  1028. package/src/wsl/i18n/fr.ts +57 -0
  1029. package/src/wsl/i18n/he.ts +54 -0
  1030. package/src/wsl/i18n/hi.ts +57 -0
  1031. package/src/wsl/i18n/hr.ts +58 -0
  1032. package/src/wsl/i18n/hu.ts +58 -0
  1033. package/src/wsl/i18n/hy.ts +57 -0
  1034. package/src/wsl/i18n/id.ts +56 -0
  1035. package/src/wsl/i18n/is.ts +55 -0
  1036. package/src/wsl/i18n/it.ts +57 -0
  1037. package/src/wsl/i18n/ja.ts +57 -0
  1038. package/src/wsl/i18n/ka.ts +56 -0
  1039. package/src/wsl/i18n/km.ts +57 -0
  1040. package/src/wsl/i18n/ko.ts +56 -0
  1041. package/src/wsl/i18n/lo.ts +54 -0
  1042. package/src/wsl/i18n/lt.ts +57 -0
  1043. package/src/wsl/i18n/lv.ts +57 -0
  1044. package/src/wsl/i18n/mk.ts +57 -0
  1045. package/src/wsl/i18n/mn.ts +58 -0
  1046. package/src/wsl/i18n/ms.ts +57 -0
  1047. package/src/wsl/i18n/my.ts +57 -0
  1048. package/src/wsl/i18n/ne.ts +57 -0
  1049. package/src/wsl/i18n/nl.ts +57 -0
  1050. package/src/wsl/i18n/no.ts +57 -0
  1051. package/src/wsl/i18n/pa.ts +57 -0
  1052. package/src/wsl/i18n/pl.ts +58 -0
  1053. package/src/wsl/i18n/ro.ts +56 -0
  1054. package/src/wsl/i18n/ru.ts +57 -0
  1055. package/src/wsl/i18n/si.ts +56 -0
  1056. package/src/wsl/i18n/sk.ts +57 -0
  1057. package/src/wsl/i18n/sl.ts +57 -0
  1058. package/src/wsl/i18n/sq.ts +56 -0
  1059. package/src/wsl/i18n/sr.ts +57 -0
  1060. package/src/wsl/i18n/sv.ts +58 -0
  1061. package/src/wsl/i18n/tg.ts +57 -0
  1062. package/src/wsl/i18n/th.ts +57 -0
  1063. package/src/wsl/i18n/tk.ts +56 -0
  1064. package/src/wsl/i18n/tr.ts +57 -0
  1065. package/src/wsl/i18n/uk.ts +57 -0
  1066. package/src/wsl/i18n/ur.ts +57 -0
  1067. package/src/wsl/i18n/uz.ts +57 -0
  1068. package/src/wsl/i18n/vi.ts +56 -0
  1069. package/src/wsl/i18n/zh.ts +53 -0
  1070. package/src/wsl/i18n/zht.ts +53 -0
  1071. package/src/wsl/index.ts +72 -0
  1072. package/src/wsl/local.ts +41 -0
  1073. package/src/wsl/machine.ts +652 -0
  1074. package/src/wsl/main.ts +95 -0
  1075. package/src/wsl/model.ts +369 -0
  1076. package/src/wsl/probe-machine.ts +143 -0
  1077. package/src/wsl/probes.ts +107 -0
  1078. package/src/wsl/remote-cli.ts +49 -0
  1079. package/src/wsl/renderer.tsx +164 -0
  1080. package/src/wsl/row-view.ts +25 -0
  1081. package/src/wsl/row.tsx +76 -0
  1082. package/src/wsl/runtime.ts +441 -0
  1083. package/src/wsl/servers.ts +330 -0
  1084. package/src/wsl/sidecar.ts +186 -0
  1085. package/tsconfig.json +21 -0
@@ -0,0 +1,1123 @@
1
+ import type { FileDiffInfo } from "@zyro-sec/client/promise"
2
+ import type { SessionReviewLineComment } from "@zyro-sec/session-ui/session-review"
3
+ import { previewSelectedLines } from "@zyro-sec/session-ui/pierre/selection-bridge"
4
+ import { artifactMime } from "@zyro-sec/util/artifact"
5
+ import { bytesToBase64 } from "@zyro-sec/util/base64"
6
+ import { checksum } from "@zyro-sec/util/encode"
7
+ import { focusManager, useQueryClient } from "@tanstack/solid-query"
8
+ import { debounce } from "@solid-primitives/scheduled"
9
+ import { createMemo, createSignal, on, onCleanup, untrack, type Accessor } from "solid-js"
10
+ import {
11
+ createKeyed,
12
+ type LineRange,
13
+ type MountedSession,
14
+ type SessionScreen,
15
+ type SetupContext,
16
+ } from "@zyro-sec/plugin/gui"
17
+ import type Review from "./index"
18
+ import {
19
+ filterRenderableDiff,
20
+ isReviewFolder,
21
+ normalizePath,
22
+ reviewDiffDirectory,
23
+ reviewDiffKinds,
24
+ reviewDiffNeedsLoad,
25
+ reviewFolderDirectory,
26
+ reviewRootDirectory,
27
+ } from "./kinds"
28
+ import {
29
+ INITIAL_REVIEW_FOLDER_STATE,
30
+ reviewExpandedDiffs,
31
+ reviewFolderCandidates,
32
+ reviewFolderLabels,
33
+ sameReviewFolderSource,
34
+ transitionReviewFolders,
35
+ type ReviewFolderEffect,
36
+ type ReviewFolderEvent,
37
+ type ReviewFolderSource,
38
+ type ReviewFolderState,
39
+ } from "./folder-machine"
40
+ import {
41
+ createReviewInitGitState,
42
+ isInitializingGit,
43
+ transitionReviewInitGit,
44
+ type ReviewInitGitEffect,
45
+ type ReviewInitGitEvent,
46
+ } from "./init-git-machine"
47
+ import {
48
+ INITIAL_REVIEW_RENDER_STATE,
49
+ reviewMobileReady,
50
+ reviewPanelReady,
51
+ transitionReviewRender,
52
+ type ReviewRenderEvent,
53
+ type ReviewRenderState,
54
+ } from "./render-machine"
55
+ import {
56
+ INITIAL_REVIEW_SCROLL_STATE,
57
+ REVIEW_SCROLL_INTERACTED,
58
+ REVIEW_SCROLL_RESTORE_REQUESTED,
59
+ canRestoreReviewScroll,
60
+ canSaveReviewScroll,
61
+ sameReviewScrollContext,
62
+ transitionReviewScroll,
63
+ type ReviewScrollEvent,
64
+ type ReviewScrollState,
65
+ } from "./scroll-machine"
66
+ import {
67
+ INITIAL_REVIEW_DIFF_STATE,
68
+ REVIEW_DIFF_TIMEOUT_MS,
69
+ reviewDiffReady,
70
+ reviewDiffView,
71
+ sameReviewDiffTarget,
72
+ transitionReviewDiff,
73
+ type ReviewDiffContext,
74
+ type ReviewDiffEffect,
75
+ type ReviewDiffEvent,
76
+ type ReviewDiffRows,
77
+ type ReviewDiffState,
78
+ type ReviewDiffTarget,
79
+ type ReviewDiffView,
80
+ } from "./machine"
81
+ import type { ReviewDetailStage, ReviewDetailTarget } from "./detail-machine"
82
+
83
+ export type ChangeMode = "git" | "branch" | "turn"
84
+
85
+ type FileSelection = { startLine: number; endLine: number; startChar: number; endChar: number }
86
+
87
+ export type Demand = { tree: number; files: number; panel: number; details: number }
88
+
89
+ /** The narrow review's list and the animation frame that restores its scroll or scrolls it to a focused file. */
90
+ type ScrollTarget = { element?: HTMLDivElement; frame?: number }
91
+
92
+ /** The frame, then task, that a session switch waits for before the review renders. */
93
+ type RenderGate = { frame?: number; timer?: ReturnType<typeof setTimeout> }
94
+
95
+ /** The diff request the driver runs: its abort controller and its timeout. */
96
+ type DiffRequest = { controller?: AbortController; timer?: ReturnType<typeof setTimeout> }
97
+
98
+ const selectionFromLines = (range: LineRange): FileSelection => ({
99
+ startLine: Math.min(range.start, range.end),
100
+ endLine: Math.max(range.start, range.end),
101
+ startChar: 0,
102
+ endChar: 0,
103
+ })
104
+
105
+ /**
106
+ * The routed session's review: its diffs, selection, and comments. Lives as long as the session screen; `view`
107
+ * returns the screen's routed session, a new object on each switch.
108
+ */
109
+ const sendLabels = { send: "comment.send", steer: "comment.steer", queue: "comment.queue" } as const
110
+
111
+ export function createReviewModel(input: {
112
+ ctx: SetupContext<typeof Review>
113
+ screen: SessionScreen
114
+ view: Accessor<MountedSession>
115
+ demand: Demand
116
+ }) {
117
+ const ctx = input.ctx
118
+ const screen = input.screen
119
+ const view = input.view
120
+ const layout = ctx.layout
121
+ const queryClient = useQueryClient()
122
+ const directory = () => screen.file.root
123
+
124
+ // The filter is transient by design: a persisted filter would silently hide files after a reload.
125
+ const [filter, setFilter] = createSignal("")
126
+
127
+ // The machines keep numbers, not the visit objects that tell routing visits apart.
128
+ const visits = { ids: new WeakMap<MountedSession["visit"], number>(), last: 0 }
129
+
130
+ const visitID = (visit: MountedSession["visit"]) => {
131
+ const existing = visits.ids.get(visit)
132
+
133
+ if (existing !== undefined) return existing
134
+ visits.last += 1
135
+ visits.ids.set(visit, visits.last)
136
+
137
+ return visits.last
138
+ }
139
+
140
+ const [renderState, setRenderState] = createSignal<ReviewRenderState>(INITIAL_REVIEW_RENDER_STATE)
141
+ const renderGate: RenderGate = {}
142
+
143
+ const dispatchRender = (event: ReviewRenderEvent) => {
144
+ const next = transitionReviewRender(untrack(renderState), event)
145
+
146
+ setRenderState(next.state)
147
+ next.effects.forEach((effect) => {
148
+ if (renderGate.frame !== undefined) cancelAnimationFrame(renderGate.frame)
149
+ clearTimeout(renderGate.timer)
150
+ renderGate.frame = undefined
151
+ renderGate.timer = undefined
152
+
153
+ if (effect.type === "frame.cancel") return
154
+
155
+ renderGate.frame = requestAnimationFrame(() => {
156
+ renderGate.frame = undefined
157
+ renderGate.timer = setTimeout(() => {
158
+ renderGate.timer = undefined
159
+ dispatchRender({ type: "frame.settled", attempt: effect.attempt })
160
+ }, 0)
161
+ })
162
+ })
163
+ }
164
+
165
+ // After a session switch the review renders a frame later, so the switch paints first. The gate follows the model's
166
+ // own routed session, which a panel can hold before the route publishes it, and keeps it while no session routes.
167
+ createKeyed(
168
+ () => visitID(view().visit),
169
+ (id) => dispatchRender({ type: "visit.synced", visitID: id }),
170
+ )
171
+ onCleanup(() => dispatchRender({ type: "disposed" }))
172
+
173
+ // The routed session's review state. Desktop loads it asynchronously; until it has, its defaults are not the
174
+ // session's choice, so nothing shows them or requests their diff, and changes wait to apply over the stored state.
175
+ const saved = createMemo(() => ctx.stores.session(view()))
176
+ const stored = () => saved().value
177
+
178
+ const update: ReturnType<typeof ctx.stores.session>["update"] = (mutation) => saved().update(mutation)
179
+
180
+ // A memo, so the store a session switch reopens does not recompute the diffs, kinds and tree rows it feeds.
181
+ const selectedFile = createMemo(() => stored()?.file)
182
+
183
+ const vcs = createMemo(() => view().server.data.location.vcs.info({ directory: directory() }))
184
+
185
+ const options = createMemo<ChangeMode[]>(() => {
186
+ const list: ChangeMode[] = []
187
+ const project = view().project
188
+
189
+ if (project?.vcs) list.push("git")
190
+
191
+ if (
192
+ project?.vcs &&
193
+ vcs()?.branch.current &&
194
+ vcs()?.branch.default &&
195
+ vcs()?.branch.current !== vcs()?.branch.default
196
+ ) {
197
+ list.push("branch")
198
+ }
199
+
200
+ // Turn snapshots are captured only for Git sessions.
201
+ if (project?.vcs === "git" && view().id) list.push("turn")
202
+
203
+ return list
204
+ })
205
+
206
+ // The session's chosen mode while it is offered. One it no longer offers, such as Branch back on the default branch,
207
+ // shows as the first mode offered; the stored choice stays, so it returns once its mode is offered again.
208
+ const mode = createMemo<ChangeMode>(() => {
209
+ const chosen = stored()?.mode ?? "git"
210
+
211
+ // Until the server and the project answer, what the session offers is unknown.
212
+ if (!view().server.connected || !view().project) return chosen
213
+
214
+ const list = options()
215
+
216
+ return list.includes(chosen) ? chosen : (list[0] ?? "git")
217
+ })
218
+
219
+ const wantsReview = createMemo(() => {
220
+ const demand = input.demand
221
+
222
+ return demand.tree + demand.files + demand.panel > 0
223
+ })
224
+
225
+ const turnKey = () => [ctx.id, view().server.id, "session-turn", view().id] as const
226
+
227
+ const diffContext = createMemo(
228
+ (): ReviewDiffContext => {
229
+ const project = view().project
230
+
231
+ if (project && !project.vcs) return { kind: "no-vcs" }
232
+
233
+ // Desktop storage loads asynchronously; until this session's mode is known, a request would use the default.
234
+ if (!stored()) return { kind: "waiting" }
235
+ const connected = view().server.connected
236
+
237
+ if (!project) return connected ? { kind: "waiting" } : { kind: "offline" }
238
+ const value = mode()
239
+ const serverID = view().server.id
240
+
241
+ const target: ReviewDiffTarget =
242
+ value === "turn"
243
+ ? { kind: "turn", serverID, sessionID: view().id }
244
+ : {
245
+ kind: "vcs",
246
+ serverID,
247
+ directory: directory(),
248
+ mode: value,
249
+ branch: vcs()?.branch.current ?? "",
250
+ defaultBranch: vcs()?.branch.default ?? "",
251
+ }
252
+
253
+ return { kind: "ready", target, connected, demanded: wantsReview() }
254
+ },
255
+ undefined,
256
+ { equals: sameDiffContext },
257
+ )
258
+
259
+ // One diff machine and its driver. The diffs a target last loaded stay in the query cache under `key`, so returning
260
+ // to a mode or directory shows them at once.
261
+ const createDiffSlice = (input: {
262
+ key: (target: ReviewDiffTarget) => readonly unknown[]
263
+ request: (target: ReviewDiffTarget, signal: AbortSignal) => Promise<readonly FileDiffInfo[]>
264
+ }) => {
265
+ const [state, setState] = createSignal<ReviewDiffState>(INITIAL_REVIEW_DIFF_STATE)
266
+ const request: DiffRequest = {}
267
+
268
+ const dispatch = (event: ReviewDiffEvent) => {
269
+ const next = transitionReviewDiff(untrack(state), event)
270
+
271
+ setState(next.state)
272
+ next.effects.forEach(run)
273
+ }
274
+
275
+ const run = (effect: ReviewDiffEffect) => {
276
+ clearTimeout(request.timer)
277
+ request.controller?.abort()
278
+
279
+ if (effect.type === "abort") return
280
+ const attempt = effect.attempt
281
+ const controller = new AbortController()
282
+
283
+ const timer = setTimeout(() => {
284
+ controller.abort()
285
+ dispatch({ type: "fetch.timed-out", attempt })
286
+ }, REVIEW_DIFF_TIMEOUT_MS)
287
+
288
+ request.controller = controller
289
+ request.timer = timer
290
+ // The machine drops the answer of a request it no longer waits for, aborted or not.
291
+ void input.request(effect.target, AbortSignal.any([ctx.signal, controller.signal])).then(
292
+ (rows) => {
293
+ clearTimeout(timer)
294
+ const loaded: ReviewDiffRows = { rows, version: Date.now() }
295
+
296
+ queryClient.setQueryData(input.key(effect.target), loaded)
297
+ dispatch({ type: "fetch.succeeded", attempt, rows: loaded })
298
+ },
299
+ (cause: unknown) => {
300
+ clearTimeout(timer)
301
+ dispatch({ type: "fetch.failed", attempt, message: cause instanceof Error ? cause.message : String(cause) })
302
+ },
303
+ )
304
+ }
305
+
306
+ const sync = (context: ReviewDiffContext) =>
307
+ dispatch({
308
+ type: "context.changed",
309
+ context:
310
+ context.kind === "ready"
311
+ ? { ...context, cached: queryClient.getQueryData<ReviewDiffRows>(input.key(context.target)) }
312
+ : context,
313
+ })
314
+
315
+ onCleanup(() => dispatch({ type: "disposed" }))
316
+
317
+ // A connection or demand change alone keeps the view, so the diffs it shows are not computed again.
318
+ return {
319
+ dispatch,
320
+ sync,
321
+ ready: () => reviewDiffReady(state()),
322
+ view: createMemo(() => reviewDiffView(state()), undefined, { equals: sameDiffView }),
323
+ }
324
+ }
325
+
326
+ const changes = createDiffSlice({
327
+ key: (target) =>
328
+ target.kind === "turn"
329
+ ? [ctx.id, target.serverID, "session-turn", target.sessionID]
330
+ : [ctx.id, target.serverID, "session-vcs", target.directory, target.branch, target.defaultBranch, target.mode],
331
+ request: (target, signal) => {
332
+ const client = view().server.client
333
+
334
+ if (target.kind === "turn") return client.session.diff({ sessionID: target.sessionID }, { signal })
335
+
336
+ return client.vcs
337
+ .diff(
338
+ {
339
+ location: { directory: target.directory },
340
+ mode: target.mode === "git" ? "working" : target.mode,
341
+ untracked: "folders",
342
+ },
343
+ { signal },
344
+ )
345
+ .then((result) => result.data)
346
+ },
347
+ })
348
+
349
+ const dispatchDiff = changes.dispatch
350
+ const diffView = changes.view
351
+
352
+ createKeyed(diffContext, changes.sync)
353
+
354
+ // The session details' changes row: the session directory's working tree, whatever the review mode, loaded only
355
+ // while the details show. Untracked files list their own line counts.
356
+ const details = createDiffSlice({
357
+ key: (target) => [ctx.id, target.serverID, "session-details", target.kind === "vcs" ? target.directory : ""],
358
+ request: (target, signal) =>
359
+ view()
360
+ .server.client.vcs.diff(
361
+ { location: { directory: target.kind === "vcs" ? target.directory : directory() }, mode: "working" },
362
+ { signal },
363
+ )
364
+ .then((result) => result.data),
365
+ })
366
+
367
+ const detailsContext = createMemo(
368
+ (): ReviewDiffContext => {
369
+ const project = view().project
370
+
371
+ if (project && !project.vcs) return { kind: "no-vcs" }
372
+ const connected = view().server.connected
373
+
374
+ if (!project) return connected ? { kind: "waiting" } : { kind: "offline" }
375
+
376
+ return {
377
+ kind: "ready",
378
+ target: {
379
+ kind: "vcs",
380
+ serverID: view().server.id,
381
+ directory: view().directory,
382
+ mode: "git",
383
+ branch: "",
384
+ defaultBranch: "",
385
+ },
386
+ connected,
387
+ demanded: input.demand.details > 0,
388
+ }
389
+ },
390
+ undefined,
391
+ { equals: sameDiffContext },
392
+ )
393
+
394
+ createKeyed(detailsContext, details.sync)
395
+
396
+ // A finished turn does not change on focus or filesystem events; the machines refresh only Git changes then.
397
+ onCleanup(
398
+ focusManager.subscribe((focused) => {
399
+ if (!focused) return
400
+ dispatchDiff({ type: "window.focused" })
401
+ details.dispatch({ type: "window.focused" })
402
+ }),
403
+ )
404
+
405
+ const refresh = debounce(() => {
406
+ dispatchDiff({ type: "refresh", source: "vcs" })
407
+ details.dispatch({ type: "refresh", source: "vcs" })
408
+ dispatchFolders({ type: "refresh" })
409
+ }, 100)
410
+
411
+ // The server reports file changes in the directory; its event stream follows a restarted server. Routing another
412
+ // session of the same directory and server keeps the listener.
413
+ createKeyed(
414
+ () => ({ directory: directory(), data: view().server.data }),
415
+ (current) =>
416
+ onCleanup(
417
+ current.data.listen(({ details }) => {
418
+ if (details.type === "filesystem.changed" && details.location?.directory === current.directory) refresh()
419
+ }),
420
+ ),
421
+ { equals: (previous, next) => previous.directory === next.directory && previous.data === next.data },
422
+ )
423
+
424
+ // Opening the side region refreshes changes a tree already shows. Otherwise it loads them once, so the
425
+ // pinned tab reads "N files changed": v2 opened the region on the review tab before selecting another.
426
+ // A region restored open does not load them until something shows them.
427
+ const opened = createMemo(
428
+ on(
429
+ () => !layout.narrow() && layout.side.opened(view()),
430
+ (open, previous) => (open && !previous ? {} : undefined),
431
+ { defer: true },
432
+ ),
433
+ )
434
+
435
+ createKeyed(opened, () => {
436
+ if (input.demand.tree > 0) {
437
+ refresh()
438
+
439
+ return
440
+ }
441
+
442
+ dispatchDiff({ type: "side.opened" })
443
+ })
444
+
445
+ const noRows: readonly FileDiffInfo[] = []
446
+
447
+ const rows = () => {
448
+ const current = diffView()
449
+
450
+ return current.status === "ready" ? current.rows : noRows
451
+ }
452
+
453
+ // Git lists an untracked folder as one row. Once the change tree opens it, the folder lists its entries one level
454
+ // deep; they stay loaded while it is closed again, until the changes' source changes or the folder goes away.
455
+ const [folderState, setFolderState] = createSignal<ReviewFolderState>(INITIAL_REVIEW_FOLDER_STATE)
456
+ const folderRequests = new Map<number, DiffRequest>()
457
+
458
+ const dispatchFolders = (event: ReviewFolderEvent) => {
459
+ const next = transitionReviewFolders(untrack(folderState), event)
460
+
461
+ setFolderState(next.state)
462
+ next.effects.forEach(runFolderEffect)
463
+ }
464
+
465
+ const runFolderEffect = (effect: ReviewFolderEffect) => {
466
+ if (effect.type === "abort") {
467
+ const request = folderRequests.get(effect.attempt)
468
+
469
+ folderRequests.delete(effect.attempt)
470
+ clearTimeout(request?.timer)
471
+ request?.controller?.abort()
472
+
473
+ return
474
+ }
475
+
476
+ const attempt = effect.attempt
477
+ const request: DiffRequest = {}
478
+
479
+ folderRequests.set(attempt, request)
480
+ // A retry waits out its backoff first; the request's own deadline starts with it.
481
+ request.timer = setTimeout(() => {
482
+ const controller = new AbortController()
483
+
484
+ request.controller = controller
485
+ request.timer = setTimeout(() => {
486
+ if (!folderRequests.delete(attempt)) return
487
+ controller.abort()
488
+ dispatchFolders({ type: "fetch.timed-out", folder: effect.folder, attempt })
489
+ }, REVIEW_DIFF_TIMEOUT_MS)
490
+ void view()
491
+ .server.client.vcs.diff(
492
+ {
493
+ location: { directory: reviewFolderDirectory(effect.source.root, effect.folder) },
494
+ mode: effect.source.mode === "branch" ? "branch" : "working",
495
+ untracked: "folders",
496
+ },
497
+ { signal: AbortSignal.any([ctx.signal, controller.signal]) },
498
+ )
499
+ .then(
500
+ (result) => {
501
+ if (!folderRequests.delete(attempt)) return
502
+ clearTimeout(request.timer)
503
+ dispatchFolders({ type: "fetch.succeeded", folder: effect.folder, attempt, entries: result.data })
504
+ },
505
+ () => {
506
+ if (!folderRequests.delete(attempt)) return
507
+ clearTimeout(request.timer)
508
+ dispatchFolders({ type: "fetch.failed", folder: effect.folder, attempt })
509
+ },
510
+ )
511
+ }, effect.delay)
512
+ }
513
+
514
+ const folderSource = createMemo(
515
+ (): ReviewFolderSource | undefined => {
516
+ const context = diffContext()
517
+
518
+ if (context.kind !== "ready" || context.target.kind !== "vcs") return undefined
519
+
520
+ return {
521
+ serverID: context.target.serverID,
522
+ root: reviewRootDirectory(view().project?.worktree ?? directory()),
523
+ directory: context.target.directory,
524
+ mode: context.target.mode,
525
+ branch: context.target.branch,
526
+ defaultBranch: context.target.defaultBranch,
527
+ }
528
+ },
529
+ undefined,
530
+ {
531
+ equals: (previous, next) => previous === next || (!!previous && !!next && sameReviewFolderSource(previous, next)),
532
+ },
533
+ )
534
+
535
+ // The tree's expanded state belongs to the session screen's file model, which the change tree and the file
536
+ // browser share.
537
+ const expandedFolders = createMemo(
538
+ () =>
539
+ new Set(
540
+ reviewFolderCandidates(rows(), folderState()).filter(
541
+ (folder) => screen.file.tree.state(normalizePath(folder))?.expanded === true,
542
+ ),
543
+ ),
544
+ undefined,
545
+ { equals: (previous, next) => previous.size === next.size && [...previous].every((folder) => next.has(folder)) },
546
+ )
547
+
548
+ // Syncs the folders the tree expands, and the changes that list them, into the folder requests.
549
+ createKeyed(
550
+ () => ({
551
+ source: folderSource(),
552
+ connected: view().server.connected,
553
+ rows: rows(),
554
+ expanded: expandedFolders(),
555
+ }),
556
+ (context) => dispatchFolders({ type: "context.changed", context }),
557
+ {
558
+ equals: (previous, next) =>
559
+ previous.source === next.source &&
560
+ previous.connected === next.connected &&
561
+ previous.rows === next.rows &&
562
+ previous.expanded === next.expanded,
563
+ },
564
+ )
565
+ onCleanup(() => dispatchFolders({ type: "disposed" }))
566
+
567
+ const diffs = createMemo(() => reviewExpandedDiffs(rows(), folderState()))
568
+
569
+ // A loaded folder's entry count, whether its listing stopped before showing or checking every entry, or its failure.
570
+ const folderLabels = createMemo(() =>
571
+ reviewFolderLabels(folderState(), {
572
+ more: (count) => ctx.t("folder.more", { count }),
573
+ failed: ctx.t("folder.failed"),
574
+ }),
575
+ )
576
+
577
+ const renderable = createMemo(() => diffs().filter(filterRenderableDiff))
578
+ const kinds = createMemo(() => reviewDiffKinds(renderable()))
579
+
580
+ const activeFile = () => {
581
+ const list = diffs()
582
+ const selected = selectedFile()
583
+
584
+ if (selected && list.some((diff) => diff.file === selected)) return selected
585
+
586
+ return list.find((diff) => !isReviewFolder(diff.file))?.file
587
+ }
588
+
589
+ // What `git status` lists: an untracked folder counts once, opened or not.
590
+ const count = () => rows().length
591
+ const hasChanges = () => count() > 0
592
+
593
+ const ready = changes.ready
594
+
595
+ // Git initialization per session. Each request keeps its session's object, so its server and location stay its own;
596
+ // only error feedback depends on which session is routed when it fails.
597
+ const [initGitState, setInitGitState] = createSignal(createReviewInitGitState())
598
+ const initGitRequests = new Map<number, DiffRequest>()
599
+ const initGitSessions = new Map<string, MountedSession>()
600
+
601
+ const dispatchInitGit = (event: ReviewInitGitEvent) => {
602
+ const next = transitionReviewInitGit(untrack(initGitState), event)
603
+
604
+ setInitGitState(next.state)
605
+
606
+ // The machine releases a session's button; the driver forgets the session object with it.
607
+ if (event.type === "disposed") initGitSessions.clear()
608
+
609
+ if (event.type !== "disposed" && !isInitializingGit(next.state, event.sessionKey))
610
+ initGitSessions.delete(event.sessionKey)
611
+ next.effects.forEach(runInitGitEffect)
612
+ }
613
+
614
+ const runInitGitEffect = (effect: ReviewInitGitEffect) => {
615
+ if (effect.type === "attempt.abort") {
616
+ const request = initGitRequests.get(effect.attempt)
617
+
618
+ initGitRequests.delete(effect.attempt)
619
+ clearTimeout(request?.timer)
620
+ request?.controller?.abort()
621
+
622
+ return
623
+ }
624
+
625
+ if (effect.type === "toast.failed") {
626
+ ctx.toast.show({
627
+ variant: "error",
628
+ title: ctx.t("common.requestFailed"),
629
+ description: effect.reason === "timeout" ? ctx.t("load.timeout") : effect.message,
630
+ })
631
+
632
+ return
633
+ }
634
+
635
+ const session = initGitSessions.get(effect.sessionKey)
636
+ const location = session?.location
637
+ const sessionKey = effect.sessionKey
638
+ const attempt = effect.attempt
639
+ const controller = new AbortController()
640
+ const signal = AbortSignal.any([ctx.signal, controller.signal])
641
+
642
+ if (effect.type === "vcs.init") {
643
+ initGitRequests.set(attempt, {
644
+ controller,
645
+ timer: setTimeout(
646
+ () => dispatchInitGit({ type: "init.timed-out", sessionKey, attempt, routedSessionKey: untrack(view).key }),
647
+ effect.timeoutMs,
648
+ ),
649
+ })
650
+ void Promise.try(() => {
651
+ if (!session || !location) throw new Error(ctx.t("common.requestFailed"))
652
+
653
+ return session.server.client.vcs.init({ location, provider: "git" }, { signal })
654
+ }).then(
655
+ () => dispatchInitGit({ type: "init.succeeded", sessionKey, attempt }),
656
+ (cause: unknown) =>
657
+ dispatchInitGit({
658
+ type: "init.failed",
659
+ sessionKey,
660
+ attempt,
661
+ routedSessionKey: untrack(view).key,
662
+ message: cause instanceof Error ? cause.message : undefined,
663
+ }),
664
+ )
665
+
666
+ return
667
+ }
668
+
669
+ initGitRequests.set(attempt, {
670
+ controller,
671
+ timer: setTimeout(() => dispatchInitGit({ type: "sync.timed-out", sessionKey, attempt }), effect.timeoutMs),
672
+ })
673
+ // Each refresh runs even when an earlier one fails: the repository exists either way.
674
+ void Promise.try(async () => {
675
+ if (!session || !location) return
676
+ const data = session.server.data
677
+
678
+ data.project.invalidate()
679
+ data.session.invalidate(session.id)
680
+ data.location.invalidate(location)
681
+ data.location.vcs.invalidate(location)
682
+ await data.project.sync().catch(() => undefined)
683
+
684
+ if (signal.aborted) return
685
+ await data.session.sync(session.id).catch(() => undefined)
686
+
687
+ if (signal.aborted) return
688
+ await Promise.allSettled([data.location.syncInfo(location), data.location.vcs.sync(location)])
689
+ })
690
+ .catch(() => undefined)
691
+ .then(() => dispatchInitGit({ type: "sync.settled", sessionKey, attempt }))
692
+ }
693
+
694
+ onCleanup(() => dispatchInitGit({ type: "disposed" }))
695
+
696
+ // Initializes Git for the routed session.
697
+ const initializeGit = () => {
698
+ const session = view()
699
+ const ready = Boolean(session.location && session.server.connected)
700
+
701
+ if (ready && !isInitializingGit(untrack(initGitState), session.key)) initGitSessions.set(session.key, session)
702
+ dispatchInitGit({ type: "init.requested", sessionKey: session.key, ready })
703
+ }
704
+
705
+ // Oversized full-file patches come back without hunks; the file's own directory, or bounded context, usually fits.
706
+ // Each request reads only its target, fixed when the file was previewed, so a session switch cannot answer it.
707
+ const detailKey = (target: ReviewDetailTarget, stage: ReviewDetailStage) =>
708
+ target.kind === "turn"
709
+ ? [ctx.id, target.serverID, "session-turn", target.sessionID, "bounded", target.version]
710
+ : [
711
+ ctx.id,
712
+ target.serverID,
713
+ "session-vcs",
714
+ target.mode,
715
+ target.branch,
716
+ target.defaultBranch,
717
+ stage === "scoped" ? target.scoped : target.root,
718
+ stage,
719
+ target.version,
720
+ ]
721
+
722
+ const detailStages = (target: ReviewDetailTarget): ReviewDetailStage[] =>
723
+ target.kind === "vcs" && target.scoped !== target.root ? ["scoped", "bounded"] : ["bounded"]
724
+
725
+ /** The previewed file's full patch: what its request reads, the patch an earlier request loaded, and the request. */
726
+ const detail = {
727
+ target: (diff: FileDiffInfo, version: number): ReviewDetailTarget => {
728
+ const session = view()
729
+ const value = mode()
730
+
731
+ const file = {
732
+ serverID: session.server.id,
733
+ file: diff.file,
734
+ additions: diff.additions,
735
+ deletions: diff.deletions,
736
+ version,
737
+ }
738
+
739
+ if (value === "turn") return { kind: "turn", sessionID: session.id, ...file }
740
+ const root = reviewRootDirectory(session.project?.worktree ?? directory())
741
+
742
+ return {
743
+ kind: "vcs",
744
+ mode: value,
745
+ branch: vcs()?.branch.current ?? "",
746
+ defaultBranch: vcs()?.branch.default ?? "",
747
+ root,
748
+ scoped: reviewDiffDirectory(root, diff.file),
749
+ ...file,
750
+ }
751
+ },
752
+ cached: (target: ReviewDetailTarget) =>
753
+ detailStages(target)
754
+ .map((stage) => validDetail(queryClient.getQueryData<FileDiffInfo[]>(detailKey(target, stage)), target))
755
+ .find((diff) => diff !== undefined),
756
+ load: (target: ReviewDetailTarget, stage: ReviewDetailStage, signal: AbortSignal) => {
757
+ const server = view().server
758
+
759
+ // The routed session moved to another server meanwhile; the preview already asks for another target.
760
+ if (server.id !== target.serverID) return Promise.reject(new Error(ctx.t("common.requestFailed")))
761
+ const both = AbortSignal.any([ctx.signal, signal])
762
+
763
+ const rows =
764
+ target.kind === "turn"
765
+ ? server.client.session.diff({ sessionID: target.sessionID, context: 3 }, { signal: both })
766
+ : server.client.vcs
767
+ .diff(
768
+ {
769
+ location: { directory: stage === "scoped" ? target.scoped : target.root },
770
+ mode: target.mode === "git" ? "working" : target.mode,
771
+ context: stage === "bounded" ? 3 : undefined,
772
+ untracked: "folders",
773
+ },
774
+ { signal: both },
775
+ )
776
+ .then((result) => result.data)
777
+
778
+ return rows.then((list) => {
779
+ queryClient.setQueryData(detailKey(target, stage), list)
780
+
781
+ return validDetail(list, target)
782
+ })
783
+ },
784
+ }
785
+
786
+ // Previews read files only to show images and audio, which need the raw bytes and their MIME type.
787
+ const readFile = (path: string) =>
788
+ view()
789
+ .server.client.file.read({ path, location: { directory: directory() } })
790
+ .then((bytes) => ({
791
+ type: "binary" as const,
792
+ content: bytesToBase64(bytes),
793
+ encoding: "base64" as const,
794
+ mimeType: artifactMime(path),
795
+ }))
796
+ .catch((error) => {
797
+ console.debug("[session-review] failed to read file", { path, error })
798
+
799
+ return undefined
800
+ })
801
+
802
+ const selectionPreview = (path: string, selection: FileSelection): string | undefined => {
803
+ const content = screen.file.get(path)?.content?.content
804
+
805
+ if (!content) return undefined
806
+
807
+ return previewSelectedLines(content, { start: selection.startLine, end: selection.endLine })
808
+ }
809
+
810
+ const addComment = (comment: SessionReviewLineComment) => {
811
+ const selection = selectionFromLines(comment.selection)
812
+ const saved = screen.comment.add({ file: comment.file, selection: comment.selection, comment: comment.comment })
813
+
814
+ screen.composer.attach({
815
+ type: "file",
816
+ path: comment.file,
817
+ selection,
818
+ comment: comment.comment,
819
+ commentID: saved.id,
820
+ commentOrigin: "review",
821
+ preview: comment.preview ?? selectionPreview(comment.file, selection),
822
+ })
823
+
824
+ if (comment.send) screen.composer.send(saved.id)
825
+ }
826
+
827
+ const updateComment = (comment: {
828
+ id: string
829
+ file: string
830
+ selection: LineRange
831
+ comment: string
832
+ preview?: string
833
+ send?: boolean
834
+ }) => {
835
+ screen.comment.update(comment.id, comment.comment)
836
+ // The composer keeps a chip's preview unless the update names a new one.
837
+ screen.composer.update(
838
+ comment.id,
839
+ comment.preview ? { comment: comment.comment, preview: comment.preview } : { comment: comment.comment },
840
+ )
841
+
842
+ if (comment.send) screen.composer.send(comment.id)
843
+ }
844
+
845
+ const removeComment = (comment: { id: string; file: string }) => {
846
+ screen.comment.remove(comment.id)
847
+ screen.composer.detach(comment.id)
848
+ }
849
+
850
+ const commentActions = createMemo(() => ({
851
+ moreLabel: ctx.t("common.moreOptions"),
852
+ editLabel: ctx.t("common.edit"),
853
+ deleteLabel: ctx.t("common.delete"),
854
+ saveLabel: ctx.t("common.save"),
855
+ }))
856
+
857
+ const mac = /(Mac|iPhone|iPad)/.test(navigator.platform)
858
+
859
+ const commentSend = createMemo(() => {
860
+ const delivery = screen.composer.delivery()
861
+
862
+ return {
863
+ label: ctx.t(sendLabels[delivery ?? "send"]),
864
+ keys: [mac ? "⌘" : ctx.t("common.key.ctrl"), "⏎"],
865
+ disabled: delivery === undefined,
866
+ }
867
+ })
868
+
869
+ const open = () => {
870
+ if (!layout.side.opened(view())) layout.side.toggle(view())
871
+ }
872
+
873
+ const openPath = (path: string) =>
874
+ update((draft) => {
875
+ if (draft.open.includes(path)) return
876
+
877
+ draft.open = [...draft.open, path]
878
+ })
879
+
880
+ const reviewDiffId = (path: string): string | undefined => {
881
+ const sum = checksum(path)
882
+
883
+ if (!sum) return undefined
884
+
885
+ return `session-review-diff-${sum}`
886
+ }
887
+
888
+ const reviewDiffTop = (element: HTMLDivElement, path: string): number | undefined => {
889
+ const id = reviewDiffId(path)
890
+
891
+ if (!id) return undefined
892
+
893
+ const target = document.getElementById(id)
894
+
895
+ if (!(target instanceof HTMLElement) || !element.contains(target)) return undefined
896
+
897
+ return target.getBoundingClientRect().top - element.getBoundingClientRect().top + element.scrollTop
898
+ }
899
+
900
+ const scrollToFile = (element: HTMLDivElement, path: string) => {
901
+ const top = reviewDiffTop(element, path)
902
+
903
+ if (top === undefined) return false
904
+
905
+ layout.scroll.set(view(), "review", { x: element.scrollLeft, y: top })
906
+ element.scrollTo({ top, behavior: "auto" })
907
+
908
+ return true
909
+ }
910
+
911
+ const focusFile = (path: string) => {
912
+ open()
913
+ openPath(path)
914
+ update((draft) => {
915
+ draft.file = path
916
+ })
917
+ dispatchScroll({ type: "file.focused", path })
918
+ }
919
+
920
+ // The narrow review's list: the element lives here, the machine knows only whether it is mounted.
921
+ const scroller: ScrollTarget = {}
922
+ const [hasScroller, setHasScroller] = createSignal(false)
923
+ const [scrollState, setScrollState] = createSignal<ReviewScrollState>(INITIAL_REVIEW_SCROLL_STATE)
924
+
925
+ const dispatchScroll = (event: ReviewScrollEvent) => {
926
+ const next = transitionReviewScroll(untrack(scrollState), event)
927
+
928
+ setScrollState(next.state)
929
+ next.effects.forEach((effect) => {
930
+ if (scroller.frame !== undefined) cancelAnimationFrame(scroller.frame)
931
+ scroller.frame = undefined
932
+
933
+ if (effect.type === "frame.cancel") return
934
+
935
+ if (effect.type === "frame.restore") {
936
+ scroller.frame = requestAnimationFrame(() => {
937
+ scroller.frame = undefined
938
+
939
+ if (canRestoreReviewScroll(untrack(scrollState), effect.attempt)) restoreScroll()
940
+ dispatchScroll({ type: "restore.stepped", attempt: effect.attempt })
941
+ })
942
+
943
+ return
944
+ }
945
+
946
+ // Scrolls the list to the file's diff, and settles once the diff stays at the top as the list above renders.
947
+ scroller.frame = requestAnimationFrame(() => {
948
+ scroller.frame = undefined
949
+ const element = scroller.element
950
+ const top = element && scrollToFile(element, effect.path) ? reviewDiffTop(element, effect.path) : undefined
951
+ const settled = !!element && top !== undefined && Math.abs(element.scrollTop - top) <= 1
952
+
953
+ dispatchScroll({ type: "frame.stepped", attempt: effect.attempt, outcome: settled ? "settled" : "retry" })
954
+ })
955
+ })
956
+ }
957
+
958
+ // Returns the narrow list to the stored scroll, as far as the diffs rendered so far reach.
959
+ const restoreScroll = () => {
960
+ const element = scroller.element
961
+
962
+ if (!element || element.clientHeight === 0 || element.clientWidth === 0) return
963
+ const stored = layout.scroll.get(view(), "review")
964
+
965
+ if (!stored || (stored.x === 0 && stored.y === 0)) return
966
+ const top = Math.min(stored.y, Math.max(0, element.scrollHeight - element.clientHeight))
967
+ const left = Math.min(stored.x, Math.max(0, element.scrollWidth - element.clientWidth))
968
+
969
+ if (element.scrollTop !== top) element.scrollTop = top
970
+
971
+ if (element.scrollLeft !== left) element.scrollLeft = left
972
+ }
973
+
974
+ createKeyed(
975
+ () => ({
976
+ visitID: visitID(view().visit),
977
+ narrow: layout.narrow(),
978
+ scroller: hasScroller(),
979
+ ready: ready(),
980
+ layoutReady: layout.ready(),
981
+ commentFocused: screen.comment.focus.current() !== null,
982
+ }),
983
+ (context) => dispatchScroll({ type: "context.synced", context }),
984
+ { equals: sameReviewScrollContext },
985
+ )
986
+ onCleanup(() => dispatchScroll({ type: "disposed" }))
987
+
988
+ const idled = createMemo(
989
+ on(
990
+ () => view().server.data.session.status(view().id),
991
+ (next, previous) => (next === "idle" && previous !== undefined && previous !== "idle" ? {} : undefined),
992
+ { defer: true },
993
+ ),
994
+ )
995
+
996
+ // A session that goes idle has finished its turn, which may have changed files.
997
+ createKeyed(idled, () => {
998
+ refresh()
999
+ dispatchDiff({ type: "refresh", source: "turn" })
1000
+ void queryClient.invalidateQueries({ queryKey: turnKey() })
1001
+ })
1002
+
1003
+ return {
1004
+ screen,
1005
+ view,
1006
+ activeFile,
1007
+ // The mode picker waits for the stored mode.
1008
+ canReview: () => !!view().project && !!stored(),
1009
+ comments: {
1010
+ actions: commentActions,
1011
+ send: commentSend,
1012
+ add: addComment,
1013
+ all: () => [...screen.comment.list()],
1014
+ focus: () => screen.comment.focus.current(),
1015
+ mentions: (query: string) => screen.file.search(query, { kind: "any" }),
1016
+ remove: removeComment,
1017
+ changeFocus: (focus: { file: string; id: string } | null) => {
1018
+ if (!focus) {
1019
+ const current = screen.comment.focus.current()
1020
+
1021
+ if (current && diffs().some((diff) => diff.file === current.file)) focusFile(current.file)
1022
+ }
1023
+
1024
+ screen.comment.focus.set(focus)
1025
+ },
1026
+ setFocus: (focus: { file: string; id: string } | null) => screen.comment.focus.set(focus),
1027
+ update: updateComment,
1028
+ },
1029
+ count,
1030
+ detail,
1031
+ /** The session details' changes row. */
1032
+ details: details.view,
1033
+ retryDetails: () => details.dispatch({ type: "retry" }),
1034
+ /** What the review shows: diffs, or why there are none yet. */
1035
+ diff: diffView,
1036
+ diffVersion: () => {
1037
+ const current = diffView()
1038
+
1039
+ return current.status === "ready" ? current.version : 0
1040
+ },
1041
+ diffs,
1042
+ folderLabels,
1043
+ renderable,
1044
+ kinds,
1045
+ focusFile,
1046
+ hasChanges,
1047
+ initializeGit,
1048
+ initializingGit: () => isInitializingGit(initGitState(), view().key),
1049
+ readFile,
1050
+ mode,
1051
+ filter,
1052
+ setFilter: (value: string) => void setFilter(value),
1053
+ open: () => stored()?.open ?? [],
1054
+ setOpen: (next: string[]) =>
1055
+ update((draft) => {
1056
+ const unique = Array.from(new Set(next))
1057
+
1058
+ if (unique.length === draft.open.length && unique.every((path, index) => path === draft.open[index])) return
1059
+
1060
+ draft.open = unique
1061
+ }),
1062
+ /** The narrow review mounts its list: one paint after each session switch. */
1063
+ mobileReady: () => reviewMobileReady(renderState()),
1064
+ options,
1065
+ /** The wide panel mounts: one paint after the first visit, then across session switches. */
1066
+ panelReady: () => reviewPanelReady(renderState()),
1067
+ ready,
1068
+ retry: () => {
1069
+ dispatchDiff({ type: "retry" })
1070
+ dispatchFolders({ type: "retry" })
1071
+ },
1072
+ setMode: (value: ChangeMode) =>
1073
+ update((draft) => {
1074
+ draft.mode = value
1075
+ }),
1076
+ /** The narrow review's list mounted, or unmounted with `undefined`. */
1077
+ setScroll: (element: HTMLDivElement | undefined) => {
1078
+ scroller.element = element
1079
+ setHasScroller(!!element)
1080
+ },
1081
+ /** The user scrolled, touched or keyed the narrow review: it stops restoring and scrolling to a focused file. */
1082
+ interacted: () => dispatchScroll(REVIEW_SCROLL_INTERACTED),
1083
+ /** The narrow list mounted, or its diffs or wrapping changed: it returns to the stored scroll while restoring. */
1084
+ requestRestore: () => dispatchScroll(REVIEW_SCROLL_RESTORE_REQUESTED),
1085
+ /** Stores the narrow list's scroll once the user, a focused file or a focused comment placed it. */
1086
+ saveScroll: (session: MountedSession, element: HTMLDivElement) => {
1087
+ if (!canSaveReviewScroll(untrack(scrollState))) return
1088
+
1089
+ if (element.clientHeight === 0 || element.clientWidth === 0) return
1090
+ layout.scroll.set(session, "review", { x: element.scrollLeft, y: element.scrollTop })
1091
+ },
1092
+ }
1093
+ }
1094
+
1095
+ export type ReviewModel = ReturnType<typeof createReviewModel>
1096
+
1097
+ function sameDiffContext(previous: ReviewDiffContext, next: ReviewDiffContext) {
1098
+ if (previous.kind !== "ready" || next.kind !== "ready") return previous.kind === next.kind
1099
+
1100
+ return (
1101
+ previous.connected === next.connected &&
1102
+ previous.demanded === next.demanded &&
1103
+ sameReviewDiffTarget(previous.target, next.target)
1104
+ )
1105
+ }
1106
+
1107
+ /** The target's patch in a loaded list, when it has hunks and the line counts the review listed. */
1108
+ function validDetail(list: readonly FileDiffInfo[] | undefined, target: ReviewDetailTarget) {
1109
+ const diff = list?.find((item) => item.file === target.file)
1110
+
1111
+ if (!diff || diff.additions !== target.additions || diff.deletions !== target.deletions) return undefined
1112
+
1113
+ return reviewDiffNeedsLoad(diff) ? undefined : diff
1114
+ }
1115
+
1116
+ function sameDiffView(previous: ReviewDiffView, next: ReviewDiffView) {
1117
+ if (previous.status === "ready" && next.status === "ready")
1118
+ return previous.rows === next.rows && previous.version === next.version
1119
+
1120
+ if (previous.status === "error" && next.status === "error") return previous.failure === next.failure
1121
+
1122
+ return previous.status === next.status
1123
+ }