@bevel-software/platform-core-frontend 0.15.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +20 -9
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/events.test.ts +43 -0
  6. package/src/core/bootstrap.ts +11 -3
  7. package/src/core/events.ts +85 -3
  8. package/src/core/registry.ts +1 -1
  9. package/src/lib/__tests__/email.test.ts +44 -0
  10. package/src/lib/email.ts +37 -1
  11. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  12. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  13. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  16. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  20. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
  21. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  22. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  23. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  24. package/src/modules/access/api.ts +140 -6
  25. package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
  26. package/src/modules/access/manage-access-affordance.ts +17 -0
  27. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  28. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  29. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  30. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  31. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  32. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  33. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  34. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  35. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  36. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  37. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  38. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  39. package/src/modules/admin/components/group-members-path.ts +32 -0
  40. package/src/modules/admin/services/roles.api.ts +12 -1
  41. package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
  42. package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
  43. package/src/modules/audit/components/AuditLogPage.tsx +373 -0
  44. package/src/modules/audit/components/principal-grouping.ts +49 -0
  45. package/src/modules/audit/services/audit.api.ts +98 -0
  46. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  47. package/src/modules/auth/components/AccountPage.tsx +73 -54
  48. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  49. package/src/modules/auth/services/account.api.ts +78 -4
  50. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  51. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  52. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  53. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  58. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  59. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  60. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  61. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  62. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  63. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  64. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  65. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  66. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  67. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  68. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  69. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  70. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  71. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  72. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  73. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  74. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  75. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  76. package/src/modules/change-requests/services/propose.api.ts +97 -8
  77. package/src/modules/change-requests/utils/approval.ts +15 -0
  78. package/src/modules/change-requests/utils/author.ts +32 -0
  79. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  80. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  81. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  82. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  83. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  84. package/src/modules/git/services/error-messages.ts +12 -0
  85. package/src/modules/git/services/pr-prompts.ts +5 -5
  86. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  87. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  88. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  89. package/src/modules/layout/components/AppLayout.tsx +2 -0
  90. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  91. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  92. package/src/modules/layout/components/SidebarFrame.tsx +108 -3
  93. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  94. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  95. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  96. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  97. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  98. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
  99. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
  100. package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
  101. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
  102. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  103. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  104. package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
  105. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  106. package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
  107. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
  108. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
  109. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  110. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  111. package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
  112. package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
  113. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  114. package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
  115. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
  116. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  117. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  118. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  119. package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
  120. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  121. package/src/modules/library/__tests__/library-paths.test.ts +47 -4
  122. package/src/modules/library/__tests__/link-membership.test.ts +13 -4
  123. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  124. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  125. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  126. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  127. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  128. package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
  129. package/src/modules/library/__tests__/status.test.ts +82 -2
  130. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  131. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  132. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  133. package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
  134. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  135. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  136. package/src/modules/library/components/LibraryCard.tsx +146 -45
  137. package/src/modules/library/components/LibraryLayout.tsx +119 -256
  138. package/src/modules/library/components/LibraryPage.tsx +172 -39
  139. package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
  140. package/src/modules/library/components/LockedPluginView.tsx +62 -34
  141. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  142. package/src/modules/library/components/NewPluginDialog.tsx +16 -2
  143. package/src/modules/library/components/PageActions.tsx +11 -9
  144. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  145. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  146. package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
  147. package/src/modules/library/components/PluginExtras.tsx +140 -17
  148. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  149. package/src/modules/library/components/PluginPage.tsx +157 -41
  150. package/src/modules/library/components/PluginRows.tsx +286 -0
  151. package/src/modules/library/components/PluginsSidebar.tsx +239 -263
  152. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  153. package/src/modules/library/components/ShareButton.tsx +17 -0
  154. package/src/modules/library/components/SkillsTree.tsx +141 -28
  155. package/src/modules/library/components/TeamRoute.tsx +15 -0
  156. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  157. package/src/modules/library/components/plugin-page-parts.tsx +103 -17
  158. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
  159. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  160. package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
  161. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  162. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  163. package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
  164. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  165. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  166. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  167. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  168. package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
  169. package/src/modules/library/routes/library-paths.ts +26 -28
  170. package/src/modules/library/services/library.api.ts +38 -20
  171. package/src/modules/library/services/plugins.api.ts +69 -8
  172. package/src/modules/library/services/teams.api.ts +15 -0
  173. package/src/modules/library/services/tools.api.ts +78 -0
  174. package/src/modules/library/state/library-data.tsx +170 -32
  175. package/src/modules/library/utils/personal-plugin.ts +13 -15
  176. package/src/modules/library/utils/plugin-entries.ts +134 -0
  177. package/src/modules/library/utils/plugin-summary.ts +75 -9
  178. package/src/modules/library/utils/status.ts +135 -33
  179. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
  180. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  181. package/src/modules/onboarding/agent-clients.ts +55 -23
  182. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  183. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  184. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  185. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  186. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  187. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  188. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  189. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  190. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  191. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  192. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  193. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  194. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  195. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  196. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  197. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  198. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  199. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  200. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  201. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  202. package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
  203. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  204. package/src/modules/settings/components/DeploymentPage.tsx +10 -30
  205. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  206. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
  207. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  208. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
  209. package/src/modules/settings/services/github-facade.api.ts +23 -0
  210. package/src/modules/settings/settings-nav-items.tsx +13 -3
  211. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  212. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  213. package/src/modules/setup/__tests__/setup.test.tsx +497 -4
  214. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  215. package/src/modules/setup/components/SetupGate.tsx +16 -16
  216. package/src/modules/setup/components/SetupScreen.tsx +532 -43
  217. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  218. package/src/modules/setup/services/setup.api.ts +141 -4
  219. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  220. package/src/modules/setup/utils/root-folders.ts +46 -0
  221. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  222. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  223. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  224. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  225. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  226. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  227. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  228. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  229. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  230. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  231. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  232. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  233. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  234. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  235. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  236. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  237. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
  238. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  239. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  240. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  241. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
  242. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  243. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  244. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  245. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  246. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  247. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  248. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  249. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  250. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  251. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  252. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  253. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  254. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  255. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  256. package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
  257. package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
  258. package/src/modules/workspace/components/FileRoute.tsx +353 -36
  259. package/src/modules/workspace/components/FileViewer.tsx +172 -46
  260. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  261. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  262. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  263. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
  264. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
  265. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
  266. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  267. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  268. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  269. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  270. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  271. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  272. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  273. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  274. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  275. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  276. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  277. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  278. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  279. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  280. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  281. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  282. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  283. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  284. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  285. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  286. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  287. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  288. package/src/modules/workspace/components/renderers/index.ts +53 -2
  289. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  290. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  291. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  292. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  293. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  294. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  295. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  296. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
  297. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  298. package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
  299. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  300. package/src/modules/workspace/routing/kb-routes.ts +206 -29
  301. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
  302. package/src/modules/workspace/services/workspace.api.ts +57 -4
  303. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  304. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  305. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  306. package/src/modules/workspace/state/workspace.context.ts +125 -19
  307. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  308. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
  309. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  310. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  311. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  312. package/src/modules/workspace/utils/file-trace.ts +50 -0
  313. package/src/modules/workspace/utils/fileTree.ts +112 -36
  314. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  315. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  316. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  317. package/src/modules/workspace/utils/uploadError.ts +29 -0
  318. package/src/shared/__tests__/marketplace-url.test.ts +6 -1
  319. package/src/shared/components/Button.tsx +16 -2
  320. package/src/shared/components/Dialog.tsx +27 -11
  321. package/src/shared/components/Menu.tsx +13 -1
  322. package/src/shared/components/PageShell.tsx +13 -8
  323. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  324. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  325. package/src/shared/components/index.ts +2 -0
  326. package/src/shared/components/useDismissableMenu.ts +32 -10
  327. package/src/shared/components/useFocusHandoff.ts +51 -0
  328. package/src/shared/components/useLatestRef.ts +28 -0
  329. package/src/shared/markdown/Markdown.tsx +12 -3
  330. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  331. package/src/shared/markdown/hrefs.ts +50 -0
  332. package/src/shared/marketplace-url.ts +33 -5
  333. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  334. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  335. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  336. package/src/shared/mcp/connect-snippets.ts +14 -9
  337. package/src/shared/mcp/index.ts +1 -1
  338. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  339. package/src/shared/theme/header.ts +75 -0
  340. package/src/shared/theme/measure.ts +7 -4
  341. package/src/shared/theme/tokens.css +25 -0
  342. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  343. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  344. package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
  345. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  346. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  347. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -3,6 +3,7 @@ import { render, screen, waitFor, act, within } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
