@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
@@ -1,8 +1,8 @@
1
1
  /** Chip title of a changes tab: the changes icon and the view's name in the current language. */
2
2
 
3
3
  import type { ReactNode } from 'react'
4
- import { IconFilesDiffOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
5
- import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
4
+ import { IconFilesDiffOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives/client'
5
+ import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client'
6
6
  import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
7
7
  import { changesTitle, parseChangesAddress } from './changes-address.ts'
8
8
  import type { NS } from './locales.ts'
@@ -4,16 +4,16 @@
4
4
  * accepted only when each of its commits has the one listed before it as its first parent.
5
5
  */
6
6
 
7
- import { useEffect, useRef, useState, type ReactNode } from 'react'
7
+ import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
8
8
  import clsx from 'clsx'
9
9
  import {
10
10
  Button, IconCheckOutlineRegular, IconChevronDownOutlineRegular, Menu, MenuItemButton, StateDot, Tooltip,
11
- } from '@deepseek-ai/dsh-client-ui-primitives'
12
- import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
13
- import type { ForgeCommitList } from '@deepseek-ai/dsh-experimental-forge/types'
11
+ } from '@deepseek-ai/dsh-client-ui-primitives/client'
12
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
13
+ import type { ForgeCommit, ForgeCommitList } from '@deepseek-ai/dsh-experimental-forge/types'
14
14
  import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
15
15
  import { rangeStart } from '../commit-range.ts'
16
- import type { ForgeCommitRange, ForgeLocalCommits } from '../types.ts'
16
+ import type { ForgeChangeCommits, ForgeCommitRange, ForgeLocalCommits } from '../types.ts'
17
17
  import { formatAgo } from './format.ts'
18
18
  import type { NS } from './locales.ts'
19
19
  import css from './CommitMenu.module.css'
@@ -23,8 +23,8 @@ const SHORT = 7
23
23
 
24
24
  /** Props of the commit picker. */
25
25
  export interface CommitMenuProps extends PropsLocale<typeof NS> {
26
- /** Commits shown, or null for all of them. */
27
- readonly chosen: ForgeCommitRange | null
26
+ /** Commits shown, or null for all of them. The owner of a change request view may show its changes up to one commit. */
27
+ readonly chosen: ForgeChangeCommits | null
28
28
  /** Whether the owning tab is visible; a hidden tab keeps the menu closed. */
29
29
  readonly visible: boolean
30
30
  /** Read the commits; null means the source cannot show single commits. `signal` aborts the read. */
@@ -43,17 +43,49 @@ export interface CommitMenuProps extends PropsLocale<typeof NS> {
43
43
  * @param t - forge panel copy.
44
44
  * @returns the label.
45
45
  */
46
- export function commitsLabel(chosen: ForgeCommitRange | null, t: PropsLocale<typeof NS>['t']): string {
46
+ export function commitsLabel(chosen: ForgeChangeCommits | null, t: PropsLocale<typeof NS>['t']): string {
47
47
  if (chosen === null) return t('commits.all')
48
+ // Changes up to a commit read as that commit, as one commit shown alone does.
49
+ if ('upTo' in chosen) return chosen.upTo.slice(0, SHORT)
48
50
  if (chosen.from === chosen.to) return chosen.from.slice(0, SHORT)
49
51
  return t('commits.range', { from: chosen.from.slice(0, SHORT), to: chosen.to.slice(0, SHORT) })
50
52
  }
51
53
 
54
+ /** Name the shown commits in the trigger's attribute: empty for all of them, `..sha` up to a commit, else `from..to`. */
55
+ function commitsAttribute(chosen: ForgeChangeCommits | null): string {
56
+ if (chosen === null) return ''
57
+ return 'upTo' in chosen ? `..${chosen.upTo}` : `${chosen.from}..${chosen.to}`
58
+ }
59
+
60
+ /** One commit row of the picker: its short object name, its title, when it was authored, and the mark of the shown run. */
61
+ function CommitRow({ commit, selected, ago, onPick }: {
62
+ readonly commit: ForgeCommit
63
+ readonly selected: boolean
64
+ readonly ago: string
65
+ readonly onPick: (sha: string) => void
66
+ }) {
67
+ const sha = commit.sha
68
+ const pick = useCallback((): void => { onPick(sha) }, [onPick, sha])
69
+ return (
70
+ <MenuItemButton current={selected} onSelect={pick}>
71
+ <span className={css.option} data-forge-commit={sha}>
72
+ <span className={css.sha}>{sha.slice(0, SHORT)}</span>
73
+ <span className={css.title}>{commit.title}</span>
74
+ <span className={css.meta}>{ago}</span>
75
+ <span className={clsx(css.check, !selected && css.unchecked)}><IconCheckOutlineRegular size={14} /></span>
76
+ </span>
77
+ </MenuItemButton>
78
+ )
79
+ }
80
+
52
81
  /**
53
- * Render the trigger and, while open, the commit list. A click shows one commit; a Shift click shows the commits
54
- * from the last commit clicked without Shift to the clicked one.
82
+ * Render the trigger and, while open, the commit list. A click shows one commit; a Shift click shows the commits up to
83
+ * the clicked one, from the one commit shown, wherever it was chosen, or else from the last commit clicked without Shift.
84
+ * Changes up to a commit, which only the view's owner chooses, have a row of their own above the list, since the list
85
+ * may no longer hold that commit.
55
86
  * @param props - the shown commits, the listing read, the choose action, and copy.
56
- * @returns the trigger with its portalled menu, or nothing when the source cannot show single commits.
87
+ * @returns the trigger with its portalled menu, or nothing when the source cannot show single commits and shows all of
88
+ * them.
57
89
  */
58
90
  export function CommitMenu({ chosen, visible, list, kept, version, choose, t }: CommitMenuProps): ReactNode {
59
91
  const [open, setOpen] = useState(false)
@@ -64,7 +96,9 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
64
96
  readonly result: RemoteResult<ForgeCommitList | ForgeLocalCommits | null>
65
97
  } | null>(null)
66
98
  const shift = useRef(false)
67
- const anchor = useRef<string | null>(chosen?.from ?? null)
99
+ const range = chosen !== null && 'from' in chosen ? chosen : null
100
+ const upTo = chosen !== null && 'upTo' in chosen ? chosen.upTo : null
101
+ const anchor = useRef<string | null>(range?.from ?? null)
68
102
  const loaded = useRef<string | null>(null)
69
103
  const shown = visible && open
70
104
  const key = `${version}\n${String(attempt)}`
@@ -80,13 +114,12 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
80
114
  })
81
115
  return () => { controller.abort() }
82
116
  }, [visible, key, list])
