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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +16 -9
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/events.test.ts +43 -0
  6. package/src/core/bootstrap.ts +11 -3
  7. package/src/core/events.ts +85 -3
  8. package/src/core/registry.ts +1 -1
  9. package/src/lib/__tests__/email.test.ts +44 -0
  10. package/src/lib/email.ts +37 -1
  11. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  12. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  13. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  16. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  20. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
  21. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  22. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  23. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  24. package/src/modules/access/api.ts +140 -6
  25. package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
  26. package/src/modules/access/manage-access-affordance.ts +17 -0
  27. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  28. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  29. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  30. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  31. package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
  32. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  33. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  34. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  35. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  36. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  37. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  38. package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
  39. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  40. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  41. package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
  42. package/src/modules/admin/components/group-members-path.ts +32 -0
  43. package/src/modules/admin/services/connection-keys.api.ts +47 -0
  44. package/src/modules/admin/services/roles.api.ts +12 -1
  45. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  46. package/src/modules/auth/components/AccountPage.tsx +73 -54
  47. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  48. package/src/modules/auth/services/account.api.ts +78 -4
  49. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  50. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  51. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  52. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  53. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  57. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  58. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  59. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  60. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  61. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  62. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  63. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  64. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  65. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  66. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  67. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  68. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  69. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  70. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  71. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  72. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  73. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  74. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  75. package/src/modules/change-requests/services/propose.api.ts +97 -8
  76. package/src/modules/change-requests/utils/approval.ts +15 -0
  77. package/src/modules/change-requests/utils/author.ts +32 -0
  78. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  79. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  80. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  81. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  82. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  83. package/src/modules/git/services/error-messages.ts +12 -0
  84. package/src/modules/git/services/pr-prompts.ts +5 -5
  85. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  86. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  87. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  88. package/src/modules/layout/components/AppLayout.tsx +2 -0
  89. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  90. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  91. package/src/modules/layout/components/SidebarFrame.tsx +108 -3
  92. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  93. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  94. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  95. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  96. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  97. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
  98. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
  99. package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
  100. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
  101. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  102. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  103. package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
  104. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  105. package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
  106. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
  107. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
  108. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  109. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  110. package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
  111. package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
  112. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  113. package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
  114. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
  115. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  116. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  117. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  118. package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
  119. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  120. package/src/modules/library/__tests__/library-paths.test.ts +47 -4
  121. package/src/modules/library/__tests__/link-membership.test.ts +13 -4
  122. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  123. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  124. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  125. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  126. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  127. package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
  128. package/src/modules/library/__tests__/status.test.ts +82 -2
  129. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  130. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  131. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  132. package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
  133. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  134. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  135. package/src/modules/library/components/LibraryCard.tsx +146 -45
  136. package/src/modules/library/components/LibraryLayout.tsx +119 -256
  137. package/src/modules/library/components/LibraryPage.tsx +172 -39
  138. package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
  139. package/src/modules/library/components/LockedPluginView.tsx +62 -34
  140. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  141. package/src/modules/library/components/NewPluginDialog.tsx +16 -2
  142. package/src/modules/library/components/PageActions.tsx +11 -9
  143. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  144. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  145. package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
  146. package/src/modules/library/components/PluginExtras.tsx +140 -17
  147. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  148. package/src/modules/library/components/PluginPage.tsx +157 -41
  149. package/src/modules/library/components/PluginRows.tsx +286 -0
  150. package/src/modules/library/components/PluginsSidebar.tsx +239 -263
  151. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  152. package/src/modules/library/components/ShareButton.tsx +17 -0
  153. package/src/modules/library/components/SkillsTree.tsx +141 -28
  154. package/src/modules/library/components/TeamRoute.tsx +15 -0
  155. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  156. package/src/modules/library/components/plugin-page-parts.tsx +103 -17
  157. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
  158. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  159. package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
  160. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  161. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  162. package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
  163. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  164. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  165. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  166. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  167. package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
  168. package/src/modules/library/routes/library-paths.ts +26 -28
  169. package/src/modules/library/services/library.api.ts +38 -20
  170. package/src/modules/library/services/plugins.api.ts +69 -8
  171. package/src/modules/library/services/teams.api.ts +15 -0
  172. package/src/modules/library/services/tools.api.ts +78 -0
  173. package/src/modules/library/state/library-data.tsx +170 -32
  174. package/src/modules/library/utils/personal-plugin.ts +13 -15
  175. package/src/modules/library/utils/plugin-entries.ts +134 -0
  176. package/src/modules/library/utils/plugin-summary.ts +75 -9
  177. package/src/modules/library/utils/status.ts +135 -33
  178. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
  179. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  180. package/src/modules/onboarding/agent-clients.ts +55 -23
  181. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  182. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  183. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  184. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  185. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  186. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  187. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  188. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  189. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  190. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  191. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  192. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  193. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  194. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  195. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  196. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  197. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  198. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  199. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  200. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  201. package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
  202. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  203. package/src/modules/settings/components/DeploymentPage.tsx +10 -30
  204. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  205. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
  206. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  207. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
  208. package/src/modules/settings/services/github-facade.api.ts +23 -0
  209. package/src/modules/settings/settings-nav-items.tsx +10 -2
  210. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  211. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  212. package/src/modules/setup/__tests__/setup.test.tsx +497 -4
  213. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  214. package/src/modules/setup/components/SetupGate.tsx +16 -16
  215. package/src/modules/setup/components/SetupScreen.tsx +521 -43
  216. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  217. package/src/modules/setup/services/setup.api.ts +140 -3
  218. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  219. package/src/modules/setup/utils/root-folders.ts +46 -0
  220. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  221. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  222. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  223. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  224. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  225. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  226. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  227. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  228. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  229. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  230. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  231. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  232. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  233. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  234. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  235. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  236. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
  237. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  238. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  239. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  240. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
  241. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  242. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  243. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  244. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  245. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  246. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  247. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  248. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  249. package/src/modules/toolbar/services/external-api-keys.api.ts +6 -0
  250. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  251. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  252. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  253. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  254. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  255. package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
  256. package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
  257. package/src/modules/workspace/components/FileRoute.tsx +353 -36
  258. package/src/modules/workspace/components/FileViewer.tsx +166 -45
  259. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  260. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  261. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  262. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
  263. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
  264. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +331 -12
  265. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  266. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  267. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  268. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  269. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  270. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  271. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  272. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  273. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  274. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  275. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  276. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  277. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  278. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  279. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  280. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  281. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  282. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  283. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  284. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  285. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  286. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  287. package/src/modules/workspace/components/renderers/index.ts +53 -2
  288. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  289. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  290. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  291. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  292. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  293. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  294. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  295. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
  296. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  297. package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
  298. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  299. package/src/modules/workspace/routing/kb-routes.ts +206 -29
  300. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
  301. package/src/modules/workspace/services/workspace.api.ts +57 -4
  302. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  303. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  304. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  305. package/src/modules/workspace/state/workspace.context.ts +125 -19
  306. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  307. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
  308. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  309. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  310. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  311. package/src/modules/workspace/utils/file-trace.ts +50 -0
  312. package/src/modules/workspace/utils/fileTree.ts +112 -36
  313. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  314. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  315. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  316. package/src/modules/workspace/utils/uploadError.ts +29 -0
  317. package/src/shared/__tests__/marketplace-url.test.ts +6 -1
  318. package/src/shared/components/Button.tsx +16 -2
  319. package/src/shared/components/Dialog.tsx +27 -11
  320. package/src/shared/components/Menu.tsx +13 -1
  321. package/src/shared/components/PageShell.tsx +13 -8
  322. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  323. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  324. package/src/shared/components/index.ts +2 -0
  325. package/src/shared/components/useDismissableMenu.ts +32 -10
  326. package/src/shared/components/useFocusHandoff.ts +51 -0
  327. package/src/shared/components/useLatestRef.ts +28 -0
  328. package/src/shared/markdown/Markdown.tsx +12 -3
  329. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  330. package/src/shared/markdown/hrefs.ts +50 -0
  331. package/src/shared/marketplace-url.ts +33 -5
  332. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  333. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  334. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  335. package/src/shared/mcp/connect-snippets.ts +14 -9
  336. package/src/shared/mcp/index.ts +1 -1
  337. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  338. package/src/shared/theme/header.ts +75 -0
  339. package/src/shared/theme/measure.ts +7 -4
  340. package/src/shared/theme/tokens.css +25 -0
  341. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  342. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  343. package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
  344. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  345. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  346. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -0,0 +1,268 @@
