@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,6 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
2
  import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';
3
- import { MemoryRouter, Route, Routes } from 'react-router-dom';
3
+ import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
4
4
  import type { ReactNode } from 'react';
5
5
  import {
6
6
  WorkspaceContext,
@@ -63,8 +63,13 @@ vi.mock('../../access/api', async (importOriginal) => {
63
63
  };
64
64
  });
65
65
 
66
+ const teamsMock = vi.hoisted(() => ({ listTeams: vi.fn() }));
67
+ vi.mock('../services/teams.api', () => ({ listTeams: teamsMock.listTeams }));
68
+ // The sidebar's change-request dock pulls in git wiring these routes do not exercise.
69
+ vi.mock('../../git/components/PullRequestsForMe', () => ({ PullRequestsForMe: () => null }));
70
+
66
71
  import { LibraryRoutes } from '../routes/LibraryRoutes';
67
- import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
72
+ import { withAuth } from './auth-harness';
68
73
 
69
74
  const CATALOG: LibraryData = {
70
75
  loading: false,
@@ -74,7 +79,10 @@ const CATALOG: LibraryData = {
74
79
  { name: 'scratch', description: 'A skill in no plugin.', path: 'Skills/scratch' },
75
80
  ],
76
81
  tools: [],
82
+ pendingTools: [],
77
83
  ownedSkills: new Set(['outreach']),
84
+ writableSkills: new Set(['outreach']),
85
+ ownedTools: new Set(),
78
86
  allowedToolsBySkill: new Map(),
79
87
  pendingSkills: [],
80
88
  crs: [],
@@ -105,9 +113,9 @@ const PLUGINS: PluginSummary[] = [
105
113
  summary({ name: 'Finance', folders: ['Plugins/Finance'], canRead: false, canWrite: false }),
106
114
  ];
107
115
 
108
- function wrap(children: ReactNode) {
116
+ function wrap(children: ReactNode, isAdmin = false) {
109
117
  const adminValue = {
110
- isAdmin: false,
118
+ isAdmin,
111
119
  unreadCount: 0,
112
120
  lastSeen: null,
113
121
  markSeen: vi.fn(),
@@ -130,19 +138,27 @@ function wrap(children: ReactNode) {
130
138
  );
131
139
  }
132
140
 
133
- function renderLibrary(path = '/skills-and-tools') {
141
+ /** Stands in for the Groups & Members page: shows where "Manage members" landed. */
142
+ function LandedOn() {
143
+ const { pathname, search } = useLocation();
144
+ return <div data-testid="landed">{`${pathname}${search}`}</div>;
145
+ }
146
+
147
+ function renderLibrary(path = '/skills-and-tools', { isAdmin = false } = {}) {
134
148
  return render(
135
149
  <MemoryRouter initialEntries={[path]}>
136
150
  {wrap(
137
151
  <Routes>
138
152
  <Route path="/skills-and-tools/*" element={<LibraryRoutes />} />
153
+ <Route path="/directory-groups" element={<LandedOn />} />
139
154
  </Routes>,
155
+ isAdmin,
140
156
  )}
141
157
  </MemoryRouter>,
142
158
  );
143
159
  }
144
160
 
145
- const nav = () => screen.getByRole('navigation', { name: 'Library plugins' });
161
+ const nav = () => screen.getByRole('navigation', { name: 'Library navigation' });
146
162
  const menuItems = () =>
147
163
  within(screen.getByRole('menu'))
148
164
  .getAllByRole('menuitem')
@@ -169,6 +185,9 @@ describe('Library sidebar: right-click, end to end', () => {
169
185
  pluginsMock.listPlugins.mockResolvedValue(PLUGINS);
170
186
  pluginsMock.listJoinRequests.mockResolvedValue([]);
171
187
  pluginsMock.deletePlugin.mockResolvedValue(undefined);
188
+ teamsMock.listTeams.mockResolvedValue([
189
+ { name: 'GTM Team', plugins: ['GTM'], skills: ['outreach'], tools: [] },
190
+ ]);
172
191
  });
173
192
 
174
193
  // Only the globals this file stubs — NOT `restoreAllMocks`, which would strip
@@ -176,19 +195,21 @@ describe('Library sidebar: right-click, end to end', () => {
176
195
  // returning undefined for whichever test happens to run next.
177
196
  afterEach(() => vi.unstubAllGlobals());
178
197
 
179
- it('gives a plugin row the full menu, titled after the plugin', async () => {
198
+ /**
199
+ * A team row, like a lens, is a slice of the catalog and not a folder —
200
+ * there is nothing to add a skill TO and no `access.md` behind it. The
201
+ * plugin verbs (add to, manage access, delete) live on the plugin page and
202
+ * on the plugin's folder in the Plugins tree; the nav answers only with
203
+ * what the nav can do.
204
+ */
205
+ it('gives a team row the verbs a slice of the catalog can answer, titled after the team', async () => {
180
206
  renderLibrary();
181
- await openMenuOn(/^GTM/);
182
- expect(screen.getByRole('menu', { name: 'Actions for GTM' })).toBeInTheDocument();
183
- expect(menuItems()).toEqual(['Add a skill or tool', 'New plugin', 'Copy link', 'Manage access']);
207
+ await openMenuOn(/^GTM Team/);
208
+ expect(screen.getByRole('menu', { name: 'Actions for GTM Team' })).toBeInTheDocument();
209
+ expect(menuItems()).toEqual(['New plugin', 'Copy link']);
184
210
  });
185
211
 
186
- /**
187
- * A lens is a slice of the catalog, not a folder — there is nothing to add a
188
- * skill TO and no `access.md` behind it. The same call the plugin page's
189
- * `PageActions` makes when it hides `Share` on the personal page.
190
- */
191
- it('gives a lens row only the verbs a slice of the catalog can answer', async () => {
212
+ it('gives a lens row the same verbs', async () => {
192
213
  renderLibrary();
193
214
  await openMenuOn(/^Owned by me/);
194
215
  expect(menuItems()).toEqual(['New plugin', 'Copy link']);
@@ -196,57 +217,13 @@ describe('Library sidebar: right-click, end to end', () => {
196
217
  fireEvent.keyDown(document, { key: 'Escape' });
197
218
  await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
198
219
 
199
- await openMenuOn(new RegExp(`^${TEST_PERSONAL_GROUP}`));
220
+ await openMenuOn(/^Everything/);
200
221
  expect(menuItems()).toEqual(['New plugin', 'Copy link']);
201
222
  });
202
223
 
203
- /**
204
- * `Manage access` is UNGATED on `canWrite`, exactly as the plugin page's
205
- * `Share` is: for a non-writer the dialog renders read-only, which is
206
- * precisely what "who is this shared with?" should answer — and for an admin
207
- * locked out of a plugin it is the self-service way back in.
208
- */
209
- it('offers Manage access on a locked plugin too', async () => {
210
- renderLibrary();
211
- await openMenuOn('Finance (locked)');
212
- expect(screen.getByRole('menu', { name: 'Actions for Finance' })).toBeInTheDocument();
213
- expect(menuItems()).toContain('Manage access');
214
- });
215
-
216
- /**
217
- * Delete is the OWNER's verb: `isOwner` is the same verdict the backend's
218
- * DELETE route enforces, so the affordance appears for exactly the people
219
- * the endpoint will let through. GTM's default summary here says
220
- * `canWrite: true, isOwner: false` — the full-menu test above is therefore
221
- * also the proof that a mere MANAGER does not see the item.
222
- */
223
- it('offers Delete plugin to an owner, and drives the confirm → delete round-trip', async () => {
224
- pluginsMock.listPlugins.mockResolvedValue([summary({ isOwner: true })]);
225
- renderLibrary();
226
- await openMenuOn(/^GTM/);
227
- expect(menuItems()).toEqual([
228
- 'Add a skill or tool',
229
- 'New plugin',
230
- 'Copy link',
231
- 'Manage access',
232
- 'Delete plugin',
233
- ]);
234
-
235
- fireEvent.click(screen.getByRole('menuitem', { name: 'Delete plugin' }));
236
- // The menu hands over to the confirmation — nothing is deleted yet.
237
- const dialog = await screen.findByRole('dialog');
238
- expect(screen.queryByRole('menu')).toBeNull();
239
- expect(pluginsMock.deletePlugin).not.toHaveBeenCalled();
240
-
241
- fireEvent.click(within(dialog).getByRole('button', { name: 'Delete plugin' }));
242
- await waitFor(() => expect(pluginsMock.deletePlugin).toHaveBeenCalledWith('GTM'));
243
- // The layout says so — same voice as every other completed verb here.
244
- expect(await screen.findByText('Deleted GTM.')).toBeInTheDocument();
245
- });
246
-
247
224
  it('gives the empty nav space the one verb that belongs to the nav itself', async () => {
248
225
  renderLibrary();
249
- await navRow(/^GTM/);
226
+ await navRow(/^GTM Team/);
250
227
  fireEvent.contextMenu(nav(), { clientX: 40, clientY: 400 });
251
228
  await screen.findByRole('menu');
252
229
  expect(menuItems()).toEqual(['New plugin']);
@@ -254,52 +231,23 @@ describe('Library sidebar: right-click, end to end', () => {
254
231
 
255
232
  it('opens the new-plugin dialog from the menu', async () => {
256
233
  renderLibrary();
257
- await openMenuOn(/^GTM/);
234
+ await openMenuOn(/^GTM Team/);
258
235
  fireEvent.click(screen.getByRole('menuitem', { name: 'New plugin' }));
259
236
  expect(await screen.findByRole('dialog')).toBeInTheDocument();
260
237
  expect(screen.queryByRole('menu')).toBeNull();
261
238
  });
262
239
 
263
- it('opens the add dialog for the plugin that was clicked, not the page you are on', async () => {
264
- renderLibrary('/skills-and-tools/owned');
265
- await openMenuOn(/^GTM/);
266
- fireEvent.click(screen.getByRole('menuitem', { name: 'Add a skill or tool' }));
267
- // The dialog titles itself with its plugin — proof the layout captured the
268
- // ROW's plugin, and not the route it happened to be sitting on.
269
- const dialog = await screen.findByRole('dialog');
270
- expect(within(dialog).getByText('Add a skill or tool to GTM')).toBeInTheDocument();
271
- });
272
-
273
- it('opens Manage access on the plugin folder, under the KB dir', async () => {
274
- const access = await import('../../access/api');
275
- renderLibrary();
276
- await openMenuOn(/^GTM/);
277
- fireEvent.click(screen.getByRole('menuitem', { name: 'Manage access' }));
278
-
279
- await waitFor(() => expect(access.fetchFileAccess).toHaveBeenCalled());
280
- /**
281
- * The whole round trip, in one assertion. The layout hands the dialog a
282
- * WORKSPACE path (`<kbDirName>/<folder>`), the dialog strips that prefix
283
- * back off, and what reaches the resolver is the REPO-relative folder —
284
- * which is the only address `access.md` is written at. Get either half
285
- * wrong and this is `undefined/Plugins/GTM` or `knowledge-base/Plugins/GTM`,
286
- * and the dialog silently resolves a folder that does not exist. It is the
287
- * same handoff `PluginPage` makes, which is why it has to match exactly.
288
- */
289
- expect(vi.mocked(access.fetchFileAccess).mock.calls[0][1]).toBe('Plugins/GTM');
290
- });
291
-
292
240
  it("copies the clicked row's own URL, not the one you are standing on", async () => {
293
241
  const writeText = vi.fn().mockResolvedValue(undefined);
294
242
  vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
295
243
 
296
244
  renderLibrary('/skills-and-tools/owned');
297
- await openMenuOn(/^GTM/);
245
+ await openMenuOn(/^GTM Team/);
298
246
  fireEvent.click(screen.getByRole('menuitem', { name: 'Copy link' }));
299
247
 
300
248
  await waitFor(() =>
301
249
  expect(writeText).toHaveBeenCalledWith(
302
- `${window.location.origin}/skills-and-tools/plugins/GTM`,
250
+ `${window.location.origin}/skills-and-tools/teams/GTM%20Team`,
303
251
  ),
304
252
  );
305
253
  expect(await screen.findByText('Link copied.')).toBeInTheDocument();
@@ -313,7 +261,7 @@ describe('Library sidebar: right-click, end to end', () => {
313
261
  });
314
262
 
315
263
  renderLibrary();
316
- await openMenuOn(/^GTM/);
264
+ await openMenuOn(/^GTM Team/);
317
265
  fireEvent.click(screen.getByRole('menuitem', { name: 'Copy link' }));
318
266
 
319
267
  // The pill itself, not `getByRole('status')` — the tree carries a second
@@ -329,19 +277,76 @@ describe('Library sidebar: right-click, end to end', () => {
329
277
 
330
278
  it('closes on an outside click, and a left click still navigates', async () => {
331
279
  renderLibrary();
332
- await openMenuOn(/^GTM/);
280
+ await openMenuOn(/^GTM Team/);
333
281
  fireEvent.mouseDown(document.body);
334
282
  await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
335
283
 
336
- fireEvent.click(await navRow(/^GTM/));
337
- expect(await screen.findByRole('heading', { name: 'GTM', level: 1 })).toBeInTheDocument();
284
+ fireEvent.click(await navRow(/^GTM Team/));
285
+ expect(await screen.findByRole('heading', { name: 'GTM Team', level: 1 })).toBeInTheDocument();
338
286
  });
339
287
 
340
288
  it('hands focus back to the row on Escape', async () => {
341
289
  renderLibrary();
342
- const row = await openMenuOn(/^GTM/);
290
+ const row = await openMenuOn(/^GTM Team/);
343
291
  fireEvent.keyDown(document, { key: 'Escape' });
344
292
  await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
345
293
  expect(document.activeElement).toBe(row);
346
294
  });
347
295
  });
296
+
297
+ /**
298
+ * "Manage members" — an administrator's way from a group row to that group's
299
+ * roster. Everyone is not a group and has no roster; a non-admin cannot edit
300
+ * one, so neither sees the item.
301
+ */
302
+ describe('Library sidebar: Manage members', () => {
303
+ beforeEach(() => {
304
+ dataMock.useLibraryData.mockReturnValue(CATALOG);
305
+ pluginsMock.listPlugins.mockResolvedValue(PLUGINS);
306
+ pluginsMock.listJoinRequests.mockResolvedValue([]);
307
+ teamsMock.listTeams.mockResolvedValue([
308
+ { name: 'Everyone', plugins: [], skills: [], tools: [] },
309
+ { name: 'GTM Team', plugins: ['GTM'], skills: ['outreach'], tools: [] },
310
+ ]);
311
+ });
312
+
313
+ it("gives an admin's group row Manage members, below the items it already had", async () => {
314
+ renderLibrary('/skills-and-tools', { isAdmin: true });
315
+ await openMenuOn(/^GTM Team/);
316
+ expect(menuItems()).toEqual(['New plugin', 'Copy link', 'Manage members']);
317
+ });
318
+
319
+ it("opens the group's card on the Groups page, the group carried in the URL", async () => {
320
+ renderLibrary('/skills-and-tools', { isAdmin: true });
321
+ await openMenuOn(/^GTM Team/);
322
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Manage members' }));
323
+ expect(await screen.findByTestId('landed')).toHaveTextContent(
324
+ '/directory-groups?group=GTM+Team',
325
+ );
326
+ expect(screen.queryByRole('menu')).toBeNull();
327
+ });
328
+
329
+ it('gives the Everyone row no Manage members, even for an admin', async () => {
330
+ renderLibrary('/skills-and-tools', { isAdmin: true });
331
+ await openMenuOn(/^Everyone/);
332
+ expect(menuItems()).toEqual(['New plugin', 'Copy link']);
333
+ });
334
+
335
+ it('gives no Manage members on a lens or the empty nav space', async () => {
336
+ renderLibrary('/skills-and-tools', { isAdmin: true });
337
+ await openMenuOn(/^Owned by me/);
338
+ expect(menuItems()).toEqual(['New plugin', 'Copy link']);
339
+ fireEvent.keyDown(document, { key: 'Escape' });
340
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
341
+
342
+ fireEvent.contextMenu(nav(), { clientX: 40, clientY: 400 });
343
+ await screen.findByRole('menu');
344
+ expect(menuItems()).toEqual(['New plugin']);
345
+ });
346
+
347
+ it("leaves a non-admin's group menu unchanged", async () => {
348
+ renderLibrary('/skills-and-tools', { isAdmin: false });
349
+ await openMenuOn(/^GTM Team/);
350
+ expect(menuItems()).toEqual(['New plugin', 'Copy link']);
351
+ });
352
+ });
@@ -0,0 +1,136 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import { LibraryToastProvider } from '../state/toast';
4
+ import type { LibraryItem } from '../state/library-data';
5
+
6
+ /**
7
+ * The link picker: offers what is not yet in the plugin, links on click, and
8
+ * turns the server's "you may edit the plugin but not the skill" refusal into
9
+ * the request path — never deciding that client-side.
10
+ */
11
+
12
+ const api = vi.hoisted(() => ({
13
+ linkSkill: vi.fn(),
14
+ requestSkillAccess: vi.fn(),
15
+ }));
16
+ vi.mock('../services/plugins.api', async (importOriginal) => ({
17
+ ...(await importOriginal<typeof import('../services/plugins.api')>()),
18
+ linkSkill: api.linkSkill,
19
+ }));
20
+ vi.mock('../services/library.api', async (importOriginal) => ({
21
+ ...(await importOriginal<typeof import('../services/library.api')>()),
22
+ requestSkillAccess: api.requestSkillAccess,
23
+ }));
24
+
25
+ import { NeedsSkillWriteError } from '../services/plugins.api';
26
+ import { LinkSkillPanel } from '../components/LinkSkillPanel';
27
+
28
+ const OK = { state: 'ok' as const, text: 'Ready' };
29
+ const items: LibraryItem[] = [
30
+ { kind: 'skill', id: 'deploy', name: 'deploy', description: 'Ship it.', owned: false, canWrite: false, plugin: null, shared: true, plugins: [], path: 'Skills/Eng/deploy', status: OK },
31
+ { kind: 'skill', id: 'outreach', name: 'outreach', description: '', owned: true, canWrite: true, plugin: 'GTM', plugins: [{ name: 'GTM', linked: false, granted: true }], path: 'Plugins/GTM/skills/outreach', status: OK },
32
+ { kind: 'skill', id: 'pitch', name: 'pitch', description: 'Sales pitch.', owned: false, canWrite: false, plugin: 'Sales', plugins: [{ name: 'Sales', linked: false, granted: true }], path: 'Plugins/Sales/skills/pitch', status: OK },
33
+ { kind: 'integration', id: 'notion', name: 'Notion', description: '', owned: false, canWrite: false, plugin: 'GTM', path: 'Plugins/GTM/mcp.json', status: OK },
34
+ // A skill whose SKILL.md still declares the old governance keys. The cast
35
+ // is the point: `lifecycle` is no longer part of `LibraryItem`, and a server
36
+ // that still sends it must not change what the picker offers.
37
+ { kind: 'skill', id: 'legacy', name: 'legacy', description: 'Old but readable.', owned: false, canWrite: false, plugin: null, shared: true, plugins: [], path: 'Skills/Eng/legacy', status: OK, lifecycle: 'retired' } as LibraryItem,
38
+ ];
39
+
40
+ function renderPanel() {
41
+ const onLinked = vi.fn();
42
+ render(
43
+ <LibraryToastProvider>
44
+ <LinkSkillPanel plugin="GTM" items={items} onLinked={onLinked} />
45
+ </LibraryToastProvider>,
46
+ );
47
+ return { onLinked };
48
+ }
49
+
50
+ beforeEach(() => {
51
+ api.linkSkill.mockReset();
52
+ api.requestSkillAccess.mockReset();
53
+ });
54
+
55
+ describe('LinkSkillPanel', () => {
56
+ it('offers released skills not already in the plugin — never tools, never its own', () => {
57
+ renderPanel();
58
+ expect(screen.getByText('deploy')).toBeInTheDocument();
59
+ expect(screen.getByText('pitch')).toBeInTheDocument();
60
+ expect(screen.queryByText('outreach')).not.toBeInTheDocument();
61
+ expect(screen.queryByText('Notion')).not.toBeInTheDocument();
62
+ });
63
+
64
+ /**
65
+ * The picker used to hide skills declaring `metadata.lifecycle: retired`,
66
+ * mirroring a server refusal that no longer exists. Lifecycle is the
67
+ * authors' business now: the list offers every readable skill, and the key
68
+ * is ignored rather than acted on.
69
+ */
70
+ it('offers a skill whose frontmatter still says retired, like any other', () => {
71
+ renderPanel();
72
+ expect(screen.getByText('legacy')).toBeInTheDocument();
73
+ });
74
+
75
+ it('narrows by the search box', () => {
76
+ renderPanel();
77
+ fireEvent.change(screen.getByLabelText('Search skills to link'), { target: { value: 'pit' } });
78
+ expect(screen.queryByText('deploy')).not.toBeInTheDocument();
79
+ expect(screen.getByText('pitch')).toBeInTheDocument();
80
+ });
81
+
82
+ it('links by the skill\'s path and reports back', async () => {
83
+ api.linkSkill.mockResolvedValue({ root: 'Skills/Eng/deploy', skills: ['Skills/Eng/deploy'] });
84
+ const { onLinked } = renderPanel();
85
+ fireEvent.click(screen.getAllByRole('button', { name: 'Link' })[0]);
86
+ await waitFor(() => expect(api.linkSkill).toHaveBeenCalledWith('GTM', 'Skills/Eng/deploy'));
87
+ await waitFor(() => expect(onLinked).toHaveBeenCalled());
88
+ });
89
+
90
+ it('says it is linking while the commit is in flight — a greyed button reads as a freeze', async () => {
91
+ let settle: (v: { root: string; skills: string[] }) => void = () => undefined;
92
+ api.linkSkill.mockReturnValue(new Promise((resolve) => (settle = resolve)));
93
+ const { onLinked } = renderPanel();
94
+ fireEvent.click(screen.getAllByRole('button', { name: 'Link' })[0]);
95
+ // The clicked row says what is happening; the others wait, still saying Link.
96
+ const linking = await screen.findByRole('button', { name: 'Linking…' });
97
+ expect(linking).toBeDisabled();
98
+ for (const other of screen.getAllByRole('button', { name: 'Link' })) expect(other).toBeDisabled();
99
+ // A disabled button drops focus, so the word is ALSO in a live region
100
+ // that assistive tech reads out — and it clears once the link lands.
101
+ expect(screen.getByRole('status', { name: 'Link progress' })).toHaveTextContent('Linking deploy…');
102
+
103
+ settle({ root: 'Skills/Eng/deploy', skills: ['Skills/Eng/deploy'] });
104
+ await waitFor(() => expect(onLinked).toHaveBeenCalled());
105
+ expect(screen.getByRole('status', { name: 'Link progress' })).toHaveTextContent('');
106
+ });
107
+
108
+ it('turns the server\'s needs-skill-write refusal into a request, and says when it is sent', async () => {
109
+ api.linkSkill.mockRejectedValue(new NeedsSkillWriteError('Skills/Eng/deploy'));
110
+ api.requestSkillAccess.mockResolvedValue({ number: 7 });
111
+ const { onLinked } = renderPanel();
112
+ fireEvent.click(screen.getAllByRole('button', { name: 'Link' })[0]);
113
+ const request = await screen.findByRole('button', { name: 'Request write access' });
114
+ expect(onLinked).not.toHaveBeenCalled();
115
+ fireEvent.click(request);
116
+ await waitFor(() => expect(api.requestSkillAccess).toHaveBeenCalledWith('deploy'));
117
+ expect(await screen.findByText('Requested')).toBeInTheDocument();
118
+ });
119
+
120
+ it('announces a write-access request as a request, never as a link', async () => {
121
+ api.linkSkill.mockRejectedValue(new NeedsSkillWriteError('Skills/Eng/deploy'));
122
+ let settle: (v: { number: number }) => void = () => undefined;
123
+ api.requestSkillAccess.mockReturnValue(new Promise((resolve) => (settle = resolve)));
124
+ renderPanel();
125
+ fireEvent.click(screen.getAllByRole('button', { name: 'Link' })[0]);
126
+ fireEvent.click(await screen.findByRole('button', { name: 'Request write access' }));
127
+ // The same live region, the right words for THIS operation.
128
+ expect(await screen.findByRole('button', { name: 'Requesting…' })).toBeDisabled();
129
+ expect(screen.getByRole('status', { name: 'Link progress' })).toHaveTextContent('Requesting write access to deploy…');
130
+ expect(screen.getByRole('status', { name: 'Link progress' })).not.toHaveTextContent('Linking');
131
+
132
+ settle({ number: 7 });
133
+ expect(await screen.findByText('Requested')).toBeInTheDocument();
134
+ expect(screen.getByRole('status', { name: 'Link progress' })).toHaveTextContent('');
135
+ });
136
+ });
@@ -60,7 +60,8 @@ function renderLocked(plugin: PluginSummary = finance()) {
60
60
  return { ...view, onRequested, onUnlocked, onManage };
61
61
  }
62
62
 
63
- const askButton = () => screen.getByRole('button', { name: 'Subscribe to its skills and tools' });
63
+ const askButton = () => screen.getByRole('button', { name: 'Subscribe to this plugin' });
64
+ const pendingButton = () => screen.getByRole('button', { name: 'Requesting…' });
64
65
 
65
66
  describe('LockedPluginView', () => {
66
67
  beforeEach(() => {
@@ -74,12 +75,18 @@ describe('LockedPluginView', () => {
74
75
  expect(screen.getByText('Locked')).toBeInTheDocument();
75
76
  expect(screen.getByText('Run by Olga Ivanova.')).toBeInTheDocument();
76
77
  expect(screen.getByText('2 skills · 1 tool. Visible once you have access.')).toBeInTheDocument();
77
- expect(screen.getByRole('link', { name: 'All plugins' })).toHaveAttribute(
78
+ expect(screen.getByRole('link', { name: 'Everything' })).toHaveAttribute(
78
79
  'href',
79
80
  '/skills-and-tools',
80
81
  );
81
82
  });
82
83
 
84
+ it('calls the plugin by its display name — the same name the unlocked page uses', () => {
85
+ renderLocked(finance({ name: 'finance', displayName: 'Finance & Ops' }));
86
+ expect(screen.getByRole('heading', { name: 'Finance & Ops', level: 1 })).toBeInTheDocument();
87
+ expect(screen.queryByText('finance')).toBeNull();
88
+ });
89
+
83
90
  it('never leaks an address, even when the summary carries one', () => {
84
91
  // The backend nulls emails for non-readers; this asserts the view would not
85
92
  // print one if a future wire change ever handed it one anyway.
@@ -94,7 +101,7 @@ describe('LockedPluginView', () => {
94
101
  expect(screen.getByText('1 skill · 0 tools. Visible once you have access.')).toBeInTheDocument();
95
102
  });
96
103
 
97
- it('asks once, disables while in flight, and flips to the Requested box', async () => {
104
+ it('says "Requesting…" in the render after the click, refuses a second, and flips to the Requested box', async () => {
98
105
  let release = () => {};
99
106
  apiMock.requestPluginAccess.mockReturnValue(
100
107
  new Promise<void>((resolve) => {
@@ -104,8 +111,12 @@ describe('LockedPluginView', () => {
104
111
  const { onRequested } = renderLocked();
105
112
 
106
113
  fireEvent.click(askButton());
107
- expect(askButton()).toBeDisabled();
108
- fireEvent.click(askButton());
114
+ // The acknowledgement is the LABEL, not just the greying-out: the click
115
+ // used to leave a disabled button that still said "Subscribe", which is
116
+ // what read as a freeze for as long as the clone took.
117
+ expect(pendingButton()).toBeDisabled();
118
+ expect(screen.queryByRole('button', { name: 'Subscribe to this plugin' })).toBeNull();
119
+ fireEvent.click(pendingButton());
109
120
  expect(apiMock.requestPluginAccess).toHaveBeenCalledTimes(1);
110
121
  expect(apiMock.requestPluginAccess).toHaveBeenCalledWith('Finance');
111
122
 
@@ -114,7 +125,7 @@ describe('LockedPluginView', () => {
114
125
  await screen.findByText('Requested: Olga Ivanova decides who gets access.'),
115
126
  ).toBeInTheDocument();
116
127
  expect(
117
- screen.queryByRole('button', { name: 'Subscribe to its skills and tools' }),
128
+ screen.queryByRole('button', { name: 'Subscribe to this plugin' }),
118
129
  ).not.toBeInTheDocument();
119
130
  expect(onRequested).toHaveBeenCalledTimes(1);
120
131
  });
@@ -131,10 +142,58 @@ describe('LockedPluginView', () => {
131
142
  renderLocked(finance({ hasRequested: true }));
132
143
  expect(screen.getByText('Requested: Olga Ivanova decides who gets access.')).toBeInTheDocument();
133
144
  expect(
134
- screen.queryByRole('button', { name: 'Subscribe to its skills and tools' }),
145
+ screen.queryByRole('button', { name: 'Subscribe to this plugin' }),
135
146
  ).not.toBeInTheDocument();
136
147
  });
137
148
 
149
+ it('hands the button back with the reason when the background work failed', () => {
150
+ renderLocked(
151
+ finance({ hasRequested: false, requestFailure: 'the remote refused the push' }),
152
+ );
153
+ expect(
154
+ screen.getByText(
155
+ 'Your request to join Finance could not be sent: the remote refused the push. Try again.',
156
+ ),
157
+ ).toBeInTheDocument();
158
+ expect(askButton()).not.toBeDisabled();
159
+ expect(screen.queryByText(/^Requested/)).not.toBeInTheDocument();
160
+ });
161
+
162
+ it('names the plugin the way people read it in the failure sentence', () => {
163
+ renderLocked(
164
+ finance({ name: 'finance', displayName: 'Finance & Ops', requestFailure: 'the branch was refused' }),
165
+ );
166
+ expect(
167
+ screen.getByText(
168
+ 'Your request to join Finance & Ops could not be sent: the branch was refused. Try again.',
169
+ ),
170
+ ).toBeInTheDocument();
171
+ });
172
+
173
+ it('never shows a stale failure next to a standing request', () => {
174
+ // The two are mutually exclusive on the wire; the view does not rely on
175
+ // that, because a card saying "Requested" above a sentence saying it
176
+ // could not be sent is the one thing it must never render.
177
+ renderLocked(finance({ hasRequested: true, requestFailure: 'the remote refused the push' }));
178
+ expect(screen.getByText('Requested: Olga Ivanova decides who gets access.')).toBeInTheDocument();
179
+ expect(screen.queryByText(/could not be sent/)).toBeNull();
180
+ });
181
+
182
+ it('retrying after a failure asks again through the same endpoint', async () => {
183
+ const { onRequested } = renderLocked(
184
+ finance({ requestFailure: 'the remote refused the push' }),
185
+ );
186
+ fireEvent.click(askButton());
187
+ expect(apiMock.requestPluginAccess).toHaveBeenCalledWith('Finance');
188
+ // On the answer the card takes over — the failure sentence goes with the
189
+ // button it was explaining.
190
+ expect(
191
+ await screen.findByText('Requested: Olga Ivanova decides who gets access.'),
192
+ ).toBeInTheDocument();
193
+ expect(screen.queryByText(/could not be sent/)).toBeNull();
194
+ expect(onRequested).toHaveBeenCalledTimes(1);
195
+ });
196
+
138
197
  it('falls back to the admins, in the plural, when nobody is named', async () => {
139
198
  renderLocked(finance({ owners: { roles: [], users: [] }, writers: { roles: [], users: [] } }));
140
199
  expect(screen.getByText('Run by the workspace admins.')).toBeInTheDocument();
@@ -187,6 +246,43 @@ describe('LockedPluginView', () => {
187
246
  renderLocked();
188
247
  expect(screen.queryByRole('button', { name: 'Manage access' })).not.toBeInTheDocument();
189
248
  });
249
+
250
+ it('announces the in-flight request to a screen reader, not just on the button', async () => {
251
+ let release = () => {};
252
+ apiMock.requestPluginAccess.mockReturnValue(
253
+ new Promise<void>((resolve) => {
254
+ release = () => resolve();
255
+ }),
256
+ );
257
+ renderLocked(finance({ name: 'finance', displayName: 'Finance & Ops' }));
258
+
259
+ const live = screen.getByRole('status', { name: 'Request progress' });
260
+ expect(live).toHaveTextContent('');
261
+
262
+ fireEvent.click(askButton());
263
+ // Pressing the button disables it, and a disabled button drops focus —
264
+ // so the label change alone is never read out. The live region is what
265
+ // carries the acknowledgement this whole ticket exists to give.
266
+ expect(live).toHaveAttribute('aria-live', 'polite');
267
+ expect(live).toHaveTextContent('Requesting access to Finance & Ops…');
268
+
269
+ release();
270
+ await screen.findByText('Requested: Olga Ivanova decides who gets access.');
271
+
272
+ // AND IT STOPS. The success path never clears `requesting` — on purpose,
273
+ // so the button cannot flicker back to life between the answer and the
274
+ // Requested card — which left this region saying the request was still
275
+ // going for as long as the page stayed up. A screen-reader user reaching
276
+ // it after the card had rendered was told something untrue.
277
+ expect(screen.getByRole('status', { name: 'Request progress' })).toHaveTextContent('');
278
+ });
279
+
280
+ it('says nothing in the live region for a request that was already standing', () => {
281
+ // Arriving on a plugin already requested: there is no in-flight request
282
+ // to announce, so the region must be empty rather than describing one.
283
+ renderLocked(finance({ hasRequested: true }));
284
+ expect(screen.getByRole('status', { name: 'Request progress' })).toHaveTextContent('');
285
+ });
190
286
  });
191
287
 
192
288
  describe('name helpers', () => {