Skip to content

Commit e797da4

Browse files
committed
Add buttons: draw them once with PageAddButton
PageAddButton, beside PageShell, is a list page's main add action: filled, the page-action size, a plus and a short label, as a link or a press. The list pages use it instead of each dropping a variant by hand, and page-add-button.test.tsx reads every page's header action under app/src. Apps keeps its header as on main: #2646 puts its add in the page's toolbar. Memory says Add fact on its button and dialog, has no section title, and its empty state drops the "Add one with" sentence. The layout skill keeps lg as the page-action size and states the rule.
1 parent 60e5e34 commit e797da4

27 files changed

Lines changed: 389 additions & 386 deletions

‎.claude/skills/openbot-screen-layout/SKILL.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ itself when the screen behind it changes something.
164164
### Procedure 4: Sizes and variants
165165

166166
1. `Item size="sm"` for rows inside a card. `default` only for a row standing on its own.
167-
2. `Button size="sm"` for a control inside a row or a dialog footer, and for a page's own action in
168-
`PageShell`'s `action`; `icon-sm` for a control floating over artwork.
169-
A list page's one add action goes in `PageShell`'s `action`, never in a section: a filled
170-
`Button` (the default variant), `size="sm"`, with `IconPlus` and a short label ("New Bot",
171-
"New skill", "Add app"). One filled button per page. The same add in an empty state is
172-
`outline`.
167+
2. `Button size="sm"` for a control inside a row or a dialog footer; `lg` for a page's own actions;
168+
`icon-sm` for a control floating over artwork.
169+
The page's main add action is one filled button, in the header or in the page's sticky toolbar
170+
where one exists (Apps). In the header it is `PageAddButton` in `PageShell`'s `action`: a plus
171+
and a short label ("New Bot", "Add fact"). The same add in an empty state is `outline`. Row
172+
actions can still be filled.
173173
3. `Item variant` — pick **one for the whole screen**. `muted` is a fill with no border; `outline` is
174174
a border with no fill; `default` is neither. Mixing two of them on one screen reads as two
175175
different kinds of list, and the reader looks for a distinction that is not there.
@@ -180,7 +180,7 @@ itself when the screen behind it changes something.
180180

181181
1. Creating a thing that takes several fields — a credential, a key — is its own screen, not a dialog
182182
over the list. Put it at `<list>_.new.tsx` (the `_` keeps it from nesting inside the list's route),
183-
and make the list's `action` a filled `Button size="sm"` rendering a `Link` to it (Procedure 4).
183+
and make the list's `action` a `PageAddButton` linking to it.
184184
2. `PageShell` with `backButton` pointing at the list, a title that is the verb ("Add credential"),
185185
and a description saying what happens on save.
186186
3. The fields go in one `PageCard` inside a `<form>`, stacked in a single column, each a `Field`

‎CHANGELOG.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
5151

5252
**List pages.**
5353

54-
- **One filled add button, top right, on every list page.** Bots, Skills, Memory, Vault, Teams, a
55-
Bot's Routines, API keys and Admin's lists each drew their add button their own way: plain,
56-
outlined, large, or in a section lower down. Each is now one filled button beside the page title,
57-
with a plus and a short label.
58-
- **Apps: Add app.** The button is named for what most people do. It opens a menu with Browse apps
59-
and Add custom MCP. Somebody who can't add a custom server gets a link to Browse apps.
60-
- **Memory: Add fact** replaces Remember a fact, and Identity providers says Add provider.
54+
- **One filled add button beside the page title.** Bots, Skills, Memory, the Vault, Teams, a Bot's
55+
Routines, API keys, and Admin's Skills, Apps, Vault, Teams, Boundaries and Identity providers
56+
each drew their add button their own way: plain, outlined, large, or in a section lower down.
57+
Each is now the same filled button with a plus, beside the page title. Empty states keep their
58+
outlined button.
59+
- **Memory says Add fact** on its button and its dialog, and no longer has a "Your memories"
60+
heading under the page title.
6161

6262
**Smaller addresses.**
6363

‎app/src/components/connections/add-app-button.tsx‎

Lines changed: 0 additions & 64 deletions
This file was deleted.

‎app/src/components/layout/page-shell.tsx‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IconChevronLeft } from "@/components/icons";
1+
import { IconChevronLeft, IconPlus } from "@/components/icons";
22
import { Link, type LinkProps } from "@tanstack/react-router";
33
import type * as React from "react";
44
import { cn } from "@/lib/utils";
@@ -116,4 +116,35 @@ export function PageShell({
116116
);
117117
}
118118

