@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
@@ -4,8 +4,7 @@
4
4
  */
5
5
 
6
6
  /**
7
- * The diff panel's CodeMirror side: the two view shapes, their theme, and the
8
- * counts the toolbar prints.
7
+ * The diff panel's CodeMirror side: the two view shapes and their theme.
9
8
  *
10
9
  * What this replaced: a unified-diff PARSER feeding two hand-built tables
11
10
  * (1 066 lines across `UnifiedView` / `SplitView` plus the diff half of
@@ -14,12 +13,13 @@
14
13
  * real editor range: the gutter markers, the deleted-chunk widgets and the
15
14
  * collapsed stretches are the extension's, not ours.
16
15
  *
17
- * Three facts about this API are load-bearing and none is guessable:
16
+ * Two neighbours own what used to live here, both split out at the per-file
17
+ * ceiling and both with a boundary of their own: `chunks.ts` (stepping through
18
+ * the changes) and `changes.ts` (what the toolbar's badge counts, and the
19
+ * whitespace fold).
20
+ *
21
+ * Two facts about this API are load-bearing and none is guessable:
18
22
  *
19
- * - `getChunks` is a FUNCTION, not a field: `state.field(getChunks)` throws
20
- * "Field is not present in this state". The counts do not need it either —
21
- * `Chunk.build(a, b)` is the same line-level chunking without a view, which
22
- * is what lets a badge be computed before anything is mounted.
23
23
  * - `collapseUnchanged` is CONFIG, so switching *Diff Only* ↔ *Full Code* is a
24
24
  * compartment reconfigure. Re-mounting would drop the reader's scroll.
25
25
  * - The merge package's own colours are hardcoded hex. They are overridden with
@@ -27,13 +27,19 @@
27
27
  * the theme.
28
28
  */
29
29
 
30
- import { Compartment, EditorState, Text, type Extension } from '@codemirror/state';
30
+ import { Compartment, EditorState, type Extension } from '@codemirror/state';
31
31
  import { EditorView, lineNumbers } from '@codemirror/view';
32
- import { Chunk, MergeView, diff, unifiedMergeView } from '@codemirror/merge';
32
+ import { MergeView, unifiedMergeView } from '@codemirror/merge';
33
33
 
34
34
  import { shikiHighlight, type ShikiThemeNames } from '@/client/components/common/code-surface/shiki';
35
35
  import { surfaceTheme } from '@/client/components/common/code-surface/theme';
36
36
  import { diffFoldingExtensions } from '@/client/components/workspace/diff-panel/folding';
37
+ import {
38
+ chunkPositionOf,
39
+ chunkReporter,
40
+ stepChunkIn,
41
+ type ChunkPosition,
42
+ } from '@/client/components/workspace/diff-panel/chunks';
37
43
 
38
44
  /** What the toolbar shows; `diff` collapses the unchanged stretches. */
39
45
  export type CollapseMode = 'diff' | 'full';
@@ -118,6 +124,14 @@ export interface DiffViewOptions {
118
124
  scrollTestId: string;
119
125
  /** The element that scrolls, reported on mount and cleared on unmount. */
120
126
  onScroller: (element: HTMLElement | null) => void;
127
+ /**
128
+ * The chunk the selection is in, reported whenever it moves.
129
+ *
130
+ * Pushed from the view rather than polled by the toolbar: the position is a
131
+ * property of the EDITOR's selection, and a caller that recomputed it on its
132
+ * own render would print a number the view had already moved past.
133
+ */
134
+ onChunkPosition?: (position: ChunkPosition) => void;
121
135
  }
122
136
 
