@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,121 @@
1
+ import { useEffect } from 'react';
2
+ import { useLatestRef } from '../../../shared/components';
3
+ import { shortcutSequence, type CommandAction, type CommandContext } from './actions';
4
+
5
+ /** How long the second key of a sequence (G, then K) is waited for. */
6
+ export const SEQUENCE_TIMEOUT_MS = 1000;
7
+
8
+ /**
9
+ * Where a key is somebody typing, not a command: a text field, a select, an
10
+ * editor (CodeMirror and the rich editors are `contenteditable`).
11
+ */
12
+ function isTypingTarget(target: EventTarget | null): boolean {
13
+ if (!(target instanceof Element)) return false;
14
+ if (target instanceof HTMLElement && target.isContentEditable) return true;
15
+ return (
16
+ target.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"]') !==
17
+ null
18
+ );
19
+ }
20
+
21
+ /**
22
+ * Bind every offered command's `shortcut` on the document: `C` for New
23
+ * page, `G` then `K` for Knowledge, `G` then `S` for Skills & Tools, and
24
+ * whatever keys a distribution gave its own commands (`mergeCommandActions`
25
+ * has already dropped the ones that would collide). The keys a row shows
26
+ * are the keys bound, one field. Mounted once, by the toolbar's palette.
27
+ *
28
+ * A bare letter is a lot to claim, so it is claimed only when nobody could
29
+ * mean it as text or as anything else:
30
+ *
31
+ * - focus is not in a field or an editor (a `c` typed into a page is a `c`);
32
+ * - no modifier is held (Ctrl+C is copy, Shift+C a capital);
33
+ * - no modal dialog is up (it owns the keyboard, as it does for Ctrl/⌘K);
34
+ * - the palette is shut (`enabled`) — open, every key is the query's.
35
+ *
36
+ * Only commands on offer run: `G` `K` with no Knowledge app does nothing,
37
+ * and lets the key through. A sequence's first key waits
38
+ * {@link SEQUENCE_TIMEOUT_MS} for its second, then is forgotten.
39
+ */
40
+ export function useCommandShortcuts({
41
+ actions,
42
+ ctx,
43
+ enabled,
44
+ run,
45
+ }: {
46
+ /** The commands on offer now (`useCommandActions`). */
47
+ actions: readonly CommandAction[];
48
+ ctx: CommandContext;
49
+ enabled: boolean;
50
+ /** How a command is run — the palette's own runner, so a failure is reported the same way. */
51
+ run: (action: CommandAction, ctx: CommandContext) => void;
52
+ }): void {
53
+ const latest = useLatestRef({ actions, ctx, enabled, run });
54
+
55
+ useEffect(() => {
56
+ let first: string | null = null;
57
+ let timer: number | undefined;
58
+ const forget = () => {
59
+ first = null;
60
+ window.clearTimeout(timer);
61
+ };
62
+
63
+ // The commands on offer now, by their keys; read per key press, since
64
+ // what is offered follows the page on screen.
65
+ const bound = (seq: string): CommandAction | undefined =>
66
+ latest.current.actions.find((a) => shortcutSequence(a) === seq);
67
+
68
+ const runBound = (keys: readonly string[]): boolean => {
69
+ const action = bound(keys.join(' '));
70
+ if (!action) return false;
71
+ run(action, latest.current.ctx);
72
+ return true;
73
+ };
74
+ const run = (action: CommandAction, ctx: CommandContext) => latest.current.run(action, ctx);
75
+
76
+ function onKeyDown(e: KeyboardEvent) {
77
+ if (!latest.current.enabled || e.defaultPrevented || e.repeat) return;
78
+ if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || isTypingTarget(e.target)) {
79
+ forget();
80
+ return;
81
+ }
82
+ if (document.querySelector('[aria-modal="true"]')) {
83
+ forget();
84
+ return;
85
+ }
86
+ const key = e.key.toLowerCase();
87
+ if (first !== null) {
88
+ const sequence = [first, key];
89
+ forget();
90
+ if (runBound(sequence)) {
91
+ e.preventDefault();
92
+ return;
93
+ }
94
+ // Not a sequence after all: the second key is tried on its own, so
95
+ // `G` then `C` still makes a page, and `G` then `G` re-arms.
96
+ }
97
+ if (runBound([key])) {
98
+ e.preventDefault();
99
+ return;
100
+ }
101
+ // The first key of a sequence: hold it for the second.
102
+ const opensSequence = latest.current.actions.some((a) => {
103
+ const keys = a.shortcut ?? [];
104
+ return keys.length === 2 && keys[0]?.toLowerCase() === key;
105
+ });
106
+ if (opensSequence) {
107
+ first = key;
108
+ timer = window.setTimeout(forget, SEQUENCE_TIMEOUT_MS);
109
+ }
110
+ }
111
+
112
+ document.addEventListener('keydown', onKeyDown);
113
+ return () => {
114
+ document.removeEventListener('keydown', onKeyDown);
115
+ forget();
116
+ };
117
+ // `enabled` is in the list so a pending first key is forgotten when the
118
+ // palette opens or closes: a `G` pressed before Ctrl+K must not turn the
119
+ // `K` typed after Escape into a navigation.
120
+ }, [latest, enabled]);
121
+ }
@@ -1,30 +1,37 @@
1
- import { useEffect, useMemo, useRef, useState } from 'react';
1
+ import { useEffect, useMemo, useRef, useState, type MouseEvent as ReactMouseEvent } from 'react';
2
2
  import { Check, ChevronDown } from 'lucide-react';
