Skip to content

Latest commit

 

History

History
412 lines (356 loc) · 29 KB

app-guidelines.md

File metadata and controls

412 lines (356 loc) · 29 KB

App guidelines

What we have agreed about OpenBot's apps: OpenBot Mobile (mobile/), and the web app and OpenBot Desktop (app/, desktop/). Read the part for the app you work on before you plan a screen or a feature for it.

These are product guidelines: what each app is for, what it is built with, and what it leaves out. Don't break the API or the database holds the hard rules, and they come first.

Every app

One color scheme, used sparingly

Every app draws with the same colors, and with few of them. This is strict: a change that breaks one of the rules below is not merged.

The scheme is the set of tokens in tokens/src/scheme.ts, each with a light and a dark value and what it means: background, foreground, card, popover, primary, secondary, muted, accent, destructive, success, warning, border, input and ring, and the chart and sidebar sets.

The grays are Tailwind's slate. In light each gray is slate at its own lightness; in dark, slate's hue moves from 265 to 252 with 40% of its tint, since slate's own dark leans indigo and reads purple. CopilotKit's lavender marks only what it means: the ring, the selected sidebar row (sidebar-accent) and the empty pattern. tokens/tests/slate.test.ts holds both.

  • Only the tokens. No color value in a screen or a component: no hex, no rgb(), no oklch(). No class from Tailwind's palette either (bg-blue-500, text-amber-600). Write bg-background, text-muted-foreground, border-border. A tint is the token with an opacity: bg-warning/10.
  • Mostly neutral. A screen is background, cards, text, muted text and borders. Nothing is colored to decorate it or to make it stand out.
  • A color means one thing. destructive is for what deletes or what failed. success is for what worked, or is working. warning is for what needs the person: something waits on them, or may not go as they expect. ring is for focus. If none of those is what you mean, the answer is no color.
  • The token has the dark value. Write the class once. No dark: override of a color.
  • Light and dark, both. A token carries both values, so a screen drawn with tokens has both. Check both before you ask for a review.
  • A new color is a change to the scheme. If a screen needs a color the scheme doesn't have, agree it first. Then it becomes a token in tokens/src/scheme.ts, with a light and a dark value and what it means, for every app. It is never added in one app only.
  • A color is never renamed or removed. A customer's theme sets the scheme's colors by name, so a name the scheme drops leaves their theme doing nothing. Change its value instead.

Where the scheme lives

tokens/ (@openbot/tokens) is the one source. Every app that can't import it keeps a copy, and the copies are written, never edited:

Copy Written as
app/src/theme.css (the web app, and the Recorder's pages, which import it) CSS custom properties, light in :root and dark in .dark
desktop/src/styles.css, desktop/src-tauri/src/connected/sign_in.rs (OpenBot Desktop's setup window and sign-in page) CSS custom properties, the tokens each uses
desktop/src-tauri/src/first_paint.rs (the window's color before the page draws) RGB
mobile/src/scheme.ts (OpenBot Mobile's old screens) Hex, since React Native draws no oklch()
mobile/global.css (OpenBot Mobile, under HeroUI Native's names) CSS custom properties, light under @variant light and dark under @variant dark
app/public/manifest.webmanifest (the web app on a phone's home screen or installed) Hex, the light background only

To change a color: change it in tokens/src/scheme.ts, run bun run tokens:generate, and commit the scheme with every copy it rewrites. A copy inside a hand-written file sits between two marker comments (tokens/src/scheme.ts, light: … and end of tokens/src/scheme.ts); the generator writes only between them. A new copy is added to tokens/src/targets.ts.

The tests that hold it, and what makes each fail. Fix the change, never the test:

Test Fails when
tokens/tests/generated.test.ts A copy isn't what the scheme writes: edited by hand, or the scheme changed without running the generator.
app/tests/color-scheme.test.ts The web app has an amber or green class anywhere, or another palette class in a file that didn't already have one.
app/tests/design-tokens.test.ts The surfaces stop going darkest to lightest, a menu's highlight matches its surface, or theme.css declares a token beyond the scheme's.

Two places don't keep these rules yet. Don't add to either:

  • A few web app files still draw with Tailwind's palette: decorative tones in onboarding, a sidebar badge, a call button. The test lists them, and the list only gets shorter. Move a file's colors to tokens and take it off the list.

OpenBot Mobile

It is not a clone of the desktop app

OpenBot Mobile doesn't have to do everything the web app and OpenBot Desktop do. A screen on the desktop is not a reason to build the same screen on the phone.

For launch: the core Bot experience

For launch, OpenBot Mobile focuses on three things:

  • Bot screens
  • Conversations
  • Routines

Before you start work on OpenBot Mobile, check that it is part of one of the three. If it isn't, it is not launch work: raise it before you build it.

A Bot's computer is a tool call

For now OpenBot Mobile has no Computer screen. When a Bot uses its computer, the conversation shows it as a tool call. The Computer screen mobile/ has today is not part of launch.

The stack

OpenBot Mobile's stack is what mobile/ has today, plus the styling and components of Better-T-Stack's native Uniwind template. That template has no backend, no API layer, no database and no sign-in of its own, because ours stay.

What mobile/ has today, which stays:

Part What we use
App Expo with React Native and React 19, in TypeScript's strict mode. One app for iOS and Android.
Screens Expo Router: a file under mobile/app/ is a screen.
The API A client generated from api/openapi.yaml by Orval, in src/api/generated. Never edited by hand: see mobile/AGENTS.md.
Data TanStack Query (mobile/src/query-client.ts): one copy of each answer, shared by every screen that shows it, under keys that start with the kind of data (mobile/src/queries.ts). Nothing is read on a timer. What changed is read again when the conversation events socket says so (mobile/src/live-updates.ts), when the app comes back to the front, on a pull, and after the person's own change.
Sign-in OAuth 2.1 with PKCE, as the server's openbot-mobile client (mobile/src/oauth.ts), in the system browser's sign-in session. The refresh token is kept in expo-secure-store. It works on every OpenBot, OpenBot Cloud included, where the server has EXPO_PROJECT_ID.
Notifications expo-notifications.
Builds EAS. In development it runs as a development client (expo-dev-client), not in Expo Go.
Updates EAS Update (expo-updates): new JavaScript for installed apps, without a store release. The runtime version is a fingerprint of the native side. See mobile/README.md.
Packages npm, with mobile/package-lock.json. The rest of the repository uses Bun.

What the template adds:

Part What we use
Styling Uniwind: Tailwind CSS 4 classes on React Native components, written in className, as in the web app.
The theme mobile/global.css: the one stylesheet. It imports Tailwind, Uniwind and HeroUI Native's styles, and the color scheme, written into it from tokens/.
Components HeroUI Native: buttons, fields, sheets, dialogs and the rest, built on Uniwind.
Under them react-native-reanimated, react-native-gesture-handler, react-native-keyboard-controller and react-native-svg, which HeroUI Native's components need.

How we use it:

  • Expo's SDK first, on its own. mobile/ is on Expo SDK 58, the template's. It moved there in a change of its own, before any Uniwind work, so a problem from the upgrade is never mistaken for one from the restyle. Keep to the newest SDK from then on, each move in a change of its own.
  • Add the template's parts to mobile/. Don't generate a new app from it. Its drawer, tabs and sample screens are not ours.
  • Install with npx expo install, so each package gets the version that fits our Expo SDK.
  • Read the docs for the SDK we're on. Expo renames and moves APIs between SDKs. Check the version in mobile/package.json and read that version's docs before you use an Expo or React Native API from memory.
  • Style with className. No StyleSheet.create, and no style object for something a class can say.

What draws what

The platform draws everything around a screen. HeroUI Native draws what is inside it.

What Drawn by
Stacks, headers, titles, back buttons Expo Router's native Stack, set in the route's layout or the screen's options.
Tabs Expo Router's NativeTabs (mobile/app/(tabs)/_layout.tsx): UIKit's tab bar on iOS, iOS 26's glass with SF Symbols, and Material 3's navigation bar on Android, with Material Symbols.
Back buttons The platform's own: iOS's chevron (in glass on iOS 26) with its edge swipe, Android's arrow with its back gesture.
Header buttons (new, a Bot's computer and settings) headerActions (mobile/src/header.tsx): native bar button items with SF Symbols on iOS, icon buttons in the toolbar on Android. A tab's title sits at the start of the bar, level with them (tabRoot).
Header menus, search in the header, a bottom toolbar The native Stack toolbar and search bar.
Sheets and modals Expo Router's native presentations (formSheet, modal).
Pickers, switches, sliders, system menus @expo/ui, so they look and behave as the platform's own.
Buttons, fields, cards, chips, alerts, and the rest of a screen's content HeroUI Native.
Long lists: conversations, messages, runs A virtualized list (FlatList, or one built for chat). Never a ScrollView with a map inside.
A page or form with fields ScrollScreen (react-native-keyboard-controller's KeyboardAwareScrollView): the field being typed in stays above the keyboard, and the form's button can be scrolled to while it is up.
A bar at the bottom with a field (the message box) KeyboardBar, inside a KeyboardAvoidingView around the screen, so the bar rides on the keyboard.
  • Native chrome stays native. Don't draw a header, a tab bar or a sheet yourself, even when HeroUI Native could make one that looks the same. The native one gets each platform's look for free, including iOS's glass material and Android's Material behavior, and keeps it as the platforms change.
  • Don't imitate glass. No blur, gradient or translucent card to look like the system's material. It comes from the native components or not at all.
  • The lightest screen that works. Use HeroUI Native's components, but only as many as the screen needs. A screen can be text and one button. Add a card, a chip or an alert only when it groups something, shows a state, or can be acted on.
  • Use a component before you build one. First one mobile/ already has, then HeroUI Native's. Build your own only when neither fits, and build it from the same tokens.
  • Check what you can't typecheck. Before you ask for a review of a screen, look at it on iOS and on Android, in light and in dark, and with the keyboard open if it has a field. Say in the pull request which of those you looked at.

The color scheme on the phone

The rules under One color scheme, used sparingly hold here too.

HeroUI Native has its own names for the tokens, and two of them mean something else than the web app's token of the same name. mobile/global.css takes the scheme under HeroUI Native's names, for light and for dark, written by bun run tokens:generate with the mapping below (an entry --surface=card in its marker comment).

No other file in mobile/ has a color value in it, but two: src/orb-palette.ts, a Bot's orb colors, and src/brand-logo.tsx, an AI provider's own mark in its own colors. Those are a Bot's identity, the same on the phone as on the web app, and mobile/tests/orb-palette.test.ts holds them to app/src/lib/orb-palette.ts.

HeroUI Native token Takes the scheme's
background, foreground background, foreground
surface card
overlay popover
default secondary
muted (a text color here) muted-foreground
accent (the main action here) primary
danger destructive
success success
warning warning
border border
focus ring
field-background, field-border card, input
segment, separator card, border
fill (ours: a quiet fill, bg-fill) muted
sidebar and its set (ours: the app's menu) sidebar and its set

The phone's components

mobile/src/components is OpenBot Mobile's library, drawn from the scheme with Uniwind and HeroUI Native: text in Inter, a Bot's orb, rows, conversation rows, messages, the message box, notices, empty states, cards, the switch, the segmented control, a choice list for options too long for it, and the search field and large title Android draws itself. A screen uses these first, then HeroUI Native's, and builds its own only when neither fits. The development build shows every one at /gallery (mobile/app/gallery.tsx), in light and dark; a new component goes there too.

  • Icons come from src/icons.ts. Tabler's index holds every icon, and Metro bundles every one it reaches. src/icons.ts imports each icon the app uses from its own file.
  • HeroUI Native from its own paths: heroui-native/button, never heroui-native, for the same reason.
  • The look is the web app's. Inter, Tabler at a 1.75 line, buttons as rounded rectangles rather than HeroUI's pills, rows as one card with hairline dividers and 32px icon tiles, the person's messages in a quiet bubble and a Bot's as plain text, and the message box the one control that lights while someone types.
  • Opening the app is one movement (mobile/src/launch.tsx): the phone's splash is OpenBot's orb on the screen's background, the app draws the same frame over everything until the fonts, the security floor, the session and the version check have answered, and then the orb glides into Welcome, or swells and fades into a signed-in screen. Nothing else draws a loading screen of its own while the app opens.
  • The tabs are the signed-in app's four, in the platform's tab bar, as icons with no words: Chats, Bots (OpenBot's orb as a flat glyph), Notifications, and your Account. Notifications' badge counts what waits on the person there. Each tab is a stack of its own with the native header, its title at the start of the bar. A conversation, a Bot and everything else opened from a tab open in the app's stack over the tabs, so the tab bar steps aside and the message box has the bottom to itself.
  • Account is the settings list. Under who is signed in, two groups of rows (SettingRow), as the web app's settings group them: "You" (General, Notifications, Organization) and "Every Bot" (AI providers, Approvals, Routines, Memory, Skills, Connections). Each row opens its screen in the app's stack. Sign out and Delete account are the last rows, in red. What only a computer has (the computer, the setup checklist, troubleshooting logs) and an admin's consoles stay on the web app.
  • Notifications is one place, a tab: everything that waits on the person, by kind: approvals and questions from their Bots, what the Bots' check-ins found, and the tasks that wait. While this phone isn't told, its switch is the first row; once it is, the switch goes. Which kinds go where is Account, Notifications. The address needs-you, which a ping's notification opens, goes there.
  • A tab's own list runs to the screen's edges, with no card (ListRow): Chats, Bots, Notifications, and Organizations, where an organization is a row with its letter and the one worked in has the tick. A card of rows with hairlines and icon tiles (Rows) is for a page of settings opened from one. What a row is about shows in its shape: a person is a circle, a Bot its orb, an organization a rounded square with its letter.
  • A row's own action is a swipe (SwipeRow): the row slides left and one button, its glyph alone, is in the room it leaves, as in the phone's own lists. A swipe alone never does it, and what deletes still asks first. An organization swipes for Delete (its owner) or Leave (anybody else).
  • An empty list says so in the middle of the screen (EmptyState): a glyph, its name, a line or two, and one button when the way on is right there. No box around it. A page (ScrollScreen) and a tab's list (ScreenList) are as tall as what the bars leave, so it centers in what the person sees and the empty page doesn't scroll.
  • Nothing is drawn where a page meets the header: no shadow, no line, no fade. What scrolls up goes under the bar's own edge, as in the phone's own apps. A chat is the one exception (below).
  • Chats is the word for conversations, everywhere a person reads it.
  • A chat is headed as iMessage heads one: the orbs of the Bots in it and their names, and tapping it opens the Bot's page, or a group's Bots. It reads from the top down, and opens at its newest message once it is longer than the screen. Only an empty chat shows the Bot in the middle of the page; the first message flies its orb up into the header. The chat scrolls on under its header, blurred most behind the status bar and fading out a little below the bar (iOS; a tint alone on Android), with the names on a small glass pill. The header steps aside while the person reads: it slides up as they scroll down, and comes back as soon as they scroll up, reach the top, or send (mobile/src/hiding-header.tsx). Two or more Bots make a group: every Bot reads what is sent, and each reply carries its Bot's orb and name.
  • A Bot's work shows as it happens, as in the web app. From the moment a message is sent there is one row under it that says what the Bot is doing and only changes its words: "Thinking…", then each step in the web app's own words while it runs ("Search the web…"), then what the steps did once they are over, in one phrase counted by kind as the web app's folded line says it ("Searched the web and read 2 pages"). Opened, each step is a line after its kind's icon, on a thin branch from that row, and never what the tool answered (mobile/src/run-steps.ts). The reply is written under it as it comes, as markdown, with what is half written closed or held back so no symbols show. Nothing is added to the page and taken away again, and a reply never steps back to a shorter reading of itself: a run that ended stays drawn from what the socket carried until the messages read back hold it in full (mobile/src/live-run.ts). The step words are a written copy of shared/tool-name.ts (bun run mobile:shared); never edit mobile/src/shared-copy/.
  • A conversation's cards are the web app's. A step whose answer names an app (a refusal, or show_app_access) is the web app's app-access card on a row of its own, with its sentence, its one press and, once the app is ready, the task carried on (mobile/src/app-access.ts, mobile/src/carry-on.ts); mobile/tests/app-access-words.test.ts holds its words to the web app's. A Team Bot's ask is its consent card. An approval is the web app's decision card, each answer with what it does. A refused or broken step says so ("Blocked: …", "…, didn't work"), a turn the server refused stays with why under it (mobile/src/refused-turns.ts), and in a group somebody else's message is on the left under their name. A step only an admin's page on the web app can finish says to set it up in OpenBot on a computer. The development build shows each of these under "Conversation cards" at /gallery.
  • Each platform's own chrome. The chrome around a screen is each platform's, not one look on both: a tab's title sits at the start of the bar with its buttons at the end, search among them (iOS 26's search button, Android's toolbar search icon). Android's sheets draw their handle and title in the sheet (SheetTitle), where iOS's sheet has its own. What is inside a screen, drawn from the scheme, is the same on both. Check a change on both before it lands.

iPhone Duo

iPhone Duo folds. Closed, its outer display is a phone. Open, its inner display is about 950 points across and 670 high. The app fills both, as Apple's own apps do: it is built with Xcode 27.1 or newer, which is what lets an iPhone app fill the inner display rather than sit in the middle of it at a phone's size.

  • Clear of the side bars. On iPhone Duo, iOS puts the tab bar in a rail at the side of the display, in the column the status bar runs down. Nothing the app draws goes under them: every screen keeps clear of the display's side safe areas (ScrollScreen, ScreenList and ScreenScrollView in mobile/src/components/screen.tsx, and a conversation's own). There is no status bar at the top, so a bar the app draws keeps some room there (useTopRoom).
  • Closed, the phone's layout. The outer display is a phone, so every screen is the phone's own.
  • Open, nothing is a stretched phone. A window 700 points across or more is a big screen (mobile/src/wide.ts). Read the window's width at each render and never keep it: folding and unfolding change it while the app runs.
    • Chats is two panes, as on the desktop app. The list is a column, headed by its own title, New chat and search, with the conversation open beside it: the one picked, marked as the web app's sidebar marks its row, or else the newest. Each pane heads itself, so the tab's own bar steps aside: this, and a conversation's header, are the only bars the app draws. New chat opens its conversation in the pane.
    • Every other page is a column. Its rows and text keep a column 640 points wide in the middle of what the side bars leave, and its title heads that column: a tab's title starts where its rows do, and a page's is centered over it. A conversation opened over the tabs keeps its messages and its message box in the same column.
    • Sign-in and onboarding are a phone's width, in the middle.
    • A sheet is iOS's own, a page sheet in the middle of the display with its title centered.
  • Folding keeps the person where they were. Closing the phone on a conversation picked beside the list keeps it open on the outer display. Opening the phone on it again puts it back beside the list.
  • Android foldables and tablets get the same layout at the same width (700 dp): Chats in two panes, every other page a column, and folding that keeps the open conversation. A page's title is Material's center-aligned top app bar, over the column. The tab bar stays Material's navigation bar at the bottom, since the native tabs offer Android no navigation rail; New chat's bottom sheet runs the display's width, with its rows in the column.
  • Check it on iPhone Duo. The iPhone Duo simulator folds from Device Hub's controls (Closed, Partially Open, Open). Look at a change open, closed and half open, in light and in dark, and say in the pull request which you looked at.

The web app and OpenBot Desktop

Beyond the color scheme above, no product guidelines yet. What the design system is built on, and the rules for changing a token or a primitive or building from a design, are in design-system.md. How a screen is laid out, worded, and reads and writes its data is already written down, in the skills under .claude/skills/:

  • openbot-screen-layout: the default layout of a screen.
  • openbot-copy: the words and the voice of anything a person reads.
  • openbot-data-access: how the browser app reads and writes server data.

The look

The web app keeps one look, drawn by the primitives in app/src/components/ui and the scheme's tokens. A screen draws with them and adds no look of its own. Sizes come from the scales: a screen takes the step it needs and never sets one of its own. A size changes only when its scale changes, for every screen at once, in a change agreed first.

  1. Colors. Only the scheme's tokens, as above.

  2. Type. Figtree on Tailwind's own type scale, in whole pixels: text-xs is 12px, text-sm 14px, text-base 16px and a page title's text-2xl 24px. Controls, rows and navigation are text-sm; labels, times and counts are text-xs. The line under a row's name (ItemDescription) is text-sm too, in muted-foreground: the name's weight and color set it apart. No text size written by hand (text-[13px]).

  3. Corners. All from --radius, 10px, the design's radius base. Controls are rounded-md (8px), cards and the page's panel rounded-lg (10px), menus, dialogs and the message box rounded-xl (14px), round things rounded-full. rounded-none squares a part off. No other step and no corner of its own (rounded-[20px]).

  4. Surfaces. The frame (sidebar), the panel the page sits in (background), cards on it (card). A card has a hairline border in light and in dark. Every line (border, a field's input, the sidebar's sidebar-border) is the text color at 10% in light and 12% in dark, about 1.25:1 against a card in light and 1.38:1 in dark, so no line in the app is fainter than another. A line is never the only cue of a control: a checkbox's edge is muted-foreground.

  5. Shadows. A shadow says how far something floats, as Linear draws it, and Tailwind's own steps only:

    • none for everything in the page: the panel, cards, rows, fields, the sidebar;
    • shadow-xs for a control pressed on a surface: an outlined button, a switch's knob, the chosen tab, a checkbox;
    • shadow-lg and a border for what opens beside the thing that opened it: menus, selects, popovers, tooltips, toasts;
    • shadow-2xl and a border for what sits over the app: dialogs, the command menu, sheets.

    Nothing else has a shadow, and none is written by hand.

  6. Sizes. Heights, padding and spacing come from the primitives and PageShell. A screen writes no size by hand (h-[43px]); it uses the nearest Tailwind step, never a smaller one.

  7. Rows and sections. A list is flat rows split by hairline dividers (PageRows), with no card around it. A row is as tall as its content: about 59px with a description, never under 48px. A row has no leading icon, unless the icon tells the rows apart: an app's mark, a file's kind, an avatar. There the icon is a 16px glyph in muted-foreground on a 32px tile with a hairline ring (ItemMedia variant="icon"). A section's title is a small label above its rows (PageSection: text-sm, font-medium, foreground), with a count after it when it has one (count). A page or a section says what it is for in one short sentence. A longer explanation goes behind "Learn more" (learnMore).

  8. The message box is a flat card at rest. While someone types in it, it glows in ring. It is the only control that glows.

  9. Icons. Hugeicons' free set, at their usual sizes, imported from components/icons and never from the set itself. The line is the set's own 1.5, which every glyph carries. An icon that needs another line says why in a comment.

  10. Widths come from PageShell. A screen sets no max-w-* of its own without a comment.

  11. Cards. A card is PageCard, for a form, or Card (components/ui/card.tsx), for one thing such as a Bot's tile. A list of rows is not a card: it is PageRows. No screen draws a bordered bg-card box by hand.

  12. One class, both themes. No dark: override of a color: the token carries both values.

  13. Home's orb. Behind Home's message box, OpenBot's orb is spread out as a pale field with rings of dots (components/home/home-field.tsx), and typing lights it. It is the app's one decoration: no other screen draws one. On the first Home of a visit the field draws itself in while the heading, the box and Explore Bots rise in; coming back to Home shows it in place. Nothing moves when less motion is asked for, and a skin has no field.

app/tests/ui-look-guard.test.ts fails when a screen breaks rules 2, 3, 5, 11 or 12. Screens drawn before these rules are counted in its allowlist, which only gets shorter. After cleaning a screen up, rewrite the counts with OPENBOT_UPDATE_UI_LOOK_ALLOWLIST=1 bun test app/tests/ui-look-guard.test.ts.