@bevel-software/platform-core-frontend 0.15.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +20 -9
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/events.test.ts +43 -0
  6. package/src/core/bootstrap.ts +11 -3
  7. package/src/core/events.ts +85 -3
  8. package/src/core/registry.ts +1 -1
  9. package/src/lib/__tests__/email.test.ts +44 -0
  10. package/src/lib/email.ts +37 -1
  11. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  12. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  13. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  16. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  20. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
  21. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  22. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  23. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  24. package/src/modules/access/api.ts +140 -6
  25. package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
  26. package/src/modules/access/manage-access-affordance.ts +17 -0
  27. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  28. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  29. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  30. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  31. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  32. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  33. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  34. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  35. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  36. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  37. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  38. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  39. package/src/modules/admin/components/group-members-path.ts +32 -0
  40. package/src/modules/admin/services/roles.api.ts +12 -1
  41. package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
  42. package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
  43. package/src/modules/audit/components/AuditLogPage.tsx +373 -0
  44. package/src/modules/audit/components/principal-grouping.ts +49 -0
  45. package/src/modules/audit/services/audit.api.ts +98 -0
  46. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  47. package/src/modules/auth/components/AccountPage.tsx +73 -54
  48. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  49. package/src/modules/auth/services/account.api.ts +78 -4
  50. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  51. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  52. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  53. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  58. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  59. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  60. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  61. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  62. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  63. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  64. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  65. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  66. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  67. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  68. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  69. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  70. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  71. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  72. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  73. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  74. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  75. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  76. package/src/modules/change-requests/services/propose.api.ts +97 -8
  77. package/src/modules/change-requests/utils/approval.ts +15 -0
  78. package/src/modules/change-requests/utils/author.ts +32 -0
  79. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  80. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  81. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  82. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  83. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  84. package/src/modules/git/services/error-messages.ts +12 -0
  85. package/src/modules/git/services/pr-prompts.ts +5 -5
  86. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  87. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  88. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  89. package/src/modules/layout/components/AppLayout.tsx +2 -0
  90. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  91. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  92. package/src/modules/layout/components/SidebarFrame.tsx +108 -3
  93. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  94. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  95. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  96. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  97. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  98. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
  99. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
  100. package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
  101. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
  102. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  103. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  104. package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
  105. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  106. package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
  107. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
  108. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
  109. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  110. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  111. package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
  112. package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
  113. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  114. package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
  115. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
  116. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  117. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  118. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  119. package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
  120. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  121. package/src/modules/library/__tests__/library-paths.test.ts +47 -4
  122. package/src/modules/library/__tests__/link-membership.test.ts +13 -4
  123. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  124. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  125. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  126. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  127. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  128. package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
  129. package/src/modules/library/__tests__/status.test.ts +82 -2
  130. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  131. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  132. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  133. package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
  134. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  135. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  136. package/src/modules/library/components/LibraryCard.tsx +146 -45
  137. package/src/modules/library/components/LibraryLayout.tsx +119 -256
  138. package/src/modules/library/components/LibraryPage.tsx +172 -39
  139. package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
  140. package/src/modules/library/components/LockedPluginView.tsx +62 -34
  141. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  142. package/src/modules/library/components/NewPluginDialog.tsx +16 -2
  143. package/src/modules/library/components/PageActions.tsx +11 -9
  144. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  145. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  146. package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
  147. package/src/modules/library/components/PluginExtras.tsx +140 -17
  148. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  149. package/src/modules/library/components/PluginPage.tsx +157 -41
  150. package/src/modules/library/components/PluginRows.tsx +286 -0
  151. package/src/modules/library/components/PluginsSidebar.tsx +239 -263
  152. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  153. package/src/modules/library/components/ShareButton.tsx +17 -0
  154. package/src/modules/library/components/SkillsTree.tsx +141 -28
  155. package/src/modules/library/components/TeamRoute.tsx +15 -0
  156. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  157. package/src/modules/library/components/plugin-page-parts.tsx +103 -17
  158. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
  159. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  160. package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
  161. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  162. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  163. package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
  164. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  165. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  166. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  167. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  168. package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
  169. package/src/modules/library/routes/library-paths.ts +26 -28
  170. package/src/modules/library/services/library.api.ts +38 -20
  171. package/src/modules/library/services/plugins.api.ts +69 -8
  172. package/src/modules/library/services/teams.api.ts +15 -0
  173. package/src/modules/library/services/tools.api.ts +78 -0
  174. package/src/modules/library/state/library-data.tsx +170 -32
  175. package/src/modules/library/utils/personal-plugin.ts +13 -15
  176. package/src/modules/library/utils/plugin-entries.ts +134 -0
  177. package/src/modules/library/utils/plugin-summary.ts +75 -9
  178. package/src/modules/library/utils/status.ts +135 -33
  179. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
  180. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  181. package/src/modules/onboarding/agent-clients.ts +55 -23
  182. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  183. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  184. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  185. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  186. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  187. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  188. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  189. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  190. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  191. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  192. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  193. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  194. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  195. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  196. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  197. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  198. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  199. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  200. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  201. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  202. package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
  203. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  204. package/src/modules/settings/components/DeploymentPage.tsx +10 -30
  205. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  206. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
  207. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  208. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
  209. package/src/modules/settings/services/github-facade.api.ts +23 -0
  210. package/src/modules/settings/settings-nav-items.tsx +13 -3
  211. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  212. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  213. package/src/modules/setup/__tests__/setup.test.tsx +497 -4
  214. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  215. package/src/modules/setup/components/SetupGate.tsx +16 -16
  216. package/src/modules/setup/components/SetupScreen.tsx +532 -43
  217. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  218. package/src/modules/setup/services/setup.api.ts +141 -4
  219. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  220. package/src/modules/setup/utils/root-folders.ts +46 -0
  221. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  222. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  223. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  224. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  225. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  226. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  227. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  228. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  229. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  230. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  231. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  232. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  233. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  234. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  235. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  236. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  237. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
  238. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  239. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  240. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  241. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
  242. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  243. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  244. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  245. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  246. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  247. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  248. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  249. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  250. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  251. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  252. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  253. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  254. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  255. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  256. package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
  257. package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
  258. package/src/modules/workspace/components/FileRoute.tsx +353 -36
  259. package/src/modules/workspace/components/FileViewer.tsx +172 -46
  260. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  261. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  262. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  263. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
  264. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
  265. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
  266. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  267. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  268. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  269. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  270. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  271. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  272. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  273. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  274. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  275. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  276. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  277. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  278. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  279. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  280. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  281. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  282. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  283. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  284. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  285. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  286. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  287. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  288. package/src/modules/workspace/components/renderers/index.ts +53 -2
  289. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  290. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  291. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  292. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  293. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  294. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  295. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  296. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
  297. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  298. package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
  299. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  300. package/src/modules/workspace/routing/kb-routes.ts +206 -29
  301. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
  302. package/src/modules/workspace/services/workspace.api.ts +57 -4
  303. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  304. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  305. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  306. package/src/modules/workspace/state/workspace.context.ts +125 -19
  307. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  308. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
  309. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  310. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  311. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  312. package/src/modules/workspace/utils/file-trace.ts +50 -0
  313. package/src/modules/workspace/utils/fileTree.ts +112 -36
  314. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  315. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  316. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  317. package/src/modules/workspace/utils/uploadError.ts +29 -0
  318. package/src/shared/__tests__/marketplace-url.test.ts +6 -1
  319. package/src/shared/components/Button.tsx +16 -2
  320. package/src/shared/components/Dialog.tsx +27 -11
  321. package/src/shared/components/Menu.tsx +13 -1
  322. package/src/shared/components/PageShell.tsx +13 -8
  323. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  324. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  325. package/src/shared/components/index.ts +2 -0
  326. package/src/shared/components/useDismissableMenu.ts +32 -10
  327. package/src/shared/components/useFocusHandoff.ts +51 -0
  328. package/src/shared/components/useLatestRef.ts +28 -0
  329. package/src/shared/markdown/Markdown.tsx +12 -3
  330. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  331. package/src/shared/markdown/hrefs.ts +50 -0
  332. package/src/shared/marketplace-url.ts +33 -5
  333. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  334. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  335. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  336. package/src/shared/mcp/connect-snippets.ts +14 -9
  337. package/src/shared/mcp/index.ts +1 -1
  338. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  339. package/src/shared/theme/header.ts +75 -0
  340. package/src/shared/theme/measure.ts +7 -4
  341. package/src/shared/theme/tokens.css +25 -0
  342. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  343. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  344. package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
  345. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  346. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  347. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -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,8 +34,9 @@ vi.mock('../services/library.api', () => ({
33
34
  getSkillFile: apiMock.getSkillFile,
34
35
  proposeChange: apiMock.proposeChange,
35
36
  listSkills: vi.fn(),
36
- // The write-access request surface: nothing pending, nothing asked.
37
- listSkillAccessRequests: vi.fn(async () => []),
37
+ // The write-access request surface: nothing pending, nothing asked — unless
38
+ // a test puts a request on it.
39
+ listSkillAccessRequests: apiMock.listSkillAccessRequests,
38
40
  reconcileSkillAccessRequest: vi.fn(async () => false),
39
41
  requestSkillAccess: vi.fn(async () => ({ number: 1 })),
40
42
  // Real behaviour, not a stub: the page resolves the caller's own request by
@@ -55,6 +57,9 @@ vi.mock('../../change-requests/services/change-requests.api', () => ({
55
57
  listOpenChangeRequests: vi.fn(async () => []),
56
58
  listMyChangeRequests: vi.fn(async () => []),
57
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 })),
58
63
  }));
