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 when the boundary could not be read (#656)
Asem ahmed820c5d510ede
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 25596c21..cc5dee86 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,12 @@ the dialog as before. It appears only when something is hidden. Hiding still chaanyone else, and nothing on the server changed: the screen reads the `GET /api/agents?hidden=true`list the server already served.+### 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+long as it was open. It now says "The boundary could not be read.", or the server's own reason, as+it did before the screen's read moved into a query.+### Browser controls are visible in chat and the Computer sidebarChannel chats and standalone Bot chats now have a labeled Computer button and always-visiblediff --git a/app/src/routes/_authed/admin/boundaries.tsx b/app/src/routes/_authed/admin/boundaries.tsxindex b792dc0e..46d5f735 100644--- a/app/src/routes/_authed/admin/boundaries.tsx+++ b/app/src/routes/_authed/admin/boundaries.tsx@@ -79,11 +79,17 @@ function BoundariesPage() {});};- if (problem && !policy) {+ /*+ * A read that failed says so. This screen used to set "The boundary could not be read." itself;+ * since the read became a query, that sentence (or the server's own) is the query's error, and+ * without this the page sat on its title with nothing under it for as long as it was open.+ */+ const unreadable = problem ?? stored.error?.message ?? null;+ if (unreadable && !policy) {return (<PageShell title="Boundaries"><p className="mt-4 text-destructive text-sm" role="alert">- {problem}+ {unreadable}</p></PageShell>);diff --git a/app/tests/boundaries-read-failure.test.tsx b/app/tests/boundaries-read-failure.test.tsxnew file mode 100644index 00000000..ea81e9f4--- /dev/null+++ b/app/tests/boundaries-read-failure.test.tsx@@ -0,0 +1,87 @@+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,+ createRouter,+ RouterProvider,+} from "@tanstack/react-router";+import { cleanup, render } from "@testing-library/react";+import type { ComponentType } from "react";+import { Route as BoundariesRoute } from "@/routes/_authed/admin/boundaries";++/**+ * Boundaries is drawn from one read, `GET /api/computers/policy`. When that read fails the page+ * used to render its title over nothing, for as long as it stayed open, because nothing read the+ * query's error. The harness is the one `composing-enter.test.tsx` uses for the same screen.+ */++beforeAll(() => GlobalRegistrator.register());+afterEach(cleanup);+afterAll(() => GlobalRegistrator.unregister());++const originalFetch = global.fetch;+let policyResponse: () => Response;++beforeEach(() => {+ global.fetch = Object.assign(+ async (path: Parameters<typeof fetch>[0]) =>+ path === "/api/computers/policy"+ ? policyResponse()+ : new Response(null, { status: 404 }),+ { preconnect: originalFetch.preconnect },+ );+});++afterEach(() => {+ global.fetch = originalFetch;+});++function drawBoundaries() {+ const Boundaries = BoundariesRoute.options.component as ComponentType;+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ const router = createRouter({+ history: createMemoryHistory({ initialEntries: ["/"] }),+ routeTree: createRootRoute({ component: () => <Boundaries /> }),+ });+ return render(+ <QueryClientProvider client={queryClient}>+ <RouterProvider router={router} />+ </QueryClientProvider>,+ );+}++test("a boundary that could not be read says so instead of leaving the page blank", async () => {+ // The shape a broken server actually sends: a 500 with no body, so the query's own sentence.+ policyResponse = () => new Response(null, { status: 500 });++ const view = drawBoundaries();++ const alert = await view.findByRole("alert");+ expect(alert.textContent).toBe("The boundary could not be read.");+});++test("a refused read shows the server's own reason", async () => {+ policyResponse = () =>+ Response.json(+ { error: "Only an administrator may read the boundary." },+ { status: 403 },+ );++ const view = drawBoundaries();++ const alert = await view.findByRole("alert");+ expect(alert.textContent).toBe(+ "Only an administrator may read the boundary.",+ );+});