1
+ import { useEffect, useId, useRef, useState, type Ref } from 'react';
2
+ import { Loader2 } from 'lucide-react';
3
+ import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
4
+ import { suggestPrincipals } from '../../access/api';
5
+ import { initials } from '../../../lib/email';
6
+
7
+ /** A person offered by the suggest endpoint — name and email, nothing more. */
8
+ export interface PersonSuggestion {
9
+ name: string;
10
+ email: string;
11
+ }
12
+
13
+ /**
14
+ * The server withholds people until the query is at least this long (its
15
+ * anti-harvesting guard). Mirrored here so a shorter query costs no request
16
+ * at all rather than one that can only come back empty.
17
+ */
18
+ const SUGGEST_MIN_CHARS = 2;
19
+
20
+ /**
21
+ * Typing settles for this long before a suggest request goes out. Exported so
22
+ * a test that has to outlast the debounce derives its wait from this value
23
+ * rather than restating it — a number here that a test does not follow is a
24
+ * silently flaky test.
25
+ */
26
+ export const SUGGEST_DEBOUNCE_MS = 200;
27
+
28
+ /** The default-branch workspace id — the admin surfaces are managed there. */
29
+ // A function, not a constant: the branch model arrives from `/api/config`
30
+ // during boot, and a module-scope capture would freeze this at the empty
31
+ // string that exists before it.
32
+ const suggestWorkspaceId = () => encodeURIComponent(DEFAULT_BRANCH);
33
+
34
+ export interface AddMemberInputProps {
35
+ /** Controlled input value — the caller owns it, and owns clearing it. */
36
+ value: string;
37
+ onValueChange: (value: string) => void;
38
+ /**
39
+ * Add the given email. Called with the typed value (Enter / the Add button)
40
+ * or with a chosen suggestion's email — the two paths are indistinguishable
41
+ * from here, which is the point. Validation and the request are the
42
+ * caller's: this component knows nothing about roles or groups.
43
+ */
44
+ onSubmit: (value: string) => void;
45
+ /** Emails already on the target — never offered as suggestions. */
46
+ exclude: readonly string[];
47
+ /** Accessible name of the input (each card names its own target). */
48
+ inputLabel: string;
49
+ /** A mutation is in flight: input and button go inert, the button spins. */
50
+ busy?: boolean;
51
+ placeholder?: string;
52
+ /** Layout classes for the row (spacing above it differs per page). */
53
+ className?: string;
54
+ /** The email field itself — for a page that lands focus on one card's input. */
55
+ inputRef?: Ref<HTMLInputElement>;
56
+ }
57
+
58
+ /**
59
+ * The add-member input shared by App roles and the Groups & Members page: an
60
+ * email field that suggests people from the deployment as you type, plus its
61
+ * Add button.
62
+ *
63
+ * SUGGESTIONS ASSIST, THEY NEVER RESTRICT. The list is a shortcut for a value
64
+ * the caller could always have typed in full — a person who has never signed
65
+ * in is still addable, and a suggest request that fails or answers a shape
66
+ * this doesn't recognise simply leaves an ordinary email input behind. That
67
+ * is why every read of the response is defensive and every failure path ends
68
+ * in "no suggestions", never an error the form has to show.
69
+ */
70
+ export function AddMemberInput({
71
+ value,
72
+ onValueChange,
73
+ onSubmit,
74
+ exclude,
75
+ inputLabel,
76
+ busy = false,
77
+ placeholder = 'Add member by email',
78
+ className = '',
79
+ inputRef,
80
+ }: AddMemberInputProps) {
81
+ const [suggestions, setSuggestions] = useState<PersonSuggestion[]>([]);
82
+ const [showSuggest, setShowSuggest] = useState(false);
83
+ // Bumped per request so a slow response never repopulates the list after a
84
+ // newer query (or a backspace below the threshold) has superseded it.
85
+ const suggestReq = useRef(0);
86
+ // The input and its list together. Focus moving between them is movement
87
+ // WITHIN the widget, not away from it — see the wrapper's onBlur.
88
+ const widget = useRef<HTMLDivElement>(null);
89
+ // The list's id, so the input can name it: a combobox whose popup a screen
90
+ // reader can find, and announce as it opens, rather than a text field that
91
+ // silently grows a list of buttons beneath it.
92
+ const listId = useId();
93
+
94
+ // A newline-joined key rather than the array itself: callers build `exclude`
95
+ // inline (`[...members, ...pending]`), so a reference dependency would
96
+ // re-run this effect on every render. The key changes only when the set does.
97
+ const excludeKey = [...new Set(exclude.map((e) => e.trim().toLowerCase()))]
98
+ .sort()
99
+ .join('\n');
100
+
101
+ useEffect(() => {
102
+ const q = value.trim();
103
+ if (q.length < SUGGEST_MIN_CHARS) {
104
+ // Invalidate any in-flight request so a late long-query response can't
105
+ // repopulate the dropdown after the user backspaced below the threshold.
106
+ suggestReq.current++;
107
+ setSuggestions([]);
108
+ return;
109
+ }
110
+ const myReq = ++suggestReq.current;
111
+ // The previous query's people are wrong for this one the moment the text
112
+ // changes. Leaving them up through the debounce and the request would keep
113
+ // a row clickable that adds someone the current text never named.
114
+ setSuggestions([]);
115
+ const t = setTimeout(() => {
116
+ suggestPrincipals(suggestWorkspaceId(), q)
117
+ .then((res) => {
118
+ if (myReq !== suggestReq.current) return;
119
+ // People only; drop anyone the caller already counts as a member.
120
+ const existing = new Set(excludeKey ? excludeKey.split('\n') : []);
121
+ setSuggestions(
122
+ (res.people ?? []).filter((p) => !existing.has(p.email.toLowerCase())),
123
+ );
124
+ })
125
+ .catch(() => {
126
+ // The suggestion feature degrades; the input keeps working.
127
+ if (myReq === suggestReq.current) setSuggestions([]);
128
+ });
129
+ }, SUGGEST_DEBOUNCE_MS);
130
+ return () => clearTimeout(t);
131
+ }, [value, excludeKey]);
132
+
133
+ const open = !busy && showSuggest && suggestions.length > 0;
134
+ // The combobox keyboard model: focus STAYS in the input and the arrow keys
135
+ // move an active option, which the input names by id — so a screen reader
136
+ // hears each suggestion as it is reached and Enter takes the active one.
137
+ // Keyed by the PERSON, not by position: the list refreshes under the
138
+ // caller's hands (a new query, an `exclude` that grew), and a numeric index
139
+ // kept across that would light a different person's row — or Enter would
140
+ // add them. A person no longer listed is simply no longer active.
141
+ const [activeEmail, setActiveEmail] = useState<string | null>(null);
142
+ const activeIdx = open && activeEmail !== null ? suggestions.findIndex((p) => p.email === activeEmail) : -1;
143
+ const setActive = (index: number) => setActiveEmail(suggestions[index]?.email ?? null);
144
+ const optionId = (index: number) => `${listId}-option-${index}`;
145
+
146
+ // Focus never leaves the field, so the browser reveals nothing on its own:
147
+ // the active row is scrolled into the list's view as it changes, or a
148
+ // longer list than the popup holds would highlight a row nobody can see.
149
+ useEffect(() => {
150
+ if (activeIdx < 0) return;
151
+ document.getElementById(optionId(activeIdx))?.scrollIntoView?.({ block: 'nearest' });
152
+ // `optionId` is derived from `listId`, which is stable for the mount.
153
+ // eslint-disable-next-line react-hooks/exhaustive-deps
154
+ }, [activeIdx, listId]);
155
+
156
+ return (
157
+ <div className={`flex items-center gap-1.5 ${className}`}>
158
+ {/* The input is capped rather than fixed-width, and its wrapper may shrink,
159
+ so the row fits the card on a narrow viewport instead of pushing the
160
+ Add button past the card border. */}
161
+ <div
162
+ ref={widget}
163
+ className="relative flex-1 min-w-0 max-w-[16rem]"
164
+ // React's onBlur bubbles (it is focusout underneath), so this one
165
+ // handler covers the input and the list. The list closes when focus
166
+ // lands outside the widget — Tab out of the field, a click elsewhere.
167
+ onBlur={(e) => {
168
+ if (!widget.current?.contains(e.relatedTarget as Node | null)) {
169
+ setShowSuggest(false);
170
+ }
171
+ }}
172
+ >
173
+ <input
174
+ ref={inputRef}
175
+ type="email"
176
+ value={value}
177
+ onChange={(e) => {
178
+ onValueChange(e.target.value);
179
+ setShowSuggest(true);
180
+ setActiveEmail(null);
181
+ }}
182
+ onFocus={() => setShowSuggest(true)}
183
+ onKeyDown={(e) => {
184
+ const n = suggestions.length;
185
+ if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && n > 0 && !busy) {
186
+ e.preventDefault();
187
+ setShowSuggest(true);
188
+ // With no row active, Down starts at the top and Up at the bottom.
189
+ setActive(
190
+ e.key === 'ArrowDown' ? (activeIdx + 1) % n : activeIdx < 0 ? n - 1 : (activeIdx - 1 + n) % n,
191
+ );
192
+ return;
193
+ }
194
+ // Home/End move the caret until a row is active; then they move the row.
195
+ if ((e.key === 'Home' || e.key === 'End') && activeIdx >= 0) {
196
+ e.preventDefault();
197
+ setActive(e.key === 'Home' ? 0 : n - 1);
198
+ return;
199
+ }
200
+ if (e.key === 'Enter') {
201
+ e.preventDefault();
202
+ onSubmit(activeIdx >= 0 ? suggestions[activeIdx]!.email : value);
203
+ return;
204
+ }
205
+ if (e.key === 'Escape') {
206
+ setShowSuggest(false);
207
+ setActiveEmail(null);
208
+ }
209
+ }}
210
+ placeholder={placeholder}
211
+ disabled={busy}
212
+ className="text-xs px-2 py-1 border border-line rounded-sm focus:outline-none focus:border-accent w-full min-w-0"
213
+ aria-label={inputLabel}
214
+ autoComplete="off"
215
+ // The combobox pattern: the field names its popup and says when it
216
+ // is open, so assistive technology announces the suggestions the
217
+ // moment they appear and can move between them.
218
+ role="combobox"
219
+ aria-autocomplete="list"
220
+ aria-expanded={open}
221
+ aria-controls={open ? listId : undefined}
222
+ aria-activedescendant={activeIdx >= 0 ? optionId(activeIdx) : undefined}
223
+ />
224
+ {open && (
225
+ <ul
226
+ id={listId}
227
+ role="listbox"
228
+ aria-label="Suggestions"
229
+ className="absolute z-10 mt-1 w-full sm:w-72 max-w-full max-h-56 overflow-auto bg-white border border-line rounded-lg shadow-lg py-1"
230
+ >
231
+ {suggestions.map((p, i) => (
232
+ // The option IS the list item — a direct child of the listbox,
233
+ // which is what `aria-activedescendant` may point at. Not a
234
+ // tab stop: focus stays in the field and the arrows walk the
235
+ // rows; a pointer still clicks one. preventDefault on mousedown
236
+ // keeps focus in the input, so a click never blurs the widget
237
+ // out from under itself; the submit hangs off click.
238
+ <li
239
+ key={p.email}
240
+ id={optionId(i)}
241
+ role="option"
242
+ aria-selected={i === activeIdx}
243
+ onMouseDown={(e) => e.preventDefault()}
244
+ onClick={() => onSubmit(p.email)}
245
+ className={`cursor-pointer px-2 py-1.5 hover:bg-hover flex items-center gap-2 ${i === activeIdx ? 'bg-hover' : ''}`}
246
+ >
247
+ <span className="w-5 h-5 rounded-full bg-ink-muted text-white text-[9px] font-semibold flex items-center justify-center shrink-0">
248
+ {initials(p.email)}
249
+ </span>
250
+ <span className="flex-1 truncate text-xs text-ink">{p.name || p.email}</span>
251
+ <span className="text-[10px] text-ink-faint truncate">{p.email}</span>
252
+ </li>
253
+ ))}
254
+ </ul>
255
+ )}
256
+ </div>
257
+ <button
258
+ type="button"
259
+ onClick={() => onSubmit(value)}
260
+ disabled={busy}
261
+ className="shrink-0 px-3 py-1 text-xs rounded-sm border border-line hover:bg-hover disabled:opacity-50 flex items-center gap-1"
262
+ >
263
+ {busy && <Loader2 size={12} className="animate-spin" />}
264
+ Add
265
+ </button>
266
+ </div>
267
+ );
268
+ }
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useEffect, useId, useRef, useState } from 'react';
2
- import { Loader2, UsersRound, X } from 'lucide-react';
2
+ import { Loader2, Lock, UsersRound, X } from 'lucide-react';
3
3
  import { PageShell } from '../../../shared/components/PageShell';
