@deepseek-ai/dsh-experimental-client-ui-forge 0.2.3-alpha.2 → 0.2.3-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. package/README.i18n.yaml +10 -10
  2. package/README.md +37 -19
  3. package/README.zh.md +37 -19
  4. package/lib/client.js +22 -17
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +941 -188
  7. package/lib/typert.host.js +894 -175
  8. package/lib/typert.remote-client.d.ts +35 -17
  9. package/lib/typert.remote-client.d.ts.map +1 -1
  10. package/lib/typert.remote-client.js +751 -146
  11. package/lib/types/client/ActionToast.d.ts +1 -1
  12. package/lib/types/client/ActionToast.d.ts.map +1 -1
  13. package/lib/types/client/ActionToast.js.map +1 -1
  14. package/lib/types/client/BaseMenu.d.ts +6 -4
  15. package/lib/types/client/BaseMenu.d.ts.map +1 -1
  16. package/lib/types/client/BaseMenu.js.map +1 -1
  17. package/lib/types/client/BranchPicker.d.ts +84 -0
  18. package/lib/types/client/BranchPicker.d.ts.map +1 -0
  19. package/lib/types/client/BranchPicker.js.map +1 -0
  20. package/lib/types/client/ChangeRequestCard.d.ts +31 -13
  21. package/lib/types/client/ChangeRequestCard.d.ts.map +1 -1
  22. package/lib/types/client/ChangeRequestCard.js.map +1 -1
  23. package/lib/types/client/ChangeRequestOverview.d.ts +28 -6
  24. package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -1
  25. package/lib/types/client/ChangeRequestOverview.js.map +1 -1
  26. package/lib/types/client/ChangeRequestsSection.d.ts +5 -3
  27. package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -1
  28. package/lib/types/client/ChangeRequestsSection.js.map +1 -1
  29. package/lib/types/client/ChangeStatus.d.ts +41 -0
  30. package/lib/types/client/ChangeStatus.d.ts.map +1 -0
  31. package/lib/types/client/ChangeStatus.js.map +1 -0
  32. package/lib/types/client/ChangedFiles.d.ts +1 -1
  33. package/lib/types/client/ChangedFiles.d.ts.map +1 -1
  34. package/lib/types/client/ChangedFiles.js.map +1 -1
  35. package/lib/types/client/ChangesLoading.d.ts +1 -1
  36. package/lib/types/client/ChangesLoading.d.ts.map +1 -1
  37. package/lib/types/client/ChangesTab.d.ts +35 -12
  38. package/lib/types/client/ChangesTab.d.ts.map +1 -1
  39. package/lib/types/client/ChangesTab.js.map +1 -1
  40. package/lib/types/client/ChangesTabTitle.d.ts +1 -1
  41. package/lib/types/client/ChangesTabTitle.d.ts.map +1 -1
  42. package/lib/types/client/ChangesTabTitle.js.map +1 -1
  43. package/lib/types/client/CommitMenu.d.ts +11 -8
  44. package/lib/types/client/CommitMenu.d.ts.map +1 -1
  45. package/lib/types/client/CommitMenu.js.map +1 -1
  46. package/lib/types/client/CopyCommandButton.d.ts +19 -0
  47. package/lib/types/client/CopyCommandButton.d.ts.map +1 -0
  48. package/lib/types/client/CopyCommandButton.js.map +1 -0
  49. package/lib/types/client/DiffFile.d.ts +36 -5
  50. package/lib/types/client/DiffFile.d.ts.map +1 -1
  51. package/lib/types/client/DiffFile.js.map +1 -1
  52. package/lib/types/client/EnvironmentRows.d.ts +6 -6
  53. package/lib/types/client/EnvironmentRows.d.ts.map +1 -1
  54. package/lib/types/client/EnvironmentRows.js.map +1 -1
  55. package/lib/types/client/FileLabel.d.ts +5 -5
  56. package/lib/types/client/FileLabel.d.ts.map +1 -1
  57. package/lib/types/client/FileLabel.js.map +1 -1
  58. package/lib/types/client/HeadMenu.d.ts +35 -0
  59. package/lib/types/client/HeadMenu.d.ts.map +1 -0
  60. package/lib/types/client/HeadMenu.js.map +1 -0
  61. package/lib/types/client/HostSettings.d.ts +33 -0
  62. package/lib/types/client/HostSettings.d.ts.map +1 -0
  63. package/lib/types/client/HostSettings.js.map +1 -0
  64. package/lib/types/client/LensFilter.d.ts +2 -2
  65. package/lib/types/client/LensFilter.d.ts.map +1 -1
  66. package/lib/types/client/LensFilter.js.map +1 -1
  67. package/lib/types/client/ReasonButton.js.map +1 -1
  68. package/lib/types/client/RefreshGlyph.js.map +1 -1
  69. package/lib/types/client/ReviewComposer.d.ts +1 -1
  70. package/lib/types/client/ReviewComposer.d.ts.map +1 -1
  71. package/lib/types/client/ReviewComposer.js.map +1 -1
  72. package/lib/types/client/ReviewControls.d.ts +1 -1
  73. package/lib/types/client/ReviewControls.d.ts.map +1 -1
  74. package/lib/types/client/ReviewControls.js.map +1 -1
  75. package/lib/types/client/ReviewThread.d.ts +1 -1
  76. package/lib/types/client/ReviewThread.d.ts.map +1 -1
  77. package/lib/types/client/ReviewThread.js.map +1 -1
  78. package/lib/types/client/ReviewThreads.d.ts +21 -4
  79. package/lib/types/client/ReviewThreads.d.ts.map +1 -1
  80. package/lib/types/client/ReviewThreads.js.map +1 -1
  81. package/lib/types/client/SessionHoverForge.d.ts +1 -1
  82. package/lib/types/client/SessionHoverForge.d.ts.map +1 -1
  83. package/lib/types/client/SessionHoverForge.js.map +1 -1
  84. package/lib/types/client/SessionRowForge.d.ts +1 -1
  85. package/lib/types/client/SessionRowForge.d.ts.map +1 -1
  86. package/lib/types/client/SessionRowForge.js.map +1 -1
  87. package/lib/types/client/SubmitReview.d.ts +1 -1
  88. package/lib/types/client/SubmitReview.d.ts.map +1 -1
  89. package/lib/types/client/SubmitReview.js.map +1 -1
  90. package/lib/types/client/ThreadList.d.ts +3 -1
  91. package/lib/types/client/ThreadList.d.ts.map +1 -1
  92. package/lib/types/client/ThreadList.js.map +1 -1
  93. package/lib/types/client/ViewOptionsMenu.d.ts +1 -1
  94. package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -1
  95. package/lib/types/client/ViewOptionsMenu.js.map +1 -1
  96. package/lib/types/client/WorktreeNameDialog.d.ts +1 -1
  97. package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -1
  98. package/lib/types/client/WorktreeNameDialog.js.map +1 -1
  99. package/lib/types/client/WorktreeProgress.d.ts +1 -1
  100. package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
  101. package/lib/types/client/WorktreeProgress.js.map +1 -1
  102. package/lib/types/client/WorktreeSettings.d.ts +1 -1
  103. package/lib/types/client/WorktreeSettings.d.ts.map +1 -1
  104. package/lib/types/client/WorktreeSettings.js.map +1 -1
  105. package/lib/types/client/WorktreeToggle.d.ts +1 -1
  106. package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
  107. package/lib/types/client/WorktreeToggle.js.map +1 -1
  108. package/lib/types/client/annotations.d.ts +1 -1
  109. package/lib/types/client/annotations.d.ts.map +1 -1
  110. package/lib/types/client/branch-search.d.ts +1 -1
  111. package/lib/types/client/branch-search.d.ts.map +1 -1
  112. package/lib/types/client/branch-search.js.map +1 -1
  113. package/lib/types/client/changes-address.d.ts +1 -1
  114. package/lib/types/client/changes-address.d.ts.map +1 -1
  115. package/lib/types/client/changes-service.d.ts +1 -1
  116. package/lib/types/client/changes-service.d.ts.map +1 -1
  117. package/lib/types/client/changes-store.d.ts +25 -6
  118. package/lib/types/client/changes-store.d.ts.map +1 -1
  119. package/lib/types/client/changes-store.js.map +1 -1
  120. package/lib/types/client/checkout.d.ts +1 -1
  121. package/lib/types/client/checkout.d.ts.map +1 -1
  122. package/lib/types/client/code-selection.d.ts.map +1 -1
  123. package/lib/types/client/code-selection.js.map +1 -1
  124. package/lib/types/client/forge-copy.d.ts +8 -1
  125. package/lib/types/client/forge-copy.d.ts.map +1 -1
  126. package/lib/types/client/forge-copy.js.map +1 -1
  127. package/lib/types/client/format.d.ts +1 -1
  128. package/lib/types/client/format.d.ts.map +1 -1
  129. package/lib/types/client/format.js.map +1 -1
  130. package/lib/types/client/glyphs.d.ts +36 -1
  131. package/lib/types/client/glyphs.d.ts.map +1 -1
  132. package/lib/types/client/glyphs.js.map +1 -1
  133. package/lib/types/client/highlight-context.d.ts +1 -1
  134. package/lib/types/client/highlight-context.d.ts.map +1 -1
  135. package/lib/types/client/host-settings-form.d.ts +69 -0
  136. package/lib/types/client/host-settings-form.d.ts.map +1 -0
  137. package/lib/types/client/host-settings-form.js.map +1 -0
  138. package/lib/types/client/host-sign-in.d.ts +31 -0
  139. package/lib/types/client/host-sign-in.d.ts.map +1 -0
  140. package/lib/types/client/host-sign-in.js.map +1 -0
  141. package/lib/types/client/index.d.ts +1 -2
  142. package/lib/types/client/index.d.ts.map +1 -1
  143. package/lib/types/client/index.js.map +1 -1
  144. package/lib/types/client/local-writes.d.ts +47 -0
  145. package/lib/types/client/local-writes.d.ts.map +1 -0
  146. package/lib/types/client/local-writes.js.map +1 -0
  147. package/lib/types/client/locales.d.ts +111 -13
  148. package/lib/types/client/locales.d.ts.map +1 -1
  149. package/lib/types/client/locales.js.map +1 -1
  150. package/lib/types/client/minute-clock.d.ts +7 -0
  151. package/lib/types/client/minute-clock.d.ts.map +1 -0
  152. package/lib/types/client/minute-clock.js.map +1 -0
  153. package/lib/types/client/mount.d.ts +15 -1
  154. package/lib/types/client/mount.d.ts.map +1 -1
  155. package/lib/types/client/mount.js.map +1 -1
  156. package/lib/types/client/review-page/ReviewActivity.d.ts +44 -0
  157. package/lib/types/client/review-page/ReviewActivity.d.ts.map +1 -0
  158. package/lib/types/client/review-page/ReviewActivity.js.map +1 -0
  159. package/lib/types/client/review-page/ReviewChat.d.ts +1 -1
  160. package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -1
  161. package/lib/types/client/review-page/ReviewChat.js.map +1 -1
  162. package/lib/types/client/review-page/ReviewDetail.d.ts +26 -9
  163. package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -1
  164. package/lib/types/client/review-page/ReviewDetail.js.map +1 -1
  165. package/lib/types/client/review-page/ReviewLabels.d.ts +1 -1
  166. package/lib/types/client/review-page/ReviewLabels.d.ts.map +1 -1
  167. package/lib/types/client/review-page/ReviewLabels.js.map +1 -1
  168. package/lib/types/client/review-page/ReviewList.d.ts +10 -8
  169. package/lib/types/client/review-page/ReviewList.d.ts.map +1 -1
  170. package/lib/types/client/review-page/ReviewList.js.map +1 -1
  171. package/lib/types/client/review-page/ReviewNav.d.ts +1 -1
  172. package/lib/types/client/review-page/ReviewNav.d.ts.map +1 -1
  173. package/lib/types/client/review-page/ReviewPage.d.ts +17 -14
  174. package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -1
  175. package/lib/types/client/review-page/ReviewPage.js.map +1 -1
  176. package/lib/types/client/review-page/ReviewSkeleton.d.ts +26 -0
  177. package/lib/types/client/review-page/ReviewSkeleton.d.ts.map +1 -0
  178. package/lib/types/client/review-page/ReviewSkeleton.js.map +1 -0
  179. package/lib/types/client/review-page/ReviewStatus.d.ts +19 -13
  180. package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -1
  181. package/lib/types/client/review-page/ReviewStatus.js.map +1 -1
  182. package/lib/types/client/review-page/review-activity.d.ts +37 -0
  183. package/lib/types/client/review-page/review-activity.d.ts.map +1 -0
  184. package/lib/types/client/review-page/review-activity.js.map +1 -0
  185. package/lib/types/client/review-page/review-lists.d.ts +48 -13
  186. package/lib/types/client/review-page/review-lists.d.ts.map +1 -1
  187. package/lib/types/client/review-page/review-lists.js.map +1 -1
  188. package/lib/types/client/review-page/review-mount.d.ts +3 -1
  189. package/lib/types/client/review-page/review-mount.d.ts.map +1 -1
  190. package/lib/types/client/review-page/review-mount.js.map +1 -1
  191. package/lib/types/client/review-page/review-store.d.ts +19 -9
  192. package/lib/types/client/review-page/review-store.d.ts.map +1 -1
  193. package/lib/types/client/review-page/review-store.js.map +1 -1
  194. package/lib/types/client/review-queue.d.ts +1 -1
  195. package/lib/types/client/review-queue.d.ts.map +1 -1
  196. package/lib/types/client/review-queue.js.map +1 -1
  197. package/lib/types/client/review-threads.d.ts +15 -8
  198. package/lib/types/client/review-threads.d.ts.map +1 -1
  199. package/lib/types/client/review-threads.js.map +1 -1
  200. package/lib/types/client/review.d.ts +12 -1
  201. package/lib/types/client/review.d.ts.map +1 -1
  202. package/lib/types/client/review.js.map +1 -1
  203. package/lib/types/client/row-form-labels.d.ts +12 -0
  204. package/lib/types/client/row-form-labels.d.ts.map +1 -0
  205. package/lib/types/client/row-form-labels.js.map +1 -0
  206. package/lib/types/client/session-list.d.ts +1 -1
  207. package/lib/types/client/session-list.d.ts.map +1 -1
  208. package/lib/types/client/slots.d.ts +1 -1
  209. package/lib/types/client/slots.d.ts.map +1 -1
  210. package/lib/types/client/source.d.ts +1 -1
  211. package/lib/types/client/source.d.ts.map +1 -1
  212. package/lib/types/client/status.d.ts +7 -6
  213. package/lib/types/client/status.d.ts.map +1 -1
  214. package/lib/types/client/status.js.map +1 -1
  215. package/lib/types/client/thread-state.d.ts +2 -2
  216. package/lib/types/client/thread-state.d.ts.map +1 -1
  217. package/lib/types/client/thread-state.js.map +1 -1
  218. package/lib/types/client/toolbar-fold.d.ts +16 -6
  219. package/lib/types/client/toolbar-fold.d.ts.map +1 -1
  220. package/lib/types/client/toolbar-fold.js.map +1 -1
  221. package/lib/types/client/worktree-settings-form.d.ts +1 -1
  222. package/lib/types/client/worktree-settings-form.d.ts.map +1 -1
  223. package/lib/types/client/worktree-settings-form.js.map +1 -1
  224. package/lib/types/diff.d.ts.map +1 -1
  225. package/lib/types/diff.js.map +1 -1
  226. package/lib/types/git.d.ts +22 -0
  227. package/lib/types/git.d.ts.map +1 -1
  228. package/lib/types/git.js.map +1 -1
  229. package/lib/types/index.d.ts +137 -36
  230. package/lib/types/index.d.ts.map +1 -1
  231. package/lib/types/index.js.map +1 -1
  232. package/lib/types/local-diff.d.ts +81 -23
  233. package/lib/types/local-diff.d.ts.map +1 -1
  234. package/lib/types/local-diff.js.map +1 -1
  235. package/lib/types/local-write.d.ts +44 -0
  236. package/lib/types/local-write.d.ts.map +1 -0
  237. package/lib/types/local-write.js.map +1 -0
  238. package/lib/types/panel.js.map +1 -1
  239. package/lib/types/parse.d.ts +12 -3
  240. package/lib/types/parse.d.ts.map +1 -1
  241. package/lib/types/parse.js.map +1 -1
  242. package/lib/types/restore.d.ts +12 -0
  243. package/lib/types/restore.d.ts.map +1 -0
  244. package/lib/types/restore.js.map +1 -0
  245. package/lib/types/types.d.ts +128 -13
  246. package/lib/types/types.d.ts.map +1 -1
  247. package/lib/types/viewer-lists.d.ts +22 -13
  248. package/lib/types/viewer-lists.d.ts.map +1 -1
  249. package/lib/types/viewer-lists.js.map +1 -1
  250. package/lib/types/worktree.js.map +1 -1
  251. package/package.json +62 -58
  252. package/src/client/ActionToast.tsx +2 -2
  253. package/src/client/BaseMenu.module.css +15 -3
  254. package/src/client/BaseMenu.tsx +25 -88
  255. package/src/client/BranchPicker.tsx +170 -0
  256. package/src/client/ChangeRequestCard.tsx +194 -70
  257. package/src/client/ChangeRequestOverview.tsx +194 -82
  258. package/src/client/ChangeRequestsSection.tsx +45 -14
  259. package/src/client/ChangeStatus.module.css +70 -0
  260. package/src/client/ChangeStatus.tsx +104 -0
  261. package/src/client/ChangedFiles.tsx +22 -9
  262. package/src/client/ChangesLoading.tsx +1 -1
  263. package/src/client/ChangesTab.module.css +181 -33
  264. package/src/client/ChangesTab.tsx +499 -183
  265. package/src/client/ChangesTabTitle.tsx +2 -2
  266. package/src/client/CommitMenu.tsx +83 -42
  267. package/src/client/CopyCommandButton.tsx +25 -0
  268. package/src/client/DiffFile.tsx +147 -29
  269. package/src/client/EnvironmentRows.tsx +34 -28
  270. package/src/client/FileLabel.module.css +16 -18
  271. package/src/client/FileLabel.tsx +16 -32
  272. package/src/client/Forge.module.css +26 -6
  273. package/src/client/HeadMenu.tsx +69 -0
  274. package/src/client/HostSettings.module.css +194 -0
  275. package/src/client/HostSettings.tsx +194 -0
  276. package/src/client/LensFilter.tsx +13 -11
  277. package/src/client/ReasonButton.tsx +1 -1
  278. package/src/client/RefreshGlyph.tsx +1 -1
  279. package/src/client/ReviewComposer.tsx +31 -19
  280. package/src/client/ReviewControls.tsx +18 -9
  281. package/src/client/ReviewThread.tsx +65 -23
  282. package/src/client/ReviewThreads.tsx +133 -38
  283. package/src/client/SessionHoverForge.tsx +2 -2
  284. package/src/client/SessionRowForge.tsx +2 -2
  285. package/src/client/SubmitReview.tsx +7 -5
  286. package/src/client/ThreadList.module.css +4 -3
  287. package/src/client/ThreadList.tsx +11 -8
  288. package/src/client/ViewOptionsMenu.tsx +12 -10
  289. package/src/client/WorktreeNameDialog.tsx +17 -13
  290. package/src/client/WorktreeProgress.tsx +13 -11
  291. package/src/client/WorktreeSettings.tsx +8 -14
  292. package/src/client/WorktreeToggle.tsx +67 -37
  293. package/src/client/annotations.ts +1 -1
  294. package/src/client/branch-search.tsx +2 -2
  295. package/src/client/changes-address.ts +1 -1
  296. package/src/client/changes-service.ts +1 -1
  297. package/src/client/changes-store.ts +57 -10
  298. package/src/client/checkout.ts +1 -1
  299. package/src/client/code-selection.ts +3 -1
  300. package/src/client/forge-copy.ts +11 -1
  301. package/src/client/format.ts +2 -2
  302. package/src/client/glyphs.tsx +72 -5
  303. package/src/client/highlight-context.ts +1 -1
  304. package/src/client/host-settings-form.ts +115 -0
  305. package/src/client/host-sign-in.ts +46 -0
  306. package/src/client/index.ts +1 -2
  307. package/src/client/local-writes.ts +129 -0
  308. package/src/client/locales.ts +881 -97
  309. package/src/client/minute-clock.ts +19 -0
  310. package/src/client/mount.ts +121 -57
  311. package/src/client/review-page/ReviewActivity.tsx +406 -0
  312. package/src/client/review-page/ReviewChat.tsx +48 -19
  313. package/src/client/review-page/ReviewDetail.tsx +246 -78
  314. package/src/client/review-page/ReviewLabels.tsx +2 -2
  315. package/src/client/review-page/ReviewList.tsx +173 -151
  316. package/src/client/review-page/ReviewNav.tsx +1 -1
  317. package/src/client/review-page/ReviewPage.module.css +571 -23
  318. package/src/client/review-page/ReviewPage.tsx +84 -53
  319. package/src/client/review-page/ReviewSkeleton.tsx +108 -0
  320. package/src/client/review-page/ReviewStatus.tsx +74 -44
  321. package/src/client/review-page/review-activity.ts +64 -0
  322. package/src/client/review-page/review-lists.ts +85 -22
  323. package/src/client/review-page/review-mount.ts +24 -7
  324. package/src/client/review-page/review-store.ts +24 -7
  325. package/src/client/review-queue.ts +7 -3
  326. package/src/client/review-threads.ts +24 -12
  327. package/src/client/review.ts +20 -2
  328. package/src/client/row-form-labels.ts +17 -0
  329. package/src/client/session-list.ts +1 -1
  330. package/src/client/slots.ts +1 -1
  331. package/src/client/source.ts +1 -1
  332. package/src/client/status.ts +20 -9
  333. package/src/client/thread-state.ts +8 -7
  334. package/src/client/toolbar-fold.ts +59 -14
  335. package/src/client/worktree-settings-form.ts +1 -1
  336. package/src/diff.ts +8 -5
  337. package/src/git.ts +31 -1
  338. package/src/index.ts +319 -70
  339. package/src/local-diff.ts +151 -48
  340. package/src/local-write.ts +159 -0
  341. package/src/panel.ts +1 -1
  342. package/src/parse.ts +26 -4
  343. package/src/restore.ts +15 -0
  344. package/src/types.ts +121 -17
  345. package/src/viewer-lists.ts +124 -48
  346. package/src/worktree.ts +1 -1
  347. package/lib/types/client/AttentionIndicator.d.ts +0 -22
  348. package/lib/types/client/AttentionIndicator.d.ts.map +0 -1
  349. package/lib/types/client/AttentionIndicator.js.map +0 -1
  350. package/src/client/AttentionIndicator.tsx +0 -37
