Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .claude/skills/openbot-screen-layout/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 `<list>_.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 `<form>`, stacked in a single column, each a `Field`
Expand Down
33 changes: 32 additions & 1 deletion app/src/components/layout/page-shell.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -123,4 +123,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 ? (
<Button render={(props) => <Link {...link} {...props} />} size="lg">
<IconPlus />
{children}
</Button>
) : (
<Button onClick={onClick} size="lg">
<IconPlus />
{children}
</Button>
);
}

export { PageCard, PageEmpty, PageRows, PageSection } from "./page-parts";
10 changes: 2 additions & 8 deletions app/src/components/manage/credentials-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -36,14 +37,7 @@ export function CredentialsPage() {
<PageShell
action={
// Its own screen, `credentials_.new.tsx`, which says why the form is not on this page.
<Button
render={(props) => <Link {...props} {...paths.newCredential()} />}
size="sm"
variant="ghost"
>
<IconPlus />
Add {noun}
</Button>
<PageAddButton link={paths.newCredential()}>Add {noun}</PageAddButton>
}
description="Manage this organization’s keys and tokens. Saved secrets cannot be viewed again."
title={paths.credentialsLabel}
Expand Down
12 changes: 3 additions & 9 deletions app/src/components/manage/plugins-list-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
IconChevronRight,
IconCircleCheck,
IconPlug,
IconPlus,
} from "@/components/icons";
import { useQuery } from "@tanstack/react-query";
import { Link } from "@tanstack/react-router";
import * as React from "react";
import {
PageAddButton,
PageEmpty,
PageRows,
PageSection,
Expand All @@ -22,7 +22,6 @@ import {
usePendingRequestCounts,
} from "@/components/plugins/access-requests";
import { PluginLogo } from "@/components/plugins/plugin-logo";
import { Button } from "@/components/ui/button";
import {
Item,
ItemActions,
Expand Down Expand Up @@ -188,14 +187,9 @@ export function PluginsListPage({
*/
action={
mayAddServer ? (
<Button
render={(props) => <Link {...props} to="/admin/plugins/new" />}
size="sm"
variant="outline"
>
<IconPlus />
<PageAddButton link={{ to: "/admin/plugins/new" }}>
Add custom MCP
</Button>
</PageAddButton>
) : undefined
}
description="Connect services for your company, then choose which Bots can use each service’s tools."
Expand Down
12 changes: 7 additions & 5 deletions app/src/components/manage/skills-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -47,11 +48,12 @@ export function SkillsPage() {
const { data: hiddenAgents } = useQuery(agentListQueryOptions(true, scope));

const skills = skillList.data ?? [];
const newSkill = (size: "lg" | "sm") => (
// The empty state's; the page's own is `PageAddButton`, so the page has one filled button.
const newSkill = () => (
<Button
render={(props) => <Link {...props} {...paths.newSkill()} />}
size={size}
variant={size === "lg" ? "default" : "outline"}
size="sm"
variant="outline"
>
<IconPlus />
New skill
Expand All @@ -60,7 +62,7 @@ export function SkillsPage() {

return (
<PageShell
action={newSkill("lg")}
action={<PageAddButton link={paths.newSkill()}>New skill</PageAddButton>}
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."
title="Skills"
>
Expand All @@ -76,7 +78,7 @@ export function SkillsPage() {
</p>
) : skills.length === 0 ? (
<PageEmpty
action={newSkill("sm")}
action={newSkill()}
icon={IconFileText}
title="No skills yet"
>
Expand Down
48 changes: 25 additions & 23 deletions app/src/components/memory/memories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 (
<>
<Button
onClick={() => {
// Opening starts clean: no draft or failure left from an earlier attempt.
setContent("");
remember.reset();
setOpen(true);
}}
size="sm"
variant="ghost"
>
<IconPlus />
Remember a fact
</Button>
{variant === "page" ? (
<PageAddButton onClick={start}>Add fact</PageAddButton>
) : (
<Button onClick={start} size="sm" variant="ghost">
<IconPlus />
Add fact
</Button>
)}
<Dialog onOpenChange={setOpen} open={open}>
<DialogContent>
<DialogHeader>
<DialogTitle>Remember a fact</DialogTitle>
<DialogTitle>Add fact</DialogTitle>
<DialogDescription>All your Bots will know it.</DialogDescription>
</DialogHeader>
<DialogBody className="mt-4">
Expand Down Expand Up @@ -147,11 +154,8 @@ export function MemoryList({
const botName = (id: string | null) =>
agents.data?.find((agent) => agent.id === id)?.name ?? "your Bot";
return (
<PageSection
action={action}
description={description}
title="Your memories"
>
// One section, so no title: the page title already names it.
<PageSection action={action} description={description}>
{memories.isPending ? null : memories.error ? (
<p role="alert" className="mt-4 text-destructive text-sm">
{failureSaid(memories.error)}
Expand All @@ -175,9 +179,7 @@ export function MemoryList({
})}
</PageRows>
) : (
<PageEmpty icon={IconBrain} title="No memories yet">
Add one with Remember a fact.
</PageEmpty>
<PageEmpty icon={IconBrain} title="No memories yet" />
)}
</PageSection>
);
Expand Down
20 changes: 15 additions & 5 deletions app/src/components/routines/new-routine-button.tsx
Original file line number Diff line number Diff line change
@@ -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.
*
* `outline` where it stands alone in an empty state, `ghost` on a page's title row, as Add
* credential and New skill are drawn.
* 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 = "ghost",
variant = "page",
}: {
agentId?: string;
variant?: "ghost" | "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 (
<PageAddButton
link={{ search: agentId ? { agentId } : {}, to: "/routines/new" }}
>
New routine
</PageAddButton>
);
return (
<Button
render={(props) => (
Expand All @@ -27,7 +37,7 @@ export function NewRoutineButton({
/>
)}
size="sm"
variant={variant}
variant="outline"
>
<IconPlus />
New routine
Expand Down
16 changes: 12 additions & 4 deletions app/src/components/settings/api-keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { IconExternalLink, IconKey, IconPlus } from "@/components/icons";
import { useMutation, useQuery } from "@tanstack/react-query";
import { Fragment, useState } from "react";
import {
PageAddButton,
PageEmpty,
PageRows,
PageSection,
Expand Down Expand Up @@ -103,15 +104,22 @@ export function ApiKeysPage() {
const [creating, setCreating] = useState(false);
const [made, setMade] = useState<NewApiKey | null>(null);
const ready = list.data?.state === "ready";
const createButton = (size: "sm" | "lg", variant: "default" | "outline") => (
<Button onClick={() => setCreating(true)} size={size} variant={variant}>
// The empty state's; the page's own is `PageAddButton`, so the page has one filled button.
const createButton = () => (
<Button onClick={() => setCreating(true)} size="sm" variant="outline">
<IconPlus />
Create key
</Button>
);
return (
<PageShell
action={ready ? createButton("lg", "default") : undefined}
action={
ready ? (
<PageAddButton onClick={() => setCreating(true)}>
Create key
</PageAddButton>
) : undefined
}
description="Create a key so a script or another program can use OpenBot as you."
title="API keys"
>
Expand All @@ -136,7 +144,7 @@ export function ApiKeysPage() {
<BrowserOnly />
) : list.data.apiKeys.length === 0 ? (
<PageEmpty
action={createButton("sm", "outline")}
action={createButton()}
icon={IconKey}
title="No API keys yet"
>
Expand Down
Loading
Loading