diff --git a/.claude/skills/openbot-screen-layout/SKILL.md b/.claude/skills/openbot-screen-layout/SKILL.md
index 7e455c4f13..a5fcfcf2ab 100644
--- a/.claude/skills/openbot-screen-layout/SKILL.md
+++ b/.claude/skills/openbot-screen-layout/SKILL.md
@@ -168,6 +168,10 @@ itself when the screen behind it changes something.
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.
+ The page's main add action is one filled button, in the header or in the page's sticky toolbar
+ where one exists (Apps). In the header it is `PageAddButton` in `PageShell`'s `action`: a plus
+ and a short label ("New Bot", "Add fact"). The same add in an empty state is `outline`. Row
+ actions can still be filled.
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.
@@ -178,7 +182,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 `PageAddButton` linking to it.
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 `
) : skills.length === 0 ? (
diff --git a/app/src/components/memory/memories.tsx b/app/src/components/memory/memories.tsx
index 8213f79dd8..1b093031ba 100644
--- a/app/src/components/memory/memories.tsx
+++ b/app/src/components/memory/memories.tsx
@@ -3,6 +3,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
import { Link } from "@tanstack/react-router";
import { Fragment, type ReactNode, useId, useState } from "react";
import {
+ PageAddButton,
PageEmpty,
PageRows,
PageSection,
@@ -49,30 +50,36 @@ import { failureSaid } from "@/lib/load-failure";
* The page's one primary verb, so it is a button for `PageShell`'s `action` that opens a dialog,
* rather than a form standing above the list somebody came to read.
*/
-export function RememberFact() {
+export function RememberFact({
+ variant = "page",
+}: {
+ /** `page` for `PageShell`'s `action`; a skin that draws its own header passes `ghost`. */
+ variant?: "page" | "ghost";
+} = {}) {
const [open, setOpen] = useState(false);
const [content, setContent] = useState("");
const formId = useId();
const remember = useMutation(createMemoryMutationOptions(queryClient));
+ // Opening starts clean: no draft or failure left from an earlier attempt.
+ const start = () => {
+ setContent("");
+ remember.reset();
+ setOpen(true);
+ };
return (
<>
-
+ {variant === "page" ? (
+ Add fact
+ ) : (
+
+ )}
) : teams.length === 0 ? (
diff --git a/app/src/components/vault/vault-page.tsx b/app/src/components/vault/vault-page.tsx
index b88bbab9db..c74c383a7c 100644
--- a/app/src/components/vault/vault-page.tsx
+++ b/app/src/components/vault/vault-page.tsx
@@ -1,9 +1,10 @@
-import { IconPlus } from "@/components/icons";
import { useQuery } from "@tanstack/react-query";
-import { Link } from "@tanstack/react-router";
-import { PageSection, PageShell } from "@/components/layout/page-shell";
+import {
+ PageAddButton,
+ PageSection,
+ PageShell,
+} from "@/components/layout/page-shell";
import { CredentialsList } from "@/components/manage/credentials-page";
-import { Button } from "@/components/ui/button";
import { useManagePaths } from "@/lib/manage-paths";
import { savedLoginsQueryOptions } from "@/lib/passwords/queries";
import { SavedLogins } from "./saved-logins";
@@ -24,6 +25,12 @@ export function VaultPage() {
const loginsTitle = count > 0 ? `Saved logins (${count})` : "Saved logins";
return (
Add key
+ ) : undefined
+ }
description={
personal
? "Your saved logins and keys are kept here. Bots never see them."
@@ -49,17 +56,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..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,16 +73,9 @@ function BotsPage() {
return (
(
-
- )}
- size="sm"
- variant="ghost"
- >
-
+
New Bot
-
+
}
description={
personal || alone
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..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,14 +53,9 @@ function BoundariesPage() {
const policy = savePolicy.data ?? stored.data ?? null;
const addRule = (
- }
- size="sm"
- variant="ghost"
- >
-
+
Add rule
-
+
);
if (!policy) {
diff --git a/app/src/routes/_authed/admin/identity-providers.tsx b/app/src/routes/_authed/admin/identity-providers.tsx
index 4e3764b43e..d76d81bd9a 100644
--- a/app/src/routes/_authed/admin/identity-providers.tsx
+++ b/app/src/routes/_authed/admin/identity-providers.tsx
@@ -5,6 +5,7 @@ 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,9 +154,9 @@ function IdentityProvidersPage() {
action={
// Offered once the server has said the providers are this organization's to change.
providers.data?.managedHere ? (
- setOpen(true)} size="lg">
+ setOpen(true)}>
Add a provider
-
+
) : undefined
}
description={words.description}
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/memory-settings.test.tsx b/app/tests/memory-settings.test.tsx
index 9ccfe8c9b0..ca9d7ea670 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",
@@ -148,12 +148,12 @@ 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();
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-button.test.tsx b/app/tests/page-add-button.test.tsx
new file mode 100644
index 0000000000..70bd879e0f
--- /dev/null
+++ b/app/tests/page-add-button.test.tsx
@@ -0,0 +1,183 @@
+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 definition = text.match(new RegExp(`const ${name} = `));
+ if (!definition?.index) return [];
+ const body = text.slice(definition.index + definition[0].length);
+ return [body.startsWith("(") ? balanced(body, 0) : body.split(";")[0]];
+ },
+ );
+ found.push([expression, ...named].join("\n"));
+ }
+ return found;
+}
+
+describe("every page's header", () => {
+ 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", () => {
+ // Apps keeps its add in the page's own toolbar, not in the header (#2646).
+ expect(handDrawn).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(" {
+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", []),
);
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",