@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
package/src/core/registry.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The app registry: the contract between the core shell (`CoreAppShell`) and
|
|
3
3
|
* optional (enterprise) modules. The core owns workspace, git, pr, access,
|
|
4
|
-
* auth,
|
|
4
|
+
* auth, version control/SSE, layout, secrets-vault, tools, toolbar and the admin
|
|
5
5
|
* roles page; everything else (chat, connectors, routines, watchlist, voice,
|
|
6
6
|
* embed, review, onboarding, admin LLM/feedback pages) is contributed through
|
|
7
7
|
* an `AppRegistry` instance passed to `<CoreAppShell registry={...} />`.
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
import {
|
|
14
14
|
createContext,
|
|
15
15
|
useContext,
|
|
16
|
+
useMemo,
|
|
16
17
|
type ComponentType,
|
|
17
18
|
type ReactElement,
|
|
18
19
|
type ReactNode,
|
|
19
20
|
} from 'react';
|
|
20
|
-
import type
|
|
21
|
+
import { currentKbLayout, type AuthUser, type FileTreeEntry } from '@bevel-software/platform-shared';
|
|
21
22
|
import type { FileRendererProps } from '../modules/workspace/components/renderers/types';
|
|
22
23
|
import type { CommandAction } from '../modules/toolbar/commands/actions';
|
|
23
24
|
|
|
@@ -339,6 +340,97 @@ export interface AppDef {
|
|
|
339
340
|
description?: string;
|
|
340
341
|
/** Sort order in the list (core: Knowledge 10, Skills & Tools 20). */
|
|
341
342
|
order?: number;
|
|
343
|
+
/**
|
|
344
|
+
* Top-level folders of the knowledge base this app hosts, by name
|
|
345
|
+
* (`['Agents', 'Workflows', 'Data']`), compared case-insensitively. Core claims none.
|
|
346
|
+
*
|
|
347
|
+
* A claimed root leaves the Knowledge explorer, and a file URL under it
|
|
348
|
+
* (`/workspace/<branch>/<kbDir>/<root>/…`, the URL `kbFileUrl` builds) opens
|
|
349
|
+
* in THIS app: the shell renders `element` in place of the Knowledge surface
|
|
350
|
+
* and puts the switcher on this app. The URL space does not change, so every
|
|
351
|
+
* link to such a file lands here. `element` is then rendered under the
|
|
352
|
+
* `/workspace/*` route, so it must show its folder surface
|
|
353
|
+
* (`KnowledgeSurface` with `roots`) for a location it does not route itself.
|
|
354
|
+
*
|
|
355
|
+
* Two apps claiming one root is a composition error: the shell throws when
|
|
356
|
+
* it is mounted, naming the root and both apps. So is claiming a root core
|
|
357
|
+
* presents itself (the layout's knowledge, skills and plugins folders):
|
|
358
|
+
* Knowledge and Skills & Tools are built on those and cannot give them up.
|
|
359
|
+
*/
|
|
360
|
+
roots?: string[];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Which app claims each root folder (see {@link AppDef.roots}), as
|
|
365
|
+
* `root → app id`. Throws when two apps claim the same root, or when an app
|
|
366
|
+
* claims one of core's own roots, so a misconfigured registry fails when the
|
|
367
|
+
* shell mounts, not when someone follows a link.
|
|
368
|
+
*
|
|
369
|
+
* Root names compare case-insensitively, as the layout's do: the workspaces
|
|
370
|
+
* live on case-insensitive filesystems, where `Agents` and `agents` are one
|
|
371
|
+
* folder. The map is keyed by the lowercased name; read it through
|
|
372
|
+
* {@link appClaimingRoot}.
|
|
373
|
+
*/
|
|
374
|
+
export function rootClaims(apps: readonly AppDef[]): ReadonlyMap<string, string> {
|
|
375
|
+
const layout = currentKbLayout();
|
|
376
|
+
const coreRoots = new Set(
|
|
377
|
+
[layout.knowledgeBaseDir, layout.skillsDir, layout.pluginsDir].map((n) => n.toLowerCase()),
|
|
378
|
+
);
|
|
379
|
+
const claims = new Map<string, string>();
|
|
380
|
+
for (const app of apps) {
|
|
381
|
+
for (const root of app.roots ?? []) {
|
|
382
|
+
// One top-level folder NAME: a path, a blank or a dot entry would be
|
|
383
|
+
// claimed and never matched (`appHostingPath` reads one segment), so
|
|
384
|
+
// the app would host nothing and Knowledge would keep the folder.
|
|
385
|
+
if (!root || root !== root.trim() || root === '.' || root === '..' || /[\\/]/.test(root)) {
|
|
386
|
+
throw new Error(`The root folder "${root}" claimed by the app "${app.id}" must be a single top-level folder name.`);
|
|
387
|
+
}
|
|
388
|
+
const key = root.toLowerCase();
|
|
389
|
+
if (coreRoots.has(key)) {
|
|
390
|
+
throw new Error(`The root folder "${root}" is core's own; the app "${app.id}" cannot claim it.`);
|
|
391
|
+
}
|
|
392
|
+
const holder = claims.get(key);
|
|
393
|
+
if (holder !== undefined && holder !== app.id) {
|
|
394
|
+
throw new Error(`The root folder "${root}" is claimed by two apps: "${holder}" and "${app.id}".`);
|
|
395
|
+
}
|
|
396
|
+
claims.set(key, app.id);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return claims;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** The app that claims a root folder, by name in any case, or undefined. */
|
|
403
|
+
export function appClaimingRoot(claims: ReadonlyMap<string, string>, root: string): string | undefined {
|
|
404
|
+
return claims.get(root.toLowerCase());
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* The app that hosts a workspace-relative path (`<kbDir>/<root>/…`), or
|
|
409
|
+
* undefined when its root is claimed by none. The one reading of a claim:
|
|
410
|
+
* the shell routes by it, the explorer hides by it, the file route keeps a
|
|
411
|
+
* hosted file's URL by it.
|
|
412
|
+
*
|
|
413
|
+
* A claim is on a root of the knowledge base, so a path outside the KB clone
|
|
414
|
+
* (a first segment other than `kbDirName`) is hosted by no app. Until the
|
|
415
|
+
* workspace has bootstrapped, `kbDirName` is null and the first segment is
|
|
416
|
+
* taken as the URL `kbFileUrl` builds it, so a pasted link opens in its app
|
|
417
|
+
* on the first render.
|
|
418
|
+
*/
|
|
419
|
+
export function appHostingPath(
|
|
420
|
+
claims: ReadonlyMap<string, string>,
|
|
421
|
+
workspacePath: string,
|
|
422
|
+
kbDirName: string | null,
|
|
423
|
+
): string | undefined {
|
|
424
|
+
if (claims.size === 0) return undefined;
|
|
425
|
+
const [kbDir, root] = workspacePath.split('/').filter(Boolean);
|
|
426
|
+
if (root === undefined || (kbDirName !== null && kbDir !== kbDirName)) return undefined;
|
|
427
|
+
return appClaimingRoot(claims, root);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** {@link rootClaims} for the registry in context. */
|
|
431
|
+
export function useRootClaims(): ReadonlyMap<string, string> {
|
|
432
|
+
const { apps } = useAppRegistry();
|
|
433
|
+
return useMemo(() => rootClaims(apps), [apps]);
|
|
342
434
|
}
|
|
343
435
|
|
|
344
436
|
/**
|
|
@@ -374,6 +466,12 @@ export interface ToolbarItemDef {
|
|
|
374
466
|
order?: number;
|
|
375
467
|
}
|
|
376
468
|
|
|
469
|
+
/** What the Connect page tells its distribution panel — see `AppRegistry.connectPanel`. */
|
|
470
|
+
export interface ConnectPanelProps {
|
|
471
|
+
/** The panel changed what the page lists (enabled or disabled a connector): refetch. */
|
|
472
|
+
onChanged: () => void;
|
|
473
|
+
}
|
|
474
|
+
|
|
377
475
|
/** Props for the overlay-provided panel on the Groups settings page. */
|
|
378
476
|
export interface GroupsDirectoryPanelProps {
|
|
379
477
|
/** The active group source, as the roster reports it. */
|
|
@@ -453,6 +551,16 @@ export interface AppRegistry {
|
|
|
453
551
|
* the page ends with its form, as it always has.
|
|
454
552
|
*/
|
|
455
553
|
deploymentPanel?: ComponentType;
|
|
554
|
+
/**
|
|
555
|
+
* A panel at the foot of the Connect page ("Connect your tools"). Core's
|
|
556
|
+
* page lists the sign-ins and keys the reader's tools need, managed
|
|
557
|
+
* connectors among them once they are enabled; which connectors a
|
|
558
|
+
* distribution offers, and enabling one in a plugin, is the distribution's
|
|
559
|
+
* to show. Rendered for every reader (the panel decides what an admin
|
|
560
|
+
* sees), and told when it changed something so the page refetches.
|
|
561
|
+
* Absent means the page ends with its lists, as it always has.
|
|
562
|
+
*/
|
|
563
|
+
connectPanel?: ComponentType<ConnectPanelProps>;
|
|
456
564
|
/**
|
|
457
565
|
* A way to sign in that the DISTRIBUTION runs, offered beside the
|
|
458
566
|
* deployment's own identity provider. See {@link SignInOptionDef}.
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,9 @@ import './html-extensions';
|
|
|
20
20
|
|
|
21
21
|
export { loadServerConfig, renderConfigFailure } from './core/bootstrap';
|
|
22
22
|
export { CoreAppShell, AuthGate } from './core/CoreAppShell';
|
|
23
|
+
// The Knowledge surface; with `roots`, the folder surface an app mounts for
|
|
24
|
+
// the root folders it claims (`AppDef.roots`).
|
|
25
|
+
export { KnowledgeSurface } from './core/KnowledgeSurface';
|
|
23
26
|
// The embed, mounted OUTSIDE the app: what a deployment's `embed` entry calls
|
|
24
27
|
// when the MCP App view loads it into a chat host's sandbox (see
|
|
25
28
|
// `modules/embed/mount.tsx`).
|
|
@@ -413,7 +413,7 @@ describe('ManageAccessDialog: a file whose folder governs its access', () => {
|
|
|
413
413
|
|
|
414
414
|
it("the server's ruling decides: an overlay-registered kind the server accepts keeps the field", async () => {
|
|
415
415
|
api.fetchFileAccess.mockResolvedValue({ ...binaryView, governedByFolder: undefined });
|
|
416
|
-
const flow = { name: 'Flow.
|
|
416
|
+
const flow = { name: 'Flow.workflow', relativePath: `${KB}/Sales/Flow.workflow`, type: 'file' } as unknown as FileTreeEntry;
|
|
417
417
|
render(<ManageAccessDialog entry={flow} onClose={() => {}} onManageAncestor={() => {}} />);
|
|
418
418
|
expect(await screen.findByRole('heading', { name: /On this file/i })).toBeInTheDocument();
|
|
419
419
|
expect(screen.getByPlaceholderText(/Add people, groups, roles or plugins/)).toBeInTheDocument();
|
|
@@ -392,19 +392,39 @@ export interface PathPrincipals {
|
|
|
392
392
|
write: AccessPrincipalRef[];
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
/** One
|
|
395
|
+
/** One principal that loses or gains one verb in a move; a person with no display name is named by their address. */
|
|
396
|
+
export interface HolderChangeRef extends AccessPrincipalRef {
|
|
397
|
+
verb: 'read' | 'write';
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Who loses and who gains opening or editing a file or folder in a move, as
|
|
402
|
+
* the resolver judges each of them on both sides — the one answer the move
|
|
403
|
+
* dialog and the agent's `move_file` both show. Not a diff of the two holder
|
|
404
|
+
* lists: those name grants, so they miss a person the destination denies by
|
|
405
|
+
* name and show a writer leaving a folder everyone reads as losing `read`.
|
|
406
|
+
*/
|
|
407
|
+
export interface HolderChanges {
|
|
408
|
+
lose: HolderChangeRef[];
|
|
409
|
+
gain: HolderChangeRef[];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** One file's or folder's holders where it is now and where a move would put it, and who the move costs and serves. */
|
|
396
413
|
export interface ProspectiveAccess {
|
|
397
414
|
before: PathPrincipals;
|
|
398
415
|
after: PathPrincipals;
|
|
416
|
+
changes: HolderChanges;
|
|
399
417
|
}
|
|
400
418
|
|
|
401
419
|
/**
|
|
402
420
|
* Resolve who holds read and write on `relativePath` today and who would hold
|
|
403
421
|
* them once it sits in `toDir` — the destination's folder rules with what the
|
|
404
422
|
* move carries layered on top: a file's own frontmatter, or the `access.md`
|
|
405
|
-
* files inside a folder, counted at the paths they land on
|
|
406
|
-
*
|
|
407
|
-
* the repo root.
|
|
423
|
+
* files inside a folder, counted at the paths they land on — and who loses
|
|
424
|
+
* and who gains in between (`changes`). Both paths are repo-relative
|
|
425
|
+
* (`Knowledge/Foo.md`, `Knowledge/Sales`); `toDir` is `''` for the repo root.
|
|
426
|
+
* The route answers 403 when the caller may not read the file or the
|
|
427
|
+
* destination folder: the dialog then says it could not work the change out.
|
|
408
428
|
*
|
|
409
429
|
* `signal` lets the move dialog give up on it: the answer decorates the
|
|
410
430
|
* confirmation and must never hold it open.
|
|
@@ -90,7 +90,7 @@ export function useFileAccess(
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
// Drafts are free-for-all (mirrors the backend's branch-protected gates
|
|
93
|
-
// in
|
|
93
|
+
// in version-control/git/git.service.ts and version-control.service.ts). Skip the network
|
|
94
94
|
// call entirely so a slow/failed lookup never grays out the editor on a
|
|
95
95
|
// draft. `branch === null` is the bootstrap window before status loads;
|
|
96
96
|
// return canWrite=null so callers stay optimistic until we know.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* layout and free to move. Export what another module needs; nothing more.
|
|
5
5
|
*/
|
|
6
6
|
export { fetchAdmins, fetchFileAccess, fetchFileAccessBatch, fetchProspectiveAccess, parsePluginPrincipalToken, pluginPrincipalLabel, suggestPrincipals } from './api';
|
|
7
|
-
export type { AccessEligible, AccessPrincipalRef, AccessResponse, AdminContact, GrantSources, PathPrincipals, ProspectiveAccess } from './api';
|
|
7
|
+
export type { AccessEligible, AccessPrincipalRef, AccessResponse, AdminContact, GrantSources, HolderChangeRef, HolderChanges, PathPrincipals, ProspectiveAccess } from './api';
|
|
8
8
|
export { useAccessRequests } from './hooks/useAccessRequests';
|
|
9
9
|
export type { AccessRequestsState } from './hooks/useAccessRequests';
|
|
10
10
|
export { formatEligible, useFileAccess } from './hooks/useFileAccess';
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* layout and free to move. Export what another module needs; nothing more.
|
|
5
5
|
*/
|
|
6
6
|
export { addMember, fetchRoles } from './services/roles.api';
|
|
7
|
-
export { AdminContext, useAdmin } from './state/admin.context';
|
|
7
|
+
export { AdminContext, useAdmin, type AdminContextValue } from './state/admin.context';
|
|
@@ -25,9 +25,16 @@ export interface ConnectAsChoiceProps {
|
|
|
25
25
|
* name with its description. Used where a connection is made — the OAuth
|
|
26
26
|
* consent step and the connection-key form — so both offer the same choice
|
|
27
27
|
* the same way.
|
|
28
|
+
*
|
|
29
|
+
* With no agent on offer there is no choice to make, and nothing is shown:
|
|
30
|
+
* the connection is Everything's, as every connection was before agents
|
|
31
|
+
* existed, and a page with one radio button would only ask what it cannot
|
|
32
|
+
* be asked. The one exception is a listing that FAILED — then the person is
|
|
33
|
+
* told, and confirms Everything, since the agents may well exist.
|
|
28
34
|
*/
|
|
29
35
|
export function ConnectAsChoice({ agents, value, onChange, disabled, hint, unavailable }: ConnectAsChoiceProps) {
|
|
30
36
|
const name = useId();
|
|
37
|
+
if (agents.length === 0 && !unavailable) return null;
|
|
31
38
|
const options: { path: string | null; title: string; detail: string }[] = [
|
|
32
39
|
{
|
|
33
40
|
path: null,
|
|
@@ -4,8 +4,8 @@ import userEvent from '@testing-library/user-event';
|
|
|
4
4
|
import { MemoryRouter } from 'react-router-dom';
|
|
5
5
|
import { AuditLogPage } from '../components/AuditLogPage';
|
|
6
6
|
import { groupByAccount } from '../components/principal-grouping';
|
|
7
|
-
import { AdminContext } from '../../admin
|
|
8
|
-
import { AuthContext } from '../../auth
|
|
7
|
+
import { AdminContext } from '../../admin';
|
|
8
|
+
import { AuthContext } from '../../auth';
|
|
9
9
|
import {
|
|
10
10
|
listPrincipals,
|
|
11
11
|
listEvents,
|
|
@@ -187,7 +187,8 @@ describe('AuditLogPage', () => {
|
|
|
187
187
|
const rowOf = (label: string) => screen.getByText(label).closest('li') as HTMLElement;
|
|
188
188
|
expect(rowOf('Claude')).toHaveTextContent('As delivery-mechanic');
|
|
189
189
|
expect(within(rowOf('Claude')).getByTitle('Agents/delivery-mechanic.agent')).toBeInTheDocument();
|
|
190
|
-
|
|
190
|
+
// Everything is what a connection is unless it says otherwise: no tag.
|
|
191
|
+
expect(rowOf('CI pipeline')).not.toHaveTextContent('As ');
|
|
191
192
|
});
|
|
192
193
|
|
|
193
194
|
it('shows an admin a key its owner deleted for good, marked as such, with its history intact', async () => {
|
|
@@ -277,11 +277,13 @@ export function AuditLogPage() {
|
|
|
277
277
|
{p.deletedAt != null && <Badge tone="outline">Deleted by owner</Badge>}
|
|
278
278
|
</span>
|
|
279
279
|
<span className="block text-meta text-ink-muted">
|
|
280
|
-
{/*
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
{/* The agent configuration the connection was made as, when it was
|
|
281
|
+
made as one; a connection made as Everything, which is what a
|
|
282
|
+
connection is unless it says otherwise, carries no tag. A page
|
|
283
|
+
acts as its viewer, so it never has one. */}
|
|
284
|
+
{p.kind !== 'page' && p.agentPath && (
|
|
283
285
|
<>
|
|
284
|
-
<span title={p.agentPath
|
|
286
|
+
<span title={p.agentPath}>As {connectedAsLabel(p.agentPath)}</span>
|
|
285
287
|
{' · '}
|
|
286
288
|
</>
|
|
287
289
|
)}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import type { AuditPrincipal } from '../services/audit.api';
|
|
2
|
-
|
|
3
|
-
export interface AccountGroup {
|
|
4
|
-
user: AuditPrincipal['user'];
|
|
5
|
-
principals: AuditPrincipal[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** The React key / disclosure id for one row — kinds share no id space, so both go in. */
|
|
9
|
-
export function principalKey(p: Pick<AuditPrincipal, 'kind' | 'id'>): string {
|
|
10
|
-
return `${p.kind}:${p.id}`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* One list from the server, grouped per account in the order the server
|
|
15
|
-
* returned it (owner email; live before revoked, most recently used first).
|
|
16
|
-
* Revoked rows are dropped unless asked for, and an account left with no
|
|
17
|
-
* rows disappears with them.
|
|
18
|
-
*
|
|
19
|
-
* `query` narrows to accounts or rows whose name, email or label contains it
|
|
20
|
-
* (case-insensitive) — the admin's "find that agent" box. A match on the
|
|
21
|
-
* account keeps every row of it; a match on a row keeps just that row.
|
|
22
|
-
*
|
|
23
|
-
* Lives beside {@link AuditLogPage} rather than in it: a component file that
|
|
24
|
-
* also exports a plain function breaks fast refresh.
|
|
25
|
-
*/
|
|
26
|
-
export function groupByAccount(
|
|
27
|
-
principals: AuditPrincipal[],
|
|
28
|
-
opts: { includeRevoked: boolean; query?: string },
|
|
29
|
-
): AccountGroup[] {
|
|
30
|
-
const q = (opts.query ?? '').trim().toLowerCase();
|
|
31
|
-
const groups: AccountGroup[] = [];
|
|
32
|
-
const byUser = new Map<string, AccountGroup>();
|
|
33
|
-
for (const p of principals) {
|
|
34
|
-
if (!opts.includeRevoked && p.revokedAt !== null) continue;
|
|
35
|
-
if (q) {
|
|
36
|
-
const accountHit = p.user.name.toLowerCase().includes(q) || p.user.email.toLowerCase().includes(q);
|
|
37
|
-
const rowHit = p.label.toLowerCase().includes(q);
|
|
38
|
-
if (!accountHit && !rowHit) continue;
|
|
39
|
-
}
|
|
40
|
-
let group = byUser.get(p.user.id);
|
|
41
|
-
if (!group) {
|
|
42
|
-
group = { user: p.user, principals: [] };
|
|
43
|
-
byUser.set(p.user.id, group);
|
|
44
|
-
groups.push(group);
|
|
45
|
-
}
|
|
46
|
-
group.principals.push(p);
|
|
47
|
-
}
|
|
48
|
-
return groups;
|
|
49
|
-
}
|
|
1
|
+
import type { AuditPrincipal } from '../services/audit.api';
|
|
2
|
+
|
|
3
|
+
export interface AccountGroup {
|
|
4
|
+
user: AuditPrincipal['user'];
|
|
5
|
+
principals: AuditPrincipal[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** The React key / disclosure id for one row — kinds share no id space, so both go in. */
|
|
9
|
+
export function principalKey(p: Pick<AuditPrincipal, 'kind' | 'id'>): string {
|
|
10
|
+
return `${p.kind}:${p.id}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* One list from the server, grouped per account in the order the server
|
|
15
|
+
* returned it (owner email; live before revoked, most recently used first).
|
|
16
|
+
* Revoked rows are dropped unless asked for, and an account left with no
|
|
17
|
+
* rows disappears with them.
|
|
18
|
+
*
|
|
19
|
+
* `query` narrows to accounts or rows whose name, email or label contains it
|
|
20
|
+
* (case-insensitive) — the admin's "find that agent" box. A match on the
|
|
21
|
+
* account keeps every row of it; a match on a row keeps just that row.
|
|
22
|
+
*
|
|
23
|
+
* Lives beside {@link AuditLogPage} rather than in it: a component file that
|
|
24
|
+
* also exports a plain function breaks fast refresh.
|
|
25
|
+
*/
|
|
26
|
+
export function groupByAccount(
|
|
27
|
+
principals: AuditPrincipal[],
|
|
28
|
+
opts: { includeRevoked: boolean; query?: string },
|
|
29
|
+
): AccountGroup[] {
|
|
30
|
+
const q = (opts.query ?? '').trim().toLowerCase();
|
|
31
|
+
const groups: AccountGroup[] = [];
|
|
32
|
+
const byUser = new Map<string, AccountGroup>();
|
|
33
|
+
for (const p of principals) {
|
|
34
|
+
if (!opts.includeRevoked && p.revokedAt !== null) continue;
|
|
35
|
+
if (q) {
|
|
36
|
+
const accountHit = p.user.name.toLowerCase().includes(q) || p.user.email.toLowerCase().includes(q);
|
|
37
|
+
const rowHit = p.label.toLowerCase().includes(q);
|
|
38
|
+
if (!accountHit && !rowHit) continue;
|
|
39
|
+
}
|
|
40
|
+
let group = byUser.get(p.user.id);
|
|
41
|
+
if (!group) {
|
|
42
|
+
group = { user: p.user, principals: [] };
|
|
43
|
+
byUser.set(p.user.id, group);
|
|
44
|
+
groups.push(group);
|
|
45
|
+
}
|
|
46
|
+
group.principals.push(p);
|
|
47
|
+
}
|
|
48
|
+
return groups;
|
|
49
|
+
}
|
|
@@ -8,5 +8,5 @@ export { createAccount, deactivateAccount, deleteAccount, getAccountReferences,
|
|
|
8
8
|
export type { AccountReferences, AccountSummary } from './services/account.api';
|
|
9
9
|
export { takePostLoginRedirect } from './services/sso';
|
|
10
10
|
export type { LoginProviders } from './services/sso';
|
|
11
|
-
export { AuthContext, useAuth } from './state/auth.context';
|
|
11
|
+
export { AuthContext, useAuth, type AuthContextValue } from './state/auth.context';
|
|
12
12
|
export { useSignInMethods } from './state/use-sign-in-methods';
|
|
@@ -32,7 +32,7 @@ vi.mock('../../pr/services/pr-cancel.api', () => ({
|
|
|
32
32
|
|
|
33
33
|
import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
34
34
|
import { GitApiError } from '../../git/services/git.api';
|
|
35
|
-
import { EventBusContext, type EventBusContextValue } from '../../
|
|
35
|
+
import { EventBusContext, type EventBusContextValue } from '../../version-control/state/event-bus.context';
|
|
36
36
|
|
|
37
37
|
const BRANCH = 'ali.raza/customer-hypotheses';
|
|
38
38
|
const CR = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
2
|
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
|
|
3
|
-
import type { PullRequestSummary,
|
|
4
|
-
import { EventBusContext, type EventBusContextValue } from '../../
|
|
3
|
+
import type { PullRequestSummary, VersionControlEvent } from '@bevel-software/platform-shared';
|
|
4
|
+
import { EventBusContext, type EventBusContextValue } from '../../version-control/state/event-bus.context';
|
|
5
5
|
import {
|
|
6
6
|
OpenChangeRequestsContext,
|
|
7
7
|
NO_CHANGE_REQUESTS,
|
|
@@ -50,10 +50,10 @@ const CR: PullRequestSummary = {
|
|
|
50
50
|
} as unknown as PullRequestSummary;
|
|
51
51
|
|
|
52
52
|
function makeFakeBus() {
|
|
53
|
-
const handlers: Record<string, ((e:
|
|
54
|
-
const bus: EventBusContextValue & { emit(e:
|
|
53
|
+
const handlers: Record<string, ((e: VersionControlEvent) => void)[]> = {};
|
|
54
|
+
const bus: EventBusContextValue & { emit(e: VersionControlEvent): void } = {
|
|
55
55
|
subscribe(kind, handler) {
|
|
56
|
-
(handlers[kind] ??= []).push(handler as (e:
|
|
56
|
+
(handlers[kind] ??= []).push(handler as (e: VersionControlEvent) => void);
|
|
57
57
|
return () => {
|
|
58
58
|
handlers[kind] = (handlers[kind] ?? []).filter((h) => h !== handler);
|
|
59
59
|
};
|
|
@@ -154,7 +154,7 @@ describe('FileChangeBoxes: who may decide', () => {
|
|
|
154
154
|
expect(api.fetchPrDetail).toHaveBeenCalledWith(CR.number, { fresh: true });
|
|
155
155
|
|
|
156
156
|
act(() => {
|
|
157
|
-
bus.emit({ kind: 'change-request-merged', number: CR.number } as unknown as
|
|
157
|
+
bus.emit({ kind: 'change-request-merged', number: CR.number } as unknown as VersionControlEvent);
|
|
158
158
|
});
|
|
159
159
|
expect(
|
|
160
160
|
await screen.findByText('Published: the file now reads with that change.'),
|
|
@@ -4,8 +4,8 @@ import type { ReactNode } from 'react';
|
|
|
4
4
|
import type {
|
|
5
5
|
ChangeRequestApplyFailure,
|
|
6
6
|
PullRequestSummary,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
VersionControlEvent,
|
|
8
|
+
VersionControlEventPayload,
|
|
9
9
|
} from '@bevel-software/platform-shared';
|
|
10
10
|
|
|
11
11
|
const detailMock = vi.hoisted(() => ({ fetchPrDetail: vi.fn() }));
|
|
@@ -30,7 +30,7 @@ import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
|
30
30
|
import {
|
|
31
31
|
EventBusContext,
|
|
32
32
|
type EventBusContextValue,
|
|
33
|
-
} from '../../
|
|
33
|
+
} from '../../version-control/state/event-bus.context';
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* The other half of the ticket: a FAILED apply used to be told only to the
|
|
@@ -64,20 +64,20 @@ const FAILURE: ChangeRequestApplyFailure = {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
function fakeBus() {
|
|
67
|
-
const handlers = new Map<string, Set<(e:
|
|
67
|
+
const handlers = new Map<string, Set<(e: VersionControlEvent) => void>>();
|
|
68
68
|
const value: EventBusContextValue = {
|
|
69
69
|
subscribe: (kind, handler) => {
|
|
70
70
|
const set = handlers.get(kind) ?? new Set();
|
|
71
|
-
set.add(handler as (e:
|
|
71
|
+
set.add(handler as (e: VersionControlEvent) => void);
|
|
72
72
|
handlers.set(kind, set);
|
|
73
|
-
return () => set.delete(handler as (e:
|
|
73
|
+
return () => set.delete(handler as (e: VersionControlEvent) => void);
|
|
74
74
|
},
|
|
75
75
|
setFocus: () => {},
|
|
76
76
|
watchWorkspace: () => () => {},
|
|
77
77
|
};
|
|
78
|
-
const emit = (event:
|
|
78
|
+
const emit = (event: VersionControlEventPayload) => {
|
|
79
79
|
for (const h of handlers.get(event.kind) ?? []) {
|
|
80
|
-
h({ id: 1, ts: new Date().toISOString(), ...event } as
|
|
80
|
+
h({ id: 1, ts: new Date().toISOString(), ...event } as VersionControlEvent);
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
return { value, emit };
|
|
@@ -12,7 +12,7 @@ import { useModalLayer } from '../../../shared/components/useModalLayer';
|
|
|
12
12
|
import { cn } from '../../../lib/utils';
|
|
13
13
|
import { PR_STALE_EVENT } from '../../../core/events';
|
|
14
14
|
import { AuthContext } from '../../auth';
|
|
15
|
-
import { useEventBus } from '../../
|
|
15
|
+
import { useEventBus } from '../../version-control';
|
|
16
16
|
import {
|
|
17
17
|
approvePrFile,
|
|
18
18
|
deleteChangeRequest,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import type { PullRequestSummary } from '@bevel-software/platform-shared';
|
|
3
|
-
import { useEventBus } from '../../
|
|
3
|
+
import { useEventBus } from '../../version-control';
|
|
4
4
|
import { fetchPrDetail, approvePrFile, mergePullRequest } from '../../pr';
|
|
5
5
|
import { friendlyGitError, friendlyGitMessage } from '../../git';
|
|
6
6
|
|
|
@@ -4,7 +4,7 @@ import { GitSyncFailedBanner } from '../components/GitSyncFailedBanner';
|
|
|
4
4
|
import {
|
|
5
5
|
EventBusContext,
|
|
6
6
|
type EventBusContextValue,
|
|
7
|
-
} from '../../
|
|
7
|
+
} from '../../version-control/state/event-bus.context';
|
|
8
8
|
import {
|
|
9
9
|
WorkspaceContext,
|
|
10
10
|
type WorkspaceContextValue,
|
|
@@ -21,21 +21,21 @@ function ok(body: unknown): Response {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
describe('pr.api', () => {
|
|
24
|
-
it('listPullRequestsForMe GETs the workflow for-me route', async () => {
|
|
24
|
+
it('listPullRequestsForMe GETs the /workflow for-me route', async () => {
|
|
25
25
|
fetchMock.mockResolvedValueOnce(ok([]));
|
|
26
26
|
const result = await listPullRequestsForMe();
|
|
27
27
|
expect(result).toEqual([]);
|
|
28
28
|
expect(fetchMock.mock.calls[0][0]).toBe('/api/workflow/change-requests/for-me');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it('listMyPullRequests GETs the workflow mine route and returns the parsed body', async () => {
|
|
31
|
+
it('listMyPullRequests GETs the /workflow mine route and returns the parsed body', async () => {
|
|
32
32
|
fetchMock.mockResolvedValueOnce(ok([]));
|
|
33
33
|
const result = await listMyPullRequests();
|
|
34
34
|
expect(result).toEqual([]);
|
|
35
35
|
expect(fetchMock.mock.calls[0][0]).toBe('/api/workflow/change-requests/mine');
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it('getPullRequest GETs the workflow change-request detail route', async () => {
|
|
38
|
+
it('getPullRequest GETs the /workflow change-request detail route', async () => {
|
|
39
39
|
fetchMock.mockResolvedValueOnce(ok({ number: 42, title: 't' }));
|
|
40
40
|
const pr = await getPullRequest(42);
|
|
41
41
|
expect(pr.number).toBe(42);
|
|
@@ -6,7 +6,7 @@ import { formatRelativeTime } from '../../../lib/utils';
|
|
|
6
6
|
import { MarkdownDiffViewer } from '../../review/components/MarkdownDiffViewer';
|
|
7
7
|
import { HistoryVersionPreview } from './HistoryVersionPreview';
|
|
8
8
|
import { friendlyGitError } from '../services/error-messages';
|
|
9
|
-
import { useEventBus, canonicalizeWorkspaceId } from '../../
|
|
9
|
+
import { useEventBus, canonicalizeWorkspaceId } from '../../version-control';
|
|
10
10
|
import { useWorkspace } from '../../workspace';
|
|
11
11
|
|
|
12
12
|
function shortSha(sha: string): string {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useContext, useState } from 'react';
|
|
2
2
|
import { AlertTriangle, CloudOff } from 'lucide-react';
|
|
3
|
-
import { useEventBusSubscription, canonicalizeWorkspaceId } from '../../
|
|
3
|
+
import { useEventBusSubscription, canonicalizeWorkspaceId } from '../../version-control';
|
|
4
4
|
import { useWorkspace, WorkspaceContext, useFileNav } from '../../workspace';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -8,7 +8,7 @@ import { authFetch } from '../../../lib/api';
|
|
|
8
8
|
/**
|
|
9
9
|
* Branch + change + working-tree API client. Talks exclusively to
|
|
10
10
|
* `/api/workspace/:id/workflow/*` — the legacy `/git/*` family was retired
|
|
11
|
-
* with the
|
|
11
|
+
* with the version-control-module migration (see `bevel-platform/PLAN.md`).
|
|
12
12
|
*
|
|
13
13
|
* Naming inside the frontend still uses git vocabulary (`fetchStatus`,
|
|
14
14
|
* `commit`, `push`) because the engineering glossary says internal symbols
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
/**
|
|
14
14
|
* Sanitize a server-derived string before splicing it into an agent-facing
|
|
15
15
|
* prompt. The prompts are dispatched as if the user typed them, so anything
|
|
16
|
-
* that originated server-side (`recoveryDetail` from a
|
|
16
|
+
* that originated server-side (`recoveryDetail` from a version-control error,
|
|
17
17
|
* `conflictedPaths` from a 409 payload) is in principle untrusted with
|
|
18
18
|
* respect to the agent: a control character, a backtick that closes our
|
|
19
19
|
* code-fence, or a 50KB rebase stderr could skew the agent's reading of
|
|
@@ -39,6 +39,14 @@ export const NO_PANES_LAYOUT: LayoutController = {
|
|
|
39
39
|
|
|
40
40
|
export const LayoutContext = createContext<LayoutController | null>(null);
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Setter through which a surface's pane layout reports its controller to the
|
|
44
|
+
* shell's chrome, whose {@link LayoutContext} provider wraps the toolbar.
|
|
45
|
+
*/
|
|
46
|
+
export const PaneControllerContext = createContext<(c: LayoutController | null) => void>(
|
|
47
|
+
() => {},
|
|
48
|
+
);
|
|
49
|
+
|
|
42
50
|
export function useLayout(): LayoutController {
|
|
43
51
|
const ctx = useContext(LayoutContext);
|
|
44
52
|
if (!ctx) throw new Error('useLayout must be used within LayoutContext.Provider');
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
import { AuthContext, type AuthContextValue } from '../../auth/state/auth.context';
|
|
10
10
|
import { GitContext, type GitContextValue } from '../../git/state/git.context';
|
|
11
11
|
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
12
|
-
import type { PullRequestSummary,
|
|
13
|
-
import { EventBusContext, type EventBusContextValue } from '../../
|
|
12
|
+
import type { PullRequestSummary, VersionControlEvent } from '@bevel-software/platform-shared';
|
|
13
|
+
import { EventBusContext, type EventBusContextValue } from '../../version-control/state/event-bus.context';
|
|
14
14
|
import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
15
15
|
import type { LibraryContextValue } from '../state/library-data';
|
|
16
16
|
|
|
@@ -329,10 +329,10 @@ function libraryValue(
|
|
|
329
329
|
* is itself worth asserting.
|
|
330
330
|
*/
|
|
331
331
|
function makeFakeBus() {
|
|
332
|
-
const handlers: Record<string, ((e:
|
|
333
|
-
const bus: EventBusContextValue & { emit(e:
|
|
332
|
+
const handlers: Record<string, ((e: VersionControlEvent) => void)[]> = {};
|
|
333
|
+
const bus: EventBusContextValue & { emit(e: VersionControlEvent): void } = {
|
|
334
334
|
subscribe(kind, handler) {
|
|
335
|
-
(handlers[kind] ??= []).push(handler as (e:
|
|
335
|
+
(handlers[kind] ??= []).push(handler as (e: VersionControlEvent) => void);
|
|
336
336
|
return () => {
|
|
337
337
|
handlers[kind] = (handlers[kind] ?? []).filter((h) => h !== handler);
|
|
338
338
|
};
|