Omnisearch
Omnisearch is one search box for records and commands. Configure the categories it searches, the shortcuts it answers to, and how it hands a request to the Command Center.
Omnisearch is the search box at the top of a Sommatic AI app. One field finds records (workflows, projects, agents,
conversations), jumps to a page, or launches a Command Center command. It answers “what exists and where is it?” so
people do not need to know the menu to operate the app. It comes from @link-loom/react-sdk; the records it finds come
from the Sommatic AI services of @sommatic/react-sdk.
How a search runs
- Records. Once the query has two characters or more, Omnisearch waits 300 ms and queries every category in
parallel, or only the category the person filtered by. Each category calls one service with the
searchquery selector and lists what comes back. - Commands. A query that starts with
/switches to command mode: Omnisearch lists the slash commands registered in the app and completes the one being typed.Cmd+/(orCtrl+/) opens Omnisearch with the/already typed. - Static commands. Fixed entries, such as “Overview”, with their own shortcut.
Configure the categories
Render OmniSearch in your navigation bar and give it the categories to search:
import { useState } from 'react';
import { OmniSearch, useGlobalShortcuts } from '@link-loom/react-sdk';
import { ProjectManagementService, CognitiveInfrastructureAgentProfileService } from '@sommatic/react-sdk';
export function NavbarSearch() {
const [open, setOpen] = useState(false);
useGlobalShortcuts([{ keys: ['meta', 'k'], action: () => setOpen((previous) => !previous) }]);
const categories = [
{
id: 'agent',
label: 'Ask Sommatic',
createLabel: 'Ask the agent',
onCreate: (query) => {
setOpen(false);
window.dispatchEvent(new CustomEvent('sommatic:open-command-center', { detail: { initialMessage: query } }));
},
},
{
id: 'projects',
label: 'Projects',
service: ProjectManagementService,
payload: { queryselector: 'search' },
onSelect: (item, navigate) => navigate(`/projects/${item.id}`),
},
{
id: 'agents',
label: 'Agents',
service: CognitiveInfrastructureAgentProfileService,
payload: { queryselector: 'search' },
onSelect: (item, navigate) => navigate(`/agents/${item.id}`),
},
];
return <OmniSearch categories={categories} staticCommands={[]} open={open} onOpenChange={setOpen} />;
}| Field | What it does |
|---|---|
id, label, icon | Identify the category and its group of results. |
service, payload | The service class to query and the parameters it receives. The text typed goes in as the search. |
onSelect(item, navigate) | Runs when a result is picked. |
onCreate(query, navigate) | Optional. Turns the typed text into an action: create a record, or hand the request to the agent. |
createLabel | The label of that action. |
Hand requests to the Command Center
The first category of the example has no service: its onCreate sends whatever the person typed to the Command Center
through the sommatic:open-command-center event. That is how a search box becomes a request in natural language.
To list the Command Center commands in Omnisearch’s command mode, register them with useOmniSearchRegisterCommand.
Commands registered this way are removed when the component that registered them unmounts. A good pattern is to wrap
each command’s action so that picking it opens the Command Center with the typed text as its first message, which is
how the Sommatic AI portal does it.