@vantran-se/openchamber-web 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/README.md +32 -24
  2. package/bin/cli.js +1 -3
  3. package/bin/cli.test.js +40 -16
  4. package/bin/lib/DOCUMENTATION.md +6 -5
  5. package/bin/lib/cli-args.js +6 -1
  6. package/bin/lib/cli-args.test.js +34 -0
  7. package/bin/lib/cli-lifecycle.js +0 -1
  8. package/bin/lib/cli-network.js +8 -2
  9. package/bin/lib/cli-process.js +1 -1
  10. package/bin/lib/cli-settings-accessors.test.js +21 -13
  11. package/bin/lib/cli-startup.js +17 -11
  12. package/bin/lib/cli-startup.test.js +92 -2
  13. package/bin/lib/commands-connect-url.js +8 -1
  14. package/bin/lib/commands-schedule.js +8 -2
  15. package/bin/lib/commands-serve.js +15 -21
  16. package/bin/lib/commands-update.js +12 -24
  17. package/bin/lib/commands-update.test.js +14 -46
  18. package/dist/assets/DiffView-Cv9MSXl1.js +4 -0
  19. package/dist/assets/FilePreviewCommentMenu-D4kLseHj.js +4 -0
  20. package/dist/assets/FilesView-BVoD8I2x.js +14 -0
  21. package/dist/assets/{GitView-DzuzhIPx.js → GitView-Bzb8p-ew.js} +4 -4
  22. package/dist/assets/GuestSurfacePane-Crdbvsxo.js +1 -0
  23. package/dist/assets/InProgressOperationBanner-CwMjNQgk.js +2 -0
  24. package/dist/assets/{JsonTreeView-B_EPRjzy.js → JsonTreeView-DRKHZfsn.js} +1 -1
  25. package/dist/assets/MarkdownImageGallery-DZtqT1Zn.js +1 -0
  26. package/dist/assets/MarkdownRendererImpl-CqG7HCNd.js +10 -0
  27. package/dist/assets/OnboardingScreen-DMIxwYK5.js +1 -0
  28. package/dist/assets/{PatchDiff-6yh1csza.js → PatchDiff-CUcCg1jk.js} +1 -1
  29. package/dist/assets/PierreDiffViewer-CnnR-dnD.js +228 -0
  30. package/dist/assets/PlanView-RCBadcY7.js +5 -0
  31. package/dist/assets/SettingsView-CjBjZFRO.js +30 -0
  32. package/dist/assets/SettingsWindow-DyM7QuhI.js +1 -0
  33. package/dist/assets/SubmoduleDiffSummary-BWIfgMED.js +1 -0
  34. package/dist/assets/ToolOutputDialog-Q0P3FuAi.js +15 -0
  35. package/dist/assets/ToolPartDiffPreview-p7qR9FpU.js +8 -0
  36. package/dist/assets/{VirtualizedFileDiff-BTJVRkyo.js → VirtualizedFileDiff-CFpjL8Ns.js} +3 -3
  37. package/dist/assets/{Virtualizer-xCEYz34p.js → Virtualizer-C0IsclZn.js} +1 -1
  38. package/dist/assets/WalkthroughView-DI31zD02.js +4 -0
  39. package/dist/assets/appThemeRegistry-B9gkFq9i.js +1 -0
  40. package/dist/assets/{computeVirtualFileMetrics-CmPe29DM.js → computeVirtualFileMetrics-C2WM6JC2.js} +2 -2
  41. package/dist/assets/de-YKfk5MmC.js +14 -0
  42. package/dist/assets/es-_gwT0kr-.js +20 -0
  43. package/dist/assets/fileTreeStatus-D438yi8M.js +1 -0
  44. package/dist/assets/fr-DqzvXmIm.js +18 -0
  45. package/dist/assets/index-BLaHKdtx.js +1 -0
  46. package/dist/assets/index-BkMXRrVQ.css +1 -0
  47. package/dist/assets/index-DxNa7xYB.js +65 -0
  48. package/dist/assets/initializeSharedPreferences-Bck5EAWP.js +1 -0
  49. package/dist/assets/{isDiffPlainText-CQmDCnEv.js → isDiffPlainText-Dgbw8VKk.js} +1 -1
  50. package/dist/assets/{isFilePlainText-CYBUzW4I.js → isFilePlainText-_ZS5UYRj.js} +1 -1
  51. package/dist/assets/ja-B-GFYhQE.js +20 -0
  52. package/dist/assets/ko-mzksfqDC.js +20 -0
  53. package/dist/assets/main-C5Xx8dn_.js +2 -0
  54. package/dist/assets/main-CfBSQM1H.js +990 -0
  55. package/dist/assets/markdownCore-BmWwW1ll.js +7 -0
  56. package/dist/assets/miniChat-mnKwy4vQ.js +2 -0
  57. package/dist/assets/mobile-DeEQd0wZ.js +2 -0
  58. package/dist/assets/nl-CWQr6NSq.js +20 -0
  59. package/dist/assets/{parseDiffFromFile-Cy0PNxun.js → parseDiffFromFile-BUgn-T9p.js} +2 -2
  60. package/dist/assets/patchFileDiff-Dt8LhgBh.js +13 -0
  61. package/dist/assets/pl-UmRcDUX2.js +20 -0
  62. package/dist/assets/pt-BR-BSLybvVF.js +20 -0
  63. package/dist/assets/relocateRestoredSession-B5E9xb3T.js +1 -0
  64. package/dist/assets/renderElectronMiniChatApp-C0a9A5_J.js +2 -0
  65. package/dist/assets/renderMobileApp-BNncg3Pk.js +25 -0
  66. package/dist/assets/runtimeEndpointReset-CZ5aafpl.js +62 -0
  67. package/dist/assets/{selectionMarkdown-TkYk5h9l.js → selectionMarkdown-CUN3wUld.js} +9 -9
  68. package/dist/assets/{sessionOwnership-Bs1xbRfB.js → sessionOwnership-BSuxCEhb.js} +1 -1
  69. package/dist/assets/shikiHighlight-DHDx-6eM.js +1 -0
  70. package/dist/assets/space-apply-DM_2pRW7.js +1 -0
  71. package/dist/assets/space-close-Bpomt8z0.js +1 -0
  72. package/dist/assets/{surface-B6n7wJtt.js → surface-C-jQaGnL.js} +1 -1
  73. package/dist/assets/{textMateThemeFromAppTheme-CDlKffWz.js → textMateThemeFromAppTheme-DlsTphbY.js} +1 -1
  74. package/dist/assets/tr-gaTrX_HK.js +11 -0
  75. package/dist/assets/uk-CnJF6ykl.js +20 -0
  76. package/dist/assets/{useAppFontEffects-DCqCVGlT.js → useAppFontEffects-DGlvOqP_.js} +194 -233
  77. package/dist/assets/useInlineCommentController-kMN4Wg_D.js +2 -0
  78. package/dist/assets/{useRootScrollLock-BowwS8kq.js → useRootScrollLock-DMPpvpNP.js} +2 -2
  79. package/dist/assets/{vendor-base-ui-DX96QhTP.js → vendor-base-ui-Det7U81h.js} +1 -1
  80. package/dist/assets/{vendor-codemirror-autocomplete-DW1FQz9_.js → vendor-codemirror-autocomplete-BSHQHbKu.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-commands-DpmhalwN.js → vendor-codemirror-commands-C4G_dPWe.js} +1 -1
  82. package/dist/assets/{vendor-codemirror-lang-angular-BqExbN1M.js → vendor-codemirror-lang-angular-B6LbBGHB.js} +1 -1
  83. package/dist/assets/{vendor-codemirror-lang-cpp-DZA36HfS.js → vendor-codemirror-lang-cpp-BWWXBx7W.js} +1 -1
  84. package/dist/assets/{vendor-codemirror-lang-css-B07blnnZ.js → vendor-codemirror-lang-css-Cayfb29q.js} +1 -1
  85. package/dist/assets/{vendor-codemirror-lang-go-BM8K9D1-.js → vendor-codemirror-lang-go-BoKlCNKw.js} +1 -1
  86. package/dist/assets/{vendor-codemirror-lang-html-DaH9adfE.js → vendor-codemirror-lang-html-BQWerHsJ.js} +1 -1
  87. package/dist/assets/{vendor-codemirror-lang-java-CsdC0viz.js → vendor-codemirror-lang-java-DWX7Fq_K.js} +1 -1
  88. package/dist/assets/{vendor-codemirror-lang-javascript-CpGYXGuo.js → vendor-codemirror-lang-javascript-DbpEcZM0.js} +2 -2
  89. package/dist/assets/{vendor-codemirror-lang-jinja-BBeGzXw5.js → vendor-codemirror-lang-jinja-D1JIJRA7.js} +1 -1
  90. package/dist/assets/{vendor-codemirror-lang-json-58T70Hqs.js → vendor-codemirror-lang-json-BzgckzmB.js} +1 -1
  91. package/dist/assets/{vendor-codemirror-lang-less-BI-xCA59.js → vendor-codemirror-lang-less-B9EpDXFi.js} +1 -1
  92. package/dist/assets/{vendor-codemirror-lang-liquid-zEcMa-zy.js → vendor-codemirror-lang-liquid-9U7kRbSf.js} +1 -1
  93. package/dist/assets/{vendor-codemirror-lang-markdown-BLKnlLP4.js → vendor-codemirror-lang-markdown-D2TEBIvZ.js} +1 -1
  94. package/dist/assets/{vendor-codemirror-lang-php-9f35M83-.js → vendor-codemirror-lang-php-BT6sDVzE.js} +1 -1
  95. package/dist/assets/vendor-codemirror-lang-python-jAMtYiA9.js +3 -0
  96. package/dist/assets/{vendor-codemirror-lang-rust-MNDL_jZQ.js → vendor-codemirror-lang-rust-CVO56EiL.js} +1 -1
  97. package/dist/assets/{vendor-codemirror-lang-sass-p9epsSNm.js → vendor-codemirror-lang-sass-DZlOoUWu.js} +1 -1
  98. package/dist/assets/{vendor-codemirror-lang-sql-Bqzh0EXX.js → vendor-codemirror-lang-sql-fZ6t1DPw.js} +1 -1
  99. package/dist/assets/{vendor-codemirror-lang-vue-BnNUWV-p.js → vendor-codemirror-lang-vue-DxbqrLiE.js} +1 -1
  100. package/dist/assets/{vendor-codemirror-lang-wast-C2a-oLmk.js → vendor-codemirror-lang-wast-DyU1Gt-I.js} +1 -1
  101. package/dist/assets/vendor-codemirror-lang-xml-C9a_K5_p.js +1 -0
  102. package/dist/assets/{vendor-codemirror-lang-yaml-C0sjswB0.js → vendor-codemirror-lang-yaml-Cptq8l0e.js} +1 -1
  103. package/dist/assets/{vendor-codemirror-language-ByBn5zIW.js → vendor-codemirror-language-DufXoQvE.js} +2 -2
  104. package/dist/assets/vendor-codemirror-language-data-CtwSWKtX.js +2 -0
  105. package/dist/assets/{vendor-codemirror-search-ib-sHD5W.js → vendor-codemirror-search-CvXM_pZg.js} +1 -1
  106. package/dist/assets/{vendor-codemirror-state-G3UuR-be.js → vendor-codemirror-state-Dek9sMtw.js} +1 -1
  107. package/dist/assets/{vendor-codemirror-view-Bniqp7p5.js → vendor-codemirror-view-1e0FQ6Wn.js} +1 -1
  108. package/dist/assets/vendor-framer-motion-DxDVhOLc.js +9 -0
  109. package/dist/assets/vendor-katex-CuQvj9-L.js +257 -0
  110. package/dist/assets/vendor-katex-DdZNUVNG.css +1 -0
  111. package/dist/assets/{vendor-motion-dom-DcCgeG69.js → vendor-motion-dom-HXPOMxb7.js} +1 -1
  112. package/dist/assets/{vendor-opencode-client-DHzhmLwV.js → vendor-opencode-client-BmFcUkbQ.js} +1 -1
  113. package/dist/assets/{vendor-replit-codemirror-vim-DkzqxN2H.js → vendor-replit-codemirror-vim-BlJRn-cW.js} +2 -2
  114. package/dist/assets/{vendor-tanstack-react-virtual-H_JmXOFV.js → vendor-tanstack-react-virtual-CvuLsk7D.js} +1 -1
  115. package/dist/assets/{vendor-tanstack-virtual-core-Dxc8hSTB.js → vendor-tanstack-virtual-core-DPaNcJcT.js} +1 -1
  116. package/dist/assets/zh-CN-t2vigSB1.js +20 -0
  117. package/dist/assets/zh-TW-jAgqBokB.js +20 -0
  118. package/dist/index.html +6 -6
  119. package/dist/mini-chat.html +6 -6
  120. package/dist/mobile.html +6 -6
  121. package/package.json +8 -5
  122. package/server/index.js +80 -36
  123. package/server/lib/agent-memory/actions.js +1 -6
  124. package/server/lib/agent-memory/routes.js +1 -2
  125. package/server/lib/agent-memory/runtime.js +1 -8
  126. package/server/lib/agent-tool/DOCUMENTATION.md +7 -3
  127. package/server/lib/agent-tool/runtime.js +3 -6
  128. package/server/lib/agent-tool/runtime.test.js +0 -2
  129. package/server/lib/browser-control/DOCUMENTATION.md +6 -0
  130. package/server/lib/changelog/update-notes.js +1 -1
  131. package/server/lib/context-obligatory/runtime.js +1 -2
  132. package/server/lib/dev-tunnel/DOCUMENTATION.md +8 -0
  133. package/server/lib/dev-tunnel/client.js +21 -10
  134. package/server/lib/dev-tunnel/tunnel.test.js +34 -0
  135. package/server/lib/dispatch-results/runtime.js +1 -1
  136. package/server/lib/enterprise-mode.d.ts +1 -0
  137. package/server/lib/enterprise-mode.js +13 -2
  138. package/server/lib/enterprise-mode.test.js +21 -0
  139. package/server/lib/event-stream/DOCUMENTATION.md +2 -2
  140. package/server/lib/event-stream/index.js +1 -3
  141. package/server/lib/event-stream/translate-v2.js +1 -9
  142. package/server/lib/event-stream/translate-v2.test.js +0 -11
  143. package/server/lib/fs/DOCUMENTATION.md +5 -2
  144. package/server/lib/fs/routes.js +62 -15
  145. package/server/lib/fs/routes.test.js +278 -48
  146. package/server/lib/fs/workspace-file-names.js +104 -0
  147. package/server/lib/fs/workspace-file-names.test.js +62 -0
  148. package/server/lib/git/DOCUMENTATION.md +17 -5
  149. package/server/lib/git/contributor-provenance-storage.js +9 -6
  150. package/server/lib/git/contributor-provenance-storage.test.js +29 -0
  151. package/server/lib/git/credential-broker.js +1 -1
  152. package/server/lib/git/credential-resolver.js +1 -4
  153. package/server/lib/git/credentials.js +1 -0
  154. package/server/lib/git/discovery-endpoint.js +1 -1
  155. package/server/lib/git/identity-provisioning.js +2 -1
  156. package/server/lib/git/identity-storage.js +3 -4
  157. package/server/lib/git/lfs-discovery.js +14 -14
  158. package/server/lib/git/lfs-discovery.test.js +16 -6
  159. package/server/lib/git/network-operation-plan.js +50 -62
  160. package/server/lib/git/network-operation-plan.test.js +103 -1
  161. package/server/lib/git/network-operation-registry.js +4 -6
  162. package/server/lib/git/network-operation-storage.js +4 -6
  163. package/server/lib/git/network-operations.js +12 -4
  164. package/server/lib/git/network-operations.test.js +19 -6
  165. package/server/lib/git/redaction.js +2 -1
  166. package/server/lib/git/repository-credential-runtime.js +5 -3
  167. package/server/lib/git/repository-credential-runtime.test.js +22 -0
  168. package/server/lib/git/routes.js +31 -137
  169. package/server/lib/git/routes.test.js +2 -2
  170. package/server/lib/git/service.js +143 -27
  171. package/server/lib/git/service.test.js +215 -1
  172. package/server/lib/git/ssh-credential-storage.js +1 -4
  173. package/server/lib/git/submodule-discovery.js +1 -1
  174. package/server/lib/git/worktree-bootstrap-storage.js +3 -4
  175. package/server/lib/git/worktree-bootstrap-storage.test.js +15 -0
  176. package/server/lib/git/worktree-creation.js +194 -0
  177. package/server/lib/git/worktree-creation.test.js +155 -0
  178. package/server/lib/github/DOCUMENTATION.md +11 -6
  179. package/server/lib/github/auth.js +2 -4
  180. package/server/lib/github/device-flow.js +2 -2
  181. package/server/lib/github/gh-cli-credential.js +1 -0
  182. package/server/lib/github/octokit.js +31 -0
  183. package/server/lib/github/pr-status.js +35 -18
  184. package/server/lib/github/pr-status.test.js +271 -3
  185. package/server/lib/github/reference-search.js +102 -13
  186. package/server/lib/github/reference-search.test.js +48 -7
  187. package/server/lib/github/routes.auth.test.js +18 -0
  188. package/server/lib/github/routes.js +360 -6
  189. package/server/lib/github/routes.mutations.test.js +239 -0
  190. package/server/lib/github/routes.test.js +134 -2
  191. package/server/lib/gitlab/DOCUMENTATION.md +5 -1
  192. package/server/lib/gitlab/auth-storage.test.js +1 -0
  193. package/server/lib/gitlab/mappers.js +30 -1
  194. package/server/lib/gitlab/resources.js +230 -6
  195. package/server/lib/gitlab/resources.test.js +179 -0
  196. package/server/lib/gitlab/routes.js +200 -6
  197. package/server/lib/gitlab/routes.test.js +186 -2
  198. package/server/lib/gitlab/validation.js +1 -5
  199. package/server/lib/guests/DOCUMENTATION.md +1 -1
  200. package/server/lib/guests/oauth.js +2 -2
  201. package/server/lib/guests/service.js +1 -1
  202. package/server/lib/guests/sockets.js +1 -1
  203. package/server/lib/injected-env.d.ts +8 -0
  204. package/server/lib/injected-env.js +50 -0
  205. package/server/lib/injected-env.test.js +56 -0
  206. package/server/lib/linear/DOCUMENTATION.md +5 -6
  207. package/server/lib/linear/issues.js +62 -4
  208. package/server/lib/linear/issues.test.js +68 -0
  209. package/server/lib/linear/oauth.js +5 -5
  210. package/server/lib/linear/parse.js +2 -9
  211. package/server/lib/message-queue/DOCUMENTATION.md +23 -1
  212. package/server/lib/message-queue/runtime.js +85 -12
  213. package/server/lib/message-queue/runtime.test.js +172 -2
  214. package/server/lib/notifications/apns-runtime.js +5 -6
  215. package/server/lib/notifications/apns-runtime.test.js +20 -4
  216. package/server/lib/openchamber-control/DOCUMENTATION.md +19 -1
  217. package/server/lib/openchamber-control/actions.js +2 -1
  218. package/server/lib/openchamber-control/service.js +119 -20
  219. package/server/lib/openchamber-control/service.test.js +166 -0
  220. package/server/lib/openchamber-sessions/archive-store.js +1 -6
  221. package/server/lib/openchamber-sessions/routes.js +47 -12
  222. package/server/lib/openchamber-sessions/routes.test.js +65 -2
  223. package/server/lib/openchamber-sessions/session-metadata-store.js +1 -6
  224. package/server/lib/opencode/DOCUMENTATION.md +22 -8
  225. package/server/lib/opencode/agents.js +62 -0
  226. package/server/lib/opencode/auth-state-runtime.js +3 -1
  227. package/server/lib/opencode/auth.d.ts +1 -1
  228. package/server/lib/opencode/auth.js +8 -0
  229. package/server/lib/opencode/auth.test.js +31 -0
  230. package/server/lib/opencode/config-entity-routes.js +16 -0
  231. package/server/lib/opencode/config-entity-v2.test.js +16 -1
  232. package/server/lib/opencode/config-paths.test.js +2 -2
  233. package/server/lib/opencode/config-v2.js +2 -4
  234. package/server/lib/opencode/feature-routes-runtime.js +89 -49
  235. package/server/lib/opencode/lifecycle.js +41 -21
  236. package/server/lib/opencode/lifecycle.test.js +50 -2
  237. package/server/lib/opencode/model-discovery.js +1 -1
  238. package/server/lib/opencode/model-discovery.test.js +17 -0
  239. package/server/lib/opencode/models-metadata.js +0 -2
  240. package/server/lib/opencode/openchamber-routes.test.js +3 -3
  241. package/server/lib/opencode/plugins.js +6 -9
  242. package/server/lib/opencode/provider-source-route.test.js +101 -3
  243. package/server/lib/opencode/providers-disabled.test.js +59 -0
  244. package/server/lib/opencode/providers.js +34 -0
  245. package/server/lib/opencode/proxy.js +11 -3
  246. package/server/lib/opencode/routes.js +40 -2
  247. package/server/lib/opencode/settings-helpers.js +27 -1
  248. package/server/lib/opencode/settings-helpers.test.js +19 -7
  249. package/server/lib/opencode/settings-registry.json +27 -16
  250. package/server/lib/opencode/settings-runtime.test.js +18 -0
  251. package/server/lib/opencode/shared-service-runtime.js +23 -104
  252. package/server/lib/opencode/shared.js +77 -46
  253. package/server/lib/opencode/shared.test.js +12 -12
  254. package/server/lib/opencode/shutdown-runtime.test.js +2 -3
  255. package/server/lib/opencode/skill-routes.js +123 -38
  256. package/server/lib/opencode/skill-routes.test.js +201 -0
  257. package/server/lib/opencode/skills.js +81 -34
  258. package/server/lib/opencode/skills.test.js +176 -21
  259. package/server/lib/opencode/startup-pipeline-runtime.js +6 -3
  260. package/server/lib/opencode/startup-pipeline-runtime.test.js +2 -1
  261. package/server/lib/opencode/watcher.test.js +0 -54
  262. package/server/lib/outbound-proxy.js +52 -0
  263. package/server/lib/outbound-proxy.test.js +55 -0
  264. package/server/lib/package-manager.js +23 -17
  265. package/server/lib/package-manager.test.js +5 -18
  266. package/server/lib/permission-auto-accept/DOCUMENTATION.md +1 -1
  267. package/server/lib/permission-auto-accept/runtime.js +19 -47
  268. package/server/lib/permission-auto-accept/runtime.test.js +2 -2
  269. package/server/lib/project-context/DOCUMENTATION.md +7 -1
  270. package/server/lib/project-context/routes.js +1 -2
  271. package/server/lib/project-context/runtime.js +12 -14
  272. package/server/lib/project-context/runtime.test.js +78 -2
  273. package/server/lib/projects/project-config.js +30 -15
  274. package/server/lib/projects/project-config.test.js +30 -0
  275. package/server/lib/projects/project-setup.js +1 -2
  276. package/server/lib/projects/routes.js +1 -2
  277. package/server/lib/quota/DOCUMENTATION.md +35 -7
  278. package/server/lib/quota/index.js +1 -0
  279. package/server/lib/quota/providers/claude/index.js +1 -1
  280. package/server/lib/quota/providers/cline-pass.js +1 -1
  281. package/server/lib/quota/providers/exe-dev.js +1 -1
  282. package/server/lib/quota/providers/google/index.js +1 -1
  283. package/server/lib/quota/providers/hyper.js +1 -1
  284. package/server/lib/quota/providers/kimi.js +116 -36
  285. package/server/lib/quota/providers/kimi.test.js +128 -3
  286. package/server/lib/quota/providers/opencode-go.js +144 -21
  287. package/server/lib/quota/providers/opencode-go.test.js +229 -6
  288. package/server/lib/quota/providers/openrouter.js +1 -1
  289. package/server/lib/quota/providers/zenmux.js +1 -1
  290. package/server/lib/quota/utils/auth.js +1 -0
  291. package/server/lib/quota/utils/transformers.js +2 -6
  292. package/server/lib/relay/DOCUMENTATION.md +18 -3
  293. package/server/lib/relay/e2ee.js +7 -7
  294. package/server/lib/relay/host-client.js +84 -13
  295. package/server/lib/relay/host-client.test.js +201 -1
  296. package/server/lib/relay/identity.js +6 -29
  297. package/server/lib/relay/identity.test.js +18 -28
  298. package/server/lib/relay/key-store.js +141 -0
  299. package/server/lib/relay/key-store.test.js +138 -0
  300. package/server/lib/relay/service.js +8 -8
  301. package/server/lib/relay/service.test.js +10 -5
  302. package/server/lib/relay/signing-key.js +13 -36
  303. package/server/lib/relay/tunnel-codec.js +10 -10
  304. package/server/lib/route-module-exports.test.js +22 -0
  305. package/server/lib/routing/DOCUMENTATION.md +23 -3
  306. package/server/lib/routing/cache.js +87 -0
  307. package/server/lib/routing/defaults.js +11 -0
  308. package/server/lib/routing/history.js +12 -4
  309. package/server/lib/routing/runtime.js +39 -3
  310. package/server/lib/routing/runtime.test.js +81 -2
  311. package/server/lib/routing/store.js +12 -1
  312. package/server/lib/routing/store.test.js +13 -0
  313. package/server/lib/scheduled-tasks/DOCUMENTATION.md +59 -1
  314. package/server/lib/scheduled-tasks/existing-session.js +119 -0
  315. package/server/lib/scheduled-tasks/existing-session.test.js +350 -0
  316. package/server/lib/scheduled-tasks/loops.js +1 -8
  317. package/server/lib/scheduled-tasks/routes.js +8 -8
  318. package/server/lib/scheduled-tasks/runtime.js +103 -13
  319. package/server/lib/scheduled-tasks/runtime.test.js +48 -0
  320. package/server/lib/scheduled-tasks/service.js +33 -11
  321. package/server/lib/scheduled-tasks/service.test.js +128 -2
  322. package/server/lib/scheduled-tasks/session-defaults.js +27 -0
  323. package/server/lib/scheduled-tasks/session-defaults.test.js +19 -0
  324. package/server/lib/session-assist/context.js +1 -0
  325. package/server/lib/session-folders/routes.js +2 -2
  326. package/server/lib/session-goal/objectives.js +1 -1
  327. package/server/lib/session-knowledge/routes.js +2 -2
  328. package/server/lib/session-knowledge/runtime.js +1 -2
  329. package/server/lib/session-work/DOCUMENTATION.md +39 -14
  330. package/server/lib/session-work/questions.js +31 -2
  331. package/server/lib/session-work/runtime.js +22 -13
  332. package/server/lib/session-work/runtime.test.js +43 -26
  333. package/server/lib/session-work/state.js +10 -4
  334. package/server/lib/session-work/state.test.js +8 -1
  335. package/server/lib/shared/DOCUMENTATION.md +89 -0
  336. package/server/lib/shared/guards.js +53 -0
  337. package/server/lib/shared/guards.test.js +112 -0
  338. package/server/lib/skills-catalog/DOCUMENTATION.md +10 -8
  339. package/server/lib/skills-catalog/cache.js +3 -2
  340. package/server/lib/skills-catalog/curated-sources.js +5 -1
  341. package/server/lib/skills-catalog/git.js +107 -20
  342. package/server/lib/skills-catalog/git.test.js +78 -0
  343. package/server/lib/skills-catalog/install.js +21 -12
  344. package/server/lib/skills-catalog/scan.js +25 -15
  345. package/server/lib/skills-catalog/source.js +26 -1
  346. package/server/lib/skills-catalog/source.test.js +27 -0
  347. package/server/lib/source-control/DOCUMENTATION.md +2 -1
  348. package/server/lib/source-control/audit-storage.js +7 -6
  349. package/server/lib/source-control/audit-storage.test.js +11 -0
  350. package/server/lib/source-control/binding-service.js +2 -5
  351. package/server/lib/source-control/change-request-worktree.js +90 -0
  352. package/server/lib/source-control/change-request-worktree.test.js +121 -0
  353. package/server/lib/source-control/mutation-executor.js +1 -1
  354. package/server/lib/source-control/mutation-storage.js +11 -5
  355. package/server/lib/source-control/provider-instance.js +1 -2
  356. package/server/lib/source-control/repository-identity.js +1 -1
  357. package/server/lib/source-control/routes.js +14 -2
  358. package/server/lib/spaces/DOCUMENTATION.md +42 -17
  359. package/server/lib/spaces/command-stream.test.js +15 -0
  360. package/server/lib/spaces/dispatcher.js +7 -0
  361. package/server/lib/spaces/dispatcher.test.js +17 -0
  362. package/server/lib/spaces/hardening.js +2 -2
  363. package/server/lib/spaces/hardening.test.js +1 -1
  364. package/server/lib/spaces/host.js +2 -0
  365. package/server/lib/spaces/journey.js +66 -5
  366. package/server/lib/spaces/journey.test.js +95 -4
  367. package/server/lib/spaces/layout.js +1 -1
  368. package/server/lib/spaces/places/docker-disk.js +38 -14
  369. package/server/lib/spaces/places/docker-disk.test.js +80 -1
  370. package/server/lib/spaces/places/docker.js +35 -11
  371. package/server/lib/spaces/places/fake-docker.js +22 -3
  372. package/server/lib/spaces/places/memory-place.js +3 -0
  373. package/server/lib/spaces/places/packed.docker.live.test.js +1 -1
  374. package/server/lib/spaces/routes.js +5 -0
  375. package/server/lib/spaces/routes.test.js +4 -2
  376. package/server/lib/spaces/run-command.js +9 -2
  377. package/server/lib/spaces/tools.js +4 -5
  378. package/server/lib/spaces/tools.test.js +2 -2
  379. package/server/lib/terminal/runtime.js +18 -6
  380. package/server/lib/terminal/runtime.test.js +66 -0
  381. package/server/lib/tts/index.js +3 -0
  382. package/server/lib/tts/service.js +4 -2
  383. package/server/lib/walkthrough/DOCUMENTATION.md +3 -1
  384. package/server/lib/walkthrough/index.js +2 -3
  385. package/server/lib/walkthrough/pr-source.test.js +22 -0
  386. package/server/lib/walkthrough/sources.js +6 -1
  387. package/server/opencode-proxy.test.js +127 -0
  388. package/bin/lib/commands-startup.test.js +0 -15
  389. package/dist/assets/CodeMirrorCommentWidgets-CVDSjcrP.js +0 -1
  390. package/dist/assets/DiffView-Ct7vL3fD.js +0 -4
  391. package/dist/assets/FilesView-DT0uEYgT.js +0 -17
  392. package/dist/assets/GuestSurfacePane-DVvk1VPu.js +0 -1
  393. package/dist/assets/LinearIssuesView-C10MwA9h.js +0 -1
  394. package/dist/assets/MarkdownImageGallery-BbN_K_3d.js +0 -1
  395. package/dist/assets/MarkdownRendererImpl-BLt2Tkk9.js +0 -10
  396. package/dist/assets/OnboardingScreen-Bgp5A3WB.js +0 -1
  397. package/dist/assets/PierreDiffViewer-CWJLj-S-.js +0 -210
  398. package/dist/assets/PlanView-DsRWnsOI.js +0 -5
  399. package/dist/assets/PublishDialog-CCeKloRu.js +0 -2
  400. package/dist/assets/SettingsView-BuPPsNPp.js +0 -30
  401. package/dist/assets/SettingsWindow-CM5fL8Ot.js +0 -1
  402. package/dist/assets/SubmoduleDiffSummary-CfsMcfiQ.js +0 -1
  403. package/dist/assets/ToolOutputDialog-mZrfSofz.js +0 -15
  404. package/dist/assets/ToolPartDiffPreview-BUGCRYEL.js +0 -8
  405. package/dist/assets/WalkthroughView-ClBo7PPd.js +0 -4
  406. package/dist/assets/appThemeRegistry-CxzMxR-H.js +0 -1
  407. package/dist/assets/de-CBla4hjd.js +0 -14
  408. package/dist/assets/es-BmnZtxTD.js +0 -20
  409. package/dist/assets/fileTreeStatus-BSHFIGEg.js +0 -1
  410. package/dist/assets/fr-OVKIBUZO.js +0 -18
  411. package/dist/assets/index-CKCFKmjF.js +0 -1
  412. package/dist/assets/index-Dbx4V4GN.css +0 -1
  413. package/dist/assets/index-vQ1Pg1cr.js +0 -61
  414. package/dist/assets/ja-6v-yr-gE.js +0 -20
  415. package/dist/assets/ko-I_ZLvgQ9.js +0 -20
  416. package/dist/assets/main-CmO4dRtR.js +0 -2
  417. package/dist/assets/main-b9vqhlYM.js +0 -999
  418. package/dist/assets/markdownCore-BPEZRQfP.js +0 -7
  419. package/dist/assets/miniChat-B5Oi7B-6.js +0 -2
  420. package/dist/assets/mobile-CVtShif9.js +0 -2
  421. package/dist/assets/nl-DcvIJf46.js +0 -20
  422. package/dist/assets/patchFileDiff-CW3wCH1O.js +0 -13
  423. package/dist/assets/pl-JxCUl0sd.js +0 -20
  424. package/dist/assets/pt-BR-L89mjja2.js +0 -20
  425. package/dist/assets/relocateRestoredSession-DYh_9oBa.js +0 -1
  426. package/dist/assets/renderElectronMiniChatApp-BD-1JHSg.js +0 -2
  427. package/dist/assets/renderMobileApp-7s5InXt1.js +0 -25
  428. package/dist/assets/runtimeEndpointReset-DqLJC6L1.js +0 -53
  429. package/dist/assets/shikiHighlight-CXgZnvHh.js +0 -1
  430. package/dist/assets/space-apply-1trGVIl8.js +0 -1
  431. package/dist/assets/space-close-y7j-NuBv.js +0 -1
  432. package/dist/assets/tr-ka5J1flt.js +0 -11
  433. package/dist/assets/uk-PyGe6Q_u.js +0 -20
  434. package/dist/assets/useInlineCommentController-CrjSGCpi.js +0 -2
  435. package/dist/assets/vendor-codemirror-lang-python-B7ClrMIT.js +0 -3
  436. package/dist/assets/vendor-codemirror-lang-xml-C8tGnS64.js +0 -1
  437. package/dist/assets/vendor-codemirror-language-data-q2bKO1EM.js +0 -2
  438. package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +0 -1
  439. package/dist/assets/vendor-katex-CHD9BdDO.js +0 -257
  440. package/dist/assets/vendor-katex-Cp579UoJ.css +0 -1
  441. package/dist/assets/zh-CN-B0P2tybJ.js +0 -20
  442. package/dist/assets/zh-TW-Bs9C5cN8.js +0 -20
