@opengeni/react 4.0.2 → 4.0.5-canary.39120434730001

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 (916) hide show
  1. package/README.md +787 -26
  2. package/dist/accounts.js +2 -0
  3. package/dist/accounts.js.map +1 -1
  4. package/dist/approvals.d.ts +2 -1
  5. package/dist/artifacts-document.js +6 -3
  6. package/dist/artifacts-presentation.js +6 -3
  7. package/dist/artifacts-spreadsheet.d.ts +1 -1
  8. package/dist/artifacts-spreadsheet.js +6 -3
  9. package/dist/artifacts.d.ts +5 -1
  10. package/dist/artifacts.js +542 -278
  11. package/dist/artifacts.js.map +1 -1
  12. package/dist/browser-viewer-GEHX3KYE.js +20 -0
  13. package/dist/capability-catalog-row.d.ts +20 -0
  14. package/dist/capability-logo-fallback.d.ts +3 -0
  15. package/dist/chat-interactive-block-5V3BGLXT.js +15 -0
  16. package/dist/chunk-2DDJ6YH6.js +41 -0
  17. package/dist/chunk-2DDJ6YH6.js.map +1 -0
  18. package/dist/chunk-2EGXXUG4.js +1161 -0
  19. package/dist/chunk-2EGXXUG4.js.map +1 -0
  20. package/dist/chunk-2XKRY4GF.js +302 -0
  21. package/dist/chunk-2XKRY4GF.js.map +1 -0
  22. package/dist/chunk-2ZUUIMBY.js +343 -0
  23. package/dist/chunk-2ZUUIMBY.js.map +1 -0
  24. package/dist/chunk-4F4FGCH2.js +34 -0
  25. package/dist/chunk-4F4FGCH2.js.map +1 -0
  26. package/dist/{chunk-Z7WBDB4E.js → chunk-4M2MJLY3.js} +848 -867
  27. package/dist/chunk-4M2MJLY3.js.map +1 -0
  28. package/dist/chunk-4U7SHFQ2.js +193 -0
  29. package/dist/chunk-4U7SHFQ2.js.map +1 -0
  30. package/dist/chunk-5I4VRWBB.js +56 -0
  31. package/dist/chunk-5I4VRWBB.js.map +1 -0
  32. package/dist/{chunk-24M4YBCL.js → chunk-62XZ3IX3.js} +1751 -845
  33. package/dist/chunk-62XZ3IX3.js.map +1 -0
  34. package/dist/chunk-77THWHSU.js +308 -0
  35. package/dist/chunk-77THWHSU.js.map +1 -0
  36. package/dist/chunk-7CZLTFXF.js +466 -0
  37. package/dist/chunk-7CZLTFXF.js.map +1 -0
  38. package/dist/chunk-7N5AD2TC.js +327 -0
  39. package/dist/chunk-7N5AD2TC.js.map +1 -0
  40. package/dist/chunk-7SZ7MMCY.js +325 -0
  41. package/dist/chunk-7SZ7MMCY.js.map +1 -0
  42. package/dist/chunk-7TG6KTR2.js +3153 -0
  43. package/dist/chunk-7TG6KTR2.js.map +1 -0
  44. package/dist/chunk-AIX25FIQ.js +409 -0
  45. package/dist/chunk-AIX25FIQ.js.map +1 -0
  46. package/dist/chunk-AT2HD6RQ.js +1936 -0
  47. package/dist/chunk-AT2HD6RQ.js.map +1 -0
  48. package/dist/chunk-B27E3V37.js +29 -0
  49. package/dist/chunk-B27E3V37.js.map +1 -0
  50. package/dist/{chunk-5M6VTFJ5.js → chunk-B4EDAXMC.js} +37 -13
  51. package/dist/chunk-B4EDAXMC.js.map +1 -0
  52. package/dist/chunk-BOG2FED3.js +35 -0
  53. package/dist/chunk-BOG2FED3.js.map +1 -0
  54. package/dist/chunk-BQYQU5QW.js +109 -0
  55. package/dist/chunk-BQYQU5QW.js.map +1 -0
  56. package/dist/{chunk-PAJU5KKL.js → chunk-BRIOXCLH.js} +68 -25
  57. package/dist/chunk-BRIOXCLH.js.map +1 -0
  58. package/dist/chunk-CM7LVUKC.js +35 -0
  59. package/dist/chunk-CM7LVUKC.js.map +1 -0
  60. package/dist/{chunk-KCGXPP5V.js → chunk-CXIGFHVL.js} +35 -23
  61. package/dist/chunk-CXIGFHVL.js.map +1 -0
  62. package/dist/chunk-DHXKEJBH.js +71 -0
  63. package/dist/chunk-DHXKEJBH.js.map +1 -0
  64. package/dist/{chunk-NOSYBS2D.js → chunk-DN3TKURW.js} +12 -9
  65. package/dist/chunk-DN3TKURW.js.map +1 -0
  66. package/dist/chunk-DNJ23AWQ.js +35 -0
  67. package/dist/chunk-DNJ23AWQ.js.map +1 -0
  68. package/dist/chunk-ESAMXNBZ.js +3237 -0
  69. package/dist/chunk-ESAMXNBZ.js.map +1 -0
  70. package/dist/{chunk-4MDLEHXL.js → chunk-EWATYP5L.js} +64 -44
  71. package/dist/chunk-EWATYP5L.js.map +1 -0
  72. package/dist/{chunk-YBM6CQRU.js → chunk-FQ5CXNUG.js} +65 -42
  73. package/dist/chunk-FQ5CXNUG.js.map +1 -0
  74. package/dist/chunk-FVROZ7HR.js +14396 -0
  75. package/dist/chunk-FVROZ7HR.js.map +1 -0
  76. package/dist/chunk-HEVQKE27.js +150 -0
  77. package/dist/chunk-HEVQKE27.js.map +1 -0
  78. package/dist/chunk-HZ47S3DP.js +1086 -0
  79. package/dist/chunk-HZ47S3DP.js.map +1 -0
  80. package/dist/chunk-I5BJ7ENY.js +174 -0
  81. package/dist/chunk-I5BJ7ENY.js.map +1 -0
  82. package/dist/chunk-IGFZFLI2.js +1390 -0
  83. package/dist/chunk-IGFZFLI2.js.map +1 -0
  84. package/dist/chunk-IGVL3ELX.js +46 -0
  85. package/dist/chunk-IGVL3ELX.js.map +1 -0
  86. package/dist/chunk-IOD24LGR.js +384 -0
  87. package/dist/chunk-IOD24LGR.js.map +1 -0
  88. package/dist/chunk-IOYHDEP3.js +38 -0
  89. package/dist/chunk-IOYHDEP3.js.map +1 -0
  90. package/dist/chunk-IQL77TMM.js +803 -0
  91. package/dist/chunk-IQL77TMM.js.map +1 -0
  92. package/dist/chunk-IZV5FTJC.js +55 -0
  93. package/dist/chunk-IZV5FTJC.js.map +1 -0
  94. package/dist/{chunk-H5YGYNXS.js → chunk-JAYYFOOB.js} +75 -28
  95. package/dist/chunk-JAYYFOOB.js.map +1 -0
  96. package/dist/chunk-KN2MYSCC.js +409 -0
  97. package/dist/chunk-KN2MYSCC.js.map +1 -0
  98. package/dist/{chunk-PEI6RANI.js → chunk-KYVJMTXL.js} +434 -145
  99. package/dist/chunk-KYVJMTXL.js.map +1 -0
  100. package/dist/{chunk-ZYRGEKWS.js → chunk-LJUMYUBO.js} +3 -1
  101. package/dist/{chunk-ZYRGEKWS.js.map → chunk-LJUMYUBO.js.map} +1 -1
  102. package/dist/{chunk-ICA6R6TW.js → chunk-LNUD3JNI.js} +1532 -395
  103. package/dist/chunk-LNUD3JNI.js.map +1 -0
  104. package/dist/chunk-M357MHH3.js +2 -0
  105. package/dist/{chunk-BV5A4OTE.js → chunk-MEL6PH2I.js} +1218 -537
  106. package/dist/chunk-MEL6PH2I.js.map +1 -0
  107. package/dist/chunk-MF6WS2XF.js +386 -0
  108. package/dist/chunk-MF6WS2XF.js.map +1 -0
  109. package/dist/chunk-MK2TQO4Y.js +24 -0
  110. package/dist/chunk-MK2TQO4Y.js.map +1 -0
  111. package/dist/chunk-N7S72EXK.js +25 -0
  112. package/dist/chunk-N7S72EXK.js.map +1 -0
  113. package/dist/{chunk-KZ73RL76.js → chunk-NAWXARTY.js} +58 -9
  114. package/dist/chunk-NAWXARTY.js.map +1 -0
  115. package/dist/chunk-NX4ADH73.js +14 -0
  116. package/dist/chunk-NX4ADH73.js.map +1 -0
  117. package/dist/chunk-OYQQJL3J.js +16 -0
  118. package/dist/chunk-OYQQJL3J.js.map +1 -0
  119. package/dist/chunk-P4MKPCTC.js +51 -0
  120. package/dist/chunk-P4MKPCTC.js.map +1 -0
  121. package/dist/{chunk-JVYQRRC4.js → chunk-PEHTX3V7.js} +21 -1
  122. package/dist/chunk-PEHTX3V7.js.map +1 -0
  123. package/dist/chunk-PMV53IMM.js +26 -0
  124. package/dist/chunk-PMV53IMM.js.map +1 -0
  125. package/dist/{chunk-HUIKIDM5.js → chunk-QOEWDOFW.js} +295 -156
  126. package/dist/chunk-QOEWDOFW.js.map +1 -0
  127. package/dist/chunk-QV3DJVRZ.js +11 -0
  128. package/dist/chunk-QV3DJVRZ.js.map +1 -0
  129. package/dist/{chunk-HUMIRRYI.js → chunk-QYUYVSNG.js} +1103 -1699
  130. package/dist/chunk-QYUYVSNG.js.map +1 -0
  131. package/dist/{chunk-6J56T3MG.js → chunk-RRAQ5FV5.js} +186 -60
  132. package/dist/chunk-RRAQ5FV5.js.map +1 -0
  133. package/dist/{chunk-5YK2ZDIG.js → chunk-TNEZNMSN.js} +4 -10
  134. package/dist/chunk-TNEZNMSN.js.map +1 -0
  135. package/dist/{chunk-22KP6LR5.js → chunk-TXS65BB2.js} +3 -1
  136. package/dist/{chunk-22KP6LR5.js.map → chunk-TXS65BB2.js.map} +1 -1
  137. package/dist/chunk-UIWIOB4U.js +2215 -0
  138. package/dist/chunk-UIWIOB4U.js.map +1 -0
  139. package/dist/chunk-UNJPZGNK.js +63 -0
  140. package/dist/chunk-UNJPZGNK.js.map +1 -0
  141. package/dist/chunk-V7UGCQHQ.js +86 -0
  142. package/dist/chunk-V7UGCQHQ.js.map +1 -0
  143. package/dist/chunk-VU4QUISJ.js +3405 -0
  144. package/dist/chunk-VU4QUISJ.js.map +1 -0
  145. package/dist/chunk-WEY5J52U.js +467 -0
  146. package/dist/chunk-WEY5J52U.js.map +1 -0
  147. package/dist/chunk-WH2CBESG.js +409 -0
  148. package/dist/chunk-WH2CBESG.js.map +1 -0
  149. package/dist/{chunk-VZTQ73XT.js → chunk-XEA5BCMA.js} +3 -1
  150. package/dist/{chunk-VZTQ73XT.js.map → chunk-XEA5BCMA.js.map} +1 -1
  151. package/dist/{chunk-NLTS7JHI.js → chunk-XEIHS3RN.js} +834 -403
  152. package/dist/chunk-XEIHS3RN.js.map +1 -0
  153. package/dist/chunk-YNXZRE3F.js +408 -0
  154. package/dist/chunk-YNXZRE3F.js.map +1 -0
  155. package/dist/chunk-YSRBFJMQ.js +43 -0
  156. package/dist/chunk-YSRBFJMQ.js.map +1 -0
  157. package/dist/{chunk-NEXLLTP4.js → chunk-ZGFU4LVW.js} +6 -5
  158. package/dist/chunk-ZGFU4LVW.js.map +1 -0
  159. package/dist/chunk-ZO35BAMO.js +172 -0
  160. package/dist/chunk-ZO35BAMO.js.map +1 -0
  161. package/dist/chunk-ZUWF4NF7.js +13 -0
  162. package/dist/chunk-ZUWF4NF7.js.map +1 -0
  163. package/dist/client.d.ts +15 -6
  164. package/dist/clipboard.js +3 -1
  165. package/dist/commands/registry.d.ts +2 -1
  166. package/dist/commands/types.d.ts +2 -0
  167. package/dist/components/anthropic-mark.d.ts +3 -0
  168. package/dist/components/approval-surface.d.ts +21 -7
  169. package/dist/components/artifacts/artifact-chrome.d.ts +121 -0
  170. package/dist/components/artifacts/artifact-sandbox.d.ts +30 -0
  171. package/dist/components/artifacts/artifact-surface.d.ts +4 -2
  172. package/dist/components/artifacts/chat-interactive-block.d.ts +29 -0
  173. package/dist/components/artifacts/deferred-chat-media.d.ts +15 -0
  174. package/dist/components/artifacts/document-editor.d.ts +4 -2
  175. package/dist/components/artifacts/editable-artifact-ui.d.ts +4 -2
  176. package/dist/components/artifacts/editable-artifact-view.d.ts +48 -0
  177. package/dist/components/artifacts/editable-document.d.ts +3 -2
  178. package/dist/components/artifacts/editable-presentation.d.ts +4 -3
  179. package/dist/components/artifacts/editable-spreadsheet.d.ts +8 -3
  180. package/dist/components/artifacts/index.d.ts +8 -1
  181. package/dist/components/artifacts/inline-html-document.d.ts +2 -0
  182. package/dist/components/artifacts/latest-task-runner.d.ts +15 -0
  183. package/dist/components/artifacts/presentation-editor.d.ts +6 -2
  184. package/dist/components/artifacts/published-html-artifact-frame.d.ts +17 -40
  185. package/dist/components/artifacts/session-artifact-viewer.d.ts +39 -0
  186. package/dist/components/artifacts/site-view.d.ts +26 -0
  187. package/dist/components/artifacts/spreadsheet-command-queue.d.ts +20 -0
  188. package/dist/components/artifacts/spreadsheet-download.d.ts +7 -0
  189. package/dist/components/artifacts/spreadsheet-general-display.d.ts +24 -0
  190. package/dist/components/artifacts/spreadsheet-grid.d.ts +11 -4
  191. package/dist/components/artifacts/spreadsheet-resize.d.ts +50 -0
  192. package/dist/components/artifacts/spreadsheet-submissions.d.ts +9 -0
  193. package/dist/components/artifacts/visualization-assets.gen.d.ts +2 -0
  194. package/dist/components/browser-select-control.d.ts +16 -0
  195. package/dist/components/browser-viewer.d.ts +11 -2
  196. package/dist/components/chat-composer.d.ts +21 -3
  197. package/dist/components/child-session-link.d.ts +5 -1
  198. package/dist/components/claude-mark.d.ts +3 -0
  199. package/dist/components/code-editor.d.ts +1 -4
  200. package/dist/components/command-palette.d.ts +1 -1
  201. package/dist/components/composer-transcription-control.d.ts +7 -0
  202. package/dist/components/composer.d.ts +30 -67
  203. package/dist/components/computer-viewer.d.ts +1 -1
  204. package/dist/components/copy-button.d.ts +3 -1
  205. package/dist/components/desktop-viewer.d.ts +1 -1
  206. package/dist/components/generated-video-player.d.ts +1 -1
  207. package/dist/components/grok-mark.d.ts +26 -0
  208. package/dist/components/human-input-form.d.ts +26 -32
  209. package/dist/components/human-input-surface.d.ts +5 -1
  210. package/dist/components/linkified-text.d.ts +18 -0
  211. package/dist/components/machine-input-display.d.ts +25 -3
  212. package/dist/components/machine-status-pill.d.ts +3 -2
  213. package/dist/components/machines/agent-status-icon.d.ts +6 -0
  214. package/dist/components/machines/health.d.ts +2 -1
  215. package/dist/components/machines/machine-detail.d.ts +7 -1
  216. package/dist/components/machines/machine-status.d.ts +49 -0
  217. package/dist/components/machines/metric-history-chart.d.ts +1 -1
  218. package/dist/components/machines/series.d.ts +3 -2
  219. package/dist/components/markdown-table-layout.d.ts +11 -2
  220. package/dist/components/markdown.d.ts +37 -4
  221. package/dist/components/message-timeline.d.ts +79 -7
  222. package/dist/components/model-mark.d.ts +29 -0
  223. package/dist/components/model-picker.d.ts +1 -1
  224. package/dist/components/model-policy-picker.d.ts +31 -22
  225. package/dist/components/new-conversation.d.ts +32 -0
  226. package/dist/components/open-geni-chat.d.ts +73 -0
  227. package/dist/components/open-geni-links.d.ts +69 -0
  228. package/dist/components/openrouter-mark.d.ts +6 -0
  229. package/dist/components/opper-mark.d.ts +7 -0
  230. package/dist/components/preview-loading.d.ts +2 -0
  231. package/dist/components/provider-recovery-notice.d.ts +17 -0
  232. package/dist/components/queue-item-content.d.ts +10 -0
  233. package/dist/components/rehype-secret-refs.d.ts +23 -0
  234. package/dist/components/remark-soft-line-breaks.d.ts +38 -0
  235. package/dist/components/sandbox-workspace.d.ts +18 -0
  236. package/dist/components/secret-question-field.d.ts +31 -0
  237. package/dist/components/secret-ref-chip.d.ts +35 -0
  238. package/dist/components/session-capability-frame.d.ts +37 -0
  239. package/dist/components/session-chrome.d.ts +20 -7
  240. package/dist/components/session-commands.d.ts +6 -0
  241. package/dist/components/session-connection-request.d.ts +8 -0
  242. package/dist/components/session-conversation.d.ts +147 -6
  243. package/dist/components/session-list.d.ts +39 -0
  244. package/dist/components/session-mcp-capability-card.d.ts +41 -0
  245. package/dist/components/session-proxy-scope.d.ts +35 -0
  246. package/dist/components/session-status.d.ts +6 -2
  247. package/dist/components/session-usage-limit-notice.d.ts +39 -0
  248. package/dist/components/this-computer/illustrations.d.ts +38 -0
  249. package/dist/components/this-computer/labels.d.ts +111 -0
  250. package/dist/components/this-computer/this-computer-card.d.ts +40 -0
  251. package/dist/components/this-computer/this-computer-setup.d.ts +35 -0
  252. package/dist/components/this-computer/this-computer-status.d.ts +42 -0
  253. package/dist/components/this-computer/use-this-computer.d.ts +29 -0
  254. package/dist/components/timeline-anchor.d.ts +3 -0
  255. package/dist/components/timeline-annotation-shared.d.ts +3 -2
  256. package/dist/components/timeline-annotations-dialog.d.ts +2 -1
  257. package/dist/components/timeline-annotations.d.ts +5 -1
  258. package/dist/components/timeline-reading-progress.d.ts +11 -0
  259. package/dist/components/timeline-search.d.ts +34 -0
  260. package/dist/components/timeline-settlement.d.ts +16 -0
  261. package/dist/components/tool-action-review.d.ts +48 -0
  262. package/dist/components/tool-review-history.d.ts +25 -0
  263. package/dist/components/usage-limit-notice.d.ts +50 -0
  264. package/dist/components/usage-member-list.d.ts +92 -0
  265. package/dist/components/usage-meter.d.ts +74 -0
  266. package/dist/components/use-viewer-menu-dismiss.d.ts +2 -0
  267. package/dist/components/user-message-body.d.ts +10 -1
  268. package/dist/components/workbench-changes.d.ts +2 -1
  269. package/dist/composer-messages.d.ts +75 -0
  270. package/dist/composer-messages.js +9 -0
  271. package/dist/composer-messages.js.map +1 -0
  272. package/dist/composer-voice-events.d.ts +8 -0
  273. package/dist/composer.d.ts +3 -3
  274. package/dist/composer.js +25 -12
  275. package/dist/computer-viewer-VOIOZGVZ.js +21 -0
  276. package/dist/computer-viewer-VOIOZGVZ.js.map +1 -0
  277. package/dist/connect-account-identity.d.ts +8 -0
  278. package/dist/connect-accounts.d.ts +15 -0
  279. package/dist/connect-chooser.d.ts +18 -0
  280. package/dist/connect-panel.d.ts +18 -0
  281. package/dist/connect-setup.d.ts +18 -0
  282. package/dist/connect.d.ts +21 -0
  283. package/dist/connect.js +2216 -0
  284. package/dist/connect.js.map +1 -0
  285. package/dist/connection-catalog.d.ts +38 -0
  286. package/dist/connection-discovery.d.ts +12 -0
  287. package/dist/connection-installed.d.ts +17 -0
  288. package/dist/connection-logo.d.ts +9 -0
  289. package/dist/connection-service-logo.d.ts +8 -0
  290. package/dist/connection-service-presentation.d.ts +13 -0
  291. package/dist/connection-skeleton.d.ts +5 -0
  292. package/dist/connection-type-picker.d.ts +6 -0
  293. package/dist/conversation-timeline.d.ts +1 -1
  294. package/dist/desktop.d.ts +7 -0
  295. package/dist/desktop.js +28 -0
  296. package/dist/desktop.js.map +1 -0
  297. package/dist/device-authorization.d.ts +23 -0
  298. package/dist/diffs.d.ts +8 -0
  299. package/dist/diffs.js +15 -0
  300. package/dist/diffs.js.map +1 -0
  301. package/dist/discovery-cache.d.ts +5 -0
  302. package/dist/editor.d.ts +7 -0
  303. package/dist/editor.js +23 -0
  304. package/dist/editor.js.map +1 -0
  305. package/dist/embedded-new-voice-KPLC5UJZ.js +19 -0
  306. package/dist/embedded-new-voice-KPLC5UJZ.js.map +1 -0
  307. package/dist/embedded-voice-V2RFSLIU.js +19 -0
  308. package/dist/embedded-voice-V2RFSLIU.js.map +1 -0
  309. package/dist/fleet-decision-row-FE73NSQ6.js +361 -0
  310. package/dist/fleet-decision-row-FE73NSQ6.js.map +1 -0
  311. package/dist/hooks/internal.d.ts +27 -2
  312. package/dist/hooks/latest-question.d.ts +26 -0
  313. package/dist/hooks/session-view-cache.d.ts +38 -0
  314. package/dist/hooks/shared-machines-list.d.ts +4 -0
  315. package/dist/hooks/shared-query.d.ts +123 -0
  316. package/dist/hooks/use-attached-browsers.d.ts +1 -1
  317. package/dist/hooks/use-auth-runs.d.ts +1 -4
  318. package/dist/hooks/use-available-models.d.ts +8 -3
  319. package/dist/hooks/use-browser-frame-stream.d.ts +1 -1
  320. package/dist/hooks/use-browser-session.d.ts +12 -1
  321. package/dist/hooks/use-client-config-flags.d.ts +49 -0
  322. package/dist/hooks/use-codex-accounts.d.ts +48 -9
  323. package/dist/hooks/use-composer.d.ts +24 -3
  324. package/dist/hooks/use-computer-frame-stream.d.ts +1 -1
  325. package/dist/hooks/use-computer-input-posture.d.ts +13 -0
  326. package/dist/hooks/use-computer-session.d.ts +5 -0
  327. package/dist/hooks/use-connect.d.ts +23 -0
  328. package/dist/hooks/use-desktop-stream.d.ts +1 -1
  329. package/dist/hooks/use-file-attachments.d.ts +4 -0
  330. package/dist/hooks/use-goal.d.ts +2 -1
  331. package/dist/hooks/use-last-started-turn-policy.d.ts +5 -1
  332. package/dist/hooks/use-machine-chip.d.ts +3 -2
  333. package/dist/hooks/use-new-conversation.d.ts +56 -0
  334. package/dist/hooks/use-new-session-draft.d.ts +74 -0
  335. package/dist/hooks/use-realtime-voice-models.d.ts +7 -0
  336. package/dist/hooks/use-sandbox-files.d.ts +3 -2
  337. package/dist/hooks/use-session-conversation.d.ts +49 -0
  338. package/dist/hooks/use-session-events.d.ts +21 -2
  339. package/dist/hooks/use-session-mcp-approval-policy.d.ts +2 -2
  340. package/dist/hooks/use-session-model-account.d.ts +48 -0
  341. package/dist/hooks/use-supergrok-accounts.d.ts +7 -1
  342. package/dist/hooks/use-terminal-stream.d.ts +11 -5
  343. package/dist/hooks/use-transcription.d.ts +2 -1
  344. package/dist/hooks/use-usage.d.ts +40 -0
  345. package/dist/hooks/use-vaults.d.ts +53 -0
  346. package/dist/hooks/use-voice-input.d.ts +8 -1
  347. package/dist/hooks/use-workspace-sessions.d.ts +24 -5
  348. package/dist/human-input-model.d.ts +123 -0
  349. package/dist/identity-link-accounts.d.ts +11 -0
  350. package/dist/identity-link-consent.d.ts +18 -0
  351. package/dist/index.d.ts +83 -18
  352. package/dist/index.js +2317 -6453
  353. package/dist/index.js.map +1 -1
  354. package/dist/interaction.d.ts +1 -1
  355. package/dist/interaction.js +20 -29
  356. package/dist/interaction.js.map +1 -1
  357. package/dist/latest-question-SXBXROBT.js +118 -0
  358. package/dist/latest-question-SXBXROBT.js.map +1 -0
  359. package/dist/lib/client-config-read.d.ts +31 -0
  360. package/dist/lib/clipboard.d.ts +7 -0
  361. package/dist/lib/error-message.d.ts +7 -0
  362. package/dist/lib/format.d.ts +59 -9
  363. package/dist/lib/host-theme.d.ts +77 -0
  364. package/dist/lib/interaction-errors.d.ts +3 -0
  365. package/dist/lib/menu-styles.d.ts +22 -0
  366. package/dist/lib/notify-observer.d.ts +2 -0
  367. package/dist/lib/pierre-diffs-loader.d.ts +20 -0
  368. package/dist/lib/provider-recovery.d.ts +56 -0
  369. package/dist/lib/scrollbars.d.ts +11 -0
  370. package/dist/lib/terminal-input-readiness.d.ts +11 -0
  371. package/dist/lib/transient-retry.d.ts +26 -0
  372. package/dist/lib/workbench-peers.d.ts +36 -0
  373. package/dist/lib/xterm-theme.d.ts +7 -5
  374. package/dist/machines.js +12 -6
  375. package/dist/{markdown-table-layout-3Z3AWBY7.js → markdown-table-layout-3PV2UAAH.js} +51 -9
  376. package/dist/markdown-table-layout-3PV2UAAH.js.map +1 -0
  377. package/dist/mcp-connection-status.d.ts +15 -0
  378. package/dist/messages/en.d.ts +3328 -0
  379. package/dist/messages/runtime.d.ts +69 -0
  380. package/dist/messages.d.ts +3 -0
  381. package/dist/messages.js +16 -0
  382. package/dist/messages.js.map +1 -0
  383. package/dist/model-mark-paths.d.ts +34 -0
  384. package/dist/model-mark-paths.js +16 -0
  385. package/dist/model-mark-paths.js.map +1 -0
  386. package/dist/model-picker-model.d.ts +112 -0
  387. package/dist/model-picker-model.js +25 -0
  388. package/dist/model-picker-model.js.map +1 -0
  389. package/dist/model-policy-picker-menu-NWIETWSR.js +18 -0
  390. package/dist/model-policy-picker-menu-NWIETWSR.js.map +1 -0
  391. package/dist/model-policy.d.ts +35 -10
  392. package/dist/model-policy.js +12 -1
  393. package/dist/native-previews.d.ts +29 -0
  394. package/dist/native-previews.js +82 -0
  395. package/dist/native-previews.js.map +1 -0
  396. package/dist/new-session-draft.d.ts +7 -0
  397. package/dist/new-session-draft.js +639 -0
  398. package/dist/new-session-draft.js.map +1 -0
  399. package/dist/notification-text.d.ts +27 -0
  400. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js → noto-sans-arabic-loader-XSH2KYWJ.js} +3 -1
  401. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js.map → noto-sans-arabic-loader-XSH2KYWJ.js.map} +1 -1
  402. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js → noto-sans-jp-loader.generated-MR5L6V7K.js} +3 -1
  403. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js.map → noto-sans-jp-loader.generated-MR5L6V7K.js.map} +1 -1
  404. package/dist/organization-model.d.ts +33 -0
  405. package/dist/organization-model.js +65 -0
  406. package/dist/organization-model.js.map +1 -0
  407. package/dist/platform-activity-row-VSQ2FZ5T.js +119 -0
  408. package/dist/platform-activity-row-VSQ2FZ5T.js.map +1 -0
  409. package/dist/plugin-details.d.ts +14 -0
  410. package/dist/plugin-discovery.d.ts +25 -0
  411. package/dist/preview-loading-paint.d.ts +20 -0
  412. package/dist/provider.d.ts +37 -2
  413. package/dist/queue-presentation-model.d.ts +73 -0
  414. package/dist/queue-presentation-model.js +38 -0
  415. package/dist/queue-presentation-model.js.map +1 -0
  416. package/dist/{queue-surface-implementation-LK3S4BIW.js → queue-surface-implementation-MEKXXWGR.js} +189 -343
  417. package/dist/queue-surface-implementation-MEKXXWGR.js.map +1 -0
  418. package/dist/realtime/embedded-new-voice.d.ts +1 -0
  419. package/dist/realtime/embedded-voice.d.ts +1 -0
  420. package/dist/realtime/realtime-control.d.ts +4 -65
  421. package/dist/realtime/session-realtime.d.ts +79 -0
  422. package/dist/realtime.js +26 -1333
  423. package/dist/realtime.js.map +1 -1
  424. package/dist/sandbox-files-5NRC2QUT.js +24 -0
  425. package/dist/sandbox-files-5NRC2QUT.js.map +1 -0
  426. package/dist/sandbox-label-model.d.ts +31 -0
  427. package/dist/sandbox-label-model.js +20 -0
  428. package/dist/sandbox-label-model.js.map +1 -0
  429. package/dist/scrollbars.d.ts +1 -0
  430. package/dist/scrollbars.js +10 -0
  431. package/dist/scrollbars.js.map +1 -0
  432. package/dist/secret-reference-label.d.ts +15 -0
  433. package/dist/secrets-ui.d.ts +57 -0
  434. package/dist/session-agents-model.d.ts +11 -0
  435. package/dist/session-agents-model.js +25 -0
  436. package/dist/session-agents-model.js.map +1 -0
  437. package/dist/session-attention-model.d.ts +8 -0
  438. package/dist/session-attention-model.js +47 -0
  439. package/dist/session-attention-model.js.map +1 -0
  440. package/dist/session-auth-recommendation.d.ts +6 -0
  441. package/dist/session-capability-policy.d.ts +32 -0
  442. package/dist/session-context.d.ts +9 -1
  443. package/dist/session-feedback-model.d.ts +21 -0
  444. package/dist/session-feedback-model.js +56 -0
  445. package/dist/session-feedback-model.js.map +1 -0
  446. package/dist/session-list-model.d.ts +139 -0
  447. package/dist/session-list-model.js +274 -0
  448. package/dist/session-list-model.js.map +1 -0
  449. package/dist/session-realtime-OZCE6IKP.js +22 -0
  450. package/dist/session-realtime-OZCE6IKP.js.map +1 -0
  451. package/dist/session-realtime.d.ts +7 -0
  452. package/dist/session-realtime.js +20 -0
  453. package/dist/session-realtime.js.map +1 -0
  454. package/dist/session-status-model.d.ts +37 -0
  455. package/dist/session-ui.d.ts +40 -3
  456. package/dist/session-ui.js +127 -21
  457. package/dist/session-ui.js.map +1 -1
  458. package/dist/session.d.ts +10 -2
  459. package/dist/session.js +44 -20
  460. package/dist/site-snapshot.d.ts +14 -0
  461. package/dist/sites-ui.d.ts +24 -0
  462. package/dist/sites.d.ts +3 -0
  463. package/dist/sites.js +15 -0
  464. package/dist/sites.js.map +1 -0
  465. package/dist/skill-discovery.d.ts +47 -0
  466. package/dist/terminal.d.ts +8 -0
  467. package/dist/terminal.js +33 -0
  468. package/dist/terminal.js.map +1 -0
  469. package/dist/testing/session-scenarios.d.ts +10 -0
  470. package/dist/testing/session-scenarios.js +367 -0
  471. package/dist/testing/session-scenarios.js.map +1 -0
  472. package/dist/this-computer.d.ts +8 -0
  473. package/dist/this-computer.js +1042 -0
  474. package/dist/this-computer.js.map +1 -0
  475. package/dist/timeline/activity-rail.d.ts +12 -2
  476. package/dist/timeline/agent-identity.d.ts +30 -0
  477. package/dist/timeline/agent-row.d.ts +31 -0
  478. package/dist/timeline/allowance-exhausted-row.d.ts +24 -0
  479. package/dist/timeline/compaction-copy.d.ts +47 -0
  480. package/dist/timeline/focus-sequence.d.ts +9 -0
  481. package/dist/timeline/genie-copy.d.ts +4 -0
  482. package/dist/timeline/genie-loading.d.ts +48 -0
  483. package/dist/timeline/index.d.ts +12 -5
  484. package/dist/timeline/invoked-tool.d.ts +6 -0
  485. package/dist/timeline/knowledge-receipt.d.ts +17 -0
  486. package/dist/timeline/learning-refusal-copy.d.ts +23 -0
  487. package/dist/timeline/learning-refusal-row.d.ts +19 -0
  488. package/dist/timeline/message-sender.d.ts +19 -0
  489. package/dist/timeline/notice-presentation.d.ts +14 -0
  490. package/dist/timeline/parsers.d.ts +11 -0
  491. package/dist/timeline/patch-apply-command.d.ts +19 -0
  492. package/dist/timeline/platform-activity-presentation.d.ts +26 -0
  493. package/dist/timeline/platform-activity-row.d.ts +1 -2
  494. package/dist/timeline/presented-image.d.ts +11 -0
  495. package/dist/timeline/projection.d.ts +32 -2
  496. package/dist/timeline/provider-logo.d.ts +15 -0
  497. package/dist/timeline/question-nav-model.d.ts +23 -0
  498. package/dist/timeline/registry.d.ts +10 -1
  499. package/dist/timeline/retained-image.d.ts +18 -0
  500. package/dist/timeline/retained-loaders.d.ts +27 -0
  501. package/dist/timeline/rolling-activity.d.ts +11 -0
  502. package/dist/timeline/screenshot-lightbox.d.ts +23 -1
  503. package/dist/timeline/session-usage-limit-row.d.ts +11 -0
  504. package/dist/timeline/shared.d.ts +8 -3
  505. package/dist/timeline/startup-dispatch-details.d.ts +5 -0
  506. package/dist/timeline/startup-preference.d.ts +3 -0
  507. package/dist/timeline/startup-timings.d.ts +4 -0
  508. package/dist/timeline/tool-display-name.d.ts +6 -2
  509. package/dist/timeline/tool-presentation.d.ts +185 -0
  510. package/dist/timeline/turn-summary-model.d.ts +102 -0
  511. package/dist/timeline/turn-summary.d.ts +20 -54
  512. package/dist/timeline/types.d.ts +184 -7
  513. package/dist/timeline/work-presentation.d.ts +61 -0
  514. package/dist/{timeline-annotation-markers-DRSTLEM6.js → timeline-annotation-markers-HYLRTT6S.js} +11 -6
  515. package/dist/timeline-annotation-markers-HYLRTT6S.js.map +1 -0
  516. package/dist/{timeline-annotation-selection-IHLUGVND.js → timeline-annotation-selection-LBKW5GHA.js} +15 -5
  517. package/dist/timeline-annotation-selection-LBKW5GHA.js.map +1 -0
  518. package/dist/{timeline-annotations-dialog-6Q53N5FG.js → timeline-annotations-dialog-JKVINC42.js} +34 -19
  519. package/dist/timeline-annotations-dialog-JKVINC42.js.map +1 -0
  520. package/dist/timeline-model.d.ts +29 -0
  521. package/dist/timeline-model.js +254 -0
  522. package/dist/timeline-model.js.map +1 -0
  523. package/dist/usage/allowance-copy.d.ts +26 -0
  524. package/dist/usage/session-usage-limit.d.ts +89 -0
  525. package/dist/usage/summary.d.ts +35 -0
  526. package/dist/usage.d.ts +17 -0
  527. package/dist/usage.js +1201 -0
  528. package/dist/usage.js.map +1 -0
  529. package/dist/voice-recording-owner.d.ts +7 -0
  530. package/package.json +119 -7
  531. package/src/approvals.ts +8 -1
  532. package/src/artifacts-spreadsheet.ts +1 -0
  533. package/src/artifacts.ts +41 -0
  534. package/src/assets/README.md +8 -0
  535. package/src/assets/gmail.ico +0 -0
  536. package/src/assets/outlook.ico +0 -0
  537. package/src/capability-catalog-row.tsx +96 -0
  538. package/src/capability-logo-fallback.ts +22 -0
  539. package/src/client.ts +18 -30
  540. package/src/commands/registry.ts +46 -36
  541. package/src/commands/types.ts +2 -0
  542. package/src/components/anthropic-mark.tsx +10 -0
  543. package/src/components/approval-surface.tsx +407 -142
  544. package/src/components/artifacts/artifact-chrome.tsx +425 -0
  545. package/src/components/artifacts/artifact-sandbox.tsx +193 -0
  546. package/src/components/artifacts/artifact-surface.tsx +48 -26
  547. package/src/components/artifacts/chat-interactive-block.tsx +260 -0
  548. package/src/components/artifacts/deferred-chat-media.tsx +72 -0
  549. package/src/components/artifacts/document-editor.tsx +193 -45
  550. package/src/components/artifacts/editable-artifact-ui.tsx +23 -11
  551. package/src/components/artifacts/editable-artifact-view.tsx +199 -0
  552. package/src/components/artifacts/editable-artifact-workbench.tsx +8 -3
  553. package/src/components/artifacts/editable-document.tsx +76 -54
  554. package/src/components/artifacts/editable-presentation.tsx +86 -40
  555. package/src/components/artifacts/editable-spreadsheet.tsx +581 -121
  556. package/src/components/artifacts/index.ts +42 -0
  557. package/src/components/artifacts/inline-html-document.ts +24 -0
  558. package/src/components/artifacts/latest-task-runner.ts +49 -0
  559. package/src/components/artifacts/presentation-editor.tsx +422 -122
  560. package/src/components/artifacts/published-html-artifact-frame.tsx +79 -265
  561. package/src/components/artifacts/session-artifact-viewer.tsx +381 -0
  562. package/src/components/artifacts/site-view.tsx +129 -0
  563. package/src/components/artifacts/spreadsheet-canvas.ts +5 -10
  564. package/src/components/artifacts/spreadsheet-command-queue.ts +190 -0
  565. package/src/components/artifacts/spreadsheet-download.tsx +117 -0
  566. package/src/components/artifacts/spreadsheet-general-display.ts +43 -0
  567. package/src/components/artifacts/spreadsheet-grid.tsx +390 -172
  568. package/src/components/artifacts/spreadsheet-resize.tsx +432 -0
  569. package/src/components/artifacts/spreadsheet-submissions.tsx +46 -0
  570. package/src/components/artifacts/visualization-assets/base.css +1015 -0
  571. package/src/components/artifacts/visualization-assets/helpers.html +349 -0
  572. package/src/components/artifacts/visualization-assets.gen.ts +3 -0
  573. package/src/components/browser-select-control.tsx +320 -0
  574. package/src/components/browser-viewer.tsx +1102 -505
  575. package/src/components/chat-composer.tsx +42 -3
  576. package/src/components/child-session-link.tsx +16 -5
  577. package/src/components/claude-mark.tsx +11 -0
  578. package/src/components/code-editor.tsx +38 -27
  579. package/src/components/command-palette.tsx +4 -1
  580. package/src/components/composer-transcription-control.tsx +151 -50
  581. package/src/components/composer.tsx +281 -176
  582. package/src/components/computer-viewer.tsx +1013 -341
  583. package/src/components/copy-button.tsx +17 -7
  584. package/src/components/desktop-viewer.tsx +42 -33
  585. package/src/components/diff-view.tsx +3 -1
  586. package/src/components/enrollment-consent.tsx +39 -34
  587. package/src/components/enrollment-device-flow.tsx +31 -19
  588. package/src/components/file-browser.tsx +47 -35
  589. package/src/components/fleet-tile.tsx +8 -4
  590. package/src/components/generated-video-player.tsx +10 -5
  591. package/src/components/grok-mark.tsx +34 -0
  592. package/src/components/human-input-form.tsx +438 -251
  593. package/src/components/human-input-surface.tsx +8 -0
  594. package/src/components/interaction-intervention-banner.tsx +15 -13
  595. package/src/components/linkified-text.tsx +79 -0
  596. package/src/components/machine-card.tsx +56 -89
  597. package/src/components/machine-dock-bar.tsx +10 -4
  598. package/src/components/machine-health-pill.tsx +4 -2
  599. package/src/components/machine-input-display.ts +309 -34
  600. package/src/components/machine-metrics.tsx +10 -7
  601. package/src/components/machine-status-pill.tsx +23 -15
  602. package/src/components/machines/agent-status-icon.tsx +31 -0
  603. package/src/components/machines/health.ts +53 -10
  604. package/src/components/machines/machine-detail.tsx +230 -42
  605. package/src/components/machines/machine-operation-policy.tsx +36 -29
  606. package/src/components/machines/machine-status.ts +264 -0
  607. package/src/components/machines/metric-history-chart.tsx +8 -2
  608. package/src/components/machines/series.ts +12 -11
  609. package/src/components/machines-dashboard.tsx +16 -9
  610. package/src/components/markdown-table-layout.ts +67 -9
  611. package/src/components/markdown.tsx +470 -133
  612. package/src/components/message-timeline.tsx +2290 -752
  613. package/src/components/model-mark.tsx +102 -0
  614. package/src/components/model-picker.tsx +27 -9
  615. package/src/components/model-policy-picker-menu.tsx +204 -100
  616. package/src/components/model-policy-picker.tsx +215 -152
  617. package/src/components/new-conversation.tsx +223 -0
  618. package/src/components/open-geni-chat.tsx +311 -0
  619. package/src/components/open-geni-links.tsx +183 -0
  620. package/src/components/openrouter-mark.tsx +13 -0
  621. package/src/components/opper-mark.tsx +18 -0
  622. package/src/components/pierre-diff.tsx +47 -19
  623. package/src/components/pierre-file.tsx +38 -11
  624. package/src/components/preview-loading.tsx +111 -0
  625. package/src/components/provider-recovery-notice.tsx +51 -0
  626. package/src/components/queue-item-content.ts +16 -0
  627. package/src/components/queue-surface-implementation.tsx +185 -420
  628. package/src/components/queue-surface-state.tsx +13 -8
  629. package/src/components/queue-surface.tsx +3 -1
  630. package/src/components/rehype-secret-refs.ts +98 -0
  631. package/src/components/remark-soft-line-breaks.ts +166 -0
  632. package/src/components/sandbox-files.tsx +75 -44
  633. package/src/components/sandbox-terminal.tsx +103 -22
  634. package/src/components/sandbox-workspace.tsx +168 -78
  635. package/src/components/secret-question-field.tsx +326 -0
  636. package/src/components/secret-ref-chip.tsx +187 -0
  637. package/src/components/session-capability-frame.tsx +203 -0
  638. package/src/components/session-chrome.tsx +559 -328
  639. package/src/components/session-commands-panel.tsx +34 -17
  640. package/src/components/session-commands.tsx +18 -0
  641. package/src/components/session-connection-request.tsx +99 -0
  642. package/src/components/session-conversation.tsx +853 -118
  643. package/src/components/session-list.tsx +259 -0
  644. package/src/components/session-mcp-capability-card.tsx +681 -0
  645. package/src/components/session-proxy-scope.tsx +160 -0
  646. package/src/components/session-status.tsx +35 -21
  647. package/src/components/session-usage-limit-notice.tsx +176 -0
  648. package/src/components/this-computer/illustrations.tsx +164 -0
  649. package/src/components/this-computer/labels.ts +234 -0
  650. package/src/components/this-computer/this-computer-card.tsx +203 -0
  651. package/src/components/this-computer/this-computer-setup.tsx +433 -0
  652. package/src/components/this-computer/this-computer-status.tsx +329 -0
  653. package/src/components/this-computer/use-this-computer.ts +183 -0
  654. package/src/components/timeline-anchor.tsx +43 -15
  655. package/src/components/timeline-annotation-chrome.tsx +33 -9
  656. package/src/components/timeline-annotation-markers.tsx +4 -2
  657. package/src/components/timeline-annotation-selection.tsx +11 -2
  658. package/src/components/timeline-annotation-shared.ts +9 -8
  659. package/src/components/timeline-annotations-dialog.tsx +30 -9
  660. package/src/components/timeline-annotations.tsx +24 -7
  661. package/src/components/timeline-reading-progress.ts +80 -0
  662. package/src/components/timeline-search.tsx +168 -0
  663. package/src/components/timeline-settlement.ts +60 -0
  664. package/src/components/tool-action-review.tsx +670 -0
  665. package/src/components/tool-review-history.tsx +88 -0
  666. package/src/components/usage-limit-notice.tsx +183 -0
  667. package/src/components/usage-member-list.tsx +797 -0
  668. package/src/components/usage-meter.tsx +386 -0
  669. package/src/components/use-viewer-menu-dismiss.ts +33 -0
  670. package/src/components/user-message-body.tsx +33 -2
  671. package/src/components/workbench-changes.tsx +28 -16
  672. package/src/components/workspace-dock.tsx +45 -13
  673. package/src/composer-messages.ts +153 -0
  674. package/src/composer-voice-events.ts +12 -0
  675. package/src/composer.ts +4 -0
  676. package/src/connect-account-identity.tsx +38 -0
  677. package/src/connect-accounts.tsx +233 -0
  678. package/src/connect-chooser.tsx +339 -0
  679. package/src/connect-panel.tsx +104 -0
  680. package/src/connect-setup.tsx +354 -0
  681. package/src/connect.ts +60 -0
  682. package/src/connection-assets.d.ts +4 -0
  683. package/src/connection-catalog.tsx +175 -0
  684. package/src/connection-discovery.tsx +251 -0
  685. package/src/connection-installed.tsx +56 -0
  686. package/src/connection-logo.tsx +37 -0
  687. package/src/connection-service-logo.tsx +55 -0
  688. package/src/connection-service-presentation.ts +46 -0
  689. package/src/connection-skeleton.tsx +16 -0
  690. package/src/connection-type-picker.tsx +38 -0
  691. package/src/conversation-timeline.ts +11 -2
  692. package/src/desktop.ts +24 -0
  693. package/src/device-authorization.tsx +111 -0
  694. package/src/diffs.ts +16 -0
  695. package/src/discovery-cache.ts +42 -0
  696. package/src/editor.ts +13 -0
  697. package/src/hooks/internal.ts +93 -10
  698. package/src/hooks/latest-question.ts +168 -0
  699. package/src/hooks/session-view-cache.ts +167 -0
  700. package/src/hooks/shared-machines-list.ts +34 -1
  701. package/src/hooks/shared-query.ts +744 -0
  702. package/src/hooks/use-attached-browsers.ts +1 -1
  703. package/src/hooks/use-auth-runs.ts +0 -27
  704. package/src/hooks/use-available-models.ts +20 -10
  705. package/src/hooks/use-browser-frame-stream.ts +23 -4
  706. package/src/hooks/use-browser-session.ts +684 -206
  707. package/src/hooks/use-browser-sessions.ts +32 -1
  708. package/src/hooks/use-client-config-flags.ts +102 -0
  709. package/src/hooks/use-codex-accounts.ts +216 -43
  710. package/src/hooks/use-composer.ts +240 -59
  711. package/src/hooks/use-computer-frame-stream.ts +29 -9
  712. package/src/hooks/use-computer-input-posture.ts +96 -0
  713. package/src/hooks/use-computer-session.ts +419 -100
  714. package/src/hooks/use-connect.ts +23 -0
  715. package/src/hooks/use-desktop-stream.ts +19 -28
  716. package/src/hooks/use-file-attachments.ts +19 -3
  717. package/src/hooks/use-goal.ts +172 -21
  718. package/src/hooks/use-human-input.ts +16 -2
  719. package/src/hooks/use-last-started-turn-policy.ts +37 -11
  720. package/src/hooks/use-machine-chip.ts +13 -8
  721. package/src/hooks/use-machines.ts +24 -10
  722. package/src/hooks/use-new-conversation.ts +377 -0
  723. package/src/hooks/use-new-session-draft.ts +813 -0
  724. package/src/hooks/use-realtime-voice-models.ts +46 -0
  725. package/src/hooks/use-sandbox-files.ts +22 -16
  726. package/src/hooks/use-session-background-commands.ts +2 -2
  727. package/src/hooks/use-session-capabilities.ts +3 -2
  728. package/src/hooks/use-session-conversation.ts +150 -0
  729. package/src/hooks/use-session-events.ts +403 -64
  730. package/src/hooks/use-session-lineage.ts +47 -9
  731. package/src/hooks/use-session-mcp-approval-policy.ts +13 -5
  732. package/src/hooks/use-session-model-account.ts +174 -0
  733. package/src/hooks/use-session.ts +19 -3
  734. package/src/hooks/use-slash-commands.ts +6 -11
  735. package/src/hooks/use-supergrok-accounts.ts +22 -8
  736. package/src/hooks/use-terminal-stream.ts +153 -27
  737. package/src/hooks/use-transcription.ts +45 -19
  738. package/src/hooks/use-turn-queue.ts +25 -5
  739. package/src/hooks/use-usage.ts +100 -0
  740. package/src/hooks/use-vaults.ts +153 -0
  741. package/src/hooks/use-video-artifact-playback.ts +1 -1
  742. package/src/hooks/use-voice-input.ts +127 -19
  743. package/src/hooks/use-workspace-capture.ts +3 -2
  744. package/src/hooks/use-workspace-sessions.ts +74 -7
  745. package/src/human-input-model.ts +374 -0
  746. package/src/identity-link-accounts.tsx +149 -0
  747. package/src/identity-link-consent.tsx +193 -0
  748. package/src/index.ts +282 -16
  749. package/src/interaction.ts +1 -0
  750. package/src/lib/client-config-read.ts +76 -0
  751. package/src/lib/clipboard.ts +29 -0
  752. package/src/lib/error-message.ts +37 -0
  753. package/src/lib/format.ts +231 -36
  754. package/src/lib/host-theme.ts +529 -0
  755. package/src/lib/interaction-errors.ts +15 -0
  756. package/src/lib/menu-styles.ts +44 -0
  757. package/src/lib/notify-observer.ts +15 -0
  758. package/src/lib/pierre-diffs-loader.ts +53 -0
  759. package/src/lib/provider-recovery.ts +255 -0
  760. package/src/lib/scrollbars.ts +30 -0
  761. package/src/lib/terminal-input-readiness.ts +51 -0
  762. package/src/lib/transient-retry.ts +101 -0
  763. package/src/lib/workbench-peers.ts +62 -0
  764. package/src/lib/xterm-theme.ts +23 -21
  765. package/src/mcp-connection-status.ts +39 -0
  766. package/src/messages/en.ts +3810 -0
  767. package/src/messages/runtime.tsx +175 -0
  768. package/src/messages.ts +19 -0
  769. package/src/model-mark-paths.ts +53 -0
  770. package/src/model-picker-model.ts +343 -0
  771. package/src/model-policy.ts +301 -79
  772. package/src/native-previews.ts +104 -0
  773. package/src/new-session-draft.ts +22 -0
  774. package/src/notification-text.ts +81 -0
  775. package/src/organization-model.ts +123 -0
  776. package/src/plugin-details.tsx +192 -0
  777. package/src/plugin-discovery.tsx +209 -0
  778. package/src/preview-loading-paint.ts +68 -0
  779. package/src/provider.tsx +105 -21
  780. package/src/queue-presentation-model.ts +475 -0
  781. package/src/realtime/dropdown-menu.tsx +19 -12
  782. package/src/realtime/embedded-new-voice.tsx +1 -0
  783. package/src/realtime/embedded-voice.tsx +3 -0
  784. package/src/realtime/realtime-control.tsx +240 -609
  785. package/src/realtime/session-realtime.ts +582 -0
  786. package/src/sandbox-label-model.ts +56 -0
  787. package/src/scrollbars.ts +3 -0
  788. package/src/secret-reference-label.ts +47 -0
  789. package/src/secrets-ui.tsx +59 -0
  790. package/src/session-agents-model.ts +40 -0
  791. package/src/session-attention-model.ts +62 -0
  792. package/src/session-auth-recommendation.ts +50 -0
  793. package/src/session-capability-policy.ts +200 -0
  794. package/src/session-context.ts +13 -5
  795. package/src/session-feedback-model.ts +101 -0
  796. package/src/session-list-model.ts +437 -0
  797. package/src/session-realtime.ts +18 -0
  798. package/src/session-status-model.ts +99 -0
  799. package/src/session-ui.ts +102 -3
  800. package/src/session.ts +19 -1
  801. package/src/site-snapshot.ts +74 -0
  802. package/src/sites-ui.tsx +350 -0
  803. package/src/sites.ts +3 -0
  804. package/src/skill-discovery.tsx +221 -0
  805. package/src/terminal.ts +26 -0
  806. package/src/testing/session-scenarios.ts +404 -0
  807. package/src/this-computer.ts +62 -0
  808. package/src/timeline/activity-rail.tsx +289 -119
  809. package/src/timeline/agent-identity.tsx +84 -0
  810. package/src/timeline/agent-row.tsx +235 -0
  811. package/src/timeline/allowance-exhausted-row.tsx +90 -0
  812. package/src/timeline/compaction-copy.ts +125 -0
  813. package/src/timeline/fleet-decision-row.tsx +120 -101
  814. package/src/timeline/focus-sequence.ts +44 -0
  815. package/src/timeline/genie-copy.ts +22 -0
  816. package/src/timeline/genie-loading.tsx +158 -0
  817. package/src/timeline/index.ts +37 -2
  818. package/src/timeline/invoked-tool.ts +15 -0
  819. package/src/timeline/knowledge-receipt.tsx +104 -0
  820. package/src/timeline/learning-refusal-copy.ts +67 -0
  821. package/src/timeline/learning-refusal-row.tsx +70 -0
  822. package/src/timeline/message-sender.tsx +71 -0
  823. package/src/timeline/notice-presentation.ts +67 -0
  824. package/src/timeline/parsers.ts +42 -2
  825. package/src/timeline/patch-apply-command.tsx +139 -0
  826. package/src/timeline/platform-activity-presentation.ts +219 -0
  827. package/src/timeline/platform-activity-row.tsx +34 -98
  828. package/src/timeline/presented-image.ts +63 -0
  829. package/src/timeline/projection.ts +1556 -71
  830. package/src/timeline/provider-logo.tsx +53 -0
  831. package/src/timeline/question-nav-model.ts +28 -0
  832. package/src/timeline/registry.ts +11 -1
  833. package/src/timeline/retained-image.ts +102 -0
  834. package/src/timeline/retained-loaders.ts +91 -0
  835. package/src/timeline/rolling-activity.tsx +84 -0
  836. package/src/timeline/screenshot-lightbox.tsx +250 -10
  837. package/src/timeline/session-usage-limit-row.tsx +44 -0
  838. package/src/timeline/shared.tsx +76 -29
  839. package/src/timeline/startup-dispatch-details.tsx +43 -0
  840. package/src/timeline/startup-preference.ts +33 -0
  841. package/src/timeline/startup-timings.tsx +164 -0
  842. package/src/timeline/tool-diff.tsx +3 -1
  843. package/src/timeline/tool-display-name.ts +38 -6
  844. package/src/timeline/tool-presentation.ts +1552 -0
  845. package/src/timeline/tool-renderers.tsx +1019 -1265
  846. package/src/timeline/turn-summary-model.ts +363 -0
  847. package/src/timeline/turn-summary.tsx +288 -367
  848. package/src/timeline/types.ts +191 -7
  849. package/src/timeline/work-presentation.ts +196 -0
  850. package/src/timeline-model.ts +143 -0
  851. package/src/usage/allowance-copy.ts +70 -0
  852. package/src/usage/session-usage-limit.ts +270 -0
  853. package/src/usage/summary.ts +93 -0
  854. package/src/usage.ts +70 -0
  855. package/src/voice-recording-owner.ts +22 -0
  856. package/styles/compiled.css +2010 -651
  857. package/styles/connect.css +290 -0
  858. package/styles/connect.d.ts +1 -0
  859. package/styles/effective-tokens.css +1 -0
  860. package/styles/index.css +286 -9
  861. package/styles/responsive.css +98 -6
  862. package/styles/session-capability.css +44 -0
  863. package/styles/this-computer.css +1042 -0
  864. package/styles/this-computer.d.ts +1 -0
  865. package/styles/tokens.css +132 -64
  866. package/dist/browser-viewer-NTD6UIPR.js +0 -14
  867. package/dist/chunk-24M4YBCL.js.map +0 -1
  868. package/dist/chunk-4MDLEHXL.js.map +0 -1
  869. package/dist/chunk-5M6VTFJ5.js.map +0 -1
  870. package/dist/chunk-5PQJOCX5.js +0 -902
  871. package/dist/chunk-5PQJOCX5.js.map +0 -1
  872. package/dist/chunk-5YK2ZDIG.js.map +0 -1
  873. package/dist/chunk-6J56T3MG.js.map +0 -1
  874. package/dist/chunk-BV5A4OTE.js.map +0 -1
  875. package/dist/chunk-CQG7YUJB.js +0 -10883
  876. package/dist/chunk-CQG7YUJB.js.map +0 -1
  877. package/dist/chunk-H5YGYNXS.js.map +0 -1
  878. package/dist/chunk-HUIKIDM5.js.map +0 -1
  879. package/dist/chunk-HUMIRRYI.js.map +0 -1
  880. package/dist/chunk-ICA6R6TW.js.map +0 -1
  881. package/dist/chunk-JVYQRRC4.js.map +0 -1
  882. package/dist/chunk-KCGXPP5V.js.map +0 -1
  883. package/dist/chunk-KZ73RL76.js.map +0 -1
  884. package/dist/chunk-NEXLLTP4.js.map +0 -1
  885. package/dist/chunk-NLTS7JHI.js.map +0 -1
  886. package/dist/chunk-NOSYBS2D.js.map +0 -1
  887. package/dist/chunk-PAJU5KKL.js.map +0 -1
  888. package/dist/chunk-PEI6RANI.js.map +0 -1
  889. package/dist/chunk-PLYRL5ER.js +0 -164
  890. package/dist/chunk-PLYRL5ER.js.map +0 -1
  891. package/dist/chunk-R4KRSFGA.js +0 -290
  892. package/dist/chunk-R4KRSFGA.js.map +0 -1
  893. package/dist/chunk-UMECRJRV.js +0 -223
  894. package/dist/chunk-UMECRJRV.js.map +0 -1
  895. package/dist/chunk-VRBL3F5E.js +0 -241
  896. package/dist/chunk-VRBL3F5E.js.map +0 -1
  897. package/dist/chunk-YBM6CQRU.js.map +0 -1
  898. package/dist/chunk-Z7WBDB4E.js.map +0 -1
  899. package/dist/computer-viewer-7TEZC6Y2.js +0 -16
  900. package/dist/fleet-decision-row-YZ3ZKWMM.js +0 -352
  901. package/dist/fleet-decision-row-YZ3ZKWMM.js.map +0 -1
  902. package/dist/hooks/use-environments.d.ts +0 -41
  903. package/dist/hooks/use-packs.d.ts +0 -32
  904. package/dist/markdown-table-layout-3Z3AWBY7.js.map +0 -1
  905. package/dist/model-policy-picker-menu-3R336DP2.js +0 -13
  906. package/dist/platform-activity-row-27LKAWZD.js +0 -169
  907. package/dist/platform-activity-row-27LKAWZD.js.map +0 -1
  908. package/dist/queue-surface-implementation-LK3S4BIW.js.map +0 -1
  909. package/dist/timeline-annotation-markers-DRSTLEM6.js.map +0 -1
  910. package/dist/timeline-annotation-selection-IHLUGVND.js.map +0 -1
  911. package/dist/timeline-annotations-dialog-6Q53N5FG.js.map +0 -1
  912. package/src/hooks/use-environments.ts +0 -182
  913. package/src/hooks/use-packs.ts +0 -157
  914. /package/dist/{browser-viewer-NTD6UIPR.js.map → browser-viewer-GEHX3KYE.js.map} +0 -0
  915. /package/dist/{computer-viewer-7TEZC6Y2.js.map → chat-interactive-block-5V3BGLXT.js.map} +0 -0
  916. /package/dist/{model-policy-picker-menu-3R336DP2.js.map → chunk-M357MHH3.js.map} +0 -0
