@bevel-software/platform-core-frontend 0.25.2 → 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 (193) 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/__tests__/ToolPage.test.tsx +53 -0
  66. package/src/modules/library/components/LibraryPage.tsx +22 -0
  67. package/src/modules/library/components/PluginExtras.tsx +23 -6
  68. package/src/modules/library/components/PluginPage.tsx +6 -1
  69. package/src/modules/library/components/tool-page/ToolPage.tsx +45 -1
  70. package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
  71. package/src/modules/library/services/plugins.api.ts +4 -1
  72. package/src/modules/library/services/tools.api.ts +27 -0
  73. package/src/modules/library/state/plugins-revision.ts +28 -0
  74. package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
  75. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
  76. package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +109 -0
  77. package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1001 -0
  78. package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +392 -0
  79. package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
  80. package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
  81. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
  82. package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
  83. package/src/modules/onboarding/components/GetStartedColumn.tsx +651 -0
  84. package/src/modules/onboarding/components/InviteButton.tsx +35 -0
  85. package/src/modules/onboarding/components/InviteDialog.tsx +424 -0
  86. package/src/modules/onboarding/components/RootLanding.tsx +8 -24
  87. package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
  88. package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
  89. package/src/modules/onboarding/first-page-prompt.ts +89 -0
  90. package/src/modules/onboarding/invite-emails.ts +175 -0
  91. package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
  92. package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
  93. package/src/modules/onboarding/state/agent-connection.ts +167 -0
  94. package/src/modules/onboarding/state/invite-dialog.context.ts +32 -0
  95. package/src/modules/onboarding/state/invite-dialog.tsx +31 -0
  96. package/src/modules/onboarding/state/onboarding.ts +133 -59
  97. package/src/modules/onboarding/state/starter-packs.ts +169 -0
  98. package/src/modules/settings/settings-nav-items.tsx +8 -3
  99. package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
  100. package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
  101. package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
  102. package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
  103. package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
  104. package/src/modules/setup/__tests__/setup.test.tsx +65 -81
  105. package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
  106. package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
  107. package/src/modules/setup/components/SetupGate.tsx +46 -1
  108. package/src/modules/setup/components/SetupScreen.tsx +92 -152
  109. package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
  110. package/src/modules/setup/services/setup.api.ts +3 -3
  111. package/src/modules/setup/utils/suggested-branch.ts +27 -0
  112. package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
  113. package/src/modules/toolbar/commands/actions.tsx +324 -0
  114. package/src/modules/toolbar/commands/command-menu.ts +44 -0
  115. package/src/modules/toolbar/commands/useCommandActions.ts +69 -0
  116. package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
  117. package/src/modules/toolbar/components/AppSwitcher.tsx +106 -22
  118. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
  119. package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
  120. package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
  121. package/src/modules/toolbar/components/Toolbar.tsx +10 -0
  122. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +187 -54
  123. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +4 -4
  124. package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
  125. package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +832 -0
  126. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
  127. package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
  128. package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
  129. package/src/modules/toolbar/search/rank.ts +111 -0
  130. package/src/modules/toolbar/search/sources.ts +169 -0
  131. package/src/modules/workflow/hooks/useFileLock.ts +10 -7
  132. package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
  133. package/src/modules/workflow/services/lock.api.ts +17 -2
  134. package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
  135. package/src/modules/workspace/components/EditorTabs.tsx +39 -15
  136. package/src/modules/workspace/components/FileExplorer.tsx +39 -6
  137. package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
  138. package/src/modules/workspace/components/FileRoute.tsx +12 -7
  139. package/src/modules/workspace/components/FileViewer.tsx +271 -74
  140. package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
  141. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
  142. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +101 -11
  143. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
  144. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
  145. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
  146. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
  147. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
  148. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
  149. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
  150. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
  151. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
  152. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
  153. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
  154. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
  155. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
  156. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
  157. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
  158. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
  159. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
  160. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
  161. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
  162. package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
  163. package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
  164. package/src/modules/workspace/components/renderers/index.ts +26 -0
  165. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
  166. package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
  167. package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
  168. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
  169. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
  170. package/src/modules/workspace/hooks/useCreatePage.ts +116 -0
  171. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
  172. package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
  173. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
  174. package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
  175. package/src/modules/workspace/routing/kb-routes.ts +66 -12
  176. package/src/modules/workspace/state/editable-page.ts +42 -0
  177. package/src/modules/workspace/state/workspace.context.ts +13 -4
  178. package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
  179. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
  180. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +26 -14
  181. package/src/modules/workspace/utils/display-file-name.ts +102 -0
  182. package/src/modules/workspace/utils/fileTree.ts +49 -14
  183. package/src/modules/workspace/utils/treeConfirm.ts +22 -5
  184. package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
  185. package/src/shared/components/ConfirmProvider.tsx +156 -0
  186. package/src/shared/components/Dialog.tsx +7 -0
  187. package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
  188. package/src/shared/components/confirm-context.ts +94 -0
  189. package/src/shared/components/index.ts +3 -0
  190. package/src/shared/mcp/__tests__/connect-snippets.test.ts +2 -2
  191. package/src/shared/mcp/connect-snippets.ts +8 -5
  192. package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
  193. package/src/modules/onboarding/welcome-state.ts +0 -36
