Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Apps & accounts: one merged "Another app" search, one row per app (#606)

Oleksandr Ivanchenko5f2922456ae5
diff --git a/frontend/src/appSearch.ts b/frontend/src/appSearch.ts
new file mode 100644
index 00000000..43241116
--- /dev/null
+++ b/frontend/src/appSearch.ts
@@ -0,0 +1,348 @@
+// One list for any app (one-app-search/design.md §2, §3): built-in tools, Composio's apps and the public list of
+// tool servers become one row per app. Each row has a lead (the way the button runs) and the other ways to add the
+// same app, folded under it. Pure functions; FindTool renders them.
+//
+// Works without the server's `by_maker` / `sign_in` fields (design §4 "Vega"): the same rules run here on what the
+// directory already sends. When the server sends them, they win.
+
+import type { Connection, DirectoryEntry } from './connections';
+import type { McpPreset } from './mcp';
+import { ToolMatch, matchTool, normalize, rankTools } from './toolSearch';
+
+// ── App key: what "the same app" means ─────────────────────────────────────────────────────────
+
+/** Words that say what kind of thing it is, not which app (dropped unless they are the whole name). */
+const KIND_WORDS = new Set(['mcp', 'server', 'official', 'tools', 'api']);
+
+/** Other spellings of the same app (from the directory's ALIASES, only the ones that name one app for sure). */
+const KEY_ALIASES: Record<string, string> = {
+ '11labs': 'elevenlabs',
+ googlemail: 'gmail',
+ gcal: 'googlecalendar',
+ twitter: 'x',
+ postgres: 'postgresql',
+};
+
+/**
+ * "Stripe MCP by InsightfulPipe" → "stripe"; "ElevenLabs" → "elevenlabs"; "11labs" → "elevenlabs";
+ * "Stripe Billing Reports" → "stripebillingreports" (a different app).
+ */
+export function appKey(name: string): string {
+ let s = (name ?? '').trim();
+ const cut = s.replace(/\s+by\s+.+$/i, '').trim();
+ if (cut) s = cut;
+ const unbracketed = s.replace(/[([{][^)\]}]*[)\]}]/g, ' ').trim();
+ if (unbracketed) s = unbracketed;
+ const words = s.split(/[\s\-_./:]+/).filter(Boolean);
+ const kept = words.filter((w) => !KIND_WORDS.has(w.toLowerCase()));
+ const key = normalize((kept.length ? kept : words).join(' '));
+ return KEY_ALIASES[key] ?? key;
+}
+
+// ── Who makes it ───────────────────────────────────────────────────────────────────────────────
+
+/** "by notion.com" for a remote built-in tool: the last two labels of its address. */
+export function presetPublisher(p: McpPreset): string | null {
+ if (p.form.transport !== 'http') return null;
+ if (p.domain) return p.domain;
+ try {
+ const host = new URL(p.form.url).hostname.split('.');
+ return host.slice(-2).join('.');
+ } catch {
+ return null;
+ }
+}
+
+const hostOf = (url: string | null | undefined): string => {
+ if (!url) return '';
+ try {
+ return new URL(url.trim()).hostname.toLowerCase();
+ } catch {
+ return '';
+ }
+};
+
+/**
+ * Made by the app's maker (design §2): the publisher is a domain (never io.github.*), the server's address is on that
+ * domain, and the title is that domain's name (stripe.com → Stripe). The server's own `by_maker` wins when sent.
+ */
+export function byMaker(entry: DirectoryEntry): boolean {
+ if (typeof entry.by_maker === 'boolean') return entry.by_maker;
+ if ((entry.registry_name ?? '').toLowerCase().startsWith('io.github.')) return false;
+ const kind = entry.publisher?.kind ?? 'domain';
+ const domain = (entry.publisher?.label ?? '').trim().toLowerCase();
+ if (kind !== 'domain' || !domain.includes('.')) return false;
+ const host = hostOf(entry.url);
+ if (!host || !(host === domain || host.endsWith(`.${domain}`))) return false;
+ const namePart = domain.split('.').slice(-2)[0];
+ return appKey(entry.title || '') === namePart;
+}
+
+// ── Sources and rows ───────────────────────────────────────────────────────────────────────────
+
+/** Where a way to add an app comes from, in the words of its chip. */
+export type Origin = 'official' | 'composio' | 'community' | 'builtin';
+
+export interface ComposioSourceApp {
+ slug: string;
+ name: string;
+ description: string;
+ tools: number | null;
+ connected: boolean;
+}
+
+interface SourceBase {
+ /** Unique across the list: b-<preset>, c-<slug>, d-<registry name>. */
+ id: string;
+ name: string;
+ description: string;
+ origin: Origin;
+ /** The domain after "Official ·", or the publisher after "Community ·". */
+ by: string | null;
+ remote: boolean;
+ /** Connected (Composio) or already added (a server). */
+ connected: boolean;
+ match: ToolMatch | null;
+ /** The app a key is for, in "Your own {App} API key". */
+ keyApp: string;
+}
+
+export type Source =
+ | (SourceBase & { kind: 'builtin'; preset: McpPreset; added: Connection | null })
+ | (SourceBase & { kind: 'composio'; app: ComposioSourceApp })
+ | (SourceBase & { kind: 'directory'; entry: DirectoryEntry });
+
+export interface MergedRow {
+ /** `app-<app key>`: stays the same when the public list lands, so the highlight keeps its app. */
+ key: string;
+ appKey: string;
+ name: string;
+ lead: Source;
+ others: Source[];
+ match: ToolMatch | null;
+}
+
+/** Which source leads a row, lower first (design §2 "Which source leads the row"). */
+export function leadTier(s: Source): number {
+ if (s.connected) return 0;
+ if (s.origin === 'official') return s.remote ? 1 : 3;
+ if (s.origin === 'composio') return 2;
+ if (s.origin === 'builtin') return 4;
+ return s.remote ? 5 : 6;
+}
+
+const presetHost = (p: McpPreset): string => (p.form.transport === 'http' ? hostOf(p.form.url) : '');
+const presetUrl = (p: McpPreset) => (p.form.transport === 'http' ? p.form.url.trim().replace(/\/+$/, '').toLowerCase() : '');
+
+/** The added server that is this built-in tool: same name, and for a remote tool the same host. A server a person named
+ * "Stripe" at another address is not the built-in Stripe; only a server with no address falls back to the name alone. */
+export function addedServer(p: McpPreset, connections: Connection[]): Connection | null {
+ const names = [p.form.name.toLowerCase(), p.label.toLowerCase()];
+ const host = presetHost(p);
+ return (
+ connections.find((c) => {
+ if (c.kind !== 'mcp' || !names.includes(c.name.toLowerCase())) return false;
+ const at = (c.detail ?? '').trim().toLowerCase();
+ return !host || !at || at === host;
+ }) ?? null
+ );
+}
+
+/** The longest known app name a title starts with, word by word ("Stripe Billing Reports" → "Stripe"). */
+function knownAppIn(title: string, known: string[]): string | null {
+ const words = title.trim().split(/\s+/);
+ let best: string | null = null;
+ for (const k of known) {
+ const n = k.trim().split(/\s+/).length;
+ if (n > words.length || (best && k.length <= best.length)) continue;
+ if (normalize(words.slice(0, n).join(' ')) === normalize(k)) best = k;
+ }
+ return best;
+}
+
+export interface MergeInput {
+ presets: McpPreset[];
+ composio: ComposioSourceApp[];
+ /** null: the public list isn't there (fewer than 2 letters, or the server has none). */
+ directory: DirectoryEntry[] | null;
+ connections: Connection[];
+ /** Rows whose button was already pressed for this query: app key → the source id that keeps leading. */
+ pinned?: Record<string, string>;
+}
+
+/** One row per app for `query`, best first (design §2). */
+export function mergeRows(query: string, input: MergeInput): MergedRow[] {
+ if (!normalize(query)) return [];
+ const { presets, composio, directory, connections, pinned = {} } = input;
+ const known = [...presets.map((p) => p.label), ...composio.map((a) => a.name)];
+ const sources: Source[] = [];
+
+ rankTools(query, presets.map((p) => ({ name: p.label, slug: p.id, p }))).forEach(({ entry: { p }, match }) => {
+ const added = addedServer(p, connections);
+ const pub = presetPublisher(p);
+ sources.push({
+ kind: 'builtin',
+ id: `b-${p.id}`,
+ name: p.label,
+ description: p.blurb,
+ origin: pub ? 'official' : 'builtin',
+ by: pub,
+ remote: p.form.transport === 'http',
+ connected: !!added,
+ match,
+ keyApp: p.label,
+ preset: p,
+ added,
+ });
+ });
+
+ rankTools(query, composio).forEach(({ entry: app, match }) =>
+ sources.push({
+ kind: 'composio',
+ id: `c-${app.slug}`,
+ name: app.name,
+ description: app.description,
+ origin: 'composio',
+ by: null,
+ remote: true,
+ connected: app.connected,
+ match,
+ keyApp: app.name,
+ app,
+ }),
+ );
+
+ if (directory) {
+ const presetUrls = new Set(presets.map(presetUrl).filter(Boolean));
+ const seen = new Set<string>();
+ for (const entry of directory) {
+ // The same server as a built-in tool is listed once, as built in.
+ if (entry.url && presetUrls.has(entry.url.trim().replace(/\/+$/, '').toLowerCase())) continue;
+ if (seen.has(entry.registry_name)) continue;
+ seen.add(entry.registry_name);
+ const name = entry.title?.trim() || entry.registry_name;
+ const official = byMaker(entry);
+ sources.push({
+ kind: 'directory',
+ id: `d-${entry.registry_name}`,
+ name,
+ description: entry.description ?? '',
+ origin: official ? 'official' : 'community',
+ by: entry.publisher?.label || null,
+ remote: entry.kind === 'remote',
+ connected: !!entry.already_added,
+ match: matchTool(query, { name }),
+ keyApp: knownAppIn(name, known) ?? name,
+ entry,
+ });
+ }
+ }
+
+ // Fold sources with the same app key (a Composio app also by its slug, a built-in tool by its id).
+ const byKey = new Map<string, number>();
+ const groups: Array<{ key: string; sources: Array<{ s: Source; i: number }> }> = [];
+ sources.forEach((s, i) => {
+ const keys = [appKey(s.name)];
+ if (s.kind === 'composio') keys.push(normalize(s.app.slug));
+ if (s.kind === 'builtin') keys.push(normalize(s.preset.id));
+ const at = keys.map((k) => byKey.get(k)).find((g) => g !== undefined);
+ const g = at ?? groups.push({ key: keys[0], sources: [] }) - 1;
+ groups[g].sources.push({ s, i });
+ keys.forEach((k) => k && !byKey.has(k) && byKey.set(k, g));
+ });
+
+ const rows = groups.map((g) => {
+ const sorted = [...g.sources].sort((a, b) => leadTier(a.s) - leadTier(b.s) || a.i - b.i);
+ const pin = pinned[g.key];
+ const leadAt = Math.max(0, pin ? sorted.findIndex((x) => x.s.id === pin) : 0);
+ const lead = sorted[leadAt].s;
+ const others = sorted.filter((_, k) => k !== leadAt).map((x) => x.s);
+ const rank = lead.match?.rank ?? Math.min(9, ...others.map((o) => o.match?.rank ?? 9));
+ const tools = lead.kind === 'composio' ? lead.app.tools ?? 0 : 0;
+ return { row: { key: `app-${g.key}`, appKey: g.key, name: lead.name, lead, others, match: lead.match } as MergedRow, rank, tools, first: g.sources[0].i };
+ });
+ rows.sort((a, b) => a.rank - b.rank || leadTier(a.row.lead) - leadTier(b.row.lead) || b.tools - a.tools || a.first - b.first);
+ return rows.map((r) => r.row);
+}
+
+// ── How you sign in (design §3) ────────────────────────────────────────────────────────────────
+
+export type SignInIcon = 'account' | 'key' | 'local' | 'none';
+export interface SignIn {
+ icon: SignInIcon;
+ text: string;
+ /** How the button reads for this way: "Connect" for a sign-in, else "Add". */
+ button: 'Connect' | 'Add';
+}
+
+const keyCount = (e: DirectoryEntry): number => (e.inputs ?? []).filter((i) => i.secret || /key|token|secret/i.test(i.name)).length;
+
+const localNeeds = (s: Source): string | null => {
+ if (s.kind === 'builtin') return s.preset.needs.find((n) => n === 'Node.js' || n === 'uv') ?? null;
+ if (s.kind === 'directory') {
+ const cmd = (s.entry.command ?? '').trim().toLowerCase();
+ if (/^(npx|node|npm|pnpm|bunx?)\b/.test(cmd)) return 'Node.js';
+ if (/^(uvx|uv|python3?|pipx)\b/.test(cmd)) return 'uv';
+ }
+ return null;
+};
+
+/**
+ * The sentence after the chip. `rowName` is the row's app; `other` is true in the other-ways block, where the app's
+ * name is right above ("your account" instead of "your {App} account").
+ */
+export function signInOf(s: Source, opts: { rowName: string; composioAdded: boolean; other?: boolean }): SignIn {
+ const account: SignIn = { icon: 'account', text: opts.other ? 'Sign in with your account' : `Sign in with your ${opts.rowName} account`, button: 'Connect' };
+ const keys = (n: number): SignIn => ({ icon: 'key', text: n > 1 ? `${n} keys from ${s.keyApp}` : `Your own ${s.keyApp} API key`, button: 'Add' });
+ const local = (): SignIn => {
+ const needs = localNeeds(s);
+ return { icon: 'local', text: needs ? `Runs on this computer · needs ${needs}` : 'Runs on this computer', button: 'Add' };
+ };
+ const none: SignIn = { icon: 'none', text: 'No sign-in needed', button: 'Add' };
+
+ if (s.kind === 'composio') return opts.composioAdded ? account : { ...account, text: `${account.text} · free Composio key first` };
+ if (s.kind === 'builtin') {
+ const n = s.preset.needs;
+ if (n.includes('Sign-in')) return account;
+ if (n.includes('API key') || n.includes('Token')) return keys(1);
+ return s.remote ? none : local();
+ }
+ const e = s.entry;
+ const count = keyCount(e);
+ switch (e.sign_in) {
+ case 'account':
+ return account;
+ case 'key':
+ return keys(Math.max(1, count));
+ case 'none':
+ return s.remote ? none : local();
+ }
+ if (count) return keys(count);
+ if (!s.remote) return local();
+ return s.origin === 'official' ? account : { icon: 'account', text: 'Signs in when you add it, if it asks', button: 'Add' };
+}
+
+// ── Words ──────────────────────────────────────────────────────────────────────────────────────
+
+/** The source in words, for the row's aria-label: "official server by elevenlabs.io". */
+export function sourceWords(s: Source): string {
+ if (s.origin === 'official') return s.by ? `official server by ${s.by}` : 'official server';
+ if (s.origin === 'composio') return 'through Composio';
+ if (s.origin === 'community') return s.by ? `community server by ${s.by}` : 'community server';
+ return 'built in';
+}
+
+/** The link that opens a row's other ways. */
+export function otherWaysLabel(others: Source[]): string {
+ if (others.length > 1) return `${others.length} other ways to add it`;
+ const o = others[0];
+ if (!o) return '';
+ if (o.origin === 'composio') return 'Also through Composio';
+ if (o.origin === 'community') return 'Also as a community server';
+ if (o.origin === 'official') return 'Also as an official server';
+ return 'Also built in';
+}
+
+/** At most 4 other ways show; past that one quiet line. */
+export const OTHER_WAYS_SHOWN = 4;
+export const moreOtherWays = (n: number): string => `and ${n} more community ${n === 1 ? 'server' : 'servers'}`;
diff --git a/frontend/src/components/AppsAccounts.tsx b/frontend/src/components/AppsAccounts.tsx
index ef8a4ace..b8de1ad7 100644
--- a/frontend/src/components/AppsAccounts.tsx
+++ b/frontend/src/components/AppsAccounts.tsx
@@ -1,4 +1,4 @@
-// Settings › This space › Apps & accounts (0.9.5): app tiles first, then Find a tool, the AI
+// Settings › This space › Apps & accounts (0.9.5): app tiles first, then Another app, the AI
// accounts the bots think with, and a closed Advanced (tool servers, Telegram, notes from bots).
// Connecting an app is one sheet with three steps; the bots picked in step 3 get it, turned on.
@@ -705,14 +705,16 @@ export const AppsAccounts: React.FC<AppsAccountsProps> = (p) => {
{data && !composio && <p className="text-[11px] text-zinc-400">This server can’t connect apps yet. Update kwant bots to connect them here.</p>}
</section>
- {/* Find a tool: built in, through Composio, and the public directory */}
+ {/* Another app: built in, through Composio and the public list, one row per app */}
{data && (
<section aria-labelledby="apps-find" className="space-y-2" data-apps-search>
<h3 id="apps-find" className={sectionTitle}>
- Find a tool
+ Another app
</h3>
<FindTool
browseWhenEmpty={false}
+ label="Find any app"
+ placeholder="Search any app, like ElevenLabs, Stripe or Airtable"
data={data}
api={p.findApi}
phone={p.phone}
diff --git a/frontend/src/components/FindTool.tsx b/frontend/src/components/FindTool.tsx
index 13862266..e24342b4 100644
--- a/frontend/src/components/FindTool.tsx
+++ b/frontend/src/components/FindTool.tsx
@@ -1,12 +1,35 @@
-// Find a tool (composio-simple/design.md §1, §2 and "Autocomplete"): one field that finds a tool
-// wherever it comes from (built in, through Composio, the public directory), from the first letter.
-// Used in Add a tool (browseWhenEmpty) and on Apps & accounts. ARIA 1.2 combobox: focus stays in the
-// field, ↑/↓ move a highlight across every group's rows, Enter runs the highlighted row's main button.
+// Find a tool / Another app (composio-simple/design.md §1, §2, "Autocomplete"; one-app-search/design.md): one field
+// that finds an app wherever it comes from, from the first letter. Typed, it shows ONE list with one row per app
+// (appSearch.mergeRows): each row says where it comes from and how you sign in, its button starts the right flow,
+// and the other ways to add the same app open under it. An empty field keeps Connected and Popular.
+// Used in Add a tool (browseWhenEmpty) and on Apps & accounts. ARIA 1.2 combobox: focus stays in the field, ↑/↓ move
+// one highlight across every option (other ways included when open), Enter runs the highlighted option's button.
//
// Text from Composio and the directory is shown as plain text, never as HTML.
import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
-import { AlertTriangle, Check, ExternalLink, Eye, EyeOff, KeyRound, Loader2, Lock, Plus, RefreshCw, Search, X } from 'lucide-react';
+import {
+ AlertTriangle,
+ Check,
+ ChevronDown,
+ ChevronRight,
+ ExternalLink,
+ Eye,
+ EyeOff,
+ KeyRound,
+ Loader2,
+ Lock,
+ LogIn,
+ type LucideIcon,
+ Minus,
+ Monitor,
+ Plus,
+ RefreshCw,
+ Search,
+ ShieldCheck,
+ Users,
+ X,
+} from 'lucide-react';
import {
CatalogEntry,
ComposioAppList,
@@ -19,9 +42,25 @@ import {
} from '../connections';
import { APP_TILES, appInitials, listNames } from '../appsAccounts';
import { COMPOSIO_ONLY_APPS, MCP_PRESETS, McpPreset } from '../mcp';
-import { ToolMatch, ghostRest, normalize, rankTools, suggestionsLine } from '../toolSearch';
+import { ToolMatch, ghostRest, matchTool, normalize, suggestionsLine } from '../toolSearch';
+import {
+ MergedRow,
+ OTHER_WAYS_SHOWN,
+ SignInIcon,
+ Source,
+ addedServer,
+ appKey,
+ mergeRows,
+ moreOtherWays,
+ otherWaysLabel,
+ presetPublisher,
+ signInOf,
+ sourceWords,
+} from '../appSearch';
import { usePhoneLayout } from '../usePhoneLayout';
+export { presetPublisher };
+
// ── Data ─────────────────────────────────────────────────────────────────────────────────────
export interface FindToolApi {
@@ -30,7 +69,7 @@ export interface FindToolApi {
addKey: (key: string) => Promise<unknown>;
replaceKey: (key: string) => Promise<unknown>;
connect: (slug: string) => Promise<{ redirect_url: string }>;
- /** null: this server has no public directory yet, so the group hides. */
+ /** null: this server has no public directory yet, so its rows never show. */
directory: (q: string, signal?: AbortSignal) => Promise<{ entries: DirectoryEntry[]; unavailable: boolean } | null>;
}
@@ -66,23 +105,18 @@ export interface FindToolProps {
api?: FindToolApi;
/** Tests and shots: start with this text. */
initialQuery?: string;
+ /** The field's name for screen readers (Apps & accounts: "Find any app"). */
+ label?: string;
+ placeholder?: string;
/** The browse grid. */
children?: React.ReactNode;
}
-type GroupKey = 'connected' | 'popular' | 'builtin' | 'composio' | 'directory';
+type GroupKey = 'connected' | 'popular';
const GROUP_LABEL: Record<GroupKey, string> = {
connected: 'Connected',
popular: 'Popular',
- builtin: 'Built in',
- composio: 'Through Composio',
- directory: 'From the public directory',
-};
-const MORE_LABEL: Partial<Record<GroupKey, string>> = {
- builtin: 'built in',
- composio: 'through Composio',
- directory: 'in the public directory',
};
interface ComposioRowApp {
@@ -93,11 +127,10 @@ interface ComposioRowApp {
connected: boolean;
}
+/** A row of the empty field (Connected, Popular). */
type Row =
| { key: string; group: GroupKey; kind: 'builtin'; name: string; match: ToolMatch | null; preset: McpPreset; added: Connection | null }
- | { key: string; group: GroupKey; kind: 'composio'; name: string; match: ToolMatch | null; app: ComposioRowApp }
- | { key: string; group: GroupKey; kind: 'directory'; name: string; match: ToolMatch | null; entry: DirectoryEntry }
- | { key: string; group: GroupKey; kind: 'more'; name: string; match: null; count: number; of: GroupKey };
+ | { key: string; group: GroupKey; kind: 'composio'; name: string; match: ToolMatch | null; app: ComposioRowApp };
interface Group {
key: GroupKey;
@@ -107,7 +140,8 @@ interface Group {
}
const POPULAR = ['gmail', 'googlecalendar', 'slack', 'notion', 'github', 'googledrive'];
-const PER_GROUP = 5;
+/** Typed: 8 rows, then "Show {n} more apps" (design §2). */
+const ROWS_SHOWN = 8;
/** What an app does, for the Composio rows we know; Composio's lists carry no description. */
const KNOWN_BLURBS: Record<string, string> = {};
@@ -118,24 +152,10 @@ for (const t of APP_TILES) if (t.tint) TINT[t.slug] = t.tint;
const FALLBACK_APPS: ComposioListedApp[] = COMPOSIO_ONLY_APPS.map((a) => ({ slug: a.toolkit, name: a.label }));
-const presetUrl = (p: McpPreset) => (p.form.transport === 'http' ? p.form.url.trim().replace(/\/+$/, '').toLowerCase() : '');
-const PRESET_URLS = new Set(MCP_PRESETS.map(presetUrl).filter(Boolean));
-
-/** "by notion.com" for a remote built-in tool: the last two labels of its address. */
-export function presetPublisher(p: McpPreset): string | null {
- if (p.form.transport !== 'http') return null;
- try {
- const host = new URL(p.form.url).hostname.split('.');
- return host.slice(-2).join('.');
- } catch {
- return null;
- }
-}
-
/** The directory clips a maker's description at 100 characters; when it stops mid-sentence, show that it was cut. */
export function markCutDescription(description: string): string {
const t = description.trimEnd();
- return description.length >= 100 && !/[.!?)\u2026]$/.test(t) ? `${t}\u2026` : description;
+ return description.length >= 100 && !/[.!?)…]$/.test(t) ? `${t}…` : description;
}
/** The directory's key chips: "API key", "2 keys" or "Sign-in". */
@@ -146,94 +166,34 @@ export function directoryNeeds(e: DirectoryEntry): string | null {
return null;
}
-/** A remote built-in tool's host, as the server shows an added tool's address (connections.rs: the host, or a local tool's command). */
-const presetHost = (p: McpPreset): string => {
- if (p.form.transport !== 'http') return '';
- try {
- return new URL(p.form.url.trim()).hostname.toLowerCase();
- } catch {
- return '';
- }
-};
-
-/** The added server that is this built-in tool: same name, and for a remote tool the same host. A server a person named
- * "Stripe" at another address is not the built-in Stripe; only a server with no address falls back to the name alone. */
-const addedServer = (p: McpPreset, connections: Connection[]): Connection | null => {
- const names = [p.form.name.toLowerCase(), p.label.toLowerCase()];
- const host = presetHost(p);
- return (
- connections.find((c) => {
- if (c.kind !== 'mcp' || !names.includes(c.name.toLowerCase())) return false;
- const at = (c.detail ?? '').trim().toLowerCase();
- return !host || !at || at === host;
- }) ?? null
- );
-};
-
-/** Every group for `query`, in order, before the Show more rows are cut. */
-export function buildGroups(opts: {
- query: string;
- composioApps: ComposioRowApp[];
- composioAdded: boolean;
- directory: DirectoryEntry[] | null;
- connections: Connection[];
- expanded: Set<GroupKey>;
-}): Group[] {
- const { query, composioApps, directory, connections, expanded } = opts;
- const q = normalize(query);
- const cut = (key: GroupKey, rows: Row[]): Group => {
- if (rows.length <= PER_GROUP || expanded.has(key)) return { key, rows };
- const more: Row = { key: `more-${key}`, group: key, kind: 'more', name: `Show ${rows.length - PER_GROUP} more ${MORE_LABEL[key]}`, match: null, count: rows.length - PER_GROUP, of: key };
- return { key, rows: [...rows.slice(0, PER_GROUP), more] };
- };
- const builtinRow = (group: GroupKey, preset: McpPreset, match: ToolMatch | null): Row => ({
+/** The empty field's groups: Connected (up to 4) and Popular. A typed field uses `mergeRows` instead. */
+export function buildGroups(opts: { composioApps: ComposioRowApp[]; connections: Connection[] }): Group[] {
+ const { composioApps, connections } = opts;
+ const builtinRow = (group: GroupKey, preset: McpPreset): Row => ({
key: `${group}-b-${preset.id}`,
group,
kind: 'builtin',
name: preset.label,
- match,
+ match: null,
preset,
added: addedServer(preset, connections),
});
- const composioRow = (group: GroupKey, app: ComposioRowApp, match: ToolMatch | null): Row => ({ key: `${group}-c-${app.slug}`, group, kind: 'composio', name: app.name, match, app });
-
- if (!q) {
- const connected: Row[] = [];
- MCP_PRESETS.forEach((p) => addedServer(p, connections) && connected.push(builtinRow('connected', p, null)));
- composioApps.filter((a) => a.connected).forEach((a) => connected.push(composioRow('connected', a, null)));
- const taken = new Set(connected.map((r) => (r.kind === 'builtin' ? r.preset.id : r.kind === 'composio' ? r.app.slug : '')));
- const popular: Row[] = [];
- POPULAR.forEach((slug) => {
- if (taken.has(slug)) return;
- const preset = MCP_PRESETS.find((p) => p.id === slug);
- if (preset) return void popular.push(builtinRow('popular', preset, null));
- const app = composioApps.find((a) => a.slug === slug);
- if (app) popular.push(composioRow('popular', app, null));
- });
- const groups: Group[] = [];
- if (connected.length) groups.push({ key: 'connected', rows: connected.slice(0, 4), rest: Math.max(0, connected.length - 4) || undefined });
- if (popular.length) groups.push({ key: 'popular', rows: popular });
- return groups;
- }
-
- const builtin = rankTools(query, MCP_PRESETS.map((p) => ({ name: p.label, slug: p.id, p })), (e) => (addedServer(e.p, connections) ? 1 : 0)).map((r) =>
- builtinRow('builtin', r.entry.p, r.match),
- );
- const composio = rankTools(query, composioApps, (a) => (a.connected ? 1e6 : 0) + (a.tools ?? 0)).map((r) => composioRow('composio', r.entry, r.match));
+ const composioRow = (group: GroupKey, app: ComposioRowApp): Row => ({ key: `${group}-c-${app.slug}`, group, kind: 'composio', name: app.name, match: null, app });
+ const connected: Row[] = [];
+ MCP_PRESETS.forEach((p) => addedServer(p, connections) && connected.push(builtinRow('connected', p)));
+ composioApps.filter((a) => a.connected).forEach((a) => connected.push(composioRow('connected', a)));
+ const taken = new Set(connected.map((r) => (r.kind === 'builtin' ? r.preset.id : r.app.slug)));
+ const popular: Row[] = [];
+ POPULAR.forEach((slug) => {
+ if (taken.has(slug)) return;
+ const preset = MCP_PRESETS.find((p) => p.id === slug);
+ if (preset) return void popular.push(builtinRow('popular', preset));
+ const app = composioApps.find((a) => a.slug === slug);
+ if (app) popular.push(composioRow('popular', app));
+ });
const groups: Group[] = [];
- if (builtin.length) groups.push(cut('builtin', builtin));
- groups.push(cut('composio', composio));
- if (directory) {
- const seen = new Set<string>();
- const rows: Row[] = directory
- .filter((e) => !(e.url && PRESET_URLS.has(e.url.trim().replace(/\/+$/, '').toLowerCase())))
- .filter((e) => (seen.has(e.registry_name) ? false : (seen.add(e.registry_name), true)))
- .map((entry) => {
- const name = entry.title?.trim() || entry.registry_name;
- return { key: `directory-${entry.registry_name}`, group: 'directory' as GroupKey, kind: 'directory' as const, name, match: rankTools(query, [{ name }])[0]?.match ?? null, entry };
- });
- groups.push(cut('directory', rows));
- }
+ if (connected.length) groups.push({ key: 'connected', rows: connected.slice(0, 4), rest: Math.max(0, connected.length - 4) || undefined });
+ if (popular.length) groups.push({ key: 'popular', rows: popular });
return groups;
}
@@ -249,6 +209,8 @@ const chip = 'inline-flex items-center px-1.5 py-px rounded-md border border-zin
const amberChip = 'inline-flex items-center px-1.5 py-px rounded-md border border-amber-500/40 text-[11px] text-amber-300';
const keycap = 'inline-flex items-center justify-center h-[18px] min-w-[18px] px-1 rounded border border-zinc-700 border-b-2 bg-zinc-900 text-[10.5px] font-medium text-zinc-400';
const fade = 'motion-safe:animate-[findtool-in_160ms_ease-out]';
+const activeBg = 'bg-[#272050]';
+const activeBar = 'shadow-[inset_2px_0_0_#9d8fff]';
const Mark: React.FC<{ name: string; slug?: string }> = ({ name, slug }) => (
<span
@@ -282,10 +244,45 @@ const Spinner: React.FC = () => (
</>
);
+/** Where a way to add an app comes from (design §1): plain chips, never holographic. */
+const SourceChip: React.FC<{ s: Source }> = ({ s }) => {
+ const base = 'shrink-0 inline-flex items-center gap-1 h-5 px-1.5 rounded-md border text-[11px] font-medium whitespace-nowrap';
+ if (s.origin === 'official')
+ return (
+ <span className={`${base} border-sky-400/45 bg-sky-400/10 text-sky-200`} data-source-chip="official">
+ <ShieldCheck size={12} aria-hidden="true" /> Official
+ {s.by && <span className="font-normal text-sky-300">· {s.by}</span>}
+ </span>
+ );
+ if (s.origin === 'community')
+ return (
+ <span className={`${base} border-zinc-700 text-zinc-300 max-w-full`} data-source-chip="community">
+ <Users size={12} aria-hidden="true" className="shrink-0" /> Community
+ {s.by && <span className="font-normal text-zinc-400 truncate">· {s.by}</span>}
+ </span>
+ );
+ return (
+ <span className={`${base} border-zinc-700 text-zinc-200`} data-source-chip={s.origin}>
+ {s.origin === 'composio' ? 'Through Composio' : 'Built in'}
+ </span>
+ );
+};
+
+const SIGN_IN_ICON: Record<SignInIcon, LucideIcon> = {
+ account: LogIn,
+ key: KeyRound,
+ local: Monitor,
+ none: Minus,
+};
+
+const lowerFirst = (s: string) => s.charAt(0).toLowerCase() + s.slice(1);
+
const openKeyPage = (url: string) => window.open(url, '_blank', 'noopener,noreferrer');
// ── The key field (§2, and Replace key for a refused saved key) ──────────────────────────────
+// ── The key field (§2, and Replace key for a refused saved key) ──────────────────────────────
+
export type KeyPhase = { s: 'idle' } | { s: 'checking' } | { s: 'refused'; text: string } | { s: 'down'; text: string };
export interface KeyFieldProps {
@@ -415,6 +412,13 @@ type AppState = { s: 'waiting'; url: string | null; since: number } | { s: 'conn
/** Where the key field is open: under a Composio row (setup before Composio is added) or Replace key. */
type KeyOpen = { slug: string | null; name: string | null; replace: boolean } | null;
+/** One option of the listbox: an empty-field row, a typed app row, one of its other ways, or "Show n more apps". */
+type Opt =
+ | { t: 'row'; key: string; name: string; match: ToolMatch | null; row: Row }
+ | { t: 'app'; key: string; name: string; match: ToolMatch | null; row: MergedRow }
+ | { t: 'other'; key: string; name: string; match: null; row: MergedRow; src: Source }
+ | { t: 'more'; key: string; name: string; match: null; n: number };
+
const KEY_DEFAULT = 'https://dashboard.composio.dev';
const POLL_MS = 3000;
const POLL_FOR_MS = 5 * 60 * 1000;
@@ -435,7 +439,9 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
const [ghostOff, setGhostOff] = useState(false);
const [caretAtEnd, setCaretAtEnd] = useState(true);
const [focusIn, setFocusIn] = useState(false);
- const [expanded, setExpanded] = useState<Set<GroupKey>>(new Set());
+ const [showAll, setShowAll] = useState(false);
+ const [open, setOpen] = useState<Set<string>>(new Set());
+ const [pins, setPins] = useState<Record<string, string>>({});
const [own, setOwn] = useState<ConnectionsList | null>(null);
const [apps, setApps] = useState<AppsLoad>({ s: 'loading' });
const [dir, setDir] = useState<DirLoad | null>(null);
@@ -494,7 +500,7 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
void loadApps();
}, [loadApps, composio?.added, composio?.mode]);
- // ── Composio's apps as rows ──
+ // ── Composio's apps (a refused key hides them; the others still show) ──
const composioApps: ComposioRowApp[] = useMemo(() => {
const listed = apps.s === 'ok' ? apps.list.apps : apps.s === 'loading' || apps.s === 'down' || apps.s === 'none' ? FALLBACK_APPS : [];
const fromCatalog = new Set((composio?.apps_connected ?? []).map((a) => a.slug));
@@ -507,7 +513,7 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
}));
}, [apps, composio?.apps_connected, appState]);
- // ── The public directory: from 2 letters, 120 ms after the last key, newer cancels older ──
+ // ── The public list: from 2 letters, 120 ms after the last key, newer cancels older ──
const q2 = normalize(query).length >= 2;
useEffect(() => {
if (dirMissing || !q2) return;
@@ -530,26 +536,47 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
};
}, [query, q2, dirMissing, dirTry]); // eslint-disable-line react-hooks/exhaustive-deps
- const groups = useMemo(
- () =>
- buildGroups({
- query,
- composioApps,
- composioAdded,
- directory: dirMissing || !q2 ? null : dir?.entries ?? [],
- connections,
- expanded,
- }),
- [query, composioApps, composioAdded, dirMissing, q2, dir, connections, expanded],
- );
- const rows = useMemo(() => groups.flatMap((g) => g.rows), [groups]);
const typed = query.trim().length > 0;
+ const dirFresh = !!dir && normalize(dir.q) === normalize(query);
+ const dirLoading = typed && q2 && !dirMissing && (!dir || dir.loading || !dirFresh);
+ const dirDown = typed && q2 && !dirMissing && !dirLoading && !!dir?.unavailable;
+ const composioLoading = typed && apps.s === 'loading';
+ const composioDown = typed && apps.s === 'down' && composioAdded;
+
+ // The empty field: Connected and Popular, as before.
+ const groups = useMemo(() => buildGroups({ composioApps, connections }), [composioApps, connections]);
+ // Typed: one row per app. Entries from an older query stay only while they still match (no flash on each key).
+ const merged = useMemo(() => {
+ if (!typed) return [];
+ let entries: DirectoryEntry[] | null = null;
+ if (q2 && !dirMissing && dir) entries = dirFresh ? dir.entries : dir.entries.filter((e) => matchTool(query, { name: e.title?.trim() || e.registry_name }));
+ return mergeRows(query, { presets: MCP_PRESETS, composio: composioApps, directory: entries, connections, pinned: pins });
+ }, [typed, query, q2, dirMissing, dir, dirFresh, composioApps, connections, pins]);
+ const rowsShown = showAll ? merged : merged.slice(0, ROWS_SHOWN);
+
const showEmptyGroups = !typed && (p.browseWhenEmpty || focusIn);
- const visibleRows = typed || showEmptyGroups ? rows : [];
- const active = visibleRows.find((r) => r.key === hl) ?? (typed && hlAuto ? visibleRows[0] : undefined) ?? null;
- const ghost = active && typed && !ghostOff && caretAtEnd && active.kind !== 'more' && active.match?.kind === 'start' ? ghostRest(query, active.name) : '';
- const optionId = (r: Row) => `${uid}-opt-${r.key}`;
- const optionCount = visibleRows.filter((r) => r.kind !== 'more').length;
+ const opts: Opt[] = useMemo(() => {
+ if (!typed) return showEmptyGroups ? groups.flatMap((g) => g.rows.map((row): Opt => ({ t: 'row', key: row.key, name: row.name, match: null, row }))) : [];
+ const out: Opt[] = [];
+ for (const row of rowsShown) {
+ out.push({ t: 'app', key: row.key, name: row.name, match: row.match, row });
+ if (open.has(row.key)) row.others.slice(0, OTHER_WAYS_SHOWN).forEach((src) => out.push({ t: 'other', key: `${row.key}~${src.id}`, name: row.name, match: null, row, src }));
+ }
+ const rest = merged.length - rowsShown.length;
+ if (rest > 0) out.push({ t: 'more', key: 'more', name: `Show ${rest} more apps`, match: null, n: rest });
+ return out;
+ }, [typed, showEmptyGroups, groups, rowsShown, merged.length, open]);
+
+ const active = opts.find((o) => o.key === hl) ?? (typed && hlAuto ? opts[0] : undefined) ?? null;
+ const ghost = active && typed && !ghostOff && caretAtEnd && (active.t === 'app' || active.t === 'row') && active.match?.kind === 'start' ? ghostRest(query, active.name) : '';
+ const optionId = (o: { key: string }) => `${uid}-opt-${o.key.replace(/[^A-Za-z0-9_-]/g, '_')}`;
+ const optionCount = typed ? rowsShown.length : opts.length;
+
+ // The highlight belongs to an app, not a position: once the first row is highlighted, it stays on that app when the
+ // public list lands and other rows move in above it, so Enter never runs a different app.
+ useEffect(() => {
+ if (typed && hlAuto && hl === null && active) setHl(active.key);
+ }, [typed, hlAuto, hl, active?.key]); // eslint-disable-line react-hooks/exhaustive-deps
// The polite live line, 400 ms after typing stops.
useEffect(() => {
@@ -557,7 +584,7 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
return () => window.clearTimeout(t);
}, [optionCount, typed, showEmptyGroups]);
- // The highlighted row scrolls into view.
+ // The highlighted option scrolls into view.
useEffect(() => {
if (!active) return;
document.getElementById(optionId(active))?.scrollIntoView?.({ block: 'nearest' });
@@ -662,50 +689,78 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
inputRef.current?.focus();
};
- /** What Enter (and the row's main button) does. */
- const run = (r: Row) => {
- if (r.kind === 'more') {
- setExpanded((s) => new Set(s).add(r.of));
- setHl(null);
- setHlAuto(true);
+ const runComposio = (app: ComposioRowApp) => {
+ const st = appState[app.slug];
+ if (keyOpen && keyOpen.slug === app.slug) return keyRef.current?.focus();
+ if (app.connected) return p.onChooseBots({ kind: 'composio', slug: app.slug, name: app.name });
+ if (st?.s === 'waiting') {
+ if (st.url) window.open(st.url, '_blank', 'noopener,noreferrer');
return;
}
- if (r.kind === 'builtin') {
- if (r.added) return p.onChooseBots({ kind: 'server', connectionId: r.added.id, name: r.preset.label });
- return p.onAddPreset(r.preset);
+ connectApp(app);
+ };
+
+ /** One way to add an app: the flow its button starts (design §3 "Buttons"). */
+ const runSource = (s: Source) => {
+ if (s.kind === 'builtin') {
+ if (s.added) return p.onChooseBots({ kind: 'server', connectionId: s.added.id, name: s.preset.label });
+ return p.onAddPreset(s.preset);
}
- if (r.kind === 'directory') {
- if (!r.entry.already_added) p.onAddDirectory?.(r.entry);
+ if (s.kind === 'directory') {
+ if (!s.entry.already_added) p.onAddDirectory?.(s.entry);
return;
}
- const st = appState[r.app.slug];
- if (keyOpen && keyOpen.slug === r.app.slug) return keyRef.current?.focus();
- if (r.app.connected) return p.onChooseBots({ kind: 'composio', slug: r.app.slug, name: r.app.name });
- if (st?.s === 'waiting') {
- if (st.url) window.open(st.url, '_blank', 'noopener,noreferrer');
- return;
+ runComposio(s.app);
+ };
+
+ /** What Enter (and the option's button) does. A pressed row keeps its lead for this query. */
+ const run = (o: Opt) => {
+ if (o.t === 'more') return setShowAll(true);
+ if (o.t === 'row') {
+ const r = o.row;
+ if (r.kind === 'builtin') {
+ if (r.added) return p.onChooseBots({ kind: 'server', connectionId: r.added.id, name: r.preset.label });
+ return p.onAddPreset(r.preset);
+ }
+ return runComposio(r.app);
}
- connectApp(r.app);
+ setPins((m) => (m[o.row.appKey] === o.row.lead.id ? m : { ...m, [o.row.appKey]: o.row.lead.id }));
+ runSource(o.t === 'app' ? o.row.lead : o.src);
+ };
+
+ const toggleOthers = (row: MergedRow, to?: boolean) => {
+ const now = open.has(row.key);
+ const next = to ?? !now;
+ if (next === now) return false;
+ setOpen((s) => {
+ const n = new Set(s);
+ if (next) n.add(row.key);
+ else n.delete(row.key);
+ return n;
+ });
+ // Closing while one of its other ways is highlighted: the highlight goes back to the row.
+ if (!next && active?.t === 'other' && active.row.key === row.key) setHl(row.key);
+ return true;
};
- const move = (dir: 1 | -1) => {
- if (!visibleRows.length) return;
- const i = active ? visibleRows.indexOf(active) : -1;
- const next = i + dir;
+ const move = (d: 1 | -1) => {
+ if (!opts.length) return;
+ const i = active ? opts.indexOf(active) : -1;
+ const next = i + d;
setGhostOff(false);
if (next < 0) {
setHl(null);
setHlAuto(false);
return;
}
- if (next >= visibleRows.length) return;
- setHl(visibleRows[next].key);
+ if (next >= opts.length) return;
+ setHl(opts[next].key);
};
const accept = () => {
if (!ghost || !active) return false;
setQuery(active.name);
- setHl(active.key.replace(/^(connected|popular)-/, active.kind === 'builtin' ? 'builtin-' : 'composio-'));
+ setHl(active.t === 'row' ? `app-${appKey(active.name)}` : active.key);
setHlAuto(true);
return true;
};
@@ -713,6 +768,7 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.nativeEvent.isComposing) return;
const atEnd = e.currentTarget.selectionStart === e.currentTarget.value.length && e.currentTarget.selectionEnd === e.currentTarget.value.length;
+ const owner = active && (active.t === 'app' || active.t === 'other') ? active.row : null;
switch (e.key) {
case 'ArrowDown':
e.preventDefault();
@@ -731,6 +787,10 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
break;
case 'ArrowRight':
if (ghost && atEnd && accept()) e.preventDefault();
+ else if (!ghost && atEnd && owner?.others.length && toggleOthers(owner, true)) e.preventDefault();
+ break;
+ case 'ArrowLeft':
+ if (!ghost && atEnd && owner && toggleOthers(owner, false)) e.preventDefault();
break;
case 'Enter':
if (active) {
@@ -762,32 +822,247 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
setHlAuto(true);
setGhostOff(false);
setCaretAtEnd(true);
- if (!v.trim()) setExpanded(new Set());
+ setShowAll(false);
+ setPins({});
+ setOpen(new Set());
};
- // ── Rows ──
- const rowAction = (r: Row, isActive: boolean) => {
- const enterCap = isActive && !phone && (
+ // ── Pieces ──
+ const enterCap = (isActive: boolean) =>
+ isActive &&
+ !phone && (
<span className={keycap} aria-hidden="true" data-enter-keycap>
↵
</span>
);
- const main = (label: React.ReactNode, onClick: () => void, extra?: { primary?: boolean; attr?: string }) => (
- <span className={`flex items-center gap-2 ${phone ? 'w-full' : ''}`}>
- {enterCap}
- <button
- type="button"
- tabIndex={-1}
- className={`${isActive || extra?.primary ? primaryBtn : quietBtn} ${phone ? 'w-full' : ''}`}
- onMouseDown={(e) => e.preventDefault()}
- onClick={onClick}
- data-row-action={extra?.attr ?? 'main'}
- >
- {label}
- <span className="sr-only"> {r.name}</span>
- </button>
+
+ const mainButton = (name: string, label: React.ReactNode, onClick: () => void, o: { active: boolean; primary?: boolean; small?: boolean; attr?: string }) => (
+ <span className={`flex items-center gap-2 ${phone ? 'w-full' : ''}`}>
+ {!o.small && enterCap(o.active)}
+ <button
+ type="button"
+ tabIndex={-1}
+ className={`${o.active || o.primary ? primaryBtn : quietBtn} ${o.small ? 'sm:min-h-[28px] sm:h-7 sm:px-2.5' : ''} ${phone ? 'w-full' : ''}`}
+ onMouseDown={(e) => e.preventDefault()}
+ onClick={onClick}
+ data-row-action={o.attr ?? 'main'}
+ >
+ {label}
+ <span className="sr-only"> {name}</span>
+ </button>
+ </span>
+ );
+
+ /** The status of a way that is already in use, or null. */
+ const inUse = (s: Source): { text: string; ok: boolean } | { waiting: true } | null => {
+ if (s.kind === 'composio') {
+ if (s.app.connected) {
+ const who = composioUsers();
+ return { text: who.length ? `Connected · ${listNames(who)} can use it` : 'Connected · No bot can use it yet.', ok: who.length > 0 };
+ }
+ if (appState[s.app.slug]?.s === 'waiting') return { waiting: true };
+ return null;
+ }
+ if (s.kind === 'builtin' && s.added) {
+ const who = s.added.used_by.map((u) => u.name);
+ return { text: who.length ? `Connected · ${listNames(who)} can use it` : 'Connected · No bot can use it yet.', ok: who.length > 0 };
+ }
+ if (s.kind === 'directory' && s.connected) return { text: 'Added', ok: true };
+ return null;
+ };
+
+ const howOf = (s: Source, row: MergedRow, other: boolean) => signInOf(s, { rowName: row.name, composioAdded, other });
+
+ /** The How line: chip, then how you sign in (or the connected / waiting status). */
+ const howLine = (s: Source, row: MergedRow, other: boolean) => {
+ const status = inUse(s);
+ const how = howOf(s, row, other);
+ const Icon = SIGN_IN_ICON[how.icon];
+ return (
+ <span className="flex flex-wrap items-center gap-x-2 gap-y-1.5 text-xs text-zinc-300 min-w-0" data-how>
+ <SourceChip s={s} />
+ {status && 'waiting' in status ? (
+ <span className="text-zinc-300">Waiting for you to finish signing in, in the new tab.</span>
+ ) : status ? (
+ <span className={status.ok ? 'text-zinc-300' : 'text-amber-300'} data-in-use>
+ {status.ok && <Check size={13} className="inline-block align-[-2px] mr-1 text-emerald-300" aria-hidden="true" />}
+ {status.text}
+ </span>
+ ) : (
+ <span data-sign-in={how.icon}>
+ <Icon size={13} className="inline-block align-[-2px] mr-1" aria-hidden="true" />
+ {how.text}
+ </span>
+ )}
</span>
);
+ };
+
+ const sourceAction = (s: Source, row: MergedRow, o: { active: boolean; small?: boolean; onClick: () => void }) => {
+ const status = inUse(s);
+ if (s.kind === 'directory' && s.connected)
+ return (
+ <span className="inline-flex items-center gap-1 text-xs text-zinc-400 whitespace-nowrap">
+ <Check size={12} aria-hidden="true" /> Added
+ </span>
+ );
+ if (status && 'waiting' in status)
+ return mainButton(
+ row.name,
+ <>
+ Open sign-in again <ExternalLink size={12} aria-hidden="true" />
+ </>,
+ o.onClick,
+ o,
+ );
+ if (status) return mainButton(row.name, 'Choose bots', o.onClick, { ...o, primary: !status.ok });
+ return mainButton(row.name, howOf(s, row, !!o.small).button, o.onClick, o);
+ };
+
+ const statusLabel = (s: Source, row: MergedRow, other: boolean): string => {
+ const status = inUse(s);
+ if (status && 'waiting' in status) return 'waiting for you to finish signing in';
+ if (status) return lowerFirst(status.text.replace(/\.$/, ''));
+ return lowerFirst(howOf(s, row, other).text);
+ };
+
+ const keySetup = (app: { slug: string; name: string }) => (
+ <div className={`mt-3 ${phone ? '' : 'pl-[42px]'} space-y-2`} data-composio-setup={app.slug}>
+ <p className="text-sm font-medium text-zinc-100">{app.name} and hundreds more apps through Composio</p>
+ <p className="text-[13px] text-zinc-300">
+ Composio is a service with a free plan that signs your bots in to apps. Add your key once and your bots can use any app you connect.
+ </p>
+ <KeyField
+ id={`${uid}-key`}
+ app={app}
+ replace={false}
+ keyUrl={keyUrl}
+ phone={phone}
+ phase={keyPhase}
+ inputRef={keyRef}
+ onSubmit={submitKey}
+ onCancel={() => (setKeyOpen(null), inputRef.current?.focus())}
+ />
+ </div>
+ );
+
+ // ── A typed app row (§1) ──
+ const renderApp = (o: Extract<Opt, { t: 'app' }>) => {
+ const row = o.row;
+ const s = row.lead;
+ const isActive = active?.key === o.key;
+ const isOpen = open.has(row.key);
+ const setupApp =
+ keyOpen && !keyOpen.replace ? [s, ...row.others].find((x): x is Extract<Source, { kind: 'composio' }> => x.kind === 'composio' && x.app.slug === keyOpen.slug) : undefined;
+ const description =
+ s.kind === 'directory' ? markCutDescription(s.description) : s.kind === 'builtin' ? s.description.replace(/\s*Sign in after adding\.$/, '') : s.description;
+ const slug = s.kind === 'composio' ? s.app.slug : s.kind === 'builtin' ? s.preset.id : row.appKey;
+ const late = s.kind === 'directory';
+ const linkId = `${optionId(o)}-ways`;
+ const setupHere = !!(setupApp && setupApp.id === s.id);
+ return (
+ <li
+ key={o.key}
+ id={optionId(o)}
+ role="option"
+ aria-selected={isActive}
+ aria-label={`${row.name}, ${sourceWords(s)}, ${statusLabel(s, row, false)}`}
+ onMouseMove={() => hl !== o.key && setHl(o.key)}
+ className={`px-3.5 py-3 ${isActive ? `${activeBg} ${activeBar}` : ''} ${late ? fade : ''}`}
+ data-row="app"
+ data-row-key={o.key}
+ data-lead={s.id}
+ data-active={isActive || undefined}
+ >
+ <div className={phone ? 'space-y-2.5' : 'flex items-start gap-3'}>
+ <div className="flex items-start gap-2.5 flex-1 min-w-0">
+ <Mark name={row.name} slug={slug} />
+ <div className="min-w-0 flex-1">
+ <Name name={row.name} bold={row.match?.bold ?? null} />
+ {description && (
+ <p className={`text-[13px] text-zinc-300 ${phone ? 'line-clamp-2' : 'truncate'}`} title={s.description}>
+ {description}
+ </p>
+ )}
+ <div className="mt-1.5">{howLine(s, row, false)}</div>
+ {phone && !setupHere && <div className="mt-2.5">{sourceAction(s, row, { active: isActive, onClick: () => run(o) })}</div>}
+ {row.others.length > 0 && (
+ <button
+ type="button"
+ tabIndex={-1}
+ aria-expanded={isOpen}
+ aria-controls={isOpen ? `${linkId}-list` : undefined}
+ className={`${linkBtn} mt-1.5 ${phone ? 'h-11' : 'sm:min-h-0 h-6'}`}
+ onMouseDown={(e) => e.preventDefault()}
+ onClick={() => toggleOthers(row)}
+ data-other-ways={row.key}
+ >
+ {isOpen ? <ChevronDown size={12} aria-hidden="true" /> : <ChevronRight size={12} aria-hidden="true" />}
+ {otherWaysLabel(row.others)}
+ <span className="sr-only"> for {row.name}</span>
+ </button>
+ )}
+ </div>
+ </div>
+ {!phone && !setupHere && <div className="shrink-0">{sourceAction(s, row, { active: isActive, onClick: () => run(o) })}</div>}
+ </div>
+ {setupApp && keySetup(setupApp.app)}
+ </li>
+ );
+ };
+
+ // ── One other way to add the app, under its row (its own option, so ↑/↓ reach it) ──
+ const renderOther = (o: Extract<Opt, { t: 'other' }>, i: number, all: Source[]) => {
+ const { row, src } = o;
+ const isActive = active?.key === o.key;
+ const first = i === 0;
+ const last = i === Math.min(all.length, OTHER_WAYS_SHOWN) - 1;
+ const rest = all.length - OTHER_WAYS_SHOWN;
+ return (
+ <li
+ key={o.key}
+ id={optionId(o)}
+ role="option"
+ aria-selected={isActive}
+ aria-label={`${row.name}, also ${sourceWords(src)}, ${statusLabel(src, row, true)}`}
+ onMouseMove={() => hl !== o.key && setHl(o.key)}
+ className={`!border-t-0 px-3.5 ${last ? 'pb-3' : 'pb-1'} ${isActive ? `${activeBg} ${activeBar}` : ''}`}
+ data-row="other"
+ data-row-key={o.key}
+ data-active={isActive || undefined}
+ >
+ <div id={first ? `${optionId({ key: row.key })}-ways-list` : undefined} className={`ml-[42px] pl-3 border-l border-zinc-700 ${first ? 'pt-1' : 'pt-1'} ${phone ? 'space-y-2' : 'flex items-center gap-3'}`}>
+ <div className="flex-1 min-w-0">{howLine(src, row, true)}</div>
+ <div className={phone ? '' : 'shrink-0'}>{sourceAction(src, row, { active: isActive, small: true, onClick: () => run(o) })}</div>
+ </div>
+ {last && rest > 0 && <p className="ml-[42px] pl-3 pt-2 border-l border-zinc-700 text-xs text-zinc-400">{moreOtherWays(rest)}</p>}
+ </li>
+ );
+ };
+
+ const renderMore = (o: Extract<Opt, { t: 'more' }>) => {
+ const isActive = active?.key === o.key;
+ return (
+ <li
+ key={o.key}
+ id={optionId(o)}
+ role="option"
+ aria-selected={isActive}
+ onMouseMove={() => hl !== o.key && setHl(o.key)}
+ onMouseDown={(e) => e.preventDefault()}
+ onClick={() => run(o)}
+ className={`px-3.5 ${phone ? 'py-3 pl-[56px]' : 'py-2.5 pl-[60px]'} cursor-pointer ${isActive ? `${activeBg} ${activeBar}` : ''}`}
+ data-more="apps"
+ >
+ <span className="text-xs font-medium text-sky-300">{o.name}</span>
+ </li>
+ );
+ };
+
+ // ── An empty-field row (Connected, Popular): unchanged ──
+ const rowAction = (r: Row, isActive: boolean) => {
+ const main = (label: React.ReactNode, onClick: () => void, extra?: { primary?: boolean }) => mainButton(r.name, label, onClick, { active: isActive, primary: extra?.primary });
+ const o: Opt = { t: 'row', key: r.key, name: r.name, match: null, row: r };
if (r.kind === 'builtin') {
if (r.added)
return (
@@ -795,51 +1070,29 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
<span className="inline-flex items-center gap-1 text-xs text-zinc-400 whitespace-nowrap">
<Check size={12} aria-hidden="true" /> Added
</span>
- {main('Choose bots', () => run(r), { primary: !r.added.used_by.length })}
- </span>
- );
- return main('Add', () => run(r));
- }
- if (r.kind === 'directory') {
- if (r.entry.already_added)
- return (
- <span className="inline-flex items-center gap-1 text-xs text-zinc-400 whitespace-nowrap">
- <Check size={12} aria-hidden="true" /> Added
+ {main('Choose bots', () => run(o), { primary: !r.added.used_by.length })}
</span>
);
- return main('Add', () => run(r));
+ return main('Add', () => run(o));
}
- if (r.kind === 'composio') {
- const st = appState[r.app.slug];
- if (r.app.connected) {
- const users = composioUsers();
- return (
- <span className={`flex items-center gap-3 ${phone ? 'w-full' : ''}`}>
- <span className="inline-flex items-center gap-1 text-xs text-emerald-300 whitespace-nowrap">
- <Check size={12} aria-hidden="true" /> Connected
- </span>
- {main('Choose bots', () => run(r), { primary: !users.length })}
+ const st = appState[r.app.slug];
+ if (r.app.connected)
+ return (
+ <span className={`flex items-center gap-3 ${phone ? 'w-full' : ''}`}>
+ <span className="inline-flex items-center gap-1 text-xs text-emerald-300 whitespace-nowrap">
+ <Check size={12} aria-hidden="true" /> Connected
</span>
- );
- }
- if (st?.s === 'waiting')
- return main(
- <>
- Open sign-in again <ExternalLink size={12} aria-hidden="true" />
- </>,
- () => run(r),
- );
- return main('Connect', () => run(r));
- }
- return null;
- };
-
- const rowSmall = (r: Row): string | null => {
- if (r.group === 'connected' || r.group === 'popular') return r.kind === 'builtin' ? 'built in' : r.kind === 'composio' ? 'through Composio' : null;
- if (r.kind === 'builtin') return presetPublisher(r.preset) ? `by ${presetPublisher(r.preset)}` : null;
- if (r.kind === 'composio') return r.app.tools ? `${r.app.tools} tools` : null;
- if (r.kind === 'directory') return r.entry.publisher?.label ? `by ${r.entry.publisher.label}` : null;
- return null;
+ {main('Choose bots', () => run(o), { primary: !composioUsers().length })}
+ </span>
+ );
+ if (st?.s === 'waiting')
+ return main(
+ <>
+ Open sign-in again <ExternalLink size={12} aria-hidden="true" />
+ </>,
+ () => run(o),
+ );
+ return main('Connect', () => run(o));
};
const rowMeta = (r: Row): React.ReactNode => {
@@ -856,51 +1109,20 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
</>
);
}
- if (r.kind === 'directory') {
- const needs = directoryNeeds(r.entry);
- return (
- <>
- <span className={chip}>{r.entry.kind === 'remote' ? 'Remote' : 'Runs on this computer'}</span>
- {needs && <span className={chip}>{needs}</span>}
- </>
- );
- }
- if (r.kind === 'composio') {
- const st = appState[r.app.slug];
- if (r.app.connected) {
- const who = composioUsers();
- return who.length ? <span className="text-xs text-zinc-400">{listNames(who)} can use it</span> : <span className="text-xs text-amber-300">No bot can use it yet.</span>;
- }
- if (st?.s === 'waiting') return <span className="text-xs text-zinc-300">Waiting for you to finish signing in, in the new tab.</span>;
+ if (r.app.connected) {
+ const who = composioUsers();
+ return who.length ? <span className="text-xs text-zinc-400">{listNames(who)} can use it</span> : <span className="text-xs text-amber-300">No bot can use it yet.</span>;
}
+ if (appState[r.app.slug]?.s === 'waiting') return <span className="text-xs text-zinc-300">Waiting for you to finish signing in, in the new tab.</span>;
return null;
};
const renderRow = (r: Row) => {
const isActive = active?.key === r.key;
- const activate = () => {
- if (hl !== r.key) setHl(r.key);
- };
- if (r.kind === 'more')
- return (
- <li
- key={r.key}
- id={optionId(r)}
- role="option"
- aria-selected={isActive}
- onMouseMove={activate}
- onMouseDown={(e) => e.preventDefault()}
- onClick={() => run(r)}
- className={`px-3.5 py-2.5 cursor-pointer ${phone ? 'pl-[56px]' : 'pl-[60px]'} ${isActive ? 'bg-[#272050] shadow-[inset_2px_0_0_#9d8fff]' : ''}`}
- data-more={r.of}
- >
- <span className="text-xs font-medium text-sky-300">{r.name}</span>
- </li>
- );
- const small = rowSmall(r);
+ const small = r.kind === 'builtin' ? 'built in' : 'through Composio';
const meta = rowMeta(r);
- const description = r.kind === 'builtin' ? r.preset.blurb : r.kind === 'composio' ? r.app.description : r.entry.description;
- const slug = r.kind === 'composio' ? r.app.slug : r.kind === 'builtin' ? r.preset.id : undefined;
+ const description = r.kind === 'builtin' ? r.preset.blurb : r.app.description;
+ const slug = r.kind === 'composio' ? r.app.slug : r.preset.id;
const setupHere = r.kind === 'composio' && keyOpen && !keyOpen.replace && keyOpen.slug === r.app.slug;
return (
<li
@@ -908,9 +1130,9 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
id={optionId(r)}
role="option"
aria-selected={isActive}
- aria-label={small ? `${r.name}, ${small}` : r.name}
- onMouseMove={activate}
- className={`px-3.5 py-3 ${isActive ? 'bg-[#272050] shadow-[inset_2px_0_0_#9d8fff]' : ''}`}
+ aria-label={`${r.name}, ${small}`}
+ onMouseMove={() => hl !== r.key && setHl(r.key)}
+ className={`px-3.5 py-3 ${isActive ? `${activeBg} ${activeBar}` : ''}`}
data-row={r.kind}
data-row-key={r.key}
data-active={isActive || undefined}
@@ -920,12 +1142,12 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
<Mark name={r.name} slug={slug} />
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-baseline gap-x-1.5">
- <Name name={r.name} bold={r.match?.bold ?? null} />
- {small && <span className={`text-xs ${isActive ? 'text-zinc-400' : 'text-zinc-400'}`}>{small}</span>}
+ <Name name={r.name} bold={null} />
+ <span className="text-xs text-zinc-400">{small}</span>
</div>
{description && (
- <p className={`text-[13px] text-zinc-300 ${r.kind === 'directory' ? 'line-clamp-2' : 'truncate'}`} title={description}>
- {r.kind === 'directory' ? markCutDescription(description) : description}
+ <p className="text-[13px] text-zinc-300 truncate" title={description}>
+ {description}
</p>
)}
{meta && <div className="mt-1 flex flex-wrap items-center gap-1.5">{meta}</div>}
@@ -933,118 +1155,100 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
</div>
{!setupHere && <div className={phone ? 'pl-[42px]' : 'shrink-0'}>{rowAction(r, isActive)}</div>}
</div>
- {setupHere && (
- <div className={`mt-3 ${phone ? '' : 'pl-[42px]'} space-y-2`} data-composio-setup={r.app.slug}>
- <p className="text-sm font-medium text-zinc-100">{r.app.name} and hundreds more apps through Composio</p>
- <p className="text-[13px] text-zinc-300">
- Composio is a service with a free plan that signs your bots in to apps. Add your key once and your bots can use any app you connect.
- </p>
- <KeyField
- id={`${uid}-key`}
- app={{ slug: r.app.slug, name: r.app.name }}
- replace={false}
- keyUrl={keyUrl}
- phone={phone}
- phase={keyPhase}
- inputRef={keyRef}
- onSubmit={submitKey}
- onCancel={() => (setKeyOpen(null), inputRef.current?.focus())}
- />
- </div>
- )}
+ {setupHere && keySetup({ slug: r.app.slug, name: r.app.name })}
</li>
);
};
- const groupHeader = (g: Group) => (
- <div className={`flex ${phone ? 'flex-col gap-0.5' : 'items-baseline justify-between gap-2'} px-0.5 mb-1.5`}>
- <h4 id={`${uid}-g-${g.key}`} className="text-[11px] font-semibold uppercase tracking-wider text-zinc-300">
- {GROUP_LABEL[g.key]}
- </h4>
- {g.key === 'composio' && (
- <span className="inline-flex items-center gap-1 text-xs text-zinc-400">
- <Lock size={12} aria-hidden="true" /> Sign-ins stay on Composio’s servers
- </span>
- )}
- {g.key === 'directory' && <span className="text-xs text-zinc-400">Listed by their makers, not checked by us</span>}
- </div>
- );
+ const retry = (what: { composio: boolean; dir: boolean }) => {
+ if (what.composio) {
+ setApps({ s: 'loading' });
+ void loadApps();
+ }
+ if (what.dir) setDirTry((n) => n + 1);
+ };
- const composioState = (g: Group): React.ReactNode => {
- if (apps.s === 'refused')
- return (
- <div role="alert" className="px-3 py-2.5 rounded-xl border border-rose-500/40 bg-rose-500/10 text-xs text-rose-200 space-y-2" data-composio-state="refused">
- <p className="flex items-start gap-2">
- <AlertTriangle size={14} className="mt-px shrink-0" aria-hidden="true" />
- Composio didn’t accept your saved key, so its apps can’t be listed.
- </p>
- {keyOpen?.replace ? (
- <div className="pl-[22px]">
- <KeyField id={`${uid}-key`} app={null} replace keyUrl={keyUrl} phone={phone} phase={keyPhase} inputRef={keyRef} onSubmit={submitKey} onCancel={() => setKeyOpen(null)} />
- </div>
- ) : (
- <button type="button" className={`${quietBtn} ml-[22px]`} onClick={() => openKey(null, true)} data-replace-key>
- <KeyRound size={12} aria-hidden="true" /> Replace key
- </button>
- )}
- </div>
- );
- if (apps.s === 'down' && composioAdded)
- return (
- <p className="flex flex-wrap items-center gap-x-2 text-xs text-zinc-300" data-composio-state="down">
- Couldn’t reach Composio, so its apps aren’t listed.
- <button type="button" className={linkBtn} onClick={() => (setApps({ s: 'loading' }), void loadApps())}>
- <RefreshCw size={12} aria-hidden="true" /> Try again
- </button>
- </p>
- );
- const hasRows = g.rows.length > 0;
- return (
+ // One quiet line at the end of the card: still loading, or a source that couldn't be reached.
+ const statusLine = (): React.ReactNode => {
+ if (!typed) return null;
+ const tryAgain = (what: { composio: boolean; dir: boolean }) => (
+ <button type="button" className={linkBtn} onClick={() => retry(what)} data-try-again>
+ <RefreshCw size={12} aria-hidden="true" /> Try again
+ </button>
+ );
+ const down = (text: string, what: { composio: boolean; dir: boolean }) => (
<>
- {apps.s === 'loading' && composioAdded && (
- <p className="flex items-center gap-2 text-xs text-zinc-300 py-1" data-composio-state="loading">
- <Spinner /> Loading Composio’s apps…
- </p>
- )}
- {!hasRows && normalize(query).length >= 2 && (
- <p className="text-xs text-zinc-300 py-1" data-not-listed>
- Not listed? Bots with Composio find its other apps themselves.
- </p>
- )}
+ <AlertTriangle size={14} className="shrink-0 text-amber-300" aria-hidden="true" />
+ <span className="min-w-0 flex-1">{text}</span>
+ {tryAgain(what)}
</>
);
- };
-
- const directoryState = (g: Group): React.ReactNode => {
- if (dir?.unavailable && !g.rows.length)
- return (
- <p className="flex flex-wrap items-center gap-x-2 text-xs text-zinc-300" data-directory-state="down">
- Couldn’t reach the public directory. The tools above still work.
- <button type="button" className={linkBtn} onClick={() => setDirTry((n) => n + 1)}>
- <RefreshCw size={12} aria-hidden="true" /> Try again
- </button>
- </p>
- );
- if ((!dir || dir.loading) && !g.rows.length)
- return (
- <p className="flex items-center gap-2 text-xs text-zinc-300 py-1" data-directory-state="loading">
- <Spinner /> Searching the public directory…
- </p>
+ let body: React.ReactNode = null;
+ let state = '';
+ if (composioDown && dirDown) {
+ state = 'down-both';
+ body = down('Couldn’t reach Composio or the public list. Built-in tools still show.', { composio: true, dir: true });
+ } else if (dirLoading || composioLoading) {
+ state = 'loading';
+ body = (
+ <>
+ <Spinner /> <span>Searching more apps…</span>
+ </>
);
- return null;
+ } else if (composioDown) {
+ state = 'down-composio';
+ body = down('Couldn’t reach Composio, so its apps aren’t in this list.', { composio: true, dir: false });
+ } else if (dirDown) {
+ state = 'down-directory';
+ body = down('Couldn’t reach the public list of tool servers, so only built-in tools and Composio apps are shown.', { composio: false, dir: true });
+ }
+ if (!body) return null;
+ return (
+ <div role="status" className={`flex flex-wrap items-center gap-x-2 gap-y-1 px-3.5 ${phone ? 'py-1' : 'py-2'} text-xs text-zinc-300`} data-find-status={state}>
+ {body}
+ </div>
+ );
};
- // A group with no rows and nothing to say is hidden.
- const shown = (g: Group): boolean => {
- if (g.rows.length) return true;
- if (g.key === 'composio') return apps.s === 'refused' || (apps.s === 'down' && composioAdded) || (apps.s === 'loading' && composioAdded) || normalize(query).length >= 2;
- if (g.key === 'directory') return !!dir?.unavailable || !dir || dir.loading;
- return false;
- };
- const visibleGroups = typed || showEmptyGroups ? groups.filter(shown) : [];
- const nothing = typed && optionCount === 0 && !(apps.s === 'refused') && !(dir?.loading || (!dir && q2 && !dirMissing)) && !dir?.unavailable;
+ const refusedAlert =
+ typed && apps.s === 'refused' ? (
+ <div role="alert" className="px-3 py-2.5 rounded-xl border border-rose-500/40 bg-rose-500/10 text-xs text-rose-200 space-y-2" data-composio-state="refused">
+ <p className="flex items-start gap-2">
+ <AlertTriangle size={14} className="mt-px shrink-0" aria-hidden="true" />
+ Composio didn’t accept your saved key, so its apps can’t be listed.
+ </p>
+ {keyOpen?.replace ? (
+ <div className="pl-[22px]">
+ <KeyField id={`${uid}-key`} app={null} replace keyUrl={keyUrl} phone={phone} phase={keyPhase} inputRef={keyRef} onSubmit={submitKey} onCancel={() => setKeyOpen(null)} />
+ </div>
+ ) : (
+ <button type="button" className={`${quietBtn} ml-[22px]`} onClick={() => openKey(null, true)} data-replace-key>
+ <KeyRound size={12} aria-hidden="true" /> Replace key
+ </button>
+ )}
+ </div>
+ ) : null;
+
+ const status = statusLine();
+ const anyDown = composioDown || dirDown;
+ const nothing = typed && merged.length === 0 && !dirLoading && !composioLoading && !anyDown && apps.s !== 'refused';
+ const shownSources = rowsShown.flatMap((r) => [r.lead, ...(open.has(r.key) ? r.others.slice(0, OTHER_WAYS_SHOWN) : [])]);
+ const notes = { composio: shownSources.some((s) => s.origin === 'composio'), community: shownSources.some((s) => s.origin === 'community') };
+ const typedCard = typed && (opts.length > 0 || !!status);
+ const listOpen = typed ? opts.length > 0 : showEmptyGroups && opts.length > 0;
+
+ // The other ways of an open row, in order, so each line knows if it is first or last.
+ const renderTyped = () =>
+ opts.map((o) => {
+ if (o.t === 'app') return renderApp(o);
+ if (o.t === 'more') return renderMore(o);
+ if (o.t === 'other') {
+ const shown = o.row.others.slice(0, OTHER_WAYS_SHOWN);
+ return renderOther(o, shown.indexOf(o.src), o.row.others);
+ }
+ return null;
+ });
- const expandedOpen = visibleGroups.length > 0;
return (
<div
ref={rootRef}
@@ -1078,9 +1282,9 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
ref={inputRef}
type="text"
role="combobox"
- aria-label="Find a tool"
+ aria-label={p.label ?? 'Find a tool'}
aria-autocomplete="both"
- aria-expanded={expandedOpen}
+ aria-expanded={listOpen}
aria-controls={`${uid}-results`}
aria-activedescendant={active ? optionId(active) : undefined}
aria-describedby={`${uid}-live`}
@@ -1091,7 +1295,7 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
spellCheck={false}
autoFocus={p.autoFocus}
value={query}
- placeholder="Find a tool, like gmail, stripe or a database"
+ placeholder={p.placeholder ?? 'Find a tool, like gmail, stripe or a database'}
onChange={(e) => change(e.target.value)}
onKeyDown={onKeyDown}
onSelect={(e) => {
@@ -1133,16 +1337,15 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
)}
<div id={`${uid}-results`} className="space-y-4" data-find-results>
- {visibleGroups.map((g) => (
- <section key={g.key} className={showEmptyGroups ? 'motion-safe:animate-[findtool-in_120ms_ease-out]' : g.key === 'directory' ? fade : ''} data-group={g.key}>
- {groupHeader(g)}
- {g.key === 'composio' && composioState(g)}
- {g.rows.length > 0 && (
- <ul
- role="listbox"
- aria-labelledby={`${uid}-g-${g.key}`}
- className="rounded-xl border border-zinc-800 bg-[#181335] divide-y divide-zinc-800 overflow-hidden"
- >
+ {showEmptyGroups &&
+ groups.map((g) => (
+ <section key={g.key} className="motion-safe:animate-[findtool-in_120ms_ease-out]" data-group={g.key}>
+ <div className="flex items-baseline justify-between gap-2 px-0.5 mb-1.5">
+ <h4 id={`${uid}-g-${g.key}`} className="text-[11px] font-semibold uppercase tracking-wider text-zinc-300">
+ {GROUP_LABEL[g.key]}
+ </h4>
+ </div>
+ <ul role="listbox" aria-labelledby={`${uid}-g-${g.key}`} className="rounded-xl border border-zinc-800 bg-[#181335] divide-y divide-zinc-800 overflow-hidden">
{g.rows.map(renderRow)}
{g.rest ? (
<li role="presentation" className="px-3.5 py-2.5 pl-[60px] text-xs text-zinc-400" data-connected-rest>
@@ -1150,10 +1353,33 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
</li>
) : null}
</ul>
+ </section>
+ ))}
+ {refusedAlert}
+ {typedCard && (
+ <div className="rounded-xl border border-zinc-800 bg-[#181335] overflow-hidden" data-find-card>
+ {opts.length > 0 && (
+ <ul role="listbox" aria-label={p.label ?? 'Find a tool'} className="divide-y divide-zinc-800" data-find-list>
+ {renderTyped()}
+ </ul>
)}
- {g.key === 'directory' && directoryState(g)}
- </section>
- ))}
+ {status && <div className={opts.length ? 'border-t border-zinc-800' : ''}>{status}</div>}
+ </div>
+ )}
+ {typed && (notes.composio || notes.community) && (
+ <div className="space-y-1 px-0.5 text-[11px] text-zinc-500" data-find-notes>
+ {notes.composio && (
+ <p className="flex items-start gap-1.5">
+ <Lock size={11} className="mt-[2px] shrink-0" aria-hidden="true" /> Through Composio: sign-ins stay on Composio’s servers.
+ </p>
+ )}
+ {notes.community && (
+ <p className="flex items-start gap-1.5">
+ <Users size={11} className="mt-[2px] shrink-0" aria-hidden="true" /> Community: listed by their makers, not checked by us.
+ </p>
+ )}
+ </div>
+ )}
{nothing && (
<div className="flex flex-col items-center gap-1.5 px-4 py-5 rounded-xl border border-zinc-800 bg-[#181335] text-center" data-find-nothing>
<p className="text-sm text-zinc-100">Nothing found for “{query.trim()}”.</p>
@@ -1163,13 +1389,18 @@ export const FindTool: React.FC<FindToolProps> = (p) => {
<Plus size={14} aria-hidden="true" /> Add by address
</button>
)}
+ {composioAdded && (
+ <p className="mt-1 text-xs text-zinc-400" data-not-listed>
+ Not listed? Bots with Composio find its other apps themselves.
+ </p>
+ )}
</div>
)}
{typed && !phone && optionCount > 0 && (
<p className="flex flex-wrap items-center gap-1.5 text-[11px] text-zinc-500" aria-hidden="true" data-find-legend>
<span className={keycap}>↑</span>
<span className={keycap}>↓</span> move ·<span className={keycap}>↵</span> runs the button ·<span className={keycap}>Tab</span> fills in the name ·
- <span className={keycap}>Esc</span> clears
+ <span className={keycap}>→</span> other ways ·<span className={keycap}>Esc</span> clears
</p>
)}
</div>
diff --git a/frontend/src/connections.ts b/frontend/src/connections.ts
index 8a7448d4..7200b9ac 100644
--- a/frontend/src/connections.ts
+++ b/frontend/src/connections.ts
@@ -109,6 +109,10 @@ export interface DirectoryEntry {
command?: string | null;
inputs: Array<{ name: string; description?: string; required?: boolean; secret?: boolean }>;
already_added?: boolean;
+ /** Optional (one-app-search, server side): made by the app's maker. The frontend has the same rule when it's missing. */
+ by_maker?: boolean;
+ /** Optional (one-app-search, server side): how you sign in. */
+ sign_in?: 'account' | 'key' | 'none' | 'unknown';
}
export interface VaultSummary {
@@ -220,7 +224,7 @@ async function searchDirectory(q: string, signal?: AbortSignal): Promise<{ entri
const answer = (await res.json().catch(() => null)) as { entries?: unknown; unavailable?: unknown } | null;
if (!res.ok || !answer) return { entries: [], unavailable: true };
const entries = Array.isArray(answer.entries) ? (answer.entries as DirectoryEntry[]).filter((e) => e && typeof e.registry_name === 'string') : [];
- return { entries: entries.slice(0, 12), unavailable: answer.unavailable === true };
+ return { entries: entries.slice(0, 20), unavailable: answer.unavailable === true };
}
const enc = encodeURIComponent;
diff --git a/frontend/src/mcp.ts b/frontend/src/mcp.ts
index fa7a8701..0fb2193d 100644
--- a/frontend/src/mcp.ts
+++ b/frontend/src/mcp.ts
@@ -100,6 +100,8 @@ export interface McpPreset {
/** Where the setup comes from: the vendor's docs or the package page. */
source: string;
form: McpFormState;
+ /** The maker's own domain, when the server's address is on another one (GitHub's is api.githubcopilot.com). */
+ domain?: string;
}
/** A preset's secret: name, placeholder, and whether the server needs it to work. */
@@ -160,6 +162,7 @@ export const MCP_PRESETS: McpPreset[] = [
needs: ['Token'],
source: 'https://github.com/github/github-mcp-server',
form: httpPreset('github', 'https://api.githubcopilot.com/mcp/', [['Authorization', 'Bearer ghp_…', true]]),
+ domain: 'github.com',
},
{
// PyPI mcp-server-fetch 2026.10.10
diff --git a/frontend/tests/appSearch.test.mjs b/frontend/tests/appSearch.test.mjs
new file mode 100644
index 00000000..13f5202a
--- /dev/null
+++ b/frontend/tests/appSearch.test.mjs
@@ -0,0 +1,184 @@
+// One list for any app (one-app-search/design.md §2, §3): appKey, byMaker, mergeRows and signInOf, table style.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+const m = await loadBundled(`
+ export { appKey, byMaker, presetPublisher, mergeRows, signInOf, leadTier, otherWaysLabel, moreOtherWays, sourceWords } from './src/appSearch';
+ export { MCP_PRESETS } from './src/mcp';
+`);
+
+const app = (slug, name, over = {}) => ({ slug, name, description: '', tools: null, connected: false, ...over });
+const dirEntry = (registry_name, title, over = {}) => ({
+ registry_name,
+ title,
+ description: '',
+ publisher: { label: registry_name.split('/')[0].split('.').reverse().join('.'), kind: 'domain' },
+ kind: 'remote',
+ url: null,
+ inputs: [],
+ ...over,
+});
+
+const COMPOSIO = [app('stripe', 'Stripe', { tools: 30 }), app('elevenlabs', 'ElevenLabs', { tools: 12 }), app('gmail', 'Gmail', { tools: 61 }), app('airtable', 'Airtable', { tools: 20 })];
+const STRIPE_DIR = [
+ // Stripe's own server is the built-in Stripe (same address): listed once.
+ dirEntry('com.stripe/mcp', 'Stripe', { url: 'https://mcp.stripe.com' }),
+ dirEntry('com.insightfulpipe/stripe', 'Stripe MCP by InsightfulPipe', { url: 'https://mcp.insightfulpipe.com/stripe', inputs: [{ name: 'STRIPE_API_KEY', secret: true }] }),
+ dirEntry('io.github.someone/stripe-billing-reports', 'Stripe Billing Reports', { publisher: { label: 'github.com/someone', kind: 'github' }, kind: 'local', command: 'npx' }),
+];
+const ELEVEN_DIR = [
+ dirEntry('io.elevenlabs/mcp', 'ElevenLabs', { url: 'https://api.us.elevenlabs.io/mcp' }),
+ dirEntry('io.github.fan/elevenlabs-mcp', 'ElevenLabs MCP', { publisher: { label: 'github.com/fan', kind: 'github' }, kind: 'local', command: 'uvx elevenlabs-mcp', inputs: [{ name: 'ELEVENLABS_API_KEY', secret: true }] }),
+ dirEntry('io.github.eleventy/eleventy', 'Eleventy', { publisher: { label: 'github.com/eleventy', kind: 'github' }, kind: 'local', command: 'npx' }),
+];
+const merge = (q, over = {}) => m.mergeRows(q, { presets: m.MCP_PRESETS, composio: COMPOSIO, directory: null, connections: [], ...over });
+const ids = (row) => [row.lead.id, ...row.others.map((o) => o.id)];
+
+test('appKey: one key per app, whatever the listing calls it', () => {
+ for (const [name, key] of [
+ ['Stripe', 'stripe'],
+ ['Stripe MCP by InsightfulPipe', 'stripe'],
+ ['ElevenLabs MCP', 'elevenlabs'],
+ ['elevenlabs', 'elevenlabs'],
+ ['11labs', 'elevenlabs'],
+ ['Official Notion MCP Server', 'notion'],
+ ['Linear (official)', 'linear'],
+ ['Google Calendar', 'googlecalendar'],
+ ['gcal', 'googlecalendar'],
+ ['Postgres', 'postgresql'],
+ ['Stripe Billing Reports', 'stripebillingreports'],
+ ['MCP', 'mcp'],
+ ['', ''],
+ ])
+ assert.equal(m.appKey(name), key, name);
+});
+
+test('presetPublisher: the maker\'s own domain wins over the address (GitHub), else the last two labels', () => {
+ const by = (id) => m.presetPublisher(m.MCP_PRESETS.find((p) => p.id === id));
+ assert.equal(by('github'), 'github.com', 'api.githubcopilot.com is GitHub\'s');
+ assert.equal(by('notion'), 'notion.com');
+ assert.equal(by('fetch'), null, 'a local server has no publisher');
+});
+
+test('byMaker: a domain publisher, its own address, and the app named after it', () => {
+ for (const [entry, want, why] of [
+ [STRIPE_DIR[0], true, 'stripe.com at mcp.stripe.com'],
+ [STRIPE_DIR[1], false, 'insightfulpipe.com publishing a Stripe server'],
+ [ELEVEN_DIR[0], true, 'elevenlabs.io at api.us.elevenlabs.io'],
+ [ELEVEN_DIR[1], false, 'github publisher'],
+ [dirEntry('io.github.stripe/mcp', 'Stripe', { publisher: { label: 'stripe.com', kind: 'domain' }, url: 'https://mcp.stripe.com' }), false, 'io.github.* is never the maker'],
+ [dirEntry('com.stripe/mcp', 'Stripe', { url: 'https://stripe.evil.example' }), false, 'address not on the domain'],
+ [dirEntry('com.stripe/mcp', 'Stripe', { kind: 'local', url: null }), false, 'no address to check'],
+ [dirEntry('com.acme/mcp', 'Acme', { url: 'https://acme.com/x', by_maker: false }), false, 'the server field wins'],
+ [dirEntry('com.acme/mcp', 'Widgets', { url: 'https://x.example', by_maker: true }), true, 'the server field wins'],
+ ])
+ assert.equal(m.byMaker(entry), want, why);
+});
+
+test('mergeRows: "stripe" folds InsightfulPipe and Composio under the official Stripe; Billing Reports stays its own row', () => {
+ const rows = merge('stripe', { directory: STRIPE_DIR });
+ assert.deepEqual(rows.map((r) => r.key), ['app-stripe', 'app-stripebillingreports']);
+ const [stripe, reports] = rows;
+ assert.deepEqual(ids(stripe), ['b-stripe', 'c-stripe', 'd-com.insightfulpipe/stripe']);
+ assert.equal(stripe.lead.origin, 'official');
+ assert.equal(stripe.lead.by, 'stripe.com');
+ assert.deepEqual(stripe.others.map((o) => o.origin), ['composio', 'community']);
+ assert.equal(reports.lead.origin, 'community');
+ assert.equal(reports.others.length, 0);
+});
+
+test('mergeRows: "eleven" puts the official ElevenLabs first, with Composio and community under it; Eleventy below', () => {
+ const rows = merge('eleven', { directory: ELEVEN_DIR });
+ assert.deepEqual(rows.map((r) => r.key), ['app-elevenlabs', 'app-eleventy']);
+ assert.deepEqual(ids(rows[0]), ['d-io.elevenlabs/mcp', 'c-elevenlabs', 'd-io.github.fan/elevenlabs-mcp']);
+ assert.equal(rows[0].lead.origin, 'official');
+ assert.equal(m.otherWaysLabel(rows[0].others), '2 other ways to add it');
+});
+
+test('mergeRows: what is already connected leads, even over an official server', () => {
+ const composio = COMPOSIO.map((a) => (a.slug === 'elevenlabs' ? { ...a, connected: true } : a));
+ const [row] = merge('eleven', { composio, directory: ELEVEN_DIR });
+ assert.equal(row.lead.id, 'c-elevenlabs');
+ assert.deepEqual(row.others.map((o) => o.id), ['d-io.elevenlabs/mcp', 'd-io.github.fan/elevenlabs-mcp']);
+});
+
+test('mergeRows: the highlight keeps its app when the public list lands', () => {
+ // Before the public list answers, ElevenLabs is Composio's; after, the official server leads the same row.
+ const before = merge('eleven');
+ const after = merge('eleven', { directory: ELEVEN_DIR });
+ assert.equal(before[0].key, 'app-elevenlabs');
+ assert.equal(before[0].lead.id, 'c-elevenlabs');
+ assert.equal(after[0].key, before[0].key);
+ assert.equal(after[0].lead.id, 'd-io.elevenlabs/mcp');
+ // A pressed row keeps its lead for this query.
+ const pinned = merge('eleven', { directory: ELEVEN_DIR, pinned: { elevenlabs: 'c-elevenlabs' } });
+ assert.equal(pinned[0].lead.id, 'c-elevenlabs');
+});
+
+test('mergeRows: lead order and row order', () => {
+ const rows = merge('a', { directory: null });
+ for (const r of rows) for (const o of r.others) assert.ok(m.leadTier(r.lead) <= m.leadTier(o), `${r.key}: ${r.lead.id} before ${o.id}`);
+ // Match strength first: "air" starts Airtable's name, so it is first.
+ assert.equal(merge('air')[0].key, 'app-airtable');
+ assert.deepEqual(merge(' '), []);
+});
+
+test('mergeRows: one listing never shows twice', () => {
+ const rows = merge('stripe', { directory: [...STRIPE_DIR, STRIPE_DIR[1]] });
+ const all = rows.flatMap(ids);
+ assert.equal(new Set(all).size, all.length);
+});
+
+test('signInOf: one sentence per way, from the §3 table', () => {
+ const rows = merge('stripe', { directory: STRIPE_DIR });
+ const eleven = merge('eleven', { directory: ELEVEN_DIR });
+ const [stripe, reports] = rows;
+ const by = (row, id) => [row.lead, ...row.others].find((s) => s.id === id);
+ for (const [s, opts, icon, text, button] of [
+ [by(stripe, 'b-stripe'), { rowName: 'Stripe', composioAdded: true }, 'account', 'Sign in with your Stripe account', 'Connect'],
+ [by(stripe, 'c-stripe'), { rowName: 'Stripe', composioAdded: true }, 'account', 'Sign in with your Stripe account', 'Connect'],
+ [by(stripe, 'c-stripe'), { rowName: 'Stripe', composioAdded: false }, 'account', 'Sign in with your Stripe account · free Composio key first', 'Connect'],
+ [by(stripe, 'c-stripe'), { rowName: 'Stripe', composioAdded: true, other: true }, 'account', 'Sign in with your account', 'Connect'],
+ [by(stripe, 'd-com.insightfulpipe/stripe'), { rowName: 'Stripe', composioAdded: true }, 'key', 'Your own Stripe API key', 'Add'],
+ [reports.lead, { rowName: reports.name, composioAdded: true }, 'local', 'Runs on this computer · needs Node.js', 'Add'],
+ [eleven[0].lead, { rowName: 'ElevenLabs', composioAdded: false }, 'account', 'Sign in with your ElevenLabs account', 'Connect'],
+ [by(eleven[0], 'd-io.github.fan/elevenlabs-mcp'), { rowName: 'ElevenLabs', composioAdded: false }, 'key', 'Your own ElevenLabs API key', 'Add'],
+ [eleven[1].lead, { rowName: 'Eleventy', composioAdded: false }, 'local', 'Runs on this computer · needs Node.js', 'Add'],
+ ]) {
+ const got = m.signInOf(s, opts);
+ assert.equal(got.icon, icon, s.id);
+ if (text) assert.equal(got.text, text, s.id);
+ if (button) assert.equal(got.button, button, s.id);
+ }
+});
+
+test('signInOf: the public list entries without the server fields', () => {
+ const src = (entry, row = 'Acme') => merge(row, { composio: [], presets: [], directory: [entry] })[0].lead;
+ for (const [entry, text] of [
+ [dirEntry('com.acme/mcp', 'Acme', { url: 'https://mcp.acme.com' }), 'Sign in with your Acme account'],
+ [dirEntry('io.github.x/acme', 'Acme', { publisher: { label: 'github.com/x', kind: 'github' }, url: 'https://acme.x.dev' }), 'Signs in when you add it, if it asks'],
+ [dirEntry('io.github.x/acme', 'Acme', { publisher: { label: 'github.com/x', kind: 'github' }, kind: 'local', command: 'uvx acme' }), 'Runs on this computer · needs uv'],
+ [dirEntry('io.github.x/acme', 'Acme', { publisher: { label: 'github.com/x', kind: 'github' }, kind: 'local', command: 'docker run acme' }), 'Runs on this computer'],
+ [dirEntry('io.github.x/acme', 'Acme', { publisher: { label: 'github.com/x', kind: 'github' }, inputs: [{ name: 'ACME_KEY' }, { name: 'ACME_SECRET', secret: true }] }), '2 keys from Acme'],
+ [dirEntry('io.github.x/acme', 'Acme', { publisher: { label: 'github.com/x', kind: 'github' }, sign_in: 'none' }), 'No sign-in needed'],
+ [dirEntry('io.github.x/acme', 'Acme', { publisher: { label: 'github.com/x', kind: 'github' }, sign_in: 'account' }), 'Sign in with your Acme account'],
+ ])
+ assert.equal(m.signInOf(src(entry), { rowName: 'Acme', composioAdded: true }).text, text, JSON.stringify(entry));
+});
+
+test('words: the other-ways link, the overflow line and the source for screen readers', () => {
+ const [stripe] = merge('stripe', { directory: STRIPE_DIR });
+ for (const [got, want] of [
+ [m.otherWaysLabel([stripe.others[0]]), 'Also through Composio'],
+ [m.otherWaysLabel([stripe.others[1]]), 'Also as a community server'],
+ [m.otherWaysLabel([stripe.lead]), 'Also as an official server'],
+ [m.otherWaysLabel(stripe.others), '2 other ways to add it'],
+ [m.moreOtherWays(1), 'and 1 more community server'],
+ [m.moreOtherWays(3), 'and 3 more community servers'],
+ [m.sourceWords(stripe.lead), 'official server by stripe.com'],
+ [m.sourceWords(stripe.others[0]), 'through Composio'],
+ [m.sourceWords(stripe.others[1]), 'community server by insightfulpipe.com'],
+ ])
+ assert.equal(got, want);
+});
diff --git a/frontend/tests/findTool.test.mjs b/frontend/tests/findTool.test.mjs
index a30328ed..dcdf3c43 100644
--- a/frontend/tests/findTool.test.mjs
+++ b/frontend/tests/findTool.test.mjs
@@ -1,6 +1,6 @@
-// Find a tool (composio-simple/design.md §1, §2, "Autocomplete"): suggestions from the first letter,
-// three groups, the ghost and the keys, Connect before Composio is set up opening the key field under
-// the row, the not-listed line, the public directory hiding on 404, and no plumbing words.
+// Find a tool / Another app (composio-simple/design.md "Autocomplete"; one-app-search/design.md): suggestions from
+// the first letter, one row per app with its source and how you sign in, the other ways under it, the ghost and the
+// keys, Connect before Composio is set up opening the key field under the row, one status line, and no plumbing words.
import assert from 'node:assert/strict';
import test, { afterEach } from 'node:test';
import { JSDOM } from 'jsdom';
@@ -17,6 +17,7 @@ g.window.HTMLElement.prototype.scrollIntoView ??= () => {};
const m = await loadBundled(`
export { FindTool, buildGroups, directoryNeeds, presetPublisher, markCutDescription } from './src/components/FindTool';
+ export { mergeRows } from './src/appSearch';
export { ConnectionsError, connectionsApi } from './src/connections';
export { MCP_PRESETS } from './src/mcp';
export { createRoot } from 'react-dom/client';
@@ -97,29 +98,49 @@ const key = async (el, k, opts = {}) => {
await settle();
return ev;
};
-const rowNames = (host, group) => [...host.querySelectorAll(`[data-group="${group}"] [data-row-name]`)].map(text);
+const rowNames = (host) => [...host.querySelectorAll('[data-find-list] [data-row="app"] [data-row-name]')].map(text);
+const rowKeys = (host) => [...host.querySelectorAll('[data-find-list] [data-row="app"]')].map((r) => r.dataset.rowKey);
const activeRow = (host) => host.querySelector('[data-active]');
+const click = async (el) => {
+ el.dispatchEvent(new window.MouseEvent('click', { bubbles: true }));
+ await settle();
+};
test('one letter already suggests, best match first, with the typed letter bold', async () => {
- const { api } = stubApi();
+ const { api, calls } = stubApi();
const host = await mount({ api });
await type(host, 'g');
- assert.deepEqual(rowNames(host, 'composio').slice(0, 3), ['Gmail', 'Google Calendar', 'Google Sheets']);
- assert.ok(host.querySelector('[data-group="builtin"]'), 'built-in tools starting with g (GitHub, Git) are listed too');
- const first = host.querySelector('[data-group="builtin"] [data-row-name] b');
+ const names = rowNames(host);
+ for (const n of ['Gmail', 'Google Calendar', 'Google Sheets', 'GitHub']) assert.ok(names.includes(n), `${n} is listed`);
+ assert.equal(host.querySelectorAll('[data-find-list]').length, 1, 'one list, not one per source');
+ assert.equal(host.querySelector('[data-group]'), null, 'no group headers when typed');
+ const first = host.querySelector('[data-find-list] [data-row-name] b');
assert.equal(text(first).toLowerCase(), 'g');
- assert.equal(host.querySelector('[data-group="directory"]'), null, 'the directory waits for two letters');
+ await settle(200);
+ assert.equal(calls.filter((c) => c[0] === 'directory').length, 0, 'the public list waits for two letters');
});
-test('the three groups come in order and say where the tool comes from', async () => {
+test('one row per app: the chip says where it comes from, one sentence says how you sign in', async () => {
const { api } = stubApi({ directory: async () => ({ entries: DIR, unavailable: false }) });
const host = await mount({ api });
await type(host, 'gm', 200);
- const groups = [...host.querySelectorAll('[data-group]')].map((s) => s.dataset.group);
- assert.deepEqual(groups, ['composio', 'directory']);
- assert.match(text(host.querySelector('[data-group="composio"]')), /Through Composio.*Sign-ins stay on Composio’s servers/);
- assert.match(text(host.querySelector('[data-group="directory"]')), /From the public directory.*Listed by their makers, not checked by us/);
- assert.match(text(host.querySelector('[data-group="directory"] [data-row]')), /by example\.io.*Runs on this computer.*API key/);
+ // "Gmail tools" from the public list is Gmail too, so it folds under Composio's Gmail.
+ assert.deepEqual(rowKeys(host), ['app-gmail']);
+ const row = host.querySelector('[data-row-key="app-gmail"]');
+ assert.equal(text(row.querySelector('[data-source-chip]')), 'Through Composio');
+ assert.equal(text(row.querySelector('[data-sign-in]')), 'Sign in with your Gmail account · free Composio key first');
+ assert.equal(row.getAttribute('aria-label'), 'Gmail, through Composio, sign in with your Gmail account · free Composio key first');
+ const link = row.querySelector('[data-other-ways]');
+ assert.equal(text(link), 'Also as a community server for Gmail');
+ assert.equal(link.getAttribute('aria-expanded'), 'false');
+ assert.match(text(host.querySelector('[data-find-notes]')), /^Through Composio: sign-ins stay on Composio’s servers\.$/);
+ await click(link);
+ assert.equal(link.getAttribute('aria-expanded'), 'true');
+ assert.ok(document.getElementById(link.getAttribute('aria-controls')), 'aria-controls names the open block');
+ const other = host.querySelector('[data-row="other"]');
+ assert.equal(other.getAttribute('role'), 'option', 'each other way is an option of the same list');
+ assert.match(text(other), /Community\s*· example\.io.*Your own Gmail API key.*Add Gmail/);
+ assert.match(text(host.querySelector('[data-find-notes]')), /Community: listed by their makers, not checked by us\./);
assert.doesNotMatch(text(host), PLUMBING);
});
@@ -128,19 +149,22 @@ test('typos and other names find the app', async () => {
const host = await mount({ api });
for (const [q, name] of [['gmial', 'Gmail'], ['slak', 'Slack'], ['notoin', 'Notion'], ['sheets', 'Google Sheets']]) {
await type(host, q);
- assert.ok(rowNames(host, 'composio').includes(name), `${q} → ${name}`);
+ assert.ok(rowNames(host).includes(name), `${q} → ${name}`);
}
});
-test('"eleven" is not in the list: the not-listed line says bots find other apps themselves', async () => {
+test('nothing from any source: the empty box, with the not-listed line once Composio is added', async () => {
const { api } = stubApi();
- const host = await mount({ api });
- await type(host, 'eleven');
- const line = host.querySelector('[data-not-listed]');
- assert.ok(line, 'the not-listed line shows');
- assert.equal(text(line), 'Not listed? Bots with Composio find its other apps themselves.');
- assert.equal(host.querySelectorAll('[data-group="composio"] [data-row]').length, 0);
- assert.equal(host.querySelector('[data-find-nothing]'), null, 'not "nothing found": the line is the answer');
+ let host = await mount({ api });
+ await type(host, 'qwzx', 200);
+ assert.ok(host.querySelector('[data-find-nothing]'));
+ assert.equal(host.querySelector('[data-not-listed]'), null, 'without Composio the line would promise nothing');
+ for (const u of mounted) u();
+ const added = stubApi({ list: async () => listOf(composio({ added: true, can_connect: true })) });
+ host = await mount({ api: added.api });
+ await type(host, 'qwzx', 200);
+ assert.equal(text(host.querySelector('[data-not-listed]')), 'Not listed? Bots with Composio find its other apps themselves.');
+ assert.equal(host.querySelector('[data-find-status]'), null, 'every source answered: no status line');
});
test('Connect before Composio is set up opens the key field under that row, focused', async () => {
@@ -149,9 +173,8 @@ test('Connect before Composio is set up opens the key field under that row, focu
window.open = (url) => (opened.push(url), { closed: false, location: {}, close() {} });
const host = await mount({ api });
await type(host, 'gm');
- const row = host.querySelector('[data-row-key="composio-c-gmail"]');
- row.querySelector('[data-row-action]').dispatchEvent(new window.MouseEvent('click', { bubbles: true }));
- await settle();
+ const row = host.querySelector('[data-row-key="app-gmail"]');
+ await click(row.querySelector('[data-row-action]'));
const setup = host.querySelector('[data-composio-setup="gmail"]');
assert.ok(setup, 'the key field opens under Gmail');
assert.ok(row.contains(setup), 'inside the row, not somewhere else');
@@ -170,7 +193,7 @@ test('Enter on Gmail before setup opens the same field; Esc in it closes it and
const { api } = stubApi();
const host = await mount({ api });
await type(host, 'gm');
- assert.equal(activeRow(host)?.dataset.rowKey, 'composio-c-gmail');
+ assert.equal(activeRow(host)?.dataset.rowKey, 'app-gmail');
await key(input(host), 'Enter');
const field = host.querySelector('[data-composio-setup="gmail"] input');
assert.equal(document.activeElement, field);
@@ -199,7 +222,7 @@ test('a good key adds Composio, then the sign-in opens in the tab opened by the
assert.deepEqual(opened, ['about:blank'], 'the tab opens synchronously in the press');
assert.equal(tab.location.href, 'https://connect.example/gmail');
assert.match(text(host.querySelector('[data-find-notice]')), /Composio is added\. Finish signing in to Gmail in the new tab\./);
- assert.match(text(host.querySelector('[data-row-key="composio-c-gmail"]')), /Waiting for you to finish signing in/);
+ assert.match(text(host.querySelector('[data-row-key="app-gmail"]')), /Waiting for you to finish signing in/);
});
test('a refused key stays in the field with the error and its fix next to it', async () => {
@@ -253,7 +276,7 @@ test('no ghost for a word or typo match', async () => {
assert.equal(host.querySelector('[data-ghost]'), null);
});
-test('arrows move one highlight across groups with no wrap; ↑ from the first row clears it', async () => {
+test('arrows move one highlight across rows and open other ways, with no wrap; ↑ from the first row clears it', async () => {
const { api } = stubApi({ directory: async () => ({ entries: DIR, unavailable: false }) });
const host = await mount({ api });
await type(host, 'gm', 200);
@@ -265,91 +288,138 @@ test('arrows move one highlight across groups with no wrap; ↑ from the first r
assert.equal(el.getAttribute('aria-activedescendant'), first.id);
assert.equal(first.getAttribute('aria-selected'), 'true');
assert.ok(first.querySelector('[data-enter-keycap]'));
+ await key(el, 'Escape'); // drop the ghost, so → opens the other ways
+ await key(el, 'ArrowRight');
+ assert.equal(host.querySelector('[data-other-ways]').getAttribute('aria-expanded'), 'true', '→ opens the row’s other ways');
await key(el, 'ArrowDown');
- assert.equal(activeRow(host).dataset.rowKey, 'directory-io.example/gmail-tools', 'down crosses into the next group');
+ assert.equal(activeRow(host).dataset.rowKey, 'app-gmail~d-io.example/gmail-tools', 'down reaches the other way');
+ assert.equal(el.getAttribute('aria-activedescendant'), activeRow(host).id);
await key(el, 'ArrowDown');
- assert.equal(activeRow(host).dataset.rowKey, 'directory-io.example/gmail-tools', 'no wrap at the end');
- await key(el, 'ArrowUp');
+ assert.equal(activeRow(host).dataset.rowKey, 'app-gmail~d-io.example/gmail-tools', 'no wrap at the end');
+ await key(el, 'ArrowLeft');
+ assert.equal(host.querySelector('[data-row="other"]'), null, '← closes them');
+ assert.equal(activeRow(host).dataset.rowKey, 'app-gmail', 'and the highlight goes back to the row');
await key(el, 'ArrowUp');
assert.equal(activeRow(host), null);
assert.equal(el.getAttribute('aria-activedescendant'), null);
- for (const lb of host.querySelectorAll('[role="listbox"]')) assert.ok(document.getElementById(lb.getAttribute('aria-labelledby')));
+ for (const lb of host.querySelectorAll('[role="listbox"]')) assert.ok(lb.getAttribute('aria-label') || document.getElementById(lb.getAttribute('aria-labelledby')));
});
-test('Enter on a built-in tool adds it; on a directory row opens its form', async () => {
+test('Enter on a built-in tool adds it; an other way’s button runs that way', async () => {
const picked = [];
const { api } = stubApi({ directory: async () => ({ entries: DIR, unavailable: false }) });
const host = await mount({ api, onAddPreset: (p) => picked.push(['preset', p.id]), onAddDirectory: (e) => picked.push(['dir', e.registry_name]) });
await type(host, 'githu');
- assert.equal(activeRow(host).dataset.row, 'builtin');
+ assert.equal(activeRow(host).dataset.lead, 'b-github');
await key(input(host), 'Enter');
- await type(host, 'gmail tools', 200);
- const dirRow = host.querySelector('[data-row-key="directory-io.example/gmail-tools"]');
- dirRow.querySelector('[data-row-action]').dispatchEvent(new window.MouseEvent('click', { bubbles: true }));
- await settle();
+ await type(host, 'gm', 200);
+ await click(host.querySelector('[data-other-ways]'));
+ await click(host.querySelector('[data-row="other"] [data-row-action]'));
assert.deepEqual(picked, [['preset', 'github'], ['dir', 'io.example/gmail-tools']]);
});
-test('the public directory hides on 404 and says so when it can’t be reached', async () => {
+test('the highlight stays on its app when the public list lands', async () => {
+ let answer;
+ const late = new Promise((r) => (answer = r));
+ const { api } = stubApi({
+ apps: async () => ({ apps: [{ slug: 'elevenlabs', name: 'ElevenLabs', tools_count: 12 }], source: 'popular' }),
+ directory: () => late,
+ });
+ const host = await mount({ api });
+ await type(host, 'el', 200);
+ assert.equal(activeRow(host).dataset.rowKey, 'app-elevenlabs');
+ assert.equal(host.querySelector('[data-find-status]').dataset.findStatus, 'loading');
+ assert.equal(text(host.querySelector('[data-find-status]')), 'Searching more apps…');
+ answer({ entries: [{ registry_name: 'co.elastic/mcp', title: 'Elastic', description: '', publisher: { label: 'elastic.co', kind: 'domain' }, kind: 'remote', url: 'https://mcp.elastic.co', inputs: [] }], unavailable: false });
+ await settle();
+ assert.deepEqual(rowKeys(host).slice(0, 2), ['app-elastic', 'app-elevenlabs'], 'the official remote Elastic moves in above');
+ assert.equal(activeRow(host).dataset.rowKey, 'app-elevenlabs', 'Enter still runs ElevenLabs');
+ assert.equal(host.querySelector('[data-find-status]'), null);
+});
+
+test('the public list hides on 404 and says so when it can’t be reached', async () => {
const missing = stubApi();
let host = await mount({ api: missing.api });
await type(host, 'gm', 200);
- assert.equal(host.querySelector('[data-group="directory"]'), null, 'a server without the directory shows no group');
+ assert.equal(host.querySelector('[data-find-status]'), null, 'a server without the public list says nothing about it');
assert.ok(missing.calls.some((c) => c[0] === 'directory'));
for (const u of mounted) u();
const down = stubApi({ directory: async () => ({ entries: [], unavailable: true }) });
host = await mount({ api: down.api });
await type(host, 'gm', 200);
- const line = host.querySelector('[data-directory-state="down"]');
+ const line = host.querySelector('[data-find-status="down-directory"]');
assert.ok(line);
- assert.match(text(line), /Couldn’t reach the public directory\. The tools above still work\. Try again/);
+ assert.equal(line.getAttribute('role'), 'status');
+ assert.equal(text(line), 'Couldn’t reach the public list of tool servers, so only built-in tools and Composio apps are shown. Try again');
+ assert.deepEqual(rowKeys(host), ['app-gmail'], 'the other rows still show');
+});
+
+test('Composio unreachable, and both unreachable: one quiet line, Try again retries', async () => {
+ let fail = true;
+ const { api, calls } = stubApi({
+ list: async () => listOf(composio({ added: true, can_connect: true })),
+ apps: async () => {
+ calls.push(['apps']);
+ if (fail) throw new Error('timeout');
+ return { apps: APPS, source: 'all' };
+ },
+ });
+ let host = await mount({ api });
+ await type(host, 'git', 200);
+ assert.equal(text(host.querySelector('[data-find-status="down-composio"]')), 'Couldn’t reach Composio, so its apps aren’t in this list. Try again');
+ assert.ok(rowKeys(host).includes('app-github'), 'built-in tools still show');
+ fail = false;
+ await click(host.querySelector('[data-try-again]'));
+ assert.equal(host.querySelector('[data-find-status]'), null);
+ for (const u of mounted) u();
+
+ fail = true;
+ const both = stubApi({ list: api.list, apps: api.apps, directory: async () => ({ entries: [], unavailable: true }) });
+ host = await mount({ api: both.api });
+ await type(host, 'git', 200);
+ assert.equal(text(host.querySelector('[data-find-status="down-both"]')), 'Couldn’t reach Composio or the public list. Built-in tools still show. Try again');
+ assert.equal(host.querySelector('[data-find-nothing]'), null);
});
test('a directory entry that is a built-in tool is listed once, as built in', () => {
const notion = m.MCP_PRESETS.find((p) => p.id === 'notion');
- const groups = m.buildGroups({
- query: 'notion',
- composioApps: [],
- composioAdded: false,
+ const rows = m.mergeRows('notion', {
+ presets: m.MCP_PRESETS,
+ composio: [],
directory: [{ registry_name: 'com.notion/mcp', title: 'Notion', description: '', publisher: { label: 'notion.com' }, kind: 'remote', url: notion.form.url + '/', inputs: [] }],
connections: [],
- expanded: new Set(),
});
- assert.deepEqual(groups.map((g) => [g.key, g.rows.length]), [['builtin', 1], ['composio', 0], ['directory', 0]]);
+ assert.deepEqual(rows.map((r) => [r.key, r.lead.id, r.others.length]), [['app-notion', 'b-notion', 0]]);
});
test('a server named like a built-in tool at another address is not that tool', () => {
// QA (mcp-finder/qa.md): a directory "Stripe" at https://api.mcp.ai/p_stripe made the built-in Stripe read "Added".
- const groupsWith = (query, detail) =>
- m.buildGroups({
- query,
- composioApps: [],
- composioAdded: false,
- directory: null,
- connections: [{ id: 'mcp:s1', kind: 'mcp', name: 'Stripe', detail, status: 'ok', used_by: [] }],
- expanded: new Set(),
- });
- const stripeRow = (detail) => groupsWith('stripe', detail).find((g) => g.key === 'builtin').rows.find((r) => r.preset?.id === 'stripe');
- assert.equal(stripeRow('api.mcp.ai').added, null, 'another host is not the built-in Stripe');
- assert.equal(stripeRow('npx').added, null, 'a local server named Stripe is not the hosted one');
- assert.equal(stripeRow('mcp.stripe.com').added?.id, 'mcp:s1', 'the same host is');
- assert.equal(stripeRow('MCP.Stripe.com ').added?.id, 'mcp:s1', 'host case and spaces do not matter');
- assert.equal(stripeRow(null).added?.id, 'mcp:s1', 'no address: the name alone decides, as before');
- const connected = (detail) => groupsWith('', detail).find((g) => g.key === 'connected');
+ const connections = (detail) => [{ id: 'mcp:s1', kind: 'mcp', name: 'Stripe', detail, status: 'ok', used_by: [] }];
+ const stripe = (detail) =>
+ m.mergeRows('stripe', { presets: m.MCP_PRESETS, composio: [], directory: null, connections: connections(detail) }).flatMap((r) => [r.lead, ...r.others]).find((s) => s.id === 'b-stripe');
+ assert.equal(stripe('api.mcp.ai').added, null, 'another host is not the built-in Stripe');
+ assert.equal(stripe('npx').added, null, 'a local server named Stripe is not the hosted one');
+ assert.equal(stripe('mcp.stripe.com').added?.id, 'mcp:s1', 'the same host is');
+ assert.equal(stripe('MCP.Stripe.com ').added?.id, 'mcp:s1', 'host case and spaces do not matter');
+ assert.equal(stripe(null).added?.id, 'mcp:s1', 'no address: the name alone decides, as before');
+ const connected = (detail) => m.buildGroups({ composioApps: [], connections: connections(detail) }).find((g) => g.key === 'connected');
assert.equal(connected('api.mcp.ai'), undefined, 'not listed under Connected as the built-in Stripe');
assert.deepEqual(connected('mcp.stripe.com').rows.map((r) => r.preset?.id), ['stripe']);
});
-test('more than five in a group: a Show more row that is itself an option', () => {
- const composioApps = Array.from({ length: 8 }, (_, i) => ({ slug: `g${i}`, name: `Gapp ${i}`, description: '', tools: null, connected: false }));
- // No built-in tool matches "gapp", so Built in is left out and the group is found by its key.
- const c = m.buildGroups({ query: 'gapp', composioApps, composioAdded: true, directory: null, connections: [], expanded: new Set() }).find((g) => g.key === 'composio');
- assert.ok(c, 'a Through Composio group');
- assert.equal(c.rows.length, 6);
- assert.equal(c.rows[5].name, 'Show 3 more through Composio');
- const all = m.buildGroups({ query: 'gapp', composioApps, composioAdded: true, directory: null, connections: [], expanded: new Set(['composio']) }).find((g) => g.key === 'composio');
- assert.equal(all.rows.length, 8);
+test('more than eight apps: one "Show n more apps" option', async () => {
+ const many = Array.from({ length: 11 }, (_, i) => ({ slug: `gapp${i}`, name: `Gapp ${i}` }));
+ const { api } = stubApi({ apps: async () => ({ apps: many, source: 'popular' }) });
+ const host = await mount({ api });
+ await type(host, 'gapp');
+ assert.equal(rowKeys(host).length, 8);
+ const more = host.querySelector('[data-more="apps"]');
+ assert.equal(more.getAttribute('role'), 'option');
+ assert.equal(text(more), 'Show 3 more apps');
+ await click(more);
+ assert.equal(rowKeys(host).length, 11);
+ assert.equal(host.querySelector('[data-more]'), null);
});
test('nothing anywhere: the empty state offers Add by address', async () => {
@@ -384,9 +454,8 @@ test('a connected app offers Choose bots, and the live line counts suggestions',
});
const host = await mount({ api, onChooseBots: (t) => chosen.push(t) });
await type(host, 'gmail', 450);
- const row = host.querySelector('[data-row-key="composio-c-gmail"]');
- assert.match(text(row), /Connected.*Choose bots/);
- assert.match(text(row), /No bot can use it yet\./);
+ const row = host.querySelector('[data-row-key="app-gmail"]');
+ assert.match(text(row), /Through Composio.*Connected · No bot can use it yet\..*Choose bots/);
await key(input(host), 'Enter');
assert.deepEqual(chosen, [{ kind: 'composio', slug: 'gmail', name: 'Gmail' }]);
assert.match(text(host.querySelector('[data-find-live]')), /^\d+ suggestions?$/);
@@ -401,25 +470,23 @@ test('a maker description cut at 100 characters ends in an ellipsis; a whole one
for (const whole of [`${cut.slice(0, 99)}.`, `${cut.slice(0, 99)})`, `${cut.slice(0, 99)}\u2026`, 'Short and cut mid-wor']) assert.equal(m.markCutDescription(whole), whole);
});
-test('directory rows show the cut, keep the full text in title; a one-line row centres its name on the mark', async () => {
+test('a public-list row shows the cut and keeps the full text in title', async () => {
const description = CUT.padEnd(100, 'x');
- const entries = [{ registry_name: 'com.stripe/mcp', title: 'Stripe tools', description, publisher: { label: 'stripe.com' }, kind: 'remote', inputs: [] }];
+ const entries = [{ registry_name: 'io.github.zeb/zebra', title: 'Zebra payments', description, publisher: { label: 'github.com/zeb', kind: 'github' }, kind: 'remote', url: 'https://zebra.example', inputs: [] }];
const { api } = stubApi({
- apps: async () => ({ apps: [...APPS, { slug: 'zebratool', name: 'Stripe Zebra' }], source: 'popular' }),
+ apps: async () => ({ apps: [...APPS, { slug: 'zebratool', name: 'Zebra Tool' }], source: 'popular' }),
directory: async () => ({ entries, unavailable: false }),
});
const host = await mount({ api });
- await type(host, 'stripe', 200);
- const dir = host.querySelector('[data-row-key="directory-com.stripe/mcp"]');
+ await type(host, 'zebra', 200);
+ const dir = host.querySelector('[data-lead="d-io.github.zeb/zebra"]');
const p = dir.querySelector('p[title]');
assert.equal(p.getAttribute('title'), description);
- assert.equal(p.textContent, `${description}\u2026`);
- assert.ok(dir.querySelector('.items-start'), 'a two-line row stays top-aligned');
- const bare = host.querySelector('[data-row-key="composio-c-zebratool"]');
+ assert.equal(p.textContent, `${description}…`);
+ assert.match(text(dir), /Community\s*· github\.com\/zeb.*Signs in when you add it, if it asks/);
+ const bare = host.querySelector('[data-lead="c-zebratool"]');
assert.ok(bare, 'the bare Composio row is listed');
- assert.equal(bare.querySelector('p'), null);
- assert.ok(bare.querySelector('.items-center > [data-row-name], .items-center [data-row-name]'));
- assert.equal(bare.querySelector('.items-start'), null);
+ assert.equal(bare.querySelector('p[title]'), null, 'no empty description line');
});
test('installing from the directory sends the Name from the form', async () => {