119+
/**
120+
* A list page's main add action, for `PageShell`'s `action`: one filled button with a plus and a
121+
* short label ("New Bot", "Add fact"). Drawn here, once, so every list page draws it the same way:
122+
* the default variant and the page-action size (the layout skill, Procedure 4). It is a link to the
123+
* screen where the thing is made, or, given `onClick`, opens what the page opens itself.
124+
*
125+
* One per page. The same add in an empty state is an outlined `Button size="sm"`, so the page still
126+
* has one filled button. It lives here, not in `page-parts.tsx`, because a link needs the router and
127+
* that file imports none.
128+
*/
129+
export function PageAddButton({
130+
children,
131+
link,
132+
onClick,
133+
}: { children: React.ReactNode } & (
134+
| { link: LinkProps; onClick?: never }
135+
| { onClick: () => void; link?: never }
136+
)) {
137+
return link ? (
138+
<Button render={(props) => <Link {...link} {...props} />} size="lg">
139+
<IconPlus />
140+
{children}
141+
</Button>
142+
) : (
143+
<Button onClick={onClick} size="lg">
144+
<IconPlus />
145+
{children}
146+
</Button>
147+
);
148+
}
149+
119150
export { PageCard, PageEmpty, PageRows, PageSection } from "./page-parts";

