@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
@@ -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
+ });
@@ -176,20 +176,20 @@ describe('SettingsLayout', () => {
176
176
  it('renders with no AdminContext at all, as a non-admin', () => {
177
177
  expect(() => renderAt('/secrets', { withAdminContext: false })).not.toThrow();
178
178
  expect(within(nav()).queryByText('Admin only')).toBeNull();
179
- expect(within(nav()).queryByRole('link', { name: 'Roles & Members' })).toBeNull();
179
+ expect(within(nav()).queryByRole('link', { name: 'App roles' })).toBeNull();
180
180
  });
181
181
 
182
182
  it('hides the admin section from a non-admin', () => {
183
183
  renderAt('/secrets', { isAdmin: false });
184
184
  expect(within(nav()).queryByText('Admin only')).toBeNull();
185
- expect(within(nav()).queryByRole('link', { name: 'Roles & Members' })).toBeNull();
185
+ expect(within(nav()).queryByRole('link', { name: 'App roles' })).toBeNull();
186
186
  expect(within(nav()).queryByRole('link', { name: 'User accounts' })).toBeNull();
187
187
  });
188
188
 
189
189
  it('shows the admin section to an admin', () => {
190
190
  renderAt('/secrets', { isAdmin: true });
191
191
  expect(within(nav()).getByText('Admin only')).toBeInTheDocument();
192
- expect(within(nav()).getByRole('link', { name: 'Roles & Members' })).toBeInTheDocument();
192
+ expect(within(nav()).getByRole('link', { name: 'App roles' })).toBeInTheDocument();
193
193
  expect(within(nav()).getByRole('link', { name: 'User accounts' })).toBeInTheDocument();
194
194
  });
195
195
 
@@ -205,12 +205,12 @@ describe('SettingsLayout', () => {
205
205
  it('grows the admin section when isAdmin flips true after mount', () => {
206
206
  const { rerender } = renderAt('/secrets', { isAdmin: false });
207
207
  const navBefore = nav();
208
- expect(within(navBefore).queryByRole('link', { name: 'Roles & Members' })).toBeNull();
208
+ expect(within(navBefore).queryByRole('link', { name: 'App roles' })).toBeNull();
209
209
 
210
210
  rerender(withAdmin(true, routerTree('/secrets')));
211
211
 
212
212
  expect(nav()).toBe(navBefore);
213
- expect(within(nav()).getByRole('link', { name: 'Roles & Members' })).toBeInTheDocument();
213
+ expect(within(nav()).getByRole('link', { name: 'App roles' })).toBeInTheDocument();
214
214
  });
215
215
 
216
216
  describe('narrow windows', () => {
@@ -0,0 +1,66 @@
1
+ import { authFetch } from '../../../lib/api';
2
+
3
+ /**
4
+ * What an Owner pastes into Claude's admin settings to register this
5
+ * deployment as a GitHub Enterprise Server — the credentials hexis generated
6
+ * for that purpose. Admins only; every field is shown so it can be copied.
7
+ */
8
+ export interface GitHubFacadeCredentials {
9
+ /** The hostname to register. */
10
+ host: string;
11
+ appId: string;
12
+ clientId: string;
13
+ clientSecret: string;
14
+ webhookSecret: string;
15
+ privateKeyPem: string;
16
+ /** The marketplace URL people paste in Cowork and claude.ai — the same one Claude Code clones. */
17
+ marketplaceUrl: string;
18
+ createdAt: number;
19
+ rotatedAt: number | null;
20
+ }
21
+
22
+ async function unwrap(res: Response, fallback: string): Promise<never> {
23
+ let serverError: string | undefined;
24
+ try {
25
+ const body = (await res.json()) as { error?: string };
26
+ if (typeof body.error === 'string' && body.error.length > 0) serverError = body.error;
27
+ } catch {
28
+ // Non-JSON error body — fall through.
29
+ }
30
+ throw new Error(serverError ?? fallback);
31
+ }
32
+
33
+ export async function fetchGitHubFacade(): Promise<GitHubFacadeCredentials> {
34
+ const res = await authFetch('/api/admin/github-facade');
35
+ if (!res.ok) await unwrap(res, "Couldn't load the Claude connection.");
36
+ return res.json() as Promise<GitHubFacadeCredentials>;
37
+ }
38
+
39
+ /**
40
+ * Whether an admin has marked this deployment registered with their Claude
41
+ * organization. Any signed-in person may ask — the answer is a boolean and
42
+ * nothing else — so the External agent access page can show the tutorial or
43
+ * the "an admin has to set this up" notice.
44
+ */
45
+ export async function fetchMarketplaceRegistration(): Promise<boolean> {
46
+ const res = await authFetch('/api/github-facade/registration');
47
+ if (!res.ok) await unwrap(res, "Couldn't check whether the marketplace is set up.");
48
+ return ((await res.json()) as { registered: boolean }).registered === true;
49
+ }
50
+
51
+ /** Admins only: say the deployment is (or is no longer) registered with Claude. */
52
+ export async function setMarketplaceRegistration(registered: boolean): Promise<boolean> {
53
+ const res = await authFetch('/api/admin/github-facade/registration', {
54
+ method: 'PUT',
55
+ headers: { 'Content-Type': 'application/json' },
56
+ body: JSON.stringify({ registered }),
57
+ });
58
+ if (!res.ok) await unwrap(res, "Couldn't save the marketplace registration.");
59
+ return ((await res.json()) as { registered: boolean }).registered === true;
60
+ }
61
+
62
+ export async function rotateGitHubFacade(): Promise<GitHubFacadeCredentials> {
63
+ const res = await authFetch('/api/admin/github-facade/rotate', { method: 'POST' });
64
+ if (!res.ok) await unwrap(res, "Couldn't rotate the Claude connection.");
65
+ return res.json() as Promise<GitHubFacadeCredentials>;
66
+ }
@@ -76,7 +76,7 @@ export const CORE_MENU_ITEMS: AdminMenuItem[] = [
76
76
  section: 'admin',
77
77
  order: 10,
78
78
  icon: <Users size={15} />,
79
- label: 'Roles & Members',
79
+ label: 'App roles',
80
80
  path: '/roles-and-members',
81
81
  },
82
82
  {
@@ -84,7 +84,7 @@ export const CORE_MENU_ITEMS: AdminMenuItem[] = [
84
84
  section: 'admin',
85
85
  order: 15,
86
86
  icon: <UsersRound size={15} />,
87
- label: 'Groups',
87
+ label: 'Groups & Members',
88
88
  path: '/directory-groups',
89
89
  },
90
90
  {
@@ -95,6 +95,14 @@ export const CORE_MENU_ITEMS: AdminMenuItem[] = [
95
95
  label: 'User accounts',
96
96
  path: '/user-accounts',
97
97
  },
98
+ {
99
+ id: 'connection-keys',
100
+ section: 'admin',
101
+ order: 25,
102
+ icon: <KeyRound size={15} />,
103
+ label: 'Connection keys',
104
+ path: '/connection-keys',
105
+ },
98
106
  ];
99
107
 
100
108
  /**
@@ -0,0 +1,172 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+
5
+ const api = vi.hoisted(() => ({
6
+ fetchSetupStatus: vi.fn(),
7
+ saveSettings: vi.fn(),
8
+ testConnection: vi.fn(),
9
+ testOidc: vi.fn(),
10
+ syncNow: vi.fn(),
11
+ }));
12
+ vi.mock('../services/setup.api', async () => {
13
+ const actual = await vi.importActual<typeof import('../services/setup.api')>('../services/setup.api');
14
+ return { ...actual, ...api };
15
+ });
16
+ vi.mock('../../settings/services/github-facade.api', () => ({
17
+ fetchGitHubFacade: vi.fn(),
18
+ rotateGitHubFacade: vi.fn(),
19
+ fetchMarketplaceRegistration: vi.fn(async () => false),
20
+ setMarketplaceRegistration: vi.fn(),
21
+ }));
22
+
23
+ import { SetupGate } from '../components/SetupGate';
24
+ import { SetupScreen } from '../components/SetupScreen';
25
+ import { SettingsProblems, type SettingStatus } from '../services/setup.api';
26
+
27
+ const SIGN_IN = 'sign-in' as const;
28
+ const setting = (key: string, envVar: string, extra: Partial<SettingStatus> = {}): SettingStatus => ({
29
+ key,
30
+ envVar,
31
+ section: SIGN_IN,
32
+ source: 'unset',
33
+ value: '',
34
+ configured: false,
35
+ secret: false,
36
+ restartToApply: true,
37
+ ...extra,
38
+ });
39
+ const SETTINGS: SettingStatus[] = [
40
+ setting('oidcIssuerUrl', 'OIDC_ISSUER_URL'),
41
+ setting('oidcClientId', 'OIDC_CLIENT_ID'),
42
+ setting('oidcClientSecret', 'OIDC_CLIENT_SECRET', { secret: true, value: undefined }),
43
+ setting('oidcScopes', 'OIDC_SCOPES'),
44
+ setting('allowedEmailDomains', 'ALLOWED_EMAIL_DOMAINS'),
45
+ ];
46
+
47
+ beforeEach(() => {
48
+ for (const fn of Object.values(api)) fn.mockReset();
49
+ });
50
+
51
+ const field = (label: string) => screen.getByLabelText(label, { exact: false });
52
+
53
+ describe('SetupScreen — single sign-on check', () => {
54
+ it('tests the typed provider values, and only those', async () => {
55
+ api.testOidc.mockResolvedValue({ ok: true, outcome: 'verified', oidcVerification: 'unverified' });
56
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="not-configured" />);
57
+ await userEvent.type(field('Provider address'), 'https://login.example.com');
58
+ await userEvent.type(field('Application ID'), 'app');
59
+ await userEvent.type(field('Application secret'), 'shh');
60
+ await userEvent.type(field('Allowed email domains'), 'example.com');
61
+ await userEvent.click(screen.getByRole('button', { name: 'Test sign-in configuration' }));
62
+ expect(await screen.findByText(/Verified\. The provider accepted/)).toBeInTheDocument();
63
+ expect(api.testOidc).toHaveBeenCalledWith({
64
+ oidcIssuerUrl: 'https://login.example.com',
65
+ oidcClientId: 'app',
66
+ oidcClientSecret: 'shh',
67
+ });
68
+ });
69
+
70
+ it.each([
71
+ [{ ok: false, outcome: 'rejected', field: 'oidcIssuerUrl', error: 'That address is not a single sign-on provider.' }, 'That address is not a single sign-on provider.'],
72
+ [{ ok: false, outcome: 'rejected', field: 'oidcClientSecret', error: 'The provider rejected the application ID or secret.' }, 'The provider rejected the application ID or secret.'],
73
+ [{ ok: false, outcome: 'unverified', error: 'could not be verified (server_error)' }, 'could not be verified (server_error)'],
74
+ [{ ok: true, outcome: 'issuer-verified' }, /is a sign-in provider/],
75
+ ])('reports %j', async (result, text) => {
76
+ api.testOidc.mockResolvedValue(result);
77
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" />);
78
+ await userEvent.click(screen.getByRole('button', { name: 'Test sign-in configuration' }));
79
+ expect(await screen.findByText(text)).toBeInTheDocument();
80
+ });
81
+
82
+ it('clears the result when a provider field is edited, but not for the domains', async () => {
83
+ api.testOidc.mockResolvedValue({ ok: true, outcome: 'verified' });
84
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" />);
85
+ await userEvent.click(screen.getByRole('button', { name: 'Test sign-in configuration' }));
86
+ await screen.findByText(/Verified\. The provider accepted/);
87
+ await userEvent.type(field('Allowed email domains'), 'x');
88
+ expect(screen.getByText(/Verified\. The provider accepted/)).toBeInTheDocument();
89
+ await userEvent.type(field('Application ID'), 'x');
90
+ expect(screen.queryByText(/Verified\. The provider accepted/)).not.toBeInTheDocument();
91
+ });
92
+
93
+ it('shows a save refused by the provider against the secret field', async () => {
94
+ api.saveSettings.mockRejectedValue(
95
+ new SettingsProblems({ oidcClientSecret: 'The provider rejected the application ID or secret.' }),
96
+ );
97
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" />);
98
+ await userEvent.type(field('Application secret'), 'wrong');
99
+ await userEvent.click(screen.getByRole('button', { name: /Save/ }));
100
+ const problem = await screen.findByText('The provider rejected the application ID or secret.');
101
+ expect(problem).toHaveAttribute('id', 'oidcClientSecret-problem');
102
+ });
103
+
104
+ it('labels the configuration with what the save answered', async () => {
105
+ api.saveSettings.mockResolvedValue({
106
+ restartRequired: true,
107
+ complete: true,
108
+ settings: SETTINGS,
109
+ oidcVerification: 'verified',
110
+ });
111
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="unverified" />);
112
+ expect(screen.getByTestId('oidc-verification')).toHaveTextContent('Unverified — sign in once to confirm');
113
+ await userEvent.type(field('Application secret'), 'new');
114
+ await userEvent.click(screen.getByRole('button', { name: /Save/ }));
115
+ await waitFor(() => expect(screen.getByTestId('oidc-verification')).toHaveTextContent('Verified'));
116
+ });
117
+
118
+ it('a host refresh supersedes a test answer for good, even one back to the value it replaced', async () => {
119
+ api.testOidc.mockResolvedValue({ ok: true, outcome: 'verified', oidcVerification: 'verified' });
120
+ const view = render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="unverified" />);
121
+ await userEvent.click(screen.getByRole('button', { name: 'Test sign-in configuration' }));
122
+ await waitFor(() => expect(screen.getByTestId('oidc-verification')).toHaveTextContent(/^Verified$/));
123
+ view.rerender(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="verified" />);
124
+ // A new secret saved since reads as unverified again: the old answer must not come back.
125
+ view.rerender(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="unverified" />);
126
+ expect(screen.getByTestId('oidc-verification')).toHaveTextContent('Unverified — sign in once to confirm');
127
+ });
128
+
129
+ it('editing a provider field drops a test answer about the old values', async () => {
130
+ api.testOidc.mockResolvedValue({ ok: true, outcome: 'verified', oidcVerification: 'verified' });
131
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="unverified" />);
132
+ await userEvent.click(screen.getByRole('button', { name: 'Test sign-in configuration' }));
133
+ await waitFor(() => expect(screen.getByTestId('oidc-verification')).toHaveTextContent(/^Verified$/));
134
+ await userEvent.type(field('Application secret'), 'x');
135
+ expect(screen.getByTestId('oidc-verification')).toHaveTextContent('Unverified — sign in once to confirm');
136
+ });
137
+
138
+ it('cannot save while a sign-in check is running', async () => {
139
+ let answer: (value: unknown) => void = () => {};
140
+ api.testOidc.mockReturnValue(new Promise((resolve) => (answer = resolve)));
141
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="unverified" />);
142
+ await userEvent.type(field('Application secret'), 'new');
143
+ await userEvent.click(screen.getByRole('button', { name: 'Test sign-in configuration' }));
144
+ expect(screen.getByRole('button', { name: /Save/ })).toBeDisabled();
145
+ answer({ ok: true, outcome: 'verified', oidcVerification: 'unverified' });
146
+ await waitFor(() => expect(screen.getByRole('button', { name: /Save/ })).toBeEnabled());
147
+ expect(api.saveSettings).not.toHaveBeenCalled();
148
+ });
149
+
150
+ it('still shows the state and the test when every provider setting comes from the environment', () => {
151
+ const fromEnv = SETTINGS.map((s) => ({ ...s, source: 'env' as const, configured: true }));
152
+ render(<SetupScreen settings={fromEnv} onSaved={() => {}} variant="settings" oidcVerification="verified" />);
153
+ expect(screen.getByTestId('oidc-verification')).toHaveTextContent('Verified');
154
+ expect(screen.getByRole('button', { name: 'Test sign-in configuration' })).toBeInTheDocument();
155
+ });
156
+
157
+ it('says when verification cannot be kept because SECRETS_ENC_KEY is unset', () => {
158
+ render(<SetupScreen settings={SETTINGS} onSaved={() => {}} variant="settings" oidcVerification="unrecordable" />);
159
+ expect(screen.getByTestId('oidc-verification')).toHaveTextContent('Not recorded — set SECRETS_ENC_KEY to keep verification');
160
+ });
161
+
162
+ it('the setup screen shows the state from the status', async () => {
163
+ api.fetchSetupStatus.mockResolvedValue({
164
+ complete: false,
165
+ isAdmin: true,
166
+ settings: SETTINGS,
167
+ oidcVerification: 'not-configured',
168
+ });
169
+ render(<SetupGate>app</SetupGate>);
170
+ expect(await screen.findByTestId('oidc-verification')).toHaveTextContent('Not configured');
171
+ });
172
+ });