@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
@@ -0,0 +1,364 @@
1
+ import { describe, it, expect, afterEach } from 'vitest';
2
+ import { DEFAULT_KB_LAYOUT, configureKbLayout } from '@bevel-software/platform-shared';
3
+ import type { AccessPrincipalRef, PathPrincipals } from '../../../access/api';
4
+ import type { FileTreeEntry } from '@bevel-software/platform-shared';
5
+ import {
6
+ accessChangeLines,
7
+ deleteSentence,
8
+ moveQuestion,
9
+ moveSentence,
10
+ moveWarnings,
11
+ platformFileDragRefusal,
12
+ platformFileMoveRefusal,
13
+ principalLabel,
14
+ } from '../treeConfirm';
15
+
16
+ /**
17
+ * The delete question counts what the listing shows. When the caller's read
18
+ * rules kept entries out of it, the delete still takes them, so the sentence
19
+ * stops naming a count as the whole and says what the count is.
20
+ */
21
+ describe('deleteSentence', () => {
22
+ const folder: FileTreeEntry = {
23
+ name: 'Sales',
24
+ relativePath: 'knowledge-base/KnowledgeBase/Sales',
25
+ type: 'directory',
26
+ children: [
27
+ { name: 'a.md', relativePath: 'knowledge-base/KnowledgeBase/Sales/a.md', type: 'file' },
28
+ { name: 'b.md', relativePath: 'knowledge-base/KnowledgeBase/Sales/b.md', type: 'file' },
29
+ ],
30
+ };
31
+
32
+ it('counts the files it can see when the listing is whole', () => {
33
+ expect(deleteSentence(folder)).toBe('Delete Sales and its 2 files?');
34
+ });
35
+
36
+ it('says "everything in it" when the folder had entries withheld', () => {
37
+ expect(deleteSentence(folder, undefined, true)).toBe(
38
+ 'Delete Sales and everything in it? (2 files on this branch you can see; it holds more you can\'t.)',
39
+ );
40
+ });
41
+ });
42
+
43
+ /**
44
+ * What the move confirmation says about access. The tester who failed the
45
+ * previous move warning asked for names — "these people would lose the
46
+ * following access, these people would gain the following access" — so these
47
+ * cases are the sentences, not the resolution: the resolver's before and after
48
+ * lists go in, the lines the dialog reads go out.
49
+ */
50
+
51
+ const group = (name: string): AccessPrincipalRef => ({ kind: 'group', name });
52
+ const role = (name: string): AccessPrincipalRef => ({ kind: 'role', name });
53
+ const person = (name: string, email: string): AccessPrincipalRef => ({ kind: 'person', name, email });
54
+ const plugin = (token: string): AccessPrincipalRef => ({ kind: 'plugin', name: token });
55
+
56
+ /** The layout is module state shared by the whole file; each test that names one puts the defaults back. */
57
+ afterEach(() => configureKbLayout({ ...DEFAULT_KB_LAYOUT }));
58
+
59
+ const side = (read: AccessPrincipalRef[], write: AccessPrincipalRef[] = []): PathPrincipals => ({
60
+ read,
61
+ write,
62
+ });
63
+
64
+ describe('accessChangeLines', () => {
65
+ it('names who loses access, by verb', () => {
66
+ const change = accessChangeLines(
67
+ side([group('Engineering')], [group('Engineering')]),
68
+ side([], []),
69
+ );
70
+
71
+ expect(change.lose).toEqual([
72
+ 'Engineering: can no longer open',
73
+ 'Engineering: can no longer edit',
74
+ ]);
75
+ expect(change.gain).toEqual([]);
76
+ });
77
+
78
+ it('names who gains access, by verb', () => {
79
+ const change = accessChangeLines(side([], []), side([group('Product')], [group('Product')]));
80
+
81
+ expect(change.lose).toEqual([]);
82
+ expect(change.gain).toEqual(['Product: can open', 'Product: can edit']);
83
+ });
84
+
85
+ it('lists both blocks when the move costs one group and serves another', () => {
86
+ const change = accessChangeLines(side([group('Engineering')]), side([group('Product')]));
87
+
88
+ expect(change.lose).toEqual(['Engineering: can no longer open']);
89
+ expect(change.gain).toEqual(['Product: can open']);
90
+ });
91
+
92
+ it('reports no change at all when both sides resolve the same', () => {
93
+ const both = side([group('Engineering'), person('Ali Raza', 'ali@x.io')], [group('Engineering')]);
94
+
95
+ expect(accessChangeLines(both, both)).toEqual({ lose: [], gain: [] });
96
+ });
97
+
98
+ it('is unmoved by the order the resolver happens to list principals in', () => {
99
+ const before = side([group('Engineering'), group('Product')]);
100
+ const after = side([group('Product'), group('Engineering')]);
101
+
102
+ expect(accessChangeLines(before, after)).toEqual({ lose: [], gain: [] });
103
+ });
104
+
105
+ it('names a directly granted person, by the name on the grant', () => {
106
+ const change = accessChangeLines(side([person('Ali Raza', 'ali@x.io')]), side([]));
107
+
108
+ expect(change.lose).toEqual(['Ali Raza: can no longer open']);
109
+ });
110
+
111
+ it('matches a person on their address, whatever name each side carries', () => {
112
+ const change = accessChangeLines(
113
+ side([person('Ali Raza', 'ali@x.io')]),
114
+ side([person('ali@x.io', 'ALI@x.io')]),
115
+ );
116
+
117
+ expect(change).toEqual({ lose: [], gain: [] });
118
+ });
119
+
120
+ it('falls back to a nameless person’s address rather than an empty line', () => {
121
+ const change = accessChangeLines(side([]), side([person('', 'ali@x.io')]));
122
+
123
+ expect(change.gain).toEqual(['ali@x.io: can open']);
124
+ });
125
+
126
+ it('keeps a group and a same-named role apart — they are different principals', () => {
127
+ const change = accessChangeLines(side([group('Design')]), side([role('Design')]));
128
+
129
+ expect(change.lose).toEqual(['Design: can no longer open']);
130
+ expect(change.gain).toEqual(['Design: can open']);
131
+ });
132
+
133
+ it('names a plugin principal as the share sheet does', () => {
134
+ const change = accessChangeLines(side([]), side([plugin('plugin/GTM/read')]));
135
+
136
+ expect(change.gain).toEqual(['GTM · readers: can open']);
137
+ });
138
+
139
+ it('names the built-in everyone role Everyone', () => {
140
+ const change = accessChangeLines(side([role('everyone')]), side([]));
141
+
142
+ expect(change.lose).toEqual(['Everyone: can no longer open']);
143
+ });
144
+
145
+ it('puts one principal’s two verbs together, opening before editing', () => {
146
+ const change = accessChangeLines(
147
+ side([group('Engineering'), group('Ops')], [group('Ops')]),
148
+ side([]),
149
+ );
150
+
151
+ expect(change.lose).toEqual([
152
+ 'Engineering: can no longer open',
153
+ 'Ops: can no longer open',
154
+ 'Ops: can no longer edit',
155
+ ]);
156
+ });
157
+
158
+ it('lists a principal in both blocks when it trades one verb for another', () => {
159
+ const change = accessChangeLines(
160
+ side([group('Engineering')], [group('Engineering')]),
161
+ side([group('Engineering')], []),
162
+ );
163
+
164
+ expect(change.lose).toEqual(['Engineering: can no longer edit']);
165
+ expect(change.gain).toEqual([]);
166
+ });
167
+
168
+ it('shows six lines and folds the rest into "and N more"', () => {
169
+ const many = Array.from({ length: 9 }, (_, i) => group(`Team ${i + 1}`));
170
+ const change = accessChangeLines(side(many), side([]));
171
+
172
+ expect(change.lose).toHaveLength(7);
173
+ expect(change.lose[5]).toBe('Team 6: can no longer open');
174
+ expect(change.lose[6]).toBe('and 3 more');
175
+ });
176
+
177
+ it('caps at six without a count when there are exactly six', () => {
178
+ const six = Array.from({ length: 6 }, (_, i) => group(`Team ${i + 1}`));
179
+ const change = accessChangeLines(side([]), side(six));
180
+
181
+ expect(change.gain).toHaveLength(6);
182
+ expect(change.gain.at(-1)).toBe('Team 6: can open');
183
+ });
184
+
185
+ it('caps each block on its own', () => {
186
+ const losers = Array.from({ length: 8 }, (_, i) => group(`Old ${i + 1}`));
187
+ const change = accessChangeLines(side(losers), side([group('Product')]));
188
+
189
+ expect(change.lose.at(-1)).toBe('and 2 more');
190
+ expect(change.gain).toEqual(['Product: can open']);
191
+ });
192
+ });
193
+
194
+ describe('the move question', () => {
195
+ it('asks it plainly, for the blocks to answer under', () => {
196
+ expect(moveQuestion('contract.pdf', 'Sales')).toBe('Move contract.pdf to Sales?');
197
+ });
198
+
199
+ // The fallback sentence, still said when the access change is not known.
200
+ it("uses 's for a destination that does not end in s", () => {
201
+ expect(moveSentence('contract.pdf', 'Old')).toBe(
202
+ "Move contract.pdf to Old? Access to it will follow Old's rules from now on.",
203
+ );
204
+ });
205
+
206
+ it("uses a bare ' for one that does", () => {
207
+ expect(moveSentence('contract.pdf', 'Sales')).toBe(
208
+ "Move contract.pdf to Sales? Access to it will follow Sales' rules from now on.",
209
+ );
210
+ });
211
+ });
212
+
213
+ describe('principalLabel', () => {
214
+ it('leaves a malformed plugin token as written rather than inventing a name', () => {
215
+ expect(principalLabel(plugin('plugin/GTM/delete'))).toBe('plugin/GTM/delete');
216
+ });
217
+ });
218
+
219
+ const KB = 'knowledge-base';
220
+
221
+ /**
222
+ * What the tree refuses before it asks, and what it no longer warns about.
223
+ *
224
+ * The refusal is the server's sentence, decided by the shared predicate, so
225
+ * the sidebar cannot drift from the endpoint it would have called.
226
+ */
227
+ describe('platformFileMoveRefusal', () => {
228
+ it('refuses the four platform files where the platform reads them', () => {
229
+ expect(platformFileMoveRefusal(`${KB}/access.md`, KB))
230
+ .toBe('access.md is a platform file and stays in its folder.');
231
+ expect(platformFileMoveRefusal(`${KB}/Sales/access.md`, KB))
232
+ .toBe('access.md is a platform file and stays in its folder.');
233
+ expect(platformFileMoveRefusal(`${KB}/Sales/.bevelignore`, KB))
234
+ .toBe('.bevelignore is a platform file and stays in its folder.');
235
+ expect(platformFileMoveRefusal(`${KB}/roles.yaml`, KB))
236
+ .toBe('roles.yaml is a platform file and stays in its folder.');
237
+ expect(platformFileMoveRefusal(`${KB}/AGENTS.md`, KB))
238
+ .toBe('AGENTS.md is a platform file and stays in its folder.');
239
+ });
240
+
241
+ it('leaves content alone, including a nested roles.yaml or AGENTS.md the platform never reads', () => {
242
+ expect(platformFileMoveRefusal(`${KB}/Sales/deal.md`, KB)).toBeNull();
243
+ expect(platformFileMoveRefusal(`${KB}/Sales/roles.yaml`, KB)).toBeNull();
244
+ expect(platformFileMoveRefusal(`${KB}/Sales/AGENTS.md`, KB)).toBeNull();
245
+ // Exact spelling, as the platform reads it.
246
+ expect(platformFileMoveRefusal(`${KB}/Sales/Access.md`, KB)).toBeNull();
247
+ });
248
+
249
+ /**
250
+ * The tree's copy of the rule reads the layout the browser was served, so a
251
+ * deployment that renamed its guide gets the same two answers here as it
252
+ * does from the server: ours is managed, theirs is a page.
253
+ */
254
+ it('follows the configured guide name — and lets go of AGENTS.md when it differs', () => {
255
+ configureKbLayout({ ...DEFAULT_KB_LAYOUT, agentsFile: 'HEXIS.md' });
256
+ expect(platformFileMoveRefusal(`${KB}/HEXIS.md`, KB))
257
+ .toBe('HEXIS.md is a platform file and stays in its folder.');
258
+ // The customer's own conventions file moves, renames and deletes like any
259
+ // page — which is the whole point of naming ours something else.
260
+ expect(platformFileMoveRefusal(`${KB}/AGENTS.md`, KB)).toBeNull();
261
+ expect(platformFileDragRefusal(`${KB}/AGENTS.md`, KB, false)).toBeNull();
262
+ // Root-only, like `roles.yaml`: a nested copy of ours is content too.
263
+ expect(platformFileMoveRefusal(`${KB}/Sales/HEXIS.md`, KB)).toBeNull();
264
+ });
265
+
266
+ it('refuses nothing outside the KB clone, or before the clone folder is known', () => {
267
+ // No repo-relative form to judge — the server is the gate and says the
268
+ // same sentence, so the tree stays quiet rather than guessing.
269
+ expect(platformFileMoveRefusal(`${KB}/access.md`, null)).toBeNull();
270
+ expect(platformFileMoveRefusal('scratch/access.md', KB)).toBeNull();
271
+ });
272
+ });
273
+
274
+ describe('platformFileDragRefusal', () => {
275
+ const sentence = (n: string) => `${n} is a platform file and stays in its folder.`;
276
+
277
+ it('is the rename refusal for anyone who is not an admin', () => {
278
+ for (const p of [`${KB}/access.md`, `${KB}/Sales/access.md`, `${KB}/Sales/.bevelignore`]) {
279
+ expect(platformFileDragRefusal(p, KB, false)).toBe(platformFileMoveRefusal(p, KB));
280
+ }
281
+ });
282
+
283
+ it('lets an admin drag a MISPLACED copy — the drag that puts one back', () => {
284
+ expect(platformFileDragRefusal(`${KB}/Sales/access.md`, KB, true)).toBeNull();
285
+ expect(platformFileDragRefusal(`${KB}/Sales/.bevelignore`, KB, true)).toBeNull();
286
+ });
287
+
288
+ it("never lets go of the root's own copy, which is the one a restore puts back", () => {
289
+ expect(platformFileDragRefusal(`${KB}/access.md`, KB, true)).toBe(sentence('access.md'));
290
+ expect(platformFileDragRefusal(`${KB}/roles.yaml`, KB, true)).toBe(sentence('roles.yaml'));
291
+ expect(platformFileDragRefusal(`${KB}/.bevelignore`, KB, true)).toBe(sentence('.bevelignore'));
292
+ expect(platformFileDragRefusal(`${KB}/AGENTS.md`, KB, true)).toBe(sentence('AGENTS.md'));
293
+ });
294
+
295
+ it('leaves ordinary content alone for either of them', () => {
296
+ for (const admin of [true, false]) {
297
+ expect(platformFileDragRefusal(`${KB}/Sales/deal.md`, KB, admin)).toBeNull();
298
+ expect(platformFileDragRefusal(`${KB}/access.md`, null, admin)).toBeNull();
299
+ }
300
+ });
301
+ });
302
+
303
+ describe('moveWarnings', () => {
304
+ it('no longer warns about a platform file — the move never reaches the dialog', () => {
305
+ expect(
306
+ moveWarnings({
307
+ sourcePath: `${KB}/KnowledgeBase/Legal/access.md`,
308
+ targetDir: `${KB}/KnowledgeBase/Sales`,
309
+ destinationLabel: 'Sales',
310
+ kbDirName: KB,
311
+ canWrite: null,
312
+ }),
313
+ ).toEqual([]);
314
+ });
315
+
316
+ it('still says what it alone knows: a denied destination and a change of root', () => {
317
+ expect(
318
+ moveWarnings({
319
+ sourcePath: `${KB}/KnowledgeBase/Legal/contract.pdf`,
320
+ targetDir: `${KB}/Data`,
321
+ destinationLabel: 'Data',
322
+ kbDirName: KB,
323
+ canWrite: false,
324
+ }),
325
+ ).toEqual([
326
+ "You can't write to Data — the move will be refused.",
327
+ 'This moves it out of KnowledgeBase/ into Data/ — the two roots are handled differently.',
328
+ ]);
329
+ });
330
+
331
+ it('does not predict a refusal for the one move a denied destination still takes', () => {
332
+ // The admin's restore: a misplaced access.md into a folder that has none.
333
+ // "The move will be refused" would be the wrong prediction — this is the
334
+ // move the destination's rules are bypassed for.
335
+ expect(
336
+ moveWarnings({
337
+ sourcePath: `${KB}/KnowledgeBase/Misplaced/access.md`,
338
+ targetDir: `${KB}/KnowledgeBase/Legal`,
339
+ destinationLabel: 'Legal',
340
+ kbDirName: KB,
341
+ canWrite: false,
342
+ isAdmin: true,
343
+ }),
344
+ ).toEqual([
345
+ "You can't write to Legal, but putting access.md back where the platform reads it is allowed for an Admin.",
346
+ ]);
347
+ });
348
+
349
+ it('promises a non-admin nothing: the exception is not theirs to use', () => {
350
+ // A nested `roles.yaml` is ordinary content, so anyone can drag one at
351
+ // the root — and for anyone but an admin the destination's refusal is
352
+ // exactly what happens.
353
+ expect(
354
+ moveWarnings({
355
+ sourcePath: `${KB}/KnowledgeBase/Misplaced/roles.yaml`,
356
+ targetDir: KB,
357
+ destinationLabel: 'the top level',
358
+ kbDirName: KB,
359
+ canWrite: false,
360
+ isAdmin: false,
361
+ }),
362
+ ).toEqual(["You can't write to the top level — the move will be refused."]);
363
+ });
364
+ });
@@ -0,0 +1,35 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { uploadErrorNextStep } from '../uploadError';
3
+
4
+ /**
5
+ * The banner's last line, pinned directly — it used to be reachable only by
6
+ * rendering a tree, which is exactly the coupling that let the classifier
7
+ * drift: the advice was picked by matching the backend's prose, so a reworded
8
+ * refusal silently started telling the user the wrong thing and no test said
9
+ * so. The status is the contract now.
10
+ */
11
+ describe('uploadErrorNextStep', () => {
12
+ it('sends a refused writer to another folder, or to the owner', () => {
13
+ expect(uploadErrorNextStep(403)).toBe('Try another folder or ask its owner.');
14
+ });
15
+
16
+ it('sends a lapsed session back to sign in — another folder would refuse the same way', () => {
17
+ expect(uploadErrorNextStep(401)).toBe('Sign in again, then try once more.');
18
+ });
19
+
20
+ it('asks for a smaller file when the upload was too big', () => {
21
+ expect(uploadErrorNextStep(413)).toContain('try a smaller one');
22
+ });
23
+
24
+ it('does not restate the size cap, which lives in the backend', () => {
25
+ // The old copy promised "Files up to 50 MB". The number is the
26
+ // backend's (`MAX_UPLOAD_BYTES`), and a change there must not leave this
27
+ // line quietly lying; the server's own reason carries the limit.
28
+ expect(uploadErrorNextStep(413)).not.toMatch(/\d/);
29
+ });
30
+
31
+ it('says "try again" for anything else, including a failure with no response', () => {
32
+ expect(uploadErrorNextStep(500)).toBe('Try again, or pick another folder.');
33
+ expect(uploadErrorNextStep(undefined)).toBe('Try again, or pick another folder.');
34
+ });
35
+ });
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Opt-in console diagnostics for the file page (`?trace=files`).
3
+ *
4
+ * Exists to reproduce a report where a file click changes the URL but the page
5
+ * stays on the empty state with no tab strip. `FileRoute` waits on two gates
6
+ * before it opens a file (the git status branch equals the URL branch, and the
7
+ * workspace for that branch bootstrapped), and while either is closed nothing
8
+ * is shown. The trace logs every run of that decision with its inputs, so a
9
+ * browser console tells which gate held the page.
10
+ *
11
+ * The flag is read from the query string once and kept in `sessionStorage`,
12
+ * because a tree click navigates to a clean file URL and would otherwise drop
13
+ * it after the first click. `?trace=off` clears it. Nothing here changes what
14
+ * the page does; with the flag off every call is a no-op.
15
+ */
16
+
17
+ export const FILE_TRACE_STORAGE_KEY = 'hexis.trace.files';
18
+ const PREFIX = '[trace:files]';
19
+
20
+ // Stands in for `sessionStorage` when it is unavailable (private mode quotas,
21
+ // sandboxed frames), so the flag still holds for this page load.
22
+ let memoryFlag = false;
23
+
24
+ /** Reads `?trace=` from `search`, remembering or forgetting the flag for the session. */
25
+ export function syncFileTraceFlag(search: string): boolean {
26
+ const value = new URLSearchParams(search).get('trace');
27
+ if (value === 'off') memoryFlag = false;
28
+ try {
29
+ if (value === 'files') sessionStorage.setItem(FILE_TRACE_STORAGE_KEY, '1');
30
+ else if (value === 'off') sessionStorage.removeItem(FILE_TRACE_STORAGE_KEY);
31
+ } catch {
32
+ // Storage unavailable: `memoryFlag` carries it.
33
+ if (value === 'files') memoryFlag = true;
34
+ }
35
+ return isFileTraceEnabled();
36
+ }
37
+
38
+ export function isFileTraceEnabled(): boolean {
39
+ try {
40
+ return sessionStorage.getItem(FILE_TRACE_STORAGE_KEY) === '1' || memoryFlag;
41
+ } catch {
42
+ return memoryFlag;
43
+ }
44
+ }
45
+
46
+ /** Logs one trace event when the flag is on. `fields` is logged as-is. */
47
+ export function traceFiles(event: string, fields: Record<string, unknown>): void {
48
+ if (!isFileTraceEnabled()) return;
49
+ console.info(PREFIX, event, { at: Math.round(performance.now()), ...fields });
50
+ }
@@ -16,24 +16,71 @@ export const KB_ROOT_DIRS = {
16
16
  };
