@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,118 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * Four hosts, four CI vocabularies, one badge.
8
+ *
9
+ * The mapping is a table rather than a chain of `if`s because the values are
10
+ * enumerable and each host keeps adding to them: GitHub's checks report
11
+ * `success|failure|neutral|skipped|cancelled|timed_out|action_required`, a
12
+ * commit status reports `success|failure|pending|error`, GitLab pipelines report
13
+ * `success|failed|running|pending|canceled|skipped|manual|created|waiting_for_resource`,
14
+ * Gitea reports `success|failure|pending|error|warning`, and Bitbucket reports
15
+ * `SUCCESSFUL|FAILED|INPROGRESS|STOPPED`.
16
+ *
17
+ * **A word nobody recognizes is `neutral`, never `failure`.** A host that adds a
18
+ * state must not paint a red badge over a change that may be fine — and it must
19
+ * not paint green either. `neutral` is the honest third answer, and the tooltip
20
+ * carries the host's own word so the reader can see what it actually said.
21
+ *
22
+ * The roll-up is `worst wins`: one failing job in twenty is a failing pipeline,
23
+ * because that is what blocks a merge.
24
+ */
25
+
26
+ import type { ForgeCi, ForgeCiState } from '../protocol';
27
+
28
+ /** Every word seen in the wild, mapped. Unknown words fall to `neutral`. */
29
+ const WORDS: Readonly<Record<string, ForgeCiState>> = {
30
+ // GitHub checks and commit statuses.
31
+ success: 'success',
32
+ neutral: 'neutral',
33
+ skipped: 'neutral',
34
+ cancelled: 'neutral',
35
+ failure: 'failure',
36
+ timed_out: 'failure',
37
+ action_required: 'failure',
38
+ error: 'failure',
39
+ pending: 'pending',
40
+ queued: 'pending',
41
+ in_progress: 'pending',
42
+ waiting: 'pending',
43
+ // GitLab pipelines.
44
+ failed: 'failure',
45
+ running: 'pending',
46
+ created: 'pending',
47
+ manual: 'pending',
48
+ waiting_for_resource: 'pending',
49
+ preparing: 'pending',
50
+ scheduled: 'pending',
51
+ canceled: 'neutral',
52
+ // Gitea.
53
+ warning: 'neutral',
54
+ // Bitbucket.
55
+ successful: 'success',
56
+ inprogress: 'pending',
57
+ stopped: 'neutral',
58
+ };
59
+
60
+ /** The normalized state for one host word. */
61
+ export function ciStateOf(word: string | null | undefined): ForgeCiState {
62
+ return WORDS[(word ?? '').trim().toLowerCase()] ?? 'neutral';
63
+ }
64
+
65
+ /** Rank for a roll-up: a worse verdict wins. */
66
+ const RANK: Record<ForgeCiState, number> = { success: 0, neutral: 1, pending: 2, failure: 3 };
67
+
68
+ /** The worst of the given states, or null when there are none. */
69
+ export function worstCi(states: readonly ForgeCiState[]): ForgeCiState | null {
70
+ if (states.length === 0) return null;
71
+ return states.reduce((worst, state) => (RANK[state] > RANK[worst] ? state : worst), states[0]);
72
+ }
73
+
74
+ /**
75
+ * One badge from a list of host states.
76
+ *
77
+ * `url` is the page a reader would open to see the run, which is why it is
78
+ * carried rather than derived: each host puts it somewhere different (a check
79
+ * run's `html_url`, a pipeline's `web_url`).
80
+ */
81
+ export function ciBadge(words: readonly (string | null | undefined)[], url: string | null): ForgeCi | null {
82
+ const present = words.filter((word): word is string => typeof word === 'string' && word.trim() !== '');
83
+ if (present.length === 0) return null;
84
+ const state = worstCi(present.map(ciStateOf));
85
+ if (!state) return null;
86
+ // The label names what the host said, and the count when there are several:
87
+ // `success` for one run, `5 checks` when it is a roll-up.
88
+ const label = present.length === 1 ? present[0] : `${present.length} checks`;
89
+ return { state, label, url };
90
+ }
91
+
92
+ /**
93
+ * A GitHub check-runs payload rolled up.
94
+ *
95
+ * `status: queued|in_progress` counts as pending even when a `conclusion` is
96
+ * absent, which is the shape a run in flight has — reading only `conclusion`
97
+ * would call an unfinished run `neutral` and paint a grey badge over a job that
98
+ * has not started.
99
+ */
100
+ export function githubChecks(payload: unknown, url: string | null): ForgeCi | null {
101
+ const runs = Array.isArray((payload as { check_runs?: unknown })?.check_runs)
102
+ ? ((payload as { check_runs: unknown[] }).check_runs as Array<Record<string, unknown>>)
103
+ : [];
104
+ if (runs.length === 0) return null;
105
+ const words = runs.map((run) => {
106
+ const conclusion = typeof run.conclusion === 'string' ? run.conclusion : '';
107
+ if (conclusion) return conclusion;
108
+ return typeof run.status === 'string' ? run.status : '';
109
+ });
110
+ return ciBadge(words, url);
111
+ }
112
+
113
+ /** A GitHub combined-status payload rolled up, for a commit with no checks. */
114
+ export function githubStatus(payload: unknown, url: string | null): ForgeCi | null {
115
+ const state = (payload as { state?: unknown })?.state;
116
+ if (typeof state !== 'string' || !state) return null;
117
+ return ciBadge([state], url);
118
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * One read, as both adapters perform it.
8
+ *
9
+ * The context exists so an adapter is a pure transcription: it is handed a way to
10
+ * GET a URL and answers protocol shapes. That is what makes the mapping testable
11
+ * against a recorded body with no host, no token and no socket — and it is why
12
+ * neither adapter owns the cache, the credential or the timeout.
13
+ */
14
+
15
+ import type { ForgeFilter, ForgeProvider } from '../protocol';
16
+ import { authHeaders, getJson, getText, type GetResult, type JsonCache } from './http';
17
+
18
+ export interface ForgeContext {
19
+ provider: ForgeProvider;
20
+ apiBase: string;
21
+ /** `owner/name`, subgroups included. */
22
+ slug: string;
23
+ webUrl: string;
24
+ host: string;
25
+ token: string | null;
26
+ perPage: number;
27
+ /** What the read is narrowed to. Every adapter translates it to its own grammar. */
28
+ filter: ForgeFilter;
29
+ cache: JsonCache;
30
+ /** Injected by the tests; production reads the platform's own `fetch`. */
31
+ fetchImpl?: typeof fetch;
32
+ }
33
+
34
+ /** One JSON read, with this context's credential and cache. */
35
+ export async function get(context: ForgeContext, url: string): Promise<GetResult> {
36
+ return getJson({
37
+ cache: context.cache,
38
+ url,
39
+ headers: authHeaders(context.provider, context.token),
40
+ ...(context.fetchImpl ? { fetchImpl: context.fetchImpl } : {}),
41
+ });
42
+ }
43
+
44
+ /**
45
+ * One TEXT read, for the hosts that answer a diff as `text/plain`.
46
+ *
47
+ * Re-exported here rather than imported from `http.ts` at each call site, so an
48
+ * adapter has one module to reach for and cannot pick the JSON reader by habit —
49
+ * which is exactly how a diff came back empty with a note about JSON.
50
+ */
51
+ export async function getTextWith(context: ForgeContext, url: string): Promise<GetResult> {
52
+ return getText({
53
+ cache: context.cache,
54
+ url,
55
+ headers: authHeaders(context.provider, context.token),
56
+ ...(context.fetchImpl ? { fetchImpl: context.fetchImpl } : {}),
57
+ });
58
+ }
59
+
60
+ /** Join an API root and a path without doubling or dropping the separator. */
61
+ export function joinUrl(base: string, path: string): string {
62
+ return `${base.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
63
+ }
64
+
65
+ /** The page size a read asks for, clamped to what every host accepts. */
66
+ export function pageSize(context: ForgeContext): number {
67
+ return Math.min(100, Math.max(1, Math.round(context.perPage)));
68
+ }
69
+
70
+ /** Join a query string onto a URL, keeping the path's own query intact. */
71
+ export function withParams(url: string, params: Record<string, string>): string {
72
+ const pairs = Object.entries(params).filter(([, value]) => value !== '');
73
+ if (pairs.length === 0) return url;
74
+ const search = new URLSearchParams(pairs).toString();
75
+ return `${url}${url.includes('?') ? '&' : '?'}${search}`;
76
+ }
@@ -0,0 +1,127 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The diff parser, over the shapes two hosts actually send.
8
+ *
9
+ * Gitea and Bitbucket answer a diff as text, and both were checked against real
10
+ * output before this parser was written: the header is `diff --git a/x b/x`, a
11
+ * new file carries `new file mode`, a deletion carries `+++ /dev/null`, and a
12
+ * rename carries `rename from`/`rename to` with BOTH paths in the header.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+
17
+ import { hasHunks, parseUnifiedDiff } from './diff';
18
+
19
+ const MODIFIED = `diff --git a/src/a.ts b/src/a.ts
20
+ index 1111111..2222222 100644
21
+ --- a/src/a.ts
22
+ +++ b/src/a.ts
23
+ @@ -1,3 +1,4 @@
24
+ one
25
+ -two
26
+ +two
27
+ +three
28
+ three
29
+ `;
30
+
31
+ const ADDED = `diff --git a/new.ts b/new.ts
32
+ new file mode 100644
33
+ index 0000000..3333333
34
+ --- /dev/null
35
+ +++ b/new.ts
36
+ @@ -0,0 +1,2 @@
37
+ +a
38
+ +b
39
+ `;
40
+
41
+ const DELETED = `diff --git a/gone.ts b/gone.ts
42
+ deleted file mode 100644
43
+ index 4444444..0000000
44
+ --- a/gone.ts
45
+ +++ /dev/null
46
+ @@ -1,1 +0,0 @@
47
+ -bye
48
+ `;
49
+
50
+ const RENAMED = `diff --git a/old/name.ts b/new/name.ts
51
+ similarity index 92%
52
+ rename from old/name.ts
53
+ rename to new/name.ts
54
+ index 5555555..6666666 100644
55
+ --- a/old/name.ts
56
+ +++ b/new/name.ts
57
+ @@ -1,1 +1,1 @@
58
+ -x
59
+ +y
60
+ `;
61
+
62
+ describe('parseUnifiedDiff', () => {
63
+ test('a modified file carries its path, counts and hunk text', () => {
64
+ const [file] = parseUnifiedDiff(MODIFIED);
65
+ expect(file.path).toBe('src/a.ts');
66
+ expect(file.status).toBe('modified');
67
+ expect(file.additions).toBe(2);
68
+ expect(file.deletions).toBe(1);
69
+ expect(file.patch).toContain('@@ -1,3 +1,4 @@');
70
+ });
71
+
72
+ test('a new file is `added`, and the /dev/null spelling agrees with the mode line', () => {
73
+ const [file] = parseUnifiedDiff(ADDED);
74
+ expect(file.path).toBe('new.ts');
75
+ expect(file.status).toBe('added');
76
+ expect(file.additions).toBe(2);
77
+ expect(file.deletions).toBe(0);
78
+ });
79
+
80
+ test('a deleted file is `removed`', () => {
81
+ const [file] = parseUnifiedDiff(DELETED);
82
+ expect(file.path).toBe('gone.ts');
83
+ expect(file.status).toBe('removed');
84
+ expect(file.deletions).toBe(1);
85
+ });
86
+
87
+ test('a rename reports the NEW path, because that is what the file is now', () => {
88
+ const [file] = parseUnifiedDiff(RENAMED);
89
+ expect(file.path).toBe('new/name.ts');
90
+ expect(file.status).toBe('renamed');
91
+ expect(file.additions).toBe(1);
92
+ expect(file.deletions).toBe(1);
93
+ });
94
+
95
+ test('several files are separated at their own headers', () => {
96
+ const files = parseUnifiedDiff(`${MODIFIED}${ADDED}`);
97
+ expect(files.map((file) => file.path)).toEqual(['src/a.ts', 'new.ts']);
98
+ expect(files.map((file) => file.status)).toEqual(['modified', 'added']);
99
+ });
100
+
101
+ test('a diff with no header at all still yields the text', () => {
102
+ const files = parseUnifiedDiff('+only a line\n');
103
+ expect(files).toHaveLength(1);
104
+ expect(files[0].path).toBe('(diff)');
105
+ expect(files[0].additions).toBe(1);
106
+ });
107
+
108
+ test('an empty diff yields nothing', () => {
109
+ expect(parseUnifiedDiff('')).toEqual([]);
110
+ expect(parseUnifiedDiff('\n\n')).toEqual([]);
111
+ });
112
+
113
+ test('a binary change has no hunks, which the caller renders as a name only', () => {
114
+ const [file] = parseUnifiedDiff(`diff --git a/logo.png b/logo.png
115
+ index 7777777..8888888 100644
116
+ Binary files a/logo.png and b/logo.png differ
117
+ `);
118
+ expect(file.path).toBe('logo.png');
119
+ expect(hasHunks(file)).toBe(false);
120
+ });
121
+
122
+ test('a hunk is kept whole, including its context lines', () => {
123
+ const [file] = parseUnifiedDiff(MODIFIED);
124
+ expect(file.patch.split('\n')[0]).toBe('@@ -1,3 +1,4 @@');
125
+ expect(file.patch).toContain(' one');
126
+ });
127
+ });
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * A unified diff, split into the files it names.
8
+ *
9
+ * Two hosts hand back a diff as TEXT rather than a file list — Gitea's
10
+ * `/pulls/:index.diff` and Bitbucket's `/pullrequests/:id/diff` — and the panel
11
+ * wants the same shape the other two hosts answer with. So this is the one
12
+ * parser between them, and it is deliberately narrow: it reads the file
13
+ * boundaries, the status word and the hunk text, and it does NOT try to apply or
14
+ * verify anything.
15
+ *
16
+ * Three facts are load-bearing:
17
+ *
18
+ * - **A header is `diff --git a/<path> b/<path>`**, and the two sides differ for
19
+ * a rename. The `b/` side is what the file IS now, so that is the path.
20
+ * - **`new file mode` / `deleted file mode` / `rename from`** carry the status;
21
+ * `--- /dev/null` and `+++ /dev/null` are the other spelling of the same
22
+ * thing, and both appear in real diffs depending on the producer.
23
+ * - **A count is the hunk's own `+`/`-` lines, not its header arithmetic.**
24
+ * `@@ -12,7 +12,9 @@` states the range, and a hunk whose body was elided (a host that truncates
25
+ * a large binary change) would report a count the body does not have.
26
+ */
27
+
28
+ import type { ForgeFile } from '../protocol';
29
+
30
+ /** The paths in a `diff --git a/x b/y` header. */
31
+ const HEADER = /^diff --git (?:"?a\/)?(.+?)"?(?: (?:"?b\/)?(.+?)"?)?$/;
32
+
33
+ /** Start a new file record. */
34
+ function blank(path: string): ForgeFile {
35
+ return { path, status: 'modified', additions: 0, deletions: 0, patch: '' };
36
+ }
37
+
38
+ /**
39
+ * Parse one unified diff.
40
+ *
41
+ * A diff with no `diff --git` header at all (a raw patch from an unusual
42
+ * producer) yields one file named `(diff)` rather than nothing: the text is
43
+ * still worth showing, and dropping it would make the panel claim the change
44
+ * touches no files.
45
+ */
46
+ export function parseUnifiedDiff(text: string): ForgeFile[] {
47
+ const lines = text.split('\n');
48
+ const files: ForgeFile[] = [];
49
+ let current: ForgeFile | null = null;
50
+ /** Lines of the hunk body, accumulated so the patch keeps its context. */
51
+ let body: string[] = [];
52
+
53
+ const flush = () => {
54
+ if (!current) return;
55
+ current.patch = body.join('\n').trim();
56
+ files.push(current);
57
+ current = null;
58
+ body = [];
59
+ };
60
+
61
+ for (const line of lines) {
62
+ const header = line.match(HEADER);
63
+ if (header) {
64
+ flush();
65
+ const path = (header[2] ?? header[1] ?? '').trim();
66
+ current = blank(path);
67
+ continue;
68
+ }
69
+
70
+ if (!current) {
71
+ // Text before the first header is a preamble (`Binary files differ`, a
72
+ // signature); it belongs to no file, so it is dropped rather than
73
+ // attributed to the next one.
74
+ if (line.startsWith('--- ') || line.startsWith('+++ ')) continue;
75
+ if (!line.trim()) continue;
76
+ current = blank('(diff)');
77
+ }
78
+
79
+ if (line.startsWith('new file mode')) {
80
+ current.status = 'added';
81
+ continue;
82
+ }
83
+ if (line.startsWith('deleted file mode')) {
84
+ current.status = 'removed';
85
+ continue;
86
+ }
87
+ if (line.startsWith('rename from ')) {
88
+ current.status = 'renamed';
89
+ continue;
90
+ }
91
+ if (line.startsWith('--- ')) {
92
+ if (line.includes('/dev/null')) current.status = 'added';
93
+ continue;
94
+ }
95
+ if (line.startsWith('+++ ')) {
96
+ if (line.includes('/dev/null')) current.status = 'removed';
97
+ continue;
98
+ }
99
+ // A file-level metadata line (`index abc..def`, `similarity index 92%`).
100
+ if (/^(index |similarity index|old mode|new mode|Binary files)/.test(line)) continue;
101
+
102
+ if (line.startsWith('+')) current.additions += 1;
103
+ else if (line.startsWith('-')) current.deletions += 1;
104
+ body.push(line);
105
+ }
106
+
107
+ flush();
108
+ return files;
109
+ }
110
+
111
+ /**
112
+ * Whether a diff is worth rendering.
113
+ *
114
+ * A binary change produces `Binary files … differ` and no hunks, so a panel that
115
+ * draws it as an empty code block looks broken. The caller shows the file's name
116
+ * and status instead.
117
+ */
118
+ export function hasHunks(file: ForgeFile): boolean {
119
+ return file.patch.includes('@@') || file.patch.startsWith('+') || file.patch.startsWith('-');
120
+ }
@@ -0,0 +1,138 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The filter grammars, which are where a filter silently returns nothing.
8
+ *
9
+ * Every case below is a quoting or vocabulary rule that produces a VALID request
10
+ * and an empty result when it is wrong — the failure mode a reader cannot
11
+ * distinguish from "there is nothing here".
12
+ */
13
+
14
+ import { describe, expect, test } from 'bun:test';
15
+
16
+ import type { ForgeFilter } from '../protocol';
17
+ import { bitbucketQuery, bare, filtersAnything, giteaParams, githubSearch, gitlabParams, quoted } from './filters';
18
+
19
+ const base: ForgeFilter = { state: 'open', mine: false, label: '', query: '' };
20
+
21
+ describe('quoted', () => {
22
+ test('wraps a value and drops the quote characters it cannot escape', () => {
23
+ expect(quoted('good first issue')).toBe('"good first issue"');
24
+ expect(quoted('a"b')).toBe('"ab"');
25
+ expect(quoted('a\\b')).toBe('"ab"');
26
+ });
27
+ });
28
+
29
+ describe('bare', () => {
30
+ test('collapses whitespace so one field cannot add a qualifier', () => {
31
+ expect(bare(' a b ')).toBe('a b');
32
+ });
33
+ });
34
+
35
+ describe('githubSearch', () => {
36
+ test('the default filter is repo + kind + state', () => {
37
+ expect(githubSearch('o/n', 'issues', base)).toBe('repo:o/n is:issue state:open');
38
+ expect(githubSearch('o/n', 'pulls', base)).toBe('repo:o/n is:pr state:open');
39
+ });
40
+
41
+ test('all omits the state qualifier rather than sending `state:all`', () => {
42
+ expect(githubSearch('o/n', 'issues', { ...base, state: 'all' })).not.toContain('state:');
43
+ });
44
+
45
+ test('mine becomes assignee:@me', () => {
46
+ expect(githubSearch('o/n', 'issues', { ...base, mine: true })).toContain('assignee:@me');
47
+ });
48
+
49
+ test('a label with a space is QUOTED, or the search reads the second word as a qualifier', () => {
50
+ expect(githubSearch('o/n', 'issues', { ...base, label: 'good first issue' })).toContain(
51
+ 'label:"good first issue"',
52
+ );
53
+ expect(githubSearch('o/n', 'issues', { ...base, label: 'bug' })).toContain('label:bug');
54
+ });
55
+
56
+ test('a quote in the label cannot close the qualifier', () => {
57
+ const q = githubSearch('o/n', 'issues', { ...base, label: 'a"b' });
58
+ expect(q.match(/"/g)?.length).toBe(2);
59
+ });
60
+
61
+ test('free text rides as typed, and its whitespace is collapsed', () => {
62
+ expect(githubSearch('o/n', 'issues', { ...base, query: ' crash on start ' })).toContain('crash on start');
63
+ });
64
+ });
65
+
66
+ describe('gitlabParams', () => {
67
+ test('the default sends the host its own state word', () => {
68
+ expect(gitlabParams('issues', base)).toEqual({ state: 'opened' });
69
+ expect(gitlabParams('issues', { ...base, state: 'closed' })).toEqual({ state: 'closed' });
70
+ expect(gitlabParams('issues', { ...base, state: 'all' })).toEqual({});
71
+ });
72
+
73
+ test('mine becomes scope, never assignee_username', () => {
74
+ expect(gitlabParams('pulls', { ...base, mine: true })).toEqual({ state: 'opened', scope: 'assigned_to_me' });
75
+ });
76
+
77
+ test('label and text are their own parameters', () => {
78
+ expect(gitlabParams('issues', { ...base, label: 'bug', query: 'crash' })).toEqual({
79
+ state: 'opened',
80
+ labels: 'bug',
81
+ search: 'crash',
82
+ });
83
+ });
84
+
85
+ test('releases carry no filter at all', () => {
86
+ expect(gitlabParams('releases', { ...base, mine: true, label: 'x', query: 'y' })).toEqual({});
87
+ });
88
+ });
89
+
90
+ describe('giteaParams', () => {
91
+ test('the section becomes the type parameter, on one endpoint', () => {
92
+ expect(giteaParams('issues', base)).toEqual({ type: 'issues', state: 'open' });
93
+ expect(giteaParams('pulls', base)).toEqual({ type: 'pulls', state: 'open' });
94
+ expect(giteaParams('releases', base)).toEqual({});
95
+ });
96
+
97
+ test('mine is assigned=true and the text is q', () => {
98
+ expect(giteaParams('issues', { ...base, mine: true, query: 'crash' })).toEqual({
99
+ type: 'issues',
100
+ state: 'open',
101
+ assigned: 'true',
102
+ q: 'crash',
103
+ });
104
+ });
105
+ });
106
+
107
+ describe('bitbucketQuery', () => {
108
+ test('closed is the three closed states, because one word cannot say it', () => {
109
+ expect(bitbucketQuery('pulls', { ...base, state: 'closed' })).toContain('state="MERGED"');
110
+ expect(bitbucketQuery('pulls', { ...base, state: 'closed' })).toContain('state="DECLINED"');
111
+ });
112
+
113
+ test('an all filter sends no state clause', () => {
114
+ expect(bitbucketQuery('pulls', { ...base, state: 'all' })).toBe('');
115
+ });
116
+
117
+ test('a label is a query clause, because there is no parameter for it', () => {
118
+ expect(bitbucketQuery('issues', { ...base, label: 'bug' })).toContain('labels ~ "bug"');
119
+ });
120
+
121
+ test('text matches the title', () => {
122
+ expect(bitbucketQuery('issues', { ...base, query: 'crash' })).toContain('title ~ "crash"');
123
+ });
124
+ });
125
+
126
+ describe('filtersAnything', () => {
127
+ test('only the default filter is nothing', () => {
128
+ expect(filtersAnything(base)).toBe(false);
129
+ for (const filter of [
130
+ { ...base, state: 'all' as const },
131
+ { ...base, mine: true },
132
+ { ...base, label: 'bug' },
133
+ { ...base, query: 'crash' },
134
+ ]) {
135
+ expect(filtersAnything(filter)).toBe(true);
136
+ }
137
+ });
138
+ });