@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
@@ -110,3 +110,31 @@ export function fetchModelsNote(result: {
110
110
  }
111
111
  return null;
112
112
  }
113
+
114
+ /**
115
+ * The line reported after omp re-ran model discovery.
116
+ *
117
+ * The refresh is CATALOG-WIDE (`omp models refresh` is the only granularity omp
118
+ * offers), so a per-provider report would overstate what happened. Saying so is
119
+ * the honest half: the counts are this provider's, and the run covered all of
120
+ * them.
121
+ */
122
+ export function refreshModelsMessage(
123
+ providerName: string,
124
+ result: { added: number; removed: number },
125
+ ): { text: string; tone: 'success' | 'error' } {
126
+ const plural = (count: number) => (count === 1 ? '' : 's');
127
+ if (result.added > 0 || result.removed > 0) {
128
+ const parts: string[] = [];
129
+ if (result.added > 0) parts.push(`${result.added} new model${plural(result.added)}`);
130
+ if (result.removed > 0) parts.push(`${result.removed} model${plural(result.removed)} gone`);
131
+ return {
132
+ text: `${providerName}: ${parts.join(', ')} after omp re-ran discovery.`,
133
+ tone: 'success',
134
+ };
135
+ }
136
+ return {
137
+ text: `${providerName}: omp re-ran discovery — this provider's list is unchanged.`,
138
+ tone: 'success',
139
+ };
140
+ }
@@ -0,0 +1,178 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * Model-level actions for one provider: discovery refresh, the endpoint import,
8
+ * visibility toggles and the per-model overrides.
9
+ *
10
+ * Split from `actions.ts` (provider-level: add, connect, enable/disable, delete)
11
+ * because the two halves answer different questions and both were growing. The
12
+ * distinction matters for reporting too: a provider-level failure leaves the
13
+ * panel unchanged, while a model-level one has to say WHICH model it was about.
14
+ */
15
+
16
+ import type { ProviderItem, ProviderModel } from '@/shared/types';
17
+ import { notifyModelsUpdated } from '@/shared/lib/models/client';
18
+ import { refreshProviderCatalog } from '@/shared/lib/models/provider/connection';
19
+ import {
20
+ fetchProviderModelsRemote,
21
+ replaceProviderModels,
22
+ syncProviderModelsToCatalog,
23
+ } from '@/shared/lib/models/provider/models';
24
+ import { removeLegacyKenariModels } from '@/shared/lib/models/provider/cleanup';
25
+ import { fetchModelsMessage, fetchModelsNote, refreshModelsMessage } from '@/client/hooks/settings/providers/messages';
26
+ import { saveModelOverrideRemote } from '@/client/hooks/settings/providers/api';
27
+
28
+ export interface ModelActionsDeps {
29
+ providers: ProviderItem[];
30
+ selectedProvider: ProviderItem | undefined;
31
+ isFetchingModels: boolean;
32
+ pushToast: (message: string, tone: 'success' | 'error') => void;
33
+ setProviders: (providers: ProviderItem[]) => void;
34
+ setIsFetchingModels: (fetching: boolean) => void;
35
+ persistProviders: (updated: ProviderItem[]) => Promise<void>;
36
+ reloadProviders: () => Promise<ProviderItem[]>;
37
+ }
38
+
39
+ export function createModelActions(deps: ModelActionsDeps) {
40
+ const {
41
+ providers,
42
+ selectedProvider,
43
+ isFetchingModels,
44
+ pushToast,
45
+ setProviders,
46
+ setIsFetchingModels,
47
+ persistProviders,
48
+ reloadProviders,
49
+ } = deps;
50
+
51
+ /**
52
+ * Ask omp to re-run discovery (`omp models refresh`).
53
+ *
54
+ * This is omp's own refresh, not a Kabmo-side probe: the CLI re-mints
55
+ * `!command` credentials and updates the catalog the chat picker reads, so the
56
+ * panel and the agent cannot disagree about what a provider serves. It is
57
+ * catalog-wide because that is the only granularity omp offers — the message
58
+ * says so instead of implying per-provider discovery.
59
+ */
60
+ const handleRefreshModels = async () => {
61
+ if (!selectedProvider || isFetchingModels) return;
62
+ const target = selectedProvider;
63
+ setIsFetchingModels(true);
64
+ try {
65
+ const result = await refreshProviderCatalog(target.slug);
66
+ if (!result.ok) {
67
+ pushToast(result.error || 'omp could not refresh the model catalog.', 'error');
68
+ return;
69
+ }
70
+ if (result.providers) setProviders(result.providers);
71
+ const message = refreshModelsMessage(target.name, result);
72
+ pushToast(message.text, message.tone);
73
+ } finally {
74
+ setIsFetchingModels(false);
75
+ }
76
+ };
77
+
78
+ /**
79
+ * The listing probe: ask the ENDPOINT what it serves and write those ids into
80
+ * `models.yml`.
81
+ *
82
+ * Only for a provider whose models are a static list. A discovery provider is
83
+ * listed by omp itself, and writing a snapshot beside that live list is the
84
+ * drift the writer's `overrideOnly` exists to prevent — the button carries a
85
+ * block reason for those instead of quietly doing it.
86
+ */
87
+ const handleFetchModels = async () => {
88
+ if (!selectedProvider || isFetchingModels) return;
89
+ const target = selectedProvider;
90
+ if (!target.baseUrl) {
91
+ pushToast('This provider has no endpoint to import from — use “refresh” instead.', 'error');
92
+ return;
93
+ }
94
+ setIsFetchingModels(true);
95
+ try {
96
+ const result = await fetchProviderModelsRemote({
97
+ baseUrl: target.baseUrl,
98
+ apiKey: target.apiKey,
99
+ providerSlug: target.slug,
100
+ persistToOmp: true,
101
+ // The endpoint's list is the new list, not an addition to the old one.
102
+ replaceModels: true,
103
+ // The provider's own dialect decides the auth header the probe sends;
104
+ // falling back to the URL classifier would send a Bearer header to an
105
+ // Anthropic-shaped proxy that only accepts x-api-key.
106
+ ...(target.api ? { api: target.api } : {}),
107
+ ...(target.auth ? { auth: target.auth } : {}),
108
+ });
109
+ if (!result.ok || !result.models) {
110
+ pushToast(result.error || 'Failed to fetch models from the provider.', 'error');
111
+ return;
112
+ }
113
+ if (result.omp?.written) notifyModelsUpdated();
114
+ const cleaned = removeLegacyKenariModels(target, target.models);
115
+ const legacyRemoved = target.models.length - cleaned.length;
116
+ const { added, addedCount, removedCount } = replaceProviderModels(cleaned, result.models);
117
+ const droppedCount = removedCount + legacyRemoved;
118
+ const message = fetchModelsMessage({ addedCount, removedCount: droppedCount });
119
+ pushToast(message.text, message.tone);
120
+ const note = fetchModelsNote(result);
121
+ if (note) pushToast(note.text, note.tone);
122
+ if (addedCount > 0) void syncProviderModelsToCatalog(target.name, added);
123
+ await reloadProviders();
124
+ } finally {
125
+ setIsFetchingModels(false);
126
+ }
127
+ };
128
+
129
+ const updateSelectedModels = (transform: (models: ProviderModel[]) => ProviderModel[]) => {
130
+ if (!selectedProvider) return;
131
+ void persistProviders(providers.map((provider) => (
132
+ provider.id === selectedProvider.id ? { ...provider, models: transform(provider.models) } : provider
133
+ )));
134
+ };
135
+
136
+ const handleHideAll = () => updateSelectedModels(
137
+ (models) => models.map((model) => ({ ...model, isVisible: false })),
138
+ );
139
+
140
+ const handleShowAll = () => updateSelectedModels(
141
+ (models) => models.map((model) => ({ ...model, isVisible: true })),
142
+ );
143
+
144
+ const handleToggleModelVisibility = (modelId: string) => updateSelectedModels(
145
+ (models) => models.map((model) => (model.id === modelId ? { ...model, isVisible: !model.isVisible } : model)),
146
+ );
147
+
148
+ /**
149
+ * Save the per-model knobs omp honours (`models.yml` modelOverrides). The
150
+ * overlay still stores the display value so the dialog reopens where the user
151
+ * left it, but omp only reads the override — writing just the overlay was the
152
+ * bug that made these controls inert.
153
+ */
154
+ const handleSaveModelConfig = async (modelId: string, updates: Partial<ProviderModel>) => {
155
+ if (!selectedProvider) return;
156
+ const provider = selectedProvider;
157
+ updateSelectedModels((models) => models.map((model) => (
158
+ model.id === modelId ? { ...model, ...updates } : model
159
+ )));
160
+
161
+ const result = await saveModelOverrideRemote(provider.slug, modelId, updates);
162
+ if (!result.ok) {
163
+ pushToast(result.error || 'Failed to save the model configuration.', 'error');
164
+ return;
165
+ }
166
+ if (result.written) notifyModelsUpdated();
167
+ else if (result.reason) pushToast(result.reason, 'error');
168
+ };
169
+
170
+ return {
171
+ handleRefreshModels,
172
+ handleFetchModels,
173
+ handleHideAll,
174
+ handleShowAll,
175
+ handleToggleModelVisibility,
176
+ handleSaveModelConfig,
177
+ };
178
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * Turn an editor exception into a toast.
8
+ *
9
+ * The surface reports through `reportEditorError` (see `editor-errors.ts`), and
10
+ * this is the listener half. It is subscribed from `useToasts`, which every toast
11
+ * host already calls — the desktop layout, its left column, the sessions view,
12
+ * the phone's wrapper, the settings modal — so an editor exception cannot be
13
+ * lost by forgetting one call site.
14
+ *
15
+ * ## One event, one toast
16
+ *
17
+ * Several of those hosts are mounted at once, and a `window` event reaches every
18
+ * listener. Measured on the desktop: one report produced THREE toasts. The event
19
+ * object is therefore claimed by the first listener that shows it, and the rest
20
+ * see the claim and stay quiet. Claiming the event (rather than deduplicating by
21
+ * message) is what keeps two genuinely different errors, raised in the same
22
+ * millisecond, both visible.
23
+ */
24
+
25
+ import { useKabmoEvent } from '@/client/hooks/ui/window-event';
26
+ import { EDITOR_ERROR_EVENT } from '@/client/lib/editor-errors';
27
+
28
+ /** What `pushToast` accepts, named so this hook does not import the toast host. */
29
+ type PushToast = (message: string, type?: 'success' | 'error', options?: { duration?: number }) => void;
30
+
31
+ /** Longer than a normal toast: the message is a bug report, not a confirmation. */
32
+ const EDITOR_ERROR_TOAST_MS = 8000;
33
+
34
+ /** Events already shown by one listener. Weak, so a dispatched event is not retained. */
35
+ const claimed = new WeakSet<Event>();
36
+
37
+ export function useEditorErrorToast(pushToast: PushToast): void {
38
+ useKabmoEvent(EDITOR_ERROR_EVENT, (event) => {
39
+ if (claimed.has(event)) return;
40
+ const message = (event as CustomEvent<{ message?: string }>).detail?.message;
41
+ if (!message) return;
42
+ claimed.add(event);
43
+ // The prefix names the source: the same sentence from a fetch failure would
44
+ // otherwise read as a network problem.
45
+ pushToast(`Editor error: ${message}`, 'error', { duration: EDITOR_ERROR_TOAST_MS });
46
+ });
47
+ }
@@ -17,6 +17,12 @@ export interface OpenFilePayload {
17
17
  * instead of `/api/fs/action`. See `client/lib/launch/file-handlers`.
18
18
  */
19
19
  handleId?: string;
20
+ /**
21
+ * True when the bytes came from the DEVICE rather than from the server (a
22
+ * document the phone handed over). The tab renders and cannot be written back,
23
+ * because there is no path to write to and no writable handle.
24
+ */
25
+ deviceFile?: boolean;
20
26
  }
21
27
 
22
28
  /**
@@ -42,6 +48,7 @@ export function openFileInEditor(payloadOrPath: string | OpenFilePayload) {
42
48
  root: payload.root,
43
49
  repo: payload.repo,
44
50
  handleId: payload.handleId,
51
+ deviceFile: payload.deviceFile,
45
52
  }
46
53
  })
47
54
  );
@@ -1,5 +1,6 @@
1
1
  import { useRef, useState } from 'preact/hooks';
2
2
  import type { ToastData } from '@/client/components/common/Toast';
3
+ import { useEditorErrorToast } from '@/client/hooks/ui/editor-error-toast';
3
4
 
4
5
  /** What `useToasts` hands back — named, so a component takes the contract rather than `ReturnType`. */
5
6
  export interface ToastsHandle {
@@ -29,5 +30,11 @@ export function useToasts(): ToastsHandle {
29
30
  setToasts(prev => prev.filter(t => t.id !== id));
30
31
  };
31
32
 
33
+ // Every toast host already calls this hook — both shells, the sidebar and the
34
+ // settings modal — so subscribing here is what makes an editor exception
35
+ // impossible to miss by forgetting one call site. A CodeMirror plugin that
36
+ // throws is caught by the library and would otherwise reach only the console.
37
+ useEditorErrorToast(pushToast);
38
+
32
39
  return { toasts, pushToast, dismissToast };
33
40
  }
@@ -20,6 +20,8 @@ export interface OpenFileInput {
20
20
  repo?: string;
21
21
  /** The live handle a PWA launch opened this file through, when there is one. */
22
22
  handleId?: string;
23
+ /** The bytes came from the device, not from a server path. */
24
+ deviceFile?: boolean;
23
25
  }
24
26
 
25
27
  /**
@@ -260,7 +262,7 @@ export function useFileTabs(
260
262
 
261
263
  // Global listeners for omp:open-file and omp:open-diff
262
264
  useKabmoEvent('omp:open-file', (e) => {
263
- const customEvent = e as CustomEvent<{ path: string; name?: string; id?: number; content?: string; root?: string; repo?: string; handleId?: string }>;
265
+ const customEvent = e as CustomEvent<{ path: string; name?: string; id?: number; content?: string; root?: string; repo?: string; handleId?: string; deviceFile?: boolean }>;
264
266
  if (!customEvent.detail || !customEvent.detail.path) return;
265
267
 
266
268
  const rawPath = customEvent.detail.path.replace(/^\/+/, '');
@@ -276,6 +278,7 @@ export function useFileTabs(
276
278
  root: customEvent.detail.root,
277
279
  repo: customEvent.detail.repo,
278
280
  handleId: customEvent.detail.handleId,
281
+ deviceFile: customEvent.detail.deviceFile,
279
282
  });
280
283
  });
281
284
 
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The one folder-expansion write.
8
+ *
9
+ * Both non-header callers (the phone's toggle and the sidebar's auto-expand)
10
+ * go through it, so what it must get right is the REQUEST: the route's URL, the
11
+ * form body the action reads, and a boolean answer the caller can trust.
12
+ */
13
+
14
+ import { afterEach, describe, expect, test } from 'bun:test';
15
+
16
+ import { setFolderExpanded } from '@/client/hooks/workspace/folder-expansion';
17
+
18
+ const originalFetch = globalThis.fetch;
19
+
20
+ afterEach(() => {
21
+ globalThis.fetch = originalFetch;
22
+ });
23
+
24
+ interface Call {
25
+ url: string;
26
+ body: Record<string, string>;
27
+ }
28
+
29
+ /** Answer every request with `status`, recording what was sent. */
30
+ function stubFetch(status: number): Call[] {
31
+ const calls: Call[] = [];
32
+ globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
33
+ const body = init?.body instanceof URLSearchParams
34
+ ? Object.fromEntries(init.body.entries())
35
+ : {};
36
+ calls.push({ url: String(input), body });
37
+ return new Response('{}', { status });
38
+ }) as unknown as typeof fetch;
39
+ return calls;
40
+ }
41
+
42
+ describe('setFolderExpanded', () => {
43
+ test('POSTs the toggle with the flag as form data', async () => {
44
+ const calls = stubFetch(200);
45
+
46
+ expect(await setFolderExpanded(7, true)).toBe(true);
47
+ expect(calls).toEqual([{ url: '/api/folders/7/toggle', body: { isExpanded: 'true' } }]);
48
+
49
+ expect(await setFolderExpanded(7, false)).toBe(true);
50
+ expect(calls[1]).toEqual({ url: '/api/folders/7/toggle', body: { isExpanded: 'false' } });
51
+ });
52
+
53
+ test('reports a refused write instead of claiming it landed', async () => {
54
+ stubFetch(500);
55
+ expect(await setFolderExpanded(7, true)).toBe(false);
56
+ });
57
+
58
+ test('reports a request that never reached the server', async () => {
59
+ globalThis.fetch = (() => Promise.reject(new Error('offline'))) as unknown as typeof fetch;
60
+ expect(await setFolderExpanded(7, true)).toBe(false);
61
+ });
62
+ });
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The folder expand/collapse write, for every caller that is not the desktop
8
+ * category header.
9
+ *
10
+ * `workspace_folders.is_expanded` is the one stored fact both layouts render,
11
+ * and the route republishes the `sidebar` structure topic on the write, so a
12
+ * caller only has to issue the request — it never has to update local state.
13
+ *
14
+ * The desktop header keeps its own `useFetcher` submit (it re-dispatches on the
15
+ * response); that difference is documented in `workspace-folder-actions.ts`.
16
+ * The phone's toggle and the controller's auto-expand both come through here so
17
+ * the URL and body cannot drift.
18
+ */
19
+ export async function setFolderExpanded(
20
+ folderId: number | string,
21
+ isExpanded: boolean,
22
+ ): Promise<boolean> {
23
+ try {
24
+ const response = await fetch(`/api/folders/${encodeURIComponent(String(folderId))}/toggle`, {
25
+ method: 'POST',
26
+ body: new URLSearchParams({ isExpanded: String(isExpanded) }),
27
+ });
28
+ return response.ok;
29
+ } catch (error) {
30
+ console.error('Failed to save workspace expansion:', error);
31
+ return false;
32
+ }
33
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * What the Source Control panel does with an action's answer: show a page the
8
+ * action READ, re-read the tree after a mutation, and report the outcome.
9
+ *
10
+ * Split out of `GitPanel` for the repo's line ceiling, and because the two
11
+ * rules in it are ordering rules rather than rendering:
12
+ *
13
+ * - **A response is acted on ONCE.** `useFetcher`'s payload is STICKY — it
14
+ * holds the last response for the life of the mount — while the reload
15
+ * callback's identity changes whenever the scope does. Switching to a
16
+ * session in another workspace therefore re-ran the effect against the
17
+ * PREVIOUS history payload and reopened a modal the user had dismissed,
18
+ * which is the reported "clicking a session item opens the commit modal".
19
+ * - **A successful mutation says what it did.** The payload carries `success`
20
+ * and, when an operation was left stopped on a conflict, WHICH one; the verb
21
+ * and its operands are recorded at dispatch (`lastAction`) and read back
22
+ * here, because the answer arrives a render later and the user may have
23
+ * pressed something else by then. `action-message.ts` owns the wording, and
24
+ * owns the decision that a stage/unstage/discard stays silent.
25
+ */
26
+
27
+ import { useEffect, useRef } from 'preact/hooks';
28
+ import type { CommitHistoryPage } from '@/shared/types';
29
+ import type { GitActionFetcher } from '@/client/hooks/workspace/git-actions';
30
+ import { gitActionSuccessMessage } from '@/client/lib/git/action-message';
31
+
32
+ export interface GitActionOutcomeOptions {
33
+ /** The mutation channel, with the action its payload answers. */
34
+ fetcher: GitActionFetcher;
35
+ /** A read that answered with a page (the history / graph modal). */
36
+ onPage: (page: CommitHistoryPage) => void;
37
+ /** An accepted mutation landed: re-read the working tree. */
38
+ onReload: () => void;
39
+ /** An accepted mutation, in the sentence the user reads. */
40
+ onSuccess: (message: string) => void;
41
+ /** The server's refusal, or a transport failure. */
42
+ onError: (message: string) => void;
43
+ }
44
+
45
+ export function useGitActionOutcome(options: GitActionOutcomeOptions): void {
46
+ const { fetcher, onPage, onReload, onSuccess, onError } = options;
47
+ /** The payload this hook has already acted on. */
48
+ const consumedRef = useRef<unknown>(null);
49
+ // The callbacks are inline arrows at the call site, so they are read through
50
+ // a ref: the effect keys on the RESPONSE, never on a new closure.
51
+ const handlersRef = useRef({ onPage, onReload, onSuccess, onError });
52
+ handlersRef.current = { onPage, onReload, onSuccess, onError };
53
+
54
+ useEffect(() => {
55
+ if (fetcher.state !== 'idle' || !fetcher.data) return;
56
+ const payload = fetcher.data;
57
+ if (payload === consumedRef.current) return;
58
+ consumedRef.current = payload;
59
+ const handlers = handlersRef.current;
60
+
61
+ if (payload.type === 'history' || payload.type === 'graph') {
62
+ // `hasMore` and `total` are part of the page, not decoration: without
63
+ // them the modal cannot know the branch holds more than the 50 rows it
64
+ // was handed, and the header reports the page size as the total.
65
+ handlers.onPage({
66
+ title: payload.type === 'graph' ? 'Git Graph' : 'Commit History',
67
+ data: payload.data || [],
68
+ hasMore: payload.hasMore,
69
+ total: payload.total,
70
+ });
71
+ return;
72
+ }
73
+
74
+ if (!payload.success) {
75
+ handlers.onError(payload.error || 'Git operation failed');
76
+ return;
77
+ }
78
+
79
+ handlers.onReload();
80
+ const dispatched = fetcher.lastAction;
81
+ const message = dispatched
82
+ ? gitActionSuccessMessage({ ...dispatched, stopped: payload.stopped })
83
+ : null;
84
+ if (message) handlers.onSuccess(message);
85
+ }, [fetcher.state, fetcher.data, fetcher.lastAction]);
86
+ }
@@ -1,4 +1,4 @@
1
- import { useCallback } from 'preact/hooks';
1
+ import { useCallback, useRef } from 'preact/hooks';
2
2
  import { useFetcher, type FetcherState } from '@/client/lib/router/fetcher';
3
3
 
4
4
  interface ActionPayload {
@@ -8,6 +8,21 @@ interface ActionPayload {
8
8
  hasMore?: boolean;
9
9
  total?: number;
10
10
  error?: string;
11
+ /**
12
+ * The operation the action left stopped on a conflict (`merge`, `rebase`,
13
+ * `stash-pop`, …), reported by the verbs that can leave one.
14
+ *
15
+ * A stopped operation is a SUCCESS with a different outcome — the pull ran
16
+ * but the push did not, the merge started but nothing is merged — so the
17
+ * toast cannot be built from `success` alone.
18
+ */
19
+ stopped?: string | null;
20
+ }
21
+
22
+ /** The action a response answers, kept so the toast can name what it acted on. */
23
+ export interface GitDispatchedAction {
24
+ actionType: string;
25
+ extra?: Record<string, string>;
11
26
  }
12
27
 
13
28
  export interface GitActionFetcher {
@@ -17,6 +32,16 @@ export interface GitActionFetcher {
17
32
  execute: (actionType: string, file?: string, extra?: Record<string, string>) => void;
18
33
  /** The last response, consumed exactly once by the caller's effect. */
19
34
  data: ActionPayload | undefined;
35
+ /**
36
+ * The fields of the action `data` answers.
37
+ *
38
+ * Recorded HERE rather than at each call site: the panel reaches `execute`
39
+ * from a dozen handlers (the toolbar, the change rows, the modals, the commit
40
+ * box), and a toast that reads the dispatch's own operands — the branch, the
41
+ * commit subject, the stash ref — needs them without threading a second
42
+ * argument through every one of them.
43
+ */
44
+ lastAction: GitDispatchedAction | null;
20
45
  }
21
46
 
22
47
  /**
@@ -36,9 +61,11 @@ export interface GitActionFetcher {
36
61
  */
37
62
  export function useGitActions(rootPath: string | undefined, activeRepo: string): GitActionFetcher {
38
63
  const fetcher = useFetcher<ActionPayload>();
64
+ const lastActionRef = useRef<GitDispatchedAction | null>(null);
39
65
 
40
66
  const execute = useCallback(
41
67
  (actionType: string, file?: string, extra?: Record<string, string>) => {
68
+ lastActionRef.current = { actionType, extra };
42
69
  const formData = new FormData();
43
70
  formData.append('actionType', actionType);
44
71
  formData.append('repo', activeRepo);
@@ -52,5 +79,5 @@ export function useGitActions(rootPath: string | undefined, activeRepo: string):
52
79
  [activeRepo, rootPath, fetcher],
53
80
  );
54
81
 
55
- return { state: fetcher.state, execute, data: fetcher.data };
82
+ return { state: fetcher.state, execute, data: fetcher.data, lastAction: lastActionRef.current };
56
83
  }