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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +34 -26
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/bootstrap.test.ts +33 -1
  6. package/src/core/__tests__/events.test.ts +43 -0
  7. package/src/core/bootstrap.ts +38 -1
  8. package/src/core/events.ts +85 -3
  9. package/src/core/registry.ts +1 -1
  10. package/src/lib/__tests__/api.test.ts +38 -0
  11. package/src/lib/__tests__/email.test.ts +44 -0
  12. package/src/lib/api.ts +19 -2
  13. package/src/lib/email.ts +37 -1
  14. package/src/lib/utils.ts +2 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  16. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  20. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  21. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  22. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  23. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  24. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
  25. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  26. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  27. package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
  28. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  29. package/src/modules/access/api.ts +192 -10
  30. package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
  31. package/src/modules/access/manage-access-affordance.ts +17 -0
  32. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  33. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  34. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  35. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  36. package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
  37. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  38. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  39. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  40. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  41. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  42. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  43. package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
  44. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  45. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  46. package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
  47. package/src/modules/admin/components/group-members-path.ts +32 -0
  48. package/src/modules/admin/services/connection-keys.api.ts +47 -0
  49. package/src/modules/admin/services/roles.api.ts +12 -1
  50. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  51. package/src/modules/auth/components/AccountPage.tsx +73 -54
  52. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  53. package/src/modules/auth/services/account.api.ts +78 -4
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  58. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  59. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  60. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  61. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  62. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  63. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  64. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  65. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  66. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  67. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  68. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  69. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  70. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  71. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  72. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  73. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  74. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  75. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  76. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  77. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  78. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  79. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  80. package/src/modules/change-requests/services/propose.api.ts +97 -8
  81. package/src/modules/change-requests/utils/approval.ts +15 -0
  82. package/src/modules/change-requests/utils/author.ts +32 -0
  83. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  84. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  85. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
  86. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  87. package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
  88. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  89. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  90. package/src/modules/git/services/error-messages.ts +12 -0
  91. package/src/modules/git/services/pr-prompts.ts +5 -5
  92. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  93. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  94. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  95. package/src/modules/layout/components/AppLayout.tsx +2 -0
  96. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  97. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  98. package/src/modules/layout/components/SidebarFrame.tsx +109 -4
  99. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  100. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  101. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  102. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  103. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  104. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
  105. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
  106. package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
  107. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
  108. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  109. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  110. package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
  111. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  112. package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
  113. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
  114. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
  115. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  116. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  117. package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
  118. package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
  119. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  120. package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
  121. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
  122. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  123. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  124. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  125. package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
  126. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  127. package/src/modules/library/__tests__/library-paths.test.ts +75 -0
  128. package/src/modules/library/__tests__/link-membership.test.ts +129 -0
  129. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  130. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  131. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  132. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  133. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  134. package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
  135. package/src/modules/library/__tests__/status.test.ts +82 -2
  136. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  137. package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
  138. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  139. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  140. package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
  141. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  142. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  143. package/src/modules/library/components/LibraryCard.tsx +149 -34
  144. package/src/modules/library/components/LibraryLayout.tsx +120 -247
  145. package/src/modules/library/components/LibraryPage.tsx +172 -39
  146. package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
  147. package/src/modules/library/components/LockedPluginView.tsx +63 -35
  148. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  149. package/src/modules/library/components/NewPluginDialog.tsx +19 -5
  150. package/src/modules/library/components/PageActions.tsx +31 -9
  151. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  152. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  153. package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
  154. package/src/modules/library/components/PluginExtras.tsx +143 -18
  155. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  156. package/src/modules/library/components/PluginPage.tsx +234 -38
  157. package/src/modules/library/components/PluginRows.tsx +286 -0
  158. package/src/modules/library/components/PluginsSidebar.tsx +271 -238
  159. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  160. package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
  161. package/src/modules/library/components/ShareButton.tsx +17 -0
  162. package/src/modules/library/components/SkillsTree.tsx +204 -0
  163. package/src/modules/library/components/StatusDot.tsx +1 -0
  164. package/src/modules/library/components/TeamRoute.tsx +15 -0
  165. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  166. package/src/modules/library/components/plugin-page-parts.tsx +132 -23
  167. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
  168. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  169. package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
  170. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  171. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  172. package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
  173. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  174. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  175. package/src/modules/library/hooks/useJoinRequests.ts +48 -18
  176. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  177. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  178. package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
  179. package/src/modules/library/routes/library-paths.ts +46 -35
  180. package/src/modules/library/services/library.api.ts +89 -17
  181. package/src/modules/library/services/plugins.api.ts +161 -9
  182. package/src/modules/library/services/teams.api.ts +15 -0
  183. package/src/modules/library/services/tools.api.ts +78 -0
  184. package/src/modules/library/state/library-data.tsx +268 -37
  185. package/src/modules/library/utils/personal-plugin.ts +13 -15
  186. package/src/modules/library/utils/plugin-entries.ts +134 -0
  187. package/src/modules/library/utils/plugin-summary.ts +102 -0
  188. package/src/modules/library/utils/status.ts +204 -35
  189. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
  190. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  191. package/src/modules/onboarding/agent-clients.ts +55 -23
  192. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  193. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  194. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  195. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  196. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  197. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  198. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  199. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  200. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  201. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  202. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  203. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  204. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  205. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  206. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  207. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  208. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  209. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  210. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  211. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  212. package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
  213. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  214. package/src/modules/settings/components/DeploymentPage.tsx +16 -22
  215. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  216. package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
  217. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
  218. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  219. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
  220. package/src/modules/settings/services/github-facade.api.ts +66 -0
  221. package/src/modules/settings/settings-nav-items.tsx +10 -2
  222. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  223. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  224. package/src/modules/setup/__tests__/setup.test.tsx +615 -4
  225. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  226. package/src/modules/setup/components/SetupGate.tsx +16 -16
  227. package/src/modules/setup/components/SetupScreen.tsx +711 -40
  228. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  229. package/src/modules/setup/services/setup.api.ts +218 -3
  230. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  231. package/src/modules/setup/utils/root-folders.ts +46 -0
  232. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  233. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  234. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  235. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  236. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  237. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  238. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  239. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  240. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  241. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  242. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  243. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  244. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  245. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  246. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  247. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  248. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
  249. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  250. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  251. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  252. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
  253. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  254. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  255. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  256. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  257. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  258. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  259. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  260. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  261. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  262. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  263. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  264. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  265. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  266. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  267. package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
  268. package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
  269. package/src/modules/workspace/components/FileRoute.tsx +376 -22
  270. package/src/modules/workspace/components/FileViewer.tsx +166 -45
  271. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  272. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  273. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  274. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
  275. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
  276. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
  277. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  278. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  279. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  280. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  281. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  282. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  283. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  284. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  285. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  286. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  287. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  288. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  289. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  290. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  291. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  292. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  293. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  294. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  295. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  296. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  297. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  298. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  299. package/src/modules/workspace/components/renderers/index.ts +53 -2
  300. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  301. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  302. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  303. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  304. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  305. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  306. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  307. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
  308. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  309. package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
  310. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  311. package/src/modules/workspace/routing/kb-routes.ts +207 -30
  312. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
  313. package/src/modules/workspace/services/workspace.api.ts +57 -4
  314. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  315. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  316. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  317. package/src/modules/workspace/state/workspace.context.ts +130 -16
  318. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  319. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
  320. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  321. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  322. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  323. package/src/modules/workspace/utils/file-trace.ts +50 -0
  324. package/src/modules/workspace/utils/fileTree.ts +126 -52
  325. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  326. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  327. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  328. package/src/modules/workspace/utils/uploadError.ts +29 -0
  329. package/src/shared/__tests__/marketplace-url.test.ts +59 -0
  330. package/src/shared/components/Badge.tsx +3 -1
  331. package/src/shared/components/Banner.tsx +5 -1
  332. package/src/shared/components/Button.tsx +16 -2
  333. package/src/shared/components/Dialog.tsx +27 -11
  334. package/src/shared/components/Menu.tsx +13 -1
  335. package/src/shared/components/PageShell.tsx +13 -8
  336. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  337. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  338. package/src/shared/components/index.ts +2 -0
  339. package/src/shared/components/useDismissableMenu.ts +32 -10
  340. package/src/shared/components/useFocusHandoff.ts +51 -0
  341. package/src/shared/components/useLatestRef.ts +28 -0
  342. package/src/shared/markdown/Markdown.tsx +12 -3
  343. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  344. package/src/shared/markdown/hrefs.ts +50 -0
  345. package/src/shared/marketplace-url.ts +118 -0
  346. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  347. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  348. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  349. package/src/shared/mcp/connect-snippets.ts +14 -9
  350. package/src/shared/mcp/index.ts +1 -1
  351. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  352. package/src/shared/theme/header.ts +75 -0
  353. package/src/shared/theme/measure.ts +7 -4
  354. package/src/shared/theme/tokens.css +34 -0
  355. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  356. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  357. package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
  358. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  359. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  360. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -1,8 +1,7 @@
