@deepseek-ai/dsh-experimental-client-ui-forge 0.2.3-alpha.1 → 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
package/src/index.ts CHANGED
@@ -6,11 +6,12 @@ import type { Agent } from '@deepseek-ai/dsh-agent'
6
6
  import type {} from '@deepseek-ai/dsh-api-remote-access'
7
7
  import { changeRequestKey } from '@deepseek-ai/dsh-experimental-forge'
8
8
  import type {
9
- BranchUpdateMethod, ChangeRequestDescription, ChangeRequestKey, ChangeRequestRef, ChangeRequestReviewer, ChangeRequestSnapshot,
10
- ChangeRequestUpdate, ForgeActionFailure, ForgeCommitList,
9
+ AutoMergeRequest, BranchUpdateMethod, ChangeRequestActivity, ChangeRequestDescription, ChangeRequestKey, ChangeRequestRef,
10
+ ChangeRequestReviewer,
11
+ ChangeRequestSnapshot, ChangeRequestUpdate, ForgeActionFailure, ForgeCommitList,
11
12
  ForgeFailure,
12
- ForgeLineComment, ForgeRerunRequest, ForgeReviewChange, ForgeReviewData, ForgeReviewerCandidate, ForgeReviewRequest, ForgeReviewResult,
13
- ForgeReviewWrite, ForgeReviewWriteResult, ForgeViewedFiles, ForgeViewedRequest, MergeMethod,
13
+ ForgeLineComment, ForgeReadiness, ForgeRerunRequest, ForgeReviewChange, ForgeReviewData, ForgeReviewerCandidate, ForgeReviewRequest,
14
+ ForgeReviewResult, ForgeReviewWrite, ForgeReviewWriteResult, ForgeViewedFiles, ForgeViewedRequest, MergeMethod,
14
15
  } from '@deepseek-ai/dsh-experimental-forge'
15
16
  import type { SessionChangeRequest } from '@deepseek-ai/dsh-experimental-forge-session'
16
17
  import type { WorktreeCleanup } from '@deepseek-ai/dsh-experimental-worktree/types'
@@ -19,18 +20,19 @@ import type { Session, SessionEvent, SessionId, UserMessage } from '@deepseek-ai
19
20
  import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
20
21
  import type {} from '@deepseek-ai/dsh-session-projection-cache'
21
22
  import type {} from '@deepseek-ai/dsh-session-query'
