@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.
- package/package.json +2 -2
- package/src/core/CoreAppShell.tsx +87 -25
- package/src/core/ProductName.tsx +49 -0
- package/src/core/__tests__/ProductName.test.tsx +46 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
- package/src/core/__tests__/core-contributions.test.ts +16 -0
- package/src/core/core-contributions.ts +17 -0
- package/src/core/maker-url.ts +30 -0
- package/src/core/registry.ts +78 -1
- package/src/index.css +23 -5
- package/src/index.ts +5 -0
- package/src/lib/__tests__/latest-request.test.ts +48 -0
- package/src/lib/latest-request.ts +45 -0
- package/src/modules/access/__tests__/ManageAccessDialog.no-sso-invite.test.tsx +222 -0
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
- package/src/modules/access/api.ts +19 -3
- package/src/modules/access/components/ManageAccessDialog.tsx +61 -8
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +16 -1
- package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +284 -39
- package/src/modules/admin/components/AdminRolesPage.tsx +13 -14
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
- package/src/modules/admin/components/UserAccountsPage.tsx +91 -107
- package/src/modules/admin/services/roles.api.ts +14 -1
- package/src/modules/auth/__tests__/LoginScreen.test.tsx +80 -5
- package/src/modules/auth/__tests__/sso-strict-probe.test.ts +66 -0
- package/src/modules/auth/components/LoginScreen.tsx +101 -73
- package/src/modules/auth/services/account.api.ts +59 -3
- package/src/modules/auth/services/sso.ts +30 -10
- package/src/modules/auth/state/use-sign-in-methods.ts +41 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
- package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
- package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
- package/src/modules/change-requests/services/change-requests.api.ts +15 -2
- package/src/modules/change-requests/utils/readFailure.ts +22 -0
- package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
- package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
- package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
- package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
- package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
- package/src/modules/embed/__tests__/mount.test.tsx +157 -0
- package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
- package/src/modules/embed/components/EmbedView.tsx +545 -0
- package/src/modules/embed/embed-config.ts +132 -0
- package/src/modules/embed/embed-host.ts +120 -0
- package/src/modules/embed/mount.tsx +80 -0
- package/src/modules/embed/services/embed-token.ts +22 -0
- package/src/modules/embed/services/embed.api.ts +158 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
- package/src/modules/git/branch-delete-menu-item.tsx +24 -0
- package/src/modules/git/components/BranchSwitcher.tsx +29 -5
- package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
- package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
- package/src/modules/git/components/PullNeededBanner.tsx +15 -49
- package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
- package/src/modules/git/index.ts +15 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
- package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
- package/src/modules/git/services/error-messages.ts +58 -1
- package/src/modules/git/services/pull-failure.ts +68 -0
- package/src/modules/git/state/branch-delete-confirm.ts +46 -0
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
- package/src/modules/layout/breakpoints.ts +8 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
- package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
- package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
- package/src/modules/library/components/LibraryPage.tsx +22 -0
- package/src/modules/library/components/PluginExtras.tsx +23 -6
- package/src/modules/library/components/PluginPage.tsx +6 -1
- package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- package/src/modules/library/state/plugins-revision.ts +28 -0
- package/src/modules/onboarding/__tests__/InviteButton.test.tsx +214 -0
- package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
- package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +164 -0
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1458 -0
- package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +811 -0
- package/src/modules/onboarding/__tests__/invite-emails.test.ts +247 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
- package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
- package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
- package/src/modules/onboarding/components/GetStartedColumn.tsx +670 -0
- package/src/modules/onboarding/components/InviteButton.tsx +139 -0
- package/src/modules/onboarding/components/InviteDialog.tsx +741 -0
- package/src/modules/onboarding/components/RootLanding.tsx +8 -24
- package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
- package/src/modules/onboarding/first-page-prompt.ts +123 -0
- package/src/modules/onboarding/invite-emails.ts +313 -0
- package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
- package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
- package/src/modules/onboarding/state/agent-connection.ts +167 -0
- package/src/modules/onboarding/state/invite-dialog.context.ts +35 -0
- package/src/modules/onboarding/state/invite-dialog.tsx +39 -0
- package/src/modules/onboarding/state/onboarding.ts +133 -59
- package/src/modules/onboarding/state/starter-packs.ts +169 -0
- package/src/modules/settings/settings-nav-items.tsx +8 -3
- package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
- package/src/modules/setup/__tests__/setup.test.tsx +56 -15
- package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
- package/src/modules/setup/components/SetupGate.tsx +46 -1
- package/src/modules/setup/components/SetupScreen.tsx +81 -84
- package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +3 -3
- package/src/modules/setup/utils/suggested-branch.ts +27 -0
- package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
- package/src/modules/toolbar/commands/actions.tsx +330 -0
- package/src/modules/toolbar/commands/command-menu.ts +44 -0
- package/src/modules/toolbar/commands/useCommandActions.ts +71 -0
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +125 -22
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
- package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
- package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
- package/src/modules/toolbar/components/Toolbar.tsx +10 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +230 -52
- package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +864 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
- package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
- package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
- package/src/modules/toolbar/search/rank.ts +111 -0
- package/src/modules/toolbar/search/sources.ts +169 -0
- package/src/modules/workflow/hooks/useFileLock.ts +10 -7
- package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
- package/src/modules/workflow/services/lock.api.ts +17 -2
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
- package/src/modules/workspace/components/EditorTabs.tsx +39 -15
- package/src/modules/workspace/components/FileExplorer.tsx +39 -6
- package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
- package/src/modules/workspace/components/FileRoute.tsx +12 -7
- package/src/modules/workspace/components/FileViewer.tsx +271 -74
- package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +92 -4
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
- package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
- package/src/modules/workspace/components/renderers/index.ts +26 -0
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
- package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
- package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
- package/src/modules/workspace/hooks/__tests__/useCreatePage.test.ts +137 -0
- package/src/modules/workspace/hooks/__tests__/useKnowledgeWriteTarget.test.ts +302 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
- package/src/modules/workspace/hooks/useCreatePage.ts +206 -0
- package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +238 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
- package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
- package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
- package/src/modules/workspace/routing/kb-routes.ts +66 -12
- package/src/modules/workspace/state/editable-page.ts +42 -0
- package/src/modules/workspace/state/workspace.context.ts +13 -4
- package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +16 -0
- package/src/modules/workspace/utils/display-file-name.ts +102 -0
- package/src/modules/workspace/utils/fileTree.ts +49 -14
- package/src/modules/workspace/utils/treeConfirm.ts +15 -0
- package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
- package/src/shared/components/ConfirmProvider.tsx +156 -0
- package/src/shared/components/Dialog.tsx +7 -0
- package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
- package/src/shared/components/confirm-context.ts +94 -0
- package/src/shared/components/index.ts +3 -0
- package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useId,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type KeyboardEvent as ReactKeyboardEvent,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
type RefObject,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import { useNavigate } from 'react-router-dom';
|
|
13
|
+
import { ChevronRight, FileText, Puzzle, Search, Sparkles, Wrench } from 'lucide-react';
|
|
14
|
+
import { MenuPanel, useDismissableMenu, useLatestRef } from '../../../shared/components';
|
|
15
|
+
import { cn } from '../../../lib/utils';
|
|
16
|
+
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
17
|
+
import { useMergedWorkspaceTree } from '../../workspace/hooks/useMergedWorkspaceTree';
|
|
18
|
+
import { useFileNav } from '../../workspace/routing/kb-routes';
|
|
19
|
+
import { knowledgeFiles } from '../../workspace/utils/fileTree';
|
|
20
|
+
import { listSkills } from '../../library/services/library.api';
|
|
21
|
+
import { listPlugins } from '../../library/services/plugins.api';
|
|
22
|
+
import { listToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
23
|
+
import { rankByName, rankByNames } from '../search/rank';
|
|
24
|
+
import {
|
|
25
|
+
libraryResults,
|
|
26
|
+
pageResults,
|
|
27
|
+
type LibraryCatalog,
|
|
28
|
+
type SearchResult,
|
|
29
|
+
type SearchResultKind,
|
|
30
|
+
} from '../search/sources';
|
|
31
|
+
import { actionNames, suggestedActions, type CommandAction, type CommandContext } from '../commands/actions';
|
|
32
|
+
import { useCommandActions } from '../commands/useCommandActions';
|
|
33
|
+
import { useCommandShortcuts } from '../commands/useCommandShortcuts';
|
|
34
|
+
import {
|
|
35
|
+
COMMAND_MENU_SHORTCUT_ARIA,
|
|
36
|
+
COMMAND_MENU_SHORTCUT_LABEL,
|
|
37
|
+
isCommandMenuShortcut,
|
|
38
|
+
onCommandMenuRequest,
|
|
39
|
+
} from '../commands/command-menu';
|
|
40
|
+
import { useSetupChecklist } from '../../onboarding/state/onboarding';
|
|
41
|
+
|
|
42
|
+
/** Rows per group. Past this the query is too short to be useful, not the list too long. */
|
|
43
|
+
const GROUP_LIMIT = 8;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Commands get a little more room: the settings alone are nine rows for an
|
|
47
|
+
* admin, and "settings" should list them all rather than drop one.
|
|
48
|
+
*/
|
|
49
|
+
const ACTION_LIMIT = 12;
|
|
50
|
+
|
|
51
|
+
/** No row highlighted — what an empty query opens on (see `activeIndex`). */
|
|
52
|
+
const NO_ROW = -1;
|
|
53
|
+
|
|
54
|
+
/** The box's own words, and the input's (which ends on an ellipsis: it is waiting for you). */
|
|
55
|
+
const TRIGGER_LABEL = 'Search or run a command';
|
|
56
|
+
const PLACEHOLDER = 'Search or run a command…';
|
|
57
|
+
|
|
58
|
+
const byName = (r: SearchResult) => r.name;
|
|
59
|
+
|
|
60
|
+
const ICONS: Record<SearchResultKind, ReactNode> = {
|
|
61
|
+
page: <FileText size={15} />,
|
|
62
|
+
skill: <Sparkles size={15} />,
|
|
63
|
+
tool: <Wrench size={15} />,
|
|
64
|
+
plugin: <Puzzle size={15} />,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** One row of the listbox: a command to run, or a page or item to open. */
|
|
68
|
+
type PaletteRow =
|
|
69
|
+
| { key: string; action: CommandAction; result?: never }
|
|
70
|
+
| { key: string; result: SearchResult; action?: never };
|
|
71
|
+
|
|
72
|
+
const actionRow = (action: CommandAction): PaletteRow => ({ key: `action:${action.id}`, action });
|
|
73
|
+
const resultRow = (result: SearchResult): PaletteRow => ({ key: result.key, result });
|
|
74
|
+
|
|
75
|
+
/** A shortcut as a screen reader should hear it: "C", "G then K". */
|
|
76
|
+
const spokenShortcut = (keys: readonly string[]) => keys.join(' then ');
|
|
77
|
+
|
|
78
|
+
interface CatalogState {
|
|
79
|
+
/** A load is in flight. The previous catalog, if any, stays on screen meanwhile. */
|
|
80
|
+
loading: boolean;
|
|
81
|
+
/** Every source failed. One failing alone (say, plugins) just leaves its rows out. */
|
|
82
|
+
failed: boolean;
|
|
83
|
+
catalog: LibraryCatalog | null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The toolbar's search box and the palette it opens — the prototype's
|
|
88
|
+
* `.search-box` and `searchPop()`: one place to find a page, a skill, a tool
|
|
89
|
+
* or a plugin BY NAME, from anywhere in the app — and to run a command ("New
|
|
90
|
+
* page", "Invite people", "Settings: Secrets"; see `commands/actions`), which
|
|
91
|
+
* are listed first. Ctrl+K (⌘K on a Mac) opens it
|
|
92
|
+
* from anywhere too, which is how it is reached on a narrow window, where the
|
|
93
|
+
* box itself does not fit in the toolbar.
|
|
94
|
+
*
|
|
95
|
+
* Name search only, against what the browser already has or can list in one
|
|
96
|
+
* request per source: no full-text index and no endpoint of its own.
|
|
97
|
+
*
|
|
98
|
+
* - Pages are the files the Knowledge explorer browses (`knowledgeFiles`),
|
|
99
|
+
* read off the same merged tree the explorer draws — so the palette finds
|
|
100
|
+
* exactly what the sidebar shows, on the branch on screen.
|
|
101
|
+
* - Skills, tools and plugins come from the Library's list endpoints. NOT
|
|
102
|
+
* `useLibraryData`: that hook is the gallery's, and pays an N+1 `getSkill`
|
|
103
|
+
* for frontmatter, access verdicts and change requests a name search never
|
|
104
|
+
* reads. And not on page load either: the catalog is fetched when the
|
|
105
|
+
* palette OPENS, and again on each later open (behind the rows already
|
|
106
|
+
* shown) so a skill created a minute ago is findable.
|
|
107
|
+
*
|
|
108
|
+
* A combobox driving a listbox (`aria-activedescendant`): focus stays in the
|
|
109
|
+
* input while ↑/↓ move the highlighted row, Enter opens it, Escape closes the
|
|
110
|
+
* palette and hands focus back to where it was before it opened.
|
|
111
|
+
*/
|
|
112
|
+
export function SearchPalette({ compact }: { compact: boolean }) {
|
|
113
|
+
const [open, setOpen] = useState(false);
|
|
114
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
115
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
116
|
+
// Where focus was before the palette opened: the trigger after a click, the
|
|
117
|
+
// editor or row the reader was on after Ctrl+K.
|
|
118
|
+
const restoreFocusRef = useRef<HTMLElement | null>(null);
|
|
119
|
+
const panelId = useId();
|
|
120
|
+
|
|
121
|
+
const [catalogState, setCatalogState] = useState<CatalogState>({
|
|
122
|
+
loading: false,
|
|
123
|
+
failed: false,
|
|
124
|
+
catalog: null,
|
|
125
|
+
});
|
|
126
|
+
// Only the newest load may land: a slow answer from an earlier open must
|
|
127
|
+
// not overwrite a fresher one.
|
|
128
|
+
const loadSeq = useRef(0);
|
|
129
|
+
const loadCatalog = useCallback(() => {
|
|
130
|
+
const seq = ++loadSeq.current;
|
|
131
|
+
setCatalogState((s) => ({ ...s, loading: true }));
|
|
132
|
+
void Promise.allSettled([listSkills(), listToolSecrets(), listPlugins()]).then(
|
|
133
|
+
([skills, tools, plugins]) => {
|
|
134
|
+
if (seq !== loadSeq.current) return;
|
|
135
|
+
const value = <T,>(r: PromiseSettledResult<T[]>): T[] => (r.status === 'fulfilled' ? r.value : []);
|
|
136
|
+
const failed = [skills, tools, plugins].every((r) => r.status === 'rejected');
|
|
137
|
+
setCatalogState((s) => ({
|
|
138
|
+
loading: false,
|
|
139
|
+
failed,
|
|
140
|
+
// A failed refresh keeps the catalog it had rather than blanking it.
|
|
141
|
+
catalog: failed ? s.catalog : { skills: value(skills), tools: value(tools), plugins: value(plugins) },
|
|
142
|
+
}));
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
}, []);
|
|
146
|
+
|
|
147
|
+
// Why the last command failed, shown when the palette reopens to say so.
|
|
148
|
+
// Commands run with the palette already shut, and nothing else in core
|
|
149
|
+
// would carry the message (toasts only speak inside the Library).
|
|
150
|
+
const [notice, setNotice] = useState<string | null>(null);
|
|
151
|
+
|
|
152
|
+
// Opening it by any route — the box, the shortcut, the Get set up list's
|
|
153
|
+
// "Try it" — ticks that list's "Find or do anything" step.
|
|
154
|
+
const { markCommandMenuOpened } = useSetupChecklist();
|
|
155
|
+
|
|
156
|
+
const openPalette = useCallback(() => {
|
|
157
|
+
if (open) {
|
|
158
|
+
// Already open: the shortcut is a way back INTO it, not a toggle.
|
|
159
|
+
inputRef.current?.focus();
|
|
160
|
+
inputRef.current?.select();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const active = document.activeElement;
|
|
164
|
+
restoreFocusRef.current = active instanceof HTMLElement && active !== document.body ? active : null;
|
|
165
|
+
setOpen(true);
|
|
166
|
+
markCommandMenuOpened();
|
|
167
|
+
loadCatalog();
|
|
168
|
+
}, [open, loadCatalog, markCommandMenuOpened]);
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Close, optionally handing focus back. `'previous'` is Escape — return to
|
|
172
|
+
* where the reader was. `'trigger'` is a chosen row or a Tab out — the page
|
|
173
|
+
* a row opens is about to replace whatever was focused before, so the box
|
|
174
|
+
* is the stable place to land (or, on a narrow window with no box, the
|
|
175
|
+
* previous element). An outside click passes nothing: it already put focus
|
|
176
|
+
* where the reader wanted it.
|
|
177
|
+
*/
|
|
178
|
+
const close = useCallback((focus?: 'previous' | 'trigger') => {
|
|
179
|
+
setOpen(false);
|
|
180
|
+
setNotice(null);
|
|
181
|
+
if (!focus) return;
|
|
182
|
+
const previous = restoreFocusRef.current?.isConnected ? restoreFocusRef.current : null;
|
|
183
|
+
const target = focus === 'previous' ? (previous ?? triggerRef.current) : (triggerRef.current ?? previous);
|
|
184
|
+
target?.focus();
|
|
185
|
+
}, []);
|
|
186
|
+
|
|
187
|
+
const openRef = useLatestRef(openPalette);
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Run a command once the palette has closed. A failure — thrown or
|
|
191
|
+
* rejected — opens the palette again with the reason under the rows, so a
|
|
192
|
+
* command that could not do its job never fails in silence.
|
|
193
|
+
*/
|
|
194
|
+
const runAction = useCallback(
|
|
195
|
+
(action: CommandAction, ctx: CommandContext) => {
|
|
196
|
+
const fail = (err: unknown) => {
|
|
197
|
+
setNotice(err instanceof Error ? err.message : String(err));
|
|
198
|
+
// A command that throws synchronously fails inside the click that
|
|
199
|
+
// closed the palette, before that close has rendered: opened at once,
|
|
200
|
+
// `openPalette` would see it still open and only refocus an input on
|
|
201
|
+
// its way out. The reopen waits for the close to commit.
|
|
202
|
+
queueMicrotask(() => openRef.current());
|
|
203
|
+
};
|
|
204
|
+
try {
|
|
205
|
+
void Promise.resolve(action.run(ctx)).catch(fail);
|
|
206
|
+
} catch (err) {
|
|
207
|
+
fail(err);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
[openRef],
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
// The commands are read here, not in the panel, because the single-key
|
|
214
|
+
// shortcuts (C, G K, G S) run them while the palette is shut.
|
|
215
|
+
const { actions, ctx } = useCommandActions();
|
|
216
|
+
useCommandShortcuts({ actions, ctx, enabled: !open, run: runAction });
|
|
217
|
+
|
|
218
|
+
// `openCommandMenu()` from outside the toolbar opens it as the shortcut does.
|
|
219
|
+
useEffect(() => onCommandMenuRequest(() => openRef.current()), [openRef]);
|
|
220
|
+
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
function onKey(e: KeyboardEvent) {
|
|
223
|
+
if (!isCommandMenuShortcut(e) || e.defaultPrevented) return;
|
|
224
|
+
// A modal dialog owns the keyboard while it is up; opening a palette
|
|
225
|
+
// underneath its scrim would move focus somewhere nobody can see.
|
|
226
|
+
if (document.querySelector('[aria-modal="true"]')) return;
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
openRef.current();
|
|
229
|
+
}
|
|
230
|
+
document.addEventListener('keydown', onKey);
|
|
231
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
232
|
+
}, [openRef]);
|
|
233
|
+
|
|
234
|
+
const panelRef = useDismissableMenu<HTMLDivElement>({
|
|
235
|
+
open,
|
|
236
|
+
onClose: () => close(),
|
|
237
|
+
returnFocusTo: triggerRef,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
// On a narrow window the box does not fit beside the toolbar essentials,
|
|
242
|
+
// so it is not drawn at all — the shortcut still opens the palette, which
|
|
243
|
+
// then pins itself below the toolbar instead of below the box.
|
|
244
|
+
<div className={cn('relative', !compact && 'ml-1 min-w-0 max-w-[440px] flex-1')}>
|
|
245
|
+
{!compact && (
|
|
246
|
+
<button
|
|
247
|
+
ref={triggerRef}
|
|
248
|
+
type="button"
|
|
249
|
+
onClick={() => (open ? close() : openPalette())}
|
|
250
|
+
className={cn(
|
|
251
|
+
'flex w-full items-center gap-2 rounded-md border border-transparent bg-sunken px-2.5 py-[5px]',
|
|
252
|
+
'text-left text-ui text-ink-faint transition-colors hover:border-line-strong',
|
|
253
|
+
open && 'border-line-strong',
|
|
254
|
+
)}
|
|
255
|
+
aria-haspopup="dialog"
|
|
256
|
+
aria-expanded={open}
|
|
257
|
+
aria-controls={open ? panelId : undefined}
|
|
258
|
+
aria-keyshortcuts={COMMAND_MENU_SHORTCUT_ARIA}
|
|
259
|
+
>
|
|
260
|
+
<Search aria-hidden size={14} className="flex-none" />
|
|
261
|
+
<span className="min-w-0 flex-1 truncate">{TRIGGER_LABEL}</span>
|
|
262
|
+
<kbd
|
|
263
|
+
aria-hidden
|
|
264
|
+
className="flex-none rounded-xs border border-line-strong px-[5px] font-mono text-meta text-ink-faint"
|
|
265
|
+
>
|
|
266
|
+
{COMMAND_MENU_SHORTCUT_LABEL}
|
|
267
|
+
</kbd>
|
|
268
|
+
</button>
|
|
269
|
+
)}
|
|
270
|
+
|
|
271
|
+
{open && (
|
|
272
|
+
<div
|
|
273
|
+
ref={panelRef}
|
|
274
|
+
id={panelId}
|
|
275
|
+
role="dialog"
|
|
276
|
+
aria-label="Command menu"
|
|
277
|
+
// A press anywhere in the panel but the input keeps focus IN the
|
|
278
|
+
// input, as the rows already do for themselves: every key the
|
|
279
|
+
// palette answers — the arrows, Enter, and Escape back to where
|
|
280
|
+
// the reader was — is handled there, and a press on the padding,
|
|
281
|
+
// the status line or the list's scroll area would otherwise blur it
|
|
282
|
+
// and leave the open palette deaf to the keyboard.
|
|
283
|
+
onMouseDown={(e) => {
|
|
284
|
+
if (e.target !== inputRef.current) e.preventDefault();
|
|
285
|
+
}}
|
|
286
|
+
className={cn(
|
|
287
|
+
'z-40',
|
|
288
|
+
compact ? 'fixed inset-x-3 top-[52px]' : 'absolute top-[calc(100%+6px)] left-0 w-full min-w-[320px]',
|
|
289
|
+
)}
|
|
290
|
+
>
|
|
291
|
+
<SearchPanel
|
|
292
|
+
inputRef={inputRef}
|
|
293
|
+
catalogState={catalogState}
|
|
294
|
+
notice={notice}
|
|
295
|
+
actions={actions}
|
|
296
|
+
ctx={ctx}
|
|
297
|
+
onClose={close}
|
|
298
|
+
onRunAction={runAction}
|
|
299
|
+
/>
|
|
300
|
+
</div>
|
|
301
|
+
)}
|
|
302
|
+
</div>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The open palette. A component of its own so that nothing in it — the tree
|
|
308
|
+
* walk, the ranking, the navigation hooks — runs while the palette is shut.
|
|
309
|
+
*/
|
|
310
|
+
function SearchPanel({
|
|
311
|
+
inputRef,
|
|
312
|
+
catalogState,
|
|
313
|
+
notice,
|
|
314
|
+
actions,
|
|
315
|
+
ctx,
|
|
316
|
+
onClose,
|
|
317
|
+
onRunAction,
|
|
318
|
+
}: {
|
|
319
|
+
inputRef: RefObject<HTMLInputElement | null>;
|
|
320
|
+
catalogState: CatalogState;
|
|
321
|
+
notice: string | null;
|
|
322
|
+
/** The commands on offer, and the context they run with (`useCommandActions`). */
|
|
323
|
+
actions: readonly CommandAction[];
|
|
324
|
+
ctx: CommandContext;
|
|
325
|
+
onClose: (focus?: 'previous' | 'trigger') => void;
|
|
326
|
+
onRunAction: (action: CommandAction, ctx: CommandContext) => void;
|
|
327
|
+
}) {
|
|
328
|
+
const navigate = useNavigate();
|
|
329
|
+
const { openWorkspacePath } = useFileNav();
|
|
330
|
+
const { kbDirName } = useWorkspace();
|
|
331
|
+
const { tree, suggestionOnlyPaths } = useMergedWorkspaceTree();
|
|
332
|
+
const [query, setQuery] = useState('');
|
|
333
|
+
/**
|
|
334
|
+
* The highlighted row. An EMPTY query highlights nothing until ↑/↓ or the
|
|
335
|
+
* pointer picks a row: its first row is a suggested command (New page), and
|
|
336
|
+
* Ctrl+K then Enter must never make a page nobody asked for. Once something
|
|
337
|
+
* is typed, the best match is highlighted and Enter takes it.
|
|
338
|
+
*/
|
|
339
|
+
const [activeIndex, setActiveIndex] = useState(NO_ROW);
|
|
340
|
+
const listboxId = useId();
|
|
341
|
+
const optionId = (key: string) => `${listboxId}-${key}`;
|
|
342
|
+
|
|
343
|
+
useEffect(() => {
|
|
344
|
+
inputRef.current?.focus();
|
|
345
|
+
}, [inputRef]);
|
|
346
|
+
|
|
347
|
+
const pages = useMemo(
|
|
348
|
+
() => pageResults(knowledgeFiles(tree, kbDirName), kbDirName, suggestionOnlyPaths),
|
|
349
|
+
[tree, kbDirName, suggestionOnlyPaths],
|
|
350
|
+
);
|
|
351
|
+
const items = useMemo(
|
|
352
|
+
() => (catalogState.catalog ? libraryResults(catalogState.catalog, kbDirName) : []),
|
|
353
|
+
[catalogState.catalog, kbDirName],
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
// Commands first: with nothing typed, a short set of the commonest; with a
|
|
357
|
+
// query, every offered command ranked by its label and keywords.
|
|
358
|
+
const actionHits = useMemo(
|
|
359
|
+
() =>
|
|
360
|
+
(query.trim() ? rankByNames(actions, query, actionNames, ACTION_LIMIT) : suggestedActions(actions, ctx)).map(
|
|
361
|
+
actionRow,
|
|
362
|
+
),
|
|
363
|
+
[actions, ctx, query],
|
|
364
|
+
);
|
|
365
|
+
const pageHits = useMemo(() => rankByName(pages, query, byName, GROUP_LIMIT).map(resultRow), [pages, query]);
|
|
366
|
+
const itemHits = useMemo(() => rankByName(items, query, byName, GROUP_LIMIT).map(resultRow), [items, query]);
|
|
367
|
+
const flat = useMemo(() => [...actionHits, ...pageHits, ...itemHits], [actionHits, pageHits, itemHits]);
|
|
368
|
+
// Clamped rather than reset when the rows change under it: the catalog can
|
|
369
|
+
// land while the reader is already arrowing through the pages.
|
|
370
|
+
const active = flat.length === 0 || activeIndex === NO_ROW ? NO_ROW : Math.min(activeIndex, flat.length - 1);
|
|
371
|
+
const activeKey = active >= 0 ? flat[active].key : null;
|
|
372
|
+
|
|
373
|
+
useEffect(() => {
|
|
374
|
+
if (!activeKey) return;
|
|
375
|
+
document.getElementById(`${listboxId}-${activeKey}`)?.scrollIntoView?.({ block: 'nearest' });
|
|
376
|
+
}, [activeKey, listboxId]);
|
|
377
|
+
|
|
378
|
+
const choose = (row: PaletteRow) => {
|
|
379
|
+
onClose('trigger');
|
|
380
|
+
if (row.action) {
|
|
381
|
+
onRunAction(row.action, ctx);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const { target } = row.result;
|
|
385
|
+
if (target.kind === 'workspace') openWorkspacePath(target.path);
|
|
386
|
+
else navigate(target.url);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const onKeyDown = (e: ReactKeyboardEvent<HTMLInputElement>) => {
|
|
390
|
+
switch (e.key) {
|
|
391
|
+
case 'ArrowDown':
|
|
392
|
+
e.preventDefault();
|
|
393
|
+
if (flat.length > 0) setActiveIndex((active + 1) % flat.length);
|
|
394
|
+
break;
|
|
395
|
+
case 'ArrowUp':
|
|
396
|
+
e.preventDefault();
|
|
397
|
+
// From no row at all, ↑ starts at the bottom, as ↓ starts at the top.
|
|
398
|
+
if (flat.length > 0) {
|
|
399
|
+
setActiveIndex(active === NO_ROW ? flat.length - 1 : (active - 1 + flat.length) % flat.length);
|
|
400
|
+
}
|
|
401
|
+
break;
|
|
402
|
+
case 'Enter':
|
|
403
|
+
e.preventDefault();
|
|
404
|
+
if (active >= 0) choose(flat[active]);
|
|
405
|
+
break;
|
|
406
|
+
case 'Escape':
|
|
407
|
+
// Stopped here so the dismissable-menu listener on `document` does
|
|
408
|
+
// not close the palette a second time and pull focus to the box.
|
|
409
|
+
e.preventDefault();
|
|
410
|
+
e.stopPropagation();
|
|
411
|
+
onClose('previous');
|
|
412
|
+
break;
|
|
413
|
+
case 'Tab':
|
|
414
|
+
// Leaving the input leaves the palette. Focus is put back on the box
|
|
415
|
+
// BEFORE the browser acts on the Tab, so it moves on from there to
|
|
416
|
+
// the next control — not from an input that has just unmounted, which
|
|
417
|
+
// would restart the tab order at the top of the page.
|
|
418
|
+
onClose('trigger');
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const trimmed = query.trim();
|
|
424
|
+
const loadingItems = catalogState.loading && !catalogState.catalog;
|
|
425
|
+
|
|
426
|
+
const renderGroup = (label: string, rows: PaletteRow[], offset: number) => {
|
|
427
|
+
if (rows.length === 0) return null;
|
|
428
|
+
const labelId = `${listboxId}-${label.replace(/\W+/g, '-')}`;
|
|
429
|
+
return (
|
|
430
|
+
<div role="group" aria-labelledby={labelId}>
|
|
431
|
+
<div id={labelId} role="presentation" className="px-2 pt-2 pb-1 text-label uppercase text-ink-faint">
|
|
432
|
+
{label}
|
|
433
|
+
</div>
|
|
434
|
+
{rows.map((r, i) => {
|
|
435
|
+
const index = offset + i;
|
|
436
|
+
const selected = index === active;
|
|
437
|
+
const shortcut = r.action?.shortcut;
|
|
438
|
+
const location = r.action ? r.action.group : r.result.location;
|
|
439
|
+
return (
|
|
440
|
+
<div
|
|
441
|
+
key={r.key}
|
|
442
|
+
id={optionId(r.key)}
|
|
443
|
+
role="option"
|
|
444
|
+
aria-selected={selected}
|
|
445
|
+
// Keep focus in the input: the row is chosen by click, not focused.
|
|
446
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
447
|
+
onMouseMove={() => {
|
|
448
|
+
if (!selected) setActiveIndex(index);
|
|
449
|
+
}}
|
|
450
|
+
onClick={() => choose(r)}
|
|
451
|
+
className={cn(
|
|
452
|
+
'flex cursor-pointer items-center gap-2.5 rounded-sm px-2 py-1.5 text-ui text-ink',
|
|
453
|
+
selected && 'bg-hover',
|
|
454
|
+
)}
|
|
455
|
+
>
|
|
456
|
+
<span aria-hidden className="flex-none text-ink-faint">
|
|
457
|
+
{r.action ? (r.action.icon ?? <ChevronRight size={15} />) : ICONS[r.result.kind]}
|
|
458
|
+
</span>
|
|
459
|
+
<span className="min-w-0 truncate">{r.action ? r.action.label : r.result.name}</span>
|
|
460
|
+
{location && (
|
|
461
|
+
<span className="ml-auto max-w-[45%] flex-none truncate pl-2 text-meta text-ink-faint">
|
|
462
|
+
{location}
|
|
463
|
+
</span>
|
|
464
|
+
)}
|
|
465
|
+
{shortcut && shortcut.length > 0 && (
|
|
466
|
+
<>
|
|
467
|
+
{/* Drawn as keys for the eye, said as words for the ear:
|
|
468
|
+
`aria-keyshortcuts` cannot express a sequence like G K. */}
|
|
469
|
+
<span aria-hidden className={cn('flex flex-none items-center gap-1 pl-2', !location && 'ml-auto')}>
|
|
470
|
+
{shortcut.map((key, k) => (
|
|
471
|
+
<kbd
|
|
472
|
+
key={k}
|
|
473
|
+
className="rounded-xs border border-line-strong px-[5px] font-mono text-meta text-ink-faint"
|
|
474
|
+
>
|
|
475
|
+
{key}
|
|
476
|
+
</kbd>
|
|
477
|
+
))}
|
|
478
|
+
</span>
|
|
479
|
+
<span className="sr-only"> (shortcut {spokenShortcut(shortcut)})</span>
|
|
480
|
+
</>
|
|
481
|
+
)}
|
|
482
|
+
</div>
|
|
483
|
+
);
|
|
484
|
+
})}
|
|
485
|
+
</div>
|
|
486
|
+
);
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
// One line under the rows for whatever they cannot say themselves: the
|
|
490
|
+
// catalog still on its way, the catalog unreachable, or no match at all.
|
|
491
|
+
// Outside the listbox, which holds options and nothing else.
|
|
492
|
+
// A failed catalog is said whether or not there are rows: with nothing
|
|
493
|
+
// typed the suggested commands fill the list, and the person would never
|
|
494
|
+
// learn that skills, tools and plugins could not be found. With a query
|
|
495
|
+
// and no rows, the failure follows the "nothing matches" line, so a reader
|
|
496
|
+
// is not told that the catalog was searched when it was not.
|
|
497
|
+
const emptiness = flat.length === 0 ? (trimmed ? `Nothing matches “${trimmed}”.` : 'Nothing to search yet.') : null;
|
|
498
|
+
const failure = catalogState.failed && !catalogState.catalog ? 'Couldn’t load skills, tools and plugins.' : null;
|
|
499
|
+
const status = loadingItems
|
|
500
|
+
? 'Loading skills, tools and plugins…'
|
|
501
|
+
: [emptiness, failure].filter(Boolean).join(' ') || null;
|
|
502
|
+
|
|
503
|
+
return (
|
|
504
|
+
<MenuPanel className="flex max-h-[min(480px,calc(100dvh-72px))] flex-col">
|
|
505
|
+
<input
|
|
506
|
+
ref={inputRef}
|
|
507
|
+
type="text"
|
|
508
|
+
role="combobox"
|
|
509
|
+
aria-label={TRIGGER_LABEL}
|
|
510
|
+
aria-expanded
|
|
511
|
+
aria-controls={listboxId}
|
|
512
|
+
aria-autocomplete="list"
|
|
513
|
+
aria-activedescendant={activeKey ? optionId(activeKey) : undefined}
|
|
514
|
+
placeholder={PLACEHOLDER}
|
|
515
|
+
value={query}
|
|
516
|
+
onChange={(e) => {
|
|
517
|
+
setQuery(e.target.value);
|
|
518
|
+
setActiveIndex(e.target.value.trim() ? 0 : NO_ROW);
|
|
519
|
+
}}
|
|
520
|
+
onKeyDown={onKeyDown}
|
|
521
|
+
autoComplete="off"
|
|
522
|
+
spellCheck={false}
|
|
523
|
+
className="mb-1 w-full flex-none border-b border-line bg-transparent px-2 pt-1.5 pb-2.5 text-body text-ink placeholder:text-ink-faint focus:outline-none"
|
|
524
|
+
/>
|
|
525
|
+
<div id={listboxId} role="listbox" aria-label="Commands and results" className="min-h-0 overflow-y-auto">
|
|
526
|
+
{renderGroup('Actions', actionHits, 0)}
|
|
527
|
+
{renderGroup('Pages', pageHits, actionHits.length)}
|
|
528
|
+
{renderGroup('Skills, tools & plugins', itemHits, actionHits.length + pageHits.length)}
|
|
529
|
+
</div>
|
|
530
|
+
{notice && (
|
|
531
|
+
<div role="alert" className="flex-none px-2 pt-2 text-ui text-danger">
|
|
532
|
+
{notice}
|
|
533
|
+
</div>
|
|
534
|
+
)}
|
|
535
|
+
<div role="status" className={cn('flex-none px-2 text-ui text-ink-muted', status && 'py-2')}>
|
|
536
|
+
{status}
|
|
537
|
+
</div>
|
|
538
|
+
</MenuPanel>
|
|
539
|
+
);
|
|
540
|
+
}
|
|
@@ -3,6 +3,7 @@ import { useLocation } from 'react-router-dom';
|
|
|
3
3
|
import { PanelRight } from 'lucide-react';
|
|
4
4
|
import { ProfileMenu } from './ProfileMenu';
|
|
5
5
|
import { AppSwitcher } from './AppSwitcher';
|
|
6
|
+
import { SearchPalette } from './SearchPalette';
|
|
6
7
|
import { useLayout } from '../../layout/state/layout.context';
|
|
7
8
|
import { useMediaQuery } from '../../layout/hooks/useMediaQuery';
|
|
8
9
|
import { useActiveAppId, useAppRegistry } from '../../../core/registry';
|
|
@@ -10,6 +11,7 @@ import { SidebarToggle } from '../../layout/components/SidebarToggle';
|
|
|
10
11
|
import { toggleSidebar, useSidebar } from '../../layout/state/sidebar';
|
|
11
12
|
import { TOOLBAR_STACK_QUERY } from '../../layout/breakpoints';
|
|
12
13
|
import { isSettingsNavPath } from '../../settings/settings-nav-items';
|
|
14
|
+
import { InviteButton } from '../../onboarding/components/InviteButton';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* The app's top bar: the nav toggle, the app switcher, and whatever the
|
|
@@ -82,6 +84,10 @@ export function Toolbar() {
|
|
|
82
84
|
<div className="flex items-center gap-2 ml-4">{itemCluster}</div>
|
|
83
85
|
)}
|
|
84
86
|
|
|
87
|
+
{/* Search by name across Knowledge and Skills & Tools. Below `md` the
|
|
88
|
+
box gives way to the essentials and Ctrl/⌘K alone opens it. */}
|
|
89
|
+
<SearchPalette compact={isCompact} />
|
|
90
|
+
|
|
85
91
|
<div className="flex-1" />
|
|
86
92
|
|
|
87
93
|
{canToggleChat && (
|
|
@@ -98,6 +104,10 @@ export function Toolbar() {
|
|
|
98
104
|
</button>
|
|
99
105
|
)}
|
|
100
106
|
|
|
107
|
+
{/* Icon-only below `md`, where its word would crowd the profile menu
|
|
108
|
+
off the row. */}
|
|
109
|
+
<InviteButton compact={isCompact} />
|
|
110
|
+
|
|
101
111
|
{/* One button for who you are and everything that follows you around.
|
|
102
112
|
It used to be three things in a row here — a name that was not a
|
|
103
113
|
control, a gear, and a sign-out arrow — all answering the same
|