3
- import { useLocation, useNavigate } from 'react-router-dom';
3
+ import { Link, useLocation, useNavigate } from 'react-router-dom';
4
4
  import { activeAppId, useActiveAppId, useAppRegistry, type AppDef } from '../../../core/registry';
5
+ import { useMediaQuery } from '../../layout/hooks/useMediaQuery';
6
+ import { TOOLBAR_STACK_QUERY } from '../../layout/breakpoints';
7
+ import { cn } from '../../../lib/utils';
8
+ import { PRODUCT_NAME, ProductName } from '../../../core/ProductName';
9
+ import { useMakerLinkLabel, useMakerUrl } from '../../../core/maker-url';
5
10
 
6
11
  const MENU_ID = 'app-switcher-menu';
7
12
 
8
13
  /**
9
- * The clickable brand in the toolbar's top-left: shows the product name, the
10
- * app you are currently in, and opens the app switcher — the list of
11
- * top-level surfaces (core apps + registry-contributed ones) you can move
12
- * between.
14
+ * The most apps the toolbar lays out side by side. Core ships two; a third
15
+ * (an enterprise extension) still fits beside the brand. Past that the row
16
+ * would crowd out the toolbar items, so the list folds back into the menu.
17
+ */
18
+ const MAX_SEGMENTS = 3;
19
+
20
+ /**
21
+ * The toolbar's top-left: the product name and the way between the top-level
22
+ * surfaces (core apps + registry-contributed ones).
13
23
  *
14
24
  * Switching between Knowledge and Skills & Tools changes everything below the
15
- * toolbar, so the trigger names the destination it landed on ("Bevel /
16
- * Knowledge"); a brand on its own left the switch invisible.
17
- *
18
- * Open/close mechanics mirror AdminMenu: click toggles, an outside mousedown
19
- * or Escape closes, and closing hands focus back to the trigger.
25
+ * toolbar, so the switch must say where you are without being opened. With
26
+ * few apps on a wide toolbar that is a segmented control — every destination
27
+ * on show, the current one lifted. With more apps, or on a compact toolbar
28
+ * where the row would not fit, it is a menu behind a trigger that names the
29
+ * current app ("Bevel / Knowledge").
20
30
  */
