@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.
- package/package.json +2 -2
- package/src/core/CoreAppShell.tsx +40 -97
- package/src/core/KnowledgeSurface.tsx +92 -0
- package/src/core/__tests__/CoreAppShell.root-claims.test.tsx +280 -0
- package/src/core/registry.ts +110 -2
- package/src/index.ts +3 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +1 -1
- package/src/modules/access/api.ts +24 -4
- package/src/modules/access/hooks/useFileAccess.ts +1 -1
- package/src/modules/access/index.ts +1 -1
- package/src/modules/admin/index.ts +1 -1
- package/src/modules/agents/components/ConnectAsChoice.tsx +7 -0
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +4 -3
- package/src/modules/audit/components/AuditLogPage.tsx +6 -4
- package/src/modules/audit/components/principal-grouping.ts +49 -49
- package/src/modules/auth/index.ts +1 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +1 -1
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +6 -6
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +8 -8
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +1 -1
- package/src/modules/git/__tests__/pr.api.test.ts +3 -3
- package/src/modules/git/components/FileHistoryPanel.tsx +1 -1
- package/src/modules/git/components/GitSyncFailedBanner.tsx +1 -1
- package/src/modules/git/services/git.api.ts +1 -1
- package/src/modules/git/services/pr-prompts.ts +1 -1
- package/src/modules/layout/state/layout.context.ts +8 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +5 -5
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +11 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +160 -5
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +103 -28
- package/src/modules/library/services/library.api.ts +2 -2
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +8 -8
- package/src/modules/onboarding/state/agent-connection.ts +1 -1
- package/src/modules/pr/services/pr-merge.api.ts +1 -1
- package/src/modules/pr/services/pr-open.api.ts +1 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +96 -30
- package/src/modules/secrets-vault/components/IncludeToggle.tsx +29 -0
- package/src/modules/secrets-vault/components/ManagedConnectorCard.tsx +189 -0
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.managed.test.tsx +212 -0
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +10 -0
- package/src/modules/secrets-vault/components/__tests__/ManagedConnectorCard.test.tsx +182 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +3 -0
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +1 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +1 -0
- package/src/modules/secrets-vault/index.ts +2 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +1 -0
- package/src/modules/secrets-vault/services/connect.api.ts +46 -5
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +21 -3
- package/src/modules/secrets-vault/utils/managed-card-state.ts +61 -0
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +5 -1
- package/src/modules/setup/utils/root-folders.ts +2 -2
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +8 -1
- package/src/modules/toolbar/components/Toolbar.tsx +1 -1
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +39 -13
- package/src/modules/{workflow → version-control}/hooks/__tests__/useFileLock.test.tsx +10 -10
- package/src/modules/{workflow → version-control}/hooks/__tests__/useFileLock.wire.test.tsx +1 -1
- package/src/modules/{workflow → version-control}/hooks/useEventBusSubscription.ts +2 -2
- package/src/modules/{workflow → version-control}/hooks/useFileLock.ts +1 -1
- package/src/modules/{workflow → version-control}/index.ts +2 -2
- package/src/modules/{workflow → version-control}/services/__tests__/lock.api.test.ts +1 -1
- package/src/modules/{workflow → version-control}/state/EventBusProvider.tsx +6 -6
- package/src/modules/{workflow → version-control}/state/event-bus.context.ts +4 -4
- package/src/modules/workspace/components/FileExplorer.tsx +96 -41
- package/src/modules/workspace/components/FileRoute.tsx +24 -1
- package/src/modules/workspace/components/FileViewer.tsx +2 -2
- package/src/modules/workspace/components/KbPageHeader.tsx +1 -1
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +191 -21
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +50 -2
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +5 -5
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +5 -5
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +9 -9
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +7 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +1 -1
- package/src/modules/workspace/hooks/useWorkspaceState.ts +2 -2
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +9 -9
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +9 -1
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +32 -48
- package/src/modules/workspace/utils/fileTree.ts +10 -2
- package/src/modules/workspace/utils/treeConfirm.ts +25 -29
- /package/src/modules/{workflow → version-control}/services/lock.api.ts +0 -0
- /package/src/modules/{workflow → version-control}/state/ChangeRequestStaleBinder.tsx +0 -0
- /package/src/modules/{workflow → version-control}/state/EventBusFocusBinder.tsx +0 -0
- /package/src/modules/{workflow → version-control}/state/__tests__/EventBusProvider.storage.test.tsx +0 -0
- /package/src/modules/{workflow → version-control}/state/__tests__/EventBusProvider.watch.test.tsx +0 -0
|
@@ -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
|
-
//
|
|
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 {
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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 {
|
|
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<
|
|
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:
|
|
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<
|
|
140
|
+
bucket.add(handler as unknown as EventHandler<VersionControlEvent['kind']>);
|
|
141
141
|
return () => {
|
|
142
|
-
bucket?.delete(handler as unknown as EventHandler<
|
|
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
|
|
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 {
|
|
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
|
|
11
|
-
event: Extract<
|
|
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
|
|
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
|
}
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
PLUGINS_DIR,
|
|
37
37
|
SKILLS_DIR,
|
|
38
38
|
AGENTS_DIR,
|
|
39
|
-
|
|
39
|
+
WORKFLOWS_DIR,
|
|
40
40
|
} from '@bevel-software/platform-shared';
|
|
41
41
|
import {
|
|
42
42
|
KNOWLEDGE_UPLOAD_TARGET,
|
|
@@ -57,7 +57,7 @@ import { uploadErrorNextStep } from '../utils/uploadError';
|
|
|
57
57
|
import { useMergedWorkspaceTree } from '../hooks/useMergedWorkspaceTree';
|
|
58
58
|
import { ChangeRequestDialog } from '../../change-requests/components/ChangeRequestDialog';
|
|
59
59
|
import { PR_STALE_EVENT, SUGGESTIONS_RETRACTED_EVENT } from '../../../core/events';
|
|
60
|
-
import { canonicalizeWorkspaceId, useEventBusSubscription } from '../../
|
|
60
|
+
import { canonicalizeWorkspaceId, useEventBusSubscription } from '../../version-control';
|
|
61
61
|
import {
|
|
62
62
|
listChangeRequestsUnderFolder,
|
|
63
63
|
removeFolderFromChangeRequests,
|
|
@@ -76,7 +76,10 @@ import { AdminContext } from '../../admin';
|
|
|
76
76
|
import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
|
|
77
77
|
import { offersManageAccess, fetchFileAccess, fetchProspectiveAccess } from '../../access';
|
|
78
78
|
import {
|
|
79
|
+
appClaimingRoot,
|
|
80
|
+
appHostingPath,
|
|
79
81
|
useAppRegistry,
|
|
82
|
+
useRootClaims,
|
|
80
83
|
type FolderMenuContext,
|
|
81
84
|
type FolderMenuItemDef,
|
|
82
85
|
type FolderMenuTools,
|
|
@@ -2232,13 +2235,18 @@ export const CHECKOUT_MISSING_MESSAGE = 'Nothing to show here: the repository ch
|
|
|
2232
2235
|
* reserved roots aside, an entry anywhere counts, because a stray top-level
|
|
2233
2236
|
* folder is folded into Knowledge). A Library tree shows one root
|
|
2234
2237
|
* (`scope: 'root'`): it is empty when that root is, whatever the notes
|
|
2235
|
-
* beside it hold.
|
|
2238
|
+
* beside it hold. A root an app claims is not in Knowledge's tree, so what
|
|
2239
|
+
* it holds does not count there either.
|
|
2236
2240
|
*/
|
|
2237
2241
|
export function EmptyTreeNotice({ rootPath, scope = 'tree' }: { rootPath: string | null; scope?: 'tree' | 'root' }) {
|
|
2238
2242
|
const { kbDirName } = useWorkspace();
|
|
2239
2243
|
const { tree, withheld: listingWithheld } = useMergedWorkspaceTree();
|
|
2244
|
+
const claims = useRootClaims();
|
|
2240
2245
|
const oneRoot = scope === 'root' && rootPath !== null;
|
|
2241
|
-
const
|
|
2246
|
+
const claimed = (name: string) => appClaimingRoot(claims, name) !== undefined;
|
|
2247
|
+
const empty =
|
|
2248
|
+
tree !== null &&
|
|
2249
|
+
(oneRoot ? !subtreeHasVisibleEntries(tree, rootPath) : !treeHasVisibleEntries(tree, kbDirName, claimed));
|
|
2242
2250
|
// What was kept out of what THIS notice covers: one root's own count, or
|
|
2243
2251
|
// the listing's — a Skills tree emptied by the rules says so; a Skills tree
|
|
2244
2252
|
// that is simply empty beside a withheld Knowledge does not.
|
|
@@ -2384,8 +2392,15 @@ export function UploadNotices() {
|
|
|
2384
2392
|
// (`checkoutRoot` lives in `../utils/fileTree` — the one lookup every
|
|
2385
2393
|
// surface that reads the workspace tree goes through.)
|
|
2386
2394
|
|
|
2387
|
-
|
|
2395
|
+
/**
|
|
2396
|
+
* The Knowledge app's file tree. With `roots`, the tree of the folder surface
|
|
2397
|
+
* an app mounts for the roots it claims (see `AppDef.roots`): those
|
|
2398
|
+
* top-level folders as sections, in that order, and nothing else of the
|
|
2399
|
+
* knowledge base. Without it, every root no app claims.
|
|
2400
|
+
*/
|
|
2401
|
+
export function FileExplorer({ roots }: { roots?: readonly string[] } = {}) {
|
|
2388
2402
|
const { openFilePath, dispatchUpload, kbDirName } = useWorkspace();
|
|
2403
|
+
const claims = useRootClaims();
|
|
2389
2404
|
const { openFile } = useFileNav();
|
|
2390
2405
|
const [dragOver, setDragOver] = useState(false);
|
|
2391
2406
|
// Download is a per-path permission (resolved server-side from the access
|
|
@@ -2429,14 +2444,25 @@ export function FileExplorer() {
|
|
|
2429
2444
|
// Resolved from the CHECKOUT, not the workspace root, for the same reason
|
|
2430
2445
|
// the sections are: a pin is a shortcut into the repository, and a path
|
|
2431
2446
|
// that lands beside it resolves to nothing rather than to a row.
|
|
2447
|
+
//
|
|
2448
|
+
// A pin into a root this tree does not show is not on it either: Knowledge
|
|
2449
|
+
// leaves the claimed roots to their app, a narrowed tree shows its own.
|
|
2450
|
+
const showsPath = useCallback(
|
|
2451
|
+
(path: string) => {
|
|
2452
|
+
const root = path.split('/').filter(Boolean)[1]?.toLowerCase();
|
|
2453
|
+
if (!roots) return appHostingPath(claims, path, kbDirName) === undefined;
|
|
2454
|
+
return root !== undefined && roots.some((r) => r.toLowerCase() === root);
|
|
2455
|
+
},
|
|
2456
|
+
[roots, claims, kbDirName],
|
|
2457
|
+
);
|
|
2432
2458
|
const pinnedEntries = useMemo(
|
|
2433
2459
|
() =>
|
|
2434
2460
|
checkout
|
|
2435
2461
|
? pinnedPaths
|
|
2436
2462
|
.map((p) => findEntryByPath(checkout, p))
|
|
2437
|
-
.filter((e): e is FileTreeEntry => e != null)
|
|
2463
|
+
.filter((e): e is FileTreeEntry => e != null && showsPath(e.relativePath))
|
|
2438
2464
|
: [],
|
|
2439
|
-
[checkout, pinnedPaths],
|
|
2465
|
+
[checkout, pinnedPaths, showsPath],
|
|
2440
2466
|
);
|
|
2441
2467
|
|
|
2442
2468
|
// Registry-contributed rows for the Pinned section (rendered below the
|
|
@@ -2464,18 +2490,34 @@ export function FileExplorer() {
|
|
|
2464
2490
|
// own tree (`SkillsTree`), with these same rows, and a skill file opens on
|
|
2465
2491
|
// its skill page there.
|
|
2466
2492
|
//
|
|
2467
|
-
// `Data/`, `Agents/` and `
|
|
2493
|
+
// `Data/`, `Agents/` and `Workflows/` are rendered when PRESENT but never
|
|
2468
2494
|
// created by core (see `CORE_REQUIRED_DIRS`) — a deployment that owns the
|
|
2469
2495
|
// agentic execution layer seeds them, and this reads whatever is there.
|
|
2496
|
+
//
|
|
2497
|
+
// A root an app claims (`AppDef.roots`) is that app's to show: it is left
|
|
2498
|
+
// out here, whether reserved or not, and folds nowhere. A narrowed tree
|
|
2499
|
+
// (`roots`) is the other side of the same claim: its roots, nothing else.
|
|
2470
2500
|
const sections = useMemo(() => {
|
|
2471
2501
|
const kids = checkout?.children;
|
|
2472
2502
|
if (!kids) return null;
|
|
2473
2503
|
const findDir = (name: string) =>
|
|
2474
2504
|
kids.find((c) => c.type === 'directory' && c.name === name);
|
|
2505
|
+
const asSection = (name: string): FileTreeEntry | null => {
|
|
2506
|
+
const found = findDir(name);
|
|
2507
|
+
return found ? { ...found, name } : null;
|
|
2508
|
+
};
|
|
2509
|
+
if (roots) {
|
|
2510
|
+
// By name in any case, as a claim is read (see `rootClaims`).
|
|
2511
|
+
const narrowed = roots
|
|
2512
|
+
.map((name) => kids.find((c) => c.type === 'directory' && c.name.toLowerCase() === name.toLowerCase()))
|
|
2513
|
+
.filter((e): e is FileTreeEntry => e !== undefined);
|
|
2514
|
+
return { knowledge: null, roots: narrowed, looseFiles: [] };
|
|
2515
|
+
}
|
|
2516
|
+
const claimed = (name: string) => appClaimingRoot(claims, name) !== undefined;
|
|
2475
2517
|
const knowledgeBase = findDir(KNOWLEDGE_BASE_DIR);
|
|
2476
2518
|
const data = findDir(DATA_DIR);
|
|
2477
2519
|
const agents = findDir(AGENTS_DIR);
|
|
2478
|
-
const
|
|
2520
|
+
const workflows = findDir(WORKFLOWS_DIR);
|
|
2479
2521
|
// Plugins counts toward "is this a split layout?" even though it is never
|
|
2480
2522
|
// rendered: its presence proves the split just as well as the others, and
|
|
2481
2523
|
// without it a KB whose only root is Plugins would fail this check, fall
|
|
@@ -2483,12 +2525,13 @@ export function FileExplorer() {
|
|
|
2483
2525
|
const plugins = findDir(PLUGINS_DIR);
|
|
2484
2526
|
// Same for Skills: the Library surface renders it, not this explorer.
|
|
2485
2527
|
const skills = findDir(SKILLS_DIR);
|
|
2486
|
-
if (!knowledgeBase && !data && !agents && !
|
|
2487
|
-
// Any other top-level content folder (e.g. a stray `Legal/`) folds into
|
|
2528
|
+
if (!knowledgeBase && !data && !agents && !workflows && !plugins && !skills) return null;
|
|
2529
|
+
// Any other top-level content folder (e.g. a stray `Legal/`) folds into
|
|
2530
|
+
// Knowledge, unless an app claims it.
|
|
2488
2531
|
const otherDirs = kids.filter(
|
|
2489
|
-
(c) => c.type === 'directory' && !KB_ROOT_DIRS.has(c.name),
|
|
2532
|
+
(c) => c.type === 'directory' && !KB_ROOT_DIRS.has(c.name) && !claimed(c.name),
|
|
2490
2533
|
);
|
|
2491
|
-
// Present Knowledge, Data, Agents and
|
|
2534
|
+
// Present Knowledge, Data, Agents and Workflows as named roots. Knowledge is
|
|
2492
2535
|
// synthetic so it can relabel `KnowledgeBase` and absorb the stray
|
|
2493
2536
|
// content folders; it reuses KnowledgeBase's own path so file ops on the
|
|
2494
2537
|
// row still resolve.
|
|
@@ -2501,19 +2544,31 @@ export function FileExplorer() {
|
|
|
2501
2544
|
: otherDirs.length > 0
|
|
2502
2545
|
? { name: 'Knowledge', relativePath: otherDirs[0].relativePath, type: 'directory', children: otherDirs }
|
|
2503
2546
|
: null;
|
|
2504
|
-
const dataRoot: FileTreeEntry | null = data ? { ...data, name: DATA_DIR } : null;
|
|
2505
|
-
const agentsRoot: FileTreeEntry | null = agents ? { ...agents, name: AGENTS_DIR } : null;
|
|
2506
|
-
const pipelinesRoot: FileTreeEntry | null = pipelines
|
|
2507
|
-
? { ...pipelines, name: PIPELINES_DIR }
|
|
2508
|
-
: null;
|
|
2509
2547
|
return {
|
|
2510
2548
|
knowledge,
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2549
|
+
roots: [DATA_DIR, AGENTS_DIR, WORKFLOWS_DIR]
|
|
2550
|
+
.filter((name) => !claimed(name))
|
|
2551
|
+
.map(asSection)
|
|
2552
|
+
.filter((e): e is FileTreeEntry => e !== null),
|
|
2514
2553
|
looseFiles: kids.filter((c) => c.type === 'file'),
|
|
2515
2554
|
};
|
|
2516
|
-
}, [checkout]);
|
|
2555
|
+
}, [checkout, roots, claims]);
|
|
2556
|
+
|
|
2557
|
+
// The flat tree of a clone that predates the split, less the roots an app
|
|
2558
|
+
// claims: still the checkout row, with its own path and actions, so a
|
|
2559
|
+
// claim never makes another folder stand in for it.
|
|
2560
|
+
const flatRoot = useMemo(
|
|
2561
|
+
() =>
|
|
2562
|
+
checkout && claims.size > 0
|
|
2563
|
+
? {
|
|
2564
|
+
...checkout,
|
|
2565
|
+
children: checkout.children?.filter(
|
|
2566
|
+
(c) => c.type !== 'directory' || appClaimingRoot(claims, c.name) === undefined,
|
|
2567
|
+
),
|
|
2568
|
+
}
|
|
2569
|
+
: checkout,
|
|
2570
|
+
[checkout, claims],
|
|
2571
|
+
);
|
|
2517
2572
|
|
|
2518
2573
|
const handleDrop = useCallback(
|
|
2519
2574
|
(e: React.DragEvent) => {
|
|
@@ -2522,7 +2577,11 @@ export function FileExplorer() {
|
|
|
2522
2577
|
// target — the workspace root, beside the missing folder, where
|
|
2523
2578
|
// nothing this sidebar shows can ever live. Refused before
|
|
2524
2579
|
// `preventDefault`, so the browser's own cursor says "not here".
|
|
2525
|
-
|
|
2580
|
+
//
|
|
2581
|
+
// A narrowed tree has no background folder either: the checkout is not
|
|
2582
|
+
// one of its roots, and a file dropped there would land out of sight.
|
|
2583
|
+
// Its folders' own rows take drops as they do in Knowledge.
|
|
2584
|
+
if (!checkout || roots) return;
|
|
2526
2585
|
e.preventDefault();
|
|
2527
2586
|
setDragOver(false);
|
|
2528
2587
|
// Only handle external file/folder drops at the root level.
|
|
@@ -2539,7 +2598,7 @@ export function FileExplorer() {
|
|
|
2539
2598
|
const files = Array.from(e.dataTransfer.files);
|
|
2540
2599
|
if (files.length > 0) dispatchUpload({ kind: 'files', files }, target, KNOWLEDGE_UPLOAD_TARGET);
|
|
2541
2600
|
},
|
|
2542
|
-
[checkout, dispatchUpload],
|
|
2601
|
+
[checkout, roots, dispatchUpload],
|
|
2543
2602
|
);
|
|
2544
2603
|
|
|
2545
2604
|
return (
|
|
@@ -2561,7 +2620,7 @@ export function FileExplorer() {
|
|
|
2561
2620
|
onDragOver={(e) => {
|
|
2562
2621
|
// Same refusal as the drop: no checkout, no drop target, so no
|
|
2563
2622
|
// highlight promising one.
|
|
2564
|
-
if (!checkout) return;
|
|
2623
|
+
if (!checkout || roots) return;
|
|
2565
2624
|
e.preventDefault();
|
|
2566
2625
|
setDragOver(true);
|
|
2567
2626
|
}}
|
|
@@ -2583,9 +2642,9 @@ export function FileExplorer() {
|
|
|
2583
2642
|
{pinnedEntries.map((e) => (
|
|
2584
2643
|
<FileTreeNode key={`pin:${e.relativePath}`} entry={e} depth={0} collapseChildren />
|
|
2585
2644
|
))}
|
|
2586
|
-
{
|
|
2587
|
-
|
|
2588
|
-
|
|
2645
|
+
{/* Knowledge's own rows (the graph view): not part of a narrowed tree. */}
|
|
2646
|
+
{!roots &&
|
|
2647
|
+
explorerItems.map(({ id, Component }) => <Component key={id} tree={mergedTree} />)}
|
|
2589
2648
|
<div className="mx-3 my-2 border-t border-line" />
|
|
2590
2649
|
{!mergedTree ? (
|
|
2591
2650
|
<div className="px-3 py-4 text-xs text-ink-muted">Loading...</div>
|
|
@@ -2598,15 +2657,9 @@ export function FileExplorer() {
|
|
|
2598
2657
|
{sections.knowledge && (
|
|
2599
2658
|
<FileTreeNode entry={sections.knowledge} depth={0} collapseChildren />
|
|
2600
2659
|
)}
|
|
2601
|
-
{sections.
|
|
2602
|
-
<FileTreeNode
|
|
2603
|
-
)}
|
|
2604
|
-
{sections.agents && (
|
|
2605
|
-
<FileTreeNode entry={sections.agents} depth={0} collapseChildren />
|
|
2606
|
-
)}
|
|
2607
|
-
{sections.pipelines && (
|
|
2608
|
-
<FileTreeNode entry={sections.pipelines} depth={0} collapseChildren />
|
|
2609
|
-
)}
|
|
2660
|
+
{sections.roots.map((root) => (
|
|
2661
|
+
<FileTreeNode key={root.relativePath} entry={root} depth={0} collapseChildren />
|
|
2662
|
+
))}
|
|
2610
2663
|
{sections.looseFiles.length > 0 && (
|
|
2611
2664
|
<>
|
|
2612
2665
|
<div className="mx-3 my-2 border-t border-line" />
|
|
@@ -2622,7 +2675,7 @@ export function FileExplorer() {
|
|
|
2622
2675
|
// fallback is a different SHAPE, never a different directory — and
|
|
2623
2676
|
// it is the ROOT row, not a folder inside one: the workspace
|
|
2624
2677
|
// directory above it is not something this explorer shows.
|
|
2625
|
-
<FileTreeNode entry={checkout} depth={0} root />
|
|
2678
|
+
<FileTreeNode entry={flatRoot ?? checkout} depth={0} root />
|
|
2626
2679
|
)}
|
|
2627
2680
|
{/* Under the (empty) roots, so the hint's "folder above" is on
|
|
2628
2681
|
screen: Knowledge's own folder is where a first page goes. A tree
|
|
@@ -2630,9 +2683,11 @@ export function FileExplorer() {
|
|
|
2630
2683
|
folder itself is where a first page goes — and when there is no
|
|
2631
2684
|
checkout at all the notice says THAT instead, and there is no
|
|
2632
2685
|
folder to offer. */}
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2686
|
+
{!roots && (
|
|
2687
|
+
<EmptyTreeNotice
|
|
2688
|
+
rootPath={sections ? sections.knowledge?.relativePath ?? null : checkout?.relativePath ?? null}
|
|
2689
|
+
/>
|
|
2690
|
+
)}
|
|
2636
2691
|
</div>
|
|
2637
2692
|
</div>
|
|
2638
2693
|
</TreeChrome>
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '../routing/kb-routes';
|
|
16
16
|
import { Banner, Button, Surface, useLatestRef } from '../../../shared/components';
|
|
17
17
|
import { FileViewer } from './FileViewer';
|
|
18
|
+
import { appHostingPath, useRootClaims } from '../../../core/registry';
|
|
18
19
|
|
|
19
20
|
type SyncError =
|
|
20
21
|
| { kind: 'dirty'; current: string; target: string; dirtyFilenames: string[] }
|
|
@@ -33,6 +34,10 @@ type SyncError =
|
|
|
33
34
|
* `.tool` behind "Edit the tool file", a note with a frontmatter id — back to
|
|
34
35
|
* the Knowledge surface, which is exactly the switch that frame exists to
|
|
35
36
|
* avoid. The path URL stays; the file is the same.
|
|
37
|
+
*
|
|
38
|
+
* A file under a root an app claims (`AppDef.roots`) is the same case, and
|
|
39
|
+
* needs no flag: its path URL is what opens it in that app, so it is never
|
|
40
|
+
* replaced, and an id URL that resolves to it is replaced by its path URL.
|
|
36
41
|
*/
|
|
37
42
|
export function FileRoute({ canonicalize = true }: { canonicalize?: boolean } = {}) {
|
|
38
43
|
const params = useParams<{ branch: string; '*': string }>();
|
|
@@ -54,6 +59,7 @@ export function FileRoute({ canonicalize = true }: { canonicalize?: boolean } =
|
|
|
54
59
|
// to be a node is canonicalized to its id URL (the redirect effect).
|
|
55
60
|
const segment = params['*'] ?? '';
|
|
56
61
|
const segmentIsId = NODE_ID_LINK_RE.test(segment);
|
|
62
|
+
const claims = useRootClaims();
|
|
57
63
|
|
|
58
64
|
const workspace = useWorkspace();
|
|
59
65
|
const git = useGit();
|
|
@@ -123,6 +129,22 @@ export function FileRoute({ canonicalize = true }: { canonicalize?: boolean } =
|
|
|
123
129
|
};
|
|
124
130
|
}, [segmentIsId, segment, branchFromUrl]);
|
|
125
131
|
|
|
132
|
+
// ── An id URL for a hosted file → its path URL ───────────────────────────
|
|
133
|
+
// The path URL is the one that opens the file in the app hosting its root;
|
|
134
|
+
// the id URL would keep it here. Same entry, same state and query, as the
|
|
135
|
+
// canonical swap below.
|
|
136
|
+
const hostedPath =
|
|
137
|
+
segmentIsId && idResolved?.seg === segment && idResolved.branch === branchFromUrl && idResolved.path
|
|
138
|
+
? appHostingPath(claims, idResolved.path, workspace.kbDirName) && idResolved.path
|
|
139
|
+
: undefined;
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!hostedPath) return;
|
|
142
|
+
navigate(kbFileUrl(branchFromUrl, hostedPath) + location.search + location.hash, {
|
|
143
|
+
replace: true,
|
|
144
|
+
state: location.state,
|
|
145
|
+
});
|
|
146
|
+
}, [hostedPath, branchFromUrl, navigate, location.search, location.hash, location.state]);
|
|
147
|
+
|
|
126
148
|
// ── Canonicalize a path URL → the node's id URL ──────────────────────────
|
|
127
149
|
// Once the file is the active tab, look up its node id and replace the path
|
|
128
150
|
// URL with `/workspace/<branch>/<id>`. Non-node files (no id) stay path-based.
|
|
@@ -141,6 +163,7 @@ export function FileRoute({ canonicalize = true }: { canonicalize?: boolean } =
|
|
|
141
163
|
const searchRef = useLatestRef(location.search);
|
|
142
164
|
useEffect(() => {
|
|
143
165
|
if (!canonicalize || segmentIsId || !segment || !branchFromUrl) return;
|
|
166
|
+
if (appHostingPath(claims, segment, workspace.kbDirName)) return;
|
|
144
167
|
if (openFilePath !== segment) return;
|
|
145
168
|
let cancelled = false;
|
|
146
169
|
(async () => {
|
|
@@ -155,7 +178,7 @@ export function FileRoute({ canonicalize = true }: { canonicalize?: boolean } =
|
|
|
155
178
|
return () => {
|
|
156
179
|
cancelled = true;
|
|
157
180
|
};
|
|
158
|
-
}, [canonicalize, segmentIsId, segment, branchFromUrl, openFilePath, location.hash, navigate, routerStateRef, searchRef]);
|
|
181
|
+
}, [canonicalize, segmentIsId, segment, branchFromUrl, openFilePath, location.hash, navigate, routerStateRef, searchRef, claims, workspace.kbDirName]);
|
|
159
182
|
|
|
160
183
|
// ── Branch sync + hydrate + URL → state (forward direction) ──────────────
|
|
161
184
|
|
|
@@ -13,13 +13,13 @@ import { KbPageHeader } from './KbPageHeader';
|
|
|
13
13
|
import { useOpenChangeRequests } from '../hooks/useOpenChangeRequests';
|
|
14
14
|
import { Banner, Button, IconButton, Surface, useFocusHandoff } from '../../../shared/components';
|
|
15
15
|
import { displayFileName, fileNameTooltip, isAccessRulesFile } from '../utils/display-file-name';
|
|
16
|
-
import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
|
|
17
16
|
import { useGit } from '../../git';
|
|
18
17
|
import { LayoutContext } from '../../layout';
|
|
19
18
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
20
19
|
import { useCanonicalFileUrl, useFileNav } from '../routing/kb-routes';
|
|
21
20
|
import { PullNeededBanner } from '../../git/components/PullNeededBanner';
|
|
22
21
|
import { GitSyncFailedBanner } from '../../git/components/GitSyncFailedBanner';
|
|
22
|
+
import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
|
|
23
23
|
import { useFileAccess, formatEligible } from '../../access';
|
|
24
24
|
import { FileHistoryPanel } from '../../git/components/FileHistoryPanel';
|
|
25
25
|
import { FileComparisonPanel } from '../../git/components/FileComparisonPanel';
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
type OpenComparisonDetail,
|
|
29
29
|
} from '../../../core/events';
|
|
30
30
|
import { useAppRegistry } from '../../../core/registry';
|
|
31
|
-
import { LockApiError, SELF_HOLD_MESSAGE, useFileLock } from '../../
|
|
31
|
+
import { LockApiError, SELF_HOLD_MESSAGE, useFileLock } from '../../version-control';
|
|
32
32
|
import { useAuth } from '../../auth';
|
|
33
33
|
import {
|
|
34
34
|
knowledgeSuggestionBranchFor,
|
|
@@ -17,7 +17,7 @@ import { useDismissableMenu } from '../../../shared/components';
|
|
|
17
17
|
import { HEADER_BAND, PAGE_HEADER_TESTID, TITLE_INK_ROOM } from '../../../shared/theme/header';
|
|
18
18
|
import { rootAnchoredPath } from '../utils/pasteLink';
|
|
19
19
|
import { displayFileName, fileNameTooltip } from '../utils/display-file-name';
|
|
20
|
-
import { SELF_HOLD_MESSAGE } from '../../
|
|
20
|
+
import { SELF_HOLD_MESSAGE } from '../../version-control';
|
|
21
21
|
import { FullScreenButton } from './FullScreenView';
|
|
22
22
|
|
|
23
23
|
/**
|