@bevel-software/platform-core-frontend 0.26.0 → 0.28.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 (206) 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__/ProductName.test.tsx +46 -0
  5. package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
  6. package/src/core/__tests__/core-contributions.test.ts +16 -0
  7. package/src/core/core-contributions.ts +17 -0
  8. package/src/core/maker-url.ts +30 -0
  9. package/src/core/registry.ts +78 -1
  10. package/src/index.css +23 -5
  11. package/src/index.ts +5 -0
  12. package/src/lib/__tests__/latest-request.test.ts +48 -0
  13. package/src/lib/latest-request.ts +45 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.no-sso-invite.test.tsx +222 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
  16. package/src/modules/access/api.ts +19 -3
  17. package/src/modules/access/components/ManageAccessDialog.tsx +61 -8
  18. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +16 -1
  19. package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
  20. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +284 -39
  21. package/src/modules/admin/components/AdminRolesPage.tsx +13 -14
  22. package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
  23. package/src/modules/admin/components/UserAccountsPage.tsx +91 -107
  24. package/src/modules/admin/services/roles.api.ts +14 -1
  25. package/src/modules/auth/__tests__/LoginScreen.test.tsx +80 -5
  26. package/src/modules/auth/__tests__/sso-strict-probe.test.ts +66 -0
  27. package/src/modules/auth/components/LoginScreen.tsx +101 -73
  28. package/src/modules/auth/services/account.api.ts +59 -3
  29. package/src/modules/auth/services/sso.ts +30 -10
  30. package/src/modules/auth/state/use-sign-in-methods.ts +41 -0
  31. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
  32. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
  33. package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
  34. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
  35. package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
  36. package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
  37. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
  38. package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
  39. package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
  40. package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
  41. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
  42. package/src/modules/change-requests/services/change-requests.api.ts +15 -2
  43. package/src/modules/change-requests/utils/readFailure.ts +22 -0
  44. package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
  45. package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
  46. package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
  47. package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
  48. package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
  49. package/src/modules/embed/__tests__/mount.test.tsx +157 -0
  50. package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
  51. package/src/modules/embed/components/EmbedView.tsx +545 -0
  52. package/src/modules/embed/embed-config.ts +132 -0
  53. package/src/modules/embed/embed-host.ts +120 -0
  54. package/src/modules/embed/mount.tsx +80 -0
  55. package/src/modules/embed/services/embed-token.ts +22 -0
  56. package/src/modules/embed/services/embed.api.ts +158 -0
  57. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
  58. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
  59. package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
  60. package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
  61. package/src/modules/git/branch-delete-menu-item.tsx +24 -0
  62. package/src/modules/git/components/BranchSwitcher.tsx +29 -5
  63. package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
  64. package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
  65. package/src/modules/git/components/PullNeededBanner.tsx +15 -49
  66. package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
  67. package/src/modules/git/index.ts +15 -0
  68. package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
  69. package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
  70. package/src/modules/git/services/error-messages.ts +58 -1
  71. package/src/modules/git/services/pull-failure.ts +68 -0
  72. package/src/modules/git/state/branch-delete-confirm.ts +46 -0
  73. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
  74. package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
  75. package/src/modules/layout/breakpoints.ts +8 -0
  76. package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
  77. package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
  78. package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
  79. package/src/modules/library/components/LibraryPage.tsx +22 -0
  80. package/src/modules/library/components/PluginExtras.tsx +23 -6
  81. package/src/modules/library/components/PluginPage.tsx +6 -1
  82. package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
  83. package/src/modules/library/services/plugins.api.ts +4 -1
  84. package/src/modules/library/state/plugins-revision.ts +28 -0
  85. package/src/modules/onboarding/__tests__/InviteButton.test.tsx +214 -0
  86. package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
  87. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
  88. package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +164 -0
  89. package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1458 -0
  90. package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +811 -0
  91. package/src/modules/onboarding/__tests__/invite-emails.test.ts +247 -0
  92. package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
  93. package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
  94. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
  95. package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
  96. package/src/modules/onboarding/components/GetStartedColumn.tsx +670 -0
  97. package/src/modules/onboarding/components/InviteButton.tsx +139 -0
  98. package/src/modules/onboarding/components/InviteDialog.tsx +741 -0
  99. package/src/modules/onboarding/components/RootLanding.tsx +8 -24
  100. package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
  101. package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
  102. package/src/modules/onboarding/first-page-prompt.ts +123 -0
  103. package/src/modules/onboarding/invite-emails.ts +313 -0
  104. package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
  105. package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
  106. package/src/modules/onboarding/state/agent-connection.ts +167 -0
  107. package/src/modules/onboarding/state/invite-dialog.context.ts +35 -0
  108. package/src/modules/onboarding/state/invite-dialog.tsx +39 -0
  109. package/src/modules/onboarding/state/onboarding.ts +133 -59
  110. package/src/modules/onboarding/state/starter-packs.ts +169 -0
  111. package/src/modules/settings/settings-nav-items.tsx +8 -3
  112. package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
  113. package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
  114. package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
  115. package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
  116. package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
  117. package/src/modules/setup/__tests__/setup.test.tsx +56 -15
  118. package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
  119. package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
  120. package/src/modules/setup/components/SetupGate.tsx +46 -1
  121. package/src/modules/setup/components/SetupScreen.tsx +81 -84
  122. package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
  123. package/src/modules/setup/services/setup.api.ts +3 -3
  124. package/src/modules/setup/utils/suggested-branch.ts +27 -0
  125. package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
  126. package/src/modules/toolbar/commands/actions.tsx +330 -0
  127. package/src/modules/toolbar/commands/command-menu.ts +44 -0
  128. package/src/modules/toolbar/commands/useCommandActions.ts +71 -0
  129. package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
  130. package/src/modules/toolbar/components/AppSwitcher.tsx +125 -22
  131. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
  132. package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
  133. package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
  134. package/src/modules/toolbar/components/Toolbar.tsx +10 -0
  135. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +230 -52
  136. package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
  137. package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +864 -0
  138. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
  139. package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
  140. package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
  141. package/src/modules/toolbar/search/rank.ts +111 -0
  142. package/src/modules/toolbar/search/sources.ts +169 -0
  143. package/src/modules/workflow/hooks/useFileLock.ts +10 -7
  144. package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
  145. package/src/modules/workflow/services/lock.api.ts +17 -2
  146. package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
  147. package/src/modules/workspace/components/EditorTabs.tsx +39 -15
  148. package/src/modules/workspace/components/FileExplorer.tsx +39 -6
  149. package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
  150. package/src/modules/workspace/components/FileRoute.tsx +12 -7
  151. package/src/modules/workspace/components/FileViewer.tsx +271 -74
  152. package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
  153. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
  154. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +92 -4
  155. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
  156. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
  157. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
  158. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
  159. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
  160. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
  161. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
  162. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
  163. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
  164. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
  165. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
  166. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
  167. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
  168. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
  169. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
  170. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
  171. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
  172. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
  173. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
  174. package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
  175. package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
  176. package/src/modules/workspace/components/renderers/index.ts +26 -0
  177. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
  178. package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
  179. package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
  180. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
  181. package/src/modules/workspace/hooks/__tests__/useCreatePage.test.ts +137 -0
  182. package/src/modules/workspace/hooks/__tests__/useKnowledgeWriteTarget.test.ts +302 -0
  183. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
  184. package/src/modules/workspace/hooks/useCreatePage.ts +206 -0
  185. package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +238 -0
  186. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
  187. package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
  188. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
  189. package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
  190. package/src/modules/workspace/routing/kb-routes.ts +66 -12
  191. package/src/modules/workspace/state/editable-page.ts +42 -0
  192. package/src/modules/workspace/state/workspace.context.ts +13 -4
  193. package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
  194. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
  195. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +16 -0
  196. package/src/modules/workspace/utils/display-file-name.ts +102 -0
  197. package/src/modules/workspace/utils/fileTree.ts +49 -14
  198. package/src/modules/workspace/utils/treeConfirm.ts +15 -0
  199. package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
  200. package/src/shared/components/ConfirmProvider.tsx +156 -0
  201. package/src/shared/components/Dialog.tsx +7 -0
  202. package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
  203. package/src/shared/components/confirm-context.ts +94 -0
  204. package/src/shared/components/index.ts +3 -0
  205. package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
  206. package/src/modules/onboarding/welcome-state.ts +0 -36
