@kabmo-labs/kabmo 0.11.1 → 0.12.0

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 (324) hide show
  1. package/README.md +67 -421
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +426 -413
  4. package/dist/client/static/js/{index-amss8pge.js → index-0smc9gm2.js} +1123 -747
  5. package/dist/client/static/js/index-shexbk5f.css +1 -0
  6. package/marketplace/marketplace.json +13 -3
  7. package/marketplace/plugins/command-runner/package.json +4 -2
  8. package/marketplace/plugins/git-forge/README.md +219 -0
  9. package/marketplace/plugins/git-forge/icon.svg +20 -0
  10. package/marketplace/plugins/git-forge/package.json +56 -0
  11. package/marketplace/plugins/git-forge/src/app.tsx +82 -0
  12. package/marketplace/plugins/git-forge/src/command.test.ts +181 -0
  13. package/marketplace/plugins/git-forge/src/command.ts +119 -0
  14. package/marketplace/plugins/git-forge/src/header.tsx +87 -0
  15. package/marketplace/plugins/git-forge/src/panel/Badge.tsx +76 -0
  16. package/marketplace/plugins/git-forge/src/panel/Change.tsx +150 -0
  17. package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +51 -0
  18. package/marketplace/plugins/git-forge/src/panel/Credential.tsx +107 -0
  19. package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +70 -0
  20. package/marketplace/plugins/git-forge/src/panel/Header.tsx +255 -0
  21. package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +198 -0
  22. package/marketplace/plugins/git-forge/src/panel/List.tsx +89 -0
  23. package/marketplace/plugins/git-forge/src/panel/Row.tsx +68 -0
  24. package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +94 -0
  25. package/marketplace/plugins/git-forge/src/panel/Write.tsx +236 -0
  26. package/marketplace/plugins/git-forge/src/panel/format.ts +78 -0
  27. package/marketplace/plugins/git-forge/src/panel/index.test.tsx +344 -0
  28. package/marketplace/plugins/git-forge/src/panel/index.tsx +193 -0
  29. package/marketplace/plugins/git-forge/src/panel/use-forge.ts +250 -0
  30. package/marketplace/plugins/git-forge/src/panel/write.test.tsx +269 -0
  31. package/marketplace/plugins/git-forge/src/protocol.ts +308 -0
  32. package/marketplace/plugins/git-forge/src/server/adapters.test.ts +274 -0
  33. package/marketplace/plugins/git-forge/src/server/bitbucket.ts +307 -0
  34. package/marketplace/plugins/git-forge/src/server/capabilities.test.ts +116 -0
  35. package/marketplace/plugins/git-forge/src/server/capabilities.ts +105 -0
  36. package/marketplace/plugins/git-forge/src/server/ci.test.ts +88 -0
  37. package/marketplace/plugins/git-forge/src/server/ci.ts +118 -0
  38. package/marketplace/plugins/git-forge/src/server/context.ts +76 -0
  39. package/marketplace/plugins/git-forge/src/server/diff.test.ts +127 -0
  40. package/marketplace/plugins/git-forge/src/server/diff.ts +120 -0
  41. package/marketplace/plugins/git-forge/src/server/filters.test.ts +138 -0
  42. package/marketplace/plugins/git-forge/src/server/filters.ts +138 -0
  43. package/marketplace/plugins/git-forge/src/server/forges.test.ts +235 -0
  44. package/marketplace/plugins/git-forge/src/server/gitea.ts +296 -0
  45. package/marketplace/plugins/git-forge/src/server/github-extras.ts +92 -0
  46. package/marketplace/plugins/git-forge/src/server/github.ts +320 -0
  47. package/marketplace/plugins/git-forge/src/server/gitlab-detail.ts +207 -0
  48. package/marketplace/plugins/git-forge/src/server/gitlab.test.ts +195 -0
  49. package/marketplace/plugins/git-forge/src/server/gitlab.ts +176 -0
  50. package/marketplace/plugins/git-forge/src/server/http.test.ts +270 -0
  51. package/marketplace/plugins/git-forge/src/server/http.ts +329 -0
  52. package/marketplace/plugins/git-forge/src/server/map.ts +120 -0
  53. package/marketplace/plugins/git-forge/src/server/registry.ts +47 -0
  54. package/marketplace/plugins/git-forge/src/server/remote.test.ts +146 -0
  55. package/marketplace/plugins/git-forge/src/server/remote.ts +188 -0
  56. package/marketplace/plugins/git-forge/src/server/scope-probe.test.ts +98 -0
  57. package/marketplace/plugins/git-forge/src/server/scope-probe.ts +128 -0
  58. package/marketplace/plugins/git-forge/src/server/scope.ts +66 -0
  59. package/marketplace/plugins/git-forge/src/server/test-context.ts +67 -0
  60. package/marketplace/plugins/git-forge/src/server/test-host.ts +51 -0
  61. package/marketplace/plugins/git-forge/src/server/token.test.ts +107 -0
  62. package/marketplace/plugins/git-forge/src/server/token.ts +139 -0
  63. package/marketplace/plugins/git-forge/src/server/write-http.test.ts +127 -0
  64. package/marketplace/plugins/git-forge/src/server/write-http.ts +110 -0
  65. package/marketplace/plugins/git-forge/src/server/writes.test.ts +218 -0
  66. package/marketplace/plugins/git-forge/src/server/writes.ts +313 -0
  67. package/marketplace/plugins/git-forge/src/server.ts +284 -0
  68. package/marketplace/plugins/git-forge/tsconfig.json +16 -0
  69. package/marketplace/plugins/session-info/package.json +4 -2
  70. package/marketplace/plugins/stats/package.json +4 -2
  71. package/package.json +6 -1
  72. package/src/client/components/common/code-surface/blame-hover.ts +188 -0
  73. package/src/client/components/common/code-surface/blame-panel.test.ts +304 -0
  74. package/src/client/components/common/code-surface/blame-panel.ts +306 -0
  75. package/src/client/components/common/code-surface/blame.test.ts +303 -0
  76. package/src/client/components/common/code-surface/blame.ts +227 -0
  77. package/src/client/components/common/code-surface/conflict-markers.test.ts +135 -0
  78. package/src/client/components/common/code-surface/conflict-markers.ts +144 -0
  79. package/src/client/components/common/code-surface/documents.ts +48 -1
  80. package/src/client/components/common/code-surface/extensions.test.ts +4 -0
  81. package/src/client/components/common/code-surface/extensions.ts +44 -0
  82. package/src/client/components/common/code-surface/fold-stack.test.ts +4 -0
  83. package/src/client/components/common/code-surface/indent.test.ts +5 -0
  84. package/src/client/components/common/code-surface/index.tsx +16 -2
  85. package/src/client/components/common/code-surface/lint-parsers.test.ts +109 -0
  86. package/src/client/components/common/code-surface/lint-parsers.ts +134 -0
  87. package/src/client/components/common/code-surface/lint.test.ts +101 -0
  88. package/src/client/components/common/code-surface/lint.ts +85 -0
  89. package/src/client/components/common/code-surface/props.ts +17 -0
  90. package/src/client/components/common/code-surface/surface-failures.test.ts +132 -0
  91. package/src/client/components/common/code-surface/theme.ts +71 -0
  92. package/src/client/components/common/header-controls/index.test.tsx +1 -1
  93. package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -1
  94. package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -1
  95. package/src/client/components/common/provider-icon/Plate.tsx +88 -0
  96. package/src/client/components/common/provider-icon/index.tsx +55 -11
  97. package/src/client/components/layout/session-sidebar/SessionsView.tsx +5 -2
  98. package/src/client/components/mobile/SessionSidebar.tsx +2 -10
  99. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +6 -0
  100. package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +8 -0
  101. package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
  102. package/src/client/components/settings/categories/ProviderSettings.tsx +43 -41
  103. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +97 -0
  104. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +106 -54
  105. package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +14 -1
  106. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +39 -150
  107. package/src/client/components/settings/categories/panel-plugins/Meta.test.tsx +143 -0
  108. package/src/client/components/settings/categories/panel-plugins/Meta.tsx +157 -0
  109. package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +149 -0
  110. package/src/client/components/settings/categories/panel-plugins/Placement.tsx +99 -0
  111. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +270 -0
  112. package/src/client/components/settings/categories/panel-plugins/Section.tsx +11 -3
  113. package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +25 -0
  114. package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +135 -80
  115. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +51 -21
  116. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +175 -0
  117. package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +275 -0
  118. package/src/client/components/settings/categories/provider-settings/Header.tsx +40 -9
  119. package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +142 -160
  120. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  121. package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +84 -46
  122. package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +217 -102
  123. package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +5 -2
  124. package/src/client/components/settings/categories/provider-settings/SidebarList.plugin.test.ts +3 -3
  125. package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +158 -102
  126. package/src/client/components/settings/categories/provider-settings/auth-section.test.tsx +135 -0
  127. package/src/client/components/settings/categories/provider-settings/groups.test.ts +98 -0
  128. package/src/client/components/settings/categories/provider-settings/groups.ts +108 -0
  129. package/src/client/components/settings/categories/provider-settings/layout.test.tsx +325 -0
  130. package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +135 -0
  131. package/src/client/components/settings/categories/provider-settings/preset-picker.test.tsx +73 -0
  132. package/src/client/components/settings/categories/usage-settings/ProviderCard.tsx +22 -2
  133. package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +2 -0
  134. package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +16 -6
  135. package/src/client/components/settings/categories/usage-settings/providers.ts +3 -0
  136. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +19 -0
  137. package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +143 -0
  138. package/src/client/components/workspace/chat-timeline/MinimapShortcuts.test.ts +2 -1
  139. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +23 -19
  140. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +23 -19
  141. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +20 -18
  142. package/src/client/components/workspace/chat-timeline/chat-input/compact.test.tsx +19 -6
  143. package/src/client/components/workspace/chat-timeline/index.tsx +7 -16
  144. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +100 -0
  145. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +3 -47
  146. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +8 -1
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util.ts +62 -0
  148. package/src/client/components/workspace/diff-panel/HunkStepper.tsx +62 -0
  149. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +29 -0
  150. package/src/client/components/workspace/diff-panel/Toolbar.tsx +32 -1
  151. package/src/client/components/workspace/diff-panel/changes.ts +69 -0
  152. package/src/client/components/workspace/diff-panel/chunks.ts +85 -0
  153. package/src/client/components/workspace/diff-panel/index.tsx +21 -1
  154. package/src/client/components/workspace/diff-panel/merge.test.ts +145 -0
  155. package/src/client/components/workspace/diff-panel/merge.ts +63 -68
  156. package/src/client/components/workspace/editor/EditorDropOverlay.tsx +6 -1
  157. package/src/client/components/workspace/editor/FileDocument.tsx +51 -1
  158. package/src/client/components/workspace/editor/FilePane.tsx +25 -1
  159. package/src/client/components/workspace/editor/StatusBar.tsx +19 -0
  160. package/src/client/components/workspace/editor/Toolbar.tsx +29 -5
  161. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +86 -0
  162. package/src/client/components/workspace/editor/toolbar-clusters.tsx +48 -16
  163. package/src/client/components/workspace/editor/viewers/bytes.ts +16 -0
  164. package/src/client/components/workspace/git-panel/index.test.ts +46 -1
  165. package/src/client/components/workspace/git-panel/index.tsx +11 -38
  166. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +66 -0
  167. package/src/client/components/workspace/model-dropdown/Item.tsx +71 -62
  168. package/src/client/components/workspace/model-dropdown/Section.tsx +31 -14
  169. package/src/client/components/workspace/model-dropdown/collapsed.ts +72 -0
  170. package/src/client/components/workspace/model-dropdown/index.tsx +42 -19
  171. package/src/client/components/workspace/model-dropdown/refresh.test.tsx +260 -0
  172. package/src/client/components/workspace/model-dropdown/trigger.test.ts +34 -0
  173. package/src/client/components/workspace/model-dropdown/use-catalog.ts +13 -2
  174. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +19 -3
  175. package/src/client/hooks/chat/omp/folder-auto-expand.ts +113 -0
  176. package/src/client/hooks/chat/omp/index.ts +20 -0
  177. package/src/client/hooks/chat/omp/pending-rows.ts +21 -0
  178. package/src/client/hooks/chat/omp/pending-sessions.test.ts +16 -1
  179. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +102 -0
  180. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +21 -1
  181. package/src/client/hooks/chat/omp/stream.ts +8 -1
  182. package/src/client/hooks/chat/timeline/index.ts +1 -1
  183. package/src/client/hooks/chat/timeline/new-chat-open.ts +60 -0
  184. package/src/client/hooks/editor/blame-settings.ts +67 -0
  185. package/src/client/hooks/editor/blame.test.ts +272 -0
  186. package/src/client/hooks/editor/blame.ts +232 -0
  187. package/src/client/hooks/editor/file-editor-types.ts +23 -0
  188. package/src/client/hooks/editor/save-file.test.ts +20 -0
  189. package/src/client/hooks/editor/use-editor-drop.test-util.ts +198 -0
  190. package/src/client/hooks/editor/use-editor-drop.test.ts +70 -175
  191. package/src/client/hooks/editor/use-editor-drop.ts +19 -36
  192. package/src/client/hooks/editor/use-file-editor.ts +7 -1
  193. package/src/client/hooks/settings/providers/actions.ts +90 -194
  194. package/src/client/hooks/settings/providers/api.ts +7 -1
  195. package/src/client/hooks/settings/providers/index.ts +171 -59
  196. package/src/client/hooks/settings/providers/login.test.ts +79 -0
  197. package/src/client/hooks/settings/providers/login.ts +276 -0
  198. package/src/client/hooks/settings/providers/messages.ts +28 -0
  199. package/src/client/hooks/settings/providers/model-actions.ts +178 -0
  200. package/src/client/hooks/ui/editor-error-toast.ts +47 -0
  201. package/src/client/hooks/ui/open-file.ts +7 -0
  202. package/src/client/hooks/ui/toasts.ts +7 -0
  203. package/src/client/hooks/workspace/file-tabs.ts +4 -1
  204. package/src/client/hooks/workspace/folder-expansion.test.ts +62 -0
  205. package/src/client/hooks/workspace/folder-expansion.ts +33 -0
  206. package/src/client/hooks/workspace/git-action-outcome.ts +86 -0
  207. package/src/client/hooks/workspace/git-actions.ts +29 -2
  208. package/src/client/hooks/workspace/plugin-contributions.test.ts +117 -0
  209. package/src/client/hooks/workspace/plugin-contributions.ts +146 -0
  210. package/src/client/lib/editor-errors.test.ts +85 -0
  211. package/src/client/lib/editor-errors.ts +71 -0
  212. package/src/client/lib/fs/resolve-open.test.ts +125 -0
  213. package/src/client/lib/fs/resolve-open.ts +90 -0
  214. package/src/client/lib/git/action-message.test.ts +82 -0
  215. package/src/client/lib/git/action-message.ts +160 -0
  216. package/src/client/lib/launch/device-files.test.ts +160 -0
  217. package/src/client/lib/launch/device-files.ts +197 -0
  218. package/src/client/lib/native/open-paths.test.ts +140 -0
  219. package/src/client/lib/native/open-paths.ts +157 -0
  220. package/src/client/lib/plugins/bootstrap.test.ts +1 -1
  221. package/src/client/main.tsx +20 -0
  222. package/src/server/db.server.test.ts +39 -0
  223. package/src/server/db.server.ts +21 -2
  224. package/src/server/lib/db/schema.ts +2 -0
  225. package/src/server/lib/fs/external-roots.test.ts +100 -0
  226. package/src/server/lib/fs/external-roots.ts +101 -0
  227. package/src/server/lib/fs/git-actions-branch.ts +15 -2
  228. package/src/server/lib/fs/git-actions-shared.ts +24 -0
  229. package/src/server/lib/fs/git-actions-sync.test.ts +18 -7
  230. package/src/server/lib/fs/git-actions-worktree.ts +5 -1
  231. package/src/server/lib/fs/git-blame.test.ts +206 -0
  232. package/src/server/lib/fs/git-blame.ts +189 -0
  233. package/src/server/lib/fs/root.ts +14 -0
  234. package/src/server/lib/http/same-origin.ts +28 -7
  235. package/src/server/lib/models/catalog.server.ts +230 -0
  236. package/src/server/lib/models/catalog.test.ts +83 -0
  237. package/src/server/lib/models/credential-origin.server.ts +108 -0
  238. package/src/server/lib/models/credential-origin.test.ts +132 -0
  239. package/src/server/lib/models/provider-icon-fetch.ts +115 -0
  240. package/src/server/lib/models/provider-icon-parse.test.ts +134 -0
  241. package/src/server/lib/models/provider-icon-parse.ts +139 -0
  242. package/src/server/lib/models/provider-icon-store.server.ts +118 -0
  243. package/src/server/lib/models/provider-icon-store.test.ts +107 -0
  244. package/src/server/lib/models/provider-icon.server.ts +209 -0
  245. package/src/server/lib/models/provider-items.server.ts +211 -37
  246. package/src/server/lib/models/provider-items.test.ts +201 -0
  247. package/src/server/lib/models/provider-registry.server.test.ts +27 -9
  248. package/src/server/lib/models/provider-registry.server.ts +160 -67
  249. package/src/server/lib/models/registry.server.test.ts +3 -3
  250. package/src/server/lib/models/registry.server.ts +8 -0
  251. package/src/server/lib/omp/config/definitions.test.ts +5 -4
  252. package/src/server/lib/omp/config/models-config.ts +42 -0
  253. package/src/server/lib/omp/config/provider-entry.test.ts +205 -0
  254. package/src/server/lib/omp/config/provider-entry.ts +197 -0
  255. package/src/server/lib/omp/config/provider-seeds.ts +10 -0
  256. package/src/server/lib/omp/core/models-json.ts +69 -0
  257. package/src/server/lib/omp/session/messages.ts +17 -3
  258. package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +13 -3
  259. package/src/server/lib/panels/bundled-catalog.server.ts +7 -0
  260. package/src/server/lib/panels/catalog-offers.server.ts +68 -0
  261. package/src/server/lib/panels/git-update.server.test.ts +14 -0
  262. package/src/server/lib/panels/git-update.server.ts +63 -1
  263. package/src/server/lib/panels/manifest.test.ts +65 -0
  264. package/src/server/lib/panels/manifest.ts +55 -1
  265. package/src/server/lib/panels/offers.server.test.ts +191 -0
  266. package/src/server/lib/panels/offers.server.ts +108 -0
  267. package/src/server/lib/panels/registry.server.test.ts +35 -1
  268. package/src/server/lib/panels/registry.server.ts +51 -142
  269. package/src/server/lib/panels/scan.server.ts +162 -0
  270. package/src/server/lib/route-adapter.ts +13 -2
  271. package/src/server/lib/tray/tray.test.ts +2 -1
  272. package/src/server/lib/usage/providers.server.ts +4 -1
  273. package/src/server/routes/chat/session.ts +7 -1
  274. package/src/server/routes/fs/git-blame-loader.test.ts +146 -0
  275. package/src/server/routes/fs/git.ts +17 -0
  276. package/src/server/routes/fs/grant.test.ts +135 -0
  277. package/src/server/routes/fs/grant.ts +79 -0
  278. package/src/server/routes/fs/index.ts +2 -0
  279. package/src/server/routes/fs/scope.ts +34 -17
  280. package/src/server/routes/omp/login.ts +41 -14
  281. package/src/server/routes/omp/routes.test.ts +23 -10
  282. package/src/server/routes/settings/index.ts +8 -0
  283. package/src/server/routes/settings/provider-entry.ts +108 -0
  284. package/src/server/routes/settings/provider-icon.ts +99 -0
  285. package/src/server/routes/settings/provider-model.ts +4 -1
  286. package/src/server/routes/settings/provider-refresh.ts +87 -0
  287. package/src/server/routes/settings/providers.ts +31 -2
  288. package/src/shared/lib/chat/omp/fold.test.ts +34 -0
  289. package/src/shared/lib/chat/omp/tool-frames.test.ts +20 -0
  290. package/src/shared/lib/chat/omp/tool-frames.ts +5 -1
  291. package/src/shared/lib/chat/omp/tool-results.ts +29 -3
  292. package/src/shared/lib/chat/tool/wait-facts.ts +4 -0
  293. package/src/shared/lib/fs/git-blame.test.ts +266 -0
  294. package/src/shared/lib/fs/git-blame.ts +246 -0
  295. package/src/shared/lib/git/url.ts +18 -0
  296. package/src/shared/lib/markdown/sanitize.test.ts +57 -0
  297. package/src/shared/lib/markdown/sanitize.ts +30 -7
  298. package/src/shared/lib/models/provider/connection.ts +135 -0
  299. package/src/shared/lib/models/provider/dialect.test.ts +4 -2
  300. package/src/shared/lib/models/provider/dialect.ts +76 -6
  301. package/src/shared/lib/models/provider/models.ts +2 -0
  302. package/src/shared/lib/models/provider/origin.ts +94 -0
  303. package/src/shared/lib/models/provider/provider-ui.test.ts +7 -0
  304. package/src/shared/lib/models/server-cache.ts +8 -3
  305. package/src/shared/lib/omp/session/messages-map-pending.test.ts +110 -0
  306. package/src/shared/lib/omp/session/messages-map.ts +34 -2
  307. package/src/shared/lib/omp/session/prewarm-misc.test.ts +7 -90
  308. package/src/shared/lib/omp/session/prewarm.test.ts +133 -0
  309. package/src/shared/lib/omp/session/prewarm.ts +23 -1
  310. package/src/shared/lib/omp/session/wait.test.ts +28 -0
  311. package/src/shared/lib/omp/session/wait.ts +38 -3
  312. package/src/shared/lib/panels/slot-labels.test.ts +61 -0
  313. package/src/shared/lib/panels/slot-labels.ts +133 -0
  314. package/src/shared/lib/workspace/panel-ids.ts +11 -0
  315. package/src/shared/types/fs.ts +6 -0
  316. package/src/shared/types/index.ts +1 -0
  317. package/src/shared/types/models.ts +12 -0
  318. package/src/shared/types/panels-registry.ts +277 -0
  319. package/src/shared/types/panels.ts +46 -213
  320. package/src/shared/types/settings/provider.ts +58 -0
  321. package/src/shared/types/settings/usage.ts +10 -0
  322. package/src/test-support/pristine-globals.ts +7 -0
  323. package/dist/client/static/js/index-bq6qeayr.css +0 -1
  324. package/src/client/components/settings/categories/provider-settings/ReconnectModal.tsx +0 -184
