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