@bevel-software/platform-core-frontend 0.35.0 → 0.36.1

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 (75) hide show
  1. package/package.json +2 -2
  2. package/src/core/CoreAppShell.tsx +40 -97
  3. package/src/core/KnowledgeSurface.tsx +92 -0
  4. package/src/core/__tests__/CoreAppShell.root-claims.test.tsx +280 -0
  5. package/src/core/registry.ts +110 -2
  6. package/src/index.ts +3 -0
  7. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +1 -1
  8. package/src/modules/access/hooks/useFileAccess.ts +1 -1
  9. package/src/modules/audit/components/principal-grouping.ts +49 -49
  10. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +1 -1
  11. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +6 -6
  12. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +8 -8
  13. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
  14. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
  15. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +1 -1
  16. package/src/modules/git/__tests__/pr.api.test.ts +3 -3
  17. package/src/modules/git/components/FileHistoryPanel.tsx +1 -1
  18. package/src/modules/git/components/GitSyncFailedBanner.tsx +1 -1
  19. package/src/modules/git/services/git.api.ts +1 -1
  20. package/src/modules/git/services/pr-prompts.ts +1 -1
  21. package/src/modules/layout/state/layout.context.ts +8 -0
  22. package/src/modules/library/__tests__/SkillPage.test.tsx +5 -5
  23. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +11 -0
  24. package/src/modules/library/__tests__/ToolVarRow.test.tsx +109 -0
  25. package/src/modules/library/components/tool-page/ToolVarRow.tsx +86 -19
  26. package/src/modules/library/services/library.api.ts +2 -2
  27. package/src/modules/onboarding/__tests__/onboarding.test.tsx +8 -8
  28. package/src/modules/onboarding/state/agent-connection.ts +1 -1
  29. package/src/modules/pr/services/pr-merge.api.ts +1 -1
  30. package/src/modules/pr/services/pr-open.api.ts +1 -1
  31. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +96 -30
  32. package/src/modules/secrets-vault/components/IncludeToggle.tsx +29 -0
  33. package/src/modules/secrets-vault/components/ManagedConnectorCard.tsx +189 -0
  34. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.managed.test.tsx +212 -0
  35. package/src/modules/secrets-vault/components/__tests__/ManagedConnectorCard.test.tsx +182 -0
  36. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +3 -0
  37. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +1 -0
  38. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +1 -0
  39. package/src/modules/secrets-vault/index.ts +2 -0
  40. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +1 -0
  41. package/src/modules/secrets-vault/services/connect.api.ts +46 -5
  42. package/src/modules/secrets-vault/services/tool-secrets.api.ts +21 -3
  43. package/src/modules/secrets-vault/utils/managed-card-state.ts +61 -0
  44. package/src/modules/setup/utils/__tests__/root-folders.test.ts +5 -1
  45. package/src/modules/setup/utils/root-folders.ts +2 -2
  46. package/src/modules/toolbar/components/Toolbar.tsx +1 -1
  47. package/src/modules/{workflow → version-control}/hooks/__tests__/useFileLock.test.tsx +10 -10
  48. package/src/modules/{workflow → version-control}/hooks/__tests__/useFileLock.wire.test.tsx +1 -1
  49. package/src/modules/{workflow → version-control}/hooks/useEventBusSubscription.ts +2 -2
  50. package/src/modules/{workflow → version-control}/hooks/useFileLock.ts +1 -1
  51. package/src/modules/{workflow → version-control}/index.ts +2 -2
  52. package/src/modules/{workflow → version-control}/services/__tests__/lock.api.test.ts +1 -1
  53. package/src/modules/{workflow → version-control}/state/EventBusProvider.tsx +6 -6
  54. package/src/modules/{workflow → version-control}/state/event-bus.context.ts +4 -4
  55. package/src/modules/workspace/components/FileExplorer.tsx +96 -41
  56. package/src/modules/workspace/components/FileRoute.tsx +24 -1
  57. package/src/modules/workspace/components/FileViewer.tsx +1 -1
  58. package/src/modules/workspace/components/KbPageHeader.tsx +1 -1
  59. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +159 -13
  60. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +50 -2
  61. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +5 -5
  62. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +5 -5
  63. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +9 -9
  64. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +7 -7
  65. package/src/modules/workspace/hooks/useImageRevision.ts +1 -1
  66. package/src/modules/workspace/hooks/useWorkspaceState.ts +2 -2
  67. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +9 -9
  68. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +9 -1
  69. package/src/modules/workspace/utils/fileTree.ts +10 -2
  70. package/src/modules/workspace/utils/treeConfirm.ts +1 -1
  71. /package/src/modules/{workflow → version-control}/services/lock.api.ts +0 -0
  72. /package/src/modules/{workflow → version-control}/state/ChangeRequestStaleBinder.tsx +0 -0
  73. /package/src/modules/{workflow → version-control}/state/EventBusFocusBinder.tsx +0 -0
  74. /package/src/modules/{workflow → version-control}/state/__tests__/EventBusProvider.storage.test.tsx +0 -0
  75. /package/src/modules/{workflow → version-control}/state/__tests__/EventBusProvider.watch.test.tsx +0 -0