4
- import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
4
+ import { useLatestRef } from '../../../shared/components/useLatestRef';
5
5
  import { useAdmin } from '../state/admin.context';
6
6
  import {
7
7
  addMember,
@@ -13,37 +13,31 @@ import {
13
13
  unassignGroup,
14
14
  type RoleRosterEntry,
15
15
  } from '../services/roles.api';
16
- import { suggestPrincipals } from '../../access/api';
17
- import { EMAIL_RE, isGroupPrefixed } from '../../../lib/email';
16
+ import { AddMemberInput } from './AddMemberInput';
17
+ import { EMAIL_RE, initials, isGroupPrefixed } from '../../../lib/email';
18
18
  import { useExclusiveRunner, type ExclusiveRunner } from '../hooks/useExclusiveRunner';
19
19
 
20
- /** The default-branch workspace id — roles are managed there (admin status derives from it). */
21
- // A function, not a constant: the branch model arrives from `/api/config`
22
- // during boot, and a module-scope capture would freeze this at the empty
23
- // string that exists before it.
24
- const rolesWorkspaceId = () => encodeURIComponent(DEFAULT_BRANCH);
25
-
26
20
  function errMessage(err: unknown, fallback: string): string {
27
21
  if (err instanceof Error) return err.message;
28
22
  return fallback;
29
23
  }
30
24
 
31
- function initials(value: string): string {
32
- const cleaned = value.trim();
33
- if (!cleaned) return '?';
34
- const [name] = cleaned.split('@');
35
- const parts = name.split(/[.\s_-]+/).filter(Boolean);
36
- if (parts.length >= 2) return (parts[0][0] + parts[1][0]).toUpperCase();
37
- return name.slice(0, 2).toUpperCase();
38
- }
39
-
40
25
  interface SelfRemoveTarget {
41
26
  canonical: string;
42
27
  email: string;
43
28
  }
44
29
 
45
30
  /**
46
- * Roles & Members, routed standalone at `/roles-and-members` (below the
31
+ * The note beside a fixed Admin member, and the refusal shown when someone
32
+ * tries to add that address as a regular member. Word-for-word the sentence
33
+ * the backend's 422 leads with (`roles-admin.service.ts`), so the two
34
+ * surfaces say the same thing.
35
+ */
36
+ const FIXED_ADMIN_NOTE =
37
+ 'Deployment admin, set in the server configuration; cannot be removed here';
38
+
39
+ /**
40
+ * App roles (formerly Roles & Members), routed standalone at `/roles-and-members` (below the
47
41
  * persistent toolbar). Admin-gated: non-admins get a clear "Admins only"
48
42
  * state instead of the roster (the backend enforces the same gate on every
49
43
  * roles endpoint — this is presentation, not the security boundary).
@@ -63,7 +57,7 @@ export function AdminRolesPage() {
63
57
 
64
58
  // Bump on every load so a stale in-flight response never overwrites the
65
59
  // current roster. (The initial fetch does NOT go through the exclusive
66
- // runner, so — unlike the Groups page — a mutation response can still race
60
+ // runner, so — unlike the Groups & Members page — a mutation response can still race
67
61
  // it; the bump in applyRoster is what drops the superseded load.)
68
62
  const requestId = useRef(0);
69
63
 
@@ -115,7 +109,7 @@ export function AdminRolesPage() {
115
109
 
116
110
  if (!isAdmin) {
117
111
  return (
118
- <PageShell title="Roles & Members">
112
+ <PageShell title="App roles">
119
113
  <div className="text-sm text-ink-muted">
120
114
  Admins only. Ask an admin if you need a membership changed.
121
115
  </div>
@@ -124,7 +118,7 @@ export function AdminRolesPage() {
124
118
  }
125
119
 
126
120
  return (
127
- <PageShell title="Roles & Members">
121
+ <PageShell title="App roles">
128
122
  <p className="mb-3 text-xs text-ink-muted leading-snug">
129
123
  Roles are defined by the app — what each one unlocks is fixed. Manage
130
124
  who holds them: add people by email, or assign a group.
@@ -169,11 +163,10 @@ function RoleCard({
169
163
  const [busy, setBusy] = useState(false);
170
164
 
171
165
  // Add-member input + people autocomplete (same suggest source as Manage
172
- // Access, scoped to people/emails — a role's members are emails).
166
+ // Access, scoped to people/emails — a role's members are emails). The
167
+ // suggestion mechanics live in AddMemberInput, shared with the Groups & Members page;
168
+ // the submit rules below stay here.
173
169
  const [memberEmail, setMemberEmail] = useState('');
174
- const [suggestions, setSuggestions] = useState<{ name: string; email: string }[]>([]);
175
- const [showSuggest, setShowSuggest] = useState(false);
176
- const suggestReq = useRef(0);
177
170
 
178
171
  // Optimistic member removal: lowercased emails hidden from the chip list
179
172
  // before the server confirms. Reconciled when the authoritative roster lands.
@@ -183,35 +176,6 @@ function RoleCard({
183
176
  // roster, or rolled back on error.
184
177
  const [pendingAdds, setPendingAdds] = useState<string[]>([]);
185
178
 
186
- useEffect(() => {
187
- const q = memberEmail.trim();
188
- // Server withholds people until q ≥ 2 chars (harvesting guard); mirror that.
189
- if (q.length < 2) {
190
- // Invalidate any in-flight request so a late 2+ char response can't
191
- // repopulate the dropdown after the user backspaced below the threshold.
192
- suggestReq.current++;
193
- setSuggestions([]);
194
- return;
195
- }
196
- const myReq = ++suggestReq.current;
197
- const t = setTimeout(() => {
198
- suggestPrincipals(rolesWorkspaceId(), q)
199
- .then((res) => {
200
- if (myReq !== suggestReq.current) return;
201
- // People only; drop anyone already a member (server or optimistic).
202
- const existing = new Set([
203
- ...role.members.map((m) => m.toLowerCase()),
204
- ...pendingAdds.map((e) => e.toLowerCase()),
205
- ]);
206
- setSuggestions((res.people ?? []).filter((p) => !existing.has(p.email.toLowerCase())));
207
- })
208
- .catch(() => {
209
- if (myReq === suggestReq.current) setSuggestions([]);
210
- });
211
- }, 200);
212
- return () => clearTimeout(t);
213
- }, [memberEmail, role.members, pendingAdds]);
214
-
215
179
  // Dialogs.
216
180
  const [selfRemove, setSelfRemove] = useState<SelfRemoveTarget | null>(null);
217
181
  const [convertOpen, setConvertOpen] = useState(false);
@@ -219,12 +183,28 @@ function RoleCard({
219
183
  // Assign-group input (roles with a group-assignable capability only).
220
184
  const [groupName, setGroupName] = useState('');
221
185
 
186
+ // Ties the "why there is no X" note to the fixed chips it explains.
187
+ const fixedNoteId = useId();
188
+
189
+ // Members the SERVER CONFIGURATION fixes (deployment admins on Admin). They
190
+ // get their own chips — badged, no remove control — and are dropped from the
191
+ // editable list below so an address named in both `roles.yaml` and
192
+ // `ADMIN_EMAIL` renders once.
193
+ const fixedMembers = role.fixedMembers ?? [];
194
+ const fixedLower = new Set(fixedMembers.map((m) => m.toLowerCase()));
195
+
222
196
  // Members shown in the UI = server members minus any optimistically-removed,
223
197
  // plus any optimistically-added not yet reflected in the server roster.
224
- const serverMembers = role.members.filter((m) => !pendingRemovals.has(m.toLowerCase()));
198
+ const serverMembers = role.members.filter(
199
+ (m) => !pendingRemovals.has(m.toLowerCase()) && !fixedLower.has(m.toLowerCase()),
200
+ );
225
201
  const serverLower = new Set(role.members.map((m) => m.toLowerCase()));
226
202
  const extraAdds = pendingAdds.filter((e) => !serverLower.has(e.toLowerCase()));
227
203
  const visibleMembers = [...serverMembers, ...extraAdds];
204
+ // The Admin ≥1-direct-email invariant counts what is in the FILE, so the
205
+ // fixed members hidden from `visibleMembers` still count towards it — but a
206
+ // fixed member the file does NOT name contributes nothing.
207
+ const hiddenFixedCount = role.members.filter((m) => fixedLower.has(m.toLowerCase())).length;
228
208
 
229
209
  // Self-heal the optimistic set against the authoritative roster: once the
230
210
  // server confirms (member gone) OR a removal was a no-op (member never there),
@@ -265,8 +245,10 @@ function RoleCard({
265
245
  [onApply, runExclusive],
266
246
  );
267
247
 
268
- const submitAddMember = async (override?: string) => {
269
- const email = (override ?? memberEmail).trim();
248
+ // `value` is whatever the input handed over: the typed text, or the email of
249
+ // a chosen suggestion. The two are deliberately indistinguishable here.
250
+ const submitAddMember = async (value: string) => {
251
+ const email = value.trim();
270
252
  // Mirror the backend's refusal of `group:`-prefixed member values with an
271
253
  // inline hint (a `group:lee@x.io` would pass the email regex server-side
272
254
  // check order matters — see roles-edit.addMember).
@@ -281,14 +263,22 @@ function RoleCard({
281
263
  return;
282
264
  }
283
265
  const lower = email.toLowerCase();
266
+ // Already a fixed member: the backend refuses this with the same sentence
267
+ // (422 `fixed-deployment-admin`). Mirrored here so the refusal is instant
268
+ // and no optimistic chip flashes for a write that can never land.
269
+ if (fixedLower.has(lower)) {
270
+ setError(`${FIXED_ADMIN_NOTE}. ${email} is already an Admin.`);
271
+ setMemberEmail('');
272
+ return;
273
+ }
284
274
  // Already a member (or already pending) — clear the input and do nothing.
285
275
  if (
286
276
  role.members.some((m) => m.toLowerCase() === lower) ||
287
277
  pendingAdds.some((e) => e.toLowerCase() === lower)
288
278
  ) {
279
+ // Clearing the input is what empties the suggestion list — it falls back
280
+ // below the two-character threshold.
289
281
  setMemberEmail('');
290
- setShowSuggest(false);
291
- setSuggestions([]);
292
282
  return;
293
283
  }
294
284
  // Optimistic: show the chip and clear the input immediately. The add commit
@@ -298,8 +288,6 @@ function RoleCard({
298
288
  setError(null);
299
289
  setPendingAdds((prev) => [...prev, email]);
300
290
  setMemberEmail('');
301
- setShowSuggest(false);
302
- setSuggestions([]);
303
291
  try {
304
292
  const rows = await runExclusive(() => addMember(role.canonical, email));
305
293
  onApply(rows);
@@ -427,13 +415,32 @@ function RoleCard({
427
415
  <p className="mt-1 text-xs text-ink-muted">{role.capability.description}</p>
428
416
  )}
429
417
 
430
- {/* Member chips — optimistically hides members pending removal. */}
418
+ {/* Member chips — fixed members first (no remove control), then the
419
+ editable ones, optimistically hiding any pending removal. */}
431
420
  <div className="mt-3 flex flex-wrap gap-2">