@@ -0,0 +1,3153 @@
1
+ "use client";
2
+ import {
3
+ CodeEditor
4
+ } from "./chunk-MF6WS2XF.js";
5
+ import {
6
+ useThemeType
7
+ } from "./chunk-B27E3V37.js";
8
+ import {
9
+ loadPierreDiffs,
10
+ pierreDiffsRevision,
11
+ subscribePierreDiffs
12
+ } from "./chunk-YSRBFJMQ.js";
13
+ import {
14
+ prefersReducedMotion
15
+ } from "./chunk-OYQQJL3J.js";
16
+ import {
17
+ MENU_BUTTON_CLASS,
18
+ MENU_SEPARATOR_CLASS,
19
+ MENU_SURFACE_CLASS
20
+ } from "./chunk-PMV53IMM.js";
21
+ import {
22
+ usePortalTokenSource,
23
+ usePortalTokenStyle
24
+ } from "./chunk-XEA5BCMA.js";
25
+ import {
26
+ useOpenGeni
27
+ } from "./chunk-ZGFU4LVW.js";
28
+ import {
29
+ sandboxAcceptsLiveIo
30
+ } from "./chunk-QV3DJVRZ.js";
31
+ import {
32
+ cn
33
+ } from "./chunk-TXS65BB2.js";
34
+ import {
35
+ createOpenGeniText,
36
+ useOpenGeniText
37
+ } from "./chunk-VU4QUISJ.js";
38
+
39
+ // src/components/sandbox-files.tsx
40
+ import { FileCode2Icon, FileWarningIcon, LoaderCircleIcon } from "lucide-react";
41
+ import { useCallback as useCallback3, useEffect as useEffect5, useRef as useRef3, useState as useState4 } from "react";
42
+ import { Group, Panel, Separator } from "react-resizable-panels";
43
+
44
+ // src/hooks/use-sandbox-files.ts
45
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
46
+ var englishText = createOpenGeniText();
47
+ var CapturedFileUnavailableError = class extends Error {
48
+ constructor(path, reason, t = englishText) {
49
+ super(
50
+ reason === "too-large" ? t("hooks.useSandboxFiles.pathExceedsTheCapturedPreview", { path }) : reason === "content-missing" ? t("hooks.useSandboxFiles.pathIsNoLongerAvailable", { path }) : t("hooks.useSandboxFiles.pathWasNotChangedIn", { path })
51
+ );
52
+ this.path = path;
53
+ this.reason = reason;
54
+ this.name = "CapturedFileUnavailableError";
55
+ }
56
+ code = "captured_file_unavailable";
57
+ };
58
+ var FileWriteConflictError = class extends Error {
59
+ constructor(path, expectedContent, liveContent, t = englishText) {
60
+ super(t("hooks.useSandboxFiles.pathChangedOnTheMachine", { path }));
61
+ this.path = path;
62
+ this.expectedContent = expectedContent;
63
+ this.liveContent = liveContent;
64
+ this.name = "FileWriteConflictError";
65
+ }
66
+ code = "file_write_conflict";
67
+ };
68
+ function normalizeRoot(root) {
69
+ const slashNormalized = root.replaceAll("\\", "/").replace(/^\.\/+/, "");
70
+ if (slashNormalized === "/") return "/";
71
+ const normalized = slashNormalized.replace(/\/+$/, "");
72
+ return normalized === "." ? "" : normalized;
73
+ }
74
+ function isAbsoluteTreePath(path) {
75
+ return path.startsWith("/") || /^[A-Za-z]:\//u.test(path);
76
+ }
77
+ function joinTreeRoot(root, path) {
78
+ if (!root || isAbsoluteTreePath(path)) return path;
79
+ return root === "/" ? `/${path}` : `${root}/${path}`;
80
+ }
81
+ function qualifyStatusPath(root, path, treeRoot) {
82
+ const normalized = normalizeRoot(root);
83
+ const workspaceRelative = joinTreeRoot(normalized, path);
84
+ return joinTreeRoot(normalizeRoot(treeRoot), workspaceRelative);
85
+ }
86
+ function summarizeStatuses(statuses) {
87
+ const repositories = statuses.filter(({ status }) => status.isRepo);
88
+ return {
89
+ branch: repositories.length === 1 ? repositories[0]?.status.head ?? null : null,
90
+ isRepo: repositories.length > 0,
91
+ repoCount: repositories.length,
92
+ ahead: repositories.reduce((sum, { status }) => sum + status.ahead, 0),
93
+ behind: repositories.reduce((sum, { status }) => sum + status.behind, 0),
94
+ dirtyCount: repositories.reduce((sum, { status }) => sum + status.files.length, 0)
95
+ };
96
+ }
97
+ function parentOf(path) {
98
+ const i = path.lastIndexOf("/");
99
+ return i <= 0 ? "" : path.slice(0, i);
100
+ }
101
+ function parentWithinTree(path, rootPath) {
102
+ const parent = parentOf(path);
103
+ return parent === "" && normalizeRoot(rootPath) === "/" && path.startsWith("/") ? "/" : parent;
104
+ }
105
+ function leafOf(path) {
106
+ const i = path.lastIndexOf("/");
107
+ return i < 0 ? path : path.slice(i + 1);
108
+ }
109
+ function sortNodes(nodes) {
110
+ return [...nodes].sort((a, b) => {
111
+ if (a.kind !== b.kind) return a.kind === "dir" ? -1 : 1;
112
+ return a.name.localeCompare(b.name, void 0, { sensitivity: "base" });
113
+ });
114
+ }
115
+ function fsNodeToTree(node, captureComplete = false) {
116
+ const kind = node.type === "dir" ? "dir" : "file";
117
+ const mappedChildren = node.children && node.children.length > 0 ? node.children.map((child) => fsNodeToTree(child, captureComplete)) : captureComplete && kind === "dir" ? [] : void 0;
118
+ return {
119
+ path: node.path,
120
+ name: node.name,
121
+ kind,
122
+ size: node.sizeBytes,
123
+ ...kind === "dir" ? { children: mappedChildren } : {},
124
+ // A collapsed residue dir from the capture index — carried through so the
125
+ // tree can show an inline "contents on machine" row cold instead of nothing.
126
+ ...kind === "dir" && node.truncated ? { truncated: true } : {}
127
+ };
128
+ }
129
+ var GIT_STATUS_TO_TREE = {
130
+ added: "added",
131
+ modified: "modified",
132
+ deleted: "deleted",
133
+ renamed: "renamed",
134
+ copied: "added",
135
+ untracked: "untracked",
136
+ typechange: "modified"
137
+ };
138
+ function replaceChildren(nodes, targetPath, children) {
139
+ return nodes.map((node) => {
140
+ if (node.path === targetPath) {
141
+ return { ...node, children };
142
+ }
143
+ if (node.kind === "dir" && node.children && targetPath.startsWith(`${node.path}/`)) {
144
+ return {
145
+ ...node,
146
+ children: replaceChildren(node.children, targetPath, children)
147
+ };
148
+ }
149
+ return node;
150
+ });
151
+ }
152
+ function findNodeByPath(nodes, path) {
153
+ for (const node of nodes) {
154
+ if (node.path === path) return node;
155
+ if (node.kind === "dir" && node.children && path.startsWith(`${node.path}/`)) {
156
+ const hit = findNodeByPath(node.children, path);
157
+ if (hit) return hit;
158
+ }
159
+ }
160
+ return void 0;
161
+ }
162
+ var FS_LIST_BATCH_REQUEST_LIMIT = 16;
163
+ function initialDirectoryFrontier(rootPath, repoPaths) {
164
+ const root = normalizeRoot(rootPath);
165
+ const rootParts = root.split("/").filter(Boolean);
166
+ const rootPrefix = root.startsWith("//") ? "//" : root.startsWith("/") ? "/" : "";
167
+ const paths = /* @__PURE__ */ new Set();
168
+ for (const repoPath of repoPaths) {
169
+ const canonicalRepoPath = joinTreeRoot(root, normalizeRoot(repoPath));
170
+ const parts = canonicalRepoPath.split("/").filter(Boolean);
171
+ if (rootParts.some((part, index) => parts[index] !== part)) continue;
172
+ for (let depth = rootParts.length + 1; depth <= parts.length; depth += 1) {
173
+ const path = parts.slice(0, depth).join("/");
174
+ paths.add(`${rootPrefix}${path}`);
175
+ }
176
+ }
177
+ return [...paths].sort((a, b) => a.split("/").length - b.split("/").length || a.localeCompare(b)).slice(0, 8);
178
+ }
179
+ function parentIsLoaded(nodes, parent, rootPath = "") {
180
+ if (parent === normalizeRoot(rootPath)) return true;
181
+ const node = findNodeByPath(nodes, parent);
182
+ return Boolean(node && node.kind === "dir" && node.children !== void 0);
183
+ }
184
+ function insertNode(nodes, parent, child, rootPath = "") {
185
+ if (parent === normalizeRoot(rootPath)) {
186
+ if (nodes.some((n) => n.path === child.path)) return nodes;
187
+ return sortNodes([...nodes, child]);
188
+ }
189
+ return nodes.map((node) => {
190
+ if (node.path === parent) {
191
+ if (node.kind !== "dir" || node.children === void 0) return node;
192
+ if (node.children.some((n) => n.path === child.path)) return node;
193
+ return { ...node, children: sortNodes([...node.children, child]) };
194
+ }
195
+ if (node.kind === "dir" && node.children && parent.startsWith(`${node.path}/`)) {
196
+ return { ...node, children: insertNode(node.children, parent, child, rootPath) };
197
+ }
198
+ return node;
199
+ });
200
+ }
201
+ function removeNode(nodes, path, rootPath = "") {
202
+ const parent = parentWithinTree(path, rootPath);
203
+ if (parent === normalizeRoot(rootPath)) {
204
+ if (!nodes.some((n) => n.path === path)) return nodes;
205
+ return nodes.filter((n) => n.path !== path);
206
+ }
207
+ return nodes.map((node) => {
208
+ if (node.path === parent) {
209
+ if (node.kind !== "dir" || node.children === void 0) return node;
210
+ return {
211
+ ...node,
212
+ children: node.children.filter((n) => n.path !== path)
213
+ };
214
+ }
215
+ if (node.kind === "dir" && node.children && parent.startsWith(`${node.path}/`)) {
216
+ return { ...node, children: removeNode(node.children, path, rootPath) };
217
+ }
218
+ return node;
219
+ });
220
+ }
221
+ function sameNodeShallow(a, b) {
222
+ return a.path === b.path && a.kind === b.kind && a.name === b.name && (a.size ?? null) === (b.size ?? null) && (a.status ?? void 0) === (b.status ?? void 0) && (a.truncated ?? false) === (b.truncated ?? false);
223
+ }
224
+ function mergeChildren(current, listed) {
225
+ const byPath = new Map(current.map((n) => [n.path, n]));
226
+ const merged = listed.map((next) => {
227
+ const existing = byPath.get(next.path);
228
+ if (!existing) return next;
229
+ if (existing.kind === "dir" && next.kind === "dir" && existing.children !== void 0) {
230
+ const candidate = { ...next, children: existing.children };
231
+ return sameNodeShallow(existing, candidate) ? existing : candidate;
232
+ }
233
+ if (existing.children === next.children && sameNodeShallow(existing, next)) {
234
+ return existing;
235
+ }
236
+ return next;
237
+ });
238
+ return sortNodes(merged);
239
+ }
240
+ function mergeRootChildren(nodes, listed) {
241
+ return mergeChildren(nodes, listed);
242
+ }
243
+ function repathNode(node, fromPrefix, toPrefix) {
244
+ const newPath = toPrefix + node.path.slice(fromPrefix.length);
245
+ const next = { ...node, path: newPath, name: leafOf(newPath) };
246
+ if (node.children) next.children = node.children.map((c) => repathNode(c, fromPrefix, toPrefix));
247
+ return next;
248
+ }
249
+ function decodeBase64Bytes(value) {
250
+ const binary = atob(value);
251
+ const bytes = new Uint8Array(binary.length);
252
+ for (let index = 0; index < binary.length; index += 1) {
253
+ bytes[index] = binary.charCodeAt(index);
254
+ }
255
+ return bytes;
256
+ }
257
+ function decodeBase64Text(value) {
258
+ return new TextDecoder().decode(decodeBase64Bytes(value));
259
+ }
260
+ function encodeBase64Bytes(bytes) {
261
+ let binary = "";
262
+ const chunkSize = 32768;
263
+ for (let offset = 0; offset < bytes.length; offset += chunkSize) {
264
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + chunkSize));
265
+ }
266
+ return btoa(binary);
267
+ }
268
+ async function assertCapturedHash(bytes, expected) {
269
+ if (!expected) throw new Error("Captured file is missing its integrity hash.");
270
+ if (!globalThis.crypto?.subtle) {
271
+ throw new Error("Captured file integrity verification is unavailable in this browser.");
272
+ }
273
+ const buffer = new ArrayBuffer(bytes.byteLength);
274
+ new Uint8Array(buffer).set(bytes);
275
+ const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", buffer));
276
+ const actual = [...digest].map((byte) => byte.toString(16).padStart(2, "0")).join("");
277
+ if (actual !== expected) throw new Error("Captured file content failed its integrity check.");
278
+ }
279
+ function useSandboxFiles(sessionId, options = {}) {
280
+ const t = useOpenGeniText();
281
+ const { client, workspaceId } = useOpenGeni(options);
282
+ const enabled = (options.enabled ?? true) && Boolean(sessionId);
283
+ const active = options.active ?? true;
284
+ const rootPath = options.rootPath ?? "";
285
+ const routeEpoch = options.route?.epoch ?? null;
286
+ const routeRoot = options.route?.root ?? null;
287
+ const route = useMemo(
288
+ () => routeEpoch !== null && routeRoot !== null ? { epoch: routeEpoch, root: routeRoot } : void 0,
289
+ [routeEpoch, routeRoot]
290
+ );
291
+ const repoPathsKey = [
292
+ ...new Set((options.repoPaths?.length ? options.repoPaths : [rootPath]).map(normalizeRoot))
293
+ ].join("\0");
294
+ const repoPaths = useMemo(() => repoPathsKey.split("\0"), [repoPathsKey]);
295
+ const capture = options.capture ?? null;
296
+ const isLive = sandboxAcceptsLiveIo(options.liveness);
297
+ const acceptsEventReads = options.liveness === void 0 || isLive;
298
+ const acceptsEventReadsRef = useRef(acceptsEventReads);
299
+ acceptsEventReadsRef.current = acceptsEventReads;
300
+ const hasLiveIoFence = options.liveness !== void 0;
301
+ const identityKey = `${workspaceId}\0${sessionId ?? ""}\0${rootPath}\0${repoPathsKey}\0${routeEpoch ?? ""}\0${routeRoot ?? ""}`;
302
+ const [tree, setTree] = useState([]);
303
+ const treeRef = useRef([]);
304
+ const [loading, setLoading] = useState(false);
305
+ const [expandingPaths, setExpandingPaths] = useState(/* @__PURE__ */ new Set());
306
+ const [error, setError] = useState(null);
307
+ const [gitSummary, setGitSummary] = useState(null);
308
+ const [gitLoading, setGitLoading] = useState(false);
309
+ const [contentRevision, setContentRevision] = useState(0);
310
+ const [stateIdentity, setStateIdentity] = useState(identityKey);
311
+ const [source, setSource] = useState(null);
312
+ const sourceRef = useRef(null);
313
+ const statusRef = useRef(/* @__PURE__ */ new Map());
314
+ const refreshGenerationRef = useRef(0);
315
+ const refreshAbortRef = useRef(null);
316
+ const identityAbortRef = useRef(new AbortController());
317
+ const eventReadAbortRef = useRef(new AbortController());
318
+ const identityGenerationRef = useRef(0);
319
+ const lastSeqRef = useRef(0);
320
+ const pendingParentsRef = useRef(/* @__PURE__ */ new Set());
321
+ const pendingGitRef = useRef(false);
322
+ const eventReconcileInFlightRef = useRef(null);
323
+ const eventReconcilePendingRef = useRef(false);
324
+ const debounceRef = useRef(null);
325
+ const ownRevisionsRef = useRef(/* @__PURE__ */ new Set());
326
+ const onMutationError = options.onMutationError;
327
+ treeRef.current = tree;
328
+ const applyStatus = useCallback((nodes) => {
329
+ const overlay = statusRef.current;
330
+ const walk = (list) => {
331
+ let changed = false;
332
+ const out = list.map((node) => {
333
+ const nextChildren = node.children ? walk(node.children) : node.children;
334
+ const wantStatus = node.kind === "file" ? overlay.get(node.path) : void 0;
335
+ const childrenChanged = nextChildren !== node.children;
336
+ const statusChanged = (node.status ?? void 0) !== (wantStatus ?? void 0);
337
+ if (!childrenChanged && !statusChanged) return node;
338
+ changed = true;
339
+ const next = {
340
+ ...node,
341
+ ...node.children ? { children: nextChildren } : {}
342
+ };
343
+ if (wantStatus) next.status = wantStatus;
344
+ else delete next.status;
345
+ return next;
346
+ });
347
+ return changed ? out : list;
348
+ };
349
+ return walk(nodes);
350
+ }, []);
351
+ const refresh = useCallback(async () => {
352
+ if (!sessionId) return;
353
+ refreshAbortRef.current?.abort();
354
+ const refreshAbort = new AbortController();
355
+ refreshAbortRef.current = refreshAbort;
356
+ const generation = refreshGenerationRef.current += 1;
357
+ setLoading(true);
358
+ setGitLoading(true);
359
+ setError(null);
360
+ try {
361
+ const frontierPaths = initialDirectoryFrontier(rootPath, repoPaths);
362
+ const listRequests = [rootPath, ...frontierPaths].map((path) => ({
363
+ path,
364
+ depth: 1,
365
+ ...route ? { route } : {}
366
+ }));
367
+ const listedBatch = await client.fsListBatch(
368
+ workspaceId,
369
+ sessionId,
370
+ { requests: listRequests },
371
+ { signal: refreshAbort.signal }
372
+ );
373
+ if (refreshGenerationRef.current !== generation) return;
374
+ const listed = listedBatch.results[0];
375
+ if (!listed) throw new Error("Workspace list batch did not return the root result.");
376
+ const children = (listed.root.children ?? []).map((node) => fsNodeToTree(node));
377
+ setTree((prev) => {
378
+ let hydrated = prev.length === 0 ? children : mergeRootChildren(prev, children);
379
+ for (const [index, path] of frontierPaths.entries()) {
380
+ const prefetched = listedBatch.results[index + 1];
381
+ if (!prefetched) continue;
382
+ hydrated = replaceChildren(
383
+ hydrated,
384
+ path,
385
+ (prefetched.root.children ?? []).map((node) => fsNodeToTree(node))
386
+ );
387
+ }
388
+ return applyStatus(hydrated);
389
+ });
390
+ sourceRef.current = "live";
391
+ setSource("live");
392
+ setLoading(false);
393
+ const statuses = repoPaths.length > 0 ? await client.gitReadBatch(
394
+ workspaceId,
395
+ sessionId,
396
+ {
397
+ requests: repoPaths.map((root) => ({
398
+ status: { path: root }
399
+ }))
400
+ },
401
+ { signal: refreshAbort.signal }
402
+ ).then(
403
+ (batch) => batch.results.map((result, index) => ({
404
+ root: repoPaths[index] ?? "",
405
+ status: result.status
406
+ }))
407
+ ).catch(() => null) : [];
408
+ if (refreshGenerationRef.current !== generation) return;
409
+ if (statuses) {
410
+ const overlay = /* @__PURE__ */ new Map();
411
+ for (const { root, status } of statuses) {
412
+ for (const file of status.files) {
413
+ const code = file.worktree ?? file.index;
414
+ const mapped = code ? GIT_STATUS_TO_TREE[code] : void 0;
415
+ if (mapped) overlay.set(qualifyStatusPath(root, file.path, rootPath), mapped);
416
+ }
417
+ }
418
+ statusRef.current = overlay;
419
+ setGitSummary(summarizeStatuses(statuses));
420
+ } else {
421
+ statusRef.current = /* @__PURE__ */ new Map();
422
+ setGitSummary(null);
423
+ }
424
+ setGitLoading(false);
425
+ setTree((prev) => applyStatus(prev));
426
+ } catch (cause) {
427
+ if (refreshGenerationRef.current !== generation) return;
428
+ setError(cause instanceof Error ? cause : new Error(String(cause)));
429
+ } finally {
430
+ if (refreshGenerationRef.current === generation) setLoading(false);
431
+ if (refreshGenerationRef.current === generation) setGitLoading(false);
432
+ if (refreshAbortRef.current === refreshAbort) refreshAbortRef.current = null;
433
+ }
434
+ }, [client, workspaceId, sessionId, rootPath, repoPaths, route, applyStatus]);
435
+ const seedFromCapture = useCallback(
436
+ (manifest) => {
437
+ const overlay = /* @__PURE__ */ new Map();
438
+ for (const file of manifest.files) {
439
+ if (file.deleted) continue;
440
+ const mapped = GIT_STATUS_TO_TREE[file.status];
441
+ if (mapped) overlay.set(file.path, mapped);
442
+ }
443
+ statusRef.current = overlay;
444
+ const children = (manifest.treeIndex.children ?? []).map((node) => fsNodeToTree(node, true));
445
+ setTree(
446
+ (prev) => applyStatus(prev.length === 0 ? children : mergeRootChildren(prev, children))
447
+ );
448
+ sourceRef.current = "capture";
449
+ setSource("capture");
450
+ setGitSummary({
451
+ branch: manifest.repos.length === 1 ? manifest.repos[0]?.head ?? null : null,
452
+ isRepo: manifest.repos.length > 0,
453
+ repoCount: manifest.repos.length,
454
+ ahead: manifest.repos.reduce((sum, repo) => sum + repo.ahead, 0),
455
+ behind: manifest.repos.reduce((sum, repo) => sum + repo.behind, 0),
456
+ dirtyCount: manifest.files.length
457
+ });
458
+ setGitLoading(false);
459
+ setError(null);
460
+ },
461
+ [applyStatus]
462
+ );
463
+ const expand = useCallback(
464
+ async (path) => {
465
+ if (!sessionId) return;
466
+ if (source === "capture" && capture) return;
467
+ const identityGeneration = identityGenerationRef.current;
468
+ const identitySignal = identityAbortRef.current.signal;
469
+ setExpandingPaths((prev) => {
470
+ const next = new Set(prev);
471
+ next.add(path);
472
+ return next;
473
+ });
474
+ try {
475
+ const listed = await client.fsList(
476
+ workspaceId,
477
+ sessionId,
478
+ { path, depth: 1, ...route ? { route } : {} },
479
+ { signal: identitySignal }
480
+ );
481
+ if (identityGenerationRef.current !== identityGeneration) return;
482
+ const children = (listed.root.children ?? []).map((node) => fsNodeToTree(node));
483
+ setTree((prev) => applyStatus(replaceChildren(prev, path, children)));
484
+ } catch (cause) {
485
+ if (identityGenerationRef.current !== identityGeneration) return;
486
+ setError(cause instanceof Error ? cause : new Error(String(cause)));
487
+ } finally {
488
+ if (identityGenerationRef.current === identityGeneration) {
489
+ setExpandingPaths((prev) => {
490
+ if (!prev.has(path)) return prev;
491
+ const next = new Set(prev);
492
+ next.delete(path);
493
+ return next;
494
+ });
495
+ }
496
+ }
497
+ },
498
+ [client, workspaceId, sessionId, capture, source, route, applyStatus]
499
+ );
500
+ const readFile = useCallback(
501
+ async (path, requestOptions = {}) => {
502
+ if (!sessionId) throw new Error("no session");
503
+ const identitySignal = identityAbortRef.current.signal;
504
+ const signal = requestOptions.signal ? AbortSignal.any([identitySignal, requestOptions.signal]) : identitySignal;
505
+ const captured = capture?.files.find((file) => file.path === path && !file.deleted);
506
+ if (source === "capture" && capture) {
507
+ if (!captured) {
508
+ throw new CapturedFileUnavailableError(path, "not-captured", t);
509
+ }
510
+ for (let attempt = 0; attempt < 2; attempt += 1) {
511
+ const result = await client.getWorkspaceCaptureFile(
512
+ workspaceId,
513
+ sessionId,
514
+ path,
515
+ capture.revision,
516
+ { signal }
517
+ );
518
+ if (result.path !== path || result.revision !== capture.revision) {
519
+ throw new Error(
520
+ "Captured file identity did not match the requested workspace revision."
521
+ );
522
+ }
523
+ if (result.hash !== captured.hash || result.sizeBytes !== captured.sizeBytes || result.isBinary !== captured.isBinary || result.tooLarge !== captured.tooLarge) {
524
+ throw new Error("Captured file metadata did not match its manifest.");
525
+ }
526
+ if (result.tooLarge) {
527
+ throw new CapturedFileUnavailableError(path, "too-large", t);
528
+ }
529
+ let bytes;
530
+ let encoding;
531
+ let content;
532
+ if (result.content !== null && result.encoding !== null) {
533
+ encoding = result.encoding;
534
+ content = result.content;
535
+ bytes = encoding === "base64" ? decodeBase64Bytes(content) : new TextEncoder().encode(content);
536
+ } else if (result.contentUrl) {
537
+ const response = await fetch(result.contentUrl.url, {
538
+ credentials: "omit",
539
+ cache: "no-store",
540
+ referrerPolicy: "no-referrer",
541
+ signal: AbortSignal.any([signal, AbortSignal.timeout(3e4)])
542
+ }).catch(() => null);
543
+ if (!response?.ok) {
544
+ if (attempt === 0 && (response === null || response.status === 401 || response.status === 403)) {
545
+ continue;
546
+ }
547
+ throw new Error("Captured file download failed.");
548
+ }
549
+ bytes = new Uint8Array(await response.arrayBuffer());
550
+ encoding = result.isBinary ? "base64" : "utf8";
551
+ content = result.isBinary ? encodeBase64Bytes(bytes) : new TextDecoder().decode(bytes);
552
+ } else {
553
+ throw new CapturedFileUnavailableError(path, "content-missing", t);
554
+ }
555
+ if (bytes.byteLength !== result.sizeBytes) {
556
+ throw new Error("Captured file size did not match its manifest.");
557
+ }
558
+ await assertCapturedHash(bytes, result.hash);
559
+ return {
560
+ path,
561
+ encoding,
562
+ content,
563
+ sizeBytes: result.sizeBytes,
564
+ truncated: false,
565
+ isBinary: result.isBinary,
566
+ revision: result.revision
567
+ };
568
+ }
569
+ throw new Error("Captured file download failed after refreshing its URL.");
570
+ }
571
+ return await client.fsRead(
572
+ workspaceId,
573
+ sessionId,
574
+ { path, ...route ? { route } : {} },
575
+ { signal }
576
+ );
577
+ },
578
+ [client, workspaceId, sessionId, capture, source, route, t]
579
+ );
580
+ const reconcilePath = useCallback(
581
+ async (path, requestSignal) => {
582
+ if (!sessionId) return;
583
+ const identityGeneration = identityGenerationRef.current;
584
+ const identitySignal = identityAbortRef.current.signal;
585
+ const signal = requestSignal ? AbortSignal.any([identitySignal, requestSignal]) : identitySignal;
586
+ if (!parentIsLoaded(treeRef.current, path, rootPath)) return;
587
+ try {
588
+ const listed = await client.fsList(
589
+ workspaceId,
590
+ sessionId,
591
+ { path, depth: 1, ...route ? { route } : {} },
592
+ { signal }
593
+ );
594
+ if (identityGenerationRef.current !== identityGeneration) return;
595
+ const children = (listed.root.children ?? []).map((node) => fsNodeToTree(node));
596
+ if (path === normalizeRoot(rootPath)) {
597
+ setTree((prev) => applyStatus(mergeRootChildren(prev, children)));
598
+ } else
599
+ setTree((prev) => {
600
+ const existing = findNodeByPath(prev, path);
601
+ const merged = existing?.children ? mergeChildren(existing.children, children) : children;
602
+ return applyStatus(replaceChildren(prev, path, merged));
603
+ });
604
+ } catch {
605
+ }
606
+ },
607
+ [client, workspaceId, sessionId, rootPath, route, applyStatus]
608
+ );
609
+ const reconcilePaths = useCallback(
610
+ async (requestedPaths, requestSignal) => {
611
+ if (!sessionId) return;
612
+ const identityGeneration = identityGenerationRef.current;
613
+ const identitySignal = identityAbortRef.current.signal;
614
+ const signal = requestSignal ? AbortSignal.any([identitySignal, requestSignal]) : identitySignal;
615
+ const paths = [...new Set(requestedPaths)].filter(
616
+ (path) => parentIsLoaded(treeRef.current, path, rootPath)
617
+ );
618
+ for (let offset = 0; offset < paths.length; offset += FS_LIST_BATCH_REQUEST_LIMIT) {
619
+ const chunk = paths.slice(offset, offset + FS_LIST_BATCH_REQUEST_LIMIT);
620
+ try {
621
+ const listed = await client.fsListBatch(
622
+ workspaceId,
623
+ sessionId,
624
+ {
625
+ requests: chunk.map((path) => ({
626
+ path,
627
+ depth: 1,
628
+ ...route ? { route } : {}
629
+ }))
630
+ },
631
+ { signal }
632
+ );
633
+ if (identityGenerationRef.current !== identityGeneration) return;
634
+ setTree((previous) => {
635
+ let next = previous;
636
+ for (const [index, path] of chunk.entries()) {
637
+ const result = listed.results[index];
638
+ if (!result) continue;
639
+ const children = (result.root.children ?? []).map((node) => fsNodeToTree(node));
640
+ if (path === normalizeRoot(rootPath)) {
641
+ next = mergeRootChildren(next, children);
642
+ } else {
643
+ const existing = findNodeByPath(next, path);
644
+ const merged = existing?.children ? mergeChildren(existing.children, children) : children;
645
+ next = replaceChildren(next, path, merged);
646
+ }
647
+ }
648
+ return applyStatus(next);
649
+ });
650
+ } catch {
651
+ }
652
+ }
653
+ },
654
+ [client, workspaceId, sessionId, rootPath, route, applyStatus]
655
+ );
656
+ const runOptimistic = useCallback(
657
+ async (opName, apply, op, reconcileParents) => {
658
+ const identityGeneration = identityGenerationRef.current;
659
+ const snapshot = treeRef.current;
660
+ setError(null);
661
+ setTree(applyStatus(apply(snapshot)));
662
+ try {
663
+ const res = await op();
664
+ if (identityGenerationRef.current !== identityGeneration) return res;
665
+ if (res && typeof res === "object" && "revision" in res) {
666
+ const rev = res.revision;
667
+ if (typeof rev === "number") ownRevisionsRef.current.add(rev);
668
+ }
669
+ for (const parent of reconcileParents) {
670
+ if (identityGenerationRef.current !== identityGeneration) return res;
671
+ await reconcilePath(parent);
672
+ }
673
+ return res;
674
+ } catch (cause) {
675
+ const err = cause instanceof Error ? cause : new Error(String(cause));
676
+ if (identityGenerationRef.current !== identityGeneration) throw err;
677
+ setTree(applyStatus(snapshot));
678
+ if (err instanceof FileWriteConflictError) throw err;
679
+ setError(err);
680
+ onMutationError?.(err, opName);
681
+ throw err;
682
+ }
683
+ },
684
+ [applyStatus, reconcilePath, onMutationError]
685
+ );
686
+ const writeFile = useCallback(
687
+ async (path, content, writeOptions = {}) => {
688
+ if (!sessionId) throw new Error("no session");
689
+ const identityGeneration = identityGenerationRef.current;
690
+ const identitySignal = identityAbortRef.current.signal;
691
+ const parent = parentWithinTree(path, rootPath);
692
+ const exists = Boolean(findNodeByPath(tree, path));
693
+ const node = {
694
+ path,
695
+ name: leafOf(path),
696
+ kind: "file",
697
+ size: content.length
698
+ };
699
+ return await runOptimistic(
700
+ "write",
701
+ (nodes) => exists ? nodes : insertNode(nodes, parent, node, rootPath),
702
+ async () => {
703
+ if (!writeOptions.force && writeOptions.expectedContent !== void 0) {
704
+ const live = await client.fsRead(
705
+ workspaceId,
706
+ sessionId,
707
+ { path, ...route ? { route } : {} },
708
+ { signal: identitySignal }
709
+ );
710
+ if (identityGenerationRef.current !== identityGeneration) {
711
+ throw new Error(t("hooks.useSandboxFiles.fileSaveCancelledBecauseThe"));
712
+ }
713
+ const liveContent = live.encoding === "base64" ? decodeBase64Text(live.content) : live.content;
714
+ if (live.truncated || live.isBinary || liveContent !== writeOptions.expectedContent) {
715
+ throw new FileWriteConflictError(path, writeOptions.expectedContent, liveContent, t);
716
+ }
717
+ }
718
+ if (identityGenerationRef.current !== identityGeneration) {
719
+ throw new Error(t("hooks.useSandboxFiles.fileSaveCancelledBecauseThe"));
720
+ }
721
+ return await client.fsWrite(workspaceId, sessionId, {
722
+ path,
723
+ content,
724
+ overwrite: true,
725
+ ...route ? { route } : {}
726
+ });
727
+ },
728
+ exists ? [] : [parent]
729
+ );
730
+ },
731
+ [client, workspaceId, sessionId, tree, rootPath, route, runOptimistic, t]
732
+ );
733
+ const createFile = useCallback(
734
+ async (path) => {
735
+ if (!sessionId) throw new Error("no session");
736
+ const parent = parentWithinTree(path, rootPath);
737
+ const node = {
738
+ path,
739
+ name: leafOf(path),
740
+ kind: "file",
741
+ size: 0
742
+ };
743
+ await runOptimistic(
744
+ t("hooks.useSandboxFiles.createFile"),
745
+ (nodes) => insertNode(nodes, parent, node, rootPath),
746
+ () => client.fsWrite(workspaceId, sessionId, {
747
+ path,
748
+ content: "",
749
+ overwrite: false,
750
+ ...route ? { route } : {}
751
+ }),
752
+ [parent]
753
+ );
754
+ },
755
+ [client, workspaceId, sessionId, rootPath, route, runOptimistic, t]
756
+ );
757
+ const createDir = useCallback(
758
+ async (path) => {
759
+ if (!sessionId) throw new Error("no session");
760
+ const parent = parentWithinTree(path, rootPath);
761
+ const node = {
762
+ path,
763
+ name: leafOf(path),
764
+ kind: "dir",
765
+ children: []
766
+ };
767
+ await runOptimistic(
768
+ t("hooks.useSandboxFiles.createFolder"),
769
+ (nodes) => insertNode(nodes, parent, node, rootPath),
770
+ () => client.fsMkdir(workspaceId, sessionId, {
771
+ path,
772
+ recursive: true,
773
+ ...route ? { route } : {}
774
+ }),
775
+ [parent]
776
+ );
777
+ },
778
+ [client, workspaceId, sessionId, rootPath, route, runOptimistic, t]
779
+ );
780
+ const deleteEntry = useCallback(
781
+ async (path, recursive = false) => {
782
+ if (!sessionId) throw new Error("no session");
783
+ await runOptimistic(
784
+ "delete",
785
+ (nodes) => removeNode(nodes, path, rootPath),
786
+ () => client.fsDelete(workspaceId, sessionId, {
787
+ path,
788
+ recursive,
789
+ ...route ? { route } : {}
790
+ }),
791
+ [parentWithinTree(path, rootPath)]
792
+ );
793
+ },
794
+ [client, workspaceId, sessionId, rootPath, route, runOptimistic]
795
+ );
796
+ const moveEntry = useCallback(
797
+ async (path, newPath, opts) => {
798
+ if (!sessionId) throw new Error("no session");
799
+ const from = parentWithinTree(path, rootPath);
800
+ const to = parentWithinTree(newPath, rootPath);
801
+ await runOptimistic(
802
+ "move",
803
+ (nodes) => {
804
+ const moving = findNodeByPath(nodes, path);
805
+ if (!moving) return nodes;
806
+ const moved = repathNode(moving, path, newPath);
807
+ return insertNode(removeNode(nodes, path, rootPath), to, moved, rootPath);
808
+ },
809
+ () => client.fsMove(workspaceId, sessionId, {
810
+ path,
811
+ newPath,
812
+ overwrite: opts?.overwrite ?? false,
813
+ ...route ? { route } : {}
814
+ }),
815
+ to === from ? [from] : [from, to]
816
+ );
817
+ },
818
+ [client, workspaceId, sessionId, rootPath, route, runOptimistic]
819
+ );
820
+ const captureRef = useRef(capture);
821
+ captureRef.current = capture;
822
+ const captureRevision = capture?.revision ?? null;
823
+ const previousIdentityRef = useRef(identityKey);
824
+ useEffect(() => {
825
+ refreshAbortRef.current?.abort();
826
+ refreshAbortRef.current = null;
827
+ refreshGenerationRef.current += 1;
828
+ eventReadAbortRef.current.abort();
829
+ eventReadAbortRef.current = new AbortController();
830
+ const identityChanged = previousIdentityRef.current !== identityKey;
831
+ previousIdentityRef.current = identityKey;
832
+ if (identityChanged || !enabled) {
833
+ if (identityChanged) eventReconcileInFlightRef.current = null;
834
+ identityAbortRef.current.abort();
835
+ identityAbortRef.current = new AbortController();
836
+ identityGenerationRef.current += 1;
837
+ lastSeqRef.current = 0;
838
+ pendingParentsRef.current = /* @__PURE__ */ new Set();
839
+ pendingGitRef.current = false;
840
+ eventReconcilePendingRef.current = false;
841
+ if (debounceRef.current) {
842
+ clearTimeout(debounceRef.current);
843
+ debounceRef.current = null;
844
+ }
845
+ ownRevisionsRef.current = /* @__PURE__ */ new Set();
846
+ statusRef.current = /* @__PURE__ */ new Map();
847
+ treeRef.current = [];
848
+ setTree([]);
849
+ setStateIdentity(identityKey);
850
+ setExpandingPaths(/* @__PURE__ */ new Set());
851
+ sourceRef.current = null;
852
+ setSource(null);
853
+ setLoading(false);
854
+ setError(null);
855
+ setGitSummary(null);
856
+ setGitLoading(false);
857
+ setContentRevision(0);
858
+ }
859
+ if (!enabled) {
860
+ return;
861
+ }
862
+ const currentCapture = captureRevision !== null ? captureRef.current : null;
863
+ if (currentCapture && (identityChanged || !isLive || sourceRef.current !== "live")) {
864
+ seedFromCapture(currentCapture);
865
+ }
866
+ if (!active) {
867
+ if (!active) {
868
+ setLoading(false);
869
+ setGitLoading(false);
870
+ }
871
+ return;
872
+ }
873
+ if (isLive || !hasLiveIoFence && !currentCapture) {
874
+ void refresh();
875
+ }
876
+ return () => {
877
+ refreshAbortRef.current?.abort();
878
+ refreshAbortRef.current = null;
879
+ refreshGenerationRef.current += 1;
880
+ eventReadAbortRef.current.abort();
881
+ eventReconcilePendingRef.current = false;
882
+ };
883
+ }, [
884
+ enabled,
885
+ active,
886
+ isLive,
887
+ hasLiveIoFence,
888
+ captureRevision,
889
+ identityKey,
890
+ refresh,
891
+ seedFromCapture
892
+ ]);
893
+ const refreshGitOverlay = useCallback(
894
+ async (requestSignal) => {
895
+ if (!sessionId) return;
896
+ const identityGeneration = identityGenerationRef.current;
897
+ const identitySignal = identityAbortRef.current.signal;
898
+ const signal = requestSignal ? AbortSignal.any([identitySignal, requestSignal]) : identitySignal;
899
+ setGitLoading(true);
900
+ try {
901
+ const batch = await client.gitReadBatch(
902
+ workspaceId,
903
+ sessionId,
904
+ { requests: repoPaths.map((root) => ({ status: { path: root } })) },
905
+ { signal }
906
+ );
907
+ const statuses = batch.results.map((result, index) => ({
908
+ root: repoPaths[index] ?? "",
909
+ status: result.status
910
+ }));
911
+ if (identityGenerationRef.current !== identityGeneration) return;
912
+ const overlay = /* @__PURE__ */ new Map();
913
+ for (const { root, status } of statuses) {
914
+ for (const file of status.files) {
915
+ const code = file.worktree ?? file.index;
916
+ const mapped = code ? GIT_STATUS_TO_TREE[code] : void 0;
917
+ if (mapped) overlay.set(qualifyStatusPath(root, file.path, rootPath), mapped);
918
+ }
919
+ }
920
+ statusRef.current = overlay;
921
+ setGitSummary(summarizeStatuses(statuses));
922
+ setTree((prev) => applyStatus(prev));
923
+ } catch {
924
+ } finally {
925
+ if (identityGenerationRef.current === identityGeneration) setGitLoading(false);
926
+ }
927
+ },
928
+ [client, workspaceId, sessionId, repoPaths, rootPath, applyStatus]
929
+ );
930
+ const performEventReconcile = useCallback(async () => {
931
+ const parents = pendingParentsRef.current;
932
+ pendingParentsRef.current = /* @__PURE__ */ new Set();
933
+ const wantGit = pendingGitRef.current;
934
+ pendingGitRef.current = false;
935
+ const signal = eventReadAbortRef.current.signal;
936
+ const paths = [...parents];
937
+ await reconcilePaths(paths, signal);
938
+ if (wantGit) await refreshGitOverlay(signal);
939
+ }, [reconcilePaths, refreshGitOverlay]);
940
+ const performEventReconcileRef = useRef(performEventReconcile);
941
+ performEventReconcileRef.current = performEventReconcile;
942
+ const reconcilePendingEvents = useCallback(async () => {
943
+ eventReconcilePendingRef.current = true;
944
+ const existing = eventReconcileInFlightRef.current;
945
+ if (existing) return await existing;
946
+ const identityGeneration = identityGenerationRef.current;
947
+ const run = (async () => {
948
+ while (eventReconcilePendingRef.current && identityGenerationRef.current === identityGeneration) {
949
+ eventReconcilePendingRef.current = false;
950
+ await performEventReconcileRef.current();
951
+ }
952
+ })();
953
+ eventReconcileInFlightRef.current = run;
954
+ try {
955
+ await run;
956
+ } finally {
957
+ if (eventReconcileInFlightRef.current === run) eventReconcileInFlightRef.current = null;
958
+ }
959
+ }, []);
960
+ const events = options.events;
961
+ useEffect(() => {
962
+ if (!enabled || !events) return;
963
+ if (!active || !acceptsEventReads) {
964
+ for (const event of events) {
965
+ if (event.sequence > lastSeqRef.current) lastSeqRef.current = event.sequence;
966
+ }
967
+ if (debounceRef.current) {
968
+ clearTimeout(debounceRef.current);
969
+ debounceRef.current = null;
970
+ }
971
+ pendingParentsRef.current = /* @__PURE__ */ new Set();
972
+ pendingGitRef.current = false;
973
+ eventReconcilePendingRef.current = false;
974
+ return;
975
+ }
976
+ let sawNew = false;
977
+ let contentChanged = false;
978
+ for (const event of events) {
979
+ if (event.sequence <= lastSeqRef.current) continue;
980
+ if (event.type === "fs.changed") {
981
+ sawNew = true;
982
+ const payload = event.payload;
983
+ if (!payload || typeof payload !== "object") continue;
984
+ if (payload.source === "write") continue;
985
+ if (typeof payload.revision === "number" && ownRevisionsRef.current.has(payload.revision))
986
+ continue;
987
+ contentChanged = true;
988
+ for (const change of payload.changes ?? []) {
989
+ pendingParentsRef.current.add(parentWithinTree(change.path, rootPath));
990
+ if (change.oldPath) {
991
+ pendingParentsRef.current.add(parentWithinTree(change.oldPath, rootPath));
992
+ }
993
+ }
994
+ } else if (event.type === "git.changed") {
995
+ sawNew = true;
996
+ const payload = event.payload;
997
+ if (payload && typeof payload === "object" && typeof payload.revision === "number" && ownRevisionsRef.current.has(payload.revision))
998
+ continue;
999
+ pendingGitRef.current = true;
1000
+ }
1001
+ }
1002
+ for (const event of events)
1003
+ if (event.sequence > lastSeqRef.current) lastSeqRef.current = event.sequence;
1004
+ if (!sawNew) return;
1005
+ if (contentChanged) setContentRevision((revision) => revision + 1);
1006
+ if (debounceRef.current) clearTimeout(debounceRef.current);
1007
+ const identityGeneration = identityGenerationRef.current;
1008
+ debounceRef.current = setTimeout(() => {
1009
+ debounceRef.current = null;
1010
+ if (identityGenerationRef.current !== identityGeneration) return;
1011
+ if (!acceptsEventReadsRef.current) {
1012
+ pendingParentsRef.current = /* @__PURE__ */ new Set();
1013
+ pendingGitRef.current = false;
1014
+ return;
1015
+ }
1016
+ void reconcilePendingEvents();
1017
+ }, 150);
1018
+ }, [enabled, active, acceptsEventReads, events, rootPath, reconcilePendingEvents]);
1019
+ useEffect(() => {
1020
+ if (active && acceptsEventReads) return;
1021
+ if (debounceRef.current) {
1022
+ clearTimeout(debounceRef.current);
1023
+ debounceRef.current = null;
1024
+ }
1025
+ pendingParentsRef.current = /* @__PURE__ */ new Set();
1026
+ pendingGitRef.current = false;
1027
+ eventReconcilePendingRef.current = false;
1028
+ }, [active, acceptsEventReads]);
1029
+ useEffect(
1030
+ () => () => {
1031
+ refreshAbortRef.current?.abort();
1032
+ identityAbortRef.current.abort();
1033
+ eventReadAbortRef.current.abort();
1034
+ eventReconcilePendingRef.current = false;
1035
+ identityGenerationRef.current += 1;
1036
+ if (debounceRef.current) clearTimeout(debounceRef.current);
1037
+ },
1038
+ []
1039
+ );
1040
+ const identityMatches = enabled && stateIdentity === identityKey;
1041
+ return {
1042
+ tree: identityMatches ? tree : [],
1043
+ expand,
1044
+ expandingPaths: identityMatches ? expandingPaths : /* @__PURE__ */ new Set(),
1045
+ readFile,
1046
+ writeFile,
1047
+ createFile,
1048
+ createDir,
1049
+ deleteEntry,
1050
+ moveEntry,
1051
+ refresh,
1052
+ contentRevision: identityMatches ? contentRevision : 0,
1053
+ source: identityMatches ? source : null,
1054
+ capturedAt: identityMatches && source === "capture" ? capture?.capturedAt ?? null : null,
1055
+ gitSummary: identityMatches ? gitSummary : null,
1056
+ gitLoading: identityMatches && gitLoading,
1057
+ loading: identityMatches && loading,
1058
+ error: identityMatches ? error : null
1059
+ };
1060
+ }
1061
+
1062
+ // src/file-node-visibility.ts
1063
+ function pathIsInsideDirectory(path, directory) {
1064
+ if (!path.startsWith(directory) || path === directory) return false;
1065
+ if (directory.endsWith("/") || directory.endsWith("\\")) return true;
1066
+ const boundary = path[directory.length];
1067
+ return boundary === "/" || boundary === "\\";
1068
+ }
1069
+ function visibleFileTree(nodes, predicate, parent = null, depth = 0) {
1070
+ if (!predicate) return nodes;
1071
+ const visible = [];
1072
+ for (const node of nodes) {
1073
+ if (!predicate(node, { depth, parent })) continue;
1074
+ visible.push(
1075
+ node.children === void 0 ? node : {
1076
+ ...node,
1077
+ children: visibleFileTree(node.children, predicate, node, depth + 1)
1078
+ }
1079
+ );
1080
+ }
1081
+ return visible;
1082
+ }
1083
+ function filePathVisibility(nodes, path, predicate, parent = null, depth = 0) {
1084
+ if (!predicate) return "visible";
1085
+ for (const node of nodes) {
1086
+ if (node.path !== path && !pathIsInsideDirectory(path, node.path)) continue;
1087
+ if (!predicate(node, { depth, parent })) return "hidden";
1088
+ if (node.path === path) return "visible";
1089
+ if (node.kind !== "dir" || node.children === void 0) return "unknown";
1090
+ return filePathVisibility(node.children, path, predicate, node, depth + 1);
1091
+ }
1092
+ return "unknown";
1093
+ }
1094
+
1095
+ // src/components/file-browser.tsx
1096
+ import {
1097
+ ChevronRightIcon,
1098
+ FileIcon,
1099
+ FilePlusIcon,
1100
+ FolderIcon,
1101
+ FolderPlusIcon,
1102
+ PencilIcon,
1103
+ RefreshCwIcon,
1104
+ TriangleAlertIcon,
1105
+ Trash2Icon
1106
+ } from "lucide-react";
1107
+ import {
1108
+ useCallback as useCallback2,
1109
+ useEffect as useEffect3,
1110
+ useId,
1111
+ useLayoutEffect,
1112
+ useMemo as useMemo3,
1113
+ useRef as useRef2,
1114
+ useState as useState2
1115
+ } from "react";
1116
+ import { AlertDialog } from "radix-ui";
1117
+ import { VList } from "virtua";
1118
+
1119
+ // src/lib/use-unicode-fonts.ts
1120
+ import { useEffect as useEffect2, useMemo as useMemo2 } from "react";
1121
+ var japaneseScript = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/u;
1122
+ var arabicScript = /[\u0600-\u06ff\u0750-\u077f\u0870-\u08ff\ufb50-\ufdff\ufe70-\ufefc]/u;
1123
+ function useUnicodeFallbackFonts(values) {
1124
+ const content = useMemo2(() => collectUnicodeContent(values), [values]);
1125
+ useEffect2(() => {
1126
+ if (content.japanese) {
1127
+ void import("./noto-sans-jp-loader.generated-MR5L6V7K.js").then(({ loadNotoSansJp }) => loadNotoSansJp(content.japanese)).catch(() => void 0);
1128
+ }
1129
+ if (content.arabic) {
1130
+ void import("./noto-sans-arabic-loader-XSH2KYWJ.js").then(({ loadNotoSansArabic }) => loadNotoSansArabic()).catch(() => void 0);
1131
+ }
1132
+ }, [content.arabic, content.japanese]);
1133
+ }
1134
+ function collectUnicodeContent(values) {
1135
+ const japanese = /* @__PURE__ */ new Set();
1136
+ const arabic = /* @__PURE__ */ new Set();
1137
+ for (const value of values) {
1138
+ for (const character of value) {
1139
+ if (japaneseScript.test(character)) japanese.add(character);
1140
+ if (arabicScript.test(character)) arabic.add(character);
1141
+ }
1142
+ }
1143
+ return { japanese: [...japanese].join(""), arabic: [...arabic].join("") };
1144
+ }
1145
+
1146
+ // src/components/file-browser.tsx
1147
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1148
+ var STATUS_TINT = {
1149
+ added: "text-og-status-idle",
1150
+ modified: "text-og-status-running",
1151
+ deleted: "text-og-status-failed line-through",
1152
+ renamed: "text-og-accent",
1153
+ untracked: "text-og-fg-subtle"
1154
+ };
1155
+ var useBrowserLayoutEffect = typeof window === "undefined" ? useEffect3 : useLayoutEffect;
1156
+ function parentOf2(path) {
1157
+ const i = path.lastIndexOf("/");
1158
+ return i <= 0 ? "" : path.slice(0, i);
1159
+ }
1160
+ function joinPath(parent, name) {
1161
+ return parent ? `${parent}/${name}` : name;
1162
+ }
1163
+ function itemKey(item) {
1164
+ switch (item.type) {
1165
+ case "node":
1166
+ return item.node.path;
1167
+ case "create":
1168
+ return `create:${item.parent}`;
1169
+ case "skeleton":
1170
+ return `skeleton:${item.path}`;
1171
+ case "residue":
1172
+ return `residue:${item.path}`;
1173
+ }
1174
+ }
1175
+ function pathIsInsideDirectory2(path, directory) {
1176
+ if (!path.startsWith(directory) || path === directory) return false;
1177
+ if (directory.endsWith("/") || directory.endsWith("\\")) return true;
1178
+ const boundary = path[directory.length];
1179
+ return boundary === "/" || boundary === "\\";
1180
+ }
1181
+ function findNode(nodes, path) {
1182
+ for (const node of nodes) {
1183
+ if (node.path === path) return node;
1184
+ if (node.kind === "dir" && node.children && pathIsInsideDirectory2(path, node.path)) {
1185
+ const hit = findNode(node.children, path);
1186
+ if (hit) return hit;
1187
+ }
1188
+ }
1189
+ return void 0;
1190
+ }
1191
+ function traceRevealPath(nodes, targetPath) {
1192
+ for (const node of nodes) {
1193
+ if (node.path === targetPath) {
1194
+ return {
1195
+ directories: node.kind === "dir" ? [node.path] : [],
1196
+ frontier: node.kind === "dir" && node.children === void 0 ? node.path : null
1197
+ };
1198
+ }
1199
+ if (node.kind !== "dir" || !pathIsInsideDirectory2(targetPath, node.path)) continue;
1200
+ if (node.children === void 0) {
1201
+ return { directories: [node.path], frontier: node.path };
1202
+ }
1203
+ const child = traceRevealPath(node.children, targetPath);
1204
+ return {
1205
+ directories: [node.path, ...child.directories],
1206
+ frontier: child.frontier
1207
+ };
1208
+ }
1209
+ return { directories: [], frontier: null };
1210
+ }
1211
+ function FileBrowser({
1212
+ result,
1213
+ fallback,
1214
+ onSelectFile,
1215
+ selectedPath,
1216
+ isNodeVisible,
1217
+ revealPath,
1218
+ revealPathRequestId,
1219
+ renderNode,
1220
+ emptyState,
1221
+ editable = true,
1222
+ confirmDelete,
1223
+ className
1224
+ }) {
1225
+ const t = useOpenGeniText();
1226
+ const [expanded, setExpanded] = useState2(/* @__PURE__ */ new Set());
1227
+ const [loadingPaths, setLoadingPaths] = useState2(/* @__PURE__ */ new Set());
1228
+ const [active, setActive] = useState2(null);
1229
+ const [draftCreate, setDraftCreate] = useState2(null);
1230
+ const [draftRename, setDraftRename] = useState2(null);
1231
+ const [dragOver, setDragOver] = useState2(null);
1232
+ const [menu, setMenu] = useState2(null);
1233
+ const [pendingDelete, setPendingDelete] = useState2(null);
1234
+ const [busy, setBusy] = useState2(false);
1235
+ const [coarsePointer, setCoarsePointer] = useState2(false);
1236
+ const [revealRequest, setRevealRequest] = useState2(null);
1237
+ const handledRevealRequestRef = useRef2(null);
1238
+ const attemptedRevealPathsRef = useRef2(/* @__PURE__ */ new Set());
1239
+ const treeId = useId();
1240
+ const container = usePortalTokenSource();
1241
+ const containerRef = container.currentRef;
1242
+ const deleteReturnFocusRef = useRef2(null);
1243
+ const vlistRef = useRef2(null);
1244
+ const portalTokenStyle = usePortalTokenStyle(container.source);
1245
+ const getTreeElement = useCallback2(
1246
+ () => typeof document === "undefined" ? null : document.getElementById(treeId),
1247
+ [treeId]
1248
+ );
1249
+ const visibleTree = useMemo3(
1250
+ () => visibleFileTree(result.tree, isNodeVisible),
1251
+ [isNodeVisible, result.tree]
1252
+ );
1253
+ useBrowserLayoutEffect(() => {
1254
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
1255
+ const query = window.matchMedia("(pointer: coarse)");
1256
+ const update = () => setCoarsePointer(query.matches);
1257
+ update();
1258
+ if (typeof query.addEventListener === "function") {
1259
+ query.addEventListener("change", update);
1260
+ return () => query.removeEventListener("change", update);
1261
+ }
1262
+ if (typeof query.addListener === "function") {
1263
+ query.addListener(update);
1264
+ return () => query.removeListener(update);
1265
+ }
1266
+ }, []);
1267
+ const effectiveRevealRequestId = revealPath ? revealPathRequestId ?? revealPath : null;
1268
+ useEffect3(() => {
1269
+ if (!revealPath || effectiveRevealRequestId === null) {
1270
+ setRevealRequest(null);
1271
+ return;
1272
+ }
1273
+ const handled = handledRevealRequestRef.current;
1274
+ if (handled?.path === revealPath && handled.requestId === effectiveRevealRequestId) return;
1275
+ handledRevealRequestRef.current = {
1276
+ path: revealPath,
1277
+ requestId: effectiveRevealRequestId
1278
+ };
1279
+ attemptedRevealPathsRef.current = /* @__PURE__ */ new Set();
1280
+ setActive(null);
1281
+ setRevealRequest({ path: revealPath, requestId: effectiveRevealRequestId });
1282
+ }, [effectiveRevealRequestId, revealPath]);
1283
+ const visibleActive = active && findNode(visibleTree, active) ? active : null;
1284
+ const cursor = visibleActive ?? (selectedPath && findNode(visibleTree, selectedPath) ? selectedPath : null);
1285
+ useEffect3(() => {
1286
+ if (active !== null && visibleActive === null) setActive(null);
1287
+ }, [active, visibleActive]);
1288
+ const expand = useCallback2(
1289
+ async (path) => {
1290
+ const node = findNode(visibleTree, path);
1291
+ if (node && node.kind === "dir" && node.children === void 0) {
1292
+ setLoadingPaths((prev) => new Set(prev).add(path));
1293
+ try {
1294
+ await result.expand(path);
1295
+ } finally {
1296
+ setLoadingPaths((prev) => {
1297
+ const next = new Set(prev);
1298
+ next.delete(path);
1299
+ return next;
1300
+ });
1301
+ }
1302
+ }
1303
+ },
1304
+ [result, visibleTree]
1305
+ );
1306
+ const open = useCallback2(
1307
+ (path) => {
1308
+ setExpanded((prev) => new Set(prev).add(path));
1309
+ void expand(path);
1310
+ },
1311
+ [expand]
1312
+ );
1313
+ useEffect3(() => {
1314
+ if (!revealRequest) return;
1315
+ const trace = traceRevealPath(visibleTree, revealRequest.path);
1316
+ if (trace.directories.length > 0) {
1317
+ setExpanded((previous) => {
1318
+ const next = new Set(previous);
1319
+ let changed = false;
1320
+ for (const path of trace.directories) {
1321
+ if (next.has(path)) continue;
1322
+ next.add(path);
1323
+ changed = true;
1324
+ }
1325
+ return changed ? next : previous;
1326
+ });
1327
+ }
1328
+ const frontier = trace.frontier;
1329
+ if (!frontier || attemptedRevealPathsRef.current.has(frontier) || loadingPaths.has(frontier) || result.expandingPaths.has(frontier)) {
1330
+ return;
1331
+ }
1332
+ attemptedRevealPathsRef.current.add(frontier);
1333
+ void expand(frontier);
1334
+ }, [expand, loadingPaths, result.expandingPaths, revealRequest, visibleTree]);
1335
+ const toggle = useCallback2(
1336
+ async (node) => {
1337
+ if (node.kind !== "dir") return;
1338
+ const isOpen = expanded.has(node.path);
1339
+ setExpanded((prev) => {
1340
+ const next = new Set(prev);
1341
+ if (isOpen) next.delete(node.path);
1342
+ else next.add(node.path);
1343
+ return next;
1344
+ });
1345
+ if (!isOpen) await expand(node.path);
1346
+ },
1347
+ [expanded, expand]
1348
+ );
1349
+ const cold = result.source !== "live";
1350
+ const renderItems = useMemo3(() => {
1351
+ const items = [];
1352
+ if (draftCreate && draftCreate.parent === "") {
1353
+ items.push({ type: "create", parent: "", kind: draftCreate.kind, depth: 0 });
1354
+ }
1355
+ const walk = (nodes, depth) => {
1356
+ for (const node of nodes) {
1357
+ items.push({ type: "node", node, depth });
1358
+ if (node.kind !== "dir" || !expanded.has(node.path)) continue;
1359
+ if (draftCreate && draftCreate.parent === node.path) {
1360
+ items.push({
1361
+ type: "create",
1362
+ parent: node.path,
1363
+ kind: draftCreate.kind,
1364
+ depth: depth + 1
1365
+ });
1366
+ }
1367
+ const childless = node.children === void 0 || node.children.length === 0;
1368
+ const isLoading = loadingPaths.has(node.path) || result.expandingPaths.has(node.path);
1369
+ if (node.truncated && childless && cold && !isLoading) {
1370
+ items.push({ type: "residue", path: node.path, depth: depth + 1 });
1371
+ } else if (node.children && node.children.length > 0) {
1372
+ walk(node.children, depth + 1);
1373
+ } else if (isLoading && childless) {
1374
+ items.push({ type: "skeleton", path: node.path, depth: depth + 1 });
1375
+ }
1376
+ }
1377
+ };
1378
+ walk(visibleTree, 0);
1379
+ return items;
1380
+ }, [visibleTree, expanded, draftCreate, loadingPaths, result.expandingPaths, cold]);
1381
+ const unicodeFontPaths = useMemo3(
1382
+ () => renderItems.flatMap((item) => item.type === "node" ? [item.node.path] : []),
1383
+ [renderItems]
1384
+ );
1385
+ useUnicodeFallbackFonts(unicodeFontPaths);
1386
+ const flatRows = useMemo3(
1387
+ () => renderItems.flatMap(
1388
+ (item) => item.type === "node" ? [{ node: item.node, depth: item.depth }] : []
1389
+ ),
1390
+ [renderItems]
1391
+ );
1392
+ const rowIndexByPath = useMemo3(
1393
+ () => new Map(flatRows.map((row, index) => [row.node.path, index])),
1394
+ [flatRows]
1395
+ );
1396
+ const treePositionByPath = useMemo3(() => {
1397
+ const positions = /* @__PURE__ */ new Map();
1398
+ const visit = (nodes) => {
1399
+ nodes.forEach((node, index) => {
1400
+ positions.set(node.path, { position: index + 1, setSize: nodes.length });
1401
+ if (node.children) visit(node.children);
1402
+ });
1403
+ };
1404
+ visit(visibleTree);
1405
+ return positions;
1406
+ }, [visibleTree]);
1407
+ const cursorIndex = cursor ? rowIndexByPath.get(cursor) ?? -1 : -1;
1408
+ const activeDescendantId = cursorIndex >= 0 ? `${treeId}-item-${cursorIndex}` : void 0;
1409
+ const supportsMutation = editable && result.source === "live" && result.error === null && !result.loading;
1410
+ const performDelete = useCallback2(
1411
+ async (node) => {
1412
+ if (!supportsMutation) return;
1413
+ const recursive = node.kind === "dir";
1414
+ setBusy(true);
1415
+ try {
1416
+ await result.deleteEntry(node.path, recursive);
1417
+ } catch {
1418
+ } finally {
1419
+ setBusy(false);
1420
+ }
1421
+ },
1422
+ [supportsMutation, result]
1423
+ );
1424
+ const runDelete = useCallback2(
1425
+ async (node, returnFocus) => {
1426
+ if (!supportsMutation) return;
1427
+ setMenu(null);
1428
+ if (!confirmDelete) {
1429
+ deleteReturnFocusRef.current = returnFocus ?? (typeof document !== "undefined" && document.activeElement instanceof HTMLElement ? document.activeElement : null);
1430
+ setPendingDelete(node);
1431
+ return;
1432
+ }
1433
+ if (await confirmDelete(node)) await performDelete(node);
1434
+ },
1435
+ [supportsMutation, confirmDelete, performDelete]
1436
+ );
1437
+ const closePendingDelete = useCallback2(
1438
+ (restoreTrigger) => {
1439
+ const returnTarget = restoreTrigger ? deleteReturnFocusRef.current : getTreeElement();
1440
+ deleteReturnFocusRef.current = null;
1441
+ setPendingDelete(null);
1442
+ if (typeof window !== "undefined") {
1443
+ window.requestAnimationFrame(() => {
1444
+ const target = returnTarget?.isConnected ? returnTarget : getTreeElement();
1445
+ target?.focus();
1446
+ });
1447
+ }
1448
+ },
1449
+ [getTreeElement]
1450
+ );
1451
+ const commitCreate = useCallback2(
1452
+ async (name) => {
1453
+ const draft = draftCreate;
1454
+ setDraftCreate(null);
1455
+ if (!draft || !supportsMutation) return;
1456
+ const trimmed = name.trim().replace(/\/+$/, "");
1457
+ if (!trimmed) return;
1458
+ const path = joinPath(draft.parent, trimmed);
1459
+ setBusy(true);
1460
+ try {
1461
+ if (draft.kind === "dir") {
1462
+ await result.createDir(path);
1463
+ open(path);
1464
+ } else {
1465
+ await result.createFile(path);
1466
+ setActive(path);
1467
+ onSelectFile?.(path);
1468
+ }
1469
+ } catch {
1470
+ } finally {
1471
+ setBusy(false);
1472
+ }
1473
+ },
1474
+ [draftCreate, supportsMutation, result, open, onSelectFile]
1475
+ );
1476
+ const commitRename = useCallback2(
1477
+ async (name) => {
1478
+ const draft = draftRename;
1479
+ setDraftRename(null);
1480
+ if (!draft || !supportsMutation) return;
1481
+ const node = findNode(visibleTree, draft.path);
1482
+ const trimmed = name.trim().replace(/\/+$/, "");
1483
+ if (!node || !trimmed || trimmed === node.name) return;
1484
+ const newPath = joinPath(parentOf2(draft.path), trimmed);
1485
+ setBusy(true);
1486
+ try {
1487
+ await result.moveEntry(draft.path, newPath);
1488
+ if (node.kind === "file" && (selectedPath === draft.path || active === draft.path)) {
1489
+ setActive(newPath);
1490
+ onSelectFile?.(newPath);
1491
+ }
1492
+ } catch {
1493
+ } finally {
1494
+ setBusy(false);
1495
+ }
1496
+ },
1497
+ [draftRename, supportsMutation, result, selectedPath, active, onSelectFile, visibleTree]
1498
+ );
1499
+ const startCreate = useCallback2(
1500
+ (kind) => {
1501
+ if (!supportsMutation) return;
1502
+ const anchor = cursor ? findNode(visibleTree, cursor) : void 0;
1503
+ const parent = anchor ? anchor.kind === "dir" ? anchor.path : parentOf2(anchor.path) : "";
1504
+ if (parent) open(parent);
1505
+ setDraftRename(null);
1506
+ setMenu(null);
1507
+ setDraftCreate({ parent, kind });
1508
+ },
1509
+ [supportsMutation, cursor, open, visibleTree]
1510
+ );
1511
+ const startRename = useCallback2(
1512
+ (node) => {
1513
+ if (!supportsMutation) return;
1514
+ setDraftCreate(null);
1515
+ setMenu(null);
1516
+ setDraftRename({ path: node.path });
1517
+ },
1518
+ [supportsMutation]
1519
+ );
1520
+ const onDropOnto = useCallback2(
1521
+ async (targetDir, sourcePath) => {
1522
+ setDragOver(null);
1523
+ if (!supportsMutation || !sourcePath) return;
1524
+ const src = findNode(visibleTree, sourcePath);
1525
+ if (!src) return;
1526
+ if (parentOf2(sourcePath) === targetDir) return;
1527
+ if (targetDir === sourcePath || targetDir.startsWith(`${sourcePath}/`)) return;
1528
+ const newPath = joinPath(targetDir, src.name);
1529
+ if (newPath === sourcePath) return;
1530
+ setBusy(true);
1531
+ try {
1532
+ await result.moveEntry(sourcePath, newPath);
1533
+ if (src.kind === "file" && (selectedPath === sourcePath || active === sourcePath)) {
1534
+ setActive(newPath);
1535
+ onSelectFile?.(newPath);
1536
+ }
1537
+ } catch {
1538
+ } finally {
1539
+ setBusy(false);
1540
+ }
1541
+ },
1542
+ [supportsMutation, result, selectedPath, active, onSelectFile, visibleTree]
1543
+ );
1544
+ const onKeyDown = useCallback2(
1545
+ (e) => {
1546
+ if (draftCreate || draftRename) return;
1547
+ if (flatRows.length === 0) return;
1548
+ const idx = flatRows.findIndex((r) => r.node.path === cursor);
1549
+ const move = (next) => {
1550
+ const clamped = Math.max(0, Math.min(flatRows.length - 1, next));
1551
+ const row = flatRows[clamped];
1552
+ if (row) setActive(row.node.path);
1553
+ e.preventDefault();
1554
+ };
1555
+ const cur = idx >= 0 ? flatRows[idx] : void 0;
1556
+ switch (e.key) {
1557
+ case "ArrowDown":
1558
+ move(idx < 0 ? 0 : idx + 1);
1559
+ break;
1560
+ case "ArrowUp":
1561
+ move(idx < 0 ? 0 : idx - 1);
1562
+ break;
1563
+ case "Home":
1564
+ move(0);
1565
+ break;
1566
+ case "End":
1567
+ move(flatRows.length - 1);
1568
+ break;
1569
+ case "PageDown": {
1570
+ const pageSize = Math.max(
1571
+ 1,
1572
+ Math.floor((containerRef.current?.clientHeight || 280) / (coarsePointer ? 44 : 28)) - 1
1573
+ );
1574
+ move((idx < 0 ? 0 : idx) + pageSize);
1575
+ break;
1576
+ }
1577
+ case "PageUp": {
1578
+ const pageSize = Math.max(
1579
+ 1,
1580
+ Math.floor((containerRef.current?.clientHeight || 280) / (coarsePointer ? 44 : 28)) - 1
1581
+ );
1582
+ move((idx < 0 ? 0 : idx) - pageSize);
1583
+ break;
1584
+ }
1585
+ case "ArrowRight":
1586
+ if (cur?.node.kind === "dir") {
1587
+ if (!expanded.has(cur.node.path)) open(cur.node.path);
1588
+ else move(idx + 1);
1589
+ e.preventDefault();
1590
+ }
1591
+ break;
1592
+ case "ArrowLeft":
1593
+ if (cur) {
1594
+ if (cur.node.kind === "dir" && expanded.has(cur.node.path)) {
1595
+ setExpanded((prev) => {
1596
+ const n = new Set(prev);
1597
+ n.delete(cur.node.path);
1598
+ return n;
1599
+ });
1600
+ } else {
1601
+ const parent = parentOf2(cur.node.path);
1602
+ if (parent) setActive(parent);
1603
+ }
1604
+ e.preventDefault();
1605
+ }
1606
+ break;
1607
+ case "Enter":
1608
+ if (cur) {
1609
+ if (cur.node.kind === "dir") void toggle(cur.node);
1610
+ else onSelectFile?.(cur.node.path);
1611
+ e.preventDefault();
1612
+ }
1613
+ break;
1614
+ case "ContextMenu":
1615
+ case "F10":
1616
+ if (cur && supportsMutation && (e.key === "ContextMenu" || e.shiftKey)) {
1617
+ const rowIndex = rowIndexByPath.get(cur.node.path) ?? 0;
1618
+ const row = document.getElementById(`${treeId}-item-${rowIndex}`);
1619
+ const rect = row?.getBoundingClientRect();
1620
+ setMenu({
1621
+ node: cur.node,
1622
+ x: rect ? rect.left + Math.min(32, rect.width / 2) : 8,
1623
+ y: rect ? rect.bottom : 8
1624
+ });
1625
+ e.preventDefault();
1626
+ } else if (e.key === "F10") {
1627
+ break;
1628
+ }
1629
+ break;
1630
+ case "F2":
1631
+ if (cur) {
1632
+ startRename(cur.node);
1633
+ e.preventDefault();
1634
+ }
1635
+ break;
1636
+ case "Delete":
1637
+ case "Backspace":
1638
+ if (cur && supportsMutation) {
1639
+ void runDelete(cur.node);
1640
+ e.preventDefault();
1641
+ }
1642
+ break;
1643
+ }
1644
+ },
1645
+ [
1646
+ draftCreate,
1647
+ draftRename,
1648
+ flatRows,
1649
+ cursor,
1650
+ expanded,
1651
+ open,
1652
+ toggle,
1653
+ onSelectFile,
1654
+ startRename,
1655
+ runDelete,
1656
+ supportsMutation,
1657
+ coarsePointer,
1658
+ containerRef,
1659
+ rowIndexByPath,
1660
+ treeId
1661
+ ]
1662
+ );
1663
+ useEffect3(() => {
1664
+ if (!menu) return;
1665
+ const close = () => setMenu(null);
1666
+ window.addEventListener("click", close);
1667
+ window.addEventListener("scroll", close, true);
1668
+ window.addEventListener("resize", close);
1669
+ return () => {
1670
+ window.removeEventListener("click", close);
1671
+ window.removeEventListener("scroll", close, true);
1672
+ window.removeEventListener("resize", close);
1673
+ };
1674
+ }, [menu]);
1675
+ const showErrorEmpty = result.error && visibleTree.length === 0 && !draftCreate;
1676
+ const showDegradedTree = result.error && visibleTree.length > 0;
1677
+ const showEmpty = !result.loading && visibleTree.length === 0 && !draftCreate;
1678
+ const showToolbar = supportsMutation || result.loading;
1679
+ const usesVirtualTree = !showErrorEmpty && !showEmpty && renderItems.length > 500;
1680
+ const renderNodeRow = (node, depth) => {
1681
+ const isOpen = expanded.has(node.path);
1682
+ if (renderNode) {
1683
+ return /* @__PURE__ */ jsx("div", { children: renderNode(node, depth, isOpen) });
1684
+ }
1685
+ const isDir = node.kind === "dir";
1686
+ const isSelected = node.path === selectedPath || node.path === active;
1687
+ const isCursor = node.path === cursor;
1688
+ const isLoading = loadingPaths.has(node.path) || result.expandingPaths.has(node.path);
1689
+ const isRenaming = draftRename?.path === node.path;
1690
+ const isDropTarget = dragOver === (isDir ? node.path : parentOf2(node.path));
1691
+ const dropDir = isDir ? node.path : parentOf2(node.path);
1692
+ const treePosition = treePositionByPath.get(node.path);
1693
+ return /* @__PURE__ */ jsx(
1694
+ "div",
1695
+ {
1696
+ id: `${treeId}-item-${rowIndexByPath.get(node.path) ?? 0}`,
1697
+ role: "treeitem",
1698
+ "aria-level": depth + 1,
1699
+ "aria-posinset": treePosition?.position,
1700
+ "aria-setsize": treePosition?.setSize,
1701
+ "aria-expanded": isDir ? isOpen : void 0,
1702
+ "aria-selected": isCursor || void 0,
1703
+ "aria-busy": isLoading || void 0,
1704
+ onDragOver: supportsMutation ? (e) => {
1705
+ e.preventDefault();
1706
+ e.dataTransfer.dropEffect = "move";
1707
+ setDragOver(dropDir);
1708
+ } : void 0,
1709
+ onDragLeave: supportsMutation ? (e) => {
1710
+ e.stopPropagation();
1711
+ setDragOver((cur) => cur === dropDir ? null : cur);
1712
+ } : void 0,
1713
+ onDrop: supportsMutation ? (e) => {
1714
+ e.preventDefault();
1715
+ e.stopPropagation();
1716
+ const src = e.dataTransfer.getData("text/og-path");
1717
+ void onDropOnto(dropDir, src);
1718
+ } : void 0,
1719
+ children: isRenaming ? /* @__PURE__ */ jsx(
1720
+ InlineInput,
1721
+ {
1722
+ depth,
1723
+ kind: node.kind,
1724
+ initialValue: node.name,
1725
+ onCommit: (name) => void commitRename(name),
1726
+ onCancel: () => setDraftRename(null)
1727
+ }
1728
+ ) : /* @__PURE__ */ jsxs(
1729
+ "button",
1730
+ {
1731
+ type: "button",
1732
+ tabIndex: -1,
1733
+ draggable: supportsMutation || void 0,
1734
+ onDragStart: supportsMutation ? (e) => {
1735
+ e.dataTransfer.setData("text/og-path", node.path);
1736
+ e.dataTransfer.effectAllowed = "move";
1737
+ } : void 0,
1738
+ onClick: () => {
1739
+ setActive(node.path);
1740
+ if (isDir) void toggle(node);
1741
+ else onSelectFile?.(node.path);
1742
+ },
1743
+ onDoubleClick: () => supportsMutation && startRename(node),
1744
+ onContextMenu: (e) => {
1745
+ if (!supportsMutation) return;
1746
+ e.preventDefault();
1747
+ setActive(node.path);
1748
+ setMenu({ node, x: e.clientX, y: e.clientY });
1749
+ },
1750
+ className: cn(
1751
+ "group relative flex min-h-7 w-full items-center gap-1 truncate rounded-og-sm px-1 py-0.5 text-left text-og-sm pointer-coarse:min-h-11",
1752
+ "hover:bg-og-surface-2",
1753
+ isSelected && "bg-og-surface-2",
1754
+ isCursor && "outline outline-1 -outline-offset-1 outline-og-accent",
1755
+ isDropTarget && "bg-og-accent-soft ring-1 ring-inset ring-og-accent",
1756
+ // A thin progress shimmer on the expanding row — no per-node spinner.
1757
+ isLoading && "after:pointer-events-none after:absolute after:inset-x-1 after:bottom-0 after:h-px after:animate-pulse after:rounded-full after:bg-og-accent-soft",
1758
+ node.status ? STATUS_TINT[node.status] : void 0
1759
+ ),
1760
+ style: { paddingLeft: `${depth * 12 + 4}px` },
1761
+ children: [
1762
+ isDir ? /* @__PURE__ */ jsx(
1763
+ ChevronRightIcon,
1764
+ {
1765
+ className: cn(
1766
+ "size-3 shrink-0 transition-transform",
1767
+ isOpen && "rotate-90",
1768
+ isLoading && "text-og-accent"
1769
+ )
1770
+ }
1771
+ ) : /* @__PURE__ */ jsx("span", { className: "inline-block w-3 shrink-0" }),
1772
+ isDir ? /* @__PURE__ */ jsx(FolderIcon, { className: "size-3.5 shrink-0" }) : /* @__PURE__ */ jsx(FileIcon, { className: "size-3.5 shrink-0" }),
1773
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: node.name }),
1774
+ supportsMutation && /* @__PURE__ */ jsx(
1775
+ "span",
1776
+ {
1777
+ role: "button",
1778
+ tabIndex: -1,
1779
+ "aria-label": t("fileBrowser.moreActions"),
1780
+ onClick: (e) => {
1781
+ e.preventDefault();
1782
+ e.stopPropagation();
1783
+ setActive(node.path);
1784
+ const rect = e.currentTarget.getBoundingClientRect();
1785
+ setMenu({ node, x: rect.right, y: rect.bottom });
1786
+ },
1787
+ className: "ml-auto hidden shrink-0 px-1 text-og-fg-subtle hover:text-og-fg group-hover:inline",
1788
+ children: "\u22EF"
1789
+ }
1790
+ )
1791
+ ]
1792
+ }
1793
+ )
1794
+ }
1795
+ );
1796
+ };
1797
+ const renderItem = (item) => {
1798
+ switch (item.type) {
1799
+ case "node":
1800
+ return renderNodeRow(item.node, item.depth);
1801
+ case "create":
1802
+ return /* @__PURE__ */ jsx(
1803
+ InlineInput,
1804
+ {
1805
+ depth: item.depth,
1806
+ kind: item.kind,
1807
+ initialValue: "",
1808
+ onCommit: (name) => void commitCreate(name),
1809
+ onCancel: () => setDraftCreate(null)
1810
+ }
1811
+ );
1812
+ case "skeleton":
1813
+ return /* @__PURE__ */ jsx(
1814
+ "div",
1815
+ {
1816
+ role: "group",
1817
+ "aria-hidden": true,
1818
+ style: { paddingLeft: `${item.depth * 12 + 4}px` },
1819
+ className: "space-y-1 py-1",
1820
+ children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx(
1821
+ "div",
1822
+ {
1823
+ className: "h-2.5 animate-pulse rounded-og-sm bg-og-surface-2",
1824
+ style: { width: `${70 - i * 12}%` }
1825
+ },
1826
+ i
1827
+ ))
1828
+ }
1829
+ );
1830
+ case "residue":
1831
+ return /* @__PURE__ */ jsxs(
1832
+ "div",
1833
+ {
1834
+ style: { paddingLeft: `${item.depth * 12 + 4}px` },
1835
+ className: "flex items-center gap-1.5 py-0.5 pr-1 text-og-xs italic text-og-fg-subtle",
1836
+ children: [
1837
+ /* @__PURE__ */ jsx("span", { className: "inline-block w-3 shrink-0" }),
1838
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: t("fileBrowser.contentsOnMachineOpenWhen") })
1839
+ ]
1840
+ }
1841
+ );
1842
+ }
1843
+ };
1844
+ useEffect3(() => {
1845
+ if (!cursor) return;
1846
+ const index = renderItems.findIndex((it) => it.type === "node" && it.node.path === cursor);
1847
+ if (index >= 0) vlistRef.current?.scrollToIndex(index);
1848
+ }, [cursor, renderItems]);
1849
+ useEffect3(() => {
1850
+ if (!revealRequest) return;
1851
+ const index = renderItems.findIndex(
1852
+ (item) => item.type === "node" && item.node.path === revealRequest.path
1853
+ );
1854
+ if (index < 0) return;
1855
+ if (usesVirtualTree) {
1856
+ vlistRef.current?.scrollToIndex(index);
1857
+ } else {
1858
+ document.getElementById(`${treeId}-item-${index}`)?.scrollIntoView?.({ block: "nearest" });
1859
+ }
1860
+ setRevealRequest(
1861
+ (current) => current?.path === revealRequest.path && current.requestId === revealRequest.requestId ? null : current
1862
+ );
1863
+ }, [renderItems, revealRequest, treeId, usesVirtualTree]);
1864
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex min-h-0 min-w-0 flex-col", className), children: [
1865
+ showToolbar && /* @__PURE__ */ jsxs(
1866
+ "div",
1867
+ {
1868
+ role: "toolbar",
1869
+ "aria-label": t("fileBrowser.fileActions"),
1870
+ className: "flex shrink-0 flex-wrap items-center gap-0.5 border-b border-og-border px-1 py-1",
1871
+ children: [
1872
+ supportsMutation ? /* @__PURE__ */ jsxs(Fragment, { children: [
1873
+ /* @__PURE__ */ jsx(
1874
+ ToolbarButton,
1875
+ {
1876
+ label: t("fileBrowser.newFile"),
1877
+ onClick: () => startCreate("file"),
1878
+ disabled: busy,
1879
+ children: /* @__PURE__ */ jsx(FilePlusIcon, { className: "size-3.5" })
1880
+ }
1881
+ ),
1882
+ /* @__PURE__ */ jsx(
1883
+ ToolbarButton,
1884
+ {
1885
+ label: t("fileBrowser.newFolder"),
1886
+ onClick: () => startCreate("dir"),
1887
+ disabled: busy,
1888
+ children: /* @__PURE__ */ jsx(FolderPlusIcon, { className: "size-3.5" })
1889
+ }
1890
+ ),
1891
+ /* @__PURE__ */ jsx(
1892
+ ToolbarButton,
1893
+ {
1894
+ label: t("fileBrowser.rename"),
1895
+ onClick: () => {
1896
+ const node = cursor ? findNode(visibleTree, cursor) : void 0;
1897
+ if (node) startRename(node);
1898
+ },
1899
+ disabled: busy || !cursor,
1900
+ children: /* @__PURE__ */ jsx(PencilIcon, { className: "size-3.5" })
1901
+ }
1902
+ ),
1903
+ /* @__PURE__ */ jsx(
1904
+ ToolbarButton,
1905
+ {
1906
+ label: t("fileBrowser.delete"),
1907
+ onClick: (event) => {
1908
+ const node = cursor ? findNode(visibleTree, cursor) : void 0;
1909
+ if (node) void runDelete(node, event.currentTarget);
1910
+ },
1911
+ disabled: busy || !cursor,
1912
+ children: /* @__PURE__ */ jsx(Trash2Icon, { className: "size-3.5" })
1913
+ }
1914
+ )
1915
+ ] }) : null,
1916
+ /* @__PURE__ */ jsx("span", { className: "ml-auto" }),
1917
+ /* @__PURE__ */ jsx(
1918
+ ToolbarButton,
1919
+ {
1920
+ label: t("fileBrowser.refresh"),
1921
+ onClick: () => void result.refresh(),
1922
+ disabled: busy || result.loading,
1923
+ children: /* @__PURE__ */ jsx(RefreshCwIcon, { className: cn("size-3.5", result.loading && "animate-spin") })
1924
+ }
1925
+ )
1926
+ ]
1927
+ }
1928
+ ),
1929
+ showDegradedTree ? /* @__PURE__ */ jsxs(
1930
+ "div",
1931
+ {
1932
+ role: "status",
1933
+ "aria-live": "polite",
1934
+ "data-opengeni-files-degraded": true,
1935
+ className: "flex shrink-0 items-center gap-2 border-b border-og-status-running/30 bg-og-status-running/10 px-2 py-1.5 text-og-xs text-og-fg-muted",
1936
+ children: [
1937
+ /* @__PURE__ */ jsx(TriangleAlertIcon, { className: "size-3.5 shrink-0 text-og-status-running", "aria-hidden": true }),
1938
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1", children: result.source === "capture" ? t("fileBrowser.liveFilesAreTemporarilyUnavailable") : t("fileBrowser.liveRefreshFailedShowingThe") }),
1939
+ /* @__PURE__ */ jsxs(
1940
+ "button",
1941
+ {
1942
+ type: "button",
1943
+ onClick: () => void result.refresh(),
1944
+ disabled: result.loading,
1945
+ className: "inline-flex min-h-7 shrink-0 items-center gap-1 rounded-og-sm border border-og-border bg-og-surface-1 px-2 font-medium text-og-fg transition-colors hover:border-og-border-strong focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:cursor-not-allowed disabled:opacity-50 pointer-coarse:min-h-11",
1946
+ children: [
1947
+ /* @__PURE__ */ jsx(
1948
+ RefreshCwIcon,
1949
+ {
1950
+ className: cn("size-3", result.loading && "animate-spin motion-reduce:animate-none"),
1951
+ "aria-hidden": true
1952
+ }
1953
+ ),
1954
+ t("fileBrowser.retry")
1955
+ ]
1956
+ }
1957
+ )
1958
+ ]
1959
+ }
1960
+ ) : null,
1961
+ /* @__PURE__ */ jsx(
1962
+ "div",
1963
+ {
1964
+ ref: container.ref,
1965
+ onFocus: (event) => {
1966
+ if (event.target.id === treeId && cursorIndex < 0) {
1967
+ const first = flatRows[0];
1968
+ if (first) setActive(first.node.path);
1969
+ }
1970
+ },
1971
+ onKeyDown,
1972
+ onDragOver: supportsMutation ? (e) => {
1973
+ e.preventDefault();
1974
+ e.dataTransfer.dropEffect = "move";
1975
+ setDragOver("");
1976
+ } : void 0,
1977
+ onDrop: supportsMutation ? (e) => {
1978
+ e.preventDefault();
1979
+ const src = e.dataTransfer.getData("text/og-path");
1980
+ void onDropOnto("", src);
1981
+ } : void 0,
1982
+ className: cn(
1983
+ "flex min-h-0 min-w-0 flex-1 flex-col p-1",
1984
+ dragOver === "" && "ring-1 ring-inset ring-og-accent"
1985
+ ),
1986
+ "data-opengeni-file-tree": true,
1987
+ children: showErrorEmpty ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-2 p-2 text-og-sm text-og-fg-subtle", children: [
1988
+ /* @__PURE__ */ jsx("div", { children: fallback ?? t("fileBrowser.couldNotLoadFilesMessage", {
1989
+ message: result.error?.message ?? t("fileBrowser.refreshTheFileListTo")
1990
+ }) }),
1991
+ /* @__PURE__ */ jsxs(
1992
+ "button",
1993
+ {
1994
+ type: "button",
1995
+ onClick: () => void result.refresh(),
1996
+ disabled: result.loading,
1997
+ className: "inline-flex items-center gap-1.5 rounded-og-sm border border-og-border px-2 py-1 text-og-xs font-medium text-og-fg-muted transition-colors hover:border-og-border-strong hover:text-og-fg disabled:cursor-not-allowed disabled:opacity-50 pointer-coarse:min-h-11",
1998
+ children: [
1999
+ /* @__PURE__ */ jsx(
2000
+ RefreshCwIcon,
2001
+ {
2002
+ className: cn("size-3.5", result.loading && "animate-spin"),
2003
+ "aria-hidden": true
2004
+ }
2005
+ ),
2006
+ t("fileBrowser.retry")
2007
+ ]
2008
+ }
2009
+ )
2010
+ ] }) : showEmpty ? /* @__PURE__ */ jsx("div", { className: "p-2 text-og-sm text-og-fg-subtle", children: emptyState ?? t("fileBrowser.thisDirectoryIsEmpty") }) : !usesVirtualTree ? /* @__PURE__ */ jsx(
2011
+ "div",
2012
+ {
2013
+ id: treeId,
2014
+ role: "tree",
2015
+ "aria-label": t("fileBrowser.workspaceFiles"),
2016
+ "aria-activedescendant": activeDescendantId,
2017
+ "aria-multiselectable": false,
2018
+ tabIndex: 0,
2019
+ className: "min-h-0 min-w-0 flex-1 overflow-auto outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-og-accent",
2020
+ children: renderItems.map((item) => /* @__PURE__ */ jsx("div", { className: "min-w-0", children: renderItem(item) }, itemKey(item)))
2021
+ }
2022
+ ) : (
2023
+ // Virtualized: only the rows in/near the viewport mount, so a 3k-node
2024
+ // tree stays responsive. The flat item list already carries the
2025
+ // expanded subtree + synthetic (create/skeleton/residue) rows.
2026
+ /* @__PURE__ */ jsx(
2027
+ VList,
2028
+ {
2029
+ ref: vlistRef,
2030
+ id: treeId,
2031
+ role: "tree",
2032
+ "aria-label": t("fileBrowser.workspaceFiles"),
2033
+ "aria-activedescendant": activeDescendantId,
2034
+ "aria-multiselectable": false,
2035
+ tabIndex: 0,
2036
+ className: "min-h-0 flex-1 outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-og-accent",
2037
+ itemSize: coarsePointer ? 44 : 28,
2038
+ ssrCount: Math.min(32, renderItems.length),
2039
+ children: renderItems.map((item) => /* @__PURE__ */ jsx("div", { className: "min-w-0", children: renderItem(item) }, itemKey(item)))
2040
+ }
2041
+ )
2042
+ )
2043
+ }
2044
+ ),
2045
+ menu && menu.node && /* @__PURE__ */ jsx(
2046
+ ContextMenu,
2047
+ {
2048
+ node: menu.node,
2049
+ x: menu.x,
2050
+ y: menu.y,
2051
+ onRename: () => menu.node && startRename(menu.node),
2052
+ onDelete: () => menu.node && void runDelete(menu.node),
2053
+ onNewFile: () => startCreate("file"),
2054
+ onNewFolder: () => startCreate("dir"),
2055
+ onClose: () => {
2056
+ setMenu(null);
2057
+ window.requestAnimationFrame(() => getTreeElement()?.focus());
2058
+ }
2059
+ }
2060
+ ),
2061
+ pendingDelete ? /* @__PURE__ */ jsx(
2062
+ DeleteDialog,
2063
+ {
2064
+ node: pendingDelete,
2065
+ busy,
2066
+ portalTokenStyle,
2067
+ onCancel: () => closePendingDelete(true),
2068
+ onConfirm: () => {
2069
+ const node = pendingDelete;
2070
+ closePendingDelete(false);
2071
+ void performDelete(node);
2072
+ }
2073
+ }
2074
+ ) : null
2075
+ ] });
2076
+ }
2077
+ function DeleteDialog({
2078
+ node,
2079
+ busy,
2080
+ portalTokenStyle,
2081
+ onCancel,
2082
+ onConfirm
2083
+ }) {
2084
+ const t = useOpenGeniText();
2085
+ const cancelRef = useRef2(null);
2086
+ const [open, setOpen] = useState2(true);
2087
+ const closeIntentRef = useRef2("cancel");
2088
+ const settledRef = useRef2(false);
2089
+ const settleTimerRef = useRef2(null);
2090
+ const settle = () => {
2091
+ if (settledRef.current) return;
2092
+ settledRef.current = true;
2093
+ if (closeIntentRef.current === "confirm") {
2094
+ onConfirm();
2095
+ } else {
2096
+ onCancel();
2097
+ }
2098
+ };
2099
+ const scheduleSettle = () => {
2100
+ if (settleTimerRef.current !== null) return;
2101
+ settleTimerRef.current = setTimeout(() => {
2102
+ settleTimerRef.current = null;
2103
+ settle();
2104
+ }, 0);
2105
+ };
2106
+ useEffect3(
2107
+ () => () => {
2108
+ if (settleTimerRef.current !== null) clearTimeout(settleTimerRef.current);
2109
+ },
2110
+ []
2111
+ );
2112
+ return /* @__PURE__ */ jsx(
2113
+ AlertDialog.Root,
2114
+ {
2115
+ open,
2116
+ onOpenChange: (nextOpen) => {
2117
+ if (!nextOpen && !busy) {
2118
+ setOpen(false);
2119
+ scheduleSettle();
2120
+ }
2121
+ },
2122
+ children: /* @__PURE__ */ jsxs(AlertDialog.Portal, { container: typeof document === "undefined" ? null : document.body, children: [
2123
+ /* @__PURE__ */ jsx(AlertDialog.Overlay, { className: "og-root fixed inset-0 z-[100] bg-black/45 backdrop-blur-[2px]" }),
2124
+ /* @__PURE__ */ jsxs(
2125
+ AlertDialog.Content,
2126
+ {
2127
+ className: "og-root fixed left-1/2 top-1/2 z-[101] max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-sm -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-og-lg border border-og-border-strong bg-og-surface-1 p-4 text-og-fg shadow-2xl outline-hidden",
2128
+ style: portalTokenStyle,
2129
+ onOpenAutoFocus: (event) => {
2130
+ event.preventDefault();
2131
+ cancelRef.current?.focus();
2132
+ },
2133
+ onCloseAutoFocus: (event) => {
2134
+ event.preventDefault();
2135
+ scheduleSettle();
2136
+ },
2137
+ onEscapeKeyDown: (event) => {
2138
+ event.stopPropagation();
2139
+ if (busy) {
2140
+ event.preventDefault();
2141
+ } else {
2142
+ closeIntentRef.current = "cancel";
2143
+ }
2144
+ },
2145
+ children: [
2146
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
2147
+ /* @__PURE__ */ jsx("span", { className: "flex size-9 shrink-0 items-center justify-center rounded-full bg-og-status-failed/12 text-og-status-failed", children: /* @__PURE__ */ jsx(Trash2Icon, { className: "size-4", "aria-hidden": true }) }),
2148
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
2149
+ /* @__PURE__ */ jsxs(AlertDialog.Title, { className: "text-og-sm font-semibold", children: [
2150
+ t("fileBrowser.delete"),
2151
+ " ",
2152
+ node.kind === "dir" ? t("fileBrowser.folder") : t("fileBrowser.file"),
2153
+ "?"
2154
+ ] }),
2155
+ /* @__PURE__ */ jsxs(AlertDialog.Description, { className: "mt-1 text-og-sm leading-relaxed text-og-fg-muted", children: [
2156
+ /* @__PURE__ */ jsx("span", { className: "break-all font-og-mono text-og-fg", children: node.path }),
2157
+ node.kind === "dir" ? " and everything inside it will be permanently removed." : " will be permanently removed."
2158
+ ] })
2159
+ ] })
2160
+ ] }),
2161
+ /* @__PURE__ */ jsxs("div", { className: "mt-4 flex justify-end gap-2", children: [
2162
+ /* @__PURE__ */ jsx(AlertDialog.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(
2163
+ "button",
2164
+ {
2165
+ ref: cancelRef,
2166
+ type: "button",
2167
+ onClick: () => {
2168
+ closeIntentRef.current = "cancel";
2169
+ },
2170
+ disabled: busy,
2171
+ className: "min-h-9 rounded-og-md border border-og-border px-3 text-og-sm font-medium text-og-fg hover:bg-og-surface-2 disabled:opacity-50 pointer-coarse:min-h-11",
2172
+ children: t("fileBrowser.cancel")
2173
+ }
2174
+ ) }),
2175
+ /* @__PURE__ */ jsx(AlertDialog.Action, { asChild: true, children: /* @__PURE__ */ jsx(
2176
+ "button",
2177
+ {
2178
+ type: "button",
2179
+ onClick: () => {
2180
+ closeIntentRef.current = "confirm";
2181
+ },
2182
+ disabled: busy,
2183
+ className: "min-h-9 rounded-og-md bg-og-danger-fill px-3 text-og-sm font-semibold text-og-danger-fg shadow-sm hover:brightness-110 disabled:opacity-50 pointer-coarse:min-h-11",
2184
+ children: t("fileBrowser.deletePermanently")
2185
+ }
2186
+ ) })
2187
+ ] })
2188
+ ]
2189
+ }
2190
+ )
2191
+ ] })
2192
+ }
2193
+ );
2194
+ }
2195
+ function ToolbarButton({
2196
+ label,
2197
+ onClick,
2198
+ disabled,
2199
+ children
2200
+ }) {
2201
+ return /* @__PURE__ */ jsx(
2202
+ "button",
2203
+ {
2204
+ type: "button",
2205
+ title: label,
2206
+ "aria-label": label,
2207
+ onClick,
2208
+ disabled,
2209
+ className: cn(
2210
+ "inline-flex size-7 items-center justify-center rounded-og-sm p-1 text-og-fg-muted max-[1023px]:size-11 pointer-coarse:min-h-11 pointer-coarse:min-w-11",
2211
+ "hover:bg-og-surface-2 hover:text-og-fg",
2212
+ "disabled:cursor-not-allowed disabled:opacity-40"
2213
+ ),
2214
+ children
2215
+ }
2216
+ );
2217
+ }
2218
+ function InlineInput({
2219
+ depth,
2220
+ kind,
2221
+ initialValue,
2222
+ onCommit,
2223
+ onCancel
2224
+ }) {
2225
+ const t = useOpenGeniText();
2226
+ const [value, setValue] = useState2(initialValue);
2227
+ const ref = useRef2(null);
2228
+ const doneRef = useRef2(false);
2229
+ useEffect3(() => {
2230
+ const el = ref.current;
2231
+ if (!el) return;
2232
+ el.focus();
2233
+ const dot = initialValue.lastIndexOf(".");
2234
+ if (initialValue && dot > 0) el.setSelectionRange(0, dot);
2235
+ else el.select();
2236
+ }, [initialValue]);
2237
+ const finish = (commit) => {
2238
+ if (doneRef.current) return;
2239
+ doneRef.current = true;
2240
+ if (commit) onCommit(value);
2241
+ else onCancel();
2242
+ };
2243
+ return /* @__PURE__ */ jsxs(
2244
+ "div",
2245
+ {
2246
+ className: "flex items-center gap-1 px-1 py-0.5",
2247
+ style: { paddingLeft: `${depth * 12 + 4}px` },
2248
+ children: [
2249
+ /* @__PURE__ */ jsx("span", { className: "inline-block w-3 shrink-0" }),
2250
+ kind === "dir" ? /* @__PURE__ */ jsx(FolderIcon, { className: "size-3.5 shrink-0" }) : /* @__PURE__ */ jsx(FileIcon, { className: "size-3.5 shrink-0" }),
2251
+ /* @__PURE__ */ jsx(
2252
+ "input",
2253
+ {
2254
+ ref,
2255
+ value,
2256
+ spellCheck: false,
2257
+ autoComplete: "off",
2258
+ "aria-label": kind === "dir" ? t("fileBrowser.folderName") : t("fileBrowser.fileName"),
2259
+ onChange: (e) => setValue(e.target.value),
2260
+ onBlur: () => finish(true),
2261
+ onKeyDown: (e) => {
2262
+ if (e.key === "Enter") {
2263
+ e.preventDefault();
2264
+ finish(true);
2265
+ } else if (e.key === "Escape") {
2266
+ e.preventDefault();
2267
+ finish(false);
2268
+ }
2269
+ e.stopPropagation();
2270
+ },
2271
+ className: cn(
2272
+ "min-w-0 flex-1 rounded-og-sm border bg-og-bg px-1 py-0 text-og-sm",
2273
+ "border-og-accent text-og-fg",
2274
+ "outline-hidden"
2275
+ )
2276
+ }
2277
+ )
2278
+ ]
2279
+ }
2280
+ );
2281
+ }
2282
+ function ContextMenu({
2283
+ node,
2284
+ x,
2285
+ y,
2286
+ onRename,
2287
+ onDelete,
2288
+ onNewFile,
2289
+ onNewFolder,
2290
+ onClose
2291
+ }) {
2292
+ const t = useOpenGeniText();
2293
+ const isDir = node.kind === "dir";
2294
+ const menuRef = useRef2(null);
2295
+ const vw = typeof window !== "undefined" ? window.innerWidth : 9999;
2296
+ const vh = typeof window !== "undefined" ? window.innerHeight : 9999;
2297
+ const left = Math.max(4, Math.min(x, vw - 180));
2298
+ const top = Math.max(4, Math.min(y, vh - 160));
2299
+ useEffect3(() => {
2300
+ menuRef.current?.querySelector('[role="menuitem"]')?.focus();
2301
+ }, []);
2302
+ const onKeyDown = (event) => {
2303
+ const items = Array.from(
2304
+ menuRef.current?.querySelectorAll('[role="menuitem"]') ?? []
2305
+ );
2306
+ if (items.length === 0) return;
2307
+ const current = items.findIndex((item2) => item2 === document.activeElement);
2308
+ let next = null;
2309
+ if (event.key === "ArrowDown") next = (current + 1 + items.length) % items.length;
2310
+ else if (event.key === "ArrowUp") next = (current - 1 + items.length) % items.length;
2311
+ else if (event.key === "Home") next = 0;
2312
+ else if (event.key === "End") next = items.length - 1;
2313
+ else if (event.key === "Escape") {
2314
+ event.preventDefault();
2315
+ event.stopPropagation();
2316
+ onClose();
2317
+ return;
2318
+ }
2319
+ if (next === null) return;
2320
+ event.preventDefault();
2321
+ event.stopPropagation();
2322
+ items[next]?.focus();
2323
+ };
2324
+ const item = (label, icon, onClick, danger) => /* @__PURE__ */ jsxs(
2325
+ "button",
2326
+ {
2327
+ type: "button",
2328
+ role: "menuitem",
2329
+ onClick: (e) => {
2330
+ e.stopPropagation();
2331
+ onClick();
2332
+ },
2333
+ className: cn(
2334
+ MENU_BUTTON_CLASS,
2335
+ danger && "text-og-status-failed [&_svg]:text-og-status-failed!"
2336
+ ),
2337
+ children: [
2338
+ icon,
2339
+ label
2340
+ ]
2341
+ }
2342
+ );
2343
+ return /* @__PURE__ */ jsxs(
2344
+ "div",
2345
+ {
2346
+ ref: menuRef,
2347
+ role: "menu",
2348
+ "aria-label": t("fileBrowser.actionsForName", { name: node.name }),
2349
+ onKeyDown,
2350
+ onClick: (e) => e.stopPropagation(),
2351
+ style: { left, top },
2352
+ className: cn(MENU_SURFACE_CLASS, "fixed z-50 min-w-[180px] overflow-hidden"),
2353
+ children: [
2354
+ isDir && /* @__PURE__ */ jsxs(Fragment, { children: [
2355
+ item(t("fileBrowser.newFile"), /* @__PURE__ */ jsx(FilePlusIcon, {}), onNewFile),
2356
+ item(t("fileBrowser.newFolder"), /* @__PURE__ */ jsx(FolderPlusIcon, {}), onNewFolder),
2357
+ /* @__PURE__ */ jsx("div", { role: "separator", className: MENU_SEPARATOR_CLASS })
2358
+ ] }),
2359
+ item(t("fileBrowser.rename"), /* @__PURE__ */ jsx(PencilIcon, {}), onRename),
2360
+ item("Delete", /* @__PURE__ */ jsx(Trash2Icon, {}), onDelete, true)
2361
+ ]
2362
+ }
2363
+ );
2364
+ }
2365
+
2366
+ // src/components/pierre-file.tsx
2367
+ import {
2368
+ lazy,
2369
+ Suspense,
2370
+ useEffect as useEffect4,
2371
+ useState as useState3,
2372
+ useSyncExternalStore
2373
+ } from "react";
2374
+ import { jsx as jsx2 } from "react/jsx-runtime";
2375
+ var LazyFile = lazy(async () => {
2376
+ const mod = await loadPierreDiffs();
2377
+ return { default: mod.File };
2378
+ });
2379
+ function PierreFile({
2380
+ path,
2381
+ contents,
2382
+ themeType,
2383
+ theme,
2384
+ disableWorkerPool,
2385
+ loading,
2386
+ fallback,
2387
+ className
2388
+ }) {
2389
+ const [failed, setFailed] = useState3(false);
2390
+ const [ready, setReady] = useState3(false);
2391
+ const loaderRevision = useSyncExternalStore(
2392
+ subscribePierreDiffs,
2393
+ pierreDiffsRevision,
2394
+ pierreDiffsRevision
2395
+ );
2396
+ useEffect4(() => {
2397
+ let cancelled = false;
2398
+ setFailed(false);
2399
+ loadPierreDiffs().then(
2400
+ () => {
2401
+ if (!cancelled) setReady(true);
2402
+ },
2403
+ () => {
2404
+ if (!cancelled) setFailed(true);
2405
+ }
2406
+ );
2407
+ return () => {
2408
+ cancelled = true;
2409
+ };
2410
+ }, [loaderRevision]);
2411
+ const name = path.split("/").filter(Boolean).pop() ?? path;
2412
+ if (failed) {
2413
+ return /* @__PURE__ */ jsx2("div", { className, children: fallback ?? /* @__PURE__ */ jsx2(PlainFile, { name, contents }) });
2414
+ }
2415
+ const options = {
2416
+ overflow: "scroll",
2417
+ stickyHeader: true,
2418
+ showLineNumbers: true,
2419
+ ...theme ? { theme } : {
2420
+ theme: {
2421
+ dark: "github-dark-high-contrast",
2422
+ light: "github-light-high-contrast"
2423
+ }
2424
+ },
2425
+ themeType: themeType ?? "dark"
2426
+ };
2427
+ const pierreVars = {
2428
+ "--diffs-dark-bg": "var(--og-color-bg)",
2429
+ "--diffs-light-bg": "var(--og-color-bg)",
2430
+ "--diffs-bg-buffer-override": "var(--og-color-surface-1)",
2431
+ "--diffs-bg-separator-override": "var(--og-color-surface-1)",
2432
+ // Pierre's default (fg mixed 65% into bg) falls under 4.5:1 on the lifted
2433
+ // graphite separator; quiet meta text keeps AA on every diff surface.
2434
+ "--diffs-fg-number-override": "var(--og-color-fg-subtle)",
2435
+ "--diffs-font-size": "var(--og-code-font-size)",
2436
+ "--diffs-line-height": "var(--og-code-line-height)"
2437
+ };
2438
+ return /* @__PURE__ */ jsx2("div", { className: cn("min-w-0", className), "data-opengeni-pierre-file": true, style: pierreVars, children: /* @__PURE__ */ jsx2(Suspense, { fallback: loading ?? /* @__PURE__ */ jsx2(FileSkeleton, {}), children: ready ? /* @__PURE__ */ jsx2(
2439
+ LazyFile,
2440
+ {
2441
+ file: { name, contents },
2442
+ options,
2443
+ ...disableWorkerPool !== void 0 ? { disableWorkerPool } : {}
2444
+ }
2445
+ ) : loading ?? /* @__PURE__ */ jsx2(FileSkeleton, {}) }) });
2446
+ }
2447
+ function PlainFile({ name, contents }) {
2448
+ return /* @__PURE__ */ jsx2(
2449
+ "pre",
2450
+ {
2451
+ className: "overflow-auto whitespace-pre p-2 font-og-mono text-og-sm text-og-fg",
2452
+ "data-file": name,
2453
+ children: contents
2454
+ }
2455
+ );
2456
+ }
2457
+ function FileSkeleton() {
2458
+ const t = useOpenGeniText();
2459
+ return /* @__PURE__ */ jsx2("div", { className: "p-3 text-og-sm text-og-fg-subtle", children: t("pierreFile.loadingFile") });
2460
+ }
2461
+
2462
+ // src/components/sandbox-files.tsx
2463
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
2464
+ function SandboxFiles({
2465
+ files,
2466
+ git,
2467
+ fileSystemAvailable = true,
2468
+ usePierre = true,
2469
+ editable = true,
2470
+ onEditIntent,
2471
+ initialSelectedPath,
2472
+ onSelectedPathChange,
2473
+ isNodeVisible,
2474
+ requestedPath,
2475
+ requestedLine,
2476
+ requestedPathRequestId,
2477
+ requestedPathReady = true,
2478
+ workspaceResting = false,
2479
+ workspaceWaking = false,
2480
+ liveWorkspaceReady = true,
2481
+ workspaceError = null,
2482
+ onWakeWorkspace,
2483
+ themeType,
2484
+ className
2485
+ }) {
2486
+ const t = useOpenGeniText();
2487
+ const [selected, setSelected] = useState4(() => initialSelectedPath ?? null);
2488
+ const [editMode, setEditMode] = useState4(false);
2489
+ const [focusLine, setFocusLine] = useState4(null);
2490
+ const [treeRevealRequest, setTreeRevealRequest] = useState4(null);
2491
+ const [liveRequestedPath, setLiveRequestedPath] = useState4(null);
2492
+ const [viewReloadRevision, setViewReloadRevision] = useState4(0);
2493
+ const viewerScrollRef = useRef3(null);
2494
+ const pendingRequestRef = useRef3(null);
2495
+ const handledRequestRef = useRef3(null);
2496
+ const requestKey = requestedPath ? requestedPathRequestId ?? requestedPath : null;
2497
+ useEffect5(() => {
2498
+ if (!requestedPath || requestKey === null) {
2499
+ pendingRequestRef.current = null;
2500
+ handledRequestRef.current = null;
2501
+ setTreeRevealRequest(null);
2502
+ return;
2503
+ }
2504
+ if (handledRequestRef.current === requestKey) {
2505
+ return;
2506
+ }
2507
+ if (!requestedPathReady) {
2508
+ pendingRequestRef.current = requestKey;
2509
+ setTreeRevealRequest(null);
2510
+ return;
2511
+ }
2512
+ if (isNodeVisible && files.loading && files.tree.length === 0) return;
2513
+ if (isNodeVisible && !files.loading && files.tree.length === 0) {
2514
+ handledRequestRef.current = requestKey;
2515
+ pendingRequestRef.current = null;
2516
+ setTreeRevealRequest(null);
2517
+ return;
2518
+ }
2519
+ if (filePathVisibility(files.tree, requestedPath, isNodeVisible) === "hidden") {
2520
+ handledRequestRef.current = requestKey;
2521
+ pendingRequestRef.current = null;
2522
+ setTreeRevealRequest(null);
2523
+ return;
2524
+ }
2525
+ handledRequestRef.current = requestKey;
2526
+ pendingRequestRef.current = null;
2527
+ setSelected(requestedPath);
2528
+ onSelectedPathChange?.(requestedPath);
2529
+ setEditMode(false);
2530
+ setFocusLine(requestedLine != null && requestedLine > 0 ? requestedLine : null);
2531
+ setTreeRevealRequest({ path: requestedPath, requestId: requestKey });
2532
+ setViewReloadRevision((revision) => revision + 1);
2533
+ }, [
2534
+ files.loading,
2535
+ files.tree,
2536
+ isNodeVisible,
2537
+ onSelectedPathChange,
2538
+ requestKey,
2539
+ requestedLine,
2540
+ requestedPath,
2541
+ requestedPathReady
2542
+ ]);
2543
+ const rootRef = useRef3(null);
2544
+ const [wide, setWide] = useState4(false);
2545
+ useEffect5(() => {
2546
+ const el = rootRef.current;
2547
+ if (!el) return;
2548
+ const update = () => setWide(el.getBoundingClientRect().width >= 720);
2549
+ update();
2550
+ if (typeof ResizeObserver === "undefined") return;
2551
+ const observer = new ResizeObserver(update);
2552
+ observer.observe(el);
2553
+ const surface = el.closest("[data-workspace-surface]");
2554
+ const surfaceObserver = surface && typeof MutationObserver !== "undefined" ? new MutationObserver(update) : null;
2555
+ surfaceObserver?.observe(surface, {
2556
+ attributes: true,
2557
+ attributeFilter: ["class", "style"]
2558
+ });
2559
+ return () => {
2560
+ observer.disconnect();
2561
+ surfaceObserver?.disconnect();
2562
+ };
2563
+ }, []);
2564
+ const resolvedTheme = useThemeType(themeType);
2565
+ const selectedVisibility = selected ? filePathVisibility(files.tree, selected, isNodeVisible) : "unknown";
2566
+ const visibilityPending = Boolean(isNodeVisible && files.loading && files.tree.length === 0);
2567
+ const viewPath = selectedVisibility === "hidden" || visibilityPending ? null : selected;
2568
+ useEffect5(() => {
2569
+ if (selected === null || selectedVisibility !== "hidden") return;
2570
+ setSelected(null);
2571
+ onSelectedPathChange?.(null);
2572
+ setEditMode(false);
2573
+ setFocusLine(null);
2574
+ setTreeRevealRequest(null);
2575
+ setLiveRequestedPath(null);
2576
+ }, [onSelectedPathChange, selected, selectedVisibility]);
2577
+ const fileView = useFileView(
2578
+ viewPath,
2579
+ files.readFile,
2580
+ `${files.contentRevision ?? 0}:${viewReloadRevision}`
2581
+ );
2582
+ useEffect5(() => {
2583
+ if (focusLine === null && viewReloadRevision > 0 && viewerScrollRef.current) {
2584
+ viewerScrollRef.current.scrollTop = 0;
2585
+ }
2586
+ }, [focusLine, viewReloadRevision]);
2587
+ const selectFile = useCallback3(
2588
+ (path) => {
2589
+ if (pendingRequestRef.current !== null) {
2590
+ handledRequestRef.current = pendingRequestRef.current;
2591
+ pendingRequestRef.current = null;
2592
+ }
2593
+ setSelected(path);
2594
+ onSelectedPathChange?.(path);
2595
+ setEditMode(false);
2596
+ setFocusLine(null);
2597
+ setTreeRevealRequest(null);
2598
+ setLiveRequestedPath(null);
2599
+ setViewReloadRevision(0);
2600
+ },
2601
+ [onSelectedPathChange]
2602
+ );
2603
+ const canEdit = editable && viewPath !== null && !fileView.loading && fileView.error === null && !fileView.isBinary && !fileView.truncated && fileView.content !== null;
2604
+ const showEditor = canEdit && editMode;
2605
+ const captureFileUnavailable = fileView.error instanceof CapturedFileUnavailableError ? fileView.error : null;
2606
+ const waitingForSelectedFile = !workspaceError && liveRequestedPath === viewPath && (!liveWorkspaceReady || files.loading) && captureFileUnavailable !== null;
2607
+ if (workspaceError && !liveWorkspaceReady && files.source !== "capture") {
2608
+ return /* @__PURE__ */ jsxs2(
2609
+ Notice,
2610
+ {
2611
+ className,
2612
+ title: t("sandboxFiles.couldNotOpenLiveWorkspace"),
2613
+ announce: "alert",
2614
+ children: [
2615
+ /* @__PURE__ */ jsx3("p", { children: workspaceError.message }),
2616
+ onWakeWorkspace ? /* @__PURE__ */ jsx3(WakeButton, { onClick: onWakeWorkspace, children: t("sandboxFiles.retryLiveWorkspace") }) : null
2617
+ ]
2618
+ }
2619
+ );
2620
+ }
2621
+ if (workspaceResting || workspaceWaking) {
2622
+ return /* @__PURE__ */ jsx3("div", { className: cn("h-full", className), "data-opengeni-workspace-resting": true, children: /* @__PURE__ */ jsxs2(
2623
+ Notice,
2624
+ {
2625
+ icon: workspaceWaking ? /* @__PURE__ */ jsx3(
2626
+ LoaderCircleIcon,
2627
+ {
2628
+ className: "size-5 animate-spin motion-reduce:animate-none",
2629
+ "aria-hidden": true
2630
+ }
2631
+ ) : /* @__PURE__ */ jsx3(FileCode2Icon, { className: "size-5", "aria-hidden": true }),
2632
+ title: workspaceWaking ? t("sandboxFiles.wakingWorkspace") : t("sandboxFiles.workspaceIsResting"),
2633
+ announce: "status",
2634
+ children: [
2635
+ /* @__PURE__ */ jsx3("p", { children: workspaceWaking ? t("sandboxFiles.connectingToTheLiveFile") : t("sandboxFiles.noCapturedRevisionIsAvailable") }),
2636
+ !workspaceWaking && onWakeWorkspace ? /* @__PURE__ */ jsx3(WakeButton, { onClick: onWakeWorkspace, children: t("sandboxFiles.openLiveWorkspace") }) : null
2637
+ ]
2638
+ }
2639
+ ) });
2640
+ }
2641
+ if (!fileSystemAvailable) {
2642
+ return /* @__PURE__ */ jsx3(
2643
+ Notice,
2644
+ {
2645
+ className,
2646
+ icon: /* @__PURE__ */ jsx3(FileWarningIcon, { className: "size-5", "aria-hidden": true }),
2647
+ title: t("sandboxFiles.filesUnavailable"),
2648
+ announce: "alert",
2649
+ children: t("sandboxFiles.thisSandboxDoesNotExpose")
2650
+ }
2651
+ );
2652
+ }
2653
+ return /* @__PURE__ */ jsxs2("div", { ref: rootRef, className: cn("flex h-full min-h-0 min-w-0 flex-col", className), children: [
2654
+ /* @__PURE__ */ jsx3(
2655
+ GitHeader,
2656
+ {
2657
+ loading: Boolean(files.loading || files.gitLoading || files.source === null || git?.loading) && files.gitSummary === null,
2658
+ git: files.gitSummary ?? {
2659
+ branch: git?.branch ?? null,
2660
+ isRepo: git?.isRepo ?? false,
2661
+ repoCount: git?.repoCount ?? 0,
2662
+ ahead: git?.ahead ?? 0,
2663
+ behind: git?.behind ?? 0,
2664
+ dirtyCount: git?.diff.length ?? 0
2665
+ }
2666
+ }
2667
+ ),
2668
+ /* @__PURE__ */ jsxs2(
2669
+ Group,
2670
+ {
2671
+ orientation: wide ? "horizontal" : "vertical",
2672
+ className: cn("min-h-0 flex-1", wide ? "flex-row" : "flex-col"),
2673
+ children: [
2674
+ /* @__PURE__ */ jsx3(
2675
+ Panel,
2676
+ {
2677
+ id: "sandbox-files-tree",
2678
+ defaultSize: wide ? "280px" : "40%",
2679
+ minSize: wide ? "180px" : "120px",
2680
+ maxSize: wide ? "60%" : "70%",
2681
+ className: "flex min-h-0 min-w-0 flex-col",
2682
+ children: /* @__PURE__ */ jsx3(
2683
+ FileBrowser,
2684
+ {
2685
+ result: files,
2686
+ isNodeVisible,
2687
+ selectedPath: selected ?? void 0,
2688
+ ...treeRevealRequest ? {
2689
+ revealPath: treeRevealRequest.path,
2690
+ revealPathRequestId: treeRevealRequest.requestId
2691
+ } : {},
2692
+ onSelectFile: selectFile,
2693
+ editable,
2694
+ emptyState: t("sandboxFiles.thisDirectoryIsEmpty"),
2695
+ className: "min-w-0 flex-1"
2696
+ }
2697
+ )
2698
+ }
2699
+ ),
2700
+ /* @__PURE__ */ jsx3(
2701
+ Separator,
2702
+ {
2703
+ "aria-label": t("sandboxFiles.resizeFileTree"),
2704
+ className: cn(
2705
+ "group relative z-10 shrink-0 cursor-col-resize outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-og-accent",
2706
+ "w-px bg-og-border after:absolute after:inset-y-0 after:left-1/2 after:w-3 after:-translate-x-1/2",
2707
+ "hover:bg-og-accent focus-visible:bg-og-accent data-[separator-state=dragging]:bg-og-accent",
2708
+ !wide && "h-px w-full cursor-row-resize after:inset-x-0 after:inset-y-auto after:top-1/2 after:h-3 after:w-full after:-translate-x-0 after:-translate-y-1/2"
2709
+ )
2710
+ }
2711
+ ),
2712
+ /* @__PURE__ */ jsxs2(
2713
+ Panel,
2714
+ {
2715
+ id: "sandbox-files-viewer",
2716
+ minSize: wide ? "240px" : "160px",
2717
+ className: cn("flex min-h-0 min-w-0 flex-col", !wide && "border-t border-og-border"),
2718
+ children: [
2719
+ /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center justify-between gap-2 border-b border-og-border bg-og-surface-1 px-2 py-1", children: [
2720
+ /* @__PURE__ */ jsx3(
2721
+ "span",
2722
+ {
2723
+ "data-opengeni-selected-file": true,
2724
+ className: "min-w-0 truncate font-og-mono text-og-xs text-og-fg-muted",
2725
+ children: selected ? focusLine !== null ? `${selected}:${focusLine}` : selected : t("sandboxFiles.noFileSelected")
2726
+ }
2727
+ ),
2728
+ canEdit && /* @__PURE__ */ jsx3(
2729
+ Segmented,
2730
+ {
2731
+ options: [
2732
+ { value: "view", label: t("sandboxFiles.view") },
2733
+ { value: "edit", label: t("sandboxFiles.edit") }
2734
+ ],
2735
+ value: editMode ? "edit" : "view",
2736
+ onChange: (v) => setEditMode(v === "edit")
2737
+ }
2738
+ )
2739
+ ] }),
2740
+ /* @__PURE__ */ jsx3(
2741
+ "div",
2742
+ {
2743
+ ref: viewerScrollRef,
2744
+ className: "min-h-0 flex-1 overflow-auto",
2745
+ "data-opengeni-file-viewer-scroll": true,
2746
+ children: viewPath ? showEditor && fileView.content !== null ? /* @__PURE__ */ jsx3(
2747
+ CodeEditor,
2748
+ {
2749
+ path: viewPath,
2750
+ initialContents: fileView.content,
2751
+ themeType: resolvedTheme,
2752
+ onSave: (contents, expectedContents) => files.writeFile(viewPath, contents, { expectedContent: expectedContents }),
2753
+ onOverwrite: (contents) => files.writeFile(viewPath, contents, { force: true }),
2754
+ onReload: () => setViewReloadRevision((revision) => revision + 1),
2755
+ ...onEditIntent ? { onEditIntent } : {},
2756
+ className: "h-full"
2757
+ },
2758
+ viewPath
2759
+ ) : workspaceError && (liveRequestedPath === viewPath || requestedPath === viewPath) && !liveWorkspaceReady ? /* @__PURE__ */ jsxs2(Notice, { title: t("sandboxFiles.couldNotOpenLiveFile"), announce: "alert", children: [
2760
+ /* @__PURE__ */ jsx3("p", { children: workspaceError.message }),
2761
+ onWakeWorkspace ? /* @__PURE__ */ jsx3(WakeButton, { onClick: onWakeWorkspace, children: t("sandboxFiles.retryLiveFile") }) : null
2762
+ ] }) : waitingForSelectedFile ? /* @__PURE__ */ jsx3(
2763
+ Notice,
2764
+ {
2765
+ icon: /* @__PURE__ */ jsx3(
2766
+ LoaderCircleIcon,
2767
+ {
2768
+ className: "size-5 animate-spin motion-reduce:animate-none",
2769
+ "aria-hidden": true
2770
+ }
2771
+ ),
2772
+ title: t("sandboxFiles.wakingWorkspace"),
2773
+ announce: "status",
2774
+ children: t("sandboxFiles.openingViewpathWhenTheLive", { viewPath })
2775
+ }
2776
+ ) : captureFileUnavailable ? /* @__PURE__ */ jsxs2(
2777
+ Notice,
2778
+ {
2779
+ icon: /* @__PURE__ */ jsx3(FileCode2Icon, { className: "size-5", "aria-hidden": true }),
2780
+ title: t("sandboxFiles.onMachine"),
2781
+ children: [
2782
+ /* @__PURE__ */ jsx3("p", { children: captureFileUnavailable.reason === "too-large" ? t("sandboxFiles.thisFileIsLargerThan") : captureFileUnavailable.reason === "content-missing" ? t("sandboxFiles.theCapturedCopyIsNo") : t("sandboxFiles.thisFileWasIndexedBut") }),
2783
+ onWakeWorkspace ? /* @__PURE__ */ jsx3(
2784
+ WakeButton,
2785
+ {
2786
+ onClick: () => {
2787
+ setLiveRequestedPath(viewPath);
2788
+ if (liveWorkspaceReady) void files.refresh();
2789
+ else onWakeWorkspace();
2790
+ },
2791
+ children: liveWorkspaceReady ? t("sandboxFiles.retryLiveFile") : t("sandboxFiles.openLiveFile")
2792
+ }
2793
+ ) : null
2794
+ ]
2795
+ }
2796
+ ) : fileView.error ? /* @__PURE__ */ jsx3(Notice, { announce: "alert", children: t("sandboxFiles.couldNotOpenViewpathMessage", {
2797
+ viewPath,
2798
+ message: fileView.error.message
2799
+ }) }) : fileView.loading ? /* @__PURE__ */ jsx3(Notice, { announce: "status", children: t("sandboxFiles.loadingViewpath", { viewPath }) }) : fileView.imageUrl ? /* @__PURE__ */ jsx3(
2800
+ RasterFilePreview,
2801
+ {
2802
+ src: fileView.imageUrl,
2803
+ path: viewPath
2804
+ },
2805
+ fileView.imageUrl
2806
+ ) : fileView.isBinary ? /* @__PURE__ */ jsxs2(Notice, { children: [
2807
+ t("sandboxFiles.viewpathIsABinaryFile", { viewPath }),
2808
+ fileView.sizeBytes ?? 0,
2809
+ " ",
2810
+ t("sandboxFiles.bytes")
2811
+ ] }) : fileView.content !== null ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
2812
+ fileView.truncated && /* @__PURE__ */ jsxs2("div", { className: "border-b border-og-border bg-og-surface-1 px-2 py-1 text-og-xs text-og-status-running", children: [
2813
+ t("sandboxFiles.largeFileShowingATruncated"),
2814
+ fileView.sizeBytes ?? 0,
2815
+ " ",
2816
+ t("sandboxFiles.bytesLoadedEditingIsDisabled")
2817
+ ] }),
2818
+ usePierre && focusLine === null ? /* @__PURE__ */ jsx3(
2819
+ PierreFile,
2820
+ {
2821
+ path: viewPath,
2822
+ contents: fileView.content,
2823
+ themeType: resolvedTheme,
2824
+ fallback: /* @__PURE__ */ jsx3("pre", { className: "overflow-auto whitespace-pre p-2 font-og-mono text-og-sm text-og-fg", children: fileView.content }),
2825
+ className: "p-1"
2826
+ },
2827
+ `${viewPath}:${viewReloadRevision}`
2828
+ ) : focusLine !== null ? /* @__PURE__ */ jsx3(
2829
+ LineNumberedFile,
2830
+ {
2831
+ path: viewPath,
2832
+ contents: fileView.content,
2833
+ focusLine
2834
+ }
2835
+ ) : /* @__PURE__ */ jsx3("pre", { className: "overflow-auto whitespace-pre p-2 font-og-mono text-og-sm text-og-fg", children: fileView.content })
2836
+ ] }) : /* @__PURE__ */ jsx3(Notice, { announce: "status", children: t("sandboxFiles.loadingViewpath", { viewPath }) }) : (
2837
+ // Nothing selected — the tree shows the whole workspace; pick a file.
2838
+ requestedPath && !requestedPathReady ? workspaceError ? /* @__PURE__ */ jsxs2(Notice, { title: t("sandboxFiles.couldNotOpenLiveFile"), announce: "alert", children: [
2839
+ /* @__PURE__ */ jsx3("p", { children: workspaceError.message }),
2840
+ onWakeWorkspace ? /* @__PURE__ */ jsx3(WakeButton, { onClick: onWakeWorkspace, children: t("sandboxFiles.retryLiveFile") }) : null
2841
+ ] }) : /* @__PURE__ */ jsx3(
2842
+ Notice,
2843
+ {
2844
+ icon: /* @__PURE__ */ jsx3(
2845
+ LoaderCircleIcon,
2846
+ {
2847
+ className: "size-5 animate-spin motion-reduce:animate-none",
2848
+ "aria-hidden": true
2849
+ }
2850
+ ),
2851
+ title: t("sandboxFiles.wakingSandbox"),
2852
+ announce: "status",
2853
+ children: t("sandboxFiles.openingRequestedpathWhenTheLive", { requestedPath })
2854
+ }
2855
+ ) : /* @__PURE__ */ jsx3(
2856
+ Notice,
2857
+ {
2858
+ icon: /* @__PURE__ */ jsx3(FileCode2Icon, { className: "size-5", "aria-hidden": true }),
2859
+ title: t("sandboxFiles.chooseAFile"),
2860
+ children: t("sandboxFiles.selectAFileInThe")
2861
+ }
2862
+ )
2863
+ )
2864
+ }
2865
+ )
2866
+ ]
2867
+ }
2868
+ )
2869
+ ]
2870
+ }
2871
+ )
2872
+ ] });
2873
+ }
2874
+ function WakeButton({ children, onClick }) {
2875
+ return /* @__PURE__ */ jsx3(
2876
+ "button",
2877
+ {
2878
+ type: "button",
2879
+ onClick,
2880
+ className: "mt-1 inline-flex min-h-11 items-center justify-center rounded-og-md border border-og-primary-border bg-og-primary text-og-primary-fg px-3 py-2 text-og-sm font-medium transition-colors hover:bg-og-primary-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent focus-visible:ring-offset-2 focus-visible:ring-offset-og-bg",
2881
+ children
2882
+ }
2883
+ );
2884
+ }
2885
+ function LineNumberedFile({
2886
+ path,
2887
+ contents,
2888
+ focusLine
2889
+ }) {
2890
+ const t = useOpenGeniText();
2891
+ const lines = contents.split("\n");
2892
+ const inRange = focusLine >= 1 && focusLine <= lines.length;
2893
+ const targetRef = useRef3(null);
2894
+ useEffect5(() => {
2895
+ targetRef.current?.scrollIntoView({
2896
+ block: "center",
2897
+ behavior: prefersReducedMotion() ? "auto" : "smooth"
2898
+ });
2899
+ }, [path, focusLine, contents]);
2900
+ return /* @__PURE__ */ jsxs2(
2901
+ "div",
2902
+ {
2903
+ className: "h-full min-h-0 overflow-auto font-og-mono text-og-sm text-og-fg",
2904
+ role: "region",
2905
+ "aria-label": inRange ? t("sandboxFiles.pathAtLineFocusline", { path, focusLine }) : path,
2906
+ children: [
2907
+ !inRange ? /* @__PURE__ */ jsx3(
2908
+ "p",
2909
+ {
2910
+ className: "border-b border-og-border bg-og-surface-1 px-2 py-1 text-og-xs text-og-fg-muted",
2911
+ role: "status",
2912
+ children: t("sandboxFiles.lineFocuslineIsPastThe", { focusLine })
2913
+ }
2914
+ ) : null,
2915
+ /* @__PURE__ */ jsx3("div", { children: lines.map((text, index) => {
2916
+ const lineNumber = index + 1;
2917
+ const focused = inRange && lineNumber === focusLine;
2918
+ return /* @__PURE__ */ jsxs2(
2919
+ "div",
2920
+ {
2921
+ ref: focused ? targetRef : void 0,
2922
+ "data-opengeni-file-line": lineNumber,
2923
+ ...focused ? { "data-opengeni-focus-line": "" } : {},
2924
+ "aria-current": focused ? "location" : void 0,
2925
+ className: cn("flex gap-3 px-2 py-0.5 leading-6", focused && "bg-og-accent-soft"),
2926
+ children: [
2927
+ /* @__PURE__ */ jsx3("span", { className: "w-11 shrink-0 select-none text-right tabular-nums text-og-fg-subtle", children: lineNumber }),
2928
+ /* @__PURE__ */ jsx3("pre", { className: "min-w-0 flex-1 whitespace-pre-wrap break-words", children: text || " " })
2929
+ ]
2930
+ },
2931
+ lineNumber
2932
+ );
2933
+ }) })
2934
+ ]
2935
+ }
2936
+ );
2937
+ }
2938
+ function GitHeader({ git, loading }) {
2939
+ const t = useOpenGeniText();
2940
+ if (loading) {
2941
+ return /* @__PURE__ */ jsxs2(
2942
+ "div",
2943
+ {
2944
+ className: "flex shrink-0 items-center gap-2 border-b border-og-border bg-og-surface-1 px-2 py-1 text-og-sm text-og-fg-muted",
2945
+ role: "status",
2946
+ "aria-live": "polite",
2947
+ children: [
2948
+ /* @__PURE__ */ jsx3(
2949
+ LoaderCircleIcon,
2950
+ {
2951
+ className: "size-3.5 shrink-0 animate-spin motion-reduce:animate-none",
2952
+ "aria-hidden": true
2953
+ }
2954
+ ),
2955
+ /* @__PURE__ */ jsx3("span", { children: t("sandboxFiles.loadingRepository") })
2956
+ ]
2957
+ }
2958
+ );
2959
+ }
2960
+ const dirty = git.dirtyCount > 0;
2961
+ return /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2 border-b border-og-border bg-og-surface-1 px-2 py-1 text-og-sm", children: [
2962
+ /* @__PURE__ */ jsx3(
2963
+ "span",
2964
+ {
2965
+ "aria-hidden": "true",
2966
+ className: cn(
2967
+ "size-2 shrink-0 rounded-full",
2968
+ dirty ? "bg-og-status-running" : "bg-og-status-idle"
2969
+ )
2970
+ }
2971
+ ),
2972
+ /* @__PURE__ */ jsx3("span", { className: "sr-only", children: dirty ? t("sandboxFiles.uncommittedChangesInDirtycountFiles", { dirtyCount: git.dirtyCount }) : t("sandboxFiles.noUncommittedChanges") }),
2973
+ /* @__PURE__ */ jsx3("span", { className: "truncate font-og-mono text-og-fg", children: git.repoCount > 1 ? t("sandboxFiles.repocountRepositories", { repoCount: git.repoCount }) : git.branch ?? (git.isRepo ? t("sandboxFiles.detached") : t("sandboxFiles.noRepo")) }),
2974
+ (git.ahead > 0 || git.behind > 0) && /* @__PURE__ */ jsxs2("span", { className: "flex shrink-0 items-center gap-1.5 text-og-xs text-og-fg-subtle", children: [
2975
+ git.ahead > 0 && /* @__PURE__ */ jsxs2("span", { "data-contrast-audited": true, children: [
2976
+ "\u2191",
2977
+ git.ahead
2978
+ ] }),
2979
+ git.behind > 0 && /* @__PURE__ */ jsxs2("span", { "data-contrast-audited": true, children: [
2980
+ "\u2193",
2981
+ git.behind
2982
+ ] })
2983
+ ] }),
2984
+ dirty && /* @__PURE__ */ jsx3(
2985
+ "span",
2986
+ {
2987
+ "aria-hidden": "true",
2988
+ "data-contrast-audited": true,
2989
+ className: "ml-auto shrink-0 text-og-xs text-og-fg-subtle",
2990
+ children: t("sandboxFiles.dirtycountChanged", { dirtyCount: git.dirtyCount })
2991
+ }
2992
+ )
2993
+ ] });
2994
+ }
2995
+ function Segmented({
2996
+ options,
2997
+ value,
2998
+ onChange
2999
+ }) {
3000
+ return /* @__PURE__ */ jsx3("div", { className: "flex flex-wrap items-center rounded-og-sm border border-og-border p-0.5", children: options.map((opt) => /* @__PURE__ */ jsx3(
3001
+ "button",
3002
+ {
3003
+ type: "button",
3004
+ onClick: () => onChange(opt.value),
3005
+ className: cn(
3006
+ "min-h-7 rounded-og-xs px-1.5 py-0.5 text-og-xs focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent max-[1023px]:min-h-11 max-[1023px]:min-w-11 pointer-coarse:min-h-11 pointer-coarse:min-w-11",
3007
+ opt.value === value ? "bg-og-accent-soft text-og-fg" : "text-og-fg-subtle hover:text-og-fg"
3008
+ ),
3009
+ children: opt.label
3010
+ },
3011
+ opt.value
3012
+ )) });
3013
+ }
3014
+ function useFileView(path, readFile, reloadRevision = 0) {
3015
+ const previousPathRef = useRef3(null);
3016
+ const [state, setState] = useState4({
3017
+ content: null,
3018
+ isBinary: false,
3019
+ truncated: false,
3020
+ sizeBytes: null,
3021
+ loading: false,
3022
+ error: null
3023
+ });
3024
+ useEffect5(() => {
3025
+ if (!path) {
3026
+ previousPathRef.current = null;
3027
+ setState({
3028
+ content: null,
3029
+ isBinary: false,
3030
+ truncated: false,
3031
+ sizeBytes: null,
3032
+ loading: false,
3033
+ error: null
3034
+ });
3035
+ return;
3036
+ }
3037
+ const pathChanged = previousPathRef.current !== path;
3038
+ previousPathRef.current = path;
3039
+ let cancelled = false;
3040
+ const abort = new AbortController();
3041
+ if (pathChanged) {
3042
+ setState({
3043
+ content: null,
3044
+ isBinary: false,
3045
+ truncated: false,
3046
+ sizeBytes: null,
3047
+ loading: true,
3048
+ error: null
3049
+ });
3050
+ } else {
3051
+ setState((previous) => ({ ...previous, error: null }));
3052
+ }
3053
+ void readFile(path, { signal: abort.signal }).then((res) => {
3054
+ if (cancelled) return;
3055
+ const content = res.isBinary ? null : res.encoding === "base64" ? decodeBase64Utf8(res.content) : res.content;
3056
+ setState({
3057
+ content,
3058
+ imageUrl: !res.truncated && res.encoding === "base64" ? rasterImageUrl(path, res.content) : null,
3059
+ isBinary: res.isBinary,
3060
+ truncated: res.truncated,
3061
+ sizeBytes: res.sizeBytes,
3062
+ loading: false,
3063
+ error: null
3064
+ });
3065
+ }).catch((cause) => {
3066
+ if (cancelled) return;
3067
+ const error = cause instanceof Error ? cause : new Error(String(cause));
3068
+ setState(
3069
+ (previous) => pathChanged ? {
3070
+ content: null,
3071
+ isBinary: false,
3072
+ truncated: false,
3073
+ sizeBytes: null,
3074
+ loading: false,
3075
+ error
3076
+ } : { ...previous, loading: false, error }
3077
+ );
3078
+ });
3079
+ return () => {
3080
+ cancelled = true;
3081
+ abort.abort();
3082
+ };
3083
+ }, [path, readFile, reloadRevision]);
3084
+ return state;
3085
+ }
3086
+ function rasterImageUrl(path, content) {
3087
+ const extension = path.split(".").pop()?.toLowerCase();
3088
+ const mime = extension === "png" ? "image/png" : extension === "jpg" || extension === "jpeg" ? "image/jpeg" : extension === "gif" ? "image/gif" : extension === "webp" ? "image/webp" : null;
3089
+ return mime ? `data:${mime};base64,${content}` : null;
3090
+ }
3091
+ function RasterFilePreview({ src, path }) {
3092
+ const t = useOpenGeniText();
3093
+ const [failed, setFailed] = useState4(false);
3094
+ return failed ? /* @__PURE__ */ jsx3(Notice, { title: t("sandboxFiles.imagePreviewUnavailable"), announce: "alert", children: t("sandboxFiles.couldNotDecodePathAs", { path }) }) : /* @__PURE__ */ jsx3(
3095
+ "img",
3096
+ {
3097
+ src,
3098
+ alt: path,
3099
+ onError: () => setFailed(true),
3100
+ className: "max-w-full object-contain"
3101
+ }
3102
+ );
3103
+ }
3104
+ function decodeBase64Utf8(b64) {
3105
+ try {
3106
+ if (typeof atob === "function") {
3107
+ const binary = atob(b64);
3108
+ const bytes = new Uint8Array(binary.length);
3109
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
3110
+ return new TextDecoder().decode(bytes);
3111
+ }
3112
+ } catch {
3113
+ }
3114
+ return b64;
3115
+ }
3116
+ function Notice({
3117
+ children,
3118
+ className,
3119
+ icon,
3120
+ title,
3121
+ announce
3122
+ }) {
3123
+ return /* @__PURE__ */ jsx3(
3124
+ "div",
3125
+ {
3126
+ role: announce,
3127
+ "aria-atomic": announce ? "true" : void 0,
3128
+ "aria-live": announce === "alert" ? "assertive" : announce === "status" ? "polite" : void 0,
3129
+ className: cn(
3130
+ "flex h-full items-center justify-center p-4 text-center text-og-sm text-og-fg-subtle",
3131
+ className
3132
+ ),
3133
+ children: /* @__PURE__ */ jsxs2("div", { className: "flex max-w-sm flex-col items-center gap-2.5", children: [
3134
+ icon ? /* @__PURE__ */ jsx3("span", { className: "grid size-10 place-items-center rounded-og-lg border border-og-border bg-og-surface-1 text-og-fg-muted shadow-sm", children: icon }) : null,
3135
+ title ? /* @__PURE__ */ jsx3("p", { className: "font-medium text-og-fg", children: title }) : null,
3136
+ /* @__PURE__ */ jsx3("div", { "data-contrast-audited": true, className: "leading-5", children })
3137
+ ] })
3138
+ }
3139
+ );
3140
+ }
3141
+
3142
+ export {
3143
+ visibleFileTree,
3144
+ filePathVisibility,
3145
+ CapturedFileUnavailableError,
3146
+ FileWriteConflictError,
3147
+ useSandboxFiles,
3148
+ useUnicodeFallbackFonts,
3149
+ FileBrowser,
3150
+ PierreFile,
3151
+ SandboxFiles
3152
+ };
3153
+ //# sourceMappingURL=chunk-7TG6KTR2.js.map