@bevel-software/platform-core-frontend 0.35.0 → 0.37.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 (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
@@ -55,6 +55,36 @@ export interface ConnectOAuth {
55
55
  authorized: boolean;
56
56
  }
57
57
 
58
+ /**
59
+ * A sign-in that goes through a managed connector: Bevel's own OAuth app, a
60
+ * broker that does the provider round-trip, nothing for the owner to
61
+ * register. What the card shows comes from the connector's definition on the
62
+ * server; what the row can DO is the same Connect / Reconnect / Disconnect as
63
+ * any sign-in, plus "Connected as" once the account is known.
64
+ */
65
+ export interface ManagedSignIn {
66
+ connectorId: string;
67
+ scopeSet: string;
68
+ /** `user`: each person connects their own account. `shared`: one workspace connection an owner makes. */
69
+ tokenScope: 'user' | 'shared';
70
+ displayName: string;
71
+ /** A lucide icon name. */
72
+ icon: string;
73
+ /** One line: what connecting lets Hexis do. */
74
+ description: string;
75
+ /** Plain-language permissions of the scope set. */
76
+ permissions: string[];
77
+ scopeSetLabel: string;
78
+ dataResidency: string;
79
+ subprocessor: string;
80
+ /** The connected account, once the sign-in reported one. */
81
+ account: string | null;
82
+ /** An owner replaced the managed app with the deployment's own; the ordinary flow applies. */
83
+ ownApp: boolean;
84
+ /** The deployment can start sign-ins through the broker. False ⇒ the admin has setup to do. */
85
+ available: boolean;
86
+ }
87
+
58
88
  /** An OAuth-backed variable declared BY a tool — authorized via the tool-scoped start. */
59
89
  export interface ConnectToolOAuth {
60
90
  slug: string;
@@ -63,19 +93,30 @@ export interface ConnectToolOAuth {
63
93
  key: string;
64
94
  label: string | null;
65
95
  authorized: boolean;
96
+ /** Present for a managed connector's sign-in — see {@link ManagedSignIn}. */
97
+ managed?: ManagedSignIn;
98
+ /** With `managed`: whether the caller may write the tool (disconnect a shared connection, bring an own app). */
99
+ canWrite?: boolean;
66
100
  /**
67
101
  * Authorized, but the token's granted permissions no longer cover what the tool
68
102
  * declares now (a scope was added since sign-in) — show Reconnect, not Connected.
69
103
  */
70
104
  needsReauth: boolean;
71
105
  /**
72
- * The owner-side half is done: the provider registration (client secret) exists,
73
- * so Authorize can actually reach a consent screen. Until it does, nobody's
74
- * sign-in can work — which is why the row is outstanding even for a person who
75
- * has nothing to do about it.
106
+ * The owner-side half is done, so Authorize can actually reach a consent
107
+ * screen: for an ordinary sign-in the provider registration (client secret)
108
+ * exists; for a MANAGED one the deployment can reach its broker, an owner
109
+ * pinned their own app, or a token is already stored. Until it is, nobody's
110
+ * sign-in can work — which is why the row is outstanding even for a person
111
+ * who has nothing to do about it.
76
112
  */
77
113
  ownerConfigured: boolean;
78
- /** Waiting on the registration above, and the caller may not write it. */
114
+ /**
115
+ * Not the caller's to do: an ordinary sign-in waiting on the registration
116
+ * above that the caller may not write, or a managed WORKSPACE connection
117
+ * (one an owner makes for everyone) seen by someone who may not write the
118
+ * tool.
119
+ */
79
120
  ownerOnly: boolean;
80
121
  }
81
122
 
@@ -1,4 +1,5 @@
1
1
  import { authFetch } from '../../../lib/api';
2
+ import type { ManagedSignIn } from './connect.api';
2
3
 
3
4
  /**
4
5
  * Per-tool secrets API. A `.tool` manual declares which `${VAR}`s are set by the
@@ -17,6 +18,13 @@ export interface ToolVarStatus {
17
18
  key: string;
18
19
  /** A shared (admin) value exists. */
19
20
  adminConfigured: boolean;
21
+ /**
22
+ * What the shared row IS: a sign-in needs an `oauth` one, not a key left
23
+ * from when the variable was static. `null` when there is no shared row.
24
+ * The server always sends it; a consumer tests for `'oauth'` and never for
25
+ * "not static", which a missing field would satisfy.
26
+ */
27
+ adminKind?: 'static' | 'oauth' | null;
20
28
  /** The caller's own value exists. */
21
29
  userConfigured: boolean;
22
30
  /** This variable is filled by an OAuth sign-in, not a typed value. */
@@ -27,6 +35,8 @@ export interface ToolVarStatus {
27
35
  needsReauth?: boolean;
28
36
  /** For an oauth var: the declared scopes the token was NOT granted (what it can't do). */
29
37
  missingScopes?: string[];
38
+ /** For a managed connector's sign-in: the card the Connect page shows (see `ManagedSignIn`). */
39
+ managed?: ManagedSignIn;
30
40
  }
31
41
 
32
42
  /**
@@ -118,15 +128,23 @@ async function deleteVar(slug: string, varName: string, tier: ToolVarScope): Pro
118
128
  * Store the confidential OAuth CLIENT SECRET for a tool's declared sign-in
119
129
  * provider — the owner-side half of a manual OAuth setup. Requires write access
120
130
  * to the `.tool`; the public provider config is pinned server-side from the
121
- * file's own `oauth` declaration.
131
+ * file's own `oauth` declaration. A MANAGED declaration names no client, so
132
+ * the caller's `clientId` is used then: the deployment's own app, replacing
133
+ * the managed one.
122
134
  */
123
- export async function setOAuthClientSecret(slug: string, varName: string, clientSecret: string): Promise<void> {
135
+ export async function setOAuthClientSecret(
136
+ slug: string,
137
+ varName: string,
138
+ clientSecret: string,
139
+ /** For a managed sign-in only: the deployment's OWN app, replacing the managed one ("use our own app"). */
140
+ clientId?: string,
141
+ ): Promise<void> {
124
142
  const res = await authFetch(
125
143
  `/api/secrets/tools/${encodeURIComponent(slug)}/vars/${encodeURIComponent(varName)}/oauth/admin`,
126
144
  {
127
145
  method: 'PUT',
128
146
  headers: { 'Content-Type': 'application/json' },
129
- body: JSON.stringify({ clientSecret }),
147
+ body: JSON.stringify(clientId ? { clientSecret, clientId } : { clientSecret }),
130
148
  },
131
149
  );
132
150
  if (!res.ok) await unwrap(res, "Couldn't save the client secret.");
@@ -0,0 +1,61 @@
1
+ import type { ConnectToolOAuth, ManagedSignIn } from '../services/connect.api';
2
+
3
+ /** A sign-in row that IS managed: the card's input, narrowed once where rows are filtered. */
4
+ export type ManagedToolOAuth = ConnectToolOAuth & { managed: ManagedSignIn };
5
+
6
+ export function isManagedRow(o: ConnectToolOAuth): o is ManagedToolOAuth {
7
+ return o.managed != null;
8
+ }
9
+
10
+ /**
11
+ * The state a managed connector card shows, in the Library's vocabulary:
12
+ * - connected a token is stored (the card adds the account when known)
13
+ * - needs-reconnect stored, but it no longer covers what the tool asks for
14
+ * - unavailable nothing stored, and no way to open a sign-in from here (the admin's job)
15
+ * - owner-only nothing stored, and it is a workspace connection a reader cannot make
16
+ * - ready nothing stored yet
17
+ *
18
+ * What is STORED comes first, whoever may change it: a workspace connection
19
+ * an owner made is connected for every reader of the tool, and telling a
20
+ * reader it "needs an owner" would contradict the tool working for them.
21
+ * Who may press what is `ownerOnly`'s to decide, on the card.
22
+ *
23
+ * A stored token is reported as such even while the broker is unreachable:
24
+ * what is stored still works, and the card withholds Connect and Reconnect
25
+ * instead (see `canStartSignIn`). The `connected` state means a token is
26
+ * STORED, the same claim every sign-in row on the Connect page makes, and the
27
+ * card says "Signed in" for it; "Connected" is the word for a call that
28
+ * worked, which is proved elsewhere.
29
+ */
30
+ export type ManagedCardState = 'unavailable' | 'owner-only' | 'ready' | 'connected' | 'needs-reconnect';
31
+
32
+ export function managedCardState(o: ManagedToolOAuth): ManagedCardState {
33
+ if (o.authorized) return o.needsReauth ? 'needs-reconnect' : 'connected';
34
+ if (!canStartSignIn(o)) return 'unavailable';
35
+ if (o.ownerOnly) return 'owner-only';
36
+ return 'ready';
37
+ }
38
+
39
+ /**
40
+ * Whether a sign-in can be opened from this deployment. A personal one goes
41
+ * through the broker, or through an owner's own app pinned in its place. A
42
+ * WORKSPACE connection goes through the broker alone: an owner's own app
43
+ * would sign the owner in to their own row, which nobody reads for it, so
44
+ * that combination is not offered (the server refuses it too).
45
+ *
46
+ * The one rule for WHETHER a start can be opened here, shared by every
47
+ * surface that offers Connect, Reconnect or Sign in on a managed sign-in
48
+ * (the Connect page's card, the tool page's row). It does not say WHO may
49
+ * make it: each surface also checks that (`ownerOnly`, `mayAct`), and a
50
+ * reader of an available workspace connection passes this rule and is
51
+ * refused the start all the same.
52
+ */
53
+ export function canStartSignIn(o: { managed: ManagedSignIn }): boolean {
54
+ if (o.managed.tokenScope === 'shared') return o.managed.available && !o.managed.ownApp;
55
+ return o.managed.ownApp || o.managed.available;
56
+ }
57
+
58
+ /** Whether "use our own app" is offered: a writer, on a personal connection (see `canStartSignIn`). */
59
+ export function canBringOwnApp(o: ManagedToolOAuth): boolean {
60
+ return o.canWrite === true && o.managed.tokenScope === 'user';
61
+ }
@@ -65,8 +65,12 @@ describe('isRootFolderSuggestion', () => {
65
65
  });
66
66
 
67
67
  it('holds back names the save would refuse: dot-folders and the reserved roots', () => {
68
- for (const name of ['.github', '.bevel', 'Data', 'agents', 'PIPELINES']) {
68
+ for (const name of ['.github', '.bevel', 'Data', 'agents', 'WORKFLOWS']) {
69
69
  expect(isRootFolderSuggestion(name)).toBe(false);
70
70
  }
71
71
  });
72
+
73
+ it('offers Pipelines, a name core no longer reserves', () => {
74
+ expect(isRootFolderSuggestion('Pipelines')).toBe(true);
75
+ });
72
76
  });
@@ -1,4 +1,4 @@
1
- import { AGENTS_DIR, DATA_DIR, PIPELINES_DIR, validateKbRootName } from '@bevel-software/platform-shared';
1
+ import { AGENTS_DIR, DATA_DIR, WORKFLOWS_DIR, validateKbRootName } from '@bevel-software/platform-shared';
2
2
 
3
3
  /**
4
4
  * What the repository holds for one configured root folder, judged against
@@ -34,7 +34,7 @@ export function rootFolderState(configured: string, rootFolders: readonly string
34
34
  };
35
35
  }
36
36
 
37
- const RESERVED_ROOTS = [DATA_DIR, AGENTS_DIR, PIPELINES_DIR].map((name) => name.toLowerCase());
37
+ const RESERVED_ROOTS = [DATA_DIR, AGENTS_DIR, WORKFLOWS_DIR].map((name) => name.toLowerCase());
38
38
 
39
39
  /**
40
40
  * Whether a listed folder may be offered as a root name: one the save would
@@ -57,7 +57,7 @@ export function Toolbar() {
57
57
  // own: the branch switcher is an enterprise contribution scoped (by the
58
58
  // item itself, via useActiveAppId) to the Knowledge app — the git module
59
59
  // still ships the component, the core shell just doesn't mount it.
60
- // (Share/Discard buttons retired with the workflow migration: lock release
60
+ // (Share/Discard buttons retired with the version-control migration: lock release
61
61
  // auto-commits + pushes, so there is no separate "share" step.)
62
62
  const toolbarItems = useMemo(
63
63
  () =>
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
2
  import { act, renderHook } from '@testing-library/react';
3
3
  import type { ReactNode } from 'react';
4
- import type { FileLock, WorkflowEvent } from '@bevel-software/platform-shared';
4
+ import type { FileLock, VersionControlEvent } from '@bevel-software/platform-shared';
5
5
 
6
6
  // The lock endpoints are the hook's only side effects; each test decides what
7
7
  // they answer. The sentences stay real — they are what the person reads.
@@ -17,7 +17,7 @@ vi.mock('../../services/lock.api', async (importOriginal) => ({
17
17
  ...api,
18
18
  }));
19
19
 
20
- // The hook and its sentence come through workflow's public entry point, as
20
+ // The hook and its sentence come through version control's public entry point, as
21
21
  // other modules see them.
22
22
  import { useFileLock, SELF_HOLD_MESSAGE } from '../..';
23
23
  import { EventBusContext, type EventBusContextValue } from '../../state/event-bus.context';
@@ -39,18 +39,18 @@ function lockHeldBy(holderUserId: string, holderName: string, expiresInMs = 60_0
39
39
 
40
40
  /** A bus the test can publish `lock-*` events on. */
41
41
  function makeBus() {
42
- const handlers = new Map<string, Set<(e: WorkflowEvent) => void>>();
42
+ const handlers = new Map<string, Set<(e: VersionControlEvent) => void>>();
43
43
  const bus: EventBusContextValue = {
44
44
  subscribe: (kind, handler) => {
45
45
  const set = handlers.get(kind) ?? new Set();
46
- set.add(handler as (e: WorkflowEvent) => void);
46
+ set.add(handler as (e: VersionControlEvent) => void);
47
47
  handlers.set(kind, set);
48
- return () => set.delete(handler as (e: WorkflowEvent) => void);
48
+ return () => set.delete(handler as (e: VersionControlEvent) => void);
49
49
  },
50
50
  setFocus: () => {},
51
51
  watchWorkspace: () => () => {},
52
52
  };
53
- const publish = (e: WorkflowEvent) => handlers.get(e.kind)?.forEach((h) => h(e));
53
+ const publish = (e: VersionControlEvent) => handlers.get(e.kind)?.forEach((h) => h(e));
54
54
  return { bus, publish };
55
55
  }
56
56
 
@@ -201,7 +201,7 @@ describe('useFileLock — the notice clears when the hold ends', () => {
201
201
  expect(result.current.externalLock).not.toBeNull();
202
202
 
203
203
  await act(async () => {
204
- publish({ kind: 'lock-released', workspaceId: 'ws', branch: 'main', path: 'kb/Knowledge/Foo.md' } as WorkflowEvent);
204
+ publish({ kind: 'lock-released', workspaceId: 'ws', branch: 'main', path: 'kb/Knowledge/Foo.md' } as VersionControlEvent);
205
205
  });
206
206
 
207
207
  expect(result.current.externalLock).toBeNull();
@@ -224,7 +224,7 @@ describe('useFileLock — the notice clears when the hold ends', () => {
224
224
  path: 'kb/Knowledge/Foo.md',
225
225
  holderUserId: 'u-dana',
226
226
  holderName: 'Dana',
227
- } as WorkflowEvent);
227
+ } as VersionControlEvent);
228
228
  });
229
229
  expect(result.current.externalLock?.holderName).toBe('Dana');
230
230
 
@@ -443,7 +443,7 @@ describe('useFileLock — a live hold of the viewer\'s own is shown on open', ()
443
443
  publish({
444
444
  kind: 'lock-acquired', workspaceId: 'ws', branch: 'main', path: 'kb/Knowledge/Foo.md',
445
445
  holderUserId: ME, holderName: 'Juan',
446
- } as WorkflowEvent);
446
+ } as VersionControlEvent);
447
447
  });
