@bevel-software/platform-core-frontend 0.15.1 → 0.20.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 (347) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +20 -9
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/events.test.ts +43 -0
  6. package/src/core/bootstrap.ts +11 -3
  7. package/src/core/events.ts +85 -3
  8. package/src/core/registry.ts +1 -1
  9. package/src/lib/__tests__/email.test.ts +44 -0
  10. package/src/lib/email.ts +37 -1
  11. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  12. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  13. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  16. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  20. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
  21. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  22. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  23. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  24. package/src/modules/access/api.ts +140 -6
  25. package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
  26. package/src/modules/access/manage-access-affordance.ts +17 -0
  27. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  28. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  29. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  30. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  31. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  32. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  33. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  34. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  35. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  36. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  37. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  38. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  39. package/src/modules/admin/components/group-members-path.ts +32 -0
  40. package/src/modules/admin/services/roles.api.ts +12 -1
  41. package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
  42. package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
  43. package/src/modules/audit/components/AuditLogPage.tsx +373 -0
  44. package/src/modules/audit/components/principal-grouping.ts +49 -0
  45. package/src/modules/audit/services/audit.api.ts +98 -0
  46. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  47. package/src/modules/auth/components/AccountPage.tsx +73 -54
  48. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  49. package/src/modules/auth/services/account.api.ts +78 -4
  50. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  51. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  52. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  53. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  58. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  59. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  60. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  61. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  62. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  63. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  64. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  65. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  66. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  67. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  68. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  69. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  70. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  71. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  72. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  73. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  74. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  75. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  76. package/src/modules/change-requests/services/propose.api.ts +97 -8
  77. package/src/modules/change-requests/utils/approval.ts +15 -0
  78. package/src/modules/change-requests/utils/author.ts +32 -0
  79. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  80. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  81. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  82. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  83. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  84. package/src/modules/git/services/error-messages.ts +12 -0
  85. package/src/modules/git/services/pr-prompts.ts +5 -5
  86. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  87. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  88. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  89. package/src/modules/layout/components/AppLayout.tsx +2 -0
  90. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  91. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  92. package/src/modules/layout/components/SidebarFrame.tsx +108 -3
  93. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  94. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  95. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  96. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  97. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  98. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
  99. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
  100. package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
  101. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
  102. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  103. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  104. package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
  105. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  106. package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
  107. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
  108. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
  109. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  110. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  111. package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
  112. package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
  113. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  114. package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
  115. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
  116. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  117. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  118. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  119. package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
  120. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  121. package/src/modules/library/__tests__/library-paths.test.ts +47 -4
  122. package/src/modules/library/__tests__/link-membership.test.ts +13 -4
  123. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  124. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  125. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  126. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  127. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  128. package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
  129. package/src/modules/library/__tests__/status.test.ts +82 -2
  130. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  131. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  132. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  133. package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
  134. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  135. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  136. package/src/modules/library/components/LibraryCard.tsx +146 -45
  137. package/src/modules/library/components/LibraryLayout.tsx +119 -256
  138. package/src/modules/library/components/LibraryPage.tsx +172 -39
  139. package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
  140. package/src/modules/library/components/LockedPluginView.tsx +62 -34
  141. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  142. package/src/modules/library/components/NewPluginDialog.tsx +16 -2
  143. package/src/modules/library/components/PageActions.tsx +11 -9
  144. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  145. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  146. package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
  147. package/src/modules/library/components/PluginExtras.tsx +140 -17
  148. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  149. package/src/modules/library/components/PluginPage.tsx +157 -41
  150. package/src/modules/library/components/PluginRows.tsx +286 -0
  151. package/src/modules/library/components/PluginsSidebar.tsx +239 -263
  152. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  153. package/src/modules/library/components/ShareButton.tsx +17 -0
  154. package/src/modules/library/components/SkillsTree.tsx +141 -28
  155. package/src/modules/library/components/TeamRoute.tsx +15 -0
  156. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  157. package/src/modules/library/components/plugin-page-parts.tsx +103 -17
  158. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
  159. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  160. package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
  161. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  162. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  163. package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
  164. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  165. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  166. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  167. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  168. package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
  169. package/src/modules/library/routes/library-paths.ts +26 -28
  170. package/src/modules/library/services/library.api.ts +38 -20
  171. package/src/modules/library/services/plugins.api.ts +69 -8
  172. package/src/modules/library/services/teams.api.ts +15 -0
  173. package/src/modules/library/services/tools.api.ts +78 -0
  174. package/src/modules/library/state/library-data.tsx +170 -32
  175. package/src/modules/library/utils/personal-plugin.ts +13 -15
  176. package/src/modules/library/utils/plugin-entries.ts +134 -0
  177. package/src/modules/library/utils/plugin-summary.ts +75 -9
  178. package/src/modules/library/utils/status.ts +135 -33
  179. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
  180. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  181. package/src/modules/onboarding/agent-clients.ts +55 -23
  182. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  183. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  184. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  185. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  186. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  187. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  188. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  189. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  190. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  191. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  192. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  193. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  194. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  195. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  196. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  197. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  198. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  199. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  200. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  201. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  202. package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
  203. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  204. package/src/modules/settings/components/DeploymentPage.tsx +10 -30
  205. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  206. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
  207. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  208. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
  209. package/src/modules/settings/services/github-facade.api.ts +23 -0
  210. package/src/modules/settings/settings-nav-items.tsx +13 -3
  211. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  212. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  213. package/src/modules/setup/__tests__/setup.test.tsx +497 -4
  214. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  215. package/src/modules/setup/components/SetupGate.tsx +16 -16
  216. package/src/modules/setup/components/SetupScreen.tsx +532 -43
  217. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  218. package/src/modules/setup/services/setup.api.ts +141 -4
  219. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  220. package/src/modules/setup/utils/root-folders.ts +46 -0
  221. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  222. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  223. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  224. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  225. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  226. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  227. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  228. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  229. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  230. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  231. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  232. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  233. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  234. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  235. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  236. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  237. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
  238. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  239. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  240. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  241. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
  242. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  243. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  244. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  245. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  246. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  247. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  248. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  249. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  250. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  251. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  252. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  253. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  254. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  255. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  256. package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
  257. package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
  258. package/src/modules/workspace/components/FileRoute.tsx +353 -36
  259. package/src/modules/workspace/components/FileViewer.tsx +172 -46
  260. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  261. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  262. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  263. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
  264. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
  265. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
  266. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  267. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  268. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  269. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  270. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  271. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  272. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  273. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  274. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  275. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  276. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  277. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  278. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  279. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  280. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  281. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  282. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  283. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  284. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  285. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  286. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  287. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  288. package/src/modules/workspace/components/renderers/index.ts +53 -2
  289. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  290. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  291. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  292. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  293. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  294. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  295. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  296. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
  297. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  298. package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
  299. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  300. package/src/modules/workspace/routing/kb-routes.ts +206 -29
  301. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
  302. package/src/modules/workspace/services/workspace.api.ts +57 -4
  303. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  304. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  305. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  306. package/src/modules/workspace/state/workspace.context.ts +125 -19
  307. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  308. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
  309. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  310. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  311. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  312. package/src/modules/workspace/utils/file-trace.ts +50 -0
  313. package/src/modules/workspace/utils/fileTree.ts +112 -36
  314. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  315. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  316. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  317. package/src/modules/workspace/utils/uploadError.ts +29 -0
  318. package/src/shared/__tests__/marketplace-url.test.ts +6 -1
  319. package/src/shared/components/Button.tsx +16 -2
  320. package/src/shared/components/Dialog.tsx +27 -11
  321. package/src/shared/components/Menu.tsx +13 -1
  322. package/src/shared/components/PageShell.tsx +13 -8
  323. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  324. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  325. package/src/shared/components/index.ts +2 -0
  326. package/src/shared/components/useDismissableMenu.ts +32 -10
  327. package/src/shared/components/useFocusHandoff.ts +51 -0
  328. package/src/shared/components/useLatestRef.ts +28 -0
  329. package/src/shared/markdown/Markdown.tsx +12 -3
  330. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  331. package/src/shared/markdown/hrefs.ts +50 -0
  332. package/src/shared/marketplace-url.ts +33 -5
  333. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  334. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  335. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  336. package/src/shared/mcp/connect-snippets.ts +14 -9
  337. package/src/shared/mcp/index.ts +1 -1
  338. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  339. package/src/shared/theme/header.ts +75 -0
  340. package/src/shared/theme/measure.ts +7 -4
  341. package/src/shared/theme/tokens.css +25 -0
  342. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  343. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  344. package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
  345. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  346. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  347. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -0,0 +1,152 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Banner, Button, Surface } from '../../../shared/components';