1
- import type { MouseEvent, ReactNode } from 'react';
1
+ import { useState, type MouseEvent, type ReactNode } from 'react';
2
2
  import { cn } from '../../../lib/utils';
3
+ import { SIDEBAR_ROW_INSET } from '../../layout/components/SidebarFrame';
3
4
  import type { LibraryFilter } from '../utils/status';
4
- import { ChalkArrow } from './plugin-page-parts';
5
- import { LockGlyph } from './LockGlyph';
6
5
 
7
6
  /**
8
7
  * Where a right-click landed in the nav, and everything the layout needs to
@@ -22,111 +21,130 @@ export interface SidebarContextTarget {
22
21
  row: HTMLElement | null;
23
22
  }
24
23
 
24
+ /**
25
+ * The two views of what sits below the lenses: by TEAM (who can use what),
26
+ * or the ADVANCED view — the two roots as they are on disk.
27
+ */
28
+ export type SidebarView = 'teams' | 'advanced';
29
+
25
30
  export interface PluginsSidebarProps {
26
31
  /** What the URL has selected, or null on a page with no gallery filter. */
27
32
  filter: LibraryFilter | null;
28
33
  /** A row was clicked — the layout navigates; the sidebar owns no state. */
29
34
  onSelect(filter: LibraryFilter): void;
30
- /** Readable plugins, with their item count and how many integrations need setup. */
31
- plugins: { plugin: string; count: number; attention: number }[];
32
- /**
33
- * Plugins the caller cannot read, alphabetical. Rendered after a gap, with a
34
- * lock instead of a count.
35
- */
36
- lockedPlugins: string[];
37
35
  ownedCount: number;
38
36
  /**
39
37
  * How many of the caller's OWN items are waiting on them. Drives the amber
40
38
  * badge; when zero the row shows `ownedCount` in grey instead.
41
39
  */
42
40
  ownedAttention: number;
43
- /** The caller's own space, e.g. `Juan's Plugin` — see `personalPluginName`. */
44
- personalPluginLabel: string;
45
- ungroupedCount: number;
46
- /** Integrations across the catalog that need setup — the amber count. */
47
- attentionCount: number;
48
- /** Send the user to the Connect page to finish those. */
49
- onFinishSetup(): void;
41
+ /**
42
+ * The teams — groups from the access rules, led by the org-wide `Everyone`
43
+ * entry the server puts first — each with how much of the
44
+ * catalog it can use, and how many of its plugins' links lock its members
45
+ * out of a skill right now. Orange wins the count slot: it is other
46
+ * people's problem, and the count is not the news.
47
+ */
48
+ teams: { name: string; count: number; urgent: number }[];
50
49
  /** Start a new plugin. The layout owns the dialog; this is only the intent. */
51
50
  onCreatePlugin(): void;
52
51
  /**
53
- * Whether to spell the first plugin out in words, with the chalk arrow. The
54
- * hover-revealed `+` is unchanged for everyone; this is only the teaching
55
- * mark, and it is an administrator's — see the empty-state block below.
52
+ * Whether to spell the first plugin out in words, as a row above the trees.
53
+ * The hover-revealed `+` is unchanged for everyone; this is only the
54
+ * teaching mark, and it is an administrator's — see the row itself below.
56
55
  *
57
56
  * The caller passes a SETTLED verdict, not just a role: the layout derives
58
57
  * it from `workspaceHasNoPlugins`, which stays false while plugin discovery
59
58
  * is loading or has failed. Without that, an admin whose plugins were still
60
59
  * arriving would briefly read "Create a plugin" over a workspace that has
61
- * twenty. The empty-`plugins` check below is therefore structural (where the
62
- * row may appear), while WHETHER it may appear is the caller's call.
60
+ * twenty.
63
61
  *
64
- * Optional, defaulting to OFF, for the same reason `isAdminLoading` is
65
- * optional on the admin context: this props type is public, and a host
62
+ * Optional, defaulting to OFF: this props type is public, and a host
66
63
  * application rendering the nav must stay source-compatible across the
67
- * upgrade. Omitting it reproduces the nav exactly as it shipped, which had
68
- * no written-out CTA at all.
64
+ * upgrade. Omitting it reproduces the nav with no written-out CTA at all.
69
65
  */
70
66
  canCreatePlugin?: boolean;
71
- /**
72
- * The all-plugins index is showing. Beside `filter` rather than inside it: the
73
- * index lists PLACES, not a filtered slice of the catalog, so it is not a
74
- * `LibraryFilter` and pretending otherwise would put a row in the gallery's
75
- * vocabulary that no gallery can render.
76
- */
77
- pluginsIndexActive: boolean;
78
- /** Go to the index — the Library's home. */
79
- onOpenPluginsIndex(): void;
80
67
  /**
81
68
  * A row — or the nav's empty space — was right-clicked. Like every other
82
- * handler here this is an INTENT, not a menu: the layout owns the popup,
83
- * because the verbs in it (add to this plugin, manage its access) need the
84
- * plugin summaries and the workspace, and the sidebar knows neither.
69
+ * handler here this is an INTENT, not a menu: the layout owns the popup.
85
70
  *
86
71
  * Omitted, the nav does nothing on right-click and the browser's own menu
87
72
  * appears — which is the honest default for a view with no actions wired.
88
73
  */
89
74
  onContextMenu?(target: SidebarContextTarget): void;
75
+ /**
76
+ * The two roots as file trees, in the Advanced view — the shared `Skills/`
77
+ * root and the `Plugins/` root, exactly as they are on disk. SLOTS rather
78
+ * than components this nav names: each tree reads the workspace and
79
+ * navigates on its own, and the sidebar stays what it is, a pure view of
80
+ * names and counts. Omitted, the view has no trees, which keeps a host
81
+ * rendering the shipped nav source-compatible.
82
+ */
83
+ skillsTree?: ReactNode;
84
+ pluginsTree?: ReactNode;
90
85
  }
