@bevel-software/platform-core-frontend 0.28.1 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +11 -4
  2. package/src/core/CoreAppShell.tsx +29 -11
  3. package/src/core/__tests__/ShellRoutes.test.tsx +43 -1
  4. package/src/core/events.ts +4 -2
  5. package/src/core/registry.ts +25 -3
  6. package/src/modules/embed/__tests__/EmbedView.test.tsx +560 -17
  7. package/src/modules/embed/__tests__/embed-config.test.ts +77 -1
  8. package/src/modules/embed/__tests__/mcp-app-view.test.ts +203 -1
  9. package/src/modules/embed/components/EmbedView.tsx +233 -47
  10. package/src/modules/embed/embed-config.ts +126 -2
  11. package/src/modules/embed/embed-host.ts +11 -2
  12. package/src/modules/embed/mount.tsx +1 -0
  13. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +213 -4
  14. package/src/modules/library/__tests__/PluginPage.test.tsx +1 -1
  15. package/src/modules/library/__tests__/SkillPage.test.tsx +10 -0
  16. package/src/modules/library/components/LibraryLayout.tsx +2 -2
  17. package/src/modules/library/components/PluginPage.tsx +2 -1
  18. package/src/modules/library/components/skill-page/SkillPage.tsx +2 -2
  19. package/src/modules/library/components/tool-page/ToolPage.tsx +1 -1
  20. package/src/modules/library/index.ts +18 -0
  21. package/src/modules/library/routes/LibraryRoutes.tsx +17 -1
  22. package/src/modules/library/routes/library-paths.ts +16 -2
  23. package/src/modules/onboarding/__tests__/get-started-column.test.tsx +3 -3
  24. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +39 -32
  25. package/src/modules/secrets-vault/components/SecretsPage.tsx +9 -24
  26. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +111 -8
  27. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +1 -1
  28. package/src/modules/secrets-vault/index.ts +7 -0
  29. package/src/modules/settings/settings-nav-items.tsx +3 -3
  30. package/src/modules/toolbar/commands/__tests__/actions.test.tsx +20 -37
  31. package/src/modules/toolbar/commands/actions.tsx +62 -50
  32. package/src/modules/toolbar/commands/command-menu.ts +37 -3
  33. package/src/modules/toolbar/commands/useCommandShortcuts.ts +29 -76
  34. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +4 -2
  35. package/src/modules/toolbar/components/SearchPalette.tsx +20 -21
  36. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +5 -2
  37. package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +242 -103
  38. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +51 -1
  39. package/src/modules/toolbar/search/__tests__/rank.test.ts +7 -3
  40. package/src/modules/workflow/hooks/__tests__/useFileLock.test.tsx +475 -0
  41. package/src/modules/workflow/hooks/__tests__/useFileLock.wire.test.tsx +115 -0
  42. package/src/modules/workflow/hooks/useFileLock.ts +321 -57
  43. package/src/modules/workflow/index.ts +8 -0
  44. package/src/modules/workflow/services/__tests__/lock.api.test.ts +4 -0
  45. package/src/modules/workflow/services/lock.api.ts +28 -9
  46. package/src/modules/workspace/components/FileViewer.tsx +30 -16
  47. package/src/modules/workspace/components/KbPageHeader.tsx +8 -1
  48. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +107 -4
  49. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +12 -0
  50. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +118 -13
  51. package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.test.tsx +189 -0
  52. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +9 -0
  53. package/src/modules/workspace/components/renderers/__tests__/kbGraphLoader.test.tsx +60 -0
  54. package/src/modules/workspace/components/renderers/frameResizeHandle.ts +116 -0
  55. package/src/modules/workspace/components/renderers/index.ts +6 -0
  56. package/src/modules/workspace/components/renderers/kbGraphLoader.ts +27 -0
  57. package/src/modules/workspace/components/renderers/lazyRenderer.tsx +1 -1
  58. package/src/modules/workspace/components/renderers/rendererSurface.ts +19 -0
  59. package/src/modules/workspace/index.ts +33 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bevel-software/platform-core-frontend",
3
- "version": "0.28.1",
3
+ "version": "0.30.0",
4
4
  "description": "Open-source core UI of the Bevel platform (raw TS/TSX source): workspace explorer/viewer, branches & change requests, Library, secrets, tools, access control.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -45,9 +45,13 @@
45
45
  "tailwind-merge": "^3.5.0",
