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

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 (315) hide show
  1. package/README.i18n.yaml +8 -8
  2. package/README.md +29 -12
  3. package/README.zh.md +29 -12
  4. package/lib/client.js +21 -16
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +874 -170
  7. package/lib/typert.host.js +831 -156
  8. package/lib/typert.remote-client.d.ts +29 -11
  9. package/lib/typert.remote-client.d.ts.map +1 -1
  10. package/lib/typert.remote-client.js +727 -134
  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/AttentionIndicator.d.ts +1 -1
  15. package/lib/types/client/AttentionIndicator.d.ts.map +1 -1
  16. package/lib/types/client/BaseMenu.d.ts +6 -4
  17. package/lib/types/client/BaseMenu.d.ts.map +1 -1
  18. package/lib/types/client/BaseMenu.js.map +1 -1
  19. package/lib/types/client/BranchPicker.d.ts +84 -0
  20. package/lib/types/client/BranchPicker.d.ts.map +1 -0
  21. package/lib/types/client/BranchPicker.js.map +1 -0
  22. package/lib/types/client/ChangeRequestCard.d.ts +21 -12
  23. package/lib/types/client/ChangeRequestCard.d.ts.map +1 -1
  24. package/lib/types/client/ChangeRequestCard.js.map +1 -1
  25. package/lib/types/client/ChangeRequestOverview.d.ts +12 -6
  26. package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -1
  27. package/lib/types/client/ChangeRequestOverview.js.map +1 -1
  28. package/lib/types/client/ChangeRequestsSection.d.ts +5 -3
  29. package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -1
  30. package/lib/types/client/ChangeRequestsSection.js.map +1 -1
  31. package/lib/types/client/ChangedFiles.d.ts +1 -1
  32. package/lib/types/client/ChangedFiles.d.ts.map +1 -1
  33. package/lib/types/client/ChangedFiles.js.map +1 -1
  34. package/lib/types/client/ChangesLoading.d.ts +1 -1
  35. package/lib/types/client/ChangesLoading.d.ts.map +1 -1
  36. package/lib/types/client/ChangesTab.d.ts +15 -7
  37. package/lib/types/client/ChangesTab.d.ts.map +1 -1
  38. package/lib/types/client/ChangesTab.js.map +1 -1
  39. package/lib/types/client/ChangesTabTitle.d.ts +1 -1
  40. package/lib/types/client/ChangesTabTitle.d.ts.map +1 -1
  41. package/lib/types/client/ChangesTabTitle.js.map +1 -1
  42. package/lib/types/client/CommitMenu.d.ts +3 -3
  43. package/lib/types/client/CommitMenu.d.ts.map +1 -1
  44. package/lib/types/client/CommitMenu.js.map +1 -1
  45. package/lib/types/client/DiffFile.d.ts +16 -2
  46. package/lib/types/client/DiffFile.d.ts.map +1 -1
  47. package/lib/types/client/DiffFile.js.map +1 -1
  48. package/lib/types/client/EnvironmentRows.d.ts +6 -6
  49. package/lib/types/client/EnvironmentRows.d.ts.map +1 -1
  50. package/lib/types/client/EnvironmentRows.js.map +1 -1
  51. package/lib/types/client/FileLabel.js.map +1 -1
  52. package/lib/types/client/HeadMenu.d.ts +35 -0
  53. package/lib/types/client/HeadMenu.d.ts.map +1 -0
  54. package/lib/types/client/HeadMenu.js.map +1 -0
  55. package/lib/types/client/HostSettings.d.ts +33 -0
  56. package/lib/types/client/HostSettings.d.ts.map +1 -0
  57. package/lib/types/client/HostSettings.js.map +1 -0
  58. package/lib/types/client/LensFilter.d.ts +2 -2
  59. package/lib/types/client/LensFilter.d.ts.map +1 -1
  60. package/lib/types/client/LensFilter.js.map +1 -1
  61. package/lib/types/client/ReasonButton.js.map +1 -1
  62. package/lib/types/client/RefreshGlyph.js.map +1 -1
  63. package/lib/types/client/ReviewComposer.d.ts +1 -1
  64. package/lib/types/client/ReviewComposer.d.ts.map +1 -1
  65. package/lib/types/client/ReviewComposer.js.map +1 -1
  66. package/lib/types/client/ReviewControls.d.ts +1 -1
  67. package/lib/types/client/ReviewControls.d.ts.map +1 -1
  68. package/lib/types/client/ReviewControls.js.map +1 -1
  69. package/lib/types/client/ReviewThread.d.ts +1 -1
  70. package/lib/types/client/ReviewThread.d.ts.map +1 -1
  71. package/lib/types/client/ReviewThread.js.map +1 -1
  72. package/lib/types/client/ReviewThreads.d.ts +4 -2
  73. package/lib/types/client/ReviewThreads.d.ts.map +1 -1
  74. package/lib/types/client/ReviewThreads.js.map +1 -1
  75. package/lib/types/client/SessionHoverForge.d.ts +1 -1
  76. package/lib/types/client/SessionHoverForge.d.ts.map +1 -1
  77. package/lib/types/client/SessionHoverForge.js.map +1 -1
  78. package/lib/types/client/SessionRowForge.d.ts +1 -1
  79. package/lib/types/client/SessionRowForge.d.ts.map +1 -1
  80. package/lib/types/client/SessionRowForge.js.map +1 -1
  81. package/lib/types/client/SubmitReview.d.ts +1 -1
  82. package/lib/types/client/SubmitReview.d.ts.map +1 -1
  83. package/lib/types/client/SubmitReview.js.map +1 -1
  84. package/lib/types/client/ThreadList.d.ts +3 -1
  85. package/lib/types/client/ThreadList.d.ts.map +1 -1
  86. package/lib/types/client/ThreadList.js.map +1 -1
  87. package/lib/types/client/ViewOptionsMenu.d.ts +1 -1
  88. package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -1
  89. package/lib/types/client/ViewOptionsMenu.js.map +1 -1
  90. package/lib/types/client/WorktreeNameDialog.d.ts +1 -1
  91. package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -1
  92. package/lib/types/client/WorktreeNameDialog.js.map +1 -1
  93. package/lib/types/client/WorktreeProgress.d.ts +1 -1
  94. package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
  95. package/lib/types/client/WorktreeProgress.js.map +1 -1
  96. package/lib/types/client/WorktreeSettings.d.ts +1 -1
  97. package/lib/types/client/WorktreeSettings.d.ts.map +1 -1
  98. package/lib/types/client/WorktreeSettings.js.map +1 -1
  99. package/lib/types/client/WorktreeToggle.d.ts +1 -1
  100. package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
  101. package/lib/types/client/WorktreeToggle.js.map +1 -1
  102. package/lib/types/client/annotations.d.ts +1 -1
  103. package/lib/types/client/annotations.d.ts.map +1 -1
  104. package/lib/types/client/branch-search.d.ts +1 -1
  105. package/lib/types/client/branch-search.d.ts.map +1 -1
  106. package/lib/types/client/branch-search.js.map +1 -1
  107. package/lib/types/client/changes-address.d.ts +1 -1
  108. package/lib/types/client/changes-address.d.ts.map +1 -1
  109. package/lib/types/client/changes-service.d.ts +1 -1
  110. package/lib/types/client/changes-service.d.ts.map +1 -1
  111. package/lib/types/client/changes-store.d.ts +18 -2
  112. package/lib/types/client/changes-store.d.ts.map +1 -1
  113. package/lib/types/client/changes-store.js.map +1 -1
  114. package/lib/types/client/checkout.d.ts +1 -1
  115. package/lib/types/client/checkout.d.ts.map +1 -1
  116. package/lib/types/client/code-selection.d.ts.map +1 -1
  117. package/lib/types/client/code-selection.js.map +1 -1
  118. package/lib/types/client/forge-copy.d.ts +8 -1
  119. package/lib/types/client/forge-copy.d.ts.map +1 -1
  120. package/lib/types/client/forge-copy.js.map +1 -1
  121. package/lib/types/client/format.d.ts +1 -1
  122. package/lib/types/client/format.d.ts.map +1 -1
  123. package/lib/types/client/format.js.map +1 -1
  124. package/lib/types/client/glyphs.d.ts +23 -1
  125. package/lib/types/client/glyphs.d.ts.map +1 -1
  126. package/lib/types/client/glyphs.js.map +1 -1
  127. package/lib/types/client/highlight-context.d.ts +1 -1
  128. package/lib/types/client/highlight-context.d.ts.map +1 -1
  129. package/lib/types/client/host-settings-form.d.ts +69 -0
  130. package/lib/types/client/host-settings-form.d.ts.map +1 -0
  131. package/lib/types/client/host-settings-form.js.map +1 -0
  132. package/lib/types/client/host-sign-in.d.ts +31 -0
  133. package/lib/types/client/host-sign-in.d.ts.map +1 -0
  134. package/lib/types/client/host-sign-in.js.map +1 -0
  135. package/lib/types/client/local-writes.d.ts +47 -0
  136. package/lib/types/client/local-writes.d.ts.map +1 -0
  137. package/lib/types/client/local-writes.js.map +1 -0
  138. package/lib/types/client/locales.d.ts +106 -9
  139. package/lib/types/client/locales.d.ts.map +1 -1
  140. package/lib/types/client/locales.js.map +1 -1
  141. package/lib/types/client/mount.d.ts +15 -1
  142. package/lib/types/client/mount.d.ts.map +1 -1
  143. package/lib/types/client/mount.js.map +1 -1
  144. package/lib/types/client/review-page/ReviewActivity.d.ts +44 -0
  145. package/lib/types/client/review-page/ReviewActivity.d.ts.map +1 -0
  146. package/lib/types/client/review-page/ReviewActivity.js.map +1 -0
  147. package/lib/types/client/review-page/ReviewChat.d.ts +1 -1
  148. package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -1
  149. package/lib/types/client/review-page/ReviewChat.js.map +1 -1
  150. package/lib/types/client/review-page/ReviewDetail.d.ts +23 -9
  151. package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -1
  152. package/lib/types/client/review-page/ReviewDetail.js.map +1 -1
  153. package/lib/types/client/review-page/ReviewLabels.d.ts +1 -1
  154. package/lib/types/client/review-page/ReviewLabels.d.ts.map +1 -1
  155. package/lib/types/client/review-page/ReviewLabels.js.map +1 -1
  156. package/lib/types/client/review-page/ReviewList.d.ts +10 -8
  157. package/lib/types/client/review-page/ReviewList.d.ts.map +1 -1
  158. package/lib/types/client/review-page/ReviewList.js.map +1 -1
  159. package/lib/types/client/review-page/ReviewNav.d.ts +1 -1
  160. package/lib/types/client/review-page/ReviewNav.d.ts.map +1 -1
  161. package/lib/types/client/review-page/ReviewPage.d.ts +15 -12
  162. package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -1
  163. package/lib/types/client/review-page/ReviewPage.js.map +1 -1
  164. package/lib/types/client/review-page/ReviewSkeleton.d.ts +26 -0
  165. package/lib/types/client/review-page/ReviewSkeleton.d.ts.map +1 -0
  166. package/lib/types/client/review-page/ReviewSkeleton.js.map +1 -0
  167. package/lib/types/client/review-page/ReviewStatus.d.ts +5 -3
  168. package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -1
  169. package/lib/types/client/review-page/ReviewStatus.js.map +1 -1
  170. package/lib/types/client/review-page/review-activity.d.ts +37 -0
  171. package/lib/types/client/review-page/review-activity.d.ts.map +1 -0
  172. package/lib/types/client/review-page/review-activity.js.map +1 -0
  173. package/lib/types/client/review-page/review-lists.d.ts +48 -13
  174. package/lib/types/client/review-page/review-lists.d.ts.map +1 -1
  175. package/lib/types/client/review-page/review-lists.js.map +1 -1
  176. package/lib/types/client/review-page/review-mount.d.ts +3 -1
  177. package/lib/types/client/review-page/review-mount.d.ts.map +1 -1
  178. package/lib/types/client/review-page/review-mount.js.map +1 -1
  179. package/lib/types/client/review-page/review-store.d.ts +18 -8
  180. package/lib/types/client/review-page/review-store.d.ts.map +1 -1
  181. package/lib/types/client/review-page/review-store.js.map +1 -1
  182. package/lib/types/client/review-queue.d.ts +1 -1
  183. package/lib/types/client/review-queue.d.ts.map +1 -1
  184. package/lib/types/client/review-queue.js.map +1 -1
  185. package/lib/types/client/review-threads.d.ts +1 -1
  186. package/lib/types/client/review-threads.d.ts.map +1 -1
  187. package/lib/types/client/review.d.ts +12 -1
  188. package/lib/types/client/review.d.ts.map +1 -1
  189. package/lib/types/client/review.js.map +1 -1
  190. package/lib/types/client/row-form-labels.d.ts +12 -0
  191. package/lib/types/client/row-form-labels.d.ts.map +1 -0
  192. package/lib/types/client/row-form-labels.js.map +1 -0
  193. package/lib/types/client/session-list.d.ts +1 -1
  194. package/lib/types/client/session-list.d.ts.map +1 -1
  195. package/lib/types/client/slots.d.ts +1 -1
  196. package/lib/types/client/slots.d.ts.map +1 -1
  197. package/lib/types/client/source.d.ts +1 -1
  198. package/lib/types/client/source.d.ts.map +1 -1
  199. package/lib/types/client/status.d.ts +7 -0
  200. package/lib/types/client/status.d.ts.map +1 -1
  201. package/lib/types/client/status.js.map +1 -1
  202. package/lib/types/client/worktree-settings-form.d.ts +1 -1
  203. package/lib/types/client/worktree-settings-form.d.ts.map +1 -1
  204. package/lib/types/client/worktree-settings-form.js.map +1 -1
  205. package/lib/types/diff.d.ts.map +1 -1
  206. package/lib/types/diff.js.map +1 -1
  207. package/lib/types/git.d.ts +22 -0
  208. package/lib/types/git.d.ts.map +1 -1
  209. package/lib/types/git.js.map +1 -1
  210. package/lib/types/index.d.ts +113 -25
  211. package/lib/types/index.d.ts.map +1 -1
  212. package/lib/types/index.js.map +1 -1
  213. package/lib/types/local-diff.d.ts +81 -23
  214. package/lib/types/local-diff.d.ts.map +1 -1
  215. package/lib/types/local-diff.js.map +1 -1
  216. package/lib/types/local-write.d.ts +44 -0
  217. package/lib/types/local-write.d.ts.map +1 -0
  218. package/lib/types/local-write.js.map +1 -0
  219. package/lib/types/parse.d.ts +12 -3
  220. package/lib/types/parse.d.ts.map +1 -1
  221. package/lib/types/parse.js.map +1 -1
  222. package/lib/types/restore.d.ts +12 -0
  223. package/lib/types/restore.d.ts.map +1 -0
  224. package/lib/types/restore.js.map +1 -0
  225. package/lib/types/types.d.ts +106 -8
  226. package/lib/types/types.d.ts.map +1 -1
  227. package/lib/types/viewer-lists.d.ts +22 -13
  228. package/lib/types/viewer-lists.d.ts.map +1 -1
  229. package/lib/types/viewer-lists.js.map +1 -1
  230. package/package.json +60 -58
  231. package/src/client/ActionToast.tsx +2 -2
  232. package/src/client/AttentionIndicator.tsx +1 -1
  233. package/src/client/BaseMenu.module.css +12 -3
  234. package/src/client/BaseMenu.tsx +25 -88
  235. package/src/client/BranchPicker.tsx +161 -0
  236. package/src/client/ChangeRequestCard.tsx +138 -44
  237. package/src/client/ChangeRequestOverview.tsx +21 -9
  238. package/src/client/ChangeRequestsSection.tsx +12 -6
  239. package/src/client/ChangedFiles.tsx +2 -2
  240. package/src/client/ChangesLoading.tsx +1 -1
  241. package/src/client/ChangesTab.module.css +95 -16
  242. package/src/client/ChangesTab.tsx +190 -72
  243. package/src/client/ChangesTabTitle.tsx +2 -2
  244. package/src/client/CommitMenu.tsx +7 -5
  245. package/src/client/DiffFile.tsx +67 -11
  246. package/src/client/EnvironmentRows.tsx +21 -17
  247. package/src/client/FileLabel.tsx +1 -1
  248. package/src/client/Forge.module.css +28 -1
  249. package/src/client/HeadMenu.tsx +69 -0
  250. package/src/client/HostSettings.module.css +194 -0
  251. package/src/client/HostSettings.tsx +192 -0
  252. package/src/client/LensFilter.tsx +2 -2
  253. package/src/client/ReasonButton.tsx +1 -1
  254. package/src/client/RefreshGlyph.tsx +1 -1
  255. package/src/client/ReviewComposer.tsx +2 -2
  256. package/src/client/ReviewControls.tsx +10 -3
  257. package/src/client/ReviewThread.tsx +2 -2
  258. package/src/client/ReviewThreads.tsx +7 -4
  259. package/src/client/SessionHoverForge.tsx +2 -2
  260. package/src/client/SessionRowForge.tsx +2 -2
  261. package/src/client/SubmitReview.tsx +2 -2
  262. package/src/client/ThreadList.tsx +6 -3
  263. package/src/client/ViewOptionsMenu.tsx +2 -2
  264. package/src/client/WorktreeNameDialog.tsx +2 -2
  265. package/src/client/WorktreeProgress.tsx +2 -2
  266. package/src/client/WorktreeSettings.tsx +4 -11
  267. package/src/client/WorktreeToggle.tsx +2 -2
  268. package/src/client/annotations.ts +1 -1
  269. package/src/client/branch-search.tsx +2 -2
  270. package/src/client/changes-address.ts +1 -1
  271. package/src/client/changes-service.ts +1 -1
  272. package/src/client/changes-store.ts +49 -5
  273. package/src/client/checkout.ts +1 -1
  274. package/src/client/code-selection.ts +3 -1
  275. package/src/client/forge-copy.ts +11 -1
  276. package/src/client/format.ts +2 -2
  277. package/src/client/glyphs.tsx +50 -5
  278. package/src/client/highlight-context.ts +1 -1
  279. package/src/client/host-settings-form.ts +115 -0
  280. package/src/client/host-sign-in.ts +46 -0
  281. package/src/client/local-writes.ts +129 -0
  282. package/src/client/locales.ts +841 -65
  283. package/src/client/mount.ts +56 -7
  284. package/src/client/review-page/ReviewActivity.tsx +405 -0
  285. package/src/client/review-page/ReviewChat.tsx +2 -2
  286. package/src/client/review-page/ReviewDetail.tsx +201 -64
  287. package/src/client/review-page/ReviewLabels.tsx +2 -2
  288. package/src/client/review-page/ReviewList.tsx +153 -136
  289. package/src/client/review-page/ReviewNav.tsx +1 -1
  290. package/src/client/review-page/ReviewPage.module.css +490 -13
  291. package/src/client/review-page/ReviewPage.tsx +44 -21
  292. package/src/client/review-page/ReviewSkeleton.tsx +108 -0
  293. package/src/client/review-page/ReviewStatus.tsx +14 -9
  294. package/src/client/review-page/review-activity.ts +64 -0
  295. package/src/client/review-page/review-lists.ts +85 -22
  296. package/src/client/review-page/review-mount.ts +24 -7
  297. package/src/client/review-page/review-store.ts +24 -7
  298. package/src/client/review-queue.ts +7 -3
  299. package/src/client/review-threads.ts +1 -1
  300. package/src/client/review.ts +20 -2
  301. package/src/client/row-form-labels.ts +17 -0
  302. package/src/client/session-list.ts +1 -1
  303. package/src/client/slots.ts +1 -1
  304. package/src/client/source.ts +1 -1
  305. package/src/client/status.ts +20 -0
  306. package/src/client/worktree-settings-form.ts +1 -1
  307. package/src/diff.ts +8 -5
  308. package/src/git.ts +31 -1
  309. package/src/index.ts +241 -50
  310. package/src/local-diff.ts +151 -48
  311. package/src/local-write.ts +159 -0
  312. package/src/parse.ts +26 -4
  313. package/src/restore.ts +15 -0
  314. package/src/types.ts +97 -12
  315. package/src/viewer-lists.ts +124 -48
