-
Notifications
You must be signed in to change notification settings - Fork 312
feat: add browseable ACP agent catalog to settings #987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ital0
wants to merge
4
commits into
main
Choose a base branch
from
italomenezes/thu-600-acp-marketplace-browse-catalog-bridge-agent-link-outs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9317fd0
feat: add ACP registry data model, parser, and live-fetch hook
ital0 e5279a3
feat: add browseable ACP agent catalog UI to settings
ital0 e60efb0
fix: clear button now resets agent catalog search
ital0 d7647ee
Merge branch 'main' into italomenezes/thu-600-acp-marketplace-browse-…
ital0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import { test, expect } from '@playwright/test' | ||
| import { collectPageErrors, loginViaOidc } from './helpers' | ||
|
|
||
| test.describe('Agents catalog', () => { | ||
| test('browse, link out, search, and empty state work without page errors', async ({ page }) => { | ||
| const errors = collectPageErrors(page) | ||
| await loginViaOidc(page) | ||
|
|
||
| await page.goto('/settings/agents') | ||
|
|
||
| // The bundled ACP registry snapshot renders immediately — no live network needed. | ||
| // Assert a few known registry cards by id. | ||
| const geminiCard = page.getByTestId('agent-catalog-card-gemini') | ||
| await expect(geminiCard).toBeVisible({ timeout: 10_000 }) | ||
| await expect(page.getByTestId('agent-catalog-card-claude-acp')).toBeVisible() | ||
| await expect(page.getByTestId('agent-catalog-card-goose')).toBeVisible() | ||
|
|
||
| // At least one link-out is present on a card. | ||
| await expect(geminiCard.getByRole('link').first()).toBeVisible() | ||
|
|
||
| // Search filters the grid: 'gemini' keeps the gemini card, drops claude-acp. | ||
| const search = page.getByPlaceholder('Search agents') | ||
| await search.fill('gemini') | ||
| await expect(page.getByTestId('agent-catalog-card-gemini')).toBeVisible() | ||
| await expect(page.getByTestId('agent-catalog-card-claude-acp')).toHaveCount(0) | ||
|
|
||
| // The clear (X) button resets the query and restores the filtered-out card. | ||
| await page.getByRole('button', { name: /clear search/i }).click() | ||
| await expect(search).toHaveValue('') | ||
| await expect(page.getByTestId('agent-catalog-card-claude-acp')).toBeVisible() | ||
|
|
||
| // A guaranteed-no-match query shows the empty state. | ||
| await search.fill('zzzqqqxx') | ||
| await expect(page.getByText(/no agents found/i)).toBeVisible() | ||
|
|
||
| // The background CDN fetch must not surface page errors even if it fails — | ||
| // the snapshot fallback covers it. | ||
| expect(errors).toEqual([]) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import { Code2, ExternalLink, Terminal } from 'lucide-react' | ||
| import { useState } from 'react' | ||
| import { Button } from '@/components/ui/button' | ||
| import { Card, CardContent, CardHeader } from '@/components/ui/card' | ||
| import { distributionLabel, primaryDistributionKind } from '@/lib/agent-registry-filter' | ||
| import type { RegistryEntry } from '@/types/registry' | ||
|
|
||
| type AgentCatalogCardProps = { | ||
| entry: RegistryEntry | ||
| } | ||
|
|
||
| /** A read-only catalogue card for a "bridge" agent: shows the agent's identity | ||
| * and metadata and links out to its website and source. There's no install | ||
| * action — these CLIs run on the user's own machine, not inside Thunderbolt. */ | ||
| export const AgentCatalogCard = ({ entry }: AgentCatalogCardProps) => { | ||
| const [iconFailed, setIconFailed] = useState(false) | ||
|
|
||
| const distributionKind = primaryDistributionKind(entry) | ||
| const websiteUrl = entry.website ?? entry.repository | ||
| const sourceUrl = entry.repository && entry.repository !== websiteUrl ? entry.repository : null | ||
| const showIcon = entry.icon && !iconFailed | ||
| const metadata = [entry.version ? `v${entry.version}` : null, entry.authors.join(', ') || null, entry.license || null] | ||
| .filter(Boolean) | ||
| .join(' · ') | ||
|
|
||
| return ( | ||
| <Card data-testid={`agent-catalog-card-${entry.id}`} className="border border-border gap-3 py-4"> | ||
| <CardHeader className="px-4"> | ||
| <div className="flex items-center gap-3 min-w-0"> | ||
| {showIcon ? ( | ||
| <img | ||
| src={entry.icon} | ||
| alt="" | ||
| className="size-8 rounded-md shrink-0" | ||
| draggable={false} | ||
| onError={() => setIconFailed(true)} | ||
| /> | ||
| ) : ( | ||
| <Terminal className="size-8 text-muted-foreground shrink-0" aria-hidden="true" /> | ||
| )} | ||
| <div className="flex items-center gap-2 min-w-0"> | ||
| <span className="font-medium truncate">{entry.name}</span> | ||
| {distributionKind && ( | ||
| <span className="text-[length:var(--font-size-xs)] text-muted-foreground rounded-md border border-border px-2 py-0.5 shrink-0"> | ||
| {distributionLabel(distributionKind)} | ||
| </span> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </CardHeader> | ||
| <CardContent className="px-4 flex flex-col gap-3"> | ||
| <p className="text-[length:var(--font-size-sm)] text-muted-foreground">{entry.description}</p> | ||
| <p className="text-[length:var(--font-size-xs)] text-muted-foreground">{metadata}</p> | ||
| <div className="flex flex-wrap gap-2"> | ||
| {websiteUrl && ( | ||
| <Button asChild variant="outline" size="sm"> | ||
| <a href={websiteUrl} target="_blank" rel="noopener noreferrer"> | ||
| <ExternalLink /> | ||
| Website | ||
| </a> | ||
| </Button> | ||
| )} | ||
| {sourceUrl && ( | ||
| <Button asChild variant="outline" size="sm"> | ||
| <a href={sourceUrl} target="_blank" rel="noopener noreferrer"> | ||
| <Code2 /> | ||
| Source | ||
| </a> | ||
| </Button> | ||
| )} | ||
| </div> | ||
| </CardContent> | ||
| </Card> | ||
| ) | ||
| } | ||
147 changes: 147 additions & 0 deletions
147
src/components/settings/agents/agent-catalog-view.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import '@testing-library/jest-dom' | ||
| import { cleanup, fireEvent, render, screen } from '@testing-library/react' | ||
| import { afterEach, describe, expect, it } from 'bun:test' | ||
| import type { RegistryEntry } from '@/types/registry' | ||
| import { AgentCatalogView } from './agent-catalog-view' | ||
|
|
||
| const entry = (overrides: Partial<RegistryEntry> & Pick<RegistryEntry, 'id' | 'name'>): RegistryEntry => ({ | ||
| version: '1.2.3', | ||
| description: `${overrides.name} description`, | ||
| authors: ['Author Inc.'], | ||
| license: 'Apache-2.0', | ||
| website: `https://example.com/${overrides.id}`, | ||
| repository: `https://github.com/example/${overrides.id}`, | ||
| distribution: { npx: { package: `${overrides.id}@1.2.3` } }, | ||
| ...overrides, | ||
| }) | ||
|
|
||
| const fixtures: ReadonlyArray<RegistryEntry> = [ | ||
| entry({ id: 'goose', name: 'goose', description: 'Extensible agent from Block', icon: 'https://cdn/goose.svg' }), | ||
| entry({ id: 'gemini', name: 'Gemini CLI', description: 'Google terminal agent' }), | ||
| ] | ||
|
|
||
| const renderCatalog = (entries: ReadonlyArray<RegistryEntry> = fixtures) => | ||
| render(<AgentCatalogView entries={entries} />) | ||
|
|
||
| describe('AgentCatalogView', () => { | ||
| afterEach(cleanup) | ||
|
|
||
| it('renders one card per entry', () => { | ||
| renderCatalog() | ||
| expect(screen.getByTestId('agent-catalog-card-goose')).toBeInTheDocument() | ||
| expect(screen.getByTestId('agent-catalog-card-gemini')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders a distribution badge per card', () => { | ||
| renderCatalog() | ||
| expect(screen.getAllByText('Node.js')).toHaveLength(fixtures.length) | ||
| }) | ||
|
|
||
| it('renders Website and Source link-outs with correct attributes', () => { | ||
| renderCatalog([entry({ id: 'goose', name: 'goose' })]) | ||
| const card = screen.getByTestId('agent-catalog-card-goose') | ||
| const links = card.querySelectorAll('a') | ||
| expect(links).toHaveLength(2) | ||
|
|
||
| const website = card.querySelector('a[href="https://example.com/goose"]') | ||
| const source = card.querySelector('a[href="https://github.com/example/goose"]') | ||
| expect(website).toBeInTheDocument() | ||
| expect(source).toBeInTheDocument() | ||
|
|
||
| for (const link of [website, source]) { | ||
| expect(link).toHaveAttribute('target', '_blank') | ||
| expect(link?.getAttribute('rel')).toContain('noopener') | ||
| expect(link?.getAttribute('rel')).toContain('noreferrer') | ||
| } | ||
| }) | ||
|
|
||
| it('falls back the Website link to the repository when no website is set, and hides the duplicate Source link', () => { | ||
| renderCatalog([entry({ id: 'claude-acp', name: 'Claude Agent', website: undefined })]) | ||
| const card = screen.getByTestId('agent-catalog-card-claude-acp') | ||
| const links = card.querySelectorAll('a') | ||
| expect(links).toHaveLength(1) | ||
| expect(card.querySelector('a[href="https://github.com/example/claude-acp"]')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('filters by search query', () => { | ||
| renderCatalog() | ||
| fireEvent.change(screen.getByPlaceholderText('Search agents'), { target: { value: 'gemini' } }) | ||
|
|
||
| expect(screen.getByTestId('agent-catalog-card-gemini')).toBeInTheDocument() | ||
| expect(screen.queryByTestId('agent-catalog-card-goose')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('clears the query and restores every card when the clear button is clicked', () => { | ||
| renderCatalog() | ||
| const input = screen.getByPlaceholderText('Search agents') as HTMLInputElement | ||
|
|
||
| fireEvent.change(input, { target: { value: 'gemini' } }) | ||
| expect(input.value).toBe('gemini') | ||
| expect(screen.queryByTestId('agent-catalog-card-goose')).not.toBeInTheDocument() | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: /clear search/i })) | ||
|
|
||
| expect(input.value).toBe('') | ||
| expect(screen.getByTestId('agent-catalog-card-gemini')).toBeInTheDocument() | ||
| expect(screen.getByTestId('agent-catalog-card-goose')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('shows a no-results message when nothing matches', () => { | ||
| renderCatalog() | ||
| fireEvent.change(screen.getByPlaceholderText('Search agents'), { target: { value: 'zzzqqqxx' } }) | ||
|
|
||
| expect(screen.getByText(/no agents found/i)).toBeInTheDocument() | ||
| expect(screen.queryByTestId('agent-catalog-card-goose')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders an icon image when icon is set', () => { | ||
| renderCatalog([entry({ id: 'goose', name: 'goose', icon: 'https://cdn/goose.svg' })]) | ||
| const header = screen.getByTestId('agent-catalog-card-goose').querySelector('[data-slot="card-header"]') | ||
| const img = header?.querySelector('img') | ||
| expect(img).toBeInTheDocument() | ||
| expect(img).toHaveAttribute('src', 'https://cdn/goose.svg') | ||
| // The Terminal fallback (an svg) must not render while the icon image loads cleanly. | ||
| expect(header?.querySelector('svg')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('falls back to the Terminal icon when the image fails to load', () => { | ||
| renderCatalog([entry({ id: 'goose', name: 'goose', icon: 'https://cdn/broken.svg' })]) | ||
| const header = screen.getByTestId('agent-catalog-card-goose').querySelector('[data-slot="card-header"]') | ||
| const img = header?.querySelector('img') | ||
| expect(img).toBeInTheDocument() | ||
|
|
||
| fireEvent.error(img as HTMLImageElement) | ||
|
|
||
| expect(header?.querySelector('img')).not.toBeInTheDocument() | ||
| expect(header?.querySelector('svg')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders the Terminal icon when no icon is set', () => { | ||
| renderCatalog([entry({ id: 'goose', name: 'goose', icon: undefined })]) | ||
| const header = screen.getByTestId('agent-catalog-card-goose').querySelector('[data-slot="card-header"]') | ||
| expect(header?.querySelector('img')).not.toBeInTheDocument() | ||
| expect(header?.querySelector('svg')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('exposes only link-out actions per card, never an install action', () => { | ||
| renderCatalog([entry({ id: 'goose', name: 'goose' })]) | ||
| const card = screen.getByTestId('agent-catalog-card-goose') | ||
|
|
||
| expect(card.querySelectorAll('a').length).toBeGreaterThan(0) | ||
| expect(card.querySelector('button')).not.toBeInTheDocument() | ||
| expect(card.querySelector('button[type="submit"]')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('keeps all cards visible for a whitespace-only query', () => { | ||
| renderCatalog() | ||
| fireEvent.change(screen.getByPlaceholderText('Search agents'), { target: { value: ' ' } }) | ||
|
|
||
| expect(screen.queryByText(/no agents found/i)).not.toBeInTheDocument() | ||
| expect(screen.getByTestId('agent-catalog-card-goose')).toBeInTheDocument() | ||
| expect(screen.getByTestId('agent-catalog-card-gemini')).toBeInTheDocument() | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import { SearchInput } from '@/components/ui/search-input' | ||
| import { useAgentRegistrySearch } from '@/hooks/use-agent-registry-search' | ||
| import type { RegistryEntry } from '@/types/registry' | ||
| import { useRef } from 'react' | ||
| import { AgentCatalogCard } from './agent-catalog-card' | ||
|
|
||
| type AgentCatalogViewProps = { | ||
| /** The agents to render. Always non-empty in production (the snapshot seeds it). */ | ||
| entries: ReadonlyArray<RegistryEntry> | ||
| } | ||
|
|
||
| /** Presentational catalogue: search + grid of read-only agent cards. Takes its | ||
| * entries as a prop and owns no data fetching, so it renders purely from inputs | ||
| * and is unit-testable without react-query. */ | ||
| export const AgentCatalogView = ({ entries }: AgentCatalogViewProps) => { | ||
| const { query, setQuery, results, isEmpty } = useAgentRegistrySearch(entries) | ||
| const showEmptyState = isEmpty && query.trim().length > 0 | ||
| const searchRef = useRef<HTMLInputElement>(null) | ||
|
|
||
| return ( | ||
| <section className="flex flex-col gap-3"> | ||
| <h2 className="text-lg font-medium">Browse agents</h2> | ||
| <SearchInput | ||
| ref={searchRef} | ||
| showIcon | ||
| placeholder="Search agents" | ||
| value={query} | ||
| onChange={(event) => setQuery(event.target.value)} | ||
| /> | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| {showEmptyState ? ( | ||
| <p className="text-[length:var(--font-size-sm)] text-muted-foreground py-6 text-center">No agents found</p> | ||
| ) : ( | ||
| <div className="grid gap-3 sm:grid-cols-2"> | ||
| {results.map((entry) => ( | ||
| <AgentCatalogCard key={entry.id} entry={entry} /> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </section> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import { useAgentRegistry } from '@/hooks/use-agent-registry' | ||
| import { AgentCatalogView } from './agent-catalog-view' | ||
|
|
||
| /** Container for the bridgeable-agent catalogue: reads the live registry hook | ||
| * (snapshot-seeded, so always non-empty) and hands the entries to the | ||
| * presentational view. */ | ||
| export const AgentCatalog = () => { | ||
| const entries = useAgentRegistry() | ||
| return <AgentCatalogView entries={entries} /> | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.