91
86
 
92
87
  /**
93
88
  * The library's nav spine — the prototype's `.side` + `.nav` (lines 55-95).
94
89
  *
95
- * Replaces the loadout rail, which came from a retired mock and has no
96
- * equivalent in the prototype. Plugins ARE the structure here: the sidebar is
97
- * how you move between them, which is why the page no longer carries
98
- * Skills/Integrations filter chips. A plugin is a folder, so this list is
99
- * derived from the catalog's paths rather than from a registry.
90
+ * The two LENSES on the whole catalog first — Everything (the Library's
91
+ * home) and Owned by me — then ONE switch between the two views of what is
92
+ * below them:
93
+ *
94
+ * - TEAMS (shown as "Groups") — Everyone first, the org-wide entry the
95
+ * server leads with, then every group from the access rules: a team's
96
+ * page is what being in that group lets a person use. The caller's own
97
+ * space is a plugin, not a group, and has no row here;
98
+ * - ADVANCED — `Skills/` and `Plugins/` as they are on disk.
99
+ *
100
+ * Plugins have no rows of their own here. They are reached through the
101
+ * pages that list them — Everything, a team — and through their folders in
102
+ * the Plugins tree; a nav that listed every plugin beside every team said
103
+ * the same thing twice and grew with the workspace.
100
104
  *
101
- * It is a pure view of the URL: `filter` comes down, clicks go up as intents,
102
- * and the layout navigates. Nothing here is state, so the back button, a deep
103
- * link and the highlighted row can never drift apart.
105
+ * The switch is the one piece of state the nav holds, and it is VIEW state,
106
+ * not selection: which rows are on screen, not which one is current. The
107
+ * URL still owns selection, so the back button, a deep link and the
108
+ * highlighted row can never drift apart — whichever view is showing. The
109
+ * choice is remembered in the browser so a reload lands on the view the
110
+ * person left; the Teams view is the default.
104
111
  *
105
112
  * This is the CONTENTS only. Being a sidebar — the width, the background, the
106
113
  * collapse animation, the drag handle — belongs to `SidebarFrame`, which
107
114
  * Knowledge's file tree renders inside too. That is the whole reason the two
108
115
  * navs cannot drift: there is one of them, holding a different list.
116
+ *
117
+ * The bottom of the sidebar is not this component's either. The setup
118
+ * reminder that used to close it — "2 integrations need setup. Finish now" —
119
+ * is a FOOTER ROW now (`IntegrationsSetupReminder`), which the layout passes
120
+ * into the frame's `footer` slot beside the change-request dock. A nav that
121
+ * also placed the last row in the column was the reason those two rows
122
+ * disagreed about where the left edge is.
109
123
  */