@@ -17,20 +17,21 @@ import {
17
17
  import clsx from 'clsx'
18
18
  import {
19
19
  Button, IconBranchOutlineRegular, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconCompareSplitOutlineRegular,
20
- IconInfoOutlineRegular, IconFilesDiffOutlineRegular, IconNowrapFillRegular, IconRightUpOutlineRegular, IconWorkspaceTreeOutlineRegular,
20
+ IconInfoOutlineRegular, IconNowrapFillRegular, IconWorkspaceTreeOutlineRegular,
21
21
  IconWrapFillRegular,
22
- Menu, Tooltip,
22
+ Menu, Modal, Tooltip,
23
23
  type MenuEntry,
24
- } from '@deepseek-ai/dsh-client-ui-primitives'
25
- import type { HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
24
+ } from '@deepseek-ai/dsh-client-ui-primitives/client'
25
+ import type { HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots/client'
26
26
  import type { SidebarRightTabInfo } from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
27
27
  import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
28
28
  import { assertNever } from '@deepseek-ai/dsh-util-values'
29
29
  import { fileAddressFor, pathPartsOf } from '@deepseek-ai/dsh-util-workspace-path'
30
30
  import type {
31
31
  ForgeBaseBranch, ForgeBaseBranches, ForgeChangeRequestDiff, ForgeCommitRange, ForgeDiffFile, ForgeExtensionState, ForgeLensFrame,
32
- ForgeLensKeep, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope,
32
+ ForgeLensKeep, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope, ForgeLocalWrite, ForgeLocalWriteResult,
33
33
  } from '../types.ts'
34
+ import { restorable } from '../restore.ts'
34
35
  import { lensVersion } from '../lens-version.ts'
35
36
  import type {
36
37
  ForgeCommitList, ForgeReviewData, ForgeReviewRequest, ForgeReviewResult, ForgeReviewThread, ForgeReviewWrite, ForgeReviewWriteResult,
@@ -40,10 +41,11 @@ import { sameReviewSource, type RemovedRecord, type ReviewQueue } from './review
40
41
  import { ReviewThread, useFileReview } from './ReviewThread.tsx'
41
42
  import type { ReviewActions } from './ReviewComposer.tsx'
42
43
  import { SubmitReview } from './SubmitReview.tsx'
43
- import type { QuoteCopy, ReviewSelection, ReviewSource } from './review.ts'
44
+ import type { QuoteCopy, ReviewHead, ReviewSelection, ReviewSource } from './review.ts'
44
45
  import { BaseMenu } from './BaseMenu.tsx'
46
+ import { HeadMenu } from './HeadMenu.tsx'
45
47
  import { parseChangesAddress, type ChangesSource, type ChangesTarget } from './changes-address.ts'
46
- import type { ChangesLens, createChangesStore } from './changes-store.ts'
48
+ import type { ChangesHead, ChangesLens, createChangesStore } from './changes-store.ts'
47
49
  import { CommitMenu } from './CommitMenu.tsx'
48
50
  import { HideTestsSwitch, LensControl, LensMenu, LENSES, ViewedProgress } from './ReviewControls.tsx'
49
51
  import { viewedStateOf, type ViewedFiles, type ViewedMarks } from './viewed-files.ts'
@@ -55,7 +57,8 @@ import { changedFileTree, filesInTreeOrder } from './file-tree.ts'
55
57
  import { ChangedFilesMenu, type ChangedFilesProps, type ChangedFilesState } from './ChangedFiles.tsx'
56
58
  import { ChangesLoading } from './ChangesLoading.tsx'
57
59
  import { drawnLines, matchesHunks, revealGap, textLines, type GapExpansion, type GapReveal } from './diff-rows.ts'
58
- import { ChangeRequestGlyph } from './glyphs.tsx'
60
+ import { ChangeRequestGlyph, ForgeGlyph } from './glyphs.tsx'
61
+ import { useLocalWrites } from './local-writes.ts'
59
62
  import type { ForgePanelKey, NS } from './locales.ts'
60
63
  import { useForgeCopy } from './forge-copy.ts'
61
64
  import { RefreshGlyph } from './RefreshGlyph.tsx'
@@ -112,12 +115,20 @@ export interface ChangesTabInjected {
112
115
  readonly reconnect: () => void
113
116
  /** Read the local changes of one scope; `signal` aborts the read. */
114
117
  readonly localDiff: (scope: ForgeLocalScope, signal: AbortSignal) => Promise<RemoteResult<ForgeLocalDiff>>
115
- /** Read the branches the `branch` scope can compare with, whose names contain `query`; `signal` aborts the read. */
116
- readonly diffBases: (query: string, signal: AbortSignal) => Promise<RemoteResult<ForgeBaseBranches>>
118
+ /** Stage, unstage, or restore files of the local changes, or return index entries to an earlier tree; never retried. */
119
+ readonly localWrite: (write: ForgeLocalWrite) => Promise<RemoteResult<ForgeLocalWriteResult>>
120
+ /**
121
+ * Read the branches the `branch` scope of the head branch `head`, by its full ref, or of the Session's own checkout
122
+ * for null, can compare with, whose names contain `query`; `signal` aborts the read.
123
+ */
124
+ readonly diffBases: (head: string | null, query: string, signal: AbortSignal) => Promise<RemoteResult<ForgeBaseBranches>>
117
125
  /** Read the new side of one file in a local scope. */
118
126
  readonly localText: (scope: ForgeLocalScope, path: string) => Promise<RemoteResult<string>>
119
- /** List the commits of the `branch` scope compared with `base`, or with the automatic fork point for null; `signal` aborts the read. */
120
- readonly localCommits: (base: string | null, signal: AbortSignal) => Promise<RemoteResult<ForgeLocalCommits>>
127
+ /**
128
+ * List the commits of the `branch` scope of the head branch `head`, or of the Session's own checkout for null,
129
+ * compared with `base`, or with the automatic fork point for null; `signal` aborts the read.
130
+ */
131
+ readonly localCommits: (head: string | null, base: string | null, signal: AbortSignal) => Promise<RemoteResult<ForgeLocalCommits>>
121
132
  /** Read the changes of a change request, or of consecutive commits of it, by its binding URL; `signal` aborts the read. */
122
133
  readonly changeRequestDiff: (
123
134
  url: string, commits: ForgeCommitRange | null, signal: AbortSignal,
@@ -197,6 +208,10 @@ type ChangesData =
197
208
  readonly files: readonly ForgeDiffFile[]
198
209
  /** Scope the files were read in. */
199
210
  readonly scope: ForgeLocalScope
211
+ /** The branch the files show in place of the Session's checked-out one, or null for the Session's own checkout. */
212
+ readonly head: ChangesHead | null
213
+ /** Top-level directory of the worktree the files were read in for `head`, or null when they come from its commits. */
214
+ readonly worktree: string | null
200
215
  /** Name of what the `branch` scope compared with; null for other scopes. */
201
216
  readonly base: string | null
202
217
  /** Untracked files left out. */
@@ -272,6 +287,9 @@ const FAILURE: Partial<Record<string, ForgePanelKey>> = {
272
287
  'forgePanel/commits-not-linear': 'commits.notLinear',
273
288
  }
274
289
 
290
+ /** Git's name for the checked-out commit, shown for a checkout that has neither a branch nor a commit yet. */
291
+ const GIT_HEAD = 'HEAD'
292
+
275
293
  /** Failures of a chosen base branch, which offer the automatic fork point instead of a retry. */
276
294
  const BASE_FAILURE: Partial<Record<string, ForgePanelKey>> = {
277
295
  'forgePanel/base-missing': 'diff.baseMissing',
@@ -295,6 +313,7 @@ function baseFailureOf(failed: string | null, base: ForgeBaseBranch | null, t: T
295
313
  * status, beside the diff; marks read at another head refuse the read as the diff refuses a moved head.
296
314
  * @param source - local changes or a change request.
297
315
  * @param scope - local scope to read.
316
+ * @param localHead - the branch the local scope shows in place of the Session's checked-out one, or null.
298
317
  * @param commits - chosen commits of a change request, or null for all of it.
299
318
  * @param head - head commit of the change request's latest status, or null.
300
319
  * @param fresh - whether the viewed marks are read from the code host although the host keeps some, as after a refresh.
@@ -305,6 +324,7 @@ function baseFailureOf(failed: string | null, base: ForgeBaseBranch | null, t: T
305
324
  async function readChanges(
306
325
  source: ChangesSource,
307
326
  scope: ForgeLocalScope,
327
+ localHead: ChangesHead | null,
308
328
  commits: ForgeCommitRange | null,
309
329
  head: string | null,
310
330
  fresh: boolean,
@@ -314,8 +334,8 @@ async function readChanges(
314
334
  if (source.kind === 'local') {
315
335
  const result = await reads.localDiff(scope, signal)
316
336
  if (!result.ok) return result
317
- const { files, base, omitted } = result.value
318
- return { ok: true, value: { kind: 'local', files, scope, base, omitted } }
337
+ const { files, base, omitted, worktree } = result.value
338
+ return { ok: true, value: { kind: 'local', files, scope, head: localHead, worktree: worktree ?? null, base, omitted } }
319
339
  }
320
340
  const [result, marks] = await Promise.all([
321
341
  reads.changeRequestDiff(source.url, commits, signal),
@@ -328,6 +348,11 @@ async function readChanges(
328
348
  return { ok: true, value: { kind: 'change', files, url: source.url, headSha, commits, localAhead, fileUrls, viewed } }
329
349
  }
330
350
 
351
+ /** The sentence that says what restoring a file of the `unstaged` scope does to it. */
352
+ function restoreCopyOf(file: ForgeDiffFile): ForgePanelKey {
353
+ return file.untracked ? 'diff.restore.untracked' : file.status === 'deleted' ? 'diff.restore.deleted' : 'diff.restore.modified'
354
+ }
355
+
331
356
  /** The ref that identifies a comparison: the chosen base branch, or null for the automatic fork point and other scopes. */
332
357
  function baseRefOf(scope: ForgeLocalScope): string | null {
333
358
  return scope.kind === 'branch' ? scope.base : null
@@ -338,21 +363,28 @@ function commitsOf(scope: ForgeLocalScope): ForgeCommitRange | null {
338
363
  return scope.kind === 'branch' ? scope.commits : null
339
364
  }
340
365
 
341
- /** The source review comments on loaded changes record: the change request head, or the local scope with its base. */
366
+ /**
367
+ * The source review comments on loaded changes record: the change request head, or the local scope with its base and,
368
+ * for another branch than the Session's checked-out one, that branch with the worktree the changes were read in.
369
+ */
342
370
  function reviewSourceOf(data: ChangesData): ReviewSource {
343
- return data.kind === 'local'
344
- ? { kind: 'local', scope: data.scope.kind, base: data.base, baseRef: baseRefOf(data.scope), commits: commitsOf(data.scope) }
345
- : { kind: 'change', url: data.url, headSha: data.headSha, commits: data.commits }
371
+ if (data.kind === 'change') return { kind: 'change', url: data.url, headSha: data.headSha, commits: data.commits }
372
+ const head: ReviewHead | undefined = data.head === null ? undefined : { key: data.head.ref, name: data.head.name, root: data.worktree }
373
+ return {
374
+ kind: 'local', scope: data.scope.kind, base: data.base, baseRef: baseRefOf(data.scope), commits: commitsOf(data.scope),
375
+ ...(head === undefined ? {} : { head }),
376
+ }
346
377
  }
347
378
 
348
379
  /**
349
- * Identity of a diff source for viewed marks: the change request or local scope with its base ref and chosen commits.
380
+ * Identity of a diff source for viewed marks: the change request or local scope with its base ref and chosen commits,
381
+ * and the head while it is not the Session's own checkout, whose marks keep the identity they had before heads.
350
382
  * A change request's marks stay across head commits, so a file whose change a new push altered reads as changed.
351
383
  */
352
384
  function viewedSourceOf(source: ReviewSource): string {
353
- return JSON.stringify(source.kind === 'local'
354
- ? ['local', source.scope, source.baseRef, source.commits]
355
- : ['change', source.url, source.commits])
385
+ if (source.kind === 'change') return JSON.stringify(['change', source.url, source.commits])
386
+ const local = ['local', source.scope, source.baseRef, source.commits]
387
+ return JSON.stringify(source.head === undefined ? local : [...local, source.head.key])
356
388
  }
357
389
 
358
390
  /**
@@ -428,9 +460,9 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
428
460
  {t('review.submit')}{reviewCount > 0 ? ` (${reviewCount})` : ''}
429
461
  </Button>
430
462
  </span>
431
- <Tooltip label={t('change.view')} side="bottom" delayMs={500}>
432
- <button type="button" className={css.tool} aria-label={t('change.view')} onClick={() => { openLink(href) }}>
433
- <IconRightUpOutlineRegular size={14} />
463
+ <Tooltip label={t('change.viewOn')} side="bottom" delayMs={500}>
464
+ <button type="button" className={css.tool} aria-label={t('change.viewOn')} onClick={() => { openLink(href) }}>
465
+ <ForgeGlyph forge={entry?.forge?.forge ?? null} />
434
466
  </button>
435
467
  </Tooltip>
436
468
  </div>
@@ -438,43 +470,61 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
438
470
  }
439
471
 
440
472
  /**
441
- * The local view's header: for the `branch` scope, the checked-out branch, the base branch picker, and a note
442
- * that uncommitted changes count; for another scope, what it compares.
473
+ * The local view's header: the head picker, then for the `branch` scope the base branch picker and, while a working
474
+ * tree is read, a note that uncommitted changes count; for another scope, what it compares. Writes and the create
475
+ * button belong to the Session's own checkout.
443
476
  */
444
- function LocalHeader({ state, scope, base, missing, visible, diffBases, choose, commitMenu, createChangeRequest, t }: {
477
+ function LocalHeader({
478
+ state, scope, head, headMissing, base, baseLabel, missing, visible, diffBases, chooseHead, choose, commitMenu, bulk, createChangeRequest,
479
+ t,
480
+ }: {
445
481
  readonly state: ChangesPanelState | null
446
482
  /** Commit picker of the `branch` scope, left of the create button. */
447
483
  readonly commitMenu: ReactNode
484
+ /** The write of every shown file that the scope offers, or null for a scope, head, or Session without writes. */
485
+ readonly bulk: { readonly label: string; readonly disabled: boolean; readonly run: () => void } | null
448
486
  readonly scope: ScopeKind
487
+ /** The branch the view shows in place of the Session's checked-out one, or null for the Session's own checkout. */
488
+ readonly head: ChangesHead | null
489
+ /** Whether the chosen head no longer exists. */
490
+ readonly headMissing: boolean
449
491
  readonly base: ForgeBaseBranch | null
492
+ /** Name of the base another head's loaded `branch` scope compared with, or null before it loaded; the panel names the own checkout's. */
493
+ readonly baseLabel: string | null
450
494
  /** Whether the chosen base branch no longer exists. */
451
495
  readonly missing: boolean
452
496
  readonly visible: boolean
453
497
  readonly diffBases: ChangesTabInjected['diffBases']
498
+ readonly chooseHead: (head: ChangesHead | null) => void
454
499
  readonly choose: (base: ForgeBaseBranch | null) => void
455
500
  readonly createChangeRequest: () => void
456
501
  readonly t: Translate
457
502
  }): ReactNode {
458
- const creatable = state !== null && state.repository !== null && openChangeRequestOf(state) === undefined
503
+ const creatable = head === null && state !== null && state.repository !== null && openChangeRequestOf(state) === undefined
459
504
  const checkout = state?.checkout.state === 'ready' ? state.checkout.checkout : null
460
- const head = checkout?.branch ?? checkout?.commit ?? 'HEAD'
505
+ const headRef = head?.ref ?? null
506
+ const listBases = useCallback((query: string, signal: AbortSignal) => diffBases(headRef, query, signal), [diffBases, headRef])
507
+ // Branches a reader can show: every branch but the one the Session has checked out, which is its own checkout's row.
508
+ const listHeads = useCallback((query: string, signal: AbortSignal) => diffBases(null, query, signal), [diffBases])
509
+ // A branch that no worktree has checked out is read from its commits; a checkout's comparison counts its uncommitted changes.
510
+ const committedOnly = head !== null && head.worktree === null
461
511
  return (
462
512
  <div className={css.header}>
513
+ <span className={css.headerIcon}><IconBranchOutlineRegular size={15} /></span>
514
+ <HeadMenu chosen={head} own={checkout?.branch ?? checkout?.commit ?? GIT_HEAD} missing={headMissing} visible={visible}
515
+ list={listHeads} choose={chooseHead} t={t} />
463
516
  {scope === 'branch' ? <>
464
- <span className={css.headerIcon}><IconBranchOutlineRegular size={15} /></span>
465
- <Tooltip label={head} side="bottom" delayMs={500}>
466
- <span className={css.headerHead} tabIndex={0} data-forge-head="">{head}</span>
467
- </Tooltip>
468
517
  <span className={css.headerArrow} aria-hidden="true">→</span>
469
- <BaseMenu chosen={base} label={base?.name ?? state?.local?.base ?? t('diff.base.automatic')} missing={missing}
470
- visible={visible} list={diffBases} choose={choose} t={t} />
471
- <span className={clsx(css.headerNote, css.headerSuffix)}>{t('diff.base.uncommitted')}</span>
472
- </> : <>
473
- <span className={css.headerIcon}><IconFilesDiffOutlineRegular size={15} /></span>
474
- <span className={css.headerNote}>{t(SCOPE_NOTE[scope])}</span>
475
- </>}
476
- {(scope === 'branch' || creatable) && <span className={css.headerEnd}>
518
+ <BaseMenu chosen={base} label={base?.name ?? (head === null ? state?.local?.base : baseLabel) ?? t('diff.base.automatic')}
519
+ missing={missing} note={t(committedOnly ? 'diff.base.noteCommitted' : 'diff.base.note')}
520
+ visible={visible} list={listBases} choose={choose} t={t} />
521
+ {!committedOnly && <span className={clsx(css.headerNote, css.headerSuffix)}>{t('diff.base.uncommitted')}</span>}
522
+ </> : <span className={css.headerNote}>{t(SCOPE_NOTE[scope])}</span>}
523
+ {(scope === 'branch' || creatable || bulk !== null) && <span className={css.headerEnd} data-forge-header-buttons={scope === 'branch' ? undefined : ''}>
477
524
  {scope === 'branch' && commitMenu}
525
+ {bulk !== null && (
526
+ <Button size="sm" variant="outline" className={css.headerAction} disabled={bulk.disabled} data-forge-write-all="" onClick={bulk.run}>{bulk.label}</Button>
527
+ )}
478
528
  {creatable && <Button size="sm" variant="outline" className={css.headerAction} onClick={createChangeRequest}>{t('changes.local.create')}</Button>}
479
529
  </span>}
480
530
  </div>
@@ -567,8 +617,8 @@ export function ChangesTab({ useTabInfo, sessionId, usePanel, useAnnotations, ..
567
617
  * @returns the view body.
568
618
  */
569
619
  export function ChangesView({
570
- tab, source, target, snapshot, annotations: viewAnnotations, openFile, quoteCopy, useStore, actions, reconnect, localDiff, diffBases,
571
- localText,
620
+ tab, source, target: viewTarget, snapshot, annotations: viewAnnotations, openFile, quoteCopy, useStore, actions, reconnect, localDiff,
621
+ localWrite, diffBases, localText,
572
622
  localCommits, changeRequestDiff, changeRequestText, changeRequestCommits, changeRequestReview, changeRequestReviewWrite, viewedFiles,
573
623
  changeRequestViewed, setFileViewed, openLink, copyPath, createChangeRequest, addReviewToInput, addThreadToInput, reviewQueue,
574
624
  submitReview, report, useLenses, useExtensions, changesLens, renderSlot, t: translate,
@@ -697,15 +747,25 @@ export function ChangesView({
697
747
  const chosenCommits = choices?.commits ?? null
698
748
  const lens = choices?.lens ?? 'all'
699
749
  const hideTests = choices?.hideTests ?? false
700
- const localScope = useMemo((): ForgeLocalScope => scope === 'branch'
701
- ? { kind: 'branch', base: base?.ref ?? null, commits: chosenCommits } : { kind: scope }, [scope, base, chosenCommits])
750
+ // The branch local changes show in place of the Session's checked-out one; a change request view has none.
751
+ const localHead = source.kind === 'local' ? choices?.head ?? null : null
752
+ const headRef = localHead?.ref ?? null
753
+ // The Session's own checkout names no head, so its scopes keep the identity they had before heads.
754
+ const localScope = useMemo((): ForgeLocalScope => {
755
+ const shown = headRef === null ? {} : { head: headRef }
756
+ return scope === 'branch' ? { kind: 'branch', ...shown, base: base?.ref ?? null, commits: chosenCommits } : { kind: scope, ...shown }
757
+ }, [scope, headRef, base, chosenCommits])
758
+ // Other plugins contribute to the Session's own local changes; another head shows without their slots and annotations.
759
+ const target = localHead === null ? viewTarget : null
702
760
  const changeCommits = source.kind === 'change' ? chosenCommits : null
703
761
  const changeUrlOf = source.kind === 'change' ? source.url : ''
704
762
  const listChangeCommits = useCallback(
705
763
  (signal: AbortSignal) => changeRequestCommits(changeUrlOf, signal), [changeRequestCommits, changeUrlOf],
706
764
  )
707
765
  const baseRef = base?.ref ?? null
708
- const listLocalCommits = useCallback((signal: AbortSignal) => localCommits(baseRef, signal), [localCommits, baseRef])
766
+ const listLocalCommits = useCallback(
767
+ (signal: AbortSignal) => localCommits(headRef, baseRef, signal), [localCommits, headRef, baseRef],
768
+ )
709
769
  const split = choices?.split ?? true
710
770
  const wrap = choices?.wrap ?? true
711
771
  // A read starts once the panel state arrives and again when what it describes moves. A change request's read
@@ -720,7 +780,7 @@ export function ChangesView({
720
780
  const headCommit = state !== null && state.checkout.state === 'ready' ? state.checkout.checkout.commit : null
721
781
  // The commits change with the head of a change request, with the local HEAD, branch, or base, and on a refresh.
722
782
  const commitsVersion = `${attempt}\n${source.kind === 'local'
723
- ? `${baseRef ?? ''}\n${headCommit ?? ''}\n${JSON.stringify(state?.local ?? null)}` : head ?? ''}`
783
+ ? `${headRef ?? ''}\n${baseRef ?? ''}\n${headCommit ?? ''}\n${JSON.stringify(state?.local ?? null)}` : head ?? ''}`
724
784
  const dataKey = source.kind === 'local' ? JSON.stringify(localScope) : `change\n${JSON.stringify(changeCommits)}`
725
785
  const [loaded, setLoaded] = useState<{ readonly key: string; readonly data: ChangesData } | null>(null)
726
786
  const [failure, setFailure] = useState<{ readonly key: string; readonly code: string } | null>(null)
@@ -743,7 +803,7 @@ export function ChangesView({
743
803
  const readAt = latestStatusAt.current
744
804
  const fresh = finishedAttempt.current !== attempt
745
805
  const reads = { localDiff, changeRequestDiff, changeRequestViewed }
746
- void readChanges(source, localScope, changeCommits, head, fresh, reads, controller.signal)
806
+ void readChanges(source, localScope, localHead, changeCommits, head, fresh, reads, controller.signal)
747
807
  .then((result) => {
748
808
  if (controller.signal.aborted) return
749
809
  if (!result.ok && result.error.code === 'forgePanel/stale-head') {
@@ -751,18 +811,30 @@ export function ChangesView({
751
811
  setFailure(null)
752
812
  return
753
813
  }
814
+ // The worktree that had the shown branch checked out is gone, so the tab falls back to the branch's commits,
815
+ // read again because what it loaded for the `branch` scope counted that worktree's files.
816
+ if (!result.ok && result.error.code === 'forgePanel/no-working-tree') {
817
+ setFinished(null)
818
+ setLoaded(null)
819
+ actions.rooted(tab.id, null)
820
+ return
821
+ }
754
822
  finishedAttempt.current = attempt
755
823
  setFinished(read)
756
824
  if (result.ok) {
757
825
  setLoaded({ key: dataKey, data: result.value })
758
826
  setFailure(null)
827
+ // A worktree added or removed since the branch was listed decides which scopes the branch has.
828
+ if (result.value.kind === 'local' && localHead !== null && result.value.worktree !== localHead.worktree) {
829
+ actions.rooted(tab.id, result.value.worktree)
830
+ }
759
831
  } else {
760
832
  setFailure({ key: dataKey, code: result.error.code })
761
833
  }
762
834
  })
763
835
  return () => { controller.abort() }
764
- }, [tab.visible, read, refused, waiting, source, localScope, changeCommits, head, attempt, dataKey, localDiff, changeRequestDiff,
765
- changeRequestViewed])
836
+ }, [tab.visible, tab.id, actions, read, refused, waiting, source, localScope, localHead, changeCommits, head, attempt, dataKey, localDiff,
837
+ changeRequestDiff, changeRequestViewed])
766
838
  const data = loaded !== null && loaded.key === dataKey ? loaded.data : null
767
839
  // Threads show only while they were read at the head of the latest status and, for the whole change request, at
768
840
  // the head the shown diff was read at, so their positions number the shown files.
@@ -839,7 +911,7 @@ export function ChangesView({
839
911
  }
840
912
  return map
841
913
  }, [allFiles, kept, shownPaths, foldTitle])
842
- const annotations = viewAnnotations ?? NO_ANNOTATIONS
914
+ const annotations = (localHead === null ? viewAnnotations : undefined) ?? NO_ANNOTATIONS
843
915
  // Annotations wait for the Host's limit.
844
916
  const annotationLimit = extensions?.maxAnnotationsPerFile
845
917
  const shownSource = useMemo(() => data === null ? null : reviewSourceOf(data), [data])
@@ -919,16 +991,25 @@ export function ChangesView({
919
991
  setWanted(null)
920
992
  }, [tab.visible, wanted, data, allFiles, lens, hideTests, kept, actions, tab.id])
921
993
  const refresh = (): void => { setAttempt(value => value + 1) }
994
+ const writes = useLocalWrites({ localWrite, report, reread: refresh, rereading })
995
+ // Staging and restoring act on the `unstaged` scope and unstaging on `staged`; in the other scopes a write could leave
996
+ // the shown diff unchanged. Writes reach the Session's own checkout only, so another head offers none.
997
+ const writeSide = data?.kind === 'local' && data.head === null && (data.scope.kind === 'unstaged' || data.scope.kind === 'staged')
998
+ ? data.scope.kind : undefined
922
999
  const root = state !== null && state.checkout.state === 'ready' ? state.checkout.checkout.root : null
923
1000
  // A chosen base branch that is gone or shares no history with HEAD offers the automatic fork point instead.
924
1001
  const baseFailure = baseFailureOf(failed, source.kind === 'local' && scope === 'branch' ? base : null, t)
925
1002
  // Configuration reads may recover after the user fixes Git settings or raises the output limit.
926
1003
  const message = failed === null ? undefined : FAILURE[failed]
927
- const failureText = baseFailure ?? t(message ?? 'diff.error')
928
1004
  const changeUrl = source.kind === 'change' ? entry?.snapshot?.url ?? source.url : null
929
- const retry = baseFailure === undefined && (message === undefined || failed === 'forgePanel/filter-config-failed')
1005
+ // A head that is gone offers the Session's own checkout instead of a retry.
1006
+ const headMissing = failed === 'forgePanel/head-missing' && localHead !== null
1007
+ const failureText = baseFailure ?? (headMissing ? t('diff.headMissing', { head: localHead.name }) : t(message ?? 'diff.error'))
1008
+ const retry = baseFailure === undefined && !headMissing && (message === undefined || failed === 'forgePanel/filter-config-failed')
930
1009
  const automaticBase = baseFailure !== undefined ? (
931
1010
  <Button size="sm" variant="outline" onClick={() => { actions.based(tab.id, null) }}>{t('diff.useAutomaticBase')}</Button>
1011
+ ) : headMissing ? (
1012
+ <Button size="sm" variant="outline" data-forge-head-own="" onClick={() => { actions.headed(tab.id, null) }}>{t('diff.head.back')}</Button>
932
1013
  ) : (failed === 'forgePanel/commits-missing' || failed === 'forgePanel/commits-not-linear') && (
933
1014
  <Button size="sm" variant="outline" onClick={() => { actions.committed(tab.id, null) }}>{t('commits.showAll')}</Button>
934
1015
  )
@@ -979,14 +1060,23 @@ export function ChangesView({
979
1060
  }
980
1061
  const fileActions = (owner: ChangesData, file: ForgeDiffFile): DiffFileAction[] => {
981
1062
  const list: DiffFileAction[] = [{ label: 'diff.copyPath', run: () => { copyPath(file.path) } }]
982
- if (file.status === 'deleted') return list
983
- if (owner.kind === 'local') {
984
- if (root !== null && openFile !== undefined) {
985
- list.push({ label: 'diff.openFileInSidebar', run: () => { openFile(`${root}/${file.path}`) } })
1063
+ if (file.status !== 'deleted') {
1064
+ if (owner.kind === 'local') {
1065
+ // The path names the Session's own working tree, which holds another head's file in another version or not at all.
1066
+ if (owner.head === null && root !== null && openFile !== undefined) {
1067
+ list.push({ label: 'diff.openFileInSidebar', run: () => { openFile(`${root}/${file.path}`) } })
1068
+ }
1069
+ } else {
1070
+ const url = owner.fileUrls[file.path]
1071
+ if (url !== undefined) list.push({ label: 'diff.openFileInBrowser', run: () => { openLink(url) } })
986
1072
  }
987
- } else {
988
- const url = owner.fileUrls[file.path]
989
- if (url !== undefined) list.push({ label: 'diff.openFileInBrowser', run: () => { openLink(url) } })
1073
+ }
1074
+ // The header's writes again, for a narrow pane on a device without hover, where the header hides them.
1075
+ if (writeSide === 'unstaged') {
1076
+ list.push({ label: 'diff.stageFile', separated: true, disabled: writes.writing, run: () => { writes.write('stage', [file]) } })
1077
+ if (restorable(file)) list.push({ label: 'diff.restoreFileMenu', disabled: writes.writing, run: () => { writes.write('restore', [file]) } })
1078
+ } else if (writeSide === 'staged') {
1079
+ list.push({ label: 'diff.unstageFile', separated: true, disabled: writes.writing, run: () => { writes.write('unstage', [file]) } })
990
1080
  }
991
1081
  return list
992
1082
  }
@@ -1058,7 +1148,7 @@ export function ChangesView({
1058
1148
  }
1059
1149
  const recordActions: ReviewActions = {
1060
1150
  source: shownSource ?? (source.kind === 'local'
1061
- ? { kind: 'local', scope, base: null, baseRef: baseRefOf(localScope), commits: commitsOf(localScope) }
1151
+ ? reviewSourceOf({ kind: 'local', files: [], scope: localScope, head: localHead, worktree: localHead?.worktree ?? null, base: null, omitted: 0 })
1062
1152
  : { kind: 'change', url: source.url, headSha: '', commits: changeCommits }),
1063
1153
  records: queue, addToInput: addReviewToInput, openLink, quoteCopy, onRemoved: reportRemoved,
1064
1154
  }
@@ -1070,11 +1160,13 @@ export function ChangesView({
1070
1160
  // Thread groups keep their identity across renders that change neither the threads nor what their cards share, so
1071
1161
  // only the sections whose threads changed redraw.
1072
1162
  const url = data?.kind === 'change' ? data.url : null
1163
+ const family = entry?.forge?.forge ?? null
1073
1164
  const threadActions = useMemo((): ThreadActions | null => review === null || url === null ? null : {
1074
1165
  author: prAuthor,
1075
1166
  addToInput: (thread, range) => addThreadToInput(thread, url, range),
1076
1167
  quoteCopy,
1077
1168
  openLink,
1169
+ forge: family,
1078
1170
  readText: (commit, path) => changeRequestText(url, commit, path),
1079
1171
  inputFailed: () => { live.current.report(quoteCopy?.failed ?? 'thread.inputFailed') },
1080
1172
  focused: focus,
@@ -1083,7 +1175,7 @@ export function ChangesView({
1083
1175
  reviewStarted: review.pendingReview !== null,
1084
1176
  canReview: review.viewerCanReview,
1085
1177
  },
1086
- }, [review, url, prAuthor, addThreadToInput, quoteCopy, openLink, changeRequestText, focus])
1178
+ }, [review, url, prAuthor, addThreadToInput, quoteCopy, openLink, family, changeRequestText, focus])
1087
1179
  const fileThreads = useMemo(() => new Map<string, FileThreads>(threadActions === null ? []
1088
1180
  : [...placed.files].map(([path, group]) => [path, { ...group, actions: threadActions }])), [placed.files, threadActions])
1089
1181
  /** Show a file's next unresolved thread in display order after the one last shown, or its first. */
@@ -1140,8 +1232,9 @@ export function ChangesView({
1140
1232
  /** Whether a key press belongs to a field, a comment, a menu, or a text selection rather than to the file list. */
1141
1233
  const typing = (container: HTMLElement, origin: EventTarget): boolean => {
1142
1234
  const selection = window.getSelection()
1143
- return !(origin instanceof HTMLElement) || !container.contains(origin)
1144
- || origin.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [data-forge-comment], [role="menu"]') !== null
1235
+ // A target other than an element has no `closest`, so it counts as typing.
1236
+ return !container.contains(origin as Node)
1237
+ || (origin as Partial<Element>).closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [data-forge-comment], [role="menu"]') !== null
1145
1238
  || (selection !== null && !selection.isCollapsed)
1146
1239
  }
1147
1240
  const navigateFiles = (event: KeyboardEvent<HTMLDivElement>): void => {
@@ -1175,8 +1268,10 @@ export function ChangesView({
1175
1268
  }
1176
1269
  /** The shown file whose section holds an element or a text node, if any. */
1177
1270
  const fileAt = (target: EventTarget | null | undefined): ForgeDiffFile | undefined => {
1178
- const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null
1179
- const path = element?.closest('[data-forge-diff-file]')?.getAttribute('data-forge-diff-file')
1271
+ // A text node has no `closest`, so its parent element answers.
1272
+ const node = target as Partial<Element> | null | undefined
1273
+ const section = node?.closest?.('[data-forge-diff-file]') ?? node?.parentElement?.closest('[data-forge-diff-file]')
1274
+ const path = section?.getAttribute('data-forge-diff-file')
1180
1275
  return files.find(file => file.path === path)
1181
1276
  }
1182
1277
  // `V` marks or clears the file being read, from anywhere in the tab except fields, comments, and menus: the file
@@ -1198,7 +1293,7 @@ export function ChangesView({
1198
1293
  // props and state, which the retried render assigns again.
1199
1294
  const callbacks = {
1200
1295
  data, expandedByDefault, expand, readContext, markViewed, fileActions, publishReview, writeReview, addPending, report, nextThread,
1201
- lensTitle, renderSlot, kept, reportRemoved, t,
1296
+ lensTitle, renderSlot, kept, reportRemoved, t, write: writes.write,
1202
1297
  }
1203
1298
  const live = useRef(callbacks)
1204
1299
  live.current = callbacks
@@ -1223,6 +1318,7 @@ export function ChangesView({
1223
1318
  /* v8 ignore next -- sections render only while changes are loaded */
1224
1319
  if (owner !== null) mark(owner, file, viewed)
1225
1320
  },
1321
+ write: (file, kind) => { live.current.write(kind, [file]) },
1226
1322
  actions: (file) => {
1227
1323
  const { data: owner, fileActions: list } = live.current
1228
1324
  /* v8 ignore next -- sections render only while changes are loaded */
@@ -1332,6 +1428,8 @@ export function ChangesView({
1332
1428
  viewedNote={host === null ? t('viewed.hint') : host.unavailable ? t('viewed.unavailable')
1333
1429
  : host.saving(path) ? t('viewed.saving') : t('viewed.hintHost')}
1334
1430
  viewedDisabled={host !== null && (host.unavailable || host.saving(path))}
1431
+ writes={writeSide}
1432
+ writing={writes.writing}
1335
1433
  handlers={handlers}
1336
1434
  t={t}
1337
1435
  />
@@ -1373,8 +1471,15 @@ export function ChangesView({
1373
1471
  return (
1374
1472
  <div className={css.root} data-forge-changes={source.kind} onKeyDown={toggleViewed}>
1375
1473
  {source.kind === 'local'
1376
- ? <LocalHeader state={state} scope={scope} base={base} missing={failed === 'forgePanel/base-missing'} visible={tab.visible}
1377
- diffBases={diffBases} choose={(next) => { actions.based(tab.id, next) }} commitMenu={commitMenu}
1474
+ ? <LocalHeader state={state} scope={scope} head={localHead} headMissing={headMissing} base={base}
1475
+ baseLabel={data?.kind === 'local' ? data.base : null} missing={failed === 'forgePanel/base-missing'} visible={tab.visible}
1476
+ diffBases={diffBases} chooseHead={(next) => { actions.headed(tab.id, next) }}
1477
+ choose={(next) => { actions.based(tab.id, next) }} commitMenu={commitMenu}
1478
+ bulk={writeSide === undefined ? null : {
1479
+ label: t(writeSide === 'unstaged' ? 'diff.stageAll' : 'diff.unstageAll'),
1480
+ disabled: writes.writing || files.length === 0,
1481
+ run: () => { writes.write(writeSide === 'unstaged' ? 'stage' : 'unstage', files) },
1482
+ }}
1378
1483
  createChangeRequest={createChangeRequest} t={t} />
1379
1484
  : <ChangeHeader url={source.url} entry={entry} openLink={openLink} commitMenu={commitMenu}
1380
1485
  reviewCount={(pendingReview?.comments ?? 0) + reviewState.comments.length}
@@ -1391,7 +1496,9 @@ export function ChangesView({
1391
1496
  {/* Above the file tree, the lens spans the tree's width; elsewhere a menu in the toolbar takes its place. */}
1392
1497
  {treeShown && <div className={css.lensCell}><LensControl {...lensProps} need={setLensWidth} /></div>}
1393
1498
  <div ref={toolbarRow} className={css.toolbarMain}>
1394
- {tab.visible && source.kind === 'local' && <ScopeMenu scope={scope} choose={(next) => { actions.scoped(tab.id, next) }} t={t} />}
1499
+ {/* A branch that no worktree has checked out has neither a working tree nor an index, so it has the `branch` scope alone. */}
1500
+ {tab.visible && source.kind === 'local' && (localHead === null || localHead.worktree !== null)
1501
+ && <ScopeMenu scope={scope} choose={(next) => { actions.scoped(tab.id, next) }} t={t} />}
1395
1502
  {tab.visible && (
1396
1503
  <span className={css.filesSlot}><ChangedFilesMenu {...navigator} loading={data === null && failed === null} visible /></span>
1397
1504
  )}
@@ -1511,9 +1618,20 @@ export function ChangesView({
1511
1618
  if (covering) setThreadList(value => ({ ...value, open: false }))
1512
1619
  openThread(entry, covering)
1513
1620
  }}
1514
- openLink={openLink} close={closeThreadList} t={t} />
1621
+ openLink={openLink} forge={family} close={closeThreadList} t={t} />
1515
1622
  )}
1516
1623
  </div>
1624
+ {writes.restoring !== null && (
1625
+ <Modal open tone="warning" title={t('diff.restore.title')} closeLabel={t('review.close')} onClose={writes.restoring.cancel}
1626
+ footer={(
1627
+ <>
1628
+ <Button variant="outline" data-modal-autofocus onClick={writes.restoring.cancel}>{t('review.cancel')}</Button>
1629
+ <Button variant="primary" onClick={writes.restoring.confirm}>{t('diff.restore.confirm')}</Button>
1630
+ </>
1631
+ )}>
1632
+ <p className={css.restoreText}>{t(restoreCopyOf(writes.restoring.file), { path: writes.restoring.file.path })}</p>
1633
+ </Modal>
1634
+ )}
1517
1635
  </div>
1518
1636
  )
1519
1637
  }
@@ -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'
@@ -8,8 +8,8 @@ import { 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'
11
+ } from '@deepseek-ai/dsh-client-ui-primitives/client'
12
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
13
13
  import type { 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'
@@ -50,8 +50,8 @@ export function commitsLabel(chosen: ForgeCommitRange | null, t: PropsLocale<typ
50
50
  }
51
51
 
52
52
  /**
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.
53
+ * Render the trigger and, while open, the commit list. A click shows one commit; a Shift click shows the commits up to
54
+ * the clicked one, from the one commit shown, wherever it was chosen, or else from the last commit clicked without Shift.
55
55
  * @param props - the shown commits, the listing read, the choose action, and copy.
56
56
  * @returns the trigger with its portalled menu, or nothing when the source cannot show single commits.
57
57
  */
@@ -94,7 +94,9 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
94
94
  return
95
95
  }
96
96
  const order = commits.commits.map(commit => commit.sha)
97
- const start = shift.current && anchor.current !== null && order.includes(anchor.current) ? anchor.current : sha
97
+ // One commit shown alone starts the run, also when the view's owner chose it and not a click here.
98
+ const held = chosen !== null && chosen.from === chosen.to ? chosen.from : anchor.current
99
+ const start = shift.current && held !== null && order.includes(held) ? held : sha
98
100
  const [from, to] = order.indexOf(start) <= order.indexOf(sha) ? [start, sha] : [sha, start]
99
101
  // Two ends cannot name a run that leaves the first-parent line, so the menu stays open and says why.
100
102
  if (rangeStart(commits.commits, { from, to }) === 'not-linear') {