46
46
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
47
47
  "yaml": "^2.9.0",
48
- "@bevel-software/platform-shared": "0.28.1"
48
+ "@bevel-software/platform-shared": "0.30.0"
49
49
  },
50
50
  "devDependencies": {
51
+ "@modelcontextprotocol/client": "^2.3.1",
52
+ "@modelcontextprotocol/core": "^2.3.1",
53
+ "@modelcontextprotocol/ext-apps": "2.0.3",
54
+ "@playwright/test": "^1.64.0",
51
55
  "@testing-library/jest-dom": "^6.9.1",
52
56
  "@testing-library/react": "^16.3.2",
53
57
  "@testing-library/user-event": "^14.6.1",
@@ -59,7 +63,9 @@
59
63
  "react-router-dom": "^7.1.1",
60
64
  "tailwindcss": "^4.2.2",
61
65
  "typescript": "~5.9.3",
62
- "vitest": "^3.2.6"
66
+ "vite": "^6.4.3",
67
+ "vitest": "^3.2.6",
68
+ "zod": "^4.4.3"
63
69
  },
64
70
  "license": "Apache-2.0",
65
71
  "repository": {
@@ -72,6 +78,7 @@
72
78
  },
73
79
  "scripts": {
74
80
  "typecheck": "tsc -p tsconfig.json --noEmit",
75
- "test": "vitest run"
81
+ "test": "vitest run",
82
+ "test:browser": "playwright test -c browser/playwright.config.ts"
76
83
  }
77
84
  }
@@ -29,6 +29,7 @@ import { FileViewer } from '../modules/workspace/components/FileViewer';
29
29
  import { OpenChangeRequestsProvider } from '../modules/workspace/state/open-change-requests';
30
30
  import { FileRoute } from '../modules/workspace/components/FileRoute';
31
31
  import { KB_ROUTE_PREFIX } from '../modules/workspace/routing/kb-routes';
32
+ import { CONNECT_TOOLS_PATH } from '../modules/library';
32
33
  import { AppLayout } from '../modules/layout/components/AppLayout';