5
5
  import { useEffect, useState } from 'react';
6
+ import { PAGE_HEADER_TESTID } from '../../../../shared/theme/header';
6
7
  import type {
7
8
  BranchInfo,
8
9
  FileTreeEntry,
@@ -85,6 +86,9 @@ vi.mock('../../../change-requests/services/change-requests.api', () => ({
85
86
  listOpenChangeRequests: vi.fn(async () => []),
86
87
  listMyChangeRequests: myCrsMock,
87
88
  readFileOnBranch: readBranchMock,
89
+ // No fork point: the change boxes fall back to the default branch, which is
90
+ // what these tests diff against.
91
+ readFileAtForkPoint: vi.fn(async () => ({ content: null, forkSha: null })),
88
92
  }));
89
93
 
90
94
  // The access sheet is a 1200-line dialog with its own suite and its own
@@ -131,6 +135,7 @@ import { GitContext, type GitContextValue } from '../../../git/state/git.context
131
135
  import { ReviewContext, type ReviewContextValue } from '../../../review/state/review.context';
132
136
  import { AuthContext, type AuthContextValue } from '../../../auth/state/auth.context';
133
137
  import { OpenChangeRequestsContext } from '../../state/open-change-requests.context';
138
+ import { OPEN_COMPARISON_EVENT } from '../../../../core/events';
134
139
 
135
140
  let injectPendingFromTest: ((value?: string) => void) | null = null;
136
141
 
@@ -152,12 +157,15 @@ const fetchFileHistoryMock = vi.fn(async () => [
152
157
  },
153
158
  ]);
154
159
 