@@ -0,0 +1,218 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The write table, over all four hosts.
8
+ *
9
+ * `callFor` is pure — it turns an intent into a URL, a method and a body — so
10
+ * every row can be asserted exactly. That matters because each host spells the
11
+ * same verb differently and three of the differences are SILENT when wrong:
12
+ *
13
+ * - GitLab's close is `state_event: close`; sending `state: closed` is accepted
14
+ * and ignored, so the merge request stays open while the panel reports success.
15
+ * - Bitbucket has no comment body at the top level (`{content: {raw}}`) and no
16
+ * state field on a pull request (a POST to `/decline`).
17
+ * - Gitea's merge style is `Do: merge|squash|rebase`, not a `merge_method`.
18
+ *
19
+ * `performWrite` is driven through the injected fetch, so nothing here can reach
20
+ * a real repository. That is deliberate: the first version of this suite was a
21
+ * live smoke, and it posted a comment to a public project.
22
+ */
23
+
24
+ import { describe, expect, test } from 'bun:test';
25
+
26
+ import { callFor, patchedItem, performWrite, providerLabel } from './writes';
27
+ import { hostContext } from './test-context';
28
+ import type { ForgeItem, ForgeProvider } from '../protocol';
29
+
30
+ /** A fetch that records one request and answers 200 with `body`. */
31
+ function recorder(body: unknown = {}) {
32
+ const seen: Array<{ url: string; method?: string; body?: unknown; headers?: Record<string, string> }> = [];
33
+ const fetchImpl = (async (input: string | URL | Request, init?: RequestInit) => {
34
+ seen.push({
35
+ url: String(input),
36
+ method: init?.method,
37
+ body: init?.body ? JSON.parse(String(init.body)) : undefined,
38
+ headers: (init?.headers ?? {}) as Record<string, string>,
39
+ });
40
+ return new Response(JSON.stringify(body), { status: 200 });
41
+ }) as unknown as typeof fetch;
42
+ return { seen, fetchImpl };
43
+ }
44
+
45
+ const call = (provider: ForgeProvider, write: Parameters<typeof callFor>[3], section: Parameters<typeof callFor>[1] = 'pulls') => {
46
+ const { fetchImpl } = recorder();
47
+ return callFor(hostContext(provider, fetchImpl), section, '12', write);
48
+ };
49
+
50
+ describe('callFor — a comment', () => {
51
+ test('GitHub and Gitea use /issues/:id/comments, because a pull request is an issue', () => {
52
+ for (const provider of ['github', 'gitea'] as const) {
53
+ const result = call(provider, { kind: 'comment', body: 'hello' });
54
+ if ('error' in result) throw new Error(result.error);
55
+ expect(result.url).toContain('/issues/12/comments');
56
+ expect(result.body).toEqual({ body: 'hello' });
57
+ expect(result.method).toBe('POST');
58
+ }
59
+ });
60
+
61
+ test('GitLab says notes', () => {
62
+ const result = call('gitlab', { kind: 'comment', body: 'hello' });
63
+ if ('error' in result) throw new Error(result.error);
64
+ expect(result.url).toContain('/merge_requests/12/notes');
65
+ expect(result.body).toEqual({ body: 'hello' });
66
+ });
67
+
68
+ test('Bitbucket nests the body under content.raw', () => {
69
+ const result = call('bitbucket', { kind: 'comment', body: 'hello' });
70
+ if ('error' in result) throw new Error(result.error);
71
+ expect(result.url).toContain('/pullrequests/12/comments');
72
+ expect(result.body).toEqual({ content: { raw: 'hello' } });
73
+ });
74
+ });
75
+
76
+ describe('callFor — a state change', () => {
77
+ test('GitLab sends an EVENT, not a state, or the close is silently ignored', () => {
78
+ const result = call('gitlab', { kind: 'state', state: 'closed' });
79
+ if ('error' in result) throw new Error(result.error);
80
+ expect(result.body).toEqual({ state_event: 'close' });
81
+ expect(result.method).toBe('PUT');
82
+
83
+ const reopen = call('gitlab', { kind: 'state', state: 'open' });
84
+ if ('error' in reopen) throw new Error(reopen.error);
85
+ expect(reopen.body).toEqual({ state_event: 'reopen' });
86
+ });
87
+
88
+ test('GitHub and Gitea PATCH a state', () => {
89
+ for (const provider of ['github', 'gitea'] as const) {
90
+ const result = call(provider, { kind: 'state', state: 'closed' });
91
+ if ('error' in result) throw new Error(result.error);
92
+ expect(result.method).toBe('PATCH');
93
+ expect(result.body).toEqual({ state: 'closed' });
94
+ }
95
+ });
96
+
97
+ test('Bitbucket declines a pull request and PATCHes an issue', () => {
98
+ const pull = call('bitbucket', { kind: 'state', state: 'closed' });
99
+ if ('error' in pull) throw new Error(pull.error);
100
+ expect(pull.url).toContain('/pullrequests/12/decline');
101
+ expect(pull.method).toBe('POST');
102
+
103
+ const issue = call('bitbucket', { kind: 'state', state: 'closed' }, 'issues');
104
+ if ('error' in issue) throw new Error(issue.error);
105
+ expect(issue.method).toBe('PUT');
106
+ expect(issue.body).toEqual({ state: 'closed' });
107
+ });
108
+ });
109
+
110
+ describe('callFor — a merge', () => {
111
+ test('each host takes the style its own way', () => {
112
+ const github = call('github', { kind: 'merge', method: 'squash' });
113
+ if ('error' in github) throw new Error(github.error);
114
+ expect(github.body).toEqual({ merge_method: 'squash' });
115
+ expect(github.method).toBe('PUT');
116
+
117
+ const gitea = call('gitea', { kind: 'merge', method: 'rebase' });
118
+ if ('error' in gitea) throw new Error(gitea.error);
119
+ expect(gitea.body).toEqual({ Do: 'rebase' });
120
+ expect(gitea.method).toBe('POST');
121
+
122
+ const gitlab = call('gitlab', { kind: 'merge', method: 'squash' });
123
+ if ('error' in gitlab) throw new Error(gitlab.error);
124
+ expect(gitlab.body).toEqual({ squash: true });
125
+
126
+ const bitbucket = call('bitbucket', { kind: 'merge', method: 'rebase' });
127
+ if ('error' in bitbucket) throw new Error(bitbucket.error);
128
+ expect(bitbucket.body).toEqual({ merge_strategy: 'fast_forward' });
129
+ });
130
+ });
131
+
132
+ describe('callFor — a review', () => {
133
+ test('GitHub sends an event; GitLab and Bitbucket POST approve', () => {
134
+ const github = call('github', { kind: 'review', verdict: 'request_changes', body: 'why' });
135
+ if ('error' in github) throw new Error(github.error);
136
+ expect(github.url).toContain('/reviews');
137
+ expect(github.body).toEqual({ event: 'REQUEST_CHANGES', body: 'why' });
138
+
139
+ const gitlab = call('gitlab', { kind: 'review', verdict: 'approve', body: '' });
140
+ if ('error' in gitlab) throw new Error(gitlab.error);
141
+ expect(gitlab.url).toContain('/approve');
142
+ expect(gitlab.body).toEqual({});
143
+ });
144
+ });
145
+
146
+ describe('callFor — a section that has no write', () => {
147
+ test('a release is not addressable, and the sentence says so', () => {
148
+ const result = call('github', { kind: 'comment', body: 'x' }, 'releases');
149
+ expect('error' in result).toBe(true);
150
+ });
151
+ });
152
+
153
+ describe('performWrite', () => {
154
+ test('it sends exactly what the table said, through the injected fetch', async () => {
155
+ const { seen, fetchImpl } = recorder({ id: 1 });
156
+ const context = hostContext('github', fetchImpl);
157
+ const result = await performWrite(context, 'pulls', '12', { kind: 'merge', method: 'squash' });
158
+
159
+ expect(result).toEqual({ ok: true, message: 'Merged.' });
160
+ expect(seen).toHaveLength(1);
161
+ expect(seen[0].method).toBe('PUT');
162
+ expect(seen[0].url).toBe('https://api.github.com/repos/kabmo-labs/kabmo/pulls/12/merge');
163
+ expect(seen[0].body).toEqual({ merge_method: 'squash' });
164
+ // The credential rides the same header the reads use.
165
+ expect(seen[0].headers?.authorization).toBe('Bearer token_test');
166
+ });
167
+
168
+ test('a refused write reports the host sentence, not a throw', async () => {
169
+ const fetchImpl = (async () => new Response('{}', { status: 405 })) as unknown as typeof fetch;
170
+ const result = await performWrite(hostContext('github', fetchImpl), 'pulls', '12', {
171
+ kind: 'merge',
172
+ method: 'merge',
173
+ });
174
+ expect(result.ok).toBe(false);
175
+ if (result.ok) return;
176
+ expect(result.message).toContain('405');
177
+ });
178
+
179
+ test('a host with no route for the verb reports it without a request', async () => {
180
+ const { seen, fetchImpl } = recorder();
181
+ const result = await performWrite(hostContext('github', fetchImpl), 'releases', 'v1', {
182
+ kind: 'comment',
183
+ body: 'x',
184
+ });
185
+ expect(result.ok).toBe(false);
186
+ expect(seen).toHaveLength(0);
187
+ });
188
+ });
189
+
190
+ describe('patchedItem', () => {
191
+ const item: ForgeItem = {
192
+ id: '12',
193
+ number: 12,
194
+ title: 't',
195
+ state: 'open',
196
+ author: 'a',
197
+ updatedAt: '',
198
+ url: 'u',
199
+ labels: [],
200
+ comments: 3,
201
+ tag: null,
202
+ };
203
+
204
+ test('a state change and a merge land on the item the panel repaints', () => {
205
+ expect(patchedItem(item, { kind: 'state', state: 'closed' }).state).toBe('closed');
206
+ expect(patchedItem(item, { kind: 'merge', method: 'squash' }).state).toBe('merged');
207
+ expect(patchedItem(item, { kind: 'comment', body: 'x' }).comments).toBe(4);
208
+ expect(patchedItem(item, { kind: 'review', verdict: 'approve', body: '' })).toBe(item);
209
+ });
210
+ });
211
+
212
+ describe('providerLabel', () => {
213
+ test('every provider has a name a sentence can use', () => {
214
+ for (const provider of ['github', 'gitlab', 'gitea', 'bitbucket'] as const) {
215
+ expect(providerLabel(provider)).not.toBe(provider);
216
+ }
217
+ });
218
+ });
@@ -0,0 +1,313 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The four writes, per host.
8
+ *
9
+ * One table per verb rather than a chain of `if`s, because four hosts × four
10
+ * verbs is sixteen shapes and a missed one is a button that silently does
11
+ * nothing. Each row states the method, the path and the body — the only thing
12
+ * that differs between hosts for the same intent.
13
+ *
14
+ * ## What is NOT shared, and why
15
+ *
16
+ * - **GitLab's "close" is `state_event: close`**, not `state: closed`. Sending
17
+ * the latter is accepted by the host and ignored, so the merge request stays
18
+ * open and the panel reports success.
19
+ * - **Bitbucket has no comment body at the top level** — it is
20
+ * `{content: {raw}}` — and its state verbs are a POST to `.../decline` or
21
+ * `.../merge`, not a PATCH.
22
+ * - **Gitea's merge takes the style in the body** (`Do: merge|squash|rebase`)
23
+ * while GitHub takes it in the path (`/merge`, `/merge/squash`… wait: GitHub
24
+ * uses `merge_method` in the body). Stated per row.
25
+ * - **A review verdict is two events on GitHub, one on GitLab, none on
26
+ * Bitbucket.** `capabilities.ts` refuses the ones a host cannot express, so
27
+ * this table only ever sees a verb the host supports.
28
+ *
29
+ * ## Every write is followed by an invalidation, not by a re-read
30
+ *
31
+ * A write changes the item AND the list it came from, and those are different
32
+ * cached URLs. `invalidateWhere` drops every entry for the repository, which is
33
+ * the whole set a write could have changed — so the panel's next read is real
34
+ * instead of a 304 describing the state before the write.
35
+ */
36
+
37
+ import type { ForgeItem, ForgeProvider, ForgeSection, ForgeWrite } from '../protocol';
38
+ import { authHeaders } from './http';
39
+ import { sendJson, type SendResult } from './write-http';
40
+ import { bitbucketPath } from './remote';
41
+ import { joinUrl, type ForgeContext } from './context';
42
+
43
+ /** One host call a write becomes. */
44
+ interface Call {
45
+ url: string;
46
+ method: 'POST' | 'PATCH' | 'PUT';
47
+ body: unknown;
48
+ /** The sentence a success reports, when the host's own answer is not one. */
49
+ message: string;
50
+ }
51
+
52
+ /** The path prefix for a section's items on each host. */
53
+ function itemPath(context: ForgeContext, section: ForgeSection, id: string): string | null {
54
+ const encoded = encodeURIComponent(id);
55
+ if (context.provider === 'github') {
56
+ const base = `/repos/${context.slug}`;
57
+ if (section === 'issues') return `${base}/issues/${encoded}`;
58
+ if (section === 'pulls') return `${base}/pulls/${encoded}`;
59
+ return null;
60
+ }
61
+ if (context.provider === 'gitlab') {
62
+ const project = `projects/${encodeURIComponent(context.slug)}`;
63
+ if (section === 'issues') return `${project}/issues/${encoded}`;
64
+ if (section === 'pulls') return `${project}/merge_requests/${encoded}`;
65
+ return null;
66
+ }
67
+ if (context.provider === 'gitea') {
68
+ const base = `/repos/${context.slug}`;
69
+ if (section === 'issues') return `${base}/issues/${encoded}`;
70
+ if (section === 'pulls') return `${base}/pulls/${encoded}`;
71
+ return null;
72
+ }
73
+ const parts = bitbucketPath(context.slug);
74
+ if (!parts) return null;
75
+ const repo = `repositories/${encodeURIComponent(parts.workspace)}/${encodeURIComponent(parts.repo)}`;
76
+ if (section === 'issues') return `${repo}/issues/${encoded}`;
77
+ if (section === 'pulls') return `${repo}/pullrequests/${encoded}`;
78
+ return null;
79
+ }
80
+
81
+ /** The comment collection for an item, which every host puts under its own noun. */
82
+ function commentPath(context: ForgeContext, section: ForgeSection, id: string): string | null {
83
+ // A release is not a discussion on any host: it has no comment collection, so
84
+ // asking for one must not fall through to `/issues/:id/comments` — which is a
85
+ // 404 at best and, on a host that numbers releases, somebody else's issue.
86
+ if (section === 'releases') return null;
87
+ const encoded = encodeURIComponent(id);
88
+ if (context.provider === 'github') return `/repos/${context.slug}/issues/${encoded}/comments`;
89
+ if (context.provider === 'gitlab') {
90
+ const kind = section === 'issues' ? 'issues' : 'merge_requests';
91
+ return `projects/${encodeURIComponent(context.slug)}/${kind}/${encoded}/notes`;
92
+ }
93
+ if (context.provider === 'gitea') return `/repos/${context.slug}/issues/${encoded}/comments`;
94
+ const parts = bitbucketPath(context.slug);
95
+ if (!parts) return null;
96
+ const repo = `repositories/${encodeURIComponent(parts.workspace)}/${encodeURIComponent(parts.repo)}`;
97
+ const kind = section === 'pulls' ? 'pullrequests' : 'issues';
98
+ return `${repo}/${kind}/${encoded}/comments`;
99
+ }
100
+
101
+ /** A comment's body, per host. */
102
+ function commentBody(context: ForgeContext, body: string): unknown {
103
+ return context.provider === 'bitbucket' ? { content: { raw: body } } : { body };
104
+ }
105
+
106
+ /** A state change, per host — and GitLab's is an EVENT, not a state. */
107
+ function stateCall(context: ForgeContext, section: ForgeSection, id: string, state: 'open' | 'closed'): Call | null {
108
+ const path = itemPath(context, section, id);
109
+ if (!path) return null;
110
+ const opening = state === 'open';
111
+
112
+ if (context.provider === 'gitlab') {
113
+ const event = section === 'pulls' ? (opening ? 'reopen' : 'close') : opening ? 'reopen' : 'close';
114
+ return {
115
+ url: joinUrl(context.apiBase, path),
116
+ method: 'PUT',
117
+ body: { state_event: event },
118
+ message: opening ? 'Reopened.' : 'Closed.',
119
+ };
120
+ }
121
+ if (context.provider === 'gitea') {
122
+ return {
123
+ url: joinUrl(context.apiBase, path),
124
+ method: 'PATCH',
125
+ body: { state },
126
+ message: opening ? 'Reopened.' : 'Closed.',
127
+ };
128
+ }
129
+ if (context.provider === 'bitbucket') {
130
+ // Bitbucket has no state field: closing a pull request is a POST to its own
131
+ // verb, and an ISSUE is closed by a PUT with a state word. There is no
132
+ // reopen verb for a declined pull request, and `capabilities.ts` does not
133
+ // offer one — the panel only ever asks for `closed` here.
134
+ if (section === 'pulls') {
135
+ return {
136
+ url: joinUrl(context.apiBase, `${path}/decline`),
137
+ method: 'POST',
138
+ body: {},
139
+ message: 'Declined.',
140
+ };
141
+ }
142
+ return {
143
+ url: joinUrl(context.apiBase, path),
144
+ method: 'PUT',
145
+ body: { state: opening ? 'open' : 'closed' },
146
+ message: opening ? 'Reopened.' : 'Closed.',
147
+ };
148
+ }
149
+ return {
150
+ url: joinUrl(context.apiBase, path),
151
+ method: 'PATCH',
152
+ body: { state },
153
+ message: opening ? 'Reopened.' : 'Closed.',
154
+ };
155
+ }
156
+
157
+ /** A merge, per host: the method's spelling and the path both differ. */
158
+ function mergeCall(context: ForgeContext, section: ForgeSection, id: string, method: 'merge' | 'squash' | 'rebase'): Call | null {
159
+ const path = itemPath(context, section, id);
160
+ if (!path) return null;
161
+
162
+ if (context.provider === 'github') {
163
+ return {
164
+ url: joinUrl(context.apiBase, `${path}/merge`),
165
+ method: 'PUT',
166
+ body: { merge_method: method },
167
+ message: 'Merged.',
168
+ };
169
+ }
170
+ if (context.provider === 'gitlab') {
171
+ return {
172
+ url: joinUrl(context.apiBase, `${path}/merge`),
173
+ method: 'PUT',
174
+ body: method === 'merge' ? {} : { squash: method === 'squash' },
175
+ message: 'Merged.',
176
+ };
177
+ }
178
+ if (context.provider === 'gitea') {
179
+ return {
180
+ url: joinUrl(context.apiBase, `${path}/merge`),
181
+ method: 'POST',
182
+ body: { Do: method },
183
+ message: 'Merged.',
184
+ };
185
+ }
186
+ return {
187
+ url: joinUrl(context.apiBase, `${path}/merge`),
188
+ method: 'POST',
189
+ body: method === 'merge' ? {} : { merge_strategy: method === 'squash' ? 'squash' : 'fast_forward' },
190
+ message: 'Merged.',
191
+ };
192
+ }
193
+
194
+ /** A review verdict, per host. */
195
+ function reviewCall(
196
+ context: ForgeContext,
197
+ section: ForgeSection,
198
+ id: string,
199
+ verdict: 'approve' | 'request_changes',
200
+ body: string,
201
+ ): Call | null {
202
+ const path = itemPath(context, section, id);
203
+ if (!path) return null;
204
+
205
+ if (context.provider === 'github') {
206
+ return {
207
+ url: joinUrl(context.apiBase, `${path}/reviews`),
208
+ method: 'POST',
209
+ body: { event: verdict === 'approve' ? 'APPROVE' : 'REQUEST_CHANGES', ...(body ? { body } : {}) },
210
+ message: verdict === 'approve' ? 'Approved.' : 'Changes requested.',
211
+ };
212
+ }
213
+ if (context.provider === 'gitlab') {
214
+ // Only `approve` reaches here: `capabilities.ts` refuses request-changes for
215
+ // GitLab, because the host has no such event.
216
+ return {
217
+ url: joinUrl(context.apiBase, `${path}/approve`),
218
+ method: 'POST',
219
+ body: {},
220
+ message: 'Approved.',
221
+ };
222
+ }
223
+ if (context.provider === 'gitea') {
224
+ return {
225
+ url: joinUrl(context.apiBase, `${path}/reviews`),
226
+ method: 'POST',
227
+ body: { event: verdict === 'approve' ? 'APPROVED' : 'REQUEST_CHANGES', ...(body ? { body } : {}) },
228
+ message: verdict === 'approve' ? 'Approved.' : 'Changes requested.',
229
+ };
230
+ }
231
+ // Bitbucket has no verdict: an approval is a POST to its own endpoint, and
232
+ // `capabilities.ts` never offers request-changes here.
233
+ return {
234
+ url: joinUrl(context.apiBase, `${path}/approve`),
235
+ method: 'POST',
236
+ body: {},
237
+ message: 'Approved.',
238
+ };
239
+ }
240
+
241
+ /** Turn one write into the host call it means, or a sentence explaining why not. */
242
+ export function callFor(
243
+ context: ForgeContext,
244
+ section: ForgeSection,
245
+ id: string,
246
+ write: ForgeWrite,
247
+ ): Call | { error: string } {
248
+ if (write.kind === 'comment') {
249
+ const path = commentPath(context, section, id);
250
+ if (!path) return { error: 'That repository is not addressable on this host.' };
251
+ return {
252
+ url: joinUrl(context.apiBase, path),
253
+ method: 'POST',
254
+ body: commentBody(context, write.body),
255
+ message: 'Comment posted.',
256
+ };
257
+ }
258
+ if (write.kind === 'state') {
259
+ const call = stateCall(context, section, id, write.state);
260
+ return call ?? { error: 'That repository is not addressable on this host.' };
261
+ }
262
+ if (write.kind === 'review') {
263
+ const call = reviewCall(context, section, id, write.verdict, write.body);
264
+ return call ?? { error: 'That repository is not addressable on this host.' };
265
+ }
266
+ const call = mergeCall(context, section, id, write.method);
267
+ return call ?? { error: 'That repository is not addressable on this host.' };
268
+ }
269
+
270
+ /** Perform one write. The caller has already checked `writeRefusal`. */
271
+ export async function performWrite(
272
+ context: ForgeContext,
273
+ section: ForgeSection,
274
+ id: string,
275
+ write: ForgeWrite,
276
+ ): Promise<{ ok: true; message: string } | { ok: false; message: string }> {
277
+ const call = callFor(context, section, id, write);
278
+ if ('error' in call) return { ok: false, message: call.error };
279
+
280
+ const result: SendResult = await sendJson({
281
+ url: call.url,
282
+ method: call.method,
283
+ body: call.body,
284
+ headers: authHeaders(context.provider, context.token),
285
+ // The SAME injected fetch the reads use, so a write is testable without a
286
+ // network. Without this the whole write path could only be exercised against
287
+ // a live repository — which is how a smoke run posted a real comment.
288
+ ...(context.fetchImpl ? { fetchImpl: context.fetchImpl } : {}),
289
+ });
290
+ if (!result.ok) return { ok: false, message: result.message };
291
+ return { ok: true, message: call.message };
292
+ }
293
+
294
+ /** The item a write answers with, so the panel can repaint without a read. */
295
+ export function patchedItem(item: ForgeItem, write: ForgeWrite): ForgeItem {
296
+ if (write.kind === 'state') {
297
+ return { ...item, state: write.state === 'closed' ? 'closed' : 'open' };
298
+ }
299
+ if (write.kind === 'merge') return { ...item, state: 'merged' };
300
+ if (write.kind === 'comment') return { ...item, comments: item.comments + 1 };
301
+ return item;
302
+ }
303
+
304
+ /** The provider's display name, for a sentence that has to name it. */
305
+ export function providerLabel(provider: ForgeProvider): string {
306
+ return provider === 'github'
307
+ ? 'GitHub'
308
+ : provider === 'gitlab'
309
+ ? 'GitLab'
310
+ : provider === 'gitea'
311
+ ? 'Gitea'
312
+ : 'Bitbucket';
313
+ }