@bevel-software/platform-core-frontend 0.26.0 → 0.27.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 (187) hide show
  1. package/package.json +2 -2
  2. package/src/core/CoreAppShell.tsx +87 -25
  3. package/src/core/ProductName.tsx +49 -0
  4. package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
  5. package/src/core/__tests__/core-contributions.test.ts +16 -0
  6. package/src/core/core-contributions.ts +17 -0
  7. package/src/core/registry.ts +51 -1
  8. package/src/index.css +23 -5
  9. package/src/index.ts +5 -0
  10. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
  11. package/src/modules/access/components/ManageAccessDialog.tsx +1 -1
  12. package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
  13. package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
  14. package/src/modules/auth/components/LoginScreen.tsx +4 -1
  15. package/src/modules/auth/services/account.api.ts +28 -1
  16. package/src/modules/auth/services/sso.ts +1 -2
  17. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
  18. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
  19. package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
  20. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
  21. package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
  22. package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
  23. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
  24. package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
  25. package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
  26. package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
  27. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
  28. package/src/modules/change-requests/services/change-requests.api.ts +15 -2
  29. package/src/modules/change-requests/utils/readFailure.ts +22 -0
  30. package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
  31. package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
  32. package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
  33. package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
  34. package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
  35. package/src/modules/embed/__tests__/mount.test.tsx +157 -0
  36. package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
  37. package/src/modules/embed/components/EmbedView.tsx +545 -0
  38. package/src/modules/embed/embed-config.ts +132 -0
  39. package/src/modules/embed/embed-host.ts +120 -0
  40. package/src/modules/embed/mount.tsx +80 -0
  41. package/src/modules/embed/services/embed-token.ts +22 -0
  42. package/src/modules/embed/services/embed.api.ts +158 -0
  43. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
  44. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
  45. package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
  46. package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
  47. package/src/modules/git/branch-delete-menu-item.tsx +24 -0
  48. package/src/modules/git/components/BranchSwitcher.tsx +29 -5
  49. package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
  50. package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
  51. package/src/modules/git/components/PullNeededBanner.tsx +15 -49
  52. package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
  53. package/src/modules/git/index.ts +15 -0
  54. package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
  55. package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
  56. package/src/modules/git/services/error-messages.ts +58 -1
  57. package/src/modules/git/services/pull-failure.ts +68 -0
  58. package/src/modules/git/state/branch-delete-confirm.ts +46 -0
  59. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
  60. package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
  61. package/src/modules/layout/breakpoints.ts +8 -0
  62. package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
  63. package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
  64. package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
  65. package/src/modules/library/components/LibraryPage.tsx +22 -0
  66. package/src/modules/library/components/PluginExtras.tsx +23 -6
  67. package/src/modules/library/components/PluginPage.tsx +6 -1
  68. package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
  69. package/src/modules/library/services/plugins.api.ts +4 -1
  70. package/src/modules/library/state/plugins-revision.ts +28 -0
  71. package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
  72. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
  73. package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +109 -0
  74. package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1001 -0
  75. package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +392 -0
  76. package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
  77. package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
  78. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
  79. package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
  80. package/src/modules/onboarding/components/GetStartedColumn.tsx +651 -0
  81. package/src/modules/onboarding/components/InviteButton.tsx +35 -0
  82. package/src/modules/onboarding/components/InviteDialog.tsx +424 -0
  83. package/src/modules/onboarding/components/RootLanding.tsx +8 -24
  84. package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
  85. package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
  86. package/src/modules/onboarding/first-page-prompt.ts +89 -0
  87. package/src/modules/onboarding/invite-emails.ts +175 -0
  88. package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
  89. package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
  90. package/src/modules/onboarding/state/agent-connection.ts +167 -0
  91. package/src/modules/onboarding/state/invite-dialog.context.ts +32 -0
  92. package/src/modules/onboarding/state/invite-dialog.tsx +31 -0
  93. package/src/modules/onboarding/state/onboarding.ts +133 -59
  94. package/src/modules/onboarding/state/starter-packs.ts +169 -0
  95. package/src/modules/settings/settings-nav-items.tsx +8 -3
  96. package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
  97. package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
  98. package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
  99. package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
  100. package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
  101. package/src/modules/setup/__tests__/setup.test.tsx +56 -15
  102. package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
  103. package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
  104. package/src/modules/setup/components/SetupGate.tsx +46 -1
  105. package/src/modules/setup/components/SetupScreen.tsx +81 -84
  106. package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
  107. package/src/modules/setup/services/setup.api.ts +3 -3
  108. package/src/modules/setup/utils/suggested-branch.ts +27 -0
  109. package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
  110. package/src/modules/toolbar/commands/actions.tsx +324 -0
  111. package/src/modules/toolbar/commands/command-menu.ts +44 -0
  112. package/src/modules/toolbar/commands/useCommandActions.ts +69 -0
  113. package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
  114. package/src/modules/toolbar/components/AppSwitcher.tsx +106 -22
  115. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
  116. package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
  117. package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
  118. package/src/modules/toolbar/components/Toolbar.tsx +10 -0
  119. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +187 -54
  120. package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
  121. package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +832 -0
  122. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
  123. package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
  124. package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
  125. package/src/modules/toolbar/search/rank.ts +111 -0
  126. package/src/modules/toolbar/search/sources.ts +169 -0
  127. package/src/modules/workflow/hooks/useFileLock.ts +10 -7
  128. package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
  129. package/src/modules/workflow/services/lock.api.ts +17 -2
  130. package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
  131. package/src/modules/workspace/components/EditorTabs.tsx +39 -15
  132. package/src/modules/workspace/components/FileExplorer.tsx +39 -6
  133. package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
  134. package/src/modules/workspace/components/FileRoute.tsx +12 -7
  135. package/src/modules/workspace/components/FileViewer.tsx +271 -74
  136. package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
  137. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
  138. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +92 -4
  139. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
  140. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
  141. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
  142. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
  143. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
  144. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
  145. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
  146. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
  147. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
  148. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
  149. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
  150. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
  151. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
  152. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
  153. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
  154. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
  155. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
  156. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
  157. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
  158. package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
  159. package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
  160. package/src/modules/workspace/components/renderers/index.ts +26 -0
  161. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
  162. package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
  163. package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
  164. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
  165. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
  166. package/src/modules/workspace/hooks/useCreatePage.ts +116 -0
  167. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
  168. package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
  169. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
  170. package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
  171. package/src/modules/workspace/routing/kb-routes.ts +66 -12
  172. package/src/modules/workspace/state/editable-page.ts +42 -0
  173. package/src/modules/workspace/state/workspace.context.ts +13 -4
  174. package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
  175. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
  176. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +16 -0
  177. package/src/modules/workspace/utils/display-file-name.ts +102 -0
  178. package/src/modules/workspace/utils/fileTree.ts +49 -14
  179. package/src/modules/workspace/utils/treeConfirm.ts +15 -0
  180. package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
  181. package/src/shared/components/ConfirmProvider.tsx +156 -0
  182. package/src/shared/components/Dialog.tsx +7 -0
  183. package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
  184. package/src/shared/components/confirm-context.ts +94 -0
  185. package/src/shared/components/index.ts +3 -0
  186. package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
  187. package/src/modules/onboarding/welcome-state.ts +0 -36