83
- if (current?.ok === true && current.value === null) return null
84
117
  const commits = current?.ok === true && current.value !== null ? current.value : null
85
- const close = (): void => {
118
+ const close = useCallback((): void => {
86
119
  setOpen(false)
87
120
  setRejected(false)
88
- }
89
- const pick = (sha: string | null): void => {
121
+ }, [])
122
+ const pick = useCallback((sha: string | null): void => {
90
123
  if (sha === null || commits === null) {
91
124
  close()
92
125
  anchor.current = null
@@ -94,7 +127,9 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
94
127
  return
95
128
  }
96
129
  const order = commits.commits.map(commit => commit.sha)
97
- const start = shift.current && anchor.current !== null && order.includes(anchor.current) ? anchor.current : sha
130
+ // One commit shown alone starts the run, also when the view's owner chose it and not a click here.
131
+ const held = range !== null && range.from === range.to ? range.from : anchor.current
132
+ const start = shift.current && held !== null && order.includes(held) ? held : sha
98
133
  const [from, to] = order.indexOf(start) <= order.indexOf(sha) ? [start, sha] : [sha, start]
99
134
  // Two ends cannot name a run that leaves the first-parent line, so the menu stays open and says why.
100
135
  if (rangeStart(commits.commits, { from, to }) === 'not-linear') {
@@ -103,51 +138,56 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
103
138
  }
104
139
  close()
105
140
  if (!shift.current || start === sha) anchor.current = sha
106
- if (from !== chosen?.from || to !== chosen.to) choose({ from, to })
107
- }
141
+ if (from !== range?.from || to !== range.to) choose({ from, to })
142
+ }, [choose, chosen, close, commits, range])
143
+ const chooseAll = useCallback((): void => { pick(null) }, [pick])
144
+ const retryListing = useCallback((): void => { setAttempt(count => count + 1) }, [])
145
+ // Changes up to a commit keep the picker, which is the way back to all commits.
146
+ if (current?.ok === true && current.value === null && upTo === null) return null
108
147
  const inChosen = (index: number): boolean => {
109
- if (chosen === null || commits === null) return false
148
+ if (range === null || commits === null) return false
110
149
  const order = commits.commits.map(commit => commit.sha)
111
- return index >= order.indexOf(chosen.from) && index <= order.indexOf(chosen.to) && order.includes(chosen.from)
150
+ return index >= order.indexOf(range.from) && index <= order.indexOf(range.to) && order.includes(range.from)
112
151
  }
