@deepseek-ai/dsh-experimental-client-ui-forge 0.2.2-rc.5 → 0.2.3-alpha.2

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 (334) hide show
  1. package/README.i18n.yaml +12 -12
  2. package/README.md +47 -30
  3. package/README.zh.md +47 -30
  4. package/lib/client.js +18 -8
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +2444 -406
  7. package/lib/typert.host.js +3433 -950
  8. package/lib/typert.remote-client.d.ts +89 -14
  9. package/lib/typert.remote-client.d.ts.map +1 -1
  10. package/lib/typert.remote-client.js +3155 -978
  11. package/lib/types/branch-name.d.ts +30 -0
  12. package/lib/types/branch-name.d.ts.map +1 -0
  13. package/lib/types/branch-name.js.map +1 -0
  14. package/lib/types/client/AttentionIndicator.d.ts +22 -0
  15. package/lib/types/client/AttentionIndicator.d.ts.map +1 -0
  16. package/lib/types/client/AttentionIndicator.js.map +1 -0
  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/ChangeRequestCard.d.ts +87 -9
  20. package/lib/types/client/ChangeRequestCard.d.ts.map +1 -1
  21. package/lib/types/client/ChangeRequestCard.js.map +1 -1
  22. package/lib/types/client/ChangeRequestOverview.d.ts +126 -10
  23. package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -1
  24. package/lib/types/client/ChangeRequestOverview.js.map +1 -1
  25. package/lib/types/client/ChangeRequestsSection.d.ts +76 -0
  26. package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -0
  27. package/lib/types/client/ChangeRequestsSection.js.map +1 -0
  28. package/lib/types/client/ChangedFiles.d.ts +6 -2
  29. package/lib/types/client/ChangedFiles.d.ts.map +1 -1
  30. package/lib/types/client/ChangedFiles.js.map +1 -1
  31. package/lib/types/client/ChangesLoading.d.ts +14 -0
  32. package/lib/types/client/ChangesLoading.d.ts.map +1 -0
  33. package/lib/types/client/ChangesLoading.js.map +1 -0
  34. package/lib/types/client/ChangesTab.d.ts +62 -14
  35. package/lib/types/client/ChangesTab.d.ts.map +1 -1
  36. package/lib/types/client/ChangesTab.js.map +1 -1
  37. package/lib/types/client/ChangesTabTitle.js.map +1 -1
  38. package/lib/types/client/DiffFile.d.ts +23 -4
  39. package/lib/types/client/DiffFile.d.ts.map +1 -1
  40. package/lib/types/client/DiffFile.js.map +1 -1
  41. package/lib/types/client/EnvironmentRows.d.ts +79 -0
  42. package/lib/types/client/EnvironmentRows.d.ts.map +1 -0
  43. package/lib/types/client/EnvironmentRows.js.map +1 -0
  44. package/lib/types/client/FileTreePane.d.ts +5 -2
  45. package/lib/types/client/FileTreePane.d.ts.map +1 -1
  46. package/lib/types/client/FileTreePane.js.map +1 -1
  47. package/lib/types/client/LensFilter.d.ts +50 -0
  48. package/lib/types/client/LensFilter.d.ts.map +1 -0
  49. package/lib/types/client/LensFilter.js.map +1 -0
  50. package/lib/types/client/ReasonButton.d.ts +15 -0
  51. package/lib/types/client/ReasonButton.d.ts.map +1 -0
  52. package/lib/types/client/ReasonButton.js.map +1 -0
  53. package/lib/types/client/ReviewComposer.d.ts +11 -4
  54. package/lib/types/client/ReviewComposer.d.ts.map +1 -1
  55. package/lib/types/client/ReviewComposer.js.map +1 -1
  56. package/lib/types/client/ReviewControls.d.ts +18 -7
  57. package/lib/types/client/ReviewControls.d.ts.map +1 -1
  58. package/lib/types/client/ReviewControls.js.map +1 -1
  59. package/lib/types/client/ReviewThread.d.ts +3 -1
  60. package/lib/types/client/ReviewThread.d.ts.map +1 -1
  61. package/lib/types/client/ReviewThread.js.map +1 -1
  62. package/lib/types/client/ReviewThreads.d.ts +32 -2
  63. package/lib/types/client/ReviewThreads.d.ts.map +1 -1
  64. package/lib/types/client/ReviewThreads.js.map +1 -1
  65. package/lib/types/client/SessionHoverForge.d.ts.map +1 -1
  66. package/lib/types/client/SessionHoverForge.js.map +1 -1
  67. package/lib/types/client/SubmitReview.d.ts +4 -4
  68. package/lib/types/client/SubmitReview.d.ts.map +1 -1
  69. package/lib/types/client/SubmitReview.js.map +1 -1
  70. package/lib/types/client/ThreadList.js.map +1 -1
  71. package/lib/types/client/ViewOptionsMenu.d.ts +7 -1
  72. package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -1
  73. package/lib/types/client/ViewOptionsMenu.js.map +1 -1
  74. package/lib/types/client/WorktreeNameDialog.d.ts +38 -0
  75. package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -0
  76. package/lib/types/client/WorktreeNameDialog.js.map +1 -0
  77. package/lib/types/client/WorktreeProgress.d.ts +14 -3
  78. package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
  79. package/lib/types/client/WorktreeProgress.js.map +1 -1
  80. package/lib/types/client/WorktreeToggle.d.ts +22 -15
  81. package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
  82. package/lib/types/client/WorktreeToggle.js.map +1 -1
  83. package/lib/types/client/action-notices.d.ts +25 -0
  84. package/lib/types/client/action-notices.d.ts.map +1 -0
  85. package/lib/types/client/action-notices.js.map +1 -0
  86. package/lib/types/client/annotations.d.ts +41 -0
  87. package/lib/types/client/annotations.d.ts.map +1 -0
  88. package/lib/types/client/annotations.js.map +1 -0
  89. package/lib/types/client/branch-search.d.ts +38 -0
  90. package/lib/types/client/branch-search.d.ts.map +1 -0
  91. package/lib/types/client/branch-search.js.map +1 -0
  92. package/lib/types/client/change-requests-store.d.ts +25 -0
  93. package/lib/types/client/change-requests-store.d.ts.map +1 -0
  94. package/lib/types/client/change-requests-store.js.map +1 -0
  95. package/lib/types/client/changes-address.d.ts +3 -1
  96. package/lib/types/client/changes-address.d.ts.map +1 -1
  97. package/lib/types/client/changes-address.js.map +1 -1
  98. package/lib/types/client/changes-service.d.ts +119 -0
  99. package/lib/types/client/changes-service.d.ts.map +1 -0
  100. package/lib/types/client/changes-service.js.map +1 -0
  101. package/lib/types/client/changes-store.d.ts +6 -2
  102. package/lib/types/client/changes-store.d.ts.map +1 -1
  103. package/lib/types/client/changes-store.js.map +1 -1
  104. package/lib/types/client/checkout.d.ts.map +1 -1
  105. package/lib/types/client/checkout.js.map +1 -1
  106. package/lib/types/client/diff-rows.d.ts +49 -7
  107. package/lib/types/client/diff-rows.d.ts.map +1 -1
  108. package/lib/types/client/diff-rows.js.map +1 -1
  109. package/lib/types/client/file-tree.d.ts +7 -0
  110. package/lib/types/client/file-tree.d.ts.map +1 -1
  111. package/lib/types/client/file-tree.js.map +1 -1
  112. package/lib/types/client/forge-copy.d.ts +29 -0
  113. package/lib/types/client/forge-copy.d.ts.map +1 -0
  114. package/lib/types/client/forge-copy.js.map +1 -0
  115. package/lib/types/client/format.d.ts +8 -0
  116. package/lib/types/client/format.d.ts.map +1 -1
  117. package/lib/types/client/format.js.map +1 -1
  118. package/lib/types/client/glyphs.d.ts +3 -3
  119. package/lib/types/client/glyphs.d.ts.map +1 -1
  120. package/lib/types/client/glyphs.js.map +1 -1
  121. package/lib/types/client/highlight-context.d.ts +73 -0
  122. package/lib/types/client/highlight-context.d.ts.map +1 -0
  123. package/lib/types/client/highlight-context.js.map +1 -0
  124. package/lib/types/client/index.d.ts +9 -5
  125. package/lib/types/client/index.d.ts.map +1 -1
  126. package/lib/types/client/index.js.map +1 -1
  127. package/lib/types/client/lens-filter.d.ts +69 -0
  128. package/lib/types/client/lens-filter.d.ts.map +1 -0
  129. package/lib/types/client/lens-filter.js.map +1 -0
  130. package/lib/types/client/locales.d.ts +188 -36
  131. package/lib/types/client/locales.d.ts.map +1 -1
  132. package/lib/types/client/locales.js.map +1 -1
  133. package/lib/types/client/mount.d.ts +0 -4
  134. package/lib/types/client/mount.d.ts.map +1 -1
  135. package/lib/types/client/mount.js.map +1 -1
  136. package/lib/types/client/review-page/ReviewChat.d.ts +112 -0
  137. package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -0
  138. package/lib/types/client/review-page/ReviewChat.js.map +1 -0
  139. package/lib/types/client/review-page/ReviewDetail.d.ts +56 -0
  140. package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -0
  141. package/lib/types/client/review-page/ReviewDetail.js.map +1 -0
  142. package/lib/types/client/review-page/ReviewLabels.d.ts +32 -0
  143. package/lib/types/client/review-page/ReviewLabels.d.ts.map +1 -0
  144. package/lib/types/client/review-page/ReviewLabels.js.map +1 -0
  145. package/lib/types/client/review-page/ReviewList.d.ts +68 -0
  146. package/lib/types/client/review-page/ReviewList.d.ts.map +1 -0
  147. package/lib/types/client/review-page/ReviewList.js.map +1 -0
  148. package/lib/types/client/review-page/ReviewNav.d.ts +28 -0
  149. package/lib/types/client/review-page/ReviewNav.d.ts.map +1 -0
  150. package/lib/types/client/review-page/ReviewNav.js.map +1 -0
  151. package/lib/types/client/review-page/ReviewPage.d.ts +61 -0
  152. package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -0
  153. package/lib/types/client/review-page/ReviewPage.js.map +1 -0
  154. package/lib/types/client/review-page/ReviewStatus.d.ts +37 -0
  155. package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -0
  156. package/lib/types/client/review-page/ReviewStatus.js.map +1 -0
  157. package/lib/types/client/review-page/host-stream.d.ts +24 -0
  158. package/lib/types/client/review-page/host-stream.d.ts.map +1 -0
  159. package/lib/types/client/review-page/host-stream.js.map +1 -0
  160. package/lib/types/client/review-page/review-lists.d.ts +116 -0
  161. package/lib/types/client/review-page/review-lists.d.ts.map +1 -0
  162. package/lib/types/client/review-page/review-lists.js.map +1 -0
  163. package/lib/types/client/review-page/review-mount.d.ts +50 -0
  164. package/lib/types/client/review-page/review-mount.d.ts.map +1 -0
  165. package/lib/types/client/review-page/review-mount.js.map +1 -0
  166. package/lib/types/client/review-page/review-store.d.ts +79 -0
  167. package/lib/types/client/review-page/review-store.d.ts.map +1 -0
  168. package/lib/types/client/review-page/review-store.js.map +1 -0
  169. package/lib/types/client/review-queue.d.ts +19 -0
  170. package/lib/types/client/review-queue.d.ts.map +1 -1
  171. package/lib/types/client/review-queue.js.map +1 -1
  172. package/lib/types/client/review-threads.d.ts +0 -8
  173. package/lib/types/client/review-threads.d.ts.map +1 -1
  174. package/lib/types/client/review-threads.js.map +1 -1
  175. package/lib/types/client/review.d.ts +18 -0
  176. package/lib/types/client/review.d.ts.map +1 -1
  177. package/lib/types/client/review.js.map +1 -1
  178. package/lib/types/client/slots.d.ts +114 -0
  179. package/lib/types/client/slots.d.ts.map +1 -0
  180. package/lib/types/client/slots.js.map +1 -0
  181. package/lib/types/client/source.d.ts +29 -23
  182. package/lib/types/client/source.d.ts.map +1 -1
  183. package/lib/types/client/source.js.map +1 -1
  184. package/lib/types/client/status.d.ts +13 -2
  185. package/lib/types/client/status.d.ts.map +1 -1
  186. package/lib/types/client/status.js.map +1 -1
  187. package/lib/types/git.d.ts +4 -15
  188. package/lib/types/git.d.ts.map +1 -1
  189. package/lib/types/git.js.map +1 -1
  190. package/lib/types/index.d.ts +346 -28
  191. package/lib/types/index.d.ts.map +1 -1
  192. package/lib/types/index.js.map +1 -1
  193. package/lib/types/lens-version.d.ts +14 -0
  194. package/lib/types/lens-version.d.ts.map +1 -0
  195. package/lib/types/lens-version.js.map +1 -0
  196. package/lib/types/lenses.d.ts +122 -0
  197. package/lib/types/lenses.d.ts.map +1 -0
  198. package/lib/types/lenses.js.map +1 -0
  199. package/lib/types/local-diff.d.ts +16 -0
  200. package/lib/types/local-diff.d.ts.map +1 -1
  201. package/lib/types/local-diff.js.map +1 -1
  202. package/lib/types/panel.d.ts +59 -8
  203. package/lib/types/panel.d.ts.map +1 -1
  204. package/lib/types/panel.js.map +1 -1
  205. package/lib/types/parse.d.ts +24 -8
  206. package/lib/types/parse.d.ts.map +1 -1
  207. package/lib/types/parse.js.map +1 -1
  208. package/lib/types/review-cache.d.ts +29 -19
  209. package/lib/types/review-cache.d.ts.map +1 -1
  210. package/lib/types/review-cache.js.map +1 -1
  211. package/lib/types/states.d.ts +11 -7
  212. package/lib/types/states.d.ts.map +1 -1
  213. package/lib/types/states.js.map +1 -1
  214. package/lib/types/types.d.ts +266 -20
  215. package/lib/types/types.d.ts.map +1 -1
  216. package/lib/types/viewer-lists.d.ts +113 -0
  217. package/lib/types/viewer-lists.d.ts.map +1 -0
  218. package/lib/types/viewer-lists.js.map +1 -0
  219. package/lib/types/worktree.d.ts +20 -11
  220. package/lib/types/worktree.d.ts.map +1 -1
  221. package/lib/types/worktree.js.map +1 -1
  222. package/locale/de.json +1 -1
  223. package/locale/en.json +1 -1
  224. package/locale/es.json +1 -1
  225. package/locale/fr.json +1 -1
  226. package/locale/ja.json +1 -1
  227. package/locale/pt.json +1 -1
  228. package/locale/ru.json +1 -1
  229. package/locale/zh.json +1 -1
  230. package/package.json +61 -52
  231. package/src/branch-name.ts +74 -0
  232. package/src/client/AttentionIndicator.tsx +37 -0
  233. package/src/client/BaseMenu.module.css +0 -20
  234. package/src/client/BaseMenu.tsx +9 -52
  235. package/src/client/ChangeRequestCard.tsx +276 -131
  236. package/src/client/ChangeRequestOverview.module.css +1 -1
  237. package/src/client/ChangeRequestOverview.tsx +183 -67
  238. package/src/client/ChangeRequestsSection.tsx +234 -0
  239. package/src/client/ChangedFiles.module.css +5 -1
  240. package/src/client/ChangedFiles.tsx +72 -36
  241. package/src/client/ChangesLoading.module.css +110 -0
  242. package/src/client/ChangesLoading.tsx +69 -0
  243. package/src/client/ChangesTab.module.css +83 -114
  244. package/src/client/ChangesTab.tsx +331 -100
  245. package/src/client/ChangesTabTitle.tsx +3 -3
  246. package/src/client/DiffFile.tsx +241 -45
  247. package/src/client/EnvironmentRows.tsx +263 -0
  248. package/src/client/FileLabel.tsx +1 -1
  249. package/src/client/FileTreePane.tsx +11 -6
  250. package/src/client/{ForgeTab.module.css → Forge.module.css} +130 -275
  251. package/src/client/LensFilter.module.css +87 -0
  252. package/src/client/LensFilter.tsx +105 -0
  253. package/src/client/ReasonButton.tsx +23 -0
  254. package/src/client/ReviewComposer.module.css +2 -8
  255. package/src/client/ReviewComposer.tsx +27 -8
  256. package/src/client/ReviewControls.module.css +39 -0
  257. package/src/client/ReviewControls.tsx +71 -15
  258. package/src/client/ReviewThread.tsx +55 -30
  259. package/src/client/ReviewThreads.module.css +24 -0
  260. package/src/client/ReviewThreads.tsx +56 -21
  261. package/src/client/SessionHoverForge.tsx +2 -1
  262. package/src/client/SubmitReview.tsx +11 -8
  263. package/src/client/ThreadList.tsx +1 -1
  264. package/src/client/ViewOptionsMenu.tsx +19 -4
  265. package/src/client/WorktreeNameDialog.module.css +53 -0
  266. package/src/client/WorktreeNameDialog.tsx +93 -0
  267. package/src/client/WorktreeProgress.tsx +100 -35
  268. package/src/client/WorktreeToggle.module.css +121 -5
  269. package/src/client/WorktreeToggle.tsx +178 -61
  270. package/src/client/action-notices.ts +38 -0
  271. package/src/client/annotations.ts +105 -0
  272. package/src/client/branch-search.tsx +77 -0
  273. package/src/client/change-requests-store.ts +50 -0
  274. package/src/client/changes-address.ts +3 -1
  275. package/src/client/changes-service.ts +173 -0
  276. package/src/client/changes-store.ts +103 -91
  277. package/src/client/checkout.ts +2 -1
  278. package/src/client/diff-rows.ts +100 -16
  279. package/src/client/file-tree.ts +29 -0
  280. package/src/client/forge-copy.ts +49 -0
  281. package/src/client/format.ts +14 -0
  282. package/src/client/glyphs.tsx +12 -13
  283. package/src/client/highlight-context.ts +213 -0
  284. package/src/client/index.ts +20 -5
  285. package/src/client/lens-filter.ts +136 -0
  286. package/src/client/locales.ts +1504 -288
  287. package/src/client/mount.ts +228 -109
  288. package/src/client/review-page/ReviewChat.tsx +311 -0
  289. package/src/client/review-page/ReviewDetail.tsx +331 -0
  290. package/src/client/review-page/ReviewLabels.tsx +94 -0
  291. package/src/client/review-page/ReviewList.tsx +461 -0
  292. package/src/client/review-page/ReviewNav.tsx +47 -0
  293. package/src/client/review-page/ReviewPage.module.css +946 -0
  294. package/src/client/review-page/ReviewPage.tsx +287 -0
  295. package/src/client/review-page/ReviewStatus.tsx +259 -0
  296. package/src/client/review-page/host-stream.ts +63 -0
  297. package/src/client/review-page/review-lists.ts +207 -0
  298. package/src/client/review-page/review-mount.ts +228 -0
  299. package/src/client/review-page/review-store.ts +94 -0
  300. package/src/client/review-queue.ts +30 -0
  301. package/src/client/review-threads.ts +0 -12
  302. package/src/client/review.ts +27 -0
  303. package/src/client/slots.ts +92 -0
  304. package/src/client/source.ts +67 -43
  305. package/src/client/status.ts +16 -4
  306. package/src/git.ts +16 -38
  307. package/src/index.ts +900 -152
  308. package/src/lens-version.ts +27 -0
  309. package/src/lenses.ts +284 -0
  310. package/src/local-diff.ts +48 -1
  311. package/src/panel.ts +123 -28
  312. package/src/parse.ts +86 -10
  313. package/src/review-cache.ts +57 -37
  314. package/src/states.ts +38 -18
  315. package/src/types.ts +267 -21
  316. package/src/viewer-lists.ts +375 -0
  317. package/src/worktree.ts +64 -34
  318. package/lib/types/client/ForgeTab.d.ts +0 -65
  319. package/lib/types/client/ForgeTab.d.ts.map +0 -1
  320. package/lib/types/client/ForgeTab.js.map +0 -1
  321. package/lib/types/client/ForgeTabTitle.d.ts +0 -11
  322. package/lib/types/client/ForgeTabTitle.d.ts.map +0 -1
  323. package/lib/types/client/ForgeTabTitle.js.map +0 -1
  324. package/lib/types/client/HeaderButton.d.ts +0 -27
  325. package/lib/types/client/HeaderButton.d.ts.map +0 -1
  326. package/lib/types/client/HeaderButton.js.map +0 -1
  327. package/lib/types/client/LocalChangesCard.d.ts +0 -29
  328. package/lib/types/client/LocalChangesCard.d.ts.map +0 -1
  329. package/lib/types/client/LocalChangesCard.js.map +0 -1
  330. package/src/client/ForgeTab.tsx +0 -263
  331. package/src/client/ForgeTabTitle.tsx +0 -21
  332. package/src/client/HeaderButton.module.css +0 -29
  333. package/src/client/HeaderButton.tsx +0 -68
  334. package/src/client/LocalChangesCard.tsx +0 -83
