@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
@@ -46,6 +46,27 @@
46
46
  padding-right: 4px;
47
47
  }
48
48
 
49
+ /* A chosen name leads; the base after it gives way first. */
50
+ .named {
51
+ max-width: 280px;
52
+ }
53
+
54
+ .nameLabel {
55
+ flex: 0 1 auto;
56
+ min-width: 4em;
57
+ overflow: hidden;
58
+ color: var(--dsw-alias-label-primary);
59
+ text-overflow: ellipsis;
60
+ }
61
+
62
+ .fromLabel {
63
+ flex: 0 100 auto;
64
+ min-width: 0;
65
+ overflow: hidden;
66
+ color: var(--dsw-alias-label-tertiary);
67
+ text-overflow: ellipsis;
68
+ }
69
+
49
70
  .current {
50
71
  box-sizing: content-box;
51
72
  max-width: 200px;
@@ -96,26 +117,116 @@
96
117
  transform: rotate(180deg);
97
118
  }
98
119
 
99
- .option {
100
- display: inline-flex;
120
+ /* The base menu: the changes view's BaseMenu rows and labels, and the label of the footer row that names the branch. */
121
+ .anchor {
122
+ flex: none;
123
+ min-width: 0;
124
+ }
125
+
126
+ .menu {
127
+ width: min(360px, calc(100vw - 24px));
128
+ }
129
+
130
+ .menuRoot {
131
+ display: flex;
132
+ flex-direction: column;
133
+ box-sizing: border-box;
134
+ width: 100%;
135
+ min-width: 0;
136
+ min-height: 0;
137
+ color: var(--dsw-alias-label-primary);
138
+ font-size: 12px;
139
+ }
140
+
141
+ .rows {
142
+ max-height: 300px;
143
+ overflow: auto;
144
+ padding: 0 0 2px;
145
+ }
146
+
147
+ .groupLabel {
148
+ display: flex;
101
149
  align-items: baseline;
102
150
  gap: 8px;
103
151
  min-width: 0;
152
+ padding: 6px 8px 4px;
153
+ color: var(--dsw-alias-label-tertiary);
154
+ font-size: 11px;
155
+ line-height: 15px;
156
+ }
157
+
158
+ .groupName {
159
+ flex: none;
160
+ }
161
+
162
+ .groupRepository {
163
+ min-width: 0;
164
+ margin-left: auto;
165
+ overflow: hidden;
166
+ font-family: var(--ds-font-family-code);
167
+ text-overflow: ellipsis;
168
+ white-space: nowrap;
169
+ }
170
+
171
+ .option {
172
+ display: flex;
173
+ flex: 1;
174
+ align-items: center;
175
+ gap: 8px;
176
+ min-width: 0;
104
177
  }
105
178
 
106
179
  .optionName {
107
180
  min-width: 0;
108
181
  overflow: hidden;
109
182
  font-family: var(--ds-font-family-code);
110
- font-size: 12px;
111
183
  text-overflow: ellipsis;
112
184
  white-space: nowrap;
113
185
  }
114
186
 
115
- .optionNote {
187
+ .remotePrefix {
188
+ color: var(--dsw-alias-label-tertiary);
189
+ }
190
+
191
+ .tag {
116
192
  flex: none;
193
+ padding: 0 5px;
194
+ border-radius: var(--dsw-radius-xs);
195
+ background: var(--dsw-alias-interactive-bg-hover);
196
+ color: var(--dsw-alias-label-secondary);
197
+ font-size: 11px;
198
+ line-height: 16px;
199
+ }
200
+
201
+ .check {
202
+ flex: none;
203
+ margin-left: auto;
204
+ color: var(--dsw-alias-state-business-primary);
205
+ }
206
+
207
+ .status {
208
+ display: flex;
209
+ align-items: center;
210
+ gap: 8px;
211
+ padding: 12px 8px;
212
+ color: var(--dsw-alias-label-secondary);
213
+ }
214
+
215
+ .footerLabel {
216
+ flex: none;
217
+ }
218
+
219
+ .footerValue {
220
+ min-width: 0;
221
+ margin-left: auto;
222
+ overflow: hidden;
117
223
  color: var(--dsw-alias-label-tertiary);
118
- font-size: 12px;
224
+ text-overflow: ellipsis;
225
+ white-space: nowrap;
226
+ }
227
+
228
+ .footerName {
229
+ font-family: var(--ds-font-family-code);
119
230
  }
120
231
 
121
232
  @media (max-width: 600px) {
@@ -126,7 +237,12 @@
126
237
  }
127
238
 
128
239
  .base,
240
+ .named,
129
241
  .current {
130
242
  max-width: 120px;
131
243
  }
244
+
245
+ .fromLabel {
246
+ display: none;
247
+ }
132
248
  }
@@ -1,14 +1,20 @@
1
- /** New Session option: start the Session in a new worktree, from a chosen local branch. */
1
+ /** New Session option: start the Session in a new worktree, on a chosen or generated branch, from a local or remote branch. */
2
2
 
3
3
  import { useState, type ReactNode } from 'react'
4
4
  import clsx from 'clsx'
5
- import { IconBranchOutlineRegular, IconChevronDownOutlineRegular, Menu, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'
6
- import type { MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives'
5
+ import {
6
+ IconBranchOutlineRegular, IconCheckOutlineRegular, IconChevronDownOutlineRegular, IconEditOutlineRegular, IconPlusOutlineRegular,
7
+ Menu, MenuItemButton, Tooltip,
8
+ } from '@deepseek-ai/dsh-client-ui-primitives'
7
9
  import type { HostObservable, InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
8
10
  import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
9
- import type { ForgeBranches, ForgePanelState, ForgeWorktreeBlocker } from '../types.ts'
11
+ import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
12
+ import { branchLabel, LOCAL_REF_PREFIX, REMOTE_REF_PREFIX } from '../branch-name.ts'
13
+ import type { ForgeBaseBranch, ForgePanelState, ForgeWorktreeBases, ForgeWorktreeBlocker } from '../types.ts'
14
+ import { branchSearchStatus, useBranchSearch } from './branch-search.tsx'
10
15
  import type { NS } from './locales.ts'
11
16
  import type { PanelSnapshot } from './source.ts'
17
+ import { WorktreeNameDialog, type WorktreeRequestResult } from './WorktreeNameDialog.tsx'
12
18
  import css from './WorktreeToggle.module.css'
13
19
 
14
20
  /** Business face of the New Session option. */
@@ -16,21 +22,24 @@ export interface WorktreeToggleInjected {
16
22
  /** Panel snapshot of the Session; the renderer binds it as `usePanel`. */
17
23
  readonly hooks: { readonly panel: HostObservable<PanelSnapshot> }
18
24
  /**
19
- * Request a worktree from a base branch, replacing an open request.
20
- * @param from - base branch, or null for HEAD.
21
- * @returns whether the Host accepted it.
25
+ * Request a worktree from a base on a branch name, replacing an open request.
26
+ * @param from - full name of a local or remote-tracking base branch, or null for HEAD.
27
+ * @param name - new branch name, or null for a generated one.
28
+ * @returns the outcome; a failure other than a refused name is already reported.
22
29
  */
23
- readonly request: (from: string | null) => Promise<boolean>
30
+ readonly request: (from: string | null, name: string | null) => Promise<WorktreeRequestResult>
24
31
  /**
25
32
  * Withdraw the open request.
26
33
  * @returns whether the Host accepted it.
27
34
  */
28
35
  readonly cancel: () => Promise<boolean>
29
36
  /**
30
- * List the local branches of the Session's checkout.
31
- * @returns the branches, or undefined when they could not be read.
37
+ * List the branches a worktree of the Session's checkout can start from whose names contain `query`.
38
+ * @param query - search text; empty for every branch.
39
+ * @param signal - aborts the read.
40
+ * @returns the branches, or the failure the menu shows.
32
41
  */
33
- readonly branches: () => Promise<ForgeBranches | undefined>
42
+ readonly bases: (query: string, signal: AbortSignal) => Promise<RemoteResult<ForgeWorktreeBases>>
34
43
  }
35
44
 
36
45
  /** Full props of the New Session option. */
@@ -38,59 +47,156 @@ export type WorktreeToggleProps = InjectFace<WorktreeToggleInjected> & PropsLoca
38
47
 
39
48
  type Translate = WorktreeToggleProps['t']
40
49
 
41
- function BaseMenu({ base, held, branches, request, t }: {
42
- readonly base: string | null
43
- /** Whether the worktree is being created, which freezes the base. */
50
+ /** One selectable branch row: the branch, the remote it belongs to, and the tag that names a pinned row. */
51
+ interface BaseRow {
52
+ readonly branch: ForgeBaseBranch
53
+ readonly remote?: string
54
+ readonly tag?: string
55
+ }
56
+
57
+ /** What the option says about a request's base. */
58
+ function baseTextOf(from: string | null, t: Translate): string {
59
+ return from === null ? t('worktree.baseHead') : t('worktree.base', { branch: branchLabel(from) })
60
+ }
61
+
62
+ /** What the option says about a request that names its branch. */
63
+ function namedTipOf(name: string, from: string | null, t: Translate): string {
64
+ return from === null ? t('worktree.namedTipHead', { name }) : t('worktree.namedTip', { name, branch: branchLabel(from) })
65
+ }
66
+
67
+ /** The full name of a request's base; earlier panels recorded local branches by their short names. */
68
+ function refOf(from: string | null): string | null {
69
+ return from === null || from.startsWith('refs/') ? from : `${LOCAL_REF_PREFIX}${from}`
70
+ }
71
+
72
+ /** A branch name split into a remote's prefix and the rest; local branches have no prefix. */
73
+ function nameParts(branch: ForgeBaseBranch, remote: string | undefined): { readonly prefix: string; readonly rest: string } {
74
+ return remote !== undefined && branch.ref.startsWith(REMOTE_REF_PREFIX)
75
+ ? { prefix: `${remote}/`, rest: branch.name.slice(remote.length + 1) }
76
+ : { prefix: '', rest: branch.name }
77
+ }
78
+
79
+ /** Id of the footer row that opens the naming dialog. */
80
+ const NAME_ENTRY = 'name'
81
+
82
+ function BranchRows({ rows, chosen, pick }: {
83
+ readonly rows: readonly BaseRow[]
84
+ readonly chosen: string | null
85
+ readonly pick: (ref: string) => void
86
+ }): ReactNode {
87
+ return rows.map(({ branch, remote, tag }) => {
88
+ const selected = branch.ref === chosen
89
+ const parts = nameParts(branch, remote)
90
+ return (
91
+ <MenuItemButton key={branch.ref} icon={<IconBranchOutlineRegular size={14} />} current={selected}
92
+ onSelect={() => { pick(branch.ref) }}>
93
+ <span className={css.option} data-forge-worktree-base={branch.ref}>
94
+ <span className={css.optionName}>
95
+ {parts.prefix !== '' && <span className={css.remotePrefix}>{parts.prefix}</span>}
96
+ {parts.rest}
97
+ </span>
98
+ {tag !== undefined && <span className={css.tag}>{tag}</span>}
99
+ {selected && <IconCheckOutlineRegular size={14} className={css.check} />}
100
+ </span>
101
+ </MenuItemButton>
102
+ )
103
+ })
104
+ }
105
+
106
+ function WorktreeMenu({ from, name, held, bases, choose, nameBranch, t }: {
107
+ readonly from: string | null
108
+ readonly name: string | null
109
+ /** Whether the worktree is being created, which freezes the request. */
44
110
  readonly held: boolean
45
- readonly branches: WorktreeToggleInjected['branches']
46
- readonly request: WorktreeToggleInjected['request']
111
+ readonly bases: WorktreeToggleInjected['bases']
112
+ readonly choose: (ref: string) => void
113
+ readonly nameBranch: () => void
47
114
  readonly t: Translate
48
115
  }): ReactNode {
49
- const [listed, setListed] = useState<ForgeBranches | null>(null)
50
116
  const [open, setOpen] = useState(false)
51
- const [loading, setLoading] = useState(false)
52
- const show = (): void => {
53
- if (open) {
54
- setOpen(false)
55
- return
56
- }
57
- setLoading(true)
58
- void branches().then((result) => {
59
- setLoading(false)
60
- if (result === undefined) return
61
- setListed(result)
62
- setOpen(true)
63
- })
117
+ const { query, setQuery, listing, retry, reset } = useBranchSearch(open, bases)
118
+ const chosen = refOf(from)
119
+ const close = (): void => {
120
+ setOpen(false)
121
+ reset()
122
+ }
123
+ const pick = (ref: string): void => {
124
+ close()
125
+ if (ref !== chosen) choose(ref)
64
126
  }
65
- const items: MenuEntry[] = [
66
- { type: 'label', id: 'title', text: t('worktree.baseMenu') },
67
- ...(listed?.branches ?? []).map(name => ({
68
- id: name,
69
- label: name === listed?.current
70
- ? <span className={css.option}><span className={css.optionName}>{name}</span><span className={css.optionNote}>{t('worktree.currentBranch')}</span></span>
71
- : <span className={css.optionName}>{name}</span>,
72
- })),
73
- ]
127
+ const value = listing?.ok === true ? listing.value : null
128
+ const needle = query.trim().toLowerCase()
129
+ const matches = (branch: ForgeBaseBranch): boolean => branch.name.toLowerCase().includes(needle)
130
+ const pinned: BaseRow[] = value === null ? [] : [
131
+ ...value.current === null ? [] : [{ branch: value.current, tag: t('worktree.currentBranch') }],
132
+ ...value.defaults.map(({ remote, ...branch }) => ({ branch, remote, tag: t('worktree.remoteDefault') })),
133
+ ].filter(row => matches(row.branch))
134
+ const local = (value?.local ?? []).filter(matches).map(branch => ({ branch }))
135
+ const remotes = (value?.remotes ?? []).map(remote => ({
136
+ ...remote, rows: remote.branches.filter(matches).map(branch => ({ branch, remote: remote.name })),
137
+ }))
138
+ .filter(remote => remote.rows.length > 0)
139
+ const empty = pinned.length === 0 && local.length === 0 && remotes.length === 0
140
+
141
+ const body: ReactNode = branchSearchStatus({ listing, empty, retry, className: css.status, t }) ?? <>
142
+ {pinned.length > 0 && <div role="group" aria-label={t('worktree.pinned')}><BranchRows rows={pinned} chosen={chosen} pick={pick} /></div>}
143
+ {local.length > 0 && (
144
+ <div role="group" aria-label={t('diff.base.local')}>
145
+ <div className={css.groupLabel} role="presentation">{t('diff.base.local')}</div>
146
+ <BranchRows rows={local} chosen={chosen} pick={pick} />
147
+ </div>
148
+ )}
149
+ {remotes.map(remote => (
150
+ <div key={remote.name} role="group" aria-label={t('worktree.remoteGroup', { remote: remote.name })}>
151
+ <div className={css.groupLabel} role="presentation">
152
+ <span className={css.groupName}>{t('worktree.remoteGroup', { remote: remote.name })}</span>
153
+ {remote.repository !== null && <span className={css.groupRepository}>{remote.repository}</span>}
154
+ </div>
155
+ <BranchRows rows={remote.rows} chosen={chosen} pick={pick} />
156
+ </div>
157
+ ))}
158
+ </>
159
+
160
+ const baseText = baseTextOf(from, t)
161
+ const label = name === null ? baseText : namedTipOf(name, from, t)
74
162
  return (
75
163
  <Menu
76
164
  open={open}
77
- items={items}
78
- selectedId={base ?? undefined}
79
- onSelect={(id) => {
80
- setOpen(false)
81
- if (id !== base) void request(id)
82
- }}
83
- onClose={() => { setOpen(false) }}
84
165
  side="bottom"
85
166
  align="end"
86
167
  portal
168
+ dense
169
+ className={css.anchor}
170
+ listClassName={css.menu}
171
+ onClose={close}
172
+ search={{ label: t('diff.base.search'), value: query, onChange: setQuery, skipAutoFocusOnTouch: true }}
173
+ footer={[{
174
+ id: NAME_ENTRY,
175
+ icon: name === null ? <IconPlusOutlineRegular size={14} /> : <IconEditOutlineRegular size={14} />,
176
+ label: (
177
+ <span className={css.option} data-forge-worktree-name-entry="">
178
+ <span className={css.footerLabel}>{t(name === null ? 'worktree.name.add' : 'worktree.name.label')}</span>
179
+ <span className={clsx(css.footerValue, name !== null && css.footerName)}>{name ?? t('worktree.name.auto')}</span>
180
+ </span>
181
+ ),
182
+ }]}
183
+ onSelect={() => { close(); nameBranch() }}
87
184
  anchor={
88
- <button type="button" className={css.base} aria-haspopup="menu" aria-expanded={open} disabled={loading || held} onClick={show}>
89
- <span className={css.baseLabel}>{base === null ? t('worktree.baseHead') : t('worktree.base', { branch: base })}</span>
90
- <IconChevronDownOutlineRegular size={12} className={clsx(css.chevron, open && css.chevronOpen)} />
91
- </button>
185
+ <Tooltip label={label} side="bottom" portal delayMs={500}>
186
+ <button type="button" className={clsx(css.base, name !== null && css.named)} aria-haspopup="menu" aria-expanded={open} aria-label={label}
187
+ data-forge-base-branch="" disabled={held} onClick={() => { if (open) close(); else setOpen(true) }}>
188
+ {name === null
189
+ ? <span className={css.baseLabel}>{baseText}</span>
190
+ : <><span className={css.nameLabel}>{name}</span><span className={css.fromLabel}>{` · ${baseText}`}</span></>}
191
+ <IconChevronDownOutlineRegular size={12} className={clsx(css.chevron, open && css.chevronOpen)} />
192
+ </button>
193
+ </Tooltip>
92
194
  }
93
- />
195
+ >
196
+ <div className={css.menuRoot} data-forge-worktree-menu="">
197
+ <div className={css.rows}>{body}</div>
198
+ </div>
199
+ </Menu>
94
200
  )
95
201
  }
96
202
 
@@ -110,35 +216,42 @@ function optionOf(state: ForgePanelState | null): {
110
216
 
111
217
  /**
112
218
  * Render the worktree option while the Session can still start in a worktree:
113
- * the current branch, or the base branch menu once requested, then the checkbox.
114
- * A blocked request keeps its selected base visible without a menu; the checkbox
115
- * only withdraws it. Branch details support pointer, touch, and keyboard access.
116
- * The request stays fixed while the worktree is being created.
117
- * @param props - panel snapshot hook, request actions, and copy.
219
+ * the current branch, or the base and branch name menu once requested, then the
220
+ * checkbox. The menu searches local branches and each remote's branches and
221
+ * opens the naming dialog. A blocked request keeps its selected base visible
222
+ * without a menu; the checkbox only withdraws it. Branch details support
223
+ * pointer, touch, and keyboard access. The request stays fixed while the
224
+ * worktree is being created.
225
+ * @param props - panel snapshot hook, request actions, the base listing, and copy.
118
226
  * @returns the option, or nothing outside a known Git checkout, once a turn started,
119
227
  * the request settled, or no worktree service is mounted.
120
228
  */
121
- export function WorktreeToggle({ usePanel, request, cancel, branches, t }: WorktreeToggleProps): ReactNode {
229
+ export function WorktreeToggle({ usePanel, request, cancel, bases, t }: WorktreeToggleProps): ReactNode {
122
230
  const state = usePanel(snapshot => snapshot.state)
123
231
  const [pending, setPending] = useState<boolean | null>(null)
232
+ const [naming, setNaming] = useState(false)
124
233
  const option = optionOf(state)
125
234
  if (state === null || option === undefined) return null
126
235
  const held = state.worktree.creation !== null
127
236
  const requested = pending ?? state.worktree.request !== null
128
237
  const usable = option.blocker === null
129
238
  const disabled = held || pending !== null || (!usable && !requested)
239
+ const currentRef = option.current === null ? null : `${LOCAL_REF_PREFIX}${option.current}`
130
240
  const current = option.current ?? (option.commit === null ? t('checkout.detached') : t('worktree.detachedTip', { commit: option.commit }))
131
- const base = state.worktree.request === null ? option.current : state.worktree.request.from
132
- const branchText = requested ? base === null ? t('worktree.baseHead') : t('worktree.base', { branch: base }) : current
241
+ const from = state.worktree.request === null ? currentRef : state.worktree.request.from
242
+ const name = state.worktree.request?.name ?? null
243
+ const requestedText = name === null ? baseTextOf(from, t) : namedTipOf(name, from, t)
244
+ const branchText = requested ? requestedText : current
133
245
  const branchTip = requested || option.current === null ? branchText : t('worktree.currentBranchTip', { branch: option.current })
134
246
  const change = (checked: boolean): void => {
135
247
  setPending(checked)
136
- void (checked ? request(option.current) : cancel()).then(() => { setPending(null) })
248
+ void (checked ? request(currentRef, null) : cancel()).then(() => { setPending(null) })
137
249
  }
138
250
  return (
139
251
  <span className={css.root} data-forge-worktree="">
140
252
  {requested && usable ? (
141
- <BaseMenu base={state.worktree.request?.from ?? option.current} held={held} branches={branches} request={request} t={t} />
253
+ <WorktreeMenu from={from} name={name} held={held} bases={bases} t={t}
254
+ choose={(ref) => { void request(ref, name) }} nameBranch={() => { setNaming(true) }} />
142
255
  ) : (
143
256
  <Tooltip label={branchTip} side="bottom" portal openOnClick>
144
257
  <button type="button" className={css.current} aria-label={branchTip}
@@ -160,6 +273,10 @@ export function WorktreeToggle({ usePanel, request, cancel, branches, t }: Workt
160
273
  {t('worktree.label')}
161
274
  </label>
162
275
  </Tooltip>
276
+ {naming && requested && (
277
+ <WorktreeNameDialog mode="name" initial={name ?? state.worktree.namePrefix} prefix={state.worktree.namePrefix} from={from}
278
+ named={name !== null} submit={next => request(from, next)} close={() => { setNaming(false) }} t={t} />
279
+ )}
163
280
  </span>
164
281
  )
165
282
  }
@@ -0,0 +1,38 @@
1
+ /** Notices that report the outcome of an action on a change request, shared by the Session panel and the review page. */
2
+
3
+ import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
4
+ import type { ForgePanelKey } from './locales.ts'
5
+ import type { NoticeSource } from './source.ts'
6
+ import type { ChangeRequestEntry } from './status.ts'
7
+
8
+ /** Notice keys of one action: success, a head that moved, and any other refusal. */
9
+ export interface ActionNoticeKeys {
10
+ /** Success; its text names the change request as `{name}`. */
11
+ readonly done: ForgePanelKey
12
+ /** The head moved since the action was confirmed, for actions that check it; its text names the change request. */
13
+ readonly stale?: ForgePanelKey
14
+ /** Any other refusal; its text names the code host's reason as `{message}`. */
15
+ readonly failed: ForgePanelKey
16
+ }
17
+
18
+ /** Reports one action's outcome. */
19
+ export type ActionReporter = (
20
+ entry: ChangeRequestEntry, result: RemoteResult<unknown>, keys: ActionNoticeKeys, params?: Readonly<Record<string, string>>,
21
+ ) => void
22
+
23
+ /**
24
+ * Create the reporter of action outcomes. An action whose outcome the code host did not confirm asks the reader to
25
+ * check the change request there.
26
+ * @param notices - the notice store.
27
+ * @param nameOf - how notices name a change request.
28
+ * @returns the reporter.
29
+ */
30
+ export function actionReporter(notices: NoticeSource, nameOf: (entry: ChangeRequestEntry) => string): ActionReporter {
31
+ return (entry, result, keys, params = {}) => {
32
+ const name = nameOf(entry)
33
+ if (result.ok) notices.report(keys.done, { tone: 'success', params: { name, ...params } })
34
+ else if (keys.stale !== undefined && result.error.code === 'forgePanel/stale-head') notices.report(keys.stale, { params: { name } })
35
+ else if (result.error.code === 'forgePanel/action-unknown') notices.report('toast.actionUnknown', { params: { name } })
36
+ else notices.report(keys.failed, { params: { message: result.error.message } })
37
+ }
38
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Line annotations of one changes view: every source's annotations merged by path, and where each one shows in a
3
+ * file's lines.
4
+ */
5
+
6
+ import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots'
7
+ import type { ChangesTarget } from './changes-address.ts'
8
+ import type { ForgeAnnotationSource, ForgeLineAnnotation } from './changes-service.ts'
9
+
10
+ /** One annotation with the source that draws it. */
11
+ export interface SourcedAnnotation {
12
+ /** Identity of the source, the key of its `forge.diff.line.annotation` entry. */
13
+ readonly source: string
14
+ readonly annotation: ForgeLineAnnotation
15
+ }
16
+
17
+ /** Annotations of one view by path, in source order and then each source's order. */
18
+ export type ViewAnnotations = ReadonlyMap<string, readonly SourcedAnnotation[]>
19
+
20
+ const EMPTY: ViewAnnotations = new Map()
21
+
22
+ /** Whether two lists hold the same annotations of the same sources at the same versions in the same order. */
23
+ function sameList(a: readonly SourcedAnnotation[], b: readonly SourcedAnnotation[]): boolean {
24
+ return a.length === b.length && a.every((item, index) => {
25
+ const other = b[index]
26
+ return other !== undefined && item.source === other.source && item.annotation.key === other.annotation.key
27
+ && item.annotation.version === other.annotation.version
28
+ })
29
+ }
30
+
31
+ /**
32
+ * The merged annotations of one view. It observes each registered source while a reader subscribes, starting with
33
+ * the first reader and stopping after the last; a file whose annotations did not change keeps its list, so its section
34
+ * does not draw again.
35
+ */
36
+ export class AnnotationView implements HostObservable<ViewAnnotations> {
37
+ private snapshot: ViewAnnotations = EMPTY
38
+ private readonly listeners = new Set<() => void>()
39
+ /** The followed sources in stacking order, each with its observable for this view and its unsubscribe. */
40
+ private followed: readonly { readonly source: ForgeAnnotationSource; readonly values: ReturnType<ForgeAnnotationSource['observe']>; readonly stop: () => void }[] = []
41
+ private stopSources: (() => void) | undefined
42
+
43
+ /**
44
+ * @param sources - the registered sources.
45
+ * @param target - the view's Session and source.
46
+ */
47
+ constructor(private readonly sources: HostObservable<readonly ForgeAnnotationSource[]>, private readonly target: ChangesTarget) {}
48
+
49
+ readonly getSnapshot = (): ViewAnnotations => this.snapshot
50
+
51
+ readonly subscribe = (listener: () => void): (() => void) => {
52
+ this.listeners.add(listener)
53
+ if (this.listeners.size === 1) {
54
+ this.stopSources = this.sources.subscribe(() => { this.sync() })
55
+ this.sync()
56
+ }
57
+ return () => {
58
+ this.listeners.delete(listener)
59
+ if (this.listeners.size > 0) return
60
+ this.stopSources?.()
61
+ this.stopSources = undefined
62
+ for (const entry of this.followed) entry.stop()
63
+ this.followed = []
64
+ }
65
+ }
66
+
67
+ /** Follow the sources registered now, observing each new one once and releasing each withdrawn one, then merge. */
68
+ private sync(): void {
69
+ const next = this.sources.getSnapshot().map(source => this.followed.find(entry => entry.source === source) ?? this.follow(source))
70
+ for (const entry of this.followed) {
71
+ if (!next.includes(entry)) entry.stop()
72
+ }
73
+ this.followed = next
74
+ this.merge()
75
+ }
76
+
77
+ private follow(source: ForgeAnnotationSource): (typeof this.followed)[number] {
78
+ const values = source.observe(this.target)
79
+ return { source, values, stop: values.subscribe(() => { this.merge() }) }
80
+ }
81
+
82
+ private merge(): void {
83
+ const lists = new Map<string, SourcedAnnotation[]>()
84
+ for (const { source, values } of this.followed) {
85
+ for (const [path, annotations] of values.getSnapshot()) {
86
+ const list = lists.get(path) ?? []
87
+ for (const annotation of annotations) list.push({ source: source.id, annotation })
88
+ if (list.length > 0) lists.set(path, list)
89
+ }
90
+ }
91
+ let changed = lists.size !== this.snapshot.size
92
+ const next = new Map<string, readonly SourcedAnnotation[]>()
93
+ for (const [path, list] of lists) {
94
+ const previous = this.snapshot.get(path)
95
+ if (previous !== undefined && sameList(previous, list)) next.set(path, previous)
96
+ else {
97
+ next.set(path, list)
98
+ changed = true
99
+ }
100
+ }
101
+ if (!changed) return
102
+ this.snapshot = next
103
+ for (const listener of [...this.listeners]) listener()
104
+ }
105
+ }