@@ -0,0 +1,424 @@
1
+ import { useEffect, useId, useRef, useState, type ReactNode } from 'react';
2
+ import { Badge, Button, Dialog, type BadgeTone } from '../../../shared/components';
3
+ import { SlotBoundary } from '../../../shared/components/SlotBoundary';
4
+ import { useAppRegistry } from '../../../core/registry';
5
+ import { useAuth } from '../../auth/state/auth.context';
6
+ import { createAccount, listAccounts } from '../../auth/services/account.api';
7
+ import { addMember, fetchRoles } from '../../admin/services/roles.api';
8
+ import { copyToClipboard } from '../../library/utils/clipboard';
9
+ import { initials } from '../../../lib/email';
10
+ import { EmailChipsInput } from './EmailChipsInput';
11
+ import {
12
+ isInvited,
13
+ isValidEmail,
14
+ sendInvites,
15
+ splitEmails,
16
+ type InviteOutcome,
17
+ type InviteRole,
18
+ } from '../invite-emails';
19
+
20
+ const ROLE_HINT: Record<InviteRole, string> = {
21
+ member: 'Sees everything shared with the whole workspace.',
22
+ admin: 'Can also change settings and who has access.',
23
+ };
24
+
25
+ /** "1 person" / "3 people" — the one plural this dialog needs. */
26
+ function people(n: number): string {
27
+ return `${n} ${n === 1 ? 'person' : 'people'}`;
28
+ }
29
+
30
+ interface InviteDialogProps {
31
+ open: boolean;
32
+ onClose(): void;
33
+ /** Called after a send that created at least one account. */
34
+ onInvited?(): void;
35
+ }
36
+
37
+ /**
38
+ * Invite your team: addresses in, accounts out — each one waiting for that
39
+ * person's first single sign-on, under the same access rules as everything
40
+ * else (Share → Manage access decides what they then see).
41
+ *
42
+ * Two views in one dialog. The form; then, after sending, who is invited and
43
+ * how to tell them. The second view exists because creating an account sends
44
+ * nobody anything — core has no mail — so the admin leaves with the sign-in
45
+ * address and a message to forward, not with an assumption that people were
46
+ * notified.
47
+ *
48
+ * Feedback stays INSIDE the dialog: the Library's toasts only exist under its
49
+ * own routes, and this opens from Knowledge too.
50
+ */
51
+ export function InviteDialog({ open, onClose, onInvited }: InviteDialogProps) {
52
+ const { user } = useAuth();
53
+ const [emails, setEmails] = useState<string[]>([]);
54
+ const [draft, setDraft] = useState('');
55
+ const [role, setRole] = useState<InviteRole>('member');
56
+ const [sending, setSending] = useState(false);
57
+ const [outcomes, setOutcomes] = useState<InviteOutcome[] | null>(null);
58
+ const emailsId = useId();
59
+ const doneRef = useRef<HTMLButtonElement>(null);
60
+
61
+ // The address field, not the header's close button, is where an invite
62
+ // starts: on open and again after "Invite more people". A frame late on
63
+ // purpose — the dialog moves focus to its first control as it opens, and
64
+ // that runs after this component's own effects.
65
+ useEffect(() => {
66
+ if (!open || outcomes) return;
67
+ const frame = requestAnimationFrame(() => document.getElementById(emailsId)?.focus());
68
+ return () => cancelAnimationFrame(frame);
69
+ }, [open, outcomes, emailsId]);
70
+
71
+ // The button that sent is gone once the result shows; focus goes to the
72
+ // way out rather than falling to the page behind the dialog.
73
+ useEffect(() => {
74
+ if (outcomes) doneRef.current?.focus();
75
+ }, [outcomes]);
76
+
77
+ // What a send would include: the chips plus anything still in the field,
78
+ // so typing one address and clicking Invite does what it says.
79
+ const pending = [...emails];
80
+ for (const email of splitEmails(draft)) if (!pending.includes(email)) pending.push(email);
81
+ const valid = pending.filter(isValidEmail);
82
+
83
+ async function send() {
84
+ if (valid.length === 0 || sending) return;
85
+ setSending(true);
86
+ try {
87
+ const result = await sendInvites(valid, role, { listAccounts, createAccount, addMember, fetchRoles });
88
+ setEmails([]);
89
+ setDraft('');
90
+ setOutcomes(result);
91
+ if (result.some((o) => o.status === 'created')) onInvited?.();
92
+ } finally {
93
+ setSending(false);
94
+ }
95
+ }
96
+
97
+ function inviteMore() {
98
+ setEmails([]);
99
+ setDraft('');
100
+ setRole('member');
101
+ setOutcomes(null);
102
+ }
103
+
104
+ if (outcomes) {
105
+ const invited = outcomes.filter(isInvited).length;
106
+ return (
107
+ <Dialog
108
+ open={open}
109
+ onClose={onClose}
110
+ size="lg"
111
+ title={
112
+ invited === 0
113
+ ? 'Nobody was invited'
114
+ : `${people(invited)} ${invited === 1 ? 'is' : 'are'} invited`
115
+ }
116
+ footer={
117
+ <>
118
+ <Button variant="quiet" size="sm" className="mr-auto" onClick={inviteMore}>
119
+ Invite more people
120
+ </Button>
121
+ <Button ref={doneRef} variant="primary" size="sm" onClick={onClose}>
122
+ Done
123
+ </Button>
124
+ </>
125
+ }
126
+ >
127
+ <InvitedBody outcomes={outcomes} invited={invited} />
128
+ </Dialog>
129
+ );
130
+ }
131
+
132
+ const domain = user?.email.split('@')[1];
133
+ return (
134
+ <Dialog
135
+ open={open}
136
+ onClose={onClose}
137
+ busy={sending}
138
+ size="lg"
139
+ title="Invite your team"
140
+ footer={
141
+ <>
142
+ <span className="mr-auto self-center text-meta text-ink-faint">
143
+ Uses the same access rules as Share → Manage access.
144
+ </span>
145
+ <Button size="sm" onClick={onClose} disabled={sending}>
146
+ Cancel
147
+ </Button>
148
+ <Button
149
+ size="sm"
150
+ variant="primary"
151
+ onClick={() => void send()}
152
+ disabled={valid.length === 0 || sending}
153
+ >
154
+ {sending
155
+ ? 'Inviting…'
156
+ : valid.length > 0
157
+ ? `Invite ${people(valid.length)}`
158
+ : 'Invite people'}
159
+ </Button>
160
+ </>
161
+ }
162
+ >
163
+ <InviteFormBody
164
+ emailsId={emailsId}
165
+ emails={emails}
166
+ onEmailsChange={setEmails}
167
+ draft={draft}
168
+ onDraftChange={setDraft}
169
+ role={role}
170
+ onRoleChange={setRole}
171
+ validCount={valid.length}
172
+ invalidCount={pending.length - valid.length}
173
+ sending={sending}
174
+ placeholder={domain ? `name@${domain}, name@${domain}` : 'name@company.com'}
175
+ />
176
+ </Dialog>
177
+ );
178
+ }
179
+
180
+ function InviteFormBody({
181
+ emailsId,
182
+ emails,
183
+ onEmailsChange,
184
+ draft,
185
+ onDraftChange,
186
+ role,
187
+ onRoleChange,
188
+ validCount,
189
+ invalidCount,
190
+ sending,
191
+ placeholder,
192
+ }: {
193
+ emailsId: string;
194
+ emails: string[];
195
+ onEmailsChange(next: string[]): void;
196
+ draft: string;
197
+ onDraftChange(next: string): void;
198
+ role: InviteRole;
199
+ onRoleChange(next: InviteRole): void;
200
+ validCount: number;
201
+ /**
202
+ * Addresses a send would leave out — chips and text still in the field
203
+ * alike, since a send clears both and the field's would otherwise go
204
+ * without a word.
205
+ */
206
+ invalidCount: number;
207
+ sending: boolean;
208
+ placeholder: string;
209
+ }) {
210
+ const Extras = useAppRegistry().inviteExtras;
211
+ const hintId = useId();
212
+ const roleId = useId();
213
+
214
+ return (
215
+ <div className="flex flex-col gap-4 py-1">
216
+ <p className="text-detail text-ink-muted">
217
+ They sign in with the account for the address you add.
218
+ </p>
219
+ <div className="flex flex-col gap-1.5">
220
+ <label htmlFor={emailsId} className="text-detail font-medium text-ink">
221
+ Work emails
222
+ </label>
223
+ <EmailChipsInput
224
+ id={emailsId}
225
+ emails={emails}
226
+ onEmailsChange={onEmailsChange}
227
+ draft={draft}
228
+ onDraftChange={onDraftChange}
229
+ placeholder={placeholder}
230
+ aria-describedby={hintId}
231
+ disabled={sending}
232
+ />
233
+ <span id={hintId} className="text-meta text-ink-faint">
234
+ {invalidCount > 0
235
+ ? `${invalidCount === 1 ? 'One address isn’t' : `${invalidCount} addresses aren’t`} valid and won’t be invited.`
236
+ : 'Paste a list, or press Enter or comma after each address.'}
237
+ </span>
238
+ </div>
239
+ <div className="flex flex-wrap items-center gap-2.5">
240
+ <label htmlFor={roleId} className="text-detail text-ink-muted">
241
+ Invite as
242
+ </label>
243
+ <select
244
+ id={roleId}
245
+ value={role}
246
+ disabled={sending}
247
+ onChange={(e) => onRoleChange(e.target.value as InviteRole)}
248
+ className="rounded-md border border-line-strong bg-surface px-2 py-1 text-detail text-ink"
249
+ >
250
+ <option value="member">Member</option>
251
+ <option value="admin">Admin</option>
252
+ </select>
253
+ <span className="text-meta text-ink-faint">{ROLE_HINT[role]}</span>
254
+ </div>
255
+ {Extras && (
256
+ <SlotBoundary label="invite panel">
257
+ <Extras inviting={validCount} />
258
+ </SlotBoundary>
259
+ )}
260
+ </div>
261
+ );
262
+ }
263
+
264
+ /** How each outcome reads on its row. */
265
+ const OUTCOME_BADGE: Record<InviteOutcome['status'], { tone: BadgeTone; label: string }> = {
266
+ created: { tone: 'neutral', label: 'Hasn’t signed in yet' },
267
+ existing: { tone: 'outline', label: 'Already had an account' },
268
+ 'no-seat': { tone: 'wait', label: 'Not invited: no seat left' },
269
+ error: { tone: 'danger', label: 'Not invited' },
270
+ };
271
+
272
+ /**
273
+ * A switched-off account is on the list but cannot sign in: its row says so,
274
+ * in the waiting tone, rather than "Already had an account" beside a claim
275
+ * that it is ready.
276
+ */
277
+ function outcomeBadge(outcome: InviteOutcome): { tone: BadgeTone; label: string } {
278
+ if (outcome.status === 'existing' && outcome.deactivated) return { tone: 'wait', label: 'Account switched off' };
279
+ return OUTCOME_BADGE[outcome.status];
280
+ }
281
+
282
+ function outcomeDetail(outcome: InviteOutcome): string {
283
+ switch (outcome.status) {
284
+ case 'created':
285
+ if (outcome.roleError) return `Member: couldn’t make them an admin (${outcome.roleError})`;
286
+ return outcome.role === 'admin' ? 'Admin' : 'Member';
287
+ case 'existing': {
288
+ const access = outcome.deactivated
289
+ ? 'Can’t sign in until it’s switched on in User accounts'
290
+ : 'Can sign in already';
291
+ if (outcome.roleError) return `${access}: couldn’t make them an admin (${outcome.roleError})`;
292
+ if (outcome.promoted) return `${access}, now an admin`;
293
+ if (outcome.alreadyAdmin) return `${access}, already an admin`;
294
+ return access;
295
+ }
296
+ case 'no-seat':
297
+ case 'error':
298
+ return outcome.message;
299
+ }
300
+ }
301
+
302
+ function InvitedBody({ outcomes, invited }: { outcomes: InviteOutcome[]; invited: number }) {
303
+ const { user } = useAuth();
304
+ const origin = window.location.origin;
305
+ const message =
306
+ 'I’ve added you to our workspace, where we keep what our AI agents should know about the company. ' +
307
+ `Sign in with your work account at ${origin}, then connect your agent from the welcome page.`;
308
+
309
+ return (
310
+ <div className="flex flex-col gap-4 py-1">
311
+ <p className="text-detail text-ink-muted">
312
+ {invited === 0
313
+ ? 'No accounts were created. The reason is on each row.'
314
+ : 'Their accounts are ready. Send them the link so they know to sign in.'}
315
+ </p>
316
+ <ul aria-label="People" className="flex flex-col divide-y divide-line">
317
+ {user && (
318
+ <PersonRow
319
+ label={`${user.name} (you)`}
320
+ detail={user.email}
321
+ badge={<Badge>Admin</Badge>}
322
+ strong
323
+ />
324
+ )}
325
+ {outcomes.map((outcome) => {
326
+ const badge = outcomeBadge(outcome);
327
+ return (
328
+ <PersonRow
329
+ key={outcome.email}
330
+ label={outcome.email}
331
+ detail={outcomeDetail(outcome)}
332
+ badge={<Badge tone={badge.tone}>{badge.label}</Badge>}
333
+ />
334
+ );
335
+ })}
336
+ </ul>
337
+ {invited > 0 && (
338
+ <>
339
+ <CopyRow label="Where they sign in" text={origin} copyLabel="Copy link" mono />
340
+ <CopyRow label="Or send this message" text={message} copyLabel="Copy message" />
341
+ </>
342
+ )}
343
+ </div>
344
+ );
345
+ }
346
+
347
+ function PersonRow({
348
+ label,
349
+ detail,
350
+ badge,
351
+ strong = false,
352
+ }: {
353
+ label: string;
354
+ detail: string;
355
+ badge: ReactNode;
356
+ strong?: boolean;
357
+ }) {
358
+ return (
359
+ <li className="flex items-center gap-2.5 py-2">
360
+ <span
361
+ aria-hidden
362
+ className="flex size-[26px] flex-none items-center justify-center rounded-full border border-line bg-sunken text-micro font-bold text-ink-muted"
363
+ >
364
+ {initials(label)}
365
+ </span>
366
+ <span className="min-w-0 flex-1">
367
+ <span className={`block truncate text-ui text-ink ${strong ? 'font-semibold' : ''}`}>
368
+ {label}
369
+ </span>
370
+ <span className="block truncate text-meta text-ink-faint" title={detail}>
371
+ {detail}
372
+ </span>
373
+ </span>
374
+ {badge}
375
+ </li>
376
+ );
377
+ }
378
+
379
+ /**
380
+ * Text to hand on, with its own copy button. The result is said on the
381
+ * button, and a failed copy says what to do instead — the text is on screen
382
+ * to select by hand.
383
+ */
384
+ function CopyRow({
385
+ label,
386
+ text,
387
+ copyLabel,
388
+ mono = false,
389
+ }: {
390
+ label: string;
391
+ text: string;
392
+ copyLabel: string;
393
+ mono?: boolean;
394
+ }) {
395
+ const [state, setState] = useState<'idle' | 'copied' | 'failed'>('idle');
396
+ const labelId = useId();
397
+ return (
398
+ <div className="flex flex-col gap-1.5">
399
+ <span id={labelId} className="text-detail font-medium text-ink">
400
+ {label}
401
+ </span>
402
+ <div className="flex items-stretch overflow-hidden rounded-md border border-line bg-sunken">
403
+ <p
404
+ aria-labelledby={labelId}
405
+ className={`min-w-0 flex-1 px-3 py-2 text-detail text-ink ${mono ? 'truncate font-mono' : 'whitespace-pre-wrap'}`}
406
+ >
407
+ {text}
408
+ </p>
409
+ <button
410
+ type="button"
411
+ onClick={() => {
412
+ void copyToClipboard(text).then((ok) => setState(ok ? 'copied' : 'failed'));
413
+ }}
414
+ className="flex-none border-l border-line bg-surface px-3 text-detail font-medium text-ink hover:bg-hover"
415
+ >
416
+ {state === 'copied' ? 'Copied' : copyLabel}
417
+ </button>
418
+ </div>
419
+ <span role="status" aria-live="polite" className="text-meta text-ink-faint empty:hidden">
420
+ {state === 'failed' ? 'Couldn’t copy: select the text and copy it yourself.' : ''}
421
+ </span>
422
+ </div>
423
+ );
424
+ }
@@ -2,36 +2,22 @@ import { useEffect, useState } from 'react';
2
2
  import { Navigate } from 'react-router-dom';
