@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,11 +1,11 @@
1
1
  import { useMemo, useCallback, useContext, useEffect, useRef, useState } from 'react';
2
- import { Check, XCircle, Lock, AlertTriangle, ArrowLeft, FileText } from 'lucide-react';
2
+ import { Check, XCircle, Lock, AlertTriangle, ArrowLeft, FileText, History } from 'lucide-react';
3
3
  import type { FileTreeEntry, PullRequestSummary } from '@bevel-software/platform-shared';
4
4
  import { useWorkspace } from '../state/workspace.context';
5
5
  import { EditorTabs } from './EditorTabs';
6
6
  import { KbPageHeader } from './KbPageHeader';
7
7
  import { useOpenChangeRequests } from '../hooks/useOpenChangeRequests';
8
- import { Banner, Button, Surface } from '../../../shared/components';
8
+ import { Banner, Button, IconButton, Surface, useFocusHandoff } from '../../../shared/components';
9
9
  import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
10
10
  import { useGit } from '../../git/state/git.context';
11
11
  import { LayoutContext } from '../../layout/state/layout.context';
@@ -33,6 +33,7 @@ import {
33
33
  readFileOnBranch,
34
34
  } from '../../change-requests/services/change-requests.api';
35
35
  import { FileChangeBoxes } from '../../change-requests/components/FileChangeBoxes';
36
+ import { othersPendingBesides } from '../../change-requests/utils/author';
36
37
  import { ChangeRequestDialog } from '../../change-requests/components/ChangeRequestDialog';
37
38
  import { formatEligible } from '../../access/hooks/useFileAccess';
38
39
  import { PR_STALE_EVENT } from '../../../core/events';
@@ -206,7 +207,6 @@ export function FileViewer() {
206
207
  fromBranch: string;
207
208
  toBranch: string;
208
209
  } | null>(null);
209
- const historyAvailable = git.availability === 'ready';
210
210
  const hasUnsavedWork = isManualDirty || manualSaveState === 'saving';
211
211
 
212
212
  const hasPending = pendingFileContent !== null;
