@bevel-software/platform-core-frontend 0.14.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +34 -26
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/bootstrap.test.ts +33 -1
  6. package/src/core/__tests__/events.test.ts +43 -0
  7. package/src/core/bootstrap.ts +38 -1
  8. package/src/core/events.ts +85 -3
  9. package/src/core/registry.ts +1 -1
  10. package/src/lib/__tests__/api.test.ts +38 -0
  11. package/src/lib/__tests__/email.test.ts +44 -0
  12. package/src/lib/api.ts +19 -2
  13. package/src/lib/email.ts +37 -1
  14. package/src/lib/utils.ts +2 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  16. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  20. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  21. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  22. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  23. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  24. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
  25. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  26. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  27. package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
  28. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  29. package/src/modules/access/api.ts +192 -10
  30. package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
  31. package/src/modules/access/manage-access-affordance.ts +17 -0
  32. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  33. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  34. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  35. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  36. package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
  37. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  38. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  39. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  40. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  41. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  42. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  43. package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
  44. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  45. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  46. package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
  47. package/src/modules/admin/components/group-members-path.ts +32 -0
  48. package/src/modules/admin/services/connection-keys.api.ts +47 -0
  49. package/src/modules/admin/services/roles.api.ts +12 -1
  50. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  51. package/src/modules/auth/components/AccountPage.tsx +73 -54
  52. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  53. package/src/modules/auth/services/account.api.ts +78 -4
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  58. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  59. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  60. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  61. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  62. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  63. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  64. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  65. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  66. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  67. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  68. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  69. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  70. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  71. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  72. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  73. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  74. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  75. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  76. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  77. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  78. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  79. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  80. package/src/modules/change-requests/services/propose.api.ts +97 -8
  81. package/src/modules/change-requests/utils/approval.ts +15 -0
  82. package/src/modules/change-requests/utils/author.ts +32 -0
  83. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  84. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  85. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
  86. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  87. package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
  88. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  89. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  90. package/src/modules/git/services/error-messages.ts +12 -0
  91. package/src/modules/git/services/pr-prompts.ts +5 -5
  92. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  93. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  94. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  95. package/src/modules/layout/components/AppLayout.tsx +2 -0
  96. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  97. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  98. package/src/modules/layout/components/SidebarFrame.tsx +109 -4
  99. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  100. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  101. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  102. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  103. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  104. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
  105. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
  106. package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
  107. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
  108. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  109. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  110. package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
  111. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  112. package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
  113. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
  114. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
  115. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  116. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  117. package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
  118. package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
  119. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  120. package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
  121. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
  122. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  123. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  124. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  125. package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
  126. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  127. package/src/modules/library/__tests__/library-paths.test.ts +75 -0
  128. package/src/modules/library/__tests__/link-membership.test.ts +129 -0
  129. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  130. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  131. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  132. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  133. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  134. package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
  135. package/src/modules/library/__tests__/status.test.ts +82 -2
  136. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  137. package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
  138. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  139. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  140. package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
  141. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  142. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  143. package/src/modules/library/components/LibraryCard.tsx +149 -34
  144. package/src/modules/library/components/LibraryLayout.tsx +120 -247
  145. package/src/modules/library/components/LibraryPage.tsx +172 -39
  146. package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
  147. package/src/modules/library/components/LockedPluginView.tsx +63 -35
  148. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  149. package/src/modules/library/components/NewPluginDialog.tsx +19 -5
  150. package/src/modules/library/components/PageActions.tsx +31 -9
  151. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  152. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  153. package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
  154. package/src/modules/library/components/PluginExtras.tsx +143 -18
  155. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  156. package/src/modules/library/components/PluginPage.tsx +234 -38
  157. package/src/modules/library/components/PluginRows.tsx +286 -0
  158. package/src/modules/library/components/PluginsSidebar.tsx +271 -238
  159. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  160. package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
  161. package/src/modules/library/components/ShareButton.tsx +17 -0
  162. package/src/modules/library/components/SkillsTree.tsx +204 -0
  163. package/src/modules/library/components/StatusDot.tsx +1 -0
  164. package/src/modules/library/components/TeamRoute.tsx +15 -0
  165. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  166. package/src/modules/library/components/plugin-page-parts.tsx +132 -23
  167. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
  168. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  169. package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
  170. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  171. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  172. package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
  173. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  174. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  175. package/src/modules/library/hooks/useJoinRequests.ts +48 -18
  176. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  177. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  178. package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
  179. package/src/modules/library/routes/library-paths.ts +46 -35
  180. package/src/modules/library/services/library.api.ts +89 -17
  181. package/src/modules/library/services/plugins.api.ts +161 -9
  182. package/src/modules/library/services/teams.api.ts +15 -0
  183. package/src/modules/library/services/tools.api.ts +78 -0
  184. package/src/modules/library/state/library-data.tsx +268 -37
  185. package/src/modules/library/utils/personal-plugin.ts +13 -15
  186. package/src/modules/library/utils/plugin-entries.ts +134 -0
  187. package/src/modules/library/utils/plugin-summary.ts +102 -0
  188. package/src/modules/library/utils/status.ts +204 -35
  189. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
  190. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  191. package/src/modules/onboarding/agent-clients.ts +55 -23
  192. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  193. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  194. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  195. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  196. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  197. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  198. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  199. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  200. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  201. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  202. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  203. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  204. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  205. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  206. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  207. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  208. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  209. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  210. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  211. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  212. package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
  213. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  214. package/src/modules/settings/components/DeploymentPage.tsx +16 -22
  215. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  216. package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
  217. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
  218. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  219. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
  220. package/src/modules/settings/services/github-facade.api.ts +66 -0
  221. package/src/modules/settings/settings-nav-items.tsx +10 -2
  222. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  223. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  224. package/src/modules/setup/__tests__/setup.test.tsx +615 -4
  225. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  226. package/src/modules/setup/components/SetupGate.tsx +16 -16
  227. package/src/modules/setup/components/SetupScreen.tsx +711 -40
  228. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  229. package/src/modules/setup/services/setup.api.ts +218 -3
  230. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  231. package/src/modules/setup/utils/root-folders.ts +46 -0
  232. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  233. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  234. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  235. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  236. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  237. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  238. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  239. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  240. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  241. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  242. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  243. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  244. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  245. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  246. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  247. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  248. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
  249. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  250. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  251. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  252. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
  253. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  254. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  255. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  256. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  257. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  258. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  259. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  260. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  261. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  262. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  263. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  264. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  265. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  266. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  267. package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
  268. package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
  269. package/src/modules/workspace/components/FileRoute.tsx +376 -22
  270. package/src/modules/workspace/components/FileViewer.tsx +166 -45
  271. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  272. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  273. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  274. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
  275. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
  276. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
  277. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  278. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  279. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  280. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  281. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  282. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  283. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  284. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  285. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  286. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  287. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  288. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  289. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  290. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  291. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  292. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  293. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  294. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  295. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  296. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  297. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  298. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  299. package/src/modules/workspace/components/renderers/index.ts +53 -2
  300. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  301. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  302. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  303. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  304. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  305. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  306. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  307. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
  308. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  309. package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
  310. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  311. package/src/modules/workspace/routing/kb-routes.ts +207 -30
  312. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
  313. package/src/modules/workspace/services/workspace.api.ts +57 -4
  314. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  315. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  316. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  317. package/src/modules/workspace/state/workspace.context.ts +130 -16
  318. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  319. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
  320. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  321. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  322. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  323. package/src/modules/workspace/utils/file-trace.ts +50 -0
  324. package/src/modules/workspace/utils/fileTree.ts +126 -52
  325. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  326. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  327. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  328. package/src/modules/workspace/utils/uploadError.ts +29 -0
  329. package/src/shared/__tests__/marketplace-url.test.ts +59 -0
  330. package/src/shared/components/Badge.tsx +3 -1
  331. package/src/shared/components/Banner.tsx +5 -1
  332. package/src/shared/components/Button.tsx +16 -2
  333. package/src/shared/components/Dialog.tsx +27 -11
  334. package/src/shared/components/Menu.tsx +13 -1
  335. package/src/shared/components/PageShell.tsx +13 -8
  336. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  337. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  338. package/src/shared/components/index.ts +2 -0
  339. package/src/shared/components/useDismissableMenu.ts +32 -10
  340. package/src/shared/components/useFocusHandoff.ts +51 -0
  341. package/src/shared/components/useLatestRef.ts +28 -0
  342. package/src/shared/markdown/Markdown.tsx +12 -3
  343. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  344. package/src/shared/markdown/hrefs.ts +50 -0
  345. package/src/shared/marketplace-url.ts +118 -0
  346. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  347. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  348. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  349. package/src/shared/mcp/connect-snippets.ts +14 -9
  350. package/src/shared/mcp/index.ts +1 -1
  351. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  352. package/src/shared/theme/header.ts +75 -0
  353. package/src/shared/theme/measure.ts +7 -4
  354. package/src/shared/theme/tokens.css +34 -0
  355. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  356. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  357. package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
  358. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  359. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  360. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -1,9 +1,10 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { render, screen } from '@testing-library/react';