3
3
  import { KB_ROUTE_PREFIX } from '../../workspace/routing/kb-routes';
4
4
  import { takePostLoginRedirect } from '../../auth/services/sso';
5
- import { useOnboarding } from '../state/onboarding';
6
- import { WELCOME_PATH } from '../paths';
7
5
 
8
6
  /**
9
- * Where `/` lands. For everyone, forever: Knowledge — except the ONE visit
10
- * where an account is brand new (`users.onboarding_done` false, and never
11
- * greeted in this browser), which lands on the welcome page instead.
7
+ * Where `/` lands: Knowledge, for everyone, brand-new accounts included.
12
8
  *
13
- * Deliberately only the root route: a deep link is an intention, and
14
- * onboarding must never hijack one. Whoever skips the welcome is reminded by
15
- * the sidebar pill, not by the router.
9
+ * There is no automatic welcome page. Choosing where the knowledge lives is
10
+ * the one step that has to come before the app (the setup gate asks it);
11
+ * connecting an agent can wait, and it waits in plain sight — the sidebar's
12
+ * Connect your agent pill and the Get set up list both lead to the welcome
13
+ * page, and neither takes over the screen on the way in.
16
14
  *
17
15
  * A deep link that came through SSO arrives HERE rather than at itself — the
18
16
  * OAuth round-trip returns to a fixed callback URL, which scrubs to `/`
19
17
  * (see `consumeSsoCallback`) — so the link's intention survives as the stash
20
- * `startSsoLogin` left behind. An existing account goes straight to it; a
21
- * brand-new one is still greeted first, and the welcome page's Done returns
22
- * to the link instead of the usual shelf (the `returnTo` state below).
23
- *
24
- * `useOnboarding` is provider-tolerant, so `ShellRoutes` stays renderable
25
- * without the full stack (its own documented property); providerless or
26
- * signed out this is exactly the old `<Navigate to={KB_ROUTE_PREFIX}>`.
27
- *
28
- * The redirect carries `greeting`, and it is the ONLY navigation that does:
29
- * arriving here because you just signed in is a different event from opening
30
- * the same page from the sidebar, and the page needs to tell them apart to
31
- * know whether it is a ceremony or a page. See `WelcomePage`.
18
+ * `startSsoLogin` left behind, and it outranks Knowledge.
32
19
  */
