Skip to content

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

Say the plugin list could not be read on a connector's own pages (#664)

kevin71d6a61fa982
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5b7a9a1b..0dfdac9c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -42,6 +42,14 @@ the dialog as before. It appears only when something is hidden. Hiding still cha
anyone else, and nothing on the server changed: the screen reads the `GET /api/agents?hidden=true`
list the server already served.
+### A connector's own pages say when the plugin list could not be read
+
+When `GET /api/plugins` failed, a connector's admin page said "Not a plugin", a tool's page said
+"This deployment has not enabled that connector.", and a person's connected-account page said "This
+is not a service you connect for yourself.", each about a connector that may be added and granted
+right now. They now say the list could not be loaded, as the per-Bot grant page beside them already
+did. A list that arrived without the connector still reads as before.
+
### Boundaries says when the policy could not be read
When `GET /api/computers/policy` failed, the Boundaries screen showed its title over nothing, for as
diff --git a/app/src/routes/_authed/admin/plugins/$key.tsx b/app/src/routes/_authed/admin/plugins/$key.tsx
index 2c0e4d1f..bac19755 100644
--- a/app/src/routes/_authed/admin/plugins/$key.tsx
+++ b/app/src/routes/_authed/admin/plugins/$key.tsx
@@ -415,6 +415,26 @@ function RouteComponent() {
if (plugins.isPending || connections.isPending) {
return <PageShell title="Plugin">{null}</PageShell>;
}
+ /*
+ * Gated on the plugin list having ARRIVED, the guard the per-Bot grant screen already keeps
+ * (`plugins.data && !server`). `isPending` goes false on a failed fetch exactly as it does on a
+ * successful one, so `!(entry || server)` alone cannot tell "this deployment has no plugin by
+ * that name" apart from "the plugin list could not be read", and a request that never came back
+ * is no evidence for the first. Nothing on this page survives the failure: the title, the tools
+ * and the grants are all that one response.
+ */
+ if (!plugins.data) {
+ return (
+ <PageShell
+ backButton={{ label: "Plugins", linkProps: { to: "/admin/plugins" } }}
+ title="Plugins"
+ >
+ <p className="mt-12 text-destructive text-sm" role="alert">
+ Plugins could not be loaded.
+ </p>
+ </PageShell>
+ );
+ }
if (!(entry || server)) {
return (
<PageShell
diff --git a/app/src/routes/_authed/admin/plugins/$key_.tools.$tool.tsx b/app/src/routes/_authed/admin/plugins/$key_.tools.$tool.tsx
index 006413b6..9dcb0e20 100644
--- a/app/src/routes/_authed/admin/plugins/$key_.tools.$tool.tsx
+++ b/app/src/routes/_authed/admin/plugins/$key_.tools.$tool.tsx
@@ -83,6 +83,22 @@ function RouteComponent() {
return <PageShell title="Tool">{null}</PageShell>;
}
+ /*
+ * A plugin list that could not be read is said as that, not as a connector that is not enabled:
+ * `isPending` goes false on a failed fetch too, and the sentence below is a claim about this
+ * deployment that a request that never came back is no evidence for. The per-Bot grant screen
+ * keeps the same guard.
+ */
+ if (!plugins.data) {
+ return (
+ <PageShell backButton={back} title={toolName}>
+ <p className="mt-12 text-destructive text-sm" role="alert">
+ Plugins could not be loaded.
+ </p>
+ </PageShell>
+ );
+ }
+
if (!tool) {
return (
<PageShell
diff --git a/app/src/routes/_authed/settings/connected-accounts/$key.tsx b/app/src/routes/_authed/settings/connected-accounts/$key.tsx
index db6838ee..66a5e661 100644
--- a/app/src/routes/_authed/settings/connected-accounts/$key.tsx
+++ b/app/src/routes/_authed/settings/connected-accounts/$key.tsx
@@ -170,6 +170,23 @@ function RouteComponent() {
);
}
+ /*
+ * The same for the plugin list. Every branch below decides what this connector is from it, and
+ * without it they concluded there is none: "This is not a service you connect for yourself",
+ * about a connector this person may hold right now.
+ */
+ if (!plugins.data) {
+ return (
+ <PageShell backButton={back} title={key}>
+ <p className="mt-12 text-destructive text-sm" role="alert">
+ This connector could not be loaded, so nothing about it is shown here
+ rather than something that may be wrong. Reload the page, and tell an
+ administrator if it persists.
+ </p>
+ </PageShell>
+ );
+ }
+
/*
* A brokered app, before the catalogue is consulted at all.
*
diff --git a/app/tests/plugin-read-failure.test.tsx b/app/tests/plugin-read-failure.test.tsx
new file mode 100644
index 00000000..4e88d3ca
--- /dev/null
+++ b/app/tests/plugin-read-failure.test.tsx
@@ -0,0 +1,274 @@
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ expect,
+ test,
+} from "bun:test";
+import { GlobalRegistrator } from "@happy-dom/global-registrator";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import {
+ createMemoryHistory,
+ createRootRoute,
+ createRoute,
+ createRouter,
+ Outlet,
+ RouterProvider,
+} from "@tanstack/react-router";
+import { cleanup, render, waitFor } from "@testing-library/react";
+import { type PluginsPage, pluginKeys } from "@/lib/plugins/queries";
+import { Route as AdminAppRoute } from "@/routes/_authed/admin/plugins/$key";
+import { Route as AdminToolRoute } from "@/routes/_authed/admin/plugins/$key_.tools.$tool";
+import { Route as ConnectedAccountRoute } from "@/routes/_authed/settings/connected-accounts/$key";
+
+/**
+ * A connector's own pages, when `GET /api/plugins` fails.
+ *
+ * Each of them decides whether the connector exists from `plugins.data`, and `isPending` goes false
+ * on a failed fetch exactly as it does on a successful one, so a request that never came back fell
+ * through to "there is no such connector" — about a connector that may be added and granted right
+ * now. The per-Bot grant screen beside them already tells the two apart (`plugins.data && !server`,
+ * see `bot-app-grants-screen.test.tsx`); these are the three pages that did not.
+ *
+ * Only the plugins read fails here. The connections and roster reads answer, so each case is about
+ * that one read and nothing else on the page.
+ *
+ * THE HARNESS IS THIS REPOSITORY'S, as in `bot-app-grants-screen.test.tsx` and
+ * `brokered-account-row.test.tsx`: `GlobalRegistrator` in `beforeAll`/`afterAll`, `cleanup` in
+ * `afterEach`, queries off `render()`'s own return, a `QueryClient` with `retry: false`, and each
+ * exported `Route` singleton captured and restored around its `.update()`.
+ */
+
+beforeAll(() => GlobalRegistrator.register());
+afterEach(cleanup);
+afterAll(() => GlobalRegistrator.unregister());
+
+const APP_KEY = "slack";
+const TOOL_NAME = "list_channels";
+const originalFetch = global.fetch;
+
+beforeEach(() => {
+ global.fetch = Object.assign(
+ async (input: Parameters<typeof fetch>[0]) => {
+ const path = String(input).split("?")[0];
+ const json = (body: unknown) =>
+ new Response(JSON.stringify(body), {
+ headers: { "content-type": "application/json" },
+ });
+ if (path === "/api/plugins/connections") return json({ connections: [] });
+ if (path === "/api/agents") return json({ agents: [] });
+ // The one read under test: a 500 with no body, the shape a broken server sends.
+ return new Response(null, { status: 500 });
+ },
+ { preconnect: originalFetch.preconnect },
+ );
+});
+
+afterEach(() => {
+ global.fetch = originalFetch;
+});
+
+/** A client the failing query settles on in one attempt, so no test waits on a retry. */
+function failingQueryClient() {
+ return new QueryClient({ defaultOptions: { queries: { retry: false } } });
+}
+
+/** A client already holding a plugins page that genuinely lacks this connector. */
+function answeredWithout() {
+ const client = failingQueryClient();
+ const page: PluginsPage = {
+ catalogue: [],
+ servers: [],
+ skills: [],
+ botsMayCallBack: true,
+ redirectUri: null,
+ composioConfigured: false,
+ };
+ client.setQueryData(pluginKeys.page(), page);
+ return client;
+}
+
+function captureRouteState(route: object): Record<string, unknown> {
+ return { ...route, options: { ...(route as { options: object }).options } };
+}
+
+function restoreRouteState(
+ route: object,
+ snapshot: Record<string, unknown>,
+): void {
+ for (const key of Object.keys(route)) {
+ if (!(key in snapshot)) {
+ delete (route as Record<string, unknown>)[key];
+ }
+ }
+ Object.assign(route, snapshot);
+}
+
+const routes = [AdminAppRoute, AdminToolRoute, ConnectedAccountRoute];
+const pristine = routes.map(captureRouteState);
+let snapshots: Record<string, unknown>[] = [];
+
+beforeEach(() => {
+ snapshots = pristine.map(captureRouteState);
+});
+
+afterEach(() => {
+ routes.forEach((route, index) => {
+ restoreRouteState(route, snapshots[index] ?? {});
+ });
+});
+
+type Updatable = { update: (options: unknown) => unknown };
+
+/** `/admin/plugins/$key` and `/admin/plugins/$key/tools/$tool`, at the ids their `useParams` read. */
+function renderAdmin(client: QueryClient, at: string) {
+ const rootRoute = createRootRoute({ component: Outlet });
+ const authedRoute = createRoute({
+ id: "/_authed",
+ getParentRoute: () => rootRoute,
+ component: Outlet,
+ });
+ const adminRoute = createRoute({
+ path: "/admin",
+ getParentRoute: () => authedRoute,
+ component: Outlet,
+ });
+ const pluginsRoute = createRoute({
+ path: "/plugins/",
+ getParentRoute: () => adminRoute,
+ component: () => null,
+ });
+ const app = (AdminAppRoute as unknown as Updatable).update({
+ id: "/plugins/$key",
+ path: "/plugins/$key",
+ getParentRoute: () => adminRoute,
+ });
+ const tool = (AdminToolRoute as unknown as Updatable).update({
+ id: "/plugins/$key_/tools/$tool",
+ path: "/plugins/$key/tools/$tool",
+ getParentRoute: () => adminRoute,
+ });
+ const tree = rootRoute.addChildren([
+ authedRoute.addChildren([
+ adminRoute.addChildren([pluginsRoute, app as never, tool as never]),
+ ]),
+ ]);
+ const router = createRouter({
+ routeTree: tree,
+ history: createMemoryHistory({ initialEntries: [at] }),
+ });
+ return render(
+ <QueryClientProvider client={client}>
+ <RouterProvider router={router as never} />
+ </QueryClientProvider>,
+ );
+}
+
+/** `/settings/connected-accounts/$key`, at the id its `useParams` reads. */
+function renderAccount(client: QueryClient) {
+ const rootRoute = createRootRoute({ component: Outlet });
+ const authedRoute = createRoute({
+ id: "/_authed",
+ getParentRoute: () => rootRoute,
+ component: Outlet,
+ });
+ const settingsRoute = createRoute({
+ path: "/settings",
+ getParentRoute: () => authedRoute,
+ component: Outlet,
+ });
+ const indexRoute = createRoute({
+ path: "/connected-accounts/",
+ getParentRoute: () => settingsRoute,
+ component: () => null,
+ });
+ const account = (ConnectedAccountRoute as unknown as Updatable).update({
+ id: "/connected-accounts/$key",
+ path: "/connected-accounts/$key",
+ getParentRoute: () => settingsRoute,
+ });
+ const tree = rootRoute.addChildren([
+ authedRoute.addChildren([
+ settingsRoute.addChildren([indexRoute, account as never]),
+ ]),
+ ]);
+ const router = createRouter({
+ routeTree: tree,
+ history: createMemoryHistory({
+ initialEntries: [`/settings/connected-accounts/${APP_KEY}`],
+ }),
+ });
+ return render(
+ <QueryClientProvider client={client}>
+ <RouterProvider router={router as never} />
+ </QueryClientProvider>,
+ );
+}
+
+async function waitForFailedRead(client: QueryClient) {
+ await waitFor(() => {
+ expect(client.getQueryState(pluginKeys.page())?.status).toBe("error");
+ });
+}
+
+test("a connector's admin page says the plugin list failed, not that there is no such plugin", async () => {
+ const client = failingQueryClient();
+ const view = renderAdmin(client, `/admin/plugins/${APP_KEY}`);
+ await waitForFailedRead(client);
+
+ expect(await view.findByText("Plugins could not be loaded.")).toBeTruthy();
+ expect(view.queryByText("Not a plugin")).toBeNull();
+ expect(view.queryByText("Nothing to configure.")).toBeNull();
+});
+
+test("a list that genuinely lacks the connector still says it is not a plugin", async () => {
+ const client = answeredWithout();
+ const view = renderAdmin(client, `/admin/plugins/${APP_KEY}`);
+ await waitForFailedRead(client);
+
+ expect(await view.findByText("Not a plugin")).toBeTruthy();
+ expect(view.queryByText("Plugins could not be loaded.")).toBeNull();
+});
+
+test("a tool's admin page says the plugin list failed, not that the connector is off", async () => {
+ const client = failingQueryClient();
+ const view = renderAdmin(
+ client,
+ `/admin/plugins/${APP_KEY}/tools/${TOOL_NAME}`,
+ );
+ await waitForFailedRead(client);
+
+ expect(await view.findByText("Plugins could not be loaded.")).toBeTruthy();
+ expect(
+ view.queryByText("This deployment has not enabled that connector."),
+ ).toBeNull();
+ expect(
+ view.queryByText("This connector does not advertise a tool by that name."),
+ ).toBeNull();
+});
+
+test("a list that genuinely lacks the connector still says it is not enabled, on the tool page", async () => {
+ const client = answeredWithout();
+ const view = renderAdmin(
+ client,
+ `/admin/plugins/${APP_KEY}/tools/${TOOL_NAME}`,
+ );
+ await waitForFailedRead(client);
+
+ expect(
+ await view.findByText("This deployment has not enabled that connector."),
+ ).toBeTruthy();
+ expect(view.queryByText("Plugins could not be loaded.")).toBeNull();
+});
+
+test("a connected account's page says the plugin list failed, not that it is not a service to connect", async () => {
+ const client = failingQueryClient();
+ const view = renderAccount(client);
+ await waitForFailedRead(client);
+
+ expect(await view.findByRole("alert")).toBeTruthy();
+ expect(
+ view.queryByText("This is not a service you connect for yourself."),
+ ).toBeNull();
+});