3
+ import { ClaudeRegistrationSteps } from '../../toolbar/components/ClaudeRegistrationSteps';
4
+ import {
5
+ fetchMarketplaceRegistration,
6
+ setMarketplaceRegistration,
7
+ } from '../services/github-facade.api';
8
+
9
+ interface Props {
10
+ /**
11
+ * Where the section stands. `setup` is the first-run screen, where it is
12
+ * marked Optional and an admin simply walks past it; `settings` is
13
+ * Deployment settings, where it waits for whenever an admin gets to it.
14
+ * There is no skip control: nothing waits on this section either way, so a
15
+ * button to decline it only added a decision the admin does not have to
16
+ * make. Same as single sign-on, which is left blank to be ignored.
17
+ */
18
+ variant: 'setup' | 'settings';
19
+ }
20
+
21
+ /**
22
+ * The Marketplace section of Deployment configuration: registering this
23
+ * deployment with a Claude organization, so people can add its marketplace in
24
+ * Cowork and on claude.ai. ONE component in both hosts — the first-run setup
25
+ * screen and Deployment settings — so the steps cannot drift between them.
26
+ *
27
+ * It holds what used to be the admin branch of the External agent access
28
+ * tutorial: the registration steps, the generated credentials (inside the
29
+ * drawer, fetched only once it is open), and the GitHub Enterprise Server
30
+ * steps. Plus the one thing Claude never reports back: whether the
31
+ * registration happened. An admin says so here, and External agent access
32
+ * shows everyone the tutorial from then on.
33
+ */
34
+ export function MarketplaceSection({ variant }: Props) {
35
+ // Controlled, both attributes together: the credentials wait on `open`, and
36
+ // the element must not be able to disagree with the state gating them.
37
+ const [open, setOpen] = useState(false);
38
+ const [registered, setRegistered] = useState<boolean | null>(null);
39
+ const [loadError, setLoadError] = useState<string | null>(null);
40
+ const [saving, setSaving] = useState(false);
41
+ const [saveError, setSaveError] = useState<string | null>(null);
42
+
43
+ useEffect(() => {
44
+ let live = true;
45
+ fetchMarketplaceRegistration()
46
+ .then((r) => {
47
+ if (live) setRegistered(r);
48
+ })
49
+ .catch((err: unknown) => {
50
+ if (live) setLoadError(err instanceof Error ? err.message : String(err));
51
+ });
52
+ return () => {
53
+ live = false;
54
+ };
55
+ }, []);
56
+
57
+ // External agent access links admins to `/deployment#marketplace`. The
58
+ // section mounts after the settings load, long after the router would have
59
+ // looked for the anchor, so it brings itself into view.
60
+ useEffect(() => {
61
+ // By id: `Surface` takes no ref, and the id is the anchor anyway.
62
+ if (window.location.hash === '#marketplace') {
63
+ document.getElementById('marketplace')?.scrollIntoView?.({ block: 'start' });
64
+ }
65
+ }, []);
66
+
67
+ const mark = async (next: boolean) => {
68
+ setSaving(true);
69
+ setSaveError(null);
70
+ try {
71
+ setRegistered(await setMarketplaceRegistration(next));
72
+ } catch (err) {
73
+ setSaveError(err instanceof Error ? err.message : String(err));
74
+ } finally {
75
+ setSaving(false);
76
+ }
77
+ };
78
+
79
+ return (
80
+ <Surface
81
+ as="section"
82
+ id="marketplace"
83
+ aria-labelledby="marketplace-heading"
84
+ tone="surface"
85
+ radius="lg"
86
+ elevation="card"
87
+ className="mt-10 p-6 space-y-4"
88
+ data-testid="marketplace-deployment-section"
89
+ >
90
+ <div>
91
+ <div className="flex items-baseline gap-2.5">
92
+ <h2 id="marketplace-heading" className="text-title font-semibold text-ink">
93
+ Marketplace
94
+ </h2>
95
+ {variant === 'setup' && <span className="text-meta text-ink-faint">Optional</span>}
96
+ </div>
97
+ <p className="mt-1 max-w-[60ch] text-detail text-ink-muted">
98
+ Lets people add this deployment's skills as plugins in Cowork and on claude.ai. Register it
99
+ once with your Claude organization, then mark it registered below: until then, External
100
+ agent access tells people an admin still has to set it up. Claude Code and Codex need none
101
+ of this.
102
+ </p>
103
+ </div>
104
+
105
+ <details
106
+ className="rounded-md border border-line"
107
+ open={open}
108
+ onToggle={(e) => setOpen(e.currentTarget.open)}
109
+ >
110
+ <summary className="cursor-pointer px-3 py-2 text-xs font-medium text-ink">
111
+ Register this deployment with Claude
112
+ </summary>
113
+ <div className="px-3 pb-3">
114
+ <ClaudeRegistrationSteps opened={open} />
115
+ </div>
116
+ </details>
117
+
118
+ <div className="space-y-2">
119
+ {loadError && (
120
+ <Banner tone="danger" role="alert">
121
+ {loadError}
122
+ </Banner>
123
+ )}
124
+ {registered !== null && (
125
+ <div className="flex flex-wrap items-center gap-3">
126
+ {/* Not a live region: the setup screen's save notices are, and
127
+ this line only changes under the button the reader pressed. */}
128
+ <p className="text-detail text-ink-muted">
129
+ {registered
130
+ ? 'Registered. Everyone sees the Cowork and claude.ai steps on External agent access.'
131
+ : 'Not registered yet. People are told an admin has to set this up.'}
132
+ </p>
133
+ <Button
134
+ type="button"
135
+ variant={registered ? 'outline' : 'primary'}
136
+ size="sm"
137
+ disabled={saving}
138
+ onClick={() => void mark(!registered)}
139
+ >
140
+ {saving ? 'Saving…' : registered ? 'Mark as not registered' : 'Mark as registered'}
141
+ </Button>
142
+ </div>
143
+ )}
144
+ {saveError && (
145
+ <Banner tone="danger" role="alert">
146
+ {saveError}
147
+ </Banner>
148
+ )}
149
+ </div>
150
+ </Surface>
151
+ );
152
+ }
@@ -1,6 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { fireEvent, render, screen, waitFor } from '@testing-library/react';
2
+ import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
3
3
  import { AdminContext, type AdminContextValue } from '../../../admin/state/admin.context';