package/src/index.ts CHANGED
@@ -6,31 +6,33 @@ import type { Agent } from '@deepseek-ai/dsh-agent'
6
6
  import type {} from '@deepseek-ai/dsh-api-remote-access'
7
7
  import { changeRequestKey } from '@deepseek-ai/dsh-experimental-forge'
8
8
  import type {
9
- BranchUpdateMethod, ChangeRequestDescription, ChangeRequestKey, ChangeRequestRef, ChangeRequestReviewer, ChangeRequestSnapshot,
10
- ChangeRequestUpdate, ForgeActionFailure, ForgeCommitList,
9
+ AutoMergeRequest, BranchUpdateMethod, ChangeRequestActivity, ChangeRequestDescription, ChangeRequestKey, ChangeRequestRef,
10
+ ChangeRequestReviewer,
11
+ ChangeRequestSnapshot, ChangeRequestUpdate, ForgeActionFailure, ForgeCommitList,
11
12
  ForgeFailure,
12
- ForgeLineComment, ForgeRerunRequest, ForgeReviewChange, ForgeReviewData, ForgeReviewerCandidate, ForgeReviewRequest, ForgeReviewResult,
13
- ForgeReviewWrite, ForgeReviewWriteResult, ForgeViewedFiles, ForgeViewedRequest, MergeMethod,
13
+ ForgeLineComment, ForgeReadiness, ForgeRerunRequest, ForgeReviewChange, ForgeReviewData, ForgeReviewerCandidate, ForgeReviewRequest,
14
+ ForgeReviewResult, ForgeReviewWrite, ForgeReviewWriteResult, ForgeViewedFiles, ForgeViewedRequest, MergeMethod,
14
15
  } from '@deepseek-ai/dsh-experimental-forge'
