@bevel-software/platform-core-frontend 0.14.0 → 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 (360) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +34 -26
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/bootstrap.test.ts +33 -1
  6. package/src/core/__tests__/events.test.ts +43 -0
  7. package/src/core/bootstrap.ts +38 -1
  8. package/src/core/events.ts +85 -3
  9. package/src/core/registry.ts +1 -1
  10. package/src/lib/__tests__/api.test.ts +38 -0
  11. package/src/lib/__tests__/email.test.ts +44 -0
  12. package/src/lib/api.ts +19 -2
  13. package/src/lib/email.ts +37 -1
  14. package/src/lib/utils.ts +2 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  16. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  20. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  21. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  22. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  23. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  24. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
  25. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  26. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  27. package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
  28. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  29. package/src/modules/access/api.ts +192 -10
  30. package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
  31. package/src/modules/access/manage-access-affordance.ts +17 -0
  32. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  33. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  34. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  35. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  36. package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
  37. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  38. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  39. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  40. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  41. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  42. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  43. package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
  44. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  45. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  46. package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
  47. package/src/modules/admin/components/group-members-path.ts +32 -0
  48. package/src/modules/admin/services/connection-keys.api.ts +47 -0
  49. package/src/modules/admin/services/roles.api.ts +12 -1
  50. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  51. package/src/modules/auth/components/AccountPage.tsx +73 -54
  52. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  53. package/src/modules/auth/services/account.api.ts +78 -4
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  58. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  59. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  60. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  61. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  62. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  63. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  64. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  65. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  66. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  67. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  68. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  69. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  70. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  71. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  72. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  73. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  74. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  75. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  76. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  77. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  78. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  79. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  80. package/src/modules/change-requests/services/propose.api.ts +97 -8
  81. package/src/modules/change-requests/utils/approval.ts +15 -0
  82. package/src/modules/change-requests/utils/author.ts +32 -0
  83. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  84. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  85. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
  86. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  87. package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
  88. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  89. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  90. package/src/modules/git/services/error-messages.ts +12 -0
  91. package/src/modules/git/services/pr-prompts.ts +5 -5
  92. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  93. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  94. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  95. package/src/modules/layout/components/AppLayout.tsx +2 -0
  96. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  97. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  98. package/src/modules/layout/components/SidebarFrame.tsx +109 -4
  99. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  100. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  101. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  102. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  103. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  104. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
  105. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
  106. package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
  107. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
  108. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  109. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  110. package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
  111. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  112. package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
  113. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
  114. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
  115. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  116. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  117. package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
  118. package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
  119. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  120. package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
  121. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
  122. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  123. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  124. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  125. package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
  126. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  127. package/src/modules/library/__tests__/library-paths.test.ts +75 -0
  128. package/src/modules/library/__tests__/link-membership.test.ts +129 -0
  129. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  130. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  131. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  132. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  133. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  134. package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
  135. package/src/modules/library/__tests__/status.test.ts +82 -2
  136. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  137. package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
  138. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  139. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  140. package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
  141. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  142. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  143. package/src/modules/library/components/LibraryCard.tsx +149 -34
  144. package/src/modules/library/components/LibraryLayout.tsx +120 -247
  145. package/src/modules/library/components/LibraryPage.tsx +172 -39
  146. package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
  147. package/src/modules/library/components/LockedPluginView.tsx +63 -35
  148. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  149. package/src/modules/library/components/NewPluginDialog.tsx +19 -5
  150. package/src/modules/library/components/PageActions.tsx +31 -9
  151. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  152. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  153. package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
  154. package/src/modules/library/components/PluginExtras.tsx +143 -18
  155. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  156. package/src/modules/library/components/PluginPage.tsx +234 -38
  157. package/src/modules/library/components/PluginRows.tsx +286 -0
  158. package/src/modules/library/components/PluginsSidebar.tsx +271 -238
  159. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  160. package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
  161. package/src/modules/library/components/ShareButton.tsx +17 -0
  162. package/src/modules/library/components/SkillsTree.tsx +204 -0
  163. package/src/modules/library/components/StatusDot.tsx +1 -0
  164. package/src/modules/library/components/TeamRoute.tsx +15 -0
  165. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  166. package/src/modules/library/components/plugin-page-parts.tsx +132 -23
  167. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
  168. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  169. package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
  170. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  171. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  172. package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
  173. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  174. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  175. package/src/modules/library/hooks/useJoinRequests.ts +48 -18
  176. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  177. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  178. package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
  179. package/src/modules/library/routes/library-paths.ts +46 -35
  180. package/src/modules/library/services/library.api.ts +89 -17
  181. package/src/modules/library/services/plugins.api.ts +161 -9
  182. package/src/modules/library/services/teams.api.ts +15 -0
  183. package/src/modules/library/services/tools.api.ts +78 -0
  184. package/src/modules/library/state/library-data.tsx +268 -37
  185. package/src/modules/library/utils/personal-plugin.ts +13 -15
  186. package/src/modules/library/utils/plugin-entries.ts +134 -0
  187. package/src/modules/library/utils/plugin-summary.ts +102 -0
  188. package/src/modules/library/utils/status.ts +204 -35
  189. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
  190. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  191. package/src/modules/onboarding/agent-clients.ts +55 -23
  192. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  193. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  194. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  195. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  196. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  197. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  198. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  199. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  200. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  201. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  202. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  203. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  204. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  205. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  206. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  207. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  208. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  209. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  210. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  211. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  212. package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
  213. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  214. package/src/modules/settings/components/DeploymentPage.tsx +16 -22
  215. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  216. package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
  217. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
  218. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  219. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
  220. package/src/modules/settings/services/github-facade.api.ts +66 -0
  221. package/src/modules/settings/settings-nav-items.tsx +10 -2
  222. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  223. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  224. package/src/modules/setup/__tests__/setup.test.tsx +615 -4
  225. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  226. package/src/modules/setup/components/SetupGate.tsx +16 -16
  227. package/src/modules/setup/components/SetupScreen.tsx +711 -40
  228. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  229. package/src/modules/setup/services/setup.api.ts +218 -3
  230. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  231. package/src/modules/setup/utils/root-folders.ts +46 -0
  232. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  233. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  234. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  235. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  236. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  237. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  238. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  239. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  240. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  241. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  242. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  243. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  244. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  245. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  246. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  247. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  248. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
  249. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  250. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  251. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  252. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
  253. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  254. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  255. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  256. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  257. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  258. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  259. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  260. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  261. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  262. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  263. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  264. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  265. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  266. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  267. package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
  268. package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
  269. package/src/modules/workspace/components/FileRoute.tsx +376 -22
  270. package/src/modules/workspace/components/FileViewer.tsx +166 -45
  271. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  272. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  273. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  274. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
  275. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
  276. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
  277. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  278. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  279. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  280. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  281. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  282. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  283. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  284. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  285. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  286. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  287. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  288. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  289. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  290. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  291. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  292. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  293. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  294. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  295. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  296. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  297. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  298. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  299. package/src/modules/workspace/components/renderers/index.ts +53 -2
  300. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  301. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  302. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  303. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  304. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  305. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  306. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  307. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
  308. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  309. package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
  310. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  311. package/src/modules/workspace/routing/kb-routes.ts +207 -30
  312. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
  313. package/src/modules/workspace/services/workspace.api.ts +57 -4
  314. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  315. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  316. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  317. package/src/modules/workspace/state/workspace.context.ts +130 -16
  318. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  319. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
  320. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  321. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  322. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  323. package/src/modules/workspace/utils/file-trace.ts +50 -0
  324. package/src/modules/workspace/utils/fileTree.ts +126 -52
  325. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  326. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  327. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  328. package/src/modules/workspace/utils/uploadError.ts +29 -0
  329. package/src/shared/__tests__/marketplace-url.test.ts +59 -0
  330. package/src/shared/components/Badge.tsx +3 -1
  331. package/src/shared/components/Banner.tsx +5 -1
  332. package/src/shared/components/Button.tsx +16 -2
  333. package/src/shared/components/Dialog.tsx +27 -11
  334. package/src/shared/components/Menu.tsx +13 -1
  335. package/src/shared/components/PageShell.tsx +13 -8
  336. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  337. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  338. package/src/shared/components/index.ts +2 -0
  339. package/src/shared/components/useDismissableMenu.ts +32 -10
  340. package/src/shared/components/useFocusHandoff.ts +51 -0
  341. package/src/shared/components/useLatestRef.ts +28 -0
  342. package/src/shared/markdown/Markdown.tsx +12 -3
  343. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  344. package/src/shared/markdown/hrefs.ts +50 -0
  345. package/src/shared/marketplace-url.ts +118 -0
  346. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  347. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  348. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  349. package/src/shared/mcp/connect-snippets.ts +14 -9
  350. package/src/shared/mcp/index.ts +1 -1
  351. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  352. package/src/shared/theme/header.ts +75 -0
  353. package/src/shared/theme/measure.ts +7 -4
  354. package/src/shared/theme/tokens.css +34 -0
  355. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  356. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  357. package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
  358. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  359. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  360. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -1,11 +1,14 @@