17
17
 
18
18
  /**
19
- * Descend past the workspace / KB-clone wrapper levels to the node that holds
20
- * the well-known KB root dirs (`KnowledgeBase/`, `Data/`, `Agents/`, …), or
21
- * null when the tree predates the split. Shared by the explorer's sectioning
22
- * and registry-contributed explorer items (e.g. the enterprise Graph view).
19
+ * The repository checkout inside the workspace tree: the direct child of the
20
+ * workspace root named by the deployment (`workspace.kbDirName`, which the
21
+ * bootstrap response already carries), or null when it is not there.
22
+ *
23
+ * A LOOKUP, not a search. This used to descend the tree until it met a node
24
+ * whose children included a well-known root name (`KnowledgeBase/`,
25
+ * `Plugins/`, …) — which is a guess, and on core-staging it guessed the
26
+ * WORKSPACE ROOT, because a stray `KnowledgeBase/` had been written beside
27
+ * the checkout. Every sidebar then read that directory: the stray became
28
+ * "Knowledge", the real checkout was folded in beneath it as ordinary
29
+ * content, and the Skills tree found no `Skills/` at all. The deployment
30
+ * NAMES the folder, so nothing has to be inferred from what happens to sit
31
+ * next to it.
32
+ *
33
+ * Null is an answer, not a cue to look elsewhere: the caller shows the
34
+ * empty-workspace state rather than rendering some other directory's
35
+ * contents (see `CHECKOUT_MISSING_MESSAGE`).
23
36
  */
