@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 } from 'vitest';
2
- import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
3
- import { MemoryRouter, Route, Routes } from 'react-router-dom';
2
+ import { render, screen, fireEvent, waitFor, act, within } from '@testing-library/react';
3
+ import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
4
4
  import {
5
5
  WorkspaceContext,
6
6
  type WorkspaceContextValue,
@@ -26,6 +26,7 @@ const apiMock = vi.hoisted(() => ({
26
26
  approvePrFile: vi.fn(),
27
27
  getOrCreateWorkspace: vi.fn(),
28
28
  writeFile: vi.fn(),
29
+ listSkillAccessRequests: vi.fn(async (): Promise<unknown[]> => []),
29
30
  }));
30
31
  vi.mock('../services/library.api', () => ({
31
32
  defaultWorkspaceId: () => 'target-company-state',
@@ -33,6 +34,11 @@ vi.mock('../services/library.api', () => ({
33
34
  getSkillFile: apiMock.getSkillFile,
34
35
  proposeChange: apiMock.proposeChange,
35
36
  listSkills: vi.fn(),
37
+ // The write-access request surface: nothing pending, nothing asked — unless
38
+ // a test puts a request on it.
39
+ listSkillAccessRequests: apiMock.listSkillAccessRequests,
40
+ reconcileSkillAccessRequest: vi.fn(async () => false),
41
+ requestSkillAccess: vi.fn(async () => ({ number: 1 })),
36
42
  // Real behaviour, not a stub: the page resolves the caller's own request by
37
43
  // this branch name, so a `vi.fn()` returning undefined would quietly disable
38
44
  // the very lookup these tests are checking.
@@ -51,6 +57,9 @@ vi.mock('../../change-requests/services/change-requests.api', () => ({
51
57
  listOpenChangeRequests: vi.fn(async () => []),
52
58
  listMyChangeRequests: vi.fn(async () => []),
53
59
  readFileOnBranch: apiMock.readFileOnBranch,
60
+ // No fork point: the change boxes fall back to the default branch, which is
61
+ // what these tests diff against.
62
+ readFileAtForkPoint: vi.fn(async () => ({ content: null, forkSha: null })),
54
63
  }));
55
64
  vi.mock('../../pr/services/pr-merge.api', () => ({ mergePullRequest: apiMock.mergePullRequest }));
56
65
  vi.mock('../../pr/services/pr-cancel.api', () => ({
@@ -62,9 +71,29 @@ vi.mock('../../pr/services/pr-detail.api', () => ({ fetchPrDetail: apiMock.fetch
62
71
  vi.mock('../../pr/services/pr-approvals.api', () => ({ approvePrFile: apiMock.approvePrFile }));
63
72
 
64
73
  // Keep the markdown pipeline (mermaid etc.) out of this test — the stub renders
65
- // the raw source so assertions can see the body text.
74
+ // the raw source so assertions can see the body text, plus two probes for the
75
+ // wiring the page hands the view: a click on a percent-encoded link, and what
76
+ // the image resolver answers for a picture beside the file.
66
77
  vi.mock('../../workspace/components/renderers/KbMarkdownView', () => ({
67
- KbMarkdownView: ({ source }: { source: string }) => <div data-testid="md-view">{source}</div>,
78
+ KbMarkdownView: ({
79
+ source,
80
+ onOpenFile,
81
+ resolveImage,
82
+ }: {
83
+ source: string;
84
+ onOpenFile: (href: string) => void;
85
+ resolveImage?: (src: string) => unknown;
86
+ }) => (
87
+ <div data-testid="md-view">
88
+ {source}
89
+ <button type="button" onClick={() => onOpenFile('Some%20File.md')}>
90
+ link-probe
91
+ </button>
92
+ <span data-testid="image-probe">
93
+ {JSON.stringify(resolveImage ? resolveImage('./assets/shot.png') : 'no-resolver')}
94
+ </span>
95
+ </div>
96
+ ),
68
97
  }));
69
98
 
70
99
  // The file bar's Edit-or-Propose decision asks the per-file access resolver.
@@ -77,11 +106,17 @@ const accessMock = vi.hoisted(() => ({
77
106
  owners: { roles: [], users: [] },
78
107
  },
79
108
  fetchFileAccess: vi.fn(),
109
+ // The Manage-access dialog's own calls — Share opens the real dialog.
110
+ grantAccess: vi.fn(),
111
+ suggestPrincipals: vi.fn(),
80
112
  }));
81
113
  accessMock.fetchFileAccess.mockImplementation(async () => accessMock.result);
82
- vi.mock('../../access/api', () => ({
114
+ vi.mock('../../access/api', async (importOriginal) => ({
115
+ ...(await importOriginal<object>()),
83
116
  fetchFileAccess: accessMock.fetchFileAccess,
84
117
  fetchFileAccessBatch: vi.fn(async () => ({ results: {} })),
118
+ grantAccess: accessMock.grantAccess,
119
+ suggestPrincipals: accessMock.suggestPrincipals,
85
120
  }));
86
121
 
87
122
  // The page reads the catalog through `useLibrary()`. Mocking the hook rather
@@ -177,7 +212,13 @@ const foreignCr = {
177
212
  url: '',
178
213
  } as unknown as PullRequestSummary;
179
214
 
180
- function libraryValue(owned: boolean, crs: PullRequestSummary[] = [], mine: number[] = []): LibraryContextValue {
215
+ function libraryValue(
216
+ owned: boolean,
217
+ crs: PullRequestSummary[] = [],
218
+ mine: number[] = [],
219
+ /** Write on SKILL.md — defaults to `owned`: an owner writes. */
220
+ canWrite: boolean = owned,
221
+ ): LibraryContextValue {
181
222
  return {
182
223
  crs,
183
224
  myCrNumbers: new Set(mine),
@@ -188,6 +229,7 @@ function libraryValue(owned: boolean, crs: PullRequestSummary[] = [], mine: numb
188
229
  name: 'newsletter',
189
230
  description: skillSummary.description,
190
231
  owned,
232
+ canWrite,
191
233
  plugin: null,
192
234
  path: skillSummary.path,
193
235
  status: { state: 'ok', text: '' },
@@ -197,6 +239,8 @@ function libraryValue(owned: boolean, crs: PullRequestSummary[] = [], mine: numb
197
239
  tools: [slackTool],
198
240
  allowedToolsBySkill: new Map([['newsletter', ['slack_post_message']]]),
199
241
  ownedSkills: owned ? new Set(['newsletter']) : new Set<string>(),
242
+ writableSkills: canWrite ? new Set(['newsletter']) : new Set<string>(),
243
+ ownedTools: new Set<string>(),
200
244
  loading: false,
201
245
  error: null,
202
246
  reload: () => {},
@@ -223,6 +267,9 @@ function makeFakeBus() {
223
267
  };
224
268
  },
225
269
  setFocus() {},
270
+ watchWorkspace() {
271
+ return () => {};
272
+ },
226
273
  emit(e) {
227
274
  (handlers[e.kind] ?? []).forEach((h) => h(e));
228
275
  },
@@ -242,9 +289,16 @@ function renderPage(
242
289
  pageProps?: { provisional?: boolean },
243
290
  /** Git state — overridden to test what the page does when there is no log. */
244
291
  gitValue: GitContextValue = git,
292
+ /** Workspace state — overridden to test the page before the KB dir is known. */
293
+ workspaceValue: WorkspaceContextValue = workspace,
245
294
  ) {
246
295
  libraryMock.value = { ...libraryValue(owned, crs, mine), ...library };
247
- return render(harness(bus, gitValue, routerState, pageProps));
296
+ return render(harness(bus, gitValue, routerState, pageProps, workspaceValue));
297
+ }
298
+
299
+ /** Where a link out of the page took the router: the Knowledge app's path. */
300
+ function NavigatedTo() {
301
+ return <div data-testid="navigated-to">{useLocation().pathname}</div>;
248
302
  }
249
303
 
250
304
  /**
@@ -282,6 +336,7 @@ function harness(
282
336
  gitValue: GitContextValue,
283
337
  routerState?: Record<string, unknown>,
284
338
  pageProps?: { provisional?: boolean },
339
+ workspaceValue: WorkspaceContextValue = workspace,
285
340
  ) {
286
341
  return (
287
342
  <MemoryRouter
@@ -290,7 +345,7 @@ function harness(
290
345
  ]}
291
346
  >
292
347
  <AuthContext.Provider value={auth}>
293
- <WorkspaceContext.Provider value={workspace}>
348
+ <WorkspaceContext.Provider value={workspaceValue}>
294
349
  <GitContext.Provider value={gitValue}>
295
350
  <EventBusContext.Provider value={bus}>
296
351
  {/* The real toast provider: the success message IS the page's
@@ -302,6 +357,7 @@ function harness(
302
357
  path="/skills-and-tools/skills/:name"
303
358
  element={<SkillPage {...(pageProps ?? {})} />}
304
359
  />
360
+ <Route path="/workspace/*" element={<NavigatedTo />} />
305
361
  </Routes>
306
362
  </LibraryToastProvider>
307
363
  </EventBusContext.Provider>
@@ -349,6 +405,7 @@ beforeEach(() => {
349
405
  isApproved: false,
350
406
  approvedBy: [],
351
407
  eligibleApprovers: { roles: ['Newsroom'], users: [] },
408
+ inMergeGate: true,
352
409
  },
353
410
  ],
354
411
  });
@@ -368,7 +425,9 @@ describe('SkillPage', () => {
368
425
  expect(apiMock.getSkill).toHaveBeenCalledWith('newsletter');
369
426
 
370
427
  // Needed integration derived from allowed-tools, with its connection state.
371
- expect(screen.getByText('slack')).toBeInTheDocument();
428
+ // Its own load, not the heading's: awaited, or a slow runner sees the
429
+ // heading before the integrations have resolved.
430
+ expect(await screen.findByText('slack')).toBeInTheDocument();
372
431
  expect(screen.getByText('Needs your sign-in')).toBeInTheDocument();
373
432
  expect(screen.getByRole('button', { name: /Connect/ })).toBeInTheDocument();
374
433
 
@@ -495,14 +554,11 @@ describe('SkillPage', () => {
495
554
  );
496
555
  });
497
556
 
498
- it('shows the Owner badge to an owner. But never access', async () => {
557
+ it('shows the Owner badge to an owner', async () => {
499
558
  renderPage(true);
500
559
  await screen.findByRole('heading', { name: 'newsletter' });
501
560
 
502
561
  expect(screen.getByText('Owner')).toBeInTheDocument();
503
- // A skill inherits its plugin folder's rules; the plugin's Share panel is the
504
- // one place they are decided, for owner and non-owner alike.
505
- expect(screen.queryByRole('button', { name: 'Manage access' })).toBeNull();
506
562
  });
507
563
 
508
564
  it('hides the Owner badge from non-owners', async () => {
@@ -512,6 +568,25 @@ describe('SkillPage', () => {
512
568
  expect(screen.queryByText('Owner')).toBeNull();
513
569
  });
514
570
 
571
+ /**
572
+ * The pill is ownership; the editor-side verbs are write. A writer who is
573
+ * not in the `owner:` grant — an Admin by role — loses the pill and keeps
574
+ * every one of them: the dock, and the verdict on someone else's change.
575
+ */
576
+ it('hides the Owner badge from a writer who is not an owner, and keeps their editor affordances', async () => {
577
+ const writer = libraryValue(false, [foreignCr], [], true);
578
+ renderPage(false, [foreignCr], [], makeFakeBus(), undefined, {
579
+ items: writer.items,
580
+ writableSkills: writer.writableSkills,
581
+ });
582
+
583
+ expect(
584
+ await screen.findByRole('complementary', { name: 'Change requests for this skill' }),
585
+ ).toBeInTheDocument();
586
+ expect(await screen.findByRole('button', { name: 'Approve' })).toBeInTheDocument();
587
+ expect(screen.queryByText('Owner')).toBeNull();
588
+ });
589
+
515
590
  /**
516
591
  * One way to change a skill, for everyone. A direct-to-`main` `Edit` used to
517
592
  * sit beside Propose; it bypassed review and, on a protected branch, usually
@@ -584,6 +659,83 @@ describe('SkillPage', () => {
584
659
  expect(apiMock.proposeChange).not.toHaveBeenCalled();
585
660
  });
586
661
 
662
+ it('a save whose allowed-tools name unknown platform tools lands, and says so in the status area', async () => {
663
+ accessMock.result = {
664
+ canWrite: true,
665
+ eligible: { roles: [], users: [] },
666
+ owners: { roles: [], users: [] },
667
+ };
668
+ apiMock.getOrCreateWorkspace.mockResolvedValue({
669
+ workspace: { id: 'target-company-state', kbDirName: 'knowledge-base' },
670
+ });
671
+ apiMock.writeFile.mockResolvedValue({
672
+ warnings: [
673
+ {
674
+ entry: 'hubspot.serch',
675
+ message: '"hubspot.serch" in allowed-tools is not a tool you can use here. Did you mean "hubspot.search"?',
676
+ suggestion: 'hubspot.search',
677
+ },
678
+ ],
679
+ });
680
+ renderPage(true);
681
+
682
+ fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
683
+ const box = await screen.findByRole('textbox', { name: 'Edit SKILL.md' });
684
+ fireEvent.change(box, { target: { value: '---\nallowed-tools: Bash hubspot.serch\n---\n' } });
685
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));
686
+
687
+ // Never a block: the save still closes the editor and confirms.
688
+ expect(await screen.findByText(/Saved: the skill now reads with your change/)).toBeInTheDocument();
689
+ const status = (await screen.findByText('Some tools this skill lists are not available')).closest('[role="status"]');
690
+ expect(status).not.toBeNull();
691
+ expect(within(status as HTMLElement).getByText(/Did you mean "hubspot.search"/)).toBeInTheDocument();
692
+ expect(screen.queryByRole('textbox', { name: 'Edit SKILL.md' })).toBeNull();
693
+ });
694
+
695
+ it('warnings the skill already carries show on open, before any save', async () => {
696
+ // A manual retired after the skill was written: nobody saved anything, so
697
+ // the only way the page can know is from the skill it loads.
698
+ apiMock.getSkill.mockResolvedValue({
699
+ ...skillDetail,
700
+ warnings: [{ entry: 'legacy_crm', message: '"legacy_crm" in allowed-tools is not a tool you can use here.' }],
701
+ });
702
+ renderPage(true);
703
+
704
+ const status = (await screen.findByText('Some tools this skill lists are not available')).closest('[role="status"]');
705
+ expect(status).not.toBeNull();
706
+ expect(within(status as HTMLElement).getByText(/"legacy_crm" in allowed-tools/)).toBeInTheDocument();
707
+ });
708
+
709
+ it('saving a bundled file leaves the loaded warnings in place', async () => {
710
+ // Only a SKILL.md save has an answer about allowed-tools. A bundled file's
711
+ // save answers with none, and taking that for "none" would clear a banner
712
+ // that is about the skill, not about sources.yaml.
713
+ accessMock.result = {
714
+ canWrite: true,
715
+ eligible: { roles: [], users: [] },
716
+ owners: { roles: [], users: [] },
717
+ };
718
+ apiMock.getOrCreateWorkspace.mockResolvedValue({
719
+ workspace: { id: 'target-company-state', kbDirName: 'knowledge-base' },
720
+ });
721
+ apiMock.writeFile.mockResolvedValue({});
722
+ apiMock.getSkill.mockResolvedValue({
723
+ ...skillDetail,
724
+ warnings: [{ entry: 'legacy_crm', message: '"legacy_crm" in allowed-tools is not a tool you can use here.' }],
725
+ });
726
+ renderPage(true);
727
+ await screen.findByText('Some tools this skill lists are not available');
728
+
729
+ fireEvent.click(screen.getByRole('tab', { name: 'sources.yaml' }));
730
+ fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
731
+ const box = await screen.findByRole('textbox', { name: 'Edit sources.yaml' });
732
+ fireEvent.change(box, { target: { value: 'watchlist:\n - topic: robotics\n' } });
733
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));
734
+
735
+ expect(await screen.findByText(/Saved: the skill now reads with your change/)).toBeInTheDocument();
736
+ expect(screen.getByText('Some tools this skill lists are not available')).toBeInTheDocument();
737
+ });
738
+
587
739
  it('arriving with startEditing in router state opens the editor without a click', async () => {
588
740
  // The creation hand-off: NewSkillPanel navigates here with the flag, so
589
741
  // the person who just made an empty skill lands with the cursor in it.
@@ -637,7 +789,7 @@ describe('SkillPage', () => {
637
789
  expect(screen.getByTestId('file-pane-card')).toBeInTheDocument();
638
790
  expect(screen.getByText('Loading…')).toBeInTheDocument();
639
791
  expect(panel).toHaveAttribute('aria-busy', 'true');
640
- expect(screen.getByRole('button', { name: /All skills & tools/ })).toBeInTheDocument();
792
+ expect(screen.getByRole('button', { name: /Everything/ })).toBeInTheDocument();
641
793
 
642
794
  await act(async () => {
643
795
  resolveSkill(skillDetail);
@@ -876,7 +1028,7 @@ describe('SkillPage: deciding on a change', () => {
876
1028
  renderPage(true, [foreignCr]);
877
1029
 
878
1030
  const approve = await screen.findByRole('button', { name: 'Approve' });
879
- expect(screen.getByText('You decide. You own this.')).toBeInTheDocument();
1031
+ expect(screen.getByText('You can decide this.')).toBeInTheDocument();
880
1032
 
881
1033
  fireEvent.click(approve);
882
1034
 
@@ -904,12 +1056,14 @@ describe('SkillPage: deciding on a change', () => {
904
1056
  isApproved: false,
905
1057
  approvedBy: [],
906
1058
  eligibleApprovers: { roles: ['Newsroom'], users: [] },
1059
+ inMergeGate: true,
907
1060
  },
908
1061
  {
909
1062
  path: 'Skills/newsletter/sources.yaml',
910
1063
  isApproved: false,
911
1064
  approvedBy: [],
912
1065
  eligibleApprovers: { roles: [], users: [] },
1066
+ inMergeGate: false,
913
1067
  },
914
1068
  ],
915
1069
  });
@@ -1171,16 +1325,17 @@ describe('SkillPage: deciding on a change', () => {
1171
1325
  * A skill is a file in the repository, and this page is the ONLY surface it
1172
1326
  * has: the shell routes every default-branch `Plugins/` URL here
1173
1327
  * (`isLibraryLocation`) and the Knowledge tree does not list `Plugins/` at
1174
- * all, so a `⋯` missing here means the git log for every skill in the
1175
- * deployment is unreachable — the audit trail the product is sold on,
1176
- * available for Knowledge pages and for nothing else.
1328
+ * all, so a Version history button missing here means the git log for every
1329
+ * skill in the deployment is unreachable — the audit trail the product is
1330
+ * sold on, available for Knowledge pages and for nothing else. The button
1331
+ * is the clock-arrow beside Edit in the file bar, the same placement the
1332
+ * Knowledge pane uses.
1177
1333
  */
1178
1334
  describe('version history', () => {
1179
1335
  it('opens the log for the file on screen, at its workspace path', async () => {
1180
1336
  renderPage(false);
1181
1337
 
1182
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1183
- fireEvent.click(screen.getByRole('menuitem', { name: 'Version history' }));
1338
+ fireEvent.click(await screen.findByRole('button', { name: 'Version history' }));
1184
1339
 
1185
1340
  // The path the panel asks git about is the workspace-relative one the
1186
1341
  // Knowledge viewer would hand it — kbDirName included. Getting this
@@ -1194,13 +1349,41 @@ describe('SkillPage: deciding on a change', () => {
1194
1349
  // And there is a way back, because history is not in the URL.
1195
1350
  fireEvent.click(screen.getByRole('button', { name: 'Back to the file' }));
1196
1351
  expect(await screen.findByTestId('md-view')).toBeInTheDocument();
1352
+ // The activated Back button unmounts with history. Hand keyboard focus
1353
+ // to the replacement clock instead of letting it fall to the document.
1354
+ expect(screen.getByRole('button', { name: 'Version history' })).toHaveFocus();
1355
+ });
1356
+
1357
+ /**
1358
+ * The file bar leaves with the file, and the clock with it; the history
1359
+ * view draws the same clock pressed beside its Back link, so the control
1360
+ * that opened the view is still on screen and is the other way back.
1361
+ */
1362
+ it('keeps a pressed clock on screen while the log is open, and it closes the log', async () => {
1363
+ renderPage(false);
1364
+
1365
+ fireEvent.click(await screen.findByRole('button', { name: 'Version history' }));
1366
+ await screen.findByText(/^Timeline:/);
1367
+
1368
+ const pressed = screen.getByRole('button', { name: 'Version history' });
1369
+ expect(pressed).toHaveAttribute('aria-pressed', 'true');
1370
+ // The bar's clock unmounted with the bar; a keyboard user's focus lands
1371
+ // on the pressed clock, not on `document`.
1372
+ expect(document.activeElement).toBe(pressed);
1373
+
1374
+ fireEvent.click(pressed);
1375
+ expect(screen.queryByText(/^Timeline:/)).toBeNull();
1376
+ expect(await screen.findByTestId('md-view')).toBeInTheDocument();
1377
+ const paneClock = screen.getByRole('button', { name: 'Version history' });
1378
+ expect(paneClock).not.toHaveAttribute('aria-pressed', 'true');
1379
+ // And back again: the pressed clock unmounted with the log.
1380
+ expect(document.activeElement).toBe(paneClock);
1197
1381
  });
1198
1382
 
1199
1383
  it('does not follow you to another file of the skill', async () => {
1200
1384
  renderPage(false);
1201
1385
 
1202
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1203
- fireEvent.click(screen.getByRole('menuitem', { name: 'Version history' }));
1386
+ fireEvent.click(await screen.findByRole('button', { name: 'Version history' }));
1204
1387
  await screen.findByText('Timeline: knowledge-base/Skills/newsletter/SKILL.md');
1205
1388
 
1206
1389
  // A tab switch is a switch of file, and history is a lens on ONE file.
@@ -1234,11 +1417,11 @@ describe('SkillPage: deciding on a change', () => {
1234
1417
 
1235
1418
  fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
1236
1419
  await screen.findByRole('textbox', { name: /Edit SKILL\.md/ });
1237
- expect(screen.queryByRole('button', { name: 'More actions' })).toBeNull();
1420
+ expect(screen.queryByRole('button', { name: 'Version history' })).toBeNull();
1238
1421
 
1239
1422
  // It comes back the moment the draft is gone.
1240
1423
  fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
1241
- expect(await screen.findByRole('button', { name: 'More actions' })).toBeInTheDocument();
1424
+ expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
1242
1425
  });
1243
1426
 
1244
1427
  /**
@@ -1250,8 +1433,7 @@ describe('SkillPage: deciding on a change', () => {
1250
1433
  it('closes for good when git stops answering mid-read', async () => {
1251
1434
  const bus = makeFakeBus();
1252
1435
  const { rerender } = renderPage(false, [], [], bus);
1253
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1254
- fireEvent.click(screen.getByRole('menuitem', { name: 'Version history' }));
1436
+ fireEvent.click(await screen.findByRole('button', { name: 'Version history' }));
1255
1437
  await screen.findByText(/^Timeline:/);
1256
1438
 
1257
1439
  // A poll fails: the log goes away, and so does its trigger.
@@ -1262,69 +1444,200 @@ describe('SkillPage: deciding on a change', () => {
1262
1444
  rerender(harness(bus, git));
1263
1445
  expect(await screen.findByTestId('md-view')).toBeInTheDocument();
1264
1446
  expect(screen.queryByText(/^Timeline:/)).toBeNull();
1265
- expect(screen.getByRole('button', { name: 'More actions' })).toBeInTheDocument();
1447
+ expect(screen.getByRole('button', { name: 'Version history' })).toBeInTheDocument();
1266
1448
  });
1267
1449
 
1268
- /**
1269
- * The MENU flag needs the same treatment as the log's, and it is a
1270
- * separate flag: the trigger and its panel both live behind
1271
- * `historyAvailable`, so an open menu unmounts with them and leaves its
1272
- * flag set behind an element nobody can see. Found by cubic on #103.
1273
- */
1274
- it('does not spring the menu back open when git recovers', async () => {
1275
- const bus = makeFakeBus();
1276
- const { rerender } = renderPage(false, [], [], bus);
1277
- const trigger = await screen.findByRole('button', { name: 'More actions' });
1278
- fireEvent.click(trigger);
1279
- expect(screen.getByRole('menuitem', { name: 'Version history' })).toBeInTheDocument();
1450
+ it('has no trigger at all when git cannot answer', async () => {
1451
+ renderPage(false, [], [], makeFakeBus(), undefined, undefined, undefined, {
1452
+ ...git,
1453
+ availability: 'loading',
1454
+ } as GitContextValue);
1280
1455
 
1281
- // A poll fails while the menu is OPEN — trigger and panel go together.
1282
- rerender(harness(bus, { ...git, availability: 'error' } as GitContextValue));
1283
- expect(screen.queryByRole('button', { name: 'More actions' })).toBeNull();
1456
+ // No log means no button — a clock that opens onto nothing is worse
1457
+ // than none.
1458
+ expect(await screen.findByRole('heading', { name: 'newsletter' })).toBeInTheDocument();
1459
+ expect(screen.queryByRole('button', { name: 'Version history' })).toBeNull();
1460
+ });
1461
+ });
1462
+ });
1284
1463
 
1285
- // The next poll succeeds. The trigger is back, and it is CLOSED.
1286
- rerender(harness(bus, git));
1287
- const back = await screen.findByRole('button', { name: 'More actions' });
1288
- expect(back).toHaveAttribute('aria-expanded', 'false');
1289
- expect(screen.queryByRole('menuitem', { name: 'Version history' })).toBeNull();
1464
+ /**
1465
+ * Links and images in the rendered file. The view is stubbed above, so its
1466
+ * probes stand in for a click on a link and for the pipeline's `<img>`; what
1467
+ * is under test is what the PAGE hands the view.
1468
+ */
1469
+ describe('SkillPage: links and images in the file', () => {
1470
+ it('opens a percent-encoded link as the file it names, on the default branch', async () => {
1471
+ // The drift this fixes: the page used to resolve the href undecoded, so a
1472
+ // link written `Some File.md` opened `Some%20File.md`, a file that is not there.
1473
+ renderPage(false);
1474
+ await settled();
1475
+ fireEvent.click(screen.getByRole('button', { name: 'link-probe' }));
1476
+ const target = await screen.findByTestId('navigated-to');
1477
+ expect(target.textContent).toMatch(
1478
+ new RegExp(
1479
+ `^/workspace/${encodeURIComponent(DEFAULT_BRANCH)}/knowledge-base/Skills/newsletter/Some(%20| )File\\.md$`,
1480
+ ),
1481
+ );
1482
+ });
1483
+
1484
+ it("serves a relative image from the default branch's workspace, under the skill folder", async () => {
1485
+ renderPage(false);
1486
+ await settled();
1487
+ expect(JSON.parse(screen.getByTestId('image-probe').textContent ?? 'null')).toEqual({
1488
+ src: `/api/workspace/${encodeURIComponent(DEFAULT_BRANCH)}/file/raw?path=knowledge-base%2FSkills%2Fnewsletter%2Fassets%2Fshot.png`,
1489
+ path: 'knowledge-base/Skills/newsletter/assets/shot.png',
1290
1490
  });
1491
+ });
1291
1492
 
1292
- /**
1293
- * `editing` is the same state by a second door, and it is reachable
1294
- * without a mouse: `useDismissableMenu` dismisses on outside POINTERDOWN,
1295
- * so tabbing from the open menu to Edit and pressing Enter never dismisses
1296
- * it. Cancel then used to hand the menu back open over the file.
1297
- */
1298
- it('does not spring the menu back open when the editor closes', async () => {
1299
- accessMock.result = {
1300
- canWrite: true,
1301
- eligible: { roles: [], users: [] },
1302
- owners: { roles: [], users: [] },
1303
- };
1304
- renderPage(true);
1305
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1306
- expect(screen.getByRole('menuitem', { name: 'Version history' })).toBeInTheDocument();
1493
+ it('hands the view no resolver before the workspace has named its KB dir', async () => {
1494
+ renderPage(false, [], [], makeFakeBus(), undefined, undefined, undefined, git, {
1495
+ workspaceId: 'target-company-state',
1496
+ kbDirName: null,
1497
+ } as unknown as WorkspaceContextValue);
1498
+ await settled();
1499
+ expect(screen.getByTestId('image-probe').textContent).toBe('"no-resolver"');
1500
+ });
1501
+ });
1307
1502
 
1308
- // Reached by keyboard, so no outside pointerdown ever dismissed the menu.
1309
- fireEvent.click(screen.getByRole('button', { name: 'Edit' }));
1310
- await screen.findByRole('textbox', { name: /Edit SKILL\.md/ });
1311
- fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
1503
+ /**
1504
+ * Share manages the SKILL's folder: the real Manage-access dialog (not a stub
1505
+ * — the grant it sends is the point), pinned to the default branch, on the
1506
+ * folder the skill lives in whether or not a plugin holds it.
1507
+ */
1508
+ describe('SkillPage: Share', () => {
1509
+ const MAIN = encodeURIComponent(DEFAULT_BRANCH);
1510
+ /** Enough of the resolver's answer for the dialog to render and to grant. */
1511
+ const FOLDER_VIEW = {
1512
+ canRead: true,
1513
+ canWrite: true,
1514
+ canDownload: false,
1515
+ canOwner: false,
1516
+ eligible: { roles: [], users: [] },
1517
+ readers: { restricted: true, roles: [], users: [] },
1518
+ owners: { roles: [], users: [] },
1519
+ downloaders: { roles: [], users: [] },
1520
+ sources: {},
1521
+ };
1312
1522
 
1313
- const back = await screen.findByRole('button', { name: 'More actions' });
1314
- expect(back).toHaveAttribute('aria-expanded', 'false');
1315
- expect(screen.queryByRole('menuitem', { name: 'Version history' })).toBeNull();
1523
+ beforeEach(() => {
1524
+ accessMock.result = FOLDER_VIEW as typeof accessMock.result;
1525
+ accessMock.fetchFileAccess.mockClear();
1526
+ accessMock.grantAccess.mockReset().mockResolvedValue(FOLDER_VIEW);
1527
+ accessMock.suggestPrincipals.mockReset().mockResolvedValue({
1528
+ roles: [],
1529
+ groups: ['GTM Team'],
1530
+ people: [],
1531
+ peopleWithheld: false,
1316
1532
  });
1533
+ apiMock.listSkillAccessRequests.mockReset().mockResolvedValue([]);
1534
+ });
1317
1535
 
1318
- it('has no trigger at all when git cannot answer', async () => {
1319
- renderPage(false, [], [], makeFakeBus(), undefined, undefined, undefined, {
1320
- ...git,
1321
- availability: 'loading',
1322
- } as GitContextValue);
1536
+ it('a standalone skill offers Share, and it opens Manage access on the skill folder', async () => {
1537
+ renderPage(false);
1538
+ await settled();
1539
+ expect(screen.queryByRole('dialog')).toBeNull();
1323
1540
 
1324
- // Version history is the whole menu, so no log means no `⋯` — an
1325
- // overflow opening onto an empty panel is worse than no overflow.
1326
- expect(await screen.findByRole('heading', { name: 'newsletter' })).toBeInTheDocument();
1327
- expect(screen.queryByRole('button', { name: 'More actions' })).toBeNull();
1541
+ fireEvent.click(screen.getByRole('button', { name: 'Share' }));
1542
+
1543
+ expect(await screen.findByRole('dialog', { name: 'Manage access' })).toBeInTheDocument();
1544
+ await waitFor(() =>
1545
+ expect(accessMock.fetchFileAccess).toHaveBeenCalledWith(MAIN, 'Skills/newsletter', 'folder'),
1546
+ );
1547
+ });
1548
+
1549
+ it("a plugin-bundled skill offers Share on ITS folder, not the plugin's", async () => {
1550
+ const path = 'Plugins/newsroom/skills/newsletter';
1551
+ apiMock.getSkill.mockResolvedValue({ ...skillDetail, path, files: [`${path}/sources.yaml`] });
1552
+ renderPage(false, [], [], makeFakeBus(), undefined, {
1553
+ items: libraryValue(false).items.map((i) => ({ ...i, path, plugin: 'newsroom' })),
1554
+ skills: [{ ...skillSummary, path }],
1555
+ });
1556
+ await settled();
1557
+
1558
+ fireEvent.click(screen.getByRole('button', { name: 'Share' }));
1559
+
1560
+ expect(await screen.findByRole('dialog', { name: 'Manage access' })).toBeInTheDocument();
1561
+ await waitFor(() =>
1562
+ expect(accessMock.fetchFileAccess).toHaveBeenCalledWith(MAIN, path, 'folder'),
1563
+ );
1564
+ expect(accessMock.fetchFileAccess).not.toHaveBeenCalledWith(
1565
+ expect.anything(),
1566
+ 'Plugins/newsroom',
1567
+ 'folder',
1568
+ );
1569
+ });
1570
+
1571
+ it('a grant from Share is the ordinary FOLDER grant on the skill folder — the one that creates access.md', async () => {
1572
+ // The backend half — the first folder grant writes `access.md`, later ones
1573
+ // edit it — is `access-mutation.service.test.ts`. What the page owns is
1574
+ // sending THAT request: kind folder, the skill's folder, the default
1575
+ // branch. The path goes out workspace-relative, as from every other
1576
+ // surface; the grant route strips the KB dir.
1577
+ renderPage(true);
1578
+ await settled();
1579
+ fireEvent.click(screen.getByRole('button', { name: 'Share' }));
1580
+ const dialog = await screen.findByRole('dialog', { name: 'Manage access' });
1581
+
1582
+ fireEvent.change(await screen.findByPlaceholderText(/add people, groups, roles or plugins/i), {
1583
+ target: { value: 'gtm' },
1328
1584
  });
1585
+ fireEvent.click(await screen.findByRole('button', { name: /GTM Team/ }));
1586
+ fireEvent.click(within(dialog).getByRole('button', { name: /^Share$/ }));
1587
+
1588
+ await waitFor(() =>
1589
+ expect(accessMock.grantAccess).toHaveBeenCalledWith(
1590
+ MAIN,
1591
+ expect.objectContaining({
1592
+ path: 'knowledge-base/Skills/newsletter',
1593
+ kind: 'folder',
1594
+ principal: { kind: 'group', group: 'GTM Team' },
1595
+ }),
1596
+ ),
1597
+ );
1598
+ });
1599
+
1600
+ it("the access-requests banner's Manage access still opens the same, single dialog", async () => {
1601
+ apiMock.listSkillAccessRequests.mockResolvedValue([
1602
+ {
1603
+ number: 3,
1604
+ branch: 'access/olga/newsletter',
1605
+ requesterName: 'Olga Martin',
1606
+ createdAt: new Date().toISOString(),
1607
+ proposals: [
1608
+ {
1609
+ verb: 'write',
1610
+ id: 'olga@x.com',
1611
+ principal: { kind: 'user', email: 'olga@x.com', displayName: 'Olga Martin' },
1612
+ label: 'Olga Martin',
1613
+ },
1614
+ ],
1615
+ },
1616
+ ]);
1617
+ renderPage(true);
1618
+ await settled();
1619
+
1620
+ fireEvent.click(await screen.findByRole('button', { name: 'Manage access' }));
1621
+ const dialog = await screen.findByRole('dialog', { name: 'Manage access' });
1622
+ await waitFor(() =>
1623
+ expect(accessMock.fetchFileAccess).toHaveBeenCalledWith(MAIN, 'Skills/newsletter', 'folder'),
1624
+ );
1625
+
1626
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Done' }));
1627
+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
1628
+
1629
+ // The other door, onto the same dialog — never a second one.
1630
+ fireEvent.click(screen.getByRole('button', { name: 'Share' }));
1631
+ await screen.findByRole('dialog', { name: 'Manage access' });
1632
+ expect(screen.getAllByRole('dialog')).toHaveLength(1);
1633
+ });
1634
+
1635
+ it('offers no Share before the KB dir is known. There is no folder path to hand over yet', async () => {
1636
+ renderPage(false, [], [], makeFakeBus(), undefined, undefined, undefined, git, {
1637
+ workspaceId: 'target-company-state',
1638
+ kbDirName: null,
1639
+ } as unknown as WorkspaceContextValue);
1640
+ await settled();
1641
+ expect(screen.queryByRole('button', { name: 'Share' })).toBeNull();
1329
1642
  });
1330
1643
  });