59
64
  vi.mock('../../pr/services/pr-merge.api', () => ({ mergePullRequest: apiMock.mergePullRequest }));
60
65
  vi.mock('../../pr/services/pr-cancel.api', () => ({
@@ -66,9 +71,29 @@ vi.mock('../../pr/services/pr-detail.api', () => ({ fetchPrDetail: apiMock.fetch
66
71
  vi.mock('../../pr/services/pr-approvals.api', () => ({ approvePrFile: apiMock.approvePrFile }));
67
72
 
68
73
  // Keep the markdown pipeline (mermaid etc.) out of this test — the stub renders
69
- // 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.
70
77
  vi.mock('../../workspace/components/renderers/KbMarkdownView', () => ({
71
- 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
+ ),
72
97
  }));
73
98
 
74
99
  // The file bar's Edit-or-Propose decision asks the per-file access resolver.
@@ -81,11 +106,17 @@ const accessMock = vi.hoisted(() => ({
81
106
  owners: { roles: [], users: [] },
82
107
  },
83
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(),
84
112
  }));
85
113
  accessMock.fetchFileAccess.mockImplementation(async () => accessMock.result);
86
- vi.mock('../../access/api', () => ({
114
+ vi.mock('../../access/api', async (importOriginal) => ({
115
+ ...(await importOriginal<object>()),
87
116
  fetchFileAccess: accessMock.fetchFileAccess,
88
117
  fetchFileAccessBatch: vi.fn(async () => ({ results: {} })),
118
+ grantAccess: accessMock.grantAccess,
119
+ suggestPrincipals: accessMock.suggestPrincipals,
89
120
  }));
90
121
 
91
122
  // The page reads the catalog through `useLibrary()`. Mocking the hook rather
@@ -181,7 +212,13 @@ const foreignCr = {
181
212
  url: '',
182
213
  } as unknown as PullRequestSummary;
183
214
 
184
- 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 {
185
222
  return {
186
223
  crs,
187
224
  myCrNumbers: new Set(mine),
@@ -192,6 +229,7 @@ function libraryValue(owned: boolean, crs: PullRequestSummary[] = [], mine: numb
192
229
  name: 'newsletter',
193
230
  description: skillSummary.description,
194
231
  owned,
232
+ canWrite,
195
233
  plugin: null,
196
234
  path: skillSummary.path,
197
235
  status: { state: 'ok', text: '' },
@@ -201,6 +239,8 @@ function libraryValue(owned: boolean, crs: PullRequestSummary[] = [], mine: numb
201
239
  tools: [slackTool],
202
240
  allowedToolsBySkill: new Map([['newsletter', ['slack_post_message']]]),
203
241
  ownedSkills: owned ? new Set(['newsletter']) : new Set<string>(),
242
+ writableSkills: canWrite ? new Set(['newsletter']) : new Set<string>(),
243
+ ownedTools: new Set<string>(),
204
244
  loading: false,
205
245
  error: null,
206
246
  reload: () => {},
@@ -227,6 +267,9 @@ function makeFakeBus() {
227
267
  };
228
268
  },
229
269
  setFocus() {},
270
+ watchWorkspace() {
271
+ return () => {};
272
+ },
230
273
  emit(e) {
231
274
  (handlers[e.kind] ?? []).forEach((h) => h(e));
232
275
  },
@@ -246,9 +289,16 @@ function renderPage(
246
289
  pageProps?: { provisional?: boolean },
247
290
  /** Git state — overridden to test what the page does when there is no log. */
248
291
  gitValue: GitContextValue = git,
292
+ /** Workspace state — overridden to test the page before the KB dir is known. */
293
+ workspaceValue: WorkspaceContextValue = workspace,
249
294
  ) {
250
295
  libraryMock.value = { ...libraryValue(owned, crs, mine), ...library };
251
- 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>;
252
302
  }
253
303
 
254
304
  /**
@@ -286,6 +336,7 @@ function harness(
286
336
  gitValue: GitContextValue,
287
337
  routerState?: Record<string, unknown>,
288
338
  pageProps?: { provisional?: boolean },
339
+ workspaceValue: WorkspaceContextValue = workspace,
289
340
  ) {
290
341
  return (
291
342
  <MemoryRouter
@@ -294,7 +345,7 @@ function harness(
294
345
  ]}
295
346
  >
296
347
  <AuthContext.Provider value={auth}>
297
- <WorkspaceContext.Provider value={workspace}>
348
+ <WorkspaceContext.Provider value={workspaceValue}>
298
349
  <GitContext.Provider value={gitValue}>
299
350
  <EventBusContext.Provider value={bus}>
300
351
  {/* The real toast provider: the success message IS the page's
@@ -306,6 +357,7 @@ function harness(
306
357
  path="/skills-and-tools/skills/:name"
307
358
  element={<SkillPage {...(pageProps ?? {})} />}
308
359
  />
360
+ <Route path="/workspace/*" element={<NavigatedTo />} />
309
361
  </Routes>
310
362
  </LibraryToastProvider>
311
363
  </EventBusContext.Provider>
@@ -353,6 +405,7 @@ beforeEach(() => {
353
405
  isApproved: false,
354
406
  approvedBy: [],
355
407
  eligibleApprovers: { roles: ['Newsroom'], users: [] },
408
+ inMergeGate: true,
356
409
  },
357
410
  ],
358
411
  });
@@ -501,14 +554,11 @@ describe('SkillPage', () => {
501
554
  );
502
555
  });
503
556
 
504
- it('shows the Owner badge to an owner. But never access', async () => {
557
+ it('shows the Owner badge to an owner', async () => {
505
558
  renderPage(true);
506
559
  await screen.findByRole('heading', { name: 'newsletter' });
507
560
 
508
561
  expect(screen.getByText('Owner')).toBeInTheDocument();
509
- // A skill inherits its plugin folder's rules; the plugin's Share panel is the
510
- // one place they are decided, for owner and non-owner alike.
511
- expect(screen.queryByRole('button', { name: 'Manage access' })).toBeNull();
512
562
  });
513
563
 
514
564
  it('hides the Owner badge from non-owners', async () => {
@@ -518,6 +568,25 @@ describe('SkillPage', () => {
518
568
  expect(screen.queryByText('Owner')).toBeNull();
519
569
  });
520
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
+
521
590
  /**
522
591
  * One way to change a skill, for everyone. A direct-to-`main` `Edit` used to
523
592
  * sit beside Propose; it bypassed review and, on a protected branch, usually
@@ -590,6 +659,83 @@ describe('SkillPage', () => {
590
659
  expect(apiMock.proposeChange).not.toHaveBeenCalled();
591
660
  });
592
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
+
593
739
  it('arriving with startEditing in router state opens the editor without a click', async () => {
594
740
  // The creation hand-off: NewSkillPanel navigates here with the flag, so
595
741
  // the person who just made an empty skill lands with the cursor in it.
@@ -643,7 +789,7 @@ describe('SkillPage', () => {
643
789
  expect(screen.getByTestId('file-pane-card')).toBeInTheDocument();
644
790
  expect(screen.getByText('Loading…')).toBeInTheDocument();
645
791
  expect(panel).toHaveAttribute('aria-busy', 'true');
646
- expect(screen.getByRole('button', { name: /All skills & tools/ })).toBeInTheDocument();
792
+ expect(screen.getByRole('button', { name: /Everything/ })).toBeInTheDocument();
647
793
 
648
794
  await act(async () => {
649
795
  resolveSkill(skillDetail);
@@ -882,7 +1028,7 @@ describe('SkillPage: deciding on a change', () => {
882
1028
  renderPage(true, [foreignCr]);
883
1029
 
884
1030
  const approve = await screen.findByRole('button', { name: 'Approve' });
885
- expect(screen.getByText('You decide. You own this.')).toBeInTheDocument();
1031
+ expect(screen.getByText('You can decide this.')).toBeInTheDocument();
886
1032
 
887
1033
  fireEvent.click(approve);
888
1034
 
@@ -910,12 +1056,14 @@ describe('SkillPage: deciding on a change', () => {
910
1056
  isApproved: false,
911
1057
  approvedBy: [],
912
1058
  eligibleApprovers: { roles: ['Newsroom'], users: [] },
1059
+ inMergeGate: true,
913
1060
  },
914
1061
  {
915
1062
  path: 'Skills/newsletter/sources.yaml',
916
1063
  isApproved: false,
917
1064
  approvedBy: [],
918
1065
  eligibleApprovers: { roles: [], users: [] },
1066
+ inMergeGate: false,
919
1067
  },
920
1068
  ],
921
1069
  });
@@ -1177,16 +1325,17 @@ describe('SkillPage: deciding on a change', () => {
1177
1325
  * A skill is a file in the repository, and this page is the ONLY surface it
1178
1326
  * has: the shell routes every default-branch `Plugins/` URL here
1179
1327
  * (`isLibraryLocation`) and the Knowledge tree does not list `Plugins/` at
1180
- * all, so a `⋯` missing here means the git log for every skill in the
1181
- * deployment is unreachable — the audit trail the product is sold on,
1182
- * 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.
1183
1333
  */
1184
1334
  describe('version history', () => {
1185
1335
  it('opens the log for the file on screen, at its workspace path', async () => {
1186
1336
  renderPage(false);
1187
1337
 
1188
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1189
- fireEvent.click(screen.getByRole('menuitem', { name: 'Version history' }));
1338
+ fireEvent.click(await screen.findByRole('button', { name: 'Version history' }));
1190
1339
 
1191
1340
  // The path the panel asks git about is the workspace-relative one the
1192
1341
  // Knowledge viewer would hand it — kbDirName included. Getting this
@@ -1200,13 +1349,41 @@ describe('SkillPage: deciding on a change', () => {
1200
1349
  // And there is a way back, because history is not in the URL.
1201
1350
  fireEvent.click(screen.getByRole('button', { name: 'Back to the file' }));
1202
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);
1203
1381
  });
1204
1382
 
1205
1383
  it('does not follow you to another file of the skill', async () => {
1206
1384
  renderPage(false);
1207
1385
 
1208
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1209
- fireEvent.click(screen.getByRole('menuitem', { name: 'Version history' }));
1386
+ fireEvent.click(await screen.findByRole('button', { name: 'Version history' }));
1210
1387
  await screen.findByText('Timeline: knowledge-base/Skills/newsletter/SKILL.md');
1211
1388
 
1212
1389
  // A tab switch is a switch of file, and history is a lens on ONE file.
@@ -1240,11 +1417,11 @@ describe('SkillPage: deciding on a change', () => {
1240
1417
 
1241
1418
  fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
1242
1419
  await screen.findByRole('textbox', { name: /Edit SKILL\.md/ });
1243
- expect(screen.queryByRole('button', { name: 'More actions' })).toBeNull();
1420
+ expect(screen.queryByRole('button', { name: 'Version history' })).toBeNull();
1244
1421
 
1245
1422
  // It comes back the moment the draft is gone.
1246
1423
  fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
1247
- expect(await screen.findByRole('button', { name: 'More actions' })).toBeInTheDocument();
1424
+ expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
1248
1425
  });
1249
1426
 
1250
1427
  /**
@@ -1256,8 +1433,7 @@ describe('SkillPage: deciding on a change', () => {
1256
1433
  it('closes for good when git stops answering mid-read', async () => {
1257
1434
  const bus = makeFakeBus();
1258
1435
  const { rerender } = renderPage(false, [], [], bus);
1259
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1260
- fireEvent.click(screen.getByRole('menuitem', { name: 'Version history' }));
1436
+ fireEvent.click(await screen.findByRole('button', { name: 'Version history' }));
1261
1437
  await screen.findByText(/^Timeline:/);
1262
1438
 
1263
1439
  // A poll fails: the log goes away, and so does its trigger.
@@ -1268,70 +1444,200 @@ describe('SkillPage: deciding on a change', () => {
1268
1444
  rerender(harness(bus, git));
1269
1445
  expect(await screen.findByTestId('md-view')).toBeInTheDocument();
1270
1446
  expect(screen.queryByText(/^Timeline:/)).toBeNull();
1271
- expect(screen.getByRole('button', { name: 'More actions' })).toBeInTheDocument();
1447
+ expect(screen.getByRole('button', { name: 'Version history' })).toBeInTheDocument();
1272
1448
  });
1273
1449
 
1274
- /**
1275
- * The MENU flag needs the same treatment as the log's, and it is a
1276
- * separate flag: the trigger and its panel both live behind
1277
- * `historyAvailable`, so an open menu unmounts with them and leaves its
1278
- * flag set behind an element nobody can see. Found by cubic on #103.
1279
- */
1280
- it('does not spring the menu back open when git recovers', async () => {
1281
- const bus = makeFakeBus();
1282
- const { rerender } = renderPage(false, [], [], bus);
1283
- const trigger = await screen.findByRole('button', { name: 'More actions' });
1284
- fireEvent.click(trigger);
1285
- 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);
1286
1455
 
1287
- // A poll fails while the menu is OPEN — trigger and panel go together.
1288
- rerender(harness(bus, { ...git, availability: 'error' } as GitContextValue));
1289
- 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
+ });
1290
1463
 
1291
- // The next poll succeeds. The trigger is back, and it is CLOSED.
1292
- rerender(harness(bus, git));
1293
- const back = await screen.findByRole('button', { name: 'More actions' });
1294
- expect(back).toHaveAttribute('aria-expanded', 'false');
1295
- 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',
1296
1490
  });
1491
+ });
1297
1492
 
1298
- /**
1299
- * `editing` is the same state by a second door, and it is reachable
1300
- * without a mouse: `useDismissableMenu` dismisses on outside POINTERDOWN,
1301
- * so tabbing from the open menu to Edit and pressing Enter never dismisses
1302
- * it. Cancel then used to hand the menu back open over the file.
1303
- */
1304
- it('does not spring the menu back open when the editor closes', async () => {
1305
- accessMock.result = {
1306
- canWrite: true,
1307
- eligible: { roles: [], users: [] },
1308
- owners: { roles: [], users: [] },
1309
- };
1310
- renderPage(true);
1311
- fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
1312
- 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
+ });
1313
1502
 
1314
- // Reached by keyboard, so no outside pointerdown ever dismissed the menu.
1315
- // Edit appears once the access verdict lands — its own load, awaited.
1316
- fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
1317
- await screen.findByRole('textbox', { name: /Edit SKILL\.md/ });
1318
- 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
+ };
1319
1522
 
1320
- const back = await screen.findByRole('button', { name: 'More actions' });
1321
- expect(back).toHaveAttribute('aria-expanded', 'false');
1322
- 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,
1323
1532
  });
1533
+ apiMock.listSkillAccessRequests.mockReset().mockResolvedValue([]);
1534
+ });
1324
1535
 
1325
- it('has no trigger at all when git cannot answer', async () => {
1326
- renderPage(false, [], [], makeFakeBus(), undefined, undefined, undefined, {
1327
- ...git,
1328
- availability: 'loading',
1329
- } 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();
1330
1540
 
1331
- // Version history is the whole menu, so no log means no `⋯` — an
1332
- // overflow opening onto an empty panel is worse than no overflow.
1333
- expect(await screen.findByRole('heading', { name: 'newsletter' })).toBeInTheDocument();
1334
- 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' },
1335
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();
1336
1642
  });
1337
1643
  });