1
- import { useCallback, useEffect, useState } from 'react';
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Link } from 'react-router-dom';
3
3
  import { Badge, Banner, Button, Surface, TextField } from '../../../shared/components';
4
4
  import { cn } from '../../../lib/utils';
5
5
  import { LIBRARY_ROOT, pathForTool } from '../../library/routes/library-paths';
6
6
  import { ToolLogo } from '../../library/components/ToolLogo';
7
7
  import { startOAuth } from '../services/secrets.api';
8
- import { setUserVar, deleteUserVar } from '../services/tool-secrets.api';
8
+ import { setUserVar, setAdminVar, deleteUserVar, setOAuthClientSecret } from '../services/tool-secrets.api';
9
+ import { SavedKeyProbeResult } from '../probe/SavedKeyProbeResult';
10
+ import { useSavedKeyProbe, type SavedKeyProbe } from '../probe/useSavedKeyProbe';
11
+ import { announceToolCredentialsChanged } from '../../../core/events';
9
12
  import {
10
13
  getConnectPending,
11
14
  startToolOAuth,
@@ -15,6 +18,12 @@ import {
15
18
  type ConnectOAuth,
16
19
  type ConnectToolOAuth,
17
20
  } from '../services/connect.api';
21
+ import {
22
+ isActionable,
23
+ outstandingCount,
24
+ ownerReason,
25
+ standaloneOutstanding,
26
+ } from '../utils/connect-status';
18
27
 
19
28
  /**
20
29
  * Persisted copy of the external-agent authorization state (`?oauth=<state>`).
@@ -26,10 +35,25 @@ const MCP_OAUTH_STATE_KEY = 'mcp-oauth-state';
26
35
 
27
36
  /**
28
37
  * "Connect your tools" — the page a person lands on from the needs-authorization
29
- * link surfaced by their external agent. It consolidates every per-user
30
- * credential they still owe across all the tools they can reach: an input for
31
- * each personal API key, an "Authorize" button for each OAuth sign-in. Shared
32
- * (owner-set) values are intentionally not shown here — they are the admin's job.
38
+ * link surfaced by their external agent, and from the plugin banner that says
39
+ * how many integrations need setup. It lists everything standing between them
40
+ * and the tools they can reach: an input for each personal API key, an
41
+ * "Authorize" button for each OAuth sign-in.
42
+ *
43
+ * It also lists what they CANNOT act on, which is the whole point of the list
44
+ * agreeing with the banner that sent them. Three states, and the page owes the
45
+ * reader the reason for each of the two that are not theirs to fix:
46
+ *
47
+ * - actionable — their own key or sign-in, or a workspace value they own;
48
+ * - owner-only — a workspace value somebody else has to set, greyed, naming
49
+ * the variable so they know what to ask for;
50
+ * - skipped — a tool they took out themselves, greyed, with Include to put it
51
+ * back.
52
+ *
53
+ * All three are counted. A banner saying four and a page showing two was the
54
+ * bug; a page that showed four and counted two would be the same bug with more
55
+ * steps. What is NOT here is a tool the reader may not read — the server never
56
+ * sends one, so there is no state in which this page names it.
33
57
  *
34
58
  * Two modes:
35
59
  * - Plain (default): configure credentials, go back to the agent by hand.
@@ -40,42 +64,78 @@ const MCP_OAUTH_STATE_KEY = 'mcp-oauth-state';
40
64
  * sends the browser back to the agent.
41
65
  *
42
66
  * DESIGN: this page speaks the Library's vocabulary, because it is the other
43
- * half of the same job. Every state reads what is STORED — `Signed in`,
44
- * `Key saved` — or `Needs …` (never a third phrasing; `Connected` is
45
- * reserved for the tool page, whose probe actually earns the word), nothing
46
- * that needs a person is grey, and a tool is
67
+ * half of the same job. Every ROW state reads what is STORED — `Signed in`,
68
+ * `Key saved` — or `Needs …`, nothing that needs a person is grey, and a tool is
47
69
  * identified by its mark before its name — the same `ToolLogo` the gallery
48
70
  * cards use. It went through the design system wholesale: no raw palette, no
49
71
  * off-scale type, no ad-hoc bordered `div`s pretending to be Surfaces.
72
+ *
73
+ * `Connected` appears in exactly one place here, and only after a real call:
74
+ * the probe each key row runs on its own save (`SavedKeyProbeResult`). This
75
+ * page used to store a key and say nothing, so a mistyped one sat here looking
76
+ * identical to a working one — the badge said `Key saved`, which was true, and
77
+ * nothing anywhere said the provider had refused it.
50
78
  */
51
79
  export function ConnectToolsPage() {
52
80
  const [tools, setTools] = useState<ConnectTool[]>([]);
53
81
  const [oauth, setOauth] = useState<ConnectOAuth[]>([]);
54
82
  const [toolOAuth, setToolOAuth] = useState<ConnectToolOAuth[]>([]);
55
83
  const [loading, setLoading] = useState(true);
84
+ /** A refetch is in flight over a list that is already on screen. */
85
+ const [refreshing, setRefreshing] = useState(false);
56
86
  const [error, setError] = useState<string | null>(null);
57
87
  const [notice, setNotice] = useState<string | null>(null);
58
88
  // Agent-connect mode: the signed authorization state + who is asking.
59
89
  const [agentState, setAgentState] = useState<string | null>(null);
60
90
  const [agentName, setAgentName] = useState<string | null>(null);
61
91
  const [finishing, setFinishing] = useState(false);
62
- // Entries the user explicitly ticked while still unconfigured (reveals the
63
- // inputs). Configured entries are implicitly ticked; unticking one wipes it.
64
- const [included, setIncluded] = useState<Set<string>>(new Set());
92
+ // Entries the user took OUT. Everything the server sent is in by default —
93
+ // it used to be the other way round, and an unconfigured tool the reader had
94
+ // never seen rendered grey and uncounted, which is exactly how a page reached
95
+ // from "4 integrations need setup" came to show two.
96
+ const [skipped, setSkipped] = useState<Set<string>>(new Set());
65
97
  const [wiping, setWiping] = useState<Set<string>>(new Set());
66
98
 
67
- const refresh = useCallback(async () => {
68
- setLoading(true);
99
+ /**
100
+ * Which load is allowed to publish. Saving a key refreshes, and so does the
101
+ * mount, the Refresh button and every wipe — so two are routinely open at
102
+ * once, and the network does not promise to answer them in order. An older
103
+ * answer landing last would repaint the page with the state from BEFORE the
104
+ * save: the row just filled in back to `Needs a key`, or the client-secret
105
+ * form the owner just completed, back and empty. The same newest-wins rule
106
+ * the probe itself follows, for the same reason.
107
+ */
108
+ const loadSeq = useRef(0);
109
+
110
+ /**
111
+ * @param quiet keep the list on screen while it refetches.
112
+ *
113
+ * The loud refresh drops the page to "Loading…", which UNMOUNTS every row —
114
+ * and a row holds the verdict of the probe its own save just started. That
115
+ * state is the only copy (nothing persists a verdict), so a loud refetch
116
+ * after a save throws away the very answer the save was waiting for. Same
117
+ * fix `useToolPage` made for the tool page, for the same reason.
118
+ */
119
+ const refresh = useCallback(async (quiet = false) => {
120
+ const mine = ++loadSeq.current;
121
+ if (!quiet) setLoading(true);
122
+ setRefreshing(true);
69
123
  try {
70
124
  const pending = await getConnectPending();
125
+ if (loadSeq.current !== mine) return;
71
126
  setTools(pending.tools);
72
127
  setOauth(pending.oauth);
73
128
  setToolOAuth(pending.toolOAuth);
74
129
  setError(null);
75
130
  } catch (err) {
76
- setError(err instanceof Error ? err.message : String(err));
131
+ // Inside the guard too: an older load failing after a newer one
132
+ // succeeded would raise an alert about a request nobody is waiting on.
133
+ if (loadSeq.current === mine) setError(err instanceof Error ? err.message : String(err));
77
134
  } finally {
78
- setLoading(false);
135
+ if (loadSeq.current === mine) {
136
+ setLoading(false);
137
+ setRefreshing(false);
138
+ }
79
139
  }
80
140
  }, []);
81
141
 
@@ -126,6 +186,10 @@ export function ConnectToolsPage() {
126
186
  else if (params.has('error')) setError(params.get('error') || 'Authorization failed.');
127
187
  if (params.has('authorized') || params.has('error')) {
128
188
  window.history.replaceState(null, '', window.location.pathname + window.location.search);
189
+ // Whichever way the round-trip went, a provider has just had its say
190
+ // about a sign-in this page did not perform itself — so the Library's
191
+ // view of the tool is from before the browser left.
192
+ announceToolCredentialsChanged();
129
193
  }
130
194
  }, []);
131
195
 
@@ -161,30 +225,51 @@ export function ConnectToolsPage() {
161
225
  };
162
226
 
163
227
  /**
164
- * Include/skip toggle. `id` keys the local opt-in set; `configured` says
228
+ * Include/skip toggle. `id` keys the local opt-out set; `configured` says
165
229
  * whether any per-user value exists; `wipe` removes them all. Unticking a
166
230
  * configured entry wipes it (that's what "skip" means — the tool must not
167
231
  * register for the agent); unticking an unconfigured one just hides inputs.
232
+ * Either way the row STAYS, greyed and still counted: skipping is a decision
233
+ * about what the agent may use, not a claim the tool is set up.
234
+ *
235
+ * `wipe` calls the `removed` callback it is handed after each DELETE that
236
+ * lands. A tool with several saved keys is several round-trips, and the
237
+ * second one can fail after the first succeeded: that key is gone for real,
238
+ * so the Library's copy went stale at the FIRST success, not at the last.
239
+ * Announcing only on a clean wipe would leave the catalog showing a key
240
+ * nobody has any more.
168
241
  */
169
- const onToggle = async (id: string, configured: boolean, wipe: () => Promise<void>) => {
170
- const isOn = configured || included.has(id);
171
- if (!isOn) {
172
- setIncluded((s) => new Set(s).add(id));
242
+ const onToggle = async (
243
+ id: string,
244
+ configured: boolean,
245
+ wipe: (removed: () => void) => Promise<void>,
246
+ ) => {
247
+ if (skipped.has(id)) {
248
+ setSkipped((s) => {
249
+ const nextSet = new Set(s);
250
+ nextSet.delete(id);
251
+ return nextSet;
252
+ });
173
253
  return;
174
254
  }
175
- setIncluded((s) => {
176
- const nextSet = new Set(s);
177
- nextSet.delete(id);
178
- return nextSet;
179
- });
255
+ setSkipped((s) => new Set(s).add(id));
180
256
  if (configured) {
181
257
  setWiping((s) => new Set(s).add(id));
258
+ let removedAny = false;
182
259
  try {
183
- await wipe();
184
- await refresh();
260
+ await wipe(() => {
261
+ removedAny = true;
262
+ });
185
263
  } catch (err) {
186
264
  setError(err instanceof Error ? err.message : String(err));
187
265
  } finally {
266
+ if (removedAny) {
267
+ // Before this page's own refetch, not after it: the Library is a
268
+ // different store with a different round-trip, and there is nothing
269
+ // for it to wait on.
270
+ announceToolCredentialsChanged();
271
+ await refresh();
272
+ }
188
273
  setWiping((s) => {
189
274
  const nextSet = new Set(s);
190
275
  nextSet.delete(id);
@@ -198,23 +283,17 @@ export function ConnectToolsPage() {
198
283
  const toolId = (t: ConnectTool) => `tool:${t.slug}`;
199
284
  const signInId = (o: ConnectToolOAuth) => `signin:${o.key}`;
200
285
  const toolConfigured = (t: ConnectTool) => t.variables.some((v) => v.configured);
201
- const isIncluded = (id: string, configured: boolean) => configured || included.has(id);
202
-
203
- // Outstanding counts only what the user is actually including — a skipped
204
- // tool owes nothing.
205
- const outstanding =
206
- tools.reduce(
207
- (n, t) =>
208
- isIncluded(toolId(t), toolConfigured(t))
209
- ? n + t.variables.filter((v) => !v.configured).length
210
- : n,
211
- 0,
212
- ) +
213
- oauth.filter((o) => !o.authorized).length +
214
- // Not-yet-connected OR connected-but-under-scoped (needs reconnect) both count.
215
- toolOAuth.filter(
216
- (o) => isIncluded(signInId(o), o.authorized) && (!o.authorized || o.needsReauth),
217
- ).length;
286
+ const isOn = (id: string) => !skipped.has(id);
287
+
288
+ // One integration, one unit — and every state of it, including the two the
289
+ // reader cannot act on. See `outstandingCount`: this number exists to equal
290
+ // the plugin banner's, and the rules that make it do so are written down
291
+ // beside the rule the banner itself uses.
292
+ // …and the standalone sign-ins on top of it, only for the "anything left?"
293
+ // question the zero-state banner asks. No banner counts those, so they stay
294
+ // out of the number that has to match one.
295
+ const listing = { tools, oauth, toolOAuth };
296
+ const outstanding = outstandingCount(listing) + standaloneOutstanding(listing);
218
297
  const nothingToDo =
219
298
  !loading && tools.length === 0 && oauth.length === 0 && toolOAuth.length === 0;
220
299
 
@@ -231,7 +310,18 @@ export function ConnectToolsPage() {
231
310
  {'‹ Skills & tools'}
232
311
  </Link>
233
312
  <h1 className="text-strong font-semibold text-ink">Connect your tools</h1>
234
- <Button variant="quiet" size="sm" className="ml-auto" onClick={() => void refresh()}>
313
+ {/* Quiet, like the refetch a save triggers. A loud one drops the page
314
+ to "Loading…", which unmounts the row holding the verdict of the
315
+ probe its own save just started — and that state is the only copy
316
+ of it. Disabling is the feedback instead: the list a spinner would
317
+ replace is already on screen. */}
318
+ <Button
319
+ variant="quiet"
320
+ size="sm"
321
+ className="ml-auto"
322
+ disabled={loading || refreshing}
323
+ onClick={() => void refresh(true)}
324
+ >
235
325
  Refresh
236
326
  </Button>
237
327
  </header>
@@ -276,12 +366,16 @@ export function ConnectToolsPage() {
276
366
  </Banner>
277
367
  )}
278
368
 
369
+ {/* The third sentence is the one that earns the list its length: the
370
+ page shows more than the reader's own homework, so it has to say
371
+ so before they wonder why a row has no field. */}
279
372
  {!nothingToDo && (
280
373
  <p className="mb-5 text-ui text-ink-muted">
281
- These tools need your own sign-in or keys before they will work in your agent.
282
- Authorize each connection and enter any keys below, then head back to your agent and
283
- run the tool again. Your values are stored securely and never shown again after
284
- saving.
374
+ These tools need a sign-in or a key before they will work in your agent. Authorize
375
+ each connection and enter any keys below, then head back to your agent and run the
376
+ tool again. Anything greyed out is not yours to do — it is waiting on the tool&apos;s
377
+ owner, or you took it out yourself. Your values are stored securely and never shown
378
+ again after saving.
285
379
  </p>
286
380
  )}
287
381
 
@@ -317,7 +411,37 @@ export function ConnectToolsPage() {
317
411
  {/* OAuth-backed tool variables — authorized via the tool-scoped flow. */}
318
412
  {toolOAuth.map((o) => {
319
413
  const id = signInId(o);
320
- const on = isIncluded(id, o.authorized);
414
+ const on = isOn(id);
415
+ // The provider was never registered, so there is no consent
416
+ // screen for Authorize to open. Whose job that is decides
417
+ // whether this is a greyed reason or a field.
418
+ if (!o.ownerConfigured) {
419
+ return o.ownerOnly ? (
420
+ <ConnectRow
421
+ key={o.key}
422
+ slug={o.slug}
423
+ name={o.toolName}
424
+ label={o.label || o.toolName}
425
+ on
426
+ dim
427
+ busy={false}
428
+ state="owner-only"
429
+ reason={ownerReason(o.varName)}
430
+ />
431
+ ) : (
432
+ <SignInOwnerSecret
433
+ key={o.key}
434
+ o={o}
435
+ onSaved={() => {
436
+ announceToolCredentialsChanged();
437
+ // Quiet, for the same reason as a key save: the row
438
+ // is about to show the probe's answer.
439
+ void refresh(true);
440
+ }}
441
+ onError={setError}
442
+ />
443
+ );
444
+ }
321
445
  return (
322
446
  <ConnectRow
323
447
  key={o.key}
@@ -325,6 +449,7 @@ export function ConnectToolsPage() {
325
449
  name={o.toolName}
326
450
  label={o.label || o.toolName}
327
451
  on={on}
452
+ dim={!on}
328
453
  busy={wiping.has(id)}
329
454
  state={
330
455
  !on
@@ -336,7 +461,10 @@ export function ConnectToolsPage() {
336
461
  : 'needs-signin'
337
462
  }
338
463
  onToggle={() =>
339
- void onToggle(id, o.authorized, () => deleteUserVar(o.slug, o.varName))
464
+ void onToggle(id, o.authorized, async (removed) => {
465
+ await deleteUserVar(o.slug, o.varName);
466
+ removed();
467
+ })
340
468
  }
341
469
  action={
342
470
  on ? (
@@ -347,7 +475,9 @@ export function ConnectToolsPage() {
347
475
  >
348
476
  {o.authorized ? 'Reconnect' : 'Authorize'}
349
477
  </Button>
350
- ) : null
478
+ ) : (
479
+ <IncludeButton onClick={() => void onToggle(id, false, async () => {})} />
480
+ )
351
481
  }
352
482
  />
353
483
  );
@@ -360,6 +490,7 @@ export function ConnectToolsPage() {
360
490
  name={o.label || o.key}
361
491
  label={o.label || o.key}
362
492
  on
493
+ dim={false}
363
494
  busy={false}
364
495
  state={o.authorized ? 'signed-in' : 'needs-signin'}
365
496
  action={
@@ -381,8 +512,28 @@ export function ConnectToolsPage() {
381
512
  {tools.map((tool) => {
382
513
  const id = toolId(tool);
383
514
  const configured = toolConfigured(tool);
384
- const on = isIncluded(id, configured);
385
- const unset = tool.variables.filter((v) => !v.configured).length;
515
+ // A tool whose every remaining variable belongs to somebody
516
+ // else offers nothing to opt into, so it gets no toggle —
517
+ // and cannot be "skipped by you", because you never had it.
518
+ const actionable = tool.variables.filter(isActionable);
519
+ const on = actionable.length === 0 || isOn(id);
520
+ const unset = actionable.filter((v) => !v.configured).length;
521
+ const ownerVar = tool.variables.find((v) => v.ownerOnly);
522
+ // Grey the CARD only when nothing on it is the reader's to
523
+ // do: they took the tool out, or every variable left on it
524
+ // belongs to an owner. A tool that owes a workspace value
525
+ // AND offers the reader a field of their own keeps its
526
+ // normal weight — the owner's line is already greyed on its
527
+ // own row (see `KeyRow`), and dimming the card around it
528
+ // would fade out an input that works right now.
529
+ const dim = !on || actionable.length === 0;
530
+ const state = !on
531
+ ? ('skipped' as const)
532
+ : unset > 0
533
+ ? ('needs-key' as const)
534
+ : ownerVar
535
+ ? ('owner-only' as const)
536
+ : ('key-saved' as const);
386
537
  return (
387
538
  <Surface
388
539
  key={tool.slug}
@@ -390,37 +541,46 @@ export function ConnectToolsPage() {
390
541
  radius="xl"
391
542
  elevation="card"
392
543
  padded
393
- className={cn(!on && 'opacity-60')}
544
+ className={cn(dim && 'opacity-60')}
394
545
  >
395
546
  <ConnectRowHead
396
547
  slug={tool.slug}
397
548
  name={tool.name}
398
549
  label={tool.name}
399
550
  on={on}
551
+ dim={dim}
400
552
  busy={wiping.has(id)}
401
- state={!on ? 'skipped' : unset > 0 ? 'needs-key' : 'key-saved'}
402
- onToggle={() =>
403
- void onToggle(id, configured, async () => {
404
- for (const v of tool.variables.filter((x) => x.configured)) {
405
- await deleteUserVar(tool.slug, v.name);
406
- }
407
- })
553
+ state={state}
554
+ reason={state === 'owner-only' && ownerVar ? ownerReason(ownerVar.name) : undefined}
555
+ onToggle={
556
+ actionable.length === 0
557
+ ? undefined
558
+ : () =>
559
+ void onToggle(id, configured, async (removed) => {
560
+ for (const v of actionable.filter((x) => x.configured)) {
561
+ await deleteUserVar(tool.slug, v.name);
562
+ removed();
563
+ }
564
+ })
565
+ }
566
+ action={
567
+ on ? undefined : (
568
+ <IncludeButton onClick={() => void onToggle(id, false, async () => {})} />
569
+ )
408
570
  }
409
571
  />
410
572
  {on && (
411
- <ul className="mt-3 flex flex-col gap-2">
412
- {tool.variables.map((v) => (
413
- <KeyRow
414
- key={v.key}
415
- slug={tool.slug}
416
- name={v.name}
417
- label={v.label}
418
- configured={v.configured}
419
- onSaved={() => void refresh()}
420
- onError={setError}
421
- />
422
- ))}
423
- </ul>
573
+ <ToolKeyList
574
+ tool={tool}
575
+ onSaved={() => {
576
+ announceToolCredentialsChanged();
577
+ // Quiet: a row is about to show what the provider
578
+ // makes of the key it just saved, and a loud
579
+ // refetch would unmount it first.
580
+ void refresh(true);
581
+ }}
582
+ onError={setError}
583
+ />
424
584
  )}
425
585
  </Surface>
426
586
  );
@@ -452,15 +612,29 @@ function Section({ title, children }: { title: string; children: React.ReactNode
452
612
  * what is wrong. "skipped" is the one non-status here: it is a choice you made,
453
613
  * not a state of the tool, so it stays grey.
454
614
  *
455
- * Note what is NOT here: `Connected`. This page knows only what is STORED, and
456
- * the one word that asserts a working connection is reserved for a probe that
457
- * actually called the provider — which only the tool page does. Two states
458
- * rather than one, because "signed in" and "key saved" describe two different
459
- * things the reader did, and telling someone a key was saved when they signed
460
- * in is a small lie of exactly the kind this vocabulary exists to stop.
615
+ * Two of the seven are GREY on purpose, against the Library's rule that nothing
616
+ * needing a person is grey — because the rule is about the person READING. A
617
+ * workspace key only an owner can set, and a tool you took out yourself, both
618
+ * need somebody; neither needs you, and drawing them amber beside the rows you
619
+ * can actually fix is what makes a list of four unusable. They keep their place
620
+ * in the count regardless: grey says "not yours", never "not counted".
621
+ *
622
+ * Note what is NOT here: `Connected`. A ROW knows only what is STORED, and the
623
+ * one word that asserts a working connection belongs to a probe that actually
624
+ * called the provider — which is the line underneath the row, not the badge on
625
+ * it. Two states rather than one, because "signed in" and "key saved" describe
626
+ * two different things the reader did, and telling someone a key was saved
627
+ * when they signed in is a small lie of exactly the kind this vocabulary
628
+ * exists to stop.
461
629
  */
462
630
  const ROW_STATE: Record<
463
- 'signed-in' | 'key-saved' | 'needs-signin' | 'needs-reauth' | 'needs-key' | 'skipped',
631
+ | 'signed-in'
632
+ | 'key-saved'
633
+ | 'needs-signin'
634
+ | 'needs-reauth'
635
+ | 'needs-key'
636
+ | 'owner-only'
637
+ | 'skipped',
464
638
  { text: string; tone: 'ok' | 'wait' | 'outline' }
465
639
  > = {
466
640
  'signed-in': { text: 'Signed in', tone: 'ok' },
@@ -468,45 +642,78 @@ const ROW_STATE: Record<
468
642
  'needs-signin': { text: 'Needs your sign-in', tone: 'wait' },
469
643
  'needs-reauth': { text: 'Needs signing in again', tone: 'wait' },
470
644
  'needs-key': { text: 'Needs a key from you', tone: 'wait' },
471
- skipped: { text: 'Skipped', tone: 'outline' },
645
+ // The default for a row whose `reason` names no variable; every one this page
646
+ // renders does name it, because "an owner" without "to set what" leaves the
647
+ // reader with nothing to ask for.
648
+ 'owner-only': { text: 'Needs an owner', tone: 'outline' },
649
+ skipped: { text: 'Skipped by you', tone: 'outline' },
472
650
  };
473
651
 
474
652
  interface RowHeadProps {
475
653
  slug: string;
476
654
  name: string;
477
655
  label: string;
656
+ /** The include/skip toggle's position — what the agent may use. */
478
657
  on: boolean;
658
+ /** Greyed: nothing here is the reader's to do. Not the same question as `on`. */
659
+ dim: boolean;
479
660
  busy: boolean;
480
661
  state: keyof typeof ROW_STATE;
662
+ /** Overrides the state's stock wording — used to name the awaited variable. */
663
+ reason?: string;
481
664
  onToggle?: () => void;
482
665
  action?: React.ReactNode;
483
666
  }
484
667
 
485
668
  /** Mark, name, state, and (optionally) the control that fixes it. */
486
- function ConnectRowHead({ slug, name, label, on, busy, state, onToggle, action }: RowHeadProps) {
669
+ function ConnectRowHead({
670
+ slug,
671
+ name,
672
+ label,
673
+ on,
674
+ dim,
675
+ busy,
676
+ state,
677
+ reason,
678
+ onToggle,
679
+ action,
680
+ }: RowHeadProps) {
487
681
  const s = ROW_STATE[state];
488
682
  return (
489
683
  <div className="flex items-center gap-2.5">
490
684
  {onToggle && <IncludeToggle on={on} busy={busy} onChange={onToggle} />}
491
- <ToolLogo slug={slug} name={name} className={cn(!on && 'grayscale')} />
685
+ <ToolLogo slug={slug} name={name} className={cn(dim && 'grayscale')} />
492
686
  <Link
493
687
  to={pathForTool(slug)}
494
688
  aria-label={`Open ${name}`}
495
689
  className={cn(
496
690
  'truncate rounded-xs text-ui font-semibold hover:underline',
497
- on ? 'text-ink' : 'text-ink-faint',
691
+ dim ? 'text-ink-faint' : 'text-ink',
498
692
  )}
499
693
  >
500
694
  {label}
501
695
  </Link>
502
696
  <Badge tone={s.tone} size="xs" className="shrink-0">
503
- {s.text}
697
+ {reason ?? s.text}
504
698
  </Badge>
505
699
  {action && <span className="ml-auto shrink-0">{action}</span>}
506
700
  </div>
507
701
  );
508
702
  }
509
703
 
704
+ /**
705
+ * Put a skipped tool back. The checkbox beside the name does the same thing,
706
+ * and this is here anyway: an unticked box in a greyed row reads as a record of
707
+ * what happened, not as the way to undo it.
708
+ */
709
+ function IncludeButton({ onClick }: { onClick: () => void }) {
710
+ return (
711
+ <Button variant="outline" size="tiny" onClick={onClick}>
712
+ Include
713
+ </Button>
714
+ );
715
+ }
716
+
510
717
  function ConnectRow(props: RowHeadProps) {
511
718
  return (
512
719
  <Surface tone="surface" radius="lg" elevation="none" padded className="border border-line">
@@ -541,18 +748,119 @@ function IncludeToggle({
541
748
  );
542
749
  }
543
750
 
751
+ /**
752
+ * One tool's keys, and the ONE probe they share.
753
+ *
754
+ * Tool-level, not row-level, because that is what a probe actually is: a
755
+ * single call carrying the tool's whole credential set. Two rows probing
756
+ * independently would each keep their own `Connected`, and the first would go
757
+ * on claiming it after the second changed the very keys it was testing.
758
+ *
759
+ * Each row saves through the call its tier needs — the workspace's value for
760
+ * an `admin` var, the reader's own for a `user` one — and a workspace value
761
+ * the reader may not write renders as the reason instead of a field.
762
+ */
763
+ function ToolKeyList({
764
+ tool,
765
+ onSaved,
766
+ onError,
767
+ }: {
768
+ tool: ConnectTool;
769
+ onSaved: () => void;
770
+ onError: (m: string) => void;
771
+ }) {
772
+ const probe = useSavedKeyProbe(tool.slug);
773
+ return (
774
+ <ul className="mt-3 flex flex-col gap-2">
775
+ {tool.variables.map((v) => (
776
+ <KeyRow
777
+ key={v.key}
778
+ name={v.name}
779
+ label={v.label}
780
+ configured={v.configured}
781
+ ownerOnly={v.ownerOnly}
782
+ save={(value) =>
783
+ v.scope === 'admin' ? setAdminVar(tool.slug, v.name, value) : setUserVar(tool.slug, v.name, value)
784
+ }
785
+ probe={probe}
786
+ onSaved={onSaved}
787
+ onError={onError}
788
+ />
789
+ ))}
790
+ </ul>
791
+ );
792
+ }
793
+
794
+ /**
795
+ * The owner's half of a sign-in — the client secret — on the Connect page, so
796
+ * the person who CAN unblock everyone else does not have to go and find the
797
+ * tool page to do it. Its own probe, like every other place a credential is
798
+ * saved: a replaced client secret can invalidate the tokens minted under the
799
+ * old one, so the tool's health is worth testing straight away.
800
+ */
801
+ function SignInOwnerSecret({
802
+ o,
803
+ onSaved,
804
+ onError,
805
+ }: {
806
+ o: ConnectToolOAuth;
807
+ onSaved: () => void;
808
+ onError: (m: string) => void;
809
+ }) {
810
+ const probe = useSavedKeyProbe(o.slug);
811
+ return (
812
+ <Surface tone="surface" radius="lg" elevation="none" padded className="border border-line">
813
+ <ConnectRowHead
814
+ slug={o.slug}
815
+ name={o.toolName}
816
+ label={o.label || o.toolName}
817
+ on
818
+ dim={false}
819
+ busy={false}
820
+ state="needs-key"
821
+ />
822
+ <ul className="mt-3 flex flex-col gap-2">
823
+ <KeyRow
824
+ name={o.varName}
825
+ label={`${o.varName} (client secret)`}
826
+ configured={false}
827
+ ownerOnly={false}
828
+ save={(value) => setOAuthClientSecret(o.slug, o.varName, value)}
829
+ probe={probe}
830
+ onSaved={onSaved}
831
+ onError={onError}
832
+ />
833
+ </ul>
834
+ </Surface>
835
+ );
836
+ }
837
+
838
+ /**
839
+ * One variable of a tool: the field that sets it, or — when it is a workspace
840
+ * value the reader may not write — the name of who has to.
841
+ *
842
+ * `save` rather than a slug plus a tier, because the three things a row can
843
+ * write (your own key, the workspace's, a sign-in's client secret) are three
844
+ * different calls and the row's job is the same in all three.
845
+ */
544
846
  function KeyRow({
545
- slug,
546
847
  name,
547
848
  label,
548
849
  configured,
850
+ ownerOnly,
851
+ save: persist,
852
+ probe,
549
853
  onSaved,
550
854
  onError,
551
855
  }: {
552
- slug: string;
553
856
  name: string;
554
857
  label: string | null;
555
858
  configured: boolean;
859
+ /** A workspace value the reader cannot set: no field, just the reason. */
860
+ ownerOnly: boolean;
861
+ save: (value: string) => Promise<void>;
862
+ /** Shared with this tool's other rows; it answers for whichever saved last. */
863
+ probe: SavedKeyProbe;
556
864
  onSaved: () => void;
557
865
  onError: (m: string) => void;
558
866
  }) {
@@ -563,43 +871,72 @@ function KeyRow({
563
871
  if (!value.trim()) return;
564
872
  setBusy(true);
565
873
  try {
566
- await setUserVar(slug, name, value.trim());
874
+ await persist(value.trim());
875
+ // The value is STORED before anything is probed, and the field is
876
+ // cleared before anything is probed. Nothing below can fail the save or
877
+ // hold it open — the probe is a question asked after the fact, and it is
878
+ // allowed to hang, fail, or not exist at all.
567
879
  setValue('');
568
880
  onSaved();
569
881
  } catch (err) {
570
882
  onError(err instanceof Error ? err.message : String(err));
883
+ return;
571
884
  } finally {
572
885
  setBusy(false);
573
886
  }
887
+ // Outside the try, and deliberately not awaited: a save that landed is a
888
+ // save that landed, and a probe's trouble is never reported as the save's.
889
+ // Naming the variable moves the shared answer onto THIS row.
890
+ probe.probeSaved(name);
574
891
  };
575
892
 
893
+ if (ownerOnly) {
894
+ return (
895
+ <li className="flex items-center gap-2.5">
896
+ <div className="flex min-w-0 flex-1 items-center gap-2">
897
+ <span className="truncate text-detail text-ink-faint">{label || name}</span>
898
+ <Badge tone="outline" size="xs" className="shrink-0">
899
+ {ownerReason(name)}
900
+ </Badge>
901
+ </div>
902
+ </li>
903
+ );
904
+ }
905
+
576
906
  return (
577
- <li className="flex items-center gap-2.5">
578
- <div className="flex min-w-0 flex-1 items-center gap-2">
579
- <span className="truncate text-detail text-ink-muted">{label || name}</span>
580
- <Badge tone={configured ? 'ok' : 'wait'} size="xs" className="shrink-0">
581
- {configured ? 'Set' : 'Needs a key'}
582
- </Badge>
907
+ <li className="flex flex-col gap-1.5">
908
+ <div className="flex items-center gap-2.5">
909
+ <div className="flex min-w-0 flex-1 items-center gap-2">
910
+ <span className="truncate text-detail text-ink-muted">{label || name}</span>
911
+ <Badge tone={configured ? 'ok' : 'wait'} size="xs" className="shrink-0">
912
+ {configured ? 'Set' : 'Needs a key'}
913
+ </Badge>
914
+ </div>
915
+ {/* Write-only. The stored value is never fetched, rendered or logged —
916
+ the field starts empty even for a configured key, and saving replaces
917
+ rather than reveals. */}
918
+ <TextField
919
+ type="password"
920
+ value={value}
921
+ onChange={(e) => setValue(e.target.value)}
922
+ placeholder={configured ? 'Replace…' : 'Enter value'}
923
+ aria-label={`${label || name} value`}
924
+ className="w-44"
925
+ />
926
+ <Button
927
+ variant="primary"
928
+ size="sm"
929
+ disabled={busy || !value.trim()}
930
+ onClick={() => void save()}
931
+ >
932
+ Save
933
+ </Button>
583
934
  </div>
584
- {/* Write-only. The stored value is never fetched, rendered or logged —
585
- the field starts empty even for a configured key, and saving replaces
586
- rather than reveals. */}
587
- <TextField
588
- type="password"
589
- value={value}
590
- onChange={(e) => setValue(e.target.value)}
591
- placeholder={configured ? 'Replace…' : 'Enter value'}
592
- aria-label={`${label || name} value`}
593
- className="w-44"
594
- />
595
- <Button
596
- variant="primary"
597
- size="sm"
598
- disabled={busy || !value.trim()}
599
- onClick={() => void save()}
600
- >
601
- Save
602
- </Button>
935
+ {/* What the provider made of the key that was just typed here — the
936
+ whole reason this page no longer accepts a wrong key in silence.
937
+ Only on the row that asked: the answer is the tool's, and the newest
938
+ save is the only place it is still current. */}
939
+ {probe.subject === name && <SavedKeyProbeResult probe={probe} />}
603
940
  </li>
604
941
  );
605
942
  }