@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,5 +1,5 @@
1
1
  import type { RefObject } from 'react';
2
- import { FilePlus, FolderPlus, Link2, Trash2, Users } from 'lucide-react';
2
+ import { FilePlus, FolderPlus, Link2, Trash2, Users, UsersRound } from 'lucide-react';
3
3
  import { MenuItem, MenuPanel, useDismissableMenu } from '../../../shared/components';
4
4
 
5
5
  /**
@@ -46,6 +46,11 @@ export interface PluginsSidebarMenuProps {
46
46
  onManageAccess?(): void;
47
47
  /** Opens the delete confirmation. Present ONLY for a plugin the caller owns. */
48
48
  onDelete?(): void;
49
+ /**
50
+ * Opens the group's card on the Groups & Members page. Present ONLY for an
51
+ * administrator on a group row — never on Everyone, which nobody edits.
52
+ */
53
+ onManageMembers?(): void;
49
54
  /** The row this menu was opened from — Escape hands focus back to it. */
50
55
  returnFocusTo?: RefObject<HTMLElement | null>;
51
56
  }
@@ -60,6 +65,7 @@ export function PluginsSidebarMenu({
60
65
  onCopyLink,
61
66
  onManageAccess,
62
67
  onDelete,
68
+ onManageMembers,
63
69
  returnFocusTo,
64
70
  }: PluginsSidebarMenuProps) {
65
71
  const ref = useDismissableMenu<HTMLDivElement>({ open: true, onClose, returnFocusTo });
@@ -134,6 +140,25 @@ export function PluginsSidebarMenu({
134
140
  </MenuItem>
135
141
  </>
136
142
  )}
143
+ {onManageMembers && (
144
+ <>
145
+ {/* Like access, it is about who is here rather than what is — so it
146
+ sits below the rule, after the items the row already had. */}
147
+ <div className="my-1 border-t border-line" />
148
+ <MenuItem
149
+ role="menuitem"
150
+ onClick={() => {
151
+ onManageMembers();
152
+ onClose();
153
+ }}
154
+ >
155
+ <span className="flex items-center gap-2">
156
+ <UsersRound size={14} />
157
+ Manage members
158
+ </span>
159
+ </MenuItem>
160
+ </>
161
+ )}
137
162
  {onDelete && (
138
163
  <>
139
164
  {/* Destructive and last, below its own rule — the file tree's menu
@@ -0,0 +1,17 @@
1
+ import { Users } from 'lucide-react';
2
+ import { Button } from '../../../shared/components';
3
+
4
+ /**
5
+ * The Library's Share button: bounded, because it is the one action beside a
6
+ * title with a consequence for other people. It IS the manage-access dialog —
7
+ * not a doorway to it — for a plugin (`PageActions`) and a skill alike, so the
8
+ * two pages cannot drift into two looks for the same verb.
9
+ */
10
+ export function ShareButton({ onClick }: { onClick(): void }) {
11
+ return (
12
+ <Button variant="outline" size="sm" onClick={onClick}>
13
+ <Users size={13} />
14
+ Share
15
+ </Button>
16
+ );
17
+ }
@@ -1,80 +1,193 @@
1
1
  import { useMemo } from 'react';
2
2
  import { useLocation, useNavigate } from 'react-router-dom';
3
- import { DEFAULT_BRANCH, SKILLS_DIR } from '@bevel-software/platform-shared';
4
- import { useWorkspace } from '../../workspace/state/workspace.context';
5
- import { findKbRoot } from '../../workspace/utils/fileTree';
3
+ import { DEFAULT_BRANCH, PLUGINS_DIR, SKILLS_DIR, type FileTreeEntry } from '@bevel-software/platform-shared';
4
+ import { libraryUploadTarget, useWorkspace } from '../../workspace/state/workspace.context';
5
+ import { checkoutRoot } from '../../workspace/utils/fileTree';
6
6
  import { KB_ROUTE_PREFIX, kbFileUrl, safeDecode } from '../../workspace/routing/kb-routes';
7
7
  import { useMergedWorkspaceTree } from '../../workspace/hooks/useMergedWorkspaceTree';
8
+ import { Puzzle } from 'lucide-react';
8
9
  import {
10
+ EmptyTreeNotice,
9
11
  FileTreeNode,
10
12
  TreeChrome,
11
13
  UploadNotices,
14
+ type TreeMenuItem,
12
15
  type TreeNav,
13
16
  } from '../../workspace/components/FileExplorer';
14
17
 
15
18
  /**
16
- * The Skills section of the Library's nav: the shared `Skills/` root as a
19
+ * One of the Library's two reserved roots — `Skills/` or `Plugins/` — as a
17
20
  * file tree, made of the SAME rows as Knowledge's explorer — right-click menu
18
21
  * (new file, new folder, rename, delete, manage access, download), drag to
19
22
  * move, drop to upload, the caller's proposed files shown in accent. One tree
20
23
  * component in the app, holding a different root.
21
24
  *
22
- * The root is a collapsible folder row called Skills, exactly as Knowledge
23
- * and Data are top-level folders in the Knowledge explorer: open by default
24
- * with its scopes collapsed under it, a drop target for uploads into
25
- * `Skills/`, the create buttons on hover, the folder's menu on right-click —
26
- * minus what a platform-owned root must not offer (`FileTreeNode.reserved`:
27
- * no rename, delete, drag or pin).
25
+ * The root is a collapsible folder row named after the folder, exactly as
26
+ * Knowledge and Data are top-level folders in the Knowledge explorer: open
27
+ * by default with its children collapsed under it, a drop target for uploads
28
+ * into the root, the create buttons on hover, the folder's menu on
29
+ * right-click — minus what a platform-owned root must not offer
30
+ * (`FileTreeNode.reserved`: no rename, delete, drag or pin).
28
31
  *
29
32
  * Two things differ from Knowledge, and both are the surroundings' (see
30
33
  * `TreeChrome`), not the rows':
31
34
  *
32
- * - A click opens the file on its SKILL PAGE, here in Skills & Tools — at
35
+ * - A click opens the file on its ITEM PAGE, here in Skills & Tools — at
33
36
  * the item's canonical default-branch URL, whatever branch is checked
34
37
  * out. The Library speaks the default branch everywhere; this is no
35
- * exception.
38
+ * exception. A skill's SKILL.md opens the skill page; a plugin's
39
+ * manifest or a loose file opens the plugin page; a tool file opens the
40
+ * tool page — `WorkspaceItemRoute` decides, from the path alone.
36
41
  * - The current row is the file the URL names, not the pane workspace's
37
42
  * open tab, which the Library never sets.
38
43
  *
39
- * Renders nothing while the tree is loading or when the caller can read no
40
- * part of the root — an empty Skills folder would be a question, not a
41
- * section.
44
+ * Renders nothing only while the tree is loading, or while the workspace has
45
+ * no repository checkout in it — there is no folder to draw a row for, and
46
+ * the empty state below says why. Once the checkout is here the folder is
47
+ * always drawn — empty when the knowledge base has none yet, at the path it
48
+ * will get — because the folder is where new things go, and a person cannot
49
+ * put one there if the way there is not on screen. The reserved root is
50
+ * forced visible by the tree filter even to a reader who may open nothing
51
+ * beneath it, so the row is present for everyone.
42
52
  */
43
- export function SkillsTree() {
53
+ export function RootFolderTree({
54
+ dir,
55
+ testId,
56
+ menuItems,
57
+ }: {
58
+ dir: string;
59
+ testId: string;
60
+ /**
61
+ * The surface's own context-menu items for an entry, injected into the
62
+ * tree's menu after its create verbs — see `TreeNav.menuItems`. The tree
63
+ * itself grows no verb per caller.
64
+ */
65
+ menuItems?: (entry: FileTreeEntry) => TreeMenuItem[];
66
+ }) {
44
67
  const { kbDirName } = useWorkspace();
45
68
  const { tree, suggestionOnlyPaths } = useMergedWorkspaceTree();
46
69
  const location = useLocation();
47
70
  const navigate = useNavigate();
48
71
 
49
- const root = useMemo(() => {
50
- const kids = findKbRoot(tree)?.children;
51
- return kids?.find((c) => c.type === 'directory' && c.name === SKILLS_DIR) ?? null;
52
- }, [tree]);
72
+ // `Skills/` and `Plugins/` are children of the CHECKOUT and of nothing
73
+ // else. A folder of either name sitting beside the checkout is somebody
74
+ // else's directory, and this tree has never had any business rendering it —
75
+ // it did, on core-staging, because the root used to be found by searching
76
+ // the workspace for a folder that looked like a knowledge base.
77
+ const root = useMemo((): { entry: FileTreeEntry; absent: boolean } | null => {
78
+ const kbRoot = checkoutRoot(tree, kbDirName);
79
+ if (!kbRoot) return null;
80
+ const found = kbRoot.children?.find((c) => c.type === 'directory' && c.name === dir);
81
+ if (found) return { entry: found, absent: false };
82
+ // No folder yet (a knowledge base from before the root existed, or one
83
+ // whose folder was removed): the row is drawn anyway, empty, at the
84
+ // path the folder will have. Every write creates its parents, so the
85
+ // first drop, file or subfolder made here creates the folder itself;
86
+ // what would READ the folder (download) is withheld until then.
87
+ // MISSING FOLDER, not missing checkout: the two are different answers and
88
+ // only this one draws a row. A checkout that is not there gets the empty
89
+ // state, because there is no path a first write could even go to.
90
+ return {
91
+ entry: { name: dir, relativePath: `${kbRoot.relativePath}/${dir}`, type: 'directory', children: [] },
92
+ absent: true,
93
+ };
94
+ }, [tree, kbDirName, dir]);
53
95
 
54
96
  const nav = useMemo<TreeNav>(
55
97
  () => ({
56
98
  activePath: activeWorkspacePath(location.pathname, kbDirName),
57
99
  open: (path) => navigate(kbFileUrl(DEFAULT_BRANCH, path)),
100
+ menuItems,
58
101
  }),
59
- [location.pathname, kbDirName, navigate],
102
+ [location.pathname, kbDirName, navigate, menuItems],
60
103
  );
61
104
 
62
- if (!root) return null;
105
+ // No checkout: no root row to draw, and `EmptyTreeNotice` says why — the
106
+ // same surface, and the same reason, as the Knowledge explorer beside it.
107
+ // Still nothing at all while the tree is loading, as before.
108
+ if (!root) {
109
+ if (!tree) return null;
110
+ return (
111
+ <div data-testid={testId}>
112
+ <EmptyTreeNotice rootPath={null} />
113
+ </div>
114
+ );
115
+ }
63
116
 
64
117
  return (
65
- <TreeChrome nav={nav} suggestionOnlyPaths={suggestionOnlyPaths}>
118
+ // The two Library trees sit in ONE sidebar over ONE piece of upload
119
+ // state: each names itself so a drop's banners appear in the tree that
120
+ // took the drop, and only there. Before that, dropping into `Skills/`
121
+ // painted the same notice above `Skills/` AND above `Plugins/`.
122
+ <TreeChrome nav={nav} suggestionOnlyPaths={suggestionOnlyPaths} uploadTarget={libraryUploadTarget(dir)}>
66
123
  {/* A right-click that lands between the tree's rows is the tree's, not
67
- the plugin nav's behind it: with nothing wired for the gap the
68
- browser's own menu is the honest answer, as in Knowledge. The rows
69
- stop their own events before reaching here. */}
70
- <div data-testid="skills-tree" onContextMenu={(e) => e.stopPropagation()}>
124
+ the nav's behind it: with nothing wired for the gap the browser's
125
+ own menu is the honest answer, as in Knowledge. The rows stop their
126
+ own events before reaching here. */}
127
+ <div data-testid={testId} onContextMenu={(e) => e.stopPropagation()}>
71
128
  <UploadNotices />
72
- <FileTreeNode entry={root} depth={0} reserved collapseChildren />
129
+ <FileTreeNode entry={root.entry} depth={0} reserved absent={root.absent} collapseChildren />
130
+ {/* The same listing as Knowledge's explorer, so the same answer when
131
+ it shows nothing — judged on THIS root, with it as where a first
132
+ one goes: an empty Skills tree is empty however full Knowledge is. */}
133
+ <EmptyTreeNotice rootPath={root.entry.relativePath} scope="root" />
73
134
  </div>
74
135
  </TreeChrome>
75
136
  );
76
137
  }
77
138
 
139
+ /** The shared `Skills/` root. */
140
+ export function SkillsTree() {
141
+ return <RootFolderTree dir={SKILLS_DIR} testId="skills-tree" />;
142
+ }
143
+
144
+ /**
145
+ * The `Plugins/` root — every plugin folder as it is on disk. A GROUPING
146
+ * folder's row (the root, or a folder no plugin owns) offers "New plugin"
147
+ * when the caller wires it, and the plugin is made THERE: the verb carries
148
+ * the folder's path below the plugins root. The one verb this root has that
149
+ * Knowledge's folders do not, injected rather than built into the tree. An
150
+ * intent: the layout owns the dialog.
151
+ */
152
+ export function PluginsTree({
153
+ onCreatePlugin,
154
+ isGroupingFolder = () => true,
155
+ }: {
156
+ /** Make a plugin in `parent` — a path below the plugins root, `''` for the root. */
157
+ onCreatePlugin?: (parent: string) => void;
158
+ /**
159
+ * Whether a repo-relative folder may HOLD a plugin: the root and folders no
160
+ * plugin owns. A plugin's own folder, or anything beneath one, cannot — a
161
+ * plugin claims its subtree, and a plugin made inside it would be listed
162
+ * nowhere. The layout answers from the plugin index.
163
+ */
164
+ isGroupingFolder?: (repoRelFolder: string) => boolean;
165
+ } = {}) {
166
+ const { kbDirName } = useWorkspace();
167
+ const menuItems = useMemo(() => {
168
+ if (!onCreatePlugin) return undefined;
169
+ return (entry: FileTreeEntry): TreeMenuItem[] => {
170
+ if (entry.type !== 'directory') return [];
171
+ const rel = repoRelative(entry.relativePath, kbDirName);
172
+ if (rel === null || !isGroupingFolder(rel)) return [];
173
+ const parent = rel === PLUGINS_DIR ? '' : rel.slice(PLUGINS_DIR.length + 1);
174
+ return [{ id: 'new-plugin', label: 'New plugin', icon: <Puzzle size={14} />, onSelect: () => onCreatePlugin(parent) }];
175
+ };
176
+ }, [onCreatePlugin, isGroupingFolder, kbDirName]);
177
+ return <RootFolderTree dir={PLUGINS_DIR} testId="plugins-tree" menuItems={menuItems} />;
178
+ }
179
+
180
+ /**
181
+ * A tree entry's path relative to the REPOSITORY (`Plugins/Teams`), from its
182
+ * workspace-relative one (`<kbDir>/Plugins/Teams`); null when it does not
183
+ * sit under the knowledge base at all.
184
+ */
185
+ function repoRelative(workspacePath: string, kbDirName: string | null): string | null {
186
+ if (kbDirName === null) return null;
187
+ const prefix = `${kbDirName}/`;
188
+ return workspacePath.startsWith(prefix) ? workspacePath.slice(prefix.length) : null;
189
+ }
190
+
78
191
  /**
79
192
  * The workspace-relative path a Library URL names, or null. Library item
80
193
  * pages live at `/workspace/<default>/<kbDir>/...` — the inverse of
@@ -0,0 +1,15 @@
1
+ import { useParams } from 'react-router-dom';
2
+ import { decodePluginSegment } from '../routes/library-paths';
3
+ import { LibraryPage } from './LibraryPage';
4
+
5
+ /**
6
+ * `teams/:group` — one team's lens on the catalog. The name comes in RAW
7
+ * from the router and is decoded here, the way the plugin page decodes its
8
+ * own segment; the page then slices the catalog by the server's answer for
9
+ * that team (`TeamAccess`), and says so when there is no such team.
10
+ */
11
+ export function TeamRoute() {
12
+ const { group = '' } = useParams<{ group: string }>();
13
+ const name = decodePluginSegment(group);
14
+ return <LibraryPage key={name} filter={{ kind: 'team', group: name }} />;
15
+ }
@@ -0,0 +1,144 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { render, screen, cleanup, within } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import type { FileTreeEntry } from '@bevel-software/platform-shared';
5
+
6
+ const accessMock = vi.hoisted(() => ({ fetchFileAccess: vi.fn() }));
7
+ vi.mock('../../../access/api', () => ({
8
+ fetchFileAccess: accessMock.fetchFileAccess,
9
+ fetchFileAccessBatch: vi.fn(async () => ({ results: {} })),
10
+ }));
11
+ vi.mock('../../../../lib/api', () => ({ authFetch: vi.fn() }));
12
+
13
+ import { PluginsTree, SkillsTree } from '../SkillsTree';
14
+ import {
15
+ WorkspaceContext,
16
+ libraryUploadTarget,
17
+ type UploadError,
18
+ type UploadNotice,
19
+ type WorkspaceContextValue,
20
+ } from '../../../workspace/state/workspace.context';
21
+ import { makeWorkspaceFixture } from '../../../workspace/__tests__/testFixtures';
22
+ import { OpenChangeRequestsContext } from '../../../workspace/state/open-change-requests.context';
23
+ import { AuthContext } from '../../../auth/state/auth.context';
24
+
25
+ /**
26
+ * The reported duplicate: one upload, the same "the upload became a
27
+ * suggestion" notice at the top of the sidebar AND further down it.
28
+ *
29
+ * The Library's sidebar holds TWO of the app's file trees — `Skills/` and
30
+ * `Plugins/` — and each renders the pair of upload banners, over one shared
31
+ * piece of workspace state. Untargeted, a single drop painted its notice in
32
+ * both. Each tree names itself now, and a banner is drawn only by the tree
33
+ * whose name it carries.
34
+ */
35
+
36
+ const KB = 'knowledge-base';
37
+
38
+ const TREE: FileTreeEntry = {
39
+ name: '.',
40
+ relativePath: '.',
41
+ type: 'directory',
42
+ children: [{
43
+ name: KB,
44
+ relativePath: KB,
45
+ type: 'directory',
46
+ children: [
47
+ { name: 'Skills', relativePath: `${KB}/Skills`, type: 'directory', children: [] },
48
+ { name: 'Plugins', relativePath: `${KB}/Plugins`, type: 'directory', children: [] },
49
+ ],
50
+ }],
51
+ };
52
+
53
+ function renderSidebar(over: Partial<WorkspaceContextValue>) {
54
+ const workspace = makeWorkspaceFixture({ kbDirName: KB, fileTree: TREE, ...over });
55
+ return render(
56
+ <MemoryRouter>
57
+ <AuthContext.Provider
58
+ value={{ user: null, token: null, isLoading: false, login: async () => {}, logout: () => {} }}
59
+ >
60
+ <WorkspaceContext.Provider value={workspace}>
61
+ <OpenChangeRequestsContext.Provider
62
+ value={{
63
+ paths: new Set(),
64
+ forPath: () => [],
65
+ minePaths: new Map(),
66
+ mineNumbers: new Set(),
67
+ }}
68
+ >
69
+ {/* Both of the Library sidebar's trees, as `PluginsSidebar` mounts them. */}
70
+ <SkillsTree />
71
+ <PluginsTree />
72
+ </OpenChangeRequestsContext.Provider>
73
+ </WorkspaceContext.Provider>
74
+ </AuthContext.Provider>
75
+ </MemoryRouter>,
76
+ );
77
+ }
78
+
79
+ /** The two trees name themselves through the same helper the trees use. */
80
+ const SKILLS = libraryUploadTarget('Skills');
81
+ const PLUGINS = libraryUploadTarget('Plugins');
82
+
83
+ const SUGGESTION: UploadNotice = {
84
+ kind: 'suggestion',
85
+ message:
86
+ "You can't write to that folder, so the upload became a suggestion: "
87
+ + 'it is now a change request for the folder’s owners to review.',
88
+ };
89
+
90
+ const REFUSAL: UploadError = {
91
+ filename: 'report.pdf',
92
+ reason: 'You do not have permission to write to Skills/house-writing-standards',
93
+ status: 403,
94
+ };
95
+
96
+ describe('the Library sidebar shows one upload banner, in the tree that took the drop', () => {
97
+ beforeEach(() => {
98
+ cleanup();
99
+ accessMock.fetchFileAccess.mockReset().mockResolvedValue({ canRead: true, canWrite: true });
100
+ });
101
+
102
+ it('renders the suggestion notice once, inside the Skills tree', () => {
103
+ renderSidebar({ uploadNotices: new Map([[SKILLS, SUGGESTION]]) });
104
+ const notices = screen.getAllByTestId('upload-notice');
105
+ expect(notices).toHaveLength(1);
106
+ expect(within(screen.getByTestId('skills-tree')).getByTestId('upload-notice')).toBe(notices[0]);
107
+ expect(within(screen.getByTestId('plugins-tree')).queryByTestId('upload-notice')).toBeNull();
108
+ });
109
+
110
+ it('renders the error banner once, inside the Skills tree, reason and all', () => {
111
+ renderSidebar({ uploadErrors: new Map([[SKILLS, REFUSAL]]) });
112
+ const alerts = screen.getAllByRole('alert');
113
+ expect(alerts).toHaveLength(1);
114
+ expect(alerts[0]).toHaveTextContent("Couldn't add report.pdf");
115
+ expect(alerts[0].textContent).toContain(REFUSAL.reason);
116
+ expect(alerts[0]).toHaveTextContent('Try another folder or ask its owner.');
117
+ expect(within(screen.getByTestId('plugins-tree')).queryByRole('alert')).toBeNull();
118
+ });
119
+
120
+ // Two drops in flight at once, one per tree. Over a single shared notice
121
+ // the second drop's dispatch replaced the first's and the first to settle
122
+ // cleared the second's — either way one of the two uploads went silent,
123
+ // which is the failure this page exists to prevent.
124
+ it('shows both trees their own drop when two are in flight at once', () => {
125
+ renderSidebar({
126
+ uploadNotices: new Map([
127
+ [SKILLS, { kind: 'progress', message: 'Adding report.pdf to Skills…' } as UploadNotice],
128
+ [PLUGINS, SUGGESTION],
129
+ ]),
130
+ });
131
+ expect(screen.getAllByTestId('upload-notice')).toHaveLength(2);
132
+ expect(within(screen.getByTestId('skills-tree')).getByTestId('upload-notice'))
133
+ .toHaveTextContent('Adding report.pdf to Skills');
134
+ expect(within(screen.getByTestId('plugins-tree')).getByTestId('upload-notice'))
135
+ .toHaveTextContent('became a suggestion');
136
+ });
137
+
138
+ it('puts a Plugins drop’s banner in the Plugins tree instead', () => {
139
+ renderSidebar({ uploadNotices: new Map([[PLUGINS, SUGGESTION]]) });
140
+ expect(screen.getAllByTestId('upload-notice')).toHaveLength(1);
141
+ expect(within(screen.getByTestId('plugins-tree')).getByTestId('upload-notice')).toBeDefined();
142
+ expect(within(screen.getByTestId('skills-tree')).queryByTestId('upload-notice')).toBeNull();
143
+ });
144
+ });