@bevel-software/platform-core-frontend 0.34.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 (86) 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/api.ts +24 -4
  9. package/src/modules/access/hooks/useFileAccess.ts +1 -1
  10. package/src/modules/access/index.ts +1 -1
  11. package/src/modules/admin/index.ts +1 -1
  12. package/src/modules/agents/components/ConnectAsChoice.tsx +7 -0
  13. package/src/modules/audit/__tests__/AuditLogPage.test.tsx +4 -3
  14. package/src/modules/audit/components/AuditLogPage.tsx +6 -4
  15. package/src/modules/audit/components/principal-grouping.ts +49 -49
  16. package/src/modules/auth/index.ts +1 -1
  17. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +1 -1
  18. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +6 -6
  19. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +8 -8
  20. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
  21. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
  22. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +1 -1
  23. package/src/modules/git/__tests__/pr.api.test.ts +3 -3
  24. package/src/modules/git/components/FileHistoryPanel.tsx +1 -1
  25. package/src/modules/git/components/GitSyncFailedBanner.tsx +1 -1
  26. package/src/modules/git/services/git.api.ts +1 -1
  27. package/src/modules/git/services/pr-prompts.ts +1 -1
  28. package/src/modules/layout/state/layout.context.ts +8 -0
  29. package/src/modules/library/__tests__/SkillPage.test.tsx +5 -5
  30. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +11 -0
  31. package/src/modules/library/__tests__/ToolVarRow.test.tsx +160 -5
  32. package/src/modules/library/components/tool-page/ToolVarRow.tsx +103 -28
  33. package/src/modules/library/services/library.api.ts +2 -2
  34. package/src/modules/onboarding/__tests__/onboarding.test.tsx +8 -8
  35. package/src/modules/onboarding/state/agent-connection.ts +1 -1
  36. package/src/modules/pr/services/pr-merge.api.ts +1 -1
  37. package/src/modules/pr/services/pr-open.api.ts +1 -1
  38. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +96 -30
  39. package/src/modules/secrets-vault/components/IncludeToggle.tsx +29 -0
  40. package/src/modules/secrets-vault/components/ManagedConnectorCard.tsx +189 -0
  41. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.managed.test.tsx +212 -0
  42. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +10 -0
  43. package/src/modules/secrets-vault/components/__tests__/ManagedConnectorCard.test.tsx +182 -0
  44. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +3 -0
  45. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +1 -0
  46. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +1 -0
  47. package/src/modules/secrets-vault/index.ts +2 -0
  48. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +1 -0
  49. package/src/modules/secrets-vault/services/connect.api.ts +46 -5
  50. package/src/modules/secrets-vault/services/tool-secrets.api.ts +21 -3
  51. package/src/modules/secrets-vault/utils/managed-card-state.ts +61 -0
  52. package/src/modules/setup/utils/__tests__/root-folders.test.ts +5 -1
  53. package/src/modules/setup/utils/root-folders.ts +2 -2
  54. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +8 -1
  55. package/src/modules/toolbar/components/Toolbar.tsx +1 -1
  56. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +39 -13
  57. package/src/modules/{workflow → version-control}/hooks/__tests__/useFileLock.test.tsx +10 -10
  58. package/src/modules/{workflow → version-control}/hooks/__tests__/useFileLock.wire.test.tsx +1 -1
  59. package/src/modules/{workflow → version-control}/hooks/useEventBusSubscription.ts +2 -2
  60. package/src/modules/{workflow → version-control}/hooks/useFileLock.ts +1 -1
  61. package/src/modules/{workflow → version-control}/index.ts +2 -2
  62. package/src/modules/{workflow → version-control}/services/__tests__/lock.api.test.ts +1 -1
  63. package/src/modules/{workflow → version-control}/state/EventBusProvider.tsx +6 -6
  64. package/src/modules/{workflow → version-control}/state/event-bus.context.ts +4 -4
  65. package/src/modules/workspace/components/FileExplorer.tsx +96 -41
  66. package/src/modules/workspace/components/FileRoute.tsx +24 -1
  67. package/src/modules/workspace/components/FileViewer.tsx +2 -2
  68. package/src/modules/workspace/components/KbPageHeader.tsx +1 -1
  69. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +191 -21
  70. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +50 -2
  71. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +5 -5
  72. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +5 -5
  73. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +9 -9
  74. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +7 -7
  75. package/src/modules/workspace/hooks/useImageRevision.ts +1 -1
  76. package/src/modules/workspace/hooks/useWorkspaceState.ts +2 -2
  77. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +9 -9
  78. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +9 -1
  79. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +32 -48
  80. package/src/modules/workspace/utils/fileTree.ts +10 -2
  81. package/src/modules/workspace/utils/treeConfirm.ts +25 -29
  82. /package/src/modules/{workflow → version-control}/services/lock.api.ts +0 -0
  83. /package/src/modules/{workflow → version-control}/state/ChangeRequestStaleBinder.tsx +0 -0
  84. /package/src/modules/{workflow → version-control}/state/EventBusFocusBinder.tsx +0 -0
  85. /package/src/modules/{workflow → version-control}/state/__tests__/EventBusProvider.storage.test.tsx +0 -0
  86. /package/src/modules/{workflow → version-control}/state/__tests__/EventBusProvider.watch.test.tsx +0 -0