123
137
  export interface DiffViewHandle {
@@ -126,6 +140,22 @@ export interface DiffViewHandle {
126
140
  /** Re-collapse or expand the unchanged stretches without re-mounting. */
127
141
  setCollapse(collapse: CollapseMode): void;
128
142
  setWordWrap(wordWrap: boolean): void;
143
+ /**
144
+ * The changed chunks in the pair on screen, and which one holds the selection.
145
+ *
146
+ * `index` is 0-based, or -1 when the selection is not inside a chunk — which
147
+ * is the normal state for a reader who has not stepped yet. The pair is
148
+ * returned together because they are read in the same render and a caller
149
+ * that fetched them separately could print "3 of 2".
150
+ */
151
+ chunkPosition(): ChunkPosition;
152
+ /**
153
+ * Move the selection to the next (`1`) or previous (`-1`) chunk, wrapping.
154
+ *
155
+ * False when there is nothing to step through, so the toolbar can leave its
156
+ * buttons inert rather than silently doing nothing.
157
+ */
158
+ stepChunk(direction: 1 | -1): boolean;
129
159
  /** The element that actually scrolls, for scroll restore. */
130
160
  scroller(): HTMLElement | null;
131
161
  destroy(): void;
@@ -185,11 +215,18 @@ export function mountUnifiedDiff(parent: HTMLElement, options: DiffViewOptions):
185
215
  parent,
186
216
  state: EditorState.create({
187
217
  doc: options.next,
188
- extensions: [...baseExtensions(options, wrap), collapse.of(unified(original))],
218
+ extensions: [
219
+ ...baseExtensions(options, wrap),
220
+ collapse.of(unified(original)),
221
+ options.onChunkPosition ? chunkReporter(options.onChunkPosition) : [],
222
+ ],
189
223
  }),
190
224
  });
191
225
  if (options.scrollTestId) view.scrollDOM.dataset.testid = options.scrollTestId;
192
226
  options.onScroller(view.scrollDOM);
227
+ // Seeded like the caret: the reporter only fires on a CHANGE, so a freshly
228
+ // mounted diff would otherwise print "0 of 0" over a file with changes.
229
+ options.onChunkPosition?.(chunkPositionOf(view));
193
230
 