448
448
 
449
449
  expect(result.current.externalLockIsMine).toBe(true);
@@ -464,7 +464,7 @@ describe('useFileLock — a live hold of the viewer\'s own is shown on open', ()
464
464
  publish({
465
465
  kind: 'lock-acquired', workspaceId: 'ws', branch: 'main', path: 'kb/Knowledge/Foo.md',
466
466
  holderUserId: ME, holderName: 'Juan',
467
- } as WorkflowEvent);
467
+ } as VersionControlEvent);
468
468
  });
469
469
  expect(result.current.externalLock).toBeNull();
470
470
 
@@ -3,7 +3,7 @@ import { act, renderHook } from '@testing-library/react';
3
3
  import type { FileLock } from '@bevel-software/platform-shared';
4
4
  // Nothing of the lock service is mocked here: these tests are about the
5
5
  // request a release becomes on the wire, so the hook is driven through
6
- // workflow's entry point, as other modules use it, down to `fetch`.
6
+ // version control's entry point, as other modules use it, down to `fetch`.
7
7
  import { useFileLock } from '../..';
8
8
  import { setToken } from '../../../../lib/api';
9
9
 
@@ -1,5 +1,5 @@
1
1
  import { useEffect } from 'react';
2
- import type { WorkflowEvent } from '@bevel-software/platform-shared';
2
+ import type { VersionControlEvent } from '@bevel-software/platform-shared';
3
3
  import { useEventBus, type EventHandler } from '../state/event-bus.context';