@@ -348,6 +348,69 @@ export function FileViewer() {
348
348
  // disables it so a double-click can't fire two acquires.
349
349
  const [isEnteringEdit, setIsEnteringEdit] = useState(false);
350
350
 
351
+ /**
352
+ * The log, and the clock that opens it, are withdrawn while a draft is
353
+ * open. Opening the log unmounts the editor; coming back re-mounts it from
354
+ * its seed, while `proposeBufferRef` still holds the newer keystrokes — so
355
+ * "Back to the document" would show the old text, and Send proposal would
356
+ * submit the new text nobody could see. The skill page applies the same
357
+ * rule (`!editing`) for the same reason. The `isEntering*` beats are in for
358
+ * the "Loading…" moment between the click and the editor, so the clock
359
+ * cannot open the log over an editor that is about to mount.
360
+ */
361
+ const historyAvailable =
362
+ git.availability === 'ready' &&
363
+ !editMode &&
364
+ !isEnteringEdit &&
365
+ !proposeMode &&
366
+ !isEnteringPropose;
367
+ // Losing the log CLOSES the view, rather than parking `activeTab` on it.
368
+ // `availability` is re-derived from a polled status call, so one failed
369
+ // poll flips it off and the next good one flips it back. Left on
370
+ // 'history', the tab would keep the column full-bleed with no panel in it
371
+ // (a bare document, no pane card, no way back but the next poll), and then
372
+ // put the log back over the file the moment git recovered, minutes after
373
+ // the reader had gone back to reading. Same rule the skill page applies to
374
+ // its own open flag.
375
+ //
376
+ // The LOG only. A comparison is asked for by the chat's "View full
377
+ // comparison" link, not by a clock this flag withdraws, and the panel
378
+ // reports git's state itself. Resetting it here too cancelled a click that
379
+ // landed before the first status poll answered (`availability` starts
380
+ // 'loading'), with nothing on screen to say so.
381
+ if (activeTab === 'history' && !historyAvailable) setActiveTab('content');
382
+ /**
383
+ * Opening the log from the pane bar's clock unmounts the pane bar, and with
384
+ * it the clock a keyboard user just activated; closing it hands the column
385
+ * back to prose, which hides the header's clock again (`historyInPane`).
386
+ * Either way focus would fall to `document`, so the clocks hand focus to
387
+ * each other across the swap (`useFocusHandoff`), and only for a swap the
388
+ * USER made. A full-bleed file has no pane bar: its header clock stays put
389
+ * and takes the focus instead. Every way out of the log or the comparison
390
+ * goes through `backToDocument`, so none can forget the handoff.
391
+ *
392
+ * BOTH clocks are withdrawn by `historyAvailable`, and a comparison
393
+ * outlives it — the panel is opened by the chat's link, not by a clock, so
394
+ * it stays up through a failed status poll. Leaving that view with git
395
+ * silent (or a draft open) would name two controls that are not on screen
396
+ * and drop focus on `document`, the one outcome this machinery exists to
397
+ * prevent. So the document's own title is named last: it is rendered in
398
+ * every one of those states, and landing on it announces the document the
399
+ * user just came back to.
400
+ */
401
+ const paneClockRef = useRef<HTMLButtonElement>(null);
402
+ const headerClockRef = useRef<HTMLButtonElement>(null);
403
+ const titleRef = useRef<HTMLHeadingElement>(null);
404
+ const handoff = useFocusHandoff(activeTab);
405
+ const openHistory = () => {
406
+ handoff('history', headerClockRef);
407
+ setActiveTab('history');
408
+ };
409
+ const backToDocument = () => {
410
+ handoff('content', paneClockRef, headerClockRef, titleRef);
411
+ setActiveTab('content');
412
+ };
413
+
351
414
  // Mirror the lock state into edit mode, but only on a transition from
352
415
  // "we held the lock" to "we don't" — that's the idle-release /
353
416
  // heartbeat-failure case where we want the UI to flip back to View
@@ -802,8 +865,8 @@ export function FileViewer() {
802
865
  // in the empty branch below because that branch is a `return` and this is a
803
866
  // hook — and it costs nothing while a file IS open, which is the common case.
804
867
  const suggestions = useMemo(
805
- () => suggestedPages(fileTree, SUGGESTION_LIMIT),
806
- [fileTree],
868
+ () => suggestedPages(fileTree, kbDirName, SUGGESTION_LIMIT),
869
+ [fileTree, kbDirName],
807
870
  );
808
871
  // Opening a suggestion is NAVIGATION, the same as clicking the file in the
809
872
  // explorer or a tab: the URL is the canonical record of what is open, and a
@@ -999,7 +1062,7 @@ export function FileViewer() {
999
1062
  // rule). While a mode is OPEN it shows the way out instead. The header's
1000
1063
  // own cluster is suppressed for prose files (`writeActionInPane`).
1001
1064
  const lockedBy = fileLock.externalLock?.holderName ?? null;
1002
- const paneActions = isReviewingPending || viewOnly ? null : proposeMode ? (
1065
+ const writeAction = isReviewingPending || viewOnly ? null : proposeMode ? (
1003
1066
  <>
1004
1067
  <Button variant="quiet" size="tiny" onClick={handleDiscardProposal} disabled={proposalBusy}>
1005
1068
  Discard
@@ -1054,6 +1117,30 @@ export function FileViewer() {
1054
1117
  {isEnteringEdit ? 'Loading…' : 'Edit'}
1055
1118
  </Button>
1056
1119
  );
1120
+ // "Who changed this, when" — the clock-arrow beside Edit, where Google Docs
1121
+ // keeps it. It sits in the bar for the same reason Edit does: history is a
1122
+ // thing you do to THE FILE, and the bar is where the file's actions live.
1123
+ // It used to be the lone item behind a ⋯ in the page header — two clicks
1124
+ // and a menu for a question people ask often. Not gated on `viewOnly` or a
1125
+ // pending review: reading the log changes nothing. Full-bleed renderers
1126
+ // have no bar, so the header carries it for them (`historyInPane`).
1127
+ const historyAction = historyAvailable ? (
1128
+ <IconButton
1129
+ ref={paneClockRef}
1130
+ aria-label="Version history"
1131
+ title="Version history"
1132
+ onClick={openHistory}
1133
+ >
1134
+ <History size={14} />
1135
+ </IconButton>
1136
+ ) : null;
1137
+ const paneActions =
1138
+ historyAction || writeAction ? (
1139
+ <>
1140
+ {historyAction}
1141
+ {writeAction}
1142
+ </>
1143
+ ) : null;
1057
1144
 
1058
1145
  return (
1059
1146
  <div className="h-full w-full flex flex-col bg-white min-w-0 relative">
@@ -1064,48 +1151,67 @@ export function FileViewer() {
1064
1151
  the Propose changes affordance already says what they CAN do, and the
1065
1152
  detailed who-may-edit copy still appears where it answers a question
1066
1153
  (the disabled-save tooltip). */}
1067
- {/* ONE column holds the tabs, the title and the text at the same width,
1154
+ {/* ONE column holds the title, the tabs and the text at the same width,
1068
1155
  so they share an edge and the page reads as a single centred block
1069
- (proto:700-705). `editorContainerRef` goes to `scrollRef` because the
1070
- shell is now the element that scrolls — the capture-phase listener
1071
- bound to it is the file lock's only activity signal for a reader. */}
1156
+ (proto:700-705). The prototype puts the tab strip above the title;
1157
+ this does not, because the title bar has to open the column to hold
1158
+ its line with the sidebar's header row — see `KbDocumentShell.header`.
1159
+ `editorContainerRef` goes to `scrollRef` because the shell is the
1160
+ element that scrolls — the capture-phase listener bound to it is the
1161
+ file lock's only activity signal for a reader. */}
1072
1162
  <KbDocumentShell
1073
- roomy={explorerHidden}
1163
+ roomy={explorerHidden}
1074
1164
  variant={shellVariant}
1075
1165
  scrollRef={editorContainerRef}
1166
+ // The document names itself, and its actions sit beside its name.
1167
+ // Everything the deleted 40px strip carried is here — the three chips
1168
+ // as Badges, Edit with the same handlers and the same lock semantics,
1169
+ // the copy-link that used to be an icon in the corner — plus Share and
1170
+ // the overflow the prototype puts on the page.
1171
+ //
1172
+ // It goes in the SLOT, not in the children, because the slot is what
1173
+ // makes it the column's first row — see `KbDocumentShell.header`. It
1174
+ // was the first child once, under `<EditorTabs />`, and a 36px tab
1175
+ // strip plus its 18px gap pushed the file page's title bar 54px below
1176
+ // the sidebar header row it lines up with.
1177
+ header={
1178
+ <KbPageHeader
1179
+ path={openFilePath}
1180
+ canWrite={access.canWrite}
1181
+ editMode={editMode}
1182
+ entering={isEnteringEdit}
1183
+ proposeMode={proposeMode}
1184
+ proposalBusy={proposalBusy}
1185
+ onPropose={handleEnterPropose}
1186
+ onSendProposal={() => void handleSendProposal()}
1187
+ onDiscardProposal={handleDiscardProposal}
1188
+ // `viewOnly` rides the same flag: it tells the header "the write
1189
+ // action is not yours to render" — and the pane bar renders none.
1190
+ writeActionInPane={shellVariant === 'prose' || viewOnly}
1191
+ // Prose gets a pane card, and the card's bar carries Version history
1192
+ // beside Edit. Not `viewOnly`: a view-only full-bleed file has no bar.
1193
+ historyInPane={shellVariant === 'prose'}
1194
+ historyButtonRef={headerClockRef}
1195
+ titleRef={titleRef}
1196
+ lockedBy={fileLock.externalLock?.holderName ?? null}
1197
+ historyAvailable={historyAvailable}
1198
+ isDirty={isManualDirty}
1199
+ waitingOnAgentUpdate={waitingOnAgentUpdate}
1200
+ isReviewingPending={isReviewingPending}
1201
+ activeTab={activeTab}
1202
+ onEdit={handleEnterEditMode}
1203
+ onDone={handleExitEditMode}
1204
+ // While the log is open the column is full-bleed, so the header
1205
+ // carries the clock (pressed). A second click on a pressed clock is a
1206
+ // request to put the document back, not to open the log again.
1207
+ onOpenHistory={activeTab === 'history' ? backToDocument : openHistory}
1208
+ onShare={handleShare}
1209
+ onCopyPage={canCopyPage ? handleCopyPage : undefined}
1210
+ onCopyLink={handleCopyLink}
1211
+ />
1212
+ }
1076
1213
  >
1077
1214
  <EditorTabs />
1078
- {/* The document names itself, and its actions sit beside its name.
1079
- Everything the deleted 40px strip carried is here — the three chips
1080
- as Badges, Edit with the same handlers and the same lock semantics,
1081
- the copy-link that used to be an icon in the corner — plus Share and
1082
- the overflow the prototype puts on the page. */}
1083
- <KbPageHeader
1084
- path={openFilePath}
1085
- canWrite={access.canWrite}
1086
- editMode={editMode}
1087
- entering={isEnteringEdit}
1088
- proposeMode={proposeMode}
1089
- proposalBusy={proposalBusy}
1090
- onPropose={handleEnterPropose}
1091
- onSendProposal={() => void handleSendProposal()}
1092
- onDiscardProposal={handleDiscardProposal}
1093
- // `viewOnly` rides the same flag: it tells the header "the write
1094
- // action is not yours to render" — and the pane bar renders none.
1095
- writeActionInPane={shellVariant === 'prose' || viewOnly}
1096
- lockedBy={fileLock.externalLock?.holderName ?? null}
1097
- historyAvailable={historyAvailable}
1098
- isDirty={isManualDirty}
1099
- waitingOnAgentUpdate={waitingOnAgentUpdate}
1100
- isReviewingPending={isReviewingPending}
1101
- activeTab={activeTab}
1102
- onEdit={handleEnterEditMode}
1103
- onDone={handleExitEditMode}
1104
- onOpenHistory={() => setActiveTab('history')}
1105
- onShare={handleShare}
1106
- onCopyPage={canCopyPage ? handleCopyPage : undefined}
1107
- onCopyLink={handleCopyLink}
1108
- />
1109
1215
 
1110
1216
  {/* Content stopped being a tab: the document IS the page, and history
1111
1217
  and comparison are two things you can go and look at. Each renders in
@@ -1113,12 +1219,12 @@ export function FileViewer() {
1113
1219
  route home would be reopening the file. */}
1114
1220
  {activeTab === 'history' && historyAvailable ? (
1115
1221
  <>
1116
- <BackToDocument onBack={() => setActiveTab('content')} label="Version history" />
1222
+ <BackToDocument onBack={backToDocument} label="Version history" />
1117
1223
  <FileHistoryPanel filePath={openFilePath} />
1118
1224
  </>
1119
- ) : activeTab === 'compare' && historyAvailable ? (
1225
+ ) : activeTab === 'compare' ? (
1120
1226
  <>
1121
- <BackToDocument onBack={() => setActiveTab('content')} label="Compare versions" />
1227
+ <BackToDocument onBack={backToDocument} label="Compare versions" />
1122
1228
  <FileComparisonPanel
1123
1229
  filePath={openFilePath}
1124
1230
  initialFrom={comparisonOverride?.fromBranch ?? null}
@@ -1327,6 +1433,21 @@ export function FileViewer() {
1327
1433
  requests={requestsOnThisFile}
1328
1434
  canDecide={access.canWrite === true}
1329
1435
  ownersLabel={ownersLabel}
1436
+ // Counted over `eligible` (the write: grants, which are what
1437
+ // approval rights and the merge gate resolve against), NOT
1438
+ // `owners` — a file can have writers and no owner: at all.
1439
+ // Only when those grants were actually loaded: a draft, a
1440
+ // non-KB path or a failed lookup default-allows with an
1441
+ // EMPTY list, which would claim the viewer is the only one.
1442
+ // Nor mid-lookup: the hook keeps the PREVIOUS file's grants
1443
+ // while the next file's lookup is in flight.
1444
+ othersPending={
1445
+ !access.error &&
1446
+ !access.loading &&
1447
+ (access.eligible.roles.length > 0 || access.eligible.users.length > 0)
1448
+ ? othersPendingBesides(access.eligible, auth.user?.email)
1449
+ : undefined
1450
+ }
1330
1451
  onApplied={() => {
1331
1452
  reloadTabFromDisk(openFilePath).catch(() => {});
1332
1453
  }}
@@ -5,6 +5,7 @@ import {
5
5
  DOCUMENT_COLUMN_WIDE,
6
6
  documentGutters,
7
7
  } from '../../../shared/theme/measure';
8
+ import { HEADER_COLUMN_TOP } from '../../../shared/theme/header';
8
9
 
9
10
  /**
10
11
  * The Knowledge surface's document column — the prototype's `.wrap.kb`.
@@ -18,6 +19,7 @@ import {
18
19
  * The tab strip mounts INSIDE it, not above it. That is the prototype's own
19
20
  * rule (proto:700-705): one column holds tabs, title and text at the same
20
21
  * width, so they share an edge and the page reads as a single centred block.
22
+ * It mounts inside it BELOW the title bar, though — see `header`.
21
23
  */
22
24
  export interface KbDocumentShellProps {
23
25
  /** Widens the column and opens the second track for the rail. */
@@ -65,6 +67,24 @@ export interface KbDocumentShellProps {
65
67
  * as "complementary" — so the rail names itself and hands the id over.
66
68
  */
67
69
  railLabelledBy?: string;
70
+ /**
71
+ * The page's title bar — and the FIRST row of this column, in every
72
+ * variant, on `HEADER_COLUMN_TOP`.
73
+ *
74
+ * A SLOT rather than the caller's first child, for the same reason
75
+ * `SidebarFrame` owns the row on the other side of the seam: the band's top
76
+ * edge is the seam, so "the title bar opens the column" is a rule the frame
77
+ * has to hold, not a JSX order a caller has to remember. It was a JSX order
78
+ * once, and `FileViewer` put `<EditorTabs />` above it — a 36px tab strip
79
+ * plus its 18px gap, so the file page's title bar rendered 54px below the
80
+ * sidebar header row it was supposed to line up with, at every width,
81
+ * whatever the two heights agreed on. Staging caught that; nothing in the
82
+ * suite did, because no test rendered the header in its real page.
83
+ *
84
+ * Passing nothing is a page with no title bar (the change-request and
85
+ * review surfaces): the column simply opens on its children.
86
+ */
87
+ header?: ReactNode;
68
88
  children: ReactNode;
69
89
  }
70
90
 
@@ -74,6 +94,7 @@ export function KbDocumentShell({
74
94
  roomy = false,
75
95
  scrollRef,
76
96
  railLabelledBy,
97
+ header,
77
98
  children,
78
99
  }: KbDocumentShellProps) {
79
100
  return (
@@ -97,7 +118,20 @@ export function KbDocumentShell({
97
118
  // widening a measure there is none of, and scrolls on its own so a
98
119
  // long link list cannot stretch the iframe.
99
120
  <div className="flex h-full min-h-0 w-full">
100
- <div className="flex h-full min-h-0 min-w-0 flex-1 flex-col">{children}</div>
121
+ {/* `HEADER_COLUMN_TOP` here too. Full-bleed gives up the measure and
122
+ the gutters, but NOT the seam: this column used to open straight
123
+ onto its renderer, so a PDF's title bar sat 12px HIGHER than the
124
+ sidebar's header row — the prose column's bug in the opposite
125
+ direction. The offset rides the column the band is already in
126
+ rather than a wrapper of its own, so the chain of definite
127
+ heights above is untouched; border-box means the renderer below
128
+ simply gets 12px less of it. */}
129
+ <div
130
+ className={cn('flex h-full min-h-0 min-w-0 flex-1 flex-col', HEADER_COLUMN_TOP)}
131
+ >
132
+ {header}
133
+ {children}
134
+ </div>
101
135
  {rail && (
102
136
  <aside
103
137
  aria-labelledby={railLabelledBy}
@@ -117,21 +151,31 @@ export function KbDocumentShell({
117
151
  className={cn(
118
152
  DOCUMENT_COLUMN_WIDE,
119
153
  documentGutters(roomy),
120
- 'grid grid-cols-1 items-start gap-11 pt-3',
154
+ 'grid grid-cols-1 items-start gap-11',
155
+ HEADER_COLUMN_TOP,
121
156
  'max-[900px]:gap-[26px] min-[901px]:grid-cols-[minmax(0,620px)_296px]',
122
157
  )}
123
158
  >
124
- <article className="min-w-0">{children}</article>
159
+ <article className="min-w-0">
160
+ {header}
161
+ {children}
162
+ </article>
125
163
  <aside aria-labelledby={railLabelledBy} className="min-w-0">
126
164
  {rail}
127
165
  </aside>
128
166
  </div>
129
167
  ) : (
130
- // `pt-3` is 12px — Knowledge's own top padding, NOT the app-wide 34px.
168
+ // `HEADER_COLUMN_TOP` is 12px — the offset every column that opens
169
+ // on a header band shares, Knowledge's own value promoted to a token.
131
170
  // The top bar already separates the column from the window, so the
132
171
  // page's own padding only has to keep the tabs off the bar
133
- // (`.wrap.kb`, proto:695-699). Do not "fix" this to 34px.
134
- <div className={cn(DOCUMENT_COLUMN, documentGutters(roomy), 'pt-3')}>{children}</div>
172
+ // (`.wrap.kb`, proto:695-699). The Library opened on 34px until
173
+ // this ticket, and 34 against 12 is what put the two surfaces' title
174
+ // bars on different lines. Do not "fix" this back to 34px.
175
+ <div className={cn(DOCUMENT_COLUMN, documentGutters(roomy), HEADER_COLUMN_TOP)}>
176
+ {header}
177
+ {children}
178
+ </div>
135
179
  )}
136
180
  </div>
137
181
  );
@@ -1,9 +1,10 @@
1
- import { useCallback, useRef, useState } from 'react';
1
+ import { useCallback, useRef, useState, type Ref } from 'react';
2
2
  import {
3
3
  Check,
4
4
  ChevronDown,
5
5
  Clock4,
6
6
  Copy,
7
+ FileText,
7
8
  History,
8
9
  Link2,
9
10
  Pencil,
@@ -13,6 +14,8 @@ import {
13
14
  import { cn } from '../../../lib/utils';
14
15
  import { Badge, Button, IconButton, MenuItem, MenuPanel } from '../../../shared/components';
15
16
  import { useDismissableMenu } from '../../../shared/components';
17
+ import { HEADER_BAND, PAGE_HEADER_TESTID } from '../../../shared/theme/header';
18
+ import { rootAnchoredPath } from '../utils/pasteLink';
16
19
 
17
20
  /**
18
21
  * The document's title, and the page's actions beside it.
@@ -24,7 +27,9 @@ import { useDismissableMenu } from '../../../shared/components';
24
27
  * Weight follows stakes, not frequency (proto:3781-3783). Share is the ONE
25
28
  * bounded button because it is the one action here with a consequence for
26
29
  * other people. Copy and Edit are icons — frequent, private, instantly
27
- * reversible. Everything monthly is behind `⋯`.
30
+ * reversible. Version history is the clock-arrow beside Edit, the placement
31
+ * Google Docs taught everyone; a ⋯ holding one item was a hiding place, not
32
+ * an overflow.
28
33
  */
29
34
 
30
35
  /** Extensions we strip from the `<h1>`. Anything else stays verbatim. */
@@ -68,6 +73,28 @@ export interface KbPageHeaderProps {
68
73
  * they have no bar to carry them.
69
74
  */
70
75
  writeActionInPane?: boolean;
76
+ /**
77
+ * The pane bar carries Version history beside its Edit, so the header
78
+ * renders none. True for prose documents — the ones that get a pane card.
79
+ * Separate from `writeActionInPane`, which `viewOnly` also raises: a
80
+ * view-only full-bleed file has no bar to carry the button, and its log is
81
+ * still worth reading.
82
+ */
83
+ historyInPane?: boolean;
84
+ /**
85
+ * The header's Version history clock, for the viewer to focus after a
86
+ * swap unmounts the control that was activated (see `FileViewer`).
87
+ */
88
+ historyButtonRef?: Ref<HTMLButtonElement>;
89
+ /**
90
+ * The document's own title, as the LAST place focus can land when a swap
91
+ * unmounts the control that was activated and both clocks are withdrawn
92
+ * (git not answering, or a draft open — see `FileViewer.backToDocument`).
93
+ * The heading is on screen in every one of those states and it names the
94
+ * thing the user just came back to, so a screen reader announces the
95
+ * document rather than nothing at all.
96
+ */
97
+ titleRef?: Ref<HTMLHeadingElement>;
71
98
  /** Disables Edit and explains why via `title`. */
72
99
  lockedBy: string | null;
73
100
  historyAvailable: boolean;
@@ -93,8 +120,8 @@ export interface KbPageHeaderProps {
93
120
  onShare(): void;
94
121
  /** The page as Markdown. Absent for a file that has no markdown to copy. */
95
122
  onCopyPage?: () => Promise<boolean>;
96
- /** The canonical URL, via `useCanonicalFileUrl`. The only copy-a-reference
97
- * action on this page — see the note where the `⋯` menu is built. */
123
+ /** The canonical URL, via `useCanonicalFileUrl`. Its sibling, Copy path,
124
+ * needs nothing from the caller: it is `path`, root-anchored. */
98
125
  onCopyLink(): Promise<boolean>;
99
126
  }
100
127
 
@@ -127,6 +154,9 @@ export function KbPageHeader({
127
154
  onSendProposal,
128
155
  onDiscardProposal,
129
156
  writeActionInPane = false,
157
+ historyInPane = false,
158
+ historyButtonRef,
159
+ titleRef,
130
160
  lockedBy,
131
161
  historyAvailable,
132
162
  isDirty,
@@ -141,23 +171,15 @@ export function KbPageHeader({
141
171
  onCopyLink,
142
172
  }: KbPageHeaderProps) {
143
173
  const [shareOpen, setShareOpen] = useState(false);
144
- const [dotsOpen, setDotsOpen] = useState(false);
145
174
  const [copied, setCopied] = useState<Record<string, CopyState>>({});
146
175
  const shareTriggerRef = useRef<HTMLButtonElement>(null);
147
- const dotsTriggerRef = useRef<HTMLButtonElement>(null);
148
176
 
149
177
  const closeShare = useCallback(() => setShareOpen(false), []);
150
- const closeDots = useCallback(() => setDotsOpen(false), []);
151
178
  const shareRef = useDismissableMenu<HTMLDivElement>({
152
179
  open: shareOpen,
153
180
  onClose: closeShare,
154
181
  returnFocusTo: shareTriggerRef,
155
182
  });
156
- const dotsRef = useDismissableMenu<HTMLDivElement>({
157
- open: dotsOpen,
158
- onClose: closeDots,
159
- returnFocusTo: dotsTriggerRef,
160
- });
161
183
 
162
184
  const report = useCallback(async (key: string, run: () => Promise<boolean>) => {
163
185
  const ok = await run();
@@ -165,6 +187,18 @@ export function KbPageHeader({
165
187
  window.setTimeout(() => setCopied((prev) => ({ ...prev, [key]: null })), COPY_FEEDBACK_MS);
166
188
  }, []);
167
189
 
190
+ // The root-anchored `/<kbDirName>/…` form, the same text the tree row's
191
+ // Copy path gives: pasted into a Markdown link it works from any folder.
192
+ const copyPath = useCallback(async () => {
193
+ try {
194
+ await navigator.clipboard.writeText(rootAnchoredPath(path));
195
+ return true;
196
+ } catch (err) {
197
+ console.error('Failed to copy path:', err);
198
+ return false;
199
+ }
200
+ }, [path]);
201
+
168
202
  const copyLabel = (key: string, idle: string) =>
169
203
  copied[key] === 'ok' ? 'Copied' : copied[key] === 'fail' ? "Couldn't copy" : idle;
170
204
 
@@ -182,20 +216,52 @@ export function KbPageHeader({
182
216
  !writeActionInPane && canWrite === false && !isReviewingPending && activeTab === 'content';
183
217
 
184
218
  return (
185
- <div className="mb-2 flex flex-wrap items-center gap-3">
186
- <h1 className="min-w-0 text-display font-semibold text-ink">{titleOf(path)}</h1>
219
+ // The shared header band: the same height as the sidebar's header row,
220
+ // from the same token, so the two rows under the toolbar read as one
221
+ // line. It used to be `flex-wrap` with no height at all — the row was as
222
+ // tall as whatever landed in it, which is why it could never agree with
223
+ // the sidebar. Wrapping is gone with the height: the title truncates
224
+ // instead (below), because a title bar that becomes two rows has already
225
+ // broken the seam this band exists to hold.
226
+ <div
227
+ data-testid={PAGE_HEADER_TESTID}
228
+ className={cn(HEADER_BAND, 'mb-2 w-full gap-3')}
229
+ >
230
+ {/* The title and its chips are the one part of this row allowed to run
231
+ out of space. They share a `min-w-0` group so that the row's
232
+ leftover width is taken from THEM and never from the actions: a
233
+ band cannot wrap, so something has to give first, and a file name
234
+ the reader can still hover for (`title`, below) is a far cheaper
235
+ loss than a Share button pushed off the side of the page. The
236
+ chips clip from the right in the order they are least urgent. */}
237
+ <div className="flex min-w-0 flex-1 items-center gap-3 overflow-hidden">
238
+ {/* `tabIndex={-1}` keeps the heading out of the tab order while letting
239
+ `.focus()` land on it — the standard way to hand focus to a region
240
+ after a view swap. No focus ring: this is a programmatic landing
241
+ after the user's own click, not a control they are about to use. */}
242
+ <h1
243
+ ref={titleRef}
244
+ tabIndex={-1}
245
+ // `title` because `truncate` hides the rest of a long file name, and
246
+ // a heading you cannot finish reading needs somewhere to say it.
247
+ title={titleOf(path)}
248
+ className="min-w-0 truncate text-display font-semibold text-ink focus:outline-none"
249
+ >
250
+ {titleOf(path)}
251
+ </h1>
187
252
 
188
- {/* The three chips the deleted strip used to carry. */}
189
- {isDirty && <Badge tone="wait">Unsaved</Badge>}
190
- {waitingOnAgentUpdate && (
191
- <Badge tone="wait">
192
- <Clock4 size={12} />
193
- Agent update waiting
194
- </Badge>
195
- )}
196
- {isReviewingPending && <Badge tone="ok">Reviewing agent update</Badge>}
253
+ {/* The three chips the deleted strip used to carry. */}
254
+ {isDirty && <Badge tone="wait">Unsaved</Badge>}
255
+ {waitingOnAgentUpdate && (
256
+ <Badge tone="wait">
257
+ <Clock4 size={12} />
258
+ Agent update waiting
259
+ </Badge>
260
+ )}
261
+ {isReviewingPending && <Badge tone="ok">Reviewing agent update</Badge>}
262
+ </div>
197
263
 
198
- <div className="ml-auto flex flex-none items-center gap-1.5">
264
+ <div className="flex flex-none items-center gap-1.5">
199
265
  {/* Share: bounded, and split. Bounded because it is the one action on
200
266
  this page with a consequence for other people. The chevron carries
201
267
  the quieter sibling errand — copying a link to the page — so that
@@ -248,6 +314,19 @@ export function KbPageHeader({
248
314
  {copyLabel('link', 'Copy link to this page')}
249
315
  </span>
250
316
  </MenuItem>
317
+ {/* For linking this page from another one. */}
318
+ <MenuItem
319
+ role="menuitem"
320
+ onClick={async () => {
321
+ await report('path', copyPath);
322
+ window.setTimeout(closeShare, COPY_FEEDBACK_MS);
323
+ }}
324
+ >
325
+ <span className="flex items-center gap-2.5">
326
+ <FileText size={14} />
327
+ {copyLabel('path', 'Copy path')}
328
+ </span>
329
+ </MenuItem>
251
330
  {/* "Share the whole folder" lived here and was cut. Sharing a
252
331
  folder from a file's page is a much bigger act than the row
253
332
  it sat in suggested — one click, and everything inside the
@@ -352,37 +431,23 @@ export function KbPageHeader({
352
431
  </IconButton>
353
432
  ))}
354
433
 
355
- {/* Version history is the whole menu now, so the trigger goes where it
356
- goes: git not ready means there is nothing behind ⋯, and an overflow
357
- that opens onto an empty panel is worse than no overflow at all. */}
358
- {historyAvailable && (
359
- <div className="relative">
360
- <IconButton
361
- ref={dotsTriggerRef}
362
- aria-label="More actions"
363
- aria-haspopup="menu"
364
- aria-expanded={dotsOpen}
365
- active={dotsOpen}
366
- onClick={() => setDotsOpen((v) => !v)}
367
- >
368
- <span aria-hidden className="text-strong leading-none">⋯</span>
369
- </IconButton>
370
- {dotsOpen && (
371
- <div ref={dotsRef} className="absolute right-0 top-[calc(100%+5px)] z-40">
372
- <MenuPanel role="menu" aria-label="More actions" className="min-w-[212px]">
373
- <MenuItem role="menuitem" onClick={() => { closeDots(); onOpenHistory(); }}>
374
- <span className="flex items-center gap-2.5"><History size={14} />Version history</span>
375
- </MenuItem>
376
- {/* "Copy path" is NOT here. Copying a reference to this page is
377
- one errand, and Share already owns it ("Copy link to this
378
- page"); two menus offering near-identical copies is how a
379
- user ends up pasting the wrong one. The tree's right-click
380
- menu keeps its own Copy path, because there it reaches rows
381
- that are not open — a different job. */}
382
- </MenuPanel>
383
- </div>
384
- )}
385
- </div>
434
+ {/* Version history, as the clock-arrow beside Edit. It was the lone
435
+ item behind a ⋯ here, and a menu with one entry is a hiding place,
436
+ not an overflow. Prose documents put Edit in the pane bar and carry
437
+ this beside it (`historyInPane`); full-bleed renderers have no bar,
438
+ so the header keeps both. Git not ready means there is no log to
439
+ show, and the button goes with it. */}
440
+ {historyAvailable && !historyInPane && (
441
+ <IconButton
442
+ ref={historyButtonRef}
443
+ aria-label="Version history"
444
+ title="Version history"
445
+ active={activeTab === 'history'}
446
+ aria-pressed={activeTab === 'history'}
447
+ onClick={onOpenHistory}
448
+ >
449
+ <History size={14} />
450
+ </IconButton>
386
451
  )}
387
452
  </div>
388
453
  </div>