@@ -44,6 +44,9 @@ function variable(over: Partial<ToolVarStatus>): ToolVarStatus {
44
44
  label: null,
45
45
  key: 'github_API_KEY',
46
46
  adminConfigured: false,
47
+ // As the server sends it: a shared row's kind follows the variable's, and
48
+ // there is none without a shared row. A case about a stale row says so.
49
+ adminKind: over.adminConfigured ? (over.oauth ? 'oauth' : 'static') : null,
47
50
  userConfigured: false,
48
51
  ...over,
49
52
  };
@@ -292,6 +295,112 @@ describe('ToolVarRow: oauth', () => {
292
295
  });
293
296
  });
294
297
 
298
+ describe('ToolVarRow: a managed sign-in', () => {
299
+ /** A sign-in through a managed connector, as `/secrets/tools` reports it. */
300
+ const managed = (over: Partial<ToolVarStatus> = {}, card: Partial<NonNullable<ToolVarStatus['managed']>> = {}) =>
301
+ variable({
302
+ name: 'ACCESS_TOKEN',
303
+ scope: 'user',
304
+ label: 'Microsoft 365 sign-in',
305
+ oauth: true,
306
+ adminConfigured: false,
307
+ managed: {
308
+ connectorId: 'microsoft365',
309
+ scopeSet: 'read',
310
+ tokenScope: 'user',
311
+ displayName: 'Microsoft 365',
312
+ icon: 'Mail',
313
+ description: 'Lets Hexis read your mail.',
314
+ permissions: ['Read your mail.'],
315
+ scopeSetLabel: 'Read',
316
+ dataResidency: 'EU',
317
+ subprocessor: 'Microsoft',
318
+ account: null,
319
+ ownApp: false,
320
+ available: true,
321
+ ...card,
322
+ },
323
+ ...over,
324
+ });
325
+ const workspace = (over: Partial<ToolVarStatus> = {}, card: Partial<NonNullable<ToolVarStatus['managed']>> = {}) =>
326
+ managed({ scope: 'admin', label: 'HubSpot sign-in', ...over }, { connectorId: 'hubspot', tokenScope: 'shared', ...card });
327
+
328
+ it('never offers a writer the client secret: the broker holds the client, and an own app is brought on the Connect page', () => {
329
+ renderRow(managed(), { canWrite: true, setupKind: 'oauth-manual' });
330
+ expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
331
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
332
+ cleanup();
333
+ renderRow(managed({ authorized: true }), { canWrite: true, setupKind: 'oauth-manual' });
334
+ expect(screen.getByText('Signed in')).toBeInTheDocument();
335
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
336
+ });
337
+
338
+ it('with no broker reachable, says so instead of blaming the owner', () => {
339
+ renderRow(managed({}, { available: false }));
340
+ expect(screen.getByText('This deployment is not connected to a connector broker yet. Ask your admin.')).toBeInTheDocument();
341
+ expect(screen.queryByRole('button', { name: 'Sign in' })).toBeNull();
342
+ });
343
+
344
+ it('offers a start only where the Connect page would: no Reconnect without a broker, an own app only on a personal sign-in', () => {
345
+ // A stored token keeps working while the broker is away; the way back
346
+ // into consent does not, so the row shows the state and no button.
347
+ renderRow(managed({ authorized: true }, { available: false }));
348
+ expect(screen.getByText('Signed in')).toBeInTheDocument();
349
+ expect(screen.queryByRole('button', { name: 'Reconnect' })).toBeNull();
350
+ cleanup();
351
+ renderRow(managed({ authorized: true, needsReauth: true }, { available: false }));
352
+ expect(screen.getByText('Needs reconnect')).toBeInTheDocument();
353
+ expect(screen.queryByRole('button', { name: 'Sign in again' })).toBeNull();
354
+ cleanup();
355
+ // An owner's own app stands in for the broker on a personal sign-in …
356
+ renderRow(managed({}, { available: false, ownApp: true }));
357
+ expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
358
+ cleanup();
359
+ // … and never on a workspace connection, which the server refuses with 422.
360
+ renderRow(workspace({}, { available: true, ownApp: true }), { canWrite: true });
361
+ expect(screen.queryByRole('button', { name: 'Sign in' })).toBeNull();
362
+ expect(screen.getByText(/has your own OAuth app pinned/)).toBeInTheDocument();
363
+ });
364
+
365
+ it('an own app pinned on a workspace connection can be removed from the row, by a writer only', async () => {
366
+ const { onChanged } = renderRow(workspace({}, { available: true, ownApp: true }), { canWrite: true });
367
+ // A pinned app is something, not "Not set".
368
+ expect(screen.queryByText('Not set')).toBeNull();
369
+ fireEvent.click(screen.getByRole('button', { name: 'Remove our own app' }));
370
+ await waitFor(() => expect(secretsMock.deleteAdminVar).toHaveBeenCalledWith('github', 'ACCESS_TOKEN'));
371
+ await waitFor(() => expect(onChanged).toHaveBeenCalled());
372
+ cleanup();
373
+ renderRow(workspace({}, { available: true, ownApp: true }), { canWrite: false });
374
+ expect(screen.queryByRole('button')).toBeNull();
375
+ });
376
+
377
+ it('a workspace connection: a reader sees its state and no control, a writer makes and remakes it', () => {
378
+ // Connected by an owner: the reader is told, and offered nothing the server would refuse.
379
+ renderRow(workspace({ authorized: true }), { canWrite: false });
380
+ expect(screen.getByText('Signed in')).toBeInTheDocument();
381
+ expect(screen.getByText('One connection for the whole workspace, made by a tool owner')).toBeInTheDocument();
382
+ expect(screen.queryByRole('button')).toBeNull();
383
+ cleanup();
384
+ // Not yet connected: the same sentence, and "Not set", not "the owner hasn't finished".
385
+ renderRow(workspace(), { canWrite: false });
386
+ expect(screen.getByText('One connection for the whole workspace, made by a tool owner')).toBeInTheDocument();
387
+ expect(screen.getByText('Not set')).toBeInTheDocument();
388
+ expect(screen.queryByRole('button')).toBeNull();
389
+ cleanup();
390
+ // Under-scoped: the reader learns it needs a reconnect; the owner gets the button.
391
+ renderRow(workspace({ authorized: true, needsReauth: true }), { canWrite: false });
392
+ expect(screen.getByText('Needs reconnect')).toBeInTheDocument();
393
+ expect(screen.queryByRole('button')).toBeNull();
394
+ cleanup();
395
+ renderRow(workspace({ authorized: true, needsReauth: true }), { canWrite: true });
396
+ expect(screen.getByRole('button', { name: 'Sign in again' })).toBeInTheDocument();
397
+ cleanup();
398
+ renderRow(workspace(), { canWrite: true });
399
+ expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
400
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
401
+ });
402
+ });
403
+
295
404
  describe('ToolVarRow: failures', () => {
296
405
  it('reports a rejected write through onError and leaves the editor open', async () => {
297
406
  secretsMock.setAdminVar.mockRejectedValue(new Error('Forbidden'));
@@ -1,6 +1,6 @@
1
1
  import { useState, type ReactNode } from 'react';
2
2
  import { Badge, Button, ListRow, TextField } from '../../../../shared/components';
3
- import { startToolOAuth } from '../../../secrets-vault';
3
+ import { canStartSignIn, startToolOAuth } from '../../../secrets-vault';
4
4
  import {
5
5
  deleteAdminVar,
6
6
  setAdminVar,
@@ -29,10 +29,18 @@ import { navigateExternal } from '../../utils/navigate-external';
29
29
  * - Every OTHER sign-in offers its owner the client secret in every state of
30
30
  * the row: "Replace client secret" while one is stored, "Set client secret"
31
31
  * while none is. The secret belongs to the tool, not to the caller's own
32
- * sign-in, so whether the owner is signed in has no say in it.
32
+ * sign-in, so whether the owner is signed in has no say in it. A MANAGED
33
+ * sign-in is the second exception: its client is the broker's, so the row
34
+ * offers no secret at all — an owner's own app is brought on the Connect
35
+ * page's card, where the client id is asked for beside it.
33
36
  * - Whose problem is it? A user-scope gap is the caller's to fix and always
34
37
  * shows an action. An admin-scope gap is the OWNER's, so a non-writer sees a
35
- * chip that explains the state and no button they can't act on.
38
+ * chip that explains the state and no button they can't act on. A managed
39
+ * WORKSPACE connection (an `admin` variable with a sign-in) is an owner's
40
+ * gap in the same way: a reader sees its state and no control.
41
+ * - A start is offered only where it can be opened: a managed sign-in follows
42
+ * `canStartSignIn` (the broker, or an owner's own app on a personal
43
+ * sign-in), the same rule the Connect page's card applies.
36
44
  *
37
45
  * Secret values are write-only throughout: `type="password"`, held in local
38
46
  * state, cleared on save or cancel. Nothing here ever reads a stored value.
@@ -129,20 +137,45 @@ export function ToolVarRow({
129
137
  let description: string;
130
138
 
131
139
  if (variable.oauth) {
132
- // An OAuth client secret only exists for a MANUALLY declared provider.
133
- const mayEditClientSecret = canWrite && setupKind !== 'oauth-auto';
140
+ // An OAuth client secret only exists for a MANUALLY declared provider. A
141
+ // MANAGED sign-in has none to set here either: its client is the broker's,
142
+ // and an owner who brings the deployment's own app does so on the Connect
143
+ // page's card, where the client id is asked for beside the secret.
144
+ const mayEditClientSecret = canWrite && setupKind !== 'oauth-auto' && !variable.managed;
145
+ // A WORKSPACE connection (a managed sign-in on an `admin` variable) is one
146
+ // connection for everyone, made and remade by a writer of the tool: a
147
+ // reader sees its state and no control the server would refuse.
148
+ const workspaceConnection = variable.managed != null && variable.scope === 'admin';
149
+ const mayAct = !workspaceConnection || canWrite;
150
+ const whose = workspaceConnection ? 'One connection for the whole workspace, made by a tool owner' : 'Each person sets their own';
151
+ // Whether a sign-in can be STARTED from this row. A managed one answers
152
+ // to the same rule as the Connect page's card (`canStartSignIn`: the
153
+ // broker, or an owner's own app on a personal sign-in) and to who may
154
+ // make it; an ordinary one always offers its caller the flow.
155
+ const mayStart = variable.managed ? canStartSignIn({ managed: variable.managed }) && mayAct : true;
156
+ // The owner's half is done when a client secret is stored on a row of the
157
+ // OAuth kind (a key left from when the variable was static is not one) —
158
+ // or, for a MANAGED sign-in, when a start can be opened from here: there
159
+ // is no secret to store for the broker's app.
160
+ const ownerReady = variable.managed ? mayStart : variable.adminConfigured && variable.adminKind === 'oauth';
134
161
 
135
162
  if (variable.authorized && !variable.needsReauth) {
136
- description = 'Each person sets their own';
163
+ description = whose;
137
164
  // Connected is not final: a provider can widen what it grants after the
138
165
  // fact (HubSpot's MCP tools do, and answer REQUIRES_REAUTHORIZATION
139
166
  // until the user consents again), a grant can be revoked provider-side,
140
167
  // or the owner can rotate the client. The caller needs a way back into
141
- // consent that doesn't wait for the scope check to notice.
168
+ // consent that doesn't wait for the scope check to notice. A stored
169
+ // managed token keeps working while the broker is away; the way back
170
+ // into consent does not, so the button waits with it.
171
+ if (mayStart) {
172
+ meta.push(
173
+ <Button key="reconnect" size="sm" variant="quiet" disabled={busy} onClick={() => void signIn()}>
174
+ Reconnect
175
+ </Button>,
176
+ );
177
+ }
142
178
  meta.push(
143
- <Button key="reconnect" size="sm" variant="quiet" disabled={busy} onClick={() => void signIn()}>
144
- Reconnect
145
- </Button>,
146
179
  // "Signed in", not "Connected": at ROW level all we know is that a token
147
180
  // exists. Whether it still works is the tool-level health line's claim,
148
181
  // and it is the only place in the UI allowed to say "Connected" — one
@@ -152,14 +185,20 @@ export function ToolVarRow({
152
185
  </Badge>,
153
186
  );
154
187
  } else if (variable.authorized) {
155
- description = 'Each person sets their own';
188
+ description = whose;
156
189
  meta.push(
157
- <Button key="reauth" size="sm" disabled={busy} onClick={() => void signIn()}>
158
- Sign in again
159
- </Button>,
190
+ mayStart ? (
191
+ <Button key="reauth" size="sm" disabled={busy} onClick={() => void signIn()}>
192
+ Sign in again
193
+ </Button>
194
+ ) : (
195
+ <Badge key="chip" tone="wait">
196
+ Needs reconnect
197
+ </Badge>
198
+ ),
160
199
  );
161
- } else if (variable.adminConfigured) {
162
- description = 'Each person sets their own';
200
+ } else if (ownerReady) {
201
+ description = whose;
163
202
  meta.push(
164
203
  <Button key="signin" size="sm" disabled={busy} onClick={() => void signIn()}>
165
204
  Sign in
@@ -167,9 +206,37 @@ export function ToolVarRow({
167
206
  );
168
207
  } else {
169
208
  // The owner hasn't declared the provider (or hasn't set its secret), so
170
- // there is nothing for anyone to sign in to yet.
171
- description = "The tool owner hasn't finished the sign-in setup yet.";
172
- if (!mayEditClientSecret) {
209
+ // there is nothing for anyone to sign in to yet. For a managed sign-in
210
+ // the missing half is the broker (the admin's), an own app pinned on a
211
+ // workspace connection (the owner's to remove), or the connection is a
212
+ // writer's to make: the row says which.
213
+ const pinnedOnWorkspace = variable.managed?.ownApp === true && workspaceConnection;
214
+ description = !variable.managed
215
+ ? "The tool owner hasn't finished the sign-in setup yet."
216
+ : !mayAct
217
+ ? whose
218
+ : pinnedOnWorkspace
219
+ ? 'This workspace connection has your own OAuth app pinned, which a workspace connection cannot use.'
220
+ : 'This deployment is not connected to a connector broker yet. Ask your admin.';
221
+ // The one way out of a pinned app on a workspace connection is to
222
+ // remove it, and this row is the only place that shows the owner it is
223
+ // there: the control sits beside the words.
224
+ if (pinnedOnWorkspace && mayAct) {
225
+ meta.push(
226
+ <Button
227
+ key="unpin"
228
+ size="sm"
229
+ variant="quiet"
230
+ disabled={busy}
231
+ onClick={() => void run(() => deleteAdminVar(slug, variable.name))}
232
+ >
233
+ Remove our own app
234
+ </Button>,
235
+ );
236
+ }
237
+ // "Not set" is the chip for a row with nothing behind it; a pinned app
238
+ // is something, and the words beside it already say what.
239
+ if (!mayEditClientSecret && !pinnedOnWorkspace) {
173
240
  meta.push(
174
241
  <Badge key="chip" tone="neutral">
175
242
  Not set
@@ -15,8 +15,8 @@ import { ensurePersonalPlugin, type JoinRequest } from './plugins.api';
15
15
  * Library data access. Skills come from the browser skill routes
16
16
  * (`GET /api/skills`, `GET /api/skills/:name[?file=…]`) — the same
17
17
  * default-branch, per-user-`canRead`-filtered catalog the agent sees.
18
- * Change requests come from the workflow routes the pr module already talks
19
- * to. Integration (tool) data is NOT here — the Library reuses
18
+ * Change requests come from the version-control module's `/api/workflow`
19
+ * routes, which the pr module already talks to. Integration (tool) data is NOT here — the Library reuses
20
20
  * `secrets-vault/services/tool-secrets.api.ts` directly.
21
21
  */
22
22
 
@@ -17,8 +17,8 @@ import { SidebarFrame } from '../../layout/components/SidebarFrame';
17
17
  import { SIDEBAR_HEADER_TESTID } from '../../../shared/theme/header';
18
18
  import { AGENT_RECHECK_MS } from '../state/agent-connection';
19
19
  import type { AgentConnection } from '../services/agent-connection.api';
20
- import { EventBusContext, type EventBusContextValue } from '../../workflow/state/event-bus.context';
21
- import type { WorkflowEvent, WorkflowEventPayload } from '@bevel-software/platform-shared';
20
+ import { EventBusContext, type EventBusContextValue } from '../../version-control/state/event-bus.context';
21
+ import type { VersionControlEvent, VersionControlEventPayload } from '@bevel-software/platform-shared';
22
22
 
23
23
  /**
24
24
  * The onboarding contract, end to end on the client:
@@ -655,28 +655,28 @@ describe('WelcomePage', () => {
655
655
  * by the test.
656
656
  */
657
657
  function fakeBus() {
658
- const handlers = new Map<string, Set<(e: WorkflowEvent) => void>>();
658
+ const handlers = new Map<string, Set<(e: VersionControlEvent) => void>>();
659
659
  const value: EventBusContextValue = {
660
660
  subscribe: (kind, handler) => {
661
661
  const set = handlers.get(kind) ?? new Set();
662
- set.add(handler as (e: WorkflowEvent) => void);
662
+ set.add(handler as (e: VersionControlEvent) => void);
663
663
  handlers.set(kind, set);
664
- return () => set.delete(handler as (e: WorkflowEvent) => void);
664
+ return () => set.delete(handler as (e: VersionControlEvent) => void);
665
665
  },
666
666
  setFocus: () => {},
667
667
  watchWorkspace: () => () => {},
668
668
  };
669
- const emit = (event: WorkflowEventPayload) => {
669
+ const emit = (event: VersionControlEventPayload) => {
670
670
  act(() => {
671
671
  for (const h of handlers.get(event.kind) ?? []) {
672
- h({ id: 1, ts: new Date().toISOString(), ...event } as WorkflowEvent);
672
+ h({ id: 1, ts: new Date().toISOString(), ...event } as VersionControlEvent);
673
673
  }
674
674
  });
675
675
  };
676
676
  return { value, emit, listening: (kind: string) => (handlers.get(kind)?.size ?? 0) > 0 };
677
677
  }
678
678
 
679
- const ARRIVED: WorkflowEventPayload = {
679
+ const ARRIVED: VersionControlEventPayload = {
680
680
  kind: 'agent-connected',
681
681
  forUserId: 'u1',
682
682
  client: 'Claude',
@@ -1,6 +1,6 @@
1
1
  import { useContext, useEffect, useState, useSyncExternalStore } from 'react';
2
2
  import { AuthContext } from '../../auth';
3
- import { useEventBus } from '../../workflow';
3
+ import { useEventBus } from '../../version-control';
4
4
  import { fetchAgentConnection, type AgentConnection } from '../services/agent-connection.api';
5
5
 
6
6
  /**
@@ -18,7 +18,7 @@ export interface MergeAccepted {
18
18
  * **Asynchronous** — the gate re-validation + `gh pr merge` can take tens of
19
19
  * seconds on a large change request (long enough to hit the gateway's idle
20
20
  * timeout), so the endpoint acks with 202 and runs the merge in the
21
- * background. The outcome arrives over the workflow event bus:
21
+ * background. The outcome arrives over the version-control event bus:
22
22
  * `change-request-merged` on success, `change-request-merge-failed`
23
23
  * (with a `conflicts` flag) on failure. Callers show a pending state until
24
24
  * one of those events lands.
@@ -2,7 +2,7 @@ import { authFetch } from '../../../lib/api';
2
2
  import { handleApiResponse } from '../../git';
3
3
 
4
4
  /** Request shape of `POST /api/workflow/change-requests` (see backend
5
- * `modules/workflow/workflow.routes.ts`). */
5
+ * `modules/version-control/version-control.routes.ts`). */
6
6
  export interface OpenChangeRequestInput {
7
7
  sourceBranch: string;
8
8
  targetBranch: string;
@@ -2,12 +2,15 @@ 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
- import { pathForTool, readOAuthFragment, ToolLogo } from '../../library';
5
+ import { pathForTool, readOAuthFragment } from '../../library';
6
+ import { ToolLogo } from '../../library/components/ToolLogo';
6
7
  import { startOAuth } from '../services/secrets.api';
7
- import { setUserVar, setAdminVar, deleteUserVar, setOAuthClientSecret } from '../services/tool-secrets.api';
8
+ import { setUserVar, setAdminVar, deleteUserVar, deleteAdminVar, setOAuthClientSecret } from '../services/tool-secrets.api';
8
9
  import { SavedKeyProbeResult } from '../probe/SavedKeyProbeResult';
9
10
  import { useSavedKeyProbe, type SavedKeyProbe } from '../probe/useSavedKeyProbe';
10
11
  import { announceToolCredentialsChanged } from '../../../core/events';
12
+ import { useAppRegistry } from '../../../core/registry';
13
+ import { SlotBoundary } from '../../../shared/components/SlotBoundary';
11
14
  import { useConnectAsChoice } from '../../agents';
12
15
  import { ConnectAsChoice } from '../../agents/components/ConnectAsChoice';
13
16
  import {
@@ -19,6 +22,9 @@ import {
19
22
  type ConnectOAuth,
20
23
  type ConnectToolOAuth,
21
24
  } from '../services/connect.api';
25
+ import { ManagedConnectorCard } from './ManagedConnectorCard';
26
+ import { IncludeToggle } from './IncludeToggle';
27
+ import { canBringOwnApp, isManagedRow } from '../utils/managed-card-state';
22
28
  import {
23
29
  isActionable,
24
30
  outstandingCount,
@@ -128,6 +134,9 @@ export function ConnectToolsPage() {
128
134
  // from "4 integrations need setup" came to show two.
129
135
  const [skipped, setSkipped] = useState<Set<string>>(new Set());
130
136
  const [wiping, setWiping] = useState<Set<string>>(new Set());
137
+ // The distribution's foot of the page (which connectors it offers, and
138
+ // enabling one), when it registers one. See `AppRegistry.connectPanel`.
139
+ const ConnectPanel = useAppRegistry().connectPanel;
131
140
 
132
141
  /**
133
142
  * Which load is allowed to publish. Saving a key refreshes, and so does the
@@ -263,6 +272,31 @@ export function ConnectToolsPage() {
263
272
  }
264
273
  };
265
274
 
275
+ /**
276
+ * Disconnect a managed connector: the server revokes the token with the
277
+ * provider where it can, then deletes it here. A WORKSPACE connection is
278
+ * the shared row, which only a writer may remove (the server enforces it;
279
+ * the card offers the button to the same people).
280
+ */
281
+ const onDisconnectManaged = async (o: ConnectToolOAuth) => {
282
+ const id = signInId(o);
283
+ setWiping((s) => new Set(s).add(id));
284
+ try {
285
+ if (o.managed?.tokenScope === 'shared') await deleteAdminVar(o.slug, o.varName);
286
+ else await deleteUserVar(o.slug, o.varName);
287
+ announceToolCredentialsChanged();
288
+ await refresh(true);
289
+ } catch (err) {
290
+ setError(err instanceof Error ? err.message : String(err));
291
+ } finally {
292
+ setWiping((s) => {
293
+ const nextSet = new Set(s);
294
+ nextSet.delete(id);
295
+ return nextSet;
296
+ });
297
+ }
298
+ };
299
+
266
300
  const onFinish = async () => {
267
301
  if (!agentState || !connectAs.mayConnect) return;
268
302
  setFinishing(true);
@@ -349,6 +383,10 @@ export function ConnectToolsPage() {
349
383
  const outstanding = outstandingCount(listing) + standaloneOutstanding(listing);
350
384
  const nothingToDo =
351
385
  !loading && tools.length === 0 && oauth.length === 0 && toolOAuth.length === 0;
386
+ // Managed connectors get a card of their own (what they do, what they ask
387
+ // for); every other sign-in stays a row under "Sign-ins".
388
+ const connectors = toolOAuth.filter(isManagedRow);
389
+ const plainSignIns = toolOAuth.filter((o) => !o.managed);
352
390
 
353
391
  // A document, like every Skills & Tools page: `LibraryLayout`'s pane is the
354
392
  // scroller. The header sticks to the top of that pane, so the title and
@@ -476,10 +514,49 @@ export function ConnectToolsPage() {
476
514
  </Banner>
477
515
  )}
478
516
 
479
- {(toolOAuth.length > 0 || oauth.length > 0) && (
517
+ {connectors.length > 0 && (
518
+ <Section title="Connectors">
519
+ {connectors.map((o) => (
520
+ <ManagedConnectorCard
521
+ key={o.key}
522
+ o={o}
523
+ busy={wiping.has(signInId(o))}
524
+ // Include/skip, as every sign-in row has it: skipping a
525
+ // personal sign-in removes the caller's own token (the
526
+ // same wipe as a row's). A workspace connection is
527
+ // everyone's and cannot be "skipped by you": nothing
528
+ // takes a shared token out of one agent's connection,
529
+ // so the card offers no toggle rather than a hollow one.
530
+ on={isOn(signInId(o))}
531
+ onToggle={
532
+ o.managed.tokenScope === 'shared'
533
+ ? undefined
534
+ : () =>
535
+ void onToggle(signInId(o), o.authorized, async (removed) => {
536
+ await deleteUserVar(o.slug, o.varName);
537
+ removed();
538
+ })
539
+ }
540
+ onConnect={() => void onAuthorizeTool(o.slug, o.varName)}
541
+ onDisconnect={() => void onDisconnectManaged(o)}
542
+ onOwnApp={
543
+ canBringOwnApp(o)
544
+ ? async (clientId, clientSecret) => {
545
+ await setOAuthClientSecret(o.slug, o.varName, clientSecret, clientId);
546
+ announceToolCredentialsChanged();
547
+ await refresh(true);
548
+ }
549
+ : undefined
550
+ }
551
+ />
552
+ ))}
553
+ </Section>
554
+ )}
555
+
556
+ {(plainSignIns.length > 0 || oauth.length > 0) && (
480
557
  <Section title="Sign-ins">
481
558
  {/* OAuth-backed tool variables — authorized via the tool-scoped flow. */}
482
- {toolOAuth.map((o) => {
559
+ {plainSignIns.map((o) => {
483
560
  const id = signInId(o);
484
561
  const on = isOn(id);
485
562
  // The provider was never registered, so there is no consent
@@ -659,6 +736,21 @@ export function ConnectToolsPage() {
659
736
  )}
660
737
  </>
661
738
  )}
739
+
740
+ {/* The distribution's foot of the page — which connectors it offers
741
+ and enabling one — rendered whatever the lists above hold: a
742
+ reader with nothing to set up is exactly who comes here to
743
+ enable something. */}
744
+ {ConnectPanel && !loading && (
745
+ <SlotBoundary label="connect panel">
746
+ <ConnectPanel
747
+ onChanged={() => {
748
+ announceToolCredentialsChanged();
749
+ void refresh(true);
750
+ }}
751
+ />
752
+ </SlotBoundary>
753
+ )}
662
754
  </div>
663
755
  </div>
664
756
  </div>
@@ -792,32 +884,6 @@ function ConnectRow(props: RowHeadProps) {
792
884
  );
793
885
  }
794
886
 
795
- /** Include/skip checkbox for a tool or sign-in row. */
796
- function IncludeToggle({
797
- on,
798
- busy,
799
- onChange,
800
- }: {
801
- on: boolean;
802
- busy: boolean;
803
- onChange: () => void;
804
- }) {
805
- const label = on
806
- ? 'Skip this tool (removes your saved keys and sign-ins for it)'
807
- : 'Include this tool';
808
- return (
809
- <input
810
- type="checkbox"
811
- checked={on}
812
- disabled={busy}
813
- onChange={onChange}
814
- title={label}
815
- aria-label={label}
816
- className="size-3.5 shrink-0 accent-accent disabled:opacity-40"
817
- />
818
- );
819
- }
820
-
821
887
  /**
822
888
  * One tool's keys, and the ONE probe they share.
823
889
  *
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Include/skip checkbox for a tool, a sign-in row or a managed connector's
3
+ * card on the Connect page: what the agent may use. One control, so every
4
+ * row names the choice the same way.
5
+ */
6
+ export function IncludeToggle({
7
+ on,
8
+ busy,
9
+ onChange,
10
+ }: {
11
+ on: boolean;
12
+ busy: boolean;
13
+ onChange: () => void;
14
+ }) {
15
+ const label = on
16
+ ? 'Skip this tool (removes your saved keys and sign-ins for it)'
17
+ : 'Include this tool';
18
+ return (
19
+ <input
20
+ type="checkbox"
21
+ checked={on}
22
+ disabled={busy}
23
+ onChange={onChange}
24
+ title={label}
25
+ aria-label={label}
26
+ className="size-3.5 shrink-0 accent-accent disabled:opacity-40"
27
+ />
28
+ );
29
+ }