21
31
  export function AppSwitcher() {
22
- const navigate = useNavigate();
23
32
  const location = useLocation();
24
33
  const registry = useAppRegistry();
25
- const [open, setOpen] = useState(false);
26
- const ref = useRef<HTMLDivElement>(null);
27
- const buttonRef = useRef<HTMLButtonElement>(null);
34
+ const isCompact = useMediaQuery(TOOLBAR_STACK_QUERY);
28
35
 
29
36
  // The shell merges the core apps into the registry (see CoreAppShell), so
30
37
  // this list is complete — core Knowledge / Skills & Tools plus extensions.
@@ -36,12 +43,88 @@ export function AppSwitcher() {
36
43
  // the path-prefix rule (a skill page at its canonical /workspace URL claims
37
44
  // Skills & Tools — see AppClaimContext). The local computation is the
38
45
  // fallback for standalone renders, where the context is undefined and the
39
- // prefix rule is all there is.
46
+ // prefix rule is all there is. Undefined on the standalone settings pages,
47
+ // where no app is active.
40
48
  const shellActiveId = useActiveAppId();
41
49
  const activeId = shellActiveId ?? activeAppId(apps, location.pathname);
42
- // Named next to the brand so the toolbar answers "which app am I in?"
43
- // without opening the menu. Undefined on the standalone settings pages,
44
- // where no app is active and the trigger is the brand alone.
50
+
51
+ if (!isCompact && apps.length > 0 && apps.length <= MAX_SEGMENTS) {
52
+ return <AppToggle apps={apps} activeId={activeId} />;
53
+ }
54
+ return <AppMenu apps={apps} activeId={activeId} />;
55
+ }
56
+
57
+ /** A primary-button click with no modifier: the one a link should treat as "go here". */
58
+ function isPlainClick(e: ReactMouseEvent<HTMLAnchorElement>): boolean {
59
+ return e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey;
60
+ }
61
+
62
+ interface SwitcherProps {
63
+ apps: AppDef[];
64
+ activeId: string | undefined;
65
+ }
66
+
67
+ /**
68
+ * The brand as plain text, then one segment per app, styled like the
69
+ * Library sidebar's view switch: on the hover tint, the current app lifted
70
+ * onto the surface.
71
+ *
72
+ * A `nav` of links with `aria-current="page"`, not a tablist: each segment
73
+ * goes somewhere else in the app rather than revealing a panel here, so it
74
+ * is navigation, and links also open in a new tab like any other.
75
+ */
76
+ function AppToggle({ apps, activeId }: SwitcherProps) {
77
+ return (
78
+ <div className="flex min-w-0 items-center gap-2">
79
+ <ProductName className="shrink-0 px-1.5 text-sm font-semibold tracking-wide text-ink" />
80
+ <nav aria-label="Apps" className="flex shrink-0 gap-0.5 rounded-md bg-hover p-0.5">
81
+ {apps.map((app) => {
82
+ const current = app.id === activeId;
83
+ return (
84
+ <Link
85
+ key={app.id}
86
+ to={app.path}
87
+ aria-current={current ? 'page' : undefined}
88
+ title={app.description}
89
+ // Same as choosing the current app in the menu: nothing. A
90
+ // click must not throw a deep link back to the app's root. A
91
+ // modified or middle click is the reader asking for a new tab
92
+ // or window, which the link still does like any other.
93
+ onClick={(e) => {
94
+ if (current && isPlainClick(e)) e.preventDefault();
95
+ }}
96
+ className={cn(
97
+ 'whitespace-nowrap rounded-sm px-2.5 py-1 text-detail font-semibold transition-[background-color,color,box-shadow]',
98
+ 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink-muted',
99
+ current ? 'bg-surface text-ink shadow-card' : 'text-ink-muted hover:text-ink',
100
+ )}
101
+ >
102
+ {app.label}
103
+ </Link>
104
+ );
105
+ })}
106
+ </nav>
107
+ </div>
108
+ );
109
+ }
110
+
111
+ /**
112
+ * The clickable brand: names the app you are currently in and opens the list
113
+ * of apps. A brand on its own left the switch invisible, hence the label.
114
+ *
115
+ * Open/close mechanics mirror AdminMenu: click toggles, an outside mousedown
116
+ * or Escape closes, and closing hands focus back to the trigger.
117
+ */
118
+ function AppMenu({ apps, activeId }: SwitcherProps) {
119
+ const navigate = useNavigate();
120
+ const makerUrl = useMakerUrl();
121
+ const makerLabel = useMakerLinkLabel(PRODUCT_NAME);
122
+ const [open, setOpen] = useState(false);
123
+ const ref = useRef<HTMLDivElement>(null);
124
+ const buttonRef = useRef<HTMLButtonElement>(null);
125
+
126
+ // Undefined on the standalone settings pages, where the trigger is the
127
+ // brand alone.
45
128
  const activeApp = apps.find((a) => a.id === activeId);
46
129
 
47
130
  const close = () => {
@@ -73,19 +156,23 @@ export function AppSwitcher() {
73
156
  };
74
157
 
75
158
  return (
76
- <div ref={ref} className="relative">
159
+ // `min-w-0` down the chain, and `truncate` on the brand as well as the app
160
+ // label: on the narrowest toolbars the trigger gives up width before the
161
+ // controls on the right are pushed off-screen. Its name is "Switch app"
162
+ // either way, and the menu it opens names every app in full.
163
+ <div ref={ref} className="relative min-w-0">
77
164
  <button
78
165
  ref={buttonRef}
79
166
  type="button"
80
167
  onClick={() => setOpen((v) => !v)}
81
- className="flex min-w-0 items-center gap-1 px-1.5 py-1 rounded hover:bg-hover text-ink"
168
+ className="flex min-w-0 items-center gap-1 px-1.5 py-1 rounded-sm hover:bg-hover text-ink"
82
169
  title={activeApp ? `Switch app. Currently ${activeApp.label}` : 'Switch app'}
83
170
  aria-label="Switch app"
84
171
  aria-haspopup="menu"
85
172
  aria-expanded={open}
86
173
  aria-controls={open ? MENU_ID : undefined}
87
174
  >
88
- <span className="shrink-0 text-sm font-semibold tracking-wide">Bevel</span>
175
+ <span className="min-w-0 truncate text-sm font-semibold tracking-wide">{PRODUCT_NAME}</span>
89
176
  {activeApp && (
90
177
  <>
91
178
  <span aria-hidden="true" className="shrink-0 text-sm text-ink-faint">
@@ -124,6 +211,22 @@ export function AppSwitcher() {
124
211
  </span>
125
212
  </button>
126
213
  ))}
214
+ {/* The maker's link, which the trigger cannot carry: a link inside a
215
+ button is not allowed. On a compact toolbar this is the only way
216
+ from a page in the app to the maker's site, or to wherever the
217
+ registry sends it, such as the hosted cloud's Impressum, under
218
+ the registry's own label for it when it names one. */}
219
+ <div role="separator" className="my-1 border-t border-line" />
220
+ <a
221
+ role="menuitem"
222
+ href={makerUrl}
223
+ target="_blank"
224
+ rel="noopener noreferrer"
225
+ onClick={close}
226
+ className="block px-3 py-2 text-xs text-ink-muted hover:bg-hover hover:text-ink"
227
+ >
228
+ {makerLabel}
229
+ </a>
127
230
  </div>
128
231
  )}
129
232
  </div>
@@ -728,7 +728,7 @@ export function ExternalAgentAccessPage() {
728
728
  <ol className="text-meta text-ink-muted mb-1 leading-snug list-decimal pl-4 space-y-0.5">
729
729
  <li>In Langdock, open your workspace settings and go to MCP servers → Add server.</li>
730
730
  <li>Choose <span className="font-medium">HTTP</span> (Streamable HTTP) as the transport.</li>
731
- <li>Give it a name (e.g. <span className="font-medium">Bevel</span>), paste the URL below into the server URL field, and add the Authorization header under custom headers.</li>
731
+ <li>Give it a name (e.g. <span className="font-medium">Hexis</span>), paste the URL below into the server URL field, and add the Authorization header under custom headers.</li>
732
732
  <li>Save, then enable the server in any assistant you want it available in.</li>
733
733
  </ol>
734
734
  <textarea
@@ -140,7 +140,8 @@ export function ProfileMenu() {
140
140
  return;
141
141
  }
142
142
  if (item.onSelect) {
143
- item.onSelect({ closeMenu: close, navigate });
143
+ // Rows render only with a user (see the early return below).
144
+ if (user) item.onSelect({ closeMenu: close, navigate, user });
144
145
  return;
145
146
  }
146
147
  if (item.path) {
@@ -180,6 +181,10 @@ export function ProfileMenu() {
180
181
  // taken as one; signed out there is nobody to be.
181
182
  if (!user) return null;
182
183
 
184
+ // Rows offered to this person right now (see `AdminMenuItem.isShown`).
185
+ const shownDefaultItems = defaultItems.filter((item) => item.isShown?.(user) ?? true);
186
+ const shownAdminItems = adminItems.filter((item) => item.isShown?.(user) ?? true);
187
+
183
188
  return (
184
189
  <div className="relative">
185
190
  <button
@@ -264,12 +269,12 @@ export function ProfileMenu() {
264
269
  </span>
265
270
  </div>
266
271
 
267
- {defaultItems.map(renderRow)}
272
+ {shownDefaultItems.map(renderRow)}
268
273
 
269
- {isAdmin && adminItems.length > 0 && (
274
+ {isAdmin && shownAdminItems.length > 0 && (
270
275
  <div role="group" aria-labelledby="profile-menu-admin-section-label">
271
276
  <MenuLabel id="profile-menu-admin-section-label">Admin only</MenuLabel>
272
- {adminItems.map(renderRow)}
277
+ {shownAdminItems.map(renderRow)}
273
278
  </div>
274
279
  )}
275
280