@bevel-software/platform-core-frontend 0.7.4 → 0.8.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 (113) hide show
  1. package/LICENSE +202 -202
  2. package/THIRD-PARTY-NOTICES.md +344 -988
  3. package/package.json +5 -5
  4. package/src/core/CoreAppShell.tsx +4 -4
  5. package/src/core/__tests__/ShellRoutes.test.tsx +1 -1
  6. package/src/core/__tests__/bootstrap.test.ts +47 -2
  7. package/src/core/bootstrap.ts +20 -0
  8. package/src/css-side-effect-imports.d.ts +7 -7
  9. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +1 -1
  10. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +5 -5
  11. package/src/modules/access/api.ts +5 -5
  12. package/src/modules/access/components/ManageAccessDialog.tsx +21 -20
  13. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  14. package/src/modules/admin/components/AdminRolesPage.tsx +1 -1
  15. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +2 -2
  16. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
  17. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
  18. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +4 -4
  19. package/src/modules/layout/__tests__/SidebarToggle.test.tsx +4 -4
  20. package/src/modules/layout/__tests__/breakpoints.test.ts +1 -1
  21. package/src/modules/layout/components/SidebarFrame.tsx +2 -2
  22. package/src/modules/library/__tests__/{AddToGroupDialog.test.tsx → AddToPluginDialog.test.tsx} +34 -34
  23. package/src/modules/library/__tests__/LibraryCard.test.tsx +30 -11
  24. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +84 -59
  25. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +51 -51
  26. package/src/modules/library/__tests__/{LockedGroupView.test.tsx → LockedPluginView.test.tsx} +33 -33
  27. package/src/modules/library/__tests__/McpServerSection.test.tsx +138 -0
  28. package/src/modules/library/__tests__/{NewGroupDialog.test.tsx → NewPluginDialog.test.tsx} +22 -22
  29. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +7 -7
  30. package/src/modules/library/__tests__/PluginExtras.test.tsx +131 -0
  31. package/src/modules/library/__tests__/{GroupJoinRequests.test.tsx → PluginJoinRequests.test.tsx} +24 -24
  32. package/src/modules/library/__tests__/{GroupPage.test.tsx → PluginPage.test.tsx} +101 -101
  33. package/src/modules/library/__tests__/{GroupsIndexPage.test.tsx → PluginsIndexPage.test.tsx} +57 -57
  34. package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +31 -31
  35. package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +28 -28
  36. package/src/modules/library/__tests__/{GroupsSidebar.test.tsx → PluginsSidebar.test.tsx} +39 -39
  37. package/src/modules/library/__tests__/{GroupsSidebarMenu.test.tsx → PluginsSidebarMenu.test.tsx} +18 -18
  38. package/src/modules/library/__tests__/SkillPage.test.tsx +8 -8
  39. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +2 -2
  40. package/src/modules/library/__tests__/ToolPage.test.tsx +41 -12
  41. package/src/modules/library/__tests__/ToolSharePanel.test.tsx +1 -1
  42. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +57 -57
  43. package/src/modules/library/__tests__/auth-harness.tsx +4 -4
  44. package/src/modules/library/__tests__/status.test.ts +19 -19
  45. package/src/modules/library/__tests__/tools.api.test.ts +70 -0
  46. package/src/modules/library/__tests__/useToolPage.test.tsx +4 -4
  47. package/src/modules/library/components/AccessRequestsBanner.tsx +8 -8
  48. package/src/modules/library/components/{AddToGroupDialog.tsx → AddToPluginDialog.tsx} +11 -11
  49. package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
  50. package/src/modules/library/components/{DeleteGroupDialog.tsx → DeletePluginDialog.tsx} +9 -9
  51. package/src/modules/library/components/LibraryCard.tsx +26 -2
  52. package/src/modules/library/components/LibraryLayout.tsx +70 -70
  53. package/src/modules/library/components/LibraryPage.tsx +8 -8
  54. package/src/modules/library/components/LockGlyph.tsx +1 -1
  55. package/src/modules/library/components/{LockedGroupView.tsx → LockedPluginView.tsx} +35 -35
  56. package/src/modules/library/components/{ManagedGroupRequests.tsx → ManagedPluginRequests.tsx} +13 -13
  57. package/src/modules/library/components/{NewGroupDialog.tsx → NewPluginDialog.tsx} +24 -24
  58. package/src/modules/library/components/NewSkillPanel.tsx +5 -5
  59. package/src/modules/library/components/PageActions.tsx +3 -3
  60. package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
  61. package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +17 -17
  62. package/src/modules/library/components/PluginExtras.tsx +195 -0
  63. package/src/modules/library/components/{GroupIndexRow.tsx → PluginIndexRow.tsx} +6 -6
  64. package/src/modules/library/components/{GroupJoinRequests.tsx → PluginJoinRequests.tsx} +12 -12
  65. package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +72 -69
  66. package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +46 -46
  67. package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +55 -55
  68. package/src/modules/library/components/{GroupsSidebarMenu.tsx → PluginsSidebarMenu.tsx} +15 -15
  69. package/src/modules/library/components/{group-page-parts.tsx → plugin-page-parts.tsx} +35 -24
  70. package/src/modules/library/components/skill-page/SkillPage.tsx +12 -12
  71. package/src/modules/library/components/tool-page/McpServerSection.tsx +380 -0
  72. package/src/modules/library/components/tool-page/ToolPage.tsx +22 -5
  73. package/src/modules/library/hooks/useJoinRequests.ts +8 -8
  74. package/src/modules/library/routes/LibraryRoutes.tsx +30 -17
  75. package/src/modules/library/routes/WorkspaceItemRoute.tsx +24 -24
  76. package/src/modules/library/routes/library-paths.ts +36 -36
  77. package/src/modules/library/services/library.api.ts +9 -9
  78. package/src/modules/library/services/{groups.api.ts → plugins.api.ts} +43 -43
  79. package/src/modules/library/services/tools.api.ts +54 -0
  80. package/src/modules/library/state/library-data.tsx +46 -46
  81. package/src/modules/library/utils/names.ts +1 -1
  82. package/src/modules/library/utils/{personal-group.ts → personal-plugin.ts} +8 -8
  83. package/src/modules/library/utils/{group-summary.ts → plugin-summary.ts} +14 -14
  84. package/src/modules/library/utils/status.ts +17 -17
  85. package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
  86. package/src/modules/onboarding/agent-clients.ts +18 -14
  87. package/src/modules/onboarding/components/WelcomePage.tsx +19 -8
  88. package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -1
  89. package/src/modules/review/components/ReviewPanel.tsx +11 -11
  90. package/src/modules/review/components/__tests__/{isGroupItemPath.test.ts → isPluginItemPath.test.ts} +24 -24
  91. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +3 -3
  92. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +1 -1
  93. package/src/modules/settings/components/SettingsLayout.tsx +1 -1
  94. package/src/modules/settings/components/SettingsNav.tsx +5 -5
  95. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +29 -107
  96. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +1 -1
  97. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +228 -0
  98. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +3 -3
  99. package/src/modules/workspace/components/FileExplorer.tsx +12 -12
  100. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
  101. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
  102. package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
  103. package/src/modules/workspace/utils/fileTree.ts +3 -3
  104. package/src/shared/mcp/ClaudeInstallLink.tsx +88 -0
  105. package/src/shared/mcp/ConnectionInstructions.tsx +51 -0
  106. package/src/shared/mcp/CopyBlock.tsx +42 -0
  107. package/src/shared/mcp/__tests__/ClaudeInstallLink.test.tsx +40 -0
  108. package/src/shared/mcp/__tests__/connect-snippets.test.ts +431 -0
  109. package/src/shared/mcp/__tests__/useCopyFeedback.test.ts +112 -0
  110. package/src/shared/mcp/connect-snippets.ts +353 -0
  111. package/src/shared/mcp/index.ts +28 -0
  112. package/src/shared/mcp/useCopyFeedback.ts +46 -0
  113. package/src/test-setup.ts +11 -0