33
34
  import {
34
35
  LayoutContext,
@@ -38,7 +39,6 @@ import {
38
39
  import { MaintenanceOverlay } from '../modules/layout/components/MaintenanceOverlay';
39
40
  import { AdminProvider } from '../modules/admin/state/admin.context';
40
41
  import { RolesCorruptedBanner } from '../modules/admin/components/RolesCorruptedBanner';
41
- import { ConnectToolsPage } from '../modules/secrets-vault/components/ConnectToolsPage';
42
42
  import { SettingsLayout } from '../modules/settings/components/SettingsLayout';
43
43
  import { DeploymentPage } from '../modules/settings/components/DeploymentPage';
44
44
  import { SecretsPage } from '../modules/secrets-vault/components/SecretsPage';
@@ -416,9 +416,9 @@ export function AppChrome() {
416
416
  * still wins over it).
417
417
  * - The standalone settings pages — full pages under the toolbar, outside
418
418
  * any app surface (activeAppId is undefined there, so the switcher shows
419
- * no checkmark and the pane toggles hide via NO_PANES_LAYOUT). `/connect`
420
- * and `/secrets` are OAuth return targets: external redirects land on
421
- * these exact URLs, so they must stay routes with these exact paths.
419
+ * no checkmark and the pane toggles hide via NO_PANES_LAYOUT). `/secrets`
420
+ * is an OAuth return target: external redirects land on this exact URL,
421
+ * so it must stay a route with this exact path.
422
422
  *
423
423
  * They now share a persistent nav via a PATHLESS `SettingsLayout` route,
424
424
  * so moving between them no longer means re-opening the profile menu. They
@@ -429,12 +429,26 @@ export function AppChrome() {
429
429
  * reachable, so a non-admin who follows a link gets the explanatory
430
430
  * "Admins only" page rather than a silent redirect to somewhere they did
431
431
  * not ask for. The nav merely declines to advertise the rows.
432
+ * - `/connect`, a permanent redirect to "Connect your tools", which is a
433
+ * Skills & Tools page (`CONNECT_TOOLS_PATH`). The server still hands out
434
+ * `/connect` — MCP consent, the claude.ai hand-off, tool sign-in returns,
435
+ * agents' "sign in again" links — so the redirect stays for as long as any
436
+ * server code writes that address.
432
437
  * - Redirects: `/` → `/workspace`, and a final catch-all for anything
433
438
  * unknown (including the retired `/library` path).
434
439
  *
435
440
  * Extracted from AppChrome so the routing behavior is testable without the
436
441
  * full provider stack.
437
442
  */
443
+ /**
444
+ * `/connect` → `/skills-and-tools/connect`, keeping the query and fragment, as
445
+ * a REPLACE: Back must not return to an address that only bounces forward.
446
+ */
447
+ function ConnectToolsRedirect() {
448
+ const { search, hash } = useLocation();
449
+ return <Navigate to={`${CONNECT_TOOLS_PATH}${search}${hash}`} replace />;
450
+ }
451
+
438
452
  export function ShellRoutes({ apps }: { apps: AppDef[] }) {
439
453
  return (
440
454
  <Routes>
@@ -445,11 +459,15 @@ export function ShellRoutes({ apps }: { apps: AppDef[] }) {
445
459
  element={app.element}
446
460
  />
447
461
  ))}
448
- {/* OUTSIDE the settings layout, deliberately. `/connect` is a flow page,
449
- not a settings destination: it has no row in the profile menu, it is
450
- an OAuth landing target, and in its agent-connect mode somebody else
451
- is blocked waiting on a Finish button. Do not "complete the set". */}
452
- <Route path="/connect" element={<ConnectToolsPage />} />
462
+ {/* OUTSIDE the settings layout, deliberately. "Connect your tools" is a
463
+ flow page, not a settings destination: it has no row in the profile
464
+ menu, it is an OAuth landing target, and in its agent-connect mode
465
+ somebody else is blocked waiting on a Finish button. Do not
466
+ "complete the set". It is a Skills & Tools page instead, and
467
+ `/connect` — the address the server hands out — is its permanent
468
+ redirect, carrying the query (`?oauth=`) and the fragment
469
+ (`#authorized`, `#error=`) those landings depend on. */}
470
+ <Route path="/connect" element={<ConnectToolsRedirect />} />
453
471
  {/* A PATHLESS layout route: the child paths below stay byte-identical,
454
472
  which is what keeps `/secrets` the exact URL external OAuth redirects
455
473
  land on. Its only job is to keep the settings nav mounted across
@@ -494,8 +512,8 @@ export function ShellRoutes({ apps }: { apps: AppDef[] }) {
494
512
  every summary's `url`). It opens the request itself, in the
495
513
  change-request view, over a quiet page; closing it goes to Knowledge.
496
514
  Before this route existed the catch-all below swallowed the link.
497
- OUTSIDE the settings layout and the apps, like `/connect`: a landing
498
- target, not a destination with a nav row. */}
515
+ OUTSIDE the settings layout and the apps, like the `/connect`
516
+ redirect: a landing target, not a destination with a nav row. */}
499
517
  <Route path="/change-requests/:number" element={<ChangeRequestLink />} />
500
518
  <Route path="*" element={<Navigate to={KB_ROUTE_PREFIX} replace />} />
501
519
  </Routes>
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import { MemoryRouter, useLocation } from 'react-router-dom';
3
+ import { MemoryRouter, useLocation, useNavigationType } from 'react-router-dom';
4
4
  import { ShellRoutes } from '../CoreAppShell';
5
5
  import type { AppDef } from '../registry';
6
6
 
@@ -150,3 +150,45 @@ describe('ShellRoutes — the change-request address', () => {
150
150
  expect(screen.queryByTestId('knowledge-surface')).not.toBeInTheDocument();
151
151
  });
152
152
  });