110
124
  export function PluginsSidebar({
111
125
  filter,
112
126
  onSelect,
113
- plugins,
114
- lockedPlugins,
115
127
  ownedCount,
116
128
  ownedAttention,
117
- personalPluginLabel,
118
- ungroupedCount,
119
- attentionCount,
120
- onFinishSetup,
129
+ teams,
121
130
  onCreatePlugin,
122
131
  canCreatePlugin = false,
123
- pluginsIndexActive,
124
- onOpenPluginsIndex,
125
132
  onContextMenu,
133
+ skillsTree,
134
+ pluginsTree,
126
135
  }: PluginsSidebarProps) {
136
+ const [view, setView] = useState<SidebarView>(readStoredView);
137
+ const switchView = (next: SidebarView) => {
138
+ setView(next);
139
+ storeView(next);
140
+ };
141
+
127
142
  const rowClass = (selected: boolean) =>
128
143
  cn(
129
- 'flex items-center justify-between gap-2 rounded-sm px-2.5 py-1.5 text-ui transition-colors',
144
+ 'flex items-center justify-between gap-2 rounded-sm py-1.5 text-ui transition-colors',
145
+ // The sidebar's row grid, from the frame that owns it — the same inset
146
+ // the footer rows below the tree take.
147
+ SIDEBAR_ROW_INSET,
130
148
  selected ? 'bg-hover font-semibold text-ink' : 'text-ink-muted hover:bg-hover hover:text-ink',
131
149
  );
132
150
 
@@ -135,10 +153,17 @@ export function PluginsSidebar({
135
153
  * row's OWN target rather than restated at each call site, so a row cannot
136
154
  * light up for a filter it does not navigate to.
137
155
  */
138
- const isCurrent = (target: LibraryFilter) =>
139
- target.kind === 'group'
140
- ? filter?.kind === 'group' && filter.plugin === target.plugin
141
- : filter?.kind === target.kind;
156
+ const isCurrent = (target: LibraryFilter) => {
157
+ if (!filter) return false;
158
+ switch (target.kind) {
159
+ case 'team':
160
+ return filter.kind === 'team' && filter.group === target.group;
161
+ case 'group':
162
+ return filter.kind === 'group' && filter.plugin === target.plugin;
163
+ default:
164
+ return filter.kind === target.kind;
165
+ }
166
+ };
142
167
 
143
168
  /**
144
169
  * Report a right-click upward. `preventDefault` only when somebody is
@@ -162,10 +187,11 @@ export function PluginsSidebar({
162
187
  label: string,
163
188
  target: LibraryFilter,
164
189
  count: number,
165
- tone: 'count' | 'pending' = 'count',
190
+ tone: 'count' | 'pending' | 'urgent' = 'count',
166
191
  ) => (
167
192
  <button
168
- key={label}
193
+ // Keyed by what the row IS (its target), never by what it says.
194
+ key={target.kind === 'team' ? `team:${target.group}` : target.kind}
169
195
  type="button"
170
196
  aria-current={isCurrent(target)}
171
197
  className={rowClass(isCurrent(target))}
@@ -178,7 +204,11 @@ export function PluginsSidebar({
178
204
  <span
179
205
  className={cn(
180
206
  'h-4.5 shrink-0 basis-5.5 rounded-md text-center text-meta leading-[18px] tabular-nums',
181
- tone === 'pending' ? 'bg-wait-soft font-bold text-wait' : 'text-ink-faint',
207
+ tone === 'urgent'
208
+ ? 'bg-urgent-soft font-bold text-urgent'
209
+ : tone === 'pending'
210
+ ? 'bg-wait-soft font-bold text-wait'
211
+ : 'text-ink-faint',
182
212
  )}
183
213
  >
184
214
  {count}
@@ -188,201 +218,204 @@ export function PluginsSidebar({
188
218
  );
189
219
 
190
220
  /**
191
- * A plugin the caller cannot read. Same chrome as every other row, because it
192
- * is the same kind of thing — a place in the workspace — and demoting it
193
- * visually would undo the reason it is listed at all.
194
- *
195
- * The count box holds a lock instead of a number, and holds it in the SAME
196
- * slot so the column of counts stays a column. Never a count (the caller
197
- * cannot see inside to count anything) and never the amber attention badge
198
- * (a non-member has nothing to fix). The accessible name carries the state in
199
- * words, so the glyph itself can stay decorative.
221
+ * A tablist is ONE tab stop: the chosen tab takes focus, the arrows move
222
+ * between the tabs and choose as they go (Home/End to the ends), so a
223
+ * keyboard user is not made to Tab through both views to reach the rows.
224
+ * Roving `tabIndex` is what makes the unchosen tab reachable by arrow and
225
+ * not by Tab.
200
226
  */
201
- const lockedRow = (name: string) => {
202
- const target: LibraryFilter = { kind: 'group', plugin: name };
203
- return (
204
- <button
205
- key={`locked:${name}`}
206
- type="button"
207
- aria-label={`${name} (locked)`}
208
- aria-current={isCurrent(target)}
209
- className={rowClass(isCurrent(target))}
210
- onClick={() => onSelect(target)}
211
- // A locked row gets the SAME menu as a readable one, for the same
212
- // reason it gets the same click: a plugin you are not in is still a
213
- // place, and `Manage access` is exactly the item an admin locked out of
214
- // one needs. Which verbs are actually true is the layout's call.
215
- onContextMenu={(e) => openMenu(e, target, name, e.currentTarget)}
216
- >
217
- <span className="truncate">{name}</span>
218
- <span className="flex h-4.5 shrink-0 basis-5.5 items-center justify-center text-ink-faint">
219
- <LockGlyph className="size-3" />
220
- </span>
221
- </button>
222
- );
227
+ const onTablistKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
228
+ const order: SidebarView[] = ['teams', 'advanced'];
229
+ const at = order.indexOf(view);
230
+ let next: SidebarView | null = null;
231
+ if (e.key === 'ArrowRight' || e.key === 'ArrowDown') next = order[(at + 1) % order.length]!;
232
+ else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') next = order[(at - 1 + order.length) % order.length]!;
233
+ else if (e.key === 'Home') next = order[0]!;
234
+ else if (e.key === 'End') next = order[order.length - 1]!;
235
+ if (next === null) return;
236
+ e.preventDefault();
237
+ switchView(next);
238
+ e.currentTarget.querySelector<HTMLElement>(`#library-view-tab-${next}`)?.focus();
223
239
  };
224
240
 
225
- return (
226
- <>
227
- <nav
228
- aria-label="Library plugins"
229
- className="flex min-h-0 flex-1 flex-col gap-px overflow-y-auto"
230
- // The nav's empty space is a target too — Knowledge's tree gives its
231
- // ROOT row a menu holding the create verbs, and this is where the
232
- // Library's equivalent click lands. Rows stop the event before it
233
- // reaches here, so this only ever fires on the gaps between them.
234
- onContextMenu={(e) => openMenu(e, null, 'Library', null)}
235
- >
236
- {/* The home row, above every section and belonging to none of them:
237
- it is where the Library opens, and the one place that lists the
238
- plugins you are NOT in beside the ones you are. Unlabelled and
239
- first for the same reason — a destination the whole surface
240
- hangs off does not sit inside a category of lenses.
241
-
242
- Written out rather than built by `row`, because it is the one
243
- row with no `LibraryFilter` behind it: the index is a list of
244
- PLACES, not a slice of the catalog. Its menu is therefore the
245
- nav's own (`filter: null`) — create a plugin, and none of the
246
- verbs that need a folder to point at. */}
247
- <button
248
- type="button"
249
- aria-current={pluginsIndexActive}
250
- className={rowClass(pluginsIndexActive)}
251
- onClick={onOpenPluginsIndex}
252
- onContextMenu={(e) => openMenu(e, null, 'All plugins', e.currentTarget)}
253
- >
254
- <span className="truncate">All plugins</span>
255
- </button>
256
-
257
- {/* Lenses — the whole catalog, sliced — which is exactly what the
258
- plugin rows below are not. Naming the section is what keeps that
259
- distinction visible. `Everything` is a row again now that the
260
- Library lands on the plugins index instead: without one it would
261
- be a page with no way in. */}
262
- <SectionLabel spaced>Library</SectionLabel>
263
- {row('Everything', { kind: 'all' }, 0)}
264
- {/* Amber is a summons, not a total. It shows how many of your own
265
- items need something FROM YOU; when none do, the slot falls back
266
- to the plain count of what you own, in grey. A permanent amber 26
267
- beside "Owned by me" trained the eye to ignore the one colour on
268
- this page that is supposed to mean "look here". */}
269
- {row(
270
- 'Owned by me',
271
- { kind: 'owned' },
272
- ownedAttention > 0 ? ownedAttention : ownedCount,
273
- ownedAttention > 0 ? 'pending' : 'count',
274
- )}
275
- <PluginsLabel onCreate={onCreatePlugin} />
241
+ const tab = (id: SidebarView, label: string) => (
242
+ <button
243
+ key={id}
244
+ type="button"
245
+ role="tab"
246
+ id={`library-view-tab-${id}`}
247
+ aria-selected={view === id}
248
+ aria-controls={`library-view-${id}`}
249
+ tabIndex={view === id ? 0 : -1}
250
+ className={cn(
251
+ 'flex-1 rounded-sm px-2 py-1 text-center text-meta font-semibold transition-[background-color,color,box-shadow]',
252
+ view === id ? 'bg-surface text-ink shadow-card' : 'text-ink-muted hover:text-ink',
253
+ )}
254
+ onClick={() => switchView(id)}
255
+ >
256
+ {label}
257
+ </button>
258
+ );
276
259
 
277
- {/* Your own space leads the plugins, as in the prototype (line 2487):
278
- it is the one you are always in. */}
279
- {row(personalPluginLabel, { kind: 'ungrouped' }, ungroupedCount)}
280
- {plugins.map(({ plugin, count, attention }) =>
281
- // Amber wins the count slot: a plugin that needs setup is telling you
282
- // something, and how many items it holds is not the news.
283
- row(
284
- plugin,
285
- { kind: 'group', plugin },
286
- attention > 0 ? attention : count,
287
- attention > 0 ? 'pending' : 'count',
288
- ),
289
- )}
290
- {/* The heading's `+` is hover-revealed, and a person with no plugins
291
- yet is exactly the person who has not learned to hover it. While
292
- the workspace holds no plugins AT ALL, the way to the first one is
293
- said in words, as a row where it would sit — with a chalk arrow
294
- from the empty space below, the same margin-note voice as the
295
- empty plugin page. It stands down the moment any plugin exists,
296
- readable or locked: a locked plugin means someone already created
297
- one, and this is a doorway for an untouched workspace, not a
298
- permanent duplicate of the `+`.
260
+ return (
261
+ <nav
262
+ aria-label="Library navigation"
263
+ className="flex min-h-0 flex-1 flex-col gap-px overflow-y-auto"
264
+ // The nav's empty space is a target too — Knowledge's tree gives its
265
+ // ROOT row a menu holding the create verbs, and this is where the
266
+ // Library's equivalent click lands. Rows stop the event before it
267
+ // reaches here, so this only ever fires on the gaps between them.
268
+ onContextMenu={(e) => openMenu(e, null, 'Library', null)}
269
+ >
270
+ {/* The two lenses on the whole catalog, unlabelled and first:
271
+ Everything is where the Library opens, and a destination the
272
+ whole surface hangs off does not sit inside a category. */}
273
+ {row('Everything', { kind: 'all' }, 0)}
274
+ {/* Amber is a summons, not a total. It shows how many of your own
275
+ items need something FROM YOU; when none do, the slot falls back
276
+ to the plain count of what you own, in grey. A permanent amber 26
277
+ beside "Owned by me" trained the eye to ignore the one colour on
278
+ this page that is supposed to mean "look here". */}
279
+ {row(
280
+ 'Owned by me',
281
+ { kind: 'owned' },
282
+ ownedAttention > 0 ? ownedAttention : ownedCount,
283
+ ownedAttention > 0 ? 'pending' : 'count',
284
+ )}
299
285
 
300
- Administrators only. On an untouched workspace the first plugin is
301
- theirs to make, and telling everyone else to make it points them
302
- at a decision that is not theirs. The `+` above is untouched for
303
- every caller — this is the teaching mark, not the affordance. */}
304
- {canCreatePlugin && plugins.length === 0 && lockedPlugins.length === 0 && (
305
- <div className="relative">
306
- <button
307
- type="button"
308
- onClick={onCreatePlugin}
309
- className="flex items-center gap-2 rounded-sm px-2.5 py-1.5 text-left text-ui text-ink-faint transition-colors hover:bg-hover hover:text-ink"
310
- >
311
- <span aria-hidden="true">+</span>
312
- <span className="truncate">Create a plugin</span>
313
- </button>
314
- {/* Mirrored, so the tip points up-left at the row's words from
315
- the room an empty nav is guaranteed to have beneath it. */}
316
- <ChalkArrow className="pointer-events-none absolute left-[22px] top-[30px] h-[52px] w-[64px] -scale-x-100 text-ink-faint" />
317
- </div>
318
- )}
319
- {/* Locked plugins, after the prototype's 14px `.navgap`. The gap is the
320
- whole statement: these are in the same list because they are in the
321
- same workspace, and below a break because you are not in them. */}
322
- {lockedPlugins.length > 0 && <div className="h-3.5" aria-hidden="true" />}
323
- {lockedPlugins.map(lockedRow)}
324
- </nav>
286
+ {/* The switch — a segmented control as quiet as the rows, on the
287
+ nav's own hover tint, the chosen half lifted onto the surface. */}
288
+ <div
289
+ role="tablist"
290
+ aria-label="Sidebar view"
291
+ className="mt-4 mb-2 flex gap-0.5 rounded-md bg-hover p-0.5"
292
+ onKeyDown={onTablistKeyDown}
293
+ // The switch is a control, not empty nav space: a right-click on it
294
+ // is nobody's to answer, so it must not reach the nav behind it.
295
+ onContextMenu={(e) => e.stopPropagation()}
296
+ >
297
+ {tab('teams', 'Groups')}
298
+ {tab('advanced', 'Advanced')}
299
+ </div>
325
300
 
326
- {attentionCount > 0 && (
301
+ {/* Both panels stay MOUNTED and the inactive one is hidden, not
302
+ dropped: a tab's `aria-controls` always names a panel that exists,
303
+ and the trees keep what a person opened in them (expanded folders,
304
+ a rename in progress) across a switch and back. */}
305
+ <div
306
+ role="tabpanel"
307
+ id="library-view-teams"
308
+ aria-labelledby="library-view-tab-teams"
309
+ hidden={view !== 'teams'}
310
+ className="flex flex-col gap-px"
311
+ >
312
+ {/* Groups only: your own space is not a group — it is reached from
313
+ its row on Everything and its folder in the Plugins tree. */}
314
+ {teams.map(({ name, count, urgent }) =>
315
+ // Orange wins the count slot: members locked out of a skill outrank
316
+ // how much the team can use, which is not the news.
317
+ row(
318
+ name,
319
+ { kind: 'team', group: name },
320
+ urgent > 0 ? urgent : count,
321
+ urgent > 0 ? 'urgent' : 'count',
322
+ ),
323
+ )}
324
+ </div>
325
+ <div
326
+ role="tabpanel"
327
+ id="library-view-advanced"
328
+ aria-labelledby="library-view-tab-advanced"
329
+ hidden={view !== 'advanced'}
330
+ className="flex flex-col gap-px"
331
+ >
332
+ {/* The usual ways to a new plugin are a right-click — on the nav's
333
+ empty space, or on a folder in the Plugins tree — and a person
334
+ with no plugins yet is exactly the person who has not learned
335
+ either. While the workspace holds no plugins AT ALL, the way to
336
+ the first one is said in words, as a row above the trees.
337
+ Words only, no chalk arrow: the `Skills/` and `Plugins/` roots
338
+ render directly beneath this row even when both are empty, so
339
+ there is no empty space for an arrow to come from — it drew
340
+ across the two root rows. (The empty plugin page keeps its
341
+ arrow; it has the room.) Administrators only: on an untouched
342
+ workspace the first plugin is theirs to make, and telling
343
+ everyone else to make it points them at a decision that is not
344
+ theirs. (Everything says the same in its plugin band, for
345
+ whoever never opens this view.) */}
346
+ {canCreatePlugin && (
327
347
  <button
328
348
  type="button"
329
- onClick={onFinishSetup}
330
- className="mt-2 rounded-sm border-t border-line px-2.5 pt-3.5 text-left text-meta text-ink-faint hover:text-ink"
349
+ onClick={onCreatePlugin}
350
+ className={cn(
351
+ 'flex items-center gap-2 rounded-sm py-1.5 text-left text-ui text-ink-faint transition-colors hover:bg-hover hover:text-ink',
352
+ SIDEBAR_ROW_INSET,
353
+ )}
331
354
  >
332
- {attentionCount} {attentionCount === 1 ? 'integration needs' : 'integrations need'} setup. Finish now
355
+ <span aria-hidden="true">+</span>
356
+ <span className="truncate">Create a plugin</span>
333
357
  </button>
334
358
  )}
335
- </>
359
+ {skillsTree}
360
+ {pluginsTree}
361
+ </div>
362
+ </nav>
336
363
  );
337
364
  }
338
365
 
339
366
  /**
340
- * The `INCLUDED IN YOUR MCP` heading, and the one way to make a new plugin —
341
- * the prototype's `.lbladd` (line 78).
342
- *
343
- * The heading says what this list IS rather than what its rows are called:
344
- * these folders are the set mounted into the caller's MCP — the agent's
345
- * working context — not merely a directory of plugins. (The locked rows that
346
- * trail the list sit below a gap for exactly that reason: they are in the
347
- * workspace but not in your MCP, and the break is what keeps the heading
348
- * honest about them.)
349
- *
350
- * `All plugins` is NOT a row here. It heads the whole nav instead: it is the
351
- * Library's home rather than one more entry in the set mounted into your MCP,
352
- * and inside this list it used to collect the clicks meant for the plugins
353
- * under it.
354
- *
355
- * The `+` is always in the DOM and always reachable by keyboard; only its
356
- * opacity follows hover, so the nav stays quiet without the control being
357
- * conditional. `focus-visible:opacity-100` is what keeps that honest for
358
- * anyone who never hovers anything.
367
+ * The remembered view. Browser storage is a per-viewer convenience: it can
368
+ * be absent, refused or cleared, and the nav must render either way — so
369
+ * every read and write is guarded and the default is the Teams view.
359
370
  */
360
- /**
361
- * A nav section's name. The first one has no top padding — the sidebar's own
362
- * `pt-6` already placed it — so the two labels are the same component with
363
- * their spacing decided by where they sit, not by which one they are.
364
- */
365
- function SectionLabel({ children, spaced = false }: { children: ReactNode; spaced?: boolean }) {
366
- return (
367
- <div className={cn('px-2.5 pb-1.5 text-label uppercase text-ink-faint', spaced && 'pt-5')}>
368
- {children}
369
- </div>
370
- );
371
+ const VIEW_STORAGE_KEY = 'bevel-library-sidebar-view';
372
+
373
+ function readStoredView(): SidebarView {
374
+ try {
375
+ return window.localStorage.getItem(VIEW_STORAGE_KEY) === 'advanced' ? 'advanced' : 'teams';
376
+ } catch {
377
+ return 'teams';
378
+ }
379
+ }
380
+
381
+ function storeView(view: SidebarView): void {
382
+ try {
383
+ window.localStorage.setItem(VIEW_STORAGE_KEY, view);
384
+ } catch {
385
+ // A browser that refuses storage still gets the view for this session.
386
+ }
371
387
  }
372
388
 
373
- function PluginsLabel({ onCreate }: { onCreate(): void }) {
389
+ /**
390
+ * A nav section's name, with an optional row of actions at its right edge.
391
+ * The first one has no top padding — the sidebar's own `pt-6` already placed
392
+ * it — so every label is the same component with its spacing decided by where
393
+ * it sits, not by which one it is.
394
+ *
395
+ * The actions are always in the DOM and always reachable by keyboard; only
396
+ * their opacity follows hover, so the nav stays quiet without the controls
397
+ * being conditional. `focus-within:opacity-100` is what keeps that honest for
398
+ * anyone who never hovers anything.
399
+ */
400
+ export function SectionLabel({
401
+ children,
402
+ spaced = false,
403
+ actions,
404
+ }: {
405
+ children: ReactNode;
406
+ spaced?: boolean;
407
+ actions?: ReactNode;
408
+ }) {
374
409
  return (
375
- <div className="group/label flex items-center gap-1 px-2.5 pb-1.5 pt-5">
376
- <span className="text-label uppercase text-ink-faint">Included in your MCP</span>
377
- <button
378
- type="button"
379
- onClick={onCreate}
380
- title="New plugin"
381
- aria-label="New plugin"
382
- className="ml-auto flex size-4.5 items-center justify-center rounded-xs text-ui leading-none text-ink-faint opacity-0 transition-opacity hover:bg-hover hover:text-ink focus-visible:opacity-100 group-hover/label:opacity-100"
383
- >
384
- +
385
- </button>
410
+ <div
411
+ className={cn('group/label flex items-center gap-1 pb-1.5', SIDEBAR_ROW_INSET, spaced && 'pt-5')}
412
+ >
413
+ <span className="text-label uppercase text-ink-faint">{children}</span>
414
+ {actions && (
415
+ <span className="ml-auto flex items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover/label:opacity-100">
416
+ {actions}
417
+ </span>
418
+ )}
386
419
  </div>
387
420
  );
388
421
  }