@@ -0,0 +1,136 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { AuthContext } from '../../auth/state/auth.context';
5
+ import { authValue } from '../../library/__tests__/auth-harness';
6
+ import { WorkspaceContext } from '../../workspace/state/workspace.context';
7
+ import { makeWorkspaceFixture } from '../../workspace/__tests__/testFixtures';
8
+ import { StarterPackCard } from '../components/StarterPackCard';
9
+ import {
10
+ StarterPackApiError,
11
+ type StarterPackApplied,
12
+ type StarterPackSummary,
13
+ type StarterPacksAnswer,
14
+ } from '../services/starter-packs.api';
15
+
16
+ /**
17
+ * "What does your team do?": one chip per pack, a choice that posts and
18
+ * fetches the tree again before handing over, a skip, and a refusal said on
19
+ * the card in the server's words.
20
+ */
21
+
22
+ const { fetchMock, chooseMock } = vi.hoisted(() => ({
23
+ fetchMock: vi.fn<() => Promise<StarterPacksAnswer>>(),
24
+ chooseMock: vi.fn<(id: string) => Promise<StarterPackApplied>>(),
25
+ }));
26
+ vi.mock('../services/starter-packs.api', async (importOriginal) => ({
27
+ ...(await importOriginal<typeof import('../services/starter-packs.api')>()),
28
+ fetchStarterPacks: fetchMock,
29
+ chooseStarterPack: chooseMock,
30
+ }));
31
+
32
+ const PACKS: StarterPackSummary[] = [
33
+ { id: 'engineering', name: 'Engineering', description: 'Pages about how you build.', order: 1 },
34
+ { id: 'sales', name: 'Sales', description: 'Pages about what you sell.', order: 2 },
35
+ { id: 'general', name: 'Something else', description: 'Pages about who you are.', order: 99 },
36
+ ];
37
+
38
+ function mount(refreshFileTree = vi.fn(async () => null)) {
39
+ const onDone = vi.fn();
40
+ render(
41
+ <AuthContext.Provider value={authValue()}>
42
+ <WorkspaceContext.Provider value={makeWorkspaceFixture({ refreshFileTree })}>
43
+ <StarterPackCard packs={PACKS} onDone={onDone} />
44
+ </WorkspaceContext.Provider>
45
+ </AuthContext.Provider>,
46
+ );
47
+ return { onDone, refreshFileTree };
48
+ }
49
+
50
+ // Every mount signs in afresh (`authValue()` makes a new user), and the
51
+ // starter answer is kept per signed-in user: no test sees another's.
52
+ beforeEach(() => {
53
+ fetchMock.mockReset().mockResolvedValue({ offered: false, chosen: 'sales', packs: [], chosenPack: null });
54
+ chooseMock.mockReset();
55
+ });
56
+
57
+ describe('StarterPackCard', () => {
58
+ it('asks the question with a chip per pack, in order, and a quiet skip', () => {
59
+ mount();
60
+ expect(screen.getByRole('heading', { name: 'What does your team do?' })).toBeInTheDocument();
61
+ expect(screen.getByText('We’ll add starter pages and skills that fit.')).toBeInTheDocument();
62
+ const chips = screen.getAllByRole('button').map((b) => b.textContent);
63
+ expect(chips).toEqual(['Engineering', 'Sales', 'Something else', 'Skip, I’ll start from scratch']);
64
+ expect(screen.getByRole('button', { name: 'Sales' })).toHaveAttribute('title', 'Pages about what you sell.');
65
+ });
66
+
67
+ it('choosing posts the pack, says it is adding, refreshes the tree and hands over what was added', async () => {
68
+ let finish!: (applied: StarterPackApplied) => void;
69
+ chooseMock.mockImplementation(() => new Promise((resolve) => (finish = resolve)));
70
+ let treeRefreshed!: () => void;
71
+ const { onDone, refreshFileTree } = mount(vi.fn(() => new Promise<null>((resolve) => (treeRefreshed = () => resolve(null)))));
72
+ await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1));
73
+
74
+ await userEvent.click(screen.getByRole('button', { name: 'Sales' }));
75
+
76
+ expect(chooseMock).toHaveBeenCalledWith('sales');
77
+ expect(screen.getByRole('button', { name: 'Adding…' })).toBeDisabled();
78
+ expect(screen.getByRole('button', { name: 'Engineering' })).toBeDisabled();
79
+ expect(screen.getByRole('button', { name: /Skip/ })).toBeDisabled();
80
+ expect(screen.getByRole('status')).toHaveTextContent('Adding starter pages and skills for Sales…');
81
+
82
+ const applied = { id: 'sales', name: 'Sales', pages: 6, skills: 37, summary: 'Added 6 pages and 37 skills for Sales.' };
83
+ finish(applied);
84
+ await waitFor(() => expect(refreshFileTree).toHaveBeenCalledTimes(1));
85
+ // The tree comes first: nothing is handed over, and the answer is not
86
+ // read again, until the pages are in it.
87
+ expect(onDone).not.toHaveBeenCalled();
88
+ expect(fetchMock).toHaveBeenCalledTimes(1);
89
+ treeRefreshed();
90
+ await waitFor(() => expect(onDone).toHaveBeenCalledWith(applied));
91
+ // The answer is read again, so the prompt and the card follow the choice.
92
+ expect(fetchMock).toHaveBeenCalledTimes(2);
93
+ });
94
+
95
+ it('skipping posts "none", says so, and has no tree to refresh', async () => {
96
+ let finish!: (applied: StarterPackApplied) => void;
97
+ chooseMock.mockImplementation(() => new Promise((resolve) => (finish = resolve)));
98
+ const { onDone, refreshFileTree } = mount();
99
+
100
+ await userEvent.click(screen.getByRole('button', { name: 'Skip, I’ll start from scratch' }));
101
+
102
+ expect(chooseMock).toHaveBeenCalledWith('none');
103
+ const skip = screen.getByRole('button', { name: 'Skipping…' });
104
+ expect(skip).toBeDisabled();
105
+ expect(skip).toHaveAttribute('aria-busy', 'true');
106
+ expect(screen.getByRole('status')).toHaveTextContent('Skipping…');
107
+
108
+ finish({ id: 'none', name: null, pages: 0, skills: 0, summary: '' });
109
+ await waitFor(() => expect(onDone).toHaveBeenCalled());
110
+ expect(refreshFileTree).not.toHaveBeenCalled();
111
+ });
112
+
113
+ it('reads the answer again when the question was answered elsewhere, so the card can go', async () => {
114
+ chooseMock.mockRejectedValueOnce(new StarterPackApiError('Starter pages were already chosen for this knowledge base.', 409));
115
+ mount();
116
+ await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1));
117
+
118
+ await userEvent.click(screen.getByRole('button', { name: 'Engineering' }));
119
+
120
+ expect(await screen.findByRole('alert')).toHaveTextContent('already chosen');
121
+ expect(fetchMock).toHaveBeenCalledTimes(2);
122
+ });
123
+
124
+ it('says a refusal on the card and lets the admin try again', async () => {
125
+ chooseMock.mockRejectedValueOnce(
126
+ new StarterPackApiError('Someone is editing the knowledge base right now. Try again in a moment.', 409),
127
+ );
128
+ const { onDone } = mount();
129
+
130
+ await userEvent.click(screen.getByRole('button', { name: 'Engineering' }));
131
+
132
+ expect(await screen.findByRole('alert')).toHaveTextContent('Someone is editing the knowledge base right now.');
133
+ expect(onDone).not.toHaveBeenCalled();
134
+ expect(screen.getByRole('button', { name: 'Engineering' })).toBeEnabled();
135
+ });
136
+ });
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useState } from 'react';
1
+ import { useMemo, useState } from 'react';
2
2
  import { Sparkles, Users } from 'lucide-react';
