@bevel-software/platform-core-frontend 0.14.0 → 0.19.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 (360) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +34 -26
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/bootstrap.test.ts +33 -1
  6. package/src/core/__tests__/events.test.ts +43 -0
  7. package/src/core/bootstrap.ts +38 -1
  8. package/src/core/events.ts +85 -3
  9. package/src/core/registry.ts +1 -1
  10. package/src/lib/__tests__/api.test.ts +38 -0
  11. package/src/lib/__tests__/email.test.ts +44 -0
  12. package/src/lib/api.ts +19 -2
  13. package/src/lib/email.ts +37 -1
  14. package/src/lib/utils.ts +2 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  16. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  20. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  21. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  22. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  23. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  24. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
  25. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  26. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  27. package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
  28. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  29. package/src/modules/access/api.ts +192 -10
  30. package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
  31. package/src/modules/access/manage-access-affordance.ts +17 -0
  32. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  33. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  34. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  35. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  36. package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
  37. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  38. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  39. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  40. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  41. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  42. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  43. package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
  44. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  45. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  46. package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
  47. package/src/modules/admin/components/group-members-path.ts +32 -0
  48. package/src/modules/admin/services/connection-keys.api.ts +47 -0
  49. package/src/modules/admin/services/roles.api.ts +12 -1
  50. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  51. package/src/modules/auth/components/AccountPage.tsx +73 -54
  52. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  53. package/src/modules/auth/services/account.api.ts +78 -4
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  58. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  59. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  60. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  61. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  62. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  63. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  64. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  65. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  66. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  67. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  68. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  69. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  70. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  71. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  72. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  73. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  74. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  75. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  76. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  77. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  78. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  79. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  80. package/src/modules/change-requests/services/propose.api.ts +97 -8
  81. package/src/modules/change-requests/utils/approval.ts +15 -0
  82. package/src/modules/change-requests/utils/author.ts +32 -0
  83. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  84. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  85. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
  86. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  87. package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
  88. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  89. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  90. package/src/modules/git/services/error-messages.ts +12 -0
  91. package/src/modules/git/services/pr-prompts.ts +5 -5
  92. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  93. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  94. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  95. package/src/modules/layout/components/AppLayout.tsx +2 -0
  96. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  97. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  98. package/src/modules/layout/components/SidebarFrame.tsx +109 -4
  99. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  100. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  101. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  102. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  103. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  104. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
  105. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
  106. package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
  107. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
  108. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  109. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  110. package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
  111. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  112. package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
  113. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
  114. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
  115. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  116. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  117. package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
  118. package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
  119. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  120. package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
  121. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
  122. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  123. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  124. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  125. package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
  126. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  127. package/src/modules/library/__tests__/library-paths.test.ts +75 -0
  128. package/src/modules/library/__tests__/link-membership.test.ts +129 -0
  129. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  130. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  131. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  132. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  133. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  134. package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
  135. package/src/modules/library/__tests__/status.test.ts +82 -2
  136. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  137. package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
  138. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  139. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  140. package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
  141. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  142. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  143. package/src/modules/library/components/LibraryCard.tsx +149 -34
  144. package/src/modules/library/components/LibraryLayout.tsx +120 -247
  145. package/src/modules/library/components/LibraryPage.tsx +172 -39
  146. package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
  147. package/src/modules/library/components/LockedPluginView.tsx +63 -35
  148. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  149. package/src/modules/library/components/NewPluginDialog.tsx +19 -5
  150. package/src/modules/library/components/PageActions.tsx +31 -9
  151. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  152. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  153. package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
  154. package/src/modules/library/components/PluginExtras.tsx +143 -18
  155. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  156. package/src/modules/library/components/PluginPage.tsx +234 -38
  157. package/src/modules/library/components/PluginRows.tsx +286 -0
  158. package/src/modules/library/components/PluginsSidebar.tsx +271 -238
  159. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  160. package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
  161. package/src/modules/library/components/ShareButton.tsx +17 -0
  162. package/src/modules/library/components/SkillsTree.tsx +204 -0
  163. package/src/modules/library/components/StatusDot.tsx +1 -0
  164. package/src/modules/library/components/TeamRoute.tsx +15 -0
  165. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  166. package/src/modules/library/components/plugin-page-parts.tsx +132 -23
  167. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
  168. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  169. package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
  170. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  171. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  172. package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
  173. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  174. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  175. package/src/modules/library/hooks/useJoinRequests.ts +48 -18
  176. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  177. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  178. package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
  179. package/src/modules/library/routes/library-paths.ts +46 -35
  180. package/src/modules/library/services/library.api.ts +89 -17
  181. package/src/modules/library/services/plugins.api.ts +161 -9
  182. package/src/modules/library/services/teams.api.ts +15 -0
  183. package/src/modules/library/services/tools.api.ts +78 -0
  184. package/src/modules/library/state/library-data.tsx +268 -37
  185. package/src/modules/library/utils/personal-plugin.ts +13 -15
  186. package/src/modules/library/utils/plugin-entries.ts +134 -0
  187. package/src/modules/library/utils/plugin-summary.ts +102 -0
  188. package/src/modules/library/utils/status.ts +204 -35
  189. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
  190. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  191. package/src/modules/onboarding/agent-clients.ts +55 -23
  192. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  193. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  194. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  195. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  196. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  197. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  198. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  199. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  200. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  201. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  202. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  203. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  204. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  205. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  206. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  207. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  208. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  209. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  210. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  211. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  212. package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
  213. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  214. package/src/modules/settings/components/DeploymentPage.tsx +16 -22
  215. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  216. package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
  217. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
  218. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  219. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
  220. package/src/modules/settings/services/github-facade.api.ts +66 -0
  221. package/src/modules/settings/settings-nav-items.tsx +10 -2
  222. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  223. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  224. package/src/modules/setup/__tests__/setup.test.tsx +615 -4
  225. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  226. package/src/modules/setup/components/SetupGate.tsx +16 -16
  227. package/src/modules/setup/components/SetupScreen.tsx +711 -40
  228. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  229. package/src/modules/setup/services/setup.api.ts +218 -3
  230. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  231. package/src/modules/setup/utils/root-folders.ts +46 -0
  232. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  233. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  234. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  235. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  236. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  237. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  238. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  239. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  240. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  241. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  242. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  243. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  244. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  245. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  246. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  247. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  248. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
  249. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  250. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  251. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  252. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
  253. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  254. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  255. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  256. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  257. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  258. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  259. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  260. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  261. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  262. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  263. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  264. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  265. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  266. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  267. package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
  268. package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
  269. package/src/modules/workspace/components/FileRoute.tsx +376 -22
  270. package/src/modules/workspace/components/FileViewer.tsx +166 -45
  271. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  272. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  273. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  274. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
  275. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
  276. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
  277. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  278. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  279. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  280. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  281. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  282. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  283. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  284. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  285. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  286. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  287. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  288. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  289. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  290. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  291. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  292. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  293. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  294. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  295. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  296. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  297. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  298. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  299. package/src/modules/workspace/components/renderers/index.ts +53 -2
  300. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  301. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  302. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  303. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  304. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  305. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  306. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  307. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
  308. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  309. package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
  310. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  311. package/src/modules/workspace/routing/kb-routes.ts +207 -30
  312. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
  313. package/src/modules/workspace/services/workspace.api.ts +57 -4
  314. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  315. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  316. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  317. package/src/modules/workspace/state/workspace.context.ts +130 -16
  318. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  319. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
  320. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  321. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  322. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  323. package/src/modules/workspace/utils/file-trace.ts +50 -0
  324. package/src/modules/workspace/utils/fileTree.ts +126 -52
  325. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  326. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  327. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  328. package/src/modules/workspace/utils/uploadError.ts +29 -0
  329. package/src/shared/__tests__/marketplace-url.test.ts +59 -0
  330. package/src/shared/components/Badge.tsx +3 -1
  331. package/src/shared/components/Banner.tsx +5 -1
  332. package/src/shared/components/Button.tsx +16 -2
  333. package/src/shared/components/Dialog.tsx +27 -11
  334. package/src/shared/components/Menu.tsx +13 -1
  335. package/src/shared/components/PageShell.tsx +13 -8
  336. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  337. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  338. package/src/shared/components/index.ts +2 -0
  339. package/src/shared/components/useDismissableMenu.ts +32 -10
  340. package/src/shared/components/useFocusHandoff.ts +51 -0
  341. package/src/shared/components/useLatestRef.ts +28 -0
  342. package/src/shared/markdown/Markdown.tsx +12 -3
  343. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  344. package/src/shared/markdown/hrefs.ts +50 -0
  345. package/src/shared/marketplace-url.ts +118 -0
  346. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  347. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  348. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  349. package/src/shared/mcp/connect-snippets.ts +14 -9
  350. package/src/shared/mcp/index.ts +1 -1
  351. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  352. package/src/shared/theme/header.ts +75 -0
  353. package/src/shared/theme/measure.ts +7 -4
  354. package/src/shared/theme/tokens.css +34 -0
  355. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  356. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  357. package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
  358. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  359. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  360. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -1,4 +1,5 @@