24
- export function findKbRoot(node: FileTreeEntry | null): FileTreeEntry | null {
25
- if (!node?.children) return null;
26
- const holdsSplit = node.children.some(
27
- (c) => c.type === 'directory' && KB_ROOT_DIRS.has(c.name),
28
- );
29
- if (holdsSplit) return node;
30
- for (const child of node.children) {
31
- if (child.type === 'directory') {
32
- const found = findKbRoot(child);
33
- if (found) return found;
34
- }
35
- }
36
- return null;
37
+ export function checkoutRoot(
38
+ tree: FileTreeEntry | null,
39
+ kbDirName: string | null,
40
+ ): FileTreeEntry | null {
41
+ if (!tree?.children || !kbDirName) return null;
42
+ return tree.children.find((c) => c.type === 'directory' && c.name === kbDirName) ?? null;
43
+ }
44
+
45
+ /**
46
+ * Whether the tree shows the caller anything of the knowledge base at all.
47
+ * What does not count: the reserved root folders themselves (every knowledge
48
+ * base has them, and the server keeps them visible even to a reader who may
49
+ * open nothing inside), and the root `.bevelignore` an admin sees in a
50
+ * knowledge base nobody has written to yet. Anything else — a file, or a
51
+ * folder, at any depth — is an entry on screen.
52
+ *
53
+ * Read from the checkout down, like every other surface. A workspace whose
54
+ * checkout is missing shows nothing, whatever else was written beside it.
55
+ */
56
+ export function treeHasVisibleEntries(tree: FileTreeEntry | null, kbDirName: string | null): boolean {
57
+ const kbRoot = checkoutRoot(tree, kbDirName);
58
+ if (!kbRoot) return false;
59
+ return (kbRoot.children ?? []).some((c) => {
60
+ if (c.type === 'file') return c.name !== '.bevelignore';
61
+ return !KB_ROOT_DIRS.has(c.name) || (c.children?.length ?? 0) > 0;
62
+ });
63
+ }
64
+
65
+ /**
66
+ * Whether ONE root of the tree — the folder at `rootPath` — shows anything.
67
+ * The Library renders `Skills/` and `Plugins/` as trees of their own, and each
68
+ * is empty on its own terms: a knowledge base full of notes still has an
69
+ * empty Skills tree, and the notice that says so belongs to that tree. A root
70
+ * that is not in the listing at all shows nothing.
71
+ */
72
+ export function subtreeHasVisibleEntries(tree: FileTreeEntry | null, rootPath: string): boolean {
73
+ const root = findEntryByPath(tree, rootPath);
74
+ return (root?.children ?? []).some((c) => c.type !== 'file' || c.name !== '.bevelignore');
75
+ }
76
+
77
+ /**
78
+ * How many entries the caller's read rules kept out of ONE folder's subtree —
79
+ * the folder's own `withheld`, which the server sets per directory. 0 for a
80
+ * folder the listing does not have, or one nothing was kept out of.
81
+ */
82
+ export function subtreeWithheld(tree: FileTreeEntry | null, rootPath: string): number {
83
+ return findEntryByPath(tree, rootPath)?.withheld ?? 0;
37
84
  }
38
85
 
39
86
  /** Documents, as opposed to the data, config and archives beside them. */
@@ -53,26 +100,34 @@ const isAccessRulesFile = (entry: FileTreeEntry): boolean => entry.name.toLowerC
53
100
  * the top of the knowledge tree, breadth-first, so the opening suggestion is a
54
101
  * section heading rather than the fifth file inside the first folder.
55
102
  *
56
- * Scoped to exactly what the explorer browses under "Knowledge" —
57
- * `KnowledgeBase/` plus any stray content folder. `Plugins/` is the Skills &
58
- * Tools app's storage and is not a browsing destination here, and the loose
59
- * files at the root (`access.md`, `roles.yaml`) are how the deployment is
60
- * configured, not something to read. A clone that predates the split has no
61
- * named roots to scope to, so its whole tree is the knowledge.
103
+ * Scoped to exactly what the explorer browses under "Knowledge", and scoped
104
+ * to the CHECKOUT: `KnowledgeBase/` plus any content folder beside it inside
105
+ * `<kbDirName>/`. `Plugins/` is the Skills & Tools app's storage and is not a
106
+ * browsing destination here, and the loose files at the checkout root
107
+ * (`access.md`, `roles.yaml`) are how the deployment is configured, not
108
+ * something to read. A clone that predates the split has no named roots at
109
+ * all, so its whole checkout is the knowledge — including the loose files at
110
+ * its root, which in that layout are pages rather than configuration. A
111
+ * workspace with no checkout in it has nothing to offer.
62
112
  *
63
113
  * Fewer than `limit` — including none at all — is a legitimate answer for a
64
114
  * knowledge base that is still empty; the caller says so rather than padding.
65
115
  */
66
- export function suggestedPages(tree: FileTreeEntry | null, limit: number): FileTreeEntry[] {
67
- const kbRoot = findKbRoot(tree);
68
- const roots = kbRoot?.children
69
- ? [
70
- ...kbRoot.children.filter((c) => c.type === 'directory' && c.name === KNOWLEDGE_BASE_DIR),
71
- ...kbRoot.children.filter((c) => c.type === 'directory' && !KB_ROOT_DIRS.has(c.name)),
72
- ]
73
- : tree
74
- ? [tree]
75
- : [];
116
+ export function suggestedPages(
117
+ tree: FileTreeEntry | null,
118
+ kbDirName: string | null,
119
+ limit: number,
120
+ ): FileTreeEntry[] {
121
+ const kbRoot = checkoutRoot(tree, kbDirName);
122
+ const split = kbRoot?.children?.some((c) => c.type === 'directory' && KB_ROOT_DIRS.has(c.name));
123
+ const roots = !kbRoot
124
+ ? []
125
+ : split
126
+ ? [
127
+ ...(kbRoot.children ?? []).filter((c) => c.type === 'directory' && c.name === KNOWLEDGE_BASE_DIR),
128
+ ...(kbRoot.children ?? []).filter((c) => c.type === 'directory' && !KB_ROOT_DIRS.has(c.name)),
129
+ ]
130
+ : [kbRoot];
76
131
 
77
132
  const pages: FileTreeEntry[] = [];
78
133
  let level = roots;
@@ -116,6 +171,28 @@ export function pathExistsInTree(tree: FileTreeEntry | null, relativePath: strin
116
171
  return findEntryByPath(tree, relativePath) !== null;
117
172
  }
118
173
 
174
+ /**
175
+ * Return the tree without one exact workspace-relative path. Reuses untouched
176
+ * branches so a caller can apply it on every render without cloning the whole
177
+ * file tree when the server has already filtered the path.
178
+ */
179
+ export function omitPathFromTree(
180
+ tree: FileTreeEntry | null,
181
+ relativePath: string,
182
+ ): FileTreeEntry | null {
183
+ if (!tree || tree.relativePath === relativePath) return null;
184
+ if (!tree.children) return tree;
185
+
186
+ let changed = false;
187
+ const children: FileTreeEntry[] = [];
188
+ for (const child of tree.children) {
189
+ const visible = omitPathFromTree(child, relativePath);
190
+ if (visible !== child) changed = true;
191
+ if (visible) children.push(visible);
192
+ }
193
+ return changed ? { ...tree, children } : tree;
194
+ }
195
+
119
196
  function collectFilesByBasename(tree: FileTreeEntry | null, basename: string, acc: string[]): void {
120
197
  if (!tree) return;
121
198
  if (tree.type === 'file' && tree.name === basename) acc.push(tree.relativePath);
@@ -152,10 +229,9 @@ export function mergePendingIntoTree(
152
229
  ): FileTreeEntry {
153
230
  if (pending.size === 0) return tree;
154
231
 
232
+ // A spread, so what the server set on a folder (`withheld`) survives the copy.
155
233
  const cloneNode = (node: FileTreeEntry): FileTreeEntry => ({
156
- name: node.name,
157
- relativePath: node.relativePath,
158
- type: node.type,
234
+ ...node,
159
235
  children: node.children ? node.children.map(cloneNode) : undefined,
160
236
  });
161
237
  const root = cloneNode(tree);
@@ -1,4 +1,5 @@
1
1
  import { parseDocument } from 'yaml';
2
+ import { extractFrontmatter } from '@bevel-software/platform-shared';
2
3
 
3
4
  export type FrontmatterData = Record<string, string | string[]>;
4
5
 
@@ -45,10 +46,13 @@ function coerce(value: unknown): string | string[] {
45
46
  * carry access entries that must always surface.
46
47
  */
47
48
  export function parseFrontmatter(content: string): { data: FrontmatterData; body: string } {
48
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
49
- if (!match) return { data: {}, body: content };
49
+ // The SHARED splitter, not a copy of its regex: this panel and the backend
50
+ // have to agree about which files have frontmatter at all, or a file shows
51
+ // no fields here while the catalog reads an id out of it.
52
+ const split = extractFrontmatter(content);
53
+ if (!split) return { data: {}, body: content };
50
54
 
51
- const body = match[2].trimStart();
55
+ const body = split.body.trimStart();
52
56
  const data: FrontmatterData = {};
53
57
 
54
58
  let parsed: unknown;
@@ -57,7 +61,7 @@ export function parseFrontmatter(content: string): { data: FrontmatterData; body
57
61
  // the best-effort value of whatever parsed — so a single malformed entry
58
62
  // doesn't blank the block. (`.toJS()` itself can still throw, e.g. on an
59
63
  // alias bomb; the catch keeps the body readable.)
60
- parsed = parseDocument(match[1]).toJS();
64
+ parsed = parseDocument(split.frontmatter).toJS();
61
65
  } catch {
62
66
  return { data: {}, body };
63
67
  }