155
- function makeGit(status: WorkingTreeStatus | null): GitContextValue {
160
+ function makeGit(
161
+ status: WorkingTreeStatus | null,
162
+ availability: GitContextValue['availability'] = 'ready',
163
+ ): GitContextValue {
156
164
  const branches: BranchInfo[] = [];
157
165
  return {
158
166
  status,
159
167
  branches,
160
- availability: 'ready',
168
+ availability,
161
169
  lastError: null,
162
170
  refreshStatus: async () => null,
163
171
  refreshBranches: async () => {},
@@ -194,8 +202,11 @@ function ViewerHarness({
194
202
  changeRequests = [],
195
203
  authUser = null,
196
204
  captureTyped = false,
205
+ gitAvailability = 'ready',
197
206
  }: {
198
207
  initialContent?: string;
208
+ /** What git reports about itself; the history views need `'ready'`. */
209
+ gitAvailability?: GitContextValue['availability'];
199
210
  pendingValue?: string;
200
211
  /** `null` = git status has not loaded (or failed) — there is no branch yet. */
201
212
  branch?: string | null;
@@ -249,6 +260,8 @@ function ViewerHarness({
249
260
  kbDirName,
250
261
  fileTree,
251
262
  bootstrapError: null,
263
+ workspaceBranch: 'main',
264
+ retryBootstrap: () => {},
252
265
  openTabs: tab ? [tab] : [],
253
266
  activeTab: tab,
254
267
  dirtyTabFilenames: [],
@@ -258,8 +271,8 @@ function ViewerHarness({
258
271
  hasUnsavedFileChanges: false,
259
272
  pendingFileContent,
260
273
  setActiveTabContent: captureTyped ? (v: string) => setOpenFileContent(v) : () => {},
261
- uploadError: null,
262
- uploadNotice: null,
274
+ uploadErrors: new Map(),
275
+ uploadNotices: new Map(),
263
276
  clearUploadNotice: () => {},
264
277
  isUploading: false,
265
278
  uploadProgress: null,
@@ -273,7 +286,7 @@ function ViewerHarness({
273
286
  activateTab: () => {},
274
287
  reorderTab: () => {},
275
288
  closeAllTabs: () => {},
276
- hydrateTabs: async () => ({ surviving: [], dropped: [], denied: [] }),
289
+ hydrateTabs: async () => ({ surviving: [], dropped: [], denied: [], superseded: false }),
277
290
  createFile: async () => {},
278
291
  createDirectory: async () => {},
279
292
  unzipHere: async () => ({ extracted: 0, skipped: [], destination: '' }),
@@ -327,7 +340,7 @@ function ViewerHarness({
327
340
  const tree = (
328
341
  <AuthContext.Provider value={auth}>
329
342
  <WorkspaceContext.Provider value={workspace}>
330
- <GitContext.Provider value={makeGit(branch ? makeStatus(branch) : null)}>
343
+ <GitContext.Provider value={makeGit(branch ? makeStatus(branch) : null, gitAvailability)}>
331
344
  <ReviewContext.Provider value={review}>
332
345
  <OpenChangeRequestsContext.Provider
333
346
  value={{
@@ -379,6 +392,10 @@ describe('FileViewer', () => {
379
392
  owners: EMPTY_ELIGIBLE,
380
393
  };
381
394
  accessMock.fetchFileAccess.mockClear();
395
+ // mockClear keeps the implementation: a test that parks the lookup
396
+ // in flight would park every test after it.
397
+ accessMock.fetchFileAccess.mockImplementation(async () => accessMock.result);
398
+ readBranchMock.mockImplementation(async () => '');
382
399
  // Restore the default "acquire succeeds" behaviour so a per-test 403
383
400
  // override doesn't leak into the next test.
384
401
  vi.mocked(acquireLockMock).mockImplementation(async () => ({
@@ -395,6 +412,41 @@ describe('FileViewer', () => {
395
412
  }));
396
413
  });
397
414
 
415
+ /**
416
+ * The seam, in the page that broke it.
417
+ *
418
+ * `HeaderAlignment.test.tsx` measures the band's HEIGHT and checks that a
419
+ * document column opens on it. This checks the thing only the real page can
420
+ * say: that the file page actually hands its title bar to that slot. It
421
+ * used to render `<EditorTabs />` above `<KbPageHeader>` inside the column,
422
+ * so the title bar opened 54px below the sidebar header row it is supposed
423
+ * to line up with — at every width, unaffected by collapsing or resizing the
424
+ * sidebar, and invisible to a suite in which no test rendered the header
425
+ * anywhere near a tab strip. Staging found it; this is what would have.
426
+ *
427
+ * Structural, not measured: happy-dom has no layout engine, so "nothing is
428
+ * drawn above the band" is the checkable form of "the band's top edge is
429
+ * the column's top edge".
430
+ */
431
+ it('opens the document column with the title bar, above the tab strip', async () => {
432
+ render(<ViewerHarness initialContent="Base content" />);
433
+
434
+ const band = await screen.findByTestId(PAGE_HEADER_TESTID);
435
+ // The harness opens one tab, so the strip really is rendered — without it
436
+ // this test would pass on the broken code too.
437
+ const tabs = screen.getByRole('tablist', { name: 'Open files' });
438
+
439
+ // Nothing above the band inside its column — the checkable form of "its
440
+ // top edge is the column's top edge".
441
+ expect(band.previousElementSibling).toBeNull();
442
+ // And the strip did not leave the column to get there; it went below the
443
+ // title. One column still holds the title, the tabs and the text
444
+ // (proto:700-705) — this only changed the order inside it.
445
+ const column = band.parentElement!;
446
+ expect(column.contains(tabs)).toBe(true);
447
+ expect(band.compareDocumentPosition(tabs) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
448
+ });
449
+
398
450
  it('immediately enters review mode when pending arrives on a clean file', async () => {
399
451
  const user = userEvent.setup();
400
452
  render(<ViewerHarness initialContent="base clean" pendingValue="agent clean" />);
@@ -681,17 +733,151 @@ describe('FileViewer', () => {
681
733
  expect(screen.queryByRole('button', { name: 'Compare' })).not.toBeInTheDocument();
682
734
  });
683
735
 
684
- it('opens Version history from ⋯ and offers a way back to the document', async () => {
736
+ it('opens Version history from the clock-arrow beside Edit and offers a way back to the document', async () => {
685
737
  const user = userEvent.setup();
686
738
  render(<ViewerHarness initialContent="historic" />);
687
739
 
688
- await user.click(screen.getByRole('button', { name: 'More actions' }));
689
- await user.click(screen.getByRole('menuitem', { name: /Version history/ }));
740
+ // ONE clock: the prose pane bar carries it beside Edit, and the header
741
+ // stands down (`historyInPane`) rather than offering a second.
742
+ await user.click(screen.getByRole('button', { name: 'Version history' }));
690
743
 
691
744
  const back = await screen.findByRole('button', { name: /Back to the document/ });
692
745
  await user.click(back);
693
746
  // The document is back, and so is its Edit affordance.
694
747
  expect(await screen.findByRole('button', { name: 'Edit' })).toBeInTheDocument();
748
+ // The Back button unmounted with the log. Keyboard focus lands on the
749
+ // bar's clock, the same handoff the header's pressed clock makes, rather
750
+ // than falling to `document`.
751
+ expect(screen.getByRole('button', { name: 'Version history' })).toHaveFocus();
752
+ });
753
+
754
+ /**
755
+ * Opening the log unmounts the editor. Coming back re-mounts it from its
756
+ * seed, while the buffer Send reads still holds the newer keystrokes: the
757
+ * page would show one text and submit another. So the clock goes away for
758
+ * exactly as long as a draft is open, the rule the skill page applies.
759
+ */
760
+ it('withdraws Version history while the editor is open, and returns it on Done', async () => {
761
+ const user = userEvent.setup();
762
+ render(<ViewerHarness initialContent="draft me" />);
763
+
764
+ expect(screen.getByRole('button', { name: 'Version history' })).toBeInTheDocument();
765
+ await user.click(screen.getByRole('button', { name: 'Edit' }));
766
+ await screen.findByRole('button', { name: 'Done' });
767
+ expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
768
+
769
+ await user.click(screen.getByRole('button', { name: 'Done' }));
770
+ expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
771
+ });
772
+
773
+ /**
774
+ * The chat's "View full comparison" link lands whenever the agent answers,
775
+ * and `availability` starts 'loading' until the first status poll returns.
776
+ * The comparison is not gated on the log's availability: the panel asks git
777
+ * itself and reports what it gets. Cancelling the tab here instead dropped
778
+ * the click with nothing on screen to say so.
779
+ */
780
+ it('opens the comparison a chat link asks for before git has answered, and keeps it through a failed poll', async () => {
781
+ const { rerender } = render(<ViewerHarness initialContent="compared" gitAvailability="loading" />);
782
+
783
+ act(() => {
784
+ window.dispatchEvent(
785
+ new CustomEvent(OPEN_COMPARISON_EVENT, {
786
+ detail: { path: 'knowledge-base/Knowledge/Foo.md', fromBranch: 'main', toBranch: 'alice/draft' },
787
+ }),
788
+ );
789
+ });
790
+ expect(await screen.findByRole('button', { name: /Back to the document/ })).toBeInTheDocument();
791
+ expect(screen.getByText('Compare versions')).toBeInTheDocument();
792
+
793
+ // A poll fails while the comparison is up. It stays up: the reader asked
794
+ // for it, and only the log closes when git stops answering.
795
+ rerender(<ViewerHarness initialContent="compared" gitAvailability="error" />);
796
+ expect(screen.getByRole('button', { name: /Back to the document/ })).toBeInTheDocument();
797
+ expect(screen.getByText('Compare versions')).toBeInTheDocument();
798
+ });
799
+
800
+ /**
801
+ * The comparison outliving `historyAvailable` is the case where the focus
802
+ * handoff has no clock to hand back to: both are withdrawn while git is
803
+ * silent. Leaving the comparison then would drop focus on `document`, the
804
+ * one outcome the handoff exists to prevent, so the document's own title is
805
+ * named last. Found by cubic on #135.
806
+ */
807
+ it('lands focus on the document title when leaving a comparison git cannot back with a clock', async () => {
808
+ const user = userEvent.setup();
809
+ render(<ViewerHarness initialContent="compared" gitAvailability="error" />);
810
+
811
+ act(() => {
812
+ window.dispatchEvent(
813
+ new CustomEvent(OPEN_COMPARISON_EVENT, {
814
+ detail: { path: 'knowledge-base/Knowledge/Foo.md', fromBranch: 'main', toBranch: 'alice/draft' },
815
+ }),
816
+ );
817
+ });
818
+ const back = await screen.findByRole('button', { name: /Back to the document/ });
819
+ // Neither clock is on screen to catch the focus.
820
+ expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
821
+
822
+ await user.click(back);
823
+ expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
824
+ const title = screen.getByRole('heading', { level: 1, name: 'Foo' });
825
+ expect(document.activeElement).toBe(title);
826
+ expect(document.activeElement).not.toBe(document.body);
827
+ });
828
+
829
+ // With the log open the column goes full-bleed and the header carries the
830
+ // clock, pressed. Clicking it again is the other way back.
831
+ /**
832
+ * `availability` is re-derived from a POLLED status call, so one failed
833
+ * poll flips it off and the next good one flips it back. If `activeTab`
834
+ * survived that on 'history', the column would stay full-bleed with no
835
+ * panel in it (a bare document, no pane card, no way back but the next
836
+ * poll), and then put the log back over the file the moment git recovered.
837
+ * Found by cubic on #134; the skill page already had the rule.
838
+ */
839
+ it('puts the document back when git stops answering mid-read, and does not reopen the log when it recovers', async () => {
840
+ const user = userEvent.setup();
841
+ const { rerender } = render(<ViewerHarness initialContent="historic" />);
842
+
843
+ await user.click(screen.getByRole('button', { name: 'Version history' }));
844
+ await screen.findByRole('button', { name: /Back to the document/ });
845
+
846
+ // A poll fails: the log goes, and the document is back in its pane card
847
+ // with its Edit, not stranded full-bleed.
848
+ rerender(<ViewerHarness initialContent="historic" gitAvailability="error" />);
849
+ expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
850
+ expect(await screen.findByRole('button', { name: 'Edit' })).toBeInTheDocument();
851
+ expect(screen.getByTestId('file-pane-card')).toBeInTheDocument();
852
+ expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
853
+
854
+ // The next poll succeeds. The file is still what is on screen, and the
855
+ // clock is back, unpressed.
856
+ rerender(<ViewerHarness initialContent="historic" gitAvailability="ready" />);
857
+ expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
858
+ expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument();
859
+ expect(screen.getByRole('button', { name: 'Version history' })).toBeInTheDocument();
860
+ });
861
+
862
+ it('closes Version history from the pressed clock in the header', async () => {
863
+ const user = userEvent.setup();
864
+ render(<ViewerHarness initialContent="historic" />);
865
+
866
+ await user.click(screen.getByRole('button', { name: 'Version history' }));
867
+ await screen.findByRole('button', { name: /Back to the document/ });
868
+ // The pane bar's clock unmounted with the bar; focus lands on the
869
+ // header's pressed clock rather than falling to `document`.
870
+ const pressed = screen.getByRole('button', { name: 'Version history' });
871
+ expect(pressed).toHaveAttribute('aria-pressed', 'true');
872
+ expect(document.activeElement).toBe(pressed);
873
+
874
+ await user.click(pressed);
875
+ expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
876
+ expect(await screen.findByRole('button', { name: 'Edit' })).toBeInTheDocument();
877
+ // And back: the header's clock hid again, so focus lands on the bar's.
878
+ const paneClock = screen.getByRole('button', { name: 'Version history' });
879
+ expect(paneClock).not.toHaveAttribute('aria-pressed', 'true');
880
+ expect(document.activeElement).toBe(paneClock);
695
881
  });
696
882
 
697
883
  it('shares the file itself from Share, and the parent folder from the chevron', async () => {
@@ -748,6 +934,110 @@ describe('FileViewer', () => {
748
934
  ).toBeInTheDocument();
749
935
  });
750
936
 
937
+ /**
938
+ * "Waiting on you and N others" counts the people who can APPROVE — the
939
+ * write: grants — not the owner: list. A file written by Bob and Carl (plus
940
+ * the inherited Admin role) with no owners must not tell Bob he is the only
941
+ * one it waits on.
942
+ */
943
+ it('counts the other approvers from the write grants, not the owners', async () => {
944
+ accessMock.result = {
945
+ canWrite: true,
946
+ canOwner: false,
947
+ eligible: {
948
+ roles: ['Admin'],
949
+ users: [
950
+ { name: 'Bob', email: 'bob@example.com' },
951
+ { name: 'Carl', email: 'carl@example.com' },
952
+ ],
953
+ },
954
+ owners: EMPTY_ELIGIBLE,
955
+ };
956
+ // The proposal must actually differ from the file, or the box reads
957
+ // "Already up to date" and has no verdict to wait on.
958
+ readBranchMock.mockImplementation((async (branch: string) =>
959
+ branch.startsWith('suggestions/') ? 'proposed' : 'current') as never);
960
+ render(
961
+ <ViewerHarness
962
+ initialContent="contested"
963
+ branch="target-company-state"
964
+ authUser={{ id: 'u-bob', email: 'bob@example.com', name: 'Bob' }}
965
+ changeRequests={[{ number: 33, title: 'Tighten the wording', who: 'Ali Raza' }]}
966
+ />,
967
+ );
968
+
969
+ expect(await screen.findByText('Waiting on you and 2 others')).toBeInTheDocument();
970
+ expect(screen.getByRole('button', { name: 'Approve' })).toBeInTheDocument();
971
+ });
972
+
973
+ /**
974
+ * A failed access lookup default-allows with an EMPTY grant list. That list
975
+ * is not the approver set, so the box must not claim "Waiting on you".
976
+ */
977
+ it('makes no waiting-on claim when the approver grants never loaded', async () => {
978
+ accessMock.fetchFileAccess.mockRejectedValueOnce(new Error('network down'));
979
+ readBranchMock.mockImplementation((async (branch: string) =>
980
+ branch.startsWith('suggestions/') ? 'proposed' : 'current') as never);
981
+ render(
982
+ <ViewerHarness
983
+ initialContent="contested"
984
+ branch="target-company-state"
985
+ authUser={{ id: 'u-bob', email: 'bob@example.com', name: 'Bob' }}
986
+ changeRequests={[{ number: 33, title: 'Tighten the wording', who: 'Ali Raza' }]}
987
+ />,
988
+ );
989
+
990
+ expect(await screen.findByText('You can decide this.')).toBeInTheDocument();
991
+ expect(screen.queryByText(/Waiting on you/)).not.toBeInTheDocument();
992
+ });
993
+
994
+ /**
995
+ * Switching files keeps the PREVIOUS file's grants in the access hook until
996
+ * the next lookup answers — which is why the "and N others" count is gated on
997
+ * `!access.loading`. The "Waiting on …" line is the same hazard: it names
998
+ * people, and naming the OUTGOING file's owners over the incoming file's box
999
+ * is a false statement about who decides this change. Mid-lookup it has to
1000
+ * fall back to the anonymous wording.
1001
+ */
1002
+ it('never names the previous file’s owners while the next lookup is in flight', async () => {
1003
+ accessMock.result = {
1004
+ canWrite: false,
1005
+ canOwner: false,
1006
+ eligible: { roles: ['Docs'], users: [] },
1007
+ owners: { roles: ['Docs'], users: [] },
1008
+ };
1009
+ readBranchMock.mockImplementation((async (branch: string) =>
1010
+ branch.startsWith('suggestions/') ? 'proposed' : 'current') as never);
1011
+ // The outgoing file's only job is to be the file we switch AWAY from,
1012
+ // leaving its owners behind in the hook. It renders a box of its own —
1013
+ // nothing is asserted on that one.
1014
+ const { rerender } = render(
1015
+ <ViewerHarness
1016
+ initialContent="outgoing"
1017
+ branch="target-company-state"
1018
+ filePath="knowledge-base/Knowledge/Other.md"
1019
+ changeRequests={[{ number: 34, title: 'Tighten the wording', who: 'Ali Raza' }]}
1020
+ />,
1021
+ );
1022
+ await waitFor(() => expect(accessMock.fetchFileAccess).toHaveBeenCalled());
1023
+
1024
+ // The incoming file's lookup never answers, so the box renders for the
1025
+ // whole of the in-flight window.
1026
+ accessMock.fetchFileAccess.mockImplementation(() => new Promise(() => {}));
1027
+ rerender(
1028
+ <ViewerHarness
1029
+ initialContent="incoming"
1030
+ branch="target-company-state"
1031
+ filePath="knowledge-base/Knowledge/Foo.md"
1032
+ changeRequests={[{ number: 34, title: 'Tighten the wording', who: 'Ali Raza' }]}
1033
+ />,
1034
+ );
1035
+
1036
+ expect(await screen.findByText(/proposed a change/)).toBeInTheDocument();
1037
+ expect(screen.getByText('Waiting on the owners')).toBeInTheDocument();
1038
+ expect(screen.queryByText('Waiting on Docs')).not.toBeInTheDocument();
1039
+ });
1040
+
751
1041
  it('says nothing on a file nobody has proposed a change to', () => {
752
1042
  render(<ViewerHarness initialContent="quiet" />);
753
1043
  expect(screen.queryByText(/proposed a change/)).not.toBeInTheDocument();
@@ -938,6 +1228,37 @@ describe('FileViewer: proposing a change without write access', () => {
938
1228
  expect(proposeMock).not.toHaveBeenCalled();
939
1229
  });
940
1230
 
1231
+ /**
1232
+ * The seeded case is where the clock did real damage: the editor re-mounts
1233
+ * from `proposeSeed` on the way back from the log, while `proposeBufferRef`
1234
+ * still holds the newer keystrokes — the old text on screen, the new text
1235
+ * sent. No clock while a proposal is open.
1236
+ */
1237
+ it('withdraws Version history while a proposal is open, and returns it on Discard', async () => {
1238
+ denyWrite();
1239
+ myCrsMock.mockResolvedValue([
1240
+ { number: 12, state: 'open', branch: 'suggestions/reader-u9/knowledge' },
1241
+ ]);
1242
+ readBranchMock.mockResolvedValue('first proposed paragraph');
1243
+ const user = userEvent.setup();
1244
+ render(
1245
+ <ViewerHarness
1246
+ initialContent="official"
1247
+ branch="target-company-state"
1248
+ authUser={reader}
1249
+ captureTyped
1250
+ />,
1251
+ );
1252
+
1253
+ expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
1254
+ await user.click(screen.getByRole('button', { name: 'Propose changes' }));
1255
+ await screen.findByRole('textbox');
1256
+ expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
1257
+
1258
+ await user.click(screen.getByRole('button', { name: 'Discard' }));
1259
+ expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
1260
+ });
1261
+
941
1262
  it('discard walks away without sending anything', async () => {
942
1263
  denyWrite();
943
1264
  const user = userEvent.setup();
@@ -972,7 +1293,15 @@ describe('FileViewer: proposing a change without write access', () => {
972
1293
  * away from the pages it holds. It offers those pages now.
973
1294
  */
974
1295
  describe('FileViewer: nothing open', () => {
975
- const TREE: FileTreeEntry = {
1296
+ /** The workspace root the API returns, wrapping whatever the checkout holds. */
1297
+ const workspace = (checkout: FileTreeEntry): FileTreeEntry => ({
1298
+ name: '.',
1299
+ relativePath: '.',
1300
+ type: 'directory',
1301
+ children: [checkout],
1302
+ });
1303
+
1304
+ const CHECKOUT: FileTreeEntry = {
976
1305
  name: 'knowledge-base',
977
1306
  relativePath: 'knowledge-base',
978
1307
  type: 'directory',
@@ -1022,6 +1351,22 @@ describe('FileViewer: nothing open', () => {
1022
1351
  ],
1023
1352
  };
1024
1353
 
1354
+ const TREE = workspace(CHECKOUT);
1355
+
1356
+ /**
1357
+ * The strays that sat beside the checkout on core-staging. Nothing here is
1358
+ * the repository, so nothing here is ever offered as a page.
1359
+ */
1360
+ const STRAYS: FileTreeEntry[] = [
1361
+ {
1362
+ name: 'KnowledgeBase',
1363
+ relativePath: 'KnowledgeBase',
1364
+ type: 'directory',
1365
+ children: [{ name: 'Planted.md', relativePath: 'KnowledgeBase/Planted.md', type: 'file' }],
1366
+ },
1367
+ { name: 'Stray.md', relativePath: 'Stray.md', type: 'file' },
1368
+ ];
1369
+
1025
1370
  it('does not send the reader off to an assistant', async () => {
1026
1371
  render(<ViewerHarness filePath={null} fileTree={TREE} />);
1027
1372
  await screen.findByRole('heading', { name: /Open a page/ });
@@ -1106,6 +1451,30 @@ describe('FileViewer: nothing open', () => {
1106
1451
  expect(await screen.findByRole('button', { name: /Handbook/ })).toBeEnabled();
1107
1452
  });
1108
1453
 
1454
+ /**
1455
+ * The strays on core-staging put a `KnowledgeBase/` beside the checkout.
1456
+ * The offer is the checkout's, so they change nothing — and when the
1457
+ * checkout itself is gone there is nothing to offer, rather than whatever
1458
+ * was written next to it.
1459
+ */
1460
+ it('offers the same pages with strays beside the checkout, and none without one', async () => {
1461
+ const { unmount } = render(
1462
+ <ViewerHarness
1463
+ filePath={null}
1464
+ fileTree={{ ...TREE, children: [...STRAYS, CHECKOUT] }}
1465
+ />,
1466
+ );
1467
+ expect(await screen.findByRole('button', { name: /Handbook/ })).toBeInTheDocument();
1468
+ expect(screen.queryByRole('button', { name: /Planted/ })).toBeNull();
1469
+ expect(screen.queryByRole('button', { name: /Stray/ })).toBeNull();
1470
+ unmount();
1471
+
1472
+ render(<ViewerHarness filePath={null} fileTree={{ ...TREE, children: STRAYS }} />);
1473
+ await screen.findByRole('heading', { name: /Open a page/ });
1474
+ expect(screen.queryByRole('button', { name: /Planted/ })).toBeNull();
1475
+ expect(screen.getByText('Pick anything from the file tree.')).toBeInTheDocument();
1476
+ });
1477
+
1109
1478
  /** A knowledge base with nothing in it has nothing to suggest, and says so. */
1110
1479
  it('promises nothing when there is nothing to open', async () => {
1111
1480
  render(<ViewerHarness filePath={null} fileTree={null} />);
@@ -1122,14 +1491,14 @@ describe('FileViewer: nothing open', () => {
1122
1491
  render(
1123
1492
  <ViewerHarness
1124
1493
  filePath={null}
1125
- fileTree={{
1494
+ fileTree={workspace({
1126
1495
  name: 'knowledge-base',
1127
1496
  relativePath: 'knowledge-base',
1128
1497
  type: 'directory',
1129
1498
  children: [
1130
1499
  { name: 'Charter.md', relativePath: 'knowledge-base/Charter.md', type: 'file' },
1131
1500
  ],
1132
- }}
1501
+ })}
1133
1502
  />,
1134
1503
  );
1135
1504
  expect(await screen.findByRole('button', { name: /Charter/ })).toBeInTheDocument();
@@ -10,6 +10,45 @@ import { KbDocumentShell } from '../KbDocumentShell';
10
10
  * lands on — rather than computed pixels.
11
11
  */
12
12
  describe('KbDocumentShell', () => {
13
+ /**
14
+ * The `header` slot's whole contract, in one assertion per variant: the
15
+ * band opens the column, whatever else the page puts in it.
16
+ *
17
+ * It is a slot rather than the caller's first child because a caller
18
+ * forgot — `FileViewer` rendered the tab strip above its title bar and put
19
+ * the file page's band 54px below the sidebar header row it lines up with.
20
+ * What that costs, and the offset each variant opens on, is asserted at the
21
+ * seam in `layout/__tests__/HeaderAlignment.test.tsx`; that the file page
22
+ * really uses the slot is asserted in `FileViewer.test.tsx`.
23
+ */
24
+ it.each([
25
+ ['prose', {}],
26
+ ['full-bleed', { variant: 'full-bleed' as const }],
27
+ ['with a rail', { rail: <p>About this file</p> }],
28
+ ])('puts the header first in the column (%s)', (_name, props) => {
29
+ render(
30
+ <KbDocumentShell {...props} header={<h1>The title bar</h1>}>
31
+ <div>Everything else the page renders</div>
32
+ </KbDocumentShell>,
33
+ );
34
+ const band = screen.getByText('The title bar');
35
+ const content = screen.getByText('Everything else the page renders');
36
+
37
+ // IN the column, not above it. "First" on its own is satisfied by a band
38
+ // hoisted into a wrapper of its own — which is the regression that
39
+ // reaches the seam, because a wrapper outside the column does not carry
40
+ // the column's `HEADER_COLUMN_TOP` and can put anything underneath it.
41
+ // Tying the band to the content is what makes the next two lines mean
42
+ // "opens the column" rather than "opens something".
43
+ expect(band.parentElement).toBe(content.parentElement);
44
+ expect(band.previousElementSibling).toBeNull();
45
+ expect(band.nextElementSibling).toBe(content);
46
+
47
+ // And the column is inside the shell's own scrolling box in every
48
+ // variant, so nothing can render between the two.
49
+ expect(screen.getByTestId('kb-document-shell')).toContainElement(band);
50
+ });
51
+
13
52
  it('renders children inside a centred, measured column', () => {
14
53
  render(
15
54
  <KbDocumentShell>
@@ -126,28 +126,29 @@ describe('KbPageHeader', () => {
126
126
  expect(screen.getByText('Agent update waiting')).toBeInTheDocument();
127
127
  });
128
128
 
129
- it('offers the whole overflow behind ⋯', async () => {
129
+ // Version history is a button of its own — the clock-arrow beside Edit,
130
+ // where Google Docs keeps it. It used to be the lone item behind a ⋯, and
131
+ // a menu with one entry is a hiding place, not an overflow.
132
+ it('opens Version history from the clock-arrow, with no overflow menu in the way', async () => {
130
133
  const user = userEvent.setup();
131
- renderHeader();
132
- await user.click(screen.getByRole('button', { name: 'More actions' }));
133
- expect(screen.getByRole('menuitem', { name: /Version history/ })).toBeInTheDocument();
134
+ const { props } = renderHeader();
135
+ await user.click(screen.getByRole('button', { name: 'Version history' }));
136
+ expect(props.onOpenHistory).toHaveBeenCalled();
137
+ expect(screen.queryByRole('button', { name: 'More actions' })).not.toBeInTheDocument();
134
138
  });
135
139
 
136
- // Copying a reference to this page is one errand, and Share owns it. Two
137
- // menus offering near-identical copies is how someone pastes the wrong one.
138
- it('does not repeat Copy path in the overflow. Share owns copying a reference', async () => {
139
- const user = userEvent.setup();
140
- renderHeader();
141
- await user.click(screen.getByRole('button', { name: 'More actions' }));
142
- expect(screen.queryByRole('menuitem', { name: /Copy path/i })).not.toBeInTheDocument();
140
+ // Git not being ready means there is no log to show, so the button goes
141
+ // rather than opening onto nothing.
142
+ it('drops the Version history button entirely when git is not ready', () => {
143
+ renderHeader({ historyAvailable: false });
144
+ expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
143
145
  });
144
146
 
145
- // Version history is the whole menu now, so git not being ready leaves
146
- // nothing behind ⋯ — and the trigger goes with it rather than opening onto
147
- // an empty panel.
148
- it('drops the ⋯ trigger entirely when git is not ready', () => {
149
- renderHeader({ historyAvailable: false });
150
- expect(screen.queryByRole('button', { name: 'More actions' })).not.toBeInTheDocument();
147
+ // A prose document's pane bar owns Edit and carries Version history beside
148
+ // it; a second clock in the header would be two controls for one action.
149
+ it('leaves Version history to the pane bar when the pane carries it', () => {
150
+ renderHeader({ historyInPane: true });
151
+ expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
151
152
  });
152
153
 
153
154
  // A copy that fails must say so — `navigator.clipboard` rejects outright on
@@ -178,6 +179,18 @@ describe('KbPageHeader', () => {
178
179
  expect(await screen.findByRole('menuitem', { name: /Copied/ })).toBeInTheDocument();
179
180
  });
180
181
 
182
+ it('copies the root-anchored path from the page menu', async () => {
183
+ const user = userEvent.setup();
184
+ // After `setup()`, which installs a clipboard stub of its own.
185
+ const writeText = vi.fn(async () => {});
186
+ Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
187
+ renderHeader();
188
+ await user.click(screen.getByRole('button', { name: 'More sharing options' }));
189
+ await user.click(screen.getByRole('menuitem', { name: /Copy path/ }));
190
+ expect(writeText).toHaveBeenCalledWith('/knowledge-base/Knowledge/Invariant.md');
191
+ expect(await screen.findByRole('menuitem', { name: /Copied/ })).toBeInTheDocument();
192
+ });
193
+
181
194
  it('says so on the row when copying the link fails', async () => {
182
195
  const user = userEvent.setup();
183
196
  renderHeader({ onCopyLink: vi.fn(async () => false) });
@@ -194,14 +207,14 @@ describe('KbPageHeader', () => {
194
207
  it('closes an open menu on Escape and returns focus to its trigger', async () => {
195
208
  const user = userEvent.setup();
196
209
  renderHeader();
197
- const trigger = screen.getByRole('button', { name: 'More actions' });
210
+ const trigger = screen.getByRole('button', { name: 'More sharing options' });
198
211
  await user.click(trigger);
199
- expect(screen.getByRole('menu', { name: 'More actions' })).toBeInTheDocument();
212
+ expect(screen.getByRole('menu', { name: 'Sharing options' })).toBeInTheDocument();
200
213
 
201
214
  await act(async () => {
202
215
  fireEvent.keyDown(document, { key: 'Escape' });
203
216
  });
204
- expect(screen.queryByRole('menu', { name: 'More actions' })).not.toBeInTheDocument();
217
+ expect(screen.queryByRole('menu', { name: 'Sharing options' })).not.toBeInTheDocument();
205
218
  expect(document.activeElement).toBe(trigger);
206
219
  });
207
220
  });