3
3
  import { Button, Dialog, Surface } from '../../../shared/components';
4
4
  import { useAuth } from '../../auth/state/auth.context';
@@ -6,19 +6,21 @@ import { NewPluginDialog } from '../../library/components/NewPluginDialog';
6
6
  import { NewSkillPanel } from '../../library/components/NewSkillPanel';
7
7
  import { useLibrary } from '../../library/state/library-data';
8
8
  import { displayFirstName } from '../../library/utils/personal-plugin';
9
- import { useOnboarding } from '../state/onboarding';
10
9
 
11
10
  /**
12
- * The first useful screen in an empty deployment.
11
+ * The first useful screen in an empty deployment: Skills & Tools' empty state
12
+ * for an admin. `LibraryPage` shows it in place of the Everything gallery
13
+ * while the catalog holds no plugins and no skills or tools.
13
14
  *
14
15
  * A regular account needs to connect an agent before the library becomes
15
16
  * useful. The first admin has a different job: make the shared structure that
16
17
  * everyone else will find. This page offers the two smallest real beginnings,
17
- * using the same plugin and skill creation flows available everywhere else.
18
+ * using the same plugin and skill creation flows available everywhere else —
19
+ * and once either exists, the catalog is no longer empty and the gallery is
20
+ * back.
18
21
  */
