From 9015e11da1c09eef0eefab6ec42464f845e396d4 Mon Sep 17 00:00:00 2001 From: Jerel John Velarde Date: Wed, 18 Nov 2026 10:28:15 -0800 Subject: [PATCH 1/2] Let a person pick Kite Bot: their Bots first, each as a kite Kite Bot is a skin like OpenDuet, OpenDots and OpenFuse. Its frame keeps OpenBot's sidebar shell and replaces the conversation list with one that leads with Bots: Needs you (the Bots waiting on the person, from the attention read the app already makes), Pinned, every Bot in a steady order with the open Bot's conversations nested under it, and Groups for conversations with several Bots. Home shows the Sky, every Bot's kite with what needs you first, in place of Explore Bots. Each Bot is drawn as a pixel kite in the colour slot its orb uses, with a status pixel beside it and eyes only on contact. Shared pieces this moves: `Skin` gains an optional `home`, `BotLook` gains "kite" (BotOrb draws the kite in its place), and app-sidebar exports `AppSidebarFooter` and `ConversationMenu` so both frames use the same destinations and the same right-click menu. `kitebot` joins SKIN_IDS and the API's skin enum, with the generated client regenerated. Motion across the app: a page change cross-fades the page while the frame around it holds (the router's view transition, typed "page"), wherever the page sits in OpenBot's sidebar inset, which is OpenBot's own frame, Settings, Admin and Kite Bot; the other skins' frames swap pages as before. A theme or skin change cross-fades the whole app, and interactive elements ease their colours over 120ms. The page is named for the transition only while one runs: a permanent view-transition-name makes a stacking context that put the page's fixed overlays under the sidebar. Reduced motion turns all of it off. --- api/openapi.yaml | 1 + api/openapi/accounts.yaml | 2 +- app/src/components/agents/abstract-avatar.tsx | 9 +- app/src/components/agents/bot-look.tsx | 13 +- app/src/components/agents/bot-orb.tsx | 9 + app/src/components/agents/kite/bot-kite.tsx | 418 +++++++++++++ app/src/components/agents/kite/kite-mark.tsx | 53 ++ app/src/components/agents/kite/kite.css | 148 +++++ app/src/components/agents/kite/kite.ts | 287 +++++++++ .../components/app-sidebar/app-sidebar.tsx | 205 ++++--- app/src/components/app-sidebar/channel.tsx | 109 ++-- app/src/components/channels/avatar.tsx | 41 +- .../components/channels/conversation-view.tsx | 6 +- app/src/components/theme-provider.tsx | 35 +- app/src/lib/api/generated/model/skinId.ts | 1 + .../lib/api/generated/people/people.zod.ts | 6 +- app/src/lib/orb-palette.ts | 29 +- app/src/lib/settings/message-list.ts | 4 +- app/src/lib/view-transition.ts | 51 ++ app/src/router.tsx | 3 + app/src/routes/_authed/_app/index.tsx | 148 ++--- app/src/skins/kitebot/frame.tsx | 26 + app/src/skins/kitebot/index.ts | 19 + app/src/skins/kitebot/roster.ts | 160 +++++ app/src/skins/kitebot/sidebar.tsx | 547 ++++++++++++++++++ app/src/skins/kitebot/skin.css | 86 +++ app/src/skins/kitebot/sky.tsx | 132 +++++ app/src/skins/registry.ts | 2 + app/src/skins/skins.css | 1 + app/src/skins/types.ts | 12 +- app/src/styles.css | 80 +++ app/tests/avatar-skin.test.tsx | 45 +- app/tests/bot-kite.test.tsx | 203 +++++++ app/tests/kitebot-frame.test.tsx | 353 +++++++++++ app/tests/kitebot-roster.test.ts | 233 ++++++++ app/tests/view-transition.test.ts | 82 +++ shared/user-preferences.ts | 1 + 37 files changed, 3318 insertions(+), 242 deletions(-) create mode 100644 app/src/components/agents/kite/bot-kite.tsx create mode 100644 app/src/components/agents/kite/kite-mark.tsx create mode 100644 app/src/components/agents/kite/kite.css create mode 100644 app/src/components/agents/kite/kite.ts create mode 100644 app/src/lib/view-transition.ts create mode 100644 app/src/skins/kitebot/frame.tsx create mode 100644 app/src/skins/kitebot/index.ts create mode 100644 app/src/skins/kitebot/roster.ts create mode 100644 app/src/skins/kitebot/sidebar.tsx create mode 100644 app/src/skins/kitebot/skin.css create mode 100644 app/src/skins/kitebot/sky.tsx create mode 100644 app/tests/bot-kite.test.tsx create mode 100644 app/tests/kitebot-frame.test.tsx create mode 100644 app/tests/kitebot-roster.test.ts create mode 100644 app/tests/view-transition.test.ts diff --git a/api/openapi.yaml b/api/openapi.yaml index b7f7a8ebb4..b7f5f57ef8 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -21620,6 +21620,7 @@ components: - openduet - opendots - openfuse + - kitebot description: How OpenBot looks. openbot is OpenBot as it is without a skin. Preferences: type: object diff --git a/api/openapi/accounts.yaml b/api/openapi/accounts.yaml index d06cf464cf..0a5e92d0d8 100644 --- a/api/openapi/accounts.yaml +++ b/api/openapi/accounts.yaml @@ -1344,7 +1344,7 @@ components: enum: ['on', 'off'] SkinId: type: string - enum: [openbot, openduet, opendots, openfuse] + enum: [openbot, openduet, opendots, openfuse, kitebot] description: How OpenBot looks. openbot is OpenBot as it is without a skin. Preferences: type: object diff --git a/app/src/components/agents/abstract-avatar.tsx b/app/src/components/agents/abstract-avatar.tsx index b1518448c6..50cfb900d5 100644 --- a/app/src/components/agents/abstract-avatar.tsx +++ b/app/src/components/agents/abstract-avatar.tsx @@ -1,8 +1,11 @@ import Avatar from "boring-avatars"; -import { useBotLook } from "@/components/agents/bot-look"; +import { drawsBotMark, useBotLook } from "@/components/agents/bot-look"; import { BotOrb } from "@/components/agents/bot-orb"; -/** A Bot's avatar: its orb, or its face in a skin that has not opted in to orbs. */ +/** + * A Bot's avatar: its orb or its kite, or its face in a skin that has opted in to neither. + * `BotOrb` draws whichever mark the skin asks for. + */ export function AbstractAvatar({ name, seed, @@ -12,7 +15,7 @@ export function AbstractAvatar({ seed: string; size?: number; }) { - if (useBotLook() === "orb") { + if (drawsBotMark(useBotLook())) { return ; } diff --git a/app/src/components/agents/bot-look.tsx b/app/src/components/agents/bot-look.tsx index 9d9c1c1259..b1902d4af8 100644 --- a/app/src/components/agents/bot-look.tsx +++ b/app/src/components/agents/bot-look.tsx @@ -1,12 +1,17 @@ import { createContext, useContext } from "react"; -/** How a Bot is drawn: as its orb, or as the generated face. */ -export type BotLook = "orb" | "face"; +/** How a Bot is drawn: as its orb, as its kite (the Kite Bot skin), or as the generated face. */ +export type BotLook = "orb" | "kite" | "face"; + +/** Whether Bots are drawn as a mark of their own, an orb or a kite, rather than as faces. */ +export function drawsBotMark(look: BotLook): boolean { + return look !== "face"; +} /* * Set once, from the active skin's `botLook` (see `_authed.tsx`), so a component asks how to draw a - * Bot rather than which skin is on. A skin opts in to orbs by setting `botLook: "orb"`; without a - * provider, as in a component test, Bots are faces. + * Bot rather than which skin is on. A skin opts in to orbs by setting `botLook: "orb"`, or to kites + * with `botLook: "kite"`; without a provider, as in a component test, Bots are faces. */ const BotLookContext = createContext("face"); diff --git a/app/src/components/agents/bot-orb.tsx b/app/src/components/agents/bot-orb.tsx index 30fadaa3b1..78ff09ff30 100644 --- a/app/src/components/agents/bot-orb.tsx +++ b/app/src/components/agents/bot-orb.tsx @@ -1,4 +1,6 @@ import type { CSSProperties } from "react"; +import { useBotLook } from "@/components/agents/bot-look"; +import { BotKite } from "@/components/agents/kite/bot-kite"; import AgentOrb from "@/components/agents/orb/agent-orb"; import { orbPalette } from "@/lib/orb-palette"; @@ -15,6 +17,9 @@ const STATIC_MAX_SIZE = 32; * each run a blur and a backdrop filter on every frame. A larger orb, or one whose Bot is working, * is the live `AgentOrb` drawing the same sphere, in the palette as it is in every state. Neither * moves under reduced motion: `AgentOrb` honours it, and the still orb has nothing to move. + * + * Where Bots are kites (`useBotLook`, the Kite Bot skin), this draws the Bot's kite in its place, so + * every spot that draws a Bot's mark follows the skin. */ export function BotOrb({ seed, @@ -27,6 +32,10 @@ export function BotOrb({ size?: number; state?: "idle" | "working" | "waiting"; }) { + const look = useBotLook(); + if (look === "kite") { + return ; + } const colors = orbPalette(seed); if (size <= STATIC_MAX_SIZE && state === "idle") { diff --git a/app/src/components/agents/kite/bot-kite.tsx b/app/src/components/agents/kite/bot-kite.tsx new file mode 100644 index 0000000000..6b189d6f6a --- /dev/null +++ b/app/src/components/agents/kite/bot-kite.tsx @@ -0,0 +1,418 @@ +import { type CSSProperties, useId } from "react"; +import { + DETAIL_MIN_SIZE, + type Expression, + eyeCells, + FACE_MIN_SIZE, + facePoint, + KITE, + KITE_PATH, + KITE_STATUS, + kiteColor, + kiteTones, + type Point, + patternShapes, + pixelUnit, + STILL_MAX_SIZE, + sailPattern, + seeded, + statusPixel, + WEAVE_MIN_SIZE, +} from "./kite"; + +export type KiteState = "idle" | "working" | "waiting"; + +/** + * A Bot drawn as a kite in its own colours: the colour its seed picks (the same slot as its orb) and a + * sail pattern of its own, in a lighter tone of that colour. The Kite Bot skin draws Bots this way. + * + * The face shows only at moments of contact. A kite drawn large enough to be what the page is about + * (48px and up, such as the top of a conversation) is awake: its pixels gather into a pair of eyes + * that look toward the text beside it. A smaller kite wakes on contact (`awake`): a row or tile + * pointed at, or the Bot you are with. Its eyes stand by rather than chase the pointer, now and then + * glancing a pixel aside and back. Every face blinks on the Bot's own schedule. A Bot waiting on the + * person looks straight out with taller eyes and shows an amber pixel, and a working Bot's face steps + * back while a blue pixel keeps time. Everywhere else a kite is a still, faceless shape, so twenty of + * them in a sidebar cost nothing. + * + * Under 22px there is no face, and at 32px and under the body never moves (a waiting Bot over 32px + * nudges every few seconds). Reduced motion stills everything (kite.css). The colours for both + * themes ride on the element, and kite.css picks one. + */ +export function BotKite({ + seed, + name, + size = 32, + state = "idle", + awake = false, + look: gaze, +}: { + seed: string; + name: string; + size?: number; + state?: KiteState; + /** + * Wakes an idle kite drawn under 48px, as one at the top of a conversation always is: its pixels + * gather into eyes that stand by. A tile or a row does this while the person points at it or + * focuses it, and a sidebar row while its Bot is the one on screen. + */ + awake?: boolean; + /** Where its eyes look, in whole pixels. By default a waiting Bot looks out, any other toward the text. */ + look?: Point; +}) { + const id = useId().replace(/[^a-zA-Z0-9_-]/g, ""); + const color = kiteColor(seed); + const pattern = sailPattern(seed); + const light = kiteTones(color, false); + const dark = kiteTones(color, true); + const detail = size >= DETAIL_MIN_SIZE; + const weave = size >= WEAVE_MIN_SIZE; + const expression: Expression | null = + size < FACE_MIN_SIZE + ? null + : state === "waiting" + ? "tall" + : state === "idle" && (detail || awake) + ? "open" + : null; + const look: Point = gaze ?? (state === "waiting" ? [0, 0] : [1, 0]); + const gap = expression && detail ? faceWindow(size, expression, look) : null; + const status = state === "idle" ? null : statusGeometry(size, state); + const style = { + "--kite-body": light.body, + "--kite-panel": light.panel, + "--kite-spar": light.spar, + "--kite-edge": light.edge, + "--kite-eye": light.eye, + "--kite-body-dark": dark.body, + "--kite-panel-dark": dark.panel, + "--kite-spar-dark": dark.spar, + "--kite-edge-dark": dark.edge, + "--kite-eye-dark": dark.eye, + // Every 3–7 s, on the Bot's own seed, so a team never blinks in unison. + "--kite-blink": `${(3 + 4 * seeded(seed, "blink")).toFixed(2)}s`, + "--kite-blink-delay": `${(-7 * seeded(seed, "phase")).toFixed(2)}s`, + // A small face's glance: every 6–10 s, one whole pixel, to a side the seed picks. + "--kite-glance": `${(6 + 4 * seeded(seed, "glance")).toFixed(2)}s`, + "--kite-glance-delay": `${(-10 * seeded(seed, "glance-phase")).toFixed(2)}s`, + // Unrounded, so the step lands on a whole screen pixel. + "--kite-glance-by": `${(seeded(seed, "glance-side") < 0.5 ? -1 : 1) * pixelUnit(size)}px`, + height: size, + width: size, + } as CSSProperties; + + return ( + + + + ); +} + +/** The fine square weave of ripstop kite fabric. */ +function Weave({ id, size }: { id: string; size: number }) { + const step = size >= 140 ? 0.06 : 0.08; + return ( + + + + ); +} + +/** + * Where a face cell lands, in whole CSS pixels: the eyes are pixel art, so every edge sits on the + * screen's grid at any size. + */ +function cellBox(size: number, column: number, row: number) { + const pixel = Math.round(pixelUnit(size) * size); + const [fx, fy] = facePoint(size); + const left = Math.round((fx + 0.5) * size) + column * pixel - pixel / 2; + const top = Math.round((fy + 0.5) * size) + row * pixel - pixel / 2; + const snap = (v: number) => Math.round(v) / size - 0.5; + return { + x: snap(left), + y: snap(top), + width: pixel / size, + height: pixel / size, + }; +} + +/** The face's window: the eyes' bounds and a pixel and a half more on every side. */ +function faceWindow(size: number, expression: Expression, look: Point) { + const cells = eyeCells(expression, look); + const columns = cells.map((cell) => cell.column); + const rows = cells.map((cell) => cell.row); + const unit = pixelUnit(size); + const from = cellBox(size, Math.min(...columns), Math.min(...rows)); + const to = cellBox(size, Math.max(...columns), Math.max(...rows)); + return { + x: from.x - 1.5 * unit, + y: from.y - 1.5 * unit, + width: to.x + to.width - from.x + 3 * unit, + height: to.y + to.height - from.y + 3 * unit, + }; +} + +/** + * The pixel eyes. Each pixel flies in from a seeded spot within three pixels of its place, one after + * another, so the eyes gather rather than appear. The rows above the bottom one close to blink. On + * `standby` (a face drawn small) the pair glances a pixel aside now and then; a large face holds its + * look, since it looks at the words beside it. + */ +function PixelEyes({ + expression, + look, + seed, + size, + standby, +}: { + expression: Expression; + look: Point; + seed: string; + size: number; + standby: boolean; +}) { + const unit = pixelUnit(size); + const cells = eyeCells(expression, look); + const eye = (cell: (typeof cells)[number], index: number) => { + const scatter = (salt: string) => + ((seeded(seed, `${salt}${index}`) - 0.5) * unit * 6).toFixed(4); + return ( + + ); + }; + const lids = cells.filter((cell) => cell.lid); + const base = cells.filter((cell) => !cell.lid); + return ( + + + {lids.map((cell) => eye(cell, cells.indexOf(cell)))} + + {base.map((cell) => eye(cell, cells.indexOf(cell)))} + + ); +} + +/** + * Status lives in a square pixel beside the body, never in it, in reserved colours. A ring around it + * is cut out of the body (`cut`, a mask in `BotKite`), so it reads on the sidebar, a card or the page. + */ +function statusGeometry(size: number, state: Exclude) { + const { half, ring } = statusPixel(size); + const [x, y] = KITE.dot; + return { + state, + size, + pixel: { x: x - half, y: y - half, width: 2 * half, height: 2 * half }, + cut: { + x: x - half - ring, + y: y - half - ring, + width: 2 * (half + ring), + height: 2 * (half + ring), + }, + }; +} + +function StatusPixel({ + state, + size, + pixel, +}: ReturnType) { + const color = KITE_STATUS[state]; + return ( + + {state === "working" ? ( + + ) : null} + + + ); +} diff --git a/app/src/components/agents/kite/kite-mark.tsx b/app/src/components/agents/kite/kite-mark.tsx new file mode 100644 index 0000000000..5e61b9c091 --- /dev/null +++ b/app/src/components/agents/kite/kite-mark.tsx @@ -0,0 +1,53 @@ +import { useId } from "react"; +import { cn } from "@/lib/utils"; +import { KITE, KITE_PATH } from "./kite"; + +/** + * OpenBot's own kite, as a mark: the Bots' silhouette in one solid ink, with its two spars cut out + * of it, so it reads as the product rather than as one more Bot. It takes the colour of the text + * around it, which is what lets a skin set it in black, white or anything else. + */ +export function KiteMark({ + size = 20, + className, +}: { + size?: number; + className?: string; +}) { + const id = `${useId().replace(/[^a-zA-Z0-9_-]/g, "")}-spars`; + // The spars are cut a whole pixel wide wherever the mark is drawn, so they never blur away. + const spar = Math.max(1, Math.round(size * 0.055)) / size; + return ( + + ); +} diff --git a/app/src/components/agents/kite/kite.css b/app/src/components/agents/kite/kite.css new file mode 100644 index 0000000000..6b08cfae88 --- /dev/null +++ b/app/src/components/agents/kite/kite.css @@ -0,0 +1,148 @@ +/* + * A Bot drawn as a kite (bot-kite.tsx). Each kite carries its colours for both themes on its own + * element, and this picks the pair for the page it is on. + * + * Motion follows one curve, fast out with a long soft landing and no overshoot, and then holds + * still: the eyes gather once and blink now and then, a small face glances aside on standby, and + * only a waiting Bot repeats a gesture. + */ +.bot-kite { + --kb: var(--kite-body); + --kp: var(--kite-panel); + --ks: var(--kite-spar); + --ke: var(--kite-edge); + --kx: var(--kite-eye); +} + +.dark .bot-kite { + --kb: var(--kite-body-dark); + --kp: var(--kite-panel-dark); + --ks: var(--kite-spar-dark); + --ke: var(--kite-edge-dark); + --kx: var(--kite-eye-dark); +} + +/* Waking: each pixel flies in from its own spot, a little after the one before. */ +.bot-kite .bot-kite-eye { + transform-box: fill-box; + transform-origin: center; + animation: bot-kite-gather 385ms cubic-bezier(0.2, 0, 0, 1) + var(--gather-delay, 0ms) both; +} + +@keyframes bot-kite-gather { + from { + opacity: 0; + transform: translate(var(--sx, 0), var(--sy, 0)) scale(0.78); + } +} + +/* A blink: 70ms to close, a moment shut, 120ms to open, once a cycle of 3–7 seconds. */ +.bot-kite .bot-kite-lids { + animation: bot-kite-blink var(--kite-blink, 4.4s) linear + var(--kite-blink-delay, 0s) infinite; +} + +@keyframes bot-kite-blink { + 0%, + 95% { + opacity: 1; + } + 96.4%, + 97.2% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +/* + * Standby, for a face drawn small: once a cycle of 6–10 seconds the eyes step one whole pixel aside, + * rest there a beat and step back. They step rather than slide, as pixel art does. + */ +.bot-kite .bot-kite-glance { + animation: bot-kite-glance var(--kite-glance, 8s) linear + var(--kite-glance-delay, 0s) infinite; +} + +@keyframes bot-kite-glance { + 0%, + 71.9%, + 86.1%, + 100% { + transform: translateX(0); + } + 72%, + 86% { + transform: translateX(var(--kite-glance-by, 0)); + } +} + +/* A Bot waiting on the person tugs at its line every 4.8 seconds. */ +.bot-kite .bot-kite-nudge { + animation: bot-kite-nudge 4.8s linear infinite; +} + +@keyframes bot-kite-nudge { + 0%, + 9.2%, + 100% { + transform: translateY(0); + } + 2.5% { + transform: translateY(0.03px); + } +} + +/* Working: a ring steps out from the blue pixel and fades, keeping time. */ +.bot-kite .bot-kite-pulse { + transform-box: fill-box; + transform-origin: center; + animation: bot-kite-pulse 1.4s cubic-bezier(0.2, 0, 0, 1) infinite; +} + +@keyframes bot-kite-pulse { + from { + opacity: 0.55; + transform: scale(1); + } + to { + opacity: 0; + transform: scale(2.2); + } +} + +/* Waiting: the amber pixel swells a little, every two seconds. */ +.bot-kite .bot-kite-beat { + transform-box: fill-box; + transform-origin: center; + animation: bot-kite-beat 2s cubic-bezier(0.2, 0, 0, 1) infinite; +} + +@keyframes bot-kite-beat { + 0%, + 40%, + 100% { + transform: scale(1); + } + 20% { + transform: scale(1.18); + } +} + +/* Reduced motion: each state's designed still. The working ring rests part way out, faint. */ +@media (prefers-reduced-motion: reduce) { + .bot-kite .bot-kite-eye, + .bot-kite .bot-kite-lids, + .bot-kite .bot-kite-glance, + .bot-kite .bot-kite-nudge, + .bot-kite .bot-kite-beat { + animation: none; + } + .bot-kite .bot-kite-pulse { + animation: none; + opacity: 0.35; + transform: scale(1.54); + } +} diff --git a/app/src/components/agents/kite/kite.ts b/app/src/components/agents/kite/kite.ts new file mode 100644 index 0000000000..d2e33f830a --- /dev/null +++ b/app/src/components/agents/kite/kite.ts @@ -0,0 +1,287 @@ +import { paletteSlot, seedHash } from "@/lib/orb-palette"; + +/* + * Kite Bot: a Bot drawn as a kite, one silhouette for every Bot, each in colours of its own (a colour + * and a sail pattern). The Kite Bot skin draws Bots this way. Everything here is a pure function of the + * Bot's seed and the size it is drawn at, so a Bot is the same kite wherever it appears. + * + * Units: a Bot's slot is 1 × 1, centred on (0, 0), which is the drawing's viewBox. + */ + +export type Point = readonly [number, number]; + +/* + * The kite: upright and symmetrical, as wide as it is tall, with the cross spar 40% of the way down + * from the nose and crisp corners. The face sits in the kite's incircle, the circle touching all four + * edges, a fifth of its radius below the centre. + */ +function kite(height: number, cross: number) { + const top = -height / 2; + const half = height / 2; + const spar = cross * height; + const crossY = top + spar; + const upper = Math.hypot(half, spar); + const lower = Math.hypot(half, height - spar); + const centre = (height * upper) / (upper + lower); + const radius = (half * centre) / upper; + return { + width: height, + height, + nose: [0, top] as Point, + right: [half, crossY] as Point, + tail: [0, top + height] as Point, + left: [-half, crossY] as Point, + cross: [0, crossY] as Point, + face: [0, top + centre + 0.2 * radius] as Point, + /** Where the status pixel sits, beside the body and never on it. */ + dot: [0.36, 0.34] as Point, + }; +} + +export const KITE = kite(0.9, 0.4); + +/** The kite's outline, as an SVG path. */ +export const KITE_PATH = `M${KITE.nose.join(" ")}L${KITE.right.join(" ")}L${KITE.tail.join(" ")}L${KITE.left.join(" ")}Z`; + +/* + * Eight colours from CopilotKit's brand, in the same slot order as `orb-palette.ts`, so a Bot is the + * same colour as a kite as it is as an orb. Each has a lifted twin for dark grounds, so all sixteen + * clear 3:1 against the page. Red, amber, green and blue are left for status. + */ +export const KITE_COLORS = [ + { name: "mint", hex: "#189370", darkHex: "#2fb38b" }, + { name: "violet", hex: "#6430ab", darkHex: "#9265dd" }, + { name: "blue", hex: "#005dbb", darkHex: "#3d8ae6" }, + { name: "teal", hex: "#0e7c86", darkHex: "#22a6b0" }, + { name: "copper", hex: "#b4561a", darkHex: "#e07b3a" }, + { name: "raspberry", hex: "#a8325e", darkHex: "#d75c86" }, + { name: "plum", hex: "#7b2f7a", darkHex: "#b061ae" }, + { name: "graphite", hex: "#2b2b2b", darkHex: "#e9e9ef" }, +] as const; + +export type KiteColor = (typeof KITE_COLORS)[number]; + +/** Status colours, reserved: never a body's colour. */ +export const KITE_STATUS = { + working: "#2f6fed", + waiting: "#d99a06", +} as const; + +/* + * The sail patterns, each painted in a lighter tone of the Bot's own colour. The quarters are the + * four panels the spars divide the sail into. + */ +export const KITE_PATTERNS = [ + "solid", + "quarters", + "top", + "left", + "spine", + "bottom", + "band", + "cross-quarters", +] as const; + +export type KitePattern = (typeof KITE_PATTERNS)[number]; + +/** A Bot's colour, from the same slot as its orb. */ +export function kiteColor(seed: string): KiteColor { + return KITE_COLORS[paletteSlot(seed)]; +} + +/* + * The colour is the seed's hash modulo eight, its low three bits. FNV-1a's low bits depend only on + * the low bits before them, so a pattern taken the same way, even from the seed with something + * appended, would follow the colour: every violet Bot would wear the same pattern. This finaliser + * (MurmurHash3's) folds the high bits down into the low ones first. + */ +function scramble(hash: number): number { + let h = hash ^ (hash >>> 16); + h = Math.imul(h, 0x85ebca6b); + h ^= h >>> 13; + h = Math.imul(h, 0xc2b2ae35); + return (h ^ (h >>> 16)) >>> 0; +} + +/** + * A Bot's sail pattern, from its seed, independent of its colour, so two Bots of one colour usually + * differ in pattern. No seed has no identity to keep, so it gets quarters, the pattern the kite was + * drawn with. + */ +export function sailPattern(seed: string): KitePattern { + if (!seed) return "quarters"; + return KITE_PATTERNS[scramble(seedHash(seed)) % KITE_PATTERNS.length]; +} + +export type Shape = + | { kind: "polygon"; points: readonly Point[] } + | { kind: "rect"; x: number; y: number; width: number; height: number }; + +/** The lighter panels of a pattern, to be clipped to the kite's outline. */ +export function patternShapes(pattern: KitePattern): Shape[] { + const { nose, right, tail, left, cross, width, height } = KITE; + const panel = { + topLeft: [nose, cross, left], + topRight: [nose, right, cross], + bottomLeft: [left, cross, tail], + bottomRight: [cross, right, tail], + } satisfies Record; + const panels: Partial> = { + quarters: ["topRight", "bottomLeft"], + "cross-quarters": ["topLeft", "bottomRight"], + top: ["topLeft", "topRight"], + bottom: ["bottomLeft", "bottomRight"], + left: ["topLeft", "bottomLeft"], + }; + const chosen = panels[pattern]; + if (chosen) { + return chosen.map((key) => ({ kind: "polygon", points: panel[key] })); + } + if (pattern === "spine") { + return [ + { + kind: "rect", + x: -0.075 * width, + y: -height, + width: 0.15 * width, + height: 2 * height, + }, + ]; + } + if (pattern === "band") { + return [ + { + kind: "rect", + x: -width, + y: cross[1] - 0.055 * height, + width: 2 * width, + height: 0.11 * height, + }, + ]; + } + return []; +} + +const hexRgb = (hex: string) => { + const n = Number.parseInt(hex.slice(1), 16); + return [(n >> 16) & 255, (n >> 8) & 255, n & 255]; +}; + +/** `a` moved toward `b` by `t`, as a hex colour. */ +export function mix(a: string, b: string, t: number): string { + const from = hexRgb(a); + const to = hexRgb(b); + return `#${from + .map((v, i) => + Math.round(v + (to[i] - v) * t) + .toString(16) + .padStart(2, "0"), + ) + .join("")}`; +} + +function rgba(hex: string, alpha: number) { + const [r, g, b] = hexRgb(hex); + return `rgba(${r},${g},${b},${alpha})`; +} + +function luminance(hex: string) { + const [r, g, b] = hexRgb(hex).map((v) => { + const c = v / 255; + return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4; + }); + return 0.2126 * r + 0.7152 * g + 0.0722 * b; +} + +export type KiteTones = { + body: string; + panel: string; + spar: string; + edge: string; + /** Solid, so the eyes read the same on a light page or a dark one. */ + eye: string; +}; + +/** The colours a kite is painted in, on a light page or a dark one. */ +export function kiteTones(color: KiteColor, dark: boolean): KiteTones { + const body = dark ? color.darkHex : color.hex; + const graphite = color.name === "graphite"; + const panel = + graphite && dark + ? mix(body, "#000000", 0.14) + : mix(body, "#ffffff", graphite ? 0.16 : 0.2); + return { + body, + panel, + spar: rgba(mix(body, "#000000", 0.38), 0.55), + edge: rgba(mix(body, "#000000", 0.3), 0.35), + // White eyes on most bodies; near-black on a light one, such as graphite on a dark page. + eye: luminance(body) > 0.45 ? "#121216" : "#ffffff", + }; +} + +/** The smallest a kite has a face at all: below it, a status pixel carries the state alone. */ +export const FACE_MIN_SIZE = 22; +/** The smallest a kite is drawn with its spars and the light across its sail. */ +export const DETAIL_MIN_SIZE = 48; +/** The smallest a kite is drawn with the fine square weave of ripstop. */ +export const WEAVE_MIN_SIZE = 64; +/** At this size and under, the body never moves: only the status pixel does. */ +export const STILL_MAX_SIZE = 32; + +/** One pixel of the face, in the drawing's units, for a kite drawn `size` CSS pixels wide. */ +export function pixelUnit(size: number): number { + return Math.max(1, Math.round(size * 0.055)) / size; +} + +/** `v` (in the drawing's units) moved onto the CSS pixel grid of a kite `size` pixels wide. */ +function onGrid(v: number, size: number) { + return Math.round((v + 0.5) * size) / size - 0.5; +} + +export type Expression = "open" | "tall"; + +/** + * The pixel eyes: two blocks, two pixels wide and three tall, a pixel's gap either side of the + * centre column; four tall while the Bot waits on the person. `look` moves both by whole pixels. + * Each cell carries its row before the look moved it, so the rows above the bottom one can close. + */ +export function eyeCells( + expression: Expression, + look: Point = [0, 0], +): { column: number; row: number; lid: boolean }[] { + const rows = expression === "tall" ? [-2, -1, 0, 1] : [-1, 0, 1]; + const cells: { column: number; row: number; lid: boolean }[] = []; + for (const column of [-3, -2, 2, 3]) { + for (const row of rows) { + cells.push({ + column: column + look[0], + row: row + look[1], + lid: row < 1, + }); + } + } + return cells; +} + +/** Where the face is drawn: a pixel above the incircle's centre, on the pixel grid. */ +export function facePoint(size: number): Point { + const unit = pixelUnit(size); + return [onGrid(KITE.face[0], size), onGrid(KITE.face[1] - unit, size)]; +} + +/** The status pixel: its half-width, and the ring of page colour that cuts it out of the body. */ +export function statusPixel(size: number) { + return { + half: Math.min(12, Math.max(2.5, size * 0.075)) / size, + ring: Math.max(1.3, size * 0.026) / size, + }; +} + +/** + * A number in [0, 1) from a seed and a salt, for the details that vary per Bot: where each eye pixel + * flies in from, and how often it blinks, so a team never blinks in unison. + */ +export function seeded(seed: string, salt: string): number { + return seedHash(`${seed}:${salt}`) / 2 ** 32; +} diff --git a/app/src/components/app-sidebar/app-sidebar.tsx b/app/src/components/app-sidebar/app-sidebar.tsx index 53426f45bf..0562666ca6 100644 --- a/app/src/components/app-sidebar/app-sidebar.tsx +++ b/app/src/components/app-sidebar/app-sidebar.tsx @@ -61,6 +61,7 @@ import { type MessageListEmphasis, useMessageListEmphasis, } from "@/lib/settings/message-list"; +import { cn } from "@/lib/utils"; import { BotsNavBadge } from "../bot-profile/attention"; import { RecordingDot, @@ -374,10 +375,13 @@ function usePointerRestingSinceNavigation(): boolean { function PrimaryNavItem({ item, tooltip, + compact = false, children, }: { item: NavigationLink; tooltip?: React.ComponentProps["tooltip"]; + /** A 32px row with its icon in a 22px slot, for a sidebar whose own rows are that shape. */ + compact?: boolean; children?: React.ReactNode; }) { return ( @@ -385,7 +389,10 @@ function PrimaryNavItem({ ( -
+
- {item.label} + + {item.label} + {children} @@ -409,10 +423,17 @@ function PrimaryNavItem({ * The Skills entry. While any of the person's Recorders records, it carries a red dot named for the recording, and a * tooltip saying the same, as the Teach a Bot entry once did. Nothing extra otherwise. */ -function SkillsNavItem({ item }: { item: NavigationLink }) { +function SkillsNavItem({ + item, + compact, +}: { + item: NavigationLink; + compact?: boolean; +}) { const recording = useLiveRecording(); return ( @@ -421,8 +442,18 @@ function SkillsNavItem({ item }: { item: NavigationLink }) { ); } -export function AppSidebar({ ...props }: React.ComponentProps) { - const emphasis = useMessageListEmphasis(); +/** + * The sidebar's foot: the main destinations (`lib/navigation.ts`) and the person's account menu, + * with the organizations they can switch to and the way out. Exported so a skin that draws its own + * sidebar keeps the same destinations, the same Bots badge and the same menu, rather than a copy + * that drifts. + */ +export function AppSidebarFooter({ + compact = false, +}: { + /** Its destinations as 32px rows, for a sidebar whose own rows are that size. */ + compact?: boolean; +} = {}) { const signOut = useSignOut(); const signOutOffered = useSignOutOffered(); // Where OpenBot lists no organizations, the menu has none at all. @@ -430,6 +461,90 @@ export function AppSidebar({ ...props }: React.ComponentProps) { const invitationsWaiting = useWaitingInvitationCount(); const switchOrganization = useSwitchOrganization(); const pointerResting = usePointerRestingSinceNavigation(); + const navigation = useNavigationItems(); + const { setOpenMobile } = useSidebar(); + return ( + + + {navigation + .filter(isNavigationLink) + .filter((item) => item.section === "primary") + .map((item) => + // Skills says when a recording is live: teaching a Bot a task is how a skill is recorded. + item.id === "skills" ? ( + + ) : ( + + {/* What waits on you across every Bot; Bots lists them first. */} + {item.id === "bots" ? : null} + + ), + )} + + + + {organizationChoices ? ( + { + // A narrow window's sheet would wait behind the dialog. + setOpenMobile(false); + openNewOrganization(); + }} + switching={switchOrganization} + /> + ) : null} + {navigation + .filter((item) => item.section === "account") + .map((item) => ( + setOpenMobile(false) } + : {}, + )} + > + + {item.label} + + ))} + {signOutOffered ? ( + + + Sign out + + ) : null} + + + + + + ); +} + +export function AppSidebar({ ...props }: React.ComponentProps) { + const emphasis = useMessageListEmphasis(); const channels = useInfiniteQuery(channelListQueryOptions()); // One socket for the app, opened where the roster is kept live. useChannelEvents(); @@ -461,7 +576,6 @@ export function AppSidebar({ ...props }: React.ComponentProps) { }, [searching]); const visibleChannels = pinnedFirst(channels.data ?? []); const animateOrder = (channels.data?.length ?? 0) <= MAX_ANIMATED_ROWS; - const navigation = useNavigationItems(); const { setOpenMobile } = useSidebar(); // Opened with Cmd/Ctrl+K over the phone sidebar, the menu closes it before it navigates. useBeforeCommandNavigate(() => setOpenMobile(false)); @@ -584,82 +698,7 @@ export function AppSidebar({ ...props }: React.ComponentProps) { - - - {navigation - .filter(isNavigationLink) - .filter((item) => item.section === "primary") - .map((item) => - // Skills says when a recording is live: teaching a Bot a task is how a skill is recorded. - item.id === "skills" ? ( - - ) : ( - - {/* What waits on you across every Bot; Bots lists them first. */} - {item.id === "bots" ? : null} - - ), - )} - - - - {organizationChoices ? ( - { - // A narrow window's sheet would wait behind the dialog. - setOpenMobile(false); - openNewOrganization(); - }} - switching={switchOrganization} - /> - ) : null} - {navigation - .filter((item) => item.section === "account") - .map((item) => ( - setOpenMobile(false) } - : {}, - )} - > - - {item.label} - - ))} - {signOutOffered ? ( - - - Sign out - - ) : null} - - - - - + ); diff --git a/app/src/components/app-sidebar/channel.tsx b/app/src/components/app-sidebar/channel.tsx index e671543c4e..72cca73184 100644 --- a/app/src/components/app-sidebar/channel.tsx +++ b/app/src/components/app-sidebar/channel.tsx @@ -6,7 +6,7 @@ import { } from "@tabler/icons-react"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { Link, useNavigate, useParams } from "@tanstack/react-router"; -import { memo, useState } from "react"; +import { memo, type ReactNode, useState } from "react"; import { DeleteConversationDialog } from "@/components/channels/delete-conversation-dialog"; import { RenameConversationDialog } from "@/components/channels/rename-conversation-dialog"; import { @@ -24,9 +24,7 @@ import { ChannelItemContent } from "./channel-item-content"; * Memoized roster row. `use-channel-events` preserves unchanged row identity, and * `content-visibility` keeps off-screen rows cheap without virtualization. * - * Right-click opens Pin, Rename and Delete. Rename is offered only to the person who started the - * conversation, which is who the server lets rename it. Deleting is confirmed in a dialog that - * names the channel, because the row it was invoked on is one of several identical-looking rows. + * Right-click opens Pin, Rename and Delete (`ConversationMenu`). */ export const Channel = memo(function Channel({ channelId, @@ -56,8 +54,6 @@ export const Channel = memo(function Channel({ busy: boolean; emphasis: MessageListEmphasis; }) { - const queryClient = useQueryClient(); - const navigate = useNavigate(); // Whether this row's channel is the one on screen, as a boolean, so navigating between // channels re-renders the two rows whose answer changed rather than the whole roster. const isOpen = useParams({ @@ -68,6 +64,69 @@ export const Channel = memo(function Channel({ /* Types in only on arrival; an already-named row draws it outright. */ const revealed = useTypedReveal(summary); const threadTitle = revealed.text || untitled || "New conversation"; + return ( + + 1 + ? "/group/$channelId" + : "/channel/$channelId" + } + params={{ channelId }} + type="button" + className="flex flex-row py-2 px-2.5 gap-2 items-center w-full hover:bg-foreground/5 rounded-lg [contain-intrinsic-size:auto_3.25rem] [content-visibility:auto]" + activeProps={{ + className: "bg-foreground/5", + }} + > + + + + ); +}); + +/** + * A conversation's right-click menu around whatever row draws it: Pin, Rename (offered only to the + * person who started it, which is who the server lets rename it) and Delete, confirmed in a dialog + * that names the conversation. Exported so a skin's own roster offers the same three things. + */ +export function ConversationMenu({ + channelId, + pinned, + canRename, + title, + open, + children, +}: { + channelId: string; + pinned: boolean; + canRename: boolean; + /** What the dialogs call the conversation. */ + title: string; + /** Whether the conversation is the one on screen, which Delete leaves first. */ + open: boolean; + children: ReactNode; +}) { + const queryClient = useQueryClient(); + const navigate = useNavigate(); const setPinned = useMutation(setChannelPinnedMutationOptions(queryClient)); const [confirming, setConfirming] = useState(false); const [renaming, setRenaming] = useState(false); @@ -84,35 +143,7 @@ export const Channel = memo(function Channel({ return ( <> - - 1 - ? "/group/$channelId" - : "/channel/$channelId" - } - params={{ channelId }} - type="button" - className="flex flex-row py-2 px-2.5 gap-2 items-center w-full hover:bg-foreground/5 rounded-lg [contain-intrinsic-size:auto_3.25rem] [content-visibility:auto]" - activeProps={{ - className: "bg-foreground/5", - }} - > - - - + {children} { @@ -150,16 +181,16 @@ export const Channel = memo(function Channel({ channelId={channelId} onOpenChange={setRenaming} open={renaming} - title={summary || untitled || ""} + title={title} /> navigate({ to: "/" }) : undefined} + leave={open ? () => navigate({ to: "/" }) : undefined} onOpenChange={setConfirming} open={confirming} - title={summary || untitled || ""} + title={title} /> ); -}); +} diff --git a/app/src/components/channels/avatar.tsx b/app/src/components/channels/avatar.tsx index 1d9549c621..e6021f3f8e 100644 --- a/app/src/components/channels/avatar.tsx +++ b/app/src/components/channels/avatar.tsx @@ -1,7 +1,7 @@ import { useQuery } from "@tanstack/react-query"; import Avatar from "boring-avatars"; import { memo, type ReactNode } from "react"; -import { useBotLook } from "@/components/agents/bot-look"; +import { drawsBotMark, useBotLook } from "@/components/agents/bot-look"; import { BotOrb } from "@/components/agents/bot-orb"; import { agentListQueryOptions } from "@/lib/agents/queries"; import { cn } from "@/lib/utils"; @@ -16,10 +16,10 @@ import { cn } from "@/lib/utils"; * `typing` overlays a working indicator at the bottom-right — three bouncing dots, so a channel * whose agent is mid-turn reads as busy from the roster without moving the row's layout. * - * Where Bots are orbs (`useBotLook`), each is drawn from its `avatarSeed`, as `AbstractAvatar` - * draws it, so a Bot is one color everywhere; a skin that has not opted in keeps the faces. The orbs - * are hidden from screen readers: the row beside the avatar names the conversation, and an id read - * aloud would name nothing. + * Where Bots are orbs or kites (`useBotLook`), each is drawn from its `avatarSeed`, as + * `AbstractAvatar` draws it, so a Bot is one color everywhere; a skin that has not opted in keeps the + * faces. The orbs and kites are hidden from screen readers: the row beside the avatar names the + * conversation, and an id read aloud would name nothing. */ export const ChannelAvatar = memo(function ChannelAvatar({ participantIds, @@ -30,7 +30,8 @@ export const ChannelAvatar = memo(function ChannelAvatar({ size?: number; typing?: boolean; }) { - const orbs = useBotLook() === "orb"; + const look = useBotLook(); + const orbs = drawsBotMark(look); const face = orbs ? orbFace : boringFace; const avatar = participantIds.length === 1 ? ( @@ -38,7 +39,15 @@ export const ChannelAvatar = memo(function ChannelAvatar({ ) : ( @@ -74,6 +83,8 @@ const LAYOUTS = { type Layout = { diameter: number; at: readonly (readonly [number, number])[]; + /** Whether a face is cut out where a later one covers it. Faces that never overlap need no cut. */ + overlaps?: boolean; }; /** The orbs' group: the first two Bots side by side, overlapping by a third of an orb. */ @@ -85,6 +96,19 @@ const ORB_PAIR: Layout = { ], }; +/** + * The kites' group: the first two Bots flying at different heights, clear of each other. A circle + * cut out of a diamond leaves a broken kite, so kites are spaced so that nothing covers them. + */ +const KITE_PAIR: Layout = { + diameter: 0.56, + at: [ + [0, 0.1], + [0.44, 0.34], + ], + overlaps: false, +}; + function boringFace(id: string, size: number) { return ; } @@ -133,7 +157,8 @@ function GroupFaces({ return (
{shown.map((id, i) => { - const cuts = at.slice(i + 1).map(([x, y]) => { + const covering = layout.overlaps === false ? [] : at.slice(i + 1); + const cuts = covering.map(([x, y]) => { const cx = x - at[i][0] + diameter / 2; const cy = y - at[i][1] + diameter / 2; const r = diameter / 2 + gap; diff --git a/app/src/components/channels/conversation-view.tsx b/app/src/components/channels/conversation-view.tsx index 6d5aec840b..b1581dbde0 100644 --- a/app/src/components/channels/conversation-view.tsx +++ b/app/src/components/channels/conversation-view.tsx @@ -9,7 +9,7 @@ import { useRef, useState, } from "react"; -import { useBotLook } from "@/components/agents/bot-look"; +import { drawsBotMark, useBotLook } from "@/components/agents/bot-look"; import { ChatTranscript, skillLabels, @@ -126,7 +126,7 @@ export function ConversationView({ restoring?: boolean; /** * The top of the conversation, drawn above the first message and scrolled away with it. Only - * where Bots are orbs (`useBotLook`); elsewhere the transcript starts at its first message. + * where Bots are orbs or kites (`useBotLook`); elsewhere the transcript starts at its first message. */ intro?: ReactNode; /** @@ -153,7 +153,7 @@ export function ConversationView({ * See `composer/queue.ts` for what this state is worth: it is memory in one tab, it does not * survive a reload, and it is not an outbox. */ - const orbs = useBotLook() === "orb"; + const orbs = drawsBotMark(useBotLook()); const [queued, setQueued] = useState([]); const queuedRef = useRef(queued); diff --git a/app/src/components/theme-provider.tsx b/app/src/components/theme-provider.tsx index cf25e657dc..a1c40f23b4 100644 --- a/app/src/components/theme-provider.tsx +++ b/app/src/components/theme-provider.tsx @@ -3,6 +3,7 @@ import { type ReactNode, useContext, useEffect, + useRef, useState, useSyncExternalStore, } from "react"; @@ -14,6 +15,7 @@ import { THEME_STORAGE_KEY, type ThemePreference, } from "@/lib/theme"; +import { crossFade } from "@/lib/view-transition"; type ThemeContextValue = { /** What the person chose: the system's light or dark, or one of their own. */ @@ -42,19 +44,28 @@ export function ThemeProvider({ children }: { children: ReactNode }) { ); const systemDark = useSyncExternalStore(subscribeToSystemDark, systemIsDark); + /* + * The first theme is drawn as the page loads; every change after it cross-fades the whole app from + * one theme to the other, rather than each colour snapping on its own. + */ + const drawn = useRef(false); useEffect(() => { - applyTheme(theme, systemDark, { - setStoredValue: (key, value) => window.localStorage.setItem(key, value), - removeStoredValue: (key) => window.localStorage.removeItem(key), - toggleRootClass: (name, force) => - document.documentElement.classList.toggle(name, force), - setRootColorScheme: (scheme) => { - document.documentElement.style.colorScheme = scheme; - }, - setRootChoice: (preference) => { - document.documentElement.dataset.themeChoice = preference; - }, - }); + const apply = () => + applyTheme(theme, systemDark, { + setStoredValue: (key, value) => window.localStorage.setItem(key, value), + removeStoredValue: (key) => window.localStorage.removeItem(key), + toggleRootClass: (name, force) => + document.documentElement.classList.toggle(name, force), + setRootColorScheme: (scheme) => { + document.documentElement.style.colorScheme = scheme; + }, + setRootChoice: (preference) => { + document.documentElement.dataset.themeChoice = preference; + }, + }); + if (drawn.current) crossFade(apply); + else apply(); + drawn.current = true; }, [theme, systemDark]); return ( diff --git a/app/src/lib/api/generated/model/skinId.ts b/app/src/lib/api/generated/model/skinId.ts index 24eea9fd19..29cf7004fd 100644 --- a/app/src/lib/api/generated/model/skinId.ts +++ b/app/src/lib/api/generated/model/skinId.ts @@ -12,4 +12,5 @@ export const SkinId = { openduet: "openduet", opendots: "opendots", openfuse: "openfuse", + kitebot: "kitebot", } as const; diff --git a/app/src/lib/api/generated/people/people.zod.ts b/app/src/lib/api/generated/people/people.zod.ts index dba8244a78..519e397052 100644 --- a/app/src/lib/api/generated/people/people.zod.ts +++ b/app/src/lib/api/generated/people/people.zod.ts @@ -919,7 +919,7 @@ export const GetPreferencesResponse = zod "Whether they narrate their recordings in OpenBot's browser, which opens the microphone only when on. Null until they choose, which the browser asks before their first recording.", ), skin: zod - .enum(["openbot", "openduet", "opendots", "openfuse"]) + .enum(["openbot", "openduet", "opendots", "openfuse", "kitebot"]) .describe( "How OpenBot looks. openbot is OpenBot as it is without a skin.", ), @@ -988,7 +988,7 @@ export const UpdatePreferencesBody = zod selfHostBannerDismissed: zod.boolean().optional(), narration: zod.enum(["on", "off"]).optional(), skin: zod - .enum(["openbot", "openduet", "opendots", "openfuse"]) + .enum(["openbot", "openduet", "opendots", "openfuse", "kitebot"]) .optional() .describe( "How OpenBot looks. openbot is OpenBot as it is without a skin.", @@ -1017,7 +1017,7 @@ export const UpdatePreferencesResponse = zod "Whether they narrate their recordings in OpenBot's browser, which opens the microphone only when on. Null until they choose, which the browser asks before their first recording.", ), skin: zod - .enum(["openbot", "openduet", "opendots", "openfuse"]) + .enum(["openbot", "openduet", "opendots", "openfuse", "kitebot"]) .describe( "How OpenBot looks. openbot is OpenBot as it is without a skin.", ), diff --git a/app/src/lib/orb-palette.ts b/app/src/lib/orb-palette.ts index bacf1aa48b..7eed236fff 100644 --- a/app/src/lib/orb-palette.ts +++ b/app/src/lib/orb-palette.ts @@ -32,18 +32,29 @@ export const ORB_PALETTES: readonly OrbColors[] = [ const FNV_OFFSET = 0x811c9dc5; const FNV_PRIME = 0x01000193; -/** - * A Bot's palette, from its seed (`avatarSeed`, the Bot's id unless set). Never from its name, so - * renaming a Bot keeps its color. A 32-bit FNV-1a hash spreads similar ids across the eight. - */ -export function orbPalette(seed: string): OrbColors { - // No seed has no identity to keep, so it gets the first palette rather than whatever the hash of - // nothing happens to land on. - if (!seed) return ORB_PALETTES[0]; +/** A 32-bit FNV-1a hash of a seed, which spreads similar ids apart. */ +export function seedHash(seed: string): number { let hash = FNV_OFFSET; for (let i = 0; i < seed.length; i++) { hash ^= seed.charCodeAt(i); hash = Math.imul(hash, FNV_PRIME); } - return ORB_PALETTES[(hash >>> 0) % ORB_PALETTES.length]; + return hash >>> 0; +} + +/** + * Which of the eight colours a Bot is, from its seed (`avatarSeed`, the Bot's id unless set). Never + * from its name, so renaming a Bot keeps its color. The orb and the Kite Bot kite both read this one + * slot, so a Bot keeps its colour whichever way a skin draws it. + */ +export function paletteSlot(seed: string): number { + // No seed has no identity to keep, so it gets the first slot rather than whatever the hash of + // nothing happens to land on. + if (!seed) return 0; + return seedHash(seed) % ORB_PALETTES.length; +} + +/** A Bot's orb palette, from its seed (`paletteSlot`). */ +export function orbPalette(seed: string): OrbColors { + return ORB_PALETTES[paletteSlot(seed)]; } diff --git a/app/src/lib/settings/message-list.ts b/app/src/lib/settings/message-list.ts index e0f0e82f89..f656051fb4 100644 --- a/app/src/lib/settings/message-list.ts +++ b/app/src/lib/settings/message-list.ts @@ -12,6 +12,7 @@ import { } from "@/lib/api/generated/people/people"; import { idempotencyKey, organizationId } from "@/lib/api/request"; import { currentUserQueryOptions } from "@/lib/auth/queries"; +import { crossFade } from "@/lib/view-transition"; import { getSkinId, setSkin } from "@/skins/store"; import { settingsKeys } from "./queries"; @@ -140,7 +141,8 @@ export function saveSkinMutationOptions( }, onMutate: async (skin) => { const previousSkin = getSkinId(); - setSkin(skin); + // A new skin is a new frame around every page: it cross-fades in rather than snapping. + crossFade(() => setSkin(skin)); await queryClient.cancelQueries({ queryKey }); const previous = queryClient.getQueryData(queryKey); if (previous) queryClient.setQueryData(queryKey, { ...previous, skin }); diff --git a/app/src/lib/view-transition.ts b/app/src/lib/view-transition.ts new file mode 100644 index 0000000000..c7e6337f49 --- /dev/null +++ b/app/src/lib/view-transition.ts @@ -0,0 +1,51 @@ +import { flushSync } from "react-dom"; + +/* + * Changes that redraw a lot at once, done as one movement instead of a snap, with the browser's view + * transitions: it takes a picture of the page, the change happens under it, and the picture gives + * way to the new page (the curves are in styles.css). Where the browser has no view transitions, or + * the person asked their system for less motion, the change simply happens, as it always did. + */ + +/** Whether the person asked their system for less motion. */ +export function prefersReducedMotion(): boolean { + return ( + typeof window !== "undefined" && + window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true + ); +} + +/** + * Runs `change`, which redraws the whole app (the theme, the skin), as one cross-fade from the old + * look to the new. React's updates inside it are flushed before the new picture is taken. + */ +export function crossFade(change: () => void): void { + if ( + typeof document === "undefined" || + typeof document.startViewTransition !== "function" || + prefersReducedMotion() + ) { + change(); + return; + } + document.startViewTransition(() => { + flushSync(change); + }); +} + +/** + * Which page changes the router draws as a transition: going to another page, never the first page + * drawn, a change to the address's options alone (a pane opening over the same page has its own + * motion), or anything for somebody who asked for less motion. The type names the transition, so + * styles.css can give a page change its own curve. + */ +export function pageTransitionTypes({ + fromLocation, + pathChanged, +}: { + fromLocation?: unknown; + pathChanged: boolean; +}): string[] | false { + if (!fromLocation || !pathChanged || prefersReducedMotion()) return false; + return ["page"]; +} diff --git a/app/src/router.tsx b/app/src/router.tsx index 3e30e90268..06cb13bc54 100644 --- a/app/src/router.tsx +++ b/app/src/router.tsx @@ -1,6 +1,7 @@ import { createRouter } from "@tanstack/react-router"; import { ReportedErrorComponent } from "./lib/error-reporting"; import { parseSearchText } from "./lib/search-text"; +import { pageTransitionTypes } from "./lib/view-transition"; import type { RouterContext } from "./router-context"; import { routeTree } from "./routeTree.gen"; @@ -15,6 +16,8 @@ export const router = createRouter({ parseSearch: parseSearchText, // The router's own error screen, which also tells OpenBot what it caught (lib/error-reporting.tsx). defaultErrorComponent: ReportedErrorComponent, + // Going to another page cross-fades the page instead of swapping it (lib/view-transition.ts). + defaultViewTransition: { types: pageTransitionTypes }, }); declare module "@tanstack/react-router" { diff --git a/app/src/routes/_authed/_app/index.tsx b/app/src/routes/_authed/_app/index.tsx index 24405b6299..3f2c0ac197 100644 --- a/app/src/routes/_authed/_app/index.tsx +++ b/app/src/routes/_authed/_app/index.tsx @@ -59,6 +59,7 @@ import { newId } from "@/lib/new-id"; import { takeInvitationLink } from "@/lib/organizations/invitation-link"; import { useAnyBotSkillCommands } from "@/lib/plugins/skill-commands"; import { queryClient } from "@/query-client"; +import { useActiveSkin } from "@/skins/registry"; /** How many Bots the home page shows before pointing to the rest. Two rows of two. */ const EXPLORE_SHOWN = 4; @@ -109,6 +110,8 @@ export const Route = createFileRoute("/_authed/_app/")({ }); function RouteComponent() { + // A skin may draw its own section under the composer in place of Explore Bots. + const { home: SkinHome } = useActiveSkin(); const { data: user } = useQuery(currentUserQueryOptions()); const channels = useInfiniteQuery(channelListQueryOptions()); const { @@ -385,79 +388,84 @@ function RouteComponent() { * composer, not the place to browse: more than four would push the composer up every time * somebody shared another Bot, so the rest are one "All Bots" away. Every state below * reserves the same two rows, so the composer above it does not move when the list settles. + * A skin may draw its own section here instead (`Skin.home`). */} -
- {loading || capabilities.isPending ? ( - <> -

Explore Bots

- - - ) : explore?.length ? ( - // Wins over `failed`: a failed background refetch does not clear TanStack Query's - // cached `data`, so a stale list here beats an error card claiming there is - // nothing to explore, which would be false while this list is still populated. -
-
-

- Explore Bots -

- {explore.length > EXPLORE_SHOWN ? ( - + ) : ( +
+ {loading || capabilities.isPending ? ( + <> +

Explore Bots

+ + + ) : explore?.length ? ( + // Wins over `failed`: a failed background refetch does not clear TanStack Query's + // cached `data`, so a stale list here beats an error card claiming there is + // nothing to explore, which would be false while this list is still populated. +
+
+

- All Bots - - ) : null} -

-
    - {explore.slice(0, EXPLORE_SHOWN).map((agent) => ( -
  • - - + Explore Bots + + {explore.length > EXPLORE_SHOWN ? ( + + All Bots -
  • - ))} -
-
- ) : personal ? null : failed && agents === undefined ? ( - // `agents === undefined` narrows this to "the query has never once returned - // successfully" — not merely "the last request errored". `?.length` alone can't - // tell that apart from a slice that loaded and is genuinely empty: TanStack Query - // never clears `data` on a failed background refetch, so once the query has - // resolved even one response, `agents` stays defined and `explore`'s emptiness is a - // fact about that response, not a symptom of the failure. Rendering the destructive - // card there would say the opposite of what a populated composer beside it (still - // working off that same, successfully loaded `agents`) proves. - <> -

Explore Bots

- - - - Couldn't load the Bots shared with you. - - - - - ) : ( - // Reached both when the query never failed and `explore` is genuinely empty, and - // when it failed but `agents` is defined — a loaded, empty slice either way. Same - // plain copy for both: an empty roster is a fact, not an error. - <> -

Explore Bots

- - - - Nobody has shared a Bot with you yet. - - - - - )} -
+ ) : null} +
+
    + {explore.slice(0, EXPLORE_SHOWN).map((agent) => ( +
  • + + + +
  • + ))} +
+
+ ) : personal ? null : failed && agents === undefined ? ( + // `agents === undefined` narrows this to "the query has never once returned + // successfully" — not merely "the last request errored". `?.length` alone can't + // tell that apart from a slice that loaded and is genuinely empty: TanStack Query + // never clears `data` on a failed background refetch, so once the query has + // resolved even one response, `agents` stays defined and `explore`'s emptiness is a + // fact about that response, not a symptom of the failure. Rendering the destructive + // card there would say the opposite of what a populated composer beside it (still + // working off that same, successfully loaded `agents`) proves. + <> +

Explore Bots

+ + + + Couldn't load the Bots shared with you. + + + + + ) : ( + // Reached both when the query never failed and `explore` is genuinely empty, and + // when it failed but `agents` is defined — a loaded, empty slice either way. Same + // plain copy for both: an empty roster is a fact, not an error. + <> +

Explore Bots

+ + + + Nobody has shared a Bot with you yet. + + + + + )} +
+ )}
{/* A Bot already working somewhere, and the way to it. Nothing while every Bot is idle. */} diff --git a/app/src/skins/kitebot/frame.tsx b/app/src/skins/kitebot/frame.tsx new file mode 100644 index 0000000000..4ed7384285 --- /dev/null +++ b/app/src/skins/kitebot/frame.tsx @@ -0,0 +1,26 @@ +import type { ReactNode } from "react"; +import { ConnectionBanner } from "@/components/layout/connection-banner"; +import { SelfHostBanner } from "@/components/layout/self-host-banner"; +import { SidebarShell } from "@/components/layout/sidebar-shell"; +import { UpdateBanner } from "@/components/layout/update-banner"; +import { SidebarInset } from "@/components/ui/sidebar"; +import { KiteSidebar } from "./sidebar"; + +/** + * Kite Bot's frame: OpenBot's own shell (the sidebar that collapses with ⌘B, is dragged wider at its + * edge and becomes a sheet on a phone, and the page inset beside it), with Kite Bot's sidebar in it. + * Every page keeps the toggle it already draws, so a collapsed or phone sidebar always comes back. + */ +export function KiteBotFrame({ children }: { children: ReactNode }) { + return ( + + + + + + + {children} + + + ); +} diff --git a/app/src/skins/kitebot/index.ts b/app/src/skins/kitebot/index.ts new file mode 100644 index 0000000000..193de8c5a8 --- /dev/null +++ b/app/src/skins/kitebot/index.ts @@ -0,0 +1,19 @@ +import type { Skin } from "../types"; +import { KiteBotFrame } from "./frame"; +import { KiteSky } from "./sky"; + +/* + * Kite Bot over OpenBot. Every Bot is drawn as OpenBot's kite, each in a colour and sail pattern of + * its own (components/agents/kite), on quiet black-and-white chrome, so the Bots are the colour on + * the page. The frame lists Bots first, with what waits on you above them; the home page shows the + * Sky, every Bot's kite and what it is doing. The pages inside are OpenBot's own. + */ +export const kitebot: Skin = { + id: "kitebot", + name: "Kite Bot", + description: + "Your Bots as kites in their own colours, listed first, with what needs you on top.", + Frame: KiteBotFrame, + botLook: "kite", + home: KiteSky, +}; diff --git a/app/src/skins/kitebot/roster.ts b/app/src/skins/kitebot/roster.ts new file mode 100644 index 0000000000..d5bac5484f --- /dev/null +++ b/app/src/skins/kitebot/roster.ts @@ -0,0 +1,160 @@ +import type { KiteState } from "@/components/agents/kite/bot-kite"; +import { waitingOnYou } from "@/components/bot-profile/attention"; +import type { AgentProfile } from "@/lib/agents/queries"; +import type { BotAttention } from "@/lib/bot-lifecycle/queries"; +import type { ChannelSummary } from "@/lib/channels/queries"; + +/* + * What Kite Bot's sidebar and its Sky say about each Bot, worked out from three things OpenBot + * already loads: the Bots, the conversations, and what waits on the person. Plain functions, so the + * frame and the tests read one answer. + */ + +/** One Bot as Kite Bot draws it. */ +export type KiteBot = { + bot: AgentProfile; + /** What its kite shows: waiting on the person, working in a conversation, or neither. */ + state: KiteState; + /** How many things it waits on the person for, counted as every badge in OpenBot counts them. */ + waiting: number; + /** Where the newest thing it waits on sits, when that is a conversation. */ + waitingIn: string | null; + paused: boolean; + /** Whether it said something in one of its conversations that the person has not seen. */ + unread: boolean; + /** Its conversations with the person alone, pinned first, then newest first. */ + conversations: ChannelSummary[]; + /** When it last spoke or was spoken to in any conversation, or null for never. */ + lastActiveAt: string | null; +}; + +/** A conversation with one Bot, which Kite Bot files under that Bot. */ +export function isOneToOne(channel: ChannelSummary): boolean { + return channel.agentIds.length === 1; +} + +/** When a conversation last moved: its last message, or when it was made. */ +export function activityOf(channel: ChannelSummary): string { + return channel.lastMessageAt ?? channel.createdAt; +} + +const newestFirst = (a: ChannelSummary, b: ChannelSummary) => + activityOf(b).localeCompare(activityOf(a)); + +/** + * Whether a Bot has said something this member has not had on screen yet: the same rule as + * OpenBot's own roster (`hasUnseenActivity`), kept beside the rows that use it here. + */ +export function unseen(channel: ChannelSummary): boolean { + if (channel.lastMessageAgentId === null || channel.lastMessageAt === null) + return false; + return ( + channel.lastReadAt === null || channel.lastMessageAt > channel.lastReadAt + ); +} + +/** + * Every Bot the sidebar lists, with what its kite shows. In a steady order (pinned Bots first, then + * by name), so a row never moves under the pointer because a Bot spoke: what needs the person is + * lifted into its own section above instead. + */ +export function kiteBots( + bots: readonly AgentProfile[], + channels: readonly ChannelSummary[], + attention: readonly BotAttention[], + openChannelId?: string, +): KiteBot[] { + return bots + .filter((bot) => !bot.hidden) + .map((bot) => { + const held = attention.find((one) => one.botId === bot.id); + const involved = channels.filter((channel) => + channel.agentIds.includes(bot.id), + ); + const conversations = involved + .filter(isOneToOne) + .sort(newestFirst) + .sort((a, b) => Number(b.pinned) - Number(a.pinned)); + const waiting = held ? waitingOnYou(held) : 0; + const working = involved.some((channel) => channel.busy === true); + const lastActiveAt = involved.map(activityOf).sort().reverse()[0] ?? null; + return { + bot, + state: waiting > 0 ? "waiting" : working ? "working" : "idle", + waiting, + waitingIn: held?.waitingIn ?? null, + paused: held?.paused ?? false, + unread: conversations.some( + (channel) => channel.id !== openChannelId && unseen(channel), + ), + conversations, + lastActiveAt, + } satisfies KiteBot; + }) + .sort( + (a, b) => + Number(b.bot.pinned) - Number(a.bot.pinned) || + a.bot.name.localeCompare(b.bot.name), + ); +} + +/** The Bots that wait on the person, most waiting first. */ +export function needingYou(bots: readonly KiteBot[]): KiteBot[] { + return bots + .filter((one) => one.waiting > 0) + .sort((a, b) => b.waiting - a.waiting); +} + +/** Conversations with more than one Bot, newest first. */ +export function groupConversations( + channels: readonly ChannelSummary[], +): ChannelSummary[] { + return channels + .filter((channel) => channel.agentIds.length > 1) + .sort(newestFirst); +} + +/** + * The Sky's order: what waits on the person, then what is working, then whoever was busiest last, + * then everyone else by name. The opposite of the sidebar's steady order, because the Sky is read + * once, top to bottom, to see what is going on. + */ +export function skyOrder(bots: readonly KiteBot[]): KiteBot[] { + const rank = (one: KiteBot) => + one.state === "waiting" ? 0 : one.state === "working" ? 1 : 2; + return [...bots].sort( + (a, b) => + rank(a) - rank(b) || + b.waiting - a.waiting || + (b.lastActiveAt ?? "").localeCompare(a.lastActiveAt ?? "") || + a.bot.name.localeCompare(b.bot.name), + ); +} + +/** + * The one Bot whose conversations the sidebar opens out: the Bot of the conversation on screen, or + * the Bot whose page is open. Null on any other page. + */ +export function openBotId( + pathname: string, + channels: readonly ChannelSummary[], +): string | null { + const channel = /^\/channel\/([^/]+)/.exec(pathname)?.[1]; + if (channel) { + const open = channels.find((one) => one.id === channel); + return open && isOneToOne(open) ? (open.agentIds[0] ?? null) : null; + } + return /^\/bots\/([^/]+)/.exec(pathname)?.[1] ?? null; +} + +/** What one line under a Bot's name says about it, on the Sky. */ +export function skyLine(one: KiteBot, ago: (iso: string) => string): string { + if (one.paused) return "Paused"; + if (one.waiting > 0) + return one.waiting === 1 + ? "Waiting on you" + : `Waiting on you · ${one.waiting}`; + if (one.state === "working") return "Working"; + if (one.lastActiveAt) return `Active ${ago(one.lastActiveAt)}`; + return one.bot.title || "Ready"; +} diff --git a/app/src/skins/kitebot/sidebar.tsx b/app/src/skins/kitebot/sidebar.tsx new file mode 100644 index 0000000000..118ca48c31 --- /dev/null +++ b/app/src/skins/kitebot/sidebar.tsx @@ -0,0 +1,547 @@ +import { IconPinFilled, IconPlus, IconSearch } from "@tabler/icons-react"; +import { useInfiniteQuery, useQuery } from "@tanstack/react-query"; +import { Link, useRouterState } from "@tanstack/react-router"; +import { AnimatePresence, motion, useReducedMotion } from "motion/react"; +import { type ReactNode, useEffect, useMemo, useState } from "react"; +import { BotKite } from "@/components/agents/kite/bot-kite"; +import { KiteMark } from "@/components/agents/kite/kite-mark"; +import { AppSidebarFooter } from "@/components/app-sidebar/app-sidebar"; +import { ConversationMenu } from "@/components/app-sidebar/channel"; +import { ChannelAvatar } from "@/components/channels/avatar"; +import { BrandName } from "@/components/edition/brand-name"; +import { + openCommandMenu, + useBeforeCommandNavigate, +} from "@/components/navigation/command-menu"; +import { + Sidebar, + SidebarContent, + SidebarHeader, + SidebarMenuSkeleton, + SidebarRail, + useSidebar, +} from "@/components/ui/sidebar"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip"; +import { agentListQueryOptions } from "@/lib/agents/queries"; +import { botAttentionQueryOptions } from "@/lib/bot-lifecycle/queries"; +import { conversationTitle } from "@/lib/channels/label"; +import { + type ChannelSummary, + channelListQueryOptions, +} from "@/lib/channels/queries"; +import { useChannelEvents } from "@/lib/channels/use-channel-events"; +import { appConfig } from "@/lib/generated/application-config"; +import { EASE_OUT, ENTRANCE_SECONDS } from "@/lib/motion"; +import { relativeTimeShort } from "@/lib/relative-time"; +import { cn } from "@/lib/utils"; +import { + activityOf, + groupConversations, + type KiteBot, + kiteBots, + needingYou, + openBotId, + unseen, +} from "./roster"; + +/** How many of a Bot's conversations show under it before "Show all". */ +const SHOWN_CONVERSATIONS = 5; + +const SHORTCUT = /Mac|iPhone|iPad|iPod/.test(navigator.userAgent) + ? "⌘K" + : "Ctrl K"; + +/** Every row's shape: 32px, the sidebar's hover, and the open page's fill. */ +const row = + "group/row relative flex h-8 w-full min-w-0 items-center gap-2.5 rounded-md px-2.5 text-[13px] text-sidebar-foreground/80 outline-none transition-colors duration-150 hover:bg-sidebar-accent hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring"; +const openRow = "bg-sidebar-accent font-medium text-sidebar-foreground"; + +/** + * A Bot's kite in a row: 22px, the smallest a kite has a face at, so a Bot can look up when you point + * at it. Whatever leads any other row sits in a slot of the same width, so every name lines up. + */ +const KITE_SIZE = 22; +const slot = "grid size-[22px] shrink-0 place-items-center"; + +/** + * The conversation open on screen, from the path: OpenBot serves a conversation with one Bot at + * `/channel/:id` and one with several at `/group/:id`. + */ +function openConversationId(pathname: string): string | undefined { + return /^\/(?:channel|group)\/([^/]+)/.exec(pathname)?.[1]; +} + +/** Where a conversation opens, by how many Bots are in it. */ +function conversationLink(channel: ChannelSummary) { + return channel.agentIds.length > 1 + ? ({ to: "/group/$channelId", params: { channelId: channel.id } } as const) + : ({ + to: "/channel/$channelId", + params: { channelId: channel.id }, + } as const); +} + +function titleOf(channel: ChannelSummary): string { + return conversationTitle(channel) || "New conversation"; +} + +/** + * Kite Bot's sidebar. Bots first: every Bot is a row with its kite, and the Bot you are with opens + * out to show its conversations, so the sidebar says where you are without a second bar on top of + * OpenBot's pages. Above the Bots, what waits on you and what you pinned; below them, the + * conversations with more than one Bot. The foot is OpenBot's own: its destinations, the Bots badge + * and the account menu. + * + * It keeps the one thing OpenBot's sidebar does beyond drawing: the socket that keeps every + * conversation, and so every kite's working pixel, live. + */ +export function KiteSidebar() { + useChannelEvents(); + const pathname = useRouterState({ + select: (state) => state.location.pathname, + }); + const bots = useQuery(agentListQueryOptions()); + const channels = useInfiniteQuery(channelListQueryOptions()); + const attention = useQuery(botAttentionQueryOptions()); + const openChannel = openConversationId(pathname); + const loaded = channels.data ?? []; + const roster = useMemo( + () => kiteBots(bots.data ?? [], loaded, attention.data ?? [], openChannel), + [bots.data, loaded, attention.data, openChannel], + ); + const needs = needingYou(roster); + const pinned = loaded.filter((channel) => channel.pinned); + const groups = groupConversations(loaded).filter( + (channel) => !channel.pinned, + ); + const openBot = openBotId(pathname, loaded); + const { isMobile, setOpenMobile } = useSidebar(); + useBeforeCommandNavigate(() => setOpenMobile(false)); + // On a phone the sidebar is a sheet over the page: going anywhere puts it away. + // biome-ignore lint/correctness/useExhaustiveDependencies: closes on each new path, by design. + useEffect(() => { + if (isMobile) setOpenMobile(false); + }, [pathname]); + + return ( + + +
+ + + + + + {appConfig.brand.productName} + + + + + } + > + + + New conversation + +
+ +
+ + {needs.length > 0 ? ( +
+ {needs.map((one) => ( + + ))} +
+ ) : null} + {pinned.length > 0 ? ( +
+ {pinned.map((channel) => ( + + ))} +
+ ) : null} +
+ All + + } + label="Bots" + > + {bots.isPending ? ( + Array.from({ length: 4 }, (_, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: placeholders have nothing else to key on. + + )) + ) : bots.isError && !bots.data ? ( +

+ Couldn't load your Bots. +

+ ) : roster.length === 0 ? ( +

+ No Bots yet. +

+ ) : ( + roster.map((one) => ( + + )) + )} +
+ {groups.length > 0 ? ( +
+ {groups.map((channel) => ( + + ))} +
+ ) : null} +
+ + +
+ ); +} + +function Section({ + label, + action, + children, +}: { + label: string; + action?: ReactNode; + children: ReactNode; +}) { + return ( +
+
+

+ {label} +

+ {action} +
+
    {children}
+
+ ); +} + +/** + * A Bot that waits on you, and the way to what it waits on: the conversation it asked in, or its + * page, where questions and approvals are answered. + */ +function NeedsYouRow({ + one, + channels, + pathname, +}: { + one: KiteBot; + channels: readonly ChannelSummary[]; + pathname: string; +}) { + const where = one.waitingIn + ? channels.find((channel) => channel.id === one.waitingIn) + : undefined; + const link = where + ? conversationLink(where) + : ({ to: "/bots/$agentId", params: { agentId: one.bot.id } } as const); + const here = where + ? pathname.endsWith(`/${where.id}`) + : pathname.startsWith(`/bots/${one.bot.id}`); + return ( +
  • + + + {one.bot.name} + + {one.waiting} + + +
  • + ); +} + +/** + * One Bot: its kite, its name, and what is new with it. Choosing it opens its newest conversation, + * or starts one when there is none. While it is the Bot you are with, its conversations open out + * under it and its kite stays awake; any other Bot's kite wakes while you point at its row or tab + * to it. + */ +function BotRow({ + one, + open, + openChannel, + pathname, +}: { + one: KiteBot; + open: boolean; + openChannel: string | undefined; + pathname: string; +}) { + const reduce = useReducedMotion(); + const [all, setAll] = useState(false); + const [contact, setContact] = useState(false); + const latest = one.conversations[0]; + const link = latest + ? conversationLink(latest) + : ({ to: "/channel/new", search: { agent: one.bot.id } } as const); + const onBotPage = pathname.startsWith(`/bots/${one.bot.id}`); + const shown = all + ? one.conversations + : one.conversations.slice(0, SHOWN_CONVERSATIONS); + const hidden = one.conversations.length - shown.length; + + return ( +
  • +
    + setContact(false)} + onFocus={() => setContact(true)} + onPointerEnter={() => setContact(true)} + onPointerLeave={() => setContact(false)} + > + + + + {one.bot.name} + {one.paused ? ( + Paused + ) : one.unread ? ( + + ) : null} + + + + } + > + + + + New conversation with {one.bot.name} + + +
    + + {open && one.conversations.length > 0 ? ( + +
      + {shown.map((channel) => ( + + ))} + {hidden > 0 ? ( +
    • + +
    • + ) : null} +
    +
    + ) : null} +
    +
  • + ); +} + +/** + * A conversation: under its Bot, just what it is about and when it last moved; on its own (pinned, + * or with several Bots), led by its Bots' kites. Right-click offers what OpenBot's roster does. + */ +function ConversationRow({ + channel, + open, + nested = false, +}: { + channel: ChannelSummary; + open: boolean; + nested?: boolean; +}) { + const title = titleOf(channel); + const unread = !open && unseen(channel); + return ( +
  • + + + {nested ? null : channel.agentIds.length > 1 ? ( + + ) : ( + + + + )} + + {title} + + {channel.busy ? ( + + Working + + ) : unread ? ( + + ) : nested && channel.pinned ? ( + + ) : ( + + {relativeTimeShort(activityOf(channel))} + + )} + + +
  • + ); +} + +/** + * A conversation with several Bots, as two of their kites flying together in the space of one: the + * second a little lower and to the right, over the first. Two kites of a row's size side by side + * would push its words out of line with every other row's. + */ +function KitePair({ ids, working }: { ids: string[]; working: boolean }) { + const bots = useQuery(agentListQueryOptions()).data; + const kites = ids.slice(0, 2).map((id) => { + const bot = bots?.find((one) => one.id === id); + return { id, name: bot?.name ?? "", seed: bot?.avatarSeed ?? id }; + }); + return ( + + {kites.map((kite, index) => ( + + + + ))} + + ); +} diff --git a/app/src/skins/kitebot/skin.css b/app/src/skins/kitebot/skin.css new file mode 100644 index 0000000000..9729b38951 --- /dev/null +++ b/app/src/skins/kitebot/skin.css @@ -0,0 +1,86 @@ +/* + * Kite Bot. OpenBot's shell in black, white and grey, so the Bots are the colour on the page: each + * is a kite in its own colours (components/agents/kite). Lines are hairline greys, selection is a + * neutral step with a breath of violet, and the one accent is OpenBot's violet, on focus alone. + * Corners are a little tighter than OpenBot's, to sit with the kite's sharp ones, and text is set + * with greyscale smoothing, which keeps small grey labels crisp on white and on black. + * + * Every token is set for both. A skin's `:root[data-skin]` outranks OpenBot's `.dark`, so a token set + * only for light would leak into dark. + */ + +:root[data-skin="kitebot"] { + color-scheme: light; + --background: #ffffff; + --foreground: #0a0a0a; + --card: #ffffff; + --card-foreground: #0a0a0a; + --popover: #ffffff; + --popover-foreground: #0a0a0a; + --primary: #0a0a0a; + --primary-foreground: #ffffff; + --secondary: #f2f2f2; + --secondary-foreground: #0a0a0a; + --muted: #f2f2f2; + --muted-foreground: #666666; + --accent: #f0f0f0; + --accent-foreground: #0a0a0a; + --destructive: #c4321f; + --success: #18794e; + --border: #ebebeb; + --input: #dcdcdc; + --ring: #6430ab; + --radius: 0.5rem; + --sidebar: #fafafa; + --sidebar-foreground: #0a0a0a; + --sidebar-primary: #0a0a0a; + --sidebar-primary-foreground: #ffffff; + --sidebar-accent: #ededed; + --sidebar-accent-foreground: #0a0a0a; + --sidebar-border: #ebebeb; + --sidebar-ring: #6430ab; + --kitebot-selection: #f4effb; +} + +:root[data-skin="kitebot"].dark { + color-scheme: dark; + --background: #0a0a0a; + --foreground: #ededed; + --card: #111111; + --card-foreground: #ededed; + --popover: #141414; + --popover-foreground: #ededed; + --primary: #ededed; + --primary-foreground: #0a0a0a; + /* Lighter than the cards, as shadcn's dark fills are, so a button or badge never reads as a hole. */ + --secondary: #1c1c1c; + --secondary-foreground: #ededed; + --muted: #1c1c1c; + --muted-foreground: #a1a1a1; + --accent: #222222; + --accent-foreground: #ededed; + --destructive: #ff7a68; + --success: #3ccf8e; + --border: #242424; + --input: #2e2e2e; + --ring: #b598f3; + --radius: 0.5rem; + --sidebar: #000000; + --sidebar-foreground: #ededed; + --sidebar-primary: #ededed; + --sidebar-primary-foreground: #0a0a0a; + --sidebar-accent: #1a1a1a; + --sidebar-accent-foreground: #ededed; + --sidebar-border: #1f1f1f; + --sidebar-ring: #b598f3; + --kitebot-selection: #2a2140; +} + +:root[data-skin="kitebot"] ::selection { + background: var(--kitebot-selection); +} + +:root[data-skin="kitebot"] body { + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/app/src/skins/kitebot/sky.tsx b/app/src/skins/kitebot/sky.tsx new file mode 100644 index 0000000000..4b240d587f --- /dev/null +++ b/app/src/skins/kitebot/sky.tsx @@ -0,0 +1,132 @@ +import { useInfiniteQuery, useQuery } from "@tanstack/react-query"; +import { Link } from "@tanstack/react-router"; +import { useState } from "react"; +import { BotKite } from "@/components/agents/kite/bot-kite"; +import { StaggerItem } from "@/components/layout/stagger"; +import { Skeleton } from "@/components/ui/skeleton"; +import { agentListQueryOptions } from "@/lib/agents/queries"; +import { botAttentionQueryOptions } from "@/lib/bot-lifecycle/queries"; +import { channelListQueryOptions } from "@/lib/channels/queries"; +import { relativeTimeShort } from "@/lib/relative-time"; +import { cn } from "@/lib/utils"; +import { type KiteBot, kiteBots, skyLine, skyOrder } from "./roster"; + +/** Two rows of four on a wide screen, two of two on a phone. The rest are one "All Bots" away. */ +const SKY_SHOWN = 8; + +function ago(iso: string): string { + const short = relativeTimeShort(iso); + return short === "now" ? "just now" : `${short} ago`; +} + +/** + * The Sky: Kite Bot's home under the composer, in place of OpenBot's Explore Bots. Every Bot's kite, + * with what needs you first, then what is working, then whoever was busiest last. A kite wakes when + * you point at it or tab to it, and choosing one opens its newest conversation, or starts one. + * + * Every state holds the same two rows, so the composer above never moves when the Bots arrive. + */ +export function KiteSky() { + const bots = useQuery(agentListQueryOptions()); + const channels = useInfiniteQuery(channelListQueryOptions()); + const attention = useQuery(botAttentionQueryOptions()); + const sky = skyOrder( + kiteBots(bots.data ?? [], channels.data ?? [], attention.data ?? []), + ); + const shown = sky.slice(0, SKY_SHOWN); + + return ( +
    +
    +

    + Your Bots +

    + {sky.length > SKY_SHOWN ? ( + + All {sky.length} + + ) : null} +
    +
      + {bots.isPending + ? Array.from({ length: 4 }, (_, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: placeholders have nothing else to key on. +
    • + +
    • + )) + : shown.map((one, index) => ( +
    • + + + +
    • + ))} +
    + {bots.isError && !bots.data ? ( +

    + Couldn't load your Bots. +

    + ) : null} +
    + ); +} + +function SkyTile({ one }: { one: KiteBot }) { + const [contact, setContact] = useState(false); + const latest = one.conversations[0]; + const link = latest + ? ({ + to: "/channel/$channelId", + params: { channelId: latest.id }, + } as const) + : ({ to: "/channel/new", search: { agent: one.bot.id } } as const); + const line = skyLine(one, ago); + return ( + setContact(false)} + onFocus={() => setContact(true)} + onPointerEnter={() => setContact(true)} + onPointerLeave={() => setContact(false)} + > + + + + {one.bot.name} + + 0 && "text-amber-700 dark:text-amber-300", + one.state === "working" && + one.waiting === 0 && + "text-[#2f6fed] dark:text-[#6c9cff]", + )} + > + {line} + + + + ); +} diff --git a/app/src/skins/registry.ts b/app/src/skins/registry.ts index 5cc9e2c542..fd002560db 100644 --- a/app/src/skins/registry.ts +++ b/app/src/skins/registry.ts @@ -1,4 +1,5 @@ import { appConfig } from "@/lib/generated/application-config"; +import { kitebot } from "./kitebot"; import { opendots } from "./opendots"; import { openduet } from "./openduet"; import { openfuse } from "./openfuse"; @@ -22,6 +23,7 @@ export const SKINS: Record = { openduet, opendots, openfuse, + kitebot, }; export function useActiveSkin(): Skin { diff --git a/app/src/skins/skins.css b/app/src/skins/skins.css index 49976f164c..d1a01fa65b 100644 --- a/app/src/skins/skins.css +++ b/app/src/skins/skins.css @@ -7,6 +7,7 @@ @import "./openduet/skin.css"; @import "./opendots/skin.css"; @import "./openfuse/skin.css"; +@import "./kitebot/skin.css"; /* * OpenBot's own composer column pads `px-4`, the transcript's inset, so a narrow pane keeps it off diff --git a/app/src/skins/types.ts b/app/src/skins/types.ts index e32b9a3178..bb57488c68 100644 --- a/app/src/skins/types.ts +++ b/app/src/skins/types.ts @@ -1,5 +1,6 @@ import type { SkinId } from "@openbot/shared/user-preferences"; import type { ComponentType, ReactNode } from "react"; +import type { BotLook } from "@/components/agents/bot-look"; /* * The ids live in `shared/` because the choice is saved on the person's account and the server @@ -25,13 +26,18 @@ export type Skin = { */ Frame?: ComponentType<{ children: ReactNode }>; /** - * How this skin draws a Bot: as its orb, with the orb, name and role at the top of a conversation, - * or as the generated face. Absent, a face. + * How this skin draws a Bot: as its orb or its kite, with that mark, the Bot's name and role at the + * top of a conversation, or as the generated face. Absent, a face. */ - botLook?: "orb" | "face"; + botLook?: BotLook; /** * Screens only this skin has, served at `/s/`. They draw OpenBot's existing data; a skin * adds no endpoint. A key the active skin does not have goes home. */ screens?: Record; + /** + * Drawn on the home page under the composer, in place of OpenBot's Explore Bots. It reads + * OpenBot's existing data, as a screen does. + */ + home?: ComponentType; }; diff --git a/app/src/styles.css b/app/src/styles.css index d459140d9f..0855866181 100644 --- a/app/src/styles.css +++ b/app/src/styles.css @@ -5,6 +5,7 @@ @import "prompt-area/tailwind.css"; @import "@fontsource-variable/inter"; @import "./theme.css"; +@import "./components/agents/kite/kite.css"; @import "./skins/skins.css"; /* @@ -446,3 +447,82 @@ transform: translateY(3px); } } + +/* + * MOTION, ONCE FOR THE WHOLE APP. + * + * Hover, press and focus ease their colours in over 120ms on everything a person points at or tabs + * to, so a row filling as the pointer crosses it reads as a response rather than a flicker. `:where` + * keeps this at no specificity: anything that names its own transition (a width, a transform) + * keeps exactly that. Menu items and options are left out, so arrowing down a list keeps up with + * the keys, and so are transforms: a press that moves is each control's own decision. + */ +@layer base { + :where( + a, + button, + summary, + input, + textarea, + select, + [role="button"], + [role="tab"], + [role="switch"], + [role="checkbox"], + [role="radio"] + ) { + transition-property: + color, background-color, border-color, outline-color, + text-decoration-color, fill, stroke, box-shadow, opacity; + transition-duration: 120ms; + transition-timing-function: cubic-bezier(0.23, 1, 0.32, 1); + } +} + +/* + * Going to another page (lib/view-transition.ts). The page is a layer of its own: the old one fades + * out fast and the new one rises 4px into place, so the eye lands on what arrived, while the frame + * around it (the sidebar, a skin's bars) holds still. A theme or skin change cross-fades the whole + * app as one picture instead. Browsers without view transitions swap the page as they always did, + * and so does every browser for somebody who asked for less motion: none of these is started then. + */ +/* + * Named only while a page change runs. A name held all the time makes the page a stacking context of + * its own, which would put anything fixed inside it (an overlay at z-50) under the sidebar. + */ +:root:active-view-transition-type(page) [data-slot="sidebar-inset"] { + view-transition-name: main; +} + +::view-transition-old(root), +::view-transition-new(root), +::view-transition-group(main) { + animation-duration: 200ms; + animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1); +} + +:root:active-view-transition-type(page)::view-transition-old(root), +:root:active-view-transition-type(page)::view-transition-new(root) { + animation: none; +} + +:root:active-view-transition-type(page)::view-transition-old(main) { + animation: page-leave 90ms ease-out both; +} + +:root:active-view-transition-type(page)::view-transition-new(main) { + animation: page-arrive 220ms cubic-bezier(0.23, 1, 0.32, 1) both; +} + +@keyframes page-leave { + to { + opacity: 0; + } +} + +@keyframes page-arrive { + from { + opacity: 0; + transform: translateY(4px); + } +} diff --git a/app/tests/avatar-skin.test.tsx b/app/tests/avatar-skin.test.tsx index 07cbd833f4..84b615acea 100644 --- a/app/tests/avatar-skin.test.tsx +++ b/app/tests/avatar-skin.test.tsx @@ -18,8 +18,9 @@ import { SKINS } from "@/skins/registry"; import { settleReactWork } from "./settle-react-work"; /* - * Bots appear as their orb where the active skin asks for it (`botLook: "orb"`). OpenBot's own look - * does; a skin that has not opted in keeps the faces it was designed with. + * Bots appear as their orb where the active skin asks for it (`botLook: "orb"`), and as their kite + * where it asks for that (`botLook: "kite"`). OpenBot's own look draws orbs and Kite Bot draws kites; a + * skin that has opted in to neither keeps the faces it was designed with. */ beforeAll(() => GlobalRegistrator.register()); @@ -61,20 +62,58 @@ describe.each(Object.entries(avatars))("%s", (_, Avatar) => { expect(view.container.querySelector("svg")).toBeNull(); }); + test("is a kite where Bots are kites", () => { + const view = renderAs("kite", ); + expect(view.container.querySelector("[data-kite]")).not.toBeNull(); + expect(view.container.querySelector("[data-variant]")).toBeNull(); + }); + test("is a face where they are not", () => { const view = renderAs("face", ); expect(view.container.querySelector("svg")).not.toBeNull(); expect(view.container.querySelector("[data-variant]")).toBeNull(); + expect(view.container.querySelector("[data-kite]")).toBeNull(); }); }); -test("OpenBot's own look opts in to orbs and the skins do not", () => { +test("OpenBot's own look opts in to orbs, Kite Bot to kites, and the other skins to neither", () => { expect(SKINS.openbot.botLook).toBe("orb"); + expect(SKINS.kitebot.botLook).toBe("kite"); for (const id of ["openduet", "opendots", "openfuse"] as const) { expect(SKINS[id].botLook ?? "face").toBe("face"); } }); +test("a group shows two kites", () => { + const view = renderAs( + "kite", + , + ); + expect(view.container.querySelectorAll("[data-kite]")).toHaveLength(2); +}); + +test("a conversation's kite is drawn from the Bot's seed, as its own avatar is", () => { + const sail = (view: ReturnType) => + view.container + .querySelector("[data-kite]") + ?.getAttribute("data-sail"); + const own = sail( + renderAs("kite", ), + ); + cleanup(); + const inSidebar = sail( + renderAs( + "kite", + , + ), + ); + expect(own).toBeTruthy(); + expect(inSidebar).toBe(own); +}); + test("a group shows two orbs", () => { const view = renderAs( "orb", diff --git a/app/tests/bot-kite.test.tsx b/app/tests/bot-kite.test.tsx new file mode 100644 index 0000000000..79ef5f31f2 --- /dev/null +++ b/app/tests/bot-kite.test.tsx @@ -0,0 +1,203 @@ +import { + afterAll, + afterEach, + beforeAll, + describe, + expect, + test, +} from "bun:test"; +import { GlobalRegistrator } from "@happy-dom/global-registrator"; +import { cleanup, render } from "@testing-library/react"; +import { BotLookProvider } from "@/components/agents/bot-look"; +import { BotOrb } from "@/components/agents/bot-orb"; +import { BotKite, type KiteState } from "@/components/agents/kite/bot-kite"; +import { + KITE_COLORS, + KITE_PATTERNS, + KITE_STATUS, + kiteColor, + kiteTones, + sailPattern, +} from "@/components/agents/kite/kite"; +import { ORB_PALETTES, orbPalette } from "@/lib/orb-palette"; +import { settleReactWork } from "./settle-react-work"; + +/* + * The Kite Bot skin draws each Bot as a kite: one silhouette for every Bot, in colours of its own (a + * colour and a sail pattern from its seed), with pixel eyes only at moments of contact and its state + * in a status pixel beside it. + */ + +beforeAll(() => GlobalRegistrator.register()); +afterEach(() => cleanup()); +afterAll(async () => { + await settleReactWork(); + GlobalRegistrator.unregister(); +}); + +const SEEDS = Array.from({ length: 200 }, (_, n) => `bot-${n}`); + +function kite(size: number, state: KiteState = "idle", seed = "knowledge") { + const view = render( + , + ); + const root = view.container.querySelector("[data-kite]"); + if (!root) throw new Error("no kite drawn"); + return { + root, + eyes: root.querySelectorAll(".bot-kite-eye"), + status: root.querySelector(`[fill="${KITE_STATUS.working}"]`) + ? "working" + : root.querySelector(`[fill="${KITE_STATUS.waiting}"]`) + ? "waiting" + : null, + }; +} + +describe("a Bot's colours", () => { + test("is the same colour slot as its orb, so a skin switch keeps each Bot's colour", () => { + for (const seed of ["", ...SEEDS]) { + expect(KITE_COLORS.indexOf(kiteColor(seed))).toBe( + ORB_PALETTES.indexOf(orbPalette(seed)), + ); + } + }); + + test("comes from the seed alone, and every pattern is used", () => { + for (const seed of SEEDS) { + expect(sailPattern(seed)).toBe(sailPattern(seed)); + } + const used = new Set(SEEDS.map(sailPattern)); + expect([...used].sort()).toEqual([...KITE_PATTERNS].sort()); + }); + + test("varies the pattern within one colour", () => { + const violet = SEEDS.filter((seed) => kiteColor(seed).name === "violet"); + expect(new Set(violet.map(sailPattern)).size).toBeGreaterThan(3); + }); + + test("never paints a body in a status colour", () => { + const status = Object.values(KITE_STATUS); + for (const color of KITE_COLORS) { + for (const dark of [false, true]) { + const tones = kiteTones(color, dark); + expect(status).not.toContain(tones.body); + expect(status).not.toContain(tones.panel); + } + } + }); + + test("reads at 3:1 or better on its page, light and dark", () => { + const luminance = (hex: string) => { + const n = Number.parseInt(hex.slice(1), 16); + const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((v) => { + const c = v / 255; + return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4; + }); + return 0.2126 * r + 0.7152 * g + 0.0722 * b; + }; + const contrast = (a: string, b: string) => { + const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x); + return (hi + 0.05) / (lo + 0.05); + }; + for (const color of KITE_COLORS) { + expect(contrast(color.hex, "#ffffff")).toBeGreaterThanOrEqual(3); + expect(contrast(color.darkHex, "#0a0a0a")).toBeGreaterThanOrEqual(3); + } + }); +}); + +describe("a kite's face", () => { + test("is absent in a list: an idle kite at avatar size is a still shape", () => { + for (const size of [16, 20, 24, 32, 40]) { + const drawn = kite(size); + expect(drawn.eyes).toHaveLength(0); + expect(drawn.status).toBeNull(); + cleanup(); + } + }); + + test("wakes where the page is about the Bot, and holds its look at the words beside it", () => { + const drawn = kite(96); + // Two eyes, each two pixels wide and three tall. + expect(drawn.eyes).toHaveLength(12); + expect(drawn.root.querySelector(".bot-kite-lids")).not.toBeNull(); + expect(drawn.root.querySelector(".bot-kite-glance")).toBeNull(); + }); + + test("woken small by contact, stands by: it blinks and glances one whole pixel aside", () => { + const view = render( + , + ); + const root = view.container.querySelector("[data-kite]"); + expect(root?.querySelectorAll(".bot-kite-eye")).toHaveLength(12); + expect(root?.querySelector(".bot-kite-lids")).not.toBeNull(); + expect(root?.querySelector(".bot-kite-glance")).not.toBeNull(); + const by = Number.parseFloat( + root?.style.getPropertyValue("--kite-glance-by") ?? "", + ); + expect(Math.abs(by * 22)).toBeCloseTo(1, 9); + }); + + test("looks out with taller eyes while the Bot waits on the person, from 22px", () => { + expect(kite(20, "waiting").eyes).toHaveLength(0); + cleanup(); + const drawn = kite(24, "waiting"); + expect(drawn.eyes).toHaveLength(16); + expect(drawn.status).toBe("waiting"); + }); + + test("steps back while the Bot works, and a blue pixel keeps time", () => { + const drawn = kite(96, "working"); + expect(drawn.eyes).toHaveLength(0); + expect(drawn.status).toBe("working"); + expect(drawn.root.querySelector(".bot-kite-pulse")).not.toBeNull(); + }); + + test("sits on whole screen pixels at every size", () => { + for (const size of [24, 48, 64, 96, 120, 160]) { + const drawn = kite(size, "waiting"); + for (const eye of drawn.eyes) { + for (const attribute of ["x", "y", "width", "height"]) { + const units = Number(eye.getAttribute(attribute)); + const pixels = + (attribute === "x" || attribute === "y" ? units + 0.5 : units) * + size; + expect(Math.abs(pixels - Math.round(pixels))).toBeLessThan(1e-6); + } + } + cleanup(); + } + }); + + test("never moves a kite of 32px or under", () => { + expect( + kite(32, "waiting").root.querySelector(".bot-kite-nudge"), + ).toBeNull(); + cleanup(); + expect( + kite(48, "waiting").root.querySelector(".bot-kite-nudge"), + ).not.toBeNull(); + }); +}); + +test("every spot that draws a Bot's orb draws its kite where Bots are kites", () => { + const view = render( + + + , + ); + const drawn = view.getByRole("img", { name: "Knowledge" }); + expect(drawn.dataset.kite).toBe("idle"); + expect(drawn.dataset.sail).toBe( + `${kiteColor("knowledge").name} ${sailPattern("knowledge")}`, + ); +}); + +test("is announced once, by the Bot's name", () => { + const view = render(); + expect(view.getAllByRole("img")).toHaveLength(1); + expect(view.container.querySelector("svg")?.getAttribute("aria-hidden")).toBe( + "true", + ); +}); diff --git a/app/tests/kitebot-frame.test.tsx b/app/tests/kitebot-frame.test.tsx new file mode 100644 index 0000000000..243cca632c --- /dev/null +++ b/app/tests/kitebot-frame.test.tsx @@ -0,0 +1,353 @@ +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, + createRoute, + createRouter, + Outlet, + RouterProvider, +} from "@tanstack/react-router"; +import { + cleanup, + fireEvent, + render, + waitFor, + within, +} from "@testing-library/react"; +import type { BotAttention } from "@/lib/bot-lifecycle/queries"; +import { navigationFor } from "@/lib/navigation"; +import { SKINS } from "@/skins/registry"; +import { ME_PATH, meBody, PREFERENCES_PATH } from "./accounts-api"; +import { DEPLOYMENT_PATH } from "./admin-settings-api"; +import { answerBotAttention, answerBotsList, attentionOf } from "./bots-api"; +import { CONVERSATIONS_PATH, conversationPage } from "./conversations-api"; +import { settleReactWork } from "./settle-react-work"; + +/* + * Kite Bot's frame replaces OpenBot's sidebar with one that lists Bots first. These render the skin + * as `_authed/_app` does (its Frame around the page, its Sky on home) against a fake of OpenBot's + * API that answers in the shapes the real endpoints return. + */ + +beforeAll(() => GlobalRegistrator.register()); +afterEach(cleanup); +afterAll(async () => { + await settleReactWork(); + GlobalRegistrator.unregister(); +}); + +const originalFetch = global.fetch; +const originalSocket = globalThis.WebSocket; +afterEach(() => { + global.fetch = originalFetch; + globalThis.WebSocket = originalSocket; +}); + +/** The frame keeps OpenBot's live socket open; here it never connects. */ +class QuietSocket { + onopen: unknown = null; + onclose: unknown = null; + onmessage: unknown = null; + onerror: unknown = null; + close() {} + send() {} +} + +const now = "2026-11-17T10:00:00.000Z"; + +function bot(id: string, name: string, title: string) { + return { + id, + name, + title, + roleDescription: "", + avatarSeed: id, + hidden: false, + pinned: false, + }; +} + +const BOTS = [ + bot("b-ledger", "Ledger", "Finance"), + bot("b-ivy", "Ivy", "Inbox"), + bot("b-scout", "Scout", "Research"), + bot("b-quill", "Quill", "Writer"), +]; + +function channel( + id: string, + agentIds: string[], + summary: string, + more: Record = {}, +) { + return { + id, + name: "", + agentIds, + threadId: `t-${id}`, + active: true, + lastMessageAt: now, + summary, + lastMessage: summary, + lastMessageAgentId: null, + createdAt: now, + pinned: false, + lastReadAt: now, + ...more, + }; +} + +const CHANNELS = [ + channel("c-close", ["b-ledger"], "October close"), + channel("c-invoices", ["b-ledger"], "Supplier invoices", { + lastMessageAt: "2026-11-16T10:00:00.000Z", + }), + channel("c-triage", ["b-ivy"], "Morning triage", { pinned: true }), + channel("c-scan", ["b-scout"], "Competitor scan", { busy: true }), + channel("g-launch", ["b-quill", "b-scout"], "Launch post draft"), +]; + +function api({ + attention = [ + attentionOf("b-ivy", "Ivy", { approvals: 2, waitingIn: "c-triage" }), + ], +}: { + attention?: BotAttention[]; +} = {}) { + const bodies: Record = { + [ME_PATH]: meBody({ + user: { + id: "u-1", + name: "Maya Chen", + email: "maya@example.com", + role: "admin", + onboarding: null, + }, + }), + [DEPLOYMENT_PATH]: { transcription: true }, + [PREFERENCES_PATH]: { + messageListEmphasis: "thread", + selfHostBannerDismissed: true, + }, + [CONVERSATIONS_PATH]: conversationPage(CHANNELS), + }; + global.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { + const path = String(input).split("?")[0] ?? ""; + const bots = answerBotsList(input, init, { visible: BOTS }); + if (bots) return bots; + const waiting = answerBotAttention(input, init, { bots: attention }); + if (waiting) return waiting; + if (path in bodies) return Response.json(bodies[path]); + return Response.json({ error: "not served" }, { status: 404 }); + }) as typeof fetch; + globalThis.WebSocket = QuietSocket as unknown as typeof WebSocket; +} + +/** Kite Bot around a page, as `_authed/_app` draws a skin's Frame, starting at `path`. */ +function renderApp(path: string) { + const { Frame, home: Home } = SKINS.kitebot; + if (!Frame || !Home) throw new Error("Kite Bot has no frame"); + const rootRoute = createRootRoute({ + component: () => ( + + + + ), + }); + const page = (routePath: string, body: () => React.ReactNode) => + createRoute({ + path: routePath, + getParentRoute: () => rootRoute, + component: body, + }); + const router = createRouter({ + routeTree: rootRoute.addChildren([ + page("/", () => ( + <> +

    Start a conversation

    + + + )), + page("/channel/$channelId", () =>

    A conversation

    ), + page("/group/$channelId", () =>

    A group

    ), + page("/channel/new", () =>

    New

    ), + page("/bots", () =>

    Bots

    ), + page("/bots/$agentId", () =>

    A Bot

    ), + ]), + history: createMemoryHistory({ initialEntries: [path] }), + }); + const client = new QueryClient({ + defaultOptions: { queries: { retry: false } }, + }); + return render( + + + , + ); +} + +function section(view: ReturnType, name: string) { + return view.findByRole("region", { name }); +} + +describe("the sidebar lists Bots first", () => { + test("every Bot is a row led by its kite, in a steady order", async () => { + api(); + const view = renderApp("/"); + const bots = await section(view, "Bots"); + await within(bots).findByText("Scout"); + const names = within(bots) + .getAllByRole("img") + .map((kite) => kite.getAttribute("aria-label")); + expect(names).toEqual(["Ivy", "Ledger", "Quill", "Scout"]); + expect(bots.querySelectorAll("[data-kite]")).toHaveLength(4); + }); + + test("Needs you lifts a waiting Bot above the rest, says how much waits, and goes to where it waits", async () => { + api(); + const view = renderApp("/"); + const needs = await section(view, "Needs you"); + const row = await within(needs).findByRole("link", { name: /Ivy/ }); + expect(row.getAttribute("href")).toBe("/channel/c-triage"); + expect(within(row).getByText("2")).toBeTruthy(); + expect(row.querySelector('[data-kite="waiting"]')).toBeTruthy(); + // Waiting, it looks out with its taller eyes: two blocks of two by four. + expect(row.querySelectorAll(".bot-kite-eye")).toHaveLength(16); + }); + + test("no Needs you section while nothing waits on the person", async () => { + api({ attention: [] }); + const view = renderApp("/"); + await within(await section(view, "Bots")).findByText("Scout"); + expect(view.queryByRole("region", { name: "Needs you" })).toBeNull(); + }); + + test("a Bot working in a conversation shows it on its kite", async () => { + api(); + const view = renderApp("/"); + const bots = await section(view, "Bots"); + const scout = await within(bots).findByRole("img", { name: "Scout" }); + await waitFor(() => + expect(scout.getAttribute("data-kite")).toBe("working"), + ); + }); + + test("the Bot you are with keeps its eyes open; any other wakes only while you point at it", async () => { + api(); + const view = renderApp("/channel/c-close"); + const bots = await section(view, "Bots"); + const eyesOf = (name: string) => + within(bots).getByRole("img", { name }).querySelectorAll(".bot-kite-eye") + .length; + await within(bots).findByRole("link", { name: /^October close/ }); + expect(eyesOf("Ledger")).toBe(12); + expect(eyesOf("Quill")).toBe(0); + const quill = within(bots).getByRole("link", { name: /^Quill/ }); + fireEvent.pointerEnter(quill); + await waitFor(() => expect(eyesOf("Quill")).toBe(12)); + fireEvent.pointerLeave(quill); + await waitFor(() => expect(eyesOf("Quill")).toBe(0)); + }); + + test("the Bot on screen opens out with its conversations, newest first; the others stay closed", async () => { + api(); + const view = renderApp("/channel/c-close"); + const bots = await section(view, "Bots"); + const close = await within(bots).findByRole("link", { + name: /^October close/, + }); + expect(close.getAttribute("href")).toBe("/channel/c-close"); + const ledgerRows = within(bots) + .getAllByRole("link") + .map((link) => link.textContent?.trim()); + const at = (title: string) => + ledgerRows.findIndex((row) => row?.startsWith(title)); + expect(at("October close")).toBeGreaterThan(-1); + expect(at("Supplier invoices")).toBeGreaterThan(at("October close")); + expect(within(bots).queryByText("Competitor scan")).toBeNull(); + }); + + test("choosing a Bot opens its newest conversation, or starts one when it has none", async () => { + api(); + const view = renderApp("/"); + const bots = await section(view, "Bots"); + const ledger = await within(bots).findByRole("link", { name: /^Ledger/ }); + expect(ledger.getAttribute("href")).toBe("/channel/c-close"); + const quill = within(bots).getByRole("link", { name: /^Quill/ }); + expect(quill.getAttribute("href")).toBe("/channel/new?agent=b-quill"); + expect( + within(bots) + .getByRole("link", { name: "New conversation with Ledger" }) + .getAttribute("href"), + ).toBe("/channel/new?agent=b-ledger"); + }); + + test("pinned conversations and conversations with several Bots have sections of their own", async () => { + api(); + const view = renderApp("/"); + const pinned = await section(view, "Pinned"); + expect( + ( + await within(pinned).findByRole("link", { name: /Morning triage/ }) + ).getAttribute("href"), + ).toBe("/channel/c-triage"); + const groups = await section(view, "Groups"); + const launch = await within(groups).findByRole("link", { + name: /Launch post draft/, + }); + expect(launch.getAttribute("href")).toBe("/group/g-launch"); + expect(launch.querySelectorAll("[data-kite]")).toHaveLength(2); + }); + + test("its foot reaches every one of OpenBot's own destinations", async () => { + api(); + const view = renderApp("/"); + await within(await section(view, "Bots")).findByText("Scout"); + const primary = navigationFor("admin").filter( + (item) => item.section === "primary", + ); + await waitFor(() => { + for (const item of primary) + expect( + view.getAllByRole("link", { name: new RegExp(`^${item.label}`) }), + ).not.toHaveLength(0); + }); + }); +}); + +describe("the Sky, on home", () => { + test("every Bot's kite, what needs you first, then what is working", async () => { + api(); + const view = renderApp("/"); + const sky = await view.findByRole("region", { name: "Your Bots" }); + await within(sky).findByText("Quill"); + await waitFor(() => { + const order = within(sky) + .getAllByRole("img") + .map((kite) => kite.getAttribute("aria-label")); + expect(order.slice(0, 2)).toEqual(["Ivy", "Scout"]); + }); + expect(within(sky).getByText("Waiting on you · 2")).toBeTruthy(); + expect(within(sky).getByText("Working")).toBeTruthy(); + }); + + test("a tile opens its Bot's newest conversation, or starts one", async () => { + api(); + const view = renderApp("/"); + const sky = await view.findByRole("region", { name: "Your Bots" }); + const ledger = await within(sky).findByRole("link", { name: /Ledger/ }); + expect(ledger.getAttribute("href")).toBe("/channel/c-close"); + expect( + within(sky).getByRole("link", { name: /Quill/ }).getAttribute("href"), + ).toBe("/channel/new?agent=b-quill"); + }); +}); diff --git a/app/tests/kitebot-roster.test.ts b/app/tests/kitebot-roster.test.ts new file mode 100644 index 0000000000..491d64c606 --- /dev/null +++ b/app/tests/kitebot-roster.test.ts @@ -0,0 +1,233 @@ +import { describe, expect, test } from "bun:test"; +import type { AgentProfile } from "@/lib/agents/queries"; +import type { ChannelSummary } from "@/lib/channels/queries"; +import { + groupConversations, + kiteBots, + needingYou, + openBotId, + skyLine, + skyOrder, +} from "@/skins/kitebot/roster"; +import { attentionOf } from "./bots-api"; + +/* + * What Kite Bot's sidebar and Sky say about each Bot, from the three things OpenBot already loads: + * the Bots, the conversations, and what waits on the person. + */ + +function bot(id: string, name: string, more: Partial = {}) { + return { + id, + name, + title: "", + avatarSeed: id, + hidden: false, + pinned: false, + ...more, + } as AgentProfile; +} + +function conversation( + id: string, + agentIds: string[], + more: Partial = {}, +): ChannelSummary { + return { + id, + name: "", + agentIds, + threadId: `t-${id}`, + active: true, + lastMessageAt: "2026-11-17T10:00:00.000Z", + summary: id, + lastMessage: null, + lastMessageAgentId: null, + createdAt: "2026-11-01T10:00:00.000Z", + pinned: false, + lastReadAt: "2026-11-17T10:00:00.000Z", + ...more, + }; +} + +const BOTS = [ + bot("b-scout", "Scout"), + bot("b-ledger", "Ledger"), + bot("b-ivy", "Ivy"), + bot("b-hidden", "Archive", { hidden: true }), +]; + +describe("each Bot's state", () => { + test("waiting beats working, and a Bot with neither is idle", () => { + const rows = kiteBots( + BOTS, + [ + conversation("c-1", ["b-scout"], { busy: true }), + conversation("c-2", ["b-ledger"], { busy: true }), + ], + [attentionOf("b-ledger", "Ledger", { approvals: 2, questions: 1 })], + ); + const state = Object.fromEntries( + rows.map((one) => [one.bot.name, one.state]), + ); + expect(state).toEqual({ Ivy: "idle", Ledger: "waiting", Scout: "working" }); + expect(rows.find((one) => one.bot.name === "Ledger")?.waiting).toBe(3); + }); + + test("a Bot working in a group conversation is working", () => { + const rows = kiteBots( + BOTS, + [conversation("g-1", ["b-scout", "b-ivy"], { busy: true })], + [], + ); + expect(rows.find((one) => one.bot.name === "Ivy")?.state).toBe("working"); + }); + + test("Bots hidden from the list are left out, and the rest stay in a steady order", () => { + const rows = kiteBots( + [...BOTS, bot("b-pinned", "Zed", { pinned: true })], + [], + [], + ); + expect(rows.map((one) => one.bot.name)).toEqual([ + "Zed", + "Ivy", + "Ledger", + "Scout", + ]); + }); + + test("its conversations are the ones with it alone, pinned first, then newest first", () => { + const rows = kiteBots( + BOTS, + [ + conversation("old", ["b-scout"], { + lastMessageAt: "2026-11-10T10:00:00.000Z", + }), + conversation("new", ["b-scout"], { + lastMessageAt: "2026-11-17T10:00:00.000Z", + }), + conversation("pinned", ["b-scout"], { + lastMessageAt: "2026-11-01T10:00:00.000Z", + pinned: true, + }), + conversation("group", ["b-scout", "b-ivy"]), + ], + [], + ); + const scout = rows.find((one) => one.bot.name === "Scout"); + expect(scout?.conversations.map((one) => one.id)).toEqual([ + "pinned", + "new", + "old", + ]); + expect(scout?.lastActiveAt).toBe("2026-11-17T10:00:00.000Z"); + }); + + test("unread is a Bot's message the person has not seen, never in the conversation on screen", () => { + const unseen = conversation("c-1", ["b-ivy"], { + lastMessageAgentId: "b-ivy", + lastMessageAt: "2026-11-17T11:00:00.000Z", + lastReadAt: "2026-11-17T10:00:00.000Z", + }); + const ownWords = conversation("c-2", ["b-scout"], { + lastMessageAgentId: null, + lastReadAt: null, + }); + const ivy = (open?: string) => + kiteBots(BOTS, [unseen, ownWords], [], open).find( + (one) => one.bot.name === "Ivy", + ); + expect(ivy()?.unread).toBe(true); + expect(ivy("c-1")?.unread).toBe(false); + expect( + kiteBots(BOTS, [unseen, ownWords], []).find( + (one) => one.bot.name === "Scout", + )?.unread, + ).toBe(false); + }); +}); + +test("Needs you lists the Bots that wait on the person, most waiting first", () => { + const rows = kiteBots( + BOTS, + [], + [ + attentionOf("b-scout", "Scout", { questions: 1 }), + attentionOf("b-ivy", "Ivy", { approvals: 3, waitingIn: "c-9" }), + ], + ); + const needs = needingYou(rows); + expect( + needs.map((one) => [one.bot.name, one.waiting, one.waitingIn]), + ).toEqual([ + ["Ivy", 3, "c-9"], + ["Scout", 1, null], + ]); +}); + +test("Groups are the conversations with more than one Bot, newest first", () => { + const groups = groupConversations([ + conversation("solo", ["b-ivy"]), + conversation("g-old", ["b-ivy", "b-scout"], { + lastMessageAt: "2026-11-02T10:00:00.000Z", + }), + conversation("g-new", ["b-ivy", "b-ledger"], { + lastMessageAt: "2026-11-16T10:00:00.000Z", + }), + ]); + expect(groups.map((one) => one.id)).toEqual(["g-new", "g-old"]); +}); + +test("the Sky puts what needs you first, then what is working, then the busiest", () => { + const rows = kiteBots( + [...BOTS, bot("b-quiet", "Quill")], + [ + conversation("c-scout", ["b-scout"], { busy: true }), + conversation("c-ivy", ["b-ivy"], { + lastMessageAt: "2026-11-17T12:00:00.000Z", + }), + ], + [attentionOf("b-ledger", "Ledger", { questions: 1 })], + ); + expect(skyOrder(rows).map((one) => one.bot.name)).toEqual([ + "Ledger", + "Scout", + "Ivy", + "Quill", + ]); +}); + +test("the Sky's line under each name says what the Bot is doing", () => { + const rows = kiteBots( + [...BOTS, bot("b-new", "Quill", { title: "Writer" })], + [ + conversation("c-scout", ["b-scout"], { busy: true }), + conversation("c-ivy", ["b-ivy"]), + ], + [ + attentionOf("b-ledger", "Ledger", { approvals: 2 }), + attentionOf("b-ivy", "Ivy", { paused: true }), + ], + ); + const line = (name: string) => + skyLine( + rows.find((one) => one.bot.name === name) ?? rows[0], + () => "3h ago", + ); + expect(line("Ledger")).toBe("Waiting on you · 2"); + expect(line("Scout")).toBe("Working"); + expect(line("Ivy")).toBe("Paused"); + expect(line("Quill")).toBe("Writer"); +}); + +test("the Bot the sidebar opens out is the one on screen", () => { + const channels = [ + conversation("c-1", ["b-scout"]), + conversation("g-1", ["b-scout", "b-ivy"]), + ]; + expect(openBotId("/channel/c-1", channels)).toBe("b-scout"); + expect(openBotId("/group/g-1", channels)).toBeNull(); + expect(openBotId("/bots/b-ivy/memory", channels)).toBe("b-ivy"); + expect(openBotId("/routines", channels)).toBeNull(); +}); diff --git a/app/tests/view-transition.test.ts b/app/tests/view-transition.test.ts new file mode 100644 index 0000000000..b778c6492c --- /dev/null +++ b/app/tests/view-transition.test.ts @@ -0,0 +1,82 @@ +import { afterEach, describe, expect, mock, test } from "bun:test"; +import { crossFade, pageTransitionTypes } from "@/lib/view-transition"; + +/* + * Whole-app changes as one movement (lib/view-transition.ts): a page change cross-fades the page, and + * a theme or skin change cross-fades the app, except where the browser cannot or the person asked + * for less motion, where the change simply happens. + */ + +const originalWindow = globalThis.window; +const originalDocument = globalThis.document; +afterEach(() => { + globalThis.window = originalWindow; + globalThis.document = originalDocument; +}); + +function browser({ + reducedMotion = false, + startViewTransition, +}: { + reducedMotion?: boolean; + startViewTransition?: (update: () => void) => unknown; +}) { + globalThis.window = { + matchMedia: (query: string) => ({ + matches: reducedMotion && query.includes("reduce"), + }), + } as unknown as typeof window; + globalThis.document = { + ...(startViewTransition ? { startViewTransition } : {}), + } as unknown as Document; +} + +describe("which page changes the router draws as a transition", () => { + test("going to another page is a page transition", () => { + browser({}); + expect( + pageTransitionTypes({ fromLocation: {}, pathChanged: true }), + ).toEqual(["page"]); + }); + + test("never the first page drawn, nor a change to the address's options alone", () => { + browser({}); + expect(pageTransitionTypes({ pathChanged: true })).toBe(false); + expect(pageTransitionTypes({ fromLocation: {}, pathChanged: false })).toBe( + false, + ); + }); + + test("never for somebody who asked for less motion", () => { + browser({ reducedMotion: true }); + expect(pageTransitionTypes({ fromLocation: {}, pathChanged: true })).toBe( + false, + ); + }); +}); + +describe("a whole-app change", () => { + test("cross-fades where the browser can, with the change made inside the transition", () => { + const order: string[] = []; + browser({ + startViewTransition: (update) => { + order.push("picture"); + update(); + return {}; + }, + }); + crossFade(() => order.push("change")); + expect(order).toEqual(["picture", "change"]); + }); + + test("simply happens where the browser cannot, or for somebody who asked for less motion", () => { + const change = mock(() => {}); + browser({}); + crossFade(change); + const start = mock(() => ({})); + browser({ reducedMotion: true, startViewTransition: start }); + crossFade(change); + expect(change).toHaveBeenCalledTimes(2); + expect(start).not.toHaveBeenCalled(); + }); +}); diff --git a/shared/user-preferences.ts b/shared/user-preferences.ts index 0a871e1f42..7a67a8b508 100644 --- a/shared/user-preferences.ts +++ b/shared/user-preferences.ts @@ -15,6 +15,7 @@ export const SKIN_IDS = [ "openduet", "opendots", "openfuse", + "kitebot", ] as const; export type SkinId = (typeof SKIN_IDS)[number]; From 73aa4650afd4c24fc0e445e23ee435644925693a Mon Sep 17 00:00:00 2001 From: Jerel John Velarde Date: Wed, 18 Nov 2026 13:38:35 -0800 Subject: [PATCH 2/2] Accept `kitebot` in the skin a person's preferences answer with oasdiff counts a new value in a response enum as breaking, since a client written against the old list could meet one it does not know. A build from before Kite Bot reads a skin id it does not know as `openbot`, as it already does for any unknown skin, so the two lines let exactly this addition through and nothing else. --- api/accepted-breaking-changes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/accepted-breaking-changes.md b/api/accepted-breaking-changes.md index e03406dba2..f35d7f3be5 100644 --- a/api/accepted-breaking-changes.md +++ b/api/accepted-breaking-changes.md @@ -44,4 +44,6 @@ Once the change is on the base branch, oasdiff no longer reports it and its line - 2026-11-15 PUT /api/v2/organizations/{organizationId}/network-policies/{networkPolicyId} added the new `team` enum value to the `scopeKind` response property for the response status `200`. A network policy can now be set for a team by id, beside the organization and a directory group; a client that never set one never reads one. - 2026-11-15 GET /api/v2/organizations/{organizationId}/shared-use-requests added the new `team` enum value to the `sharedUseRequests/items/current/oneOf[#/components/schemas/SharedUseApproval]/members/items/kind` response property for the response status `200` (shared schema: `SharedUseApproval`, also at `sharedUseRequests/items/proposed/members/items/kind`). A shared account's audience can now name a team by id beside a person and a directory group; nothing is taken from a client, and one written before teams never sent or approved a team. - 2026-11-15 POST /api/v2/organizations/{organizationId}/shared-use-requests/{sharedUseRequestId}/approve added the new `team` enum value to the `current/oneOf[#/components/schemas/SharedUseApproval]/members/items/kind` response property for the response status `200` (shared schema: `SharedUseApproval`, also at `proposed/members/items/kind`). A shared account's audience can now name a team by id beside a person and a directory group; nothing is taken from a client, and one written before teams never sent or approved a team. -- 2026-11-15 POST /api/v2/organizations/{organizationId}/shared-use-requests/{sharedUseRequestId}/decline added the new `team` enum value to the `current/oneOf[#/components/schemas/SharedUseApproval]/members/items/kind` response property for the response status `200` (shared schema: `SharedUseApproval`, also at `proposed/members/items/kind`). A shared account's audience can now name a team by id beside a person and a directory group; nothing is taken from a client, and one written before teams never sent or approved a team. \ No newline at end of file +- 2026-11-15 POST /api/v2/organizations/{organizationId}/shared-use-requests/{sharedUseRequestId}/decline added the new `team` enum value to the `current/oneOf[#/components/schemas/SharedUseApproval]/members/items/kind` response property for the response status `200` (shared schema: `SharedUseApproval`, also at `proposed/members/items/kind`). A shared account's audience can now name a team by id beside a person and a directory group; nothing is taken from a client, and one written before teams never sent or approved a team. +- 2026-11-18 GET /api/v2/organizations/{organizationId}/people/{personId}/preferences added the new `kitebot` enum value to the `skin` response property for the response status `200`. A person's skin is the one they picked, and Kite Bot is a new one. A build from before it reads an id it does not know as `openbot`, OpenBot's own look, as it already reads any skin it does not know, so a client written against the old list shows OpenBot rather than failing. +- 2026-11-18 PATCH /api/v2/organizations/{organizationId}/people/{personId}/preferences added the new `kitebot` enum value to the `skin` response property for the response status `200`. The same skin, as a save answers it. \ No newline at end of file