‎app/src/components/manage/credentials-page.tsx‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { IconKey, IconPlus } from "@/components/icons";
22
import { useMutation, useQuery } from "@tanstack/react-query";
33
import { Link } from "@tanstack/react-router";
44
import {
5+
PageAddButton,
56
PageEmpty,
67
PageRows,
78
PageSection,
@@ -36,13 +37,7 @@ export function CredentialsPage() {
3637
<PageShell
3738
action={
3839
// Its own screen, `credentials_.new.tsx`, which says why the form is not on this page.
39-
<Button
40-
render={(props) => <Link {...props} {...paths.newCredential()} />}
41-
size="sm"
42-
>
43-
<IconPlus />
44-
Add {noun}
45-
</Button>
40+
<PageAddButton link={paths.newCredential()}>Add {noun}</PageAddButton>
4641
}
4742
description="Manage this organization’s keys and tokens. Saved secrets cannot be viewed again."
4843
title={paths.credentialsLabel}

‎app/src/components/manage/plugins-list-page.tsx‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import {
77
IconPlug,
88
} from "@/components/icons";
99
import { useQuery } from "@tanstack/react-query";
10-
import { Link, linkOptions } from "@tanstack/react-router";
10+
import { Link } from "@tanstack/react-router";
1111
import * as React from "react";
1212
import {
13+
PageAddButton,
1314
PageEmpty,
1415
PageRows,
1516
PageSection,
1617
PageShell,
1718
} from "@/components/layout/page-shell";
18-
import { AddAppButton } from "@/components/connections/add-app-button";
1919
import { RowMark } from "@/components/layout/row-mark";
2020
import {
2121
AccessRequestsSection,
@@ -140,7 +140,7 @@ export function PluginsListPage({
140140
const paths = useManagePaths();
141141
const edition = useQuery(deploymentCapabilitiesQueryOptions()).data?.edition;
142142
const role = useQuery(currentUserQueryOptions()).data?.role;
143-
// Offered to exactly the people Connections offers its custom MCP server to.
143+
// Offered to exactly the people Connections offers its Add custom MCP to.
144144
const mayAddServer = mayAddApps(edition === "personal", role);
145145
const plugins = useQuery(appsQueryOptions());
146146
const catalogue = useQuery(catalogueQueryOptions());
@@ -182,17 +182,15 @@ export function PluginsListPage({
182182
return (
183183
<PageShell
184184
/*
185-
* The page's one verb, as on Connections: Add app, for the directory and for an MCP server
186-
* OpenBot doesn't list, added by its address. The same form, opened from here, so an admin
187-
* finds it where apps are set up.
185+
* The page's one verb, as on Connections: an MCP server OpenBot doesn't list, added by its
186+
* address. The same form, opened from here, so an admin finds it where apps are set up.
188187
*/
189188
action={
190-
<AddAppButton
191-
browse={moreApps.linked ? paths.brokerDirectory(provider) : undefined}
192-
customServer={
193-
mayAddServer ? linkOptions({ to: "/admin/plugins/new" }) : undefined
194-
}
195-
/>
189+
mayAddServer ? (
190+
<PageAddButton link={{ to: "/admin/plugins/new" }}>
191+
Add custom MCP
192+
</PageAddButton>
193+
) : undefined
196194
}
197195
description="Connect services for your company, then choose which Bots can use each service’s tools."
198196
title="Apps"

‎app/src/components/manage/skills-page.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useQuery } from "@tanstack/react-query";
33
import { Link } from "@tanstack/react-router";
44
import * as React from "react";
55
import {
6+
PageAddButton,
67
PageEmpty,
78
PageRows,
89
PageSection,
@@ -47,11 +48,12 @@ export function SkillsPage() {
4748
const { data: hiddenAgents } = useQuery(agentListQueryOptions(true, scope));
4849

4950
const skills = skillList.data ?? [];
50-
const newSkill = (variant: "default" | "outline" = "default") => (
51+
// The empty state's; the page's own is `PageAddButton`, so the page has one filled button.
52+
const newSkill = () => (
5153
<Button
5254
render={(props) => <Link {...props} {...paths.newSkill()} />}
5355
size="sm"
54-
variant={variant}
56+
variant="outline"
5557
>
5658
<IconPlus />
5759
New skill
@@ -60,7 +62,7 @@ export function SkillsPage() {
6062

6163
return (
6264
<PageShell
63-
action={newSkill()}
65+
action={<PageAddButton link={paths.newSkill()}>New skill</PageAddButton>}
6466
description="Write instructions a Bot follows when someone picks a skill from the / menu. A skill only uses what a Bot can already do, and you choose which Bots offer it."
6567
title="Skills"
6668
>
@@ -76,7 +78,7 @@ export function SkillsPage() {
7678
</p>
7779
) : skills.length === 0 ? (
7880
<PageEmpty
79-
action={newSkill("outline")}
81+
action={newSkill()}
8082
icon={IconFileText}
8183
title="No skills yet"
8284
>

‎app/src/components/memory/memories.tsx‎

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
33
import { Link } from "@tanstack/react-router";
44
import { Fragment, type ReactNode, useId, useState } from "react";
55
import {
6+
PageAddButton,
67
PageEmpty,
78
PageRows,
89
PageSection,
@@ -50,34 +51,35 @@ import { failureSaid } from "@/lib/load-failure";
5051
* rather than a form standing above the list somebody came to read.
5152
*/
5253
export function RememberFact({
53-
variant = "default",
54+
variant = "page",
5455
}: {
55-
/** Filled as the page's one add action (`PageShell`'s `action`); a skin's section passes `ghost`. */
56-
variant?: "default" | "ghost";
56+
/** `page` for `PageShell`'s `action`; a skin that draws its own header passes `ghost`. */
57+
variant?: "page" | "ghost";
5758
} = {}) {
5859
const [open, setOpen] = useState(false);
5960
const [content, setContent] = useState("");
6061
const formId = useId();
6162
const remember = useMutation(createMemoryMutationOptions(queryClient));
63+
// Opening starts clean: no draft or failure left from an earlier attempt.
64+
const start = () => {
65+
setContent("");
66+
remember.reset();
67+
setOpen(true);
68+
};
6269
return (
6370
<>
64-
<Button
65-
onClick={() => {
66-
// Opening starts clean: no draft or failure left from an earlier attempt.
67-
setContent("");
68-
remember.reset();
69-
setOpen(true);
70-
}}
71-
size="sm"
72-
variant={variant}
73-
>
74-
<IconPlus />
75-
Add fact
76-
</Button>
71+
{variant === "page" ? (
72+
<PageAddButton onClick={start}>Add fact</PageAddButton>
73+
) : (
74+
<Button onClick={start} size="sm" variant="ghost">
75+
<IconPlus />
76+
Add fact
77+
</Button>
78+
)}
7779
<Dialog onOpenChange={setOpen} open={open}>
7880
<DialogContent>
7981
<DialogHeader>
80-
<DialogTitle>Remember a fact</DialogTitle>
82+
<DialogTitle>Add fact</DialogTitle>
8183
<DialogDescription>All your Bots will know it.</DialogDescription>
8284
</DialogHeader>
8385
<DialogBody className="mt-4">
@@ -152,11 +154,8 @@ export function MemoryList({
152154
const botName = (id: string | null) =>
153155
agents.data?.find((agent) => agent.id === id)?.name ?? "your Bot";
154156
return (
155-
<PageSection
156-
action={action}
157-
description={description}
158-
title="Your memories"
159-
>
157+
// One section, so no title: the page title already names it.
158+
<PageSection action={action} description={description}>
160159
{memories.isPending ? null : memories.error ? (
161160
<p role="alert" className="mt-4 text-destructive text-sm">
162161
{failureSaid(memories.error)}
@@ -180,9 +179,7 @@ export function MemoryList({
180179
})}
181180
</PageRows>
182181
) : (
183-
<PageEmpty icon={IconBrain} title="No memories yet">
184-
Add one with Remember a fact.
185-
</PageEmpty>
182+
<PageEmpty icon={IconBrain} title="No memories yet" />
186183
)}
187184
</PageSection>
188185
);

0 commit comments

Comments
 (0)