@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.
- 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/hooks/useFileAccess.ts +1 -1
- package/src/modules/audit/components/principal-grouping.ts +49 -49
- 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 +109 -0
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +86 -19
- 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__/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/Toolbar.tsx +1 -1
- 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 +1 -1
- package/src/modules/workspace/components/KbPageHeader.tsx +1 -1
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +159 -13
- 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/fileTree.ts +10 -2
- package/src/modules/workspace/utils/treeConfirm.ts +1 -1
- /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();
|
|
@@ -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.
|
|
@@ -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
|
+
}
|
|
@@ -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
|
};
|
|
@@ -201,6 +201,7 @@ describe('ToolConnectionSection', () => {
|
|
|
201
201
|
label: null,
|
|
202
202
|
key: 'github_SIGNIN',
|
|
203
203
|
adminConfigured: true,
|
|
204
|
+
adminKind: 'oauth',
|
|
204
205
|
userConfigured: false,
|
|
205
206
|
oauth: true,
|
|
206
207
|
authorized: false,
|
|
@@ -242,6 +243,7 @@ describe('ToolConnectionSection', () => {
|
|
|
242
243
|
label: 'HeyReach API key',
|
|
243
244
|
key: 'heyreach_API_KEY',
|
|
244
245
|
adminConfigured: false,
|
|
246
|
+
adminKind: null,
|
|
245
247
|
userConfigured: false,
|
|
246
248
|
...over,
|
|
247
249
|
});
|
|
@@ -330,6 +332,7 @@ describe('ToolConnectionSection', () => {
|
|
|
330
332
|
label: 'Sign-in',
|
|
331
333
|
key: 'heyreach_SIGNIN',
|
|
332
334
|
adminConfigured: true,
|
|
335
|
+
adminKind: 'oauth',
|
|
333
336
|
userConfigured: false,
|
|
334
337
|
oauth: true,
|
|
335
338
|
authorized: false,
|
|
@@ -354,6 +357,7 @@ describe('ToolConnectionSection', () => {
|
|
|
354
357
|
label: null,
|
|
355
358
|
key: 'heyreach_API_KEY',
|
|
356
359
|
adminConfigured: true,
|
|
360
|
+
adminKind: 'static',
|
|
357
361
|
userConfigured: true,
|
|
358
362
|
},
|
|
359
363
|
],
|
|
@@ -388,6 +392,7 @@ describe('ToolConnectionSection', () => {
|
|
|
388
392
|
label: null,
|
|
389
393
|
key: 'github_API_KEY',
|
|
390
394
|
adminConfigured: true,
|
|
395
|
+
adminKind: 'static',
|
|
391
396
|
userConfigured: true,
|
|
392
397
|
},
|
|
393
398
|
],
|
|
@@ -523,6 +528,7 @@ describe('ToolConnectionSection', () => {
|
|
|
523
528
|
label: null,
|
|
524
529
|
key: 'github_API_KEY',
|
|
525
530
|
adminConfigured: true,
|
|
531
|
+
adminKind: 'static',
|
|
526
532
|
userConfigured: false,
|
|
527
533
|
},
|
|
528
534
|
],
|
|
@@ -576,6 +582,7 @@ describe('ToolConnectionSection', () => {
|
|
|
576
582
|
label: null,
|
|
577
583
|
key: 'github_API_KEY',
|
|
578
584
|
adminConfigured: true,
|
|
585
|
+
adminKind: 'static',
|
|
579
586
|
userConfigured: false,
|
|
580
587
|
},
|
|
581
588
|
],
|
|
@@ -742,6 +749,7 @@ describe('ToolConnectionSection', () => {
|
|
|
742
749
|
label: null,
|
|
743
750
|
key: 'github_API_KEY',
|
|
744
751
|
adminConfigured,
|
|
752
|
+
adminKind: adminConfigured ? 'static' : null,
|
|
745
753
|
userConfigured: false,
|
|
746
754
|
},
|
|
747
755
|
],
|
|
@@ -916,6 +924,7 @@ describe('ToolConnectionSection', () => {
|
|
|
916
924
|
label: null,
|
|
917
925
|
key: 'github_SIGNIN',
|
|
918
926
|
adminConfigured: true,
|
|
927
|
+
adminKind: 'oauth',
|
|
919
928
|
userConfigured: false,
|
|
920
929
|
oauth: true,
|
|
921
930
|
authorized: false,
|
|
@@ -928,6 +937,7 @@ describe('ToolConnectionSection', () => {
|
|
|
928
937
|
label: null,
|
|
929
938
|
key: 'github_API_KEY',
|
|
930
939
|
adminConfigured: true,
|
|
940
|
+
adminKind: 'static',
|
|
931
941
|
userConfigured: false,
|
|
932
942
|
...over,
|
|
933
943
|
});
|
|
@@ -963,6 +973,7 @@ describe('ToolConnectionSection', () => {
|
|
|
963
973
|
label: null,
|
|
964
974
|
key: 'github_MY_KEY',
|
|
965
975
|
adminConfigured: false,
|
|
976
|
+
adminKind: null,
|
|
966
977
|
userConfigured: false,
|
|
967
978
|
},
|
|
968
979
|
],
|