@@ -7,7 +7,7 @@ import { LibraryPage } from '../components/LibraryPage';
7
7
  import { PluginPage } from '../components/PluginPage';
8
8
  import { PersonalPluginPage } from '../components/PersonalPluginPage';
9
9
  import { TeamRoute } from '../components/TeamRoute';
10
- import { WelcomeRoute } from '../../onboarding/components/WelcomeRoute';
10
+ import { WelcomePage } from '../../onboarding/components/WelcomePage';
11
11
  import { WorkspaceItemRoute } from './WorkspaceItemRoute';
12
12
  import { decodePluginSegment, LIBRARY_ROOT, pathForPlugin, urlForLibraryItem, urlForSkillFile } from './library-paths';
13
13
 
@@ -33,9 +33,10 @@ export function LibraryRoutes() {
33
33
  <Routes>
34
34
  <Route element={<LibraryLayout />}>
35
35
  {/* The Library OPENS on Everything: plugins, skills and tools, the
36
- whole catalog with the library-wide search. `everything` is
37
- the same page at the URL it used to have, so older links
38
- still land. */}
36
+ whole catalog with the library-wide search — or, for an admin
37
+ whose catalog is still empty, the creator welcome in its place
38
+ (see `LibraryPage`). `everything` is the same page at the URL
39
+ it used to have, so older links still land. */}
39
40
  <Route index element={<LibraryPage filter={{ kind: 'all' }} />} />
