@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
@@ -20,7 +20,7 @@ vi.mock('../../routing/kb-routes', async (importOriginal) => {
20
20
  import type { WorkingTreeStatus } from '@bevel-software/platform-shared';
21
21
  import { FileRoute } from '../FileRoute';
22
22
  import { WorkspaceApiError } from '../../services/workspace.api';
23
- import { GitContext, type GitContextValue } from '../../../git/state/git.context';
23
+ import { GitContext, type GitContextValue } from '../../../git';
24
24
  import {
25
25
  WorkspaceContext,
26
26
  type WorkspaceContextValue,
@@ -29,7 +29,8 @@ import {
29
29
  } from '../../state/workspace.context';
30
30
  import { makeWorkspaceFixture } from '../../__tests__/testFixtures';
31
31
  import { ReviewContext, type ReviewContextValue } from '../../../review/state/review.context';
32
- import { AuthContext, type AuthContextValue } from '../../../auth/state/auth.context';
32
+ import { AuthContext, type AuthContextValue } from '../../../auth';
33
+ import { AppRegistryContext, makeRegistry, type AppDef } from '../../../../core/registry';
33
34
 
34
35
  function makeStatus(branch = 'alice/draft'): WorkingTreeStatus {
35
36
  return { branch, hasUpstream: true, unmergedFromUpstream: false };
@@ -145,6 +146,8 @@ function renderAt(
145
146
  canonicalize?: boolean;
146
147
  /** Router state on the first entry, as a navigation would have left it. */
147
148
  state?: unknown;
149
+ /** Apps in the registry — the ones whose `roots` claim top-level folders. */
150
+ apps?: AppDef[];
148
151
  } = {},
149
152
  ): {
150
153
  workspace: WorkspaceContextValue;
@@ -189,8 +192,10 @@ function renderAt(
189
192
  logout: () => {},
190
193
  };
191
194
 
195
+ const registry = makeRegistry({ apps: opts.apps ?? [] });
192
196
  function Tree({ children }: { children: ReactNode }) {
193
197
  return (
198
+ <AppRegistryContext.Provider value={registry}>
194
199
  <AuthContext.Provider value={auth}>
195
200
  <WorkspaceContext.Provider value={workspace}>
196
201
  <GitContext.Provider value={git}>
@@ -200,6 +205,7 @@ function renderAt(
200
205
  </GitContext.Provider>
201
206
  </WorkspaceContext.Provider>
202
207
  </AuthContext.Provider>
208
+ </AppRegistryContext.Provider>
203
209
  );
204
210
  }
205
211
 
@@ -288,6 +294,48 @@ describe('FileRoute: the canonical id URL', () => {
288
294
  });
289
295
  });
290
296
 
297
+ /**
298
+ * A file under a root an app claims opens in that app by its PATH URL, so the
299
+ * route never trades it for the id URL, and an id URL that resolves to one is
300
+ * traded for the path URL instead.
301
+ */
302
+ describe('FileRoute: a file under a claimed root', () => {
303
+ const PATH = 'knowledge-base/Data/Tickets/T-1.md';
304
+ const apps: AppDef[] = [{ id: 'agents', label: 'Agents', path: '/agents', element: <div />, roots: ['Data'] }];
305
+ function openOn(): { workspace: WorkspaceContextValue; git: GitContextValue } {
306
+ const tab = makeTab({ path: PATH });
307
+ const workspace = makeWorkspace({
308
+ openTabs: [tab],
309
+ activeTab: tab,
310
+ hydrateTabs: vi.fn<WorkspaceContextValue['hydrateTabs']>(async () => makeHydrateResult({ surviving: [PATH] })),
311
+ });
312
+ return { workspace, git: makeGit({ status: makeStatus('main') }) };
313
+ }
314
+
315
+ it('keeps the path URL of an id-bearing file', async () => {
316
+ routesMock.fetchNodeId.mockResolvedValue('t-1');
317
+ renderAt(`/workspace/main/${PATH}`, { ...openOn(), apps });
318
+ await settle();
319
+ expect(screen.getByLabelText('pathname')).toHaveTextContent(`/workspace/main/${PATH}`);
320
+ expect(routesMock.fetchNodeId).not.toHaveBeenCalled();
321
+ });
322
+
323
+ it('replaces an id URL that resolves to it with its path URL, keeping the query', async () => {
324
+ routesMock.fetchNodeWorkspacePath.mockResolvedValue(PATH);
325
+ renderAt('/workspace/main/t-1?fullscreen=1', { ...openOn(), apps });
326
+ await waitFor(() =>
327
+ expect(screen.getByLabelText('pathname')).toHaveTextContent(`/workspace/main/${PATH}`),
328
+ );
329
+ expect(screen.getByLabelText('search')).toHaveTextContent('?fullscreen=1');
330
+ });
331
+
332
+ it('canonicalises as before when no app claims the root', async () => {
333
+ routesMock.fetchNodeId.mockResolvedValue('t-1');
334
+ renderAt(`/workspace/main/${PATH}`, openOn());
335
+ await waitFor(() => expect(screen.getByLabelText('pathname')).toHaveTextContent('/workspace/main/t-1'));
336
+ });
337
+ });
338
+
291
339
  describe('FileRoute', () => {
292
340
  it('hydrates tabs with the URL path when branch matches', async () => {
293
341
  const hydrateTabs = vi.fn<WorkspaceContextValue['hydrateTabs']>(
@@ -38,9 +38,9 @@ vi.mock('../../../access/api', () => ({
38
38
  // real endpoints. In these tests we just need the acquire to succeed so the
39
39
  // save flow can finish; lock contention paths are exercised in lock-specific
40
40
  // tests, not here.
41
- vi.mock('../../../workflow/services/lock.api', async (importOriginal) => ({
41
+ vi.mock('../../../version-control/services/lock.api', async (importOriginal) => ({
42
42
  // The sentences (SELF_HOLD_MESSAGE, EDITING_ENDED_MESSAGE) stay real.
43
- ...(await importOriginal<typeof import('../../../workflow/services/lock.api')>()),
43
+ ...(await importOriginal<typeof import('../../../version-control/services/lock.api')>()),
44
44
  acquireLock: vi.fn(async () => ({
45
45
  acquired: true,
46
46
  lock: {
@@ -108,8 +108,8 @@ vi.mock('../../../access/components/ManageAccessDialog', () => ({
108
108
  // `recordActivity`, which has no other visible effect (it resets a timer), so
109
109
  // there is no way to assert the scroll→lock wiring without a spy on it.
110
110
  const lockActivity = vi.hoisted(() => ({ recordActivity: vi.fn() }));
111
- vi.mock('../../../workflow/hooks/useFileLock', async (importOriginal) => {
112
- const actual = await importOriginal<typeof import('../../../workflow/hooks/useFileLock')>();
111
+ vi.mock('../../../version-control/hooks/useFileLock', async (importOriginal) => {
112
+ const actual = await importOriginal<typeof import('../../../version-control/hooks/useFileLock')>();
113
113
  const { useCallback } = await import('react');
114
114
  return {
115
115
  ...actual,
@@ -148,7 +148,7 @@ import {
148
148
  releaseLock as releaseLockMock,
149
149
  LockApiError,
150
150
  SELF_HOLD_MESSAGE,
151
- } from '../../../workflow/services/lock.api';
151
+ } from '../../../version-control/services/lock.api';
152
152
  import { WorkspaceContext, type WorkspaceContextValue } from '../../state/workspace.context';
153
153
  import { GitContext, type GitContextValue } from '../../../git/state/git.context';
154
154
  import { ReviewContext, type ReviewContextValue } from '../../../review/state/review.context';
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
2
  import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
3
- import type { WorkflowEvent } from '@bevel-software/platform-shared';
3
+ import type { VersionControlEvent } from '@bevel-software/platform-shared';
4
4
  import {
5
5
  WorkspaceContext,
6
6
  type WorkspaceContextValue,
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  EventBusContext,
10
10
  type EventBusContextValue,
11
- } from '../../../../workflow/state/event-bus.context';
11
+ } from '../../../../version-control/state/event-bus.context';
12
12
 
13
13
  const apiMock = vi.hoisted(() => ({ authFetch: vi.fn() }));
14
14
  vi.mock('../../../../../lib/api', () => ({ authFetch: apiMock.authFetch }));
@@ -75,9 +75,9 @@ describe('ImageRenderer', () => {
75
75
  * to.
76
76
  */
77
77
  it('refetches when an image in the workspace changes', async () => {
78
- const handlers: ((e: WorkflowEvent) => void)[] = [];
78
+ const handlers: ((e: VersionControlEvent) => void)[] = [];
79
79
  const bus = {
80
- subscribe: (_kind: string, handler: (e: WorkflowEvent) => void) => {
80
+ subscribe: (_kind: string, handler: (e: VersionControlEvent) => void) => {
81
81
  handlers.push(handler);
82
82
  return () => {};
83
83
  },
@@ -109,7 +109,7 @@ describe('ImageRenderer', () => {
109
109
  workspaceId: 'ws-1',
110
110
  branch: 'ws-1',
111
111
  path: 'Knowledge/assets/shot.png',
112
- } as unknown as WorkflowEvent),
112
+ } as unknown as VersionControlEvent),
113
113
  ),
114
114
  );
115
115
 
@@ -1,20 +1,20 @@
1
1
  import { describe, it, expect } from 'vitest';
2
2
  import { act, renderHook } from '@testing-library/react';
3
3
  import type { ReactNode } from 'react';
4
- import type { WorkflowEvent } from '@bevel-software/platform-shared';
5
- import { EventBusContext, type EventBusContextValue } from '../../../workflow/state/event-bus.context';
4
+ import type { VersionControlEvent } from '@bevel-software/platform-shared';
5
+ import { EventBusContext, type EventBusContextValue } from '../../../version-control/state/event-bus.context';
6
6
  import { useImageRevision, isImagePath } from '../useImageRevision';
7
7
 
8
8
  function makeFakeBus() {
9
- const handlers: Record<string, ((e: WorkflowEvent) => void)[]> = {};
9
+ const handlers: Record<string, ((e: VersionControlEvent) => void)[]> = {};
10
10
  // The workspaces the hook has ASKED to be delivered. Without a watch the
11
11
  // real stream sends nothing for a workspace the session isn't focused on,
12
12
  // so "did it subscribe" and "will anything arrive" are separate facts and
13
13
  // the fake tracks both.
14
14
  const watched: string[] = [];
15
- const bus: EventBusContextValue & { emit(e: WorkflowEvent): void; watched: string[] } = {
15
+ const bus: EventBusContextValue & { emit(e: VersionControlEvent): void; watched: string[] } = {
16
16
  subscribe(kind, handler) {
17
- (handlers[kind] ??= []).push(handler as (e: WorkflowEvent) => void);
17
+ (handlers[kind] ??= []).push(handler as (e: VersionControlEvent) => void);
18
18
  return () => {
19
19
  handlers[kind] = (handlers[kind] ?? []).filter((h) => h !== handler);
20
20
  };
@@ -35,18 +35,18 @@ function makeFakeBus() {
35
35
  return bus;
36
36
  }
37
37
 
38
- function fileChanged(workspaceId: string, path: string): WorkflowEvent {
38
+ function fileChanged(workspaceId: string, path: string): VersionControlEvent {
39
39
  return {
40
40
  kind: 'file-changed',
41
41
  workspaceId,
42
42
  branch: workspaceId,
43
43
  path,
44
44
  newSha: 'abc123',
45
- } as unknown as WorkflowEvent;
45
+ } as unknown as VersionControlEvent;
46
46
  }
47
47
 
48
- function treeChanged(workspaceId: string): WorkflowEvent {
49
- return { kind: 'fs-tree-changed', workspaceId, branch: workspaceId } as unknown as WorkflowEvent;
48
+ function treeChanged(workspaceId: string): VersionControlEvent {
49
+ return { kind: 'fs-tree-changed', workspaceId, branch: workspaceId } as unknown as VersionControlEvent;
50
50
  }
51
51
 
52
52
  function renderRevision(bus: ReturnType<typeof makeFakeBus>, workspaceId: string | null) {
@@ -1,18 +1,18 @@
1
1
  import { describe, it, expect } from 'vitest';
2
2
  import { act, renderHook } from '@testing-library/react';
3
3
  import type { ReactNode } from 'react';
4
- import type { WorkflowEvent } from '@bevel-software/platform-shared';
5
- import { EventBusContext, type EventBusContextValue } from '../../../workflow/state/event-bus.context';
4
+ import type { VersionControlEvent } from '@bevel-software/platform-shared';
5
+ import { EventBusContext, type EventBusContextValue } from '../../../version-control/state/event-bus.context';
6
6
  import { WorkspaceContext } from '../../state/workspace.context';
7
7
  import { makeWorkspaceFixture } from '../../__tests__/testFixtures';
8
8
  import { useWorkspaceImageResolver } from '../useWorkspaceImageResolver';
9
9
 
10
10
  function makeFakeBus() {
11
- const handlers: Record<string, ((e: WorkflowEvent) => void)[]> = {};
11
+ const handlers: Record<string, ((e: VersionControlEvent) => void)[]> = {};
12
12
  const watched: string[] = [];
13
- const bus: EventBusContextValue & { emit(e: WorkflowEvent): void; watched: string[] } = {
13
+ const bus: EventBusContextValue & { emit(e: VersionControlEvent): void; watched: string[] } = {
14
14
  subscribe(kind, handler) {
15
- (handlers[kind] ??= []).push(handler as (e: WorkflowEvent) => void);
15
+ (handlers[kind] ??= []).push(handler as (e: VersionControlEvent) => void);
16
16
  return () => {
17
17
  handlers[kind] = (handlers[kind] ?? []).filter((h) => h !== handler);
18
18
  };
@@ -33,14 +33,14 @@ function makeFakeBus() {
33
33
  return bus;
34
34
  }
35
35
 
36
- function imageChanged(workspaceId: string, path: string): WorkflowEvent {
36
+ function imageChanged(workspaceId: string, path: string): VersionControlEvent {
37
37
  return {
38
38
  kind: 'file-changed',
39
39
  workspaceId,
40
40
  branch: workspaceId,
41
41
  path,
42
42
  newSha: 'abc123',
43
- } as unknown as WorkflowEvent;
43
+ } as unknown as VersionControlEvent;
44
44
  }
45
45
 
46
46
  function renderResolver(
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { useEventBus, canonicalizeWorkspaceId } from '../../workflow';
2
+ import { useEventBus, canonicalizeWorkspaceId } from '../../version-control';
3
3
 
4
4
  /**
5
5
  * The extensions the raw file route serves as pictures, which is what a
@@ -5,7 +5,7 @@ import {
5
5
  isProtectedBranch,
6
6
  type FileTreeEntry,
7
7
  } from '@bevel-software/platform-shared';
8
- import { useEventBus, canonicalizeWorkspaceId } from '../../workflow';
8
+ import { useEventBus, canonicalizeWorkspaceId } from '../../version-control';
9
9
  import { AuthContext } from '../../auth';
10
10
  import { fetchFileAccess } from '../../access';
11
11
  import {
@@ -1578,7 +1578,7 @@ export function useWorkspaceState(): UseWorkspaceStateReturn {
1578
1578
 
1579
1579
  // ── Live updates: react to other users' / agent's edits ───────────────────
1580
1580
  //
1581
- // When the backend's lock-release commits + pushes a file, the workflow
1581
+ // When the backend's lock-release commits + pushes a file, the version-control service
1582
1582
  // event bus pushes a `file-changed` event to every session focused on
1583
1583
  // this workspace+branch. We:
1584
1584
  //
@@ -3,8 +3,8 @@ import { renderHook, waitFor, act } from '@testing-library/react';
3
3
  import type { ReactNode } from 'react';
4
4
  import type {
5
5
  PullRequestSummary,
6
- WorkflowEvent,
7
- WorkflowEventPayload,
6
+ VersionControlEvent,
7
+ VersionControlEventPayload,
8
8
  } from '@bevel-software/platform-shared';
9
9
 
10
10
  const api = vi.hoisted(() => ({
@@ -20,11 +20,11 @@ vi.mock('../../../change-requests/services/change-requests.api', () => ({
20
20
  import { OpenChangeRequestsProvider } from '../open-change-requests';
21
21
  import { useOpenChangeRequests } from '../../hooks/useOpenChangeRequests';
22
22
  import { WorkspaceContext, type WorkspaceContextValue } from '../workspace.context';
23
- import { ChangeRequestStaleBinder } from '../../../workflow/state/ChangeRequestStaleBinder';
23
+ import { ChangeRequestStaleBinder } from '../../../version-control/state/ChangeRequestStaleBinder';
24
24
  import {
25
25
  EventBusContext,
26
26
  type EventBusContextValue,
27
- } from '../../../workflow/state/event-bus.context';
27
+ } from '../../../version-control/state/event-bus.context';
28
28
  import { PR_STALE_COALESCE_MS, PR_STALE_FALLBACK_MS } from '../../../../core/events';
29
29
 
30
30
  /**
@@ -67,20 +67,20 @@ function pr(over: Partial<PullRequestSummary> = {}): PullRequestSummary {
67
67
  }
68
68
 
69
69
  function fakeBus() {
70
- const handlers = new Map<string, Set<(e: WorkflowEvent) => void>>();
70
+ const handlers = new Map<string, Set<(e: VersionControlEvent) => void>>();
71
71
  const value: EventBusContextValue = {
72
72
  subscribe: (kind, handler) => {
73
73
  const set = handlers.get(kind) ?? new Set();
74
- set.add(handler as (e: WorkflowEvent) => void);
74
+ set.add(handler as (e: VersionControlEvent) => void);
75
75
  handlers.set(kind, set);
76
- return () => set.delete(handler as (e: WorkflowEvent) => void);
76
+ return () => set.delete(handler as (e: VersionControlEvent) => void);
77
77
  },
78
78
  setFocus: () => {},
79
79
  watchWorkspace: () => () => {},
80
80
  };
81
- const emit = (event: WorkflowEventPayload) => {
81
+ const emit = (event: VersionControlEventPayload) => {
82
82
  for (const h of handlers.get(event.kind) ?? []) {
83
- h({ id: 1, ts: new Date().toISOString(), ...event } as WorkflowEvent);
83
+ h({ id: 1, ts: new Date().toISOString(), ...event } as VersionControlEvent);
84
84
  }
85
85
  };
86
86
  return { value, emit };
@@ -247,7 +247,7 @@ describe('suggestedPages', () => {
247
247
  dir('knowledge-base', [
248
248
  dir('knowledge-base/KnowledgeBase', [
249
249
  dir('knowledge-base/KnowledgeBase/Data', [page('knowledge-base/KnowledgeBase/Data/rows.md')]),
250
- dir('knowledge-base/KnowledgeBase/Pipelines', [page('knowledge-base/KnowledgeBase/Pipelines/run.md')]),
250
+ dir('knowledge-base/KnowledgeBase/Workflows', [page('knowledge-base/KnowledgeBase/Workflows/run.md')]),
251
251
  dir('knowledge-base/KnowledgeBase/Skills', [page('knowledge-base/KnowledgeBase/Skills/x.md')]),
252
252
  dir('knowledge-base/KnowledgeBase/Team', [page('knowledge-base/KnowledgeBase/Team/People.md')]),
253
253
  ]),
@@ -354,6 +354,14 @@ describe('treeHasVisibleEntries', () => {
354
354
  expect(treeHasVisibleEntries(d('.', [d('kb', [f('kb/a.md')])]), 'kb')).toBe(true);
355
355
  });
356
356
 
357
+ it('does not count a hidden root, nor anything in it', () => {
358
+ const claimed = (name: string) => name.toLowerCase() === 'agents';
359
+ expect(treeHasVisibleEntries(kb(d('kb/Agents', [f('kb/Agents/a.md')])), 'kb', claimed)).toBe(false);
360
+ expect(treeHasVisibleEntries(d('.', [d('kb', [d('kb/Agents', [f('kb/Agents/a.md')])])]), 'kb', claimed)).toBe(false);
361
+ expect(treeHasVisibleEntries(kb(d('kb/Agents', [f('kb/Agents/a.md')]), d('kb/Legal')), 'kb', claimed)).toBe(true);
362
+ expect(treeHasVisibleEntries(kb(d('kb/Agents', [f('kb/Agents/a.md')])), 'kb')).toBe(true);
363
+ });
364
+
357
365
  it('counts nothing outside the checkout, and nothing when there is no checkout', () => {
358
366
  const strays = [d('KnowledgeBase', [f('KnowledgeBase/Planted.md')]), f('Stray.docx')];
359
367
  expect(treeHasVisibleEntries(d('.', [...strays, d('kb', [d('kb/KnowledgeBase')])]), 'kb')).toBe(false);
@@ -10,7 +10,7 @@ import { isAccessRulesFile as isAccessRulesPath } from './display-file-name';
10
10
  // RESERVED is not the same as CREATED (see kb-layout.ts): core only seeds
11
11
  // KnowledgeBase/, Skills/ and Plugins/, but every reserved name renders as its
12
12
  // own root when present — a distribution that owns the execution layer seeds
13
- // Data/, Agents/ and Pipelines/, and a KB that has them must not see them
13
+ // Data/, Agents/ and Workflows/, and a KB that has them must not see them
14
14
  // folded into Knowledge as stray content. A function, not a module-scope set:
15
15
  // three of the names are configurable and arrive after this module loads.
16
16
  export const KB_ROOT_DIRS = {
@@ -54,12 +54,20 @@ export function checkoutRoot(
54
54
  *
55
55
  * Read from the checkout down, like every other surface. A workspace whose
56
56
  * checkout is missing shows nothing, whatever else was written beside it.
57
+ *
58
+ * `hiddenRoot` names the top-level folders the tree does not show (the roots
59
+ * an app claims, `AppDef.roots`): nothing in them is on screen here.
57
60
  */
58
- export function treeHasVisibleEntries(tree: FileTreeEntry | null, kbDirName: string | null): boolean {
61
+ export function treeHasVisibleEntries(
62
+ tree: FileTreeEntry | null,
63
+ kbDirName: string | null,
64
+ hiddenRoot: (name: string) => boolean = () => false,
65
+ ): boolean {
59
66
  const kbRoot = checkoutRoot(tree, kbDirName);
60
67
  if (!kbRoot) return false;
61
68
  return (kbRoot.children ?? []).some((c) => {
62
69
  if (c.type === 'file') return c.name !== '.bevelignore';
70
+ if (hiddenRoot(c.name)) return false;
63
71
  return !KB_ROOT_DIRS.has(c.name) || (c.children?.length ?? 0) > 0;
64
72
  });
65
73
  }
@@ -290,7 +290,7 @@ export function accessChangeOf(access: ProspectiveAccess): AccessChange {
290
290
  * nothing — the dialog never blocks on it, and the server stays the gate.
291
291
  * A move into a folder the caller may not write is REFUSED today: the move
292
292
  * route acquires the write lock on both ends, and the lock gate throws
293
- * AccessDeniedError on a protected branch (`WorkflowService.acquireLock`).
293
+ * AccessDeniedError on a protected branch (`VersionControlService.acquireLock`).
294
294
  * Only uploads are rerouted to a suggestion; a move is not.
295
295
  */
296
296
  export function moveWarnings(opts: {