π OpenHands: AI-Driven Development
feat: add plugins catalog service and usePluginsMarketplace hook (#1464)
Hiep Le712013bd31cc
diff --git a/.pr/evidence/README.md b/.pr/evidence/README.mddeleted file mode 100644index caf422e677..0000000000--- a/.pr/evidence/README.md+++ /dev/null@@ -1,66 +0,0 @@-# Live evidence for PR #1206 β Add command-k menu--- Repository: OpenHands/agent-canvas-- PR: https://github.com/OpenHands/agent-canvas/pull/1206-- Branch: `feature/command-k-menu`-- PR HEAD at time of run: `c9016f43d608f716ab4d799ea84c25c242b24844`--## What was run--The intended path was to pull and run the PR's published Docker image-`ghcr.io/openhands/agent-canvas:pr-1206` on a free localhost port and exercise-the new βK / Ctrl+K command menu in a real browser. That path was **blocked by-a permissions issue**: this delegated environment cannot reach the Docker-daemon (`permission denied while trying to connect to the docker API at-unix:///var/run/docker.sock`), the current user is not in the `docker` group,-and `sudo` requires an interactive password that is not available. See-`docker_run.txt` for the exact error and socket/group context.--Per the task's fallback guidance ("if the image is unavailable, fall back to-building from the branch with the repo's Dockerfile and report that"), and-since building the Docker image also requires Docker access, the PR branch was-instead built and served directly from source on a free port, which exercises-the exact code on `feature/command-k-menu`:--- `git checkout feature/command-k-menu` (clean tree)-- `npm ci` (1199 packages, Node v22.22.1, satisfies `engines.node >=22.12.0`)-- `npm run build:mock` (Vite production build of the React Router app in- `VITE_MOCK_API=true` mode, so the UI renders without a live backend)-- Served the static SPA build with `npx sirv-cli build/ --single --port 18080 --host 127.0.0.1`-- Health-checked with `curl -sS -o /dev/null -w '%{http_code}' http://127.0.0.1:18080/` β `200`--Port 18000 was occupied (by a host OpenHands agent-server process), so port-**18080** was used instead. Host ports 8000/8001 were avoided as required.--The command menu was then driven with a real Chromium browser via Playwright-(chromium-1228, shipped with the repo's dev dependencies). Screenshots and a-step-by-step log are under `screenshots/`. Real DOM observations (option text,-filtered counts, element presence) are recorded in `screenshots/run.log` and-narrated in `browser_steps.md`.--## Environment--- OS: Linux (Debian-based), user `gneubig`-- Node: v22.22.1 / npm 9.2.0-- Browser: Playwright Chromium (headless), viewport 1440Γ900-- Server: sirv-cli serving `build/` (mock API build) on `127.0.0.1:18080`-- Docker: **unavailable** in this environment (see `docker_run.txt`)--## PASS/FAIL per check--| Check | Result | Evidence |-|---|---|---|-| Container/app starts and serves HTTP 200 | PASS (served from source; Docker blocked) | `docker_run.txt`, `screenshots/run.log` |-| Command menu opens via Ctrl+K | PASS | `screenshots/02-menu-open.png`, run.log (`command-menu element count after Ctrl+K: 1`) |-| Menu shows grouped navigation / settings / local action commands | PASS | run.log lists 12 options across navigation, settings, and a local "Toggle sidebar" action; `screenshots/02-menu-open.png` |-| Filtering works (query narrows the list) | PASS | run.log: query "settings" narrowed 12 β 6 options; `screenshots/03-filtered.png` |-| Keyboard navigation works (ArrowDown/ArrowUp/Enter/Escape) | PASS | run.log: ArrowDown moved selection (aria-selected count 1), Enter closed the menu (action ran), Escape closed the menu; `screenshots/04-navigated.png`, `05-navigated-up.png`, `06-after-enter.png`, `07-after-escape.png` |-| Screenshots captured | PASS | 7 real PNGs (1440Γ900) under `screenshots/` |--## Notes / blockers--- **Docker blocked**: could not pull/run `ghcr.io/openhands/agent-canvas:pr-1206`- (no docker group membership, no passwordless sudo). Fallback: built and- served the PR branch from source on port 18080. This still exercises the- actual merged feature code on `feature/command-k-menu`.-- No source files were modified. Only files under `.pr/` were added.\ No newline at end of filediff --git a/.pr/evidence/browser_steps.md b/.pr/evidence/browser_steps.mddeleted file mode 100644index f804623f6e..0000000000--- a/.pr/evidence/browser_steps.md+++ /dev/null@@ -1,57 +0,0 @@-# Browser steps for PR #1206 command-k menu--Browser: Playwright Chromium (headless), viewport 1440Γ900, driven against-`http://127.0.0.1:18080/` (sirv-cli serving the PR branch's mock build).--All observations below are real DOM/Playwright readings captured during the-run (see `screenshots/run.log` for the raw timestamped log).--## Step 1 β Load the app-- Action: `page.goto("http://127.0.0.1:18080/", waitUntil="networkidle")`,- then waited ~2.5s for React hydration.-- Observed: page title = `OpenHands`. The landing screen rendered with the- sidebar visible. Screenshot: `screenshots/01-landing.png`.--## Step 2 β Open the command menu with Ctrl+K-- Action: `page.keyboard.press("Control+k")`, waited 800ms.-- Observed: `[data-testid="command-menu"]` element count went from 0 β 1.- The menu portal opened. Screenshot: `screenshots/02-menu-open.png`.-- Observed menu options (12 total), grouped:- - Navigation: New chat, Customize, Automations, MCP servers- - Settings: Settings, Agent settings, LLM profiles, Condenser settings,- Verification settings, Application settings, Secrets settings- - Local action: Toggle sidebar ( Collapse or expand the navigation rail β Run)- Each row shows title + description + a "Go"/"Run" affordance.--## Step 3 β Filter the list-- Action: focused `#command-menu-search` and typed `settings`.-- Observed: the list narrowed from 12 options to 6 (Settings, Agent settings,- Condenser settings, Verification settings, Application settings, Secrets- settings). Screenshot: `screenshots/03-filtered.png`.--## Step 4 β Keyboard navigation down-- Action: pressed `ArrowDown` twice from the search input.-- Observed: one option became `aria-selected="true"` (active highlight moved).- Screenshot: `screenshots/04-navigated.png`.--## Step 5 β Keyboard navigation up-- Action: pressed `ArrowUp` once.-- Observed: selection moved up the list.- Screenshot: `screenshots/05-navigated-up.png`.--## Step 6 β Enter triggers a command-- Action: with 6 filtered options present, pressed `Enter`.-- Observed: `[data-testid="command-menu"]` count went 1 β 0, i.e. the menu- closed because the highlighted command's action ran (navigation/callback).- Screenshot: `screenshots/06-after-enter.png`.--## Step 7 β Reopen with Ctrl+K, then close with Escape-- Action: pressed `Control+k` (menu reopened, count 0 β 1), then `Escape`.-- Observed: menu closed (count 1 β 0).- Screenshot: `screenshots/07-after-escape.png`.--## Summary-The command menu opened via Ctrl+K, displayed grouped navigation/settings/local-commands, filtered correctly by query, supported ArrowDown/ArrowUp/Enter/Escape-keyboard navigation, and Enter ran a command (closing the menu). All checks-passed live.\ No newline at end of filediff --git a/.pr/evidence/docker_run.txt b/.pr/evidence/docker_run.txtdeleted file mode 100644index af27d5c057..0000000000--- a/.pr/evidence/docker_run.txt+++ /dev/null@@ -1,30 +0,0 @@-=== docker pull attempt (pr-1206) ===-permission denied while trying to connect to the docker API at unix:///var/run/docker.sock-exit=1--=== docker socket / group context ===-srw-rw---- 1 root docker 0 Jun 14 07:50 /var/run/docker.sock-uid=1000(gneubig) gid=1000(gneubig) groups=1000(gneubig),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users),111(lpadmin),114(lxd)-docker:x:973:--=== fallback: built and served PR branch directly ===-node: v22.22.1-npm: 9.2.0-branch: feature/command-k-menu-HEAD: c9016f43d608f716ab4d799ea84c25c242b24844--=== start server (sirv-cli, mock build) ===-command: npx sirv-cli build/ --single --port 18080 --host 127.0.0.1-log:-[H[2J- Your application is ready~! π-- - Local: http://127.0.0.1:18080- - Network: http://10.0.0.150:18080-- LOGS-- [10:24:59] 200 β 2.51ms β /--=== health check ===-GET / -> http_code=200diff --git a/.pr/evidence/screenshots/01-landing.png b/.pr/evidence/screenshots/01-landing.pngdeleted file mode 100644index 47da27fae9..0000000000Binary files a/.pr/evidence/screenshots/01-landing.png and /dev/null differdiff --git a/.pr/evidence/screenshots/02-menu-open.png b/.pr/evidence/screenshots/02-menu-open.pngdeleted file mode 100644index 5802ffc709..0000000000Binary files a/.pr/evidence/screenshots/02-menu-open.png and /dev/null differdiff --git a/.pr/evidence/screenshots/03-filtered.png b/.pr/evidence/screenshots/03-filtered.pngdeleted file mode 100644index 486a955bc9..0000000000Binary files a/.pr/evidence/screenshots/03-filtered.png and /dev/null differdiff --git a/.pr/evidence/screenshots/04-navigated.png b/.pr/evidence/screenshots/04-navigated.pngdeleted file mode 100644index 26c5f0fe9a..0000000000Binary files a/.pr/evidence/screenshots/04-navigated.png and /dev/null differdiff --git a/.pr/evidence/screenshots/05-navigated-up.png b/.pr/evidence/screenshots/05-navigated-up.pngdeleted file mode 100644index b181ddaefa..0000000000Binary files a/.pr/evidence/screenshots/05-navigated-up.png and /dev/null differdiff --git a/.pr/evidence/screenshots/06-after-enter.png b/.pr/evidence/screenshots/06-after-enter.pngdeleted file mode 100644index c2b6dfb479..0000000000Binary files a/.pr/evidence/screenshots/06-after-enter.png and /dev/null differdiff --git a/.pr/evidence/screenshots/07-after-escape.png b/.pr/evidence/screenshots/07-after-escape.pngdeleted file mode 100644index c2b6dfb479..0000000000Binary files a/.pr/evidence/screenshots/07-after-escape.png and /dev/null differdiff --git a/.pr/evidence/screenshots/run.log b/.pr/evidence/screenshots/run.logdeleted file mode 100644index 0569b1234c..0000000000--- a/.pr/evidence/screenshots/run.log+++ /dev/null@@ -1,20 +0,0 @@-[2026-06-26T14:26:20.264Z] navigating to http://127.0.0.1:18080/-[2026-06-26T14:26:24.384Z] page title: OpenHands-[2026-06-26T14:26:24.426Z] screenshot saved: .pr/evidence/screenshots/01-landing.png-[2026-06-26T14:26:24.426Z] pressing Ctrl+K to open command menu-[2026-06-26T14:26:25.256Z] command-menu element count after Ctrl+K: 1-[2026-06-26T14:26:25.326Z] screenshot saved: .pr/evidence/screenshots/02-menu-open.png-[2026-06-26T14:26:25.340Z] menu options visible: ["New chatStart a fresh OpenHands conversation.Go","CustomizeBrowse skills, plugins, and integrations.Go","AutomationsReview scheduled and webhook automations.Go","MCP serversManage Model Context Protocol integrations.Go","SettingsOpen the settings overview.Go","Agent settingsConfigure agent type and delegation.Go","LLM profilesManage models, providers, and API keys.Go","Condenser settingsTune context condensation behavior.Go","Verification settingsAdjust risk and confirmation controls.Go","Application settingsChange app language, theme, and preferences.Go","Secrets settingsCreate and edit saved runtime secrets.Go","Toggle sidebarCollapse or expand the navigation rail.Run"]-[2026-06-26T14:26:25.861Z] filtered options for 'settings': ["SettingsOpen the settings overview.Go","Agent settingsConfigure agent type and delegation.Go","Condenser settingsTune context condensation behavior.Go","Verification settingsAdjust risk and confirmation controls.Go","Application settingsChange app language, theme, and preferences.Go","Secrets settingsCreate and edit saved runtime secrets.Go"]-[2026-06-26T14:26:25.926Z] screenshot saved: .pr/evidence/screenshots/03-filtered.png-[2026-06-26T26:26.345Z] active element id after 2x ArrowDown (input focused): command-menu-search-[2026-06-26T14:26:26.347Z] active/aria-selected option count: 1-[2026-06-26T14:26:26.394Z] screenshot saved: .pr/evidence/screenshots/04-navigated.png-[2026-06-26T14:26:26.660Z] screenshot saved: .pr/evidence/screenshots/05-navigated-up.png-[2026-06-26T14:26:26.662Z] filtered option count before Enter: 6-[2026-06-26T14:26:27.473Z] command-menu count after Enter: 0 (0 = closed = action ran)-[2026-06-26T14:26:27.509Z] screenshot saved: .pr/evidence/screenshots/06-after-enter.png-[2026-06-26T14:26:28.118Z] command-menu count after reopen Ctrl+K: 1-[2026-06-26T14:26:28.524Z] command-menu count after Escape: 0-[2026-06-26T14:26:28.556Z] screenshot saved: .pr/evidence/screenshots/07-after-escape.png-[2026-06-26T14:26:28.576Z] done\ No newline at end of filediff --git a/src/api/plugins-service.test.ts b/src/api/plugins-service.test.tsnew file mode 100644index 0000000000..fbc150155b--- /dev/null+++ b/src/api/plugins-service.test.ts@@ -0,0 +1,72 @@+import { beforeEach, describe, expect, it, vi } from "vitest";+import { PluginsClient } from "@openhands/typescript-client/clients";+import {+ setActiveSelection,+ setRegisteredBackends,+} from "./backend-registry/active-store";+import PluginsService from "./plugins-service";++vi.mock("@openhands/typescript-client/clients", () => ({+ PluginsClient: vi.fn(),+}));++const getPluginsMarketplace = vi.fn();+const close = vi.fn();++function useBackend(kind: "local" | "cloud"): void {+ setRegisteredBackends([+ {+ id: kind,+ name: kind,+ host: "http://127.0.0.1:8001",+ apiKey: "session-key",+ kind,+ },+ ]);+ setActiveSelection({ backendId: kind, orgId: null });+}++describe("PluginsService.getPluginsMarketplace", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ vi.mocked(PluginsClient).mockImplementation(function MockPluginsClient() {+ return { getPluginsMarketplace, close } as unknown as PluginsClient;+ } as unknown as typeof PluginsClient);+ });++ it("returns the catalog from the local agent-server", async () => {+ useBackend("local");+ const plugin = {+ name: "city-weather",+ description: "Weather plugin",+ source: "github:OpenHands/extensions",+ ref: null,+ repo_path: "plugins/city-weather",+ installed: false,+ };+ getPluginsMarketplace.mockResolvedValue({ plugins: [plugin] });++ const result = await PluginsService.getPluginsMarketplace();++ expect(result).toEqual([plugin]);+ expect(getPluginsMarketplace).toHaveBeenCalledTimes(1);+ });++ it("returns an empty catalog on a cloud backend without calling the client", async () => {+ useBackend("cloud");++ const result = await PluginsService.getPluginsMarketplace();++ expect(result).toEqual([]);+ expect(PluginsClient).not.toHaveBeenCalled();+ });++ it("returns an empty catalog when the local request fails", async () => {+ useBackend("local");+ getPluginsMarketplace.mockRejectedValue(new Error("unreachable"));++ const result = await PluginsService.getPluginsMarketplace();++ expect(result).toEqual([]);+ });+});diff --git a/src/api/plugins-service.ts b/src/api/plugins-service.tsnew file mode 100644index 0000000000..daadb7ef39--- /dev/null+++ b/src/api/plugins-service.ts@@ -0,0 +1,46 @@+import { PluginsClient } from "@openhands/typescript-client/clients";+import { getActiveBackend } from "./backend-registry/active-store";+import { getAgentServerClientOptions } from "./agent-server-client-options";++/**+ * A plugin in the dynamic marketplace catalog, with attachable coordinates and+ * install state. Matches the agent-server `MarketplacePluginInfo` / the+ * typescript-client `MarketplacePlugin`.+ */+export interface MarketplacePlugin {+ name: string;+ description: string | null;+ source: string;+ ref?: string | null;+ repo_path?: string | null;+ installed: boolean;+}++class PluginsService {+ /**+ * Fetch the dynamic plugins marketplace catalog.+ *+ * Local backend only for now: the catalog is fetched at run time from the+ * agent-server via the typed client (no bundled catalog, so the list stays+ * dynamic). On a cloud backend an empty catalog is returned β there is no+ * cloud plugins-marketplace endpoint yet (tracked as a follow-up ticket).+ */+ static async getPluginsMarketplace(): Promise<MarketplacePlugin[]> {+ if (getActiveBackend().backend.kind === "cloud") {+ return [];+ }++ try {+ const response = await new PluginsClient(+ getAgentServerClientOptions(),+ ).getPluginsMarketplace();+ return (response.plugins ?? []) as MarketplacePlugin[];+ } catch {+ // Agent-server may not support the plugins endpoint or be unreachable;+ // surface an empty catalog rather than throwing.+ return [];+ }+ }+}++export default PluginsService;diff --git a/src/hooks/query/use-plugins-marketplace.ts b/src/hooks/query/use-plugins-marketplace.tsnew file mode 100644index 0000000000..de67f8a2a6--- /dev/null+++ b/src/hooks/query/use-plugins-marketplace.ts@@ -0,0 +1,15 @@+import { useQuery } from "@tanstack/react-query";+import PluginsService, { type MarketplacePlugin } from "#/api/plugins-service";++/**+ * Query hook for the dynamic plugins marketplace catalog. The catalog is global+ * (not project-scoped), and currently local-backend only β a cloud backend+ * yields an empty list. Mirrors `useSkills`.+ */+export const usePluginsMarketplace = () =>+ useQuery<MarketplacePlugin[]>({+ queryKey: ["plugins-marketplace"],+ queryFn: () => PluginsService.getPluginsMarketplace(),+ staleTime: 1000 * 60 * 10, // 10 minutes β catalog rarely changes+ refetchOnWindowFocus: false,+ });