40
41
  <Route path="everything" element={<Navigate to={LIBRARY_ROOT} replace />} />
41
42
 
@@ -46,9 +47,9 @@ export function LibraryRoutes() {
46
47
 
47
48
  {/* The connect-your-agent welcome — inside the layout, so the
48
49
  sidebar (and the pill's selected state) is on screen with it.
49
- Auto-reached once, on first sign-in (see `RootLanding`);
50
- reachable forever through the pill and by URL. */}
51
- <Route path="welcome" element={<WelcomeRoute />} />
50
+ Never reached automatically (see `RootLanding`): opened from
51
+ the pill, the Get set up list and by URL. */}
52
+ <Route path="welcome" element={<WelcomePage />} />
52
53
 
53
54
  <Route path="owned" element={<LibraryPage filter={{ kind: 'owned' }} />} />
54
55
 
@@ -1,5 +1,6 @@
1
1
  import { authFetch } from '../../../lib/api';
2
2
  import { handleApiResponse } from '../../git/services/git.api';
3
+ import { notePluginCreated } from '../state/plugins-revision';
3
4
 
4
5
  /**
5
6
  * Plugin enumeration + join requests — the browser half of the backend's
@@ -141,7 +142,9 @@ export async function createPlugin(
141
142
  const body = (await res.json().catch(() => ({}))) as { error?: string };
142
143
  throw new Error(body.error ?? "Couldn't create that plugin.");
143
144
  }
144
- return (await res.json()) as { folder: string; name: string; displayName: string };
145
+ const created = (await res.json()) as { folder: string; name: string; displayName: string };
146
+ notePluginCreated();
147
+ return created;
145
148
  }
146
149
 
147
150
  /**
@@ -0,0 +1,28 @@
1
+ import { useSyncExternalStore } from 'react';
2
+
3
+ /**
4
+ * How many plugins this tab has created — a signal for readers OUTSIDE the
5
+ * Library's provider (the Get set up column sits beside both apps) that need
6
+ * to hear "a plugin now exists" without asking `GET /api/plugins` on every
7
+ * navigation. Bumped by `createPlugin` once the server has made it.
8
+ */
9
+ let revision = 0;
10
+ const listeners = new Set<() => void>();
11
+
12
+ function subscribe(listener: () => void): () => void {
13
+ listeners.add(listener);
14
+ return () => listeners.delete(listener);
15
+ }
16
+
17
+ const snapshot = () => revision;
18
+
19
+ /** A plugin was just created in this tab. */
20
+ export function notePluginCreated(): void {
21
+ revision++;
22
+ listeners.forEach((l) => l());
23
+ }
24
+
25
+ /** The current count, re-rendering the caller whenever it moves. */
26
+ export function usePluginsRevision(): number {
27
+ return useSyncExternalStore(subscribe, snapshot, snapshot);
28
+ }
@@ -0,0 +1,55 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { fetchAgentConnection } from '../services/agent-connection.api';
3
+
4
+ /**
5
+ * `GET /api/onboarding/agent-connection`, read field by field: the two
6
+ * documented shapes come through, and anything else is a failure — never a
7
+ * quiet "not connected", and never a stray value steering the first-page
8
+ * step's links.
9
+ */
10
+
11
+ const { authFetchMock } = vi.hoisted(() => ({ authFetchMock: vi.fn() }));
12
+ vi.mock('../../../lib/api', () => ({ authFetch: authFetchMock }));
13
+
14
+ function answer(body: unknown, status = 200) {
15
+ authFetchMock.mockResolvedValueOnce({ ok: status < 400, status, json: async () => body } as Response);
16
+ }
17
+
18
+ beforeEach(() => {
19
+ authFetchMock.mockReset();
20
+ });
21
+
22
+ describe('fetchAgentConnection', () => {
23
+ it('reads "not yet"', async () => {
24
+ answer({ connected: false });
25
+ await expect(fetchAgentConnection()).resolves.toEqual({ connected: false });
26
+ });
27
+
28
+ it('reads "connected", with when, as what and through which kind of credential', async () => {
29
+ answer({ connected: true, at: '2026-10-07T12:00:00.000Z', client: 'Claude', kind: 'agent' });
30
+ await expect(fetchAgentConnection()).resolves.toEqual({
31
+ connected: true,
32
+ at: '2026-10-07T12:00:00.000Z',
33
+ client: 'Claude',
34
+ kind: 'agent',
35
+ });
36
+ });
37
+
38
+ it('throws on a refusal', async () => {
39
+ answer({ error: 'nope' }, 401);
40
+ await expect(fetchAgentConnection()).rejects.toThrow('agent-connection: 401');
41
+ });
42
+
43
+ it.each([
44
+ ['null', null],
45
+ ['an array', []],
46
+ ['no connected flag', { client: 'Claude' }],
47
+ ['a connected flag that is not a boolean', { connected: 'yes' }],
48
+ ['a non-string time', { connected: true, at: 1700000000000 }],
49
+ ['a non-string client', { connected: true, client: { name: 'Claude' } }],
50
+ ['an unknown kind', { connected: true, client: 'Claude', kind: 'oauth' }],
51
+ ])('throws on a malformed body: %s', async (_label, body) => {
52
+ answer(body);
53
+ await expect(fetchAgentConnection()).rejects.toThrow('agent-connection: malformed body');
54
+ });
55
+ });
@@ -1,5 +1,5 @@
1
1
  import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { render, renderHook, screen, waitFor } from '@testing-library/react';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