113
152
 
114
153
  let body: ReactNode
115
154
  if (current === null) {
116
155
  body = <div className={css.status} role="status"><StateDot state="ongoing" />{t('commits.loading')}</div>
117
- } else if (!current.ok || commits === null) {
156
+ } else if (!current.ok) {
118
157
  body = (
119
158
  <div className={css.status} role="status">
120
159
  <span>{t('commits.failed')}</span>
121
- <Button size="sm" variant="outline" onClick={() => { setAttempt(count => count + 1) }}>{t('retry')}</Button>
160
+ <Button size="sm" variant="outline" onClick={retryListing}>{t('retry')}</Button>
122
161
  </div>
123
162
  )
124
163
  } else {
125
164
  const now = Date.now()
165
+ const rows = commits?.commits ?? []
126
166
  body = <>
127
- <MenuItemButton current={chosen === null} onSelect={() => { pick(null) }}>
167
+ <MenuItemButton current={chosen === null} onSelect={chooseAll}>
128
168
  <span className={css.option}>
129
169
  <span className={css.allTitle}>{t('commits.all')}</span>
130
- <span className={css.meta}>{t('commits.count', { count: commits.commits.length })}</span>
170
+ {commits !== null && <span className={css.meta}>{t('commits.count', { count: commits.commits.length })}</span>}
131
171
  {chosen === null && <IconCheckOutlineRegular size={14} className={css.check} />}
132
172
  </span>
133
173
  </MenuItemButton>
134
- {commits.commits.length > 0 && <div className={css.label} role="presentation">{t('commits.shiftHint')}</div>}
135
- {commits.commits.map((commit, index) => {
136
- const selected = inChosen(index)
137
- return (
138
- <MenuItemButton key={commit.sha} current={selected} onSelect={() => { pick(commit.sha) }}>
139
- <span className={css.option} data-forge-commit={commit.sha}>
140
- <span className={css.sha}>{commit.sha.slice(0, SHORT)}</span>
141
- <span className={css.title}>{commit.title}</span>
142
- <span className={css.meta}>{formatAgo(commit.authoredAt, now, t) ?? ''}</span>
143
- <span className={clsx(css.check, !selected && css.unchecked)}><IconCheckOutlineRegular size={14} /></span>
144
- </span>
145
- </MenuItemButton>
146
- )
147
- })}
148
- {commits.truncated && (
174
+ {upTo !== null && (
175
+ <MenuItemButton current onSelect={close}>
176
+ <span className={css.option} data-forge-commit-up-to={upTo}>
177
+ <span className={css.sha}>{upTo.slice(0, SHORT)}</span>
178
+ <span className={css.title}>{t('commits.threadCommit')}</span>
179
+ <span className={css.check}><IconCheckOutlineRegular size={14} /></span>
180
+ </span>
181
+ </MenuItemButton>
182
+ )}
183
+ {rows.length > 0 && <div className={css.label} role="presentation">{t('commits.shiftHint')}</div>}
184
+ {rows.map((commit, index) => (
185
+ <CommitRow key={commit.sha} commit={commit} selected={inChosen(index)}
186
+ ago={formatAgo(commit.authoredAt, now, t) ?? ''} onPick={pick} />
187
+ ))}
188
+ {commits?.truncated === true && (
149
189
  <div className={css.note}>
150
- {t(kept === 'oldest' ? 'commits.truncatedOldest' : 'commits.truncatedNewest', { count: commits.commits.length })}
190
+ {t(kept === 'oldest' ? 'commits.truncatedOldest' : 'commits.truncatedNewest', { count: rows.length })}
151
191
  </div>
152
192
  )}
153
193
  </>
@@ -166,7 +206,8 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
166
206
  anchor={(
167
207
  <Tooltip label={t('commits.aria', { commits: label })} side="bottom" portal delayMs={500}>
168
208
  <button type="button" className={clsx(css.trigger, chosen !== null && css.chosen)} aria-haspopup="menu" aria-expanded={shown}
169
- aria-label={t('commits.aria', { commits: label })} data-forge-commits={chosen === null ? '' : `${chosen.from}..${chosen.to}`}
209
+ aria-label={t('commits.aria', { commits: label })}
210
+ data-forge-commits={commitsAttribute(chosen)}
170
211
  onClick={() => { setOpen(value => !value); setRejected(false) }}>
171
212
  <span className={css.triggerName}>{label}</span>
172
213
  <IconChevronDownOutlineRegular size={12} />
@@ -0,0 +1,25 @@
1
+ /** The button the forge surfaces use to copy a host's sign-in command. */
2
+
3
+ import { useCallback } from 'react'
4
+ import { Button } from '@deepseek-ai/dsh-client-ui-primitives/client'
5
+ import type { ButtonVariant } from '@deepseek-ai/dsh-client-ui-primitives/client'
6
+
7
+ /**
8
+ * Copy one host command through the caller's clipboard channel.
9
+ * @param props.command - the command text to copy.
10
+ * @param props.copyText - the surface's clipboard writer.
11
+ * @param props.label - the button text.
12
+ * @param props.ariaLabel - accessible name when the button text alone is not the action's name.
13
+ * @param props.variant - visual family; outlined unless the surface places it in a command row.
14
+ * @returns the copy button.
15
+ */
16
+ export function CopyCommandButton({ command, copyText, label, ariaLabel, variant = 'outline' }: {
17
+ readonly command: string
18
+ readonly copyText: (text: string) => void
19
+ readonly label: string
20
+ readonly ariaLabel?: string | undefined
21
+ readonly variant?: ButtonVariant | undefined
22
+ }) {
23
+ const copy = useCallback((): void => { copyText(command) }, [command, copyText])
24
+ return <Button size="sm" variant={variant} aria-label={ariaLabel} onClick={copy}>{label}</Button>
25
+ }
@@ -1,21 +1,22 @@
1
1
  /**
2
2
  * One file of the changes view: a sticky header with the path, badges, line
3
- * counts, and file actions, then its hunks unified or side by side with the
3
+ * counts, the writes of a local scope, the viewed mark, and file actions, then its hunks unified or side by side with the
4
4
  * unchanged lines between them collapsed into rows that expand them. A section
5
5
  * draws and highlights its lines once it comes within reach of the scrollport;
6
6
  * it redraws only when its own props change.
7
7
  */
8
8
 
9
- import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
9
+ import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type Dispatch, type ReactNode, type SetStateAction } from 'react'
10
10
  import clsx from 'clsx'
11
11
  import { flushSync } from 'react-dom'
12
12
  import {
13
- FileTypeIcon, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconChevronUpOutlineRegular, IconEllipsisOutlineRegular,
14
- IconPlusOutlineRegular,
13
+ FileTypeIcon, IconCheckCircleOutlineRegular, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconChevronUpOutlineRegular,
14
+ IconEllipsisOutlineRegular, IconPlusOutlineRegular,
15
15
  Tag, Tooltip,
16
16
  languageForPath, Menu, MenuItemButton, useCodeHighlighter, type CodeHighlighter, type HighlightSpan,
17
- } from '@deepseek-ai/dsh-client-ui-primitives'
18
- import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
17
+ } from '@deepseek-ai/dsh-client-ui-primitives/client'
18
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
19
+ import { restorable } from '../restore.ts'
19
20
  import type { ForgeDiffFile } from '../types.ts'
20
21
  import {
21
22
  drawnLines, EXPAND_STEP, hidesLine, segmentsOf, splitRows,
@@ -29,6 +30,8 @@ import type { FileReviewState } from './review-queue.ts'
29
30
  import { ReviewComposer, type ReviewActions } from './ReviewComposer.tsx'
30
31
  import reviewCss from './ReviewComposer.module.css'
31
32
  import { FileLabel } from './FileLabel.tsx'
33
+ import { FileMarkGlyph } from './glyphs.tsx'
34
+ import type { LocalWriteKind } from './local-writes.ts'
32
35
  import type { ForgePanelKey, NS } from './locales.ts'
33
36
  import type { ViewedState } from './viewed-files.ts'
34
37
  import type { SectionReach } from './section-reach.ts'
@@ -44,6 +47,10 @@ export interface DiffFileAction {
44
47
  readonly label: ForgePanelKey
45
48
  /** Runs the action. */
46
49
  readonly run: () => void
50
+ /** Whether the row starts a new group of the menu. */
51
+ readonly separated?: boolean | undefined
52
+ /** Whether the row cannot be activated now. */
53
+ readonly disabled?: boolean | undefined
47
54
  }
48
55
 
49
56
  /** New side of a file: its lines once read, `loading` while a read runs, or undefined before any. */
@@ -64,6 +71,8 @@ export interface DiffFileHandlers {
64
71
  readonly readContext: (file: ForgeDiffFile) => void
65
72
  /** Mark a file viewed, which also collapses it, or clear the mark. */
66
73
  readonly view: (file: ForgeDiffFile, viewed: boolean) => void
74
+ /** Stage or unstage the file, or ask to restore it. */
75
+ readonly write: (file: ForgeDiffFile, kind: LocalWriteKind) => void
67
76
  /** Rows of a file's menu, read whenever the menu draws. */
68
77
  readonly actions: (file: ForgeDiffFile) => readonly DiffFileAction[]
69
78
  /** Receive a file's section element, which scrolling to the file targets, or null once it unmounts. */
@@ -104,6 +113,8 @@ export interface DiffFileProps {
104
113
  readonly wrap: boolean
105
114
  /** Badge text after the path, or empty for none. */
106
115
  readonly badge: string
116
+ /** The letter a narrow view draws in place of the badge text, or empty without a badge. */
117
+ readonly badgeLetter: string
107
118
  /** Hover text of the path: both paths of a renamed file, else the path. */
108
119
  readonly tooltip: string
109
120
  /** Whether the reader marked this change viewed, or marked an earlier change of the file. */
@@ -112,6 +123,13 @@ export interface DiffFileProps {
112
123
  readonly viewedNote: string
113
124
  /** Whether the mark cannot change now, while its write is in flight or the host's marks could not be read. */
114
125
  readonly viewedDisabled: boolean
126
+ /**
127
+ * The local scope whose writes the header offers: staging and restoring for `unstaged`, unstaging for `staged`;
128
+ * undefined offers none.
129
+ */
130
+ readonly writes?: 'unstaged' | 'staged' | undefined
131
+ /** Whether the header's writes wait for a write in flight or a reread of the scope. */
132
+ readonly writing?: boolean | undefined
115
133
  /** Review threads of the file from the code host, or undefined while none are read; the view keeps their identity. */
116
134
  readonly threads?: FileThreads | undefined
117
135
  /** Whether the section draws its lines at once, as the target of a thread jump, whose card must exist to be centered. */
@@ -128,20 +146,45 @@ export interface DiffFileProps {
128
146
  readonly t: Translate
129
147
  }
130
148
 
149
+ /** The line counts {@link Counts} draws for one file. */
150
+ type CountedFile = Pick<ForgeDiffFile, 'additions' | 'deletions' | 'binary'>
151
+
152
+ const addedCount = (file: CountedFile): string => `+${file.additions.toLocaleString('en-US')}`
153
+ const deletedCount = (file: CountedFile): string => `−${file.deletions.toLocaleString('en-US')}`
154
+
155
+ /** The width {@link Counts} reads from the nearest ancestor that sets it, in `ch` of the counts' monospace font. */
156
+ export type CountsColumn = CSSProperties & { '--forge-deleted-width': string }
157
+
131
158
  /**
132
- * Render added and deleted line counts, or the binary label for binary content.
159
+ * Size the deleted count of a list of files to the list's widest `−N`. The counts end at a row's trailing edge, so
160
+ * with one width for the deleted count every row under the element that takes the style also ends its added count on
161
+ * one edge.
162
+ * @param files - every file the list can show.
163
+ * @returns the style for the list's container.
164
+ */
165
+ export function countsColumn(files: readonly CountedFile[]): CountsColumn {
166
+ let deleted = 0
167
+ for (const file of files) {
168
+ if (!file.binary) deleted = Math.max(deleted, deletedCount(file).length)
169
+ }
170
+ return { '--forge-deleted-width': `${deleted}ch` }
171
+ }
172
+
173
+ /**
174
+ * Render added and deleted line counts, or the binary label for binary content. Under a container styled with
175
+ * {@link countsColumn}, the deleted count fills that width from the trailing edge.
133
176
  * @param props - the counts and copy.
134
177
  * @returns the counts.
135
178
  */
136
179
  export function Counts({ file, t }: {
137
- readonly file: Pick<ForgeDiffFile, 'additions' | 'deletions' | 'binary'>
180
+ readonly file: CountedFile
138
181
  readonly t: Translate
139
182
  }): ReactNode {
140
183
  if (file.binary) return <span>{t('diff.binaryLabel')}</span>
141
184
  return (
142
185
  <span className={css.counts}>
143
- <span className={css.added}>{`+${file.additions.toLocaleString('en-US')}`}</span>
144
- <span className={css.deleted}>{`−${file.deletions.toLocaleString('en-US')}`}</span>
186
+ <span className={css.added}>{addedCount(file)}</span>
187
+ <span className={css.deleted}>{deletedCount(file)}</span>
145
188
  </span>
146
189
  )
147
190
  }
@@ -266,6 +309,21 @@ function pairKind(pair: SplitRow): 'context' | 'change' {
266
309
  return pair.left !== null && pair.left.kind === 'context' ? 'context' : 'change'
267
310
  }
268
311
 
312
+ /** An open comment editor for one range, which closes itself out of the ranges being written. */
313
+ function RangeEditor({ item, actions, visible, setEditors, t }: {
314
+ readonly item: ReviewSelection
315
+ readonly actions: ReviewActions
316
+ readonly visible: boolean
317
+ readonly setEditors: Dispatch<SetStateAction<readonly ReviewSelection[]>>
318
+ readonly t: Translate
319
+ }) {
320
+ const comment = item.comment
321
+ const close = useCallback((): void => {
322
+ setEditors(list => list.filter(open => !sameRange(open.comment, comment)))
323
+ }, [comment, setEditors])
324
+ return <ReviewComposer selection={item} visible={visible} actions={actions} close={close} t={t} />
325
+ }
326
+
269
327
  /** The hunks of one file with their collapsed and expanded unchanged lines. */
270
328
  function Lines({ file, text, open, handlers, split, wrap, review, visible, comments, threads, folded, annotations, t }: Pick<DiffFileProps,
271
329
  'file' | 'text' | 'open' | 'handlers' | 'split' | 'wrap' | 'review' | 'visible' | 'threads' | 'folded' | 't'> & LinesNotes): ReactNode {
@@ -329,7 +387,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
329
387
  if (nativeSide === null) return
330
388
  const copy = (event: ClipboardEvent): void => {
331
389
  if (root.current === null || event.clipboardData === null
332
- || (event.target instanceof Element && event.target.closest('input, textarea, [contenteditable="true"]') !== null)) return
390
+ || (event.target as Partial<Element>).closest?.('input, textarea, [contenteditable="true"]') != null) return
333
391
  const selected = readCodeSelection(root.current, nativeSide)
334
392
  if (selected === undefined) return
335
393
  event.preventDefault()
@@ -520,8 +578,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
520
578
  return nodes
521
579
  }
522
580
  const editorOf = (item: ReviewSelection, actions: ReviewActions): ReactNode =>
523
- <ReviewComposer key={`comment-${rangeKey(item)}`} selection={item} visible={visible} actions={actions}
524
- close={() => { setEditors(list => list.filter(open => !sameRange(open.comment, item.comment))) }} t={t} />
581
+ <RangeEditor key={`comment-${rangeKey(item)}`} item={item} actions={actions} visible={visible} setEditors={setEditors} t={t} />
525
582
  // Side by side, a row's comments sit in a row of two cells under its columns, each continuing its line's background.
526
583
  const notes = (key: string, pair: SplitRow): void => {
527
584
  const left = commentsAt('L', pair.left?.no ?? null)
@@ -630,8 +687,8 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
630
687
  data-review={review === undefined ? undefined : ''}
631
688
  data-native-side={nativeSide ?? undefined}
632
689
  onPointerDownCapture={(event) => {
633
- if (event.button !== 0 || !(event.target instanceof Node)) return
634
- const side = codeSideAt(event.currentTarget, event.target)
690
+ if (event.button !== 0) return
691
+ const side = codeSideAt(event.currentTarget, event.target as Node)
635
692
  if (side === undefined) return
636
693
  if (!event.shiftKey || nativeSide !== side) window.getSelection()?.removeAllRanges()
637
694
  dragging.current = 'text'
@@ -696,6 +753,27 @@ function Body(props: DiffFileProps): ReactNode {
696
753
  </>
697
754
  }
698
755
 
756
+ /** One row of a file's menu: it closes the menu, then runs the action. */
757
+ function FileMenuAction({ action, close, t }: {
758
+ readonly action: DiffFileAction
759
+ readonly close: () => void
760
+ readonly t: Translate
761
+ }) {
762
+ const run = useCallback((): void => {
763
+ close()
764
+ action.run()
765
+ }, [action, close])
766
+ return (
767
+ <MenuItemButton
768
+ separatorBefore={action.separated === true}
769
+ disabled={action.disabled === true}
770
+ onSelect={run}
771
+ >
772
+ {t(action.label)}
773
+ </MenuItemButton>
774
+ )
775
+ }
776
+
699
777
  /** File actions live only while their owning tab is visible. */
700
778
  function FileMenu({ name, file, handlers, t }: {
701
779
  readonly name: string
@@ -704,6 +782,7 @@ function FileMenu({ name, file, handlers, t }: {
704
782
  readonly t: Translate
705
783
  }): ReactNode {
706
784
  const [menuOpen, setMenuOpen] = useState(false)
785
+ const close = useCallback((): void => { setMenuOpen(false) }, [])
707
786
  return (
708
787
  <Menu
709
788
  open={menuOpen}
@@ -711,7 +790,7 @@ function FileMenu({ name, file, handlers, t }: {
711
790
  align="end"
712
791
  dense
713
792
  autoFocus
714
- onClose={() => { setMenuOpen(false) }}
793
+ onClose={close}
715
794
  anchor={(
716
795
  <button
717
796
  type="button"
@@ -726,21 +805,38 @@ function FileMenu({ name, file, handlers, t }: {
726
805
  )}
727
806
  >
728
807
  {handlers.actions(file).map(action => (
729
- <MenuItemButton
730
- key={action.label}
731
- onSelect={() => {
732
- setMenuOpen(false)
733
- action.run()
734
- }}
735
- >
736
- {t(action.label)}
737
- </MenuItemButton>
808
+ <FileMenuAction key={action.label} action={action} close={close} t={t} />
738
809
  ))}
739
810
  {menuOpen && <div className={css.menuPlugins}>{handlers.fileMenu(file, () => { setMenuOpen(false) })}</div>}
740
811
  </Menu>
741
812
  )
742
813
  }
743
814
 
815
+ const WRITE_COPY: Record<LocalWriteKind, { readonly tip: ForgePanelKey; readonly name: ForgePanelKey }> = {
816
+ stage: { tip: 'diff.stageFile', name: 'diff.stageFileAria' },
817
+ unstage: { tip: 'diff.unstageFile', name: 'diff.unstageFileAria' },
818
+ restore: { tip: 'diff.restoreFile', name: 'diff.restoreFileAria' },
819
+ }
820
+
821
+ /** One write of a file as an icon button, named by its tooltip. */
822
+ function WriteTool({ kind, name, file, disabled, handlers, t }: {
823
+ readonly kind: LocalWriteKind
824
+ readonly name: string
825
+ readonly file: ForgeDiffFile
826
+ readonly disabled: boolean
827
+ readonly handlers: DiffFileHandlers
828
+ readonly t: Translate
829
+ }): ReactNode {
830
+ return (
831
+ <Tooltip label={t(WRITE_COPY[kind].tip)} side="bottom" portal delayMs={500}>
832
+ <button type="button" className={css.tool} aria-label={t(WRITE_COPY[kind].name, { name })} disabled={disabled} data-forge-write={kind}
833
+ onClick={() => { handlers.write(file, kind) }}>
834
+ {kind === 'stage' ? <IconPlusOutlineRegular /> : <FileMarkGlyph mark={kind} />}
835
+ </button>
836
+ </Tooltip>
837
+ )
838
+ }
839
+
744
840
  /**
745
841
  * Render one file of a diff. Until the section first comes within reach of the scrollport or a thread jump targets it,
746
842
  * an expanded file that draws lines shows a box of about their height instead.
@@ -748,7 +844,10 @@ function FileMenu({ name, file, handlers, t }: {
748
844
  * @returns the file section.
749
845
  */
750
846
  function DiffFileSection(props: DiffFileProps): ReactNode {
751
- const { file, expanded, large, revealed, badge, tooltip, viewed, viewedNote, viewedDisabled, threads, handlers, t } = props
847
+ const {
848
+ file, expanded, large, revealed, badge, badgeLetter, tooltip, viewed, viewedNote, viewedDisabled, writes, writing = false,
849
+ threads, handlers, t,
850
+ } = props
752
851
  const name = file.path.slice(file.path.lastIndexOf('/') + 1)
753
852
  const element = useRef<HTMLElement | null>(null)
754
853
  const [reached, setReached] = useState(false)
@@ -768,7 +867,7 @@ function DiffFileSection(props: DiffFileProps): ReactNode {
768
867
  return (
769
868
  <section ref={sectionRef} className={css.file} data-forge-diff-file={file.path} data-expanded={expanded ? '' : undefined}
770
869
  data-viewed={viewed}>
771
- <div className={css.fileHeader}>
870
+ <div className={css.fileHeader} data-forge-file-writes={writes}>
772
871
  <button
773
872
  type="button"
774
873
  className={css.fileToggle}
@@ -796,13 +895,32 @@ function DiffFileSection(props: DiffFileProps): ReactNode {
796
895
  </Tooltip>
797
896
  )}
798
897
  <span className={css.fileSpacer} data-forge-path-spacer="" />
799
- {badge !== '' && <span className={css.badge}>{badge}</span>}
898
+ {badge !== '' && (
899
+ // The tooltip repeats the badge's words where they are cut: past half the title, or to their letter in a narrow view.
900
+ <Tooltip label={badge} side="bottom" portal delayMs={500} openOnClick onlyWhenClipped>
901
+ <span className={css.badge} data-forge-file-badge="">
902
+ <span className={css.badgeText}>{badge}</span>
903
+ <span className={css.badgeLetter} aria-hidden="true">{badgeLetter}</span>
904
+ </span>
905
+ </Tooltip>
906
+ )}
800
907
  </span>
801
908
  {!file.binary && <Counts file={file} t={t} />}
909
+ {writes !== undefined && (
910
+ <span className={css.fileActions} data-forge-file-actions="">
911
+ {writes === 'unstaged' && restorable(file) && (
912
+ <WriteTool kind="restore" name={name} file={file} disabled={writing} handlers={handlers} t={t} />
913
+ )}
914
+ <WriteTool kind={writes === 'unstaged' ? 'stage' : 'unstage'} name={name} file={file} disabled={writing} handlers={handlers} t={t} />
915
+ </span>
916
+ )}
802
917
  <Tooltip label={viewedNote} side="bottom" align="end" portal delayMs={500}>
803
- <label className={css.viewed} data-disabled={viewedDisabled ? '' : undefined}>
918
+ <label className={css.viewed} data-checked={viewed === 'viewed' ? '' : undefined} data-disabled={viewedDisabled ? '' : undefined}>
804
919
  <input type="checkbox" checked={viewed === 'viewed'} aria-label={t('viewed.aria', { name })} disabled={viewedDisabled}
805
920
  onChange={(event) => { handlers.view(file, event.target.checked) }} />
921
+ <span className={css.viewedMark} aria-hidden="true">
922
+ {viewed === 'viewed' ? <IconCheckCircleOutlineRegular /> : <FileMarkGlyph mark="unviewed" />}
923
+ </span>
806
924
  <span className={css.viewedLabel} aria-hidden="true">{t('viewed.label')}</span>
807
925
  </label>
808
926
  </Tooltip>