15
16
  import type { SessionChangeRequest } from '@deepseek-ai/dsh-experimental-forge-session'
16
17
  import type { WorktreeCleanup } from '@deepseek-ai/dsh-experimental-worktree/types'
17
- import { appendPluginRecord } from '@deepseek-ai/dsh-session'
18
+ import { appendPluginRecord } from '@deepseek-ai/dsh-session-store'
18
19
  import type { Session, SessionEvent, SessionId, UserMessage } from '@deepseek-ai/dsh-session'
19
20
  import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
20
21
  import type {} from '@deepseek-ai/dsh-session-projection-cache'
21
22
  import type {} from '@deepseek-ai/dsh-session-query'
22
- import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
23
+ import { deadline, MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
23
24
  import { Remote, RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
24
25
  import { assertNever } from '@deepseek-ai/dsh-util-values'
25
26
  import { gitIn, hasBranch, inspectCheckout } from './git.ts'
26
27
  import type { Inspection } from './git.ts'
27
- import { branchNameProblem } from './branch-name.ts'
28
+ import { branchNameProblem, LOCAL_REF_PREFIX } from './branch-name.ts'
28
29
  import { parseDiff } from './diff.ts'
29
30
  import {
30
- aheadOf, BaseMissing, baseBranches, chosenForkPoint, CommitsMissing, CommitsNotLinear, DiffTooLarge, FilterConfigError, forkPoint,
31
- localCommits, localDiff, localOldText, localText, NoForkPoint,
31
+ aheadOf, baseBranches, BaseMissing, branchTip, branchWorktrees, chosenForkPoint, CommitsMissing, CommitsNotLinear, DiffTooLarge,
32
+ FilterConfigError, forkPoint, HeadMissing, localCommits, localDiff, localOldText, localText, NoForkPoint, sessionHead,
32
33
  } from './local-diff.ts'
33
- import type { ForkPoint } from './local-diff.ts'
34
+ import type { ForkPoint, SessionHead } from './local-diff.ts'
35
+ import { LocalChangesStale, LocalPathReplaced, localWrite } from './local-write.ts'
34
36
  import { LensCache, LensFailed, lensFrames, LensRegistry, LensWithdrawn, runLens } from './lenses.ts'
35
37
  import type { LensSubject } from './lenses.ts'
36
38
  import { lensVersion } from './lens-version.ts'
@@ -44,9 +46,10 @@ import { ChangeRequestStates, changeRequestStatesDomain } from './states.ts'
44
46
  import { Reader, ViewerLists } from './viewer-lists.ts'
45
47
  import type { KeptPanel, PanelConfig } from './panel.ts'
46
48
  import type {
47
- Config, ForgeBaseBranches, ForgeChangeRequestDiff, ForgeChangeRequestStatesFrame, ForgeCommitRange, ForgeDiffFile,
48
- ForgeReviewChangeRequest, ForgeReviewCountFrame, ForgeReviewFrame,
49
+ Config, ForgeBaseBranches, ForgeChangeCommits, ForgeChangeRequestDiff, ForgeChangeRequestStatesFrame, ForgeCommitRange, ForgeDiffFile,
50
+ ForgeReviewChangeRequest, ForgeReviewCountFrame, ForgeReviewFrame, ForgeReviewRepository,
49
51
  ForgeExtensionState, ForgeLens, ForgeLensFrame, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope,
52
+ ForgeLocalWrite, ForgeLocalWriteResult,
50
53
  ForgeMissingWorktree, ForgePanelState, ForgeSessionWorktree, ForgeWorktreeBases, ForgeWorktreeState,
51
54
  } from './types.ts'
52
55
  import { forgeWorktreeProjection, messageOf, within, WORKTREE_RECORD, WorktreeCreations } from './worktree.ts'
@@ -61,6 +64,23 @@ declare module '@deepseek-ai/cordis' {
61
64
  }
62
65
  }
63
66
 
67
+ /** What a local read targets. */
68
+ interface LocalTarget {
69
+ /** The checkout Git runs in: the Session's own, or the worktree that has the head branch checked out. */
70
+ readonly inspection: Inspection
71
+ /** The worktree the Session created, while the read targets its own checkout; it fixes the automatic fork point. */
72
+ readonly created: ForgeSessionWorktree | null
73
+ /** `HEAD` for the checkout's working tree, or the verified ref of a head branch read from its commits. */
74
+ readonly tip: string
75
+ /** Top-level directory of the head branch's worktree, or null for the Session's own checkout and a head read from its commits. */
76
+ readonly worktree: string | null
77
+ /**
78
+ * The Session's own HEAD, which a head branch is compared with while no base branch is chosen; null for the
79
+ * Session's own checkout, and while its checked-out branch has no commit.
80
+ */
81
+ readonly against: SessionHead | null
82
+ }
83
+
64
84
  /** A change request a read or action addresses, with its latest polling result. */
65
85
  interface ChangeRequestTarget {
66
86
  readonly ref: ChangeRequestRef
@@ -196,6 +216,7 @@ export class ForgePanelController extends TypertRemoteService {
196
216
  sources: () => ctx.forge.viewerSources(),
197
217
  list: async (forge, query, signal) => await ctx.forge.listForViewer(forge, query, signal),
198
218
  count: async (forge, host, signal) => await ctx.forge.countForViewer(forge, host, signal),
219
+ signIn: async (forge, host, signal) => (await ctx.forge.readiness({ forge, host }, signal)).signIn?.command ?? null,
199
220
  report: (error) => { ctx.logger.warn(`forge-panel: reading a review list failed: ${String(error)}`) },
200
221
  }, {
201
222
  listIntervalMs: resolved.reviewListIntervalMs,
@@ -287,15 +308,17 @@ export class ForgePanelController extends TypertRemoteService {
287
308
  /**
288
309
  * Stream the review page's lists of the signed-in user's open change requests on every host a provider lists them on:
289
310
  * the lists read so far first, then a frame after each read settles. Readers of one repository scope share one
290
- * reader, which reads every `reviewListIntervalMs` while some stream lasts and backs off after failed rounds up to
291
- * `reviewMaxBackoffMs`; nothing is read while no stream lasts. The stream ends when `signal` aborts or the Remote stops.
292
- * @param repository - one repository to list in, or null for every repository the user can read.
311
+ * reader, which reads each host every `reviewListIntervalMs` while some stream lasts and reads a host whose read failed
312
+ * again later each time, up to `reviewMaxBackoffMs`, without delaying the other hosts; nothing is read while no stream
313
+ * lasts. The stream ends when `signal` aborts or the Remote stops.
314
+ * @param repository - one repository to list in, read on its host only, or null for every repository the user can
315
+ * read on every host.
293
316
  * @param signal - ends the stream.
294
317
  * @returns frames, each complete.
295
318
  */
296
319
  @Remote({ mode: 'stream' })
297
320
  async *reviewLists(
298
- repository: { readonly owner: string; readonly name: string } | null, signal: AbortSignal,
321
+ repository: ForgeReviewRepository | null, signal: AbortSignal,
299
322
  ): AsyncIterable<ForgeReviewFrame> {
300
323
  yield* this.viewerLists.lists(repository, signal)
301
324
  }
@@ -323,6 +346,28 @@ export class ForgePanelController extends TypertRemoteService {
323
346
  this.viewerLists.refresh()
324
347
  }
325
348
 
349
+ /**
350
+ * Report whether a provider reaches one of its hosts with the Host's current credentials, for the host list on the
351
+ * Plugins page of that provider's row. The read names no Session, so, like the review page reads, only callers that
352
+ * may use the Host's code host credentials reach it.
353
+ * @param forge - forge family of a registered provider, such as `gitlab`.
354
+ * @param host - host name as the provider's configuration lists it.
355
+ * @param signal - request cancellation.
356
+ * @returns the provider's readiness for the host; `unavailable` with the reason when no provider serves the family,
357
+ * the probe fails, or it runs past `readinessTimeoutMs`.
358
+ */
359
+ @Remote
360
+ async hostReadiness(forge: string, host: string, signal: AbortSignal): Promise<ForgeReadiness> {
361
+ signal.throwIfAborted()
362
+ try {
363
+ using timeout = deadline(signal, this.config.readinessTimeoutMs, 'FORGE_PANEL_READINESS_TIMEOUT')
364
+ return await this.home.forge.readiness({ forge, host: host.toLowerCase() }, timeout.signal)
365
+ } catch (error) {
366
+ signal.throwIfAborted()
367
+ return { state: 'unavailable', message: messageOf(error), signIn: null }
368
+ }
369
+ }
370
+
326
371
  /**
327
372
  * Poll one change request the review page shows at once; its stream reports the result.
328
373
  * @param url - web URL of the change request.
@@ -391,6 +436,41 @@ export class ForgePanelController extends TypertRemoteService {
391
436
  return result
392
437
  }
393
438
 
439
+ /**
440
+ * Read the activity of a change request for the review page: its comments, submitted reviews, commits, and changes
441
+ * of state.
442
+ * @param url - web URL of the change request.
443
+ * @param signal - request cancellation.
444
+ * @returns the activity, or null when the change request's provider reads none.
445
+ * @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/activity-failed` with the
446
+ * host's reason when the host does not provide it.
447
+ */
448
+ @Remote
449
+ async reviewActivity(url: string, signal: AbortSignal): Promise<ChangeRequestActivity | null> {
450
+ signal.throwIfAborted()
451
+ const result = await this.home.forge.readActivity(this.served(url).ref, signal)
452
+ if (!('code' in result)) return result
453
+ if (result.code === 'unsupported') return null
454
+ throw new RemoteError('forgePanel/activity-failed', result.message, {})
455
+ }
456
+
457
+ /**
458
+ * Add a comment to the conversation of a change request the review page shows.
459
+ * @param url - web URL of the change request.
460
+ * @param body - Markdown source of the comment.
461
+ * @param signal - request cancellation.
462
+ * @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` when `body` is
463
+ * blank, or with the host's reason; `forgePanel/action-unknown` when the host's answer did not confirm the comment.
464
+ */
465
+ @Remote
466
+ async reviewComment(url: string, body: string, signal: AbortSignal): Promise<void> {
467
+ signal.throwIfAborted()
468
+ const { ref } = this.served(url)
469
+ if (body.trim() === '') throw new RemoteError('forgePanel/action-failed', 'The comment is empty', {})
470
+ const failure = await this.home.forge.addComment(ref, body, signal)
471
+ if (failure !== undefined) throw actionError(failure)
472
+ }
473
+
394
474
  /**
395
475
  * Read every check of a change request the review page shows.
396
476
  * @param url - web URL of the change request.
@@ -451,16 +531,16 @@ export class ForgePanelController extends TypertRemoteService {
451
531
  }
452
532
 
453
533
  /**
454
- * Read the changes of a change request the review page shows, or of consecutive commits of it.
534
+ * Read the changes of a change request the review page shows, of consecutive commits of it, or of it up to one commit.
455
535
  * @param url - web URL of the change request.
456
- * @param commits - consecutive commits of the change request, or null for all of it.
536
+ * @param commits - consecutive commits of the change request, the commit its changes go up to, or null for all of it.
457
537
  * @param signal - request cancellation.
458
538
  * @returns the files and the commit they end at, without a local checkout count.
459
539
  * @throws as {@link ForgePanelController.changeRequestDiff} does, with `forgePanel/unrecognized-url` in place of
460
540
  * `forgePanel/not-bound`.
461
541
  */
462
542
  @Remote
463
- async reviewDiff(url: string, commits: ForgeCommitRange | null, signal: AbortSignal): Promise<ForgeChangeRequestDiff> {
543
+ async reviewDiff(url: string, commits: ForgeChangeCommits | null, signal: AbortSignal): Promise<ForgeChangeRequestDiff> {
464
544
  signal.throwIfAborted()
465
545
  return await this.readDiff(this.served(url), commits, signal, async () => await Promise.resolve(null))
466
546
  }
@@ -560,6 +640,22 @@ export class ForgePanelController extends TypertRemoteService {
560
640
  if (failure !== undefined) throw actionError(failure)
561
641
  }
562
642
 
643
+ /**
644
+ * Turn the code host's automatic merge of a change request the review page shows on, while its head is still the
645
+ * request's `headSha`, or off.
646
+ * @param url - web URL of the change request.
647
+ * @param request - on with the merge method and the head commit the user confirmed, or off.
648
+ * @param signal - request cancellation.
649
+ * @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
650
+ * `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
651
+ */
652
+ @Remote
653
+ async reviewSetAutoMerge(url: string, request: AutoMergeRequest, signal: AbortSignal): Promise<void> {
654
+ signal.throwIfAborted()
655
+ const failure = await this.home.forge.setAutoMerge(this.served(url).ref, request, signal)
656
+ if (failure !== undefined) throw actionError(failure)
657
+ }
658
+
563
659
  /**
564
660
  * Rerun the failed checks of a change request the review page shows.
565
661
  * @param url - web URL of the change request.
@@ -674,21 +770,26 @@ export class ForgePanelController extends TypertRemoteService {
674
770
  }
675
771
 
676
772
  /**
677
- * List the branches the `branch` scope of the Session's current checkout can compare with.
773
+ * List the branches the `branch` scope can compare with, for the Session's current checkout or for a head branch
774
+ * read in its place.
678
775
  * @param session - Session whose checkout is read.
776
+ * @param head - full ref of the branch the scope reads in place of the checked-out one, or null for the checkout.
679
777
  * @param query - text the branch names must contain, ignoring case; empty for every branch.
680
778
  * @param signal - request cancellation.
681
779
  * @returns the automatic fork point and at most `maxBranches` remote-tracking and local branches each,
682
- * most recently committed first, without the checked-out branch.
683
- * @throws `forgePanel/not-a-checkout` outside a checkout; the Git error when Git fails or the listed refs exceed `maxDiffBytes`.
780
+ * most recently committed first, without the branch the scope shows and, for a head, without the Session's
781
+ * checked-out branch, which the automatic fork point compares with; a local branch that a worktree has checked
782
+ * out names that worktree's directory.
783
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head does not exist; the
784
+ * Git error when Git fails or the listed refs exceed `maxDiffBytes`.
684
785
  */
685
786
  @Remote
686
- async diffBases(session: Session, query: string, signal: AbortSignal): Promise<ForgeBaseBranches> {
787
+ async diffBases(session: Session, head: string | null, query: string, signal: AbortSignal): Promise<ForgeBaseBranches> {
687
788
  signal.throwIfAborted()
688
- const inspection = await this.checkoutOf(session, signal)
789
+ const { inspection, created, tip, against } = await this.localTarget(session, head, false, signal)
689
790
  // A search can match any branch, so every ref is listed; a repository's refs can far exceed other short Git output.
690
791
  const git = gitIn(this.home, { ...this.config, maxOutputBytes: this.config.maxDiffBytes }, session, inspection.checkout.root, signal)
691
- return await baseBranches(git, inspection, this.worktreeState(session).created, query, this.config.maxBranches)
792
+ return await baseBranches(git, inspection, created, query, this.config.maxBranches, tip, against)
692
793
  }
693
794
 
694
795
  /* oxlint-disable typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect */
@@ -749,13 +850,15 @@ export class ForgePanelController extends TypertRemoteService {
749
850
  }
750
851
 
751
852
  /**
752
- * Read the changes one scope covers in the checkout of the Session's
753
- * current directory, with Git using the Session's sandbox policy.
853
+ * Read the changes one scope covers in the checkout of the Session's current directory, or for the head branch the
854
+ * scope names: in the worktree that has it checked out, else from its commits. Git uses the Session's sandbox policy.
754
855
  * @param session - Session whose checkout is read.
755
856
  * @param scope - which changes to read.
756
857
  * @param signal - request cancellation.
757
- * @returns the files, the base of the `branch` scope, and the untracked files left out.
758
- * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/base-missing` when the base branch
858
+ * @returns the files, the base of the `branch` scope, the untracked files left out, and the worktree read for a head.
859
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head the scope names
860
+ * does not exist; `forgePanel/no-working-tree` for another scope than `branch` whose head no worktree has checked
861
+ * out; `forgePanel/base-missing` when the base branch
759
862
  * chosen for the `branch` scope does not exist; `forgePanel/no-fork-point` for the `branch` scope without
760
863
  * a fork point; `forgePanel/commits-missing` when chosen commits are not between the fork point and HEAD in order;
761
864
  * `forgePanel/commits-not-linear` when a chosen commit's first parent is not the commit listed before it;
@@ -765,54 +868,88 @@ export class ForgePanelController extends TypertRemoteService {
765
868
  @Remote
766
869
  async localDiff(session: Session, scope: ForgeLocalScope, signal: AbortSignal): Promise<ForgeLocalDiff> {
767
870
  signal.throwIfAborted()
768
- const inspection = await this.checkoutOf(session, signal)
871
+ const target = await this.localTarget(session, scope.head ?? null, scope.kind !== 'branch', signal)
872
+ const { inspection, created, tip, worktree, against } = target
769
873
  const root = inspection.checkout.root
770
874
  const git = gitIn(this.home, this.config, session, root, signal)
771
- const created = this.worktreeState(session).created
772
875
  const fork = scope.kind !== 'branch' ? null
773
- : await diffing(scope.base === null ? forkPoint(git, inspection, created) : chosenForkPoint(git, scope.base))
774
- return await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal))
876
+ : await diffing(scope.base === null ? forkPoint(git, inspection, created, tip, against) : chosenForkPoint(git, scope.base, tip))
877
+ const diff = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal, tip))
878
+ return worktree === null ? diff : { ...diff, worktree }
775
879
  }
776
880
 
777
881
  /**
778
- * List the commits of the `branch` scope of the Session's current checkout, which the changes view can show one or
779
- * several of instead of the whole scope.
882
+ * List the commits of the `branch` scope of the Session's current checkout or of a head branch read in its place,
883
+ * which the changes view can show one or several of instead of the whole scope.
780
884
  * @param session - Session whose checkout is read.
885
+ * @param head - full ref of the branch the scope reads in place of the checked-out one, or null for the checkout.
781
886
  * @param base - the base ref of the `branch` scope, or null for its automatic fork point.
782
887
  * @param signal - request cancellation.
783
- * @returns the newest `maxCommits` commits between the fork point and HEAD, oldest first, and HEAD's commit.
784
- * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/base-missing` when the base branch does not
785
- * exist; `forgePanel/no-fork-point` without a fork point; the Git error when Git fails or the listing exceeds `maxDiffBytes`.
888
+ * @returns the newest `maxCommits` commits between the fork point and the shown HEAD or branch, oldest first, and its commit.
889
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head does not exist;
890
+ * `forgePanel/base-missing` when the base branch does not exist; `forgePanel/no-fork-point` without a fork point;
891
+ * the Git error when Git fails or the listing exceeds `maxDiffBytes`.
786
892
  */
787
893
  @Remote
788
- async localCommits(session: Session, base: string | null, signal: AbortSignal): Promise<ForgeLocalCommits> {
894
+ async localCommits(session: Session, head: string | null, base: string | null, signal: AbortSignal): Promise<ForgeLocalCommits> {
789
895
  signal.throwIfAborted()
790
- const inspection = await this.checkoutOf(session, signal)
896
+ const { inspection, created, tip, against } = await this.localTarget(session, head, false, signal)
791
897
  const git = gitIn(this.home, { ...this.config, maxOutputBytes: this.config.maxDiffBytes }, session, inspection.checkout.root, signal)
792
- const created = this.worktreeState(session).created
793
- const fork = await diffing(base === null ? forkPoint(git, inspection, created) : chosenForkPoint(git, base))
898
+ const fork = await diffing(base === null ? forkPoint(git, inspection, created, tip, against) : chosenForkPoint(git, base, tip))
794
899
  if (fork === null) throw new RemoteError('forgePanel/no-fork-point', 'The checkout has no fork point to compare its branch with', {})
795
- return await localCommits(git, fork, this.config.maxCommits)
900
+ return await localCommits(git, fork, this.config.maxCommits, tip)
796
901
  }
797
902
 
798
903
  /**
799
904
  * Read the new side of one changed file in a scope, which supplies the
800
905
  * unchanged lines between its hunks: the index for `staged`, the last chosen commit for chosen commits of
801
- * the `branch` scope, else the working tree.
906
+ * the `branch` scope, the branch for a head read from its commits, else the working tree of the checkout the scope reads.
802
907
  * @param session - Session whose checkout is read.
803
908
  * @param scope - the scope the diff was read in.
804
909
  * @param path - path relative to the checkout's top-level directory, as the diff names it.
805
910
  * @param signal - request cancellation.
806
911
  * @returns the text.
807
- * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/diff-too-large` over `maxDiffBytes`;
912
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` and `forgePanel/no-working-tree`
913
+ * as for {@link ForgePanelController.localDiff}; `forgePanel/diff-too-large` over `maxDiffBytes`;
808
914
  * `forgePanel/commits-missing` for a chosen commit that is not a full object name; an error for a path outside
809
915
  * the checkout, binary content, or a failed read.
810
916
  */
811
917
  @Remote
812
918
  async localText(session: Session, scope: ForgeLocalScope, path: string, signal: AbortSignal): Promise<string> {
919
+ signal.throwIfAborted()
920
+ const { inspection, tip } = await this.localTarget(session, scope.head ?? null, scope.kind !== 'branch', signal)
921
+ return await diffing(localText(this.home, this.config, session, inspection.checkout.root, scope, path, signal, tip))
922
+ }
923
+
924
+ /**
925
+ * Stage, unstage, or restore whole files in the checkout of the Session's current directory, or return index
926
+ * entries to the tree an earlier write reported. The caller's press authorizes the write, so Git runs without the
927
+ * Session's sandbox policy and under any access mode. The Session's panel inspects the checkout again afterwards,
928
+ * whether or not the write succeeded.
929
+ * @param session - Session whose checkout is written.
930
+ * @param write - the write; `stage` and `restore` name each file with the digest of the change the reader saw.
931
+ * @param signal - request cancellation.
932
+ * @returns the index before a `stage` or `unstage` as a tree, for undoing it.
933
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/local-stale` before anything is written when a
934
+ * file's unstaged change is not the one the reader saw; `forgePanel/local-path-replaced` before anything is written
935
+ * when a deleted file's path holds a directory; the errors of {@link ForgePanelController.localDiff} for the
936
+ * `unstaged` scope; an error for a path outside the checkout, a tree that is not a full object name, a restore of a
937
+ * submodule or of a file without index content, or a Git failure.
938
+ */
939
+ @Remote
940
+ async localWrite(session: Session, write: ForgeLocalWrite, signal: AbortSignal): Promise<ForgeLocalWriteResult> {
813
941
  signal.throwIfAborted()
814
942
  const inspection = await this.checkoutOf(session, signal)
815
- return await diffing(localText(this.home, this.config, session, inspection.checkout.root, scope, path, signal))
943
+ try {
944
+ return await diffing(localWrite(this.home, this.config, session, inspection.checkout.root, write, this.layers, signal))
945
+ } catch (error) {
946
+ if (error instanceof LocalChangesStale) throw new RemoteError('forgePanel/local-stale', error.message, {}, { cause: error })
947
+ if (error instanceof LocalPathReplaced) throw new RemoteError('forgePanel/local-path-replaced', error.message, {}, { cause: error })
948
+ throw error
949
+ } finally {
950
+ // A failed write can have changed the paths of its earlier commands.
951
+ this.panels.get(session)?.reinspect()
952
+ }
816
953
  }
817
954
 
818
955
  /**
@@ -855,24 +992,29 @@ export class ForgePanelController extends TypertRemoteService {
855
992
  * of the commit the diff ends at. Without `commits` the diff covers the change
856
993
  * request at the head commit of its latest status; a patch already read at the
857
994
  * same head commit and base branch is reused from memory with its attributes, for
858
- * any Session, until `maxCachedDiffBytes` evicts it. With `commits`, it covers those
859
- * commits, from the first one's first parent to the last, and is read every time.
995
+ * any Session, until `maxCachedDiffBytes` evicts it. With consecutive `commits`, it covers those
996
+ * commits, from the first one's first parent to the last; with `commits` up to one commit, it covers
997
+ * the change request as that commit ended it, from the merge base of the status's base commit with
998
+ * that commit, which the host reads by name whether or not the change request still lists it. Either
999
+ * is read every time.
860
1000
  * @param session - Session the change request is bound to.
861
1001
  * @param url - binding URL of the change request.
862
- * @param commits - consecutive commits of the change request, or null for all of it.
1002
+ * @param commits - consecutive commits of the change request, the commit its changes go up to, or null for all of it.
863
1003
  * @param signal - request cancellation.
864
1004
  * @returns the files, the commit they end at, each file's web page, and the commits the checkout has beyond the head.
865
1005
  * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
866
- * `forgePanel/commits-missing` when chosen commits are not among the change request's commits in order;
1006
+ * `forgePanel/commits-missing` when chosen commits are not among the change request's commits in order, and for a
1007
+ * commit to go up to that is not a full object name or that the host does not have;
867
1008
  * `forgePanel/commits-not-linear` when a chosen commit's first parent is not the commit listed before it;
868
1009
  * `forgePanel/stale-head` without `commits` when the head moved past the latest status, which is then polled again;
869
1010
  * `forgePanel/diff-too-large` when the host or its provider refuses the diff over a size limit;
870
- * `forgePanel/diff-failed` before its status was read, for a first chosen commit without a parent, and when the host
871
- * does not provide the commits, the diff, or an existing `.gitattributes` otherwise.
1011
+ * `forgePanel/diff-failed` before its status was read, for a first chosen commit without a parent, for changes up
1012
+ * to a commit while the status names no base commit, and when the host does not provide the commits, the merge
1013
+ * base, the diff, or an existing `.gitattributes` otherwise.
872
1014
  */
873
1015
  @Remote
874
1016
  async changeRequestDiff(
875
- session: Session, url: string, commits: ForgeCommitRange | null, signal: AbortSignal,
1017
+ session: Session, url: string, commits: ForgeChangeCommits | null, signal: AbortSignal,
876
1018
  ): Promise<ForgeChangeRequestDiff> {
877
1019
  signal.throwIfAborted()
878
1020
  return await this.readDiff(this.bound(session, url), commits, signal, async (headBranch, headSha) => {
@@ -1121,6 +1263,25 @@ export class ForgePanelController extends TypertRemoteService {
1121
1263
  if (failure !== undefined) throw actionError(failure)
1122
1264
  }
1123
1265
 
1266
+ /**
1267
+ * Turn the code host's automatic merge of a change request of a Session on, while its head is still the request's
1268
+ * `headSha`, or off; the change request is polled again once the host answers.
1269
+ * @param session - Session the change request is bound to.
1270
+ * @param url - binding URL of the change request.
1271
+ * @param request - on with the merge method and the head commit the user confirmed, or off.
1272
+ * @param signal - request cancellation.
1273
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1274
+ * `forgePanel/stale-head` when the head moved past the request's `headSha`; `forgePanel/action-failed` with the
1275
+ * host's reason when the host refuses otherwise, cannot be reached, or sets no automatic merge;
1276
+ * `forgePanel/action-unknown` when the host's answer did not confirm the change.
1277
+ */
1278
+ @Remote
1279
+ async setAutoMerge(session: Session, url: string, request: AutoMergeRequest, signal: AbortSignal): Promise<void> {
1280
+ signal.throwIfAborted()
1281
+ const failure = await this.home.forge.setAutoMerge(this.bound(session, url).ref, request, signal)
1282
+ if (failure !== undefined) throw actionError(failure)
1283
+ }
1284
+
1124
1285
  /**
1125
1286
  * Rerun the failed checks of a change request of a Session while its head is still the commit whose checks the user
1126
1287
  * saw; the change request is polled again once the host answers.
@@ -1401,6 +1562,35 @@ export class ForgePanelController extends TypertRemoteService {
1401
1562
  return { files: this.layers.classify(parseDiff(patch), attributes), parent }
1402
1563
  }
1403
1564
 
1565
+ /**
1566
+ * The files of a change request up to a commit, from the merge base of the status's base commit with it, which is
1567
+ * returned too. The provider reads that commit by name, so it may have left the change request's listed commits; a
1568
+ * commit the host does not have is refused as `forgePanel/commits-missing`.
1569
+ */
1570
+ private async filesUpTo(
1571
+ ref: ChangeRequestRef, snapshot: ChangeRequestSnapshot, commit: string, signal: AbortSignal,
1572
+ ): Promise<{ readonly files: ForgeDiffFile[]; readonly parent: string }> {
1573
+ if (!isCommit(commit)) throw new RemoteError('forgePanel/commits-missing', 'The chosen commit is not a full object name', {})
1574
+ if (snapshot.baseSha === undefined) {
1575
+ throw new RemoteError('forgePanel/diff-failed', 'The code host provider reports no base commit to compare from', {})
1576
+ }
1577
+ const base = await this.home.forge.mergeBase(ref, snapshot.baseSha, commit, signal)
1578
+ if (typeof base !== 'string') throw upToError(base)
1579
+ const { patch, attributes } = await this.patchAt(ref, commit, async (operation) => {
1580
+ const compared = await this.home.forge.compare(ref, base, commit, operation)
1581
+ if (typeof compared !== 'string') throw upToError(compared)
1582
+ return compared
1583
+ }, signal)
1584
+ return { files: this.layers.classify(parseDiff(patch), attributes), parent: base }
1585
+ }
1586
+
1587
+ /** The files of chosen commits of a change request with the commit their old side shows. */
1588
+ private async chosenFiles(
1589
+ ref: ChangeRequestRef, snapshot: ChangeRequestSnapshot, commits: ForgeChangeCommits, signal: AbortSignal,
1590
+ ): Promise<{ readonly files: ForgeDiffFile[]; readonly parent: string }> {
1591
+ return 'upTo' in commits ? await this.filesUpTo(ref, snapshot, commits.upTo, signal) : await this.commitFiles(ref, commits, signal)
1592
+ }
1593
+
1404
1594
  /**
1405
1595
  * Read a patch that ends at `commit` together with the root `.gitattributes` at that commit. A failed patch read
1406
1596
  * cancels the attributes read. Both reads end before the result: the patch's failure passes on first, and the
@@ -1436,6 +1626,39 @@ export class ForgePanelController extends TypertRemoteService {
1436
1626
  throw readError(attributes)
1437
1627
  }
1438
1628
 
1629
+ /**
1630
+ * Resolve what a local read targets: the Session's own checkout with the worktree it created; for a head branch,
1631
+ * the worktree of the repository that has it checked out, read as a checkout; or, when none has, the verified
1632
+ * branch itself, read from its commits. A head branch also carries the Session's own HEAD, which is what it is
1633
+ * compared with while no base branch is chosen.
1634
+ * @param working - whether the read needs a working tree, as every scope but `branch` does.
1635
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the branch does not exist;
1636
+ * `forgePanel/no-working-tree` when `working` and no worktree has the branch checked out.
1637
+ */
1638
+ private async localTarget(session: Session, head: string | null, working: boolean, signal: AbortSignal): Promise<LocalTarget> {
1639
+ const own = await this.checkoutOf(session, signal)
1640
+ const ownTarget: LocalTarget = {
1641
+ inspection: own, created: this.worktreeState(session).created, tip: 'HEAD', worktree: null, against: null,
1642
+ }
1643
+ if (head === null) return ownTarget
1644
+ // Worktree paths are as long as the directories users choose, so the listing takes the larger limit.
1645
+ const git = gitIn(this.home, { ...this.config, maxOutputBytes: this.config.maxDiffBytes }, session, own.checkout.root, signal)
1646
+ const tip = await diffing(branchTip(git, head))
1647
+ const against = await sessionHead(git, own.checkout)
1648
+ // Only a local branch can be checked out; a remote-tracking one is always read from its commits.
1649
+ const directory = head.startsWith(LOCAL_REF_PREFIX) ? (await branchWorktrees(git)).get(head) : undefined
1650
+ // The directory is as Git's listing spells it, which can be cut short or name one that is gone, so the read
1651
+ // confirms that a checkout of the branch in this repository is there.
1652
+ const inspection = directory === undefined || await this.home.fs.lstat(directory, undefined, signal) === undefined ? undefined
1653
+ : await inspectCheckout(this.home, this.config, session, directory, signal)
1654
+ if (inspection?.commonDir === own.commonDir && inspection.checkout.branch === head.slice(LOCAL_REF_PREFIX.length)) {
1655
+ return inspection.checkout.root === own.checkout.root ? ownTarget
1656
+ : { inspection, created: null, tip: 'HEAD', worktree: inspection.checkout.root, against }
1657
+ }
1658
+ if (working) throw new RemoteError('forgePanel/no-working-tree', 'No worktree has the branch checked out, so it has no working tree', {})
1659
+ return { inspection: own, created: null, tip, worktree: null, against }
1660
+ }
1661
+
1439
1662
  /** Inspect the checkout of the Session's current directory, which local diffs read. */
1440
1663
  private async checkoutOf(session: Session, signal: AbortSignal): Promise<Inspection> {
1441
1664
  const inspection = await inspectCheckout(this.home, this.config, session, this.home.workingDirectory.get(session), signal)
@@ -1454,9 +1677,9 @@ export class ForgePanelController extends TypertRemoteService {
1454
1677
  return result
1455
1678
  }
1456
1679
 
1457
- /** Read the changes of a change request at the head of its latest status, or of chosen commits; `ahead` counts local commits. */
1680
+ /** Read the changes of a change request at the head of its latest status, or of its chosen commits; `ahead` counts local commits. */
1458
1681
  private async readDiff(
1459
- target: ChangeRequestTarget, commits: ForgeCommitRange | null, signal: AbortSignal,
1682
+ target: ChangeRequestTarget, commits: ForgeChangeCommits | null, signal: AbortSignal,
1460
1683
  ahead: (headBranch: string, headSha: string) => Promise<number | null>,
1461
1684
  ): Promise<ForgeChangeRequestDiff> {
1462
1685
  const { ref, update } = target
@@ -1464,9 +1687,10 @@ export class ForgePanelController extends TypertRemoteService {
1464
1687
  throw new RemoteError('forgePanel/diff-failed', 'The change request status has not been read yet', {})
1465
1688
  }
1466
1689
  if (commits !== null) {
1467
- const { files } = await this.commitFiles(ref, commits, signal)
1468
- const fileUrls = Object.fromEntries(files.map(file => [file.path, this.home.forge.fileUrl(ref, commits.to, file.path)]))
1469
- return { headSha: commits.to, files, localAhead: null, fileUrls }
1690
+ const { files } = await this.chosenFiles(ref, update.snapshot, commits, signal)
1691
+ const end = lastOf(commits)
1692
+ const fileUrls = Object.fromEntries(files.map(file => [file.path, this.home.forge.fileUrl(ref, end, file.path)]))
1693
+ return { headSha: end, files, localAhead: null, fileUrls }
1470
1694
  }
1471
1695
  const { headSha, headBranch } = update.snapshot
1472
1696
  const files = await this.headFiles(ref, update.snapshot, signal)
@@ -1638,7 +1862,7 @@ export class ForgePanelController extends TypertRemoteService {
1638
1862
  try {
1639
1863
  running = agent.runMaintenance(async (signal) => { await work(agent, signal) })
1640
1864
  } catch (error) {
1641
- throw new RemoteError('forgePanel/session-busy', 'The Session is busy', {}, { cause: error })
1865
+ throw new RemoteError('forgePanel/session-busy', `The Session is busy: ${messageOf(error)}`, {}, { cause: error })
1642
1866
  }
1643
1867
  await running
1644
1868
  }
@@ -1707,13 +1931,14 @@ export class ForgePanelController extends TypertRemoteService {
1707
1931
  session: Session, source: ForgeLensRequest['source'], signal: AbortSignal,
1708
1932
  ): Promise<LensSubject & { readonly key: string }> {
1709
1933
  if (source.kind === 'local') {
1710
- const inspection = await this.checkoutOf(session, signal)
1711
- const root = inspection.checkout.root
1712
1934
  const { scope } = source
1935
+ const target = await this.localTarget(session, scope.head ?? null, scope.kind !== 'branch', signal)
1936
+ const { inspection, created, tip, against } = target
1937
+ const root = inspection.checkout.root
1713
1938
  const fork: ForkPoint | null = scope.kind !== 'branch' ? null : await diffing(scope.base === null
1714
- ? forkPoint(gitIn(this.home, this.config, session, root, signal), inspection, this.worktreeState(session).created)
1715
- : chosenForkPoint(gitIn(this.home, this.config, session, root, signal), scope.base))
1716
- const { files } = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal))
1939
+ ? forkPoint(gitIn(this.home, this.config, session, root, signal), inspection, created, tip, against)
1940
+ : chosenForkPoint(gitIn(this.home, this.config, session, root, signal), scope.base, tip))
1941
+ const { files } = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal, tip))
1717
1942
  return {
1718
1943
  key: JSON.stringify(['local', session.id, scope]),
1719
1944
  source: { kind: 'local', scope },
@@ -1721,7 +1946,7 @@ export class ForgePanelController extends TypertRemoteService {
1721
1946
  read: async (side, file, inner) => {
1722
1947
  if (file.binary || (side === 'old' ? file.status === 'added' : file.status === 'deleted')) return null
1723
1948
  return side === 'new'
1724
- ? await diffing(localText(this.home, this.config, session, root, scope, file.path, inner))
1949
+ ? await diffing(localText(this.home, this.config, session, root, scope, file.path, inner, tip))
1725
1950
  : await diffing(localOldText(this.home, this.config, session, root, scope, fork, file.previousPath ?? file.path, inner))
1726
1951
  },
1727
1952
  }
@@ -1735,6 +1960,9 @@ export class ForgePanelController extends TypertRemoteService {
1735
1960
  let files: ForgeDiffFile[]
1736
1961
  let newCommit: string
1737
1962
  let oldCommit: (inner: AbortSignal) => Promise<string>
1963
+ // A lens sees changes up to a commit as the whole change request with that commit as its head.
1964
+ let shownHead = snapshot.headSha
1965
+ let shownRange: ForgeCommitRange | null = null
1738
1966
  if (commits === null) {
1739
1967
  files = await this.headFiles(ref, snapshot, signal)
1740
1968
  newCommit = snapshot.headSha
@@ -1750,14 +1978,16 @@ export class ForgePanelController extends TypertRemoteService {
1750
1978
  }
1751
1979
  }
1752
1980
  } else {
1753
- const read = await this.commitFiles(ref, commits, signal)
1981
+ const read = await this.chosenFiles(ref, snapshot, commits, signal)
1754
1982
  files = read.files
1755
- newCommit = commits.to
1983
+ newCommit = lastOf(commits)
1756
1984
  oldCommit = () => Promise.resolve(read.parent)
1985
+ if ('upTo' in commits) shownHead = commits.upTo
1986
+ else shownRange = commits
1757
1987
  }
1758
1988
  return {
1759
1989
  key: JSON.stringify(['change', changeRequestKey(ref), newCommit, commits]),
1760
- source: { kind: 'change', ref, headSha: snapshot.headSha, commits },
1990
+ source: { kind: 'change', ref, headSha: shownHead, commits: shownRange },
1761
1991
  files,
1762
1992
  read: async (side, file, inner) => {
1763
1993
  if (file.binary || (side === 'old' ? file.status === 'added' : file.status === 'deleted')) return null
@@ -1798,6 +2028,15 @@ export class ForgePanelController extends TypertRemoteService {
1798
2028
  }
1799
2029
  }
1800
2030
 
2031
+ /**
2032
+ * Name the commit that chosen commits of a change request end at.
2033
+ * @param commits - the chosen commits.
2034
+ * @returns the last commit's object name.
2035
+ */
2036
+ function lastOf(commits: ForgeChangeCommits): string {
2037
+ return 'upTo' in commits ? commits.upTo : commits.to
2038
+ }
2039
+
1801
2040
  /**
1802
2041
  * Whether a value names a full commit object name.
1803
2042
  * @param value - the value from the browser.
@@ -1856,6 +2095,15 @@ function readError(failure: ForgeFailure): RemoteError {
1856
2095
  }
1857
2096
  }
1858
2097
 
2098
+ /**
2099
+ * Report why the code host did not provide the merge base or the diff of the changes up to a commit.
2100
+ * @param failure - the provider's failure.
2101
+ * @returns `forgePanel/commits-missing` when the host does not have the commit, else what {@link readError} reports.
2102
+ */
2103
+ function upToError(failure: ForgeFailure): RemoteError {
2104
+ return failure.code === 'not-found' ? new RemoteError('forgePanel/commits-missing', failure.message, {}) : readError(failure)
2105
+ }
2106
+
1859
2107
  /**
1860
2108
  * Report why the code host did not provide review threads.
1861
2109
  * @param failure - the provider's failure.
@@ -1877,8 +2125,8 @@ function reviewError(failure: ForgeFailure): RemoteError {
1877
2125
  }
1878
2126
 
1879
2127
  /**
1880
- * Settle a diff read, reporting its size limit, its filter configuration, a missing fork point, a missing base branch, and chosen
1881
- * commits that are not on the branch as Remote errors.
2128
+ * Settle a diff read, reporting its size limit, its filter configuration, a missing fork point, a missing base branch, a missing
2129
+ * head, and chosen commits that are not on the branch as Remote errors.
1882
2130
  * @param reading - the read.
1883
2131
  * @returns what the read returned.
1884
2132
  */
@@ -1890,6 +2138,7 @@ async function diffing<T>(reading: Promise<T>): Promise<T> {
1890
2138
  if (error instanceof DiffTooLarge) throw new RemoteError('forgePanel/diff-too-large', error.message, {}, { cause: error })
1891
2139
  if (error instanceof NoForkPoint) throw new RemoteError('forgePanel/no-fork-point', error.message, {}, { cause: error })
1892
2140
  if (error instanceof BaseMissing) throw new RemoteError('forgePanel/base-missing', error.message, {}, { cause: error })
2141
+ if (error instanceof HeadMissing) throw new RemoteError('forgePanel/head-missing', error.message, {}, { cause: error })
1893
2142
  if (error instanceof CommitsMissing) throw new RemoteError('forgePanel/commits-missing', error.message, {}, { cause: error })
1894
2143
  if (error instanceof CommitsNotLinear) throw new RemoteError('forgePanel/commits-not-linear', error.message, {}, { cause: error })
1895
2144
  throw error