5
5
  import type { ReactNode } from 'react';
@@ -9,11 +9,20 @@ import { authValue } from '../../library/__tests__/auth-harness';
9
9
  import { LibraryContext } from '../../library/state/library-context';
10
10
  import type { LibraryContextValue } from '../../library/state/library-data';
11
11
  import { LibraryToastProvider } from '../../library/state/toast';
12
- import { setSidebarCollapsed, useSidebar } from '../../layout/state/sidebar';
13
- import { WelcomeRoute } from '../components/WelcomeRoute';
14
- import { WELCOME_PATH } from '../paths';
12
+ import { LibraryPage } from '../../library/components/LibraryPage';
13
+ import { LIBRARY_ROOT } from '../../library/routes/library-paths';
14
+ import type { LibraryFilter } from '../../library/utils/status';
15
+ import { WorkspaceContext } from '../../workspace/state/workspace.context';
16
+ import { makeWorkspaceFixture } from '../../workspace/__tests__/testFixtures';
15
17
  import { resetOnboardingForTests } from '../state/onboarding';
16
18
 
19
+ /**
20
+ * The creator welcome: Skills & Tools' empty state for an admin. The page the
21
+ * Library opens on (Everything) offers a first plugin and a first skill in
22
+ * place of an empty gallery — only for an admin, only once both indexes have
23
+ * answered empty, and only there.
24
+ */
25
+
17
26
  const serviceMocks = vi.hoisted(() => ({
18
27
  createPlugin: vi.fn(),
19
28
  createEmptySkill: vi.fn(),
@@ -21,7 +30,8 @@ const serviceMocks = vi.hoisted(() => ({
21
30
 
22
31
  vi.mock('../../library/services/plugins.api', async (importOriginal) => {
23
32
  const actual = await importOriginal<typeof import('../../library/services/plugins.api')>();
24
- return { ...actual, createPlugin: serviceMocks.createPlugin };
33
+ // The gallery asks for join requests to show; nobody is asking here.
34
+ return { ...actual, createPlugin: serviceMocks.createPlugin, listJoinRequests: vi.fn().mockResolvedValue([]) };
25
35
  });
26
36
 
27
37
  vi.mock('../../library/services/library.api', async (importOriginal) => {
@@ -91,18 +101,19 @@ function providers(
91
101
  })}
92
102
  >
93
103
  <AdminContext.Provider value={admin(options.admin)}>
94
- <LibraryContext.Provider value={library(options.library)}>
95
- <LibraryToastProvider>{children}</LibraryToastProvider>
96
- </LibraryContext.Provider>
104
+ <WorkspaceContext.Provider value={makeWorkspaceFixture()}>
105
+ <LibraryContext.Provider value={library(options.library)}>
106
+ <LibraryToastProvider>{children}</LibraryToastProvider>
107
+ </LibraryContext.Provider>
108
+ </WorkspaceContext.Provider>
97
109
  </AdminContext.Provider>
98
110
  </AuthContext.Provider>
99
111
  );
100
112
  }
101
113
 
102
114
  interface WelcomeOptions {
103
- greeted?: boolean;
104
- /** Overrides the greeting arrival's route state — e.g. to carry `returnTo`. */
105
- routeState?: Record<string, unknown>;
115
+ /** The Library view on screen; Everything, the page it opens on, unless said. */
116
+ filter?: LibraryFilter;
106
117
  admin?: Partial<AdminContextValue>;
107
118
  library?: Partial<LibraryContextValue>;
108
119
  }
@@ -113,16 +124,12 @@ interface WelcomeOptions {
113
124
  * hand-assembling a second copy that can drift from this one.
114
125
  */
115
126
  function welcomeUi(options: WelcomeOptions = {}) {
116
- const entry = options.greeted === false
117
- ? WELCOME_PATH
118
- : { pathname: WELCOME_PATH, state: options.routeState ?? { greeting: true } };
119
-
120
127
  return (
121
- <MemoryRouter initialEntries={[entry]}>
128
+ <MemoryRouter initialEntries={[LIBRARY_ROOT]}>
122
129
  {providers(
123
130
  <>
124
131
  <Routes>
125
- <Route path={WELCOME_PATH} element={<WelcomeRoute />} />
132
+ <Route path={LIBRARY_ROOT} element={<LibraryPage filter={options.filter ?? { kind: 'all' }} />} />
126
133
  <Route path="/skills-and-tools/plugins/:plugin" element={<div>plugin page</div>} />
127
134
  <Route path="/skills-and-tools/skills/:skill" element={<div>skill page</div>} />
128
135
  </Routes>
@@ -138,9 +145,23 @@ function renderWelcome(options: WelcomeOptions = {}) {
138
145
  return render(welcomeUi(options));
139
146
  }
140
147
 
148
+ const ROADMAP_SKILL: LibraryContextValue['items'][number] = {
149
+ kind: 'skill',
150
+ id: 'roadmap',
151
+ name: 'roadmap',
152
+ description: 'Keeps the roadmap current.',
153
+ owned: true,
154
+ canWrite: true,
155
+ status: { state: 'ok', text: 'Ready' },
156
+ plugin: null,
157
+ path: 'Skills/roadmap',
158
+ };
159
+
160
+ const isCreatorWelcome = () => screen.queryByText(/Build the shared library/) !== null;
161
+ const isGallery = () => screen.queryByRole('heading', { name: 'Everything', level: 1 }) !== null;
162
+
141
163
  beforeEach(() => {
142
164
  resetOnboardingForTests();
143
- setSidebarCollapsed(false, true);
144
165
  serviceMocks.createPlugin.mockReset();
145
166
  serviceMocks.createPlugin.mockResolvedValue({ folder: 'Design', name: 'design' });
146
167
  serviceMocks.createEmptySkill.mockReset();
@@ -152,92 +173,76 @@ beforeEach(() => {
152
173
  });
153
174
  });
154
175
 
155
- describe('creator welcome routing', () => {
156
- it('welcomes an admin to build a truly empty library', () => {
176
+ describe('creator welcome: the empty state of Skills & Tools', () => {
177
+ it('welcomes an admin to build a truly empty library, in place of the gallery', () => {
157
178
  renderWelcome();
158
179
 
159
180
  expect(screen.getByRole('heading', { name: 'Welcome, Juan' })).toBeInTheDocument();
160
181
  expect(screen.getByText(/Build the shared library/)).toBeInTheDocument();
161
182
  expect(screen.getByRole('button', { name: 'Create a plugin' })).toBeInTheDocument();
162
183
  expect(screen.getByRole('button', { name: 'Create a skill' })).toBeInTheDocument();
163
- expect(screen.queryByRole('radiogroup', { name: 'Your agent' })).toBeNull();
184
+ expect(isGallery()).toBe(false);
164
185
  });
165
186
 
166
- it('keeps the external-agent welcome for non-admin users', () => {
187
+ it('keeps the gallery for members, whose job is not the shared structure', () => {
167
188
  renderWelcome({ admin: { isAdmin: false } });
168
189
 
169
- expect(screen.getByRole('radiogroup', { name: 'Your agent' })).toBeInTheDocument();
170
- expect(screen.queryByRole('button', { name: 'Create a plugin' })).toBeNull();
190
+ expect(isGallery()).toBe(true);
191
+ expect(isCreatorWelcome()).toBe(false);
171
192
  });
172
193
 
173
- it('keeps the external-agent welcome when the admin already has content', () => {
174
- renderWelcome({
175
- library: {
176
- items: [
177
- {
178
- kind: 'skill',
179
- id: 'roadmap',
180
- name: 'roadmap',
181
- description: 'Keeps the roadmap current.',
182
- owned: true,
183
- canWrite: true,
184
- status: { state: 'ok', text: 'Ready' },
185
- plugin: null,
186
- path: 'Skills/roadmap',
187
- },
188
- ],
189
- },
190
- });
191
-
192
- expect(screen.getByRole('radiogroup', { name: 'Your agent' })).toBeInTheDocument();
193
- expect(screen.queryByRole('button', { name: 'Create a plugin' })).toBeNull();
194
+ it('keeps the gallery once the catalog holds anything — a skill, or a plugin', () => {
195
+ const { rerender } = renderWelcome({ library: { items: [ROADMAP_SKILL] } });
196
+ expect(isGallery()).toBe(true);
197
+ expect(isCreatorWelcome()).toBe(false);
198
+
199
+ rerender(
200
+ welcomeUi({
201
+ library: {
202
+ pluginSummaries: [
203
+ {
204
+ name: 'GTM',
205
+ folders: ['Plugins/GTM'],
206
+ canRead: true,
207
+ canWrite: true,
208
+ isOwner: true,
209
+ skillCount: 0,
210
+ toolCount: 0,
211
+ owners: { roles: [], users: [] },
212
+ writers: { roles: [], users: [] },
213
+ readers: { roles: [], users: [], restricted: false },
214
+ hasRequested: false,
215
+ requestNumber: null,
216
+ },
217
+ ],
218
+ },
219
+ }),
220
+ );
221
+ expect(isCreatorWelcome()).toBe(false);
194
222
  });
195
223
 
196
- it('does not mistake loading or failed plugin data for an empty library', () => {
197
- // While the ADMIN verdict is unknown the hold says nothing about a
198
- // library — the reader may be headed for the agent welcome, where theirs
199
- // is beside the point.
224
+ it('does not mistake an unsettled admin verdict, or loading or failed indexes, for an empty library', () => {
200
225
  const { rerender } = renderWelcome({ admin: { isAdminLoading: true } });
201
- expect(screen.getByText('One moment…')).toBeInTheDocument();
226
+ expect(isCreatorWelcome()).toBe(false);
202
227
 
203
- rerender(welcomeUi({ library: { pluginsError: "Couldn't load plugins." } }));
228
+ rerender(welcomeUi({ library: { loading: true } }));
229
+ expect(isCreatorWelcome()).toBe(false);
204
230
 
205
- expect(screen.getByRole('radiogroup', { name: 'Your agent' })).toBeInTheDocument();
206
- });
231
+ rerender(welcomeUi({ library: { pluginsLoading: true } }));
232
+ expect(isCreatorWelcome()).toBe(false);
207
233
 
208
- it("names the wait truthfully once the verdict says admin — it IS their library loading", () => {
209
- renderWelcome({ library: { loading: true } });
210
- expect(screen.getByText('Preparing your library…')).toBeInTheDocument();
211
- });
234
+ rerender(welcomeUi({ library: { pluginsError: "Couldn't load plugins." } }));
235
+ expect(isCreatorWelcome()).toBe(false);
212
236
 
213
- it('keeps a carried deep link out of the creator welcome', () => {
214
- // Only `WelcomePage` has the exit that honors `returnTo`. An empty-library
215
- // admin would otherwise be routed to the creator page — and lose the page
216
- // their SSO round-trip was carrying them to.
217
- renderWelcome({
218
- routeState: {
219
- greeting: true,
220
- returnTo: '/workspace/main/knowledge-base/KnowledgeBase/Start here.md',
221
- },
222
- });
223
- expect(screen.getByRole('radiogroup', { name: 'Your agent' })).toBeInTheDocument();
224
- expect(screen.getByRole('button', { name: /Continue to your link/ })).toBeInTheDocument();
225
- expect(screen.queryByText(/Build the shared library/)).toBeNull();
237
+ rerender(welcomeUi({ library: { error: "Couldn't load the library." } }));
238
+ expect(isCreatorWelcome()).toBe(false);
226
239
  });
227
240
 
228
- it('uses the external-agent welcome for later visits from its reminder', () => {
229
- renderWelcome({ greeted: false });
241
+ it('is the empty state of Everything alone, not of every view', () => {
242
+ renderWelcome({ filter: { kind: 'owned' } });
230
243
 
231
- expect(screen.getByRole('radiogroup', { name: 'Your agent' })).toBeInTheDocument();
232
- expect(screen.queryByRole('button', { name: 'Create a plugin' })).toBeNull();
233
- });
234
-
235
- it('collapses the sidebar before the creator welcome is shown', () => {
236
- renderWelcome();
237
- expect(renderHook(() => useSidebar()).result.current).toMatchObject({
238
- collapsed: true,
239
- instant: true,
240
- });
244
+ expect(screen.getByRole('heading', { name: 'Owned by me', level: 1 })).toBeInTheDocument();
245
+ expect(isCreatorWelcome()).toBe(false);
241
246
  });
242
247
  });
243
248
 
@@ -0,0 +1,109 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { FIRST_PAGE_PROMPT, chatGptPromptUrl, claudePromptUrl, firstPagePromptFor, firstPageRoute } from '../first-page-prompt';
3
+
4
+ /**
5
+ * The first-page prompt links: the prompt must arrive in the chat exactly as
6
+ * written — every space, colon, comma and apostrophe — and stay short enough
7
+ * to travel in a URL.
8
+ */
9
+
10
+ describe('first-page prompt links', () => {
11
+ it('opens a new Claude chat with the prompt as its q parameter, round-tripping exactly', () => {
12
+ const url = new URL(claudePromptUrl(FIRST_PAGE_PROMPT));
13
+ expect(url.origin).toBe('https://claude.ai');
14
+ expect(url.pathname).toBe('/new');
15
+ expect(url.searchParams.get('q')).toBe(FIRST_PAGE_PROMPT);
16
+ });
17
+
18
+ it('opens a new ChatGPT chat the same way', () => {
19
+ const url = new URL(chatGptPromptUrl(FIRST_PAGE_PROMPT));
20
+ expect(url.origin).toBe('https://chatgpt.com');
21
+ expect(url.pathname).toBe('/');
22
+ expect(url.searchParams.get('q')).toBe(FIRST_PAGE_PROMPT);
23
+ });
24
+
25
+ it('percent-encodes everything a query string would otherwise read as structure', () => {
26
+ const tricky = "a & b = c? #1 + 100% it's";
27
+ const claude = claudePromptUrl(tricky);
28
+ expect(claude).toBe(
29
+ 'https://claude.ai/new?q=a%20%26%20b%20%3D%20c%3F%20%231%20%2B%20100%25%20it\'s',
30
+ );
31
+ expect(claude).not.toContain(' ');
32
+ expect(new URL(claude).searchParams.get('q')).toBe(tricky);
33
+ expect(new URL(chatGptPromptUrl(tricky)).searchParams.get('q')).toBe(tricky);
34
+ // Nothing after a `#` would ever reach the chat — the fragment stays in the prompt.
35
+ expect(new URL(claude).hash).toBe('');
36
+ });
37
+
38
+ it('keeps the prompt short enough for a link', () => {
39
+ expect(claudePromptUrl(FIRST_PAGE_PROMPT).length).toBeLessThan(400);
40
+ });
41
+ });
42
+
43
+ /**
44
+ * Which way in leads is read off the connected agent's name: a link only
45
+ * where the web chat it opens can actually reach the knowledge base.
46
+ */
47
+ describe('firstPageRoute', () => {
48
+ it.each(['Claude', 'claude', ' CLAUDE ', 'claude.ai', 'Claude Desktop', 'claude-desktop'])(
49
+ 'leads with Claude for %j',
50
+ (client) => {
51
+ expect(firstPageRoute(client, 'agent').primary).toBe('claude');
52
+ },
53
+ );
54
+
55
+ it.each(['ChatGPT', 'chatgpt', 'ChatGPT Connector'])('leads with ChatGPT for %j', (client) => {
56
+ expect(firstPageRoute(client, 'agent').primary).toBe('chatgpt');
57
+ });
58
+
59
+ it.each(['Claude Code', 'claude code', 'Cursor', 'Windsurf', 'Codex', 'My laptop key', 'Claudette'])(
60
+ 'leads with Copy prompt for %j',
61
+ (client) => {
62
+ expect(firstPageRoute(client, 'agent')).toEqual({ primary: 'copy', agentName: client });
63
+ },
64
+ );
65
+
66
+ it('leads with Copy prompt for any agent on the local server, Claude included, naming the agent alone', () => {
67
+ expect(firstPageRoute('Claude Code · local server on LAPTOP-1', 'agent')).toEqual({
68
+ primary: 'copy',
69
+ agentName: 'Claude Code',
70
+ });
71
+ expect(firstPageRoute('Claude Desktop · local server on LAPTOP-1', 'agent')).toEqual({
72
+ primary: 'copy',
73
+ agentName: 'Claude Desktop',
74
+ });
75
+ expect(firstPageRoute('Claude · LOCAL SERVER ON mac.local', 'agent')).toEqual({ primary: 'copy', agentName: 'Claude' });
76
+ });
77
+
78
+ it('has no name to offer for an unnamed or unknown agent, or none at all', () => {
79
+ expect(firstPageRoute('Unnamed agent', 'agent')).toEqual({ primary: 'copy', agentName: null });
80
+ expect(firstPageRoute('Unknown agent · local server on LAPTOP-1', 'agent')).toEqual({ primary: 'copy', agentName: null });
81
+ expect(firstPageRoute(undefined, 'agent')).toEqual({ primary: 'copy', agentName: null });
82
+ expect(firstPageRoute(null, 'agent')).toEqual({ primary: 'copy', agentName: null });
83
+ expect(firstPageRoute(' ', 'agent')).toEqual({ primary: 'copy', agentName: null });
84
+ });
85
+
86
+ it.each(['Claude', 'ChatGPT', 'ChatGPT CLI', 'Claude Desktop', 'My laptop key'])(
87
+ 'leads with Copy prompt, naming no agent, for a connection key labelled %j',
88
+ (label) => {
89
+ // A key's label is free text: it names the key, not the app holding it.
90
+ expect(firstPageRoute(label, 'key')).toEqual({ primary: 'copy', agentName: null });
91
+ },
92
+ );
93
+
94
+ it('leads with Copy prompt when the answer does not say which kind of connection it is', () => {
95
+ expect(firstPageRoute('Claude', undefined)).toEqual({ primary: 'copy', agentName: null });
96
+ expect(firstPageRoute('ChatGPT', null)).toEqual({ primary: 'copy', agentName: null });
97
+ });
98
+ });
99
+
100
+ describe('firstPagePromptFor', () => {
101
+ it("is the chosen starter pack's own request, without the YAML block's trailing newline", () => {
102
+ expect(firstPagePromptFor({ firstPagePrompt: 'Fill in the Customers page.\n' })).toBe('Fill in the Customers page.');
103
+ });
104
+
105
+ it('is the generic request without a pack, or with one that has none to give', () => {
106
+ expect(firstPagePromptFor(null)).toBe(FIRST_PAGE_PROMPT);
107
+ expect(firstPagePromptFor({ firstPagePrompt: ' ' })).toBe(FIRST_PAGE_PROMPT);
108
+ });
109
+ });