19
22
  export function CreatorWelcomePage() {
20
23
  const { user } = useAuth();
21
- const onboarding = useOnboarding();
22
24
  const data = useLibrary();
23
25
  const [newPluginOpen, setNewPluginOpen] = useState(false);
24
26
  const [newSkillOpen, setNewSkillOpen] = useState(false);
@@ -31,12 +33,6 @@ export function CreatorWelcomePage() {
31
33
  */
32
34
  const [newSkillBusy, setNewSkillBusy] = useState(false);
33
35
 
34
- const { markWelcomed } = onboarding;
35
- useEffect(() => {
36
- markWelcomed();
37
- // eslint-disable-next-line react-hooks/exhaustive-deps -- one idempotent welcome record per mount
38
- }, []);
39
-
40
36
  const pluginNames = useMemo(
41
37
  () => [
42
38
  ...new Set([
@@ -0,0 +1,138 @@
1
+ import { useRef, type ClipboardEvent, type KeyboardEvent } from 'react';
2
+ import { X } from 'lucide-react';
3
+ import { cn } from '../../../lib/utils';
4
+ import { isValidEmail, splitEmails } from '../invite-emails';
5
+
6
+ /** `current` plus whatever of `added` it does not already hold, in order. */
7
+ function withAdded(current: string[], added: string[]): string[] {
8
+ const next = [...current];
9
+ for (const email of added) if (!next.includes(email)) next.push(email);
10
+ return next;
11
+ }
12
+
13
+ interface EmailChipsInputProps {
14
+ /** Labels the text input (pair with a `<label htmlFor>`). */
15
+ id: string;
16
+ emails: string[];
17
+ onEmailsChange(next: string[]): void;
18
+ /** The text not yet turned into a chip. Controlled, so a submit can include it. */
19
+ draft: string;
20
+ onDraftChange(next: string): void;
21
+ placeholder?: string;
22
+ /** Id of the hint below the field. */
23
+ 'aria-describedby'?: string;
24
+ disabled?: boolean;
25
+ }
26
+
27
+ /**
28
+ * An address field that turns what you type into chips: Enter or a comma
29
+ * after each address, or paste a whole list at once. Backspace in an empty
30
+ * field takes the last chip back. An address that cannot be one stays on
31
+ * screen in the danger tone rather than vanishing — the person typed it,
32
+ * and the fix is theirs to see.
33
+ *
34
+ * Borrows Manage access's chip picker look (a TextField that grew chips), but
35
+ * not its code: that one picks principals from suggestions, this one only
36
+ * ever holds addresses.
37
+ */
38
+ export function EmailChipsInput({
39
+ id,
40
+ emails,
41
+ onEmailsChange,
42
+ draft,
43
+ onDraftChange,
44
+ placeholder,
45
+ 'aria-describedby': describedBy,
46
+ disabled = false,
47
+ }: EmailChipsInputProps) {
48
+ const inputRef = useRef<HTMLInputElement>(null);
49
+
50
+ function commit(text: string) {
51
+ const added = splitEmails(text);
52
+ if (added.length > 0) onEmailsChange(withAdded(emails, added));
53
+ onDraftChange('');
54
+ }
55
+
56
+ function onKeyDown(e: KeyboardEvent<HTMLInputElement>) {
57
+ if ((e.key === 'Enter' || e.key === ',' || e.key === ';') && draft.trim()) {
58
+ e.preventDefault();
59
+ commit(draft);
60
+ return;
61
+ }
62
+ if (e.key === 'Backspace' && draft === '' && emails.length > 0) {
63
+ e.preventDefault();
64
+ onEmailsChange(emails.slice(0, -1));
65
+ }
66
+ }
67
+
68
+ // A single pasted address is ordinary typing; a LIST becomes chips at once,
69
+ // so pasting thirty addresses does not leave one thirty-address chip.
70
+ function onPaste(e: ClipboardEvent<HTMLInputElement>) {
71
+ const text = e.clipboardData.getData('text');
72
+ if (!/[\s,;<]/.test(text.trim())) return;
73
+ e.preventDefault();
74
+ commit(`${draft} ${text}`);
75
+ }
76
+
77
+ return (
78
+ // The box, not just the input, is the click target: clicking between
79
+ // chips should land the caret where the next address goes.
80
+ <div
81
+ className={cn(
82
+ 'flex w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border border-line-strong bg-surface px-2 py-1.5',
83
+ 'focus-within:border-transparent focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-accent',
84
+ disabled && 'cursor-not-allowed opacity-50',
85
+ )}
86
+ onClick={() => inputRef.current?.focus()}
87
+ >
88
+ {emails.map((email) => {
89
+ const valid = isValidEmail(email);
90
+ return (
91
+ <span
92
+ key={email}
93
+ className={cn(
94
+ 'inline-flex min-w-0 max-w-full items-center gap-1 rounded-full py-0.5 pl-2 pr-1 text-detail',
95
+ valid ? 'bg-sunken text-ink' : 'bg-danger-soft text-danger',
96
+ )}
97
+ title={valid ? email : `${email} is not an email address`}
98
+ >
99
+ <span className="min-w-0 truncate">{email}</span>
100
+ {!valid && <span className="sr-only">(not an email address)</span>}
101
+ <button
102
+ type="button"
103
+ disabled={disabled}
104
+ onClick={(e) => {
105
+ e.stopPropagation();
106
+ onEmailsChange(emails.filter((x) => x !== email));
107
+ inputRef.current?.focus();
108
+ }}
109
+ className="flex size-4 shrink-0 items-center justify-center rounded-full text-ink-faint hover:bg-hover hover:text-ink"
110
+ aria-label={`Remove ${email}`}
111
+ >
112
+ <X size={10} aria-hidden />
113
+ </button>
114
+ </span>
115
+ );
116
+ })}
117
+ <input
118
+ ref={inputRef}
119
+ id={id}
120
+ value={draft}
121
+ disabled={disabled}
122
+ onChange={(e) => onDraftChange(e.target.value)}
123
+ onKeyDown={onKeyDown}
124
+ onPaste={onPaste}
125
+ // Leaving the field keeps what was typed: a person who types one
126
+ // address and reaches for the role select has not abandoned it.
127
+ onBlur={() => {
128
+ if (draft.trim()) commit(draft);
129
+ }}
130
+ placeholder={emails.length > 0 ? 'Add more…' : placeholder}
131
+ autoComplete="off"
132
+ spellCheck={false}
133
+ aria-describedby={describedBy}
134
+ className="min-w-40 flex-1 bg-transparent px-1 py-0.5 text-ui text-ink placeholder:text-ink-faint focus:outline-none"
135
+ />
136
+ </div>
137
+ );
138
+ }