@@ -17,31 +17,32 @@ import {
17
17
  import clsx from 'clsx'
18
18
  import {
19
19
  Button, IconBranchOutlineRegular, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconCompareSplitOutlineRegular,
20
- IconInfoOutlineRegular, IconListPenOutlineRegular, IconNowrapFillRegular, IconRightUpOutlineRegular, IconWorkspaceTreeOutlineRegular,
20
+ IconInfoOutlineRegular, IconFilesDiffOutlineRegular, IconNowrapFillRegular, IconRightUpOutlineRegular, IconWorkspaceTreeOutlineRegular,
21
21
  IconWrapFillRegular,
22
- Menu, StateDot, Tooltip,
22
+ Menu, Tooltip,
23
23
  type MenuEntry,
24
24
  } from '@deepseek-ai/dsh-client-ui-primitives'
25
- import type { HostObservable, InjectFace, PropsLocale, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
25
+ import type { HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
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
- ForgeBaseBranch, ForgeBaseBranches, ForgeChangeRequestDiff, ForgeCommitRange, ForgeDiffFile, ForgeLocalCommits, ForgeLocalDiff,
32
- ForgeLocalScope, ForgePanelChangeRequest, ForgePanelState,
31
+ ForgeBaseBranch, ForgeBaseBranches, ForgeChangeRequestDiff, ForgeCommitRange, ForgeDiffFile, ForgeExtensionState, ForgeLensFrame,
32
+ ForgeLensKeep, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope,
33
33
  } from '../types.ts'
34
+ import { lensVersion } from '../lens-version.ts'
34
35
  import type {
35
36
  ForgeCommitList, ForgeReviewData, ForgeReviewRequest, ForgeReviewResult, ForgeReviewThread, ForgeReviewWrite, ForgeReviewWriteResult,
36
37
  ForgeThreadId, ForgeViewedFiles, ForgeViewedRequest,
37
38
  } from '@deepseek-ai/dsh-experimental-forge/types'
38
- import { sameReviewSource, type ReviewQueue } from './review-queue.ts'
39
+ import { sameReviewSource, type RemovedRecord, type ReviewQueue } from './review-queue.ts'
39
40
  import { ReviewThread, useFileReview } from './ReviewThread.tsx'
40
41
  import type { ReviewActions } from './ReviewComposer.tsx'
41
42
  import { SubmitReview } from './SubmitReview.tsx'
42
- import type { ReviewSelection, ReviewSource } from './review.ts'
43
+ import type { QuoteCopy, ReviewSelection, ReviewSource } from './review.ts'
43
44
  import { BaseMenu } from './BaseMenu.tsx'
44
- import { parseChangesAddress, type ChangesSource } from './changes-address.ts'
45
+ import { parseChangesAddress, type ChangesSource, type ChangesTarget } from './changes-address.ts'
45
46
  import type { ChangesLens, createChangesStore } from './changes-store.ts'
46
47
  import { CommitMenu } from './CommitMenu.tsx'
47
48
  import { HideTestsSwitch, LensControl, LensMenu, LENSES, ViewedProgress } from './ReviewControls.tsx'
@@ -52,18 +53,25 @@ import { SectionReach } from './section-reach.ts'
52
53
  import { FileTreePane, type FileTreePosition } from './FileTreePane.tsx'
53
54
  import { changedFileTree, filesInTreeOrder } from './file-tree.ts'
54
55
  import { ChangedFilesMenu, type ChangedFilesProps, type ChangedFilesState } from './ChangedFiles.tsx'
55
- import { drawnLines, matchesHunks, textLines } from './diff-rows.ts'
56
+ import { ChangesLoading } from './ChangesLoading.tsx'
57
+ import { drawnLines, matchesHunks, revealGap, textLines, type GapExpansion, type GapReveal } from './diff-rows.ts'
56
58
  import { ChangeRequestGlyph } from './glyphs.tsx'
57
59
  import type { ForgePanelKey, NS } from './locales.ts'
60
+ import { useForgeCopy } from './forge-copy.ts'
58
61
  import { RefreshGlyph } from './RefreshGlyph.tsx'
59
62
  import { ViewOptionsMenu } from './ViewOptionsMenu.tsx'
63
+ import type { ForgeLensDescription } from './changes-service.ts'
64
+ import type { SourcedAnnotation, ViewAnnotations } from './annotations.ts'
65
+ import { foldedHunks, useLensRun } from './lens-filter.ts'
66
+ import { LensFilterMenu, type LensChoice } from './LensFilter.tsx'
67
+ import type {} from './slots.ts'
60
68
  import { observeToolbarFold } from './toolbar-fold.ts'
61
69
  import type { FileThreads, ThreadActions, ThreadFocus, ThreadWrite } from './ReviewThreads.tsx'
62
70
  import { inFileOrder, type ThreadFilter } from './review-threads.ts'
63
71
  import { usePlacedThreads, useThreadRead, type PlacedThread } from './thread-state.ts'
64
72
  import { ThreadList } from './ThreadList.tsx'
65
- import type { PanelSnapshot } from './source.ts'
66
- import { numberOf, openChangeRequestOf, TONE_LABEL, toneOf } from './status.ts'
73
+ import type { HostStream, NoticeOptions, PanelSnapshot, StreamSnapshot } from './source.ts'
74
+ import { numberOf, openChangeRequestOf, TONE_LABEL, toneOf, type ChangeRequestEntry, type ChangesPanelState } from './status.ts'
67
75
  import css from './ChangesTab.module.css'
68
76
 
69
77
  type Translate = PropsLocale<typeof NS>['t']
@@ -80,13 +88,26 @@ interface Wanted {
80
88
  /** Business face of the changes tab body. */
81
89
  export interface ChangesTabInjected {
82
90
  /** Append a frozen comment to the main input without submitting it. */
83
- readonly addReviewToInput: (selection: ReviewSelection) => boolean
91
+ readonly addReviewToInput: (selection: ReviewSelection) => boolean | Promise<boolean>
84
92
  /** Records retained across Session switches and cleared when this tab occurrence closes. */
85
- readonly reviewQueue: (tab: Pick<SidebarRightTabInfo['tab'], 'id' | 'signal'>) => ReviewQueue
93
+ readonly reviewQueue: (tab: Pick<ChangesViewTab, 'id' | 'signal'>) => ReviewQueue
86
94
  /** Publish one comment or a completed review; never retries mutations. */
87
95
  readonly submitReview: (url: string, request: ForgeReviewRequest) => Promise<RemoteResult<ForgeReviewResult>>
88
- /** Panel source while visible; the renderer releases the subscription for an inactive key. */
89
- readonly keyedHooks: { readonly panel: (visibility: string) => HostObservable<PanelSnapshot> | undefined }
96
+ /**
97
+ * Panel source while visible, which the renderer releases for an inactive key; and the plugin annotations of a view by
98
+ * its address, which the renderer binds as `useAnnotations`.
99
+ */
100
+ readonly keyedHooks: {
101
+ readonly panel: (visibility: string) => HostObservable<PanelSnapshot> | undefined
102
+ readonly annotations: (address: string) => HostObservable<ViewAnnotations>
103
+ }
104
+ /** Lens titles Client plugins describe and the Host's lenses and annotation limit; bound as `useLenses` and `useExtensions`. */
105
+ readonly hooks: {
106
+ readonly lenses: HostObservable<readonly ForgeLensDescription[]>
107
+ readonly extensions: HostObservable<StreamSnapshot<ForgeExtensionState | null>>
108
+ }
109
+ /** Classify the shown files with a Host lens; `signal` aborts the stream. */
110
+ readonly changesLens: (request: ForgeLensRequest, signal: AbortSignal) => HostStream<ForgeLensFrame>
90
111
  /** Open the panel stream again after it ended. */
91
112
  readonly reconnect: () => void
92
113
  /** Read the local changes of one scope; `signal` aborts the read. */
@@ -107,9 +128,11 @@ export interface ChangesTabInjected {
107
128
  readonly viewedFiles: ViewedFiles
108
129
  /**
109
130
  * Read the signed-in user's viewed marks on a change request's files at `headSha`, or null when its provider keeps
110
- * none; `signal` aborts the read.
131
+ * none; `fresh` skips the marks the host keeps, and `signal` aborts the read.
111
132
  */
112
- readonly changeRequestViewed: (url: string, headSha: string, signal: AbortSignal) => Promise<RemoteResult<ForgeViewedFiles | null>>
133
+ readonly changeRequestViewed: (
134
+ url: string, headSha: string, fresh: boolean, signal: AbortSignal,
135
+ ) => Promise<RemoteResult<ForgeViewedFiles | null>>
113
136
  /** Set or clear the signed-in user's viewed mark on one file of a change request. */
114
137
  readonly setFileViewed: (url: string, request: ForgeViewedRequest) => Promise<RemoteResult<void>>
115
138
  /** Read one file of a change request at a commit. */
@@ -121,24 +144,52 @@ export interface ChangesTabInjected {
121
144
  /** Write to the review threads or the pending review of a change request; never retries a write. */
122
145
  readonly changeRequestReviewWrite: (url: string, write: ForgeReviewWrite) => Promise<RemoteResult<ForgeReviewWriteResult>>
123
146
  /** Quote a whole review thread of the change request at `url` in the main input without submitting it. */
124
- readonly addThreadToInput: (thread: ForgeReviewThread, url: string, range: string | null) => boolean
147
+ readonly addThreadToInput: (thread: ForgeReviewThread, url: string, range: string | null) => boolean | Promise<boolean>
125
148
  /** Open a URL outside the app. */
126
149
  readonly openLink: (url: string) => void
127
150
  /** Copy a path to the clipboard and report the outcome. */
128
151
  readonly copyPath: (path: string) => void
129
152
  /** Ask the Session's Agent to create a change request for its changes, reporting the outcome. */
130
153
  readonly createChangeRequest: () => void
131
- /** Show a failure notice. */
132
- readonly report: (key: ForgePanelKey, params?: Readonly<Record<string, string>>) => void
154
+ /** Show a notice: a failure unless the options name another tone, with the undo action they carry. */
155
+ readonly report: (key: ForgePanelKey, options?: NoticeOptions) => void
133
156
  }
134
157
 
135
158
  /** Full props of the changes tab body. */
136
159
  export type ChangesTabProps =
137
160
  Pick<PropsRuntime<'sidebar.right.pane.tab'>, 'useTabInfo' | 'sessionId'>
161
+ & Pick<PropsRenderSlots<'forge.changes.toolbar' | 'forge.changes.file.menu' | 'forge.diff.line.annotation' | 'forge.diff.comment.actions'>,
162
+ 'renderSlot'>
138
163
  & PropsStore<ReturnType<typeof createChangesStore>>
139
164
  & InjectFace<ChangesTabInjected>
140
165
  & PropsLocale<typeof NS>
141
166
 
167
+ /** The tab facts the changes view reads: its sidebar tab's, or the review page's for one change request. */
168
+ export interface ChangesViewTab extends Pick<SidebarRightTabInfo['tab'], 'visible' | 'navigation' | 'signal'> {
169
+ /** Identity the view's choices and pending review comments are kept under. */
170
+ readonly id: string
171
+ /** Bind the view's refresh to the tab's refresh command; returns the unbinding. */
172
+ readonly actions: Pick<SidebarRightTabInfo['tab']['actions'], 'bindCommands'>
173
+ }
174
+
175
+ /** Props of the changes view, which the changes tab and the review page draw. */
176
+ export type ChangesViewProps = Omit<ChangesTabProps, 'useTabInfo' | 'sessionId' | 'usePanel' | 'useAnnotations'> & {
177
+ /** Tab facts. */
178
+ readonly tab: ChangesViewTab
179
+ /** What the view shows. */
180
+ readonly source: ChangesSource
181
+ /** The view plugins see, or null on the review page, where plugin slots and annotations do not show. */
182
+ readonly target: ChangesTarget | null
183
+ /** The panel facts while known, and whether their stream ended. */
184
+ readonly snapshot: { readonly state: ChangesPanelState | null; readonly disconnected: boolean } | undefined
185
+ /** Plugin annotations of the view, or undefined before any. */
186
+ readonly annotations: ViewAnnotations | undefined
187
+ /** Open a file of the checkout in the right sidebar, by its absolute path; undefined where no sidebar shows. */
188
+ readonly openFile: ((path: string) => void) | undefined
189
+ /** Copy of the quote actions where they quote somewhere other than the Session's input. */
190
+ readonly quoteCopy?: QuoteCopy | undefined
191
+ }
192
+
142
193
  /** Changes of either source as the view draws them. */
143
194
  type ChangesData =
144
195
  | {
@@ -174,11 +225,11 @@ interface WriteRefusal {
174
225
  readonly unknown: boolean
175
226
  }
176
227
 
177
- /** Unchanged lines read for one loaded diff: each file's new side and its expanded gaps. */
228
+ /** Unchanged lines and expanded gaps belong to one comparison. A local checkout can change between reads. */
178
229
  interface Expansion {
179
- readonly data: ChangesData | null
230
+ readonly source: string | Extract<ChangesData, { kind: 'local' }> | null
180
231
  readonly texts: Readonly<Record<string, readonly string[] | 'loading'>>
181
- readonly open: Readonly<Record<string, ReadonlySet<number>>>
232
+ readonly open: Readonly<Record<string, ReadonlyMap<number, GapReveal>>>
182
233
  }
183
234
 
184
235
  /** Files whose hunks draw more lines show the large-file notice until revealed. */
@@ -187,7 +238,16 @@ const LARGE_FILE_LINES = 1000
187
238
  /** Lines the files above may change before a file starts collapsed. */
188
239
  const OPEN_LINES = 5000
189
240
 
190
- const NO_GAPS: ReadonlySet<number> = new Set()
241
+ const NO_GAPS: ReadonlyMap<number, GapReveal> = new Map()
242
+
243
+ const NO_FOLDS: ReadonlyMap<string, { readonly hunks: ReadonlySet<number>; readonly lens: string }> = new Map()
244
+
245
+ const NO_PATHS: ReadonlySet<string> = new Set()
246
+
247
+ const NO_ANNOTATIONS: ViewAnnotations = new Map()
248
+
249
+ /** The toolbar row's close action, which has no menu to close. */
250
+ function noop(): void {}
191
251
 
192
252
  const SCOPE_LABEL: Record<ScopeKind, ForgePanelKey> = {
193
253
  branch: 'diff.scope.branch',
@@ -237,6 +297,7 @@ function baseFailureOf(failed: string | null, base: ForgeBaseBranch | null, t: T
237
297
  * @param scope - local scope to read.
238
298
  * @param commits - chosen commits of a change request, or null for all of it.
239
299
  * @param head - head commit of the change request's latest status, or null.
300
+ * @param fresh - whether the viewed marks are read from the code host although the host keeps some, as after a refresh.
240
301
  * @param reads - the Remote reads.
241
302
  * @param signal - cancellation of the reads.
242
303
  * @returns the changes, or why they could not be read.
@@ -246,6 +307,7 @@ async function readChanges(
246
307
  scope: ForgeLocalScope,
247
308
  commits: ForgeCommitRange | null,
248
309
  head: string | null,
310
+ fresh: boolean,
249
311
  reads: Pick<ChangesTabInjected, 'localDiff' | 'changeRequestDiff' | 'changeRequestViewed'>,
250
312
  signal: AbortSignal,
251
313
  ): Promise<RemoteResult<ChangesData>> {
@@ -257,7 +319,7 @@ async function readChanges(
257
319
  }
258
320
  const [result, marks] = await Promise.all([
259
321
  reads.changeRequestDiff(source.url, commits, signal),
260
- commits === null && head !== null && head !== '' ? reads.changeRequestViewed(source.url, head, signal) : Promise.resolve(null),
322
+ commits === null && head !== null && head !== '' ? reads.changeRequestViewed(source.url, head, fresh, signal) : Promise.resolve(null),
261
323
  ])
262
324
  if (!result.ok) return result
263
325
  if (marks !== null && !marks.ok && marks.error.code === 'forgePanel/stale-head') return marks
@@ -311,9 +373,12 @@ function initiallyOpen(files: readonly ForgeDiffFile[], marks: ViewedMarks): Rea
311
373
  return open
312
374
  }
313
375
 
314
- /** Whether a file shows under a lens while test files hide or not. */
315
- function shownBy(file: ForgeDiffFile, lens: ChangesLens, hideTests: boolean): boolean {
376
+ /** Whether a file shows under a layer while test files hide or not, and among the files a filter lens keeps when one applies. */
377
+ function shownBy(
378
+ file: ForgeDiffFile, lens: ChangesLens, hideTests: boolean, kept: Readonly<Record<string, ForgeLensKeep>> | null = null,
379
+ ): boolean {
316
380
  return !(hideTests && file.layer === 'test') && (lens === 'all' || file.layer === lens)
381
+ && (kept === null || Object.hasOwn(kept, file.path))
317
382
  }
318
383
 
319
384
  /** What a rename badge names: the old file name, or the old path when only the directory changed. */
@@ -339,7 +404,7 @@ function badgeOf(file: ForgeDiffFile, data: ChangesData, t: Translate): string {
339
404
 
340
405
  function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDisabled, onReview, t }: {
341
406
  readonly url: string
342
- readonly entry: ForgePanelChangeRequest | undefined
407
+ readonly entry: ChangeRequestEntry | undefined
343
408
  /** Commit picker left of the review button. */
344
409
  readonly commitMenu: ReactNode
345
410
  readonly reviewCount: number
@@ -363,7 +428,7 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
363
428
  {t('review.submit')}{reviewCount > 0 ? ` (${reviewCount})` : ''}
364
429
  </Button>
365
430
  </span>
366
- <Tooltip label={t('change.view')} side="bottom">
431
+ <Tooltip label={t('change.view')} side="bottom" delayMs={500}>
367
432
  <button type="button" className={css.tool} aria-label={t('change.view')} onClick={() => { openLink(href) }}>
368
433
  <IconRightUpOutlineRegular size={14} />
369
434
  </button>
@@ -377,7 +442,7 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
377
442
  * that uncommitted changes count; for another scope, what it compares.
378
443
  */
379
444
  function LocalHeader({ state, scope, base, missing, visible, diffBases, choose, commitMenu, createChangeRequest, t }: {
380
- readonly state: ForgePanelState | null
445
+ readonly state: ChangesPanelState | null
381
446
  /** Commit picker of the `branch` scope, left of the create button. */
382
447
  readonly commitMenu: ReactNode
383
448
  readonly scope: ScopeKind
@@ -397,7 +462,7 @@ function LocalHeader({ state, scope, base, missing, visible, diffBases, choose,
397
462
  <div className={css.header}>
398
463
  {scope === 'branch' ? <>
399
464
  <span className={css.headerIcon}><IconBranchOutlineRegular size={15} /></span>
400
- <Tooltip label={head} side="bottom">
465
+ <Tooltip label={head} side="bottom" delayMs={500}>
401
466
  <span className={css.headerHead} tabIndex={0} data-forge-head="">{head}</span>
402
467
  </Tooltip>
403
468
  <span className={css.headerArrow} aria-hidden="true">→</span>
@@ -405,7 +470,7 @@ function LocalHeader({ state, scope, base, missing, visible, diffBases, choose,
405
470
  visible={visible} list={diffBases} choose={choose} t={t} />
406
471
  <span className={clsx(css.headerNote, css.headerSuffix)}>{t('diff.base.uncommitted')}</span>
407
472
  </> : <>
408
- <span className={css.headerIcon}><IconListPenOutlineRegular size={15} /></span>
473
+ <span className={css.headerIcon}><IconFilesDiffOutlineRegular size={15} /></span>
409
474
  <span className={css.headerNote}>{t(SCOPE_NOTE[scope])}</span>
410
475
  </>}
411
476
  {(scope === 'branch' || creatable) && <span className={css.headerEnd}>
@@ -482,16 +547,36 @@ function OrphanReviews({ path, actions, t }: PropsLocale<typeof NS> & {
482
547
  * @param props - tab information, the tab's choices, the panel snapshot hook, reads and actions, and copy.
483
548
  * @returns the view body.
484
549
  */
485
- export function ChangesTab({
486
- useTabInfo, sessionId, useStore, actions, usePanel, reconnect, localDiff, diffBases, localText, localCommits, changeRequestDiff,
487
- changeRequestText, changeRequestCommits, changeRequestReview, changeRequestReviewWrite, viewedFiles, changeRequestViewed, setFileViewed,
488
- openLink, copyPath, createChangeRequest, addReviewToInput, addThreadToInput, reviewQueue, submitReview, report, t,
489
- }: ChangesTabProps): ReactNode {
550
+ export function ChangesTab({ useTabInfo, sessionId, usePanel, useAnnotations, ...props }: ChangesTabProps): ReactNode {
490
551
  const { tab } = useTabInfo()
491
- const { navigation, signal } = tab
492
552
  const target = useMemo(() => parseChangesAddress(tab.contentId), [tab.contentId])
493
553
  if (target === undefined) throw new Error(`forge-panel: not a changes address "${tab.contentId}"`)
494
- const source = target.source
554
+ const snapshot = usePanel(tab.visible ? 'visible' : 'inactive')
555
+ const annotations = useAnnotations(tab.contentId)
556
+ const tabActions = tab.actions
557
+ const openFile = useCallback((path: string) => {
558
+ tabActions.openResource(fileAddressFor(sessionId, undefined, path))
559
+ }, [tabActions, sessionId])
560
+ return <ChangesView {...props} tab={tab} source={target.source} target={target} snapshot={snapshot} annotations={annotations}
561
+ openFile={openFile} />
562
+ }
563
+
564
+ /**
565
+ * Render the changes of a Session's checkout or of one change request.
566
+ * @param props - tab facts, what the view shows, the view's choices, the panel facts, reads and actions, and copy.
567
+ * @returns the view body.
568
+ */
569
+ export function ChangesView({
570
+ tab, source, target, snapshot, annotations: viewAnnotations, openFile, quoteCopy, useStore, actions, reconnect, localDiff, diffBases,
571
+ localText,
572
+ localCommits, changeRequestDiff, changeRequestText, changeRequestCommits, changeRequestReview, changeRequestReviewWrite, viewedFiles,
573
+ changeRequestViewed, setFileViewed, openLink, copyPath, createChangeRequest, addReviewToInput, addThreadToInput, reviewQueue,
574
+ submitReview, report, useLenses, useExtensions, changesLens, renderSlot, t: translate,
575
+ }: ChangesViewProps): ReactNode {
576
+ const { navigation, signal } = tab
577
+ const state = snapshot?.state ?? null
578
+ const entry = source.kind === 'change' ? state?.changeRequests.find(item => item.url === source.url) : undefined
579
+ const { t, host: hostCopy } = useForgeCopy(translate, source.kind === 'change' ? source.url : null, entry?.forge ?? null)
495
580
  const queue = reviewQueue(tab)
496
581
  useSyncExternalStore(queue.subscribe, queue.getStatus)
497
582
  const reviewState = queue.getSnapshot()
@@ -522,7 +607,8 @@ export function ChangesTab({
522
607
  return message
523
608
  }
524
609
  if (!complete(result.url)) return t('review.unknown')
525
- report(request.kind === 'review' ? 'review.submitted' : 'review.published')
610
+ if (request.kind === 'review') report('review.submitted', { tone: 'success' })
611
+ else report('review.published', { tone: 'success', params: hostCopy })
526
612
  if (request.kind === 'review') setReviewOpen(false)
527
613
  return undefined
528
614
  } catch (_error) {
@@ -579,13 +665,20 @@ export function ChangesTab({
579
665
  const [treeState, setTreeState] = useState<ChangedFilesState>({ query: '', collapsed: {}, selected: null })
580
666
  const [treePosition, setTreePosition] = useState<FileTreePosition>('left')
581
667
  const [treeWidth, setTreeWidth] = useState(0)
668
+ // The lens's labels set the least width of the tree they sit above.
669
+ const [lensWidth, setLensWidth] = useState(0)
582
670
  const treeId = useId()
583
671
  const [chosen, setChosen] = useState<Readonly<Record<string, boolean>>>({})
584
672
  // Each navigation applies once; its file, if it names one, opens and scrolls into view.
585
673
  useEffect(() => {
586
674
  if (choices?.navigated === navigation.revision) return
587
675
  actions.navigated(tab.id, navigation.revision)
588
- const path = navigation.params?.path
676
+ // Every tab of this kind is a `forge-changes` resource address, so its params are that type's; the union is
677
+ // narrowed on the field read, not validated.
678
+ const params = navigation.params
679
+ const lensParam = params !== undefined && 'lens' in params ? params.lens : undefined
680
+ if (lensParam !== undefined) actions.filtered(tab.id, lensParam)
681
+ const path = params !== undefined && 'path' in params ? params.path : undefined
589
682
  if (path === undefined) return
590
683
  setTreeState(value => ({ ...value, selected: path }))
591
684
  setChosen(value => ({ ...value, [path]: true }))
@@ -599,8 +692,6 @@ export function ChangesTab({
599
692
  }, [signal, actions, tab.id])
600
693
  const [attempt, setAttempt] = useState(0)
601
694
  useEffect(() => tab.actions.bindCommands({ refresh: () => { setAttempt(value => value + 1) } }), [tab.actions])
602
- const snapshot = usePanel(tab.visible ? 'visible' : 'inactive')
603
- const state = snapshot?.state ?? null
604
695
  const scope = choices?.scope ?? 'branch'
605
696
  const base = choices?.base ?? null
606
697
  const chosenCommits = choices?.commits ?? null
@@ -617,12 +708,15 @@ export function ChangesTab({
617
708
  const listLocalCommits = useCallback((signal: AbortSignal) => localCommits(baseRef, signal), [localCommits, baseRef])
618
709
  const split = choices?.split ?? true
619
710
  const wrap = choices?.wrap ?? true
620
- const entry = source.kind === 'change' ? state?.changeRequests.find(item => item.url === source.url) : undefined
621
711
  // A read starts once the panel state arrives and again when what it describes moves. A change request's read
622
- // also waits for its first status, which names the head, unless no provider serves it or its first poll failed.
712
+ // also waits for the first status of the panel stream, which names the head the Host reads at, unless no provider
713
+ // serves it or its first poll failed; until then the entry may show a snapshot the Host kept from an earlier stream.
623
714
  const pending = entry !== undefined && entry.ref !== null && entry.update === null
624
- const head = entry?.snapshot?.headSha ?? (pending ? null : '')
625
- const version = state === null ? null : source.kind === 'local' ? `${scope}\n${JSON.stringify(state.local)}` : head
715
+ const head = pending ? null : entry?.snapshot?.headSha ?? ''
716
+ // An accepted review change the host announced, from any plugin, reads a change request's viewed marks again.
717
+ const hostRevision = entry?.reviewRevision ?? 0
718
+ const version = state === null ? null : source.kind === 'local' ? `${scope}\n${JSON.stringify(state.local)}`
719
+ : head === null ? null : `${head}\n${hostRevision}`
626
720
  const headCommit = state !== null && state.checkout.state === 'ready' ? state.checkout.checkout.commit : null
627
721
  // The commits change with the head of a change request, with the local HEAD, branch, or base, and on a refresh.
628
722
  const commitsVersion = `${attempt}\n${source.kind === 'local'
@@ -640,11 +734,16 @@ export function ChangesTab({
640
734
  useEffect(() => { latestStatusAt.current = statusAt }, [statusAt])
641
735
  const [refused, setRefused] = useState<{ readonly read: string; readonly statusAt: number | null } | null>(null)
642
736
  const waiting = refused !== null && refused.read === read && refused.statusAt === statusAt
737
+ // The refresh whose read finished last; until the read of a later refresh finishes, reads skip the viewed marks the
738
+ // host keeps, which marks changed on the code host itself leave unchanged.
739
+ const finishedAttempt = useRef(attempt)
643
740
  useEffect(() => {
644
741
  if (!tab.visible || read === null || read === finished || waiting) return
645
742
  const controller = new AbortController()
646
743
  const readAt = latestStatusAt.current
647
- void readChanges(source, localScope, changeCommits, head, { localDiff, changeRequestDiff, changeRequestViewed }, controller.signal)
744
+ const fresh = finishedAttempt.current !== attempt
745
+ const reads = { localDiff, changeRequestDiff, changeRequestViewed }
746
+ void readChanges(source, localScope, changeCommits, head, fresh, reads, controller.signal)
648
747
  .then((result) => {
649
748
  if (controller.signal.aborted) return
650
749
  if (!result.ok && result.error.code === 'forgePanel/stale-head') {
@@ -652,6 +751,7 @@ export function ChangesTab({
652
751
  setFailure(null)
653
752
  return
654
753
  }
754
+ finishedAttempt.current = attempt
655
755
  setFinished(read)
656
756
  if (result.ok) {
657
757
  setLoaded({ key: dataKey, data: result.value })
@@ -661,15 +761,15 @@ export function ChangesTab({
661
761
  }
662
762
  })
663
763
  return () => { controller.abort() }
664
- }, [tab.visible, read, refused, waiting, source, localScope, changeCommits, head, dataKey, localDiff, changeRequestDiff,
764
+ }, [tab.visible, read, refused, waiting, source, localScope, changeCommits, head, attempt, dataKey, localDiff, changeRequestDiff,
665
765
  changeRequestViewed])
666
766
  const data = loaded !== null && loaded.key === dataKey ? loaded.data : null
667
767
  // Threads show only while they were read at the head of the latest status and, for the whole change request, at
668
768
  // the head the shown diff was read at, so their positions number the shown files.
669
- const prHead = entry?.snapshot?.headSha ?? null
769
+ const prHead = pending ? null : entry?.snapshot?.headSha ?? null
670
770
  const prAuthor = entry?.snapshot?.author ?? null
671
771
  const threadRead = useThreadRead({ visible: tab.visible, url: source.kind === 'change' ? source.url : null, head: prHead,
672
- updatedAt: entry?.snapshot?.updatedAt ?? null, statusAt, attempt, revision: reviewRevision, read: changeRequestReview })
772
+ updatedAt: entry?.snapshot?.updatedAt ?? null, statusAt, attempt, revision: reviewRevision + hostRevision, read: changeRequestReview })
673
773
  const review = data?.kind === 'change' && threadRead.review !== null && threadRead.review.headSha === prHead
674
774
  && (data.commits !== null || data.headSha === prHead) ? threadRead.review : null
675
775
  const placed = usePlacedThreads(review, data?.kind === 'change' ? { head: prHead ?? '', end: data.headSha, commits: data.commits } : null)
@@ -682,27 +782,93 @@ export function ChangesTab({
682
782
  const threadsToggle = useRef<HTMLButtonElement>(null)
683
783
  const [focus, setFocus] = useState<ThreadFocus | null>(null)
684
784
  const allFiles = useMemo(() => filesInTreeOrder(changedFileTree(data?.files ?? [])), [data])
685
- const files = useMemo(() => allFiles.filter(file => shownBy(file, lens, hideTests)), [allFiles, lens, hideTests])
785
+ // A Host filter lens keeps files only once its result for the shown files arrived; until then every file shows.
786
+ const extensions = useExtensions(current => current.state)
787
+ const descriptions = useLenses(current => current)
788
+ const hostLenses = extensions?.lenses ?? null
789
+ const chosenLens = choices?.filterLens ?? null
790
+ const activeEntry = chosenLens === null ? null : hostLenses?.find(item => item.id === chosenLens) ?? null
791
+ const activeLens = activeEntry?.id ?? null
792
+ const lensSource = useMemo((): ForgeLensRequest['source'] | null => data === null ? null
793
+ : data.kind === 'local' ? { kind: 'local', scope: data.scope } : { kind: 'change', url: data.url, commits: data.commits }, [data])
794
+ const filesVersion = useMemo(() => data === null ? null : lensVersion(data.files), [data])
795
+ const [lensAttempt, setLensAttempt] = useState(0)
796
+ const lensRun = useLensRun({
797
+ visible: tab.visible, lens: activeEntry, source: lensSource, version: filesVersion, attempt: lensAttempt, open: changesLens,
798
+ })
799
+ const kept = lensRun.run.kind === 'ready' ? lensRun.run.files : null
800
+ const files = useMemo(() => allFiles.filter(file => shownBy(file, lens, hideTests, kept)), [allFiles, lens, hideTests, kept])
686
801
  const lensCounts = useMemo(() => Object.fromEntries(LENSES.map(item => [item,
687
- allFiles.filter(file => shownBy(file, item, hideTests)).length])) as Record<ChangesLens, number>, [allFiles, hideTests])
802
+ allFiles.filter(file => shownBy(file, item, hideTests, kept)).length])) as Record<ChangesLens, number>, [allFiles, hideTests, kept])
803
+ const lensTitle = (id: string): string => {
804
+ const described = descriptions.find(item => item.id === id)
805
+ return described === undefined ? id : described.title()
806
+ }
807
+ // The described lenses come in their described order, then the lenses no Client plugin describes, by their identity.
808
+ const offered = hostLenses ?? []
809
+ const lensChoices: readonly LensChoice[] = [
810
+ ...descriptions.flatMap(item => offered.filter(entry => entry.id === item.id)),
811
+ ...offered.filter(entry => !descriptions.some(item => item.id === entry.id)),
812
+ ].map((entry) => {
813
+ const result = lensRun.resultOf(entry)
814
+ const count = result === undefined ? null : allFiles.filter(file => shownBy(file, lens, hideTests, result)).length
815
+ return { id: entry.id, title: lensTitle(entry.id), count }
816
+ })
817
+ const chosenChoice = lensChoices.find(item => item.id === activeLens) ?? null
818
+ // A lens the Host withdrew, as when its plugin unloaded, stops filtering; the reader is told once.
819
+ const withdrawn = chosenLens !== null && hostLenses !== null && activeEntry === null ? chosenLens : null
820
+ useEffect(() => {
821
+ if (withdrawn === null) return
822
+ actions.filtered(tab.id, null)
823
+ report('filterLens.removed', { params: { lens: live.current.lensTitle(withdrawn) } })
824
+ }, [withdrawn, actions, tab.id, report])
825
+ const chooseLens = (next: string | null): void => { actions.filtered(tab.id, next) }
826
+ // The hunks each kept file folds stay folded until the reader shows them for that file; a new result folds again.
827
+ const [unfolded, setUnfolded] = useState<{ readonly kept: typeof kept; readonly paths: ReadonlySet<string> }>(
828
+ { kept: null, paths: new Set() })
829
+ const shownPaths = unfolded.kept === kept ? unfolded.paths : NO_PATHS
830
+ const foldTitle = chosenChoice?.title ?? ''
831
+ const folds = useMemo(() => {
832
+ if (kept === null) return NO_FOLDS
833
+ const map = new Map<string, { readonly hunks: ReadonlySet<number>; readonly lens: string }>()
834
+ for (const file of allFiles) {
835
+ const keep = kept[file.path]
836
+ if (keep === undefined || shownPaths.has(file.path)) continue
837
+ const hunks = foldedHunks(file.hunks, keep)
838
+ if (hunks.size > 0) map.set(file.path, { hunks, lens: foldTitle })
839
+ }
840
+ return map
841
+ }, [allFiles, kept, shownPaths, foldTitle])
842
+ const annotations = viewAnnotations ?? NO_ANNOTATIONS
843
+ // Annotations wait for the Host's limit.
844
+ const annotationLimit = extensions?.maxAnnotationsPerFile
688
845
  const shownSource = useMemo(() => data === null ? null : reviewSourceOf(data), [data])
689
846
  const viewedKey = shownSource === null ? '' : viewedSourceOf(shownSource)
690
847
  const localMarks = useSyncExternalStore(viewedFiles.subscribe, () => viewedFiles.marksOf(viewedKey))
691
848
  const hostOwner = useMemo(() => data?.kind === 'change' && data.viewed !== null
692
849
  ? { url: data.url, headSha: data.headSha, files: data.files, viewed: data.viewed } : null, [data])
693
850
  const host = useHostViewed(hostOwner, setFileViewed, (failure) => {
694
- if (failure.kind === 'stale') report('viewed.syncStale')
695
- else if (failure.kind === 'unknown') report('viewed.syncUnknown', { message: failure.message })
696
- else report('viewed.syncFailed', { message: failure.message })
851
+ if (failure.kind === 'stale') report('viewed.syncStale', { params: hostCopy })
852
+ else if (failure.kind === 'unknown') report('viewed.syncUnknown', { params: { message: failure.message } })
853
+ else report('viewed.syncFailed', { params: { ...hostCopy, message: failure.message } })
697
854
  })
698
855
  const marks = host?.marks ?? localMarks
856
+ // Files marked viewed at their current change, which the file tree draws subdued.
857
+ const viewedPaths = useMemo(() => new Set(files.filter(file => viewedStateOf(marks, file.path, file.digest) === 'viewed').map(file => file.path)),
858
+ [files, marks])
699
859
  // The centered loader marks a first read; the toolbar's glyph turns only while shown changes are read again.
700
860
  const rereading = read !== null && finished !== read && data !== null
701
861
  const failed = failure !== null && failure.key === dataKey ? failure.code : null
702
- const [expansion, setExpansion] = useState<Expansion>({ data: null, texts: {}, open: {} })
703
- const current = expansion.data === data ? expansion : { data, texts: {}, open: {} }
704
- const latest = useRef(data)
705
- useEffect(() => { latest.current = data }, [data])
862
+ // Review marks can refresh while a file read is in flight. The commit supplies its text and the patch digests identify its gaps.
863
+ const expansionSource = useMemo(() => data?.kind === 'change'
864
+ ? JSON.stringify([data.url, data.headSha, data.commits?.from, data.commits?.to, data.files.map(file => file.digest)])
865
+ : data, [data])
866
+ const [expansion, setExpansion] = useState<Expansion>({ source: null, texts: {}, open: {} })
867
+ const current = expansion.source === expansionSource ? expansion : { source: expansionSource, texts: {}, open: {} }
868
+ const latest = useRef(expansionSource)
869
+ // Files whose new side was read ahead for highlighting in this comparison, each read at most once.
870
+ const contextReads = useRef<{ readonly source: typeof expansionSource; readonly paths: Set<string> }>({ source: null, paths: new Set() })
871
+ useLayoutEffect(() => { latest.current = expansionSource }, [expansionSource])
706
872
  const [revealed, setRevealed] = useState<ReadonlySet<string>>(new Set())
707
873
  // The line budget counts the files not marked viewed when the diff loads, so later marks leave it unchanged. A file stays
708
874
  // collapsed while it is marked viewed unless the reader expands it; a file whose change differs from its mark expands
@@ -728,11 +894,12 @@ export function ChangesTab({
728
894
  const jumpPosition = useRef<{ readonly data: ChangesData; readonly top: number } | null>(null)
729
895
  useLayoutEffect(() => {
730
896
  if (!tab.visible || wanted === null || data === null) return
731
- // A file the lens or the test switch hides is shown before the view scrolls to it.
732
- const hidden = allFiles.find(file => file.path === wanted.path && !shownBy(file, lens, hideTests))
897
+ // A file the layer, the test switch, or the filter lens hides is shown before the view scrolls to it.
898
+ const hidden = allFiles.find(file => file.path === wanted.path && !shownBy(file, lens, hideTests, kept))
733
899
  if (hidden !== undefined) {
734
900
  if (lens !== 'all') actions.lensed(tab.id, 'all')
735
901
  if (hideTests && hidden.layer === 'test') actions.toggledTests(tab.id)
902
+ if (kept !== null && !Object.hasOwn(kept, hidden.path)) actions.filtered(tab.id, null)
736
903
  return
737
904
  }
738
905
  // The browser's scroll anchoring keeps the section in place while the sections above it draw their lines.
@@ -750,7 +917,7 @@ export function ChangesTab({
750
917
  }
751
918
  if (scrollport.current !== null) jumpPosition.current = { data, top: scrollport.current.scrollTop }
752
919
  setWanted(null)
753
- }, [tab.visible, wanted, data, allFiles, lens, hideTests, actions, tab.id])
920
+ }, [tab.visible, wanted, data, allFiles, lens, hideTests, kept, actions, tab.id])
754
921
  const refresh = (): void => { setAttempt(value => value + 1) }
755
922
  const root = state !== null && state.checkout.state === 'ready' ? state.checkout.checkout.root : null
756
923
  // A chosen base branch that is gone or shares no history with HEAD offers the automatic fork point instead.
@@ -766,40 +933,56 @@ export function ChangesTab({
766
933
  <Button size="sm" variant="outline" onClick={() => { actions.committed(tab.id, null) }}>{t('commits.showAll')}</Button>
767
934
  )
768
935
 
769
- /** Apply a change to the unchanged lines of `owner`, unless newer changes replaced it. */
770
- const update = (owner: ChangesData, change: (value: Expansion) => Expansion): void => {
936
+ const update = (change: (value: Expansion) => Expansion): void => {
771
937
  setExpansion((previous) => {
772
- if (latest.current !== owner) return previous
773
- return change(previous.data === owner ? previous : { data: owner, texts: {}, open: {} })
938
+ if (latest.current !== expansionSource) return previous
939
+ return change(previous.source === expansionSource ? previous : { source: expansionSource, texts: {}, open: {} })
774
940
  })
775
941
  }
776
- const expand = (owner: ChangesData, file: ForgeDiffFile, index: number): void => {
942
+ const expand = (owner: ChangesData, file: ForgeDiffFile, index: number, expansion: GapExpansion): void => {
777
943
  const path = file.path
778
- update(owner, value => ({ ...value, open: { ...value.open, [path]: new Set([...value.open[path] ?? [], index]) } }))
944
+ update(value => ({ ...value, open: { ...value.open, [path]: revealGap(value.open[path], index, expansion) } }))
779
945
  if (current.texts[path] !== undefined) return
780
- update(owner, value => ({ ...value, texts: { ...value.texts, [path]: 'loading' } }))
946
+ update(value => ({ ...value, texts: { ...value.texts, [path]: 'loading' } }))
781
947
  const reading = owner.kind === 'local' ? localText(owner.scope, path) : changeRequestText(owner.url, owner.headSha, path)
782
948
  void reading.then((result) => {
783
949
  const lines = result.ok ? textLines(result.value) : undefined
784
950
  if (lines !== undefined && matchesHunks(lines, file.hunks)) {
785
- update(owner, value => ({ ...value, texts: { ...value.texts, [path]: lines } }))
951
+ update(value => ({ ...value, texts: { ...value.texts, [path]: lines } }))
786
952
  return
787
953
  }
788
954
  if (result.ok) report('toast.expandStale')
789
- else report('toast.expandFailed', { message: result.error.message })
790
- update(owner, (value) => {
955
+ else report('toast.expandFailed', { params: { message: result.error.message } })
956
+ update((value) => {
791
957
  const { [path]: _text, ...texts } = value.texts
792
958
  const { [path]: _open, ...open } = value.open
793
959
  return { ...value, texts, open }
794
960
  })
795
961
  })
796
962
  }
963
+ /**
964
+ * Read a local file's new side ahead of any expansion, once per comparison, so its rows can be highlighted with the
965
+ * lines before them. A change request's files are not read for this, since each read costs a request to the code host.
966
+ */
967
+ const readContext = (owner: ChangesData, file: ForgeDiffFile): void => {
968
+ const path = file.path
969
+ if (owner.kind !== 'local') return
970
+ if (contextReads.current.source !== expansionSource) contextReads.current = { source: expansionSource, paths: new Set() }
971
+ if (contextReads.current.paths.has(path)) return
972
+ contextReads.current.paths.add(path)
973
+ void localText(owner.scope, path).then((result) => {
974
+ const lines = result.ok ? textLines(result.value) : undefined
975
+ // A read that fails or no longer matches leaves the file as it is, and an expansion reads it again and says why.
976
+ if (lines === undefined || !matchesHunks(lines, file.hunks)) return
977
+ update(value => value.texts[path] !== undefined ? value : { ...value, texts: { ...value.texts, [path]: lines } })
978
+ })
979
+ }
797
980
  const fileActions = (owner: ChangesData, file: ForgeDiffFile): DiffFileAction[] => {
798
981
  const list: DiffFileAction[] = [{ label: 'diff.copyPath', run: () => { copyPath(file.path) } }]
799
982
  if (file.status === 'deleted') return list
800
983
  if (owner.kind === 'local') {
801
- if (root !== null) {
802
- list.push({ label: 'diff.openFileInSidebar', run: () => { tab.actions.openResource(fileAddressFor(sessionId, undefined, `${root}/${file.path}`)) } })
984
+ if (root !== null && openFile !== undefined) {
985
+ list.push({ label: 'diff.openFileInSidebar', run: () => { openFile(`${root}/${file.path}`) } })
803
986
  }
804
987
  } else {
805
988
  const url = owner.fileUrls[file.path]
@@ -812,8 +995,6 @@ export function ChangesTab({
812
995
  // the code host is submitted or discarded there; without one, the summary and any comment drafts kept in the browser
813
996
  // are published as one review.
814
997
  const pendingReview = review?.pendingReview ?? null
815
- // Logins compare without case, as GitHub's do.
816
- const ownChangeRequest = review?.viewer != null && prAuthor !== null && review.viewer.toLowerCase() === prAuthor.toLowerCase()
817
998
  const finishWrite = async (send: () => Promise<string | undefined>, done: ForgePanelKey): Promise<void> => {
818
999
  if (reviewRunning.current) return
819
1000
  reviewRunning.current = true
@@ -825,7 +1006,7 @@ export function ChangesTab({
825
1006
  setReviewError(failure)
826
1007
  return
827
1008
  }
828
- report(done)
1009
+ report(done, { tone: 'success' })
829
1010
  setReviewOpen(false)
830
1011
  } finally {
831
1012
  reviewRunning.current = false
@@ -833,7 +1014,8 @@ export function ChangesTab({
833
1014
  }
834
1015
  }
835
1016
  const reviewForm = tab.visible && data !== null && reviewOpen && data.kind === 'change' && data.commits === null && <SubmitReview queue={queue}
836
- url={data.url} headSha={data.headSha} pending={pendingReview} own={ownChangeRequest} busy={reviewBusy} error={reviewError}
1017
+ url={data.url} headSha={data.headSha} pending={pendingReview} events={review?.reviewEvents ?? null} busy={reviewBusy}
1018
+ error={reviewError}
837
1019
  close={() => { setReviewOpen(false) }}
838
1020
  check={() => { openLink(data.url) }} reconcile={() => { queue.finish(false); setReviewError(null) }}
839
1021
  submit={() => {
@@ -870,11 +1052,15 @@ export function ChangesTab({
870
1052
  return writeReview(selection.source.url, { kind: 'add-pending', headSha: selection.source.headSha, comment: { path, side, startLine, endLine, body } })
871
1053
  }
872
1054
 
1055
+ /** Report a reference or receipt removed from the view and offer to put it back where it was. */
1056
+ const reportRemoved = (removed: RemovedRecord): void => {
1057
+ report('review.recordRemoved', { tone: 'success', undo: () => { if (!queue.restoreRecord(removed)) report('toast.undoFailed') } })
1058
+ }
873
1059
  const recordActions: ReviewActions = {
874
1060
  source: shownSource ?? (source.kind === 'local'
875
1061
  ? { kind: 'local', scope, base: null, baseRef: baseRefOf(localScope), commits: commitsOf(localScope) }
876
1062
  : { kind: 'change', url: source.url, headSha: '', commits: changeCommits }),
877
- records: queue, addToInput: addReviewToInput, openLink,
1063
+ records: queue, addToInput: addReviewToInput, openLink, quoteCopy, onRemoved: reportRemoved,
878
1064
  }
879
1065
  const absentPaths = [...new Set([...reviewState.comments, ...reviewState.records.map(item => item.selection)]
880
1066
  .filter(item => sameReviewSource(item.source, recordActions.source)).map(item => item.comment.path))]
@@ -887,16 +1073,17 @@ export function ChangesTab({
887
1073
  const threadActions = useMemo((): ThreadActions | null => review === null || url === null ? null : {
888
1074
  author: prAuthor,
889
1075
  addToInput: (thread, range) => addThreadToInput(thread, url, range),
1076
+ quoteCopy,
890
1077
  openLink,
891
1078
  readText: (commit, path) => changeRequestText(url, commit, path),
892
- inputFailed: () => { live.current.report('thread.inputFailed') },
1079
+ inputFailed: () => { live.current.report(quoteCopy?.failed ?? 'thread.inputFailed') },
893
1080
  focused: focus,
894
1081
  writes: {
895
1082
  write: (write: ThreadWrite) => live.current.writeReview(url, { ...write, headSha: review.headSha }),
896
1083
  reviewStarted: review.pendingReview !== null,
897
1084
  canReview: review.viewerCanReview,
898
1085
  },
899
- }, [review, url, prAuthor, addThreadToInput, openLink, changeRequestText, focus])
1086
+ }, [review, url, prAuthor, addThreadToInput, quoteCopy, openLink, changeRequestText, focus])
900
1087
  const fileThreads = useMemo(() => new Map<string, FileThreads>(threadActions === null ? []
901
1088
  : [...placed.files].map(([path, group]) => [path, { ...group, actions: threadActions }])), [placed.files, threadActions])
902
1089
  /** Show a file's next unresolved thread in display order after the one last shown, or its first. */
@@ -1010,7 +1197,8 @@ export function ChangesTab({
1010
1197
  // an effect would hand them the previous diff's links. A render React discards leaves values derived from the same
1011
1198
  // props and state, which the retried render assigns again.
1012
1199
  const callbacks = {
1013
- data, expandedByDefault, expand, markViewed, fileActions, publishReview, writeReview, addPending, report, nextThread, t,
1200
+ data, expandedByDefault, expand, readContext, markViewed, fileActions, publishReview, writeReview, addPending, report, nextThread,
1201
+ lensTitle, renderSlot, kept, reportRemoved, t,
1014
1202
  }
1015
1203
  const live = useRef(callbacks)
1016
1204
  live.current = callbacks
@@ -1020,10 +1208,15 @@ export function ChangesTab({
1020
1208
  setChosen(value => ({ ...value, [file.path]: !(value[file.path] ?? byDefault) }))
1021
1209
  },
1022
1210
  reveal: (path) => { setRevealed(value => new Set([...value, path])) },
1023
- expand: (file, index) => {
1211
+ expand: (file, index, expansion) => {
1024
1212
  const { data: owner, expand: open } = live.current
1025
1213
  /* v8 ignore next -- sections render only while changes are loaded */
1026
- if (owner !== null) open(owner, file, index)
1214
+ if (owner !== null) open(owner, file, index, expansion)
1215
+ },
1216
+ readContext: (file) => {
1217
+ const { data: owner, readContext: read } = live.current
1218
+ /* v8 ignore next -- sections render only while changes are loaded */
1219
+ if (owner !== null) read(owner, file)
1027
1220
  },
1028
1221
  view: (file, viewed) => {
1029
1222
  const { data: owner, markViewed: mark } = live.current
@@ -1041,20 +1234,30 @@ export function ChangesTab({
1041
1234
  },
1042
1235
  nextThread: (path) => { live.current.nextThread(path) },
1043
1236
  reach,
1044
- }), [reach])
1237
+ annotation: (path, item: SourcedAnnotation) => target === null ? null : live.current.renderSlot('forge.diff.line.annotation',
1238
+ { target, path, annotation: item.annotation }, { entryKey: item.source }),
1239
+ fileMenu: (file, dismiss) => target === null ? null : live.current.renderSlot('forge.changes.file.menu', { target, file, dismiss }),
1240
+ unfold: (path) => {
1241
+ const { kept: current } = live.current
1242
+ setUnfolded(value => ({ kept: current, paths: new Set([...(value.kept === current ? value.paths : []), path]) }))
1243
+ },
1244
+ }), [reach, target])
1045
1245
  const reviewStarted = pendingReview !== null
1046
1246
  const publishingBlocked = reviewState.uncertain !== null
1047
- // Comments on a commit range or on local changes go to the input only; a whole change request also takes GitHub comments:
1048
- // into its pending review once the threads say the user may review, and on their own while the user has no pending
1049
- // review, since GitHub refuses a single comment beside one.
1247
+ // Comments on a commit range or on local changes go to the input only; a whole change request also takes comments on the
1248
+ // code host: into its pending review once the threads say the user may review, and on their own while the user has no
1249
+ // pending review, since GitHub refuses a single comment beside one and the view keeps one rule for every host.
1050
1250
  const whole = data?.kind === 'change' && data.commits === null
1051
1251
  const queueable = whole && review?.viewerCanReview === true
1052
1252
  const single = whole && pendingReview === null
1053
1253
  const fileReview = useMemo((): ReviewActions | undefined => shownSource === null ? undefined : {
1054
1254
  source: shownSource,
1055
1255
  addToInput: addReviewToInput,
1256
+ quoteCopy,
1257
+ renderActions: owner => target === null ? null : live.current.renderSlot('forge.diff.comment.actions', { target, ...owner }),
1056
1258
  records: queue, openLink, reviewStarted,
1057
1259
  onQuoted: (selection) => { if (!queue.recordAgent(selection)) live.current.report('review.saveFailed') },
1260
+ onRemoved: (removed) => { live.current.reportRemoved(removed) },
1058
1261
  publishingBlocked,
1059
1262
  ...queueable ? { queue: (selection: ReviewSelection) => live.current.addPending(selection) } : {},
1060
1263
  ...single ? {
@@ -1063,7 +1266,7 @@ export function ChangesTab({
1063
1266
  url => queue.published(selection, url))
1064
1267
  : Promise.resolve(live.current.t('review.stale')),
1065
1268
  } : {},
1066
- }, [shownSource, addReviewToInput, queue, openLink, reviewStarted, publishingBlocked, queueable, single])
1269
+ }, [shownSource, addReviewToInput, quoteCopy, queue, openLink, reviewStarted, publishingBlocked, queueable, single, target])
1067
1270
 
1068
1271
  let body: ReactNode
1069
1272
  if (data === null) {
@@ -1075,7 +1278,7 @@ export function ChangesTab({
1075
1278
  </div>
1076
1279
  )
1077
1280
  } else if (failed === null) {
1078
- body = <div className={css.centered}><StateDot state="ongoing" /></div>
1281
+ body = <div className={css.files} aria-busy="true"><ChangesLoading split={split} t={t} /></div>
1079
1282
  } else {
1080
1283
  body = (
1081
1284
  <div className={css.centered} role="status">
@@ -1121,6 +1324,9 @@ export function ChangesTab({
1121
1324
  badge={badgeOf(file, data, t)}
1122
1325
  tooltip={pathTooltipOf(file, t)}
1123
1326
  threads={fileThreads.get(path)}
1327
+ annotations={annotations.get(path)}
1328
+ annotationLimit={annotationLimit}
1329
+ folded={folds.get(path)}
1124
1330
  drawNow={wanted !== null && wanted.center !== null && wanted.path === path}
1125
1331
  viewed={viewedStateOf(marks, path, file.digest)}
1126
1332
  viewedNote={host === null ? t('viewed.hint') : host.unavailable ? t('viewed.unavailable')
@@ -1136,7 +1342,7 @@ export function ChangesTab({
1136
1342
  )
1137
1343
  }
1138
1344
  const navigator: ChangedFilesProps = {
1139
- files, state: treeState, t,
1345
+ files, state: treeState, t, viewed: viewedPaths,
1140
1346
  filter: (query) => { setTreeState(value => ({ ...value, query })) },
1141
1347
  toggle: (path) => { setTreeState(value => ({ ...value, collapsed: { ...value.collapsed, [path]: value.collapsed[path] !== true } })) },
1142
1348
  jump,
@@ -1183,17 +1389,26 @@ export function ChangesTab({
1183
1389
  {!reviewOpen && reviewError !== null && reviewState.uncertain === null && <Notice>{reviewError}</Notice>}
1184
1390
  <div className={css.toolbar} data-tree={treeShown ? treePosition : 'hidden'} style={toolbarStyle}>
1185
1391
  {/* Above the file tree, the lens spans the tree's width; elsewhere a menu in the toolbar takes its place. */}
1186
- {treeShown && <div className={css.lensCell}><LensControl {...lensProps} /></div>}
1392
+ {treeShown && <div className={css.lensCell}><LensControl {...lensProps} need={setLensWidth} /></div>}
1187
1393
  <div ref={toolbarRow} className={css.toolbarMain}>
1188
1394
  {tab.visible && source.kind === 'local' && <ScopeMenu scope={scope} choose={(next) => { actions.scoped(tab.id, next) }} t={t} />}
1189
- {tab.visible && <span className={css.filesSlot}><ChangedFilesMenu {...navigator} visible /></span>}
1395
+ {tab.visible && (
1396
+ <span className={css.filesSlot}><ChangedFilesMenu {...navigator} loading={data === null && failed === null} visible /></span>
1397
+ )}
1190
1398
  {tab.visible && allFiles.length > 0 && (
1191
1399
  <span className={css.lensMenu}><LensMenu {...lensProps} visible /></span>
1192
1400
  )}
1193
1401
  {allFiles.length > 0 && <span className={css.foldTests}>
1194
1402
  <HideTestsSwitch hidden={hideTests} toggle={toggleTests} t={t} />
1195
1403
  </span>}
1404
+ {tab.visible && allFiles.length > 0 && lensChoices.length > 0 && (
1405
+ // A chosen lens stays in the row, where it says what the files are filtered by.
1406
+ <span className={activeLens === null ? css.foldTests : css.lensSlot}>
1407
+ <LensFilterMenu lenses={lensChoices} chosen={chosenChoice} run={lensRun.run} choose={chooseLens} visible t={t} />
1408
+ </span>
1409
+ )}
1196
1410
  <span className={css.spacer} data-fold-spacer="" />
1411
+ <span className={css.foldPlugins}>{target !== null && renderSlot('forge.changes.toolbar', { target, form: 'bar', close: noop })}</span>
1197
1412
  {/* A truncated read keeps the list, whose footer says so, even when it kept no thread. */}
1198
1413
  {review !== null && (review.threads.length > 0 || review.truncated) && (
1199
1414
  <button ref={threadsToggle} type="button" className={css.threadsToggle} aria-pressed={threadList.open} data-forge-threads-toggle=""
@@ -1207,31 +1422,31 @@ export function ChangesTab({
1207
1422
  <span className={clsx(css.totals, css.foldViews)}><Counts file={{ additions, deletions, binary: false }} t={t} /></span>
1208
1423
  )}
1209
1424
  <span className={css.tools}>
1210
- <Tooltip label={t('diff.refresh')} side="bottom">
1425
+ <Tooltip label={t('diff.refresh')} side="bottom" delayMs={500}>
1211
1426
  <button type="button" className={clsx(css.tool, css.foldRefresh)} aria-label={t('diff.refresh')} onClick={refresh}>
1212
1427
  <RefreshGlyph busy={rereading} size={16} />
1213
1428
  </button>
1214
1429
  </Tooltip>
1215
- <Tooltip label={expansionLabel} side="bottom">
1430
+ <Tooltip label={expansionLabel} side="bottom" delayMs={500}>
1216
1431
  <button type="button" className={clsx(css.tool, css.foldViews)} data-expanded={anyExpanded ? '' : undefined} aria-label={expansionLabel}
1217
1432
  disabled={files.length === 0} onClick={toggleExpansion}>
1218
1433
  <IconChevronsUpDownOutlineRegular />
1219
1434
  </button>
1220
1435
  </Tooltip>
1221
- <Tooltip label={t(split ? 'diff.unified' : 'diff.split')} side="bottom">
1436
+ <Tooltip label={t(split ? 'diff.unified' : 'diff.split')} side="bottom" delayMs={500}>
1222
1437
  <button type="button" className={clsx(css.tool, css.foldViews)} aria-pressed={split} aria-label={t('diff.splitAria')}
1223
1438
  onClick={toggleSplit}>
1224
1439
  <IconCompareSplitOutlineRegular className={css.compareIcon} />
1225
1440
  </button>
1226
1441
  </Tooltip>
1227
- <Tooltip label={t(wrap ? 'diff.nowrap' : 'diff.wrap')} side="bottom">
1442
+ <Tooltip label={t(wrap ? 'diff.nowrap' : 'diff.wrap')} side="bottom" delayMs={500}>
1228
1443
  <button type="button" className={clsx(css.tool, css.foldViews)} aria-pressed={wrap} aria-label={t('diff.wrapAria')}
1229
1444
  onClick={toggleWrap}>
1230
1445
  {wrap ? <IconNowrapFillRegular /> : <IconWrapFillRegular />}
1231
1446
  </button>
1232
1447
  </Tooltip>
1233
1448
  <span className={css.treeToggle}>
1234
- <Tooltip label={treeAction} side="bottom">
1449
+ <Tooltip label={treeAction} side="bottom" delayMs={500}>
1235
1450
  <button type="button" className={css.tool} aria-label={treeAction} aria-expanded={treePosition !== 'hidden'}
1236
1451
  aria-controls={treeId} disabled={allFiles.length === 0}
1237
1452
  onClick={() => { setTreePosition(value => value === 'left' ? 'right' : value === 'right' ? 'hidden' : 'left') }}>
@@ -1242,6 +1457,8 @@ export function ChangesTab({
1242
1457
  <ViewOptionsMenu visible={tab.visible} options={{
1243
1458
  anyExpanded, hasFiles: files.length > 0, toggleExpansion, split, toggleSplit, wrap, toggleWrap,
1244
1459
  hideTests: allFiles.length > 0 ? hideTests : undefined, toggleTests, refresh,
1460
+ lenses: allFiles.length > 0 && activeLens === null ? lensChoices : [], chooseLens,
1461
+ plugins: close => target === null ? null : renderSlot('forge.changes.toolbar', { target, form: 'menu', close }),
1245
1462
  }} t={t} />
1246
1463
  </span>
1247
1464
  </div>
@@ -1257,6 +1474,18 @@ export function ChangesTab({
1257
1474
  <Notice>{t('diff.stale', { count: data.localAhead })}</Notice>
1258
1475
  )}
1259
1476
  {data?.kind === 'local' && data.omitted > 0 && <Notice>{t('diff.omitted', { count: data.omitted })}</Notice>}
1477
+ {lensRun.run.kind === 'failed' && chosenChoice !== null && (
1478
+ <Notice action={<span className={css.noticeAction}>
1479
+ {lensRun.run.code === 'forgePanel/lens-stale'
1480
+ ? <Button size="sm" variant="outline" onClick={refresh}>{t('diff.refresh')}</Button>
1481
+ : <Button size="sm" variant="outline" onClick={() => { setLensAttempt(value => value + 1) }}>{t('retry')}</Button>}
1482
+ <Button size="sm" variant="outline" onClick={() => { chooseLens(null) }}>{t('filterLens.clear')}</Button>
1483
+ </span>}>
1484
+ {lensRun.run.code === 'forgePanel/lens-stale' ? t('filterLens.stale', { lens: chosenChoice.title })
1485
+ : lensRun.run.code === 'forgePanel/lens-interrupted' ? t('filterLens.interrupted', { lens: chosenChoice.title })
1486
+ : t('filterLens.failed', { lens: chosenChoice.title, message: lensRun.run.message })}
1487
+ </Notice>
1488
+ )}
1260
1489
  {data?.kind === 'change' && data.viewed?.kind === 'failed' && (
1261
1490
  <Notice action={<Button size="sm" variant="outline" className={css.noticeAction} onClick={refresh}>{t('retry')}</Button>}>
1262
1491
  {t('viewed.readFailed', { message: data.viewed.message })}
@@ -1270,7 +1499,9 @@ export function ChangesTab({
1270
1499
  {reviewForm}
1271
1500
  <div className={css.body}>
1272
1501
  {body}
1273
- {allFiles.length > 0 && <FileTreePane {...navigator} id={treeId} position={treePosition} onWidth={setTreeWidth} />}
1502
+ {allFiles.length > 0 && (
1503
+ <FileTreePane {...navigator} id={treeId} position={treePosition} least={lensWidth} onWidth={setTreeWidth} />
1504
+ )}
1274
1505
  {review !== null && data?.kind === 'change' && threadList.open && (
1275
1506
  <ThreadList entries={placed.entries} files={allFiles} truncated={review.truncated} url={data.url}
1276
1507
  filter={threadList.filter} choose={(filter) => { setThreadList(value => ({ ...value, filter })) }}