153
+
154
+ describe('ShellRoutes — /connect', () => {
155
+ /** The whole address, and how the router got there. */
156
+ function AddressProbe() {
157
+ const { pathname, search, hash } = useLocation();
158
+ return (
159
+ <>
160
+ <div data-testid="address">{pathname + search + hash}</div>
161
+ <div data-testid="navigation">{useNavigationType()}</div>
162
+ </>
163
+ );
164
+ }
165
+
166
+ function renderConnect(path: string) {
167
+ return render(
168
+ <MemoryRouter initialEntries={[path]}>
169
+ <ShellRoutes apps={apps} />
170
+ <AddressProbe />
171
+ </MemoryRouter>,
172
+ );
173
+ }
174
+
175
+ // The server keeps handing out `/connect` — MCP consent (`?oauth=`), tool
176
+ // sign-in returns (`#authorized`, `#error=`) — and each of those depends on
177
+ // what rides along, so the redirect must carry the query AND the fragment.
178
+ it.each([
179
+ ['/connect', '/skills-and-tools/connect'],
180
+ ['/connect?oauth=abc&x=1#authorized=1', '/skills-and-tools/connect?oauth=abc&x=1#authorized=1'],
181
+ ['/connect#error=Nope.', '/skills-and-tools/connect#error=Nope.'],
182
+ ['/connect?from=agent', '/skills-and-tools/connect?from=agent'],
183
+ ])('sends %s to %s inside Skills & Tools', (from, to) => {
184
+ renderConnect(from);
185
+ expect(screen.getByTestId('address').textContent).toBe(to);
186
+ expect(screen.getByTestId('skills-surface')).toBeInTheDocument();
187
+ });
188
+
189
+ // Back must not land on an address that only bounces forward again.
190
+ it('replaces the history entry rather than pushing one', () => {
191
+ renderConnect('/connect?oauth=abc');
192
+ expect(screen.getByTestId('navigation')).toHaveTextContent('REPLACE');
193
+ });
194
+ });
@@ -102,8 +102,10 @@ export interface OpenComparisonDetail {
102
102
  * the write until the reader reaches for the browser's own reload button.
103
103
  *
104
104
  * An event rather than a direct call because the writing surfaces do not all
105
- * live under the Library's provider: `/connect` and `/secrets` are shell
106
- * routes of their own, so there is nothing to reach for from inside them.
105
+ * live under the Library's provider: `/secrets` and the `.tool` editor in
106
+ * Knowledge (`ToolRenderer`) are outside it, so there is nothing to reach for
107
+ * from inside them. (The Library's own tool page and "Connect your tools" are
108
+ * inside it, but announce the same way.)
107
109
  * Announcing regardless keeps ONE rule for every surface — with no listener
108
110
  * the announcement is simply unheard, which is the right outcome for a
109
111
  * provider that will refetch on its next mount anyway.
@@ -560,16 +560,38 @@ export interface AppRegistry {
560
560
  * Commands a distribution adds to the toolbar's command menu (Ctrl/⌘K),
561
561
  * listed after core's own.
562
562
  *
563
- * Core's commands are the verbs every deployment has — New page, Invite
564
- * people, the apps, the settings pages. A verb like "New ontology" belongs
563
+ * Core's commands are the verbs every deployment has — Create new page,
564
+ * Invite people, the apps, the settings pages. A verb like "New ontology" belongs
565
565
  * to the distribution that has ontologies, so core offers the place rather
566
566
  * than the command, as it does for folder-menu entries. Each one is plain
567
567
  * data plus `visible` and `run`, both handed the menu's context (router,
568
568
  * admin verdict, page on screen) — see `CommandAction`. An id core already
569
- * uses is dropped; a `visible` that throws costs only its own row. Absent
569
+ * uses is dropped; a `visible` that throws costs only its own row. A
570
+ * command's `shortcut` is one letter, with or without Shift
571
+ * (`{ key: 'o', shift: true }`); one that is not, or that takes a key
572
+ * already bound, is dropped with its hint. Absent
570
573
  * means the menu offers core's commands and no others.
571
574
  */
572
575
  commandActions?: CommandAction[];
576
+ /**
577
+ * Where a renderer that draws the knowledge graph (a dashboard's HTML)
578
+ * gets the graph from, on each surface it can be mounted on: the app,
579
+ * where the reader's session reads it, and the embed, where only the
580
+ * embed token does. Core has no graph; a distribution that has one
581
+ * registers both, and its renderer asks `useKbGraphLoader` — which
582
+ * answers `inEmbed` through the embed's surface and `inApp` in the app —
583
+ * rather than any address, so the same renderer draws inside a chat or an
584
+ * issue panel as it draws in the app.
585
+ */
586
+ kbGraphSource?: KbGraphSource;
587
+ }
588
+
589
+ /** See {@link AppRegistry.kbGraphSource}. What the graph is, is the distribution's; core carries it as is. */
590
+ export interface KbGraphSource {
591
+ /** The graph as the signed-in reader may see it, for `workspaceId`. */
592
+ inApp(workspaceId: string): Promise<unknown>;
593
+ /** The graph as the embed token's viewer may see it. */
594
+ inEmbed(token: string): Promise<unknown>;
573
595
  }
574
596
 
575
597
  export const EMPTY_REGISTRY: AppRegistry = {