@@ -3,22 +3,22 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
3
  import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
4
4
 
5
5
  /**
6
- * Making a group.
6
+ * Making a plugin.
7
7
  *
8
- * A group comes from the dedicated provisioning endpoint — the server owns
8
+ * A plugin comes from the dedicated provisioning endpoint — the server owns
9
9
  * the folder, the seeded access.md and the commit. What is worth testing here
10
10
  * is the two refusals the dialog can reach before the call — a name that
11
- * collides with a group you cannot even see, and a name that would create a
11
+ * collides with a plugin you cannot even see, and a name that would create a
12
12
  * nested folder — plus the fact that the caller lands somewhere real
13
13
  * afterwards, and that the server's own refusal is what the toast shows.
14
14
  */
15
15
 
16
- const groupsMock = vi.hoisted(() => ({ createGroup: vi.fn() }));
17
- vi.mock('../services/groups.api', () => ({
18
- createGroup: groupsMock.createGroup,
16
+ const pluginsMock = vi.hoisted(() => ({ createPlugin: vi.fn() }));
17
+ vi.mock('../services/plugins.api', () => ({
18
+ createPlugin: pluginsMock.createPlugin,
19
19
  }));
20
20
 
21
- import { NewGroupDialog } from '../components/NewGroupDialog';
21
+ import { NewPluginDialog } from '../components/NewPluginDialog';
22
22
  import { LibraryToastProvider } from '../state/toast';
23
23
 
24
24
  function LocationProbe() {
@@ -36,7 +36,7 @@ function renderDialog(existing: string[] = ['GTM', 'Finance']) {
36
36
  <Route
37
37
  path="*"
38
38
  element={
39
- <NewGroupDialog existing={existing} onClose={onClose} onCreated={onCreated} />
39
+ <NewPluginDialog existing={existing} onClose={onClose} onCreated={onCreated} />
40
40
  }
41
41
  />
42
42
  </Routes>
@@ -47,42 +47,42 @@ function renderDialog(existing: string[] = ['GTM', 'Finance']) {
47
47
  return {
48
48
  onCreated,
49
49
  onClose,
50
- field: () => screen.getByRole('textbox', { name: 'Group name' }),
51
- submit: () => screen.getByRole('button', { name: /Create group|Creating/ }),
50
+ field: () => screen.getByRole('textbox', { name: 'Plugin name' }),
51
+ submit: () => screen.getByRole('button', { name: /Create plugin|Creating/ }),
52
52
  pathname: () => screen.getByLabelText('pathname').textContent,
53
53
  };
54
54
  }
55
55
 
56
- describe('NewGroupDialog', () => {
56
+ describe('NewPluginDialog', () => {
57
57
  beforeEach(() => {
58
- groupsMock.createGroup.mockReset();
58
+ pluginsMock.createPlugin.mockReset();
59
59
  // A folder name that DIFFERS from the input, so a dialog that navigates
60
60
  // with the typed name instead of the server's answer fails here.
61
- groupsMock.createGroup.mockImplementation(async (name: string) => ({
61
+ pluginsMock.createPlugin.mockImplementation(async (name: string) => ({
62
62
  folder: `${name}-canonical`,
63
63
  }));
64
64
  });
65
65
 
66
- it('will not create an unnamed group', () => {
66
+ it('will not create an unnamed plugin', () => {
67
67
  const { submit } = renderDialog();
68
68
  expect(submit()).toBeDisabled();
69
69
  });
70
70
 
71
- it('creates the folder under Groups/ and opens the new group', async () => {
71
+ it('creates the folder under Plugins/ and opens the new plugin', async () => {
72
72
  const { field, submit, onCreated, pathname } = renderDialog();
73
73
  fireEvent.change(field(), { target: { value: ' Design ' } });
74
74
  fireEvent.click(submit());
75
75
 
76
76
  // Trimmed — the endpoint owns everything after the name.
77
- await waitFor(() => expect(groupsMock.createGroup).toHaveBeenCalledWith('Design'));
77
+ await waitFor(() => expect(pluginsMock.createPlugin).toHaveBeenCalledWith('Design'));
78
78
  // The route is built from the SERVER's folder, not the typed name.
79
- await waitFor(() => expect(pathname()).toBe('/skills-and-tools/groups/Design-canonical'));
79
+ await waitFor(() => expect(pathname()).toBe('/skills-and-tools/plugins/Design-canonical'));
80
80
  expect(onCreated).toHaveBeenCalledTimes(1);
81
81
  });
82
82
 
83
83
  it('refuses a name that is already taken, whoever can see it', () => {
84
- // `existing` carries LOCKED groups too. Creating `Groups/Finance` when a
85
- // Finance you cannot read exists would not make a group — it would put
84
+ // `existing` carries LOCKED plugins too. Creating `Plugins/Finance` when a
85
+ // Finance you cannot read exists would not make a plugin — it would put
86
86
  // your items in somebody else's.
87
87
  const { field, submit } = renderDialog(['GTM', 'Finance']);
88
88
  fireEvent.change(field(), { target: { value: 'finance' } });
@@ -91,7 +91,7 @@ describe('NewGroupDialog', () => {
91
91
  });
92
92
 
93
93
  it('refuses a name that would create a nested folder', () => {
94
- // `Groups/A/B` would be read back by `groupOfPath` as the group "A".
94
+ // `Plugins/A/B` would be read back by `pluginOfPath` as the plugin "A".
95
95
  const { field, submit } = renderDialog();
96
96
  fireEvent.change(field(), { target: { value: 'GTM/EMEA' } });
97
97
  expect(screen.getByRole('alert')).toHaveTextContent('/');
@@ -101,8 +101,8 @@ describe('NewGroupDialog', () => {
101
101
  it("shows the server's own refusal and stays open", async () => {
102
102
  // The server's check runs against the live tree (ours against a stale
103
103
  // catalog), so ITS words are the ones worth showing.
104
- groupsMock.createGroup.mockRejectedValue(
105
- new Error('Group names starting with "personal-" are reserved.'),
104
+ pluginsMock.createPlugin.mockRejectedValue(
105
+ new Error('Plugin names starting with "personal-" are reserved.'),
106
106
  );
107
107
  const { field, submit, onClose } = renderDialog();
108
108
  fireEvent.change(field(), { target: { value: 'personal-notes' } });
@@ -16,7 +16,7 @@ import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
16
16
  * It carried one door until now — copy a prompt — because its first half used
17
17
  * to be a LINK into the destination folder and this page is defined as the
18
18
  * items in no folder. Writing needs no such destination: an ungrouped skill
19
- * lives in the caller's own `Groups/personal-<id>/` folder, so the door is back.
19
+ * lives in the caller's own `Plugins/personal-<id>/` folder, so the door is back.
20
20
  *
21
21
  * The load-bearing assertion is that it creates DIRECTLY. A skill you make
22
22
  * here is yours — the new folder's `access.md` is seeded naming you as owner
@@ -96,8 +96,8 @@ describe('PersonalAddDialog', () => {
96
96
  beforeEach(() => {
97
97
  apiMock.createEmptySkill.mockReset();
98
98
  apiMock.createEmptySkill.mockResolvedValue({
99
- repoRelativePath: 'Groups/scratch/SKILL.md',
100
- workspacePath: 'knowledge-base/Groups/scratch/SKILL.md',
99
+ repoRelativePath: 'Plugins/scratch/SKILL.md',
100
+ workspacePath: 'knowledge-base/Plugins/scratch/SKILL.md',
101
101
  branch: 'target-company-state',
102
102
  direct: true,
103
103
  });
@@ -115,7 +115,7 @@ describe('PersonalAddDialog', () => {
115
115
  const { field } = renderDialog();
116
116
  expect(field()).toBeInTheDocument();
117
117
  expect(screen.getByRole('button', { name: 'Copy prompt' })).toBeInTheDocument();
118
- expect(screen.getByText(/Yours alone until you add it to a group/)).toBeInTheDocument();
118
+ expect(screen.getByText(/Yours alone until you add it to a plugin/)).toBeInTheDocument();
119
119
  });
120
120
 
121
121
  it('creates the skill as PERSONAL. Destination resolution belongs to the api layer', async () => {
@@ -134,7 +134,7 @@ describe('PersonalAddDialog', () => {
134
134
  // The skill's own library page, editor invited open — not the Knowledge app.
135
135
  // The canonical address: the new SKILL.md's own workspace URL.
136
136
  await waitFor(() =>
137
- expect(href()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Groups/scratch/SKILL.md`),
137
+ expect(href()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Plugins/scratch/SKILL.md`),
138
138
  );
139
139
  expect(onClose).toHaveBeenCalledTimes(1);
140
140
  });
@@ -156,7 +156,7 @@ describe('PersonalAddDialog', () => {
156
156
  expect(screen.queryByText(/sent for review/)).not.toBeInTheDocument();
157
157
  });
158
158
 
159
- it('refuses a name a group’s skill already holds', async () => {
159
+ it('refuses a name a plugin’s skill already holds', async () => {
160
160
  const { field, create } = renderDialog(['rfi']);
161
161
  fireEvent.change(field(), { target: { value: 'RFI' } });
162
162
  expect(screen.getByRole('alert')).toHaveTextContent('already exists');
@@ -171,7 +171,7 @@ describe('PersonalAddDialog', () => {
171
171
  expect(screen.queryByRole('textbox', { name: 'Skill name' })).not.toBeInTheDocument();
172
172
  expect(screen.getByRole('button', { name: 'Copy prompt' })).toBeInTheDocument();
173
173
  expect(screen.getByText(/Tell your agent what you need/)).toBeInTheDocument();
174
- expect(screen.getByText(/Yours alone until you add it to a group/)).toBeInTheDocument();
174
+ expect(screen.getByText(/Yours alone until you add it to a plugin/)).toBeInTheDocument();
175
175
  expect(apiMock.createEmptySkill).not.toHaveBeenCalled();
176
176
  });
177
177
  });
@@ -0,0 +1,131 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import { DEFAULT_BRANCH, type FileTreeEntry } from '@bevel-software/platform-shared';
5
+ import {
6
+ WorkspaceContext,
7
+ type WorkspaceContextValue,
8
+ } from '../../workspace/state/workspace.context';
9
+
10
+ /**
11
+ * The client-extensions section's tree source. The section pins its listing to
12
+ * the default branch; what is under test is WHERE that tree comes from — the
13
+ * workspace context's already-loaded tree when the context sits on the default
14
+ * branch (no request at all), the fetch only when it sits elsewhere.
15
+ */
16
+
17
+ const apiMock = vi.hoisted(() => ({ listFiles: vi.fn() }));
18
+ vi.mock('../../workspace/services/workspace.api', async (importOriginal) => ({
19
+ ...(await importOriginal<object>()),
20
+ listFiles: apiMock.listFiles,
21
+ }));
22
+
23
+ const navigateMock = vi.hoisted(() => vi.fn());
24
+ vi.mock('react-router-dom', async (importOriginal) => ({
25
+ ...(await importOriginal<object>()),
26
+ useNavigate: () => navigateMock,
27
+ }));
28
+
29
+ import { ClientExtensionsSection } from '../components/PluginExtras';
30
+
31
+ const dir = (name: string, children: FileTreeEntry[]): FileTreeEntry =>
32
+ ({ name, relativePath: name, type: 'directory', children }) as FileTreeEntry;
33
+ const file = (name: string): FileTreeEntry =>
34
+ ({ name, relativePath: name, type: 'file' }) as FileTreeEntry;
35
+
36
+ /** A tree whose GTM plugin carries one foreign namespace dir. */
37
+ const TREE: FileTreeEntry = dir('root', [
38
+ dir('knowledge-base', [
39
+ dir('Plugins', [
40
+ dir('GTM', [
41
+ dir('com.example.client', [dir('hooks', [file('on-save.js')])]),
42
+ dir('outreach', [file('SKILL.md')]),
43
+ ]),
44
+ dir('Product', [dir('roadmap', [file('SKILL.md')])]),
45
+ ]),
46
+ ]),
47
+ ]);
48
+
49
+ function renderSection(workspace: Partial<WorkspaceContextValue>, folder = 'GTM') {
50
+ return render(
51
+ <MemoryRouter>
52
+ <WorkspaceContext.Provider value={workspace as WorkspaceContextValue}>
53
+ <ClientExtensionsSection kbDirName="knowledge-base" folder={folder} />
54
+ </WorkspaceContext.Provider>
55
+ </MemoryRouter>,
56
+ );
57
+ }
58
+
59
+ beforeEach(() => {
60
+ apiMock.listFiles.mockReset();
61
+ navigateMock.mockReset();
62
+ });
63
+
64
+ describe('ClientExtensionsSection', () => {
65
+ it('reuses the context tree when the workspace sits on the default branch — no fetch', async () => {
66
+ renderSection({ workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: TREE });
67
+ expect(await screen.findByText('com.example.client/')).toBeInTheDocument();
68
+ expect(screen.getByRole('button', { name: 'hooks/on-save.js' })).toBeInTheDocument();
69
+ expect(apiMock.listFiles).not.toHaveBeenCalled();
70
+ });
71
+
72
+ it('fetches the default-branch tree when the context sits on a draft branch', async () => {
73
+ // A draft's tree could list files the section's default-branch links
74
+ // cannot open — the fetch is the correctness fallback, not the norm.
75
+ apiMock.listFiles.mockResolvedValue(TREE);
76
+ renderSection({ workspaceId: 'draft-my-changes', fileTree: dir('root', []) });
77
+ expect(await screen.findByText('com.example.client/')).toBeInTheDocument();
78
+ expect(apiMock.listFiles).toHaveBeenCalledWith(encodeURIComponent(DEFAULT_BRANCH));
79
+ });
80
+
81
+ /**
82
+ * The fileTree can carry workspace/KB-clone wrapper levels above the kb dir
83
+ * (`findKbRoot` exists for exactly this shape). The section must find the
84
+ * plugin's namespace dirs through them, not assume the root's direct child
85
+ * is the kb dir.
86
+ */
87
+ it('finds the namespace dirs through wrapper levels above the kb dir', async () => {
88
+ const wrapped = dir('root', [dir('workspace-clone', TREE.children ?? [])]);
89
+ renderSection({ workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: wrapped });
90
+ expect(await screen.findByText('com.example.client/')).toBeInTheDocument();
91
+ expect(screen.getByRole('button', { name: 'hooks/on-save.js' })).toBeInTheDocument();
92
+ });
93
+
94
+ /**
95
+ * `rawFile` steps past the app gate into the Knowledge editor — right for
96
+ * opaque client data, wrong for a `.tool`, which has a first-class tool
97
+ * page in this app. The same URL without the state renders that page.
98
+ */
99
+ it('opens a .tool in the library (no rawFile), other files in the Knowledge editor', async () => {
100
+ const withTool: FileTreeEntry = dir('root', [
101
+ dir('knowledge-base', [
102
+ dir('Plugins', [
103
+ dir('GTM', [
104
+ dir('com.example.client', [dir('hooks', [file('on-save.js')])]),
105
+ dir('software.bevel.hexis', [dir('tools', [file('web-search.tool')])]),
106
+ ]),
107
+ ]),
108
+ ]),
109
+ ]);
110
+ renderSection({ workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: withTool });
111
+ fireEvent.click(await screen.findByRole('button', { name: 'tools/web-search.tool' }));
112
+ expect(navigateMock).toHaveBeenLastCalledWith(
113
+ expect.stringContaining('web-search.tool'),
114
+ undefined,
115
+ );
116
+ fireEvent.click(screen.getByRole('button', { name: 'hooks/on-save.js' }));
117
+ expect(navigateMock).toHaveBeenLastCalledWith(
118
+ expect.stringContaining('on-save.js'),
119
+ { state: { rawFile: true } },
120
+ );
121
+ });
122
+
123
+ it('renders nothing for a plugin with no namespace dirs, still without fetching', async () => {
124
+ const { container } = renderSection(
125
+ { workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: TREE },
126
+ 'Product',
127
+ );
128
+ await waitFor(() => expect(container).toBeEmptyDOMElement());
129
+ expect(apiMock.listFiles).not.toHaveBeenCalled();
130
+ });
131
+ });
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect, beforeEach, vi } from 'vitest';
2
2
  import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
3
  import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
4
- import type { JoinRequest } from '../services/groups.api';
4
+ import type { JoinRequest } from '../services/plugins.api';
5
5
 
6
6
  /**
7
7
  * The manager-side join-request surface.
@@ -11,13 +11,13 @@ import type { JoinRequest } from '../services/groups.api';
11
11
  * branch untouched. The request then settles itself server-side, which this
12
12
  * surface only has to ask about.
13
13
  */
14
- const groupsMock = vi.hoisted(() => ({
14
+ const pluginsMock = vi.hoisted(() => ({
15
15
  listJoinRequests: vi.fn(),
16
16
  reconcileJoinRequest: vi.fn(),
17
17
  }));
18
- vi.mock('../services/groups.api', () => ({
19
- listJoinRequests: groupsMock.listJoinRequests,
20
- reconcileJoinRequest: groupsMock.reconcileJoinRequest,
18
+ vi.mock('../services/plugins.api', () => ({
19
+ listJoinRequests: pluginsMock.listJoinRequests,
20
+ reconcileJoinRequest: pluginsMock.reconcileJoinRequest,
21
21
  }));
22
22
 
23
23
  const accessMock = vi.hoisted(() => ({ grantAccess: vi.fn() }));
@@ -29,7 +29,7 @@ vi.mock('../../pr/services/pr-cancel.api', () => ({
29
29
  }));
30
30
 
31
31
  import { LibraryToastProvider } from '../state/toast';
32
- import { GroupJoinRequests } from '../components/GroupJoinRequests';
32
+ import { PluginJoinRequests } from '../components/PluginJoinRequests';
33
33
 
34
34
  const request = (over: Partial<JoinRequest> = {}): JoinRequest => ({
35
35
  number: 7,
@@ -50,32 +50,32 @@ const request = (over: Partial<JoinRequest> = {}): JoinRequest => ({
50
50
  function renderBanner(onManage = vi.fn()) {
51
51
  render(
52
52
  <LibraryToastProvider>
53
- <GroupJoinRequests group="GTM" folders={['Groups/GTM']} onManage={onManage} />
53
+ <PluginJoinRequests plugin="GTM" folders={['Plugins/GTM']} onManage={onManage} />
54
54
  </LibraryToastProvider>,
55
55
  );
56
56
  return { onManage };
57
57
  }
58
58
 
59
- describe('GroupJoinRequests', () => {
59
+ describe('PluginJoinRequests', () => {
60
60
  beforeEach(() => {
61
61
  vi.clearAllMocks();
62
- groupsMock.listJoinRequests.mockResolvedValue([request()]);
63
- groupsMock.reconcileJoinRequest.mockResolvedValue(true);
62
+ pluginsMock.listJoinRequests.mockResolvedValue([request()]);
63
+ pluginsMock.reconcileJoinRequest.mockResolvedValue(true);
64
64
  accessMock.grantAccess.mockResolvedValue({});
65
65
  prMock.cancelPullRequest.mockResolvedValue({});
66
66
  });
67
67
 
68
68
  it('names the requester and the exact grant being proposed', async () => {
69
69
  renderBanner();
70
- expect(await screen.findByText(/Ali Baba asked to join GTM/)).toBeInTheDocument();
70
+ expect(await screen.findByText(/Ali Baba asked for access to GTM/)).toBeInTheDocument();
71
71
  expect(
72
72
  screen.getByRole('button', { name: 'Grant read to Ali Baba' }),
73
73
  ).toBeInTheDocument();
74
74
  });
75
75
 
76
76
  it('states the VERB when a request asks for more than read', async () => {
77
- // "asked to join" must never hide a write/owner request.
78
- groupsMock.listJoinRequests.mockResolvedValue([
77
+ // "asked for access to" must never hide a write/owner request.
78
+ pluginsMock.listJoinRequests.mockResolvedValue([
79
79
  request({
80
80
  proposals: [
81
81
  {
@@ -99,18 +99,18 @@ describe('GroupJoinRequests', () => {
99
99
  await waitFor(() => expect(accessMock.grantAccess).toHaveBeenCalledTimes(1));
100
100
  // The grant lands on the DEFAULT branch — that is where "the list" lives.
101
101
  expect(accessMock.grantAccess).toHaveBeenCalledWith(encodeURIComponent(DEFAULT_BRANCH), {
102
- path: 'Groups/GTM',
102
+ path: 'Plugins/GTM',
103
103
  kind: 'folder',
104
104
  verb: 'read',
105
105
  principal: { kind: 'user', email: 'ali@bevel.software', displayName: 'Ali Baba' },
106
106
  });
107
107
  // Then it asks the server to settle the request now rather than waiting
108
108
  // for the next listing.
109
- await waitFor(() => expect(groupsMock.reconcileJoinRequest).toHaveBeenCalledWith('GTM', 7));
109
+ await waitFor(() => expect(pluginsMock.reconcileJoinRequest).toHaveBeenCalledWith('GTM', 7));
110
110
  });
111
111
 
112
112
  it('offers each proposal separately, so one request can be answered in parts', async () => {
113
- groupsMock.listJoinRequests.mockResolvedValue([
113
+ pluginsMock.listJoinRequests.mockResolvedValue([
114
114
  request({
115
115
  proposals: [
116
116
  ...request().proposals,
@@ -142,7 +142,7 @@ describe('GroupJoinRequests', () => {
142
142
  expect(
143
143
  await screen.findByRole('button', { name: 'Grant read to Ali Baba' }),
144
144
  ).toBeInTheDocument();
145
- expect(groupsMock.reconcileJoinRequest).not.toHaveBeenCalled();
145
+ expect(pluginsMock.reconcileJoinRequest).not.toHaveBeenCalled();
146
146
  });
147
147
 
148
148
  it('declining rejects the change request', async () => {
@@ -155,24 +155,24 @@ describe('GroupJoinRequests', () => {
155
155
  });
156
156
 
157
157
  it('renders nothing when there is nothing pending', async () => {
158
- groupsMock.listJoinRequests.mockResolvedValue([]);
158
+ pluginsMock.listJoinRequests.mockResolvedValue([]);
159
159
  const { container } = render(
160
160
  <LibraryToastProvider>
161
- <GroupJoinRequests group="GTM" folders={['Groups/GTM']} onManage={vi.fn()} />
161
+ <PluginJoinRequests plugin="GTM" folders={['Plugins/GTM']} onManage={vi.fn()} />
162
162
  </LibraryToastProvider>,
163
163
  );
164
- await waitFor(() => expect(groupsMock.listJoinRequests).toHaveBeenCalled());
165
- expect(container.textContent).not.toContain('asked to join');
164
+ await waitFor(() => expect(pluginsMock.listJoinRequests).toHaveBeenCalled());
165
+ expect(container.textContent).not.toContain('asked for access to');
166
166
  });
167
167
 
168
168
  it('stays silent when the listing fails. A manager surface must not break the page', async () => {
169
- groupsMock.listJoinRequests.mockRejectedValue(new Error('boom'));
169
+ pluginsMock.listJoinRequests.mockRejectedValue(new Error('boom'));
170
170
  const { container } = render(
171
171
  <LibraryToastProvider>
172
- <GroupJoinRequests group="GTM" folders={['Groups/GTM']} onManage={vi.fn()} />
172
+ <PluginJoinRequests plugin="GTM" folders={['Plugins/GTM']} onManage={vi.fn()} />
173
173
  </LibraryToastProvider>,
174
174
  );
175
- await waitFor(() => expect(groupsMock.listJoinRequests).toHaveBeenCalled());
175
+ await waitFor(() => expect(pluginsMock.listJoinRequests).toHaveBeenCalled());
176
176
  expect(container.querySelector('[role="alert"]')).toBeNull();
177
177
  });
178
178
  });