1
1
  import { parseDocument } from 'yaml';
2
+ import { extractFrontmatter } from '@bevel-software/platform-shared';
2
3
 
3
4
  export type FrontmatterData = Record<string, string | string[]>;
4
5
 
@@ -45,10 +46,13 @@ function coerce(value: unknown): string | string[] {
45
46
  * carry access entries that must always surface.
46
47
  */
47
48
  export function parseFrontmatter(content: string): { data: FrontmatterData; body: string } {
48
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
49
- if (!match) return { data: {}, body: content };
49
+ // The SHARED splitter, not a copy of its regex: this panel and the backend
50
+ // have to agree about which files have frontmatter at all, or a file shows
51
+ // no fields here while the catalog reads an id out of it.
52
+ const split = extractFrontmatter(content);
53
+ if (!split) return { data: {}, body: content };
50
54
 
51
- const body = match[2].trimStart();
55
+ const body = split.body.trimStart();
52
56
  const data: FrontmatterData = {};
53
57
 
54
58
  let parsed: unknown;
@@ -57,7 +61,7 @@ export function parseFrontmatter(content: string): { data: FrontmatterData; body
57
61
  // the best-effort value of whatever parsed — so a single malformed entry
58
62
  // doesn't blank the block. (`.toJS()` itself can still throw, e.g. on an
59
63
  // alias bomb; the catch keeps the body readable.)
60
- parsed = parseDocument(match[1]).toJS();
64
+ parsed = parseDocument(split.frontmatter).toJS();
61
65
  } catch {
62
66
  return { data: {}, body };
63
67
  }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The form Copy path puts on the clipboard: root-anchored, `/<kbDirName>/…`.
3
+ *
4
+ * Markdown reads a slash-less path as relative to the CURRENT file's folder,
5
+ * so `knowledge-base/KnowledgeBase/x.md` pasted into a link in a subfolder
6
+ * resolves to a doubled path and the page says File not found. The leading
7
+ * slash anchors it at the workspace root, where it resolves from any folder.
8
+ */
9
+ export function rootAnchoredPath(relativePath: string): string {
10
+ return relativePath.startsWith('/') ? relativePath : `/${relativePath}`;
11
+ }
12
+
13
+ /**
14
+ * `[` and `]` in a label would close the link early. Backslashes go first: a
15
+ * label already holding `\]` would otherwise become `\\]`, where Markdown
16
+ * reads the doubled backslash as one literal and the bracket as the close.
17
+ */
18
+ function escapeLabel(label: string): string {
19
+ return label.replace(/\\/g, '\\\\').replace(/[[\]]/g, '\\$&');
20
+ }
21
+
22
+ /**
23
+ * Whether a root-anchored path names a file the way the explorer would: every
24
+ * segment a real name. A `..` would resolve to a different place than the
25
+ * text says, an empty segment doubles a slash, and a backslash is never part
26
+ * of a workspace path — such a clipboard is pasted as text, not turned into a
27
+ * link to somewhere else. One trailing slash is how a folder's path is
28
+ * copied and is allowed; a second one is an empty segment like any other.
29
+ */
30
+ function isPlainWorkspacePath(text: string): boolean {
31
+ const segments = text.replace(/\/$/, '').split('/').slice(1);
32
+ return segments.every((s) => s !== '' && s !== '.' && s !== '..' && !s.includes('\\'));
33
+ }
34
+
35
+ /**
36
+ * A destination with a space or a bracket goes in angle brackets
37
+ * (`(<Some File.md>)`) — plain CommonMark, and the same form the renderer's
38
+ * `escapeSpacesInLinkDestinations` produces.
39
+ */
40
+ function destination(target: string): string {
41
+ return /[\s()<>]/.test(target) ? `<${target}>` : target;
42
+ }
43
+
44
+ /** `Foo.md` → `Foo`; a dotfile or an extension-less name stays whole. */
45
+ function stem(name: string): string {
46
+ const dot = name.lastIndexOf('.');
47
+ return dot > 0 ? name.slice(0, dot) : name;
48
+ }
49
+
50
+ /**
51
+ * What pasting `clipboard` over `selection` should insert, or `null` for an
52
+ * ordinary paste.
53
+ *
54
+ * Only a clipboard that is exactly ONE bare workspace path (`/<kbDirName>/…`,
55
+ * spaces in folder names allowed) or ONE `http(s)` URL becomes a link. The
56
+ * label is the selection when there is one; otherwise the file name without
57
+ * its extension for a path, and host plus path for a URL. The path stays in
58
+ * its root-anchored form, so the link works from any folder.
59
+ */
60
+ export function markdownLinkForPaste(
61
+ clipboard: string,
62
+ kbDirName: string | null,
63
+ selection = '',
64
+ ): string | null {
65
+ const text = clipboard.trim();
66
+ if (!text || /[\r\n]/.test(text)) return null;
67
+
68
+ if (kbDirName && text.startsWith(`/${kbDirName}/`)) {
69
+ if (!isPlainWorkspacePath(text)) return null;
70
+ const name = text.replace(/\/$/, '').split('/').pop() ?? '';
71
+ if (!name || name === kbDirName) return null;
72
+ // The link resolver splits at the first `#` and percent-decodes the rest,
73
+ // so a literal `#` or `%` in a file name is encoded to survive both.
74
+ const target = text.replace(/%/g, '%25').replace(/#/g, '%23');
75
+ return `[${escapeLabel(selection || stem(name))}](${destination(target)})`;
76
+ }
77
+
78
+ if (/^https?:\/\/\S+$/i.test(text)) {
79
+ let url: URL;
80
+ try {
81
+ url = new URL(text);
82
+ } catch {
83
+ return null;
84
+ }
85
+ const label = selection || `${url.host}${url.pathname.replace(/\/+$/, '')}`;
86
+ return `[${escapeLabel(label)}](${destination(text)})`;
87
+ }
88
+
89
+ return null;
90
+ }
@@ -0,0 +1,338 @@
1
+ import {
2
+ isPlatformFile,
3
+ isPlatformRestoreShape,
4
+ isRootPlatformFile,
5
+ platformFileRefusal,
6
+ type FileTreeEntry,
7
+ } from '@bevel-software/platform-shared';
8
+ import {
9
+ parsePluginPrincipalToken,
10
+ pluginPrincipalLabel,
11
+ type AccessPrincipalRef,
12
+ type PathPrincipals,
13
+ type ProspectiveAccess,
14
+ } from '../../access/api';
15
+ import { KB_ROOT_DIRS } from './fileTree';
16
+
17
+ // What the tree's delete and move confirmations say — see
18
+ // `components/TreeActionConfirm.tsx` for the dialog that says it.
19
+
20
+ /** The repo-relative form of a workspace-relative path, or null outside the KB clone. */
21
+ function repoRelative(wsRelativePath: string, kbDirName: string | null): string | null {
22
+ if (!kbDirName) return null;
23
+ const prefix = `${kbDirName}/`;
24
+ return wsRelativePath.startsWith(prefix) ? wsRelativePath.slice(prefix.length) : null;
25
+ }
26
+
27
+ /**
28
+ * Why this row may not be renamed, moved or dragged — the same sentence the
29
+ * server refuses with — or null when it may.
30
+ *
31
+ * Judged on the path's REPO-relative form, because that is what the platform
32
+ * reads: `roles.yaml` and the agent guide (`AGENTS.md` unless this deployment
33
+ * named it something else) count at the repository root only, so a nested file
34
+ * of either name is ordinary content and stays draggable. Outside
35
+ * the KB clone, and before `kbDirName` is known, nothing is refused here — the
36
+ * server is the gate and says the same sentence.
37
+ */
38
+ export function platformFileMoveRefusal(
39
+ wsRelativePath: string,
40
+ kbDirName: string | null,
41
+ ): string | null {
42
+ const rel = repoRelative(wsRelativePath, kbDirName);
43
+ if (rel === null) return null;
44
+ return isPlatformFile(rel) ? platformFileRefusal(rel) : null;
45
+ }
46
+
47
+ /**
48
+ * Why this row may not be DRAGGED, or null when it may — the rename refusal
49
+ * minus the one move that is a repair.
50
+ *
51
+ * An admin may put a misplaced platform file back where the platform reads it
52
+ * (a stray `access.md` into a folder that has none, a stray `.bevelignore`
53
+ * onto the root), and dragging it there is how a person does that. Refusing
54
+ * the drag on the row would leave that recovery reachable only over the API —
55
+ * for `access.md`, which is a platform file wherever it sits, not reachable
56
+ * from the sidebar at all — while the sentence shown promised what the server
57
+ * would say and the server would have said yes.
58
+ *
59
+ * So the row's own copy of the rule keeps only the part that is certain: the
60
+ * ROOT's copy never moves, and nobody but an admin moves any of them. What is
61
+ * left — which destination, and whether the disk agrees — the drop's own
62
+ * response says, because only the server knows it. A rename is never a
63
+ * repair (it lands the file beside the name the platform reads, not on it),
64
+ * so it keeps the full refusal.
65
+ */
66
+ export function platformFileDragRefusal(
67
+ wsRelativePath: string,
68
+ kbDirName: string | null,
69
+ isAdmin: boolean,
70
+ ): string | null {
71
+ const refusal = platformFileMoveRefusal(wsRelativePath, kbDirName);
72
+ if (refusal === null || !isAdmin) return refusal;
73
+ const rel = repoRelative(wsRelativePath, kbDirName);
74
+ return rel === null || isRootPlatformFile(rel) ? refusal : null;
75
+ }
76
+
77
+ /**
78
+ * Every file under a folder, at any depth — what a folder delete takes with it.
79
+ * `isProposed` names the rows that are only proposed (a change request's file
80
+ * this branch does not have): they are not on the branch, so the delete does
81
+ * not take them, and they are not counted.
82
+ */
83
+ export function countFiles(entry: FileTreeEntry, isProposed: (path: string) => boolean = () => false): number {
84
+ if (entry.type === 'file') return isProposed(entry.relativePath) ? 0 : 1;
85
+ return (entry.children ?? []).reduce((n, child) => n + countFiles(child, isProposed), 0);
86
+ }
87
+
88
+ /**
89
+ * The reserved root a workspace-relative path sits in (`KnowledgeBase`,
90
+ * `Skills`, `Data`, …), or null when it sits in none — outside the KB clone,
91
+ * at its top level, or in a stray top-level folder.
92
+ */
93
+ export function rootOf(path: string, kbDirName: string | null): string | null {
94
+ if (!kbDirName || !path.startsWith(`${kbDirName}/`)) return null;
95
+ const first = path.slice(kbDirName.length + 1).split('/')[0];
96
+ return first && KB_ROOT_DIRS.has(first) ? first : null;
97
+ }
98
+
99
+ const possessive = (name: string) => (/s$/i.test(name) ? `${name}'` : `${name}'s`);
100
+
101
+ /**
102
+ * The delete question. A folder's count is of the files this listing SHOWS:
103
+ * when the caller's read rules kept entries out of THIS folder (`partial`),
104
+ * the delete still takes every file under it, seen or not, so the sentence
105
+ * says "everything in it" and gives the visible count as what it is.
106
+ */
107
+ export function deleteSentence(
108
+ entry: FileTreeEntry,
109
+ isProposed?: (path: string) => boolean,
110
+ partial = false,
111
+ ): string {
112
+ if (entry.type === 'file') return `Delete ${entry.name}?`;
113
+ const n = countFiles(entry, isProposed);
114
+ const files = `${n} ${n === 1 ? 'file' : 'files'}`;
115
+ // "On this branch": a proposed-only row is shown but not counted, since the
116
+ // delete does not take it.
117
+ if (partial) return `Delete ${entry.name} and everything in it? (${files} on this branch you can see; it holds more you can't.)`;
118
+ return `Delete ${entry.name} and its ${files}?`;
119
+ }
120
+
121
+ /** `#12 "Title" by Ana (2 files)` — one open change request as a folder delete names it. */
122
+ export function folderRequestLine(request: {
123
+ number: number;
124
+ title: string;
125
+ authorName: string | null;
126
+ mine: boolean;
127
+ paths: string[];
128
+ }): string {
129
+ const by = request.mine ? 'by you' : request.authorName ? `by ${request.authorName}` : null;
130
+ const n = request.paths.length;
131
+ return `#${request.number} “${request.title}”${by ? ` ${by}` : ''} (${n} proposed ${n === 1 ? 'file' : 'files'})`;
132
+ }
133
+
134
+ /**
135
+ * The move question on its own. The dialog follows it with what the access
136
+ * lookup found: the lose and gain blocks, "Nobody's access changes.", or —
137
+ * when the lookup could not answer — {@link moveSentence}'s older sentence
138
+ * and a note saying so.
139
+ */
140
+ export function moveQuestion(name: string, destination: string): string {
141
+ return `Move ${name} to ${destination}?`;
142
+ }
143
+
144
+ /**
145
+ * The move question with the one sentence it used to carry alone. Still what
146
+ * the dialog says when the access change is not known: a tester read this as
147
+ * unclear, which is why the blocks exist, but it is honest where a list of
148
+ * names would be a guess.
149
+ */
150
+ export function moveSentence(name: string, destination: string): string {
151
+ return `${moveQuestion(name, destination)} Access to it will follow ${possessive(destination)} rules from now on.`;
152
+ }
153
+
154
+ /** What the dialog reads when the lookup answered and found no change. */
155
+ export const NO_ACCESS_CHANGE = "Nobody's access changes.";
156
+
157
+ /** What the dialog reads when the lookup failed or ran out of its two seconds. */
158
+ export const ACCESS_CHANGE_UNKNOWN = "Couldn't work out the access change.";
159
+
160
+ /**
161
+ * The whole budget for the access lookup. Past it the dialog stops claiming to
162
+ * know: a confirmation the user is staring at may not wait on a resolver.
163
+ */
164
+ export const ACCESS_LOOKUP_TIMEOUT_MS = 2000;
165
+
166
+ /** Lines past this many are folded into "and N more". */
167
+ const ACCESS_BLOCK_CAP = 6;
168
+
169
+ /** The two verbs the move compares, in the order their lines are listed. */
170
+ const ACCESS_VERBS = ['read', 'write'] as const;
171
+
172
+ /** How each verb reads to someone who is not thinking about access grammar. */
173
+ const VERB_WORD: Record<(typeof ACCESS_VERBS)[number], string> = {
174
+ read: 'open',
175
+ write: 'edit',
176
+ };
177
+
178
+ /**
179
+ * A principal as the Manage access dialog names it — the same spelling in both
180
+ * places, so the confirmation and the sheet never describe one grant two ways.
181
+ * A plugin principal's raw `plugin/<Name>/<verb>` token becomes "GTM ·
182
+ * readers"; the built-in `everyone` role becomes "Everyone".
183
+ */
184
+ export function principalLabel(principal: AccessPrincipalRef): string {
185
+ if (principal.kind === 'plugin') {
186
+ const parsed = parsePluginPrincipalToken(principal.name);
187
+ return parsed ? pluginPrincipalLabel(parsed.plugin, parsed.verb) : principal.name;
188
+ }
189
+ if (principal.kind === 'role' && principal.name.trim().toLowerCase() === 'everyone') {
190
+ return 'Everyone';
191
+ }
192
+ // A person granted directly, with no display name on record, is still
193
+ // someone: their email names them better than a blank line does.
194
+ if (principal.kind === 'person') return principal.name || (principal.email ?? '');
195
+ return principal.name;
196
+ }
197
+
198
+ /**
199
+ * One principal's identity across the two sides of the move. People are the
200
+ * same person at the same address whatever name each side carries; a
201
+ * collective is the same principal at the same name and kind — a group and a
202
+ * role sharing a name are two principals, as everywhere else in access.
203
+ */
204
+ function principalKey(principal: AccessPrincipalRef): string {
205
+ return principal.kind === 'person'
206
+ ? `person:${(principal.email ?? principal.name).toLowerCase()}`
207
+ : `${principal.kind}:${principal.name.toLowerCase()}`;
208
+ }
209
+
210
+ /** The lose and gain blocks of one move, each already capped. */
211
+ export interface AccessChange {
212
+ lose: string[];
213
+ gain: string[];
214
+ }
215
+
216
+ /** Six lines, then "and N more" for the rest. */
217
+ function capped(lines: string[]): string[] {
218
+ if (lines.length <= ACCESS_BLOCK_CAP) return lines;
219
+ return [...lines.slice(0, ACCESS_BLOCK_CAP), `and ${lines.length - ACCESS_BLOCK_CAP} more`];
220
+ }
221
+
222
+ /**
223
+ * Who loses and who gains access in one move: per verb, the principals
224
+ * present before and absent after, and absent before and present after.
225
+ *
226
+ * Lines are grouped by principal in the order the lists name them — the
227
+ * resolver's order, collectives before directly granted people — and within a
228
+ * principal, opening before editing. A principal that loses one verb and
229
+ * gains another appears in both blocks, which is what happened.
230
+ */
231
+ export function accessChangeLines(before: PathPrincipals, after: PathPrincipals): AccessChange {
232
+ const lose: string[] = [];
233
+ const gain: string[] = [];
234
+ // First-seen order over every list, so a principal's lines sit together
235
+ // wherever the verb that introduced it came from.
236
+ const order: AccessPrincipalRef[] = [];
237
+ const seen = new Set<string>();
238
+ for (const side of [before, after]) {
239
+ for (const verb of ACCESS_VERBS) {
240
+ for (const principal of side[verb]) {
241
+ const key = principalKey(principal);
242
+ if (seen.has(key)) continue;
243
+ seen.add(key);
244
+ order.push(principal);
245
+ }
246
+ }
247
+ }
248
+ const keysOf = (list: AccessPrincipalRef[]) => new Set(list.map(principalKey));
249
+ const sides = {
250
+ before: { read: keysOf(before.read), write: keysOf(before.write) },
251
+ after: { read: keysOf(after.read), write: keysOf(after.write) },
252
+ };
253
+ for (const principal of order) {
254
+ const key = principalKey(principal);
255
+ const label = principalLabel(principal);
256
+ for (const verb of ACCESS_VERBS) {
257
+ const had = sides.before[verb].has(key);
258
+ const has = sides.after[verb].has(key);
259
+ if (had && !has) lose.push(`${label}: can no longer ${VERB_WORD[verb]}`);
260
+ if (!had && has) gain.push(`${label}: can ${VERB_WORD[verb]}`);
261
+ }
262
+ }
263
+ return { lose: capped(lose), gain: capped(gain) };
264
+ }
265
+
266
+ /** {@link accessChangeLines} over a whole prospective-access answer. */
267
+ export function accessChangeOf(access: ProspectiveAccess): AccessChange {
268
+ return accessChangeLines(access.before, access.after);
269
+ }
270
+
271
+ /**
272
+ * The warnings that apply to one move, in a fixed order.
273
+ *
274
+ * `canWrite` is the caller's write permission on the destination: `false`
275
+ * adds the refusal warning, `null` (not known yet, or the lookup failed) adds
276
+ * nothing — the dialog never blocks on it, and the server stays the gate.
277
+ * A move into a folder the caller may not write is REFUSED today: the move
278
+ * route acquires the write lock on both ends, and the lock gate throws
279
+ * AccessDeniedError on a protected branch (`WorkflowService.acquireLock`).
280
+ * Only uploads are rerouted to a suggestion; a move is not.
281
+ */
282
+ export function moveWarnings(opts: {
283
+ sourcePath: string;
284
+ targetDir: string;
285
+ destinationLabel: string;
286
+ kbDirName: string | null;
287
+ canWrite: boolean | null;
288
+ /**
289
+ * Whether the person making the move is an admin. Only the restore line
290
+ * reads it, and it must: a nested `roles.yaml` is ordinary content, so
291
+ * ANYONE can drag one at the root, and telling a non-admin their move is
292
+ * "allowed for an Admin" would promise them what the server will refuse.
293
+ */
294
+ isAdmin?: boolean;
295
+ }): string[] {
296
+ const name = opts.sourcePath.split('/').pop() ?? opts.sourcePath;
297
+ const warnings: string[] = [];
298
+ if (opts.canWrite === false) {
299
+ // A restore is the one move allowed past a destination that refuses the
300
+ // write, so for the admin who may make it "the move will be refused" is
301
+ // the wrong prediction. For everyone else it is the right one.
302
+ const destination = opts.targetDir ? `${opts.targetDir}/${name}` : name;
303
+ const from = repoRelative(opts.sourcePath, opts.kbDirName);
304
+ const to = repoRelative(destination, opts.kbDirName);
305
+ const restore =
306
+ opts.isAdmin === true && from !== null && to !== null && isPlatformRestoreShape(from, to);
307
+ warnings.push(
308
+ restore
309
+ ? `You can't write to ${opts.destinationLabel}, but putting ${name} back where the platform reads it is allowed for an Admin.`
310
+ : `You can't write to ${opts.destinationLabel} — the move will be refused.`,
311
+ );
312
+ }
313
+ // No platform-file warning here: moving one out of its folder breaks the
314
+ // workspace, so the tree refuses it outright (`platformFileMoveRefusal`)
315
+ // instead of offering it as something to confirm. The only platform file
316
+ // that still reaches this dialog is a misplaced one an admin is putting
317
+ // back, and there is nothing to warn about in a repair.
318
+ const fromRoot = rootOf(opts.sourcePath, opts.kbDirName);
319
+ const toRoot = rootOf(opts.targetDir ? `${opts.targetDir}/${name}` : name, opts.kbDirName);
320
+ if (fromRoot && toRoot && fromRoot !== toRoot) {
321
+ warnings.push(`This moves it out of ${fromRoot}/ into ${toRoot}/ — the two roots are handled differently.`);
322
+ }
323
+ return warnings;
324
+ }
325
+
326
+ /**
327
+ * What a withdraw asks before it takes a suggestion back.
328
+ *
329
+ * Withdrawal is per REQUEST, never per file: a multi-file drop became ONE
330
+ * change request, and cancelling it cancels all of it. The user right-clicked
331
+ * a single row, so the count is said out loud — learning afterwards that two
332
+ * other files went with it is the one outcome this sentence exists to prevent.
333
+ */
334
+ export function withdrawSentence(files: string[]): string {
335
+ if (files.length > 1) return `This withdraws the whole suggestion: ${files.length} files`;
336
+ const name = files[0]?.split('/').pop();
337
+ return name ? `Withdraw ${name}?` : 'Withdraw this suggestion?';
338
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What to do about a refused upload.
3
+ *
4
+ * The error banner ends with a next step because the reason alone leaves the
5
+ * user holding a file and no idea where to put it — and the refusals that
6
+ * have a specific answer want different ones.
7
+ *
8
+ * The HTTP STATUS decides, not the wording: the backend answers 401 for a
9
+ * session that lapsed, 403 for a folder the caller may not write and 413 for
10
+ * a file over the upload cap, and each maps onto its own step. Classifying on the
11
+ * server's prose instead meant any rewording of a message — or a change to
12
+ * the size cap the advice used to restate — silently started telling users
13
+ * the wrong thing, with nothing failing to say so. The message is for the
14
+ * banner's reason line and nothing else.
15
+ *
16
+ * `status` is absent for a failure that never reached an HTTP response (the
17
+ * network, or the folder walker); "try again" is the honest step for those.
18
+ *
19
+ * Lives here rather than beside the banner so it can be read and tested
20
+ * without rendering a tree.
21
+ */
22
+ export function uploadErrorNextStep(status: number | undefined): string {
23
+ // A lapsed session is not a refused folder: another folder fails the same
24
+ // way and its owner refused nothing. Signing in again is the step.
25
+ if (status === 401) return 'Sign in again, then try once more.';
26
+ if (status === 403) return 'Try another folder or ask its owner.';
27
+ if (status === 413) return 'That file is over the upload size limit — try a smaller one.';
28
+ return 'Try again, or pick another folder.';
29
+ }
@@ -0,0 +1,59 @@
1
+ import { describe, it, expect, afterEach } from 'vitest';
2
+ import {
3
+ configureMarketplaceGitUrl,
4
+ marketplaceCommands,
5
+ marketplaceGitUrl,
6
+ resetMarketplaceGitUrlForTests,
7
+ withConnectionKey,
8
+ } from '../marketplace-url';
9
+
10
+ afterEach(() => resetMarketplaceGitUrlForTests());
11
+
12
+ describe('marketplace git url', () => {
13
+ it('uses the server\'s address, with any credential stripped', () => {
14
+ configureMarketplaceGitUrl('https://user:hunter2@kb.acme.com/git/marketplace.git');
15
+ expect(marketplaceGitUrl()).toBe('https://kb.acme.com/git/marketplace.git');
16
+ });
17
+
18
+ it('falls back to the origin when the server sends nothing usable', () => {
19
+ configureMarketplaceGitUrl(undefined);
20
+ expect(marketplaceGitUrl()).toBe(`${window.location.origin}/git/marketplace.git`);
21
+ configureMarketplaceGitUrl('javascript:alert(1)');
22
+ expect(marketplaceGitUrl()).toBe(`${window.location.origin}/git/marketplace.git`);
23
+ });
24
+
25
+ it('puts the connection key in the URL the way git sends it', () => {
26
+ configureMarketplaceGitUrl('https://kb.acme.com/git/marketplace.git');
27
+ expect(withConnectionKey('bevel_abc')).toBe('https://key:bevel_abc@kb.acme.com/git/marketplace.git');
28
+ const cmds = marketplaceCommands('bevel_abc');
29
+ expect(cmds.claude).toBe(
30
+ 'claude plugin marketplace add https://key:bevel_abc@kb.acme.com/git/marketplace.git && claude plugin install hexis-all@hexis',
31
+ );
32
+ expect(cmds.codex.split('\n')).toEqual([
33
+ 'codex plugin marketplace add https://key:bevel_abc@kb.acme.com/git/marketplace.git',
34
+ 'codex plugin add skills-and-knowledge@hexis',
35
+ 'codex mcp login hexis',
36
+ 'codex exec --skip-git-repo-check "Call the hexis MCP server\'s list_tools tool and print the tool names it returns."',
37
+ ]);
38
+ expect(cmds.skills).toBe('npx skills add https://key:bevel_abc@kb.acme.com/git/marketplace.git --all -y');
39
+ });
40
+
41
+ it('shows a placeholder verbatim — never percent-encoded into something that looks like a key', () => {
42
+ configureMarketplaceGitUrl('https://kb.acme.com/git/marketplace.git');
43
+ expect(withConnectionKey('<external-api-key>')).toBe(
44
+ 'https://key:<external-api-key>@kb.acme.com/git/marketplace.git',
45
+ );
46
+ expect(marketplaceCommands('<external-api-key>').claude).not.toContain('%3C');
47
+ });
48
+
49
+ it('keeps a real key byte for byte — tenant prefix plus base64url, with its dashes and underscores', () => {
50
+ configureMarketplaceGitUrl('https://kb.acme.com/git/marketplace.git');
51
+ const key = 'corestaging_Ab-9_x2C9-Nmm_ic';
52
+ expect(withConnectionKey(key)).toBe(`https://key:${key}@kb.acme.com/git/marketplace.git`);
53
+ });
54
+
55
+ it('keeps a non-default port in the remote', () => {
56
+ configureMarketplaceGitUrl('http://localhost:3000/git/marketplace.git');
57
+ expect(withConnectionKey('bevel_abc')).toBe('http://key:bevel_abc@localhost:3000/git/marketplace.git');
58
+ });
59
+ });
@@ -14,13 +14,15 @@ import { cn } from '../../lib/utils';
14
14
  * tightened tracking so digits line up.
15
15
  */
16
16
 
17
- export type BadgeTone = 'neutral' | 'ok' | 'wait' | 'danger' | 'outline';
17
+ export type BadgeTone = 'neutral' | 'ok' | 'wait' | 'urgent' | 'danger' | 'outline';
18
18
  export type BadgeSize = 'sm' | 'xs';
19
19
 
20
20
  const TONE: Record<BadgeTone, string> = {
21
21
  neutral: 'bg-sunken text-ink-muted',
22
22
  ok: 'bg-ok-soft text-ok',
23
23
  wait: 'bg-wait-soft text-wait font-semibold',
24
+ // Above wait, below danger: blocking other people, not just the reader.
25
+ urgent: 'bg-urgent-soft text-urgent font-semibold',
24
26
  danger: 'bg-danger-soft text-danger font-semibold',
25
27
  outline: 'border border-line bg-transparent text-ink-muted',
26
28
  };
@@ -16,10 +16,14 @@ import { cn } from '../../lib/utils';
16
16
  * conditional element.
17
17
  */
18
18
 
19
- export type BannerTone = 'wait' | 'ok' | 'danger' | 'neutral';
19
+ export type BannerTone = 'wait' | 'urgent' | 'ok' | 'danger' | 'neutral';
20
20
 
21
21
  const TONE: Record<BannerTone, string> = {
22
22
  wait: 'bg-wait-soft text-ink',
23
+ // Above wait, below danger: blocking other people, not just the reader.
24
+ // Orange ink, unlike wait's neutral ink: amber text on amber fails contrast
25
+ // (2.6:1), orange on its soft ground passes AA (5.1:1).
26
+ urgent: 'bg-urgent-soft text-urgent',
23
27
  ok: 'bg-ok-soft text-ok',
24
28
  danger: 'bg-danger-soft text-danger',
25
29
  neutral: 'bg-sunken text-ink',
@@ -1,4 +1,4 @@
1
- import type { ButtonHTMLAttributes, ReactNode } from 'react';
1
+ import type { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
2
2
  import { cn } from '../../lib/utils';
3
3
 
4
4
  /**
@@ -68,6 +68,14 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
68
68
  leadingIcon?: ReactNode;
69
69
  /** Rendered after the label. */
70
70
  trailingIcon?: ReactNode;
71
+ /**
72
+ * Declared explicitly because `ButtonHTMLAttributes` does not carry `ref`
73
+ * (the same contract as `IconButton`). A labelled button that opens a menu
74
+ * has to be referenceable: dismissing on Escape hands focus back to it, and
75
+ * an outside-click handler has to tell "clicked the trigger" from "clicked
76
+ * away", or one click closes and reopens.
77
+ */
78
+ ref?: Ref<HTMLButtonElement>;
71
79
  }
72
80
 
73
81
  export function Button({
@@ -78,10 +86,16 @@ export function Button({
78
86
  className,
79
87
  children,
80
88
  type = 'button',
89
+ ref,
81
90
  ...rest
82
91
  }: ButtonProps) {
83
92
  return (
84
- <button type={type} className={buttonClasses({ variant, size, className })} {...rest}>
93
+ <button
94
+ ref={ref}
95
+ type={type}
96
+ className={buttonClasses({ variant, size, className })}
97
+ {...rest}
98
+ >
85
99
  {leadingIcon}
86
100
  {children}
87
101
  {trailingIcon}