2
+ import { fireEvent, render, screen, within } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
- import { MemoryRouter } from 'react-router-dom';
4
+ import { MemoryRouter, Route, Routes } from 'react-router-dom';
5
5
  import { ExternalAgentAccessPage } from '../ExternalAgentAccessPage';
6
6
  import { configureMcpUrl } from '../../../../shared/mcp';
7
+ import { GITHUB_LINK_KIND, configureMarketplaceGitUrl } from '../../../../shared/marketplace-url';
7
8
 
8
9
  /**
9
10
  * The Connect page's contract, and the reason this file exists at all: every
@@ -21,9 +22,31 @@ import { configureMcpUrl } from '../../../../shared/mcp';
21
22
  * regression cases below name all six.
22
23
  */
23
24
 
24
- const { listMock, createMock } = vi.hoisted(() => ({
25
+ const { listMock, createMock, instructionsMock, facadeMock, registrationMock, adminState } = vi.hoisted(() => ({
25
26
  listMock: vi.fn(),
26
27
  createMock: vi.fn(),
28
+ instructionsMock: vi.fn(),
29
+ facadeMock: vi.fn(),
30
+ registrationMock: vi.fn(),
31
+ // Mutable so one file can mount the page as both roles: the tutorial must
32
+ // be identical for both, and only the "not set up" notice may differ.
33
+ adminState: { isAdmin: false },
34
+ }));
35
+
36
+ // Only the hook is replaced. `AdminContext` itself stays real, because the
37
+ // instructions card below reads the context directly rather than through the
38
+ // hook; a whole-module mock left it undefined and every case here threw.
39
+ vi.mock('../../../admin/state/admin.context', async (importOriginal) => ({
40
+ ...(await importOriginal<typeof import('../../../admin/state/admin.context')>()),
41
+ useAdmin: () => ({ isAdmin: adminState.isAdmin }),
42
+ }));
43
+
44
+ // The registration state the Cowork drawer reads, and the admin credentials
45
+ // endpoint this page must never call. Mocked, or the component reaches for
46
+ // the real endpoints over the network.
47
+ vi.mock('../../../settings/services/github-facade.api', () => ({
48
+ fetchGitHubFacade: facadeMock,
49
+ fetchMarketplaceRegistration: registrationMock,
27
50
  }));
28
51
 
29
52
  vi.mock('../../services/external-api-keys.api', () => ({
@@ -33,6 +56,14 @@ vi.mock('../../services/external-api-keys.api', () => ({
33
56
  deleteExternalApiKey: vi.fn(async () => {}),
34
57
  }));
35
58
 
59
+ // The "What connected agents are told" card fetches on mount; its own cases
60
+ // live in AgentInstructionsCard.test.tsx. Here it only has to stay out of the
61
+ // way of the snippet assertions, which read every textbox on the page.
62
+ vi.mock('../../services/agent-instructions.api', async (importOriginal) => ({
63
+ ...(await importOriginal<typeof import('../../services/agent-instructions.api')>()),
64
+ fetchAgentInstructions: instructionsMock,
65
+ }));
66
+
36
67
  /** A deployment configured the way a real one is: public, https, its own domain. */
37
68
  const PUBLIC_URL = 'https://kb.acme.com/api/mcp';
38
69
  /** What an unconfigured deployment actually runs with — see `.env.example`. */
@@ -40,8 +71,38 @@ const LOCALHOST_URL = 'http://localhost:3001/api/mcp';
40
71
 
41
72
  const KEY = 'bvl_live_s3cret';
42
73
 
74
+ const FACADE = {
75
+ host: 'kb.acme.com',
76
+ appId: '12345',
77
+ clientId: 'Iv1.abcdef',
78
+ clientSecret: 'ghs_secret',
79
+ webhookSecret: 'whsec_0123456789012345678',
80
+ privateKeyPem: '-----BEGIN RSA PRIVATE KEY-----\nx\n-----END RSA PRIVATE KEY-----',
81
+ marketplaceUrl: 'https://kb.acme.com/git/marketplace.git',
82
+ createdAt: Date.now(),
83
+ rotatedAt: null,
84
+ };
85
+
43
86
  beforeEach(() => {
87
+ adminState.isAdmin = false;
88
+ // Cleared, not just re-stubbed: the count is an assertion of its own below.
89
+ facadeMock.mockClear();
90
+ facadeMock.mockResolvedValue(FACADE);
91
+ registrationMock.mockReset();
92
+ registrationMock.mockResolvedValue(true);
44
93
  listMock.mockResolvedValue([]);
94
+ instructionsMock.mockResolvedValue({
95
+ instructions: 'Search the knowledge base first.',
96
+ header: 'Search the knowledge base first.',
97
+ preamble: '',
98
+ toolPrefix: 'Search it before answering from memory.',
99
+ toolPrefixLine: 'Search it before answering from memory.',
100
+ truncated: false,
101
+ preambleChars: 0,
102
+ toolPrefixTruncated: false,
103
+ toolPrefixChars: 40,
104
+ unterminatedComment: false,
105
+ });
45
106
  createMock.mockResolvedValue({
46
107
  plaintext: KEY,
47
108
  summary: {
@@ -50,12 +111,15 @@ beforeEach(() => {
50
111
  createdAt: Date.now(),
51
112
  lastUsedAt: null,
52
113
  revokedAt: null,
114
+ revokedBy: null,
53
115
  },
54
116
  });
55
117
  });
56
118
 
57
119
  function mount(mcpUrl: string) {
58
120
  configureMcpUrl(mcpUrl);
121
+ // The marketplace remote is served from the same deployment address.
122
+ configureMarketplaceGitUrl(`${new URL(mcpUrl).origin}/git/marketplace.git`);
59
123
  return render(
60
124
  <MemoryRouter>
61
125
  <ExternalAgentAccessPage />
@@ -63,6 +127,13 @@ function mount(mcpUrl: string) {
63
127
  );
64
128
  }
65
129
 
130
+ /** Opens the Cowork drawer on the Marketplaces tab — the opening is what reads the registration state. */
131
+ async function openCowork(user: ReturnType<typeof userEvent.setup>) {
132
+ const cowork = screen.getByText('Cowork and claude.ai').closest('details') as HTMLDetailsElement;
133
+ await user.click(within(cowork).getByText('Cowork and claude.ai'));
134
+ return cowork;
135
+ }
136
+
66
137
  /** Every read-only snippet on screen, as plain strings. */
67
138
  function snippets(): string[] {
68
139
  return screen
@@ -78,7 +149,7 @@ async function revealAKey(user: ReturnType<typeof userEvent.setup>) {
78
149
  await screen.findByRole('heading', { name: /Save this external API key now/ });
79
150
  }
80
151
 
81
- describe('the interactive tab: local first, hosted second, each with its own address', () => {
152
+ describe('the interactive tab: Claude and ChatGPT first, each family on its own address', () => {
82
153
  it('builds all three hosted keyless snippets from the configured URL', () => {
83
154
  mount(PUBLIC_URL);
84
155
  const values = snippets();
@@ -96,26 +167,52 @@ describe('the interactive tab: local first, hosted second, each with its own add
96
167
  });
97
168
 
98
169
  /**
99
- * The RECOMMENDED path leads: the local-server drawer renders above the
100
- * hosted one, and its two snippets are KEYLESS — interactive mode signs in
101
- * through the browser on first run, so no key belongs in the config. Both
102
- * quote the workspace ORIGIN, because hexis-mcp resolves the endpoint from
103
- * `GET <base>/api/config` itself.
170
+ * Claude and ChatGPT lead, OPEN: the page arrives on the one-click button
171
+ * and the address to paste. Desktop agents and every other agent follow,
172
+ * closed — and no drawer title calls itself recommended any more.
104
173
  */
105
- it('leads with the local server: keyless snippets built from the origin', () => {
174
+ it('leads with an open Claude and ChatGPT drawer, then Desktop agents, then any other agent', () => {
106
175
  mount(PUBLIC_URL);
107
- // Two CLOSED drawers, desktop first. The summaries are the whole pitch;
108
- // the configs sit inside and neither drawer arrives open.
109
- const local = screen.getByText(
176
+ const summaries = [
177
+ 'Claude and ChatGPT',
110
178
  'Desktop agents: Claude Code, Claude Desktop, Cursor, Windsurf, Cline and similar',
179
+ 'Any other agent',
180
+ ].map((text) => screen.getByText(text));
181
+ for (const summary of summaries) expect(summary.tagName).toBe('SUMMARY');
182
+ // The page's own drawers, in order — the Marketplaces and Autonomous tabs are not mounted.
183
+ const drawers = Array.from(
184
+ screen.getByTestId('agent-connection-section').querySelectorAll('details > summary'),
111
185
  );
112
- const hosted = screen.getByText('Any other agent');
113
- // DOCUMENT_POSITION_FOLLOWING: the hosted drawer comes after the local one.
114
- expect(local.compareDocumentPosition(hosted) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
115
- for (const drawer of [local, hosted]) {
116
- expect((drawer.closest('details') as HTMLDetailsElement).open).toBe(false);
117
- }
186
+ expect(drawers).toEqual(summaries);
187
+ expect(drawers.some((d) => /recommended/i.test(d.textContent ?? ''))).toBe(false);
188
+ expect(summaries.map((s) => (s.closest('details') as HTMLDetailsElement).open)).toEqual([
189
+ true,
190
+ false,
191
+ false,
192
+ ]);
193
+
194
+ // Everything the first drawer promises lives inside it.
195
+ const first = summaries[0]!.closest('details') as HTMLElement;
196
+ expect(within(first).getByRole('link', { name: 'Add to Claude' })).toBeInTheDocument();
197
+ expect(within(first).getByRole('link', { name: 'Add to ChatGPT' })).toBeInTheDocument();
198
+ expect(within(first).getByRole('link', { name: /Configure your tools/ })).toBeInTheDocument();
199
+ expect(
200
+ within(first).getAllByRole('textbox').map((el) => (el as HTMLTextAreaElement).value),
201
+ ).toContain(PUBLIC_URL);
118
202
 
203
+ // Desktop agents keeps the sentence about local-only tools.
204
+ const desktop = summaries[1]!.closest('details') as HTMLElement;
205
+ expect(within(desktop).getByText(/local-only tools/)).toBeInTheDocument();
206
+ });
207
+
208
+ /**
209
+ * The local-server snippets are KEYLESS — interactive mode signs in through
210
+ * the browser on first run, so no key belongs in the config. Both quote the
211
+ * workspace ORIGIN, because hexis-mcp resolves the endpoint from
212
+ * `GET <base>/api/config` itself.
213
+ */
214
+ it('gives Desktop agents keyless snippets built from the origin', () => {
215
+ mount(PUBLIC_URL);
119
216
  const values = snippets();
120
217
  expect(values).toContain(
121
218
  `claude mcp add skills-tools-knowledge --env HEXIS_URL="${window.location.origin}" -- npx -y @bevel-software/hexis-mcp`,
@@ -128,6 +225,27 @@ describe('the interactive tab: local first, hosted second, each with its own add
128
225
  expect(parsed.env.HEXIS_CONNECTION_KEY).toBeUndefined();
129
226
  });
130
227
 
228
+ /**
229
+ * The two things that stop this configuration working on a machine where it
230
+ * is otherwise correct: the wrong Node major, and a client that cannot see
231
+ * `npx` because it was launched from the Dock rather than from a shell. The
232
+ * SNIPPET must not try to fix the second one — an absolute path is specific
233
+ * to one machine, and baking one in would break every reader whose PATH was
234
+ * fine — so the prose beside it is the only place this can be said.
235
+ */
236
+ it('warns Desktop agents about Node and PATH without touching the snippet', () => {
237
+ mount(PUBLIC_URL);
238
+ const desktop = screen
239
+ .getByText('Desktop agents: Claude Code, Claude Desktop, Cursor, Windsurf, Cline and similar')
240
+ .closest('details') as HTMLElement;
241
+ expect(within(desktop).getByText(/Needs Node 22\.13\+ or 24/)).toBeInTheDocument();
242
+ expect(within(desktop).getByText(/cannot see your shell's PATH/)).toBeInTheDocument();
243
+ expect(within(desktop).getByText('which npx')).toBeInTheDocument();
244
+ // The snippet still spawns the bare `npx`, for every client that can find it.
245
+ const json = snippets().find((v) => v.includes('mcpServers') && v.includes('"command"'));
246
+ expect(JSON.parse(json!).mcpServers['skills-tools-knowledge'].command).toBe('npx');
247
+ });
248
+
131
249
  /**
132
250
  * The regression stated as a negative, per family: a hosted snippet
133
251
  * quoting the origin means one of the six sites quietly went back to
@@ -137,7 +255,12 @@ describe('the interactive tab: local first, hosted second, each with its own add
137
255
  it('keeps each family on its own address', () => {
138
256
  mount(PUBLIC_URL);
139
257
  for (const value of snippets()) {
140
- if (value.includes('hexis')) {
258
+ if (value.includes('marketplace.git')) {
259
+ // The marketplace remote is the deployment's own address (with the
260
+ // key in the userinfo, so the HOST is what survives), never the browser's.
261
+ expect(value).toContain(new URL(PUBLIC_URL).host);
262
+ expect(value).not.toContain(window.location.host);
263
+ } else if (value.includes('hexis')) {
141
264
  expect(value).toContain(window.location.origin);
142
265
  expect(value).not.toContain(PUBLIC_URL);
143
266
  } else {
@@ -189,22 +312,22 @@ describe('the key-bearing snippets quote the deployment too', () => {
189
312
  });
190
313
 
191
314
  /**
192
- * The modal leads with the local server too — the recommended block comes
193
- * first, with the REAL key in both snippets (unlike the interactive tab's
194
- * placeholder). And it is the one place the page's own origin is right:
315
+ * The modal follows the tab's order — the hosted endpoint first, the local
316
+ * server second — with the REAL key in both local snippets (unlike the
317
+ * interactive tab, which carries none). And it is the one place the page's own origin is right:
195
318
  * hexis-mcp takes the workspace's address — the one the browser provably
196
319
  * loaded this app from — and resolves the MCP endpoint from it itself,
197
320
  * so the configured `mcpUrl` (possibly a proxy serving only the MCP path)
198
321
  * must appear in neither snippet.
199
322
  */
200
- it('leads with the local server, handing it the origin and the minted key', async () => {
323
+ it('hands the local server the origin and the minted key, after the hosted endpoint', async () => {
201
324
  const user = userEvent.setup();
202
325
  mount(PUBLIC_URL);
203
326
  await revealAKey(user);
204
- const local = screen.getByText('Desktop agents — the local server (recommended)');
205
- const hosted = screen.getByText('Web agents and pipelines — the hosted endpoint');
206
- // DOCUMENT_POSITION_FOLLOWING: the hosted block comes after the local one.
207
- expect(local.compareDocumentPosition(hosted) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
327
+ const hosted = screen.getByText('Claude, ChatGPT and pipelines — the hosted endpoint');
328
+ const local = screen.getByText('Desktop agents — the local server');
329
+ // DOCUMENT_POSITION_FOLLOWING: the local block comes after the hosted one.
330
+ expect(hosted.compareDocumentPosition(local) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
208
331
  const values = snippets();
209
332
 
210
333
  // 7. the Claude Code stdio one-liner
@@ -220,6 +343,48 @@ describe('the key-bearing snippets quote the deployment too', () => {
220
343
  expect(json).not.toContain(PUBLIC_URL);
221
344
  });
222
345
 
346
+ /**
347
+ * The modal's three drawers run in the interactive tab's order — hosted
348
+ * endpoint for Claude and ChatGPT, Desktop agents, marketplace — and every
349
+ * one of them arrives closed: the key is what the
350
+ * dialog hands over, and the configs wait until the reader picks a side.
351
+ */
352
+ it('folds the configs into three drawers in the tab\'s order, all closed', async () => {
353
+ const user = userEvent.setup();
354
+ mount(PUBLIC_URL);
355
+ await revealAKey(user);
356
+ const dialog = screen.getByRole('alertdialog');
357
+ const summaries = [
358
+ 'Claude, ChatGPT and pipelines — the hosted endpoint',
359
+ 'Desktop agents — the local server',
360
+ 'Skills as native plugins — the marketplace',
361
+ ].map((text) => within(dialog).getByText(text));
362
+ expect(Array.from(dialog.querySelectorAll('details > summary'))).toEqual(summaries);
363
+ for (const summary of summaries) {
364
+ expect(summary.tagName).toBe('SUMMARY');
365
+ expect((summary.closest('details') as HTMLDetailsElement).open).toBe(false);
366
+ }
367
+ expect(summaries[0].compareDocumentPosition(summaries[1]) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
368
+ expect(summaries[1].compareDocumentPosition(summaries[2]) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
369
+ // The key itself is not behind a drawer.
370
+ expect(within(dialog).getByRole('button', { name: 'Copy external API key' }).closest('details')).toBeNull();
371
+ });
372
+
373
+ /**
374
+ * The placeholder in the keyless marketplace commands is a placeholder, not
375
+ * a percent-encoded one: `%3Cexternal-api-key%3E` looked like a secret to
376
+ * paste. The commands live on the Marketplaces tab now.
377
+ */
378
+ it('shows the marketplace placeholder verbatim in the keyless commands', async () => {
379
+ const user = userEvent.setup();
380
+ mount(PUBLIC_URL);
381
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
382
+ const marketplace = snippets().filter((v) => v.includes('marketplace.git'));
383
+ expect(marketplace.length).toBeGreaterThan(0);
384
+ for (const v of marketplace) expect(v).not.toContain('%3C');
385
+ expect(marketplace.some((v) => v.includes('key:<external-api-key>@'))).toBe(true);
386
+ });
387
+
223
388
  /**
224
389
  * The consolidation's real risk: snippets that must carry a secret
225
390
  * and snippets that must not. Losing the token during the move would look
@@ -231,11 +396,397 @@ describe('the key-bearing snippets quote the deployment too', () => {
231
396
  expect(snippets().some((v) => v.includes(KEY))).toBe(false);
232
397
  await revealAKey(user);
233
398
  expect(snippets().filter((v) => v.includes(KEY))).toHaveLength(
234
- // the reveal textarea itself, the three keyed hosted snippets, and the
235
- // two local-server (hexis-mcp) snippets
236
- 6,
399
+ // the reveal textarea itself, the three keyed hosted snippets, the two
400
+ // local-server (hexis-mcp) snippets, and the three marketplace commands
401
+ 9,
402
+ );
403
+ });
404
+ });
405
+
406
+ describe('the Marketplaces tab', () => {
407
+ it('is the third tab, and the interactive tab points at it instead of carrying the remote', async () => {
408
+ const user = userEvent.setup();
409
+ mount(PUBLIC_URL);
410
+ expect(screen.getAllByRole('tab').map((t) => t.textContent)).toEqual([
411
+ 'Your agent',
412
+ 'Marketplaces',
413
+ 'Autonomous agents',
414
+ ]);
415
+ // The remote no longer lives on the interactive tab.
416
+ expect(snippets().some((v) => v.includes('marketplace.git'))).toBe(false);
417
+ await user.click(screen.getByRole('button', { name: 'Marketplaces' }));
418
+ expect(screen.getByRole('tab', { name: 'Marketplaces' })).toHaveAttribute('aria-selected', 'true');
419
+ });
420
+
421
+ it('leads with the Cowork route and follows with the git remote, both closed, one URL for both', async () => {
422
+ const user = userEvent.setup();
423
+ mount(PUBLIC_URL);
424
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
425
+ const cowork = screen.getByText('Cowork and claude.ai');
426
+ const git = screen.getByText('Claude Code, Codex and the skills CLI');
427
+ expect(cowork.compareDocumentPosition(git) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
428
+ for (const drawer of [cowork, git]) {
429
+ expect((drawer.closest('details') as HTMLDetailsElement).open).toBe(false);
430
+ }
431
+ await openCowork(user);
432
+ await within(cowork.closest('details') as HTMLElement).findByRole('region', {
433
+ name: 'Set up the Claude marketplace',
434
+ });
435
+ const remote = `${new URL(PUBLIC_URL).origin}/git/marketplace.git`;
436
+ // The same address in both drawers: what Cowork adds is what Claude Code clones.
437
+ expect(snippets().filter((v) => v === remote)).toHaveLength(2);
438
+ // The keyed commands point at the deployment's host.
439
+ const commands = snippets().filter((v) => v.includes('key:'));
440
+ expect(commands.length).toBeGreaterThan(0);
441
+ for (const v of commands) expect(v).toContain(new URL(PUBLIC_URL).host);
442
+ });
443
+
444
+ /**
445
+ * The registration steps live on pages inside Claude's ADMIN settings, and
446
+ * now in Deployment configuration here. This page has no admin branch left:
447
+ * the six actions every person takes, one at a time, and none of the
448
+ * registration screenshots.
449
+ */
450
+ it('gives everyone only the personal steps, and none of the admin screenshots', async () => {
451
+ const user = userEvent.setup();
452
+ mount(PUBLIC_URL);
453
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
454
+ const cowork = await openCowork(user);
455
+
456
+ const carousel = await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
457
+ expect(within(cowork).queryByText('Register this deployment with your Claude organization')).toBeNull();
458
+ expect(carousel).toHaveAttribute('aria-roledescription', 'carousel');
459
+ expect(within(cowork).getByText('Select repository')).toBeTruthy();
460
+ expect(within(cowork).getByText('Connect to URL')).toBeTruthy();
461
+
462
+ // One action shot at a time, beginning with the repository picker trigger,
463
+ // and not one of the four screens that only an admin can use.
464
+ const alts = within(cowork).getAllByRole('img').map((el) => el.getAttribute('alt') ?? '');
465
+ expect(alts).toHaveLength(1);
466
+ expect(alts[0]).toContain('Select repository');
467
+ expect(alts.some((a) => a.includes('admin settings'))).toBe(false);
468
+ });
469
+
470
+ it('pairs every screenshot with its instruction and lets the reader move through all six', async () => {
471
+ const user = userEvent.setup();
472
+ mount(PUBLIC_URL);
473
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
474
+ const cowork = await openCowork(user);
475
+ const carousel = await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
476
+ // One shot a slide, except the connector: that step is one action read
477
+ // across two screens — the row that says Not added and the dialog the
478
+ // button opens — so splitting it would put the check that it worked on a
479
+ // different slide from the control that does it.
480
+ const expected: [string[], string][] = [
481
+ [['Select repository'], 'Connect to URL'],
482
+ [['Plugins tab'], 'select the Plugins tab'],
483
+ [['Add marketplace'], 'choose Add marketplace'],
484
+ [['URL field'], 'Paste the Marketplace URL'],
485
+ [['Hexis all row'], 'choose the Hexis all row'],
486
+ [['Not added', 'Add custom connector dialog'], 'Add for your team'],
487
+ ];
488
+
489
+ for (const [alts, instruction] of expected) {
490
+ const shown = within(carousel)
491
+ .getAllByRole('img')
492
+ .map((el) => el.getAttribute('alt') ?? '');
493
+ expect(shown).toHaveLength(alts.length);
494
+ alts.forEach((alt, index) => expect(shown[index]).toContain(alt));
495
+ expect(carousel).toHaveTextContent(instruction);
496
+ if (within(carousel).queryByRole('button', { name: 'Next' })) {
497
+ await user.click(within(carousel).getByRole('button', { name: 'Next' }));
498
+ }
499
+ }
500
+
501
+ expect(within(carousel).getByRole('button', { name: 'Review again' })).toBeTruthy();
502
+ await user.click(within(carousel).getByRole('button', { name: 'Go to step 3: Marketplace' }));
503
+ expect(within(carousel).getByRole('group')).toHaveAccessibleName(
504
+ 'Step 3 of 6: Choose Add marketplace',
505
+ );
506
+ });
507
+
508
+ /**
509
+ * Installing the plugin brings the skills and leaves the knowledge base
510
+ * disconnected, which is where this tutorial used to stop. The last slide
511
+ * is the connector, and End reaches it: the carousel is reachable from the
512
+ * keyboard, and the step a reader most needs is the one furthest away.
513
+ */
514
+ it('ends on the connector step, reachable with End, naming Add for your team', async () => {
515
+ const user = userEvent.setup();
516
+ mount(PUBLIC_URL);
517
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
518
+ const cowork = await openCowork(user);
519
+ const carousel = await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
520
+
521
+ await user.click(within(carousel).getByRole('button', { name: 'Next' }));
522
+ fireEvent.keyDown(carousel, { key: 'End' });
523
+
524
+ expect(within(carousel).getByRole('group')).toHaveAccessibleName(
525
+ 'Step 6 of 6: Add the hexis connector',
526
+ );
527
+ expect(within(carousel).getByRole('button', { name: 'Review again' })).toBeTruthy();
528
+ expect(within(carousel).getByText('6 / 6')).toBeTruthy();
529
+
530
+ // What the step has to say, in the reader's own words: the plugin does
531
+ // not bring the connector, the row that proves it, the button, and the
532
+ // check that it worked.
533
+ expect(carousel).toHaveTextContent('does not connect its MCP server');
534
+ expect(carousel).toHaveTextContent('Not added');
535
+ expect(carousel).toHaveTextContent('Add for your team');
536
+ expect(carousel).toHaveTextContent('Add custom connector');
537
+ expect(carousel).toHaveTextContent('approve the sign-in on this deployment');
538
+ expect(carousel).toHaveTextContent('no longer reads');
539
+ expect(carousel).toHaveTextContent('Without organization-admin rights');
540
+
541
+ // Both of its screens are drawings rather than captures, and the slide
542
+ // says so under each one: a reader comparing their own Claude to a
543
+ // sketch should not be left deciding they are on the wrong screen. One
544
+ // note per shot.
545
+ expect(within(carousel).getAllByText(/Illustration, not a capture/)).toHaveLength(2);
546
+
547
+ // And Home goes back to the first, so End is not a one-way door. The
548
+ // first slide is a real capture, so the same press is what shows the
549
+ // note is per-shot rather than part of the shell. One press proving
550
+ // both: a second one here would only be re-entering a state the press
551
+ // before it had already produced.
552
+ fireEvent.keyDown(carousel, { key: 'Home' });
553
+ expect(within(carousel).getByRole('group')).toHaveAccessibleName(
554
+ 'Step 1 of 6: Select this deployment in Claude Code',
555
+ );
556
+ expect(within(carousel).queryByText(/Illustration, not a capture/)).toBeNull();
557
+ });
558
+
559
+ /**
560
+ * Changing slide moves no focus, so nothing would be announced: the reader
561
+ * is left on the control they pressed while everything under it changes.
562
+ * The slide group is the live region, and the counter is not, so the step
563
+ * is announced once rather than twice.
564
+ */
565
+ it('announces the slide that replaced it, and only once', async () => {
566
+ const user = userEvent.setup();
567
+ mount(PUBLIC_URL);
568
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
569
+ const cowork = await openCowork(user);
570
+ const carousel = await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
571
+
572
+ expect(within(carousel).getByRole('group')).toHaveAttribute('aria-live', 'polite');
573
+ expect(within(carousel).getByText('1 / 6')).not.toHaveAttribute('aria-live');
574
+ });
575
+
576
+ /**
577
+ * The footer control is ONE button that changes its label, so reaching the
578
+ * last slide cannot unmount the button the reader is focused on — focus
579
+ * would fall to the body and take the arrow keys with it, which this
580
+ * section handles. Node identity is asserted alongside focus because it is
581
+ * the property that actually guarantees this: it names the cause, so a
582
+ * `key` or a wrapper added later fails here rather than somewhere vague.
583
+ */
584
+ it('keeps focus on the footer control when the last slide relabels it', async () => {
585
+ const user = userEvent.setup();
586
+ mount(PUBLIC_URL);
587
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
588
+ const cowork = await openCowork(user);
589
+ const carousel = await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
590
+
591
+ const advance = within(carousel).getByRole('button', { name: 'Next' });
592
+ for (let step = 0; step < 5; step += 1) {
593
+ await user.click(within(carousel).getByRole('button', { name: 'Next' }));
594
+ }
595
+
596
+ const restart = within(carousel).getByRole('button', { name: 'Review again' });
597
+ expect(restart).toBe(advance);
598
+ expect(restart).toHaveFocus();
599
+
600
+ // And it still works as the control it now says it is.
601
+ await user.click(restart);
602
+ expect(within(carousel).getByRole('group')).toHaveAccessibleName(
603
+ 'Step 1 of 6: Select this deployment in Claude Code',
237
604
  );
238
605
  });
606
+
607
+ /**
608
+ * State one of three: REGISTERED. The tutorial is the same DOM for an admin
609
+ * as for anyone else — the admin branch is gone, not merely hidden — and
610
+ * no one's copy of this page asks for the credentials.
611
+ */
612
+ it('shows an admin exactly the tutorial a non-admin sees once the deployment is registered', async () => {
613
+ const drawerHtml = async () => {
614
+ const user = userEvent.setup();
615
+ const view = mount(PUBLIC_URL);
616
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
617
+ const cowork = await openCowork(user);
618
+ await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
619
+ expect(within(cowork).queryByTestId('marketplace-not-configured')).toBeNull();
620
+ const html = cowork.innerHTML;
621
+ view.unmount();
622
+ return html;
623
+ };
624
+
625
+ adminState.isAdmin = false;
626
+ const asMember = await drawerHtml();
627
+ adminState.isAdmin = true;
628
+ const asAdmin = await drawerHtml();
629
+
630
+ expect(asAdmin).toBe(asMember);
631
+ expect(asAdmin).not.toContain('Register this deployment with your Claude organization');
632
+ expect(facadeMock).not.toHaveBeenCalled();
633
+ });
634
+
635
+ /**
636
+ * State two: NOT REGISTERED, for a non-admin. No tutorial — its first
637
+ * screen would list no deployment — and a notice that an admin has to
638
+ * configure the marketplace, with no link to a page they cannot use.
639
+ */
640
+ it('tells a non-admin an admin must configure the marketplace, and shows no tutorial', async () => {
641
+ registrationMock.mockResolvedValue(false);
642
+ const user = userEvent.setup();
643
+ mount(PUBLIC_URL);
644
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
645
+ const cowork = await openCowork(user);
646
+
647
+ const notice = await within(cowork).findByTestId('marketplace-not-configured');
648
+ expect(notice).toHaveTextContent('An admin has to configure the marketplace');
649
+ expect(within(notice).queryByRole('link')).toBeNull();
650
+ expect(within(cowork).queryByRole('region', { name: 'Set up the Claude marketplace' })).toBeNull();
651
+ expect(within(cowork).queryAllByRole('img')).toHaveLength(0);
652
+ expect(facadeMock).not.toHaveBeenCalled();
653
+ });
654
+
655
+ /**
656
+ * State three: NOT REGISTERED, for an admin. The same absence of a
657
+ * tutorial, and a notice pointing at the Deployment section that fixes it —
658
+ * a link that actually lands there.
659
+ */
660
+ it('points an admin at the Deployment section with a working link', async () => {
661
+ registrationMock.mockResolvedValue(false);
662
+ adminState.isAdmin = true;
663
+ const user = userEvent.setup();
664
+ render(
665
+ <MemoryRouter initialEntries={['/external-agent-access']}>
666
+ <Routes>
667
+ <Route path="/external-agent-access" element={<ExternalAgentAccessPage />} />
668
+ <Route path="/deployment" element={<div>Deployment settings page</div>} />
669
+ </Routes>
670
+ </MemoryRouter>,
671
+ );
672
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
673
+ const cowork = await openCowork(user);
674
+
675
+ const notice = await within(cowork).findByTestId('marketplace-not-configured');
676
+ expect(within(cowork).queryByRole('region', { name: 'Set up the Claude marketplace' })).toBeNull();
677
+ const link = within(notice).getByRole('link', { name: /Marketplace section of Deployment settings/ });
678
+ expect(link).toHaveAttribute('href', '/deployment#marketplace');
679
+ await user.click(link);
680
+ expect(await screen.findByText('Deployment settings page')).toBeInTheDocument();
681
+ expect(facadeMock).not.toHaveBeenCalled();
682
+ });
683
+
684
+ /**
685
+ * A closed <details> still mounts its children, so a read on mount put a
686
+ * request behind every visit to this tab — and never repeated it, leaving
687
+ * the "not set up yet" notice standing after an admin registered the
688
+ * deployment elsewhere. The state is read when the drawer opens, and again
689
+ * on every opening.
690
+ */
691
+ it('reads the registration state only when the drawer opens, and again on each opening', async () => {
692
+ registrationMock.mockResolvedValueOnce(false).mockResolvedValue(true);
693
+ const user = userEvent.setup();
694
+ mount(PUBLIC_URL);
695
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
696
+ const cowork = screen.getByText('Cowork and claude.ai').closest('details') as HTMLDetailsElement;
697
+ expect(cowork.open).toBe(false);
698
+ expect(registrationMock).not.toHaveBeenCalled();
699
+
700
+ const summary = within(cowork).getByText('Cowork and claude.ai');
701
+ await user.click(summary);
702
+ await within(cowork).findByTestId('marketplace-not-configured');
703
+ expect(registrationMock).toHaveBeenCalledTimes(1);
704
+
705
+ // Registered in the meantime: closing and reopening is all it takes.
706
+ await user.click(summary);
707
+ expect(cowork.open).toBe(false);
708
+ await user.click(summary);
709
+ await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
710
+ expect(within(cowork).queryByTestId('marketplace-not-configured')).toBeNull();
711
+ expect(registrationMock).toHaveBeenCalledTimes(2);
712
+ expect(facadeMock).not.toHaveBeenCalled();
713
+ });
714
+
715
+ /**
716
+ * Every box is decoration: `aria-hidden`, and the control it frames is
717
+ * named in the image's own alt text. A screen reader that never sees a red
718
+ * rectangle still gets the instruction.
719
+ */
720
+ it('names the highlighted control in alt text rather than only boxing it', async () => {
721
+ const user = userEvent.setup();
722
+ mount(PUBLIC_URL);
723
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
724
+ const cowork = await openCowork(user);
725
+ await within(cowork).findByRole('region', { name: 'Set up the Claude marketplace' });
726
+
727
+ for (const img of within(cowork).getAllByRole('img')) {
728
+ expect((img.getAttribute('alt') ?? '').length).toBeGreaterThan(40);
729
+ }
730
+ // The deployment's own host, never a hard-coded example.
731
+ expect(cowork).toHaveTextContent(new URL(PUBLIC_URL).host);
732
+ });
733
+
734
+ it('tells Claude connections from keys by their stored kind — never by the label', async () => {
735
+ listMock.mockResolvedValue([
736
+ { id: 'c1', kind: GITHUB_LINK_KIND, label: 'My Cowork link', createdAt: Date.now(), lastUsedAt: null, revokedAt: null, revokedBy: null },
737
+ // A hand-made key wearing the link's usual label is still a key.
738
+ { id: 'k1', kind: 'key', label: 'Claude (claude.ai and Cowork)', createdAt: Date.now(), lastUsedAt: null, revokedAt: null, revokedBy: null },
739
+ ]);
740
+ const user = userEvent.setup();
741
+ mount(PUBLIC_URL);
742
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
743
+ const cowork = await openCowork(user);
744
+ await screen.findByText('My Cowork link');
745
+ expect(cowork).toHaveTextContent('My Cowork link');
746
+ expect(cowork).not.toHaveTextContent('Claude (claude.ai and Cowork)');
747
+
748
+ await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
749
+ await screen.findByText('Claude (claude.ai and Cowork)');
750
+ expect(screen.queryByText('My Cowork link')).toBeNull();
751
+ });
752
+
753
+ it('tells a key an admin revoked from one you disconnected yourself', async () => {
754
+ // "Disconnected" invites reconnecting. A key an admin took will not come
755
+ // back that way, so the row must say who ended it.
756
+ listMock.mockResolvedValue([
757
+ { id: 'k1', kind: 'key', label: 'CI', createdAt: Date.now(), lastUsedAt: null, revokedAt: Date.now(), revokedBy: 'admin' },
758
+ { id: 'k2', kind: 'key', label: 'Laptop', createdAt: Date.now(), lastUsedAt: null, revokedAt: Date.now(), revokedBy: 'owner' },
759
+ // Revoked before who-did-it was recorded: read as the owner's doing.
760
+ { id: 'k3', kind: 'key', label: 'Old', createdAt: Date.now(), lastUsedAt: null, revokedAt: Date.now(), revokedBy: null },
761
+ ]);
762
+ const user = userEvent.setup();
763
+ mount(PUBLIC_URL);
764
+ await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
765
+ await screen.findByText('CI');
766
+ const rowOf = (label: string) => screen.getByText(label).closest('li') as HTMLElement;
767
+ expect(rowOf('CI')).toHaveTextContent('Revoked by an admin');
768
+ expect(rowOf('CI')).not.toHaveTextContent('Disconnected');
769
+ expect(rowOf('Laptop')).toHaveTextContent('Disconnected');
770
+ expect(rowOf('Laptop')).not.toHaveTextContent('Revoked by an admin');
771
+ expect(rowOf('Old')).toHaveTextContent('Disconnected');
772
+ });
773
+
774
+ it('says where the keys went when only Claude connections exist, and shows a load error on both tabs', async () => {
775
+ listMock.mockResolvedValue([
776
+ { id: 'c1', kind: GITHUB_LINK_KIND, label: 'Claude', createdAt: Date.now(), lastUsedAt: null, revokedAt: null, revokedBy: null },
777
+ ]);
778
+ const user = userEvent.setup();
779
+ const first = mount(PUBLIC_URL);
780
+ await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
781
+ await screen.findByText(/Your Claude connections are on the Marketplaces tab/);
782
+ first.unmount();
783
+
784
+ listMock.mockRejectedValue(new Error('keys are down'));
785
+ mount(PUBLIC_URL);
786
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
787
+ await screen.findByText('keys are down');
788
+ expect(screen.queryByText(/None yet/)).toBeNull();
789
+ });
239
790
  });
240
791
 
241
792
  describe('the one-click install link', () => {
@@ -258,16 +809,17 @@ describe('the one-click install link', () => {
258
809
 
259
810
  /**
260
811
  * ChatGPT sits beside Claude, with the honest difference: no prefill
261
- * exists, so the button opens the settings pane and the copy under it
812
+ * exists, so the button opens the settings root and the copy under it
262
813
  * names the connector to type. Same gate — an endpoint Anthropic cannot
263
814
  * reach is one OpenAI cannot reach.
264
815
  */
265
816
  it('offers Add to ChatGPT beside it, naming what to call the connector', () => {
266
817
  mount(PUBLIC_URL);
267
818
  const link = screen.getByRole('link', { name: 'Add to ChatGPT' });
268
- // The whole href, not just the origin: the settings-pane anchor is the
269
- // only part that makes the link worth clicking.
270
- expect(link).toHaveAttribute('href', 'https://chatgpt.com/#settings/Connectors');
819
+ // The whole href, not just the origin: it opens the settings root, not a
820
+ // pane anchor — ChatGPT renamed the connectors pane, so no anchor reliably
821
+ // lands there, and the steps beside the button start from Settings.
822
+ expect(link).toHaveAttribute('href', 'https://chatgpt.com/#settings');
271
823
  expect(link).toHaveAttribute('target', '_blank');
272
824
  expect(link).toHaveAttribute('rel', 'noopener noreferrer');
273
825
  expect(screen.getByText('Skills, Tools and Knowledge')).toBeInTheDocument();
@@ -310,10 +862,24 @@ describe('the one-click install link', () => {
310
862
  });
311
863
 
312
864
  describe('tabs', () => {
865
+ it('puts connection setup first and agent instructions in a separate card below it', () => {
866
+ mount(PUBLIC_URL);
867
+ const connections = screen.getByTestId('agent-connection-section');
868
+ const instructions = screen.getByTestId('agent-instructions-section');
869
+ expect(within(connections).getByRole('tablist')).toBeInTheDocument();
870
+ expect(within(instructions).getByRole('heading', {
871
+ name: 'What agents are told about this knowledge base',
872
+ })).toBeInTheDocument();
873
+ expect(connections.compareDocumentPosition(instructions) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
874
+ expect(connections.parentElement).toBe(instructions.parentElement);
875
+ expect(connections.className).toContain('rounded-lg');
876
+ expect(instructions.className).toContain('rounded-lg');
877
+ });
878
+
313
879
  it('starts on the interactive tab', () => {
314
880
  mount(PUBLIC_URL);
315
881
  const tabs = screen.getAllByRole('tab');
316
- expect(tabs.map((t) => t.textContent)).toEqual(['Your agent', 'Autonomous agents']);
882
+ expect(tabs.map((t) => t.textContent)).toEqual(['Your agent', 'Marketplaces', 'Autonomous agents']);
317
883
  expect(tabs[0]).toHaveAttribute('aria-selected', 'true');
318
884
  expect(tabs[1]).toHaveAttribute('aria-selected', 'false');
319
885
  });
@@ -347,3 +913,60 @@ describe('tabs', () => {
347
913
  expect(screen.queryByRole('link', { name: 'Add to Claude' })).toBeNull();
348
914
  });
349
915
  });
916
+
917
+ /**
918
+ * Adding a marketplace installs nothing in Codex, and the compiled plugin's
919
+ * server entry carries no credentials: the block has to carry the install and
920
+ * the sign-in, and the page has to say why the sign-in is there.
921
+ */
922
+ describe('the Codex block', () => {
923
+ const REMOTE = 'https://key:<external-api-key>@kb.acme.com/git/marketplace.git';
924
+ const note = /Codex signs in through your browser once: the login line is needed because the plugin's server entry carries no credentials\./;
925
+
926
+ function codexLines(remote: string): string[] {
927
+ return [
928
+ `codex plugin marketplace add ${remote}`,
929
+ 'codex plugin add skills-and-knowledge@hexis',
930
+ 'codex mcp login hexis',
931
+ 'codex exec --skip-git-repo-check "Call the hexis MCP server\'s list_tools tool and print the tool names it returns."',
932
+ ];
933
+ }
934
+
935
+ it('adds, installs, signs in and checks, in that order, and says why it signs in', async () => {
936
+ const user = userEvent.setup();
937
+ mount(PUBLIC_URL);
938
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
939
+ const drawer = screen.getByTestId('marketplace-section');
940
+ const codex = within(drawer)
941
+ .getAllByRole('textbox')
942
+ .map((el) => (el as HTMLTextAreaElement).value)
943
+ .find((v) => v.startsWith('codex '));
944
+ expect(codex?.split('\n')).toEqual(codexLines(REMOTE));
945
+ expect(within(drawer).getByText(note)).toBeTruthy();
946
+ // The other two commands are exactly what they were.
947
+ const values = within(drawer).getAllByRole('textbox').map((el) => (el as HTMLTextAreaElement).value);
948
+ expect(values).toContain(`claude plugin marketplace add ${REMOTE} && claude plugin install hexis-all@hexis`);
949
+ expect(values).toContain(`npx skills add ${REMOTE} --all -y`);
950
+ });
951
+
952
+ it('copies the whole block, not its first line', async () => {
953
+ const user = userEvent.setup();
954
+ mount(PUBLIC_URL);
955
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
956
+ // Stubbed after userEvent.setup(), which installs a clipboard of its own.
957
+ const writeText = vi.fn().mockResolvedValue(undefined);
958
+ Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
959
+ fireEvent.click(screen.getByRole('button', { name: 'Copy: Codex' }));
960
+ expect(writeText).toHaveBeenCalledWith(codexLines(REMOTE).join('\n'));
961
+ });
962
+
963
+ it('is the same block in the connection-keys dialog, with the key filled in', async () => {
964
+ const user = userEvent.setup();
965
+ mount(PUBLIC_URL);
966
+ await revealAKey(user);
967
+ const dialog = screen.getByRole('alertdialog');
968
+ const block = within(dialog).getByRole('textbox', { name: 'Codex marketplace command' }) as HTMLTextAreaElement;
969
+ expect(block.value.split('\n')).toEqual(codexLines(`https://key:${KEY}@kb.acme.com/git/marketplace.git`));
970
+ expect(within(dialog).getByText(note)).toBeTruthy();
971
+ });
972
+ });