432
- {visibleMembers.length === 0 ? (
421
+ {fixedMembers.map((email) => (
422
+ <span
423
+ key={`fixed:${email}`}
424
+ // No remove control, deliberately: the server configuration owns
425
+ // this membership. The note below the row says so, and
426
+ // `aria-describedby` ties it to every fixed chip.
427
+ aria-describedby={fixedNoteId}
428
+ className="inline-flex max-w-full items-center gap-1.5 pl-1 pr-2 py-1 bg-sunken border border-line rounded-full text-xs text-ink"
429
+ title={FIXED_ADMIN_NOTE}
430
+ >
431
+ <span className="w-5 h-5 shrink-0 rounded-full bg-ink-muted text-white text-[9px] font-semibold flex items-center justify-center">
432
+ {initials(email)}
433
+ </span>
434
+ <span className="min-w-0 truncate max-w-[14rem]">{email}</span>
435
+ <Lock size={11} className="shrink-0 text-ink-faint" aria-hidden="true" />
436
+ </span>
437
+ ))}
438
+ {visibleMembers.length === 0 && fixedMembers.length === 0 ? (
433
439
  <span className="text-xs text-ink-faint">No members.</span>
434
440
  ) : (
435
441
  visibleMembers.map((email) => {
436
- const isLastAdminMember = role.isAdmin && visibleMembers.length === 1;
442
+ const isLastAdminMember =
443
+ role.isAdmin && visibleMembers.length + hiddenFixedCount === 1;
437
444
  return (
438
445
  <span
439
446
  key={email}
@@ -463,66 +470,26 @@ function RoleCard({
463
470
  )}
464
471
  </div>
465
472
 
466
- {/* Add member — with people autocomplete (Manage Access suggest source). */}
467
- {/* The input is capped rather than fixed-width, and its wrapper may shrink,
468
- so the row fits the card on a narrow viewport instead of pushing the
469
- Add button past the card border. */}
470
- <div className="mt-3 flex items-center gap-1.5">
471
- <div className="relative flex-1 min-w-0 max-w-[16rem]">
472
- <input
473
- type="email"
474
- value={memberEmail}
475
- onChange={(e) => {
476
- setMemberEmail(e.target.value);
477
- setShowSuggest(true);
478
- }}
479
- onFocus={() => setShowSuggest(true)}
480
- // Delay so a click on a suggestion lands before the list unmounts.
481
- onBlur={() => setTimeout(() => setShowSuggest(false), 150)}
482
- onKeyDown={(e) => {
483
- if (e.key === 'Enter') submitAddMember();
484
- if (e.key === 'Escape') setShowSuggest(false);
485
- }}
486
- placeholder="Add member by email"
487
- disabled={busy}
488
- className="text-xs px-2 py-1 border border-line rounded-sm focus:outline-none focus:border-accent w-full min-w-0"
489
- aria-label="Member email"
490
- autoComplete="off"
491
- />
492
- {showSuggest && suggestions.length > 0 && (
493
- <ul className="absolute z-10 mt-1 w-full sm:w-72 max-w-full max-h-56 overflow-auto bg-white border border-line rounded-lg shadow-lg py-1">
494
- {suggestions.map((p) => (
495
- <li key={p.email}>
496
- <button
497
- type="button"
498
- // onMouseDown (not onClick) so it fires before the input's blur.
499
- onMouseDown={(e) => {
500
- e.preventDefault();
501
- submitAddMember(p.email);
502
- }}
503
- className="w-full text-left px-2 py-1.5 hover:bg-hover flex items-center gap-2"
504
- >
505
- <span className="w-5 h-5 rounded-full bg-ink-muted text-white text-[9px] font-semibold flex items-center justify-center shrink-0">
506
- {initials(p.email)}
507
- </span>
508
- <span className="flex-1 truncate text-xs text-ink">{p.name || p.email}</span>
509
- <span className="text-[10px] text-ink-faint truncate">{p.email}</span>
510
- </button>
511
- </li>
512
- ))}
513
- </ul>
514
- )}
515
- </div>
516
- <button
517
- type="button"
518
- onClick={() => submitAddMember()}
519
- disabled={busy}
520
- className="shrink-0 px-3 py-1 text-xs rounded-sm border border-line hover:bg-hover disabled:opacity-50 flex items-center gap-1"
521
- >
522
- {busy && <Loader2 size={12} className="animate-spin" />}
523
- Add
524
- </button>
525
- </div>
473
+ {/* Why those chips have no X. Rendered once for the row, not per chip. */}
474
+ {fixedMembers.length > 0 && (
475
+ <p id={fixedNoteId} className="mt-1.5 text-xs text-ink-muted">
476
+ {FIXED_ADMIN_NOTE}.
477
+ </p>
478
+ )}
479
+
480
+ {/* Add member — with people autocomplete (Manage Access suggest source).
481
+ Members already on the role, optimistic ones included, are excluded
482
+ from the suggestions: offering them would be offering a no-op — and
483
+ a fixed member would be offering a refusal. */}
484
+ <AddMemberInput
485
+ value={memberEmail}
486
+ onValueChange={setMemberEmail}
487
+ onSubmit={submitAddMember}
488
+ exclude={[...role.members, ...fixedMembers, ...pendingAdds]}
489
+ inputLabel="Member email"
490
+ busy={busy}
491
+ className="mt-3"
492
+ />
526
493
 
527
494
  {/* Group assignments — everyone in an assigned group holds the role.
528
495
  The section shows whenever there is something to see: assignments the
@@ -603,7 +570,7 @@ function RoleCard({
603
570
  >
604
571
  <p className="text-sm text-ink">
605
572
  Grants keep working — the name stays; it just becomes a group. Manage its
606
- members on the Groups page afterwards.
573
+ members on the Groups & Members page afterwards.
607
574
  </p>
608
575
  </ConfirmDialog>
609
576
  )}
@@ -648,10 +615,7 @@ function ConfirmDialog({
648
615
  const panelRef = useRef<HTMLDivElement>(null);
649
616
  // Latest onCancel without re-running the mount effect on every parent render
650
617
  // (the parent passes a fresh closure each time, e.g. when `busy` flips).
651
- const onCancelRef = useRef(onCancel);
652
- useEffect(() => {
653
- onCancelRef.current = onCancel;
654
- }, [onCancel]);
618
+ const onCancelRef = useLatestRef(onCancel);
655
619
 
656
620
  // Real modal behaviour: hand focus to the dialog on open, restore it to the
657
621
  // trigger on close, close on Escape, and trap Tab/Shift+Tab inside the panel
@@ -694,7 +658,8 @@ function ConfirmDialog({
694
658
  document.removeEventListener('keydown', onKeyDown, true);
695
659
  previouslyFocused?.focus?.();
696
660
  };
697
- }, []);
661
+ // The ref is stable for the component's life; listed for the linter.
662
+ }, [onCancelRef]);
698
663
 
699
664
  return (
700
665
  <div