@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,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,36 @@
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';
5
9
 
6
10
  const MENU_ID = 'app-switcher-menu';
7
11
 
8
12
  /**
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.
13
+ * The most apps the toolbar lays out side by side. Core ships two; a third
14
+ * (an enterprise extension) still fits beside the brand. Past that the row
15
+ * would crowd out the toolbar items, so the list folds back into the menu.
16
+ */
17
+ const MAX_SEGMENTS = 3;
18
+
19
+ /**
20
+ * The toolbar's top-left: the product name and the way between the top-level
21
+ * surfaces (core apps + registry-contributed ones).
13
22
  *
14
23
  * 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.
24
+ * toolbar, so the switch must say where you are without being opened. With
25
+ * few apps on a wide toolbar that is a segmented control — every destination
26
+ * on show, the current one lifted. With more apps, or on a compact toolbar
27
+ * where the row would not fit, it is a menu behind a trigger that names the
28
+ * current app ("Bevel / Knowledge").
20
29
  */
21
30
  export function AppSwitcher() {
22
- const navigate = useNavigate();
23
31
  const location = useLocation();
24
32
  const registry = useAppRegistry();
25
- const [open, setOpen] = useState(false);
26
- const ref = useRef<HTMLDivElement>(null);
27
- const buttonRef = useRef<HTMLButtonElement>(null);
33
+ const isCompact = useMediaQuery(TOOLBAR_STACK_QUERY);
28
34
 
29
35
  // The shell merges the core apps into the registry (see CoreAppShell), so
30
36
  // this list is complete — core Knowledge / Skills & Tools plus extensions.
@@ -36,12 +42,86 @@ export function AppSwitcher() {
36
42
  // the path-prefix rule (a skill page at its canonical /workspace URL claims
37
43
  // Skills & Tools — see AppClaimContext). The local computation is the
38
44
  // fallback for standalone renders, where the context is undefined and the
39
- // prefix rule is all there is.
45
+ // prefix rule is all there is. Undefined on the standalone settings pages,
46
+ // where no app is active.
40
47
  const shellActiveId = useActiveAppId();
41
48
  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.
49
+
50
+ if (!isCompact && apps.length > 0 && apps.length <= MAX_SEGMENTS) {
51
+ return <AppToggle apps={apps} activeId={activeId} />;
52
+ }
53
+ return <AppMenu apps={apps} activeId={activeId} />;
54
+ }
55
+
56
+ /** A primary-button click with no modifier: the one a link should treat as "go here". */
57
+ function isPlainClick(e: ReactMouseEvent<HTMLAnchorElement>): boolean {
58
+ return e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey;
59
+ }
60
+
61
+ interface SwitcherProps {
62
+ apps: AppDef[];
63
+ activeId: string | undefined;
64
+ }
65
+
66
+ /**
67
+ * The brand as plain text, then one segment per app, styled like the
68
+ * Library sidebar's view switch: on the hover tint, the current app lifted
69
+ * onto the surface.
70
+ *
71
+ * A `nav` of links with `aria-current="page"`, not a tablist: each segment
72
+ * goes somewhere else in the app rather than revealing a panel here, so it
73
+ * is navigation, and links also open in a new tab like any other.
74
+ */
75
+ function AppToggle({ apps, activeId }: SwitcherProps) {
76
+ return (
77
+ <div className="flex min-w-0 items-center gap-2">
78
+ <ProductName className="shrink-0 px-1.5 text-sm font-semibold tracking-wide text-ink" />
79
+ <nav aria-label="Apps" className="flex shrink-0 gap-0.5 rounded-md bg-hover p-0.5">
80
+ {apps.map((app) => {
81
+ const current = app.id === activeId;
82
+ return (
83
+ <Link
84
+ key={app.id}
85
+ to={app.path}
86
+ aria-current={current ? 'page' : undefined}
87
+ title={app.description}
88
+ // Same as choosing the current app in the menu: nothing. A
89
+ // click must not throw a deep link back to the app's root. A
90
+ // modified or middle click is the reader asking for a new tab
91
+ // or window, which the link still does like any other.
92
+ onClick={(e) => {
93
+ if (current && isPlainClick(e)) e.preventDefault();
94
+ }}
95
+ className={cn(
96
+ 'whitespace-nowrap rounded-sm px-2.5 py-1 text-detail font-semibold transition-[background-color,color,box-shadow]',
97
+ 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink-muted',
98
+ current ? 'bg-surface text-ink shadow-card' : 'text-ink-muted hover:text-ink',
99
+ )}
100
+ >
101
+ {app.label}
102
+ </Link>
103
+ );
104
+ })}
105
+ </nav>
106
+ </div>
107
+ );
108
+ }
109
+
110
+ /**
111
+ * The clickable brand: names the app you are currently in and opens the list
112
+ * of apps. A brand on its own left the switch invisible, hence the label.
113
+ *
114
+ * Open/close mechanics mirror AdminMenu: click toggles, an outside mousedown
115
+ * or Escape closes, and closing hands focus back to the trigger.
116
+ */
117
+ function AppMenu({ apps, activeId }: SwitcherProps) {
118
+ const navigate = useNavigate();
119
+ const [open, setOpen] = useState(false);
120
+ const ref = useRef<HTMLDivElement>(null);
121
+ const buttonRef = useRef<HTMLButtonElement>(null);
122
+
123
+ // Undefined on the standalone settings pages, where the trigger is the
124
+ // brand alone.
45
125
  const activeApp = apps.find((a) => a.id === activeId);
46
126
 
47
127
  const close = () => {
@@ -73,19 +153,23 @@ export function AppSwitcher() {
73
153
  };
74
154
 
75
155
  return (
76
- <div ref={ref} className="relative">
156
+ // `min-w-0` down the chain, and `truncate` on the brand as well as the app
157
+ // label: on the narrowest toolbars the trigger gives up width before the
158
+ // controls on the right are pushed off-screen. Its name is "Switch app"
159
+ // either way, and the menu it opens names every app in full.
160
+ <div ref={ref} className="relative min-w-0">
77
161
  <button
78
162
  ref={buttonRef}
79
163
  type="button"
80
164
  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"
165
+ className="flex min-w-0 items-center gap-1 px-1.5 py-1 rounded-sm hover:bg-hover text-ink"
82
166
  title={activeApp ? `Switch app. Currently ${activeApp.label}` : 'Switch app'}
83
167
  aria-label="Switch app"
84
168
  aria-haspopup="menu"
85
169
  aria-expanded={open}
86
170
  aria-controls={open ? MENU_ID : undefined}
87
171
  >
88
- <span className="shrink-0 text-sm font-semibold tracking-wide">Bevel</span>
172
+ <span className="min-w-0 truncate text-sm font-semibold tracking-wide">{PRODUCT_NAME}</span>
89
173
  {activeApp && (
90
174
  <>
91
175
  <span aria-hidden="true" className="shrink-0 text-sm text-ink-faint">
@@ -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