From 8d97c032739f98b640560798217b6ff8655e4c63 Mon Sep 17 00:00:00 2001 From: Sam Julien Date: Tue, 1 Dec 2026 16:35:19 -0800 Subject: [PATCH 1/4] One filled add button on every list page Each list page's main add action now sits in PageShell's action slot as one filled Button (default variant, size sm) with a plus: Bots, Skills, Memory, Vault, Teams, a Bot's Routines, API keys, and Admin's Skills, Apps, Vault, Teams, Boundaries and Identity providers. Apps names the button for what most people do: Add app. It opens a menu with Browse apps and Add custom MCP, or links to Browse apps for somebody who can't add a custom server. The new AddAppButton serves both Apps pages. Memory's button moves from its section to the header as Add fact. The Vault's Add key and the Skills page's New skill move up the same way. Empty states keep their outlined button, so a page has one filled button. --- .claude/skills/openbot-screen-layout/SKILL.md | 10 +- CHANGELOG.md | 10 ++ .../components/connections/add-app-button.tsx | 64 ++++++++ .../components/manage/credentials-page.tsx | 1 - .../components/manage/plugins-list-page.tsx | 28 ++-- app/src/components/manage/skills-page.tsx | 10 +- app/src/components/memory/memories.tsx | 11 +- .../routines/new-routine-button.tsx | 8 +- app/src/components/settings/api-keys.tsx | 8 +- .../components/settings/learning-sharing.tsx | 11 +- .../skills/skills-settings-page.tsx | 37 +++-- app/src/components/teams/teams-page.tsx | 4 +- app/src/components/vault/vault-page.tsx | 24 +-- app/src/routes/_authed/_app/bots.index.tsx | 1 - .../routes/_authed/_app/connections.index.tsx | 25 ++-- app/src/routes/_authed/_app/memory.tsx | 3 +- app/src/routes/_authed/admin/boundaries.tsx | 1 - .../_authed/admin/identity-providers.tsx | 10 +- app/src/skins/opendots/screens.tsx | 2 +- .../admin-apps-add-server-entry.test.tsx | 16 +- app/tests/admin-apps-add-server.test.tsx | 5 +- app/tests/memory-settings.test.tsx | 6 +- app/tests/page-add-action.test.tsx | 140 ++++++++++++++++++ app/tests/second-organization.test.tsx | 6 +- ...team-connections-directory-layout.test.tsx | 2 +- app/tests/team-connections-directory.test.tsx | 18 ++- app/tests/too-many-requests.test.tsx | 2 +- 27 files changed, 347 insertions(+), 116 deletions(-) create mode 100644 app/src/components/connections/add-app-button.tsx create mode 100644 app/tests/page-add-action.test.tsx diff --git a/.claude/skills/openbot-screen-layout/SKILL.md b/.claude/skills/openbot-screen-layout/SKILL.md index 2ca169bed6..2102f9a0de 100644 --- a/.claude/skills/openbot-screen-layout/SKILL.md +++ b/.claude/skills/openbot-screen-layout/SKILL.md @@ -164,8 +164,12 @@ itself when the screen behind it changes something. ### Procedure 4: Sizes and variants 1. `Item size="sm"` for rows inside a card. `default` only for a row standing on its own. -2. `Button size="sm"` for a control inside a row or a dialog footer; `lg` for a page's own actions; - `icon-sm` for a control floating over artwork. +2. `Button size="sm"` for a control inside a row or a dialog footer, and for a page's own action in + `PageShell`'s `action`; `icon-sm` for a control floating over artwork. + A list page's one add action goes in `PageShell`'s `action`, never in a section: a filled + `Button` (the default variant), `size="sm"`, with `IconPlus` and a short label ("New Bot", + "New skill", "Add app"). One filled button per page. The same add in an empty state is + `outline`. 3. `Item variant` — pick **one for the whole screen**. `muted` is a fill with no border; `outline` is a border with no fill; `default` is neither. Mixing two of them on one screen reads as two different kinds of list, and the reader looks for a distinction that is not there. @@ -176,7 +180,7 @@ itself when the screen behind it changes something. 1. Creating a thing that takes several fields — a credential, a key — is its own screen, not a dialog over the list. Put it at `_.new.tsx` (the `_` keeps it from nesting inside the list's route), - and make the list's `action` a `Button` rendering a `Link` to it. + and make the list's `action` a filled `Button size="sm"` rendering a `Link` to it (Procedure 4). 2. `PageShell` with `backButton` pointing at the list, a title that is the verb ("Add credential"), and a description saying what happens on save. 3. The fields go in one `PageCard` inside a `
`, stacked in a single column, each a `Field` diff --git a/CHANGELOG.md b/CHANGELOG.md index 3076d58f3d..30e0c6a414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,16 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged. API key, with the scope and organization it has on the artifact's REST operations. A credential that isn't good there opens what nobody signed in opens, as before. +**List pages.** + +- **One filled add button, top right, on every list page.** Bots, Skills, Memory, Vault, Teams, a + Bot's Routines, API keys and Admin's lists each drew their add button their own way: plain, + outlined, large, or in a section lower down. Each is now one filled button beside the page title, + with a plus and a short label. +- **Apps: Add app.** The button is named for what most people do. It opens a menu with Browse apps + and Add custom MCP. Somebody who can't add a custom server gets a link to Browse apps. +- **Memory: Add fact** replaces Remember a fact, and Identity providers says Add provider. + **Smaller addresses.** - **Lists travel in a body, not the address.** Reading an app for the actions a Bot needs, and the diff --git a/app/src/components/connections/add-app-button.tsx b/app/src/components/connections/add-app-button.tsx new file mode 100644 index 0000000000..9ccfa582bd --- /dev/null +++ b/app/src/components/connections/add-app-button.tsx @@ -0,0 +1,64 @@ +import { Link, type LinkOptions } from "@tanstack/react-router"; +import { IconPlus } from "@/components/icons"; +import { Button } from "@/components/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; + +/** + * Add app, the Apps page's one add action (`PageShell`'s `action`), filled as every list page's is. + * + * Named for what most people do, which is find an app in the directory, not for the rarer custom + * MCP server. For whoever may add a custom server it opens a menu, so Add custom MCP is still one + * press away under the name the form and a Bot's refusals use. For anybody else it is the link to + * the directory, and with no directory it is not drawn. + */ +export function AddAppButton({ + browse, + customServer, +}: { + /** The broker's directory of apps, when one is set up. */ + browse?: LinkOptions; + /** The form for an MCP server OpenBot doesn't list, when this person may add one. */ + customServer?: LinkOptions; +}) { + const label = ( + <> + + Add app + + ); + if (customServer) + return ( + + }> + {label} + + + {browse ? ( + } + > + Browse apps + + ) : null} + } + > + Add custom MCP + + + + ); + if (!browse) return null; + return ( + + ); +} diff --git a/app/src/components/manage/credentials-page.tsx b/app/src/components/manage/credentials-page.tsx index 3334bf6700..11ceff6ad6 100644 --- a/app/src/components/manage/credentials-page.tsx +++ b/app/src/components/manage/credentials-page.tsx @@ -39,7 +39,6 @@ export function CredentialsPage() { - ) : undefined + } description="Connect services for your company, then choose which Bots can use each service’s tools." title="Apps" diff --git a/app/src/components/manage/skills-page.tsx b/app/src/components/manage/skills-page.tsx index 1eac9c269e..6e7054723d 100644 --- a/app/src/components/manage/skills-page.tsx +++ b/app/src/components/manage/skills-page.tsx @@ -47,11 +47,11 @@ export function SkillsPage() { const { data: hiddenAgents } = useQuery(agentListQueryOptions(true, scope)); const skills = skillList.data ?? []; - const newSkill = (size: "lg" | "sm") => ( + const newSkill = (variant: "default" | "outline") => ( diff --git a/app/src/components/routines/new-routine-button.tsx b/app/src/components/routines/new-routine-button.tsx index 6adac61967..ee8c7b1048 100644 --- a/app/src/components/routines/new-routine-button.tsx +++ b/app/src/components/routines/new-routine-button.tsx @@ -5,15 +5,15 @@ import { Button } from "@/components/ui/button"; /** * New routine, opening the create screen. `agentId` starts it out for one Bot. * - * `outline` where it stands alone in an empty state, `ghost` on a page's title row, as Add - * credential and New skill are drawn. + * Filled on a page's title row, as every list page's one add action is drawn (`PageShell`'s + * `action`). `outline` where it stands alone in an empty state. */ export function NewRoutineButton({ agentId, - variant = "ghost", + variant = "default", }: { agentId?: string; - variant?: "ghost" | "outline"; + variant?: "default" | "outline"; }) { // A list drawn with no router around it, as a skin's own tests draw it, has nowhere to link to. if (!useRouter({ warn: false })) return null; diff --git a/app/src/components/settings/api-keys.tsx b/app/src/components/settings/api-keys.tsx index 5eb0d317ce..133f722f0f 100644 --- a/app/src/components/settings/api-keys.tsx +++ b/app/src/components/settings/api-keys.tsx @@ -103,15 +103,15 @@ export function ApiKeysPage() { const [creating, setCreating] = useState(false); const [made, setMade] = useState(null); const ready = list.data?.state === "ready"; - const createButton = (size: "sm" | "lg", variant: "default" | "outline") => ( - ); return ( @@ -136,7 +136,7 @@ export function ApiKeysPage() { ) : list.data.apiKeys.length === 0 ? ( diff --git a/app/src/components/settings/learning-sharing.tsx b/app/src/components/settings/learning-sharing.tsx index cc159451d1..7de68b9fe1 100644 --- a/app/src/components/settings/learning-sharing.tsx +++ b/app/src/components/settings/learning-sharing.tsx @@ -133,7 +133,6 @@ export function LearningSharing({ written = [], writtenKnown = true, heldAbove = false, - action, }: { /** * The page above has already said OpenBot is holding off (a move, or the database out of reach): @@ -144,8 +143,6 @@ export function LearningSharing({ written?: React.ReactNode[]; /** False while the page is still reading the written skills, or failed to: an empty `written` then means "not known", not "none". */ writtenKnown?: boolean; - /** The section's one verb: New skill. */ - action?: React.ReactNode; } = {}) { const sharing = useQuery(personalLearningQueryOptions()); const setMode = useMutation( @@ -170,12 +167,12 @@ export function LearningSharing({ if (sharing.isPending && !writtenKnown) return null; const personal = capabilities.data?.edition === "personal"; /* - * The skills a person wrote don't come from Learning, so they and New skill are drawn whether or - * not it answered. Its failure is said inside the section, above what is still known. + * The skills a person wrote don't come from Learning, so they are drawn whether or not it + * answered. Its failure is said inside the section, above what is still known. */ if (sharing.isPending || sharing.error) { return ( - + {sharing.error && !(heldAbove && isHeld(sharing.error)) ? (

{failureSaid(sharing.error)} @@ -201,7 +198,6 @@ export function LearningSharing({ const none = learned.length === 0 && written.length === 0; return ( 0 diff --git a/app/src/components/skills/skills-settings-page.tsx b/app/src/components/skills/skills-settings-page.tsx index f1db62552a..e1f7bb2707 100644 --- a/app/src/components/skills/skills-settings-page.tsx +++ b/app/src/components/skills/skills-settings-page.tsx @@ -223,6 +223,24 @@ export function SkillsSettingsPage({ open={showCreate || showEdit} > + // The personal edition's skills each have a switch per Bot, so a new one is written + // on the page that leads to those switches. Elsewhere a person's own skill is + // written in the panel beside the list. + personal ? ( + + ) : ( + + ) + } + size="sm" + > + + New skill + + } className="@container" description="Skills are how your Bots do a task your way. Write one, teach a Bot by showing it, or review what OpenBot proposes." title="Skills" @@ -242,25 +260,6 @@ export function SkillsSettingsPage({ ) : null} - // The personal edition's skills each have a switch per Bot, so a new one is written - // on the page that leads to those switches. Elsewhere a person's own skill is - // written in the panel beside the list. - personal ? ( - - ) : ( - - ) - } - size="sm" - variant="ghost" - > - - New skill - - } heldAbove={heldAbove} written={written} writtenKnown={writtenKnown} diff --git a/app/src/components/teams/teams-page.tsx b/app/src/components/teams/teams-page.tsx index 805e32f52a..5b7ee74238 100644 --- a/app/src/components/teams/teams-page.tsx +++ b/app/src/components/teams/teams-page.tsx @@ -49,7 +49,7 @@ function Teams({ paths }: { paths: TeamPaths }) { const teams = list.data?.pages.flatMap((page) => page.teams) ?? []; const canCreate = list.data?.pages[0]?.canCreate === true; - const newTeam = (variant: "ghost" | "outline") => ( + const newTeam = (variant: "default" | "outline") => ( + ) : undefined + } description={ personal ? "Your saved logins and keys are kept here. Bots never see them." @@ -44,17 +57,6 @@ export function VaultPage() { )} {personal ? ( } - size="sm" - variant="ghost" - > - - Add key - - } description="API keys and tokens your apps and models use. A saved key can't be viewed again." title="Keys" > diff --git a/app/src/routes/_authed/_app/bots.index.tsx b/app/src/routes/_authed/_app/bots.index.tsx index ebf3f47dbb..0d1647a5d9 100644 --- a/app/src/routes/_authed/_app/bots.index.tsx +++ b/app/src/routes/_authed/_app/bots.index.tsx @@ -83,7 +83,6 @@ function BotsPage() { )} size="sm" - variant="ghost" > New Bot diff --git a/app/src/routes/_authed/_app/connections.index.tsx b/app/src/routes/_authed/_app/connections.index.tsx index aa0c4327d5..0365aaa629 100644 --- a/app/src/routes/_authed/_app/connections.index.tsx +++ b/app/src/routes/_authed/_app/connections.index.tsx @@ -6,7 +6,6 @@ import { IconChevronRight, IconLock, IconPlug, - IconPlus, IconSearch, } from "@/components/icons"; import { useQuery } from "@tanstack/react-query"; @@ -23,6 +22,7 @@ import { PageSection, PageShell, } from "@/components/layout/page-shell"; +import { AddAppButton } from "@/components/connections/add-app-button"; import { RowMark } from "@/components/layout/row-mark"; import { MovedAppsNotice } from "@/components/moves/moved-apps-notice"; import { directoryPressMode } from "@/components/plugins/broker-directory"; @@ -632,20 +632,17 @@ function RouteComponent() { return ( } - size="sm" - variant="outline" - > - - Add custom MCP - - ) : undefined + } className="@container" description={ @@ -779,7 +776,7 @@ function RouteComponent() { title="No apps yet" > {openTeam - ? "Apps show up here once they're added. Add one with Add custom MCP." + ? "Apps show up here once they're added. Add one with Add app." : edition === "team" ? "Apps show up here once an admin turns them on." : edition === "personal" diff --git a/app/src/routes/_authed/_app/memory.tsx b/app/src/routes/_authed/_app/memory.tsx index 554739ce22..d66a60e6ce 100644 --- a/app/src/routes/_authed/_app/memory.tsx +++ b/app/src/routes/_authed/_app/memory.tsx @@ -31,11 +31,12 @@ export const Route = createFileRoute("/_authed/_app/memory")({ function MemoryPage() { return ( } className="@container" description="Your Bots remember facts about you, like your role and how you like to work, and use them in every conversation. Facts you add, or ask a Bot to remember, reach all your Bots. A fact a Bot notices by itself stays with that Bot, and you can confirm or forget it here." title="Memory" > - } /> + ); } diff --git a/app/src/routes/_authed/admin/boundaries.tsx b/app/src/routes/_authed/admin/boundaries.tsx index 71baf60116..65b770714a 100644 --- a/app/src/routes/_authed/admin/boundaries.tsx +++ b/app/src/routes/_authed/admin/boundaries.tsx @@ -55,7 +55,6 @@ function BoundariesPage() { ) : undefined } @@ -178,7 +179,8 @@ function IdentityProvidersPage() { setOpen(true)} size="sm" variant="outline"> - Add a provider + + Add provider } icon={IconBuildingBank} diff --git a/app/src/skins/opendots/screens.tsx b/app/src/skins/opendots/screens.tsx index 1a07d79f40..36128fa623 100644 --- a/app/src/skins/opendots/screens.tsx +++ b/app/src/skins/opendots/screens.tsx @@ -71,7 +71,7 @@ export function MemoriesScreen() { if (!offersMemory(capabilities.data)) return ; return ( } + action={} description="What your Bots know about you." title="Memories" > diff --git a/app/tests/admin-apps-add-server-entry.test.tsx b/app/tests/admin-apps-add-server-entry.test.tsx index 4eb3af442b..a68d569168 100644 --- a/app/tests/admin-apps-add-server-entry.test.tsx +++ b/app/tests/admin-apps-add-server-entry.test.tsx @@ -17,6 +17,7 @@ import { RouterProvider, } from "@tanstack/react-router"; import { cleanup, render } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; import { authKeys } from "@/lib/auth/queries"; import { deploymentKeys } from "@/lib/deployment/queries"; import { Route as AdminAppsRoute } from "@/routes/_authed/admin/plugins/index"; @@ -33,8 +34,9 @@ import { settleReactWork } from "./settle-react-work"; * * Reported in dogfooding: adding an MCP server by its address was hard to find. An admin looked for * it where apps are set up, Admin then Apps, and it wasn't there: its button was only on - * Connections. Apps now offers it too, as Add custom MCP, the same words as Connections. It is - * offered to exactly the people Connections offers it to, and it opens Apps' own add page. + * Connections. Apps now offers it too, as Add custom MCP under Add app, the same words as + * Connections. It is offered to exactly the people Connections offers it to, and it opens Apps' own + * add page. */ beforeAll(() => GlobalRegistrator.register()); @@ -111,7 +113,9 @@ describe("Admin, Apps", () => { test(`offers an ${role} Add custom MCP, which opens its add page`, async () => { const view = draw(role, "team"); await view.findByRole("heading", { name: "Connected" }); - const add = view.getByRole("button", { name: "Add custom MCP" }); + const user = userEvent.setup({ document }); + await user.click(view.getByRole("button", { name: "Add app" })); + const add = await view.findByRole("menuitem", { name: "Add custom MCP" }); expect(add.getAttribute("href")).toBe("/admin/plugins/new"); }); } @@ -119,7 +123,11 @@ describe("Admin, Apps", () => { test("offers the one person of a personal OpenBot Add custom MCP", async () => { const view = draw("member", "personal"); await view.findByRole("heading", { name: "Connected" }); - expect(view.getByRole("button", { name: "Add custom MCP" })).toBeTruthy(); + const user = userEvent.setup({ document }); + await user.click(view.getByRole("button", { name: "Add app" })); + expect( + await view.findByRole("menuitem", { name: "Add custom MCP" }), + ).toBeTruthy(); }); test("offers a member no Add custom MCP, as Connections doesn't", async () => { diff --git a/app/tests/admin-apps-add-server.test.tsx b/app/tests/admin-apps-add-server.test.tsx index a6c0b75c9f..a50c92e6c7 100644 --- a/app/tests/admin-apps-add-server.test.tsx +++ b/app/tests/admin-apps-add-server.test.tsx @@ -162,7 +162,10 @@ describe("Admin, Apps, Add custom MCP", () => { expect(view.getByText("Nothing connected yet")).toBeTruthy(); const user = userEvent.setup({ document }); - await user.click(view.getByRole("button", { name: "Add custom MCP" })); + await user.click(view.getByRole("button", { name: "Add app" })); + await user.click( + await view.findByRole("menuitem", { name: "Add custom MCP" }), + ); // Connections' own form, with its way back named for Apps. await view.findByRole("heading", { name: "Add custom MCP", level: 1 }); diff --git a/app/tests/memory-settings.test.tsx b/app/tests/memory-settings.test.tsx index 9ccfe8c9b0..69ffcf699d 100644 --- a/app/tests/memory-settings.test.tsx +++ b/app/tests/memory-settings.test.tsx @@ -106,7 +106,7 @@ test("remembering a fact saves it", async () => { const view = draw(); const user = userEvent.setup({ document }); // The form lives in a dialog behind the page's action, not on the page. - fireEvent.click(view.getByRole("button", { name: "Remember a fact" })); + fireEvent.click(view.getByRole("button", { name: "Add fact" })); await user.type( await view.findByRole("textbox", { name: "Something you want your Bots to know", @@ -153,7 +153,7 @@ test("reopening Remember a fact after a failure starts clean", async () => { refuseWrite = "Memory is full."; const view = draw(); const user = userEvent.setup({ document }); - await user.click(view.getByRole("button", { name: "Remember a fact" })); + await user.click(view.getByRole("button", { name: "Add fact" })); await user.type( await view.findByRole("textbox", { name: "Something you want your Bots to know", @@ -164,7 +164,7 @@ test("reopening Remember a fact after a failure starts clean", async () => { expect((await view.findByRole("alert")).textContent).toBe("Memory is full."); await user.keyboard("{Escape}"); await waitFor(() => expect(view.queryByRole("dialog")).toBeNull()); - await user.click(view.getByRole("button", { name: "Remember a fact" })); + await user.click(view.getByRole("button", { name: "Add fact" })); const field = (await view.findByRole("textbox", { name: "Something you want your Bots to know", })) as HTMLTextAreaElement; diff --git a/app/tests/page-add-action.test.tsx b/app/tests/page-add-action.test.tsx new file mode 100644 index 0000000000..12dd4f9a9b --- /dev/null +++ b/app/tests/page-add-action.test.tsx @@ -0,0 +1,140 @@ +import { + afterAll, + afterEach, + beforeAll, + describe, + expect, + test, +} from "bun:test"; +import { GlobalRegistrator } from "@happy-dom/global-registrator"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { + createMemoryHistory, + createRootRoute, + createRouter, + linkOptions, + RouterProvider, +} from "@tanstack/react-router"; +import { cleanup, render } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import type { ReactNode } from "react"; +import { AddAppButton } from "@/components/connections/add-app-button"; +import { PageShell } from "@/components/layout/page-shell"; +import { RememberFact } from "@/components/memory/memories"; +import { NewRoutineButton } from "@/components/routines/new-routine-button"; +import { settleReactWork } from "./settle-react-work"; + +/** + * ONE FILLED ADD BUTTON ON A LIST PAGE. Each list page's main add action sits in `PageShell`'s + * `action`, at the top right of the header, drawn as the Button's default (filled) variant at size + * `sm` with a plus. Before this, Bots, Skills, Memory, Vault and the rest each drew it their own way: + * ghost, outline, large, or down in a section. Apps names it for what most people do (Add app) and + * keeps the custom MCP server in its menu. + */ + +beforeAll(() => GlobalRegistrator.register()); +afterEach(cleanup); +afterAll(async () => { + await settleReactWork(); + GlobalRegistrator.unregister(); +}); + +const BROWSE = linkOptions({ to: "/connections/browse/composio" }); +const CUSTOM = linkOptions({ to: "/connections/new" }); + +/** Draws `node` inside a router and a query client, as a page has them. */ +function draw(node: ReactNode) { + const router = createRouter({ + history: createMemoryHistory({ initialEntries: ["/"] }), + routeTree: createRootRoute({ component: () => node }), + }); + return render( + + + , + ); +} + +/** The Button's default variant: the primary fill. */ +const filled = (element: HTMLElement) => + element.className.split(" ").includes("bg-primary"); +/** The Button's `sm` size. */ +const small = (element: HTMLElement) => + element.className.split(" ").includes("h-7"); + +describe("Add app", () => { + test("with a directory and a custom server, opens a menu of both", async () => { + const view = draw(); + const button = await view.findByRole("button", { name: "Add app" }); + expect(filled(button)).toBe(true); + expect(small(button)).toBe(true); + + await userEvent.setup({ document }).click(button); + expect( + (await view.findByRole("menuitem", { name: "Browse apps" })).getAttribute( + "href", + ), + ).toBe("/connections/browse/composio"); + expect( + view + .getByRole("menuitem", { name: "Add custom MCP" }) + .getAttribute("href"), + ).toBe("/connections/new"); + }); + + test("with only a custom server, its menu still names Add custom MCP", async () => { + const view = draw(); + await userEvent + .setup({ document }) + .click(await view.findByRole("button", { name: "Add app" })); + expect( + await view.findByRole("menuitem", { name: "Add custom MCP" }), + ).toBeTruthy(); + expect(view.queryByRole("menuitem", { name: "Browse apps" })).toBeNull(); + }); + + test("with only a directory, is the link to it", async () => { + const view = draw(); + const link = await view.findByRole("button", { name: "Add app" }); + expect(link.getAttribute("href")).toBe("/connections/browse/composio"); + expect(filled(link)).toBe(true); + }); + + test("with neither, draws nothing", async () => { + const view = draw( + } title="Apps"> +

Apps

+
, + ); + await view.findByRole("heading", { name: "Apps" }); + expect(view.queryByRole("button", { name: "Add app" })).toBeNull(); + }); +}); + +describe("the shared add buttons are filled by default", () => { + test("New routine, on a page's title row", async () => { + const view = draw(); + const button = await view.findByRole("button", { name: "New routine" }); + expect(filled(button)).toBe(true); + expect(small(button)).toBe(true); + }); + + test("New routine stays outlined where it stands alone in an empty state", async () => { + const view = draw(); + const button = await view.findByRole("button", { name: "New routine" }); + expect(filled(button)).toBe(false); + }); + + test("Add fact, Memory's one add action", async () => { + const view = draw(); + const button = await view.findByRole("button", { name: "Add fact" }); + expect(filled(button)).toBe(true); + expect(small(button)).toBe(true); + }); + + test("Add fact in a skin's own section keeps the skin's ghost look", async () => { + const view = draw(); + const button = await view.findByRole("button", { name: "Add fact" }); + expect(filled(button)).toBe(false); + }); +}); diff --git a/app/tests/second-organization.test.tsx b/app/tests/second-organization.test.tsx index b8c5d19d77..7be1ab2ff6 100644 --- a/app/tests/second-organization.test.tsx +++ b/app/tests/second-organization.test.tsx @@ -184,7 +184,7 @@ test("Harbor's admin registers Harbor's own identity providers, which sign in Ha "Configure your company’s SAML or OpenID Connect provider for this organization’s members. Email domains determine which provider people use to sign in.", ); expect( - view.getAllByRole("button", { name: "Add a provider" }).length, + view.getAllByRole("button", { name: "Add provider" }).length, ).toBeGreaterThan(0); expect(view.queryByText("Set up for all of OpenBot")).toBeNull(); expect(document.body.textContent).not.toMatch( @@ -287,7 +287,7 @@ test("an admin of `default` who doesn't run OpenBot reads that its identity prov ); expect(view.queryByRole("alert")).toBeNull(); expect(view.queryByText(/Couldn't load identity providers/)).toBeNull(); - expect(view.queryByRole("button", { name: "Add a provider" })).toBeNull(); + expect(view.queryByRole("button", { name: "Add provider" })).toBeNull(); expect(view.queryByRole("switch", { name: "Require SSO" })).toBeNull(); // Nothing of the deployment's own settings is drawn to somebody who can't act on them. expect(document.body.textContent).not.toMatch( @@ -304,7 +304,7 @@ test("an admin of `default` still registers providers there", async () => { const view = identityProviders(); await view.findByText("No identity providers yet"); expect( - view.getAllByRole("button", { name: "Add a provider" }).length, + view.getAllByRole("button", { name: "Add provider" }).length, ).toBeGreaterThan(0); expect(view.queryByText("Set up for all of OpenBot")).toBeNull(); }); diff --git a/app/tests/team-connections-directory-layout.test.tsx b/app/tests/team-connections-directory-layout.test.tsx index 246b2ac1c8..7691c0cfec 100644 --- a/app/tests/team-connections-directory-layout.test.tsx +++ b/app/tests/team-connections-directory-layout.test.tsx @@ -309,7 +309,7 @@ describe.skipIf(!asked)("Connections on OpenBot Cloud", () => { const browse = page.getByTestId("account-browse"); await browse.waitFor({ timeout: 15_000 }); await page - .getByRole("button", { name: "Add custom MCP" }) + .getByRole("button", { name: "Add app" }) .waitFor({ timeout: 15_000 }); expect(await browse.innerText()).not.toContain("admin"); await style(page); diff --git a/app/tests/team-connections-directory.test.tsx b/app/tests/team-connections-directory.test.tsx index 1e6c017512..730873a5d2 100644 --- a/app/tests/team-connections-directory.test.tsx +++ b/app/tests/team-connections-directory.test.tsx @@ -568,19 +568,27 @@ describe("apps open, a member adds and connects in one press", () => { test("Add custom MCP is offered to a member with apps open, and not locked down", async () => { lockedDown = false; const open = draw("member"); - const add = await open.view.findByRole("button", { - name: "Add custom MCP", - }); + await open.user.click( + await open.view.findByRole("button", { name: "Add app" }), + ); + expect( + ( + await open.view.findByRole("menuitem", { name: "Browse apps" }) + ).getAttribute("href"), + ).toBe("/connections/browse/composio"); + const add = open.view.getByRole("menuitem", { name: "Add custom MCP" }); expect(add.getAttribute("href")).toBe("/connections/new"); cleanup(); + // Locked down, Add app is the way to the directory alone, where a member asks for an app. lockedDown = true; const locked = draw("member"); await locked.view.findByTestId("account-browse"); await settleReactWork(); expect( - locked.view.queryByRole("button", { name: "Add custom MCP" }), - ).toBeNull(); + locked.view.getByRole("button", { name: "Add app" }).getAttribute("href"), + ).toBe("/connections/browse/composio"); + expect(locked.view.queryByText("Add custom MCP")).toBeNull(); }); test("locked down, the catalogue's apps nobody has added aren't offered to anybody", async () => { diff --git a/app/tests/too-many-requests.test.tsx b/app/tests/too-many-requests.test.tsx index 213ad23a3b..caf72d7198 100644 --- a/app/tests/too-many-requests.test.tsx +++ b/app/tests/too-many-requests.test.tsx @@ -229,7 +229,7 @@ test("Remember a fact refused 429 says the server's sentence, calmly, and isn't serve(`POST ${MEMORY.memories}`, () => tooMany(3)); const view = draw(); const person = userEvent.setup({ document }); - await person.click(view.getByRole("button", { name: "Remember a fact" })); + await person.click(view.getByRole("button", { name: "Add fact" })); await person.type( await view.findByRole("textbox", { name: "Something you want your Bots to know", From 60e5e34bd6f2d623680cfd0e55db34eccfe78ec2 Mon Sep 17 00:00:00 2001 From: Sam Julien Date: Tue, 1 Dec 2026 16:53:53 -0800 Subject: [PATCH 2/4] Add buttons: leave the filled style to the default argument organization-address.test.ts reads a "default" first argument as a hard-coded organization id. newSkill, createButton and newTeam now take the style as an optional argument that defaults to filled. --- app/src/components/manage/skills-page.tsx | 4 ++-- app/src/components/settings/api-keys.tsx | 4 ++-- app/src/components/teams/teams-page.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/components/manage/skills-page.tsx b/app/src/components/manage/skills-page.tsx index 6e7054723d..d58fb77dbc 100644 --- a/app/src/components/manage/skills-page.tsx +++ b/app/src/components/manage/skills-page.tsx @@ -47,7 +47,7 @@ export function SkillsPage() { const { data: hiddenAgents } = useQuery(agentListQueryOptions(true, scope)); const skills = skillList.data ?? []; - const newSkill = (variant: "default" | "outline") => ( + const newSkill = (variant: "default" | "outline" = "default") => ( - ); -} diff --git a/app/src/components/layout/page-shell.tsx b/app/src/components/layout/page-shell.tsx index e51a0be7a0..a96c5e91d7 100644 --- a/app/src/components/layout/page-shell.tsx +++ b/app/src/components/layout/page-shell.tsx @@ -1,4 +1,4 @@ -import { IconChevronLeft } from "@/components/icons"; +import { IconChevronLeft, IconPlus } from "@/components/icons"; import { Link, type LinkProps } from "@tanstack/react-router"; import type * as React from "react"; import { cn } from "@/lib/utils"; @@ -116,4 +116,35 @@ export function PageShell({ ); } +/** + * A list page's main add action, for `PageShell`'s `action`: one filled button with a plus and a + * short label ("New Bot", "Add fact"). Drawn here, once, so every list page draws it the same way: + * the default variant and the page-action size (the layout skill, Procedure 4). It is a link to the + * screen where the thing is made, or, given `onClick`, opens what the page opens itself. + * + * One per page. The same add in an empty state is an outlined `Button size="sm"`, so the page still + * has one filled button. It lives here, not in `page-parts.tsx`, because a link needs the router and + * that file imports none. + */ +export function PageAddButton({ + children, + link, + onClick, +}: { children: React.ReactNode } & ( + | { link: LinkProps; onClick?: never } + | { onClick: () => void; link?: never } +)) { + return link ? ( + + ) : ( + + ); +} + export { PageCard, PageEmpty, PageRows, PageSection } from "./page-parts"; diff --git a/app/src/components/manage/credentials-page.tsx b/app/src/components/manage/credentials-page.tsx index 11ceff6ad6..fd08e388f9 100644 --- a/app/src/components/manage/credentials-page.tsx +++ b/app/src/components/manage/credentials-page.tsx @@ -2,6 +2,7 @@ import { IconKey, IconPlus } from "@/components/icons"; import { useMutation, useQuery } from "@tanstack/react-query"; import { Link } from "@tanstack/react-router"; import { + PageAddButton, PageEmpty, PageRows, PageSection, @@ -36,13 +37,7 @@ export function CredentialsPage() { } - size="sm" - > - - Add {noun} - + Add {noun} } description="Manage this organization’s keys and tokens. Saved secrets cannot be viewed again." title={paths.credentialsLabel} diff --git a/app/src/components/manage/plugins-list-page.tsx b/app/src/components/manage/plugins-list-page.tsx index 72e2dc3299..bd14003338 100644 --- a/app/src/components/manage/plugins-list-page.tsx +++ b/app/src/components/manage/plugins-list-page.tsx @@ -7,15 +7,15 @@ import { IconPlug, } from "@/components/icons"; import { useQuery } from "@tanstack/react-query"; -import { Link, linkOptions } from "@tanstack/react-router"; +import { Link } from "@tanstack/react-router"; import * as React from "react"; import { + PageAddButton, PageEmpty, PageRows, PageSection, PageShell, } from "@/components/layout/page-shell"; -import { AddAppButton } from "@/components/connections/add-app-button"; import { RowMark } from "@/components/layout/row-mark"; import { AccessRequestsSection, @@ -140,7 +140,7 @@ export function PluginsListPage({ const paths = useManagePaths(); const edition = useQuery(deploymentCapabilitiesQueryOptions()).data?.edition; const role = useQuery(currentUserQueryOptions()).data?.role; - // Offered to exactly the people Connections offers its custom MCP server to. + // Offered to exactly the people Connections offers its Add custom MCP to. const mayAddServer = mayAddApps(edition === "personal", role); const plugins = useQuery(appsQueryOptions()); const catalogue = useQuery(catalogueQueryOptions()); @@ -182,17 +182,15 @@ export function PluginsListPage({ return ( + mayAddServer ? ( + + Add custom MCP + + ) : undefined } description="Connect services for your company, then choose which Bots can use each service’s tools." title="Apps" diff --git a/app/src/components/manage/skills-page.tsx b/app/src/components/manage/skills-page.tsx index d58fb77dbc..d55562816f 100644 --- a/app/src/components/manage/skills-page.tsx +++ b/app/src/components/manage/skills-page.tsx @@ -3,6 +3,7 @@ import { useQuery } from "@tanstack/react-query"; import { Link } from "@tanstack/react-router"; import * as React from "react"; import { + PageAddButton, PageEmpty, PageRows, PageSection, @@ -47,11 +48,12 @@ export function SkillsPage() { const { data: hiddenAgents } = useQuery(agentListQueryOptions(true, scope)); const skills = skillList.data ?? []; - const newSkill = (variant: "default" | "outline" = "default") => ( + // The empty state's; the page's own is `PageAddButton`, so the page has one filled button. + const newSkill = () => ( + {variant === "page" ? ( + Add fact + ) : ( + + )} - Remember a fact + Add fact All your Bots will know it. @@ -152,11 +154,8 @@ export function MemoryList({ const botName = (id: string | null) => agents.data?.find((agent) => agent.id === id)?.name ?? "your Bot"; return ( - + // One section, so no title: the page title already names it. + {memories.isPending ? null : memories.error ? (

{failureSaid(memories.error)} @@ -180,9 +179,7 @@ export function MemoryList({ })} ) : ( - - Add one with Remember a fact. - + )} ); diff --git a/app/src/components/routines/new-routine-button.tsx b/app/src/components/routines/new-routine-button.tsx index ee8c7b1048..eecd4e2373 100644 --- a/app/src/components/routines/new-routine-button.tsx +++ b/app/src/components/routines/new-routine-button.tsx @@ -1,22 +1,32 @@ import { Link, useRouter } from "@tanstack/react-router"; import { IconPlus } from "@/components/icons"; +import { PageAddButton } from "@/components/layout/page-shell"; import { Button } from "@/components/ui/button"; /** * New routine, opening the create screen. `agentId` starts it out for one Bot. * - * Filled on a page's title row, as every list page's one add action is drawn (`PageShell`'s - * `action`). `outline` where it stands alone in an empty state. + * The page's one add action on a page's title row (`PageAddButton`), `outline` where it stands + * alone in an empty state. */ export function NewRoutineButton({ agentId, - variant = "default", + variant = "page", }: { agentId?: string; - variant?: "default" | "outline"; + /** `page` for `PageShell`'s `action`, `outline` for an empty state. */ + variant?: "page" | "outline"; }) { // A list drawn with no router around it, as a skin's own tests draw it, has nowhere to link to. if (!useRouter({ warn: false })) return null; + if (variant === "page") + return ( + + New routine + + ); return ( ); return ( setCreating(true)}> + Create key + + ) : undefined + } description="Create a key so a script or another program can use OpenBot as you." title="API keys" > @@ -136,7 +144,7 @@ export function ApiKeysPage() { ) : list.data.apiKeys.length === 0 ? ( diff --git a/app/src/components/settings/learning-sharing.tsx b/app/src/components/settings/learning-sharing.tsx index 7de68b9fe1..cc159451d1 100644 --- a/app/src/components/settings/learning-sharing.tsx +++ b/app/src/components/settings/learning-sharing.tsx @@ -133,6 +133,7 @@ export function LearningSharing({ written = [], writtenKnown = true, heldAbove = false, + action, }: { /** * The page above has already said OpenBot is holding off (a move, or the database out of reach): @@ -143,6 +144,8 @@ export function LearningSharing({ written?: React.ReactNode[]; /** False while the page is still reading the written skills, or failed to: an empty `written` then means "not known", not "none". */ writtenKnown?: boolean; + /** The section's one verb: New skill. */ + action?: React.ReactNode; } = {}) { const sharing = useQuery(personalLearningQueryOptions()); const setMode = useMutation( @@ -167,12 +170,12 @@ export function LearningSharing({ if (sharing.isPending && !writtenKnown) return null; const personal = capabilities.data?.edition === "personal"; /* - * The skills a person wrote don't come from Learning, so they are drawn whether or not it - * answered. Its failure is said inside the section, above what is still known. + * The skills a person wrote don't come from Learning, so they and New skill are drawn whether or + * not it answered. Its failure is said inside the section, above what is still known. */ if (sharing.isPending || sharing.error) { return ( - + {sharing.error && !(heldAbove && isHeld(sharing.error)) ? (

{failureSaid(sharing.error)} @@ -198,6 +201,7 @@ export function LearningSharing({ const none = learned.length === 0 && written.length === 0; return ( 0 diff --git a/app/src/components/skills/skills-settings-page.tsx b/app/src/components/skills/skills-settings-page.tsx index e1f7bb2707..304a5e4aac 100644 --- a/app/src/components/skills/skills-settings-page.tsx +++ b/app/src/components/skills/skills-settings-page.tsx @@ -3,7 +3,6 @@ import { IconChalkboardTeacher, IconChevronRight, IconDots, - IconPlus, } from "@/components/icons"; import { useMutation, useQuery } from "@tanstack/react-query"; import { Link, useNavigate } from "@tanstack/react-router"; @@ -11,6 +10,7 @@ import { useState } from "react"; import { TEACH_A_BOT } from "@/components/browser/browser-nav-item"; import { DetailPanel } from "@/components/layout/detail-panel"; import { + PageAddButton, PageRows, PageSection, PageShell, @@ -224,22 +224,17 @@ export function SkillsSettingsPage({ > - // The personal edition's skills each have a switch per Bot, so a new one is written - // on the page that leads to those switches. Elsewhere a person's own skill is - // written in the panel beside the list. - personal ? ( - - ) : ( - - ) + // The personal edition's skills each have a switch per Bot, so a new one is written on the + // page that leads to those switches. Elsewhere it is written in the panel beside the list. + - New skill - + } className="@container" description="Skills are how your Bots do a task your way. Write one, teach a Bot by showing it, or review what OpenBot proposes." diff --git a/app/src/components/teams/teams-page.tsx b/app/src/components/teams/teams-page.tsx index 664c098b53..804d9e5511 100644 --- a/app/src/components/teams/teams-page.tsx +++ b/app/src/components/teams/teams-page.tsx @@ -9,7 +9,12 @@ import { useInfiniteQuery, useQuery } from "@tanstack/react-query"; import { Link } from "@tanstack/react-router"; import { useEffect, useState } from "react"; import { TeamPage } from "@/components/edition/for-a-team"; -import { PageEmpty, PageRows, PageShell } from "@/components/layout/page-shell"; +import { + PageAddButton, + PageEmpty, + PageRows, + PageShell, +} from "@/components/layout/page-shell"; import { StaggerItem } from "@/components/layout/stagger"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; @@ -49,11 +54,12 @@ function Teams({ paths }: { paths: TeamPaths }) { const teams = list.data?.pages.flatMap((page) => page.teams) ?? []; const canCreate = list.data?.pages[0]?.canCreate === true; - const newTeam = (variant: "default" | "outline" = "default") => ( + // The empty state's; the page's own is `PageAddButton`, so the page has one filled button. + const newTeam = () => ( + Add key ) : undefined } description={ diff --git a/app/src/routes/_authed/_app/bots.index.tsx b/app/src/routes/_authed/_app/bots.index.tsx index 0d1647a5d9..48fece1ad7 100644 --- a/app/src/routes/_authed/_app/bots.index.tsx +++ b/app/src/routes/_authed/_app/bots.index.tsx @@ -1,20 +1,15 @@ -import { - IconBook, - IconBrain, - IconChevronRight, - IconPlus, -} from "@/components/icons"; +import { IconBook, IconBrain, IconChevronRight } from "@/components/icons"; import { useQuery } from "@tanstack/react-query"; import { createFileRoute, Link } from "@tanstack/react-router"; import { z } from "zod"; import { NewBotSheet } from "@/components/agents/new-bot-sheet"; import { BotRoster } from "@/components/bots/bot-roster"; import { + PageAddButton, PageRows, PageSection, PageShell, } from "@/components/layout/page-shell"; -import { Button } from "@/components/ui/button"; import { Item, ItemActions, @@ -78,15 +73,9 @@ function BotsPage() { return ( ( - - )} - size="sm" - > - + New Bot - + } description={ personal || alone diff --git a/app/src/routes/_authed/_app/connections.index.tsx b/app/src/routes/_authed/_app/connections.index.tsx index 0365aaa629..aa0c4327d5 100644 --- a/app/src/routes/_authed/_app/connections.index.tsx +++ b/app/src/routes/_authed/_app/connections.index.tsx @@ -6,6 +6,7 @@ import { IconChevronRight, IconLock, IconPlug, + IconPlus, IconSearch, } from "@/components/icons"; import { useQuery } from "@tanstack/react-query"; @@ -22,7 +23,6 @@ import { PageSection, PageShell, } from "@/components/layout/page-shell"; -import { AddAppButton } from "@/components/connections/add-app-button"; import { RowMark } from "@/components/layout/row-mark"; import { MovedAppsNotice } from "@/components/moves/moved-apps-notice"; import { directoryPressMode } from "@/components/plugins/broker-directory"; @@ -632,17 +632,20 @@ function RouteComponent() { return ( + mayAddServer ? ( + + ) : undefined } className="@container" description={ @@ -776,7 +779,7 @@ function RouteComponent() { title="No apps yet" > {openTeam - ? "Apps show up here once they're added. Add one with Add app." + ? "Apps show up here once they're added. Add one with Add custom MCP." : edition === "team" ? "Apps show up here once an admin turns them on." : edition === "personal" diff --git a/app/src/routes/_authed/admin/boundaries.tsx b/app/src/routes/_authed/admin/boundaries.tsx index 65b770714a..736c98fc66 100644 --- a/app/src/routes/_authed/admin/boundaries.tsx +++ b/app/src/routes/_authed/admin/boundaries.tsx @@ -7,6 +7,7 @@ import { import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { createFileRoute, Link } from "@tanstack/react-router"; import { + PageAddButton, PageEmpty, PageRows, PageSection, @@ -52,13 +53,9 @@ function BoundariesPage() { const policy = savePolicy.data ?? stored.data ?? null; const addRule = ( - + ); if (!policy) { diff --git a/app/src/routes/_authed/admin/identity-providers.tsx b/app/src/routes/_authed/admin/identity-providers.tsx index d074e3e404..d76d81bd9a 100644 --- a/app/src/routes/_authed/admin/identity-providers.tsx +++ b/app/src/routes/_authed/admin/identity-providers.tsx @@ -1,10 +1,11 @@ -import { IconBuildingBank, IconPlus, IconTrash } from "@/components/icons"; +import { IconBuildingBank, IconTrash } from "@/components/icons"; import { useMutation, useQuery } from "@tanstack/react-query"; import { createFileRoute, redirect } from "@tanstack/react-router"; import { useId, useState } from "react"; import { SignInSection } from "@/components/admin/controls/sign-in-section"; import { TeamPage } from "@/components/edition/for-a-team"; import { + PageAddButton, PageEmpty, PageRows, PageSection, @@ -153,10 +154,9 @@ function IdentityProvidersPage() { action={ // Offered once the server has said the providers are this organization's to change. providers.data?.managedHere ? ( - + setOpen(true)}> + Add a provider + ) : undefined } description={words.description} @@ -179,8 +179,7 @@ function IdentityProvidersPage() { setOpen(true)} size="sm" variant="outline"> - - Add provider + Add a provider } icon={IconBuildingBank} diff --git a/app/tests/admin-apps-add-server-entry.test.tsx b/app/tests/admin-apps-add-server-entry.test.tsx index a68d569168..4eb3af442b 100644 --- a/app/tests/admin-apps-add-server-entry.test.tsx +++ b/app/tests/admin-apps-add-server-entry.test.tsx @@ -17,7 +17,6 @@ import { RouterProvider, } from "@tanstack/react-router"; import { cleanup, render } from "@testing-library/react"; -import userEvent from "@testing-library/user-event"; import { authKeys } from "@/lib/auth/queries"; import { deploymentKeys } from "@/lib/deployment/queries"; import { Route as AdminAppsRoute } from "@/routes/_authed/admin/plugins/index"; @@ -34,9 +33,8 @@ import { settleReactWork } from "./settle-react-work"; * * Reported in dogfooding: adding an MCP server by its address was hard to find. An admin looked for * it where apps are set up, Admin then Apps, and it wasn't there: its button was only on - * Connections. Apps now offers it too, as Add custom MCP under Add app, the same words as - * Connections. It is offered to exactly the people Connections offers it to, and it opens Apps' own - * add page. + * Connections. Apps now offers it too, as Add custom MCP, the same words as Connections. It is + * offered to exactly the people Connections offers it to, and it opens Apps' own add page. */ beforeAll(() => GlobalRegistrator.register()); @@ -113,9 +111,7 @@ describe("Admin, Apps", () => { test(`offers an ${role} Add custom MCP, which opens its add page`, async () => { const view = draw(role, "team"); await view.findByRole("heading", { name: "Connected" }); - const user = userEvent.setup({ document }); - await user.click(view.getByRole("button", { name: "Add app" })); - const add = await view.findByRole("menuitem", { name: "Add custom MCP" }); + const add = view.getByRole("button", { name: "Add custom MCP" }); expect(add.getAttribute("href")).toBe("/admin/plugins/new"); }); } @@ -123,11 +119,7 @@ describe("Admin, Apps", () => { test("offers the one person of a personal OpenBot Add custom MCP", async () => { const view = draw("member", "personal"); await view.findByRole("heading", { name: "Connected" }); - const user = userEvent.setup({ document }); - await user.click(view.getByRole("button", { name: "Add app" })); - expect( - await view.findByRole("menuitem", { name: "Add custom MCP" }), - ).toBeTruthy(); + expect(view.getByRole("button", { name: "Add custom MCP" })).toBeTruthy(); }); test("offers a member no Add custom MCP, as Connections doesn't", async () => { diff --git a/app/tests/admin-apps-add-server.test.tsx b/app/tests/admin-apps-add-server.test.tsx index a50c92e6c7..a6c0b75c9f 100644 --- a/app/tests/admin-apps-add-server.test.tsx +++ b/app/tests/admin-apps-add-server.test.tsx @@ -162,10 +162,7 @@ describe("Admin, Apps, Add custom MCP", () => { expect(view.getByText("Nothing connected yet")).toBeTruthy(); const user = userEvent.setup({ document }); - await user.click(view.getByRole("button", { name: "Add app" })); - await user.click( - await view.findByRole("menuitem", { name: "Add custom MCP" }), - ); + await user.click(view.getByRole("button", { name: "Add custom MCP" })); // Connections' own form, with its way back named for Apps. await view.findByRole("heading", { name: "Add custom MCP", level: 1 }); diff --git a/app/tests/memory-settings.test.tsx b/app/tests/memory-settings.test.tsx index 69ffcf699d..ca9d7ea670 100644 --- a/app/tests/memory-settings.test.tsx +++ b/app/tests/memory-settings.test.tsx @@ -148,7 +148,7 @@ test("Edit memory says what the dialog is for", async () => { expect(view.queryByText("You told a Bot", { exact: true })).toBeNull(); }); -test("reopening Remember a fact after a failure starts clean", async () => { +test("reopening Add fact after a failure starts clean", async () => { serving(); refuseWrite = "Memory is full."; const view = draw(); diff --git a/app/tests/page-add-action.test.tsx b/app/tests/page-add-action.test.tsx deleted file mode 100644 index 12dd4f9a9b..0000000000 --- a/app/tests/page-add-action.test.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { - afterAll, - afterEach, - beforeAll, - describe, - expect, - test, -} from "bun:test"; -import { GlobalRegistrator } from "@happy-dom/global-registrator"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { - createMemoryHistory, - createRootRoute, - createRouter, - linkOptions, - RouterProvider, -} from "@tanstack/react-router"; -import { cleanup, render } from "@testing-library/react"; -import userEvent from "@testing-library/user-event"; -import type { ReactNode } from "react"; -import { AddAppButton } from "@/components/connections/add-app-button"; -import { PageShell } from "@/components/layout/page-shell"; -import { RememberFact } from "@/components/memory/memories"; -import { NewRoutineButton } from "@/components/routines/new-routine-button"; -import { settleReactWork } from "./settle-react-work"; - -/** - * ONE FILLED ADD BUTTON ON A LIST PAGE. Each list page's main add action sits in `PageShell`'s - * `action`, at the top right of the header, drawn as the Button's default (filled) variant at size - * `sm` with a plus. Before this, Bots, Skills, Memory, Vault and the rest each drew it their own way: - * ghost, outline, large, or down in a section. Apps names it for what most people do (Add app) and - * keeps the custom MCP server in its menu. - */ - -beforeAll(() => GlobalRegistrator.register()); -afterEach(cleanup); -afterAll(async () => { - await settleReactWork(); - GlobalRegistrator.unregister(); -}); - -const BROWSE = linkOptions({ to: "/connections/browse/composio" }); -const CUSTOM = linkOptions({ to: "/connections/new" }); - -/** Draws `node` inside a router and a query client, as a page has them. */ -function draw(node: ReactNode) { - const router = createRouter({ - history: createMemoryHistory({ initialEntries: ["/"] }), - routeTree: createRootRoute({ component: () => node }), - }); - return render( - - - , - ); -} - -/** The Button's default variant: the primary fill. */ -const filled = (element: HTMLElement) => - element.className.split(" ").includes("bg-primary"); -/** The Button's `sm` size. */ -const small = (element: HTMLElement) => - element.className.split(" ").includes("h-7"); - -describe("Add app", () => { - test("with a directory and a custom server, opens a menu of both", async () => { - const view = draw(); - const button = await view.findByRole("button", { name: "Add app" }); - expect(filled(button)).toBe(true); - expect(small(button)).toBe(true); - - await userEvent.setup({ document }).click(button); - expect( - (await view.findByRole("menuitem", { name: "Browse apps" })).getAttribute( - "href", - ), - ).toBe("/connections/browse/composio"); - expect( - view - .getByRole("menuitem", { name: "Add custom MCP" }) - .getAttribute("href"), - ).toBe("/connections/new"); - }); - - test("with only a custom server, its menu still names Add custom MCP", async () => { - const view = draw(); - await userEvent - .setup({ document }) - .click(await view.findByRole("button", { name: "Add app" })); - expect( - await view.findByRole("menuitem", { name: "Add custom MCP" }), - ).toBeTruthy(); - expect(view.queryByRole("menuitem", { name: "Browse apps" })).toBeNull(); - }); - - test("with only a directory, is the link to it", async () => { - const view = draw(); - const link = await view.findByRole("button", { name: "Add app" }); - expect(link.getAttribute("href")).toBe("/connections/browse/composio"); - expect(filled(link)).toBe(true); - }); - - test("with neither, draws nothing", async () => { - const view = draw( - } title="Apps"> -

Apps

-
, - ); - await view.findByRole("heading", { name: "Apps" }); - expect(view.queryByRole("button", { name: "Add app" })).toBeNull(); - }); -}); - -describe("the shared add buttons are filled by default", () => { - test("New routine, on a page's title row", async () => { - const view = draw(); - const button = await view.findByRole("button", { name: "New routine" }); - expect(filled(button)).toBe(true); - expect(small(button)).toBe(true); - }); - - test("New routine stays outlined where it stands alone in an empty state", async () => { - const view = draw(); - const button = await view.findByRole("button", { name: "New routine" }); - expect(filled(button)).toBe(false); - }); - - test("Add fact, Memory's one add action", async () => { - const view = draw(); - const button = await view.findByRole("button", { name: "Add fact" }); - expect(filled(button)).toBe(true); - expect(small(button)).toBe(true); - }); - - test("Add fact in a skin's own section keeps the skin's ghost look", async () => { - const view = draw(); - const button = await view.findByRole("button", { name: "Add fact" }); - expect(filled(button)).toBe(false); - }); -}); diff --git a/app/tests/page-add-button.test.tsx b/app/tests/page-add-button.test.tsx new file mode 100644 index 0000000000..26e07c7656 --- /dev/null +++ b/app/tests/page-add-button.test.tsx @@ -0,0 +1,193 @@ +import { + afterAll, + afterEach, + beforeAll, + describe, + expect, + test, +} from "bun:test"; +import { readdirSync, readFileSync, statSync } from "node:fs"; +import { join, relative } from "node:path"; +import { GlobalRegistrator } from "@happy-dom/global-registrator"; +import { + createMemoryHistory, + createRootRoute, + createRouter, + RouterProvider, +} from "@tanstack/react-router"; +import { cleanup, render } from "@testing-library/react"; +import type { ReactNode } from "react"; +import { PageAddButton } from "@/components/layout/page-shell"; +import { settleReactWork } from "./settle-react-work"; + +/* + * ONE FILLED ADD BUTTON ON A LIST PAGE, DRAWN ONCE. A list page's main add action is + * `PageAddButton` in `PageShell`'s `action`: filled, the page-action size, a plus and a short label. + * Before it, Bots, Skills, Memory, Vault and the rest each drew that button by hand, as ghost, + * outline, large or down in a section, so no two pages matched. + * + * Two parts: what `PageAddButton` draws, and a read of every page's header action under app/src, + * so a page that draws its add button by hand again fails here. + */ + +beforeAll(() => GlobalRegistrator.register()); +afterEach(cleanup); +afterAll(async () => { + await settleReactWork(); + GlobalRegistrator.unregister(); +}); + +function draw(node: ReactNode) { + const router = createRouter({ + history: createMemoryHistory({ initialEntries: ["/"] }), + routeTree: createRootRoute({ component: () => node }), + }); + return render(); +} + +const classes = (element: HTMLElement) => element.className.split(" "); + +describe("PageAddButton", () => { + test("a link: filled, the page-action size, with a plus", async () => { + const view = draw( + New team, + ); + const link = await view.findByRole("button", { name: "New team" }); + expect(link.getAttribute("href")).toBe("/teams/new"); + expect(classes(link)).toContain("bg-primary"); + expect(classes(link)).toContain("h-10"); + expect(link.querySelector("svg")).not.toBeNull(); + }); + + test("a press, for a page that opens its own dialog", async () => { + let pressed = 0; + const view = draw( + pressed++}>Add fact, + ); + const button = await view.findByRole("button", { name: "Add fact" }); + expect(button.getAttribute("href")).toBeNull(); + expect(classes(button)).toContain("bg-primary"); + button.click(); + expect(pressed).toBe(1); + }); +}); + +const SRC = join(import.meta.dir, "../src"); + +function sources(dir: string): string[] { + return readdirSync(dir).flatMap((name) => { + const path = join(dir, name); + if (statSync(path).isDirectory()) + return name === "generated" ? [] : sources(path); + return /\.tsx$/.test(name) ? [path] : []; + }); +} + +/** The text from `start` to the bracket that closes the one at `start`. */ +function balanced(text: string, start: number): string { + const open = text[start] as string; + const close = ({ "{": "}", "(": ")" } as Record)[open]; + let depth = 0; + for (let i = start; i < text.length; i++) { + if (text[i] === open) depth++; + else if (text[i] === close && --depth === 0) + return text.slice(start, i + 1); + } + return text.slice(start); +} + +/** The opening tag that starts at `start`: up to the first `>` outside braces and quotes. */ +function openingTag(text: string, start: number): string { + let depth = 0; + let quote: string | null = null; + for (let i = start; i < text.length; i++) { + const c = text[i] as string; + if (quote) { + if (c === quote) quote = null; + } else if (c === '"' || c === "`") quote = c; + else if (c === "{") depth++; + else if (c === "}") depth--; + else if (c === ">" && depth === 0) return text.slice(start, i + 1); + } + return text.slice(start); +} + +/** + * Each header action in a file: the `action={…}` of every ` { + const pages = sources(SRC).map((path) => ({ + file: relative(SRC, path), + actions: headerActions(readFileSync(path, "utf8")), + })); + const handDrawn = pages + .filter(({ actions }) => actions.some((a) => a.includes(" file); + + test("draws its add button with PageAddButton, not by hand", () => { + expect(handDrawn.filter((file) => !NOT_YET.includes(file))).toEqual([]); + }); + + test("the pages not yet moved are still listed for a reason", () => { + // A page taken off by its own change takes its entry off with it. + expect(NOT_YET.filter((file) => !handDrawn.includes(file))).toEqual([]); + }); + + test("the list pages each put PageAddButton, or a button made from it, in their header", () => { + const LIST_PAGES: Record = { + "routes/_authed/_app/bots.index.tsx": //, + "components/vault/vault-page.tsx": / { + const page = pages.find((one) => one.file === file); + return !page?.actions.some((action) => button.test(action)); + }) + .map(([file]) => file); + expect(missing).toEqual([]); + // And the two buttons made from it draw it on a title row. + for (const file of [ + "components/memory/memories.tsx", + "components/routines/new-routine-button.tsx", + ]) + expect(readFileSync(join(SRC, file), "utf8")).toContain(" { const view = identityProviders(); await view.findByText("No identity providers yet"); expect( - view.getAllByRole("button", { name: "Add provider" }).length, + view.getAllByRole("button", { name: "Add a provider" }).length, ).toBeGreaterThan(0); expect(view.queryByText("Set up for all of OpenBot")).toBeNull(); }); diff --git a/app/tests/team-connections-directory-layout.test.tsx b/app/tests/team-connections-directory-layout.test.tsx index 7691c0cfec..246b2ac1c8 100644 --- a/app/tests/team-connections-directory-layout.test.tsx +++ b/app/tests/team-connections-directory-layout.test.tsx @@ -309,7 +309,7 @@ describe.skipIf(!asked)("Connections on OpenBot Cloud", () => { const browse = page.getByTestId("account-browse"); await browse.waitFor({ timeout: 15_000 }); await page - .getByRole("button", { name: "Add app" }) + .getByRole("button", { name: "Add custom MCP" }) .waitFor({ timeout: 15_000 }); expect(await browse.innerText()).not.toContain("admin"); await style(page); diff --git a/app/tests/team-connections-directory.test.tsx b/app/tests/team-connections-directory.test.tsx index 730873a5d2..1e6c017512 100644 --- a/app/tests/team-connections-directory.test.tsx +++ b/app/tests/team-connections-directory.test.tsx @@ -568,27 +568,19 @@ describe("apps open, a member adds and connects in one press", () => { test("Add custom MCP is offered to a member with apps open, and not locked down", async () => { lockedDown = false; const open = draw("member"); - await open.user.click( - await open.view.findByRole("button", { name: "Add app" }), - ); - expect( - ( - await open.view.findByRole("menuitem", { name: "Browse apps" }) - ).getAttribute("href"), - ).toBe("/connections/browse/composio"); - const add = open.view.getByRole("menuitem", { name: "Add custom MCP" }); + const add = await open.view.findByRole("button", { + name: "Add custom MCP", + }); expect(add.getAttribute("href")).toBe("/connections/new"); cleanup(); - // Locked down, Add app is the way to the directory alone, where a member asks for an app. lockedDown = true; const locked = draw("member"); await locked.view.findByTestId("account-browse"); await settleReactWork(); expect( - locked.view.getByRole("button", { name: "Add app" }).getAttribute("href"), - ).toBe("/connections/browse/composio"); - expect(locked.view.queryByText("Add custom MCP")).toBeNull(); + locked.view.queryByRole("button", { name: "Add custom MCP" }), + ).toBeNull(); }); test("locked down, the catalogue's apps nobody has added aren't offered to anybody", async () => { diff --git a/app/tests/too-many-requests.test.tsx b/app/tests/too-many-requests.test.tsx index caf72d7198..c956f7f984 100644 --- a/app/tests/too-many-requests.test.tsx +++ b/app/tests/too-many-requests.test.tsx @@ -43,7 +43,7 @@ import { settleReactWork } from "./settle-react-work"; * Retry-After, never before; * - refused again and again, each wait is longer, and once answered it polls as before; * - a first load refused 429 keeps loading, then fills in with no failure drawn (Memory); - * - a press refused 429 says the server's own sentence, calmly (Memory's Remember a fact). + * - a press refused 429 says the server's own sentence, calmly (Memory's Add fact). */ const NativeResponse = globalThis.Response; @@ -222,7 +222,7 @@ test("Memory's first load refused 429 keeps loading, then fills in with nothing expect(asked[`GET ${MEMORY.memories}`]?.length).toBe(3); }, 10_000); -test("Remember a fact refused 429 says the server's sentence, calmly, and isn't sent again by itself", async () => { +test("Add fact refused 429 says the server's sentence, calmly, and isn't sent again by itself", async () => { serve(`GET ${MEMORY.memories}`, () => page(memoryContract.ListMemoriesResponse, "memories", []), ); From f356804c98ff63c8a8a22b5ea558aba90d3a1d26 Mon Sep 17 00:00:00 2001 From: Sam Julien Date: Tue, 1 Dec 2026 17:56:29 -0800 Subject: [PATCH 4/4] Leave CHANGELOG.md to the release: the note is in the PR description --- CHANGELOG.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c21677dbf5..9d5220bcf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,16 +55,6 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged. API key, with the scope and organization it has on the artifact's REST operations. A credential that isn't good there opens what nobody signed in opens, as before. -**List pages.** - -- **One filled add button beside the page title.** Bots, Skills, Memory, the Vault, Teams, a Bot's - Routines, API keys, and Admin's Skills, Apps, Vault, Teams, Boundaries and Identity providers - each drew their add button their own way: plain, outlined, large, or in a section lower down. - Each is now the same filled button with a plus, beside the page title. Empty states keep their - outlined button. -- **Memory says Add fact** on its button and its dialog, and no longer has a "Your memories" - heading under the page title. - **Smaller addresses.** - **Lists travel in a body, not the address.** Reading an app for the actions a Bot needs, and the