4
+ import { KbInitFailed } from '../../../setup/services/setup.api';
4
5
 
5
6
  /**
6
7
  * The deployment settings page — first-run setup with a permanent address.
@@ -11,15 +12,18 @@ import { AdminContext, type AdminContextValue } from '../../../admin/state/admin
11
12
  */
12
13
 
13
14
  const apiMock = vi.hoisted(() => ({ fetchSetupStatus: vi.fn(), saveSettings: vi.fn() }));
14
- // The Claude connection card fetches its credentials on mount; answer it so
15
- // its retry button never stands beside the page's own.
16
- vi.mock('../../services/github-facade.api', () => ({
15
+ // The Marketplace section reads the registration state on mount, and the
16
+ // credentials only once its drawer opens — the count is asserted below.
17
+ const facadeMock = vi.hoisted(() => ({
17
18
  fetchGitHubFacade: vi.fn(async () => ({
18
19
  host: 'kb.test', appId: '123456', clientId: 'Iv1.x', clientSecret: 's', webhookSecret: 'w',
19
20
  privateKeyPem: 'p', marketplaceUrl: 'https://kb.test/git/marketplace.git', createdAt: 0, rotatedAt: null,
20
21
  })),
21
22
  rotateGitHubFacade: vi.fn(),
23
+ fetchMarketplaceRegistration: vi.fn(async () => false),
24
+ setMarketplaceRegistration: vi.fn(),
22
25
  }));
26
+ vi.mock('../../services/github-facade.api', () => facadeMock);
23
27
 
24
28
  vi.mock('../../../setup/services/setup.api', async (importOriginal) => ({
25
29
  ...(await importOriginal<object>()),
@@ -60,6 +64,15 @@ describe('DeploymentPage', () => {
60
64
  apiMock.fetchSetupStatus.mockResolvedValue(COMPLETE_STATUS);
61
65
  });
62
66
 
67
+ it('shows whether the single sign-on configuration is verified', async () => {
68
+ apiMock.fetchSetupStatus.mockResolvedValue({ ...COMPLETE_STATUS, oidcVerification: 'unverified' });
69
+ renderPage(admin(true));
70
+ expect(await screen.findByTestId('oidc-verification')).toHaveTextContent(
71
+ 'Unverified — sign in once to confirm',
72
+ );
73
+ expect(screen.getByRole('button', { name: 'Test sign-in configuration' })).toBeInTheDocument();
74
+ });
75
+
63
76
  it('shows the setup form to an admin — AFTER setup is complete', async () => {
64
77
  renderPage(admin(true));
65
78
  // The single-sign-on fields are reachable again: the whole point of the page.
@@ -73,10 +86,35 @@ describe('DeploymentPage', () => {
73
86
  ).toBeInTheDocument();
74
87
  });
75
88
 
89
+ /**
90
+ * The settings host of the Marketplace section: the same section the first
91
+ * run shows, here without "Optional" (there is nothing to skip past), and
92
+ * with its credentials still waiting for the drawer.
93
+ */
94
+ it('renders the Marketplace section below the form, credentials unfetched until opened', async () => {
95
+ facadeMock.fetchGitHubFacade.mockClear();
96
+ renderPage(admin(true));
97
+ const section = await screen.findByTestId('marketplace-deployment-section');
98
+ expect(section).toHaveAttribute('id', 'marketplace');
99
+ expect(screen.getByRole('heading', { name: 'Marketplace' })).toBeInTheDocument();
100
+ expect(screen.getByText('Register this deployment with your Claude organization')).toBeInTheDocument();
101
+ expect(screen.queryByRole('button', { name: 'Skip for now' })).toBeNull();
102
+ // After the settings fields, and BEFORE "Save and continue": the button is
103
+ // the last thing on the page, so a reader meets this section before the
104
+ // control that leaves the screen. The button is tied to the form it sits
105
+ // outside of by `form=`.
106
+ const save = screen.getByRole('button', { name: 'Save and continue' });
107
+ expect(save.compareDocumentPosition(section) & Node.DOCUMENT_POSITION_PRECEDING).toBeTruthy();
108
+ expect(save).toHaveAttribute('form', 'setup-settings-form');
109
+ expect(await screen.findByRole('button', { name: 'Mark as registered' })).toBeInTheDocument();
110
+ expect(facadeMock.fetchGitHubFacade).not.toHaveBeenCalled();
111
+ });
112
+
76
113
  it('tells a non-admin this is not theirs, and never fetches the settings', () => {
77
114
  renderPage(admin(false));
78
115
  expect(screen.getByText(/Admins only/)).toBeInTheDocument();
79
116
  expect(screen.queryByText('Provider address')).toBeNull();
117
+ expect(screen.queryByTestId('marketplace-deployment-section')).toBeNull();
80
118
  // Never fetched, not merely never rendered: the page already told them
81
119
  // this is not theirs, so a request nothing renders is pure noise.
82
120
  expect(apiMock.fetchSetupStatus).not.toHaveBeenCalled();
@@ -106,6 +144,31 @@ describe('DeploymentPage', () => {
106
144
  expect(screen.getByRole('button', { name: 'Try again' })).toBeInTheDocument();
107
145
  });
108
146
 
147
+ it('an out-of-date status answer cannot bring back a failure a retry cleared', async () => {
148
+ const WRITE_REFUSED = { kind: 'write-refused' as const, cause: 'Grant the token push access, then retry.' };
149
+ const FAILED = { ...COMPLETE_STATUS, complete: false, kbInit: WRITE_REFUSED };
150
+ apiMock.fetchSetupStatus.mockResolvedValueOnce(FAILED);
151
+ renderPage(admin(true));
152
+ await screen.findByTestId('kb-init-failure');
153
+
154
+ // The refresh after a failed save is slow to answer…
155
+ let answerStale!: (s: unknown) => void;
156
+ apiMock.fetchSetupStatus.mockReturnValueOnce(new Promise((r) => (answerStale = r)));
157
+ apiMock.saveSettings.mockRejectedValueOnce(new KbInitFailed(WRITE_REFUSED));
158
+ fireEvent.click(screen.getByRole('button', { name: 'Save and continue' }));
159
+ await waitFor(() => expect(apiMock.fetchSetupStatus).toHaveBeenCalledTimes(2));
160
+
161
+ // …a retry succeeds meanwhile, and its refresh answers first.
162
+ apiMock.fetchSetupStatus.mockResolvedValueOnce(COMPLETE_STATUS);
163
+ apiMock.saveSettings.mockResolvedValueOnce({ ...COMPLETE_STATUS, restartRequired: false });
164
+ fireEvent.click(await screen.findByRole('button', { name: 'Retry initialization' }));
165
+ await waitFor(() => expect(apiMock.fetchSetupStatus).toHaveBeenCalledTimes(3));
166
+ await waitFor(() => expect(screen.queryByTestId('kb-init-failure')).toBeNull());
167
+
168
+ await act(async () => answerStale(FAILED));
169
+ expect(screen.queryByTestId('kb-init-failure')).toBeNull();
170
+ });
171
+
109
172
  it('offers a retry when the status cannot be loaded, and the retry fetches again', async () => {
110
173
  apiMock.fetchSetupStatus.mockRejectedValueOnce(new Error('down'));
111
174
  renderPage(admin(true));
@@ -0,0 +1,325 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { MemoryRouter } from 'react-router-dom';
5
+ import { configureMarketplaceGitUrl } from '../../../../shared/marketplace-url';
6
+
7
+ /**
8
+ * The Marketplace section of Deployment configuration — the admin branch
9
+ * that used to live on External agent access. Its host-specific rendering is
10
+ * covered where it is hosted (setup.test.tsx, DeploymentPage.test.tsx); what
11
+ * is worth testing here is the section's own contract: the credentials wait
12
+ * for the drawer, first run can skip it, and marking it registered is what
13
+ * External agent access reads.
14
+ */
15
+
16
+ const api = vi.hoisted(() => ({
17
+ fetchGitHubFacade: vi.fn(),
18
+ rotateGitHubFacade: vi.fn(),
19
+ fetchMarketplaceRegistration: vi.fn(),
20
+ setMarketplaceRegistration: vi.fn(),
21
+ }));
22
+ vi.mock('../../services/github-facade.api', () => api);
23
+
24
+ import { MarketplaceSection } from '../MarketplaceSection';
25
+
26
+ const CREDS = {
27
+ host: 'kb.acme.com',
28
+ appId: '123456',
29
+ clientId: 'Iv1.0123456789abcdef',
30
+ clientSecret: 'secret-1',
31
+ webhookSecret: 'hook-1',
32
+ privateKeyPem: '-----BEGIN RSA PRIVATE KEY-----\nabc\n-----END RSA PRIVATE KEY-----\n',
33
+ marketplaceUrl: 'https://kb.acme.com/git/marketplace.git',
34
+ createdAt: Date.UTC(2026, 8, 7),
35
+ rotatedAt: null,
36
+ };
37
+
38
+ beforeEach(() => {
39
+ configureMarketplaceGitUrl('https://kb.acme.com/git/marketplace.git');
40
+ api.fetchGitHubFacade.mockReset().mockResolvedValue(CREDS);
41
+ api.rotateGitHubFacade.mockReset();
42
+ api.fetchMarketplaceRegistration.mockReset().mockResolvedValue(false);
43
+ api.setMarketplaceRegistration.mockReset().mockImplementation(async (next: boolean) => next);
44
+ });
45
+
46
+ function mount(variant: 'setup' | 'settings') {
47
+ return render(
48
+ <MemoryRouter>
49
+ <MarketplaceSection variant={variant} />
50
+ </MemoryRouter>,
51
+ );
52
+ }
53
+
54
+ const drawer = () =>
55
+ screen.getByText('Register this deployment with Claude').closest('details') as HTMLDetailsElement;
56
+
57
+ /**
58
+ * The admin carousel inside the drawer. Its region name says what the region
59
+ * IS rather than repeating the drawer's summary, which already reads
60
+ * "Register this deployment with Claude" one level up.
61
+ */
62
+ const carousel = () =>
63
+ within(drawer()).getByRole('region', { name: 'Claude registration steps' });
64
+
65
+ /** The slide on screen, by the accessible name the live region carries. */
66
+ const slideName = (strip: HTMLElement) =>
67
+ within(strip).getByRole('group').getAttribute('aria-label');
68
+
69
+ /** Open the drawer and hand back the carousel it holds. */
70
+ async function openDrawer(user: ReturnType<typeof userEvent.setup>) {
71
+ await user.click(screen.getByText('Register this deployment with Claude'));
72
+ return carousel();
73
+ }
74
+
75
+ describe('MarketplaceSection', () => {
76
+ /**
77
+ * The registration steps are a CAROUSEL now, on the same shell as the
78
+ * personal tutorial: four screenshots stacked down a page was a wall, and
79
+ * the admin reading them is following one screen at a time anyway. What
80
+ * the shell owes the reader is asserted here — the progress strip, the
81
+ * counter, one shot at a time — because this is the route that did not
82
+ * have it.
83
+ */
84
+ it('walks the registration steps as a carousel, one screenshot at a time', async () => {
85
+ const user = userEvent.setup();
86
+ mount('settings');
87
+ const section = await screen.findByTestId('marketplace-deployment-section');
88
+ expect(within(section).getByRole('heading', { name: 'Marketplace' })).toBeInTheDocument();
89
+ const strip = await openDrawer(user);
90
+ expect(strip).toHaveAttribute('aria-roledescription', 'carousel');
91
+
92
+ const steps = [
93
+ ['Register this deployment with your Claude organization', `admin settings, Claude Code page`],
94
+ ['Fill the form and add the configuration', 'Add GitHub Enterprise dialog'],
95
+ ['Connect your own Claude account to it', 'admin settings, GitHub page'],
96
+ ['Pick this deployment as the GitHub instance', 'Install the Claude Code GitHub App dialog'],
97
+ ];
98
+
99
+ for (const [index, [title, alt]] of steps.entries()) {
100
+ expect(within(strip).getByRole('group')).toHaveAccessibleName(
101
+ `Step ${index + 1} of 5: ${title}`,
102
+ );
103
+ expect(within(strip).getByText(`${index + 1} / 5`)).toBeInTheDocument();
104
+ // One shot mounted, and it is this step's.
105
+ const shots = within(strip).getAllByRole('img');
106
+ expect(shots).toHaveLength(1);
107
+ expect(shots[0].getAttribute('alt')).toContain(alt);
108
+ // And the progress strip can jump straight to it.
109
+ expect(
110
+ within(strip).getByRole('button', { name: new RegExp(`^Go to step ${index + 1}: `) }),
111
+ ).toBeInTheDocument();
112
+ await user.click(within(strip).getByRole('button', { name: 'Next' }));
113
+ }
114
+
115
+ // Past the last registration step is the shared connector step, and the
116
+ // footer control has relabelled itself rather than disappearing.
117
+ expect(within(strip).getByRole('button', { name: 'Review again' })).toBeInTheDocument();
118
+ expect(within(strip).queryByRole('button', { name: 'Next' })).toBeNull();
119
+ expect(within(strip).getByRole('button', { name: 'Back' })).toBeEnabled();
120
+
121
+ // The deployment's own host and port, never a hard-coded example. The
122
+ // port lives on the Add-configuration step, the host on the instance one.
123
+ await user.click(within(strip).getByRole('button', { name: 'Go to step 2: Configure' }));
124
+ expect(strip).toHaveTextContent('the port is 443');
125
+ await user.click(within(strip).getByRole('button', { name: 'Go to step 4: Instance' }));
126
+ expect(strip).toHaveTextContent('kb.acme.com');
127
+
128
+ // Optional is a first-run word.
129
+ expect(within(section).queryByText('Optional')).toBeNull();
130
+ });
131
+
132
+ /**
133
+ * The admin route ends where everyone else's does. ONE slide definition
134
+ * behind both, so this copy and the personal tutorial's cannot drift; the
135
+ * assertion here is that the admin actually reaches it.
136
+ */
137
+ it('ends the admin carousel on the shared connector step', async () => {
138
+ const user = userEvent.setup();
139
+ mount('settings');
140
+ await screen.findByTestId('marketplace-deployment-section');
141
+ const strip = await openDrawer(user);
142
+
143
+ fireEvent.keyDown(strip, { key: 'End' });
144
+ expect(within(strip).getByRole('group')).toHaveAccessibleName(
145
+ 'Step 5 of 5: Add the hexis connector',
146
+ );
147
+ expect(strip).toHaveTextContent('does not connect its MCP server');
148
+ expect(strip).toHaveTextContent('Add for your team');
149
+ expect(strip).toHaveTextContent('Add custom connector');
150
+ expect(strip).toHaveTextContent('approve the sign-in on this deployment');
151
+ expect(strip).toHaveTextContent('Without organization-admin rights');
152
+ // Its two screens: the row that says Not added, and the dialog.
153
+ const alts = within(strip).getAllByRole('img').map((el) => el.getAttribute('alt') ?? '');
154
+ expect(alts).toHaveLength(2);
155
+ expect(alts[0]).toContain('Not added');
156
+ expect(alts[1]).toContain('Add custom connector dialog');
157
+ });
158
+
159
+ /**
160
+ * The keyboard half of the shared shell, on the admin route. The personal
161
+ * carousel covers the same keys on its own page; asserting them here too
162
+ * is what stops a regression in `SetupCarousel` from passing green on the
163
+ * route that only ever exercised End.
164
+ *
165
+ * The two no-op edges are part of the contract, not an oversight: Left on
166
+ * the first slide and Right on the last leave the keys to the browser, so
167
+ * a reader who tabbed onto a screenshot link still gets the default
168
+ * scroll. What the test can see is that the slide does not move.
169
+ */
170
+ it('moves through the admin carousel with the arrow keys, Home and End', async () => {
171
+ const user = userEvent.setup();
172
+ mount('settings');
173
+ await screen.findByTestId('marketplace-deployment-section');
174
+ const strip = await openDrawer(user);
175
+ expect(slideName(strip)).toBe('Step 1 of 5: Register this deployment with your Claude organization');
176
+
177
+ // Left on the first slide is a no-op, and does not wrap to the end.
178
+ // fireEvent hands back false when the handler called preventDefault, so
179
+ // this also asserts the key was LEFT to the browser rather than
180
+ // swallowed by a section that had nowhere to move.
181
+ expect(fireEvent.keyDown(strip, { key: 'ArrowLeft' })).toBe(true);
182
+ expect(slideName(strip)).toBe('Step 1 of 5: Register this deployment with your Claude organization');
183
+
184
+ // A key that does move is ours, and is prevented.
185
+ expect(fireEvent.keyDown(strip, { key: 'ArrowRight' })).toBe(false);
186
+ expect(slideName(strip)).toBe('Step 2 of 5: Fill the form and add the configuration');
187
+ fireEvent.keyDown(strip, { key: 'ArrowRight' });
188
+ expect(slideName(strip)).toBe('Step 3 of 5: Connect your own Claude account to it');
189
+ fireEvent.keyDown(strip, { key: 'ArrowLeft' });
190
+ expect(slideName(strip)).toBe('Step 2 of 5: Fill the form and add the configuration');
191
+
192
+ fireEvent.keyDown(strip, { key: 'End' });
193
+ expect(slideName(strip)).toBe('Step 5 of 5: Add the hexis connector');
194
+ // Right on the last slide is the other no-op edge: no wrap to step 1,
195
+ // and the key goes back to the browser. End on the last slide is the
196
+ // same, which is what a reader focused on a screenshot link needs.
197
+ expect(fireEvent.keyDown(strip, { key: 'ArrowRight' })).toBe(true);
198
+ expect(fireEvent.keyDown(strip, { key: 'End' })).toBe(true);
199
+ expect(slideName(strip)).toBe('Step 5 of 5: Add the hexis connector');
200
+
201
+ expect(fireEvent.keyDown(strip, { key: 'Home' })).toBe(false);
202
+ expect(slideName(strip)).toBe('Step 1 of 5: Register this deployment with your Claude organization');
203
+ });
204
+
205
+ /**
206
+ * "Review again" is the one control that wraps. The footer button
207
+ * relabels itself on the last slide rather than disappearing, and
208
+ * pressing it puts the admin back on step 1 with the progress strip
209
+ * reset — which is the whole reason it is a relabel and not a second
210
+ * button somewhere else.
211
+ */
212
+ it('restarts the admin carousel at step 1 from Review again', async () => {
213
+ const user = userEvent.setup();
214
+ mount('settings');
215
+ await screen.findByTestId('marketplace-deployment-section');
216
+ const strip = await openDrawer(user);
217
+
218
+ fireEvent.keyDown(strip, { key: 'End' });
219
+ expect(slideName(strip)).toBe('Step 5 of 5: Add the hexis connector');
220
+
221
+ await user.click(within(strip).getByRole('button', { name: 'Review again' }));
222
+ expect(slideName(strip)).toBe('Step 1 of 5: Register this deployment with your Claude organization');
223
+ expect(within(strip).getByText('1 / 5')).toBeInTheDocument();
224
+ expect(within(strip).getByRole('button', { name: 'Next' })).toBeInTheDocument();
225
+ expect(within(strip).getByRole('button', { name: 'Back' })).toBeDisabled();
226
+ expect(
227
+ within(strip).getByRole('button', { name: 'Go to step 1: Add manually' }),
228
+ ).toHaveAttribute('aria-current', 'step');
229
+ });
230
+
231
+ /**
232
+ * The drawer regression, carried over from External agent access: a closed
233
+ * <details> still MOUNTS its children, so credentials must wait on the
234
+ * drawer being open, not on the section rendering. A client secret is not
235
+ * put in the DOM of something nobody opened.
236
+ *
237
+ * The carousel adds the second gate. The credentials belong to the
238
+ * Add-configuration step and to nothing else, so they are mounted on that
239
+ * slide and on no other — opening the drawer is no longer enough on its
240
+ * own, and moving off the slide takes them back out.
241
+ */
242
+ it('fetches the credentials only on the Add-configuration slide of an open drawer', async () => {
243
+ const user = userEvent.setup();
244
+ mount('settings');
245
+ await screen.findByRole('button', { name: 'Mark as registered' });
246
+ expect(drawer().open).toBe(false);
247
+ expect(api.fetchGitHubFacade).not.toHaveBeenCalled();
248
+ expect(screen.queryByDisplayValue(CREDS.clientSecret)).toBeNull();
249
+
250
+ // Open, but standing on step 1: still nothing secret in the DOM.
251
+ const strip = await openDrawer(user);
252
+ expect(drawer().open).toBe(true);
253
+ expect(api.fetchGitHubFacade).not.toHaveBeenCalled();
254
+ expect(screen.queryByDisplayValue(CREDS.clientSecret)).toBeNull();
255
+
256
+ await user.click(within(strip).getByRole('button', { name: 'Next' }));
257
+
258
+ await within(drawer()).findByDisplayValue(CREDS.clientSecret);
259
+ expect(api.fetchGitHubFacade).toHaveBeenCalledTimes(1);
260
+ for (const value of [CREDS.host, CREDS.appId, CREDS.clientId, CREDS.webhookSecret]) {
261
+ expect(within(drawer()).getByDisplayValue(value)).toBeInTheDocument();
262
+ }
263
+ // Rotation is right there now: this IS the Deployment page.
264
+ expect(within(drawer()).getByRole('button', { name: 'Rotate credentials' })).toBeInTheDocument();
265
+
266
+ // Every other slide, including the connector at the end, is without them.
267
+ for (const step of ['Go to step 1: Add manually', 'Go to step 3: Connect', 'Go to step 4: Instance', 'Go to step 5: Connector']) {
268
+ await user.click(within(strip).getByRole('button', { name: step }));
269
+ expect(screen.queryByDisplayValue(CREDS.clientSecret)).toBeNull();
270
+ expect(within(drawer()).queryByRole('button', { name: 'Rotate credentials' })).toBeNull();
271
+ }
272
+
273
+ // Closing the drawer takes the secrets out of the DOM again.
274
+ await user.click(within(strip).getByRole('button', { name: 'Go to step 2: Configure' }));
275
+ await within(drawer()).findByDisplayValue(CREDS.clientSecret);
276
+ await user.click(screen.getByText('Register this deployment with Claude'));
277
+ expect(drawer().open).toBe(false);
278
+ expect(screen.queryByDisplayValue(CREDS.clientSecret)).toBeNull();
279
+ });
280
+
281
+ /**
282
+ * First run marks the section Optional and offers no way to decline it: an
283
+ * admin who does not want a marketplace walks past it, exactly as they walk
284
+ * past single sign-on by leaving it blank. Nothing waits on the section, so
285
+ * a skip control only added a decision nobody had to make.
286
+ */
287
+ it('is marked optional on first run, with no skip control, and fetches nothing secret unopened', async () => {
288
+ mount('setup');
289
+ const section = await screen.findByTestId('marketplace-deployment-section');
290
+ expect(within(section).getByText('Optional')).toBeInTheDocument();
291
+
292
+ expect(within(section).queryByRole('button', { name: 'Skip for now' })).toBeNull();
293
+ expect(section).not.toHaveTextContent('Marketplace skipped');
294
+ expect(within(section).queryByRole('button', { name: 'Set it up now' })).toBeNull();
295
+
296
+ // The section still renders its own content, and still holds back the
297
+ // credentials until the drawer is opened.
298
+ expect(
299
+ within(section).getByText('Register this deployment with your Claude organization'),
300
+ ).toBeInTheDocument();
301
+ expect(api.fetchGitHubFacade).not.toHaveBeenCalled();
302
+ expect(api.setMarketplaceRegistration).not.toHaveBeenCalled();
303
+ });
304
+
305
+ it('marks the deployment registered, and back', async () => {
306
+ const user = userEvent.setup();
307
+ mount('settings');
308
+ await user.click(await screen.findByRole('button', { name: 'Mark as registered' }));
309
+ await waitFor(() => expect(api.setMarketplaceRegistration).toHaveBeenCalledWith(true));
310
+ expect(await screen.findByText(/^Registered\./)).toBeInTheDocument();
311
+
312
+ await user.click(screen.getByRole('button', { name: 'Mark as not registered' }));
313
+ await waitFor(() => expect(api.setMarketplaceRegistration).toHaveBeenLastCalledWith(false));
314
+ expect(await screen.findByText(/Not registered yet/)).toBeInTheDocument();
315
+ });
316
+
317
+ it('says so when the registration cannot be saved', async () => {
318
+ api.setMarketplaceRegistration.mockRejectedValue(new Error('Admins only'));
319
+ const user = userEvent.setup();
320
+ mount('settings');
321
+ await user.click(await screen.findByRole('button', { name: 'Mark as registered' }));
322
+ expect(await screen.findByRole('alert')).toHaveTextContent('Admins only');
323
+ expect(screen.getByText(/Not registered yet/)).toBeInTheDocument();
324
+ });
325
+ });
@@ -111,6 +111,7 @@ describe('SettingsLayout', () => {
111
111
  const links = within(nav()).getAllByRole('link');
112
112
  expect(links.map((l) => l.textContent)).toEqual([
113
113
  'External agent access',
114
+ 'Audit log',
114
115
  'Secrets',
115
116
  'Browse available tools',
116
117
  'Account',
@@ -176,20 +177,20 @@ describe('SettingsLayout', () => {
176
177
  it('renders with no AdminContext at all, as a non-admin', () => {
177
178
  expect(() => renderAt('/secrets', { withAdminContext: false })).not.toThrow();
178
179
  expect(within(nav()).queryByText('Admin only')).toBeNull();
179
- expect(within(nav()).queryByRole('link', { name: 'Roles & Members' })).toBeNull();
180
+ expect(within(nav()).queryByRole('link', { name: 'App roles' })).toBeNull();
180
181
  });
181
182
 
182
183
  it('hides the admin section from a non-admin', () => {
183
184
  renderAt('/secrets', { isAdmin: false });
184
185
  expect(within(nav()).queryByText('Admin only')).toBeNull();
185
- expect(within(nav()).queryByRole('link', { name: 'Roles & Members' })).toBeNull();
186
+ expect(within(nav()).queryByRole('link', { name: 'App roles' })).toBeNull();
186
187
  expect(within(nav()).queryByRole('link', { name: 'User accounts' })).toBeNull();
187
188
  });
188
189
 
189
190
  it('shows the admin section to an admin', () => {
190
191
  renderAt('/secrets', { isAdmin: true });
191
192
  expect(within(nav()).getByText('Admin only')).toBeInTheDocument();
192
- expect(within(nav()).getByRole('link', { name: 'Roles & Members' })).toBeInTheDocument();
193
+ expect(within(nav()).getByRole('link', { name: 'App roles' })).toBeInTheDocument();
193
194
  expect(within(nav()).getByRole('link', { name: 'User accounts' })).toBeInTheDocument();
194
195
  });
195
196
 
@@ -205,12 +206,12 @@ describe('SettingsLayout', () => {
205
206
  it('grows the admin section when isAdmin flips true after mount', () => {
206
207
  const { rerender } = renderAt('/secrets', { isAdmin: false });
207
208
  const navBefore = nav();
208
- expect(within(navBefore).queryByRole('link', { name: 'Roles & Members' })).toBeNull();
209
+ expect(within(navBefore).queryByRole('link', { name: 'App roles' })).toBeNull();
209
210
 
210
211
  rerender(withAdmin(true, routerTree('/secrets')));
211
212
 
212
213
  expect(nav()).toBe(navBefore);
213
- expect(within(nav()).getByRole('link', { name: 'Roles & Members' })).toBeInTheDocument();
214
+ expect(within(nav()).getByRole('link', { name: 'App roles' })).toBeInTheDocument();
214
215
  });
215
216
 
216
217
  describe('narrow windows', () => {
@@ -242,7 +243,7 @@ describe('SettingsLayout', () => {
242
243
  renderAt('/secrets');
243
244
  expect(document.getElementById(SIDEBAR_DOM_ID)).toBeNull();
244
245
  expect(noNav()).not.toBeNull();
245
- expect(within(nav()).getAllByRole('link')).toHaveLength(4);
246
+ expect(within(nav()).getAllByRole('link')).toHaveLength(5);
246
247
  vi.unstubAllGlobals();
247
248
  });
248
249
  });