22
- import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
23
+ import { deadline, MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
23
24
  import { Remote, RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
24
25
  import { assertNever } from '@deepseek-ai/dsh-util-values'
25
26
  import { gitIn, hasBranch, inspectCheckout } from './git.ts'
26
27
  import type { Inspection } from './git.ts'
27
- import { branchNameProblem } from './branch-name.ts'
28
+ import { branchNameProblem, LOCAL_REF_PREFIX } from './branch-name.ts'
28
29
  import { parseDiff } from './diff.ts'
29
30
  import {
30
- aheadOf, BaseMissing, baseBranches, chosenForkPoint, CommitsMissing, CommitsNotLinear, DiffTooLarge, FilterConfigError, forkPoint,
31
- localCommits, localDiff, localOldText, localText, NoForkPoint,
31
+ aheadOf, baseBranches, BaseMissing, branchTip, branchWorktrees, chosenForkPoint, CommitsMissing, CommitsNotLinear, DiffTooLarge,
32
+ FilterConfigError, forkPoint, HeadMissing, localCommits, localDiff, localOldText, localText, NoForkPoint, sessionHead,
32
33
  } from './local-diff.ts'
33
- import type { ForkPoint } from './local-diff.ts'
34
+ import type { ForkPoint, SessionHead } from './local-diff.ts'
35
+ import { LocalChangesStale, LocalPathReplaced, localWrite } from './local-write.ts'
34
36
  import { LensCache, LensFailed, lensFrames, LensRegistry, LensWithdrawn, runLens } from './lenses.ts'
35
37
  import type { LensSubject } from './lenses.ts'
36
38
  import { lensVersion } from './lens-version.ts'
@@ -45,8 +47,9 @@ import { Reader, ViewerLists } from './viewer-lists.ts'
45
47
  import type { KeptPanel, PanelConfig } from './panel.ts'
46
48
  import type {
47
49
  Config, ForgeBaseBranches, ForgeChangeRequestDiff, ForgeChangeRequestStatesFrame, ForgeCommitRange, ForgeDiffFile,
48
- ForgeReviewChangeRequest, ForgeReviewCountFrame, ForgeReviewFrame,
50
+ ForgeReviewChangeRequest, ForgeReviewCountFrame, ForgeReviewFrame, ForgeReviewRepository,
49
51
  ForgeExtensionState, ForgeLens, ForgeLensFrame, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope,
52
+ ForgeLocalWrite, ForgeLocalWriteResult,
50
53
  ForgeMissingWorktree, ForgePanelState, ForgeSessionWorktree, ForgeWorktreeBases, ForgeWorktreeState,
51
54
  } from './types.ts'
52
55
  import { forgeWorktreeProjection, messageOf, within, WORKTREE_RECORD, WorktreeCreations } from './worktree.ts'
@@ -61,6 +64,23 @@ declare module '@deepseek-ai/cordis' {
61
64
  }
62
65
  }
63
66
 
67
+ /** What a local read targets. */
68
+ interface LocalTarget {
69
+ /** The checkout Git runs in: the Session's own, or the worktree that has the head branch checked out. */
70
+ readonly inspection: Inspection
71
+ /** The worktree the Session created, while the read targets its own checkout; it fixes the automatic fork point. */
72
+ readonly created: ForgeSessionWorktree | null
73
+ /** `HEAD` for the checkout's working tree, or the verified ref of a head branch read from its commits. */
74
+ readonly tip: string
75
+ /** Top-level directory of the head branch's worktree, or null for the Session's own checkout and a head read from its commits. */
76
+ readonly worktree: string | null
77
+ /**
78
+ * The Session's own HEAD, which a head branch is compared with while no base branch is chosen; null for the
79
+ * Session's own checkout, and while its checked-out branch has no commit.
80
+ */
81
+ readonly against: SessionHead | null
82
+ }
83
+
64
84
  /** A change request a read or action addresses, with its latest polling result. */
65
85
  interface ChangeRequestTarget {
66
86
  readonly ref: ChangeRequestRef
@@ -196,6 +216,7 @@ export class ForgePanelController extends TypertRemoteService {
196
216
  sources: () => ctx.forge.viewerSources(),
197
217
  list: async (forge, query, signal) => await ctx.forge.listForViewer(forge, query, signal),
198
218
  count: async (forge, host, signal) => await ctx.forge.countForViewer(forge, host, signal),
219
+ signIn: async (forge, host, signal) => (await ctx.forge.readiness({ forge, host }, signal)).signIn?.command ?? null,
199
220
  report: (error) => { ctx.logger.warn(`forge-panel: reading a review list failed: ${String(error)}`) },
200
221
  }, {
201
222
  listIntervalMs: resolved.reviewListIntervalMs,
@@ -287,15 +308,17 @@ export class ForgePanelController extends TypertRemoteService {
287
308
  /**
288
309
  * Stream the review page's lists of the signed-in user's open change requests on every host a provider lists them on:
289
310
  * the lists read so far first, then a frame after each read settles. Readers of one repository scope share one
290
- * reader, which reads every `reviewListIntervalMs` while some stream lasts and backs off after failed rounds up to
291
- * `reviewMaxBackoffMs`; nothing is read while no stream lasts. The stream ends when `signal` aborts or the Remote stops.
292
- * @param repository - one repository to list in, or null for every repository the user can read.
311
+ * reader, which reads each host every `reviewListIntervalMs` while some stream lasts and reads a host whose read failed
312
+ * again later each time, up to `reviewMaxBackoffMs`, without delaying the other hosts; nothing is read while no stream
313
+ * lasts. The stream ends when `signal` aborts or the Remote stops.
314
+ * @param repository - one repository to list in, read on its host only, or null for every repository the user can
315
+ * read on every host.
293
316
  * @param signal - ends the stream.
294
317
  * @returns frames, each complete.
295
318
  */
296
319
  @Remote({ mode: 'stream' })
297
320
  async *reviewLists(
298
- repository: { readonly owner: string; readonly name: string } | null, signal: AbortSignal,
321
+ repository: ForgeReviewRepository | null, signal: AbortSignal,
299
322
  ): AsyncIterable<ForgeReviewFrame> {
300
323
  yield* this.viewerLists.lists(repository, signal)
301
324
  }
@@ -323,6 +346,28 @@ export class ForgePanelController extends TypertRemoteService {
323
346
  this.viewerLists.refresh()
324
347
  }
325
348
 
349
+ /**
350
+ * Report whether a provider reaches one of its hosts with the Host's current credentials, for the host list on the
351
+ * Plugins page of that provider's row. The read names no Session, so, like the review page reads, only callers that
352
+ * may use the Host's code host credentials reach it.
353
+ * @param forge - forge family of a registered provider, such as `gitlab`.
354
+ * @param host - host name as the provider's configuration lists it.
355
+ * @param signal - request cancellation.
356
+ * @returns the provider's readiness for the host; `unavailable` with the reason when no provider serves the family,
357
+ * the probe fails, or it runs past `readinessTimeoutMs`.
358
+ */
359
+ @Remote
360
+ async hostReadiness(forge: string, host: string, signal: AbortSignal): Promise<ForgeReadiness> {
361
+ signal.throwIfAborted()
362
+ try {
363
+ using timeout = deadline(signal, this.config.readinessTimeoutMs, 'FORGE_PANEL_READINESS_TIMEOUT')
364
+ return await this.home.forge.readiness({ forge, host: host.toLowerCase() }, timeout.signal)
365
+ } catch (error) {
366
+ signal.throwIfAborted()
367
+ return { state: 'unavailable', message: messageOf(error), signIn: null }
368
+ }
369
+ }
370
+
326
371
  /**
327
372
  * Poll one change request the review page shows at once; its stream reports the result.
328
373
  * @param url - web URL of the change request.
@@ -391,6 +436,41 @@ export class ForgePanelController extends TypertRemoteService {
391
436
  return result
392
437
  }
393
438
 
439
+ /**
440
+ * Read the activity of a change request for the review page: its comments, submitted reviews, commits, and changes
441
+ * of state.
442
+ * @param url - web URL of the change request.
443
+ * @param signal - request cancellation.
444
+ * @returns the activity, or null when the change request's provider reads none.
445
+ * @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/activity-failed` with the
446
+ * host's reason when the host does not provide it.
447
+ */
448
+ @Remote
449
+ async reviewActivity(url: string, signal: AbortSignal): Promise<ChangeRequestActivity | null> {
450
+ signal.throwIfAborted()
451
+ const result = await this.home.forge.readActivity(this.served(url).ref, signal)
452
+ if (!('code' in result)) return result
453
+ if (result.code === 'unsupported') return null
454
+ throw new RemoteError('forgePanel/activity-failed', result.message, {})
455
+ }
456
+
457
+ /**
458
+ * Add a comment to the conversation of a change request the review page shows.
459
+ * @param url - web URL of the change request.
460
+ * @param body - Markdown source of the comment.
461
+ * @param signal - request cancellation.
462
+ * @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` when `body` is
463
+ * blank, or with the host's reason; `forgePanel/action-unknown` when the host's answer did not confirm the comment.
464
+ */
465
+ @Remote
466
+ async reviewComment(url: string, body: string, signal: AbortSignal): Promise<void> {
467
+ signal.throwIfAborted()
468
+ const { ref } = this.served(url)
469
+ if (body.trim() === '') throw new RemoteError('forgePanel/action-failed', 'The comment is empty', {})
470
+ const failure = await this.home.forge.addComment(ref, body, signal)
471
+ if (failure !== undefined) throw actionError(failure)
472
+ }
473
+
394
474
  /**
395
475
  * Read every check of a change request the review page shows.
396
476
  * @param url - web URL of the change request.
@@ -560,6 +640,22 @@ export class ForgePanelController extends TypertRemoteService {
560
640
  if (failure !== undefined) throw actionError(failure)
561
641
  }
562
642
 
643
+ /**
644
+ * Turn the code host's automatic merge of a change request the review page shows on, while its head is still the
645
+ * request's `headSha`, or off.
646
+ * @param url - web URL of the change request.
647
+ * @param request - on with the merge method and the head commit the user confirmed, or off.
648
+ * @param signal - request cancellation.
649
+ * @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
650
+ * `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
651
+ */
652
+ @Remote
653
+ async reviewSetAutoMerge(url: string, request: AutoMergeRequest, signal: AbortSignal): Promise<void> {
654
+ signal.throwIfAborted()
655
+ const failure = await this.home.forge.setAutoMerge(this.served(url).ref, request, signal)
656
+ if (failure !== undefined) throw actionError(failure)
657
+ }
658
+
563
659
  /**
564
660
  * Rerun the failed checks of a change request the review page shows.
565
661
  * @param url - web URL of the change request.
@@ -674,21 +770,26 @@ export class ForgePanelController extends TypertRemoteService {
674
770
  }
675
771
 
676
772
  /**
677
- * List the branches the `branch` scope of the Session's current checkout can compare with.
773
+ * List the branches the `branch` scope can compare with, for the Session's current checkout or for a head branch
774
+ * read in its place.
678
775
  * @param session - Session whose checkout is read.
776
+ * @param head - full ref of the branch the scope reads in place of the checked-out one, or null for the checkout.
679
777
  * @param query - text the branch names must contain, ignoring case; empty for every branch.
680
778
  * @param signal - request cancellation.
681
779
  * @returns the automatic fork point and at most `maxBranches` remote-tracking and local branches each,
682
- * most recently committed first, without the checked-out branch.
683
- * @throws `forgePanel/not-a-checkout` outside a checkout; the Git error when Git fails or the listed refs exceed `maxDiffBytes`.
780
+ * most recently committed first, without the branch the scope shows and, for a head, without the Session's
781
+ * checked-out branch, which the automatic fork point compares with; a local branch that a worktree has checked
782
+ * out names that worktree's directory.
783
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head does not exist; the
784
+ * Git error when Git fails or the listed refs exceed `maxDiffBytes`.
684
785
  */
685
786
  @Remote
686
- async diffBases(session: Session, query: string, signal: AbortSignal): Promise<ForgeBaseBranches> {
787
+ async diffBases(session: Session, head: string | null, query: string, signal: AbortSignal): Promise<ForgeBaseBranches> {
687
788
  signal.throwIfAborted()
688
- const inspection = await this.checkoutOf(session, signal)
789
+ const { inspection, created, tip, against } = await this.localTarget(session, head, false, signal)
689
790
  // A search can match any branch, so every ref is listed; a repository's refs can far exceed other short Git output.
690
791
  const git = gitIn(this.home, { ...this.config, maxOutputBytes: this.config.maxDiffBytes }, session, inspection.checkout.root, signal)
691
- return await baseBranches(git, inspection, this.worktreeState(session).created, query, this.config.maxBranches)
792
+ return await baseBranches(git, inspection, created, query, this.config.maxBranches, tip, against)
692
793
  }
693
794
 
694
795
  /* oxlint-disable typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect */
@@ -749,13 +850,15 @@ export class ForgePanelController extends TypertRemoteService {
749
850
  }
750
851
 
751
852
  /**
752
- * Read the changes one scope covers in the checkout of the Session's
753
- * current directory, with Git using the Session's sandbox policy.
853
+ * Read the changes one scope covers in the checkout of the Session's current directory, or for the head branch the
854
+ * scope names: in the worktree that has it checked out, else from its commits. Git uses the Session's sandbox policy.
754
855
  * @param session - Session whose checkout is read.
755
856
  * @param scope - which changes to read.
756
857
  * @param signal - request cancellation.
757
- * @returns the files, the base of the `branch` scope, and the untracked files left out.
758
- * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/base-missing` when the base branch
858
+ * @returns the files, the base of the `branch` scope, the untracked files left out, and the worktree read for a head.
859
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head the scope names
860
+ * does not exist; `forgePanel/no-working-tree` for another scope than `branch` whose head no worktree has checked
861
+ * out; `forgePanel/base-missing` when the base branch
759
862
  * chosen for the `branch` scope does not exist; `forgePanel/no-fork-point` for the `branch` scope without
760
863
  * a fork point; `forgePanel/commits-missing` when chosen commits are not between the fork point and HEAD in order;
761
864
  * `forgePanel/commits-not-linear` when a chosen commit's first parent is not the commit listed before it;
@@ -765,54 +868,88 @@ export class ForgePanelController extends TypertRemoteService {
765
868
  @Remote
766
869
  async localDiff(session: Session, scope: ForgeLocalScope, signal: AbortSignal): Promise<ForgeLocalDiff> {
767
870
  signal.throwIfAborted()
768
- const inspection = await this.checkoutOf(session, signal)
871
+ const target = await this.localTarget(session, scope.head ?? null, scope.kind !== 'branch', signal)
872
+ const { inspection, created, tip, worktree, against } = target
769
873
  const root = inspection.checkout.root
770
874
  const git = gitIn(this.home, this.config, session, root, signal)
771
- const created = this.worktreeState(session).created
772
875
  const fork = scope.kind !== 'branch' ? null
773
- : await diffing(scope.base === null ? forkPoint(git, inspection, created) : chosenForkPoint(git, scope.base))
774
- return await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal))
876
+ : await diffing(scope.base === null ? forkPoint(git, inspection, created, tip, against) : chosenForkPoint(git, scope.base, tip))
877
+ const diff = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal, tip))
878
+ return worktree === null ? diff : { ...diff, worktree }
775
879
  }
776
880
 
777
881
  /**
778
- * List the commits of the `branch` scope of the Session's current checkout, which the changes view can show one or
779
- * several of instead of the whole scope.
882
+ * List the commits of the `branch` scope of the Session's current checkout or of a head branch read in its place,
883
+ * which the changes view can show one or several of instead of the whole scope.
780
884
  * @param session - Session whose checkout is read.
885
+ * @param head - full ref of the branch the scope reads in place of the checked-out one, or null for the checkout.
781
886
  * @param base - the base ref of the `branch` scope, or null for its automatic fork point.
782
887
  * @param signal - request cancellation.
783
- * @returns the newest `maxCommits` commits between the fork point and HEAD, oldest first, and HEAD's commit.
784
- * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/base-missing` when the base branch does not
785
- * exist; `forgePanel/no-fork-point` without a fork point; the Git error when Git fails or the listing exceeds `maxDiffBytes`.
888
+ * @returns the newest `maxCommits` commits between the fork point and the shown HEAD or branch, oldest first, and its commit.
889
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head does not exist;
890
+ * `forgePanel/base-missing` when the base branch does not exist; `forgePanel/no-fork-point` without a fork point;
891
+ * the Git error when Git fails or the listing exceeds `maxDiffBytes`.
786
892
  */
787
893
  @Remote
788
- async localCommits(session: Session, base: string | null, signal: AbortSignal): Promise<ForgeLocalCommits> {
894
+ async localCommits(session: Session, head: string | null, base: string | null, signal: AbortSignal): Promise<ForgeLocalCommits> {
789
895
  signal.throwIfAborted()
790
- const inspection = await this.checkoutOf(session, signal)
896
+ const { inspection, created, tip, against } = await this.localTarget(session, head, false, signal)
791
897
  const git = gitIn(this.home, { ...this.config, maxOutputBytes: this.config.maxDiffBytes }, session, inspection.checkout.root, signal)
792
- const created = this.worktreeState(session).created
793
- const fork = await diffing(base === null ? forkPoint(git, inspection, created) : chosenForkPoint(git, base))
898
+ const fork = await diffing(base === null ? forkPoint(git, inspection, created, tip, against) : chosenForkPoint(git, base, tip))
794
899
  if (fork === null) throw new RemoteError('forgePanel/no-fork-point', 'The checkout has no fork point to compare its branch with', {})
795
- return await localCommits(git, fork, this.config.maxCommits)
900
+ return await localCommits(git, fork, this.config.maxCommits, tip)
796
901
  }
797
902
 
798
903
  /**
799
904
  * Read the new side of one changed file in a scope, which supplies the
800
905
  * unchanged lines between its hunks: the index for `staged`, the last chosen commit for chosen commits of
801
- * the `branch` scope, else the working tree.
906
+ * the `branch` scope, the branch for a head read from its commits, else the working tree of the checkout the scope reads.
802
907
  * @param session - Session whose checkout is read.
803
908
  * @param scope - the scope the diff was read in.
804
909
  * @param path - path relative to the checkout's top-level directory, as the diff names it.
805
910
  * @param signal - request cancellation.
806
911
  * @returns the text.
807
- * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/diff-too-large` over `maxDiffBytes`;
912
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` and `forgePanel/no-working-tree`
913
+ * as for {@link ForgePanelController.localDiff}; `forgePanel/diff-too-large` over `maxDiffBytes`;
808
914
  * `forgePanel/commits-missing` for a chosen commit that is not a full object name; an error for a path outside
809
915
  * the checkout, binary content, or a failed read.
810
916
  */
811
917
  @Remote
812
918
  async localText(session: Session, scope: ForgeLocalScope, path: string, signal: AbortSignal): Promise<string> {
919
+ signal.throwIfAborted()
920
+ const { inspection, tip } = await this.localTarget(session, scope.head ?? null, scope.kind !== 'branch', signal)
921
+ return await diffing(localText(this.home, this.config, session, inspection.checkout.root, scope, path, signal, tip))
922
+ }
923
+
924
+ /**
925
+ * Stage, unstage, or restore whole files in the checkout of the Session's current directory, or return index
926
+ * entries to the tree an earlier write reported. The caller's press authorizes the write, so Git runs without the
927
+ * Session's sandbox policy and under any access mode. The Session's panel inspects the checkout again afterwards,
928
+ * whether or not the write succeeded.
929
+ * @param session - Session whose checkout is written.
930
+ * @param write - the write; `stage` and `restore` name each file with the digest of the change the reader saw.
931
+ * @param signal - request cancellation.
932
+ * @returns the index before a `stage` or `unstage` as a tree, for undoing it.
933
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/local-stale` before anything is written when a
934
+ * file's unstaged change is not the one the reader saw; `forgePanel/local-path-replaced` before anything is written
935
+ * when a deleted file's path holds a directory; the errors of {@link ForgePanelController.localDiff} for the
936
+ * `unstaged` scope; an error for a path outside the checkout, a tree that is not a full object name, a restore of a
937
+ * submodule or of a file without index content, or a Git failure.
938
+ */
939
+ @Remote
940
+ async localWrite(session: Session, write: ForgeLocalWrite, signal: AbortSignal): Promise<ForgeLocalWriteResult> {
813
941
  signal.throwIfAborted()
814
942
  const inspection = await this.checkoutOf(session, signal)
815
- return await diffing(localText(this.home, this.config, session, inspection.checkout.root, scope, path, signal))
943
+ try {
944
+ return await diffing(localWrite(this.home, this.config, session, inspection.checkout.root, write, this.layers, signal))
945
+ } catch (error) {
946
+ if (error instanceof LocalChangesStale) throw new RemoteError('forgePanel/local-stale', error.message, {}, { cause: error })
947
+ if (error instanceof LocalPathReplaced) throw new RemoteError('forgePanel/local-path-replaced', error.message, {}, { cause: error })
948
+ throw error
949
+ } finally {
950
+ // A failed write can have changed the paths of its earlier commands.
951
+ this.panels.get(session)?.reinspect()
952
+ }
816
953
  }
817
954
 
818
955
  /**
@@ -1121,6 +1258,25 @@ export class ForgePanelController extends TypertRemoteService {
1121
1258
  if (failure !== undefined) throw actionError(failure)
1122
1259
  }
1123
1260
 
1261
+ /**
1262
+ * Turn the code host's automatic merge of a change request of a Session on, while its head is still the request's
1263
+ * `headSha`, or off; the change request is polled again once the host answers.
1264
+ * @param session - Session the change request is bound to.
1265
+ * @param url - binding URL of the change request.
1266
+ * @param request - on with the merge method and the head commit the user confirmed, or off.
1267
+ * @param signal - request cancellation.
1268
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1269
+ * `forgePanel/stale-head` when the head moved past the request's `headSha`; `forgePanel/action-failed` with the
1270
+ * host's reason when the host refuses otherwise, cannot be reached, or sets no automatic merge;
1271
+ * `forgePanel/action-unknown` when the host's answer did not confirm the change.
1272
+ */
1273
+ @Remote
1274
+ async setAutoMerge(session: Session, url: string, request: AutoMergeRequest, signal: AbortSignal): Promise<void> {
1275
+ signal.throwIfAborted()
1276
+ const failure = await this.home.forge.setAutoMerge(this.bound(session, url).ref, request, signal)
1277
+ if (failure !== undefined) throw actionError(failure)
1278
+ }
1279
+
1124
1280
  /**
1125
1281
  * Rerun the failed checks of a change request of a Session while its head is still the commit whose checks the user
1126
1282
  * saw; the change request is polled again once the host answers.
@@ -1436,6 +1592,39 @@ export class ForgePanelController extends TypertRemoteService {
1436
1592
  throw readError(attributes)
1437
1593
  }
1438
1594
 
1595
+ /**
1596
+ * Resolve what a local read targets: the Session's own checkout with the worktree it created; for a head branch,
1597
+ * the worktree of the repository that has it checked out, read as a checkout; or, when none has, the verified
1598
+ * branch itself, read from its commits. A head branch also carries the Session's own HEAD, which is what it is
1599
+ * compared with while no base branch is chosen.
1600
+ * @param working - whether the read needs a working tree, as every scope but `branch` does.
1601
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the branch does not exist;
1602
+ * `forgePanel/no-working-tree` when `working` and no worktree has the branch checked out.
1603
+ */
1604
+ private async localTarget(session: Session, head: string | null, working: boolean, signal: AbortSignal): Promise<LocalTarget> {
1605
+ const own = await this.checkoutOf(session, signal)
1606
+ const ownTarget: LocalTarget = {
1607
+ inspection: own, created: this.worktreeState(session).created, tip: 'HEAD', worktree: null, against: null,
1608
+ }
1609
+ if (head === null) return ownTarget
1610
+ // Worktree paths are as long as the directories users choose, so the listing takes the larger limit.
1611
+ const git = gitIn(this.home, { ...this.config, maxOutputBytes: this.config.maxDiffBytes }, session, own.checkout.root, signal)
1612
+ const tip = await diffing(branchTip(git, head))
1613
+ const against = await sessionHead(git, own.checkout)
1614
+ // Only a local branch can be checked out; a remote-tracking one is always read from its commits.
1615
+ const directory = head.startsWith(LOCAL_REF_PREFIX) ? (await branchWorktrees(git)).get(head) : undefined
1616
+ // The directory is as Git's listing spells it, which can be cut short or name one that is gone, so the read
1617
+ // confirms that a checkout of the branch in this repository is there.
1618
+ const inspection = directory === undefined || await this.home.fs.lstat(directory, undefined, signal) === undefined ? undefined
1619
+ : await inspectCheckout(this.home, this.config, session, directory, signal)
1620
+ if (inspection?.commonDir === own.commonDir && inspection.checkout.branch === head.slice(LOCAL_REF_PREFIX.length)) {
1621
+ return inspection.checkout.root === own.checkout.root ? ownTarget
1622
+ : { inspection, created: null, tip: 'HEAD', worktree: inspection.checkout.root, against }
1623
+ }
1624
+ if (working) throw new RemoteError('forgePanel/no-working-tree', 'No worktree has the branch checked out, so it has no working tree', {})
1625
+ return { inspection: own, created: null, tip, worktree: null, against }
1626
+ }
1627
+
1439
1628
  /** Inspect the checkout of the Session's current directory, which local diffs read. */
1440
1629
  private async checkoutOf(session: Session, signal: AbortSignal): Promise<Inspection> {
1441
1630
  const inspection = await inspectCheckout(this.home, this.config, session, this.home.workingDirectory.get(session), signal)
@@ -1638,7 +1827,7 @@ export class ForgePanelController extends TypertRemoteService {
1638
1827
  try {
1639
1828
  running = agent.runMaintenance(async (signal) => { await work(agent, signal) })
1640
1829
  } catch (error) {
1641
- throw new RemoteError('forgePanel/session-busy', 'The Session is busy', {}, { cause: error })
1830
+ throw new RemoteError('forgePanel/session-busy', `The Session is busy: ${messageOf(error)}`, {}, { cause: error })
1642
1831
  }
1643
1832
  await running
1644
1833
  }
@@ -1707,13 +1896,14 @@ export class ForgePanelController extends TypertRemoteService {
1707
1896
  session: Session, source: ForgeLensRequest['source'], signal: AbortSignal,
1708
1897
  ): Promise<LensSubject & { readonly key: string }> {
1709
1898
  if (source.kind === 'local') {
1710
- const inspection = await this.checkoutOf(session, signal)
1711
- const root = inspection.checkout.root
1712
1899
  const { scope } = source
1900
+ const target = await this.localTarget(session, scope.head ?? null, scope.kind !== 'branch', signal)
1901
+ const { inspection, created, tip, against } = target
1902
+ const root = inspection.checkout.root
1713
1903
  const fork: ForkPoint | null = scope.kind !== 'branch' ? null : await diffing(scope.base === null
1714
- ? forkPoint(gitIn(this.home, this.config, session, root, signal), inspection, this.worktreeState(session).created)
1715
- : chosenForkPoint(gitIn(this.home, this.config, session, root, signal), scope.base))
1716
- const { files } = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal))
1904
+ ? forkPoint(gitIn(this.home, this.config, session, root, signal), inspection, created, tip, against)
1905
+ : chosenForkPoint(gitIn(this.home, this.config, session, root, signal), scope.base, tip))
1906
+ const { files } = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal, tip))
1717
1907
  return {
1718
1908
  key: JSON.stringify(['local', session.id, scope]),
1719
1909
  source: { kind: 'local', scope },
@@ -1721,7 +1911,7 @@ export class ForgePanelController extends TypertRemoteService {
1721
1911
  read: async (side, file, inner) => {
1722
1912
  if (file.binary || (side === 'old' ? file.status === 'added' : file.status === 'deleted')) return null
1723
1913
  return side === 'new'
1724
- ? await diffing(localText(this.home, this.config, session, root, scope, file.path, inner))
1914
+ ? await diffing(localText(this.home, this.config, session, root, scope, file.path, inner, tip))
1725
1915
  : await diffing(localOldText(this.home, this.config, session, root, scope, fork, file.previousPath ?? file.path, inner))
1726
1916
  },
1727
1917
  }
@@ -1877,8 +2067,8 @@ function reviewError(failure: ForgeFailure): RemoteError {
1877
2067
  }
1878
2068
 
1879
2069
  /**
1880
- * Settle a diff read, reporting its size limit, its filter configuration, a missing fork point, a missing base branch, and chosen
1881
- * commits that are not on the branch as Remote errors.
2070
+ * Settle a diff read, reporting its size limit, its filter configuration, a missing fork point, a missing base branch, a missing
2071
+ * head, and chosen commits that are not on the branch as Remote errors.
1882
2072
  * @param reading - the read.
1883
2073
  * @returns what the read returned.
1884
2074
  */
@@ -1890,6 +2080,7 @@ async function diffing<T>(reading: Promise<T>): Promise<T> {
1890
2080
  if (error instanceof DiffTooLarge) throw new RemoteError('forgePanel/diff-too-large', error.message, {}, { cause: error })
1891
2081
  if (error instanceof NoForkPoint) throw new RemoteError('forgePanel/no-fork-point', error.message, {}, { cause: error })
1892
2082
  if (error instanceof BaseMissing) throw new RemoteError('forgePanel/base-missing', error.message, {}, { cause: error })
2083
+ if (error instanceof HeadMissing) throw new RemoteError('forgePanel/head-missing', error.message, {}, { cause: error })
1893
2084
  if (error instanceof CommitsMissing) throw new RemoteError('forgePanel/commits-missing', error.message, {}, { cause: error })
1894
2085
  if (error instanceof CommitsNotLinear) throw new RemoteError('forgePanel/commits-not-linear', error.message, {}, { cause: error })
1895
2086
  throw error