@@ -201,6 +201,7 @@ describe('ToolConnectionSection', () => {
201
201
  label: null,
202
202
  key: 'github_SIGNIN',
203
203
  adminConfigured: true,
204
+ adminKind: 'oauth',
204
205
  userConfigured: false,
205
206
  oauth: true,
206
207
  authorized: false,
@@ -242,6 +243,7 @@ describe('ToolConnectionSection', () => {
242
243
  label: 'HeyReach API key',
243
244
  key: 'heyreach_API_KEY',
244
245
  adminConfigured: false,
246
+ adminKind: null,
245
247
  userConfigured: false,
246
248
  ...over,
247
249
  });
@@ -330,6 +332,7 @@ describe('ToolConnectionSection', () => {
330
332
  label: 'Sign-in',
331
333
  key: 'heyreach_SIGNIN',
332
334
  adminConfigured: true,
335
+ adminKind: 'oauth',
333
336
  userConfigured: false,
334
337
  oauth: true,
335
338
  authorized: false,
@@ -354,6 +357,7 @@ describe('ToolConnectionSection', () => {
354
357
  label: null,
355
358
  key: 'heyreach_API_KEY',
356
359
  adminConfigured: true,
360
+ adminKind: 'static',
357
361
  userConfigured: true,
358
362
  },
359
363
  ],
@@ -388,6 +392,7 @@ describe('ToolConnectionSection', () => {
388
392
  label: null,
389
393
  key: 'github_API_KEY',
390
394
  adminConfigured: true,
395
+ adminKind: 'static',
391
396
  userConfigured: true,
392
397
  },
393
398
  ],
@@ -523,6 +528,7 @@ describe('ToolConnectionSection', () => {
523
528
  label: null,
524
529
  key: 'github_API_KEY',
525
530
  adminConfigured: true,
531
+ adminKind: 'static',
526
532
  userConfigured: false,
527
533
  },
528
534
  ],
@@ -576,6 +582,7 @@ describe('ToolConnectionSection', () => {
576
582
  label: null,
577
583
  key: 'github_API_KEY',
578
584
  adminConfigured: true,
585
+ adminKind: 'static',
579
586
  userConfigured: false,
580
587
  },
581
588
  ],
@@ -742,6 +749,7 @@ describe('ToolConnectionSection', () => {
742
749
  label: null,
743
750
  key: 'github_API_KEY',
744
751
  adminConfigured,
752
+ adminKind: adminConfigured ? 'static' : null,
745
753
  userConfigured: false,
746
754
  },
747
755
  ],
@@ -916,6 +924,7 @@ describe('ToolConnectionSection', () => {
916
924
  label: null,
917
925
  key: 'github_SIGNIN',
918
926
  adminConfigured: true,
927
+ adminKind: 'oauth',
919
928
  userConfigured: false,
920
929
  oauth: true,
921
930
  authorized: false,
@@ -928,6 +937,7 @@ describe('ToolConnectionSection', () => {
928
937
  label: null,
929
938
  key: 'github_API_KEY',
930
939
  adminConfigured: true,
940
+ adminKind: 'static',
931
941
  userConfigured: false,
932
942
  ...over,
933
943
  });
@@ -963,6 +973,7 @@ describe('ToolConnectionSection', () => {
963
973
  label: null,
964
974
  key: 'github_MY_KEY',
965
975
  adminConfigured: false,
976
+ adminKind: null,
966
977
  userConfigured: false,
967
978
  },
968
979
  ],
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
- import type { ToolVarStatus } from '../../secrets-vault/services/tool-secrets.api';
2
+ import { render, screen, fireEvent, waitFor, cleanup } from '@testing-library/react';
3
+ import type { ToolVarStatus } from '../../secrets-vault';
4
4
 
5
5
  /**
6
6
  * The per-variable state matrix, one case per row of the spec table.
@@ -12,16 +12,21 @@ import type { ToolVarStatus } from '../../secrets-vault/services/tool-secrets.ap
12
12
  * clobber the discovered provider).
13
13
  */
14
14
 
15
+ // The row reaches Secrets & connections through that module's entry, so the
16
+ // mock sits on the entry too — the same surface, with the rest of the module
17
+ // left as it is — never on the files behind it.
15
18
  const secretsMock = vi.hoisted(() => ({
16
19
  setAdminVar: vi.fn(),
17
20
  setUserVar: vi.fn(),
18
21
  deleteAdminVar: vi.fn(),
19
22
  setOAuthClientSecret: vi.fn(),
20
23
  }));
21
- vi.mock('../../secrets-vault/services/tool-secrets.api', () => secretsMock);
22
-
23
24
  const connectMock = vi.hoisted(() => ({ startToolOAuth: vi.fn() }));
24
- vi.mock('../../secrets-vault/services/connect.api', () => connectMock);
25
+ vi.mock('../../secrets-vault', async (importOriginal) => ({
26
+ ...(await importOriginal<typeof import('../../secrets-vault')>()),
27
+ ...secretsMock,
28
+ ...connectMock,
29
+ }));
25
30
 
26
31
  // External navigation behind a spy-able module — never assign
27
32
  // window.location.href in a test.
@@ -39,6 +44,9 @@ function variable(over: Partial<ToolVarStatus>): ToolVarStatus {
39
44
  label: null,
40
45
  key: 'github_API_KEY',
41
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,
42
50
  userConfigured: false,
43
51
  ...over,
44
52
  };
@@ -236,7 +244,48 @@ describe('ToolVarRow: oauth', () => {
236
244
  expect(screen.getByRole('button', { name: 'Replace client secret' })).toBeInTheDocument();
237
245
  });
238
246
 
247
+ it('offers a writer Replace client secret while not signed in, and it opens the client-secret editor', async () => {
248
+ const { onChanged } = renderRow(signin({ authorized: false }), { canWrite: true, setupKind: 'oauth-manual' });
249
+ expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
250
+ expect(screen.queryByRole('button', { name: 'Set client secret' })).toBeNull();
251
+ fireEvent.click(screen.getByRole('button', { name: 'Replace client secret' }));
252
+
253
+ const input = screen.getByLabelText('Client secret for SIGNIN');
254
+ expect(input).toHaveAttribute('type', 'password');
255
+ fireEvent.change(input, { target: { value: 'cs_new' } });
256
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));
257
+ await waitFor(() =>
258
+ expect(secretsMock.setOAuthClientSecret).toHaveBeenCalledWith('github', 'SIGNIN', 'cs_new'),
259
+ );
260
+ await waitFor(() => expect(onChanged).toHaveBeenCalled());
261
+ });
262
+
263
+ it('offers a writer Replace client secret beside Sign in again', () => {
264
+ renderRow(signin({ authorized: true, needsReauth: true }), { canWrite: true, setupKind: 'oauth-manual' });
265
+ expect(screen.getByRole('button', { name: 'Sign in again' })).toBeInTheDocument();
266
+ expect(screen.getByRole('button', { name: 'Replace client secret' })).toBeInTheDocument();
267
+ });
268
+
269
+ it('shows a reader who cannot write the tool Sign in only, in every state', () => {
270
+ renderRow(signin({ authorized: false }), { canWrite: false, setupKind: 'oauth-manual' });
271
+ expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
272
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
273
+ cleanup();
274
+ renderRow(signin({ authorized: true }), { canWrite: false, setupKind: 'oauth-manual' });
275
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
276
+ cleanup();
277
+ renderRow(signin({ authorized: true, needsReauth: true }), { canWrite: false, setupKind: 'oauth-manual' });
278
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
279
+ });
280
+
239
281
  it('never shows a client-secret affordance for oauth-auto, even to a writer', () => {
282
+ renderRow(signin({ authorized: false }), { canWrite: true, setupKind: 'oauth-auto' });
283
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
284
+ cleanup();
285
+ renderRow(signin({ authorized: true, needsReauth: true }), { canWrite: true, setupKind: 'oauth-auto' });
286
+ expect(screen.queryByRole('button', { name: /client secret/ })).toBeNull();
287
+ cleanup();
288
+
240
289
  renderRow(signin({ authorized: true }), { canWrite: true, setupKind: 'oauth-auto' });
241
290
  expect(screen.queryByRole('button', { name: 'Replace client secret' })).toBeNull();
242
291
 
@@ -246,6 +295,112 @@ describe('ToolVarRow: oauth', () => {
246
295
  });
247
296
  });
248
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
+
249
404
  describe('ToolVarRow: failures', () => {
250
405
  it('reports a rejected write through onError and leaves the editor open', async () => {
251
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,
@@ -26,9 +26,21 @@ import { navigateExternal } from '../../utils/navigate-external';
26
26
  * - `oauth-auto` NEVER gets a client-secret affordance. Its client was
27
27
  * auto-registered by PKCE dynamic registration and has no secret; saving one
28
28
  * would clobber the discovered provider row and break sign-in for everyone.
29
+ * - Every OTHER sign-in offers its owner the client secret in every state of
30
+ * the row: "Replace client secret" while one is stored, "Set client secret"
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. 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.
29
36
  * - Whose problem is it? A user-scope gap is the caller's to fix and always
30
37
  * shows an action. An admin-scope gap is the OWNER's, so a non-writer sees a
31
- * 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.
32
44
  *
33
45
  * Secret values are write-only throughout: `type="password"`, held in local
34
46
  * state, cleared on save or cancel. Nothing here ever reads a stored value.
@@ -125,20 +137,45 @@ export function ToolVarRow({
125
137
  let description: string;
126
138
 
127
139
  if (variable.oauth) {
128
- // An OAuth client secret only exists for a MANUALLY declared provider.
129
- 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';
130
161
 
131
162
  if (variable.authorized && !variable.needsReauth) {
132
- description = 'Each person sets their own';
163
+ description = whose;
133
164
  // Connected is not final: a provider can widen what it grants after the
134
165
  // fact (HubSpot's MCP tools do, and answer REQUIRES_REAUTHORIZATION
135
166
  // until the user consents again), a grant can be revoked provider-side,
136
167
  // or the owner can rotate the client. The caller needs a way back into
137
- // 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
+ }
138
178
  meta.push(
139
- <Button key="reconnect" size="sm" variant="quiet" disabled={busy} onClick={() => void signIn()}>
140
- Reconnect
141
- </Button>,
142
179
  // "Signed in", not "Connected": at ROW level all we know is that a token
143
180
  // exists. Whether it still works is the tool-level health line's claim,
144
181
  // and it is the only place in the UI allowed to say "Connected" — one
@@ -147,22 +184,21 @@ export function ToolVarRow({
147
184
  Signed in
148
185
  </Badge>,
149
186
  );
150
- if (mayEditClientSecret) {
151
- meta.push(
152
- <Button key="secret" size="sm" variant="quiet" onClick={() => open('client-secret')}>
153
- Replace client secret
154
- </Button>,
155
- );
156
- }
157
187
  } else if (variable.authorized) {
158
- description = 'Each person sets their own';
188
+ description = whose;
159
189
  meta.push(
160
- <Button key="reauth" size="sm" disabled={busy} onClick={() => void signIn()}>
161
- Sign in again
162
- </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
+ ),
163
199
  );
164
- } else if (variable.adminConfigured) {
165
- description = 'Each person sets their own';
200
+ } else if (ownerReady) {
201
+ description = whose;
166
202
  meta.push(
167
203
  <Button key="signin" size="sm" disabled={busy} onClick={() => void signIn()}>
168
204
  Sign in
@@ -170,15 +206,37 @@ export function ToolVarRow({
170
206
  );
171
207
  } else {
172
208
  // The owner hasn't declared the provider (or hasn't set its secret), so
173
- // there is nothing for anyone to sign in to yet.
174
- description = "The tool owner hasn't finished the sign-in setup yet.";
175
- 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) {
176
225
  meta.push(
177
- <Button key="secret" size="sm" onClick={() => open('client-secret')}>
178
- Set client secret
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
179
234
  </Button>,
180
235
  );
181
- } else {
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) {
182
240
  meta.push(
183
241
  <Badge key="chip" tone="neutral">
184
242
  Not set
@@ -186,6 +244,23 @@ export function ToolVarRow({
186
244
  );
187
245
  }
188
246
  }
247
+ // The client secret is the owner's, not the sign-in's: whatever state the
248
+ // caller's own sign-in is in, an owner who may edit it can replace a stored
249
+ // secret (or set a missing one) from this row. Tying it to the caller being
250
+ // signed in left an owner replacing a connector with no way to do it here.
251
+ if (mayEditClientSecret) {
252
+ meta.push(
253
+ variable.adminConfigured ? (
254
+ <Button key="secret" size="sm" variant="quiet" onClick={() => open('client-secret')}>
255
+ Replace client secret
256
+ </Button>
257
+ ) : (
258
+ <Button key="secret" size="sm" onClick={() => open('client-secret')}>
259
+ Set client secret
260
+ </Button>
261
+ ),
262
+ );
263
+ }
189
264
  } else if (variable.scope === 'admin') {
190
265
  if (variable.adminConfigured) {
191
266
  description = 'One value for the whole team. Already handled';
@@ -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;