4
4
 
5
5
  /**
@@ -12,7 +12,7 @@ import { useEventBus, type EventHandler } from '../state/event-bus.context';
12
12
  * don't mount it). That lets components subscribe unconditionally
13
13
  * without each test having to scaffold the bus.
14
14
  */
15
- export function useEventBusSubscription<K extends WorkflowEvent['kind']>(
15
+ export function useEventBusSubscription<K extends VersionControlEvent['kind']>(
16
16
  kind: K,
17
17
  handler: EventHandler<K>,
18
18
  ): void {
@@ -375,7 +375,7 @@ export function useFileLock(args: UseFileLockArgs): UseFileLockReturn {
375
375
  // an already-locked file would render "free" until the next
376
376
  // release.
377
377
  //
378
- // 2. **`lock-acquired` / `lock-released` events** from the workflow
378
+ // 2. **`lock-acquired` / `lock-released` events** from the version-control service
379
379
  // event bus — replace the 15s poll the hook used to do. The bus
380
380
  // fans these out within milliseconds of the acquire/release on
381
381
  // the backend, so the banner appears / disappears in near real
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Workflow's public surface for other modules: the per-file edit hold the
2
+ * Version control's public surface for other modules: the per-file edit hold the
3
3
  * editor takes, and the sentences and error type that come with it. Other
4
- * modules import these from here rather than reaching into workflow's
4
+ * modules import these from here rather than reaching into version control's
5
5
  * hooks and services.
6
6
  */
7
7
  export { useFileLock, type AcquireOutcome } from './hooks/useFileLock';
@@ -41,5 +41,5 @@ describe('lock.api', () => {
41
41
  });
42
42
 
43
43
  // What a release looks like on the wire (keep-alive on `pagehide`, the
44
- // bearer header, the queued answer) is tested through workflow's entry
44
+ // bearer header, the queued answer) is tested through version control's entry
45
45
  // point in `hooks/__tests__/useFileLock.wire.test.tsx`, not here.
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
2
- import type { WorkflowEvent } from '@bevel-software/platform-shared';
2
+ import type { VersionControlEvent } from '@bevel-software/platform-shared';
3
3
  import { EventBusContext, type EventBusContextValue, type EventHandler } from './event-bus.context';
4
4
 
5
5
  /** Storage key for the per-tab sessionId. SessionStorage so it survives a
@@ -63,7 +63,7 @@ export function EventBusProvider({ children }: { children: ReactNode }) {
63
63
  // Subscriber registry. Keyed by event kind so dispatch is O(handlers
64
64
  // for THIS kind) rather than scanning every subscriber on every event.
65
65
  // `Set` so duplicate registrations don't double-fire.
66
- const subscribersRef = useRef<Map<string, Set<EventHandler<WorkflowEvent['kind']>>>>(new Map());
66
+ const subscribersRef = useRef<Map<string, Set<EventHandler<VersionControlEvent['kind']>>>>(new Map());
67
67
 
68
68
  // **Two focus refs, not one** — the "synced" focus (what the server
69
69
  // confirmed) and the "desired" focus (what the client wants).
@@ -101,7 +101,7 @@ export function EventBusProvider({ children }: { children: ReactNode }) {
101
101
  [],
102
102
  );
103
103
 
104
- const dispatch = useCallback((event: WorkflowEvent) => {
104
+ const dispatch = useCallback((event: VersionControlEvent) => {
105
105
  // Heartbeats are connection-keepalives only — they shouldn't reach
106
106
  // app code. Same for resync (we'd want to refetch state from
107
107
  // scratch, but that's left to consumers that subscribe to it
@@ -137,9 +137,9 @@ export function EventBusProvider({ children }: { children: ReactNode }) {
137
137
  bucket = new Set();
138
138
  subscribersRef.current.set(kind, bucket);
139
139
  }
140
- bucket.add(handler as unknown as EventHandler<WorkflowEvent['kind']>);
140
+ bucket.add(handler as unknown as EventHandler<VersionControlEvent['kind']>);
141
141
  return () => {
142
- bucket?.delete(handler as unknown as EventHandler<WorkflowEvent['kind']>);
142
+ bucket?.delete(handler as unknown as EventHandler<VersionControlEvent['kind']>);
143
143
  if (bucket && bucket.size === 0) {
144
144
  subscribersRef.current.delete(kind);
145
145
  }
@@ -297,7 +297,7 @@ export function EventBusProvider({ children }: { children: ReactNode }) {
297
297
 
298
298
  const handleMessage = (e: MessageEvent<string>) => {
299
299
  try {
300
- const event = JSON.parse(e.data) as WorkflowEvent;
300
+ const event = JSON.parse(e.data) as VersionControlEvent;
301
301
  dispatch(event);
302
302
  } catch (err) {
303
303
  console.warn('[event-bus] failed to parse SSE payload:', err);
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from 'react';
2
- import type { WorkflowEvent } from '@bevel-software/platform-shared';
2
+ import type { VersionControlEvent } from '@bevel-software/platform-shared';
3
3
 
4
4
  /**
5
5
  * Handler signature for an event-bus subscription. The handler runs
@@ -7,8 +7,8 @@ import type { WorkflowEvent } from '@bevel-software/platform-shared';
7
7
  * (state updates, callbacks); long-running work should be deferred via
8
8
  * `useEffect` / setState batching.
9
9
  */
10
- export type EventHandler<K extends WorkflowEvent['kind']> = (
11
- event: Extract<WorkflowEvent, { kind: K }>,
10
+ export type EventHandler<K extends VersionControlEvent['kind']> = (
11
+ event: Extract<VersionControlEvent, { kind: K }>,
12
12
  ) => void;
13
13
 
14
14
  /**
@@ -39,7 +39,7 @@ export type EventHandler<K extends WorkflowEvent['kind']> = (
39
39
  * needs to know (e.g. a status banner), we'll add it then.
40
40
  */
41
41
  export interface EventBusContextValue {
42
- subscribe<K extends WorkflowEvent['kind']>(kind: K, handler: EventHandler<K>): () => void;
42
+ subscribe<K extends VersionControlEvent['kind']>(kind: K, handler: EventHandler<K>): () => void;
43
43
  setFocus(workspaceId: string | null): void;
44
44
  watchWorkspace(workspaceId: string): () => void;
45
45
  }