33
20
  export function RootLanding() {
34
- const { shouldWelcome } = useOnboarding();
35
21
  const [stash, setStash] = useState<{ returnTo: string | null } | null>(null);
36
22
 
37
23
  // Taken in an effect, not a state initializer: the take CLEARS the stash,
@@ -40,6 +26,7 @@ export function RootLanding() {
40
26
  // only the run that found something writes.
41
27
  useEffect(() => {
42
28
  const returnTo = takePostLoginRedirect();
29
+ // eslint-disable-next-line react-hooks/set-state-in-effect -- the one-shot take described above; it settles in one extra render
43
30
  setStash((s) => s ?? { returnTo });
44
31
  }, []);
45
32
 
@@ -47,8 +34,5 @@ export function RootLanding() {
47
34
  // after would put the wrong page in the history.
48
35
  if (stash === null) return null;
49
36
 
50
- if (shouldWelcome) {
51
- return <Navigate to={WELCOME_PATH} state={{ greeting: true, returnTo: stash.returnTo }} replace />;
52
- }
53
37
  return <Navigate to={stash.returnTo ?? KB_ROUTE_PREFIX} replace />;
54
38
  }
@@ -0,0 +1,98 @@
1
+ import { useState } from 'react';
2
+ import { Button } from '../../../shared/components';
3
+ import { useWorkspace } from '../../workspace/state/workspace.context';
4
+ import { useStarterPacks } from '../state/starter-packs';
5
+ import { SKIP_STARTER_PACK, type StarterPackApplied, type StarterPackSummary } from '../services/starter-packs.api';
6
+
7
+ /**
8
+ * "What does your team do?" — what a new knowledge base's admin sees where
9
+ * the reader's empty state would be, while the server still offers it (see
10
+ * `useStarterPacks`): one chip per starter pack, in the server's order, and a
11
+ * quiet way out.
12
+ *
13
+ * Choosing adds the pack in one commit; the tree is fetched again here rather
14
+ * than left to the change event, and BEFORE the shared answer retires the
15
+ * card, so the pages are in the tree by the time the ordinary empty state
16
+ * takes over and suggests them (should that fetch fail, the change event the
17
+ * commit sends brings the tree up to date). A refusal is said on the card
18
+ * itself, in the server's words: toasts speak only inside the Library, and
19
+ * "someone is editing the knowledge base right now" is exactly the sentence
20
+ * the admin needs to read. What is under way is said in a live region too:
21
+ * the buttons only change shape, and a screen reader would hear nothing
22
+ * until the result.
23
+ */
24
+ export function StarterPackCard({
25
+ packs,
26
+ onDone,
27
+ }: {
28
+ packs: StarterPackSummary[];
29
+ /** Called once the choice landed (a skip included), with what was added. */
30
+ onDone(applied: StarterPackApplied): void;
31
+ }) {
32
+ const { choose } = useStarterPacks();
33
+ const { refreshFileTree } = useWorkspace();
34
+ const [busy, setBusy] = useState<string | null>(null);
35
+ const [error, setError] = useState<string | null>(null);
36
+
37
+ async function pick(id: string) {
38
+ if (busy) return;
39
+ setBusy(id);
40
+ setError(null);
41
+ try {
42
+ const applied = await choose(id, (added) =>
43
+ added.pages + added.skills > 0 ? refreshFileTree() : Promise.resolve(null),
44
+ );
45
+ onDone(applied);
46
+ } catch (err) {
47
+ setError(err instanceof Error ? err.message : String(err));
48
+ setBusy(null);
49
+ }
50
+ }
51
+
52
+ const skipping = busy === SKIP_STARTER_PACK;
53
+ const adding = busy && !skipping ? packs.find((pack) => pack.id === busy) : undefined;
54
+ const underWay = adding ? `Adding starter pages and skills for ${adding.name}…` : skipping ? 'Skipping…' : '';
55
+
56
+ return (
57
+ <section aria-labelledby="starter-pack-title" className="text-center">
58
+ <h2 id="starter-pack-title" className="mb-2 text-head text-ink">
59
+ What does your team do?
60
+ </h2>
61
+ <p className="mb-6 text-ui text-ink-muted">We’ll add starter pages and skills that fit.</p>
62
+ <div role="group" aria-labelledby="starter-pack-title" className="flex flex-wrap justify-center gap-2">
63
+ {packs.map((pack) => (
64
+ <Button
65
+ key={pack.id}
66
+ size="md"
67
+ variant="outline"
68
+ title={pack.description}
69
+ disabled={busy !== null}
70
+ aria-busy={busy === pack.id}
71
+ onClick={() => void pick(pack.id)}
72
+ >
73
+ {busy === pack.id ? 'Adding…' : pack.name}
74
+ </Button>
75
+ ))}
76
+ </div>
77
+ {error && (
78
+ <p role="alert" className="mt-3 text-detail text-danger">
79
+ {error}
80
+ </p>
81
+ )}
82
+ <Button
83
+ size="sm"
84
+ variant="quiet"
85
+ className="mt-4"
86
+ disabled={busy !== null}
87
+ aria-busy={skipping}
88
+ onClick={() => void pick(SKIP_STARTER_PACK)}
89
+ >
90
+ {skipping ? 'Skipping…' : 'Skip, I’ll start from scratch'}
91
+ </Button>
92
+ {/* Always in the tree, so the region exists before it has something to say. */}
93
+ <span role="status" aria-live="polite" className="sr-only">
94
+ {underWay}
95
+ </span>
96
+ </section>
97
+ );
98
+ }