@@ -173,8 +173,14 @@ async function scheduleCommand(options = {}, action = 'help') {
173
173
 
174
174
  if (action === 'enable' || action === 'disable') {
175
175
  const taskID = assertRequired(options.task, '--task');
176
- const enabled = action === 'enable';
177
- const { task } = await requestControlAction(port, 'schedule.toggle', { ...target, taskId: taskID, disabled: !enabled }, options);
176
+ const requested = action === 'enable';
177
+ const body = await requestControlAction(port, 'schedule.toggle', { ...target, taskId: taskID, disabled: !requested }, options);
178
+ // Report what the server saved, never what was asked for.
179
+ const task = body?.task;
180
+ const enabled = body?.enabled === true;
181
+ if (enabled !== requested) {
182
+ throw new TunnelCliError(`${task?.name || taskID} is still ${enabled ? 'enabled' : 'disabled'}.`, EXIT_CODE.GENERAL_ERROR);
183
+ }
178
184
  if (isJsonMode(options)) {
179
185
  printJson({ task, enabled });
180
186
  return;
@@ -10,6 +10,7 @@ import { rotateLogFile } from './cli-log-files.js';
10
10
  import { discoverOpenChamberInstanceOnPort, isDesktopRuntimeForPort } from './cli-lifecycle.js';
11
11
  import { getPidFilePath, getInstanceFilePath, writePidFile, writeInstanceOptions, removePidFile, removeInstanceFile, isProcessRunning, terminateProcessTree } from './cli-process.js';
12
12
  import { isNetworkExposedBindHost } from '../../server/lib/security/bind-host.js';
13
+ import { assignInjectedEnv } from '../../server/lib/injected-env.js';
13
14
  import {
14
15
  intro as clackIntro,
15
16
  outro as clackOutro,
@@ -155,14 +156,16 @@ async function serveCommand(options) {
155
156
  }
156
157
 
157
158
  // Propagate resolved values into env before importing the server module.
159
+ // The binary path is left unmarked: a startup service enabled from this
160
+ // server's terminal wants the same OpenCode.
158
161
  if (opencodeBinary) {
159
162
  process.env.OPENCODE_BINARY = opencodeBinary;
160
163
  }
161
- if (effectiveUiPassword) {
162
- process.env.OPENCHAMBER_UI_PASSWORD = effectiveUiPassword;
163
- }
164
- process.env.OPENCHAMBER_HOST = effectiveHost;
165
- process.env.OPENCHAMBER_RUNTIME = 'web';
164
+ assignInjectedEnv(process.env, {
165
+ OPENCHAMBER_UI_PASSWORD: effectiveUiPassword || undefined,
166
+ OPENCHAMBER_HOST: effectiveHost,
167
+ OPENCHAMBER_RUNTIME: 'web',
168
+ });
166
169
 
167
170
  // In --quiet mode, redirect stdout/stderr to the log file so that
168
171
  // server runtime output (console.log calls) does not pollute the
@@ -280,16 +283,16 @@ async function serveCommand(options) {
280
283
  detached: true,
281
284
  windowsHide: true,
282
285
  stdio: ['ignore', logFd, logFd, 'ipc'],
283
- env: {
284
- ...process.env,
286
+ // Same marking as the foreground path above: the server's own settings
287
+ // are recorded as OpenChamber's, the binary path is not.
288
+ env: assignInjectedEnv({ ...process.env, OPENCODE_BINARY: opencodeBinary }, {
285
289
  OPENCHAMBER_PORT: String(targetPort),
286
290
  OPENCHAMBER_RUNTIME: 'web',
287
- OPENCODE_BINARY: opencodeBinary,
288
291
  OPENCHAMBER_HOST: effectiveHost,
289
- ...(effectiveUiPassword ? { OPENCHAMBER_UI_PASSWORD: effectiveUiPassword } : {}),
290
- ...(options.apiOnly === true ? { OPENCHAMBER_API_ONLY: 'true' } : {}),
291
- ...(process.env.OPENCODE_SKIP_START ? { OPENCHAMBER_SKIP_OPENCODE_START: process.env.OPENCODE_SKIP_START } : {}),
292
- },
292
+ OPENCHAMBER_UI_PASSWORD: effectiveUiPassword || undefined,
293
+ OPENCHAMBER_API_ONLY: options.apiOnly === true ? 'true' : undefined,
294
+ OPENCHAMBER_SKIP_OPENCODE_START: process.env.OPENCODE_SKIP_START || undefined,
295
+ }),
293
296
  });
294
297
 
295
298
  child.unref();
@@ -311,15 +314,6 @@ async function serveCommand(options) {
311
314
  settled = true;
312
315
  clearTimeout(timeout);
313
316
  resolve(msg.port);
314
- return;
315
- }
316
- if (msg && msg.type === 'openchamber:error') {
317
- settled = true;
318
- clearTimeout(timeout);
319
- const error = new Error(msg.message || 'OpenChamber failed to start');
320
- if (msg.code) error.code = msg.code;
321
- if (msg.url) error.url = msg.url;
322
- reject(error);
323
317
  }
324
318
  });
325
319
 
@@ -1,6 +1,6 @@
1
1
  import { requestServerShutdown } from './cli-http.js';
2
- import { discoverRunningInstances as discoverRunningInstancesDefault } from './cli-lifecycle.js';
3
- import { getStartupStatus as getStartupStatusDefault, restartStartupService as restartStartupServiceDefault } from './cli-startup.js';
2
+ import { discoverRunningInstances } from './cli-lifecycle.js';
3
+ import { getStartupStatus, restartStartupService } from './cli-startup.js';
4
4
  import {
5
5
  readInstanceOptions,
6
6
  removePidFile,
@@ -17,27 +17,18 @@ import {
17
17
  logStatus,
18
18
  } from '../cli-output.js';
19
19
 
20
- export function partitionUpdateInstances(instances, readOptions = readInstanceOptions, startupStatus = null) {
20
+ export function partitionUpdateInstances(instances, readOptions = readInstanceOptions) {
21
21
  const managed = [];
22
- const startup = [];
23
22
  const foreground = [];
24
23
  for (const instance of instances) {
25
24
  const options = readOptions(instance.instanceFilePath) || {};
26
- if (options.launchMode !== 'foreground') managed.push(instance);
27
- else if (startupStatus?.enabled && startupStatus.port === instance.port && instance.startupService === true) startup.push(instance);
28
- else foreground.push(instance);
25
+ if (options.launchMode === 'foreground') foreground.push(instance);
26
+ else managed.push(instance);
29
27
  }
30
- return { managed, startup, foreground };
28
+ return { managed, foreground };
31
29
  }
32
30
 
33
- function createUpdateCommand({
34
- importFromFilePath,
35
- packageManagerPath,
36
- serveCommand,
37
- discoverRunningInstances = discoverRunningInstancesDefault,
38
- getStartupStatus = getStartupStatusDefault,
39
- restartStartupService = restartStartupServiceDefault,
40
- }) {
31
+ function createUpdateCommand({ importFromFilePath, packageManagerPath, serveCommand, getStartupStatus: readStartupStatus = getStartupStatus, restartStartupService: restartService = restartStartupService }) {
41
32
  return async function updateCommand(options = {}) {
42
33
  const showOutput = shouldRenderHumanOutput(options);
43
34
  const updateSpin = createSpinner(options);
@@ -50,12 +41,9 @@ function createUpdateCommand({
50
41
  } = await importFromFilePath(packageManagerPath);
51
42
 
52
43
  const runningInstances = await discoverRunningInstances();
53
- const startupStatus = getStartupStatus();
54
- const { managed: managedInstances, startup: startupInstances } = partitionUpdateInstances(
55
- runningInstances,
56
- readInstanceOptions,
57
- startupStatus,
58
- );
44
+ const startupStatus = readStartupStatus();
45
+ const startupInstances = runningInstances.filter((instance) => startupStatus.enabled && startupStatus.port === instance.port);
46
+ const { managed: managedInstances } = partitionUpdateInstances(runningInstances.filter((instance) => !startupInstances.includes(instance)));
59
47
  const currentVersion = getCurrentVersion();
60
48
 
61
49
  if (showOutput) {
@@ -133,7 +121,7 @@ function createUpdateCommand({
133
121
 
134
122
  if (startupInstances.length > 0) {
135
123
  updateSpin?.message('Restarting startup service...');
136
- restartStartupService();
124
+ restartService();
137
125
  }
138
126
 
139
127
  if (managedInstances.length > 0) {
@@ -161,7 +149,7 @@ function createUpdateCommand({
161
149
  currentVersion,
162
150
  latestVersion: updateInfo.version || 'latest',
163
151
  updated: true,
164
- restartedCount: runningInstances.length,
152
+ restartedCount: startupInstances.length + managedInstances.length,
165
153
  });
166
154
  return;
167
155
  }
@@ -12,60 +12,26 @@ async function withTempOpenChamberDataDir(fn) {
12
12
  try {
13
13
  return await fn(dir);
14
14
  } finally {
15
- if (previous === undefined) delete process.env.OPENCHAMBER_DATA_DIR;
16
- else process.env.OPENCHAMBER_DATA_DIR = previous;
15
+ if (typeof previous === 'string') {
16
+ process.env.OPENCHAMBER_DATA_DIR = previous;
17
+ } else {
18
+ delete process.env.OPENCHAMBER_DATA_DIR;
19
+ }
17
20
  fs.rmSync(dir, { recursive: true, force: true });
18
21
  }
19
22
  }
20
23
 
21
24
  describe('update command', () => {
22
- it('separates CLI daemons from the installed startup service', () => {
25
+ it('leaves foreground service-manager instances running', () => {
23
26
  const daemon = { port: 3000, instanceFilePath: '/daemon.json' };
24
- const startup = { port: 3069, instanceFilePath: '/startup.json', startupService: true };
25
- const manualForeground = { port: 3070, instanceFilePath: '/manual.json' };
26
- const readOptions = vi.fn((filePath) => ({
27
- launchMode: filePath === daemon.instanceFilePath ? 'daemon' : 'foreground',
28
- }));
27
+ const foreground = { port: 3069, instanceFilePath: '/foreground.json' };
28
+ const readOptions = vi.fn((filePath) => (
29
+ filePath === foreground.instanceFilePath ? { launchMode: 'foreground' } : { launchMode: 'daemon' }
30
+ ));
29
31
 
30
- expect(partitionUpdateInstances(
31
- [daemon, startup, manualForeground],
32
- readOptions,
33
- { enabled: true, active: true, port: 3069 },
34
- )).toEqual({
32
+ expect(partitionUpdateInstances([daemon, foreground], readOptions)).toEqual({
35
33
  managed: [daemon],
36
- startup: [startup],
37
- foreground: [manualForeground],
38
- });
39
- });
40
-
41
- it('restarts the installed startup service after updating', async () => {
42
- await withTempOpenChamberDataDir(async (dir) => {
43
- const originalWrite = process.stdout.write;
44
- process.stdout.write = vi.fn(() => true);
45
- const instanceFilePath = path.join(dir, 'run', 'openchamber-3069.json');
46
- fs.mkdirSync(path.dirname(instanceFilePath), { recursive: true });
47
- fs.writeFileSync(instanceFilePath, JSON.stringify({ port: 3069, launchMode: 'foreground' }));
48
- const restartStartupService = vi.fn();
49
- const updateCommand = createUpdateCommand({
50
- packageManagerPath: '/fake/package-manager.js',
51
- serveCommand: vi.fn(),
52
- discoverRunningInstances: vi.fn(async () => [{ port: 3069, instanceFilePath, startupService: true }]),
53
- getStartupStatus: vi.fn(() => ({ supported: true, enabled: true, active: true, port: 3069 })),
54
- restartStartupService,
55
- importFromFilePath: vi.fn(async () => ({
56
- checkForUpdates: vi.fn(async () => ({ available: true, version: '9.9.9' })),
57
- detectPackageManager: vi.fn(() => 'npm'),
58
- executeUpdate: vi.fn(() => ({ success: true, exitCode: 0 })),
59
- getCurrentVersion: vi.fn(() => '1.0.0'),
60
- })),
61
- });
62
-
63
- try {
64
- await updateCommand({ json: true });
65
- expect(restartStartupService).toHaveBeenCalledTimes(1);
66
- } finally {
67
- process.stdout.write = originalWrite;
68
- }
34
+ foreground: [foreground],
69
35
  });
70
36
  });
71
37
 
@@ -77,6 +43,7 @@ describe('update command', () => {
77
43
  const updateCommand = createUpdateCommand({
78
44
  packageManagerPath: '/fake/package-manager.js',
79
45
  serveCommand: vi.fn(),
46
+ getStartupStatus: vi.fn(() => ({ enabled: false })),
80
47
  importFromFilePath: vi.fn(async () => ({
81
48
  checkForUpdates: vi.fn(async () => ({ available: true, version: '9.9.9' })),
82
49
  detectPackageManager: vi.fn(() => 'npm'),
@@ -107,6 +74,7 @@ describe('update command', () => {
107
74
  const updateCommand = createUpdateCommand({
108
75
  packageManagerPath: '/fake/package-manager.js',
109
76
  serveCommand: vi.fn(),
77
+ getStartupStatus: vi.fn(() => ({ enabled: false })),
110
78
  importFromFilePath: vi.fn(async () => ({
111
79
  checkForUpdates: vi.fn(async () => ({ available: true, version: '9.9.9' })),
112
80
  detectPackageManager: vi.fn(() => 'npm'),
@@ -0,0 +1,4 @@
1
+ import{R as r,f as nt,j as n}from"./vendor-react-BUCujlKS.js";import{u as H,V as Ae,M as as,t as hn,a as Te,G as ls}from"./index-DxNa7xYB.js";import{c as cs,b as us,u as ds,a as fs,B as ms,C as ps,P as hs,h as gs,e as xs,g as ys,i as bs,f as ws}from"./patchFileDiff-Dt8LhgBh.js";import{c as vs,b as js,i as Ns,u as Ss,a as ks,d as Cs,S as Fs}from"./SubmoduleDiffSummary-BWIfgMED.js";import{f as Ue,B as ye,I as z,h as oe,N as Cn,ay as Rs,L as de,az as Ds,aI as Es,cN as As,bJ as Ts,K as Vs,aA as Ls,aH as Ms,z as gn,k as Bs,dT as Fn,t as tt,mr as Is,aZ as ft,mj as Rn,ms as Ps,eS as zs,b1 as Ut,jg as _s,aQ as Mt,aW as dt,aY as Os,cA as Xt,aS as Ws,aU as Hs,aV as qs,aR as $s}from"./useAppFontEffects-DGlvOqP_.js";import{bv as xn,bz as Gs,N as Ks,bs as Jt,x as Us}from"./runtimeEndpointReset-CZ5aafpl.js";import{P as Xs}from"./PierreDiffViewer-CnnR-dnD.js";import{v as Js,g as Ys,W as Qs}from"./main-CfBSQM1H.js";import{b as Zs,c as er}from"./changesTree-CePHbFcj.js";import{p as tr}from"./parseDiffFromFile-BUgn-T9p.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CxRSdNoV.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-BmFcUkbQ.js";import"./computeVirtualFileMetrics-C2WM6JC2.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-Det7U81h.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-C4G_dPWe.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-1e0FQ6Wn.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DufXoQvE.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DbpEcZM0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BSHQHbKu.js";import"./vendor-codemirror-lang-json-BzgckzmB.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Cayfb29q.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-BQWerHsJ.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-D2TEBIvZ.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CtwSWKtX.js";import"./vendor-codemirror-lang-python-jAMtYiA9.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-DViGR95I.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./space-apply-DM_2pRW7.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./isDiffPlainText-Dgbw8VKk.js";import"./vendor-diff-C3JhlQdm.js";import"./VirtualizedFileDiff-CFpjL8Ns.js";import"./Virtualizer-C0IsclZn.js";import"./useInlineCommentController-kMN4Wg_D.js";import"./appThemeRegistry-B9gkFq9i.js";import"./textMateThemeFromAppTheme-DlsTphbY.js";import"./vendor-katex-CuQvj9-L.js";import"./useRootScrollLock-DMPpvpNP.js";import"./fileTreeStatus-D438yi8M.js";import"./sessionOwnership-BSuxCEhb.js";const nr=r.memo(function(e){const s=nt.c(13),{index:c,staged:g,busyHunk:m,disabled:v,onAction:N}=e,{t:y}=Ue();let o;s[0]!==g?(o=g?["unstage"]:["discard","stage"],s[0]=g,s[1]=o):o=s[1];const b=o;let j;s[2]===Symbol.for("react.memo_cache_sentinel")?(j={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=j):j=s[2];let R;s[3]!==b||s[4]!==m||s[5]!==v||s[6]!==c||s[7]!==N||s[8]!==y?(R=n.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:b.map(L=>{const w=y(L==="stage"?"diffView.hunk.stageTitle":L==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:c+1}),D=m?.index===c&&m.action===L;return n.jsx(ye,{variant:"ghost",size:"xs",className:oe("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",L==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",L==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:v||m!==null,title:w,"aria-label":w,onPointerDown:sr,onClick:E=>{E.stopPropagation(),N(c,L)},children:n.jsx(z,{name:D?"loader-4":L==="stage"?"add":"arrow-go-back",className:oe(L==="stage"?"size-4":"size-3.5",D&&"animate-spin")})},L)})}),s[3]=b,s[4]=m,s[5]=v,s[6]=c,s[7]=N,s[8]=y,s[9]=R):R=s[9];let p;return s[10]!==c||s[11]!==R?(p=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:j,"data-hunk-actions":c,children:R}),s[10]=c,s[11]=R,s[12]=p):p=s[12],p});function sr(a){return a.stopPropagation()}const yn=(a,e)=>{if(e.length===0)return null;let s=null,c=null;for(const m of e)m.top<=a?(!s||m.top>s.top)&&(s=m):(!c||m.top<c.top)&&(c=m);const g=s??c;return g?{path:g.path,topOffset:g.top-a}:null},rr=(a,e,s,c)=>Math.min(Math.max(0,c),Math.max(0,a+s-e)),qt=a=>a.slice(a.lastIndexOf("/")+1),Dn=(a,e)=>{const s=[],c=(g,m)=>{const v=Array.from(g.children.values()).sort((y,o)=>y.name.localeCompare(o.name));for(const y of v){const{node:o,label:b}=er(y),j=!e.has(o.path);s.push({kind:"directory",key:`dir:${o.path}`,depth:m,path:o.path,label:b,fileCount:o.files.length,expanded:j}),j&&c(o,m+1)}const N=[...g.directFiles].sort((y,o)=>qt(y.path).localeCompare(qt(o.path)));for(const y of N)s.push({kind:"file",key:`file:${y.path}`,depth:m,name:qt(y.path),file:y})};return c(Zs(a),0),s},bn=a=>{if(!a)return null;const e=a.split(`
2
+ `);let s=null;for(const c of e){const g=c.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(g){const m=Number.parseInt(g[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(c.startsWith(" ")){s+=1;continue}if(c.startsWith("+"))return s;if(c.startsWith("-"))return Math.max(1,s)}}return null},ir=1100,or=15e3,wn=500,vn=300,En=1e6,Gt=3,ar=a=>a<=6?a:a<=12?6:a<=25?4:2,jn={status:"loading"},lr=3,cr=r.memo(()=>{const a=nt.c(4),{t:e}=Ue();let s;a[0]!==e?(s=e("diffView.binary.unavailable"),a[0]=e,a[1]=s):s=a[1];let c;return a[2]!==s?(c=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),a[2]=s,a[3]=c):c=a[3],c}),ur=a=>{const{index:e,working_dir:s}=a;return e==="A"||s==="A"||e==="?"||s==="?"},Nn=a=>{const e=a.index?.trim();return!!(e&&e!=="?")},Sn=a=>!!a.working_dir?.trim()||a.index==="?",dr=(a,e)=>_s(a,e),kn=(a,e)=>{const s=a.split(`
3
+ `),c=e.split(`
4
+ `),g=Math.min(s.length,c.length);for(let m=0;m<g;m+=1)if(s[m]!==c[m])return m+1;return c.length>s.length?s.length+1:s.length>c.length?Math.max(1,c.length):1},fr=a=>a==="added"?"A":a==="deleted"?"D":"M",Kt=(a,e,s)=>bs(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:ws(a,e),contextMode:s},An=(a,e,s)=>{const c=a??0,g=e??0;return!c&&!g?null:n.jsxs("span",{className:oe("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[c?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",c]}):null,g?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",g]}):null]})},mr=r.memo(a=>{const e=nt.c(70),{scope:s,workingCount:c,stagedCount:g,turnCount:m,branchCount:v,commitCount:N,prCount:y,showCommitOption:o,showBranchOption:b,changeRequestProvider:j,onScopeChange:R}=a,{t:p}=Ue(),[L,w]=r.useState(!1),D=s==="pr"?y??0:s==="staged"?g:s==="turn"?m:s==="branch"?v??0:s==="commit"?N??0:c;let E;e[0]!==j||e[1]!==s||e[2]!==p?(E=p(s==="pr"?Mt("session.githubIntegration.tabs.pullRequests",j):s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=j,e[1]=s,e[2]=p,e[3]=E):E=e[3];const u=E;let A;e[4]!==p?(A=p("diffView.scope.selectorAria"),e[4]=p,e[5]=A):A=e[5];let _;e[6]!==D?(_=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",D]}),e[6]=D,e[7]=_):_=e[7];let ae;e[8]!==u||e[9]!==_?(ae=n.jsxs("span",{className:"whitespace-nowrap",children:[u,_]}),e[8]=u,e[9]=_,e[10]=ae):ae=e[10];let be;e[11]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(z,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[11]=be):be=e[11];let Z;e[12]!==A||e[13]!==ae?(Z=n.jsx(Ws,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":A,children:[ae,be]})}),e[12]=A,e[13]=ae,e[14]=Z):Z=e[14];let S;e[15]!==R?(S=se=>{(se==="working"||se==="staged"||se==="turn"||se==="branch"||se==="commit"||se==="pr")&&(R?.(se),w(!1))},e[15]=R,e[16]=S):S=e[16];let k;e[17]!==p?(k=p("diffView.scope.changed"),e[17]=p,e[18]=k):k=e[18];let G;e[19]!==k?(G=n.jsx("span",{children:k}),e[19]=k,e[20]=G):G=e[20];let fe;e[21]!==c?(fe=n.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[21]=c,e[22]=fe):fe=e[22];let ee;e[23]!==fe||e[24]!==G?(ee=n.jsx(dt,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[G,fe]})}),e[23]=fe,e[24]=G,e[25]=ee):ee=e[25];let Ce;e[26]!==p?(Ce=p("diffView.scope.staged"),e[26]=p,e[27]=Ce):Ce=e[27];let le;e[28]!==Ce?(le=n.jsx("span",{children:Ce}),e[28]=Ce,e[29]=le):le=e[29];let we;e[30]!==g?(we=n.jsx("span",{className:"typography-meta text-muted-foreground",children:g}),e[30]=g,e[31]=we):we=e[31];let te;e[32]!==le||e[33]!==we?(te=n.jsx(dt,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[le,we]})}),e[32]=le,e[33]=we,e[34]=te):te=e[34];let K;e[35]!==p?(K=p("diffView.scope.lastTurn"),e[35]=p,e[36]=K):K=e[36];let U;e[37]!==K?(U=n.jsx("span",{children:K}),e[37]=K,e[38]=U):U=e[38];let q;e[39]!==m?(q=n.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[39]=m,e[40]=q):q=e[40];let J;e[41]!==U||e[42]!==q?(J=n.jsx(dt,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[U,q]})}),e[41]=U,e[42]=q,e[43]=J):J=e[43];let ne;e[44]!==v||e[45]!==b||e[46]!==p?(ne=b?n.jsx(dt,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:v??"…"})]})}):null,e[44]=v,e[45]=b,e[46]=p,e[47]=ne):ne=e[47];let B;e[48]!==N||e[49]!==o||e[50]!==p?(B=o&&n.jsx(dt,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:N??"…"})]})}),e[48]=N,e[49]=o,e[50]=p,e[51]=B):B=e[51];let me;e[52]!==j||e[53]!==y||e[54]!==o||e[55]!==p?(me=o&&n.jsx(dt,{value:"pr",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p(Mt("session.githubIntegration.tabs.pullRequests",j))}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:y??"…"})]})}),e[52]=j,e[53]=y,e[54]=o,e[55]=p,e[56]=me):me=e[56];let C;e[57]!==s||e[58]!==ee||e[59]!==te||e[60]!==J||e[61]!==ne||e[62]!==B||e[63]!==me||e[64]!==S?(C=n.jsx(Hs,{align:"start",className:"w-40",children:n.jsxs(qs,{value:s,onValueChange:S,children:[ee,te,J,ne,B,me]})}),e[57]=s,e[58]=ee,e[59]=te,e[60]=J,e[61]=ne,e[62]=B,e[63]=me,e[64]=S,e[65]=C):C=e[65];let Y;return e[66]!==L||e[67]!==C||e[68]!==Z?(Y=n.jsxs($s,{open:L,onOpenChange:w,children:[Z,C]}),e[66]=L,e[67]=C,e[68]=Z,e[69]=Y):Y=e[69],Y}),pr=r.memo(a=>{const e=nt.c(11),{changedFiles:s,selectedFile:c,onSelectFile:g}=a,{t:m}=Ue();if(s.length===0)return null;let v;if(e[0]!==s||e[1]!==g||e[2]!==c||e[3]!==m){let y;e[5]!==g||e[6]!==c||e[7]!==m?(y=o=>{const b=Jt(o),j=c===o.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>g(o.path),className:oe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",j?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(Ut,{filePath:o.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:b.color},title:m(b.descriptionKey),"aria-label":m(b.descriptionKey),children:b.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:o.path,children:o.path}),An(o.insertions,o.deletions)]})},o.path)},e[5]=g,e[6]=c,e[7]=m,e[8]=y):y=e[8],v=s.map(y),e[0]=s,e[1]=g,e[2]=c,e[3]=m,e[4]=v}else v=e[4];let N;return e[9]!==v?(N=n.jsx(Xt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:v})}),e[9]=v,e[10]=N):N=e[10],N}),Tn=12,Vn=8,$t=160,hr=.5,gr=r.memo(a=>{const e=nt.c(18),{changedFiles:s,selectedFile:c,onSelectFile:g}=a,{t:m}=Ue(),[v,N]=r.useState(wr);let y;e[0]!==s||e[1]!==v?(y=Dn(s,v),e[0]=s,e[1]=v,e[2]=y):y=e[2];const o=y;let b,j;e[3]!==c?(b=()=>{c&&N(E=>{const u=Array.from(E).filter(_=>c.startsWith(`${_}/`));if(u.length===0)return E;const A=new Set(E);return u.forEach(_=>A.delete(_)),A})},j=[c],e[3]=c,e[4]=b,e[5]=j):(b=e[4],j=e[5]),r.useEffect(b,j);let R;e[6]===Symbol.for("react.memo_cache_sentinel")?(R=E=>{N(u=>{const A=new Set(u);return A.delete(E)||A.add(E),A})},e[6]=R):R=e[6];const p=R,L=jr;let w;if(e[7]!==g||e[8]!==o||e[9]!==c||e[10]!==m){let E;e[12]!==g||e[13]!==c||e[14]!==m?(E=u=>{const A=`${Vn+u.depth*Tn}px`;if(u.kind==="directory")return n.jsxs("li",{className:"relative",children:[L(u.depth),n.jsxs("button",{type:"button",onClick:()=>p(u.path),"aria-expanded":u.expanded,"aria-label":u.expanded?m("diffView.fileTree.collapseDirectoryAria",{path:u.path}):m("diffView.fileTree.expandDirectoryAria",{path:u.path}),className:"flex w-full items-center gap-1 rounded-md py-1 pr-2 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground",style:{paddingLeft:A},title:u.path,children:[n.jsx(z,{name:"arrow-right-s",className:oe("size-3.5 flex-shrink-0 transition-transform",u.expanded&&"rotate-90")}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:u.label})]})]},u.key);const _=Jt(u.file),ae=c===u.file.path;return n.jsxs("li",{className:"relative",children:[L(u.depth),n.jsxs("button",{type:"button",onClick:()=>g(u.file.path),"aria-current":ae?"true":void 0,className:oe("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left transition-colors",ae?"bg-interactive-selection text-interactive-selection-foreground":"text-foreground/90 hover:bg-interactive-hover hover:text-foreground"),style:{paddingLeft:A},title:u.file.path,children:[n.jsx(Ut,{filePath:u.file.path,className:"ml-0.5 size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:u.name}),n.jsx("span",{className:"typography-micro font-semibold w-3 text-center uppercase",style:{color:_.color},title:m(_.descriptionKey),"aria-label":m(_.descriptionKey),children:_.code})]})]},u.key)},e[12]=g,e[13]=c,e[14]=m,e[15]=E):E=e[15],w=o.map(E),e[7]=g,e[8]=o,e[9]=c,e[10]=m,e[11]=w}else w=e[11];let D;return e[16]!==w?(D=n.jsx(Xt,{outerClassName:"flex-1 min-h-0",className:"px-1.5 py-1.5",children:n.jsx("ul",{className:"flex flex-col",children:w})}),e[16]=w,e[17]=D):D=e[17],D}),xr=r.memo(a=>{const e=nt.c(20),{filePath:s,diff:c,renderSideBySide:g}=a,{t:m}=Ue(),v=c.original.length>0,N=c.modified.length>0,y=g?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",o=g?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={contain:"layout"},e[0]=b):b=e[0];let j;e[1]!==c.original||e[2]!==s||e[3]!==v||e[4]!==o||e[5]!==g||e[6]!==m?(j=v&&n.jsxs("div",{className:o,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),n.jsx("img",{src:c.original,alt:m("diffView.image.originalAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=c.original,e[2]=s,e[3]=v,e[4]=o,e[5]=g,e[6]=m,e[7]=j):j=e[7];let R;e[8]!==c.modified||e[9]!==s||e[10]!==N||e[11]!==v||e[12]!==o||e[13]!==g||e[14]!==m?(R=N&&n.jsxs("div",{className:o,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(v?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:c.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=c.modified,e[9]=s,e[10]=N,e[11]=v,e[12]=o,e[13]=g,e[14]=m,e[15]=R):R=e[15];let p;return e[16]!==y||e[17]!==j||e[18]!==R?(p=n.jsx("div",{className:"w-full overflow-auto p-4",style:b,children:n.jsxs("div",{className:y,children:[j,R]})}),e[16]=y,e[17]=j,e[18]=R,e[19]=p):p=e[19],p}),yr=r.memo(a=>{const e=nt.c(24),{filePath:s,diff:c,staged:g,renderSideBySide:m,wrapLines:v,hideWhitespace:N,hunkActions:y,onExpandContextRequest:o,pendingContextExpansion:b,contextLoading:j}=a;let R;e[0]!==s?(R=Os(s)||"text",e[0]=s,e[1]=R):R=e[1];const p=R;if(c.submodule){let D;return e[2]!==c.submodule||e[3]!==g?(D=n.jsx(Fs,{state:c.submodule,staged:g}),e[2]=c.submodule,e[3]=g,e[4]=D):D=e[4],D}if(c.isBinary){let D;return e[5]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(cr,{}),e[5]=D):D=e[5],D}if(ft(s)){let D;return e[6]!==c||e[7]!==s||e[8]!==m?(D=n.jsx(xr,{filePath:s,diff:c,renderSideBySide:m}),e[6]=c,e[7]=s,e[8]=m,e[9]=D):D=e[9],D}let L;e[10]===Symbol.for("react.memo_cache_sentinel")?(L={contain:"layout"},e[10]=L):L=e[10];let w;return e[11]!==j||e[12]!==c.fileDiff||e[13]!==c.modified||e[14]!==c.original||e[15]!==s||e[16]!==N||e[17]!==y||e[18]!==p||e[19]!==o||e[20]!==b||e[21]!==m||e[22]!==v?(w=n.jsx("div",{className:"w-full",style:L,children:n.jsx(Xs,{original:c.original,modified:c.modified,fileDiff:c.fileDiff,language:p,fileName:s,renderSideBySide:m,wrapLines:v,hideWhitespace:N,layout:"inline",hunkActions:y,onExpandContextRequest:o,pendingContextExpansion:b,contextLoading:j})}),e[11]=j,e[12]=c.fileDiff,e[13]=c.modified,e[14]=c.original,e[15]=s,e[16]=N,e[17]=y,e[18]=p,e[19]=o,e[20]=b,e[21]=m,e[22]=v,e[23]=w):w=e[23],w}),br=r.memo(({visible:a=!0,directory:e,file:s,layout:c,wrapLines:g,hideWhitespace:m=!1,isSelected:v,isExpanded:N,isMounted:y,onSelect:o,onExpandedChange:b,registerSectionRef:j,showOpenInEditorAction:R=!1,isOpeningInEditor:p=!1,onOpenInEditor:L,staged:w=!1,loadFullFiles:D=!1,initialDiffData:E=null,comparisonDiff:u,onRetryComparisonDiff:A,loadFullComparisonDiff:_,readOnlyActions:ae=!1,hunkActionsEnabled:be=!1,contentRevision:Z=0})=>{const{t:S}=Ue(),{git:k}=Cn(),G=de(r.useCallback(x=>x.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),fe=de(x=>x.setDiff),ee=de(x=>x.fetchStatus),Ce=H(x=>x.setDiffFileLayout),[le,we]=r.useState(0),[te,K]=r.useState(null),[U,q]=r.useState(!1),[J,ne]=r.useState(null),B=J!==null&&J.source===u?J.result:u,me=!!e&&!E&&(!u||!!_),C=r.useMemo(()=>B?B.status==="error"?{kind:"error",message:B.message}:null:te,[B,te]),Y=B?B.status==="loading":U,[se,Xe]=r.useState(null),st=r.useRef(!1),[Ve,rt]=r.useState(null),[Nt,Bt]=r.useState(!1),[mt,it]=r.useState(null),[ot,Le]=r.useState(null),[Me,d]=r.useState(null),ce=D||Me!==null;r.useEffect(()=>{if(!Me||!_||!u||u.status!=="ready"||J?.source===u)return;let x=!1;return _(s.path).then(O=>{if(!x){if(O.status==="error"){tt.error(O.message),d(null);return}ne({source:u,result:O})}}),()=>{x=!0}},[Me,s.path,J,_,u]);const re=r.useRef(null),St=r.useRef(null),ve=r.useMemo(()=>Jt(s),[s]),pt=c==="side-by-side",Be=ce?"full":"patch",Je=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,pe=be&&!ae&&!E&&!B&&!ft(s.path),Ye=JSON.stringify([Te(),e,s.path,w,Je,le,Z]),ie=Ve?.scope===Ye?Ve.patch:null,De=Ve?.scope===Ye?Ve.submodule:null,je=r.useMemo(()=>B?B.status==="ready"?B.data:null:E||(w?ot:mt||(G?{original:G.original,modified:G.modified,isBinary:G.isBinary,submodule:G.submodule,contextMode:"full"}:null)),[B,G,E,mt,w,ot]),Ie=je?.contextMode===Be,It=r.useCallback(x=>{St.current=x,j(s.path,x)},[s.path,j]),ht=r.useCallback(x=>{b(s.path,x)},[s.path,b]),he=r.useCallback(()=>{o(s.path)},[s.path,o]),at=r.useRef(w);r.useEffect(()=>{a&&at.current!==w&&(at.current=w,w?Le(null):it(null),K(null),re.current=null)},[w,a]);const Pe=`${Z}:${Je}`,[gt,lt]=r.useState(Pe),Fe=gt===Pe;r.useEffect(()=>{Fe||(K(null),re.current=null)},[Fe]),r.useEffect(()=>{if(!a||!N||!y||te)return;if(!e||B||E||je&&Ie&&Fe&&(!pe||ie!==null)){re.current=null,q(!1);return}const x=`${e}::${s.path}::${w?"staged":"unstaged"}::${Je}::${Be}::${le}::${Z}`;if(re.current===x)return;re.current=x,K(null),q(!0);let O=!1;const ge=Te(),Oe=ce?En:Gt,Q=ft(s.path)?k.getGitFileDiff(e,{path:s.path,staged:w}):!ce&&ie!==null?Promise.resolve({diff:ie,submodule:De}):k.getGitDiff(e,{path:s.path,staged:w,contextLines:Oe}),We=pe&&ce&&ie===null?k.getGitDiff(e,{path:s.path,staged:w,contextLines:Gt}).then(M=>M.diff):Promise.resolve(ie),Se=Promise.all([Q,We]),He=or;let ct;const Pt=new Promise((M,xt)=>{ct=setTimeout(()=>xt(new Error(`Timed out after ${He}ms`)),He)});return Promise.race([Se,Pt]).then(([M,xt])=>{if(O||ge!==Te())return;const qe="diff"in M&&!ce?M.diff:xt;if(pe&&ce&&qe!==null&&/^@@\s/m.test(qe)&&"diff"in M&&M.diff!==qe&&!gs(M.diff,qe))throw rt(null),new Error(S("diffView.hunk.unavailable"));if(pe&&qe!==null&&rt({scope:Ye,patch:qe,submodule:M.submodule}),"diff"in M){const $e={...Kt(s.path,M.diff,Be),submodule:M.submodule};w?Le($e):it($e)}else{const $e={original:M.original??"",modified:M.modified??"",isBinary:M.isBinary,submodule:M.submodule,contextMode:"full"};w?Le($e):(fe(e,s.path,$e,ge),it($e))}lt(Pe),q(!1)}).catch(M=>{if(!(O||ge!==Te())){if(q(!1),M instanceof ls){K({kind:"unavailable",reason:M.reason}),M.reason==="path_not_found"&&ee(e,k,{force:!0,silent:!0});return}K({kind:"error",message:M instanceof Error?M.message:String(M)})}}).finally(()=>clearTimeout(ct)),()=>{O=!0,clearTimeout(ct),re.current===x&&(re.current=null)}},[ie,De,Z,Pe,pe,Fe,Ye,B,Be,je,Ie,le,e,ee,s.path,Je,k,E,N,y,ce,te,fe,w,S,a]);const kt=r.useCallback(()=>{ht(!N),he()},[ht,he,N]),Qe=r.useCallback(()=>{K(null),rt(null),it(null),Le(null),re.current=null,we(x=>x+1)},[]),Ct=zs(),{confirm:Re}=Ct,ze=r.useCallback(async(x,O)=>{if(!e||!pe||Y||C||st.current||se!==null)return;const ge=ie?xs(ie,x):null;if(!ge){tt.error(S("diffView.hunk.unavailable"));return}if(w&&O!=="unstage"||!w&&O==="unstage"||O==="discard"&&!await Re({title:S("diffView.hunk.discardDialogTitle"),message:S("diffView.hunk.discardDescription",{path:s.path}),action:S("diffView.hunk.discard"),destructive:!0})||st.current)return;st.current=!0;const Oe=Te();Xe({index:x,action:O});try{const Q=O==="stage"?k.stageGitHunk:O==="unstage"?k.unstageGitHunk:k.revertGitHunk;if(!Q){tt.error(S("diffView.hunk.unsupported"));return}if(await Q(e,s.path,ge),Oe!==Te())return;Qe(),Fn.requestGitRefresh({directory:e,paths:[s.path]}),await ee(e,k)}catch(Q){if(Oe!==Te())return;Qe(),tt.error(Q instanceof Error&&Q.message?Q.message:S("diffView.hunk.unavailable"))}finally{st.current=!1,Xe(Q=>Q?.index===x&&Q.action===O?null:Q)}},[ie,Re,pe,Y,C,e,ee,s.path,k,se,Qe,w,S]),Ne=r.useMemo(()=>pe&&ie!==null?ys(ie):[],[ie,pe]),$=r.useCallback(x=>n.jsx(nr,{index:x,staged:w,busyHunk:se,disabled:Y||!!C,onAction:ze}),[C,ze,se,Y,w]),_e=r.useMemo(()=>Ne.length>0?{anchors:Ne,render:$}:void 0,[Ne,$]);return n.jsxs("div",{ref:It,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:kt,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),kt())},className:oe("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",v?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:N?n.jsx(z,{name:"arrow-down-s",className:"size-4"}):n.jsx(z,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:ve.color},title:S(ve.descriptionKey),"aria-label":S(ve.descriptionKey),children:ve.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Ut,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const x=s.path.lastIndexOf("/");if(x===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const O=s.path.slice(0,x),ge=s.path.slice(x+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:O}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ge})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[An(s.insertions,s.deletions),R&&L?n.jsx(ye,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:S("diffView.actions.openFileInEditorAtChange"),onClick:x=>{x.stopPropagation(),L(s.path,je)},disabled:p,children:p?n.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(z,{name:"edit",className:"size-3.5"})}):null,n.jsx(Rn,{mode:pt?"side-by-side":"unified",onModeChange:x=>{const O=x==="side-by-side"?"side-by-side":"inline";Ce(s.path,O)},className:"opacity-70"})]})]})}),N&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!y&&!C?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,C?.kind==="unavailable"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:C.reason==="nested_repository"?S("diffView.unavailable.nestedRepositoryTitle"):C.reason==="untracked_directory"?S("diffView.unavailable.untrackedDirectoryTitle"):S("diffView.unavailable.missingTitle")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C.reason==="nested_repository"?S("diffView.unavailable.nestedRepositoryDescription"):C.reason==="untracked_directory"?S("diffView.unavailable.untrackedDirectoryDescription"):S("diffView.unavailable.missingDescription")}),C.reason==="path_not_found"?n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:Qe,children:S("diffView.actions.retry")}):null]}):null,C?.kind==="error"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:S("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C.message}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>B?A?.():Qe(),children:S("diffView.actions.retry")})]}):null,y&&Y&&!je&&!C?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),S("diffView.state.loadingDiff")]}):null,y&&je&&!Nt&&s.insertions+s.deletions>wn?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:S("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:S("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Bt(!0),children:S("diffView.actions.renderAnyway")})]}):null,y&&je&&(Nt||s.insertions+s.deletions<=wn)?n.jsx(n.Fragment,{children:n.jsx(yr,{filePath:s.path,diff:je,staged:w,renderSideBySide:pt,wrapLines:g,hideWhitespace:m,hunkActions:_e,onExpandContextRequest:me?d:void 0,pendingContextExpansion:Me,contextLoading:Me!==null&&je.contextMode!=="full"&&!C})}):null]}),Ct.dialog]})}),qo=({visible:a=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:c=!1,showOpenInEditorAction:g=!1,diffScope:m="all",onDiffScopeChange:v,targetFilePath:N=null,flushContent:y=!1})=>{const{t:o}=Ue(),{git:b,files:j,sourceControl:R}=Cn(),p=Rs(),L=de(t=>t.runtimeKey),{rootIsGitRepo:w,gitDirectory:D,nestedRepos:E}=Ds(p??null,{enabled:a,recheckOnOpen:!0}),u=D??p,A=Es(u,R),_=H(t=>t.openContextSurface),ae=As(t=>t.requestTarget),{screenWidth:be,isMobile:Z}=Ts(),S=Vs(u??null),k=Ls(u??null),G=Ms(u??null),fe=de(t=>t.setActiveDirectory),ee=de(t=>t.ensureStatus),Ce=de(t=>t.selectNestedRepo),le=de(t=>t.fetchStatus),we=de(t=>t.fetchBranches),te=de(t=>t.clearDiffCache),K=de(t=>t.setDiff),[U,q]=r.useState(null),[J,ne]=r.useState(!1),[B,me]=r.useState(null),[C,Y]=r.useState(()=>new Set),[se,Xe]=r.useState(()=>new Set),[st,Ve]=r.useState(0),[rt,Nt]=r.useState(()=>new Map),[Bt,mt]=r.useState(0),[it,ot]=r.useState(!1),[Le,Me]=r.useState(!1),[d,ce]=r.useState(m);r.useEffect(()=>{ce(m)},[m]);const re=H(t=>t.pendingDiffFile),St=H(t=>t.pendingDiffStaged),ve=H(t=>t.pendingDiffScope),pt=H(t=>t.setPendingDiffFile),Be=H(t=>t.diffLayoutPreference),Je=H(t=>t.diffFileLayout),pe=H(t=>t.setDiffFileLayout),Ye=H(t=>t.diffWrapLines),ie=H(t=>t.setDiffWrapLines),De=H(t=>t.diffHideWhitespace),je=H(t=>t.setDiffHideWhitespace),Ie=H(t=>t.diffFileListMode),It=H(t=>t.setDiffFileListMode),ht=H(t=>t.openContextFileAtLine),he=gn(t=>t.currentSessionId),at=Bs(d==="turn"?he??"":"",p??void 0),Pe=Ye,gt=d==="staged"?!0:d==="working"?!1:null,lt=gt??J,Fe=Z||be<=768,kt=!!he&&d!=="turn"&&d!=="commit"&&d!=="pr"&&!Fe&&!Ae(),Qe=d!=="turn"&&!Fe&&!Ae(),Ct=!e&&!Fe&&be>=1024,Re=r.useRef(null),ze=r.useRef(new Map),Ne=r.useRef(null),$=r.useRef(null),_e=r.useRef(!1),x=r.useRef(null),O=r.useRef(null),ge=r.useRef(null),Oe=r.useRef(null),Q=r.useCallback(()=>{const t=Re.current;if(!t)return null;const i=t.getBoundingClientRect().top,l=[];for(const[f,h]of ze.current)h&&l.push({path:f,top:h.getBoundingClientRect().top});return yn(i,l)},[]),We=r.useCallback(()=>{Ne.current=null,_e.current=!1,me(null),$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null)},[]),Se=r.useCallback(t=>{Y(i=>{if(i.has(t))return i;const l=new Set(i);return l.add(t),l})},[]),[He,ct]=r.useState([]),Pt=at.length>0?at[at.length-1].id:"";r.useEffect(()=>{if(d!=="turn"||!he||!a)return;let t=!1;return as.getSessionTurnDiff(he,{directory:p??void 0}).then(i=>{t||ct(i.map(l=>({file:l.file,patch:l.patch,status:l.status,additions:l.additions,deletions:l.deletions})))}).catch(i=>{t||(console.warn("[diff-view] turn diff unavailable:",i instanceof Error?i.message:i),ct([]))}),()=>{t=!0}},[d,he,Pt,p,a]);const M=r.useMemo(()=>{const t=new Map;for(const i of He)if(i.file){if(typeof i.patch=="string"){t.set(i.file,Kt(i.file,i.patch,"patch"));continue}t.set(i.file,{original:i.before??"",modified:i.after??"",contextMode:"full"})}return t},[He]),xt=r.useMemo(()=>k?.files?k.files.filter(Sn).length:0,[k]),qe=r.useMemo(()=>k?.files?k.files.filter(Nn).length:0,[k]),$e=He.length,W=k?.current??null,Ft=A.contexts[0]?.provider==="github"||A.contexts[0]?.provider==="gitlab"?A.contexts[0]:null,yt=xn(t=>u?t.diffRequests.get(u):void 0),ue=cs(u??null,W,Ft,a&&d==="pr"&&!Ae(),yt),Ee=ue.selectedSource;r.useEffect(()=>{!u||!yt||!k||Ee!==yt||xn.getState().settleDiffRequest(u,yt)},[u,yt,Ee,k]);const Ge=us(u??null,W,a&&d==="commit"&&!Ae()),Ze=Ge.selectedCommit?.hash??null;r.useEffect(()=>{(d==="commit"||d==="pr")&&Ae()&&(ce("working"),v?.("working"))},[d,v]);const et=de(t=>u?t.directories.get(u)?.branches??null:null),Ln=de(t=>u?t.directories.get(u)?.isLoadingBranches??!1:!1),Mn=r.useCallback(()=>{u&&we(u,b)},[u,we,b]),Bn=vs(u??null,a&&S!==!1,Ln,!!et,Mn,lr),Yt=r.useMemo(()=>{const t=A.contexts[0]?.primaryRemote;return t?et?.defaultBranches?.[t]??null:null},[A.contexts,et]),Qt=!Ae()&&js(W,Yt),In=k!==null,Zt=Ae()||Bn||Ns(W,Yt,In,et!==null&&A.status==="ready"),Pn=ds(t=>t.setOverride),{base:bt,resolved:zn,revision:en}=fs(u??null,W,a&&Qt&&d==="branch"),[_n,On]=r.useState(0);r.useEffect(()=>{const t=Cs(d,!Zt);t!==d&&(ce(t),t==="working"&&v?.("working"))},[d,Zt,v]);const Ke=r.useMemo(()=>{if(!bt||bt===W)return null;const t=et?.all??[];return Gs(bt,{localBranches:t.filter(i=>!i.startsWith("remotes/")),remoteBranches:t.filter(i=>i.startsWith("remotes/")).map(i=>i.slice(8)),remoteNames:new Set(A.read?.repository.remotes.map(i=>i.name)??[]),primaryRemote:A.contexts[0]?.primaryRemote})},[A.contexts,A.read,bt,et,W]),Wn=r.useMemo(()=>d==="pr"?Ee:d==="commit"&&Ze?{kind:"commit",hash:Ze}:d==="branch"&&Ke&&W?{kind:"branch",baseRef:Ke,headRef:W}:null,[d,Ke,W,Ze,Ee]),I=Ss(u??null,Wn,a&&!Ae(),d==="branch"?en:"",ue.readContext,ue.provider),{fetchDiff:tn,fetchFullFile:nn}=I,sn=d==="commit"?I.files:null,rn=d==="commit"?I.error:null,Rt=d==="branch"?I.files:null,on=d==="branch"?I.error:null,an=I.files?d==="pr"?JSON.stringify([I.key,I.revision]):I.key:null,Hn=r.useMemo(()=>d==="branch"||d==="commit"||d==="pr"?Array.from(C).sort().join("\0"):"",[d,C]),zt=r.useCallback(async(t,i=!1)=>{try{const l=await tn(t,i?En:Gt);return{status:"ready",data:Kt(t,l.diff,i?"full":"patch")}}catch(l){return{status:"error",message:l instanceof Error?l.message:o("diffView.state.failedToLoadDiff")}}},[tn,o]),ln=r.useCallback(async t=>{try{const{original:i,modified:l}=await nn(t),f=tr({name:t,contents:i},{name:t,contents:l});return{status:"ready",data:{original:i,modified:l,fileDiff:f,contextMode:"full"}}}catch(i){return{status:"error",message:i instanceof Error?i.message:o("diffView.state.failedToLoadDiff")}}},[nn,o]),qn=r.useMemo(()=>d==="branch"||d==="commit"?t=>zt(t,!0):d==="pr"?ln:void 0,[d,zt,ln]),$n=ks(an,a?Hn:"",an?zt:null,jn,JSON.stringify([d==="branch"?en:"",d==="pr"?I.revision:0,_n])),Gn=Rt?.length??null,T=r.useMemo(()=>{if(d==="commit"||d==="pr")return(I.files??[]).map(f=>({path:f.path,index:"",working_dir:f.status,insertions:f.insertions,deletions:f.deletions,isNew:f.status==="A"}));if(d==="branch")return(Rt??[]).map(f=>({path:f.path,index:"",working_dir:f.status,insertions:0,deletions:0,isNew:f.status==="A"})).sort((f,h)=>f.path.localeCompare(h.path));if(d==="turn")return He.map(f=>({path:f.file??"",index:"",working_dir:fr(f.status),insertions:f.additions??0,deletions:f.deletions??0,isNew:f.status==="added"})).filter(f=>f.path).sort((f,h)=>f.path.localeCompare(h.path));if(!k?.files)return[];const t=k.diffStats,i=d==="staged"?Nn:d==="working"?Sn:()=>!0,l=f=>{const h=t?.staged?.[f],F=t?.working?.[f];return d==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:d==="working"?{insertions:F?.insertions??0,deletions:F?.deletions??0}:{insertions:(h?.insertions??0)+(F?.insertions??0),deletions:(h?.deletions??0)+(F?.deletions??0)}};return k.files.filter(i).map(f=>{const h=l(f.path);return{...f,insertions:h.insertions,deletions:h.deletions,isNew:ur(f)}}).sort((f,h)=>f.path.localeCompare(h.path))},[d,Rt,I.files,He,k]),_t=r.useMemo(()=>T.map(t=>t.path).join("\0"),[T]);r.useEffect(()=>{const t=_t?_t.split("\0"):[],i=new Set(t),l=`${u??""}:${d}:${s?"collapsed":"default"}`,f=O.current!==l;O.current=l,Y(h=>{if(f){const P=s?0:ar(t.length);return new Set(t.slice(0,P))}let F=!1;const V=new Set;for(const P of h){if(!i.has(P)){F=!0;continue}V.add(P)}return F?V:h}),Xe(h=>{if(f)return new Set;let F=!1;const V=new Set;for(const P of h){if(!i.has(P)){F=!0;continue}V.add(P)}return F?V:h})},[d,_t,u,s]);const cn=r.useCallback(()=>{if(x.current=null,!a)return;const t=Re.current;if(!t)return;const i=t.getBoundingClientRect(),l=i.top-vn,f=i.bottom+vn,h={},F=[];for(const[V,P]of ze.current){if(!P)continue;const X=P.getBoundingClientRect();F.push({path:V,top:X.top}),C.has(V)&&(X.bottom<l||X.top>f||(h[V]=!0))}ge.current=yn(i.top,F),Xe(V=>{let P=!1;const X=new Set(V);for(const jt of Object.keys(h))X.has(jt)||(X.add(jt),P=!0);return P?X:V})},[C,a]),xe=r.useCallback(()=>{a&&(typeof window>"u"||x.current===null&&(x.current=window.requestAnimationFrame(cn)))},[cn,a]);r.useEffect(()=>{const t=Re.current;if(!(!a||!t))return xe(),t.addEventListener("scroll",xe,{passive:!0}),window.addEventListener("resize",xe),()=>{t.removeEventListener("scroll",xe),window.removeEventListener("resize",xe),x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null)}},[T,C,xe,a]);const Ot=r.useCallback(t=>{const i=Je[t.path];if(i)return i;if(Be==="inline")return"inline";if(Be==="side-by-side")return"side-by-side";const l=be<ir;return t.isNew||l?"inline":"side-by-side"},[Je,Be,be]),un=r.useMemo(()=>T.length===0?null:T.every(t=>Ot(t)==="side-by-side")?"side-by-side":"inline",[T,Ot]);r.useEffect(()=>{a&&u&&(fe(u),ee(u,b))},[u,fe,ee,b,a]);const Dt=JSON.stringify([L,u]),Wt=r.useRef({scope:Dt,paths:new Set,dirty:!1,unscoped:!1}),dn=r.useRef(a);r.useEffect(()=>{const t=a&&!dn.current;if(dn.current=a,Wt.current.scope!==Dt&&(Wt.current={scope:Dt,paths:new Set,dirty:!1,unscoped:!1}),!u)return;const i=(f,h)=>{f.length&&(Oe.current=Q()??ge.current,te(u,f),Nt(F=>{const V=new Map(F);for(const P of f)V.set(P,(V.get(P)??0)+1);return V})),h&&mt(F=>F+1),le(u,b,{silent:!0})},l=Wt.current;return a&&(t||l.dirty)&&(i([...l.paths],l.unscoped),l.paths.clear(),l.dirty=!1,l.unscoped=!1),Fn.onGitRefreshHint(f=>{if(hn(f.directory)!==hn(u))return;const h=f.paths??[],F=h.length===0;if(!a){l.dirty=!0,l.unscoped||=F;for(const V of h)l.paths.add(V);return}i(h,F)})},[Q,te,u,le,b,Dt,a]),r.useLayoutEffect(()=>{const t=Oe.current;if(!t)return;Oe.current=null;const i=Re.current,l=ze.current.get(t.path);if(!i||!l)return;const f=i.getBoundingClientRect().top,h=l.getBoundingClientRect().top-f;i.scrollTop=rr(i.scrollTop,t.topOffset,h,i.scrollHeight-i.clientHeight),ge.current=t},[rt]),r.useEffect(()=>{!a||d!=="all"&&!ve||re&&(ve&&ce(ve),q(re),ne(ve==="staged"||!ve&&St),pt(null),_e.current=!0,Ne.current=re,Se(re),Ve(t=>t+1))},[d,Se,re,ve,St,pt,a]),r.useEffect(()=>{if(d==="all")return;const t=N?.trim();t&&(q(t),ne(d==="staged"),_e.current=!0,Ne.current=t,Se(t),Ve(i=>i+1))},[d,Se,N]),r.useEffect(()=>{if(!U)return;T.some(i=>i.path===U)||(q(null),ne(!1))},[T,U]);const Kn=r.useCallback((t,i)=>{const l=ze.current;i?l.set(t,i):l.delete(t),xe()},[xe]),Un=r.useCallback((t,i)=>{We(),Y(l=>{const f=l.has(t);if(i===f)return l;const h=new Set(l);return i?h.add(t):h.delete(t),h}),i||Xe(l=>{if(!l.has(t))return l;const f=new Set(l);return f.delete(t),f}),xe()},[We,xe]),Xn=r.useCallback(()=>{We(),Y(t=>t.size>0?new Set:new Set(T.map(i=>i.path))),Xe(new Set),xe()},[We,T,xe]),Jn=r.useCallback(async t=>{if(!he)return;const i=gn.getState().getDirectoryForSession(he)||p||"";if(!i){tt.error(o("diffView.reviewDialog.toast.noSessionDirectory"));return}Me(!0);try{await Is({originalSessionID:he,directory:i,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),ot(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),tt.error(l instanceof Error?l.message:o("diffView.reviewDialog.toast.startFailed"))}finally{Me(!1)}},[he,p,o]),Et=r.useCallback(t=>{const i=ze.current.get(t),l=Re.current;if(!i||!l)return!1;const f=i.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+f,behavior:"auto"}),!0},[]);r.useEffect(()=>{const t=Ne.current;if(!a||!t)return;let i=0;const l=20;let f=!1;const h=(V=!0)=>{f||(f=!0,Ne.current=null,_e.current=!1,V&&me(null),$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null))},F=()=>{if(f){$.current=null;return}const V=Ne.current;if(!V){h(),$.current=null;return}if(!Et(V)){i+=1,i<l?$.current=window.requestAnimationFrame(F):(h(),$.current=null);return}if(c&&_e.current){me(V),h(!1);return}h()};return $.current=window.requestAnimationFrame(F),()=>{f=!0,$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null)}},[c,st,Et,a]);const Yn=r.useCallback(t=>{},[]),ke=Ie==="tree"&&!Fe,Qn=H(t=>t.diffFileTreeWidth),At=H(t=>t.setDiffFileTreeWidth),fn=r.useRef(null),[Zn,mn]=r.useState(!1),wt=Math.max(Qn,$t),Tt=r.useCallback(t=>{const i=Math.max($t,(fn.current?.clientWidth??0)*hr);return Math.min(i,Math.max($t,t))},[]),es=r.useCallback(t=>{t.preventDefault();const i=t.clientX,l=wt;mn(!0);const f=F=>{At(Tt(l+F.clientX-i))},h=()=>{mn(!1),window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h)},[Tt,wt,At]),ts=r.useCallback(t=>{const i=t.shiftKey?40:10,l=t.key==="ArrowLeft"?-i:t.key==="ArrowRight"?i:0;l!==0&&(t.preventDefault(),At(Tt(wt+l)))},[Tt,wt,At]),Ht=r.useMemo(()=>ke?Dn(T,new Set).flatMap(t=>t.kind==="file"?[t.file]:[]):[],[T,ke]),vt=ke?Ht:T,ut=ke?Ht.find(t=>t.path===U)??Ht[0]??null:null,Vt=ut?.path??null;r.useEffect(()=>{Vt&&!C.has(Vt)&&Se(Vt)},[Se,C,Vt]);const Lt=r.useCallback(t=>{if(We(),ke){q(t),ne(!1),Se(t),Re.current?.scrollTo({top:0});return}q(t),ne(!1),_e.current=!0,Ne.current=t,Se(t),Ve(i=>i+1),Et(t)},[We,Se,ke,Et]);r.useEffect(()=>{const t=i=>{if(!a||!i.altKey||i.metaKey||i.ctrlKey||i.shiftKey||i.key!=="ArrowDown"&&i.key!=="ArrowUp")return;const l=i.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||(i.preventDefault(),vt.length===0))return;const f=i.key==="ArrowDown"?1:-1,h=ke?ut?.path:U,F=h?vt.findIndex(X=>X.path===h):-1,V=F===-1?f>0?0:vt.length-1:F+f,P=vt[V];P&&Lt(P.path)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[U,Lt,ke,vt,ut,a]);const ns=r.useCallback(t=>{const i=t==="side-by-side"?"side-by-side":"inline";T.forEach(l=>{pe(l.path,i)})},[T,pe]),[ss,pn]=r.useState(null),rs=r.useCallback(async(t,i)=>{if(!u||!t)return;pn(t);const l=Te();try{let f=null;if(i?.patch&&!i.isBinary&&!ft(t)?f=bn(i.patch):i&&i.contextMode==="full"&&!i.isBinary&&!ft(t)&&(f=kn(i.original,i.modified)),f===null)try{const X=await b.getGitDiff(u,{path:t,staged:lt,contextLines:3});f=bn(X.diff)}catch{f=null}let h=i;if(f===null||!h){const X=await b.getGitFileDiff(u,{path:t,staged:lt}),jt={original:X.original??"",modified:X.modified??"",isBinary:X.isBinary,submodule:X.submodule};h=jt,lt||K(u,t,jt,l)}const F=f??(h.isBinary||ft(t)?1:kn(h.original,h.modified)),V=dr(u,t),P=await Js(j,V,{directory:u});if(!P.ok){tt.error(Ys(P.reason));return}ht(u,V,F,1)}finally{pn(f=>f===t?null:f)}},[lt,u,j,b,ht,K]),is=()=>{if(!u)return null;const t=(l,f=!1)=>n.jsx(br,{visible:a,directory:u,file:l,layout:Ot(l),wrapLines:Pe,hideWhitespace:De,isSelected:!1,isExpanded:f||C.has(l.path),isMounted:f||se.has(l.path)||l.path===B,onSelect:Yn,onExpandedChange:Un,registerSectionRef:Kn,showOpenInEditorAction:g&&d!=="turn",isOpeningInEditor:ss===l.path,onOpenInEditor:(h,F)=>{rs(h,F)},staged:i(l.path),readOnlyActions:d==="branch"||d==="commit"||d==="pr",hunkActionsEnabled:d==="all"||d==="working"||d==="staged",contentRevision:Bt+(rt.get(l.path)??0),comparisonDiff:d==="branch"||d==="commit"||d==="pr"?$n.get(l.path)??jn:void 0,onRetryComparisonDiff:()=>On(h=>h+1),loadFullComparisonDiff:qn,initialDiffData:d==="turn"?M.get(l.path)??null:null},`${Te()}:${u}:${l.path}`),i=l=>gt!==null?gt:J&&l===U;return n.jsxs("div",{ref:fn,className:oe("flex min-w-0 flex-1 min-h-0 h-full",y?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[ke&&n.jsxs(n.Fragment,{children:[n.jsx("section",{className:"flex max-w-[50%] flex-shrink-0 flex-col",style:{width:`${wt}px`},children:n.jsx(gr,{changedFiles:T,selectedFile:ut?.path??null,onSelectFile:Lt})}),n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("diffView.fileTree.resize"),tabIndex:0,onPointerDown:es,onKeyDown:ts,className:oe("relative w-px shrink-0 cursor-col-resize bg-[var(--interactive-border)]/40","before:absolute before:inset-y-0 before:-left-1 before:-right-1 before:content-['']","hover:bg-interactive-selection focus-visible:bg-interactive-selection focus-visible:outline-none",Zn&&"bg-interactive-selection")})]}),Ct&&!ke&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:o("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:T.length})]}),n.jsx(pr,{changedFiles:T,selectedFile:null,onSelectFile:Lt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(Xt,{ref:Re,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:ke?ut&&t(ut,!0):T.map(l=>t(l))})})})]})},os=()=>{if(!u)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:o("diffView.state.selectSessionDirectory")});if(d!=="turn"&&G&&!k)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.state.loadingRepositoryStatus")]});if(d!=="turn"&&S===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:o("diffView.state.notGitRepository")});if(d==="pr"){if(!Ee||I.error)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[!I.error&&!ue.error&&!ue.loading&&n.jsx(z,{name:"git-pull-request",className:"size-6 text-muted-foreground"}),n.jsx("p",{className:"typography-meta text-muted-foreground",children:I.error??ue.error??(ue.loading?o(Mt("session.githubPrPicker.loading.pullRequests",ue.provider)):o(Mt("pullRequestComparison.pickAbove",ue.provider)))}),(I.error||ue.error)&&n.jsx(ye,{variant:"outline",size:"sm",onClick:()=>{Ee?I.refresh():ue.refresh()},children:o("diffView.actions.retry")})]});if(!I.files)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.state.loadingDiff")]})}if(d==="commit"){if(rn)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:rn}),n.jsx(ye,{variant:"outline",size:"sm",onClick:()=>{I.refresh()},children:o("diffView.actions.retry")})]});if(!Ze&&!Ge.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Ge.error??o("commitComparison.noCommits")});if(!sn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.state.loadingDiff")]})}if(d==="branch"){if(!zn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.branch.resolvingBase")]});if(!Ke)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(z,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:o("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:o("gitView.pr.toast.baseBranchRequired")})]});if(on)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:o("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:on}),n.jsx(ye,{variant:"outline",size:"sm",onClick:()=>{I.refresh()},children:o("diffView.actions.retry")})]});if(Rt===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.branch.loadingFiles")]})}return T.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:d==="turn"?o("diffView.state.noLastTurnChanges"):d==="pr"?o("walkthrough.blocked.emptyDiff.description"):d==="commit"?o("commitComparison.emptyDiff"):d==="branch"&&Ke?o("diffView.branch.empty",{base:Us(Ke)}):o("diffView.state.cleanWorkingTree")}):is()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[w===!1&&Array.isArray(E)&&E.length>0?n.jsx(Ks,{repositories:E,selectedRepository:D??null,onSelectRepository:t=>{p&&Ce(p,t)},repositoryRoot:p??void 0}):null,!Z&&(d!=="all"?n.jsx(mr,{scope:d,workingCount:xt,stagedCount:qe,turnCount:$e,branchCount:Gn,commitCount:d==="commit"?sn?.length??null:null,prCount:d==="pr"?I.files?.length??null:null,showCommitOption:!Ae(),showBranchOption:Qt,changeRequestProvider:ue.provider,onScopeChange:t=>{ce(t),v?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:G&&!k?o("diffView.state.loadingChanges"):T.length===1?o("diffView.summary.changedFilesSingle",{count:T.length}):o("diffView.summary.changedFilesPlural",{count:T.length})})})),d==="branch"&&n.jsx(ms,{branches:et?.all??[],currentBranch:W,base:bt,onSelect:t=>{u&&W&&Pn(u,W,t)}},JSON.stringify([u,W])),d==="commit"&&n.jsx(ps,{commits:Ge.commits,selectedHash:Ze,loading:Ge.loading,error:Ge.error,onSelect:Ge.select,onRefresh:()=>{Ge.refresh()}},JSON.stringify([u,W])),d==="pr"&&n.jsxs(n.Fragment,{children:[n.jsx(hs,{comparison:ue},JSON.stringify([L,u,W])),Ee&&n.jsx(ye,{variant:"ghost",size:"sm",disabled:I.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),title:o("session.githubIssuePicker.actions.refresh"),onClick:()=>{I.refresh()},children:n.jsx(z,{name:"refresh",className:"size-4"})})]}),T.length>0&&n.jsxs(ye,{variant:"ghost",size:"sm",onClick:Xn,className:oe("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:C.size>0?o("diffView.actions.collapseAll"):o("diffView.actions.expandAll"),children:[n.jsx(z,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:C.size>0?o("diffView.actions.collapseAll"):o("diffView.actions.expandAll")})]}),T.length>0&&kt&&n.jsxs(ye,{variant:"default",size:"sm",onClick:()=>ot(!0),disabled:Le,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":o("diffView.actions.reviewAria"),children:[Le?n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(z,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:o("diffView.actions.review")})]}),T.length>0&&Qe&&(d!=="pr"||Ft)&&n.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>{const t=u??"";ae(t,d==="pr"&&Ee&&Ft?{source:Ee,context:Ft}:{source:d==="commit"&&Ze?{kind:"commit",hash:Ze}:d==="branch"&&Ke&&W?{kind:"branch",baseRef:Ke,headRef:W}:{kind:"working-tree",scope:d==="staged"||d==="working"?d:"all"}}),_(p??t,"walkthrough")},className:oe("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",Qs),"aria-label":o("walkthrough.action.open"),children:[n.jsx(z,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:o("walkthrough.action.open")})]}),T.length>0&&!Fe&&n.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>It(Ie==="tree"?"flat":"tree"),"aria-pressed":Ie==="tree",className:oe("h-5 w-5 p-0 transition-opacity",Ie==="tree"?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:o(Ie==="tree"?"diffView.fileTree.showAsList":"diffView.fileTree.showAsTree"),children:n.jsx(z,{name:"node-tree",className:"size-4"})}),T.length>0&&n.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>ie(!Ye),className:oe("h-5 w-5 p-0 transition-opacity",Pe?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:o(Pe?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(z,{name:"text-wrap",className:"size-4"})}),T.length>0&&n.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>je(!De),"aria-pressed":De,className:oe("h-5 w-5 p-0 transition-opacity",De?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:o(De?"diffView.actions.showWhitespace":"diffView.actions.hideWhitespace"),"aria-label":o(De?"diffView.actions.showWhitespace":"diffView.actions.hideWhitespace"),children:n.jsx(z,{name:"space",className:"size-4"})}),un&&n.jsx(Rn,{mode:un==="side-by-side"?"side-by-side":"unified",onModeChange:ns})]}),n.jsx(Ps,{open:it,onOpenChange:ot,projectDirectory:u??null,submitting:Le,onConfirm:Jn}),os()]})};function wr(){return new Set}function vr(a,e){return n.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 w-px bg-border/50",style:{left:`${Vn+e*Tn+7}px`}},e)}function jr(a){return Array.from({length:a},vr)}export{qo as DiffView,br as MultiFileDiffEntry};
@@ -0,0 +1,4 @@
1
+ import{j as r,f as he,R as d,c as ce}from"./vendor-react-BUCujlKS.js";import{I as ae,a as ge}from"./useInlineCommentController-kMN4Wg_D.js";import{f as ve,bJ as we,z as fe,ay as _e,dq as be,I as Se,h as te,le as ye,ds as Re,lf as Ce}from"./useAppFontEffects-DGlvOqP_.js";import"./index-DxNa7xYB.js";function Fe(i){const{drafts:e,editingDraftId:h,commentText:f,onTextChange:x,selection:s,isDragging:g,fileLabel:S,newWidgetId:y,mapDraftToRange:R,onSave:C,onCancel:c,onEdit:O,onDelete:a}=i,v=[];for(const t of e){const E=R(t);if(t.id===h){v.push({afterLine:E.end,id:`edit-${t.id}`,content:r.jsx(ae,{initialText:f,onTextChange:x,fileLabel:S,lineRange:E,isEditing:!0,onSave:C,onCancel:c},`edit-${t.id}`)});continue}v.push({afterLine:E.end,id:`card-${t.id}`,content:r.jsx(ge,{draft:t,onEdit:()=>O(t),onDelete:()=>a(t)},`card-${t.id}`)})}if(s&&!h&&!g){const t={...s,start:Math.min(s.start,s.end),end:Math.max(s.start,s.end)};v.push({afterLine:t.end,id:y,content:r.jsx(ae,{initialText:f,onTextChange:x,fileLabel:S,lineRange:t,isEditing:!1,onSave:C,onCancel:c},y)})}return v}function $e(i){const e=he.c(63),{containerRef:h,filePath:f,fileContent:x}=i,{t:s}=ve(),{isMobile:g}=we(),S=fe(ze),y=fe(Me),R=_e(),C=be(Ne),[c,O]=d.useState(null),[a,v]=d.useState(""),[t,E]=d.useState(!1),[ne,me]=d.useState(""),P=d.useRef(!1),oe=d.useRef(null),ie=d.useRef(null),[z,re]=d.useState(null);let F;e[0]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{O(null),v(""),E(!1),P.current=!1,ie.current=null,re(null)},e[0]=F):F=e[0];const w=F;let $,q;e[1]!==h?($=()=>{const n=h.current;if(!n)return;const o=()=>{if(P.current)return;const m=window.getSelection(),A=m?.toString().trim()??"";if(!m||!A||m.rangeCount===0){w();return}const p=m.getRangeAt(0);if(!n.contains(p.commonAncestorContainer)){w();return}const b=p.getBoundingClientRect();ie.current=p.cloneRange(),v(A),O({x:b.left+b.width/2,y:b.top-10})},l=m=>{oe.current?.contains(m.target)||P.current&&w()};return document.addEventListener("selectionchange",o),document.addEventListener("pointerdown",l),()=>{document.removeEventListener("selectionchange",o),document.removeEventListener("pointerdown",l)}},q=[h,w],e[1]=h,e[2]=$,e[3]=q):($=e[2],q=e[3]),d.useEffect($,q);let B;e[4]!==x?(B=n=>{const o=M=>x.slice(0,M).split(`
2
+ `).length,l=Ie,m=(M,pe)=>{for(const xe of l(M)){const ue=x.indexOf(xe,pe);if(ue>=0)return ue}return-1},A=n.length>=8?x.indexOf(n):-1;if(A>=0){const M=o(A);return{start:M,end:M+n.split(`
3
+ `).length-1}}const p=n.split(`
4
+ `).map(De).filter(Boolean);if(p.length===0)return null;const b=m(p[0],0);if(b<0)return null;const ee=o(b);if(p.length===1)return{start:ee,end:ee};const de=m(p[p.length-1],b);return de<0?null:{start:ee,end:Math.max(ee,o(de))}},e[4]=x,e[5]=B):B=e[5];const L=B;let H;e[6]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{const n=ie.current;if(!n){re(null);return}re(ye(n))},e[6]=H):H=e[6];const se=H;let K,U;e[7]!==t?(K=()=>{if(!t)return;let n=null;const o=()=>{n===null&&(n=window.requestAnimationFrame(()=>{n=null,se()}))};return document.addEventListener("scroll",o,{capture:!0,passive:!0}),window.addEventListener("resize",o),()=>{n!==null&&window.cancelAnimationFrame(n),document.removeEventListener("scroll",o,{capture:!0}),window.removeEventListener("resize",o)}},U=[t,se],e[7]=t,e[8]=K,e[9]=U):(K=e[8],U=e[9]),d.useEffect(K,U);let W;e[10]!==a?(W=n=>{a&&(me(n),E(!0),P.current=!0,se(),window.getSelection()?.removeAllRanges())},e[10]=a,e[11]=W):W=e[11];const u=W;let J,G;e[12]!==c||e[13]!==t||e[14]!==g||e[15]!==u?(G=()=>{if(!c||t||g)return;const n=o=>{const l=Ce(o);l&&(o.preventDefault(),u(l))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},J=[c,t,g,u],e[12]=c,e[13]=t,e[14]=g,e[15]=u,e[16]=J,e[17]=G):(J=e[16],G=e[17]),d.useEffect(G,J);let Q;e[18]!==C||e[19]!==S||e[20]!==R||e[21]!==f||e[22]!==y||e[23]!==L||e[24]!==a?(Q=n=>{const o=S??(y?"draft":null);if(!a||!o||!R){w();return}const l=L(a);C({directory:R,sessionKey:o},{source:"file-quote",fileLabel:f,startLine:l?.start??0,endLine:l?.end??0,code:a,language:"",text:n.trim()}),w(),queueMicrotask(je)},e[18]=C,e[19]=S,e[20]=R,e[21]=f,e[22]=y,e[23]=L,e[24]=a,e[25]=Q):Q=e[25];const le=Q;if(!c)return null;let V;e[26]!==t||e[27]!==L||e[28]!==a?(V=t?L(a):null,e[26]=t,e[27]=L,e[28]=a,e[29]=V):V=e[29];const k=V;let X;e[30]!==t||e[31]!==z?(X=t&&z&&z.length>0?r.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:z.map(Le)}):null,e[30]=t,e[31]=z,e[32]=X):X=e[32];const _=X;let j;e[33]!==k?(j=k?{start:k.start,end:k.end}:void 0,e[33]=k,e[34]=j):j=e[34];let Y;e[35]!==f||e[36]!==ne||e[37]!==le||e[38]!==j?(Y=r.jsx(ae,{initialText:ne,fileLabel:f,lineRange:j,onSave:le,onCancel:w}),e[35]=f,e[36]=ne,e[37]=le,e[38]=j,e[39]=Y):Y=e[39];const D=Y;if(g){let n;e[40]===Symbol.for("react.memo_cache_sentinel")?(n={paddingBottom:"calc(0.5rem + env(safe-area-inset-bottom, 0px))"},e[40]=n):n=e[40];let o;e[41]!==D||e[42]!==t||e[43]!==u||e[44]!==s?(o=r.jsx("div",{ref:oe,className:"pointer-events-auto mx-auto max-w-[420px] px-3",style:n,children:t?D:r.jsx("div",{className:te("mx-auto w-fit","oc-glass-popover rounded-full border border-[var(--interactive-border)]","p-1 shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]"),children:r.jsxs("button",{type:"button",onMouseDown:Ee,onClick:()=>u(""),className:te("flex min-w-0 items-center gap-2 rounded-full px-4 py-2","text-sm font-medium leading-tight text-foreground","active:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:s("chat.textSelection.title.commentOnSelection"),children:[r.jsx(Se,{name:"chat-1",className:"size-4 flex-shrink-0"}),r.jsx("span",{className:"min-w-0 whitespace-nowrap",children:s("chat.textSelection.actions.comment")})]})})}),e[41]=D,e[42]=t,e[43]=u,e[44]=s,e[45]=o):o=e[45];let l;return e[46]!==_||e[47]!==o?(l=ce.createPortal(r.jsxs("div",{className:"oc-keyboard-inset-surface pointer-events-none fixed inset-x-0 bottom-0 z-50",children:[_,o]}),document.body),e[46]=_,e[47]=o,e[48]=l):l=e[48],l}let I;e[49]!==c.x||e[50]!==c.y?(I={left:c.x,top:c.y,transform:"translate(-50%, -100%)"},e[49]=c.x,e[50]=c.y,e[51]=I):I=e[51];let T;e[52]!==_?(T=_?ce.createPortal(_,document.body):null,e[52]=_,e[53]=T):T=e[53];let N;e[54]!==D||e[55]!==t||e[56]!==u||e[57]!==s?(N=t?r.jsx("div",{className:"w-[min(420px,80vw)]",children:D}):r.jsx("div",{className:te("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:r.jsx("button",{type:"button",onClick:()=>u(""),className:te("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:s("chat.textSelection.title.commentOnSelection"),children:s("chat.textSelection.actions.comment")})}),e[54]=D,e[55]=t,e[56]=u,e[57]=s,e[58]=N):N=e[58];let Z;return e[59]!==I||e[60]!==T||e[61]!==N?(Z=ce.createPortal(r.jsxs("div",{ref:oe,className:"fixed z-50",style:I,children:[T,N]}),document.body),e[59]=I,e[60]=T,e[61]=N,e[62]=Z):Z=e[62],Z}function Ee(i){return i.preventDefault()}function Le(i,e){return r.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:i.left,top:i.top,width:i.width,height:i.height}},e)}function je(){Re()}function De(i){return i.trim()}function Ie(i){const e=i.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Te)}function Te(i){return i.length>=8}function Ne(i){return i.addDraft}function Me(i){return i.newSessionDraft?.open}function ze(i){return i.currentSessionId}export{$e as F,Fe as b};