194
231
  return {
195
232
  setDocuments(nextOriginal, next) {
@@ -210,6 +247,8 @@ export function mountUnifiedDiff(parent: HTMLElement, options: DiffViewOptions):
210
247
  options.wordWrap = wordWrap;
211
248
  view.dispatch({ effects: wrap.reconfigure(wordWrap ? EditorView.lineWrapping : []) });
212
249
  },
250
+ chunkPosition: () => chunkPositionOf(view),
251
+ stepChunk: (direction) => stepChunkIn(view, direction),
213
252
  scroller: () => view.scrollDOM,
214
253
  destroy: () => {
215
254
  options.onScroller(null);
@@ -224,7 +263,13 @@ export function mountSplitDiff(parent: HTMLElement, options: DiffViewOptions): D
224
263
  const merge = new MergeView({
225
264
  parent,
226
265
  a: { doc: options.original, extensions: baseExtensions(options, wrap) },
227
- b: { doc: options.next, extensions: baseExtensions(options, wrap) },
266
+ b: {
267
+ doc: options.next,
268
+ extensions: [
269
+ ...baseExtensions(options, wrap),
270
+ options.onChunkPosition ? chunkReporter(options.onChunkPosition) : [],
271
+ ],
272
+ },
228
273
  collapseUnchanged: collapseConfig(options.collapse),
229
274
  highlightChanges: true,
230
275
  gutter: true,
@@ -235,6 +280,7 @@ export function mountSplitDiff(parent: HTMLElement, options: DiffViewOptions): D
235
280
  const scroller = merge.dom;
236
281
  if (options.scrollTestId) scroller.dataset.testid = options.scrollTestId;
237
282
  options.onScroller(scroller);
283
+ options.onChunkPosition?.(chunkPositionOf(merge.b));
238
284
 
239
285
  return {
240
286
  setDocuments(original, next) {
@@ -254,6 +300,12 @@ export function mountSplitDiff(parent: HTMLElement, options: DiffViewOptions): D
254
300
  merge.a.dispatch({ effects });
255
301
  merge.b.dispatch({ effects });
256
302
  },
303
+ // The B side is the file as it is now, which is the one a reader steps
304
+ // through: `a` is the version being compared against and is read-only for a
305
+ // different reason. Both sides carry the chunk field, so the count is the
306
+ // same either way.
307
+ chunkPosition: () => chunkPositionOf(merge.b),
308
+ stepChunk: (direction) => stepChunkIn(merge.b, direction),
257
309
  scroller: () => scroller,
258
310
  destroy: () => {
259
311
  options.onScroller(null);
@@ -261,60 +313,3 @@ export function mountSplitDiff(parent: HTMLElement, options: DiffViewOptions): D
261
313
  },
262
314
  };
263
315
  }
264
-
265
- /**
266
- * Additions and deletions, counted from the SAME line-level diff the view draws.
267
- *
268
- * `Chunk.build` is the merge view's own chunking — a line-level diff, which is
269
- * what its rows are. `diff()` would be the wrong source here: it is a
270
- * CHARACTER diff, so changing `line 5` into `line 5 changed` reports one
271
- * insertion of `" changed"` and no deletion at all, and the badge would claim
272
- * two additions for two edited lines.
273
- *
274
- * Counting from the view's own chunks is also what makes the whitespace toggle
275
- * honest: a change folded out of the comparison is not a changed row on screen,
276
- * and it is not counted.
277
- */
278
- export function countChanges(original: string, next: string): { additions: number; deletions: number } {
279
- const a = Text.of(original.split('\n'));
280
- const b = Text.of(next.split('\n'));
281
- let additions = 0;
282
- let deletions = 0;
283
- for (const chunk of Chunk.build(a, b)) {
284
- // `endA`/`endB` are the end of the chunk's last line, and equal the start
285
- // when the chunk covers no lines on that side (a pure insertion/deletion).
286
- if (chunk.endA > chunk.fromA) deletions += a.lineAt(chunk.endA).number - a.lineAt(chunk.fromA).number + 1;
287
- if (chunk.endB > chunk.fromB) additions += b.lineAt(chunk.endB).number - b.lineAt(chunk.fromB).number + 1;
288
- }
289
- return { additions, deletions };
290
- }
291
-
292
- /**
293
- * `original` with every whitespace-only change replaced by the new text.
294
- *
295
- * The toolbar's whitespace toggle means "do not show me formatting noise", and
296
- * the merge view compares DOCUMENTS — so the way to honour it is to make the two
297
- * sides agree there. The old table parser folded a `-`/`+` pair whose trimmed
298
- * text matched back into a context row; this does the same at the source, which
299
- * is why the toggle changes the CHUNKS rather than only their colour.
300
- *
301
- * Only line-for-line changes are folded: an inserted or deleted line is a real
302
- * change even when it is blank, and hiding it would make the file's line count
303
- * disagree with what is on screen.
304
- */
305
- export function foldWhitespaceOnly(original: string, next: string): string {
306
- const changes = diff(original, next);
307
- let folded = original;
308
- // Back to front: an earlier splice would move every later offset.
309
- for (let index = changes.length - 1; index >= 0; index--) {
310
- const change = changes[index];
311
- const before = original.slice(change.fromA, change.toA);
312
- const after = next.slice(change.fromB, change.toB);
313
- const beforeLines = before.split('\n');
314
- const afterLines = after.split('\n');
315
- if (beforeLines.length !== afterLines.length) continue;
316
- if (!beforeLines.every((line, lineIndex) => line.trim() === afterLines[lineIndex].trim())) continue;
317
- folded = folded.slice(0, change.fromA) + after + folded.slice(change.toA);
318
- }
319
- return folded;
320
- }
@@ -18,7 +18,12 @@ export function EditorDropOverlay({ visible }: { visible: boolean }) {
18
18
  <div className="pointer-events-none absolute inset-0 z-20 flex flex-col items-center justify-center gap-1 border-2 border-dashed border-ink/40 bg-canvas/90 text-ink">
19
19
  <UploadCloud size={18} className="text-ink/60" />
20
20
  <span className="text-[11px] font-semibold">Drop a file to open it</span>
21
- <span className="text-[10px] text-ink/50">Inside a workspace the console can read</span>
21
+ {/* The old line promised "Inside a workspace the console can read", which
22
+ stopped being true when a drop started granting its own directory
23
+ (`client/lib/fs/resolve-open.ts`) — the file may live anywhere the user
24
+ can reach, and the sentence has to say so or it contradicts the gesture
25
+ that works. */}
26
+ <span className="text-[10px] text-ink/50">Any file this console can read</span>
22
27
  </div>
23
28
  );
24
29
  }
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useState } from 'preact/hooks';
1
+ import { useCallback, useEffect, useMemo, useState } from 'preact/hooks';
2
2
  import type { RefObject } from 'preact';
3
3
  import { MarkdownRenderer } from '@/client/components/common/MarkdownRenderer';
4
4
  import { CodeSurface, type CodeSurfaceHandle } from '@/client/components/common/code-surface';
@@ -20,6 +20,10 @@ import { EDITOR_LINE_HEIGHT } from '@/shared/lib/code/editor/typography';
20
20
  import type { ViewerKind } from '@/shared/lib/fs/document-kind';
21
21
  import type { EditorCommand } from '@/shared/lib/code/editor/keymap';
22
22
  import type { EditorThemeState } from '@/client/hooks/editor/theme';
23
+ import { useFileBlame } from '@/client/hooks/editor/blame';
24
+ import { useEditorBlame } from '@/client/hooks/editor/blame-settings';
25
+ import { blameExtensions } from '@/client/components/common/code-surface/blame';
26
+ import { countConflicts } from '@/client/components/common/code-surface/conflict-markers';
23
27
 
24
28
  interface FileDocumentProps {
25
29
  activeFile: { id: number | string; name: string; path: string; root?: string; repo?: string };
@@ -97,7 +101,50 @@ export function FileDocument({
97
101
  // an editor that is already open.
98
102
  const editorIndent = useEditorIndent();
99
103
  const editorTyping = useEditorTyping();
104
+ const editorBlame = useEditorBlame();
105
+ /**
106
+ * The blame answer for THIS file.
107
+ *
108
+ * `dirty` is the editor's own comparison against its baseline, which is what
109
+ * decides whether the blame describes the bytes on screen: an unsaved edit
110
+ * shifts every line number, and a label naming the wrong line is worse than
111
+ * no label. The controller refuses to read while it is true, and the labels
112
+ * disappear the moment it flips.
113
+ */
114
+ const blame = useFileBlame(
115
+ {
116
+ name: activeFile.name,
117
+ path: activeFile.path,
118
+ // A file tab carries no `repo` — only a diff tab does — so the panel's own
119
+ // scope is the fallback. Without it a file inside a NESTED repository is
120
+ // blamed against the workspace root, which answers "untracked" for a file
121
+ // that has a full history one directory down.
122
+ root: activeFile.root ?? rootPath ?? undefined,
123
+ repo: activeFile.repo ?? repoPath ?? '.',
124
+ },
125
+ { enabled: editorBlame.enabled, dirty: editor.isDirty },
126
+ );
127
+ /**
128
+ * The extension, rebuilt only when one of its inputs moves.
129
+ *
130
+ * A fresh array per render would reconfigure the compartment on every
131
+ * keystroke — and a reconfigure re-creates the label plugin, which rebuilds
132
+ * every decoration on the viewport.
133
+ */
134
+ const blameExtension = useMemo(
135
+ () => (editorBlame.enabled ? blameExtensions({ controller: blame, inline: editorBlame.inline }) : null),
136
+ [editorBlame.enabled, editorBlame.inline, blame],
137
+ );
100
138
  const [caret, setCaret] = useState<CaretPosition | null>(null);
139
+ /**
140
+ * Merge-conflict blocks in the buffer.
141
+ *
142
+ * Derived from the CONTENT, not from git status: the panel's `conflicted` flag
143
+ * comes from the status string, which a hand-edited file no longer matches the
144
+ * moment the markers are gone. What the reader needs to know is how many
145
+ * blocks are still in front of them.
146
+ */
147
+ const conflicts = useMemo(() => countConflicts(editor.content), [editor.content]);
101
148
  const [goToLineOpen, setGoToLineOpen] = useState(false);
102
149
  // The request is a COUNTER: the dialog closes itself, and a boolean would need a
103
150
  // matching "closed" write from this component to the panel that owns the chord.
@@ -218,11 +265,13 @@ export function FileDocument({
218
265
  // must not sit under it: an explicit theme's background is opaque and
219
266
  // would be a rectangle inside the panel's own colour.
220
267
  className="flex-1 min-h-0 text-ink select-text"
268
+ blame={blameExtension}
221
269
  themeVars={editorTheme.vars}
222
270
  themes={editorTheme.themes}
223
271
  indentUnitText={indentUnitFor(editorIndent)}
224
272
  typing={editorTyping}
225
273
  padding={16}
274
+ placeholder="This file is empty"
226
275
  style={{
227
276
  fontFamily: editorFontFamily,
228
277
  fontSize: `${zoomLevel}px`,
@@ -245,6 +294,7 @@ export function FileDocument({
245
294
  byteViewer={editor.isBinaryViewer}
246
295
  viewerKind={viewerKind}
247
296
  lineCount={editor.content ? editor.content.split('\n').length : 0}
297
+ conflicts={conflicts}
248
298
  />
249
299
  ) : null}
250
300
  </div>
@@ -114,9 +114,10 @@ export function FilePane({
114
114
  isPreview={isPreview}
115
115
  copied={editor.copied}
116
116
  byteViewer={byteViewer}
117
- saveDisabled={Boolean(editor.loadError) || editor.handleMissing}
117
+ saveDisabled={Boolean(editor.loadError) || editor.handleMissing || editor.deviceBacked}
118
118
  unsupported={Boolean(editor.unsupported)}
119
119
  handleMissing={editor.handleMissing}
120
+ readOnly={editor.deviceBacked}
120
121
  isMaximized={isMaximized}
121
122
  findOpen={find.open}
122
123
  onToggleFind={() => (find.open ? find.close() : find.openFind())}
@@ -179,6 +180,29 @@ export function FilePane({
179
180
  </div>
180
181
  )}
181
182
 
183
+ {/* A document the PHONE handed over: the bytes were pushed into the page
184
+ and there is no path to write back to. Distinct from the banner below,
185
+ which is about a permission that ENDED — telling a phone user to reopen
186
+ the file for write access would promise something reopening cannot
187
+ give. */}
188
+ {editor.deviceBacked && (
189
+ <div className="flex items-start gap-2 px-3 py-2 border-b border-ink/20 bg-ink/5 text-ink/70">
190
+ <AlertTriangle size={14} className="shrink-0 mt-0.5" />
191
+ <div className="min-w-0">
192
+ <div className="text-[11.5px] font-sans">
193
+ {editor.deviceMissing
194
+ ? 'The bytes for this file did not survive the reload.'
195
+ : 'Opened from this device, so it is read-only here.'}
196
+ </div>
197
+ <div className="text-[11px] font-sans text-ink/50">
198
+ {editor.deviceMissing
199
+ ? 'A phone\'s file lives only on the phone, so it cannot be re-read. Open it again from the app that shared it.'
200
+ : 'The console cannot reach a file on your phone. Copy it into a workspace to edit it.'}
201
+ </div>
202
+ </div>
203
+ </div>
204
+ )}
205
+
182
206
  {editor.isImage && editor.imageUrl ? (
183
207
  // A workspace image: the raw URL is what `<img>` paints, and the picture
184
208
  // owns its own pan/zoom, so it must NOT sit inside the scrolling text
@@ -49,6 +49,13 @@ interface EditorStatusBarProps {
49
49
  byteViewer: boolean;
50
50
  viewerKind: ViewerKind;
51
51
  lineCount: number;
52
+ /**
53
+ * Merge-conflict blocks in the buffer, or 0.
54
+ *
55
+ * Printed only when non-zero: a permanent "0 conflicts" would be a readout
56
+ * about a file that has none, on every file the user opens.
57
+ */
58
+ conflicts?: number;
52
59
  }
53
60
 
54
61
  /** `Spaces: 2` / `Tabs`, which is what the indent actually inserts. */
@@ -66,6 +73,7 @@ export function EditorStatusBar({
66
73
  byteViewer,
67
74
  viewerKind,
68
75
  lineCount,
76
+ conflicts = 0,
69
77
  }: EditorStatusBarProps) {
70
78
  return (
71
79
  <footer
@@ -99,6 +107,17 @@ export function EditorStatusBar({
99
107
  )}
100
108
  </div>
101
109
  <div className="flex items-center gap-3 min-w-0">
110
+ {conflicts > 0 && (
111
+ // The count is the reason the file is red: the markers themselves are
112
+ // painted by the surface (`conflict-markers.ts`), but a reader who has
113
+ // scrolled past them needs to know how many blocks are left.
114
+ <span
115
+ className="text-error font-semibold tabular-nums"
116
+ title={`${conflicts} unresolved conflict${conflicts === 1 ? '' : 's'} — markers are highlighted in the file`}
117
+ >
118
+ ⚠ {conflicts} conflict{conflicts === 1 ? '' : 's'}
119
+ </span>
120
+ )}
102
121
  <span className="uppercase text-ink/40">{language}</span>
103
122
  </div>
104
123
  </footer>
@@ -8,6 +8,8 @@ import {
8
8
  import { EditorViewButtons, useEditorViewActions } from '@/client/components/common/editor-view-buttons';
9
9
  import { ToolbarRow } from '@/client/components/common/toolbar-row';
10
10
  import { ACTION_CLASS, buildEditorClusters } from '@/client/components/workspace/editor/toolbar-clusters';
11
+ import { writeKabmoSettings } from '@/shared/lib/settings/client';
12
+ import { EDITOR_BLAME_CHANGED_EVENT, currentEditorBlame, useEditorBlame } from '@/client/hooks/editor/blame-settings';
11
13
 
12
14
  export type EditorSaveStatus = 'idle' | 'saving' | 'saved' | 'error' | 'needs-permission';
13
15
 
@@ -42,6 +44,15 @@ interface EditorToolbarProps {
42
44
  * separately from the other two: the file is fine, the CAPABILITY is gone.
43
45
  */
44
46
  handleMissing?: boolean;
47
+ /**
48
+ * The tab's bytes came from the DEVICE (a document a phone handed over), so
49
+ * there is nowhere to write them back.
50
+ *
51
+ * Its own flag rather than reusing `handleMissing`: the two read as different
52
+ * sentences, and "could not be read" would be a lie about a file that is on
53
+ * screen.
54
+ */
55
+ readOnly?: boolean;
45
56
  isMaximized?: boolean;
46
57
  /** Find/replace is open — the button reflects it and toggles the bar. */
47
58
  findOpen?: boolean;
@@ -88,6 +99,7 @@ export function EditorToolbar({
88
99
  saveDisabled = false,
89
100
  unsupported = false,
90
101
  handleMissing = false,
102
+ readOnly = false,
91
103
  isMaximized = false,
92
104
  findOpen = false,
93
105
  onToggleFind,
@@ -105,11 +117,13 @@ export function EditorToolbar({
105
117
  }: EditorToolbarProps) {
106
118
  const saveTitle =
107
119
  saveDisabled
108
- ? handleMissing
109
- ? 'Cannot save — reopen the file from the system to restore write access'
110
- : unsupported
111
- ? 'Nothing to save — this file cannot be opened as a document'
112
- : 'Nothing to save — this file could not be read'
120
+ ? readOnly
121
+ ? 'Read-only — this file was opened from the phone, not from a workspace'
122
+ : handleMissing
123
+ ? 'Cannot save — reopen the file from the system to restore write access'
124
+ : unsupported
125
+ ? 'Nothing to save — this file cannot be opened as a document'
126
+ : 'Nothing to save — this file could not be read'
113
127
  : saveStatus === 'needs-permission'
114
128
  ? 'Click Save to allow writing this file'
115
129
  : saveStatus === 'saving'
@@ -156,12 +170,14 @@ export function EditorToolbar({
156
170
  </button>
157
171
  );
158
172
 
173
+ const blame = useEditorBlame();
159
174
  const viewModeActions = useEditorViewActions();
160
175
  const clusters = buildEditorClusters({
161
176
  byteViewer,
162
177
  hasPreview,
163
178
  isPreview,
164
179
  wordWrap,
180
+ blameInline: blame.inline,
165
181
  findOpen,
166
182
  copied,
167
183
  isMaximized,
@@ -179,6 +195,14 @@ export function EditorToolbar({
179
195
  onTogglePreview,
180
196
  onToggleFind,
181
197
  onToggleWordWrap,
198
+ onToggleBlameInline: () => {
199
+ // The setting is written through the same helper the Settings modal uses,
200
+ // and the event is what reaches an editor already on screen — a prop read
201
+ // once would never arrive.
202
+ const next = { ...currentEditorBlame(), inline: !blame.inline };
203
+ writeKabmoSettings({ editorBlameInline: next.inline });
204
+ window.dispatchEvent(new CustomEvent(EDITOR_BLAME_CHANGED_EVENT, { detail: next }));
205
+ },
182
206
  onZoomIn,
183
207
  onZoomOut,
184
208
  onCopy,
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The editor toolbar's cluster ORDER, which is also its hiding priority.
8
+ *
9
+ * `ToolbarRow` hides by ROW ORDER: a cluster takes the row if the budget still
10
+ * covers it, and the first one that does not fit — and every later one — goes
11
+ * into `⋯`. There is no separate priority field, so where a cluster sits IS its
12
+ * priority, and the ordering is therefore worth pinning.
13
+ *
14
+ * The regression this holds: `Save as` sat after the reading aids, and the
15
+ * blame cluster added ahead of it took the last 30px of the 320px floor's row,
16
+ * which put the only control that writes the buffer to a NEW file behind `⋯`
17
+ * while a hover aid stayed on the row. Measured in Chromium on a real file:
18
+ * the row showed `Save file … Show line blame … Full screen` and `Save as…`
19
+ * only as a menu item.
20
+ */
21
+
22
+ import { describe, expect, test } from 'bun:test';
23
+ import { buildEditorClusters, type ToolbarState } from '@/client/components/workspace/editor/toolbar-clusters';
24
+
25
+ /** The minimum a cluster builder reads; every toggle is off, nothing is disabled. */
26
+ function state(): ToolbarState {
27
+ const noop = () => {};
28
+ return {
29
+ byteViewer: false,
30
+ saveButton: null,
31
+ saveDisabled: false,
32
+ onSave: noop,
33
+ hasPreview: true,
34
+ previewLabel: 'Preview',
35
+ isPreview: false,
36
+ onTogglePreview: noop,
37
+ findLabel: 'Find and replace',
38
+ findOpen: false,
39
+ onToggleFind: noop,
40
+ wordWrapLabel: 'Word wrap on',
41
+ wordWrap: false,
42
+ onToggleWordWrap: noop,
43
+ blameInline: false,
44
+ onToggleBlameInline: noop,
45
+ onZoomIn: noop,
46
+ onZoomOut: noop,
47
+ onSaveAs: noop,
48
+ canRevert: false,
49
+ onRevert: noop,
50
+ copyLabel: 'Copy content',
51
+ onCopy: noop,
52
+ onDownload: noop,
53
+ copied: false,
54
+ viewModeActions: [],
55
+ viewModeButtons: null,
56
+ isMaximized: false,
57
+ maximizeLabel: 'Full screen',
58
+ onToggleMaximize: noop,
59
+ maximizeButton: null,
60
+ };
61
+ }
62
+
63
+ describe('buildEditorClusters order', () => {
64
+ test('Save as is placed ahead of every reading aid, so an aid cannot evict it', () => {
65
+ const ids = buildEditorClusters(state()).map((cluster) => cluster.id);
66
+ const saveAs = ids.indexOf('save-as');
67
+ expect(saveAs).toBeGreaterThan(ids.indexOf('save'));
68
+ for (const aid of ['blame', 'zoom', 'copy', 'revert']) {
69
+ expect(saveAs).toBeLessThan(ids.indexOf(aid));
70
+ }
71
+ });
72
+
73
+ test('the width modes and full screen are the pinned tail', () => {
74
+ const clusters = buildEditorClusters(state());
75
+ const pinned = clusters.filter((cluster) => cluster.pinned).map((cluster) => cluster.id);
76
+ expect(pinned).toEqual(['save', 'view-modes', 'maximize']);
77
+ });
78
+
79
+ test('a byte viewer drops the text-only clusters, Save as among them', () => {
80
+ const ids = buildEditorClusters({ ...state(), byteViewer: true }).map((cluster) => cluster.id);
81
+ for (const absent of ['save', 'save-as', 'find', 'wrap', 'blame', 'zoom']) {
82
+ expect(ids).not.toContain(absent);
83
+ }
84
+ expect(ids).toContain('copy');
85
+ });
86
+ });
@@ -29,6 +29,7 @@ import {
29
29
  Download,
30
30
  Eye,
31
31
  EyeOff,
32
+ GitCommitVertical,
32
33
  Maximize,
33
34
  Minimize,
34
35
  RotateCcw,
@@ -52,6 +53,8 @@ export interface ToolbarState {
52
53
  hasPreview: boolean;
53
54
  isPreview: boolean;
54
55
  wordWrap: boolean;
56
+ /** The inline blame label is drawn (the setting, not whether a file has blame). */
57
+ blameInline: boolean;
55
58
  findOpen: boolean;
56
59
  copied: boolean;
57
60
  isMaximized: boolean;
@@ -66,6 +69,7 @@ export interface ToolbarState {
66
69
  onTogglePreview: () => void;
67
70
  onToggleFind: () => void;
68
71
  onToggleWordWrap: () => void;
72
+ onToggleBlameInline: () => void;
69
73
  onZoomIn: () => void;
70
74
  onZoomOut: () => void;
71
75
  onCopy: () => void;
@@ -128,6 +132,27 @@ export function buildEditorClusters(state: ToolbarState): ToolbarCluster[] {
128
132
  actions: [{ label: 'Save file', icon: Save, onSelect: state.onSave, disabled: state.saveDisabled }],
129
133
  children: state.saveButton,
130
134
  });
135
+
136
+ clusters.push({
137
+ id: 'save-as',
138
+ // Never pinned: it is a rare operation, and the row's space belongs to Save.
139
+ // It IS placed directly after Save, because unpinned clusters take the row in
140
+ // ROW ORDER: measured at the 320px floor, the 26px blame cluster added after
141
+ // it claimed the last 30px and pushed `Save as` into `⋯` — a reading aid
142
+ // evicting a write. Sibling writes outrank reading aids here.
143
+ actions: [{ label: 'Save as…', icon: SaveAll, onSelect: state.onSaveAs }],
144
+ children: (
145
+ <button
146
+ type="button"
147
+ onClick={state.onSaveAs}
148
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
149
+ title="Save the buffer to a new file"
150
+ aria-label="Save as"
151
+ >
152
+ <SaveAll size={14} />
153
+ </button>
154
+ ),
155
+ });
131
156
  }
132
157
 
133
158
  if (state.hasPreview) {
@@ -175,6 +200,29 @@ export function buildEditorClusters(state: ToolbarState): ToolbarCluster[] {
175
200
  </Toggle>
176
201
  ),
177
202
  });
203
+ // A reading aid, so it sits with wrap rather than with Save: it changes how
204
+ // the document is SHOWN, and a narrow panel moves it into the `⋯` menu.
205
+ clusters.push({
206
+ id: 'blame',
207
+ actions: [
208
+ {
209
+ label: state.blameInline ? 'Hide line blame' : 'Show line blame',
210
+ icon: GitCommitVertical,
211
+ onSelect: state.onToggleBlameInline,
212
+ active: state.blameInline,
213
+ },
214
+ ],
215
+ children: (
216
+ <Toggle
217
+ label={state.blameInline ? 'Hide line blame' : 'Show line blame'}
218
+ pressed={state.blameInline}
219
+ title="Who last changed each block, from git (hover a line for the commit)"
220
+ onClick={state.onToggleBlameInline}
221
+ >
222
+ <GitCommitVertical size={14} />
223
+ </Toggle>
224
+ ),
225
+ });
178
226
  clusters.push({
179
227
  id: 'zoom',
180
228
  actions: [
@@ -204,22 +252,6 @@ export function buildEditorClusters(state: ToolbarState): ToolbarCluster[] {
204
252
  </>
205
253
  ),
206
254
  });
207
- clusters.push({
208
- id: 'save-as',
209
- // Never pinned: it is a rare operation, and the row's space belongs to Save.
210
- actions: [{ label: 'Save as…', icon: SaveAll, onSelect: state.onSaveAs }],
211
- children: (
212
- <button
213
- type="button"
214
- onClick={state.onSaveAs}
215
- className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
216
- title="Save the buffer to a new file"
217
- aria-label="Save as"
218
- >
219
- <SaveAll size={14} />
220
- </button>
221
- ),
222
- });
223
255
  clusters.push({
224
256
  id: 'revert',
225
257
  // Never `pinned`: it is the one destructive control in the row, and a menu is