graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(native): Beautiful UI harness in a merjs desktop shell
Cursor Agente63f8f67b6b9
diff --git a/apps/native/.env.example b/apps/native/.env.examplenew file mode 100644index 00000000..55eb9d1c--- /dev/null+++ b/apps/native/.env.example@@ -0,0 +1,18 @@+# Optional. The Next.js proxy talks to graff serve on this URL.+# Start the bridge from the repo root: zig-out/bin/graff serve --port 8787+GRAFF_SERVE_URL=http://127.0.0.1:8787++# Optional Bearer token (HARNESS_SERVE_TOKEN / graff serve --token).+# Required by graff on non-loopback binds; also the switch that opens CORS+# on the bridge itself. The UI always goes through /api/graff, so the+# browser never needs this.+HARNESS_SERVE_TOKEN=++# Skip bash/tool permission prompts on the child (graff --yolo).+GRAFF_YOLO=1++# Default model or provider id for new sessions (e.g. gpt-5.5, claude-opus-4-8, codex).+NEXT_PUBLIC_GRAFF_MODEL=++# Workspace the child process should run in. Defaults to the repo root.+GRAFF_CWD=diff --git a/apps/native/.gitignore b/apps/native/.gitignorenew file mode 100644index 00000000..7c83d812--- /dev/null+++ b/apps/native/.gitignore@@ -0,0 +1,8 @@+node_modules/+.next/+out/+*.tsbuildinfo+next-env.d.ts+.env+.env.local+.DS_Storediff --git a/apps/native/ATTRIBUTION.md b/apps/native/ATTRIBUTION.mdnew file mode 100644index 00000000..3b383761--- /dev/null+++ b/apps/native/ATTRIBUTION.md@@ -0,0 +1,21 @@+# Attribution++## Beautiful UI++Copied from https://github.com/slev12397/beautiful-ui (MIT).+See `LICENSE.beautiful-ui`.++- `app/globals.css`+- `components/primitives/*`+- `components/atoms/*`+- `components/site/ThemeSync.tsx`, `ThemeToggle.tsx`+- fonts / token approach from `app/layout.tsx`++## merjs++Native window pattern from https://github.com/justrach/merjs+`examples/desktop/main.zig` (MIT). See `LICENSE.merjs`.++merjs is not vendored as a web framework here. The UI is Next.js so the+React primitives can be used as-is. The Zig file in `desktop/` is the+WKWebView shell only.diff --git a/apps/native/LICENSE.beautiful-ui b/apps/native/LICENSE.beautiful-uinew file mode 100644index 00000000..6635631a--- /dev/null+++ b/apps/native/LICENSE.beautiful-ui@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2026 Shane Levine++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/apps/native/LICENSE.merjs b/apps/native/LICENSE.merjsnew file mode 100644index 00000000..5651f92c--- /dev/null+++ b/apps/native/LICENSE.merjs@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2025 merjs contributors++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/apps/native/README.md b/apps/native/README.mdnew file mode 100644index 00000000..b7158bbf--- /dev/null+++ b/apps/native/README.md@@ -0,0 +1,86 @@+# Codegraff native app (merjs + Beautiful UI)++The Tauri desktop app in `gui/` is unchanged. This directory is a new native+surface:++- **Shell:** merjs `examples/desktop` — Zig → ObjC → `NSWindow` + `WKWebView`+ (no Electron). merjs is a separate repo; we copied only the window pattern.+- **UI:** [Beautiful UI](https://github.com/slev12397/beautiful-ui) primitives+ (MIT) + design tokens, composed as a graff harness.+- **Backend:** this repo's `graff serve` HTTP/NDJSON bridge (same `--json`+ events the TypeScript SDK already speaks).++## What was copied, what was dropped++Copied from Beautiful UI:++- `components/primitives/*`+- `components/atoms/*` (primitives depend on them)+- `app/globals.css` (`:root`, `.dark`, `@theme`, radii, shadows, motion)+- Inter + JetBrains Mono via `next/font` in `app/layout.tsx`+- IceCreamHarness chrome (tabs, sidebar, prompt bar, window radius 14)++Dropped:++- **posthog** / `instrumentation-client.ts` / email capture+- **cuelume** interaction sounds+- **dialkit** tuning overlay+- **`@central-icons-react`** — commercial; `CENTRAL_LICENSE_KEY` is not set+ here, so SidebarNav uses the free stroke set in `lib/icons.tsx`+- Ice-cream `SCENARIOS` / `matchScenario` demo data++Kept (free): `tailwindcss` v4, `shadow-plugin`, `glimm` (prompt-bar sweep),+`iconoir-react`, `liveline`.++## How the harness talks to graff++```+browser → Next.js /api/graff/* → graff serve → graff --json child+ (this app) :8787 NDJSON events+```++The proxy exists because `graff serve` only opens CORS when a Bearer token is+set. Same-origin `/api/graff` keeps the browser simple.++| graff event | primitive |+| --- | --- |+| `reasoning` / `model_call_started` | `ThinkingState` |+| `text` | `StreamingText` |+| `tool_call` / `tool_result` | `ToolChips` (+ diff chips for edits) |+| `ask_user` | `ApprovalCard` → `{"type":"answer"}` |+| `todo_write` | `TaskRows` in the side pane |+| `turn` / `error` | settle / error line |++Live-control (`set_model`, `cancel`) uses the same protocol as+`sdk/ts/remote.ts`.++## Run++```bash+# 1. agent backend (repo root)+zig build+./zig-out/bin/graff serve --port 8787++# 2. UI+cd apps/native+cp .env.example .env.local # optional+npm install+npm run dev # http://127.0.0.1:3000+```++macOS window (after the UI is up):++```bash+zig build-exe apps/native/desktop/main.zig -O ReleaseSmall \+ -femit-bin=zig-out/bin/graff-native \+ -framework AppKit -framework WebKit+GRAFF_NATIVE_URL=http://127.0.0.1:3000 ./zig-out/bin/graff-native+```++Linux has no WKWebView in the merjs shell — use the browser, or `xdg-open`+from `desktop/main.zig`. See `desktop/README.md`.++`npm test` runs the event-mapper unit tests (no provider calls).++Offline UI check (not the real agent): `npm run mock-serve` on :8787 streams+the same NDJSON shapes so the page can be clicked without a provider key.diff --git a/apps/native/app/api/graff/[...path]/route.ts b/apps/native/app/api/graff/[...path]/route.tsnew file mode 100644index 00000000..a9b225a6--- /dev/null+++ b/apps/native/app/api/graff/[...path]/route.ts@@ -0,0 +1,67 @@+import { NextRequest } from "next/server";++export const runtime = "nodejs";+export const dynamic = "force-dynamic";++function upstream(): string {+ return (process.env.GRAFF_SERVE_URL ?? "http://127.0.0.1:8787").replace(/\/+$/, "");+}++function headers(req: NextRequest): Headers {+ const h = new Headers();+ const type = req.headers.get("content-type");+ if (type) h.set("content-type", type);+ const token = process.env.HARNESS_SERVE_TOKEN;+ if (token) h.set("authorization", `Bearer ${token}`);+ return h;+}++function target(req: NextRequest, path: string[]): string {+ const suffix = path.join("/");+ const url = new URL(req.url);+ return `${upstream()}/${suffix}${url.search}`;+}++async function relay(req: NextRequest, path: string[], method: string): Promise<Response> {+ const init: RequestInit = {+ method,+ headers: headers(req),+ cache: "no-store",+ };+ if (method !== "GET" && method !== "HEAD" && method !== "DELETE") {+ init.body = await req.text();+ }+ let res: Response;+ try {+ res = await fetch(target(req, path), init);+ } catch (err) {+ const detail = err instanceof Error ? err.message : String(err);+ return Response.json(+ {+ error: "graff serve is not reachable",+ hint: "From the repo root: zig-out/bin/graff serve --port 8787",+ detail,+ },+ { status: 502 },+ );+ }+ const out = new Headers();+ const ct = res.headers.get("content-type");+ if (ct) out.set("content-type", ct);+ out.set("cache-control", "no-store");+ return new Response(res.body, { status: res.status, headers: out });+}++type Ctx = { params: Promise<{ path: string[] }> };++export async function GET(req: NextRequest, ctx: Ctx) {+ return relay(req, (await ctx.params).path, "GET");+}++export async function POST(req: NextRequest, ctx: Ctx) {+ return relay(req, (await ctx.params).path, "POST");+}++export async function DELETE(req: NextRequest, ctx: Ctx) {+ return relay(req, (await ctx.params).path, "DELETE");+}diff --git a/apps/native/app/globals.css b/apps/native/app/globals.cssnew file mode 100644index 00000000..62c0cfa4--- /dev/null+++ b/apps/native/app/globals.css@@ -0,0 +1,1501 @@+@import "tailwindcss";+/* shadow-plugin (flornkm) — smooth, layered shadow stacks. The unprefixed+ * entry maps them onto Tailwind's --shadow-xs…2xl scale; our semantic tokens+ * below build on those values so the whole app picks up the smooth shadows. */+@import "shadow-plugin/unprefixed";++@custom-variant dark (&:where(.dark, .dark *));++/* ──────────────────────────────────────────────────────────+ * Beautiful UI — design tokens+ * Cool near-white canvas, white cards, hairline borders, layered+ * single-digit-opacity shadows, a neutral ink ramp, and semantic+ * color used sparingly as a condiment.+ * ────────────────────────────────────────────────────────── */++:root {+ /* surfaces — cool, blue-tinted neutrals */+ --page: oklch(0.985 0.001 286.376);+ --canvas: oklch(0.961 0.002 247.84);+ --surface: oklch(1 0 0);+ --inset: oklch(0.979 0.002 247.839);+ --hover: oklch(0.97 0.002 247.839);+ --hover-2: oklch(0.933 0.003 247.86);++ /* ink ramp */+ --ink: oklch(0.247 0.006 258.361);+ --ink-2: oklch(0.506 0.01 264.477);+ --ink-3: oklch(0.695 0.009 264.505);++ /* borders — solid and crisp, not alpha */+ --line: oklch(0.946 0.003 264.542);+ --line-strong: oklch(0.912 0.005 258.326);+ --field: oklch(0.961 0.001 286.375);+ --stripe: oklch(0.405 0 0 / 0.075);+ --stripe-bg: oklch(0.97 0 0);++ /* accent */+ --accent: oklch(0.626 0.205 254.947);+ --accent-ink: oklch(0.556 0.187 255.617);+ --accent-tint: oklch(0.96 0.019 252.878);++ /* semantic */+ --green: oklch(0.603 0.155 150.883);+ --green-tint: oklch(0.958 0.017 159.118);+ --orange: oklch(0.689 0.179 49.902);+ --orange-tint: oklch(0.964 0.021 67.581);+ --red: oklch(0.621 0.192 23.042);+ --red-tint: oklch(0.956 0.017 17.462);++ /* chart overlays — neutral system colors with enough contrast on either theme */+ --tooltip-bg: oklch(0.272 0.008 264.435);+ --tooltip-fg: oklch(0.976 0.002 247.839);+ --tooltip-muted: oklch(0.731 0.008 260.731);+ --tooltip-border: oklch(0.356 0.007 264.474);++ /* shadows — our solid hairline ring + shadow-plugin's smooth layered stacks+ * (--shadow-xs…lg come from shadow-plugin/unprefixed) so every surface reads+ * consistently across the app. */+ --shadow-hairline: 0 0 0 1px var(--line);+ --shadow-btn: 0 0 0 1px var(--line-strong), var(--shadow-xs);+ --shadow-card: 0 0 0 1px var(--line), var(--shadow-sm);+ --shadow-raised: 0 0 0 1px var(--line), var(--shadow-md);+ --shadow-overlay: 0 0 0 1px var(--line), var(--shadow-lg);+ --shadow-inset-field: inset 0 1px 2px oklch(0 0 0 / 0.12);+}++.dark {+ --page: oklch(0.209 0.004 264.477);+ --canvas: oklch(0.231 0.004 264.487);+ --surface: oklch(0.26 0.006 271.191);+ --inset: oklch(0.243 0.004 264.492);+ --hover: oklch(0.289 0.006 271.22);+ --hover-2: oklch(0.318 0.007 274.747);++ --ink: oklch(0.964 0.002 247.839);+ --ink-2: oklch(0.731 0.008 260.731);+ --ink-3: oklch(0.541 0.01 264.484);++ --line: oklch(0.308 0.006 258.354);+ --line-strong: oklch(0.356 0.007 264.474);+ --field: oklch(0.293 0.006 271.223);+ --stripe: oklch(1 0 0 / 0.055);+ --stripe-bg: oklch(0.226 0.004 264.485);++ --accent: oklch(0.68 0.173 253.301);+ --accent-ink: oklch(0.788 0.113 248.33);+ --accent-tint: oklch(0.68 0.173 253.301 / 0.16);++ --green: oklch(0.705 0.154 153.814);+ --green-tint: oklch(0.705 0.154 153.814 / 0.14);+ --orange: oklch(0.746 0.156 55.642);+ --orange-tint: oklch(0.746 0.156 55.642 / 0.14);+ --red: oklch(0.666 0.18 21.433);+ --red-tint: oklch(0.666 0.18 21.433 / 0.14);++ --tooltip-bg: oklch(0.182 0.004 264.459);+ --tooltip-fg: oklch(0.964 0.002 247.839);+ --tooltip-muted: oklch(0.731 0.008 260.731);+ --tooltip-border: oklch(0.308 0.006 258.354);++ --shadow-hairline: 0 0 0 1px var(--line);+ /* Elevation rings go to a subtle *light* hairline in dark mode: the ring+ * paints over the surface behind the element, so a low-alpha white edge+ * dissolves into the shadow as one continuous stroke (per smooth-shadow-ring),+ * graduated by how far the surface floats. */+ --shadow-btn: 0 0 0 1px oklch(1 0 0 / 0.1), 0 1px 2px oklch(0 0 0 / 0.3);+ --shadow-card:+ 0 0 0 1px oklch(1 0 0 / 0.11), 0 1px 2px oklch(0 0 0 / 0.2),+ 0 2px 6px oklch(0 0 0 / 0.2);+ --shadow-raised:+ 0 0 0 1px oklch(1 0 0 / 0.13), 0 2px 10px oklch(0 0 0 / 0.22);+ --shadow-overlay:+ 0 0 0 1px oklch(1 0 0 / 0.15), 0 8px 28px oklch(0 0 0 / 0.34);+ --shadow-inset-field: inset 0 1px 2px oklch(0 0 0 / 0.4);+}++@theme inline {+ /* colors */+ --color-page: var(--page);+ --color-canvas: var(--canvas);+ --color-surface: var(--surface);+ --color-inset: var(--inset);+ --color-ink: var(--ink);+ --color-ink-2: var(--ink-2);+ --color-ink-3: var(--ink-3);+ --color-hover: var(--hover);+ --color-hover-2: var(--hover-2);+ --color-field: var(--field);+ --color-line: var(--line);+ --color-line-strong: var(--line-strong);+ --color-accent: var(--accent);+ --color-accent-ink: var(--accent-ink);+ --color-accent-tint: var(--accent-tint);+ --color-green: var(--green);+ --color-green-tint: var(--green-tint);+ --color-orange: var(--orange);+ --color-orange-tint: var(--orange-tint);+ --color-red: var(--red);+ --color-red-tint: var(--red-tint);++ /* shadows */+ --shadow-hairline: var(--shadow-hairline);+ --shadow-btn: var(--shadow-btn);+ --shadow-inset-field: var(--shadow-inset-field);+ --shadow-card: var(--shadow-card);+ --shadow-raised: var(--shadow-raised);+ --shadow-overlay: var(--shadow-overlay);++ /* type */+ --font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;+ --font-mono: var(--font-mono-face), ui-monospace, "SF Mono", monospace;++ /* radii — chips 6, controls 8, cards 10, windows 14, pills 999 */+ --radius-chip: 6px;+ --radius-control: 8px;+ --radius-card: 10px;+ --radius-window: 14px;++ /* easing — strong curves; built-ins are too weak */+ --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);+ --ease-in-out-strong: cubic-bezier(0.77, 0, 0.175, 1);+ --ease-link: cubic-bezier(0.16, 1, 0.3, 1);+}++/* ── base ─────────────────────────────────────────────── */++html {+ -webkit-font-smoothing: antialiased;+ -moz-osx-font-smoothing: grayscale;+ text-rendering: optimizeLegibility;+}++body {+ background-color: var(--stripe-bg);+ background-image: repeating-linear-gradient(+ -45deg,+ transparent 0,+ transparent 7px,+ var(--stripe) 7px,+ var(--stripe) 8px+ );+ /* Pin the stripe pattern to the viewport so it stays put on scroll. */+ background-attachment: fixed;+ color: var(--ink);+ font-feature-settings: "cv11", "ss01";+ font-size: 14px;+ letter-spacing: -0.01em;+ line-height: 1.5;+}++::selection {+ background: var(--accent-tint);+ color: var(--ink);+}++/* ── interface hygiene (interfaces.dev cheat sheet) ────── */++/* headings balance; descriptions avoid orphans (skip long-form — we have none) */+h1,+h2,+h3,+h4 {+ text-wrap: balance;+}++p {+ text-wrap: pretty;+}++/* underlines clear descenders */+a {+ text-underline-position: from-font;+ text-decoration-skip-ink: auto;+}++/* theme switches swap every token at once — freeze transitions so the flip+ * is one clean repaint instead of hundreds of mismatched color fades */+.theme-switching *,+.theme-switching *::before,+.theme-switching *::after {+ transition: none !important;+}++/* touch: :hover sticks after a tap, so neutralize row/header hovers there */+@media (hover: none) {+ .records-row:hover > .records-cell {+ background: transparent;+ }++ .records-row:hover > td.is-colsel {+ background: color-mix(in srgb, var(--accent) 4%, var(--surface));+ }++ .records-header-button:hover {+ background: transparent;+ color: var(--ink-2);+ }+}++/* Keep the component nav scrollable but hide its scrollbar. */+.component-nav-scroll {+ scrollbar-width: none; /* Firefox */+ -ms-overflow-style: none; /* legacy Edge */+}+.component-nav-scroll::-webkit-scrollbar {+ display: none; /* WebKit */+}++@media (min-width: 64rem) {+ .component-nav-scroll {+ -webkit-mask-image: linear-gradient(+ to bottom,+ oklch(0 0 0) 0,+ oklch(0 0 0) calc(100% - 6rem),+ transparent 100%+ );+ mask-image: linear-gradient(+ to bottom,+ oklch(0 0 0) 0,+ oklch(0 0 0) calc(100% - 6rem),+ transparent 100%+ );+ }+}++/* Mobile demo gestures should operate controls and visualizations rather than+ * selecting surrounding labels. Text entry and code remain intentionally+ * selectable. */+@media (hover: none) and (pointer: coarse) {+ .primitive-showcase {+ -webkit-user-select: none;+ user-select: none;+ -webkit-touch-callout: none;+ }++ .primitive-showcase :is(input, textarea, [contenteditable="true"], pre, code) {+ -webkit-user-select: text;+ user-select: text;+ -webkit-touch-callout: default;+ }++ .primitive-showcase :is(a, button, [role="button"]) {+ -webkit-tap-highlight-color: transparent;+ }++ .primitive-showcase :is(a, button, [role="button"]):focus-visible {+ outline: none;+ }++ .primitive-showcase :is(img, svg, canvas) {+ -webkit-user-drag: none;+ }++ .insight-chart-stage {+ touch-action: pan-y;+ }+}++/* Tailwind v4 resets buttons to cursor:default — anything+ * clickable must invite the click */+button:not(:disabled),+[role="button"]:not([aria-disabled="true"]),+label:has(input),+a {+ cursor: pointer;+}+++:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+ border-radius: 4px;+}++input:focus-visible,+textarea:focus-visible,+select:focus-visible,+[contenteditable]:focus-visible {+ outline: none;+}++.animated-underline {+ position: relative;+ display: inline-block;+}++.animated-underline::after {+ position: absolute;+ right: 0;+ bottom: -1px;+ left: 0;+ height: 1px;+ content: "";+ background: currentColor;+ transform: scaleX(0);+ transform-origin: left center;+ transition: transform 280ms var(--ease-link);+}++a:hover .animated-underline::after,+a:focus-visible .animated-underline::after {+ transform: scaleX(1);+}++.source-avatar {+ box-shadow: 0 0 0 1px oklch(0.21 0.034 263.436 / 0.1);+}++.dark .source-avatar {+ box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08);+}++/* ── primitive spacing system ─────────────────────────────+ * Shared optical offsets for small demo cards. Use these+ * instead of hand-tuning 10/12/14px per component.+ */++.primitive-card-pad {+ padding: 12px;+}++.primitive-card-bar {+ padding: 10px 12px;+}++.primitive-card-footer {+ padding: 10px 12px;+}++.primitive-table-cell {+ padding: 10px 12px;+}++.primitive-icon-button {+ display: inline-flex;+ width: 28px;+ height: 28px;+ align-items: center;+ justify-content: center;+ border-radius: var(--radius-control);+}++/* ── shared keyframes ─────────────────────────────────── */++@keyframes shimmer-text {+ from {+ background-position: 150% center;+ }+ to {+ background-position: -50% center;+ }+}++@keyframes fade-up {+ from {+ opacity: 0;+ transform: translateY(8px);+ }+ to {+ opacity: 1;+ transform: translateY(0);+ }+}++.home-reveal {+ will-change: opacity, transform, filter;+}++/* The sidebar is one persistent 224px tree clipped by a 52px shell.+ * Every rail glyph remains centered at x=26 in both states. */+.sidebar-row {+ width: 208px;+ transition-duration: var(--sidebar-copy-duration);+ transition-timing-function: var(--sidebar-easing);+}++.sidebar-copy {+ opacity: 1;+ transform: translateX(0);+ transition:+ opacity var(--sidebar-copy-duration) ease-out,+ transform var(--sidebar-copy-duration) var(--sidebar-easing);+}++.sidebar-logo,+.sidebar-collapse-control,+.sidebar-expand-control {+ transition-duration: var(--sidebar-copy-duration);+ transition-timing-function: ease-out;+}++.sidebar-expand-control {+ pointer-events: none;+ opacity: 0;+}++.sidebar-glide-highlight {+ right: 8px;+ left: 8px;+}++[data-sidebar-collapsed="true"] .sidebar-row {+ width: 36px;+}++[data-sidebar-collapsed="true"] .sidebar-copy {+ pointer-events: none;+ opacity: 0;+ transform: translateX(calc(var(--sidebar-copy-offset) * -1));+}++[data-sidebar-collapsed="true"] .sidebar-workspace-control {+ pointer-events: none;+}++[data-sidebar-collapsed="true"] .sidebar-logo,+[data-sidebar-collapsed="true"] .sidebar-collapse-control {+ pointer-events: none;+ opacity: 0;+}++[data-sidebar-collapsed="true"] .sidebar-expand-control {+ pointer-events: auto;+ opacity: 1;+}++[data-sidebar-collapsed="true"] .sidebar-glide-highlight {+ right: auto;+ width: 36px;+}++@media (prefers-reduced-motion: reduce) {+ .home-reveal {+ opacity: 1 !important;+ transform: none !important;+ filter: none !important;+ }+}++/* ── records table ────────────────────────────────────────+ * The grid is deliberately more architectural than card-like:+ * one quiet surface, precise rules, and color reserved for+ * meaning. The first column remains an anchor while both axes+ * can move independently inside the table viewport.+ */++.records-shell {+ width: 100%;+ min-width: 0;+ overflow: hidden;+ border: 1px solid var(--line);+ border-radius: 10px;+ background: var(--surface);+ box-shadow: 0 1px 2px oklch(0 0 0 / 0.06);+}++/* fill mode: the shell stretches to fill its container and drops its own+ * border/radius/shadow so it reads as part of the surrounding card rather+ * than a container-in-a-container. The grid body flexes to fill height. */+.records-shell.is-fill {+ display: flex;+ flex-direction: column;+ flex: 1;+ min-height: 0;+ height: 100%;+ border: 0;+ border-radius: 0;+ box-shadow: none;+}++.records-shell.is-fill .records-scroll {+ max-height: none;+ flex: 1;+}++.records-toolbar {+ display: flex;+ min-height: 52px;+ align-items: center;+ justify-content: space-between;+ gap: 12px;+ padding: 8px 10px;+ border-bottom: 1px solid var(--line-strong);+ background: var(--surface);+}++.records-toolbar-left,+.records-toolbar-right,+.records-company-header,+.records-quiet-button,+.records-secondary-button,+.records-primary-button,+.records-select-button,+.records-strength,+.records-link,+.records-add-calculation {+ display: inline-flex;+ align-items: center;+}++.records-toolbar-left,+.records-toolbar-right {+ gap: 4px;+}++.records-toolbar-right {+ flex-shrink: 0;+}++.records-select-button,+.records-quiet-button,+.records-secondary-button,+.records-primary-button {+ height: 32px;+ gap: 7px;+ border-radius: var(--radius-control);+ padding: 0 10px;+ font-size: 12px;+ font-weight: 500;+ white-space: nowrap;+ transition: background-color 140ms var(--ease-out-strong), color 140ms var(--ease-out-strong), transform 140ms var(--ease-out-strong), box-shadow 140ms var(--ease-out-strong);+}++.records-select-button {+ gap: 8px;+ color: var(--ink);+ border: 1px solid var(--line);+ background: var(--surface);+}++.records-select-button:hover,+.records-quiet-button:hover,+.records-secondary-button:hover {+ background: var(--hover);+ color: var(--ink);+}++.records-quiet-button {+ color: var(--ink-2);+}++.records-quiet-button.is-active {+ background: var(--accent-tint);+ color: var(--accent-ink);+}++.records-secondary-button {+ border: 1px solid var(--tooltip-border);+ color: var(--ink-2);+ box-shadow: none;+}++.records-primary-button {+ margin-left: 3px;+ background: var(--accent);+ color: oklch(1 0 0);+ box-shadow: none;+}++.records-primary-button:hover {+ filter: saturate(0.9) brightness(1.04);+}++.records-quiet-button:active,+.records-secondary-button:active,+.records-primary-button:active,+.records-select-button:active,+.records-add-calculation:active {+ transform: scale(0.96);+}++.records-database-icon {+ display: inline-flex;+ color: var(--green);+}++.records-filter-wrap {+ position: relative;+}++.records-filter-dot {+ width: 5px;+ height: 5px;+ margin-left: -2px;+ border-radius: 99px;+ background: var(--accent);+}++.records-filter-menu {+ position: absolute;+ z-index: 30;+ top: calc(100% + 7px);+ left: 0;+ width: 190px;+ padding: 6px;+ border: 1px solid var(--line-strong);+ border-radius: var(--radius-card);+ background: var(--surface);+ box-shadow: var(--shadow-overlay);+ animation: pop-in 160ms var(--ease-out-strong) both;+ transform-origin: top left;+}++.records-sort-menu {+ left: -48px;+}++.records-filter-label {+ padding: 5px 8px 6px;+ color: var(--ink-3);+ font-size: 10.5px;+ font-weight: 500;+ letter-spacing: 0.04em;+ text-transform: uppercase;+}++.records-filter-menu button {+ display: flex;+ width: 100%;+ align-items: center;+ gap: 7px;+ border-radius: var(--radius-chip);+ padding: 7px 8px;+ color: var(--ink-2);+ font-size: 12px;+ text-align: left;+ transition: background-color 120ms ease-out, color 120ms ease-out;+}++.records-filter-menu button:hover,+.records-filter-menu button.is-selected {+ background: var(--hover);+ color: var(--ink);+}++.records-menu-check {+ width: 13px;+ color: var(--accent-ink);+ font-size: 12px;+ font-weight: 500;+ text-align: center;+}++.records-scroll {+ max-height: 438px;+ overflow: auto;+ overscroll-behavior: none;+ scrollbar-color: var(--line-strong) transparent;+ scrollbar-gutter: stable;+}++.records-scroll:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: -2px;+}++.records-table {+ width: 100%;+ min-width: 990px;+ border-collapse: separate;+ border-spacing: 0;+ color: var(--ink);+ font-size: 13px;+ font-weight: 500;+ table-layout: fixed;+}++.records-company-col { width: 270px; }+.records-category-col { width: 275px; }+.records-last-col { width: 190px; }+.records-strength-col { width: 210px; }+.records-link-col { width: 175px; }++.records-table th,+.records-table td {+ border-right: 1px solid color-mix(in srgb, var(--line) 78%, transparent);+ border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);+ text-align: left;+ vertical-align: middle;+}++.records-table tr > :last-child {+ border-right: 0;+}++.records-table thead th {+ position: sticky;+ z-index: 5;+ top: 0;+ height: 35px;+ background: var(--surface);+ color: var(--ink-2);+ font-size: 12.5px;+ font-weight: 500;+}++.records-header-cell {+ padding: 0;+}++.records-resize-handle {+ position: absolute;+ z-index: 12;+ top: 0;+ right: -6px;+ width: 12px;+ height: 100%;+ cursor: col-resize;+ touch-action: none;+}++.records-resize-handle::after {+ position: absolute;+ top: 7px;+ bottom: 7px;+ left: 5px;+ width: 2px;+ border-radius: 99px;+ background: var(--accent);+ content: "";+ opacity: 0;+ transform: scaleY(0.65);+ transition: opacity 120ms ease-out, transform 150ms var(--ease-out-strong);+}++.records-resize-handle:hover::after,+.records-resize-handle.is-resizing::after {+ opacity: 1;+ transform: scaleY(1);+}++.records-header-cell.records-sticky-cell {+ z-index: 7;+}++.records-header-button,+.records-company-header {+ width: 100%;+ height: 35px;+ gap: 8px;+ padding: 0 12px;+}++.records-company-header {+ padding-left: 6px;+}++.records-header-button {+ display: flex;+ align-items: center;+ color: var(--ink-2);+ text-align: left;+ transition: background-color 120ms ease-out, color 120ms ease-out;+}++.records-header-button:hover {+ background: var(--hover);+ color: var(--ink);+}++.records-header-icon {+ display: inline-flex;+ flex-shrink: 0;+ color: var(--ink-3);+}++.records-sort {+ display: inline-flex;+ flex-shrink: 0;+ margin-left: auto;+ opacity: 0;+ transition: opacity 120ms ease-out, transform 160ms var(--ease-out-strong);+}++.records-header-button:hover .records-sort,+.records-sort.is-visible {+ opacity: 1;+}++.records-company-header {+ display: flex;+}++.records-company-header > span:not(.records-checkbox-box) {+ white-space: nowrap;+}++.records-add-field {+ display: inline-flex;+ margin-left: auto;+ color: var(--ink-3);+ opacity: 0;+ transition: opacity 120ms ease-out, color 120ms ease-out;+}++.records-company-header:hover .records-add-field,+.records-add-field:focus-visible {+ opacity: 1;+}++.records-add-field:hover {+ color: var(--ink);+}++.records-checkbox {+ position: relative;+ display: inline-flex;+ width: 24px;+ height: 24px;+ flex: 0 0 24px;+ align-items: center;+ justify-content: center;+ border-radius: var(--radius-chip);+}++.records-checkbox input {+ position: absolute;+ width: 1px;+ height: 1px;+ opacity: 0;+}++.records-checkbox-box {+ display: inline-flex;+ width: 18px;+ height: 18px;+ align-items: center;+ justify-content: center;+ border: 1px solid oklch(0.845 0.011 247.953);+ border-radius: 6px;+ color: oklch(0.446 0.018 251.343);+ background: oklch(1 0 0);+ transition: border-color 140ms ease-out, background-color 140ms ease-out, box-shadow 140ms ease-out, transform 140ms var(--ease-out-strong);+}++.records-checkbox:hover .records-checkbox-box {+ border-color: oklch(0.773 0.016 251.194);+ background: oklch(0.966 0.003 228.784);+}++.records-checkbox:active .records-checkbox-box {+ transform: scale(0.96);+}++.records-checkbox input:focus-visible + .records-checkbox-box {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+}++.records-checkbox-box.is-active {+ border-color: var(--accent);+ color: oklch(1 0 0);+ background: var(--accent);+ box-shadow: none;+}++.records-checkbox-dash {+ width: 8px;+ height: 1.5px;+ border-radius: 99px;+ background: oklch(1 0 0);+}++.dark .records-checkbox-box {+ border-color: oklch(0.45 0.017 254.711);+ color: oklch(0.917 0.007 247.901);+ background: oklch(0.346 0.015 252.294);+}++.dark .records-checkbox:hover .records-checkbox-box {+ border-color: oklch(0.521 0.019 254);+ background: oklch(0.391 0.016 251.761);+}++.dark .records-checkbox-box.is-active {+ border-color: var(--accent);+ color: oklch(1 0 0);+ background: var(--accent);+}++.dark .records-checkbox-dash {+ background: oklch(1 0 0);+}++.records-cell {+ height: 35px;+ padding: 0 8px;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.records-sticky-cell {+ position: sticky;+ left: 0;+ z-index: 2;+ background: var(--surface);+ box-shadow: 5px 0 8px -10px oklch(0 0 0 / 0.4);+}++.records-company-cell {+ display: flex;+ align-items: center;+ gap: 4px;+ padding-left: 6px;+ overflow: visible;+}++.records-row > .records-cell {+ transition: background-color 120ms ease-out, color 120ms ease-out;+}++.records-row:hover > .records-cell {+ background: var(--hover);+}++.records-row.is-selected > .records-cell {+ background: color-mix(in srgb, var(--accent) 7%, var(--surface));+}++/* ── spreadsheet gutter ──────────────────────────────────+ * Row numbers at rest; the checkbox takes their place on+ * hover or once the row is selected. */+.records-rownum {+ display: inline-flex;+ width: 24px;+ height: 24px;+ flex: 0 0 24px;+ align-items: center;+ justify-content: center;+ color: var(--ink-3);+ font-size: 11.5px;+ font-variant-numeric: tabular-nums;+}++.records-row .records-checkbox {+ display: none;+}++.records-row:hover .records-rownum,+.records-row.is-selected .records-rownum {+ display: none;+}++.records-row:hover .records-checkbox,+.records-row.is-selected .records-checkbox {+ display: inline-flex;+}++/* ── selected column — the property being configured ───── */+.records-table th.is-colsel {+ background: color-mix(in srgb, var(--accent) 8%, var(--surface));+ box-shadow: inset 0 2px 0 var(--accent);+}++th.is-colsel .records-header-button,+th.is-colsel .records-company-header,+th.is-colsel .records-header-icon {+ color: var(--accent-ink);+}++.records-table td.is-colsel {+ background: color-mix(in srgb, var(--accent) 4%, var(--surface));+}++.records-row:hover > td.is-colsel {+ background: color-mix(in srgb, var(--accent) 8%, var(--surface));+}++.records-row.is-selected > td.is-colsel {+ background: color-mix(in srgb, var(--accent) 10%, var(--surface));+}++/* ── AI column calculating state ─────────────────────────── */+.records-calc {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+}++.records-pulse {+ width: 8px;+ height: 8px;+ flex: 0 0 8px;+ border-radius: 50%;+ background: var(--accent);+ animation: records-pulse 1.1s ease-in-out infinite;+}++@keyframes records-pulse {+ 0%,+ 100% {+ opacity: 0.35;+ transform: scale(0.8);+ }+ 50% {+ opacity: 1;+ transform: scale(1);+ }+}++.records-company-mark {+ display: inline-flex;+ width: 20px;+ height: 20px;+ flex: 0 0 20px;+ align-items: center;+ justify-content: center;+ border: 0;+ border-radius: 6px;+ color: var(--ink-2);+ background: var(--field);+ font-size: 10px;+ font-weight: 500;+}++.records-company-name {+ min-width: 0;+ overflow: hidden;+ color: var(--ink);+ font-size: 13px;+ font-weight: 500;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.records-company-name.has-link:hover,+.records-company-name.has-link:focus-visible {+ color: var(--accent-ink);+ text-decoration: underline;+ text-underline-offset: 3px;+}++.records-tags {+ position: relative;+ display: flex;+ width: 100%;+ min-width: 0;+ align-items: center;+ gap: 4px;+ overflow: hidden;+}++.records-tags-measure {+ position: absolute;+ top: 0;+ left: 0;+ display: flex;+ width: max-content;+ gap: 4px;+ pointer-events: none;+ visibility: hidden;+}++.records-tags-measure > span {+ display: inline-flex;+}++.records-tag {+ display: inline-flex;+ height: 23px;+ max-width: 115px;+ align-items: center;+ flex-shrink: 0;+ overflow: hidden;+ cursor: pointer;+ border: 1px solid color-mix(in srgb, var(--tag-base) 32%, var(--surface));+ border-radius: 8px;+ padding: 0 7px;+ color: color-mix(in srgb, var(--tag-base) 92%, var(--ink));+ background: color-mix(in srgb, var(--tag-base) 18%, var(--surface));+ font-size: 13px;+ font-weight: 500;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.records-more-tag {+ display: inline-flex;+ height: 23px;+ align-items: center;+ flex-shrink: 0;+ border: 1px solid var(--line-strong);+ border-radius: 6px;+ padding: 0 7px;+ color: var(--ink-3);+ background: var(--inset);+ font-size: 11px;+ font-weight: 500;+}++.records-more-tag {+ border-color: var(--line-strong);+ color: var(--ink-3);+ background: var(--inset);+}++.records-muted {+ color: var(--ink-3);+}++.records-strength {+ gap: 8px;+ color: var(--ink-2);+}++.records-strength-dot {+ display: inline-block;+ width: 8px;+ height: 8px;+ flex: 0 0 8px;+ border-radius: 50%;+}++.records-link {+ max-width: 100%;+ gap: 5px;+ overflow: hidden;+ color: var(--accent-ink);+ text-overflow: ellipsis;+ text-decoration: underline;+ text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);+ text-underline-offset: 3px;+ transition: color 120ms ease-out, text-decoration-color 120ms ease-out;+}++.records-link-label {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.records-link svg {+ flex-shrink: 0;+}++.records-link:hover,+.records-link:focus-visible {+ color: var(--ink);+ text-decoration-color: currentColor;+}++.records-table tfoot td {+ position: sticky;+ z-index: 4;+ bottom: 0;+ height: 35px;+ background: var(--inset);+ color: var(--ink-2);+ font-size: 14px;+ font-weight: 500;+ line-height: 1;+}++.records-table tfoot .records-sticky-cell {+ z-index: 6;+ background: var(--inset);+}++.records-calculation-label {+ color: var(--ink-2);+ font-weight: 500;+}++.records-footer-value {+ display: inline-flex;+ height: 35px;+ align-items: center;+ vertical-align: middle;+}++.records-calculation-number {+ margin-right: 3px;+ color: var(--ink);+ font-variant-numeric: tabular-nums;+}++.records-add-calculation {+ height: 35px;+ gap: 6px;+ color: var(--ink-3);+ font-size: 14px;+ font-weight: 500;+ line-height: 1;+ transition: color 120ms ease-out, transform 140ms var(--ease-out-strong);+}++.records-add-calculation:hover {+ color: var(--ink);+}++.records-average {+ display: inline-flex;+ align-items: center;+ gap: 7px;+ color: var(--ink-2);+}++.records-calculation-row-secondary td {+ position: sticky;+ bottom: 35px;+ background: color-mix(in srgb, var(--inset) 70%, var(--surface));+}++.records-calculation-row-secondary .records-sticky-cell {+ position: sticky;+ background: color-mix(in srgb, var(--inset) 70%, var(--surface));+}++.records-footer {+ display: flex;+ min-height: 35px;+ align-items: center;+ justify-content: space-between;+ gap: 12px;+ padding: 0 12px;+ color: var(--ink-3);+ font-size: 11.5px;+}++.records-footer strong {+ color: var(--ink-2);+ font-weight: 500;+}++.records-footer-hint {+ display: inline-flex;+ align-items: center;+ gap: 5px;+ opacity: 0;+ transition: opacity 160ms ease-out;+}++.records-shell:hover .records-footer-hint {+ opacity: 1;+}++.records-scroll-cue {+ display: inline-flex;+ color: var(--ink-3);+}++@media (max-width: 640px) {+ .records-toolbar {+ align-items: flex-start;+ flex-direction: column;+ }++ .records-toolbar-left,+ .records-toolbar-right {+ width: 100%;+ }++ .records-toolbar-right {+ justify-content: flex-end;+ }++ .records-footer-hint {+ display: none;+ }+}++/* ── filter table electric status colors ─────────────────── */++.filter-status-todo,+.filter-status-progress,+.filter-status-done {+ border: 1px solid transparent;+}++.insight-chart-stage {+ overflow: hidden;+}++.insight-chart-cursor {+ position: absolute;+ z-index: 4;+ top: 0;+ bottom: 0;+ width: 1px;+ background: var(--ink);+ opacity: 0.26;+ pointer-events: none;+}++.insight-chart-tooltip-anchor {+ position: absolute;+ z-index: 5;+ top: 8px;+ transform: translateX(-50%);+ pointer-events: none;+}++.insight-chart-tooltip {+ display: flex;+ align-items: center;+ gap: 12px;+ padding: 5px 9px;+ border: 1px solid var(--line-strong);+ border-radius: 8px;+ color: var(--tooltip-fg);+ background: var(--tooltip-bg);+ box-shadow: var(--shadow-overlay);+ font-size: 11.5px;+ font-variant-numeric: tabular-nums;+ white-space: nowrap;+}++.insight-chart-tooltip-item {+ display: inline-flex;+ align-items: center;+ gap: 6px;+}++.insight-chart-tooltip-dot {+ width: 8px;+ height: 8px;+ flex: 0 0 8px;+ border-radius: 50%;+}++/* Status pills share the same base-hue → color-mix derivation as .records-tag,+ * so both components stay consistent across light and dark. */+.filter-status-todo {+ --tag-base: oklch(0.757 0.153 66.401);+}+.filter-status-progress {+ --tag-base: oklch(0.671 0.118 219.351);+}+.filter-status-done {+ --tag-base: oklch(0.652 0.131 162.865);+}++.filter-status-todo,+.filter-status-progress,+.filter-status-done {+ color: color-mix(in srgb, var(--tag-base) 92%, var(--ink));+ background: color-mix(in srgb, var(--tag-base) 20%, var(--surface));+ border-color: color-mix(in srgb, var(--tag-base) 34%, var(--surface));+}++/* Dark mode — a richer, saturated same-hue fill+ * with bright same-hue text and no visible border (light mode keeps the soft+ * tinted pastels above). Applies to both the records grid and status pills. */+.dark .records-tag,+.dark .filter-status-todo,+.dark .filter-status-progress,+.dark .filter-status-done {+ color: color-mix(in srgb, var(--tag-base) 86%, white);+ background: color-mix(in srgb, var(--tag-base) 34%, var(--surface));+ border-color: color-mix(in srgb, var(--tag-base) 34%, var(--surface));+}++@keyframes fade-in {+ from {+ opacity: 0;+ }+ to {+ opacity: 1;+ }+}++@keyframes eq-bounce {+ 0%,+ 100% {+ transform: scaleY(0.35);+ }+ 50% {+ transform: scaleY(1);+ }+}++/* ── StreamText primitive ─────────────────────────────────+ * Fast character reveal: the newest few characters carry a+ * soft, masked blur so the leading edge resolves smoothly as+ * text flows in. The caret holds solid while streaming, then+ * blinks once the string settles. */+.stream-tail {+ filter: blur(1.6px);+ -webkit-mask-image: linear-gradient(to right, oklch(0 0 0) 20%, oklch(0 0 0 / 0.2));+ mask-image: linear-gradient(to right, oklch(0 0 0) 20%, oklch(0 0 0 / 0.2));+}++.stream-caret {+ display: inline-block;+ width: 2px;+ height: 1.05em;+ margin-left: 1.5px;+ translate: 0 -0.5px;+ border-radius: 1px;+ background: var(--ink);+ vertical-align: text-bottom;+ animation: caret-blink 1s step-end infinite;+}++.stream-caret.is-streaming {+ animation: none;+}++@keyframes caret-blink {+ 0%,+ 100% {+ opacity: 1;+ }+ 50% {+ opacity: 0;+ }+}++@media (prefers-reduced-motion: reduce) {+ .stream-caret {+ animation: none;+ }+ .stream-tail {+ filter: none;+ -webkit-mask-image: none;+ mask-image: none;+ }+}++@keyframes pop-in {+ from {+ opacity: 0;+ transform: scale(0.95);+ }+ to {+ opacity: 1;+ transform: scale(1);+ }+}++@keyframes spin {+ to {+ transform: rotate(360deg);+ }+}++/* pixel-grid loader — brighten plateau, staggered per cell */+@keyframes pixel-on {+ 0%, 100% {+ opacity: 0.15;+ }+ 18%, 42% {+ opacity: 1;+ }+ 62% {+ opacity: 0.15;+ }+}++@media (prefers-reduced-motion: reduce) {+ *,+ *::before,+ *::after {+ animation-duration: 0.01ms !important;+ animation-iteration-count: 1 !important;+ transition-duration: 0.01ms !important;+ }+}diff --git a/apps/native/app/layout.tsx b/apps/native/app/layout.tsxnew file mode 100644index 00000000..0f2a2789--- /dev/null+++ b/apps/native/app/layout.tsx@@ -0,0 +1,37 @@+import type { Metadata } from "next";+import { Inter, JetBrains_Mono } from "next/font/google";+import "./globals.css";+import { ThemeSync } from "@/components/site/ThemeSync";++const inter = Inter({+ subsets: ["latin"],+ variable: "--font-inter",+});++const mono = JetBrains_Mono({+ subsets: ["latin"],+ variable: "--font-mono-face",+});++export const metadata: Metadata = {+ title: "Codegraff",+ description: "Native graff harness — Beautiful UI primitives in a merjs desktop shell.",+};++const themeScript = `(function(){try{var t=localStorage.getItem("bui-theme");document.documentElement.classList.toggle("dark",t!=="light")}catch(e){document.documentElement.classList.add("dark")}})()`;++export default function RootLayout({+ children,+}: Readonly<{ children: React.ReactNode }>) {+ return (+ <html lang="en" suppressHydrationWarning>+ <head>+ <script dangerouslySetInnerHTML={{ __html: themeScript }} />+ </head>+ <body className={`${inter.variable} ${mono.variable} font-sans`}>+ <ThemeSync />+ {children}+ </body>+ </html>+ );+}diff --git a/apps/native/app/page.tsx b/apps/native/app/page.tsxnew file mode 100644index 00000000..bb6022d7--- /dev/null+++ b/apps/native/app/page.tsx@@ -0,0 +1,5 @@+import GraffHarness from "@/components/site/GraffHarness";++export default function Page() {+ return <GraffHarness />;+}diff --git a/apps/native/components/atoms/Button.tsx b/apps/native/components/atoms/Button.tsxnew file mode 100644index 00000000..f658788b--- /dev/null+++ b/apps/native/components/atoms/Button.tsx@@ -0,0 +1,45 @@+"use client";++import { ButtonHTMLAttributes } from "react";++export type ButtonVariant = "primary" | "secondary" | "ghost" | "accent" | "success";+type Size = "sm" | "md";++const filledShadow = "shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]";++const variants: Record<ButtonVariant, string> = {+ primary:+ `bg-ink text-canvas hover:opacity-90 dark:bg-ink dark:text-canvas ${filledShadow}`,+ secondary:+ "bg-surface text-ink shadow-btn hover:bg-inset aria-expanded:bg-hover",+ ghost: "bg-hover-2 text-ink hover:bg-line-strong",+ accent: `bg-accent text-white hover:bg-accent-ink ${filledShadow}`,+ success: `bg-green text-white hover:brightness-95 ${filledShadow}`,+};++/* Pill-shaped by default — the app's core button style. Explicit symmetric+ * padding (not a fixed height) so the top/bottom spacing is always equal. */+const sizes: Record<Size, string> = {+ sm: "px-3 py-[7px] text-[13px] leading-none rounded-full gap-1.5",+ md: "px-4 py-[9px] text-sm leading-none rounded-full gap-2",+};++export function Button({+ variant = "secondary",+ size = "md",+ className = "",+ ...props+}: ButtonHTMLAttributes<HTMLButtonElement> & {+ variant?: ButtonVariant;+ size?: Size;+}) {+ return (+ <button+ className={`inline-flex items-center justify-center font-medium select-none+ transition-[transform,background-color,opacity] duration-150 ease-out+ active:scale-[0.96] disabled:opacity-50 disabled:pointer-events-none+ ${variants[variant]} ${sizes[size]} ${className}`}+ {...props}+ />+ );+}diff --git a/apps/native/components/atoms/Chip.tsx b/apps/native/components/atoms/Chip.tsxnew file mode 100644index 00000000..abb434a0--- /dev/null+++ b/apps/native/components/atoms/Chip.tsx@@ -0,0 +1,24 @@+/** Monospace token chip — for code values like `updated_at`. */+export function Chip({+ children,+ tone = "neutral",+ className = "",+}: {+ children: React.ReactNode;+ tone?: "neutral" | "accent" | "orange";+ className?: string;+}) {+ const tones = {+ neutral: "bg-inset text-ink-2",+ accent: "bg-accent-tint text-accent-ink",+ orange: "bg-orange-tint text-orange",+ };+ return (+ <code+ className={`inline rounded-md px-1.5 py-0.5 font-mono text-[12px]+ leading-none align-[-1px] ${tones[tone]} ${className}`}+ >+ {children}+ </code>+ );+}diff --git a/apps/native/components/atoms/ProgressRing.tsx b/apps/native/components/atoms/ProgressRing.tsxnew file mode 100644index 00000000..4270cbe1--- /dev/null+++ b/apps/native/components/atoms/ProgressRing.tsx@@ -0,0 +1,54 @@+/** Small progress ring with content in the center — the task-badge from the refs. */+export function ProgressRing({+ progress,+ tone = "orange",+ children,+ size = 28,+}: {+ progress: number; // 0..1+ tone?: "orange" | "green" | "red" | "accent";+ children?: React.ReactNode;+ size?: number;+}) {+ const stroke = 2;+ const r = (size - stroke) / 2;+ const c = 2 * Math.PI * r;+ const tones = {+ orange: "var(--orange)",+ green: "var(--green)",+ red: "var(--red)",+ accent: "var(--accent)",+ };+ return (+ <span+ className="relative inline-flex items-center justify-center"+ style={{ width: size, height: size }}+ >+ <svg width={size} height={size} className="-rotate-90 absolute inset-0">+ <circle+ cx={size / 2}+ cy={size / 2}+ r={r}+ fill="none"+ stroke="var(--line)"+ strokeWidth={stroke}+ />+ <circle+ cx={size / 2}+ cy={size / 2}+ r={r}+ fill="none"+ stroke={tones[tone]}+ strokeWidth={stroke}+ strokeLinecap="round"+ strokeDasharray={c}+ strokeDashoffset={c * (1 - Math.min(1, Math.max(0, progress)))}+ style={{ transition: "stroke-dashoffset 400ms cubic-bezier(0.23,1,0.32,1)" }}+ />+ </svg>+ <span className="relative text-[12px] font-semibold tabular-nums">+ {children}+ </span>+ </span>+ );+}diff --git a/apps/native/components/atoms/SegmentedControl.tsx b/apps/native/components/atoms/SegmentedControl.tsxnew file mode 100644index 00000000..b70a03da--- /dev/null+++ b/apps/native/components/atoms/SegmentedControl.tsx@@ -0,0 +1,48 @@+"use client";++/** Segmented control — equal-width segments, sliding thumb. */+export function SegmentedControl<T extends string>({+ options,+ value,+ onChange,+ className = "",+}: {+ options: readonly T[];+ value: T;+ onChange: (v: T) => void;+ className?: string;+}) {+ const index = options.indexOf(value);+ return (+ <div+ className={`relative inline-grid h-8 select-none rounded-full bg-line/60 p-0.5 ${className}`}+ style={{ gridTemplateColumns: `repeat(${options.length}, 1fr)` }}+ role="tablist"+ >+ <span+ aria-hidden+ className="absolute inset-y-0.5 rounded-full bg-surface shadow-hairline+ transition-transform duration-200"+ style={{+ width: `calc((100% - 4px) / ${options.length})`,+ left: 2,+ transform: `translateX(${index * 100}%)`,+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ />+ {options.map((opt) => (+ <button+ key={opt}+ role="tab"+ aria-selected={opt === value}+ onClick={() => onChange(opt)}+ className={`relative z-10 rounded-full px-3 text-[13px] font-medium+ transition-colors duration-150+ ${opt === value ? "text-ink" : "text-ink-3 hover:text-ink-2"}`}+ >+ {opt}+ </button>+ ))}+ </div>+ );+}diff --git a/apps/native/components/atoms/Shimmer.tsx b/apps/native/components/atoms/Shimmer.tsxnew file mode 100644index 00000000..4bc88f4a--- /dev/null+++ b/apps/native/components/atoms/Shimmer.tsx@@ -0,0 +1,22 @@+/** Shimmering label — signals the agent is processing. */+export function Shimmer({+ children,+ className = "",+}: {+ children: React.ReactNode;+ className?: string;+}) {+ return (+ <span+ className={`inline-block bg-clip-text text-transparent ${className}`}+ style={{+ backgroundImage:+ "linear-gradient(90deg, var(--ink-3) 35%, var(--ink) 50%, var(--ink-3) 65%)",+ backgroundSize: "200% 100%",+ animation: "shimmer-text 1.8s linear infinite",+ }}+ >+ {children}+ </span>+ );+}diff --git a/apps/native/components/atoms/StatusPill.tsx b/apps/native/components/atoms/StatusPill.tsxnew file mode 100644index 00000000..f632f9ce--- /dev/null+++ b/apps/native/components/atoms/StatusPill.tsx@@ -0,0 +1,32 @@+type Tone = "green" | "orange" | "red" | "accent" | "neutral";++const tones: Record<Tone, { bg: string; fg: string; dot: string }> = {+ green: { bg: "bg-green-tint", fg: "text-green", dot: "bg-green" },+ orange: { bg: "bg-orange-tint", fg: "text-orange", dot: "bg-orange" },+ red: { bg: "bg-red-tint", fg: "text-red", dot: "bg-red" },+ accent: { bg: "bg-accent-tint", fg: "text-accent-ink", dot: "bg-accent" },+ neutral: { bg: "bg-inset", fg: "text-ink-2", dot: "bg-ink-3" },+};++export function StatusPill({+ tone = "neutral",+ children,+ dot = true,+ className = "",+}: {+ tone?: Tone;+ children: React.ReactNode;+ dot?: boolean;+ className?: string;+}) {+ const t = tones[tone];+ return (+ <span+ className={`inline-flex h-6 items-center gap-1.5 rounded-full px-2.5+ text-[13px] font-medium leading-none ${t.bg} ${t.fg} ${className}`}+ >+ {dot && <span className={`size-1.5 rounded-full ${t.dot}`} />}+ {children}+ </span>+ );+}diff --git a/apps/native/components/atoms/StreamText.tsx b/apps/native/components/atoms/StreamText.tsxnew file mode 100644index 00000000..c7b63ec4--- /dev/null+++ b/apps/native/components/atoms/StreamText.tsx@@ -0,0 +1,78 @@+"use client";++import { useEffect, useRef, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * STREAM TEXT — reusable streaming primitive+ * Reveals characters quickly (fast, like a real token stream);+ * the leading edge resolves out of a soft blur, and the caret+ * stays solid while streaming, then blinks once the text+ * settles. Inherits typography from its context, so it drops+ * into any text surface (Selection Actions, chat, etc.).+ * ───────────────────────────────────────────────────────── */++export function StreamText({+ text,+ charsPerTick = 2,+ tickMs = 9,+ blurTail = 6,+ caret = true,+ className,+ onProgress,+ onDone,+}: {+ text: string;+ /** characters revealed per tick — higher is faster */+ charsPerTick?: number;+ /** interval between reveals, ms */+ tickMs?: number;+ /** how many trailing characters carry the soft blur edge */+ blurTail?: number;+ /** render the caret (solid while streaming, blinks once idle) */+ caret?: boolean;+ className?: string;+ /** fires each tick — useful for re-anchoring UI to reflowing text */+ onProgress?: () => void;+ /** fires once the full string is shown */+ onDone?: () => void;+}) {+ const [count, setCount] = useState(0);+ const onProgressRef = useRef(onProgress);+ const onDoneRef = useRef(onDone);+ onProgressRef.current = onProgress;+ onDoneRef.current = onDone;++ useEffect(() => {+ setCount(0);+ let i = 0;+ const id = setInterval(() => {+ i = Math.min(i + charsPerTick, text.length);+ setCount(i);+ onProgressRef.current?.();+ if (i >= text.length) {+ clearInterval(id);+ onDoneRef.current?.();+ }+ }, tickMs);+ return () => clearInterval(id);+ }, [text, charsPerTick, tickMs]);++ const streaming = count < text.length;+ const shown = text.slice(0, count);+ const split = streaming ? Math.max(0, shown.length - blurTail) : shown.length;++ return (+ <span className={className}>+ {shown.slice(0, split)}+ {split < shown.length && (+ <span className="stream-tail">{shown.slice(split)}</span>+ )}+ {caret && (+ <span+ aria-hidden+ className={`stream-caret${streaming ? " is-streaming" : ""}`}+ />+ )}+ </span>+ );+}diff --git a/apps/native/components/atoms/Switch.tsx b/apps/native/components/atoms/Switch.tsxnew file mode 100644index 00000000..3c297df1--- /dev/null+++ b/apps/native/components/atoms/Switch.tsx@@ -0,0 +1,31 @@+"use client";++export function Switch({+ checked,+ onChange,+ label,+}: {+ checked: boolean;+ onChange: (v: boolean) => void;+ label?: string;+}) {+ return (+ <button+ role="switch"+ aria-checked={checked}+ aria-label={label}+ onClick={() => onChange(!checked)}+ className={`relative h-6 w-10 shrink-0 rounded-full transition-colors duration-200+ ${checked ? "bg-ink" : "bg-line-strong"}`}+ >+ <span+ className="absolute top-0.5 left-0.5 size-5 rounded-full bg-white+ shadow-[0_1px_2px_rgba(0,0,0,0.2)] transition-transform duration-200"+ style={{+ transform: checked ? "translateX(16px)" : "translateX(0)",+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ />+ </button>+ );+}diff --git a/apps/native/components/atoms/TextRow.tsx b/apps/native/components/atoms/TextRow.tsxnew file mode 100644index 00000000..32428e81--- /dev/null+++ b/apps/native/components/atoms/TextRow.tsx@@ -0,0 +1,26 @@+/** Label-left / value-right row — the workhorse of every card in the refs. */+export function TextRow({+ label,+ value,+ meta,+ className = "",+}: {+ label: React.ReactNode;+ value: React.ReactNode;+ meta?: React.ReactNode;+ className?: string;+}) {+ return (+ <div+ className={`flex min-h-11 items-center justify-between gap-4 py-2 ${className}`}+ >+ <span className="text-sm text-ink-2">{label}</span>+ <span className="flex items-baseline gap-2 text-right">+ <span className="text-sm font-medium text-ink tabular-nums">+ {value}+ </span>+ {meta && <span className="text-[13px] text-ink-3">{meta}</span>}+ </span>+ </div>+ );+}diff --git a/apps/native/components/primitives/ApprovalCard.tsx b/apps/native/components/primitives/ApprovalCard.tsxnew file mode 100644index 00000000..2d557085--- /dev/null+++ b/apps/native/components/primitives/ApprovalCard.tsx@@ -0,0 +1,395 @@+"use client";++import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties } from "react";+import { Button } from "@/components/atoms/Button";++/* ─────────────────────────────────────────────────────────+ * APPROVAL CARD (human-in-the-loop)+ * One question at a time. The stack slides vertically as you+ * move between questions (the card's height animates to fit),+ * the step counter rolls like an odometer, and the footer uses+ * pill actions — a quiet Skip and a dark Continue with a ⏎.+ * Single-choice answers auto-advance; multi-select waits.+ * ───────────────────────────────────────────────────────── */++const DEFAULT_QUESTIONS = [+ {+ q: "How many flavors should we launch?",+ type: "radio" as const,+ options: ["Three (core line)", "Five (full case)", "Just one hero"],+ },+ {+ q: "Which mix-ins should we stock?",+ type: "check" as const,+ options: ["Chocolate chips", "Waffle bits", "Sprinkles"],+ },+ {+ q: "Which market do we enter first?",+ type: "radio" as const,+ options: ["Food trucks", "Grocery freezers", "Scoop shops"],+ },+];++const ROLL_MS = 400;+const SLIDE = "360ms cubic-bezier(0.22, 1, 0.36, 1)";++/* odometer digits — each character that changes rolls up (or down) */+function RollingDigits({ value }: { value: string }) {+ const prevRef = useRef(value);+ const [oldVal, setOldVal] = useState(value);+ const [newVal, setNewVal] = useState(value);+ const [rolling, setRolling] = useState(false);+ const [shifted, setShifted] = useState(false);+ const [dir, setDir] = useState<"up" | "down">("up");++ useEffect(() => {+ if (prevRef.current === value) return;+ const from = prevRef.current;+ prevRef.current = value;+ const fromN = parseInt(from, 10);+ const toN = parseInt(value, 10);+ setDir(Number.isFinite(fromN) && Number.isFinite(toN) && toN < fromN ? "down" : "up");+ setOldVal(from);+ setNewVal(value);+ setRolling(true);+ setShifted(false);++ let raf2 = 0;+ const raf1 = requestAnimationFrame(() => {+ raf2 = requestAnimationFrame(() => setShifted(true));+ });+ const done = setTimeout(() => {+ setRolling(false);+ setOldVal(value);+ setShifted(false);+ }, ROLL_MS);++ return () => {+ cancelAnimationFrame(raf1);+ cancelAnimationFrame(raf2);+ clearTimeout(done);+ };+ }, [value]);++ const chars = rolling ? newVal : oldVal;++ return (+ <>+ {Array.from({ length: chars.length }, (_, i) => {+ const o = oldVal[i] ?? "";+ const n = chars[i] ?? "";+ if (!rolling || o === n) {+ return <span key={`${i}-${n}`}>{n}</span>;+ }+ const top = dir === "down" ? n : o;+ const bottom = dir === "down" ? o : n;+ const restY = dir === "down" ? "0" : "-1em";+ const startY = dir === "down" ? "-1em" : "0";+ return (+ <span+ key={`${i}-${o}-${n}-${dir}`}+ style={{ display: "inline-block", position: "relative", overflow: "hidden", height: "1em", lineHeight: "1em", verticalAlign: "-0.05em" }}+ >+ <span+ style={{+ display: "flex",+ flexDirection: "column",+ transition: "transform 350ms cubic-bezier(0.4, 0, 0.2, 1)",+ transform: `translateY(${shifted ? restY : startY})`,+ }}+ >+ <span style={{ height: "1em", lineHeight: "1em" }}>{top}</span>+ <span style={{ height: "1em", lineHeight: "1em" }}>{bottom}</span>+ </span>+ </span>+ );+ })}+ </>+ );+}++function Ico({ path, size = 14, sw = 2 }: { path: React.ReactNode; size?: number; sw?: number }) {+ return (+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round" aria-hidden>+ {path}+ </svg>+ );+}++export type ApprovalQuestion = {+ q: string;+ type: "radio" | "check";+ options: string[];+};++export default function ApprovalCard({+ onSubmitted,+ resettable = true,+ questions,+}: {+ onSubmitted?: (answers?: string[]) => void;+ resettable?: boolean;+ variant?: string;+ questions?: ApprovalQuestion[];+} = {}) {+ const QUESTIONS = questions && questions.length > 0 ? questions : DEFAULT_QUESTIONS;+ const [qi, setQi] = useState(0);+ const [answers, setAnswers] = useState<Record<number, number[]>>({});+ const [custom, setCustom] = useState<Record<number, string>>({});+ const [sent, setSent] = useState(false);+ const [open, setOpen] = useState(true);++ const advanceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);+ const questionRefs = useRef<(HTMLDivElement | null)[]>([]);+ const measured = useRef(false);+ const [viewportH, setViewportH] = useState<number | undefined>(undefined);+ const [trackY, setTrackY] = useState(0);+ const [animate, setAnimate] = useState(false);++ const last = qi === QUESTIONS.length - 1;+ const selected = answers[qi] ?? [];+ const hasAnswer = selected.length > 0 || Boolean(custom[qi]?.trim());++ const sync = (withAnim: boolean) => {+ const item = questionRefs.current[qi];+ if (!item) return;+ const reduce = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;+ setViewportH(item.offsetHeight);+ setTrackY(item.offsetTop);+ setAnimate(withAnim && !reduce);+ };++ useLayoutEffect(() => {+ const withAnim = measured.current;+ measured.current = true;+ sync(withAnim);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [qi, answers, custom, open, sent]);++ useEffect(() => {+ const id = requestAnimationFrame(() => sync(measured.current));+ return () => cancelAnimationFrame(id);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [qi]);++ useEffect(() => () => { if (advanceTimer.current) clearTimeout(advanceTimer.current); }, []);++ const goTo = (next: number) => {+ if (advanceTimer.current) clearTimeout(advanceTimer.current);+ setQi(Math.min(Math.max(next, 0), QUESTIONS.length - 1));+ };++ const send = () => {+ if (advanceTimer.current) clearTimeout(advanceTimer.current);+ setSent(true);+ const collected = QUESTIONS.map((question, qIdx) => {+ const customText = custom[qIdx]?.trim();+ if (customText) return customText;+ const picked = answers[qIdx] ?? [];+ return picked.map((i) => question.options[i]).filter(Boolean).join(", ");+ }).filter(Boolean);+ onSubmitted?.(collected);+ };++ const advance = () => {+ if (last) send();+ else goTo(qi + 1);+ };++ const toggle = (index: number) => {+ const type = QUESTIONS[qi].type;+ setAnswers((current) => {+ const picked = current[qi] ?? [];+ const next = type === "radio"+ ? [index]+ : picked.includes(index)+ ? picked.filter((item) => item !== index)+ : [...picked, index];+ return { ...current, [qi]: next };+ });+ if (type === "radio") {+ setCustom((current) => ({ ...current, [qi]: "" }));+ if (advanceTimer.current) clearTimeout(advanceTimer.current);+ advanceTimer.current = setTimeout(() => {+ if (last) send();+ else setQi((current) => Math.min(QUESTIONS.length - 1, current + 1));+ }, 480);+ }+ };++ const reset = () => {+ setQi(0);+ setAnswers({});+ setCustom({});+ setSent(false);+ setOpen(true);+ measured.current = false;+ };++ if (!open) {+ return (+ <button type="button" onClick={() => setOpen(true)} className="rounded-control bg-surface px-3 py-2 text-[12.5px] font-medium text-ink shadow-btn transition-colors duration-150 hover:bg-hover">+ Open approval+ </button>+ );+ }++ if (sent) {+ return (+ <div className="flex w-full max-w-80 items-center gap-3" style={{ animation: "pop-in 260ms cubic-bezier(0.23,1,0.32,1) both" }}>+ <span className="inline-flex items-center gap-1.5 rounded-full bg-green-tint py-1 pr-2.5 pl-1 text-[12.5px] font-medium text-green">+ <span className="flex size-4.5 items-center justify-center rounded-full bg-green text-white">+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6L9 17l-5-5" /></svg>+ </span>+ Answers sent+ </span>+ {resettable && (+ <button type="button" onClick={reset} className="text-[12px] font-medium text-ink-3 transition-colors duration-150 hover:text-ink">+ Start over+ </button>+ )}+ </div>+ );+ }++ return (+ <div className="w-full max-w-80">+ <div className="relative overflow-hidden rounded-card bg-surface shadow-card" style={{ animation: "fade-up 380ms cubic-bezier(0.23,1,0.32,1) both" }}>+ <button+ type="button"+ aria-label="Dismiss"+ onClick={() => setOpen(false)}+ className="primitive-icon-button absolute right-2.5 top-2.5 z-10 text-ink-3 transition-colors duration-100 hover:bg-hover hover:text-ink"+ >+ <Ico size={14} sw={2.2} path={<path d="M18 6L6 18M6 6l12 12" />} />+ </button>+ <div className="primitive-card-pad">+ {/* the question itself is the heading */}+ <div+ className="overflow-hidden"+ style={{ height: viewportH, transition: animate ? `height ${SLIDE}` : undefined }}+ aria-live="polite"+ >+ <div+ style={{+ display: "flex",+ flexDirection: "column",+ gap: 26,+ transform: `translate3d(0, ${-trackY}px, 0)`,+ transition: animate ? `transform ${SLIDE}` : undefined,+ willChange: "transform",+ }}+ >+ {QUESTIONS.map((question, qIdx) => {+ const active = qIdx === qi;+ const picked = answers[qIdx] ?? [];+ const questionStyle: CSSProperties = {+ opacity: active ? 1 : 0,+ transition: animate ? `opacity ${SLIDE}` : undefined,+ pointerEvents: active ? undefined : "none",+ };+ return (+ <div+ key={qIdx}+ ref={(el) => { questionRefs.current[qIdx] = el; }}+ aria-hidden={active ? undefined : true}+ style={questionStyle}+ >+ <div className="pr-7 text-[14px] font-medium text-ink">{question.q}</div>+ <div className="mt-2 flex flex-col gap-0.5">+ {question.options.map((option, i) => {+ const on = picked.includes(i);+ return (+ <button+ key={option}+ type="button"+ aria-pressed={on}+ tabIndex={active ? 0 : -1}+ onClick={() => { if (active) toggle(i); }}+ className="flex items-center gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-100 hover:bg-hover"+ >+ <span+ className={`flex size-4 shrink-0 items-center justify-center transition-colors duration-200+ ${question.type === "radio" ? "rounded-full" : "rounded-[5px]"}+ ${on ? "bg-ink text-canvas" : "shadow-[inset_0_0_0_1.5px_var(--line-strong)] text-transparent"}`}+ >+ {question.type === "radio" ? (+ <span className="size-1.5 rounded-full bg-canvas transition-transform duration-200" style={{ transform: on ? "scale(1)" : "scale(0)" }} />+ ) : (+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6L9 17l-5-5" /></svg>+ )}+ </span>+ <span className={`text-[13px] transition-colors duration-200 ${on ? "text-ink" : "text-ink-2"}`}>+ {option}+ </span>+ </button>+ );+ })}+ <label className="flex items-center gap-2 rounded-control px-1.5 py-1 transition-colors duration-100 focus-within:bg-hover hover:bg-hover">+ <span aria-hidden="true" className="size-4 shrink-0" />+ <input+ value={custom[qIdx] ?? ""}+ tabIndex={active ? 0 : -1}+ onChange={(event) => {+ if (!active) return;+ setCustom((current) => ({ ...current, [qIdx]: event.target.value }));+ if (question.type === "radio") setAnswers((current) => ({ ...current, [qIdx]: [] }));+ }}+ onKeyDown={(event) => {+ if (event.key === "Enter" && hasAnswer) {+ event.preventDefault();+ advance();+ }+ }}+ placeholder="Something else…"+ aria-label="Custom answer"+ className="min-w-0 flex-1 bg-transparent text-[13px] text-ink outline-none placeholder:text-ink-3"+ />+ </label>+ </div>+ </div>+ );+ })}+ </div>+ </div>+ </div>++ {/* footer — step nav (rolling counter) + pill actions */}+ <div className="primitive-card-footer flex items-center justify-between gap-3">+ <div className="flex items-center gap-1 text-ink-3">+ <button+ type="button"+ aria-label="Previous question"+ disabled={qi <= 0}+ onClick={() => goTo(qi - 1)}+ className="flex size-[18px] items-center justify-center rounded-[5px] transition-colors duration-100 enabled:hover:text-ink disabled:opacity-30"+ >+ <Ico size={14} path={<path d="M18 15l-6-6-6 6" />} />+ </button>+ <span className="inline-flex items-center text-[12px] font-medium tabular-nums text-ink-3" style={{ letterSpacing: "-0.1px", lineHeight: 1 }}>+ <RollingDigits value={`${qi + 1} / ${QUESTIONS.length}`} />+ </span>+ <button+ type="button"+ aria-label="Next question"+ disabled={last}+ onClick={() => goTo(qi + 1)}+ className="flex size-[18px] items-center justify-center rounded-[5px] transition-colors duration-100 enabled:hover:text-ink disabled:opacity-30"+ >+ <Ico size={14} path={<path d="M6 9l6 6 6-6" />} />+ </button>+ </div>++ <div className="-mr-0.5 flex items-center gap-1.5">+ <Button variant="ghost" size="sm" onClick={() => setOpen(false)}>+ Skip+ </Button>+ <Button variant="accent" size="sm" disabled={!hasAnswer} onClick={advance}>+ {last ? "Send" : "Continue"}+ </Button>+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/ChatComposer.tsx b/apps/native/components/primitives/ChatComposer.tsxnew file mode 100644index 00000000..532fb26d--- /dev/null+++ b/apps/native/components/primitives/ChatComposer.tsx@@ -0,0 +1,187 @@+"use client";++import { useEffect, useRef, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * CHAT — interactive panel with tabs, replies, and composer.+ * The reply sequence begins only after the user sends.+ * ───────────────────────────────────────────────────────── */++type Phase = "idle" | "sent" | "reply1" | "reply2" | "done";++function Section({+ label,+ sub,+ time,+ body,+ resolving,+}: {+ label: string;+ sub: string;+ time: string;+ body: string;+ resolving?: boolean;+}) {+ return (+ <div+ className="flex w-full flex-col gap-1.5 transition-[opacity,filter,transform] duration-400"+ style={{+ opacity: resolving ? 0.55 : 1,+ filter: resolving ? "blur(0.5px)" : "blur(0)",+ transform: resolving ? "scale(0.985)" : "scale(1)",+ transformOrigin: "top left",+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ animation: "fade-up 400ms cubic-bezier(0.23,1,0.32,1) both",+ }}+ >+ <div className="flex items-center gap-1 text-[12px] leading-[1.3]">+ <span className="font-medium text-ink">{label}</span>+ <span className="text-ink-2">{sub}</span>+ <span className="text-ink">for {time}</span>+ </div>+ <p className="text-[13px] leading-normal text-ink">{body}</p>+ </div>+ );+}++export default function ChatComposer() {+ const [phase, setPhase] = useState<Phase>("done");+ const [draft, setDraft] = useState("");+ const [submitted, setSubmitted] = useState("Compare mint chip to last summer");+ const [tab, setTab] = useState("Flavors");+ const inputRef = useRef<HTMLInputElement>(null);++ useEffect(() => {+ let t: ReturnType<typeof setTimeout>;+ if (phase === "sent") t = setTimeout(() => setPhase("reply1"), 500);+ else if (phase === "reply1") t = setTimeout(() => setPhase("reply2"), 1400);+ else if (phase === "reply2") t = setTimeout(() => setPhase("done"), 1200);+ else return;+ return () => clearTimeout(t);+ }, [phase]);++ const sent = phase !== "idle";+ const canSend = draft.trim().length > 0;++ const send = () => {+ if (!canSend) return;+ setSubmitted(draft.trim());+ setDraft("");+ setPhase("sent");+ };++ return (+ <div className="flex h-[288px] w-full max-w-95 flex-col self-start overflow-hidden rounded-[14px] bg-surface shadow-card">+ {/* header — tabs + actions */}+ <div className="flex shrink-0 items-center justify-between border-b border-line p-1.5">+ <div className="flex items-center">+ {["Flavors", "Suppliers"].map((item) => (+ <button+ key={item}+ type="button"+ aria-pressed={tab === item}+ onClick={() => setTab(item)}+ className={`rounded-[6px] px-2 py-[3px] text-[13px] text-ink transition-[background-color,opacity] duration-100 ${tab === item ? "bg-field" : "opacity-50 hover:opacity-75"}`}+ >+ {item}+ </button>+ ))}+ </div>+ <div className="flex items-center gap-1">+ {[+ <path key="p" d="M12 5v14M5 12h14" />,+ <g key="h"><circle cx="12" cy="12" r="9" /><path d="M12 7v5l3 2" /></g>,+ <g key="e" fill="currentColor" stroke="none"><circle cx="5" cy="12" r="1.8" /><circle cx="12" cy="12" r="1.8" /><circle cx="19" cy="12" r="1.8" /></g>,+ ].map((icon, i) => (+ <button+ key={i}+ type="button"+ aria-label="Action"+ className="flex size-6 items-center justify-center rounded-[6px] text-ink-3+ transition-colors duration-100 hover:bg-hover hover:text-ink-2"+ >+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">+ {icon}+ </svg>+ </button>+ ))}+ </div>+ </div>++ {/* conversation — fixed region so the card never changes shape */}+ <div className="flex min-h-0 flex-1 flex-col gap-2.5 overflow-y-auto px-3 pt-2.5 pb-1">+ {/* user bubble — right aligned, soft block */}+ <div className="flex justify-end pl-14">+ <div+ className="rounded-xl bg-field px-3 py-1.5 text-[13px] leading-[1.4] text-ink+ transition-[opacity,transform] duration-300"+ style={{+ opacity: sent ? 1 : 0,+ transform: sent ? "translateY(0)" : "translateY(10px)",+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ >+ {submitted}+ </div>+ </div>++ {phase === "reply1" || phase === "reply2" || phase === "done" ? (+ <Section+ label="Sales History"+ sub="Flavor Data"+ time="4s"+ body="Pulled 3 summers of mint chip sales for comparison."+ />+ ) : null}+ {phase === "reply2" || phase === "done" ? (+ <Section+ label="Comparison"+ sub="Trend Detection"+ time="2s"+ body="Mint chip is up 12% with stronger weekend peaks."+ resolving={phase === "reply2"}+ />+ ) : null}+ </div>++ {/* composer */}+ <div className="mt-auto shrink-0 p-1.5">+ <div+ role="presentation"+ onClick={() => inputRef.current?.focus()}+ className="flex cursor-text flex-col gap-2 rounded-control border border-line bg-field p-2.5 shadow-[0_1px_2px_rgba(0,0,0,0.035)] transition-[border-color,box-shadow] duration-150 focus-within:border-line-strong focus-within:shadow-[0_1px_2px_rgba(0,0,0,0.025)]"+ >+ <input+ ref={inputRef}+ value={draft}+ onChange={(event) => setDraft(event.target.value)}+ onKeyDown={(event) => {+ if (event.key === "Enter") send();+ }}+ placeholder="Prompt or tag a flavor with @"+ aria-label="Chat prompt"+ className="min-h-4.5 bg-transparent text-[13px] leading-[1.4] text-ink outline-none placeholder:text-ink-3"+ />+ <div className="flex items-center justify-end">+ <button+ type="button"+ aria-label="Send"+ disabled={!canSend}+ onClick={send}+ className="flex size-7 items-center justify-center rounded-[8px]+ transition-[background-color,color,transform] duration-200 enabled:active:scale-[0.96]"+ style={{+ background: canSend ? "var(--ink)" : "var(--line-strong)",+ color: canSend ? "var(--surface)" : "var(--ink-2)",+ }}+ >+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round">+ <path d="M12 19V5M5 12l7-7 7 7" />+ </svg>+ </button>+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/CodeBlock.tsx b/apps/native/components/primitives/CodeBlock.tsxnew file mode 100644index 00000000..3d9503e5--- /dev/null+++ b/apps/native/components/primitives/CodeBlock.tsx@@ -0,0 +1,111 @@+"use client";++import { useCallback, useEffect, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * CODE BLOCK+ * Agent-written code streams line by line; copy is live.+ * ───────────────────────────────────────────────────────── */++const LINE_MS = 240;+const HOLD_MS = 3200;++type Tok = { t: string; c?: "kw" | "str" | "num" | "fn" | "dim" };++const LINES: Tok[][] = [+ [{ t: "export async function ", c: "kw" }, { t: "churnBatch", c: "fn" }, { t: "() {", c: "dim" }],+ [{ t: " const ", c: "kw" }, { t: "flavor = " }, { t: "await ", c: "kw" }, { t: "getFlavor", c: "fn" }, { t: "(", c: "dim" }, { t: "\"pistachio\"", c: "str" }, { t: ");", c: "dim" }],+ [{ t: " const ", c: "kw" }, { t: "base = " }, { t: "await ", c: "kw" }, { t: "dairy." }, { t: "fetch", c: "fn" }, { t: "({ flavor });", c: "dim" }],+ [{ t: " await ", c: "kw" }, { t: "freezer." }, { t: "store", c: "fn" }, { t: "(base, { temp: ", c: "dim" }, { t: "\"-14C\"", c: "str" }, { t: " });", c: "dim" }],+ [{ t: " return ", c: "kw" }, { t: "base.gallons;" }],+ [{ t: "}", c: "dim" }],+];++const COLORS: Record<string, string> = {+ kw: "var(--accent-ink)",+ str: "var(--green)",+ num: "var(--orange)",+ fn: "var(--ink)",+ dim: "var(--ink-3)",+};++const RAW = `export async function churnBatch() {+ const flavor = await getFlavor("pistachio");+ const base = await dairy.fetch({ flavor });+ await freezer.store(base, { temp: "-14C" });+ return base.gallons;+}`;++export default function CodeBlock() {+ const [count, setCount] = useState(0);+ const [copied, setCopied] = useState(false);+ const done = count >= LINES.length;++ /* stream in once, then hold — replaying reads as noise */+ useEffect(() => {+ if (done) return;+ const t = setTimeout(() => setCount((c) => c + 1), count === 0 ? 400 : LINE_MS);+ return () => clearTimeout(t);+ }, [count, done]);++ const copy = useCallback(() => {+ navigator.clipboard.writeText(RAW).then(() => {+ setCopied(true);+ setTimeout(() => setCopied(false), 1500);+ });+ }, []);++ return (+ <div className="w-full max-w-95 overflow-hidden rounded-card bg-surface shadow-card">+ {/* header */}+ <div className="primitive-card-bar flex items-center justify-between border-b border-line">+ <span className="flex items-center gap-2">+ <svg aria-hidden width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" className="shrink-0 text-ink-3">+ <path d="M17.25 6.75 22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3-4.5 16.5" />+ </svg>+ <span className="font-mono text-[12px] font-medium text-ink">churn.ts</span>+ <span className="text-[11.5px] text-ink-3">TypeScript</span>+ </span>+ <button+ aria-label="Copy code"+ onClick={copy}+ className={`flex h-6 items-center gap-1 rounded-[6px] px-1.5 text-[11.5px]+ font-medium transition-colors duration-100 hover:bg-hover+ ${copied ? "text-green" : "text-ink-3 hover:text-ink"}`}+ >+ {copied ? (+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6L9 17l-5-5" /></svg>+ ) : (+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="9" y="9" width="12" height="12" rx="2.5" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" /></svg>+ )}+ {copied ? "Copied" : "Copy"}+ </button>+ </div>++ {/* code */}+ <pre className="min-h-[137px] bg-inset px-3 py-2.5 font-mono text-[11.5px] leading-[1.7]">+ {LINES.slice(0, count).map((line, i) => (+ <div+ key={i}+ className="flex"+ style={{ animation: "fade-up 250ms cubic-bezier(0.23,1,0.32,1) both" }}+ >+ <span className="w-7 shrink-0 border-r border-line pr-2 text-right text-[10.5px] leading-[1.86] text-ink-3/60 select-none">+ {i + 1}+ </span>+ <span className="pl-3 whitespace-pre">+ {line.map((tok, j) => (+ <span key={j} style={{ color: tok.c ? COLORS[tok.c] : "var(--ink-2)" }}>+ {tok.t}+ </span>+ ))}+ {i === count - 1 && !done && (+ <span className="ml-0.5 inline-block h-3 w-[3px] translate-y-0.5 rounded-full bg-accent" />+ )}+ </span>+ </div>+ ))}+ </pre>+ </div>+ );+}diff --git a/apps/native/components/primitives/ContextCards.tsx b/apps/native/components/primitives/ContextCards.tsxnew file mode 100644index 00000000..a6debef4--- /dev/null+++ b/apps/native/components/primitives/ContextCards.tsx@@ -0,0 +1,90 @@+"use client";++import { useEffect, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * CONTEXT CARDS+ * Retrieved chunks enter once, then remain available.+ * ───────────────────────────────────────────────────────── */++const CHUNKS = [+ {+ title: "Vendor onboarding rule",+ chars: "290 characters",+ body: "Cold-chain certification must be verified before a new dairy can be added to the reorder workflow.",+ source: "Dairy Onboarding SOP.pdf",+ badge: "PDF",+ tone: "bg-red",+ },+ {+ title: "Seasonal demand row",+ chars: "1,250 characters",+ body: "Q4 velocity table: pistachio +18%, vanilla +6%, rocky road -11%; retire flavors below 40 scoops weekly.",+ source: "Sales Velocity Export.csv",+ badge: "CSV",+ tone: "bg-green",+ },+];++export default function ContextCards() {+ const [chipsShown, setChipsShown] = useState(false);++ useEffect(() => {+ const chips = setTimeout(() => setChipsShown(true), 700);+ return () => clearTimeout(chips);+ }, []);++ return (+ <div className="flex w-full max-w-95 flex-col gap-2">+ <div+ className="flex items-center gap-2 px-0.5"+ style={{ animation: "fade-in 400ms ease-out both" }}+ >+ <span className="text-[13px] font-semibold text-ink">All chunks</span>+ <span className="inline-flex h-5 items-center rounded-md bg-inset px-1.5 text-[11.5px] font-medium text-ink-2 shadow-hairline tabular-nums">+ 32+ </span>+ </div>++ {CHUNKS.map((chunk, i) => (+ <div+ key={chunk.title}+ className="overflow-hidden rounded-card bg-surface shadow-card"+ style={{+ animation: `fade-up 400ms cubic-bezier(0.23,1,0.32,1) ${i * 100}ms both`,+ }}+ >+ <div className="primitive-card-bar flex items-center gap-2.5 border-b border-line">+ <span className="flex min-w-0 items-center gap-1.5 text-[13px] font-medium text-ink">+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"><path d="M4 6h16M4 12h16M4 18h10" /></svg>+ <span className="truncate">{chunk.title}</span>+ </span>+ <span className="ml-auto shrink-0 text-[12px] text-ink-3 tabular-nums">{chunk.chars}</span>+ </div>+ <p className="px-3 pt-2 pb-1 text-[12.5px] leading-relaxed text-ink-2">+ {chunk.body}+ </p>+ <div className="px-3 pb-3">+ <span+ className="inline-flex h-6 items-center gap-1.5 rounded-full bg-inset px-2+ text-[12px] font-medium text-ink-2 shadow-btn+ transition-[opacity,transform,background-color] duration-300 hover:bg-hover"+ style={{+ opacity: chipsShown ? 1 : 0,+ transform: chipsShown ? "scale(1)" : "scale(0.95)",+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ transitionDelay: `${i * 80}ms`,+ }}+ >+ <span className={`flex size-3.5 items-center justify-center rounded-[4px] ${chunk.tone} text-[7px] font-bold text-white`}>+ {chunk.badge}+ </span>+ {chunk.source}+ <svg width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M7 17L17 7M7 7h10v10" /></svg>+ </span>+ </div>+ </div>+ ))}+ </div>+ );+}diff --git a/apps/native/components/primitives/DiffTable.tsx b/apps/native/components/primitives/DiffTable.tsxnew file mode 100644index 00000000..0fb6bc84--- /dev/null+++ b/apps/native/components/primitives/DiffTable.tsx@@ -0,0 +1,237 @@+"use client";++import { useEffect, useState } from "react";+import { Button } from "@/components/atoms/Button";++/* ─────────────────────────────────────────────────────────+ * DIFF TABLE+ * The proposed edit plays once and rests on the completed+ * diff. Each changed row is the control: click it to include+ * or exclude that specific addition/removal before applying.+ * ───────────────────────────────────────────────────────── */++function useStage(steps: number[]) {+ const [stage, setStage] = useState(0);+ useEffect(() => {+ if (stage >= steps.length) return;+ const t = setTimeout(() => setStage((s) => s + 1), steps[stage]);+ return () => clearTimeout(t);+ }, [stage, steps]);+ return stage;+}++const STAGE_DELAYS = [180, 260];++const ROWS = [+ { key: "rocky", id: "Rocky Road", dept: "Classic", email: "aurora-scoops", removed: true },+ { key: "bubblegum", id: "Bubblegum", dept: "Retro", email: "kumo-creamery", removed: true },+ { key: "mint", id: "Mint Chip", dept: "Classic", email: "maple-orbit", removed: false },+];++const DOT: Record<string, string> = {+ Classic: "bg-accent",+ Retro: "bg-ink-3",+ Seasonal: "bg-orange",+};++function IncludedMark({ included, tone }: { included: boolean; tone: "red" | "green" }) {+ return (+ <span+ aria-hidden+ className={`flex size-4.5 shrink-0 items-center justify-center rounded-[5px] transition-[background-color,color,transform] duration-150 ${+ included+ ? tone === "red" ? "bg-red text-white" : "bg-green text-white"+ : "bg-inset text-ink-3 shadow-hairline"+ }`}+ style={{ transform: included ? "scale(1)" : "scale(0.92)" }}+ >+ {included ? (+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6L9 17l-5-5" /></svg>+ ) : null}+ </span>+ );+}++export default function DiffTable() {+ const stage = useStage(STAGE_DELAYS);+ // 0 plain · 1 removals · 2 completed diff+ const tinted = stage >= 1;+ const settled = stage >= 2;+ const [accepted, setAccepted] = useState(false);+ const [edits, setEdits] = useState<Record<string, boolean>>({ rocky: true, bubblegum: true, pistachio: true });++ const removals = ["rocky", "bubblegum"].filter((key) => edits[key]).length;+ const additions = edits.pistachio ? 1 : 0;+ const showAdded = settled;++ const toggleEdit = (key: string) => setEdits((current) => ({ ...current, [key]: !current[key] }));++ return (+ <div className="w-full max-w-95">+ <div className="relative overflow-hidden rounded-card bg-surface shadow-card">+ <div className="primitive-card-bar flex items-center justify-between border-b border-line">+ <span className="text-[12.5px] font-medium text-ink">Proposed menu cleanup</span>+ {settled && !accepted && <span className="text-[11px] text-ink-3">Click changed rows to toggle</span>}+ </div>++ <table className="w-full table-fixed border-collapse text-left">+ <colgroup>+ <col className="w-[34%]" />+ <col className="w-[30%]" />+ <col className="w-[36%]" />+ </colgroup>+ <thead>+ <tr className="border-b border-line">+ {["Flavor", "Category", "Supplier"].map((h) => (+ <th key={h} className="primitive-table-cell text-[12px] font-medium text-ink-3">+ {h}+ </th>+ ))}+ </tr>+ </thead>+ <tbody>+ {ROWS.map((row) => {+ const out = row.removed && tinted && edits[row.key];+ const interactive = row.removed && settled && !accepted;+ return (+ <tr+ key={row.key}+ tabIndex={interactive ? 0 : undefined}+ aria-selected={row.removed ? edits[row.key] : undefined}+ onClick={interactive ? () => toggleEdit(row.key) : undefined}+ onKeyDown={interactive ? (event) => {+ if (event.key === "Enter" || event.key === " ") {+ event.preventDefault();+ toggleEdit(row.key);+ }+ } : undefined}+ className={`border-b border-line transition-[background-color,filter,opacity] duration-150 last:border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent ${+ interactive ? "cursor-pointer hover:brightness-[0.985]" : ""+ }`}+ style={{ background: out ? "var(--red-tint)" : undefined }}+ >+ <td+ className="primitive-table-cell text-[13px] font-medium tabular-nums transition-colors duration-200"+ style={{ color: out ? "var(--red)" : "var(--ink)" }}+ >+ {row.id}+ </td>+ <td className="primitive-table-cell">+ <span+ className="inline-flex h-5.5 items-center gap-1.5 rounded-full bg-inset px-2 text-[11.5px] font-medium shadow-hairline transition-opacity duration-200"+ style={{ opacity: out ? 0.55 : 1 }}+ >+ <span className={`size-1.5 rounded-full ${DOT[row.dept]}`} />+ <span className="text-ink-2">{row.dept}</span>+ </span>+ </td>+ <td+ className="primitive-table-cell text-[12.5px] whitespace-nowrap transition-colors duration-200"+ style={{+ color: out ? "var(--red)" : "var(--ink-2)",+ textDecorationLine: out ? "line-through" : "none",+ textDecorationColor: "color-mix(in srgb, var(--red) 50%, transparent)",+ }}+ >+ <span className="flex items-center justify-between gap-2">+ <span className="min-w-0 truncate">{row.email}</span>+ {row.removed && settled && <IncludedMark included={edits[row.key]} tone="red" />}+ </span>+ </td>+ </tr>+ );+ })}+ {/* added row */}+ <tr>+ <td colSpan={3} className="p-0">+ <div+ className="grid transition-[grid-template-rows,opacity] duration-200"+ style={{+ gridTemplateRows: showAdded ? "1fr" : "0fr",+ opacity: showAdded ? 1 : 0,+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ >+ <div className="overflow-hidden">+ <div+ role="checkbox"+ tabIndex={accepted ? -1 : 0}+ aria-checked={edits.pistachio}+ aria-label="Include adding Pistachio"+ onClick={accepted ? undefined : () => toggleEdit("pistachio")}+ onKeyDown={accepted ? undefined : (event) => {+ if (event.key === "Enter" || event.key === " ") {+ event.preventDefault();+ toggleEdit("pistachio");+ }+ }}+ className={`grid grid-cols-[34%_30%_36%] items-center border-t border-line transition-[background-color,filter,opacity] duration-150 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent ${+ accepted ? "" : "cursor-pointer hover:brightness-[0.985]"+ }`}+ style={{ background: edits.pistachio ? "var(--green-tint)" : undefined }}+ >+ <span className="primitive-table-cell text-[13px] font-medium tabular-nums transition-colors duration-200" style={{ color: edits.pistachio ? "var(--green)" : "var(--ink-3)" }}>+ Pistachio+ </span>+ <span className="primitive-table-cell">+ <span className="inline-flex h-5.5 items-center gap-1.5 rounded-full bg-surface px-2 text-[11.5px] font-medium shadow-hairline">+ <span className="size-1.5 rounded-full bg-green" />+ <span className="text-ink-2">Seasonal</span>+ </span>+ </span>+ <span className="primitive-table-cell text-[13px] transition-colors duration-200" style={{ color: edits.pistachio ? "var(--green)" : "var(--ink-3)" }}>+ <span className="flex items-center justify-between gap-2">+ <span className="min-w-0 truncate">maple-orbit</span>+ <IncludedMark included={edits.pistachio} tone="green" />+ </span>+ </span>+ </div>+ </div>+ </div>+ </td>+ </tr>+ </tbody>+ </table>++ {/* footer — the summary follows the row-level selection */}+ {settled && (+ <div+ className="primitive-card-footer flex min-h-11 items-center justify-between border-t border-line"+ style={{ animation: "fade-up 180ms cubic-bezier(0.23,1,0.32,1) both" }}+ >+ {accepted ? (+ <span+ className="inline-flex items-center gap-1.5 rounded-full bg-green-tint py-1 pr-2.5 pl-1 text-[12.5px] font-medium text-green"+ style={{ animation: "pop-in 180ms cubic-bezier(0.23,1,0.32,1) both" }}+ >+ <span className="flex size-4.5 items-center justify-center rounded-full bg-green text-white">+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6L9 17l-5-5" /></svg>+ </span>+ {removals + additions} {removals + additions === 1 ? "edit" : "edits"} applied+ </span>+ ) : (+ <>+ <span className="text-[11.5px] tabular-nums text-ink-3">+ {removals} {removals === 1 ? "removal" : "removals"} · {additions} {additions === 1 ? "addition" : "additions"}+ </span>+ <span className="flex items-center gap-1.5">+ <Button+ variant="accent"+ size="sm"+ disabled={removals + additions === 0}+ onClick={() => {+ setAccepted(true);+ }}+ className="text-[12px]"+ >+ Apply {removals + additions} {removals + additions === 1 ? "change" : "changes"}+ </Button>+ </span>+ </>+ )}+ </div>+ )}+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/FilterTable.tsx b/apps/native/components/primitives/FilterTable.tsxnew file mode 100644index 00000000..afbd3a5a--- /dev/null+++ b/apps/native/components/primitives/FilterTable.tsx@@ -0,0 +1,122 @@+"use client";++import { useState } from "react";++/* ─────────────────────────────────────────────────────────+ * FILTER TABLE+ * Status chips directly filter the task table.+ * ───────────────────────────────────────────────────────── */++type Status = "todo" | "progress" | "done";++const FILTERS: { key: "all" | Status; label: string; dot?: string; count: number }[] = [+ { key: "all", label: "All", count: 5 },+ { key: "todo", label: "To do", dot: "#f09a2f", count: 2 },+ { key: "progress", label: "In Progress", dot: "#16a6c7", count: 2 },+ { key: "done", label: "Completed", dot: "#25a878", count: 1 },+];++const ROWS: { task: string; date: string; status: Status; owner: string }[] = [+ { task: "Restock mango sorbet", date: "Dec 03", status: "todo", owner: "Mango Moon Gelato" },+ { task: "Churn black sesame", date: "Sep 22", status: "progress", owner: "Kumo Creamery" },+ { task: "Print summer menu", date: "Jan 02", status: "todo", owner: "Coral Coast Sorbet" },+ { task: "Taste-test batch 42", date: "Nov 08", status: "progress", owner: "Maple Orbit" },+ { task: "Order waffle cones", date: "Apr 14", status: "done", owner: "Aurora Scoops" },+];++const PILLS: Record<Status, { label: string; cls: string }> = {+ todo: { label: "To do", cls: "filter-status-todo" },+ progress: { label: "In Progress", cls: "filter-status-progress" },+ done: { label: "Completed", cls: "filter-status-done" },+};++export default function FilterTable() {+ const [filter, setFilter] = useState<"all" | Status>("all");++ return (+ <div className="w-full max-w-105">+ {/* filter chips */}+ <div+ className="-mx-1 mb-1 flex items-center gap-1 overflow-x-auto px-1 py-1"+ style={{ scrollbarWidth: "none" }}+ >+ {FILTERS.map((f) => {+ const active = filter === f.key;+ return (+ <button+ key={f.key}+ type="button"+ aria-pressed={active}+ onClick={() => setFilter(f.key)}+ className={`flex h-6.5 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-[12px]+ font-medium transition-[background-color,box-shadow,color] duration-200+ ${active ? "bg-surface text-ink shadow-btn" : "text-ink-2 hover:bg-hover"}`}+ >+ {f.dot && <span className="size-1.5 rounded-full" style={{ background: f.dot }} />}+ {f.label}+ <span+ className={`rounded-[4px] px-1 text-[10.5px] tabular-nums+ ${active ? "bg-field text-ink-2" : "text-ink-3"}`}+ >+ {f.count}+ </span>+ </button>+ );+ })}+ </div>++ {/* table */}+ <div+ aria-label="Scrollable task table"+ className="overflow-x-auto rounded-card bg-surface shadow-card"+ role="region"+ tabIndex={0}+ style={{ scrollbarWidth: "none" }}+ >+ <div className="min-w-[420px]">+ <div className="grid grid-cols-[1.3fr_0.6fr_0.95fr_0.9fr] gap-x-2 border-b border-line px-3 py-2 text-[12.5px] font-medium text-ink-3">+ <span>Task name</span>+ <span>Date</span>+ <span>Status</span>+ <span>Advisor</span>+ </div>+ {ROWS.map((row) => {+ const shown = filter === "all" || row.status === filter;+ const pill = PILLS[row.status];+ return (+ <div+ key={row.task}+ className="grid transition-[grid-template-rows,opacity] duration-300"+ style={{+ gridTemplateRows: shown ? "1fr" : "0fr",+ opacity: shown ? 1 : 0,+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ >+ <div className="overflow-hidden">+ <div+ className="grid grid-cols-[1.3fr_0.6fr_0.95fr_0.9fr] gap-x-2 items-center border-b+ border-line px-3 py-2 text-[13px] transition-colors duration-100+ last:border-0 hover:bg-hover"+ >+ <span className="truncate font-medium text-ink">{row.task}</span>+ <span className="text-ink-2 tabular-nums">{row.date}</span>+ <span>+ <span+ className={`inline-flex h-[23px] items-center rounded-[8px] border px-[7px]+ text-[13px] font-medium ${pill.cls}`}+ >+ {pill.label}+ </span>+ </span>+ <span className="truncate text-ink-2">{row.owner}</span>+ </div>+ </div>+ </div>+ );+ })}+ </div>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/FineTuneCard.tsx b/apps/native/components/primitives/FineTuneCard.tsxnew file mode 100644index 00000000..400268d5--- /dev/null+++ b/apps/native/components/primitives/FineTuneCard.tsx@@ -0,0 +1,249 @@+"use client";++import { useRef, useState } from "react";+import GlideMenu from "@/components/primitives/GlideMenu";++/* ─────────────────────────────────────────────────────────+ * FINE-TUNE CARD — compact interactive inspector.+ * Number fields scrub: hover the label for an ↔ cursor and+ * drag to adjust, use ↑/↓ (⇧ for ×10), or type directly.+ * ───────────────────────────────────────────────────────── */++function ScrubField({+ label,+ value,+ onChange,+ min,+ max,+ step = 1,+ suffix = "",+ active,+}: {+ label: string;+ value: number;+ onChange: (v: number) => void;+ min: number;+ max: number;+ step?: number;+ suffix?: string;+ active?: boolean;+}) {+ const drag = useRef<{ x: number; v: number } | null>(null);+ const clamp = (v: number) => Math.min(max, Math.max(min, Math.round(v)));++ return (+ <label+ className="flex h-6.5 min-w-0 items-center gap-1 rounded-chip py-1 pr-1 pl-0.5+ transition-[background-color,box-shadow] duration-200"+ style={{+ background: active ? "var(--accent-tint)" : "var(--field)",+ boxShadow: active ? "0 0 0 1px var(--accent)" : "none",+ }}+ >+ {/* scrub handle */}+ <span+ role="slider"+ aria-label={label}+ aria-valuenow={value}+ aria-valuemin={min}+ aria-valuemax={max}+ tabIndex={0}+ onPointerDown={(e) => {+ (e.target as HTMLElement).setPointerCapture(e.pointerId);+ drag.current = { x: e.clientX, v: value };+ }}+ onPointerMove={(e) => {+ if (!drag.current) return;+ onChange(clamp(drag.current.v + ((e.clientX - drag.current.x) / 2) * step));+ }}+ onPointerUp={() => (drag.current = null)}+ onKeyDown={(e) => {+ const mult = e.shiftKey ? 10 : 1;+ if (e.key === "ArrowUp" || e.key === "ArrowRight") {+ e.preventDefault();+ onChange(clamp(value + step * mult));+ } else if (e.key === "ArrowDown" || e.key === "ArrowLeft") {+ e.preventDefault();+ onChange(clamp(value - step * mult));+ }+ }}+ className="flex h-full shrink-0 cursor-ew-resize touch-none items-center rounded-[4px]+ px-0.5 text-[12px] text-ink-3 select-none hover:text-ink-2 focus-visible:text-accent-ink+ focus-visible:outline-none"+ >+ {label}+ </span>+ <input+ inputMode="numeric"+ value={value}+ onChange={(e) => {+ const n = Number(e.target.value.replace(/[^\d-]/g, ""));+ if (!Number.isNaN(n)) onChange(clamp(n));+ }}+ aria-label={`${label} value`}+ className="min-w-0 flex-1 bg-transparent text-[12px] text-ink tabular-nums outline-none"+ />+ {suffix && <span className="shrink-0 pr-0.5 text-[11.5px] text-ink-3">{suffix}</span>}+ </label>+ );+}++const SEGMENTS = ["row", "col", "grid"] as const;++function SegmentIcon({ kind }: { kind: string }) {+ const dot = "size-1.5 rounded-[2px] border-[1.2px] border-current";+ if (kind === "row")+ return <span className="flex gap-0.5">{[0, 1, 2].map((i) => <span key={i} className={dot} />)}</span>;+ if (kind === "col")+ return <span className="flex flex-col gap-0.5">{[0, 1].map((i) => <span key={i} className={dot} />)}</span>;+ return (+ <span className="grid grid-cols-2 gap-0.5">+ {[0, 1, 2, 3].map((i) => <span key={i} className={dot} />)}+ </span>+ );+}++export default function FineTuneCard() {+ const [seg, setSeg] = useState(0);+ const [width, setWidth] = useState(324);+ const [height, setHeight] = useState(96);+ const [radius, setRadius] = useState(28);+ const [opacity, setOpacity] = useState(100);+ const [menuOpen, setMenuOpen] = useState(false);+ const [typeValue, setTypeValue] = useState("Select type");+ const done =+ seg !== 0 || width !== 324 || height !== 96 || radius !== 28 || opacity !== 100 || typeValue !== "Select type";++ return (+ <div className="relative w-full max-w-60 rounded-card bg-surface shadow-raised">+ {/* header */}+ <div className="primitive-card-bar flex items-center justify-between border-b border-line">+ <span className="text-[13px] font-medium text-ink">Flavor card</span>+ {done ? (+ <span+ className="flex items-center gap-1.5 text-[12px] font-medium text-green"+ style={{ animation: "pop-in 250ms cubic-bezier(0.23,1,0.32,1) both" }}+ >+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round">+ <path d="M20 6L9 17l-5-5" />+ </svg>+ Edited+ </span>+ ) : (+ <span className="flex items-center gap-1.5">+ <span className="flex size-4.5 items-center justify-center rounded-[5px] border border-accent/30 bg-accent-tint">+ <svg width="9" height="9" viewBox="0 0 24 24" fill="var(--accent)">+ <path d="M12 2l2.4 7.2L22 12l-7.6 2.8L12 22l-2.4-7.2L2 12l7.6-2.8z" />+ </svg>+ </span>+ <span+ className="bg-clip-text text-[12px] font-medium text-transparent"+ style={{+ backgroundImage:+ "linear-gradient(90deg, var(--accent) 35%, var(--accent-ink) 50%, var(--accent) 65%)",+ backgroundSize: "200% 100%",+ animation: "shimmer-text 1.4s linear infinite",+ }}+ >+ Adjust+ </span>+ </span>+ )}+ </div>++ {/* layout section */}+ <div className="primitive-card-pad flex flex-col gap-2 border-b border-line">+ <p className="text-[12.5px] font-medium text-ink">Layout</p>+ {/* segmented control: gray track, raised white thumb */}+ <div className="relative grid grid-cols-3 rounded-control bg-field p-0.5">+ <span+ aria-hidden+ className="absolute inset-y-0.5 rounded-[6px] bg-surface shadow-btn transition-transform duration-300"+ style={{+ width: "calc((100% - 4px) / 3)",+ left: 2,+ transform: `translateX(${seg * 100}%)`,+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ />+ {SEGMENTS.map((s, i) => (+ <button+ key={s}+ type="button"+ aria-label={`${s} layout`}+ aria-pressed={i === seg}+ onClick={() => setSeg(i)}+ className={`relative z-10 flex h-6 items-center justify-center transition-colors duration-200+ ${i === seg ? "text-accent" : "text-ink-3"}`}+ >+ <SegmentIcon kind={s} />+ </button>+ ))}+ </div>+ <div className="grid min-w-0 grid-cols-2 gap-2">+ <ScrubField label="W" value={width} onChange={setWidth} min={40} max={999} active={width !== 324} />+ <ScrubField label="H" value={height} onChange={setHeight} min={24} max={999} active={height !== 96} />+ </div>+ <div className="grid min-w-0 grid-cols-2 gap-2">+ <ScrubField label="Radius" value={radius} onChange={setRadius} min={0} max={64} active={radius !== 28} />+ <ScrubField label="Opacity" value={opacity} onChange={setOpacity} min={0} max={100} suffix="%" active={opacity !== 100} />+ </div>+ </div>++ {/* interaction section */}+ <div className="primitive-card-footer flex items-center justify-between">+ <span className="text-[12px] text-ink-3">Type</span>+ <div className="relative -mr-0.5 w-30">+ <button+ type="button"+ aria-expanded={menuOpen}+ onClick={() => setMenuOpen((current) => !current)}+ className="flex h-6.5 w-full items-center justify-between rounded-chip bg-inset py-1 pr-1 pl-2+ shadow-hairline transition-shadow duration-200 focus-visible:outline-none"+ style={{ boxShadow: menuOpen ? "0 0 0 1px var(--accent)" : undefined }}+ >+ <span className={`text-[12px] ${typeValue !== "Select type" ? "text-ink" : "text-ink-3"}`}>+ {typeValue}+ </span>+ <svg+ width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="var(--ink-3)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"+ className="transition-transform duration-200"+ style={{ transform: menuOpen ? "rotate(180deg)" : "rotate(0)" }}+ >+ <path d="M6 9l6 6 6-6" />+ </svg>+ </button>++ {menuOpen && (+ <div+ className="absolute right-0 bottom-8 z-10 w-30 rounded-[10px] bg-surface p-1 shadow-raised"+ style={{+ animation: "pop-in 200ms cubic-bezier(0.23,1,0.32,1) both",+ transformOrigin: "bottom right",+ }}+ >+ <GlideMenu className="flex flex-col gap-px" highlightClassName="inset-x-0 rounded-[6px] bg-field">+ {["Seasonal", "Classic", "Limited"].map((item) => (+ <button+ key={item}+ data-menu-row+ type="button"+ onClick={() => {+ setTypeValue(item);+ setMenuOpen(false);+ }}+ className={`relative z-10 flex h-6.5 w-full items-center rounded-[6px] px-2 text-left text-[12.5px] text-ink ${+ item === typeValue ? "bg-field group-hover/glide-menu:bg-transparent" : ""+ }`}+ >+ {item}+ </button>+ ))}+ </GlideMenu>+ </div>+ )}+ </div>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/Flowchart.tsx b/apps/native/components/primitives/Flowchart.tsxnew file mode 100644index 00000000..76f162cc--- /dev/null+++ b/apps/native/components/primitives/Flowchart.tsx@@ -0,0 +1,538 @@+"use client";++import { useEffect, useRef, useState } from "react";+import { useLayoutEffect } from "react";++/* ─────────────────────────────────────────────────────────+ * FLOWCHART — an agent workflow on a dotted editor canvas.+ * Two steps: a Trigger card and an If/Else condition card,+ * joined by a measured connector. Cards drag anywhere on+ * the canvas; the connector follows. Condition chips open+ * real dropdowns (same menu as the PromptBar model picker).+ * ───────────────────────────────────────────────────────── */++const PURPLE = "#9a5cff";+const AMBER = "#f09a2f";++const mix = (hue: string, pct: number, base = "var(--surface)") =>+ `color-mix(in srgb, ${hue} ${pct}%, ${base})`;++/* ── layout constants ── */+const PAD_Y = 24;+const ROW_GAP = 64;+const PILL_OFFSET = 30; // kind pill + gap above a card++type StepNode = {+ id: string;+ row: number;+ x: number; // 0–1 center of the node+ w: number;+ kind?: { label: string; hue: string };+ hue?: string;+ title?: string;+ caption?: string;+ condition?: boolean; // renders the if/else chip rows instead+};++const NODES: StepNode[] = [+ {+ id: "trigger",+ row: 0,+ x: 0.5,+ w: 300,+ kind: { label: "Trigger", hue: PURPLE },+ hue: PURPLE,+ title: "New order created",+ caption: "Trigger when a new order is created",+ },+ {+ id: "cond",+ row: 1,+ x: 0.5,+ w: 356,+ kind: { label: "If / Else", hue: AMBER },+ condition: true,+ },+];++const EDGES = [{ from: "trigger", to: "cond" }];++/* estimated heights for the first paint; measured immediately after */+const EST_H: Record<string, number> = { trigger: 92, cond: 134 };++const PROPERTIES = ["flavor", "topping", "size", "scoops"];+const FLAVORS = [+ { name: "Rocky Road", tag: "Classic" },+ { name: "Mint Chip", tag: "Classic" },+ { name: "Pistachio", tag: "Seasonal" },+ { name: "Bubblegum", tag: "Retro" },+];+const TOPPINGS = [+ { name: "Brown butter bourbon brittle crunch" },+ { name: "Rainbow sprinkles" },+ { name: "Hot fudge" },+ { name: "Candied pecans" },+];++/* ── icons ── */+function ConeIcon({ size = 16 }: { size?: number }) {+ return (+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">+ <path d="m7 11 4.08 10.35a1 1 0 0 0 1.84 0L17 11" />+ <path d="M17 7A5 5 0 0 0 7 7" />+ <path d="M17 7a2 2 0 0 1 0 4H7a2 2 0 0 1 0-4" />+ </svg>+ );+}++function Chevron() {+ return (+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" className="shrink-0 text-ink-3">+ <path d="m6 9 6 6 6-6" />+ </svg>+ );+}++function Handle() {+ return (+ <svg width="10" height="16" viewBox="0 0 10 16" className="shrink-0 cursor-grab text-ink-3/70">+ {[3, 8, 13].flatMap((y) => [+ <circle key={`l${y}`} cx="3" cy={y} r="1.1" fill="currentColor" />,+ <circle key={`r${y}`} cx="7.5" cy={y} r="1.1" fill="currentColor" />,+ ])}+ </svg>+ );+}++function CheckIcon() {+ return (+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <path d="M20 6L9 17l-5-5" />+ </svg>+ );+}++/* ── dropdown menu — same pattern as the PromptBar model picker ── */+function Menu({+ items,+ value,+ width,+ align,+ onPick,+}: {+ items: { name: string; tag?: string }[];+ value: string;+ width: string;+ align: "left" | "right";+ onPick: (name: string) => void;+}) {+ const [hovered, setHovered] = useState<number | null>(null);+ const rowRefs = useRef<(HTMLButtonElement | null)[]>([]);+ const [box, setBox] = useState<{ top: number; height: number } | null>(null);++ const valueIndex = items.findIndex((item) => item.name === value);+ useLayoutEffect(() => {+ const row = rowRefs.current[hovered ?? valueIndex];+ if (row) setBox({ top: row.offsetTop, height: row.offsetHeight });+ }, [hovered, valueIndex]);++ return (+ <div+ onMouseLeave={() => setHovered(null)}+ className={`absolute bottom-full z-20 mb-1.5 rounded-[10px] bg-surface p-1 shadow-raised ${width}+ ${align === "right" ? "right-0" : "left-0"}`}+ style={{+ animation: "pop-in 180ms cubic-bezier(0.23,1,0.32,1) both",+ transformOrigin: align === "right" ? "bottom right" : "bottom left",+ }}+ >+ <span+ aria-hidden+ className="pointer-events-none absolute inset-x-1 rounded-[6px] bg-hover"+ style={{+ top: box?.top ?? 0,+ height: box?.height ?? 0,+ opacity: box && hovered !== null ? 1 : 0,+ transition:+ "top 220ms cubic-bezier(0.23,1,0.32,1), height 220ms cubic-bezier(0.23,1,0.32,1), opacity 150ms ease",+ }}+ />+ {items.map((item, i) => (+ <button+ key={item.name}+ type="button"+ ref={(el) => {+ rowRefs.current[i] = el;+ }}+ onMouseEnter={() => setHovered(i)}+ onClick={() => onPick(item.name)}+ className="relative z-10 flex h-7.5 w-full cursor-pointer items-center gap-2 rounded-[6px] px-2 text-left"+ >+ <span className="min-w-0 flex-1 truncate text-[12.5px] font-medium text-ink">{item.name}</span>+ {item.tag && <span className="shrink-0 text-[11px] text-ink-3">{item.tag}</span>}+ <span className={`shrink-0 text-ink ${item.name === value ? "" : "invisible"}`}>+ <CheckIcon />+ </span>+ </button>+ ))}+ </div>+ );+}++/* ── chips used inside the condition card ── */+function SourceChip() {+ return (+ <span+ data-ui+ className="inline-flex h-6 shrink-0 items-center gap-1 rounded-[6px] bg-surface px-1.5 text-[12px] font-medium text-ink shadow-btn"+ >+ <span className="text-ink-2">+ <ConeIcon size={12} />+ </span>+ order+ </span>+ );+}++function SelectChip({+ id,+ value,+ dot,+ items,+ width,+ align = "left",+ open,+ onToggle,+ onPick,+}: {+ id: string;+ value: string;+ dot?: boolean;+ items: { name: string; tag?: string }[];+ width: string;+ align?: "left" | "right";+ open: boolean;+ onToggle: (id: string) => void;+ onPick: (id: string, name: string) => void;+}) {+ return (+ <span data-ui className="relative inline-flex min-w-0">+ <button+ type="button"+ aria-expanded={open}+ onClick={() => onToggle(id)}+ className={`inline-flex h-6 min-w-0 cursor-pointer items-center gap-1 rounded-[6px] px-1.5+ text-[12px] font-medium text-ink transition-colors duration-100+ ${open ? "bg-hover-2" : "bg-field hover:bg-hover-2"}`}+ >+ {dot && <span className="size-1.5 shrink-0 rounded-full" style={{ background: AMBER }} />}+ <span className="min-w-0 truncate">{value}</span>+ <Chevron />+ </button>+ {open && (+ <Menu+ items={items}+ value={value}+ width={width}+ align={align}+ onPick={(name) => onPick(id, name)}+ />+ )}+ </span>+ );+}++function ConditionBody() {+ const [values, setValues] = useState<Record<string, string>>({+ prop1: "flavor",+ val1: "Rocky Road",+ prop2: "topping",+ val2: "Brown butter bourbon brittle crunch",+ });+ const [open, setOpen] = useState<string | null>(null);++ /* click anywhere else closes the menu */+ useEffect(() => {+ if (!open) return;+ const close = (event: PointerEvent) => {+ if (!(event.target as Element).closest("[data-ui]")) setOpen(null);+ };+ document.addEventListener("pointerdown", close);+ return () => document.removeEventListener("pointerdown", close);+ }, [open]);++ const toggle = (id: string) => setOpen((current) => (current === id ? null : id));+ const pick = (id: string, name: string) => {+ setValues((current) => ({ ...current, [id]: name }));+ setOpen(null);+ };++ const chip = (id: string, items: { name: string; tag?: string }[], width: string, extra?: object) => (+ <SelectChip+ id={id}+ value={values[id]}+ items={items}+ width={width}+ open={open === id}+ onToggle={toggle}+ onPick={pick}+ {...extra}+ />+ );++ return (+ <div className="flex flex-col gap-1.5 px-3 py-2.5">+ <div className="flex min-w-0 items-center gap-1.5">+ <Handle />+ <span className="w-7 text-[12.5px] text-ink-2">If</span>+ <SourceChip />+ {chip("prop1", PROPERTIES.map((name) => ({ name })), "w-36")}+ <span className="text-[12.5px] text-ink-2">is</span>+ {chip("val1", FLAVORS, "w-44", { dot: true, align: "right" })}+ </div>+ <div className="flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1.5">+ <Handle />+ <span className="w-7 text-[12.5px] text-ink-2">and</span>+ <SourceChip />+ {chip("prop2", PROPERTIES.map((name) => ({ name })), "w-36")}+ <span className="text-[12.5px] text-ink-2">is</span>+ <span className="max-w-full pl-[49px]">+ {chip("val2", TOPPINGS, "w-64", { dot: true })}+ </span>+ </div>+ </div>+ );+}++function StepBody({ node }: { node: StepNode }) {+ return (+ <div className="flex items-center gap-2.5 px-3 py-2.5">+ <span+ className="flex size-9 shrink-0 items-center justify-center rounded-[8px]"+ style={{+ background: mix(node.hue!, 12),+ color: node.hue,+ boxShadow: `0 0 0 1px ${mix(node.hue!, 20)}`,+ }}+ >+ <ConeIcon />+ </span>+ <span className="min-w-0 text-left">+ <span className="block truncate text-[13px] font-semibold text-ink">{node.title}</span>+ <span className="mt-0.5 block text-[12px] leading-snug text-ink-2">{node.caption}</span>+ </span>+ </div>+ );+}++/* ── the canvas ── */+export default function Flowchart() {+ const canvasRef = useRef<HTMLDivElement>(null);+ const nodeRefs = useRef(new Map<string, HTMLElement>());+ const [width, setWidth] = useState(0);+ const [heights, setHeights] = useState<Record<string, number>>(EST_H);+ const [selected, setSelected] = useState<string | null>(null);+ const [offsets, setOffsets] = useState<Record<string, { dx: number; dy: number }>>({});+ const drag = useRef<{+ id: string;+ startX: number;+ startY: number;+ baseDx: number;+ baseDy: number;+ moved: boolean;+ } | null>(null);++ useLayoutEffect(() => {+ const canvas = canvasRef.current;+ if (!canvas) return;++ const measure = () => {+ setWidth(canvas.clientWidth);+ setHeights((prev) => {+ const next = { ...prev };+ let changed = false;+ nodeRefs.current.forEach((el, id) => {+ const h = el.offsetHeight;+ if (h && Math.abs(h - (next[id] ?? 0)) > 0.5) {+ next[id] = h;+ changed = true;+ }+ });+ return changed ? next : prev;+ });+ };++ measure();+ const observer = new ResizeObserver(measure);+ observer.observe(canvas);+ nodeRefs.current.forEach((el) => observer.observe(el));+ return () => observer.disconnect();+ }, []);++ /* rows → y offsets from measured node heights */+ const rows = [...new Set(NODES.map((n) => n.row))].sort((a, b) => a - b);+ const rowH = rows.map((r) =>+ Math.max(...NODES.filter((n) => n.row === r).map((n) => heights[n.id] ?? 90)),+ );+ const rowY: number[] = [];+ rows.forEach((_, i) => {+ rowY[i] = i === 0 ? PAD_Y : rowY[i - 1] + rowH[i - 1] + ROW_GAP;+ });+ const canvasH = rowY[rows.length - 1] + rowH[rows.length - 1] + PAD_Y;++ const cw = width || 480;+ const place = (n: StepNode) => {+ const w = Math.min(n.w, cw * 0.92);+ const off = offsets[n.id];+ return {+ w,+ cx: n.x * cw + (off?.dx ?? 0),+ top: rowY[rows.indexOf(n.row)] + (off?.dy ?? 0),+ };+ };++ /* card anchor points (pills sit above the card, so offset the top) */+ const anchors = (n: StepNode) => {+ const { cx, top } = place(n);+ return {+ top: { x: cx, y: top + (n.kind ? PILL_OFFSET : 0) },+ bottom: { x: cx, y: top + (heights[n.id] ?? 90) },+ };+ };++ const bezier = (edge: { from: string; to: string }) => {+ const from = anchors(NODES.find((n) => n.id === edge.from)!).bottom;+ const to = anchors(NODES.find((n) => n.id === edge.to)!).top;+ const k = Math.min(Math.max(Math.abs(to.y - from.y) * 0.55, 24), 84);+ return `M ${from.x} ${from.y} C ${from.x} ${from.y + k}, ${to.x} ${to.y - k}, ${to.x} ${to.y}`;+ };++ /* ── dragging ── */+ const onPointerDown = (node: StepNode) => (event: React.PointerEvent<HTMLDivElement>) => {+ if ((event.target as Element).closest("[data-ui]")) return;+ const off = offsets[node.id];+ drag.current = {+ id: node.id,+ startX: event.clientX,+ startY: event.clientY,+ baseDx: off?.dx ?? 0,+ baseDy: off?.dy ?? 0,+ moved: false,+ };+ (event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);+ };++ const onPointerMove = (node: StepNode) => (event: React.PointerEvent<HTMLDivElement>) => {+ const d = drag.current;+ if (!d || d.id !== node.id) return;+ const dx = d.baseDx + event.clientX - d.startX;+ const dy = d.baseDy + event.clientY - d.startY;+ if (!d.moved && Math.hypot(dx - d.baseDx, dy - d.baseDy) < 3) return;+ d.moved = true;++ /* keep the card inside the canvas */+ const { w } = place(node);+ const h = heights[node.id] ?? 90;+ const baseCx = node.x * cw;+ const baseTop = rowY[rows.indexOf(node.row)];+ const cx = Math.min(Math.max(baseCx + dx, w / 2 + 8), cw - w / 2 - 8);+ const top = Math.min(Math.max(baseTop + dy, 8), canvasH - h - 8);+ setOffsets((current) => ({ ...current, [node.id]: { dx: cx - baseCx, dy: top - baseTop } }));+ };++ const onPointerUp = (node: StepNode) => () => {+ const d = drag.current;+ if (d?.id === node.id) {+ /* a real drag shouldn't also toggle selection */+ if (d.moved) setTimeout(() => (drag.current = null), 0);+ else drag.current = null;+ }+ };++ const wasDragged = () => drag.current?.moved === true;++ const isLit = (edge: { from: string; to: string }) =>+ selected === edge.from || selected === edge.to;++ return (+ <div+ ref={canvasRef}+ className="relative w-full select-none overflow-hidden rounded-card bg-page shadow-hairline"+ style={{+ height: canvasH,+ backgroundImage: "radial-gradient(var(--line-strong) 1px, transparent 1.25px)",+ backgroundSize: "22px 22px",+ backgroundPosition: "center",+ }}+ >+ {/* connectors */}+ <svg width={cw} height={canvasH} className="pointer-events-none absolute inset-0">+ {EDGES.map((edge) => (+ <path+ key={`${edge.from}-${edge.to}`}+ d={bezier(edge)}+ fill="none"+ stroke={isLit(edge) ? "var(--accent)" : "var(--line-strong)"}+ strokeWidth="1.25"+ className="transition-[stroke] duration-150"+ />+ ))}+ </svg>++ {/* nodes */}+ {NODES.map((node) => {+ const { w, cx, top } = place(node);+ const active = selected === node.id;+ return (+ <div+ key={node.id}+ ref={(el) => {+ if (el) nodeRefs.current.set(node.id, el);+ else nodeRefs.current.delete(node.id);+ }}+ onPointerDown={onPointerDown(node)}+ onPointerMove={onPointerMove(node)}+ onPointerUp={onPointerUp(node)}+ className="absolute flex -translate-x-1/2 touch-none flex-col items-start gap-1.5"+ style={{ left: cx, top, width: w, zIndex: drag.current?.id === node.id ? 2 : 1 }}+ >+ {node.kind && (+ <span+ className="inline-flex h-6 items-center rounded-[6px] px-2 text-[11.5px] font-medium"+ style={{+ background: mix(node.kind.hue, 14, "var(--page)"),+ color: mix(node.kind.hue, 80, "var(--ink)"),+ }}+ >+ {node.kind.label}+ </span>+ )}+ {node.condition ? (+ <div className="w-full rounded-card bg-surface shadow-card transition-shadow duration-150 hover:shadow-raised">+ <ConditionBody />+ </div>+ ) : (+ <button+ type="button"+ onClick={() => {+ if (wasDragged()) return;+ setSelected(active ? null : node.id);+ }}+ aria-pressed={active}+ className={`w-full cursor-pointer rounded-card bg-surface text-left outline-none+ transition-shadow duration-150 focus-visible:shadow-[0_0_0_1.5px_var(--accent)]+ ${+ active+ ? "shadow-[0_0_0_1.5px_var(--accent),0_2px_10px_rgba(0,0,0,0.045)]"+ : "shadow-card hover:shadow-raised"+ }`}+ >+ <StepBody node={node} />+ </button>+ )}+ </div>+ );+ })}+ </div>+ );+}diff --git a/apps/native/components/primitives/GlideMenu.tsx b/apps/native/components/primitives/GlideMenu.tsxnew file mode 100644index 00000000..2487aea9--- /dev/null+++ b/apps/native/components/primitives/GlideMenu.tsx@@ -0,0 +1,59 @@+"use client";++import { useRef, useState, type ReactNode } from "react";++type GlideMenuProps = {+ children: ReactNode;+ className?: string;+ highlightClassName?: string;+ rowSelector?: string;+};++/** A single hover layer that glides between interactive menu rows. */+export default function GlideMenu({+ children,+ className = "",+ highlightClassName = "inset-x-0 rounded-[8px] bg-hover",+ rowSelector = "[data-menu-row]",+}: GlideMenuProps) {+ const ref = useRef<HTMLDivElement>(null);+ const [box, setBox] = useState<{ top: number; height: number } | null>(null);+ const [visible, setVisible] = useState(false);++ const moveTo = (target: EventTarget | null) => {+ const container = ref.current;+ if (!(target instanceof Element) || !container) return;+ const row = target.closest(rowSelector);+ if (!(row instanceof HTMLElement) || !container.contains(row)) return;+ const containerRect = container.getBoundingClientRect();+ const rowRect = row.getBoundingClientRect();+ setBox({ top: rowRect.top - containerRect.top, height: rowRect.height });+ setVisible(true);+ };++ return (+ <div+ ref={ref}+ onMouseOver={(event) => moveTo(event.target)}+ onMouseLeave={() => setVisible(false)}+ onFocusCapture={(event) => moveTo(event.target)}+ onBlurCapture={(event) => {+ if (!ref.current?.contains(event.relatedTarget as Node | null)) setVisible(false);+ }}+ className={`group/glide-menu relative ${className}`}+ >+ <span+ aria-hidden+ className={`pointer-events-none absolute ${highlightClassName}`}+ style={{+ top: box?.top ?? 0,+ height: box?.height ?? 0,+ opacity: box && visible ? 1 : 0,+ transition:+ "top 220ms cubic-bezier(0.23,1,0.32,1), height 220ms cubic-bezier(0.23,1,0.32,1), opacity 150ms ease",+ }}+ />+ {children}+ </div>+ );+}diff --git a/apps/native/components/primitives/InsightCards.tsx b/apps/native/components/primitives/InsightCards.tsxnew file mode 100644index 00000000..6e484d55--- /dev/null+++ b/apps/native/components/primitives/InsightCards.tsx@@ -0,0 +1,490 @@+"use client";++import { Liveline, type LivelinePoint, type LivelineSeries } from "liveline";+import { useEffect, useMemo, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * INSIGHT CARDS+ * Embedded mini-visualizations in an "Insights N ‹ ›"+ * carousel. Autoplay yields as soon as a person uses it.+ * ───────────────────────────────────────────────────────── */++const EASE = "cubic-bezier(0.16, 1, 0.3, 1)";++const formatPercent = (v: number) => `${v > 0 ? "+" : ""}${v.toFixed(2)}%`;+const formatMoney = (v: number) => `$${Math.round(v).toLocaleString("en-US")}`;+/* anchor the snapshot to *call* time (inside each card's mount-time memo) —+ * a module-load constant goes stale, and once the points age past the chart+ * window the canvas renders empty */+function makePoints(values: number[], gap = 6): LivelinePoint[] {+ const end = Math.floor(Date.now() / 1000);+ return values.map((value, index) => ({+ time: end - (values.length - 1 - index) * gap,+ value,+ }));+}++/* Catmull-Rom resample — turn a sparse series into a dense, smoothly curved+ * one so both the line and the hover cursor glide instead of stepping between+ * a handful of points. */+function smooth(values: number[], perSegment = 9): number[] {+ if (values.length < 3) return values.slice();+ const out: number[] = [];+ const n = values.length;+ for (let i = 0; i < n - 1; i += 1) {+ const p0 = values[Math.max(0, i - 1)];+ const p1 = values[i];+ const p2 = values[i + 1];+ const p3 = values[Math.min(n - 1, i + 2)];+ for (let s = 0; s < perSegment; s += 1) {+ const t = s / perSegment;+ const t2 = t * t;+ const t3 = t2 * t;+ out.push(+ 0.5 *+ (2 * p1 ++ (-p0 + p2) * t ++ (2 * p0 - 5 * p1 + 4 * p2 - p3) * t2 ++ (-p0 + 3 * p1 - 3 * p2 + p3) * t3),+ );+ }+ }+ out.push(values[n - 1]);+ return out;+}++/* dense, smoothed points spanning exactly `spanSecs` — keeps the chart window+ * unchanged while multiplying the resolution. */+function smoothPoints(values: number[], spanSecs: number): LivelinePoint[] {+ const dense = smooth(values);+ return makePoints(dense, spanSecs / (dense.length - 1));+}++function useDarkMode() {+ const [dark, setDark] = useState(false);++ useEffect(() => {+ const root = document.documentElement;+ const update = () => setDark(root.classList.contains("dark"));+ update();+ const observer = new MutationObserver(update);+ observer.observe(root, { attributes: true, attributeFilter: ["class"] });+ return () => observer.disconnect();+ }, []);++ return dark;+}++/* inline @entity mention */+function Entity({ name, tone }: { name: string; tone: string }) {+ return (+ <span className="inline-flex items-center gap-1 align-baseline font-medium text-ink">+ <span className={`inline-block size-2.5 rounded-full ${tone}`} />+ @{name}+ </span>+ );+}++function Mono({ children, tone }: { children: React.ReactNode; tone: "red" | "green" }) {+ return (+ <code className={`font-mono text-[11.5px] ${tone === "red" ? "text-red" : "text-green"}`}>+ {children}+ </code>+ );+}++function chartIndexFromPointer(event: React.PointerEvent<HTMLDivElement>, pointCount: number) {+ const rect = event.currentTarget.getBoundingClientRect();+ const progress = Math.max(0, Math.min(1, (event.clientX - rect.left) / rect.width));+ return Math.round(progress * (pointCount - 1));+}++function ChartTooltip({ rows }: { rows: { label: string; value: string; color: string }[] }) {+ return (+ <div className="insight-chart-tooltip">+ {rows.map((row) => (+ <span key={row.label} className="insight-chart-tooltip-item">+ <span className="insight-chart-tooltip-dot" style={{ background: row.color }} />+ {row.value}+ </span>+ ))}+ </div>+ );+}++/* 1 — return comparison: 2 series, legend + big deltas + line chart */+function CompareCard() {+ const dark = useDarkMode();+ const [hoverIndex, setHoverIndex] = useState<number | null>(null);+ const data = useMemo(+ () => ({+ mint: smoothPoints([-2.9, -3.4, -3.05, -3.86, -3.52, -4.1, -3.82, -4.41], 42),+ pistachio: smoothPoints([0.22, 0.58, 0.42, 0.91, 0.76, 1.08, 0.96, 1.15], 42),+ }),+ [],+ );++ const latestMint = data.mint.at(-1)?.value ?? -4.41;+ const latestPistachio = data.pistachio.at(-1)?.value ?? 1.15;+ const series: LivelineSeries[] = useMemo(+ () => [+ {+ id: "mint",+ label: "",+ data: data.mint,+ value: latestMint,+ color: "#f68f3c",+ },+ {+ id: "pistachio",+ label: "",+ data: data.pistachio,+ value: latestPistachio,+ color: "#3d9aff",+ },+ ],+ [data.mint, data.pistachio, latestMint, latestPistachio],+ );++ return (+ <div className="min-h-[278px] rounded-card bg-surface p-3 shadow-hairline">+ <div className="flex items-center gap-4">+ {[+ {+ name: "Mint Chip",+ delta: formatPercent(latestMint),+ sub: "-$2,377.66",+ tone: "red",+ dot: "bg-orange",+ },+ {+ name: "Pistachio",+ delta: formatPercent(latestPistachio),+ sub: "+$617.22",+ tone: "green",+ dot: "bg-accent",+ },+ ].map((s) => (+ <div key={s.name} className="flex-1">+ <span className="flex items-center gap-1.5 text-[11.5px] text-ink-2">+ <span className={`size-2 rounded-full ${s.dot}`} />+ {s.name}+ </span>+ <span className={`block text-[17px] font-semibold tracking-[-0.01em] tabular-nums ${s.tone === "red" ? "text-red" : "text-green"}`}>+ {s.delta}+ </span>+ <Mono tone={s.tone as "red" | "green"}>{s.sub}</Mono>+ </div>+ ))}+ </div>+ <div className="mt-2 overflow-hidden rounded-control bg-inset shadow-hairline">+ <div className="flex items-center justify-between border-b border-line px-2.5 py-1.5">+ <span className="text-[11px] text-ink-3 tabular-nums">+ Trend snapshot+ </span>+ <span className="rounded-full bg-field px-2 py-0.5 text-[10.5px] font-medium text-ink-2">+ Snapshot+ </span>+ </div>+ <div+ className="insight-chart-stage relative h-[166px]"+ onPointerDown={(event) => setHoverIndex(chartIndexFromPointer(event, data.mint.length))}+ onPointerMove={(event) => setHoverIndex(chartIndexFromPointer(event, data.mint.length))}+ onPointerLeave={() => setHoverIndex(null)}+ onPointerCancel={() => setHoverIndex(null)}+ onPointerUp={() => setHoverIndex(null)}+ >+ <Liveline+ data={[]}+ value={0}+ series={series}+ theme={dark ? "dark" : "light"}+ grid={false}+ pulse={false}+ window={42}+ paused+ scrub={false}+ cursor="default"+ lineWidth={2.25}+ padding={{ top: 40, right: 0, bottom: 22, left: 0 }}+ formatValue={formatPercent}+ />+ {hoverIndex !== null && <>+ <span className="insight-chart-cursor" style={{ left: `${(hoverIndex / (data.mint.length - 1)) * 100}%` }} />+ <span className="insight-chart-tooltip-anchor" style={{ left: `${Math.min(Math.max((hoverIndex / (data.mint.length - 1)) * 100, 28), 72)}%` }}>+ <ChartTooltip rows={[{ label: "Mint Chip", value: formatPercent(data.mint[hoverIndex].value), color: "var(--orange)" }, { label: "Pistachio", value: formatPercent(data.pistachio[hoverIndex].value), color: "var(--accent)" }]} />+ </span>+ </>}+ </div>+ </div>+ </div>+ );+}++/* 2 — anomaly: bars with threshold + big spent value */+function AnomalyCard() {+ const dark = useDarkMode();+ const [metric, setMetric] = useState<"spend" | "usage">("spend");+ const [hoverIndex, setHoverIndex] = useState<number | null>(null);+ const spend = useMemo(+ () => makePoints([274, 289, 264, 307, 331, 1210, 1718, 2112], 7),+ [],+ );+ const usage = useMemo(+ () => makePoints([18, 19, 17, 21, 22, 58, 81, 96], 7),+ [],+ );++ const data = metric === "spend" ? spend : usage;+ const value = data.at(-1)?.value ?? (metric === "spend" ? 2112 : 96);+ const threshold = metric === "spend" ? "$2,112" : "82 kWh";+ const moneyLabel = formatMoney(spend.at(-1)?.value ?? 2112);++ return (+ <div className="min-h-[278px] rounded-card bg-surface p-3 shadow-hairline">+ <div className="flex items-center justify-between">+ <span className="flex items-center gap-1.5 text-[12px] font-medium text-ink">+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--red)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M12 19V5M5 12l7-7 7 7" /></svg>+ High freezer spend+ </span>+ <span className="rounded-full bg-field px-2 py-0.5 text-[10.5px] font-medium text-ink-2">+ Snapshot+ </span>+ </div>+ <div className="mt-2 overflow-hidden rounded-control bg-inset shadow-hairline">+ <div className="flex items-center justify-between border-b border-line px-2.5 py-1.5">+ <span className="text-[11px] text-ink-3 tabular-nums">+ {hoverIndex !== null+ ? metric === "spend"+ ? formatMoney(data[hoverIndex].value)+ : `${Math.round(data[hoverIndex].value)} kWh`+ : `${threshold} threshold`}+ </span>+ <span className="flex rounded-full bg-field p-0.5">+ {(["spend", "usage"] as const).map((item) => (+ <button+ key={item}+ type="button"+ aria-pressed={metric === item}+ onClick={() => setMetric(item)}+ className={`rounded-full px-2 py-0.5 text-[10.5px] font-medium transition-[background-color,color,box-shadow,transform] duration-150 active:scale-[0.96] ${+ metric === item ? "bg-surface text-ink shadow-btn" : "text-ink-3 hover:text-ink-2"+ }`}+ >+ {item === "spend" ? "Spend" : "Usage"}+ </button>+ ))}+ </span>+ </div>+ <div+ className="insight-chart-stage relative h-[166px]"+ onPointerDown={(event) => setHoverIndex(chartIndexFromPointer(event, data.length))}+ onPointerMove={(event) => setHoverIndex(chartIndexFromPointer(event, data.length))}+ onPointerLeave={() => setHoverIndex(null)}+ onPointerCancel={() => setHoverIndex(null)}+ onPointerUp={() => setHoverIndex(null)}+ >+ <Liveline+ data={data}+ value={value}+ theme={dark ? "dark" : "light"}+ color="#ee5c61"+ grid+ scrub={false}+ fill={false}+ pulse={false}+ momentum={false}+ paused+ window={49}+ lineWidth={2.25}+ cursor="crosshair"+ padding={{ top: 34, right: 0, bottom: 22, left: 0 }}+ formatValue={(v) => (metric === "spend" ? formatMoney(v) : `${Math.round(v)} kWh`)}+ />+ {hoverIndex !== null && <>+ <span className="insight-chart-cursor" style={{ left: `${(hoverIndex / (data.length - 1)) * 100}%` }} />+ <span className="insight-chart-tooltip-anchor" style={{ left: `${Math.min(Math.max((hoverIndex / (data.length - 1)) * 100, 28), 72)}%` }}>+ <ChartTooltip rows={[{ label: metric === "spend" ? "Spend" : "Usage", value: metric === "spend" ? formatMoney(data[hoverIndex].value) : `${Math.round(data[hoverIndex].value)} kWh`, color: "var(--red)" }]} />+ </span>+ </>}+ </div>+ </div>+ <div className="mt-1.5 flex items-baseline gap-2">+ <span className="text-[17px] font-semibold tracking-[-0.01em] text-ink tabular-nums">+ {moneyLabel} spent+ </span>+ <Mono tone="red">+$1,834.66</Mono>+ <span className="text-[11px] text-ink-3">vs 3 months</span>+ </div>+ </div>+ );+}++/* 3 — allocation: hero number + segmented bar + legend */+function AllocationCard() {+ const segments = [+ { name: "VAN", label: "Vanilla", pct: 72.5, amount: "$51,785", cls: "bg-orange", tone: "text-orange" },+ { name: "CHOC", label: "Chocolate", pct: 22.8, amount: "$16,278", cls: "bg-line-strong", tone: "text-ink-2" },+ { name: "MINT", label: "Mint", pct: 4.7, amount: "$3,357", cls: "bg-line", tone: "text-ink-3" },+ ];+ const [selected, setSelected] = useState(segments[0].name);+ const active = segments.find((segment) => segment.name === selected) ?? segments[0];++ return (+ <div className="min-h-[278px] rounded-card bg-surface p-3 shadow-hairline">+ <span className="flex items-center gap-1.5 text-[12px] font-medium text-ink">+ <span className="flex size-3.5 items-center justify-center rounded-full bg-orange text-[8px] font-bold text-white">+ V+ </span>+ Vanilla allocation+ </span>+ <span className="mt-1 block text-[20px] font-semibold tracking-[-0.01em] text-ink tabular-nums">+ {active.amount}+ </span>+ <div+ className="mt-3 flex h-9 gap-0.5 overflow-hidden rounded-full bg-field p-0.5"+ role="group"+ aria-label="Allocation segments"+ >+ {segments.map((s) => (+ <button+ key={s.name}+ type="button"+ aria-pressed={selected === s.name}+ aria-label={`${s.label}: ${s.pct}%`}+ onClick={() => setSelected(s.name)}+ className={`relative h-full overflow-hidden rounded-full ${s.cls} transition-[opacity,transform,box-shadow] duration-300 active:scale-[0.98]`}+ style={{+ width: `${s.pct}%`,+ opacity: selected === s.name ? 1 : 0.58,+ boxShadow: selected === s.name ? "inset 0 0 0 1px rgba(255,255,255,0.22)" : undefined,+ transitionTimingFunction: EASE,+ }}+ >+ <span+ className="absolute inset-y-1 left-1 rounded-full bg-white/20 transition-[width,opacity] duration-500"+ style={{+ width: selected === s.name ? "calc(100% - 8px)" : "0%",+ opacity: selected === s.name ? 1 : 0,+ transitionTimingFunction: EASE,+ }}+ />+ </button>+ ))}+ </div>+ <div className="mt-2 flex items-center gap-1.5">+ {segments.map((s) => (+ <button+ key={s.name}+ type="button"+ aria-pressed={selected === s.name}+ onClick={() => setSelected(s.name)}+ className={`flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] transition-[background-color,color,transform] duration-150 active:scale-[0.96] ${+ selected === s.name ? "bg-field text-ink" : "text-ink-2 hover:bg-hover hover:text-ink"+ }`}+ >+ <span className={`size-1.5 rounded-full ${s.cls}`} />+ {s.name} <span className="tabular-nums">{s.pct}%</span>+ </button>+ ))}+ </div>+ <div className="mt-3 min-h-16 rounded-control bg-inset px-2.5 py-2 shadow-hairline">+ <span className={`block text-[11.5px] font-medium ${active.tone}`}>{active.label}</span>+ <span className="mt-1 block text-[11px] leading-relaxed text-ink-3">+ Contribution snapshot across current inventory value. Segment selection changes the inspected group without moving the card.+ </span>+ </div>+ </div>+ );+}++const PAGES = [+ {+ key: "compare",+ prose: (+ <>+ The worst performer in your <Entity name="Creamery" tone="bg-orange" /> is+ Rocky Road — down <Mono tone="red">-6%</Mono> or <Mono tone="red">-$2,453.44</Mono>.+ </>+ ),+ Card: CompareCard,+ pill: "Should I rebalance flavors?",+ },+ {+ key: "anomaly",+ prose: (+ <>+ Unusually high freezer bill on <span className="font-medium text-ink">Dec 13</span> —{" "}+ <Mono tone="red">+$1,834.66</Mono> above your average.+ </>+ ),+ Card: AnomalyCard,+ pill: "Get tips on cutting freezer costs",+ },+ {+ key: "allocation",+ prose: (+ <>+ You’re heavily invested in <Entity name="Vanilla" tone="bg-orange" /> — it’s{" "}+ <span className="font-medium text-ink">72.5%</span> of your case.+ </>+ ),+ Card: AllocationCard,+ pill: "If we look at seasonals, what changes?",+ },+];++export default function InsightCards() {+ const [page, setPage] = useState(0);++ const move = (direction: -1 | 1) => {+ setPage((current) => (current + direction + PAGES.length) % PAGES.length);+ };++ const { prose, Card, pill } = PAGES[page];++ return (+ <div className="min-h-[408px] w-full max-w-86">+ {/* pager header */}+ <div className="flex items-center justify-between">+ <span className="flex items-baseline gap-1.5">+ <span className="text-[13px] font-semibold text-ink">Insights</span>+ <span className="text-[13px] text-ink-3 tabular-nums">{PAGES.length}</span>+ </span>+ <span className="flex items-center gap-0.5">+ {(["M15 18l-6-6 6-6", "M9 6l6 6-6 6"] as const).map((d, i) => (+ <button+ key={i}+ aria-label={i === 0 ? "Previous insight" : "Next insight"}+ onClick={() => move(i === 0 ? -1 : 1)}+ className="flex size-6 items-center justify-center rounded-[6px] text-ink-3+ transition-[background-color,color,transform] duration-100 hover:bg-hover+ hover:text-ink active:scale-[0.96]"+ >+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">+ <path d={d} />+ </svg>+ </button>+ ))}+ </span>+ </div>++ {/* page content — blurred crossfade */}+ <div+ className="transition-[opacity,filter] duration-250"+ style={{ opacity: 1, filter: "blur(0)" }}+ >+ <p className="mt-1.5 text-[12.5px] leading-relaxed text-ink-2">{prose}</p>+ <div className="mt-2">+ <Card />+ </div>+ <button+ className="mt-2 rounded-full bg-surface px-3 py-1.5 text-left text-[12px] text-ink+ shadow-btn transition-colors duration-100 hover:bg-hover"+ >+ {pill}+ </button>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/LoadingState.tsx b/apps/native/components/primitives/LoadingState.tsxnew file mode 100644index 00000000..210b98f5--- /dev/null+++ b/apps/native/components/primitives/LoadingState.tsx@@ -0,0 +1,151 @@+"use client";++import { useEffect, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * LOADING STATE — pixel-grid loader for long-running work+ *+ * Variants:+ * Drive — square cells, chevron wavefront driving right;+ * the 650ms cycle is shorter than the sweep, so+ * two fronts are always in flight+ * Dots — same wavefront, circular cells+ * Orbit — a comet lapping the grid perimeter+ * Surfer — the Drive loader paired with a meme video below+ *+ * Paired with a shimmering label and a live elapsed timer+ * in mono tabular figures. Reduced motion freezes the grid+ * to its dim state; the timer still ticks.+ * ───────────────────────────────────────────────────────── */++const chevron = Array.from({ length: 9 }, (_, i) => {+ const r = Math.floor(i / 3), c = i % 3;+ return (c + Math.abs(r - 1)) * 90;+});++const ORBIT_ORDER = [0, 1, 2, 5, 8, 7, 6, 3];+const orbit = Array.from({ length: 9 }, (_, i) => {+ const k = ORBIT_ORDER.indexOf(i);+ return k === -1 ? null : k * 110;+});++const PATTERNS: Record<string, { delays: (number | null)[]; dur: number; round: boolean }> = {+ Drive: { delays: chevron, dur: 650, round: false },+ Dots: { delays: chevron, dur: 650, round: true },+ Orbit: { delays: orbit, dur: 950, round: false },+};++function LoaderGrid({+ delays,+ dur,+ round,+}: {+ delays: (number | null)[];+ dur: number;+ round: boolean;+}) {+ return (+ <span aria-hidden className="grid shrink-0 grid-cols-[repeat(3,4px)] gap-[1.5px]">+ {delays.map((delay, index) => (+ <span+ key={index}+ className={`size-[4px] bg-ink ${round ? "rounded-full" : "rounded-[1px]"}`}+ style={{+ opacity: delay === null ? 0.07 : 0.15,+ animation: delay === null ? "none" : `pixel-on ${dur}ms ease-in-out ${delay}ms infinite`,+ }}+ />+ ))}+ </span>+ );+}++function useElapsed() {+ const [ds, setDs] = useState(0);+ useEffect(() => {+ const t = setInterval(() => setDs((d) => d + 1), 100);+ return () => clearInterval(t);+ }, []);+ const total = ds / 10;+ if (total < 60) return `${total.toFixed(1)}s`;+ return `${Math.floor(total / 60)}m ${(total % 60).toFixed(1)}s`;+}++export default function LoadingState({+ label,+ variant = "Drive",+ /** the meme feed for the Surfer variant; drop the file in /public to light it up */+ videoSrc = "/subway-surfers.mp4",+}: {+ label?: string;+ variant?: string;+ videoSrc?: string;+}) {+ const elapsed = useElapsed();+ const surfer = variant === "Surfer";+ const resolvedLabel = label ?? (surfer ? "Subway surfing" : "Churning");+ const [videoOk, setVideoOk] = useState(true);+ const { delays, dur, round } = PATTERNS[variant] ?? PATTERNS.Drive;++ const labelEl = (+ <span+ className="bg-clip-text text-[13px] font-medium text-transparent"+ style={{+ backgroundImage:+ "linear-gradient(90deg, var(--ink-3) 35%, var(--ink) 50%, var(--ink-3) 65%)",+ backgroundSize: "200% 100%",+ animation: "shimmer-text 1.4s linear infinite",+ }}+ >+ {resolvedLabel}+ </span>+ );+ const elapsedEl = <span className="font-mono text-[12px] text-ink-3 tabular-nums">{elapsed}</span>;++ if (surfer) {+ return (+ <div role="status" className="flex w-fit flex-col items-start">+ <div className="flex items-center gap-2.5">+ <LoaderGrid {...PATTERNS.Drive} />+ {labelEl}+ {elapsedEl}+ </div>++ {/* the context card follows the status text it is illustrating */}+ <div+ className="mt-2 w-56 overflow-hidden rounded-[10px] shadow-overlay"+ style={{ animation: "pop-in 200ms cubic-bezier(0.16,1,0.3,1) both", transformOrigin: "top left" }}+ >+ <div className="relative aspect-video w-full" style={{ background: "var(--tooltip-bg)" }}>+ {videoOk ? (+ <video+ src={videoSrc}+ autoPlay+ muted+ loop+ playsInline+ onError={() => setVideoOk(false)}+ className="h-full w-full object-cover"+ />+ ) : (+ <div className="flex h-full w-full flex-col items-center justify-center gap-1.5">+ <LoaderGrid {...PATTERNS.Drive} />+ <span className="px-3 text-center font-mono text-[10px]" style={{ color: "var(--tooltip-muted)" }}>+ Video unavailable+ </span>+ </div>+ )}+ </div>+ </div>+ </div>+ );+ }++ return (+ <div role="status" className="flex w-fit items-center gap-2.5">+ <LoaderGrid delays={delays} dur={dur} round={round} />+ {labelEl}+ {elapsedEl}+ </div>+ );+}diff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsxnew file mode 100644index 00000000..49c166b8--- /dev/null+++ b/apps/native/components/primitives/PromptBar.tsx@@ -0,0 +1,726 @@+"use client";++import { useEffect, useLayoutEffect, useRef, useState } from "react";+import { createShader, playSweep, accentChain, ACCENTS } from "glimm";++/* The built-in "prism" palette is only cyan→indigo→magenta, so a sweep+ * reads as blue/purple. Build a true full-spectrum rainbow instead. */+const RAINBOW = accentChain([+ ACCENTS.red,+ ACCENTS.orange,+ ACCENTS.yellow,+ ACCENTS.green,+ ACCENTS.cyan,+ ACCENTS.blue,+ ACCENTS.purple,+]);++/* ─────────────────────────────────────────────────────────+ * PROMPT BAR+ * A composer with real controls: attach, @ data sources,+ * / commands, a model picker, dictation, and send.+ * Type @ or / to open the menus; ↑↓ + Enter to pick.+ * Variants: Rounded (card radius) · Pill (full radius).+ * ───────────────────────────────────────────────────────── */++function Icon({ children, size = 15, strokeWidth = 1.8 }: { children: React.ReactNode; size?: number; strokeWidth?: number }) {+ return (+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">+ {children}+ </svg>+ );+}++const GLYPHS: Record<string, React.ReactNode> = {+ clip: <path d="m21.4 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" />,+ chart: <path d="M4 20V10M10 20V4M16 20v-7M22 20H2" />,+ layers: <g><path d="M12 2 2 7l10 5 10-5-10-5z" /><path d="M2 17l10 5 10-5M2 12l10 5 10-5" /></g>,+ globe: <g><circle cx="12" cy="12" r="10" /><path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" /></g>,+};++/* real product marks, inline so the file stays self-contained */+const BRANDS: Record<string, React.ReactNode> = {+ figma: (+ <svg width="11" height="16" viewBox="0 0 38 57" aria-hidden="true">+ <path d="M9.5 57A9.5 9.5 0 0 0 19 47.5V38H9.5a9.5 9.5 0 0 0 0 19z" fill="#0ACF83" />+ <path d="M0 28.5A9.5 9.5 0 0 1 9.5 19H19v19H9.5A9.5 9.5 0 0 1 0 28.5z" fill="#A259FF" />+ <path d="M0 9.5A9.5 9.5 0 0 1 9.5 0H19v19H9.5A9.5 9.5 0 0 1 0 9.5z" fill="#F24E1E" />+ <path d="M19 0h9.5a9.5 9.5 0 1 1 0 19H19V0z" fill="#FF7262" />+ <path d="M38 28.5a9.5 9.5 0 1 1-19 0 9.5 9.5 0 0 1 19 0z" fill="#1ABCFE" />+ </svg>+ ),+ slack: (+ <svg width="15" height="15" viewBox="0 0 127 127" aria-hidden="true">+ <path d="M27.2 80c0 7.3-5.9 13.2-13.2 13.2C6.7 93.2.8 87.3.8 80c0-7.3 5.9-13.2 13.2-13.2h13.2V80zm6.6 0c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2v33c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V80z" fill="#E01E5A" />+ <path d="M47 27.2c-7.3 0-13.2-5.9-13.2-13.2C33.8 6.7 39.7.8 47 .8c7.3 0 13.2 5.9 13.2 13.2v13.2H47zm0 6.7c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H13.9C6.6 60.3.7 54.4.7 47.1c0-7.3 5.9-13.2 13.2-13.2H47z" fill="#36C5F0" />+ <path d="M99.9 47.1c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H99.9V47.1zm-6.6 0c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V13.9C66.9 6.6 72.8.7 80.1.7c7.3 0 13.2 5.9 13.2 13.2v33.2z" fill="#2EB67D" />+ <path d="M80.1 99.8c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V99.8h13.2zm0-6.6c-7.3 0-13.2-5.9-13.2-13.2 0-7.3 5.9-13.2 13.2-13.2h33.1c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H80.1z" fill="#ECB22E" />+ </svg>+ ),+ gmail: (+ <svg width="15" height="12" viewBox="0 0 256 193" aria-hidden="true">+ <path d="M58.182 192.05V93.14L27.507 65.077 0 49.504v125.091c0 9.658 7.825 17.455 17.455 17.455h40.727Z" fill="#4285F4" />+ <path d="M197.818 192.05h40.727c9.659 0 17.455-7.826 17.455-17.455V49.505l-31.156 17.837-27.026 25.798v98.91Z" fill="#34A853" />+ <path d="m58.182 93.14-4.174-38.647 4.174-36.989L128 69.868l69.818-52.364 4.669 34.992-4.669 40.644L128 145.504 58.182 93.14Z" fill="#EA4335" />+ <path d="M197.818 17.504V93.14L256 49.504V26.231c0-21.585-24.64-33.89-41.89-20.945l-16.292 12.218Z" fill="#FBBC04" />+ <path d="m0 49.504 26.759 20.07L58.182 93.14V17.504L41.89 5.286C24.61-7.66 0 4.646 0 26.23v23.273Z" fill="#C5221F" />+ </svg>+ ),+};++type Source = {+ key: string;+ name: string;+ desc: string;+ glyph?: string;+ brand?: string;+ attach?: boolean;+ connect?: boolean;+};++const SOURCES: Source[] = [+ { key: "attach", name: "Add photos & files", desc: "Upload from your computer", glyph: "clip", attach: true },+ { key: "scoop", name: "Scoop Data", desc: "Sales & churn metrics", glyph: "chart" },+ { key: "flavors", name: "Flavor records", desc: "26 makers, tags, links", glyph: "layers" },+ { key: "web", name: "Web search", desc: "Real-time news and info", glyph: "globe" },+ { key: "figma", name: "Figma", desc: "Design-to-code workflows", brand: "figma" },+ { key: "slack", name: "Slack", desc: "Read and manage Slack", brand: "slack" },+ { key: "gmail", name: "Gmail", desc: "Read and manage Gmail", brand: "gmail", connect: true },+];++const COMMANDS = [+ { key: "compare", name: "/compare", desc: "Flavor vs. last summer" },+ { key: "churn-plan", name: "/churn-plan", desc: "Draft a churn schedule" },+ { key: "restock", name: "/restock", desc: "Build a reorder list" },+ { key: "draft-email", name: "/draft-email", desc: "Write a supplier email" },+ { key: "summarize", name: "/summarize", desc: "Digest the thread so far" },+];++const MODELS = [+ { key: "sprinkles-5", name: "Sprinkles 5", tag: "Flagship" },+ { key: "vanilla-1", name: "Vanilla 1", tag: "Basic" },+ { key: "freezer-burn", name: "Freezer Burn 0.4", tag: "Stale" },+];++const FILES = ["flavor-chart.png", "summer-menu.pdf", "pos-export.csv"];+const DICTATION = "Compare pistachio weekends to last summer";++/* self-running demo: walk the @ menu, then the / menu, and repeat.+ * Any pointer or key interaction hands control to the user. */+const AUTO_STEPS: {+ draft: string;+ active?: number;+ connect?: boolean;+ modelOpen?: boolean;+ model?: string;+ hold: number;+}[] = [+ { draft: "", connect: false, model: "vanilla-1", hold: 1100 },+ { draft: "@", active: 0, hold: 900 },+ { draft: "@", active: 1, hold: 620 },+ { draft: "@", active: 4, hold: 620 },+ { draft: "@", active: 6, hold: 700 },+ { draft: "@", active: 6, connect: true, hold: 1000 },+ { draft: "", hold: 700 },+ { draft: "/", active: 0, hold: 900 },+ { draft: "/", active: 1, hold: 620 },+ { draft: "/", active: 3, hold: 1000 },+ { draft: "", hold: 800 },+ // open the model picker and upgrade to the flagship → rainbow sweep+ { draft: "", modelOpen: true, hold: 1200 },+ { draft: "", model: "sprinkles-5", hold: 2400 },+ { draft: "", hold: 900 },+];++/* the last @word or /word being typed, if any */+function parseToken(draft: string): { kind: "at" | "slash"; query: string; start: number } | null {+ const match = /(^|\s)([@/])([\w-]*)$/.exec(draft);+ if (!match) return null;+ return {+ kind: match[2] === "@" ? "at" : "slash",+ query: match[3].toLowerCase(),+ start: match.index + match[1].length,+ };+}++export type PromptModel = { key: string; name: string; tag?: string };++export default function PromptBar({+ variant = "Rounded",+ demo = true,+ tall = false,+ placeholder,+ onSend,+ models,+ modelKey,+ onModelChange,+ disabled,+}: {+ variant?: string;+ /** the self-running walkthrough; turn off when embedding in a real surface */+ demo?: boolean;+ /** hero sizing: a multi-line input with controls on their own row */+ tall?: boolean;+ placeholder?: string;+ onSend?: (text: string) => void;+ models?: PromptModel[];+ modelKey?: string;+ onModelChange?: (key: string) => void;+ disabled?: boolean;+}) {+ const pill = variant === "Pill";+ const catalog = models && models.length > 0 ? models : MODELS;+ const [draft, setDraft] = useState("");+ const [dismissed, setDismissed] = useState(false);+ const [plusOpen, setPlusOpen] = useState(false);+ const [modelOpen, setModelOpen] = useState(false);+ const [model, setModel] = useState(+ () => catalog.find((m) => m.key === modelKey) ?? catalog[0] ?? MODELS[1],+ );+ const [attachments, setAttachments] = useState<string[]>([]);+ const [connected, setConnected] = useState(false);+ const [active, setActive] = useState(0);+ const [listening, setListening] = useState(false);+ const [auto, setAuto] = useState(demo);+ const [autoStep, setAutoStep] = useState(0);+ const [expanded, setExpanded] = useState(false);+ const wide = expanded || tall;+ const [rowBox, setRowBox] = useState<{ top: number; height: number } | null>(null);+ const [engaged, setEngaged] = useState(false);+ const [modelBox, setModelBox] = useState<{ top: number; height: number } | null>(null);+ const [modelHovered, setModelHovered] = useState<number | null>(null);+ const [modelMenuLeft, setModelMenuLeft] = useState(0);+ const [modelMenuBottom, setModelMenuBottom] = useState(0);+ const composerAnchorRef = useRef<HTMLDivElement>(null);+ const controlsRef = useRef<HTMLDivElement>(null);+ const inputRef = useRef<HTMLTextAreaElement>(null);+ const measureRef = useRef<HTMLSpanElement>(null);+ const modelRef = useRef<HTMLButtonElement>(null);+ const rowRefs = useRef<(HTMLButtonElement | null)[]>([]);+ const modelRowRefs = useRef<(HTMLButtonElement | null)[]>([]);+ const glimmRef = useRef<HTMLCanvasElement>(null);+ const shaderRef = useRef<ReturnType<typeof createShader> | null>(null);+ const sweepingRef = useRef(false);++ /* hand control to the user: stop the demo loop, and when they aim at+ * the input itself, clear the demo's leftover draft for a clean start */+ const takeOver = (event: { target: EventTarget | null }) => {+ setAuto(false);+ if (auto && event.target === inputRef.current) setDraft("");+ };++ const token = dismissed ? null : parseToken(draft);+ const menu: "at" | "slash" | null = plusOpen ? "at" : token?.kind ?? null;+ const query = plusOpen ? "" : token?.query ?? "";++ const rows: { key: string; name: string; desc: string }[] =+ menu === "at"+ ? SOURCES.filter((s) => s.name.toLowerCase().includes(query))+ : menu === "slash"+ ? COMMANDS.filter((c) => c.name.slice(1).startsWith(query))+ : [];++ useEffect(() => {+ setActive(0);+ setEngaged(false);+ }, [menu, query]);++ /* a single highlight glides to the active row instead of each row+ * toggling its own background — matches the gliding pill in the nav */+ useLayoutEffect(() => {+ const target = rowRefs.current[active];+ if (target) setRowBox({ top: target.offsetTop, height: target.offsetHeight });+ }, [menu, query, active, connected, rows.length]);++ /* same gliding highlight in the model menu — floats to the hovered+ * row, falling back to the currently-selected model */+ const modelIndex = catalog.findIndex((m) => m.key === model.key);+ useLayoutEffect(() => {+ if (!modelOpen) return;+ const target = modelRowRefs.current[modelHovered ?? modelIndex];+ if (target) setModelBox({ top: target.offsetTop, height: target.offsetHeight });+ }, [modelOpen, modelHovered, modelIndex]);++ /* The menu is outside the clipped composer, so align it to the model+ * trigger by measurement instead of pinning it to the far-right edge. */+ useLayoutEffect(() => {+ if (!modelOpen || !composerAnchorRef.current || !modelRef.current) return;+ const anchorRect = composerAnchorRef.current.getBoundingClientRect();+ const triggerRect = modelRef.current.getBoundingClientRect();+ setModelMenuLeft(Math.max(0, Math.min(triggerRect.left - anchorRect.left, anchorRect.width - 176)));+ setModelMenuBottom(anchorRect.bottom - triggerRect.top + 8);+ }, [modelOpen, wide, model.name]);++ useEffect(() => {+ if (!modelOpen) setModelHovered(null);+ }, [modelOpen]);++ /* Build the shader with a pinned hue phase. createShader seeds its+ * internal hueShift from Math.random(), which made the sweep a different+ * colour on every reload — pin it so the rainbow is identical each time. */+ const makeShader = () => {+ const canvas = glimmRef.current;+ if (!canvas) return null;+ const random = Math.random;+ Math.random = () => 0;+ try {+ return createShader({+ canvas,+ palette: RAINBOW,+ direction: "ltr",+ bandTight: 10,+ swellAmount: 0.85,+ });+ } finally {+ Math.random = random;+ }+ };++ /* Glimm shader lives inside the composer, invisible at rest. Selecting+ * the flagship model fires a one-shot rainbow sweep across the interior. */+ useEffect(() => {+ shaderRef.current = makeShader();+ return () => {+ shaderRef.current?.destroy();+ shaderRef.current = null;+ };+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);++ const celebrate = () => {+ if (sweepingRef.current) return;+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;+ // Recreate the shader per sweep so uTime restarts at 0 — the hue phase+ // (which drifts with time) is then identical on every trigger.+ shaderRef.current?.destroy();+ const shader = makeShader();+ shaderRef.current = shader;+ if (!shader) return;+ sweepingRef.current = true;+ const sweep = playSweep(shader, {+ palette: RAINBOW,+ direction: "ltr",+ sweepMs: 570,+ outroMs: 80,+ peakAlpha: 1.3,+ bandTight: 10,+ brightness: 1.4,+ swellAmount: 1,+ waveSpeed: 1.8,+ easing: "easeOutExpo",+ });+ sweep.done.finally(() => {+ sweepingRef.current = false;+ });+ };++ const selectModel = (next: PromptModel) => {+ setModel(next);+ setModelOpen(false);+ onModelChange?.(next.key);+ if (next.key === "sprinkles-5") celebrate();+ };++ /* autoplay: apply the current step, then advance after its hold */+ useEffect(() => {+ if (!auto) return;+ const step = AUTO_STEPS[autoStep % AUTO_STEPS.length];+ setDraft(step.draft);+ if (step.active !== undefined) setActive(step.active);+ if (step.connect !== undefined) setConnected(step.connect);+ if (step.modelOpen !== undefined) setModelOpen(step.modelOpen);+ if (step.model) {+ const next = MODELS.find((m) => m.key === step.model);+ if (next) selectModel(next);+ }+ const t = setTimeout(() => setAutoStep((s) => s + 1), step.hold);+ return () => clearTimeout(t);+ }, [auto, autoStep]);++ /* dictation resolves after a beat, like a real transcript landing */+ useEffect(() => {+ if (!listening) return;+ const t = setTimeout(() => {+ setDraft((current) => (current ? `${current.trimEnd()} ${DICTATION}` : DICTATION));+ setListening(false);+ inputRef.current?.focus();+ }, 2200);+ return () => clearTimeout(t);+ }, [listening]);++ /* Move wrapped text above the controls, then grow to a compact maximum. */+ useLayoutEffect(() => {+ const input = inputRef.current;+ const controls = controlsRef.current;+ const measure = measureRef.current;+ const modelButton = modelRef.current;+ if (!input || !controls || !measure || !modelButton) return;++ const fixedControlsWidth = 28 * 3 + modelButton.offsetWidth;+ const inlineGaps = 4 * 4;+ const inlineInputWidth = controls.clientWidth - fixedControlsWidth - inlineGaps;+ const needsFullWidth = draft.includes("\n") || measure.offsetWidth + 8 > inlineInputWidth;+ if (needsFullWidth !== expanded) {+ setExpanded(needsFullWidth);+ }++ const minHeight = 28;+ const maxHeight = 100;+ input.style.height = "0px";+ const contentHeight = input.scrollHeight;+ input.style.height = `${Math.min(Math.max(contentHeight, minHeight), maxHeight)}px`;+ input.style.overflowY = contentHeight > maxHeight ? "auto" : "hidden";+ }, [draft, expanded]);++ /* clicking anywhere outside the composer closes the open menus */+ useEffect(() => {+ if (!modelOpen && !plusOpen) return;+ const close = (event: PointerEvent) => {+ if (!(event.target as Element).closest("[data-promptbar]")) {+ setModelOpen(false);+ setPlusOpen(false);+ }+ };+ document.addEventListener("pointerdown", close);+ return () => document.removeEventListener("pointerdown", close);+ }, [modelOpen, plusOpen]);++ const closeMenus = () => {+ setPlusOpen(false);+ setModelOpen(false);+ };++ const pick = (row: { key: string; name: string }) => {+ const source = SOURCES.find((s) => s.key === row.key);+ if (source?.attach) {+ setAttachments((current) => [...current, FILES[current.length % FILES.length]]);+ if (token) setDraft(draft.slice(0, token.start));+ } else if (menu === "at") {+ setDraft(`${token ? draft.slice(0, token.start) : draft}@${row.name} `);+ } else {+ setDraft(`${token ? draft.slice(0, token.start) : draft}${row.name} `);+ }+ setPlusOpen(false);+ setDismissed(false);+ inputRef.current?.focus();+ };++ const canSend = !disabled && (draft.trim().length > 0 || attachments.length > 0);+ const send = () => {+ if (!canSend) return;+ onSend?.(draft.trim());+ setDraft("");+ setAttachments([]);+ closeMenus();+ };++ return (+ <div+ data-promptbar+ className={demo ? "flex min-h-[384px] w-full max-w-105 flex-col justify-end pb-8" : "w-full"}+ onPointerDownCapture={takeOver}+ onKeyDownCapture={takeOver}+ >+ {/* composer is the anchor — menus grow up from its top edge */}+ <div ref={composerAnchorRef} className="relative">+ {/* ── @ / slash menu ─────────────────────────────── */}+ {menu && (+ <div+ onMouseLeave={() => setEngaged(false)}+ className="absolute inset-x-0 bottom-full z-10 mb-2 rounded-[10px] bg-surface p-1 shadow-raised"+ style={{ animation: "pop-in 180ms cubic-bezier(0.23,1,0.32,1) both", transformOrigin: "bottom center" }}+ >+ {/* single gliding highlight — appears once a row is hovered */}+ <span+ aria-hidden+ className="pointer-events-none absolute inset-x-1 rounded-[6px] bg-hover"+ style={{+ top: rowBox?.top ?? 0,+ height: rowBox?.height ?? 0,+ opacity: rowBox && engaged && rows.length > 0 ? 1 : 0,+ transition:+ "top 220ms cubic-bezier(0.23,1,0.32,1), height 220ms cubic-bezier(0.23,1,0.32,1), opacity 150ms ease",+ }}+ />+ {rows.map((row, i) => {+ const source = menu === "at" ? SOURCES.find((s) => s.key === row.key) : undefined;+ return (+ <button+ key={row.key}+ type="button"+ ref={(el) => {+ rowRefs.current[i] = el;+ }}+ onMouseDown={(event) => event.preventDefault()}+ onMouseEnter={() => {+ setActive(i);+ setEngaged(true);+ }}+ onClick={() => pick(row)}+ className="relative z-10 flex h-9 w-full items-center gap-2.5 rounded-[6px] px-2 text-left"+ >+ {source && (+ <span className="flex size-5.5 shrink-0 items-center justify-center text-ink-2">+ {source.brand ? BRANDS[source.brand] : <Icon size={15}>{GLYPHS[source.glyph ?? "clip"]}</Icon>}+ </span>+ )}+ <span className="shrink-0 text-[12.5px] font-medium text-ink">+ {row.name}+ </span>+ <span className="min-w-0 flex-1 truncate text-[12px] text-ink-3">{row.desc}</span>+ {source?.connect && (+ <span+ role="button"+ tabIndex={-1}+ onClick={(event) => {+ event.stopPropagation();+ setConnected((current) => !current);+ }}+ className={`shrink-0 text-[12px] font-medium transition-colors duration-100 ${+ connected ? "text-green" : "text-accent-ink hover:underline"+ }`}+ >+ {connected ? "Connected" : "Connect"}+ </span>+ )}+ </button>+ );+ })}+ {rows.length === 0 && (+ <div className="flex h-9 items-center px-2 text-[12px] text-ink-3">+ No matches for “{query}”+ </div>+ )}+ <div className="mt-1 border-t border-line px-2 pt-1.5 pb-1 text-[11px] text-ink-3">+ {menu === "at" ? "Type to search sources & files" : "Type to search commands"}+ </div>+ </div>+ )}++ {/* ── model menu ─────────────────────────────────── */}+ {modelOpen && (+ <div+ onMouseLeave={() => setModelHovered(null)}+ className="absolute z-10 w-44 rounded-[10px] bg-surface p-1 shadow-raised"+ style={{ left: modelMenuLeft, bottom: modelMenuBottom, animation: "pop-in 180ms cubic-bezier(0.23,1,0.32,1) both", transformOrigin: "bottom left" }}+ >+ {/* single gliding highlight — floats to the hovered / selected row */}+ <span+ aria-hidden+ className="pointer-events-none absolute inset-x-1 rounded-[6px] bg-hover"+ style={{+ top: modelBox?.top ?? 0,+ height: modelBox?.height ?? 0,+ opacity: modelBox && modelHovered !== null ? 1 : 0,+ transition:+ "top 220ms cubic-bezier(0.23,1,0.32,1), height 220ms cubic-bezier(0.23,1,0.32,1), opacity 150ms ease",+ }}+ />+ {catalog.map((m, i) => (+ <button+ key={m.key}+ type="button"+ ref={(el) => {+ modelRowRefs.current[i] = el;+ }}+ onMouseDown={(event) => event.preventDefault()}+ onMouseEnter={() => setModelHovered(i)}+ onClick={() => {+ selectModel(m);+ inputRef.current?.focus();+ }}+ className="relative z-10 flex h-7.5 w-full items-center gap-2 rounded-[6px] px-2 text-left"+ >+ <span className="min-w-0 flex-1 truncate text-[12.5px] font-medium text-ink">{m.name}</span>+ <span className="shrink-0 text-[11px] text-ink-3">{m.tag}</span>+ <span className={`shrink-0 text-ink ${m.key === model.key ? "" : "invisible"}`}>+ <Icon size={13} strokeWidth={2.5}><path d="M20 6L9 17l-5-5" /></Icon>+ </span>+ </button>+ ))}+ </div>+ )}++ {/* ── composer ───────────────────────────────────── */}+ <div+ className={`relative isolate flex flex-col overflow-hidden border border-line bg-surface shadow-card transition-[border-color,border-radius] duration-150 focus-within:border-line-strong ${+ tall ? "gap-2.5 p-3.5" : "gap-1.5 p-1.5"+ } ${+ pill ? (attachments.length > 0 || wide ? "rounded-[24px]" : "rounded-full") : tall ? "rounded-[22px]" : "rounded-[14px]"+ }`}+ >+ {/* rainbow glimm sweep — plays across the interior on model change.+ explicit w/h: a <canvas> is a replaced element and won't stretch+ to inset-0 alone, which feeds back into the shader's ResizeObserver. */}+ <canvas+ ref={glimmRef}+ aria-hidden="true"+ className="pointer-events-none absolute inset-0 -z-10 h-full w-full"+ style={{ borderRadius: "inherit" }}+ />+ <span+ ref={measureRef}+ aria-hidden="true"+ className="pointer-events-none absolute invisible whitespace-pre text-[13px] leading-[18px]"+ >+ {draft}+ </span>++ {attachments.length > 0 && (+ <div className={`flex flex-wrap gap-1.5 pt-0.5 ${pill ? "px-1" : "px-0.5"}`}>+ {attachments.map((file, i) => (+ <span+ key={`${file}-${i}`}+ className={`flex h-6.5 items-center gap-1.5 bg-field py-1 pr-1 pl-1.5 text-[11.5px] text-ink-2 shadow-hairline ${+ pill ? "rounded-full" : "rounded-chip"+ }`}+ style={{ animation: "pop-in 200ms cubic-bezier(0.23,1,0.32,1) both" }}+ >+ <Icon size={12}><g><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><path d="M14 2v6h6" /></g></Icon>+ <span className="max-w-36 truncate">{file}</span>+ <button+ type="button"+ aria-label={`Remove ${file}`}+ onClick={() => setAttachments((current) => current.filter((_, j) => j !== i))}+ className={`-my-1 flex size-6 items-center justify-center text-ink-3 transition-colors duration-100 hover:bg-line/70 hover:text-ink ${+ pill ? "rounded-full" : "rounded-[5px]"+ }`}+ >+ <Icon size={10} strokeWidth={2.5}><path d="M18 6L6 18M6 6l12 12" /></Icon>+ </button>+ </span>+ ))}+ </div>+ )}++ <div+ ref={controlsRef}+ className={`grid items-end gap-x-1 gap-y-1.5 ${+ wide+ ? "grid-cols-[28px_auto_minmax(0,1fr)_28px_28px]"+ : "grid-cols-[28px_minmax(0,1fr)_auto_28px_28px]"+ }`}+ >+ <button+ type="button"+ aria-label="Add attachments and sources"+ aria-expanded={plusOpen}+ onClick={() => {+ setModelOpen(false);+ setPlusOpen((current) => !current);+ inputRef.current?.focus();+ }}+ className={`flex size-7 shrink-0 items-center justify-center justify-self-start text-ink-3 transition-[background-color,color,transform] duration-150 hover:bg-hover hover:text-ink active:scale-[0.94] ${+ pill ? "rounded-full" : "rounded-[8px]"+ } ${plusOpen ? "bg-hover text-ink" : ""} ${wide ? "col-start-1 row-start-2" : "col-start-1 row-start-1"}`}+ >+ <Icon size={16} strokeWidth={2}><path d="M12 5v14M5 12h14" /></Icon>+ </button>++ <textarea+ ref={inputRef}+ rows={1}+ value={draft}+ onChange={(event) => {+ setDraft(event.target.value);+ setDismissed(false);+ setPlusOpen(false);+ }}+ onKeyDown={(event) => {+ if (menu && rows.length > 0) {+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {+ event.preventDefault();+ setEngaged(true);+ setActive((current) => (current + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length);+ return;+ }+ if ((event.key === "Enter" && !event.shiftKey) || event.key === "Tab") {+ event.preventDefault();+ pick(rows[active]);+ return;+ }+ }+ if (event.key === "Escape") {+ setDismissed(true);+ closeMenus();+ return;+ }+ if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {+ event.preventDefault();+ send();+ }+ }}+ placeholder={listening ? "Listening…" : placeholder ?? "Write a message…"}+ aria-label="Prompt"+ className={`${tall ? "min-h-[68px] px-2 py-2 text-[14px] leading-5" : "min-h-7 px-1 py-[5px] text-[13px] leading-[18px]"} min-w-0 w-full resize-none bg-transparent text-ink outline-none [overflow-wrap:anywhere] placeholder:text-ink-3 ${+ wide ? "col-span-full col-start-1 row-start-1" : "col-start-2 row-start-1"+ }`}+ />++ {/* model picker */}+ <button+ ref={modelRef}+ type="button"+ aria-expanded={modelOpen}+ aria-label="Choose model"+ onClick={() => {+ setPlusOpen(false);+ setModelOpen((current) => !current);+ }}+ className={`flex h-7 shrink-0 items-center gap-1 px-1.5 text-[12px] font-medium text-ink-2 transition-colors duration-150 hover:bg-hover hover:text-ink ${+ pill ? "rounded-full" : "rounded-[8px]"+ } ${wide ? "col-start-2 row-start-2 justify-self-start" : "col-start-3 row-start-1"}`}+ >+ {model.name}+ <span className="text-ink-3">+ <Icon size={11} strokeWidth={2.4}><path d="M6 9l6 6 6-6" /></Icon>+ </span>+ </button>++ {/* dictation */}+ <button+ type="button"+ aria-label={listening ? "Stop dictation" : "Start dictation"}+ aria-pressed={listening}+ onClick={() => setListening((current) => !current)}+ className={`flex size-7 shrink-0 items-center justify-center transition-[background-color,color,transform] duration-150 active:scale-[0.94] ${+ pill ? "rounded-full" : "rounded-[8px]"+ } ${listening ? "bg-accent-tint text-accent-ink" : "text-ink-3 hover:bg-hover hover:text-ink"} ${wide ? "col-start-4 row-start-2" : "col-start-4 row-start-1"}`}+ >+ {listening ? (+ <span className="flex h-3.5 items-center gap-[2.5px]">+ {[0, 1, 2].map((i) => (+ <span+ key={i}+ className="w-[2.5px] rounded-full bg-current"+ style={{ height: "100%", animation: `eq-bounce 900ms ease-in-out ${i * 150}ms infinite` }}+ />+ ))}+ </span>+ ) : (+ <Icon size={15} strokeWidth={2}><g><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z" /><path d="M19 10v2a7 7 0 0 1-14 0v-2M12 19v3" /></g></Icon>+ )}+ </button>++ {/* send — tactile square (round in the pill variant) */}+ <button+ type="button"+ aria-label="Send"+ disabled={!canSend}+ onClick={send}+ className={`flex size-7 shrink-0 items-center justify-center transition-[background-color,color,transform] duration-200 enabled:active:scale-[0.94] ${+ pill ? "rounded-full" : "rounded-[8px]"+ } ${wide ? "col-start-5 row-start-2" : "col-start-5 row-start-1"}`}+ style={{+ background: canSend ? "var(--ink)" : "var(--line-strong)",+ color: canSend ? "var(--surface)" : "var(--ink-2)",+ }}+ >+ <Icon size={16} strokeWidth={2.4}><path d="M12 19V5M5 12l7-7 7 7" /></Icon>+ </button>+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/RecommendationCard.tsx b/apps/native/components/primitives/RecommendationCard.tsxnew file mode 100644index 00000000..b8db39e9--- /dev/null+++ b/apps/native/components/primitives/RecommendationCard.tsx@@ -0,0 +1,203 @@+"use client";++import { useState } from "react";+import { Button, type ButtonVariant } from "@/components/atoms/Button";++/* ─────────────────────────────────────────────────────────+ * RECOMMENDATION CARD+ * The card holds its shape. Pressing "Alternatives" opens a+ * new drawer listing the other options; picking one promotes+ * it to the recommendation. The primary action confirms.+ * ───────────────────────────────────────────────────────── */++type Option = {+ key: string;+ body: React.ReactNode;+ short: string;+ signal: number;+ tone: string;+ label: string;+ cta: string;+ ctaVariant: ButtonVariant;+};++/* a supplier as a little logo chip — circular mark + name, no external arrow */+function VendorChip({ name, color = "#e08a3c" }: { name: string; color?: string }) {+ return (+ <span className="mx-0.5 inline-flex items-center gap-1 rounded-full bg-field py-px pl-[3px] pr-1.5 align-middle shadow-hairline">+ <span+ className="flex size-4 shrink-0 items-center justify-center rounded-full text-[9px] font-semibold leading-none text-white"+ style={{ background: color }}+ >+ {name.charAt(0)}+ </span>+ <span className="text-[12px] font-medium text-ink">{name}</span>+ </span>+ );+}++/* a plain value as a soft rounded badge — not a mono token */+function Pill({ children, tone = "neutral" }: { children: React.ReactNode; tone?: "neutral" | "green" }) {+ return (+ <span+ className={`mx-0.5 inline-flex items-center rounded-full px-1.5 py-0 align-middle text-[12px] font-medium ${+ tone === "green" ? "bg-green-tint text-green" : "bg-field text-ink-2"+ }`}+ style={{+ boxShadow: tone === "green"+ ? "0 0 0 1px color-mix(in oklch, var(--green) 28%, transparent)"+ : "var(--shadow-hairline)",+ }}+ >+ {children}+ </span>+ );+}++const OPTIONS: Option[] = [+ {+ key: "high",+ body: (+ <>+ Reorder waffle cones from{" "}+ <VendorChip name="Cone King" />{" "}+ with lead time <Pill tone="green">7 days</Pill>+ </>+ ),+ short: "Reorder from Cone King · 7-day lead",+ signal: 3,+ tone: "var(--green)",+ label: "High confidence",+ cta: "Accept",+ ctaVariant: "accent",+ },+ {+ key: "review",+ body: (+ <>+ Switch vanilla to <Pill>Vanilla Madagascar</Pill> for peak season.+ </>+ ),+ short: "Switch to Vanilla Madagascar",+ signal: 2,+ tone: "var(--orange)",+ label: "Needs review",+ cta: "Configure",+ ctaVariant: "primary",+ },+ {+ key: "none",+ body: (+ <>+ Fall back to a <span className="font-medium text-ink">full restock</span> across every SKU.+ </>+ ),+ short: "Full restock across every SKU",+ signal: 0,+ tone: "var(--ink-3)",+ label: "No signal",+ cta: "Accept full restock",+ ctaVariant: "primary",+ },+];++function Meter({ signal, tone }: { signal: number; tone: string }) {+ return (+ <span className="flex items-end gap-0.5">+ {[0, 1, 2].map((bar) => (+ <span+ key={bar}+ className="w-1 rounded-full transition-colors duration-300"+ style={{ height: 10, background: bar < signal ? tone : "var(--line-strong)" }}+ />+ ))}+ </span>+ );+}++export default function RecommendationCard() {+ const [selected, setSelected] = useState(0);+ const [open, setOpen] = useState(false);+ const [accepted, setAccepted] = useState(false);++ const active = OPTIONS[selected];+ const others = OPTIONS.map((o, i) => ({ o, i })).filter(({ i }) => i !== selected);++ return (+ <div className="w-full max-w-95 overflow-hidden rounded-card bg-surface shadow-card">+ <div className="primitive-card-pad">+ <span className="text-[14px] font-medium text-ink">+ Want me to place this restock order?+ </span>+ <p+ key={active.key}+ className="mt-1.5 min-h-12 text-[13px] leading-relaxed text-ink-2"+ style={{ animation: "fade-in 180ms ease-out both" }}+ >+ {active.body}+ </p>+ </div>++ {/* alternatives drawer — a distinctly new section of the card */}+ <div+ className="grid transition-[grid-template-rows,opacity] duration-300"+ style={{+ gridTemplateRows: open ? "1fr" : "0fr",+ opacity: open ? 1 : 0,+ transitionTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)",+ }}+ >+ <div className="overflow-hidden">+ <div className="border-t border-line bg-surface px-2 py-2">+ <p className="px-1.5 pb-1 text-[11px] font-medium text-ink-3">+ Other options+ </p>+ {others.map(({ o, i }) => (+ <button+ key={o.key}+ type="button"+ onClick={() => {+ setSelected(i);+ setAccepted(false);+ }}+ className="flex w-full items-center gap-2.5 rounded-control px-1.5 py-1.5+ text-left transition-colors duration-100 hover:bg-hover"+ >+ <Meter signal={o.signal} tone={o.tone} />+ <span className="min-w-0 flex-1 truncate text-[12.5px] text-ink">{o.short}</span>+ <span className="shrink-0 text-[11px] text-ink-3">{o.label}</span>+ </button>+ ))}+ </div>+ </div>+ </div>++ <div className="primitive-card-footer flex items-center justify-between gap-3 bg-surface">+ <span className="flex items-center gap-2">+ <Meter signal={active.signal} tone={active.tone} />+ <span className="text-[12.5px] font-medium text-ink-2">{active.label}</span>+ </span>++ <span className="-mr-0.5 flex items-center gap-2">+ <Button+ variant="secondary"+ size="sm"+ aria-expanded={open}+ onClick={() => setOpen((current) => !current)}+ className="px-2.5 text-[12.5px]"+ >+ Alternatives+ </Button>+ <Button+ variant={accepted ? "success" : active.ctaVariant}+ size="sm"+ onClick={() => setAccepted(true)}+ className="text-[12.5px]"+ >+ {accepted ? "Accepted" : active.cta}+ </Button>+ </span>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/RecordsTable.tsx b/apps/native/components/primitives/RecordsTable.tsxnew file mode 100644index 00000000..6cf8adc1--- /dev/null+++ b/apps/native/components/primitives/RecordsTable.tsx@@ -0,0 +1,1053 @@+"use client";++import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import GlideMenu from "@/components/primitives/GlideMenu";++/* ─────────────────────────────────────────────────────────+ * RECORDS TABLE — an AI spreadsheet grid. Columns are+ * *properties*: click a header to open its configuration+ * popover (type, tool, grounding, inputs, prompt, run), add+ * a new AI property from the + header, and watch cells+ * resolve row-by-row while it calculates.+ * ───────────────────────────────────────────────────────── */++type Strength = "strong" | "weak" | "veryweak" | "none";+type SortKey = "name" | "last" | "strength";+type ColumnKey = "company" | "categories" | "last" | "strength" | "links" | "ai";++const DEFAULT_COLUMN_WIDTHS: Record<ColumnKey, number> = {+ company: 270,+ categories: 275,+ last: 190,+ strength: 210,+ links: 175,+ ai: 240,+};++const STRENGTH: Record<Strength, { label: string; color: string; rank: number }> = {+ strong: { label: "Very strong", color: "var(--green)", rank: 3 },+ weak: { label: "Weak", color: "var(--orange)", rank: 2 },+ veryweak: { label: "Very weak", color: "var(--red)", rank: 1 },+ none: { label: "No communication", color: "var(--ink-3)", rank: 0 },+};++// A single mid-lightness base hue per tag. Background, text, and border are+// derived from this via color-mix() against the theme tokens in .records-tag,+// so the chips adapt to light and dark automatically (same pattern as FilterTable).+type TagColor = { base: string };++const TAG_PALETTE: Record<string, TagColor> = {+ amber: { base: "oklch(0.76 0.13 70)" },+ lime: { base: "oklch(0.77 0.16 122)" },+ yellow: { base: "oklch(0.80 0.15 101)" },+ purple: { base: "oklch(0.62 0.18 293)" },+ orange: { base: "oklch(0.71 0.16 48)" },+ cyan: { base: "oklch(0.72 0.10 221)" },+ red: { base: "oklch(0.64 0.19 27)" },+ magenta: { base: "oklch(0.66 0.21 323)" },+ green: { base: "oklch(0.70 0.13 162)" },+ pink: { base: "oklch(0.67 0.19 3)" },+};++const TAG_COLORS: Record<string, TagColor> = {+ B2B: TAG_PALETTE.amber,+ B2C: TAG_PALETTE.lime,+ Cafe: TAG_PALETTE.red,+ Catering: TAG_PALETTE.magenta,+ "Dairy-free": TAG_PALETTE.cyan,+ Gelato: TAG_PALETTE.purple,+ Imports: TAG_PALETTE.orange,+ Local: TAG_PALETTE.green,+ Seasonal: TAG_PALETTE.yellow,+ Sorbet: TAG_PALETTE.pink,+ Vegan: TAG_PALETTE.lime,+ Wholesale: TAG_PALETTE.amber,+};++type Row = {+ id: string;+ name: string;+ tags: string[];+ last: string;+ strength: Strength;+ website?: string;+};++const INITIAL_ROWS: Row[] = [+ { id: "aurora", name: "Aurora Scoops — Reykjavík", tags: ["Gelato", "Seasonal"], last: "9 days ago", strength: "strong", website: "aurora-scoops.example.com" },+ { id: "kumo", name: "Kumo Creamery — Tokyo", tags: ["B2C", "Cafe", "Vegan"], last: "3 weeks ago", strength: "strong", website: "kumo-creamery.example.com" },+ { id: "sol-nieve", name: "Sol y Nieve — Buenos Aires", tags: ["Gelato", "Local"], last: "2 months ago", strength: "weak", website: "sol-y-nieve.example.com" },+ { id: "maple-orbit", name: "Maple Orbit — Montréal", tags: ["B2B", "Wholesale", "Seasonal"], last: "15 days ago", strength: "weak", website: "maple-orbit.example.com" },+ { id: "blue-fig", name: "Blue Fig Gelato — Florence", tags: ["Gelato", "Cafe"], last: "over 1 year ago", strength: "veryweak", website: "blue-fig.example.com" },+ { id: "sahara-swirl", name: "Sahara Swirl — Marrakech", tags: ["Sorbet", "Local"], last: "5 months ago", strength: "veryweak" },+ { id: "cloudberry", name: "Cloudberry Cone — Helsinki", tags: ["Dairy-free", "Seasonal"], last: "No contact", strength: "none", website: "cloudberry-cone.example.com" },+ { id: "palm-sugar", name: "Palm Sugar Creamery — Bangkok", tags: ["B2C", "Vegan"], last: "3 months ago", strength: "veryweak", website: "palm-sugar.example.com" },+ { id: "cape-vanilla", name: "Cape Vanilla Co. — Cape Town", tags: ["Wholesale", "Imports"], last: "over 1 year ago", strength: "veryweak", website: "cape-vanilla.example.com" },+ { id: "andes-snow", name: "Andes Snow Creamery — Quito", tags: ["Gelato", "Catering"], last: "almost 2 years ago", strength: "veryweak" },+ { id: "tasman-sea", name: "Tasman Sea Gelato — Hobart", tags: ["Gelato", "Local"], last: "2 months ago", strength: "weak", website: "tasman-sea.example.com" },+ { id: "silk-road", name: "Silk Road Sorbet — Tbilisi", tags: ["Sorbet", "Imports"], last: "about 1 month ago", strength: "weak", website: "silk-road.example.com" },+ { id: "rosewater", name: "Rosewater Kulfi — Jaipur", tags: ["B2C", "Seasonal"], last: "2 months ago", strength: "veryweak" },+ { id: "lumen", name: "Lumen Soft Serve — Copenhagen", tags: ["Dairy-free", "Cafe"], last: "8 months ago", strength: "weak", website: "lumen-soft-serve.example.com" },+ { id: "cacao-norte", name: "Cacao Norte — Oaxaca", tags: ["B2B", "Local", "Wholesale"], last: "about 2 years ago", strength: "none", website: "cacao-norte.example.com" },+ { id: "pine-pistachio", name: "Pine & Pistachio — Istanbul", tags: ["Gelato", "Catering"], last: "about 1 month ago", strength: "veryweak" },+ { id: "ember-cone", name: "Ember Cone Company — Seoul", tags: ["B2C", "Vegan"], last: "15 days ago", strength: "weak", website: "ember-cone.example.com" },+ { id: "coral-coast", name: "Coral Coast Sorbet — Honolulu", tags: ["Sorbet", "Local"], last: "9 days ago", strength: "strong", website: "coral-coast.example.com" },+ { id: "sunbird", name: "Sunbird Gelateria — Lisbon", tags: ["Gelato", "Cafe"], last: "over 2 years ago", strength: "none", website: "sunbird.example.com" },+ { id: "mooncake", name: "Mooncake Ice Cream — Singapore", tags: ["B2B", "Wholesale"], last: "about 1 month ago", strength: "veryweak", website: "mooncake-ice-cream.example.com" },+ { id: "juniper", name: "Juniper & Cream — Vancouver", tags: ["Dairy-free", "Catering"], last: "No contact", strength: "none" },+ { id: "mango-moon", name: "Mango Moon Gelato — Nairobi", tags: ["Sorbet", "Vegan"], last: "almost 2 years ago", strength: "veryweak", website: "mango-moon.example.com" },+ { id: "fjord-fizz", name: "Fjord Fizz Ice — Oslo", tags: ["Dairy-free", "Seasonal"], last: "No contact", strength: "none" },+ { id: "pampa", name: "Pampa Creamery — Córdoba", tags: ["B2C", "Local"], last: "12 months ago", strength: "veryweak", website: "pampa-creamery.example.com" },+ { id: "lotus-leaf", name: "Lotus Leaf Scoops — Hanoi", tags: ["Vegan", "Cafe"], last: "15 days ago", strength: "weak" },+ { id: "saffron-sky", name: "Saffron Sky Kulfi — Dubai", tags: ["Imports", "Catering"], last: "almost 2 years ago", strength: "veryweak", website: "saffron-sky.example.com" },+ { id: "alpine-churn", name: "Alpine Churn — Zürich", tags: ["B2B", "Gelato", "Wholesale"], last: "4 days ago", strength: "strong", website: "alpine-churn.example.com" },+ { id: "monsoon-mango", name: "Monsoon Mango — Mumbai", tags: ["Sorbet", "Vegan", "Catering"], last: "18 days ago", strength: "weak", website: "monsoon-mango.example.com" },+ { id: "cedar-spoon", name: "Cedar Spoon — Beirut", tags: ["Cafe", "Local", "Seasonal"], last: "6 days ago", strength: "strong", website: "cedar-spoon.example.com" },+ { id: "baltic-berry", name: "Baltic Berry — Tallinn", tags: ["Dairy-free", "Seasonal", "B2C"], last: "5 weeks ago", strength: "weak", website: "baltic-berry.example.com" },+ { id: "delta-dairy", name: "Delta Dairy Works — New Orleans", tags: ["B2B", "Wholesale", "Local"], last: "2 days ago", strength: "strong", website: "delta-dairy.example.com" },+ { id: "yuzu-yard", name: "Yuzu Yard — Kyoto", tags: ["Sorbet", "Cafe", "Seasonal"], last: "11 days ago", strength: "strong", website: "yuzu-yard.example.com" },+ { id: "copper-cone", name: "Copper Cone — Melbourne", tags: ["Gelato", "Cafe", "B2C"], last: "about 1 month ago", strength: "weak", website: "copper-cone.example.com" },+ { id: "mint-medina", name: "Mint Medina — Tunis", tags: ["Dairy-free", "Vegan", "Local"], last: "No contact", strength: "none" },+ { id: "glacier-grove", name: "Glacier Grove — Anchorage", tags: ["Seasonal", "Local", "Catering"], last: "7 weeks ago", strength: "weak", website: "glacier-grove.example.com" },+ { id: "orchard-cloud", name: "Orchard Cloud — Lyon", tags: ["Gelato", "Seasonal", "Cafe"], last: "5 days ago", strength: "strong", website: "orchard-cloud.example.com" },+ { id: "tamarind-tide", name: "Tamarind Tide — Chennai", tags: ["Vegan", "Sorbet", "B2C"], last: "9 months ago", strength: "veryweak", website: "tamarind-tide.example.com" },+ { id: "amber-scoop", name: "Amber Scoop — Prague", tags: ["Gelato", "B2B"], last: "over 1 year ago", strength: "none" },+ { id: "boreal-batch", name: "Boreal Batch — Yellowknife", tags: ["Dairy-free", "Local", "Seasonal"], last: "8 days ago", strength: "strong", website: "boreal-batch.example.com" },+ { id: "coconut-commons", name: "Coconut Commons — Manila", tags: ["Vegan", "B2C", "Cafe"], last: "24 days ago", strength: "weak", website: "coconut-commons.example.com" },+ { id: "dolomite-dairy", name: "Dolomite Dairy — Bolzano", tags: ["Gelato", "Wholesale"], last: "3 days ago", strength: "strong", website: "dolomite-dairy.example.com" },+ { id: "equator-cream", name: "Equator Cream — Kampala", tags: ["B2B", "Catering", "Local"], last: "10 months ago", strength: "veryweak", website: "equator-cream.example.com" },+ { id: "hibiscus-house", name: "Hibiscus House — Accra", tags: ["Sorbet", "Cafe"], last: "6 weeks ago", strength: "weak", website: "hibiscus-house.example.com" },+ { id: "lagoon-ladle", name: "Lagoon Ladle — Venice", tags: ["Gelato", "Seasonal", "Catering"], last: "7 days ago", strength: "strong", website: "lagoon-ladle.example.com" },+ { id: "midnight-milk", name: "Midnight Milk — Tromsø", tags: ["Dairy-free", "Vegan", "Wholesale"], last: "No contact", strength: "none" },+ { id: "nomad-nougat", name: "Nomad Nougat — Ulaanbaatar", tags: ["Imports", "B2B"], last: "almost 2 years ago", strength: "none", website: "nomad-nougat.example.com" },+ { id: "olive-snow", name: "Olive Snow — Athens", tags: ["Gelato", "Cafe", "Local"], last: "4 days ago", strength: "strong", website: "olive-snow.example.com" },+ { id: "pacific-pear", name: "Pacific Pear — Valparaíso", tags: ["Sorbet", "Seasonal"], last: "2 months ago", strength: "weak", website: "pacific-pear.example.com" },+ { id: "quartz-cone", name: "Quartz Cone — Denver", tags: ["B2C", "Wholesale"], last: "10 days ago", strength: "strong", website: "quartz-cone.example.com" },+ { id: "red-lantern", name: "Red Lantern Creamery — Taipei", tags: ["Cafe", "Vegan"], last: "about 1 month ago", strength: "weak", website: "red-lantern.example.com" },+ { id: "salt-silk", name: "Salt & Silk — Muscat", tags: ["Imports", "Catering", "Gelato"], last: "8 months ago", strength: "veryweak", website: "salt-and-silk.example.com" },+ { id: "tropic-churn", name: "Tropic Churn — San Juan", tags: ["Sorbet", "Local", "B2C"], last: "6 days ago", strength: "strong", website: "tropic-churn.example.com" },+ { id: "umber-cream", name: "Umber Cream — Warsaw", tags: ["B2B", "Wholesale", "Cafe"], last: "5 weeks ago", strength: "weak", website: "umber-cream.example.com" },+ { id: "vanilla-vale", name: "Vanilla Vale — Antananarivo", tags: ["Imports", "Local"], last: "No contact", strength: "none" },+ { id: "willow-whip", name: "Willow Whip — Portland", tags: ["Dairy-free", "Vegan", "Cafe"], last: "3 days ago", strength: "strong", website: "willow-whip.example.com" },+ { id: "zenith-gelato", name: "Zenith Gelato — Auckland", tags: ["Gelato", "Seasonal"], last: "3 weeks ago", strength: "weak", website: "zenith-gelato.example.com" },+ { id: "apricot-atlas", name: "Apricot Atlas — Algiers", tags: ["Sorbet", "Imports"], last: "11 months ago", strength: "veryweak", website: "apricot-atlas.example.com" },+ { id: "black-sesame", name: "Black Sesame Social — Bandung", tags: ["Vegan", "Cafe", "B2C"], last: "9 days ago", strength: "strong", website: "black-sesame.example.com" },+ { id: "crimson-clover", name: "Crimson Clover — Brussels", tags: ["Gelato", "Wholesale", "Catering"], last: "2 months ago", strength: "weak", website: "crimson-clover.example.com" },+ { id: "dragonfruit-dock", name: "Dragonfruit Dock — Shenzhen", tags: ["Sorbet", "B2B", "Wholesale"], last: "No contact", strength: "none" },+];++/* the AI column resolves to fictional competitor pairs */+const AI_LABEL = "Competitors";+const COMPETITOR_POOL = [+ "Frost & Ladle",+ "Polar Pint Co.",+ "Meltwater Creamery",+ "Cirrus Scoops",+ "Golden Churn",+ "Velvet Freeze",+ "North Cone Collective",+ "Sundae Syndicate",+];+const competitorsFor = (index: number) => `${COMPETITOR_POOL[index % 8]}, ${COMPETITOR_POOL[(index + 3) % 8]}`;++function Icon({ children, size = 14, strokeWidth = 1.8 }: { children: React.ReactNode; size?: number; strokeWidth?: number }) {+ return (+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">+ {children}+ </svg>+ );+}++/* glyph library for property types & tools */+const TYPE_GLYPHS: Record<string, React.ReactNode> = {+ Text: <path d="M4 6h16M4 12h10M4 18h7" />,+ File: <g><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><path d="M14 2v6h6" /></g>,+ Collection: <g><ellipse cx="12" cy="5" rx="8" ry="3" /><path d="M4 5v14c0 1.66 3.58 3 8 3s8-1.34 8-3V5M4 12c0 1.66 3.58 3 8 3s8-1.34 8-3" /></g>,+ "Single select": <g><circle cx="12" cy="12" r="9" /><path d="m8.5 12 2.4 2.4 4.6-4.9" /></g>,+ "Multi select": <g><path d="M11 6h9M11 12h9M11 18h9" /><path d="M4 6l1.5 1.5L8 5M4 12l1.5 1.5L8 11M4 18l1.5 1.5L8 17" /></g>,+ URL: <g><path d="M10 13a5 5 0 0 0 7.1.1l2-2a5 5 0 0 0-7.1-7.1l-1.1 1.1" /><path d="M14 11a5 5 0 0 0-7.1-.1l-2 2A5 5 0 0 0 12 20l1.1-1.1" /></g>,+ Reference: <path d="M7 17 17 7M9 7h8v8" />,+ JSON: <g><path d="M8 4c-2 0-2 2-2 3s.5 3-2 3c2.5 0 2 2 2 3s0 3 2 3" /><path d="M16 4c2 0 2 2 2 3s-.5 3 2 3c-2.5 0-2 2-2 3s0 3-2 3" /></g>,+ "File splitter": <g><rect x="8" y="8" width="12" height="12" rx="2" /><path d="M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" /></g>,+ Date: <g><rect x="3" y="5" width="18" height="16" rx="2.5" /><path d="M8 3v4M16 3v4M3 10h18" /></g>,+};++const TOOL_GLYPHS: Record<string, React.ReactNode> = {+ model: <path d="M12 3l1.7 5.1a2 2 0 0 0 1.2 1.2L20 11l-5.1 1.7a2 2 0 0 0-1.2 1.2L12 19l-1.7-5.1a2 2 0 0 0-1.2-1.2L4 11l5.1-1.7a2 2 0 0 0 1.2-1.2z" />,+ web: <g><circle cx="12" cy="12" r="9" /><path d="M3 12h18M12 3a13.5 13.5 0 0 1 3.5 9 13.5 13.5 0 0 1-3.5 9 13.5 13.5 0 0 1-3.5-9A13.5 13.5 0 0 1 12 3z" /></g>,+ user: <g><circle cx="12" cy="8" r="4" /><path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1" /></g>,+};++/* per-property configuration shown in the popover */+type Prompt = { before: string; chip?: string; after?: string };+type ToolKind = "model" | "web" | "user";+type ColumnMeta = { type: string; tool: string; toolKind: ToolKind; inputs?: string; prompt?: Prompt };++const COLUMN_META: Record<string, ColumnMeta> = {+ Company: { type: "Text", tool: "User input", toolKind: "user" },+ Categories: { type: "Multi select", tool: "Sprinkles 5", toolKind: "model", inputs: "Company", prompt: { before: "Tag each ", chip: "Company", after: " with its market categories." } },+ "Last interaction": { type: "Date", tool: "User input", toolKind: "user" },+ "Connection strength": { type: "Single select", tool: "Sprinkles 5", toolKind: "model", inputs: "Last interaction", prompt: { before: "Score the relationship from ", chip: "Last interaction", after: "." } },+ Links: { type: "URL", tool: "Web search", toolKind: "web", inputs: "Company", prompt: { before: "Find the website for ", chip: "Company", after: "." } },+ [AI_LABEL]: { type: "Text", tool: "Web search", toolKind: "web", inputs: "Company", prompt: { before: "Find competitors for ", chip: "Company" } },+};++const NEW_PROPERTY_TYPES = ["Text", "File", "Collection", "Single select", "Multi select", "URL", "Reference", "JSON", "File splitter"];+const MODEL_OPTIONS = ["Sprinkles 5", "Sprinkles 4.2", "Sprinkles Mini"];+const INPUT_OPTIONS = ["Company", "Categories", "Last interaction", "Connection strength", "Links"];++function Checkbox({ checked, mixed = false, onChange, label }: { checked: boolean; mixed?: boolean; onChange: () => void; label: string }) {+ return (+ <label className="records-checkbox" title={label} onClick={(event) => event.stopPropagation()}>+ <input type="checkbox" checked={checked} onChange={onChange} aria-label={label} />+ <span className={`records-checkbox-box ${checked || mixed ? "is-active" : ""}`}>+ {mixed ? <span className="records-checkbox-dash" /> : checked ? <Icon size={12}><path d="m5 12 4 4L19 6" /></Icon> : null}+ </span>+ </label>+ );+}++function Tag({ name }: { name: string }) {+ const color = TAG_COLORS[name] ?? { base: "var(--ink-3)" };+ return (+ <span+ className="records-tag"+ style={{ "--tag-base": color.base } as React.CSSProperties}+ >+ {name}+ </span>+ );+}++function TagList({ tags }: { tags: string[] }) {+ const containerRef = useRef<HTMLDivElement>(null);+ const measureRef = useRef<HTMLDivElement>(null);+ const [visibleCount, setVisibleCount] = useState(tags.length);++ useLayoutEffect(() => {+ const container = containerRef.current;+ const measure = measureRef.current;+ if (!container || !measure) return;++ const update = () => {+ const available = container.clientWidth;+ const tagWidths = Array.from(measure.querySelectorAll<HTMLElement>("[data-tag-measure]"), (tag) => tag.offsetWidth);+ const moreWidth = measure.querySelector<HTMLElement>("[data-more-measure]")?.offsetWidth ?? 0;+ let used = 0;+ let count = 0;++ for (let index = 0; index < tagWidths.length; index += 1) {+ const nextUsed = used + (count > 0 ? 4 : 0) + tagWidths[index];+ const hiddenAfter = tags.length - (index + 1);+ const totalWithOverflow = nextUsed + (hiddenAfter > 0 ? 4 + moreWidth : 0);+ if (totalWithOverflow > available) break;+ used = nextUsed;+ count += 1;+ }++ setVisibleCount(count);+ };++ update();+ const observer = new ResizeObserver(update);+ observer.observe(container);+ return () => observer.disconnect();+ }, [tags]);++ const hiddenCount = tags.length - visibleCount;++ return (+ <div ref={containerRef} className="records-tags" title={tags.join(", ")} aria-label={`Categories: ${tags.join(", ")}`}>+ <div ref={measureRef} className="records-tags-measure" aria-hidden>+ {tags.map((tag) => <span key={tag} data-tag-measure><Tag name={tag} /></span>)}+ <span data-more-measure className="records-more-tag">+{tags.length}</span>+ </div>+ {tags.slice(0, visibleCount).map((tag) => <Tag key={tag} name={tag} />)}+ {hiddenCount > 0 && <span className="records-more-tag">+{hiddenCount}</span>}+ </div>+ );+}++function CalcCell() {+ return (+ <span className="records-calc">+ <span className="records-muted">Calculating…</span>+ <span className="records-pulse" />+ </span>+ );+}++function MiniSwitch({ on, onToggle, label }: { on: boolean; onToggle: () => void; label: string }) {+ return (+ <button+ type="button"+ role="switch"+ aria-checked={on}+ aria-label={label}+ onClick={onToggle}+ className="relative h-4.5 w-7.5 shrink-0 rounded-full transition-colors duration-150"+ style={{ background: on ? "var(--accent)" : "var(--line-strong)" }}+ >+ <span+ className="absolute top-0.5 left-0.5 size-3.5 rounded-full bg-white shadow-btn transition-transform duration-150"+ style={{ transform: on ? "translateX(12px)" : "translateX(0)", transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)" }}+ />+ </button>+ );+}++function HeaderCell({ label, icon, sortKey, sort, onSort, onResizeStart, resizing = false, className = "", selected = false, onPick }: { label: string; icon: React.ReactNode; sortKey?: SortKey; sort: { key: SortKey; dir: 1 | -1 }; onSort: (key: SortKey) => void; onResizeStart: (event: React.PointerEvent<HTMLSpanElement>) => void; resizing?: boolean; className?: string; selected?: boolean; onPick?: (event: React.MouseEvent) => void }) {+ return (+ <th className={`records-header-cell ${selected ? "is-colsel" : ""} ${className}`}>+ {/* header click opens the property config; the arrow sorts */}+ <button type="button" className="records-header-button" onClick={onPick}>+ <span className="records-header-icon">{icon}</span>+ <span className="truncate">{label}</span>+ {sortKey && (+ <span+ role="button"+ tabIndex={0}+ aria-label={`Sort by ${label}`}+ onClick={(event) => {+ event.stopPropagation();+ onSort(sortKey);+ }}+ onKeyDown={(event) => {+ if (event.key === "Enter" || event.key === " ") {+ event.preventDefault();+ event.stopPropagation();+ onSort(sortKey);+ }+ }}+ className={`records-sort ${sort.key === sortKey ? "is-visible" : ""}`}+ style={{ transform: sort.key === sortKey && sort.dir === -1 ? "rotate(180deg)" : undefined }}+ >+ <Icon size={12}><path d="M12 5v14M5 12l7 7 7-7" /></Icon>+ </span>+ )}+ </button>+ <span+ role="separator"+ aria-orientation="vertical"+ aria-label={`Resize ${label} column`}+ className={`records-resize-handle ${resizing ? "is-resizing" : ""}`}+ onPointerDown={onResizeStart}+ />+ </th>+ );+}++/* config row inside the property popover */+function ConfigRow({ label, children }: { label: string; children: React.ReactNode }) {+ return (+ <div className="relative flex h-8 items-center justify-between">+ <span className="text-[13px] text-ink-3">{label}</span>+ {children}+ </div>+ );+}++function ConfigPicker({+ label,+ options,+ selected,+ onSelect,+}: {+ label: string;+ options: { label: string; icon: React.ReactNode }[];+ selected: string;+ onSelect: (value: string) => void;+}) {+ return (+ <div+ role="menu"+ aria-label={label}+ className="absolute left-full top-0 z-30 ml-5 w-[210px] rounded-[12px] bg-surface p-1.5 shadow-overlay"+ style={{ animation: "pop-in 140ms cubic-bezier(0.23,1,0.32,1) both", transformOrigin: "top left" }}+ >+ <div className="px-2 pb-1 pt-0.5 text-[11.5px] font-medium text-ink-3">{label}</div>+ <GlideMenu className="flex flex-col gap-px">+ {options.map((option) => (+ <button+ key={option.label}+ data-menu-row+ type="button"+ role="menuitemradio"+ aria-checked={selected === option.label}+ onClick={() => onSelect(option.label)}+ className="relative z-10 flex h-8 w-full items-center gap-1.5 rounded-[8px] px-1.5 text-left text-[13px] font-medium text-ink"+ >+ <span className="flex size-4 shrink-0 items-center justify-center text-ink-2">{option.icon}</span>+ <span className="min-w-0 flex-1 truncate">{option.label}</span>+ <span className={selected === option.label ? "text-ink" : "invisible"}>+ <Icon size={14} strokeWidth={2.2}><path d="m5 12 4 4L19 6" /></Icon>+ </span>+ </button>+ ))}+ </GlideMenu>+ </div>+ );+}++function InputPicker({+ options,+ selected,+ onToggle,+}: {+ options: string[];+ selected: string[];+ onToggle: (value: string) => void;+}) {+ return (+ <div+ role="menu"+ aria-label="Calculation inputs"+ className="absolute left-full top-0 z-30 ml-5 w-[220px] rounded-[12px] bg-surface p-1.5 shadow-overlay"+ style={{ animation: "pop-in 140ms cubic-bezier(0.23,1,0.32,1) both", transformOrigin: "top left" }}+ >+ <div className="px-2 pb-1 pt-0.5 text-[11.5px] font-medium text-ink-3">Use values from</div>+ <GlideMenu className="flex flex-col gap-px">+ {options.map((option) => {+ const checked = selected.includes(option);+ return (+ <button+ key={option}+ data-menu-row+ type="button"+ role="menuitemcheckbox"+ aria-checked={checked}+ onClick={() => onToggle(option)}+ className="relative z-10 flex h-8 w-full items-center gap-1.5 rounded-[8px] px-1.5 text-left text-[13px] font-medium text-ink"+ >+ <span className={`flex size-4 shrink-0 items-center justify-center rounded-[5px] border ${checked ? "border-accent bg-accent text-white" : "border-line-strong text-transparent"}`}>+ <Icon size={11} strokeWidth={2.4}><path d="m5 12 4 4L19 6" /></Icon>+ </span>+ <span className="min-w-0 flex-1 truncate">{option}</span>+ </button>+ );+ })}+ </GlideMenu>+ </div>+ );+}++export default function RecordsTable({ fill = false }: { fill?: boolean; variant?: string }) {+ const rows = INITIAL_ROWS;+ const [selected, setSelected] = useState<Set<string>>(new Set());+ const [sort, setSort] = useState<{ key: SortKey; dir: 1 | -1 }>({ key: "name", dir: 1 });+ const [columnWidths, setColumnWidths] = useState(DEFAULT_COLUMN_WIDTHS);+ const [actionColumnWidth, setActionColumnWidth] = useState(100);+ const [columnWidthsLocked, setColumnWidthsLocked] = useState(false);+ const [resizingColumn, setResizingColumn] = useState<ColumnKey | null>(null);+ const initialColumnWidthsRef = useRef<Record<ColumnKey, number> | null>(null);+ const tableRef = useRef<HTMLTableElement>(null);++ /* property popover, anchored to the clicked header */+ const [prop, setProp] = useState<{ col: string; x: number; y: number } | null>(null);+ const [grounding, setGrounding] = useState(false);+ const [groundingHelpOpen, setGroundingHelpOpen] = useState(false);+ const [configMenu, setConfigMenu] = useState<"type" | "tool" | "inputs" | null>(null);+ const [columnOverrides, setColumnOverrides] = useState<Record<string, Partial<ColumnMeta>>>({});+ const [inputSelections, setInputSelections] = useState<Record<string, string[]>>({});+ const [pinnedColumns, setPinnedColumns] = useState<Set<string>>(new Set());+ const [moreSettingsOpen, setMoreSettingsOpen] = useState(false);+ const [advancedSettings, setAdvancedSettings] = useState({ required: false, allowEmpty: true, confidence: false });+ /* + new-property menu */+ const [addOpen, setAddOpen] = useState<{ x: number; y: number } | null>(null);+ const [tableMenuOpen, setTableMenuOpen] = useState<{ x: number; y: number } | null>(null);+ /* the added AI column and its lifecycle */+ const [aiAdded, setAiAdded] = useState(false);+ const [aiDone, setAiDone] = useState(false);+ const [pendingOpenAi, setPendingOpenAi] = useState(false);+ const aiThRef = useRef<HTMLTableCellElement>(null);+ /* programmatic scrolls (revealing the new column) shouldn't close popovers */+ const ignoreScrollRef = useRef(false);+ /* a running calculation resolves rows one by one */+ const [calc, setCalc] = useState<{ col: string; resolved: number } | null>(null);++ /* Let the table fill its available space once, then capture those rendered+ * widths before paint. From that point on every column is explicit, so a+ * resize changes only the dragged column and the table's total width. */+ useLayoutEffect(() => {+ if (columnWidthsLocked || !tableRef.current) return;+ const headers = Array.from(tableRef.current.querySelectorAll<HTMLTableCellElement>("thead th"));+ if (headers.length < 6) return;++ const measured: Record<ColumnKey, number> = {+ company: headers[0].getBoundingClientRect().width,+ categories: headers[1].getBoundingClientRect().width,+ last: headers[2].getBoundingClientRect().width,+ strength: headers[3].getBoundingClientRect().width,+ links: headers[4].getBoundingClientRect().width,+ ai: DEFAULT_COLUMN_WIDTHS.ai,+ };+ initialColumnWidthsRef.current = measured;+ setColumnWidths(measured);+ setActionColumnWidth(headers[headers.length - 1].getBoundingClientRect().width);+ setColumnWidthsLocked(true);+ }, [columnWidthsLocked]);++ const visibleRows = useMemo(() => {+ return [...rows].sort((a, b) => {+ const value = sort.key === "name"+ ? a.name.localeCompare(b.name)+ : sort.key === "last"+ ? a.last.localeCompare(b.last)+ : STRENGTH[a.strength].rank - STRENGTH[b.strength].rank;+ return value * sort.dir;+ });+ }, [sort]);++ /* stagger: one row resolves every beat */+ useEffect(() => {+ if (!calc) return;+ if (calc.resolved > visibleRows.length) {+ if (calc.col === AI_LABEL) setAiDone(true);+ setCalc(null);+ return;+ }+ const t = setTimeout(() => setCalc((current) => (current ? { ...current, resolved: current.resolved + 1 } : current)), 110);+ return () => clearTimeout(t);+ }, [calc, visibleRows.length]);++ /* after adding the AI column, scroll it into view and open its config+ * anchored to the new header */+ useEffect(() => {+ if (!pendingOpenAi || !aiThRef.current) return;+ const scroller = aiThRef.current.closest(".records-scroll");+ if (scroller) {+ ignoreScrollRef.current = true;+ scroller.scrollLeft = scroller.scrollWidth;+ }+ const rect = aiThRef.current.getBoundingClientRect();+ setProp({ col: AI_LABEL, x: Math.min(rect.left, window.innerWidth - 336), y: rect.bottom + 6 });+ setPendingOpenAi(false);+ }, [pendingOpenAi, aiAdded]);++ /* click anywhere else closes popovers */+ useEffect(() => {+ if (!prop && !addOpen && !tableMenuOpen) return;+ const close = (event: PointerEvent) => {+ if (!(event.target as Element).closest("[data-recpop]")) {+ setProp(null);+ setConfigMenu(null);+ setGroundingHelpOpen(false);+ setMoreSettingsOpen(false);+ setAddOpen(null);+ setTableMenuOpen(null);+ }+ };+ document.addEventListener("pointerdown", close);+ return () => document.removeEventListener("pointerdown", close);+ }, [prop, addOpen, tableMenuOpen]);++ const openProp = (col: string) => (event: React.MouseEvent) => {+ const th = (event.currentTarget as Element).closest("th");+ if (!th) return;+ setAddOpen(null);+ setTableMenuOpen(null);+ setConfigMenu(null);+ setGroundingHelpOpen(false);+ setMoreSettingsOpen(false);+ setProp((current) => {+ if (current?.col === col) return null;+ const rect = th.getBoundingClientRect();+ return { col, x: Math.min(rect.left, window.innerWidth - 336), y: rect.bottom + 6 };+ });+ };++ const isCalc = (col: string, index: number) => !!calc && calc.col === col && index >= calc.resolved;++ const allSelected = visibleRows.length > 0 && visibleRows.every((row) => selected.has(row.id));+ const partiallySelected = !allSelected && visibleRows.some((row) => selected.has(row.id));++ const toggleSort = (key: SortKey) => setSort((current) => current.key === key ? { key, dir: (current.dir * -1) as 1 | -1 } : { key, dir: 1 });+ const startColumnResize = (key: ColumnKey, minWidth = 120) => (event: React.PointerEvent<HTMLSpanElement>) => {+ event.preventDefault();+ event.stopPropagation();+ setProp(null);+ setConfigMenu(null);+ setGroundingHelpOpen(false);+ setMoreSettingsOpen(false);+ setAddOpen(null);+ setTableMenuOpen(null);++ const startX = event.clientX;+ const startWidth = columnWidths[key];+ const previousCursor = document.body.style.cursor;+ const previousSelection = document.body.style.userSelect;+ document.body.style.cursor = "col-resize";+ document.body.style.userSelect = "none";+ setResizingColumn(key);++ const move = (moveEvent: PointerEvent) => {+ const width = Math.max(minWidth, startWidth + moveEvent.clientX - startX);+ setColumnWidths((current) => ({ ...current, [key]: width }));+ };+ const finish = () => {+ window.removeEventListener("pointermove", move);+ window.removeEventListener("pointerup", finish);+ window.removeEventListener("pointercancel", finish);+ document.body.style.cursor = previousCursor;+ document.body.style.userSelect = previousSelection;+ setResizingColumn(null);+ };++ window.addEventListener("pointermove", move);+ window.addEventListener("pointerup", finish);+ window.addEventListener("pointercancel", finish);+ };+ const toggleRow = (id: string) => setSelected((current) => {+ const next = new Set(current);+ next.has(id) ? next.delete(id) : next.add(id);+ return next;+ });+ const toggleAll = () => setSelected((current) => {+ const next = new Set(current);+ if (allSelected) visibleRows.forEach((row) => next.delete(row.id));+ else visibleRows.forEach((row) => next.add(row.id));+ return next;+ });++ const meta = prop ? { ...COLUMN_META[prop.col], ...columnOverrides[prop.col] } : null;+ const selectedInputs = prop && meta+ ? inputSelections[prop.col] ?? (meta.inputs ? [meta.inputs] : [])+ : [];+ const tableWidth = columnWidths.company + columnWidths.categories + columnWidths.last + columnWidths.strength + columnWidths.links + (aiAdded ? columnWidths.ai : 0) + actionColumnWidth;++ return (+ <div className={`records-shell${fill ? " is-fill" : ""}`}>+ <div+ className="records-scroll"+ tabIndex={0}+ aria-label="Companies table. Scroll horizontally and vertically to view all columns and records."+ onScroll={() => {+ if (ignoreScrollRef.current) {+ ignoreScrollRef.current = false;+ return;+ }+ setProp(null);+ setConfigMenu(null);+ setGroundingHelpOpen(false);+ setMoreSettingsOpen(false);+ setAddOpen(null);+ setTableMenuOpen(null);+ }}+ >+ <table ref={tableRef} className="records-table" style={{ width: columnWidthsLocked ? tableWidth : "100%", minWidth: tableWidth }}>+ <colgroup>+ <col className="records-company-col" style={{ width: columnWidths.company }} />+ <col className="records-category-col" style={{ width: columnWidths.categories }} />+ <col className="records-last-col" style={{ width: columnWidths.last }} />+ <col className="records-strength-col" style={{ width: columnWidths.strength }} />+ <col className="records-link-col" style={{ width: columnWidths.links }} />+ {aiAdded && <col style={{ width: columnWidths.ai }} />}+ <col style={{ width: 100 }} />+ </colgroup>+ <thead>+ <tr>+ <th className={`records-header-cell records-sticky-cell ${prop?.col === "Company" ? "is-colsel" : ""}`}>+ <div className="records-company-header" style={{ cursor: "pointer" }} onClick={(event) => openProp("Company")(event)}>+ <Checkbox checked={allSelected} mixed={partiallySelected} onChange={toggleAll} label="Select all companies" />+ <span>Company</span>+ </div>+ <span role="separator" aria-orientation="vertical" aria-label="Resize Company column" className={`records-resize-handle ${resizingColumn === "company" ? "is-resizing" : ""}`} onPointerDown={startColumnResize("company", 180)} />+ </th>+ <HeaderCell label="Categories" selected={prop?.col === "Categories"} onPick={openProp("Categories")} sort={sort} onSort={toggleSort} onResizeStart={startColumnResize("categories")} resizing={resizingColumn === "categories"} icon={<Icon size={15}>{TYPE_GLYPHS["Multi select"]}</Icon>} />+ <HeaderCell label="Last interaction" selected={prop?.col === "Last interaction"} onPick={openProp("Last interaction")} sortKey="last" sort={sort} onSort={toggleSort} onResizeStart={startColumnResize("last")} resizing={resizingColumn === "last"} icon={<Icon size={15}>{TYPE_GLYPHS.Date}</Icon>} />+ <HeaderCell label="Connection strength" selected={prop?.col === "Connection strength"} onPick={openProp("Connection strength")} sortKey="strength" sort={sort} onSort={toggleSort} onResizeStart={startColumnResize("strength")} resizing={resizingColumn === "strength"} icon={<Icon size={15}>{TYPE_GLYPHS["Single select"]}</Icon>} />+ <HeaderCell label="Links" selected={prop?.col === "Links"} onPick={openProp("Links")} sort={sort} onSort={toggleSort} onResizeStart={startColumnResize("links")} resizing={resizingColumn === "links"} icon={<Icon size={15}>{TYPE_GLYPHS.URL}</Icon>} />+ {aiAdded && (+ <th ref={aiThRef} className={`records-header-cell ${prop?.col === AI_LABEL ? "is-colsel" : ""}`}>+ <button type="button" className="records-header-button" onClick={openProp(AI_LABEL)}>+ <span className="records-header-icon"><Icon size={15}>{TYPE_GLYPHS.Text}</Icon></span>+ <span className="truncate">{AI_LABEL}</span>+ </button>+ <span role="separator" aria-orientation="vertical" aria-label={`Resize ${AI_LABEL} column`} className={`records-resize-handle ${resizingColumn === "ai" ? "is-resizing" : ""}`} onPointerDown={startColumnResize("ai")} />+ </th>+ )}+ <th className="records-header-cell">+ <div className="flex h-[35px] items-center gap-1 px-2">+ <button+ type="button"+ aria-label="New property"+ data-recpop+ onClick={(event) => {+ setProp(null);+ setTableMenuOpen(null);+ const rect = (event.currentTarget as Element).getBoundingClientRect();+ setAddOpen((current) => (current ? null : { x: Math.min(rect.left, window.innerWidth - 276), y: rect.bottom + 6 }));+ }}+ className="flex size-7 items-center justify-center rounded-[7px] text-ink-2 transition-colors duration-100 hover:bg-hover hover:text-ink"+ >+ <Icon size={15} strokeWidth={2}><path d="M12 5v14M5 12h14" /></Icon>+ </button>+ <button+ type="button"+ aria-label="Table options"+ aria-expanded={!!tableMenuOpen}+ data-recpop+ onClick={(event) => {+ setProp(null);+ setAddOpen(null);+ const rect = event.currentTarget.getBoundingClientRect();+ setTableMenuOpen((current) => current ? null : {+ x: Math.max(8, Math.min(rect.right - 220, window.innerWidth - 228)),+ y: rect.bottom + 6,+ });+ }}+ className="flex size-7 items-center justify-center rounded-[7px] text-ink-3 transition-colors duration-100 hover:bg-hover hover:text-ink"+ >+ <svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor" aria-hidden><circle cx="5" cy="12" r="1.6" /><circle cx="12" cy="12" r="1.6" /><circle cx="19" cy="12" r="1.6" /></svg>+ </button>+ </div>+ </th>+ </tr>+ </thead>+ {/* data cells stay silent — the papery link/flick sound is too much when scanning rows */}+ <tbody data-cuelume-silent>+ {visibleRows.map((row, index) => {+ const selectedRow = selected.has(row.id);+ const strength = STRENGTH[row.strength];+ return <tr key={row.id} className={`records-row ${selectedRow ? "is-selected" : ""}`}>+ <td className={`records-cell records-sticky-cell records-company-cell ${prop?.col === "Company" ? "is-colsel" : ""}`}><span className="records-rownum">{index + 1}</span><Checkbox checked={selectedRow} onChange={() => toggleRow(row.id)} label={`Select ${row.name}`} /><span className="records-company-mark">{row.name.slice(0, 1).toUpperCase()}</span><a href={row.website ? `https://${row.website}` : "#"} onClick={(event) => !row.website && event.preventDefault()} title={row.name} className={`records-company-name ${row.website ? "has-link" : ""}`}>{row.name}</a></td>+ <td className={`records-cell ${prop?.col === "Categories" ? "is-colsel" : ""}`}>{isCalc("Categories", index) ? <CalcCell /> : <TagList tags={row.tags} />}</td>+ <td className={`records-cell ${row.last === "No contact" ? "records-muted" : ""} ${prop?.col === "Last interaction" ? "is-colsel" : ""}`}>{isCalc("Last interaction", index) ? <CalcCell /> : row.last}</td>+ <td className={`records-cell ${prop?.col === "Connection strength" ? "is-colsel" : ""}`}>{isCalc("Connection strength", index) ? <CalcCell /> : <span className="records-strength"><span className="records-strength-dot" style={{ background: strength.color }} />{strength.label}</span>}</td>+ <td className={`records-cell ${prop?.col === "Links" ? "is-colsel" : ""}`}>{isCalc("Links", index) ? <CalcCell /> : row.website ? <a className="records-link" href={`https://${row.website}`} title={row.website} target="_blank" rel="noreferrer"><span className="records-link-label">{row.website}</span><Icon size={12}><path d="M14 5h5v5M19 5l-8 8" /></Icon></a> : <span className="records-muted">—</span>}</td>+ {aiAdded && (+ <td className={`records-cell ${prop?.col === AI_LABEL ? "is-colsel" : ""}`}>+ {calc?.col === AI_LABEL ? (index < calc.resolved ? competitorsFor(index) : <CalcCell />) : aiDone ? competitorsFor(index) : <span className="records-muted">—</span>}+ </td>+ )}+ <td className="records-cell" />+ </tr>;+ })}+ </tbody>+ <tfoot>+ <tr className="records-calculation-row">+ <td className="records-cell records-sticky-cell">+ <span className="records-footer-value records-calculation-label"><span className="records-calculation-number">{rows.length}</span> count</span>+ </td>+ <td className="records-cell">+ <button type="button" className="records-add-calculation"><Icon size={15}><path d="M12 5v14M5 12h14" /></Icon>Add calculation</button>+ </td>+ <td className="records-cell records-muted"><span className="records-footer-value">—</span></td>+ <td className="records-cell">+ <span className="records-footer-value records-average"><span className="records-strength-dot" style={{ background: "var(--orange)" }} />{Math.round(rows.reduce((sum, row) => sum + STRENGTH[row.strength].rank, 0) / rows.length / 3 * 100)}% average</span>+ </td>+ <td className="records-cell"><span className="records-footer-value records-muted">{rows.filter((row) => row.website).length} links</span></td>+ {aiAdded && <td className="records-cell records-muted"><span className="records-footer-value">{aiDone ? `${rows.length} filled` : "—"}</span></td>}+ <td className="records-cell" />+ </tr>+ </tfoot>+ </table>+ </div>++ {/* ── property configuration popover ─────────────────── */}+ {prop && meta && (+ <div+ data-recpop+ className="fixed z-50 w-[320px] rounded-[14px] bg-surface px-3 pt-3 pb-1.5 shadow-overlay"+ style={{ top: prop.y, left: prop.x, animation: "pop-in 160ms cubic-bezier(0.23,1,0.32,1) both", transformOrigin: "top left" }}+ >+ <div className="pb-2 text-[13.5px] font-medium text-ink">{prop.col}</div>++ <ConfigRow label="Type">+ <button+ type="button"+ aria-haspopup="menu"+ aria-expanded={configMenu === "type"}+ onClick={() => setConfigMenu((current) => current === "type" ? null : "type")}+ className="flex items-center gap-1.5 rounded-[6px] px-1.5 py-1 text-[13px] font-medium text-ink transition-colors duration-100 hover:bg-hover"+ >+ <span className="text-ink-2"><Icon size={14}>{TYPE_GLYPHS[meta.type] ?? TYPE_GLYPHS.Text}</Icon></span>+ {meta.type}+ <span className="text-ink-3"><Icon size={12} strokeWidth={2.2}><path d="M9 6l6 6-6 6" /></Icon></span>+ </button>+ {configMenu === "type" && (+ <ConfigPicker+ label="Property type"+ selected={meta.type}+ options={NEW_PROPERTY_TYPES.map((type) => ({ label: type, icon: <Icon size={15}>{TYPE_GLYPHS[type]}</Icon> }))}+ onSelect={(type) => {+ setColumnOverrides((current) => ({ ...current, [prop.col]: { ...current[prop.col], type } }));+ setConfigMenu(null);+ }}+ />+ )}+ </ConfigRow>+ <ConfigRow label="Tool">+ <button+ type="button"+ aria-haspopup="menu"+ aria-expanded={configMenu === "tool"}+ onClick={() => setConfigMenu((current) => current === "tool" ? null : "tool")}+ className="flex items-center gap-1.5 rounded-[6px] px-1.5 py-1 text-[13px] font-medium text-ink transition-colors duration-100 hover:bg-hover"+ >+ <span className={meta.toolKind === "model" ? "text-accent" : "text-ink-2"}>+ {meta.toolKind === "model"+ ? <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden>{TOOL_GLYPHS.model}</svg>+ : <Icon size={14}>{TOOL_GLYPHS[meta.toolKind]}</Icon>}+ </span>+ {meta.tool}+ <span className="text-ink-3"><Icon size={12} strokeWidth={2.2}><path d="M9 6l6 6-6 6" /></Icon></span>+ </button>+ {configMenu === "tool" && (+ <ConfigPicker+ label="Model"+ selected={meta.tool}+ options={MODEL_OPTIONS.map((model) => ({+ label: model,+ icon: <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden>{TOOL_GLYPHS.model}</svg>,+ }))}+ onSelect={(tool) => {+ setColumnOverrides((current) => ({ ...current, [prop.col]: { ...current[prop.col], tool, toolKind: "model" } }));+ setConfigMenu(null);+ }}+ />+ )}+ </ConfigRow>+ <ConfigRow label="Grounding">+ <span className="flex items-center gap-2">+ <MiniSwitch label="Grounding" on={grounding} onToggle={() => setGrounding((current) => !current)} />+ <button+ type="button"+ aria-label="About grounding"+ aria-expanded={groundingHelpOpen}+ onClick={() => setGroundingHelpOpen((open) => !open)}+ className="flex size-6 items-center justify-center rounded-[6px] text-ink-3 transition-colors duration-100 hover:bg-hover hover:text-ink"+ >+ <Icon size={13}><g><circle cx="12" cy="12" r="9" /><path d="M12 8h.01M11 12h1v4h1" /></g></Icon>+ </button>+ </span>+ {groundingHelpOpen && (+ <div className="absolute right-0 top-[30px] z-30 w-[230px] rounded-[10px] px-3 py-2.5 text-[12px] leading-relaxed shadow-overlay" style={{ color: "var(--tooltip-fg)", background: "var(--tooltip-bg)" }} role="status">+ Grounding lets the model verify generated values against connected sources.+ </div>+ )}+ </ConfigRow>+ <ConfigRow label="Inputs">+ <button+ type="button"+ aria-haspopup="menu"+ aria-expanded={configMenu === "inputs"}+ onClick={() => setConfigMenu((current) => current === "inputs" ? null : "inputs")}+ className="flex max-w-[220px] items-center gap-1.5 rounded-[6px] px-1.5 py-1 text-[13px] text-ink-2 transition-colors duration-100 hover:bg-hover hover:text-ink"+ >+ {selectedInputs.length ? (+ <span className="flex min-w-0 items-center gap-1">+ {selectedInputs.slice(0, 2).map((input) => (+ <span key={input} className="max-w-[92px] truncate rounded-[5px] bg-accent-tint px-1.5 py-0.5 text-[12px] font-medium text-accent-ink">{input}</span>+ ))}+ {selectedInputs.length > 2 && <span className="text-[11px] font-medium text-ink-3">+{selectedInputs.length - 2}</span>}+ </span>+ ) : (+ <span>Select inputs</span>+ )}+ <span className="shrink-0 text-ink-3"><Icon size={12} strokeWidth={2.2}><path d="M9 6l6 6-6 6" /></Icon></span>+ </button>+ {configMenu === "inputs" && (+ <InputPicker+ selected={selectedInputs}+ options={INPUT_OPTIONS.filter((input) => input !== prop.col)}+ onToggle={(input) => {+ setInputSelections((current) => {+ const existing = current[prop.col] ?? (meta.inputs ? [meta.inputs] : []);+ const next = existing.includes(input) ? existing.filter((item) => item !== input) : [...existing, input];+ return { ...current, [prop.col]: next };+ });+ }}+ />+ )}+ </ConfigRow>++ {/* prompt — @-mention chips inline */}+ <div+ contentEditable+ suppressContentEditableWarning+ role="textbox"+ aria-label={`${prop.col} calculation prompt`}+ aria-multiline="true"+ spellCheck+ className="mt-2 min-h-[88px] cursor-text rounded-[10px] bg-inset p-3 text-[13px] leading-relaxed shadow-hairline outline-none transition-[box-shadow] duration-150 focus:shadow-[0_0_0_2px_var(--accent)]"+ >+ {meta.prompt ? (+ <span className="text-ink">+ {meta.prompt.before}+ {meta.prompt.chip && <span contentEditable={false} className="rounded-[5px] bg-accent-tint px-1.5 py-0.5 text-[12px] font-medium text-accent-ink">{meta.prompt.chip}</span>}+ {meta.prompt.after}+ </span>+ ) : (+ <span className="text-ink-3">Set a prompt (press @ to mention an input)</span>+ )}+ </div>++ <button+ type="button"+ disabled={!!calc}+ onClick={() => {+ setCalc({ col: prop.col, resolved: 0 });+ setProp(null);+ }}+ className="mt-2.5 flex h-9 w-full items-center justify-center gap-2 rounded-[9px] text-[12.5px] font-medium text-ink shadow-btn transition-[background-color,transform] duration-150 hover:bg-hover active:scale-[0.98] disabled:opacity-60"+ >+ <Icon size={14} strokeWidth={1.9}><path d="M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6" /></Icon>+ Go calculate+ </button>++ <GlideMenu className="mt-3 flex flex-col gap-0.5 border-t border-line pt-2" highlightClassName="-inset-x-1.5 rounded-[8px] bg-hover">+ <button+ data-menu-row+ type="button"+ aria-pressed={pinnedColumns.has(prop.col)}+ onClick={() => setPinnedColumns((current) => {+ const next = new Set(current);+ next.has(prop.col) ? next.delete(prop.col) : next.add(prop.col);+ return next;+ })}+ className="relative z-10 -mx-1.5 flex h-8 items-center gap-2.5 rounded-[8px] px-1.5 text-left text-[13px] leading-none text-ink transition-transform duration-150 active:scale-[0.96]"+ >+ <span className={pinnedColumns.has(prop.col) ? "text-accent" : "text-ink-2"}><Icon size={15}><path d="M12 17v5M8 3h8l-1 7 3 3H6l3-3-1-7z" /></Icon></span>+ {pinnedColumns.has(prop.col) ? "Unpin" : "Pin"}+ </button>+ <button+ data-menu-row+ type="button"+ aria-expanded={moreSettingsOpen}+ onClick={() => setMoreSettingsOpen((open) => !open)}+ className="relative z-10 -mx-1.5 flex h-8 items-center gap-2.5 rounded-[8px] px-1.5 text-left text-[13px] leading-none text-ink transition-transform duration-150 active:scale-[0.96]"+ >+ <span className={moreSettingsOpen ? "text-ink" : "text-ink-2"}><Icon size={15}><g><circle cx="12" cy="12" r="3" /><path d="M12 2v3M12 19v3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M2 12h3M19 12h3M4.9 19.1 7 17M17 7l2.1-2.1" /></g></Icon></span>+ <span className="flex-1">More settings</span>+ <span className={`text-ink-3 transition-transform duration-150 ${moreSettingsOpen ? "rotate-90" : ""}`}><Icon size={12} strokeWidth={2.2}><path d="M9 6l6 6-6 6" /></Icon></span>+ </button>+ {prop.col === AI_LABEL && (+ <button+ data-menu-row+ type="button"+ onClick={() => {+ setAiAdded(false);+ setAiDone(false);+ setProp(null);+ }}+ className="relative z-10 -mx-1.5 flex h-8 items-center gap-2.5 rounded-[8px] px-1.5 text-left text-[13px] leading-none text-ink transition-transform duration-150 active:scale-[0.96]"+ >+ <span className="text-ink-2"><Icon size={15}><g><path d="M10.6 5.1A9.8 9.8 0 0 1 12 5c7 0 10 7 10 7a16.3 16.3 0 0 1-2.1 3M6.6 6.6A16 16 0 0 0 2 12s3 7 10 7a9.7 9.7 0 0 0 5.4-1.6M3 3l18 18" /><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2" /></g></Icon></span>+ Hide from view+ </button>+ )}+ </GlideMenu>++ {moreSettingsOpen && (+ <div className="mt-2 border-t border-line pt-2" style={{ animation: "fade-up 160ms cubic-bezier(0.23,1,0.32,1) both" }}>+ <div className="pb-1 text-[11.5px] font-medium text-ink-3">Behavior</div>+ <ConfigRow label="Required value">+ <MiniSwitch label="Required value" on={advancedSettings.required} onToggle={() => setAdvancedSettings((current) => ({ ...current, required: !current.required }))} />+ </ConfigRow>+ <ConfigRow label="Allow empty results">+ <MiniSwitch label="Allow empty results" on={advancedSettings.allowEmpty} onToggle={() => setAdvancedSettings((current) => ({ ...current, allowEmpty: !current.allowEmpty }))} />+ </ConfigRow>+ <ConfigRow label="Show confidence">+ <MiniSwitch label="Show confidence" on={advancedSettings.confidence} onToggle={() => setAdvancedSettings((current) => ({ ...current, confidence: !current.confidence }))} />+ </ConfigRow>+ </div>+ )}+ </div>+ )}++ {/* ── new property type menu ─────────────────────────── */}+ {addOpen && (+ <div+ data-recpop+ className="fixed z-50 w-[260px] rounded-[14px] bg-surface p-1.5 shadow-overlay"+ style={{ top: addOpen.y, left: addOpen.x, animation: "pop-in 160ms cubic-bezier(0.23,1,0.32,1) both", transformOrigin: "top left" }}+ >+ <div className="px-2 pb-1 pt-1 text-[12px] font-medium text-ink-3">New property</div>+ <GlideMenu className="flex flex-col gap-px">+ {NEW_PROPERTY_TYPES.map((type) => (+ <button+ key={type}+ data-menu-row+ type="button"+ onClick={() => {+ setAddOpen(null);+ setAiDone(false);+ setAiAdded(true);+ setPendingOpenAi(true);+ }}+ className="relative z-10 flex h-9 w-full items-center gap-2.5 rounded-[8px] px-2 text-left text-[13px] text-ink"+ >+ <span className="text-ink-2"><Icon size={15}>{TYPE_GLYPHS[type]}</Icon></span>+ {type}+ </button>+ ))}+ </GlideMenu>+ </div>+ )}++ {/* ── table options menu ─────────────────────────────── */}+ {tableMenuOpen && (+ <div+ data-recpop+ className="fixed z-50 w-[220px] rounded-[14px] bg-surface p-1.5 shadow-overlay"+ style={{ top: tableMenuOpen.y, left: tableMenuOpen.x, animation: "pop-in 160ms cubic-bezier(0.23,1,0.32,1) both", transformOrigin: "top right" }}+ >+ <div className="px-2 pb-1 pt-1 text-[12px] font-medium text-ink-3">Table options</div>+ <GlideMenu className="flex flex-col gap-px">+ <button+ data-menu-row+ type="button"+ onClick={() => {+ const position = tableMenuOpen;+ setTableMenuOpen(null);+ setAddOpen({ x: Math.min(position.x, window.innerWidth - 276), y: position.y });+ }}+ className="relative z-10 flex h-9 w-full items-center gap-2.5 rounded-[8px] px-2 text-left text-[13px] text-ink"+ >+ <span className="text-ink-2"><Icon size={15} strokeWidth={2}><path d="M12 5v14M5 12h14" /></Icon></span>+ Add property+ </button>+ <button+ data-menu-row+ type="button"+ onClick={() => {+ setColumnWidths({ company: 220, categories: 220, last: 155, strength: 180, links: 160, ai: 200 });+ setTableMenuOpen(null);+ }}+ className="relative z-10 flex h-9 w-full items-center gap-2.5 rounded-[8px] px-2 text-left text-[13px] text-ink"+ >+ <span className="text-ink-2"><Icon size={15}><path d="M4 8h16M7 4 3 8l4 4M17 4l4 4-4 4M4 16h16" /></Icon></span>+ Compact columns+ </button>+ <button+ data-menu-row+ type="button"+ onClick={() => {+ setColumnWidths({ ...(initialColumnWidthsRef.current ?? DEFAULT_COLUMN_WIDTHS) });+ setTableMenuOpen(null);+ }}+ className="relative z-10 flex h-9 w-full items-center gap-2.5 rounded-[8px] px-2 text-left text-[13px] text-ink"+ >+ <span className="text-ink-2"><Icon size={15}><path d="M3 12a9 9 0 1 0 3-6.7M3 4v6h6" /></Icon></span>+ Reset column widths+ </button>+ <div className="my-1 h-px bg-line" />+ <button+ data-menu-row+ type="button"+ onClick={() => {+ setSelected(new Set());+ setTableMenuOpen(null);+ }}+ className="relative z-10 flex h-9 w-full items-center gap-2.5 rounded-[8px] px-2 text-left text-[13px] text-ink"+ >+ <span className="text-ink-2"><Icon size={15}><path d="M5 5l14 14M19 5 5 19" /></Icon></span>+ Clear selection+ </button>+ </GlideMenu>+ </div>+ )}+ </div>+ );+}diff --git a/apps/native/components/primitives/SearchList.tsx b/apps/native/components/primitives/SearchList.tsxnew file mode 100644index 00000000..5c28b9f9--- /dev/null+++ b/apps/native/components/primitives/SearchList.tsx@@ -0,0 +1,93 @@+"use client";++import { useState } from "react";+import GlideMenu from "@/components/primitives/GlideMenu";++/* ─────────────────────────────────────────────────────────+ * SEARCH — command search with live filtering.+ * The field, clear action, and results are directly usable.+ * ───────────────────────────────────────────────────────── */++const ITEMS = [+ "Forecast summer demand",+ "Find waffle cone suppliers",+ "Compare seasonal flavors",+ "Draft flavor launch plan",+ "Check cold-chain status",+ "Audit sugar costs",+ "Retire low sellers",+];++export default function SearchList() {+ const [query, setQuery] = useState("");+ const results = query+ ? ITEMS.filter((i) => i.toLowerCase().includes(query.toLowerCase()))+ : ITEMS.slice(0, 5);+ const empty = query.length > 2 && results.length === 0;++ return (+ <div className="flex min-h-[248px] w-full max-w-72 flex-col items-stretch">+ <div className="w-full self-start overflow-hidden rounded-card bg-surface shadow-raised">+ {/* input row */}+ <div className="flex h-10 items-center gap-2 border-b border-line px-3 transition-colors duration-100 hover:bg-hover">+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--ink-3)" strokeWidth="2" strokeLinecap="round" className="shrink-0">+ <circle cx="11" cy="11" r="7" />+ <path d="M21 21l-4.3-4.3" />+ </svg>+ <input+ value={query}+ onChange={(event) => setQuery(event.target.value)}+ placeholder="Search flavors…"+ aria-label="Search flavors"+ className="min-w-0 flex-1 bg-transparent text-[13px] text-ink outline-none placeholder:text-ink-3"+ />+ {query && (+ <button+ aria-label="Clear search"+ type="button"+ onClick={() => setQuery("")}+ className="flex size-6 items-center justify-center rounded-full text-ink-3+ transition-colors duration-100 hover:bg-line/70 hover:text-ink"+ style={{ animation: "fade-in 150ms ease-out both" }}+ >+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ )}+ </div>++ {/* results / empty state */}+ {empty ? (+ <div className="flex flex-col items-center justify-center gap-1 px-4 py-8" style={{ animation: "fade-in 250ms ease-out both" }}>+ <span className="mb-1.5 flex size-8 items-center justify-center rounded-control bg-inset text-ink-3 shadow-hairline">+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round">+ <circle cx="11" cy="11" r="7" />+ <path d="M21 21l-4.3-4.3" />+ </svg>+ </span>+ <span className="text-[13px] font-medium text-ink">No results found</span>+ <span className="text-[12px] text-ink-3">Adjust your search to try again</span>+ </div>+ ) : (+ <div className="p-1">+ <GlideMenu className="flex flex-col gap-px" highlightClassName="inset-x-0 rounded-[6px] bg-hover">+ {results.map((item) => (+ <button+ key={item}+ data-menu-row+ type="button"+ onClick={() => setQuery(item)}+ className="relative z-10 flex h-8 w-full items-center rounded-[6px] px-2 text-left text-[13px] text-ink"+ style={{ animation: "fade-in 200ms ease-out both" }}+ >+ {item}+ </button>+ ))}+ </GlideMenu>+ </div>+ )}+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/SelectionActions.tsx b/apps/native/components/primitives/SelectionActions.tsxnew file mode 100644index 00000000..99fa3ad6--- /dev/null+++ b/apps/native/components/primitives/SelectionActions.tsx@@ -0,0 +1,491 @@+"use client";++import {+ useCallback,+ useEffect,+ useLayoutEffect,+ useRef,+ useState,+} from "react";+import {+ ArrowUp,+ ChatBubbleQuestion,+ Check,+ EmojiSatisfied,+ NavArrowRight,+ Refresh,+ Scissor,+ Spark,+ TextBox,+ Xmark,+} from "iconoir-react";+import { Shimmer } from "@/components/atoms/Shimmer";+import { StreamText } from "@/components/atoms/StreamText";++/* ─────────────────────────────────────────────────────────+ * SELECTION ACTIONS+ * A contextual AI bar attached beneath selected text.+ * The global theme owns its surface; this component only+ * composes existing surface, ink, accent, radius and motion+ * tokens.+ * ───────────────────────────────────────────────────────── */++const LEAD = "Pistachio holds the top slot all weekend. ";+const PICKED =+ "Churn it first thing Saturday so the batch has time to firm up before the afternoon rush.";+const REWRITE =+ "Churn pistachio first thing Saturday so the batch has time to fully firm before the afternoon rush.";++type Mode = "idle" | "thinking" | "streaming" | "result";++const iconProps = {+ width: 14,+ height: 14,+ strokeWidth: 1.8,+ "aria-hidden": true,+} as const;++const icons = {+ explain: <ChatBubbleQuestion {...iconProps} />,+ improve: <Spark {...iconProps} />,+ shorten: <Scissor {...iconProps} />,+ tone: <EmojiSatisfied {...iconProps} />,+ grammar: <TextBox {...iconProps} />,+ send: (+ <ArrowUp+ width="16"+ height="16"+ strokeWidth="2.4"+ aria-hidden="true"+ />+ ),+ chevron: <NavArrowRight {...iconProps} />,+ check: <Check {...iconProps} />,+ close: <Xmark {...iconProps} />,+ retry: <Refresh {...iconProps} />,+};++const control =+ "inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[12px] font-normal text-ink transition-[background-color,color,transform] duration-150 hover:bg-hover active:scale-[0.96]";++const primary =+ "inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-ink px-2.5 text-[12.5px] font-normal text-canvas shadow-hairline transition-[opacity,transform] duration-150 hover:opacity-90 active:scale-[0.96]";++export default function SelectionActions() {+ const [shown, setShown] = useState(false);+ const [mode, setMode] = useState<Mode>("idle");+ const [action, setAction] = useState("Improve");+ const [prompt, setPrompt] = useState("");+ const [typingWidth, setTypingWidth] = useState<number | null>(null);+ const [expanded, setExpanded] = useState(false);+ const [anchor, setAnchor] = useState({ x: 0, y: 0 });+ const [positioned, setPositioned] = useState(false);++ const hostRef = useRef<HTMLDivElement>(null);+ const selectionRef = useRef<HTMLSpanElement>(null);+ const barRef = useRef<HTMLDivElement>(null);+ const contentRef = useRef<HTMLDivElement>(null);+ const frameRef = useRef<number | null>(null);+ const previousModeRef = useRef<Mode>("idle");+ const lastWidthRef = useRef(0);+ const widthAnimationRef = useRef<Animation | null>(null);++ useEffect(() => {+ const timer = window.setTimeout(() => setShown(true), 280);+ return () => window.clearTimeout(timer);+ }, []);++ useEffect(() => {+ if (mode !== "thinking") return;+ const timer = window.setTimeout(() => setMode("streaming"), 700);+ return () => window.clearTimeout(timer);+ }, [mode]);++ /* Attach beneath the final selected line, while centering the bar+ * against the complete selection bounds. requestAnimationFrame batches+ * streaming reflow measurements and avoids visible intermediate positions. */+ const place = useCallback(() => {+ if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);+ frameRef.current = requestAnimationFrame(() => {+ const host = hostRef.current;+ const selection = selectionRef.current;+ if (!host || !selection) return;++ const bounds = selection.getBoundingClientRect();+ const lines = Array.from(selection.getClientRects());+ const lastLine = lines.at(-1);+ if (!lastLine) return;++ const hostBounds = host.getBoundingClientRect();+ const next = {+ x: Math.round(bounds.left - hostBounds.left + bounds.width / 2),+ y: Math.round(lastLine.bottom - hostBounds.top + 8),+ };++ setAnchor((current) =>+ current.x === next.x && current.y === next.y ? current : next,+ );+ setPositioned(true);+ });+ }, []);++ useLayoutEffect(() => {+ place();+ }, [mode, place]);++ useEffect(() => {+ const host = hostRef.current;+ if (!host) return;+ const observer = new ResizeObserver(place);+ observer.observe(host);+ window.addEventListener("resize", place);+ return () => {+ observer.disconnect();+ window.removeEventListener("resize", place);+ if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);+ };+ }, [place]);++ /* Intrinsic width handles the preset expansion. When the entire content+ * changes between idle, loading and confirmation, animate from the last+ * rendered width to the new intrinsic width before the browser paints. */+ useLayoutEffect(() => {+ const bar = barRef.current;+ const content = contentRef.current;+ if (!bar || !content) return;++ const nextWidth = Math.ceil(content.getBoundingClientRect().width) + 8;+ const previousWidth =+ lastWidthRef.current || Math.ceil(bar.getBoundingClientRect().width);++ if (+ previousModeRef.current !== mode &&+ Math.abs(nextWidth - previousWidth) > 1+ ) {+ widthAnimationRef.current?.cancel();+ const animation = bar.animate(+ [+ { width: `${previousWidth}px` },+ { width: `${nextWidth}px` },+ ],+ {+ duration: 320,+ easing: "cubic-bezier(0.23,1,0.32,1)",+ },+ );+ widthAnimationRef.current = animation;+ animation.onfinish = () => {+ lastWidthRef.current = nextWidth;+ widthAnimationRef.current = null;+ };+ } else {+ lastWidthRef.current = nextWidth;+ }++ previousModeRef.current = mode;+ }, [mode]);++ useEffect(() => {+ const content = contentRef.current;+ if (!content) return;++ const observer = new ResizeObserver(() => {+ if (widthAnimationRef.current?.playState === "running") return;+ lastWidthRef.current =+ Math.ceil(content.getBoundingClientRect().width) + 8;+ });+ observer.observe(content);+ return () => {+ observer.disconnect();+ widthAnimationRef.current?.cancel();+ };+ }, []);++ const run = (nextAction: string) => {+ setAction(nextAction);+ setExpanded(false);+ setMode("thinking");+ };++ const reset = () => {+ setExpanded(false);+ setPrompt("");+ setTypingWidth(null);+ setAction("Improve");+ setMode("idle");+ };++ const busy = mode === "thinking" || mode === "streaming";+ const visible = shown && positioned;+ const hasPrompt = prompt.trim().length > 0;+ const busyLabel =+ action === "Improve"+ ? "Improving"+ : action === "Shorten"+ ? "Shortening"+ : action === "Change tone"+ ? "Changing tone"+ : "Editing";++ return (+ <div className="w-full max-w-[460px]">+ <div ref={hostRef} className="relative select-none pb-12">+ <p className="text-[13px] leading-relaxed text-ink">+ {LEAD}+ <span+ ref={selectionRef}+ className="box-decoration-clone rounded-[3px] bg-[color-mix(in_srgb,var(--accent)_14%,var(--surface))] text-ink dark:bg-accent-tint"+ >+ {mode === "idle" || mode === "thinking" ? (+ PICKED+ ) : mode === "streaming" ? (+ <StreamText+ text={REWRITE}+ onProgress={place}+ onDone={() => setMode("result")}+ />+ ) : (+ REWRITE+ )}+ </span>+ </p>++ <div+ className="absolute top-0 left-0 z-10"+ style={{+ transform: `translate3d(${anchor.x}px, ${anchor.y}px, 0) translateX(-50%)`,+ transition:+ "transform 320ms cubic-bezier(0.77,0,0.175,1), opacity 180ms ease-out",+ opacity: visible ? 1 : 0,+ pointerEvents: visible ? "auto" : "none",+ willChange: "transform",+ }}+ >+ {/* A 36px pill wraps 28px controls at a 4px inset. The controls+ resolve to a 14px radius, preserving the concentric curve. */}+ <div+ ref={barRef}+ className="flex h-9 w-fit max-w-[calc(100vw-48px)] items-center justify-center gap-0.5 overflow-hidden rounded-full bg-surface p-1 font-sans font-normal text-ink shadow-overlay"+ style={{+ width:+ mode === "idle" && hasPrompt && typingWidth+ ? typingWidth+ : undefined,+ ...(visible+ ? {+ animation:+ "pop-in 220ms cubic-bezier(0.23,1,0.32,1) both",+ }+ : {}),+ }}+ >+ <div+ ref={contentRef}+ className="flex w-fit shrink-0 items-center justify-center gap-0.5"+ style={{+ width:+ mode === "idle" && hasPrompt && typingWidth+ ? typingWidth - 8+ : undefined,+ }}+ >+ {busy && (+ <span className="inline-flex h-7 items-center gap-1.5 whitespace-nowrap px-2.5 text-[12.5px] font-normal text-ink-2">+ <span+ className="size-3 shrink-0 rounded-full border-[1.5px] border-line-strong border-t-ink-2"+ style={{ animation: "spin 700ms linear infinite" }}+ />+ {mode === "thinking" ? (+ <Shimmer className="text-[12.5px] font-normal">+ {busyLabel}…+ </Shimmer>+ ) : (+ <span>{busyLabel}…</span>+ )}+ </span>+ )}++ {mode === "result" && (+ <>+ <button+ type="button"+ onClick={reset}+ className={primary}+ >+ {icons.check}+ Keep+ </button>+ <button type="button" onClick={reset} className={control}>+ {icons.close}+ Discard+ </button>+ <span className="mx-0.5 h-4 w-px shrink-0 bg-line" />+ <button+ type="button"+ aria-label="Try again"+ onClick={() => run(action)}+ className="flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 transition-[background-color,color,transform] duration-150 hover:bg-hover-2 hover:text-ink-2 active:scale-[0.96]"+ >+ {icons.retry}+ </button>+ </>+ )}++ {mode === "idle" && (+ <>+ <div+ className="flex min-w-0 items-center overflow-hidden transition-[max-width,opacity,transform] duration-400"+ style={{+ maxWidth: expanded+ ? 0+ : hasPrompt && typingWidth+ ? typingWidth - 40+ : 145,+ opacity: expanded ? 0 : 1,+ transform: expanded ? "translateX(-8px)" : "translateX(0)",+ transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)",+ }}+ >+ <form+ className="flex h-7 shrink-0 items-center transition-[width] duration-400"+ style={{+ width:+ hasPrompt && typingWidth ? typingWidth - 40 : 145,+ transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)",+ }}+ onSubmit={(event) => {+ event.preventDefault();+ run(prompt.trim() || "Improve");+ }}+ >+ <input+ value={prompt}+ onChange={(event) => {+ const next = event.target.value;+ if (!prompt.trim() && next.trim()) {+ setTypingWidth(+ Math.ceil(+ barRef.current?.getBoundingClientRect().width ??+ 0,+ ),+ );+ } else if (!next.trim()) {+ setTypingWidth(null);+ }+ setPrompt(next);+ }}+ aria-label="Describe edits"+ placeholder="Describe edits"+ className="h-7 w-full bg-transparent pr-2.5 pl-3 text-[12.5px] text-ink placeholder:text-ink-3"+ />+ </form>+ </div>++ <div+ className="flex min-w-0 items-center gap-0.5 overflow-hidden transition-[max-width,opacity,transform] duration-400"+ style={{+ maxWidth: hasPrompt ? 0 : expanded ? 462 : 224,+ opacity: hasPrompt ? 0 : 1,+ transform: hasPrompt ? "translateX(-8px)" : "translateX(0)",+ transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)",+ }}+ >+ {!expanded && (+ <span className="mx-1 h-4 w-px shrink-0 bg-line-strong" />+ )}+ <button type="button" className={control}>+ {icons.explain}+ Explain+ </button>+ <button+ type="button"+ onClick={() => run("Improve")}+ className={control}+ >+ {icons.improve}+ Improve+ </button>++ <div+ className="flex min-w-0 items-center gap-0.5 overflow-hidden transition-[max-width,opacity,margin] duration-400"+ style={{+ maxWidth: expanded ? 262 : 0,+ opacity: expanded ? 1 : 0,+ marginLeft: expanded ? 2 : 0,+ transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)",+ }}+ >+ <button+ type="button"+ onClick={() => run("Shorten")}+ className={control}+ >+ {icons.shorten}+ Shorten+ </button>+ <button+ type="button"+ onClick={() => run("Change tone")}+ className={control}+ >+ {icons.tone}+ Tone+ </button>+ <button+ type="button"+ onClick={() => run("Fix grammar")}+ className={control}+ >+ {icons.grammar}+ Grammar+ </button>+ </div>++ <span className="mx-0.5 h-4 w-px shrink-0 bg-line" />+ <button+ type="button"+ aria-label={expanded ? "Show fewer actions" : "Show more actions"}+ aria-expanded={expanded}+ onClick={() => setExpanded((value) => !value)}+ className="flex size-7 shrink-0 items-center justify-center rounded-full text-ink transition-[background-color,transform] duration-200 hover:bg-hover active:scale-[0.96]"+ >+ <span+ className="flex transition-transform duration-400"+ style={{+ transform: expanded ? "rotate(180deg)" : "rotate(0deg)",+ transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)",+ }}+ >+ {icons.chevron}+ </span>+ </button>+ </div>++ <div+ className="flex min-w-0 items-center overflow-hidden transition-[max-width,opacity,transform] duration-400"+ style={{+ maxWidth: hasPrompt ? 30 : 0,+ opacity: hasPrompt ? 1 : 0,+ transform: hasPrompt ? "scale(1)" : "scale(0.88)",+ transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)",+ }}+ >+ <button+ type="button"+ aria-label="Send edit instruction"+ onClick={() => run(prompt.trim())}+ className="flex size-7 shrink-0 items-center justify-center rounded-full bg-ink text-surface transition-[opacity,transform] duration-200 active:scale-[0.94]"+ >+ {icons.send}+ </button>+ </div>+ </>+ )}+ </div>+ </div>+ </div>+ </div>++ </div>+ );+}diff --git a/apps/native/components/primitives/SidebarNav.tsx b/apps/native/components/primitives/SidebarNav.tsxnew file mode 100644index 00000000..5653aea0--- /dev/null+++ b/apps/native/components/primitives/SidebarNav.tsx@@ -0,0 +1,448 @@+"use client";++import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from "react";+import { createPortal } from "react-dom";+import {+ IconArrowBoxLeft,+ IconCheckmark1Small,+ IconChevronDownSmall,+ IconCrossSmall,+ IconEditBig,+ IconFolder,+ IconHome,+ IconMagnifyingGlass,+ IconPlusMedium,+ IconPopsicle2,+ IconSettingsGear1,+ IconSidebarLeftArrow,+ IconUserAdd,+} from "@/lib/icons";+import GlideMenu from "@/components/primitives/GlideMenu";++/* ─────────────────────────────────────────────────────────+ * SIDEBAR NAV+ * Shared by the design-system preview and the harness shell:+ * compact workspace switcher, primary navigation, searchable+ * chat history, and a collapse that preserves icon alignment.+ * ───────────────────────────────────────────────────────── */++const WORKSPACE = { key: "graff", name: "Codegraff", monogram: "G" };++const NAV_ITEMS: { key: string; label: string; icon: ReactNode; count?: string }[] = [+ { key: "home", label: "Home", icon: <IconHome size={18} /> },+ { key: "workspace", label: "Workspace", icon: <IconFolder size={18} /> },+];++export type SidebarRecent = {+ id: string;+ label: string;+ prompt?: string;+};++const DEFAULT_RECENTS: SidebarRecent[] = [+ { id: "files", label: "What files are here?" },+ { id: "readme", label: "Summarize README.md" },+ { id: "review", label: "Review the last commit" },+ { id: "todos", label: "What's on the checklist?" },+];++type SidebarNavProps = {+ activeTitle?: string | null;+ className?: string;+ fill?: boolean;+ onNewChat?: () => void;+ onPick?: (id: string, label: string, prompt?: string) => void;+ /** controlled primary-nav selection (e.g. "home" | "invite") */+ activeNav?: string;+ onNavigate?: (key: string) => void;+ /** footer call-to-action — defaults to the demo "Upgrade" button */+ footerLabel?: string;+ footerIcon?: ReactNode;+ onFooterClick?: () => void;+ recents?: SidebarRecent[];+ variant?: string;+};++const SIDEBAR_MOTION = {+ expandedWidth: 224,+ collapsedWidth: 52,+ duration: 280,+ copyDuration: 180,+ copyOffset: 8,+ easing: "cubic-bezier(0.16, 1, 0.3, 1)",+};++/* ─────────────────────────────────────────────────────────+ * CHAT SEARCH STORYBOARD+ *+ * 0ms search is triggered; Chats label begins fading+ * 0ms field grows right → left from the search control+ * 180ms field fills the row; cursor is focused and ready+ * ───────────────────────────────────────────────────────── */+const CHAT_SEARCH_MOTION = {+ duration: 180,+ closedWidth: 28,+ easing: "cubic-bezier(0.16, 1, 0.3, 1)",+};++function GlideGroup({ children }: { children: ReactNode }) {+ return (+ <GlideMenu+ rowSelector="[data-row]"+ highlightClassName="sidebar-glide-highlight rounded-[7px] bg-hover-2"+ className="group/glide flex flex-col gap-px"+ >+ {children}+ </GlideMenu>+ );+}++function RailButton({+ icon,+ label,+ active = false,+ count,+ onClick,+}: {+ icon: ReactNode;+ label: string;+ active?: boolean;+ count?: string;+ onClick?: () => void;+}) {+ return (+ <button+ data-row+ type="button"+ onClick={onClick}+ className={`sidebar-row relative z-10 mx-2 flex h-8 items-center rounded-[8px] px-2 text-left+ transition-[width,background-color,color,transform] duration-150 active:scale-[0.98]+ ${active ? "bg-hover-2 group-hover/glide:bg-transparent" : ""}`}+ >+ <span className={`flex size-5 shrink-0 items-center justify-center ${active ? "text-ink" : "text-ink-2"}`}>+ {icon}+ </span>+ <span className={`sidebar-copy ml-1.5 min-w-0 flex-1 truncate text-[14px] font-medium ${active ? "text-ink" : "text-ink-2"}`}>+ {label}+ </span>+ {count && (+ <span className="sidebar-copy mr-2 shrink-0 text-[12px] font-medium tabular-nums text-ink-3">+ {count}+ </span>+ )}+ </button>+ );+}++function WorkspaceMenu({+ position,+ onClose,+}: {+ position: { top: number; left: number };+ onClose: () => void;+}) {+ return createPortal(+ <div+ data-workspace-menu+ className="fixed z-50 w-64 rounded-[14px] bg-surface p-1.5 shadow-overlay"+ style={{+ top: position.top,+ left: position.left,+ animation: "pop-in 180ms cubic-bezier(0.23,1,0.32,1) both",+ transformOrigin: "top left",+ }}+ >+ <GlideMenu className="flex flex-col gap-px" highlightClassName="inset-x-0 rounded-[8px] bg-hover-2">+ <button+ data-menu-row+ type="button"+ onClick={onClose}+ className="relative z-10 flex h-10 w-full items-center gap-1.5 rounded-[8px] px-2 text-left"+ >+ <span className="flex size-6 shrink-0 items-center justify-center rounded-[7px] bg-ink text-[11px] font-semibold text-surface">+ {WORKSPACE.monogram}+ </span>+ <span className="min-w-0 flex-1 truncate text-[13.5px] font-medium text-ink">{WORKSPACE.name}</span>+ <span className="shrink-0 text-ink"><IconCheckmark1Small size={18} /></span>+ </button>+ <div className="my-1 h-px bg-line" />+ {[+ { label: "New workspace", icon: <IconPlusMedium size={16} /> },+ { label: "Workspace settings", icon: <IconSettingsGear1 size={16} /> },+ { label: "Invite team members", icon: <IconUserAdd size={16} /> },+ ].map((item) => (+ <button+ key={item.label}+ data-menu-row+ type="button"+ onClick={onClose}+ className="relative z-10 flex h-9 w-full items-center gap-1.5 rounded-[8px] px-2 text-left"+ >+ <span className="flex size-5 shrink-0 items-center justify-center text-ink-2">{item.icon}</span>+ <span className="min-w-0 flex-1 truncate text-[13.5px] text-ink">{item.label}</span>+ </button>+ ))}+ <div className="my-1 h-px bg-line" />+ <button+ data-menu-row+ type="button"+ onClick={onClose}+ className="relative z-10 flex h-9 w-full items-center gap-1.5 rounded-[8px] px-2 text-left"+ >+ <span className="flex size-5 shrink-0 items-center justify-center text-ink-2"><IconArrowBoxLeft size={16} /></span>+ <span className="min-w-0 flex-1 truncate text-[13.5px] text-ink">Sign out</span>+ </button>+ </GlideMenu>+ </div>,+ document.body,+ );+}++export default function SidebarNav({+ activeTitle,+ className = "",+ fill = false,+ onNewChat,+ onPick,+ activeNav,+ onNavigate,+ footerLabel = "Upgrade",+ footerIcon,+ onFooterClick,+ recents = DEFAULT_RECENTS,+}: SidebarNavProps) {+ const [collapsed, setCollapsed] = useState(false);+ const [internalNav, setInternalNav] = useState("chats");+ const currentNav = activeNav ?? internalNav;+ const selectNav = (key: string) => {+ setInternalNav(key);+ onNavigate?.(key);+ };+ const [demoActiveTitle, setDemoActiveTitle] = useState<string | null>(null);+ const [workspaceOpen, setWorkspaceOpen] = useState(false);+ const [workspacePosition, setWorkspacePosition] = useState({ top: 0, left: 0 });+ const [searchOpen, setSearchOpen] = useState(false);+ const [query, setQuery] = useState("");+ const workspaceButtonRef = useRef<HTMLButtonElement>(null);+ const searchRef = useRef<HTMLInputElement>(null);++ const selectedTitle = activeTitle === undefined ? demoActiveTitle : activeTitle;+ const visibleRecents = recents.filter((item) => item.label.toLowerCase().includes(query.trim().toLowerCase()));++ useEffect(() => {+ if (!workspaceOpen) return;+ const close = (event: PointerEvent) => {+ const target = event.target as Element;+ if (!target.closest("[data-workspace-trigger]") && !target.closest("[data-workspace-menu]")) {+ setWorkspaceOpen(false);+ }+ };+ document.addEventListener("pointerdown", close);+ return () => document.removeEventListener("pointerdown", close);+ }, [workspaceOpen]);++ useEffect(() => {+ if (searchOpen) searchRef.current?.focus();+ }, [searchOpen]);++ const collapse = () => {+ setCollapsed(true);+ setWorkspaceOpen(false);+ setSearchOpen(false);+ setQuery("");+ };++ return (+ <aside+ data-sidebar-collapsed={collapsed}+ aria-label="Workspace navigation"+ className={`relative flex shrink-0 overflow-hidden transition-[width] ${fill ? "h-full" : "h-[600px]"} ${className}`}+ style={{+ width: collapsed ? SIDEBAR_MOTION.collapsedWidth : SIDEBAR_MOTION.expandedWidth,+ transitionDuration: `${SIDEBAR_MOTION.duration}ms`,+ transitionTimingFunction: SIDEBAR_MOTION.easing,+ "--sidebar-copy-duration": `${SIDEBAR_MOTION.copyDuration}ms`,+ "--sidebar-copy-offset": `${SIDEBAR_MOTION.copyOffset}px`,+ "--sidebar-easing": SIDEBAR_MOTION.easing,+ } as CSSProperties}+ >+ <div className="flex min-h-0 w-[224px] shrink-0 flex-col">+ <div className="relative mb-2.5 h-10 shrink-0">+ <button+ ref={workspaceButtonRef}+ data-workspace-trigger+ type="button"+ aria-expanded={workspaceOpen}+ aria-hidden={collapsed}+ tabIndex={collapsed ? -1 : 0}+ onClick={() => {+ if (!workspaceOpen && workspaceButtonRef.current) {+ const rect = workspaceButtonRef.current.getBoundingClientRect();+ setWorkspacePosition({ top: rect.bottom + 6, left: rect.left });+ }+ setWorkspaceOpen((open) => !open);+ }}+ className="sidebar-workspace-control absolute left-2 top-1 flex h-8 w-[164px] items-center rounded-[8px] px-2 text-left transition-[background-color,transform] duration-100 hover:bg-hover-2 active:scale-[0.99]"+ >+ <span className="sidebar-logo flex size-5 shrink-0 items-center justify-center text-ink">+ <IconPopsicle2 size={18} />+ </span>+ <span className="sidebar-copy ml-1.5 min-w-0 flex-1 truncate text-[14px] font-medium text-ink-2">+ {WORKSPACE.name}+ </span>+ <span className="sidebar-copy ml-1 flex shrink-0 text-ink-3">+ <IconChevronDownSmall size={16} />+ </span>+ </button>++ {workspaceOpen && <WorkspaceMenu position={workspacePosition} onClose={() => setWorkspaceOpen(false)} />}++ <button+ type="button"+ aria-label="Collapse sidebar"+ aria-hidden={collapsed}+ tabIndex={collapsed ? -1 : 0}+ onClick={collapse}+ className="sidebar-collapse-control absolute right-2 top-1 flex size-8 items-center justify-center rounded-[8px] text-ink-3 transition-[opacity,background-color,color] duration-150 hover:bg-hover-2 hover:text-ink"+ >+ <IconSidebarLeftArrow size={18} />+ </button>+ <button+ type="button"+ aria-label="Expand sidebar"+ aria-hidden={!collapsed}+ tabIndex={collapsed ? 0 : -1}+ onClick={() => setCollapsed(false)}+ className="sidebar-expand-control absolute left-2 top-0.5 flex size-9 items-center justify-center rounded-[8px] text-ink-3 transition-[opacity,background-color,color] duration-150 hover:bg-hover-2 hover:text-ink"+ >+ <IconSidebarLeftArrow size={18} className="rotate-180" />+ </button>+ </div>++ <GlideGroup>+ <RailButton+ icon={<IconEditBig size={18} />}+ label="New chat"+ onClick={() => {+ if (activeTitle === undefined) setDemoActiveTitle(null);+ selectNav("chats");+ onNewChat?.();+ }}+ />+ {NAV_ITEMS.map((item) => (+ <RailButton+ key={item.key}+ icon={item.icon}+ label={item.label}+ count={item.count}+ active={currentNav === item.key}+ onClick={() => selectNav(item.key)}+ />+ ))}+ </GlideGroup>++ <div className="mt-3 min-h-0 flex-1 overflow-y-auto">+ <div className="sidebar-copy relative mx-2 mb-1 h-8">+ <div+ aria-hidden={searchOpen}+ className={`absolute inset-0 flex items-center gap-1.5 px-2 text-[12.5px] font-medium text-ink-3 transition-[opacity,transform] ${searchOpen ? "pointer-events-none -translate-x-1 opacity-0" : "translate-x-0 opacity-100"}`}+ style={{ transitionDuration: `${CHAT_SEARCH_MOTION.duration}ms`, transitionTimingFunction: CHAT_SEARCH_MOTION.easing }}+ >+ <IconChevronDownSmall size={16} />+ <span>Chats</span>+ </div>++ <button+ type="button"+ aria-label="Search chats"+ aria-expanded={searchOpen}+ onClick={() => setSearchOpen(true)}+ className={`absolute right-0 top-0 z-10 flex size-8 items-center justify-center rounded-[8px] text-ink-3 transition-[opacity,background-color,color,transform] hover:bg-hover-2 hover:text-ink active:scale-[0.96] ${searchOpen ? "pointer-events-none opacity-0" : "opacity-100"}`}+ style={{ transitionDuration: `${CHAT_SEARCH_MOTION.duration}ms` }}+ >+ <IconMagnifyingGlass size={16} />+ </button>++ <div+ className={`absolute right-0 top-0 z-20 flex h-8 items-center overflow-hidden rounded-[8px] bg-field text-ink-3 shadow-hairline transition-[width,opacity] focus-within:text-ink-2 ${searchOpen ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"}`}+ style={{+ width: searchOpen ? "100%" : CHAT_SEARCH_MOTION.closedWidth,+ transitionDuration: `${CHAT_SEARCH_MOTION.duration}ms`,+ transitionTimingFunction: CHAT_SEARCH_MOTION.easing,+ }}+ >+ <span className="ml-2 flex shrink-0 items-center justify-center">+ <IconMagnifyingGlass size={15} />+ </span>+ <input+ ref={searchRef}+ value={query}+ onChange={(event) => setQuery(event.target.value)}+ onKeyDown={(event) => {+ if (event.key === "Escape") {+ setSearchOpen(false);+ setQuery("");+ }+ }}+ placeholder="Search chats"+ aria-label="Search chat history"+ className="ml-1.5 min-w-0 flex-1 bg-transparent text-[13px] font-medium text-ink outline-none placeholder:text-ink-3"+ />+ <button+ type="button"+ aria-label="Close chat search"+ onClick={() => {+ setSearchOpen(false);+ setQuery("");+ }}+ className="flex size-8 shrink-0 items-center justify-center rounded-[8px] text-ink-3 transition-[background-color,color,transform] duration-150 hover:bg-hover-2 hover:text-ink active:scale-[0.96]"+ >+ <IconCrossSmall size={16} />+ </button>+ </div>+ </div>++ <GlideGroup>+ {visibleRecents.map((item) => {+ const active = item.label === selectedTitle;+ return (+ <button+ key={item.id}+ data-row+ type="button"+ title={item.label}+ onClick={() => {+ selectNav("chats");+ if (activeTitle === undefined) setDemoActiveTitle(item.label);+ onPick?.(item.id, item.label, item.prompt);+ }}+ className={`sidebar-row relative z-10 mx-2 flex h-8 items-center rounded-[8px] px-2 text-left transition-[width,background-color,color,transform] duration-150 active:scale-[0.98] ${+ active ? "bg-hover-2 group-hover/glide:bg-transparent" : ""+ }`}+ >+ <span className={`sidebar-copy min-w-0 flex-1 truncate text-[14px] font-medium ${active ? "text-ink" : "text-ink-2"}`}>+ {item.label}+ </span>+ </button>+ );+ })}+ {query && visibleRecents.length === 0 && (+ <div className="sidebar-copy mx-2 px-2 py-2 text-[12.5px] text-ink-3">No chats found</div>+ )}+ </GlideGroup>+ </div>++ <div className="sidebar-copy mx-2 mt-3 w-[208px] border-t border-line pt-3">+ <button+ type="button"+ onClick={onFooterClick ?? onNewChat}+ className="flex h-8 w-full items-center justify-center gap-1.5 rounded-control bg-hover-2 text-[12.5px] font-medium text-ink transition-[background-color,transform] duration-150 hover:bg-line-strong active:scale-[0.98]"+ >+ {footerIcon}+ {footerLabel}+ </button>+ </div>+ </div>+ </aside>+ );+}diff --git a/apps/native/components/primitives/StreamingText.tsx b/apps/native/components/primitives/StreamingText.tsxnew file mode 100644index 00000000..1ca14fb5--- /dev/null+++ b/apps/native/components/primitives/StreamingText.tsx@@ -0,0 +1,237 @@+"use client";++import { useEffect, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * STREAMING TEXT+ * Words resolve out of blur, inline citations appear in+ * context, then actions and follow-up prompts become usable.+ * ───────────────────────────────────────────────────────── */++const WORD_MS = 55;+const HOLD_MS = 3400;++type Token = { text: string; cite?: boolean };++const TOKENS: Token[] = [+ ..."Pistachio is your fastest-growing flavor — sales are up 23% this month and margins beat vanilla by 8 points."+ .split(" ")+ .map((text) => ({ text })),+ { text: "", cite: true },+ ..."Stone-fruit flavors are trending in the same range."+ .split(" ")+ .map((text) => ({ text })),+];++const FOLLOW_UPS = [+ "Which flavors sell best in winter",+ "Compare gelato and soft serve margins",+];++const SOURCE_IMAGES = {+ scoop:+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='16' fill='%231f7a5f'/%3E%3Cpath d='M20 36c0 7 5.4 12 12 12s12-5 12-12H20Z' fill='%23fff'/%3E%3Ccircle cx='32' cy='25' r='11' fill='%23bff3dd'/%3E%3Cpath d='M24 24c4-7 13-7 17 0' fill='none' stroke='%231f7a5f' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E",+ trends:+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='16' fill='%232f6fec'/%3E%3Cpath d='M15 43 27 31l8 7 14-18' fill='none' stroke='%23fff' stroke-width='7' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='49' cy='20' r='5' fill='%23bfe0ff'/%3E%3C/svg%3E",+ market:+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='16' fill='%23e56d24'/%3E%3Cpath d='M17 45V25h8v20h-8Zm11 0V16h8v29h-8Zm11 0V30h8v15h-8Z' fill='%23fff'/%3E%3Cpath d='M16 49h32' stroke='%23ffd6b8' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E",+};++const SOURCES = [+ { name: "Scoop Data", domain: "scoopdata.io", href: "https://scoopdata.io/", image: SOURCE_IMAGES.scoop },+ { name: "Trends Index", domain: "trends.google.com", href: "https://trends.google.com/trends/", image: SOURCE_IMAGES.trends },+ { name: "Market Basket", domain: "marketbasket.io", href: "https://marketbasket.io/", image: SOURCE_IMAGES.market },+];++function sourceImage(source: (typeof SOURCES)[number]) {+ return source.image;+}++function SourceChip() {+ const source = SOURCES[0];+ return (+ <a+ href={source.href}+ target="_blank"+ rel="noreferrer"+ className="ml-0 mr-1 inline-flex h-4.5 translate-y-[-1px] items-center gap-1 rounded-[5px]+ bg-inset pr-[3px] pl-[3px] align-middle font-mono text-[10.5px] text-ink-2 shadow-hairline+ transition-colors duration-150 hover:bg-hover hover:text-ink"+ style={{ animation: "pop-in 250ms cubic-bezier(0.23,1,0.32,1) both" }}+ >+ <img src={sourceImage(source)} alt="" className="source-avatar size-3 rounded-[3px]" />+ <span>{source.domain}</span>+ </a>+ );+}++const ACTION_ICONS: React.ReactNode[] = [+ <g key="copy"><rect x="9" y="9" width="12" height="12" rx="2.5" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" /></g>,+ <path key="retry" d="M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6" />,+ <path key="up" d="M7 10v12M15 5.88L14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88z" />,+ <path key="down" d="M17 14V2M9 18.12L10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88z" />,+];++export default function StreamingText({+ loop = true,+ fill = false,+ onDone,+ text,+ streaming = false,+}: {+ variant?: string;+ /** restart the stream after a hold; turn off when embedding in a real thread */+ loop?: boolean;+ /** fill the parent width instead of the gallery's fixed measure */+ fill?: boolean;+ onDone?: () => void;+ /** Live assistant text. When set, the pistachio demo tokens are unused. */+ text?: string;+ streaming?: boolean;+}) {+ const live = text !== undefined;+ const [count, setCount] = useState(0);+ const [sourcesOpen, setSourcesOpen] = useState(false);+ const done = live ? !streaming : count >= TOKENS.length;++ useEffect(() => {+ if (live) {+ if (done) onDone?.();+ return;+ }+ if (done && !loop) {+ onDone?.();+ return;+ }+ const t = setTimeout(+ () => setCount((c) => (c >= TOKENS.length ? 0 : c + 1)),+ done ? HOLD_MS : WORD_MS,+ );+ return () => clearTimeout(t);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [count, done, loop, live]);++ return (+ <div className={fill ? "w-full" : "min-h-[15.5rem] w-full max-w-95"}>+ <p className="text-[13px] leading-relaxed text-ink whitespace-pre-wrap">+ {live ? (+ text+ ) : (+ TOKENS.slice(0, count).map((token, i) =>+ token.cite ? (+ <SourceChip key={i} />+ ) : (+ <span key={i} className="inline">+ {token.text}{" "}+ </span>+ ),+ )+ )}+ {!done && (+ <span+ className="stream-caret is-streaming ml-0.5 inline-block h-3 w-0.5 translate-y-0.5 rounded-full bg-ink"+ style={{ animation: "fade-in 150ms ease-out both" }}+ />+ )}+ </p>++ {/* action icons row — gallery demo only */}+ {!live && (+ <>+ <div+ className="mt-2 flex items-center gap-0.5 transition-opacity duration-400"+ style={{ opacity: done ? 1 : 0, pointerEvents: done ? "auto" : "none" }}+ >+ {ACTION_ICONS.map((icon, i) => (+ <button+ key={i}+ type="button"+ aria-label="Action"+ className="flex size-6 items-center justify-center rounded-[6px] text-ink-3+ transition-colors duration-100 hover:bg-hover-2 hover:text-ink-2"+ >+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">+ {icon}+ </svg>+ </button>+ ))}+ <button+ type="button"+ aria-expanded={sourcesOpen}+ onClick={() => setSourcesOpen((current) => !current)}+ className="ml-1.5 flex items-center gap-1.5 rounded-[6px] px-1 py-0.5 text-left transition-colors duration-150 hover:bg-hover"+ >+ <span className="flex -space-x-1">+ {SOURCES.map((source) => (+ <img+ key={source.domain}+ src={sourceImage(source)}+ alt=""+ className="source-avatar size-3.5 rounded-full bg-surface shadow-[0_0_0_1.5px_var(--canvas)]"+ />+ ))}+ </span>+ <span className="text-[12px] text-ink-2">10 sources</span>+ </button>+ </div>++ <div+ className="grid transition-[grid-template-rows,opacity] duration-300"+ style={{+ gridTemplateRows: done && sourcesOpen ? "1fr" : "0fr",+ opacity: done && sourcesOpen ? 1 : 0,+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ >+ <div className="overflow-hidden">+ <div className="mt-1.5 flex flex-col rounded-[10px] bg-inset p-1 shadow-hairline">+ {SOURCES.map((source) => (+ <a+ key={source.domain}+ href={source.href}+ target="_blank"+ rel="noreferrer"+ className="flex items-center gap-2 rounded-[6px] px-1.5 py-1 text-[12px] text-ink-2 transition-colors duration-150 hover:bg-hover hover:text-ink"+ >+ <img src={sourceImage(source)} alt="" className="source-avatar size-4 rounded-[4px]" />+ <span className="animated-underline">{source.name}</span>+ <span className="ml-auto font-mono text-[10.5px] text-ink-3">{source.domain}</span>+ </a>+ ))}+ </div>+ </div>+ </div>++ {/* follow-ups */}+ <div+ className="mt-2.5 transition-opacity duration-400"+ style={{ opacity: done ? 1 : 0, pointerEvents: done ? "auto" : "none" }}+ >+ <p className="text-[12px] font-medium text-ink-2">Follow-ups</p>+ <div className="mt-0.5 flex flex-col">+ {FOLLOW_UPS.map((text, i) => (+ <button+ key={text}+ className="-mx-1.5 flex items-center gap-2 rounded-[7px] border-b border-line+ px-1.5 py-1.5 text-left text-[12.5px] text-ink transition-colors+ duration-100 hover:bg-hover-2"+ style={+ done+ ? { animation: `fade-up 350ms cubic-bezier(0.23,1,0.32,1) ${i * 90}ms both` }+ : { opacity: 0 }+ }+ >+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="var(--ink-3)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="shrink-0">+ <path d="M9 10l-5 5 5 5" />+ <path d="M20 4v7a4 4 0 0 1-4 4H4" />+ </svg>+ {text}+ </button>+ ))}+ </div>+ </div>+ </>+ )}+ </div>+ );+}diff --git a/apps/native/components/primitives/TaskRows.tsx b/apps/native/components/primitives/TaskRows.tsxnew file mode 100644index 00000000..55e1eade--- /dev/null+++ b/apps/native/components/primitives/TaskRows.tsx@@ -0,0 +1,269 @@+"use client";++import { useEffect, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * TASK ROWS+ *+ * 0ms rows enter staggered (80ms apart)+ * 600ms row 1 ring sweeps 0 → 66%+ * 1500ms row 1 expands — detail steps drop down+ * 3900ms row 1 collapses; row 2 flips to Failed + retry+ * 5300ms row 2 resolves to Completed+ * The status run completes once; task details stay clickable.+ * ───────────────────────────────────────────────────────── */++const TICKS = [600, 900, 2400, 1400, 2400, 600];++function useTick(intervals: number[]) {+ const [tick, setTick] = useState(0);+ useEffect(() => {+ if (tick >= intervals.length - 1) return;+ const t = setTimeout(() => setTick((x) => x + 1), intervals[tick]);+ return () => clearTimeout(t);+ }, [tick, intervals]);+ return tick;+}++function SpinnerRing({ active, children }: { active?: boolean; children?: React.ReactNode }) {+ const size = 24, stroke = 2;+ const r = (size - stroke) / 2;+ const c = 2 * Math.PI * r;+ return (+ <span className="relative inline-flex shrink-0 items-center justify-center" style={{ width: size, height: size }}>+ <svg+ width={size} height={size} className="absolute inset-0"+ style={active ? { animation: "spin 1.1s linear infinite" } : undefined}+ >+ <circle cx={size / 2} cy={size / 2} r={r} fill="none" stroke="var(--line)" strokeWidth={stroke} />+ {active && (+ <circle+ cx={size / 2} cy={size / 2} r={r} fill="none"+ stroke="var(--ink-3)" strokeWidth={stroke} strokeLinecap="round"+ strokeDasharray={`${c * 0.28} ${c * 0.72}`}+ />+ )}+ </svg>+ <span className="relative text-[10.5px] font-semibold tabular-nums text-ink">{children}</span>+ </span>+ );+}++function Badge({ tone, children }: { tone: "red" | "green"; children: React.ReactNode }) {+ return (+ <span+ className={`flex size-5.5 shrink-0 items-center justify-center rounded-full text-white+ ${tone === "red" ? "bg-red" : "bg-green"}`}+ style={{ animation: "pop-in 300ms cubic-bezier(0.23,1,0.32,1) both" }}+ >+ {children}+ </span>+ );+}++const XIcon = (+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3.5" strokeLinecap="round"><path d="M18 6L6 18M6 6l12 12" /></svg>+);+const CheckIcon = (+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3.5" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6L9 17l-5-5" /></svg>+);+const RetryIcon = (+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><path d="M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6" /></svg>+);++export type TaskItem = {+ key: string;+ label: string;+ status: "pending" | "in_progress" | "completed" | "failed";+ amount?: string;+ details?: { label: string; meta?: string }[];+};++export default function TaskRows({+ variant = "Capsules",+ items,+}: {+ variant?: string;+ items?: TaskItem[];+}) {+ const live = items !== undefined;+ const tick = useTick(live ? [0] : TICKS);+ const [manualOpen, setManualOpen] = useState<Record<string, boolean>>({});+ const row2: "pending" | "failed" | "done" = tick < 3 ? "pending" : tick === 3 ? "failed" : "done";++ const liveRows = (items ?? []).map((item) => ({+ key: item.key,+ badge:+ item.status === "completed" ? (+ <Badge tone="green">{CheckIcon}</Badge>+ ) : item.status === "failed" ? (+ <Badge tone="red">{XIcon}</Badge>+ ) : (+ <SpinnerRing active={item.status === "in_progress"} />+ ),+ label: item.label,+ amount: item.amount ?? "",+ pill:+ item.status === "completed" ? (+ <span className="inline-flex h-5.5 items-center rounded-full bg-green-tint px-2 text-[11.5px] font-medium text-green">+ Completed+ </span>+ ) : item.status === "in_progress" ? (+ <span className="inline-flex h-5.5 items-center rounded-full bg-accent-tint px-2 text-[11.5px] font-medium text-accent-ink">+ In progress+ </span>+ ) : item.status === "failed" ? (+ <span className="inline-flex h-5.5 items-center rounded-full bg-red-tint px-2 text-[11.5px] font-medium text-red">+ Failed+ </span>+ ) : (+ <span className="inline-flex h-5.5 items-center rounded-full bg-inset px-2 text-[11.5px] font-medium text-ink-3">+ Pending+ </span>+ ),+ details: item.details ?? [],+ }));++ const rows = live ? liveRows : [+ {+ key: "verify",+ badge: <Badge tone="green">{CheckIcon}</Badge>,+ label: "Verified vendor records",+ amount: "12 suppliers",+ pill: (+ <span className="inline-flex h-5.5 items-center rounded-full bg-green-tint px-2 text-[11.5px] font-medium text-green">+ Completed+ </span>+ ),+ details: [+ { label: "Matched tax and contact IDs", meta: "12/12" },+ { label: "Flagged stale records", meta: "0" },+ ],+ },+ {+ key: "index",+ badge: <SpinnerRing active>2</SpinnerRing>,+ label: "Build reorder task list",+ amount: "7 SKUs",+ pill: null,+ details: [+ { label: "Reading POS export", meta: "3 files" },+ { label: "Scoring stockout risk", meta: "68%" },+ ],+ },+ {+ key: "draft",+ badge:+ row2 === "pending" ? (+ <SpinnerRing>3</SpinnerRing>+ ) : row2 === "failed" ? (+ <Badge tone="red">{XIcon}</Badge>+ ) : (+ <Badge tone="green">{CheckIcon}</Badge>+ ),+ label: "Draft supplier emails",+ amount: "2 messages",+ pill:+ row2 === "failed" ? (+ <span className="inline-flex h-5.5 items-center gap-1.5 rounded-full bg-red-tint px-2 text-[11.5px] font-medium text-red" style={{ animation: "fade-in 200ms ease-out both" }}>+ Failed <span style={{ animation: "spin 1.2s linear infinite" }} className="flex">{RetryIcon}</span>+ </span>+ ) : row2 === "done" ? (+ <span className="inline-flex h-5.5 items-center gap-1.5 rounded-full bg-green-tint px-2 text-[11.5px] font-medium text-green" style={{ animation: "fade-in 200ms ease-out both" }}>+ Completed+ </span>+ ) : null,+ details: [+ { label: "Cone supplier follow-up", meta: "draft" },+ { label: "Pistachio reorder note", meta: "draft" },+ ],+ },+ ];++ const list = variant === "List";+ return (+ <div+ className={`flex w-full max-w-110 flex-col ${+ list ? "gap-0 self-start overflow-hidden rounded-card bg-surface shadow-card" : "min-h-[196px] gap-2"+ }`}+ >+ {rows.map((row, i) => {+ const open = manualOpen[row.key] ?? (row.key === "index" && tick === 2);+ return (+ <div+ key={row.key}+ className={`self-stretch overflow-hidden transition-[border-radius,background-color] duration-300 hover:bg-inset ${+ list ? "border-b border-line last:border-0" : "bg-surface shadow-card"+ }`}+ style={{+ borderRadius: list ? 0 : open ? 14 : 22,+ animation: `fade-up 450ms cubic-bezier(0.23,1,0.32,1) ${i * 80}ms both`,+ }}+ >+ <button+ type="button"+ aria-expanded={open}+ onClick={() => setManualOpen((current) => ({ ...current, [row.key]: !open }))}+ className="flex h-11 w-full items-center gap-2.5 px-2.5 text-left"+ >+ <span className="flex size-6 shrink-0 items-center justify-center">+ {row.badge}+ </span>+ <span className="min-w-0 flex-1 truncate text-[13px] font-medium text-ink">+ {row.label}+ </span>+ <span className="text-[12.5px] text-ink-2 tabular-nums">{row.amount}</span>+ {row.pill}+ <span+ aria-hidden="true"+ className="-ml-2 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3"+ >+ <svg+ width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"+ className="transition-transform duration-300"+ style={{ transform: open ? "rotate(180deg)" : "rotate(0)" }}+ >+ <path d="M6 9l6 6 6-6" />+ </svg>+ </span>+ </button>++ {/* dropdown detail — same expandable grammar as Chain of Thought */}+ <div+ className="grid transition-[grid-template-rows,opacity] duration-300"+ style={{+ gridTemplateRows: open ? "1fr" : "0fr",+ opacity: open ? 1 : 0,+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ >+ <div className="overflow-hidden">+ <div className="mb-2.5 grid grid-cols-[24px_1fr] gap-2.5 px-2.5">+ <span aria-hidden className="mx-auto h-full w-px bg-line" />+ <div className="flex flex-col gap-1.5">+ {row.details.map((d, j) => (+ <div+ key={d.label}+ className="flex items-center justify-between"+ style={+ open+ ? { animation: `fade-up 300ms cubic-bezier(0.23,1,0.32,1) ${120 + j * 100}ms both` }+ : undefined+ }+ >+ <span className="text-[12px] text-ink-2">{d.label}</span>+ <span className="font-mono text-[11.5px] text-ink-3 tabular-nums">+ {d.meta}+ </span>+ </div>+ ))}+ </div>+ </div>+ </div>+ </div>+ </div>+ );+ })}+ </div>+ );+}diff --git a/apps/native/components/primitives/ThinkingState.tsx b/apps/native/components/primitives/ThinkingState.tsxnew file mode 100644index 00000000..17b4ba4e--- /dev/null+++ b/apps/native/components/primitives/ThinkingState.tsx@@ -0,0 +1,304 @@+"use client";++import { useEffect, useLayoutEffect, useRef, useState } from "react";++/* ─────────────────────────────────────────────────────────+ * THINKING — expandable agent trace, four variants+ *+ * Steps step list with spinner → muted checks+ * Reasoning prose reasoning that expands, then settles+ * Search web-search trace: query + sources read+ * Coding tool trace: files read, edits, commands+ *+ * The trace runs once, settles, and remains expandable.+ * ───────────────────────────────────────────────────────── */++const STAGES = [800, 600, 1800, 2600, 1600];++function useSequence(steps: number[]) {+ const [stage, setStage] = useState(0);+ useEffect(() => {+ if (stage >= steps.length - 1) return;+ const t = setTimeout(() => setStage((s) => s + 1), steps[stage]);+ return () => clearTimeout(t);+ }, [stage, steps]);+ return stage;+}++type Row = {+ primary: string;+ secondary?: string;+ mono?: boolean;+ add?: number;+ del?: number;+ href?: string;+};++const VARIANTS: Record<+ string,+ { active: string; done: string; rows: Row[]; query?: string }+> = {+ Steps: {+ active: "Thinking",+ done: "Thought for 4 seconds",+ rows: [+ { primary: "Reading flavor briefs" },+ { primary: "Scanning supplier lists" },+ { primary: "Comparing tasting notes", secondary: "6 flavors" },+ { primary: "Writing the scoop report" },+ ],+ },+ Reasoning: {+ active: "Thinking",+ done: "Thought for 4 seconds",+ rows: [+ { primary: "Summer demand spikes for stone-fruit flavors — peach and apricot lead." },+ { primary: "I should check cone inventory before promoting a waffle-bowl special." },+ ],+ },+ Search: {+ active: "Searching the web",+ done: "Searched the web",+ query: "best waffle cone supplier",+ rows: [+ { primary: "Joy Cone", secondary: "joycone.com", href: "https://joycone.com/fs_products/waffle-cones/" },+ { primary: "WebstaurantStore", secondary: "webstaurantstore.com", href: "https://www.webstaurantstore.com/ice-cream-shop-supplies.html" },+ { primary: "The Konery", secondary: "thekonery.com", href: "https://www.thekonery.com/" },+ ],+ },+ Coding: {+ active: "Running tools",+ done: "Ran 3 tools",+ rows: [+ { primary: "Read", secondary: "flavors.ts", mono: true },+ { primary: "Edit", secondary: "ChurnSchedule.tsx", mono: true, add: 74, del: 41 },+ { primary: "Run", secondary: "npm run freeze", mono: true },+ ],+ },+};++function Dot({ tone }: { tone: string }) {+ return (+ <span className={`flex size-3.5 shrink-0 items-center justify-center rounded-full text-white ${tone}`}>+ <svg width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <circle cx="12" cy="12" r="9" />+ <path d="M3.5 12h17M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18" />+ </svg>+ </span>+ );+}++const TONES = ["bg-accent", "bg-orange", "bg-green"];++export type ThinkingRow = {+ primary: string;+ secondary?: string;+ mono?: boolean;+ add?: number;+ del?: number;+ href?: string;+};++export default function ThinkingState({+ variant = "Steps",+ onSettled,+ rows,+ activeLabel,+ doneLabel,+ working: workingProp,+}: {+ variant?: string;+ onSettled?: () => void;+ /** Live rows from the agent. When set, the demo sequence is skipped. */+ rows?: ThinkingRow[];+ activeLabel?: string;+ doneLabel?: string;+ working?: boolean;+}) {+ const live = rows !== undefined;+ const stage = useSequence(live ? [0] : STAGES);+ const [manualExpanded, setManualExpanded] = useState<boolean | null>(null);+ const [selectedTool, setSelectedTool] = useState<string | null>(null);+ const canned = VARIANTS[variant] ?? VARIANTS.Steps;+ const v = {+ active: activeLabel ?? canned.active,+ done: doneLabel ?? canned.done,+ rows: rows ?? canned.rows,+ query: live ? undefined : canned.query,+ };+ const autoExpanded = live ? true : stage >= 1 && stage < 4;+ const expanded = manualExpanded ?? autoExpanded;+ const working = workingProp ?? (!live && stage < 3);+ const visible = live ? v.rows.length : stage < 2 ? 0 : stage === 2 ? Math.min(2, v.rows.length) : v.rows.length;+ const traceRef = useRef<HTMLDivElement>(null);+ const [lineHeight, setLineHeight] = useState(0);+ useLayoutEffect(() => {+ if (traceRef.current) setLineHeight(traceRef.current.offsetHeight);+ }, [visible, expanded, variant, stage]);++ /* let embedders sequence content after the trace settles */+ const settledRef = useRef(false);+ useEffect(() => {+ if (working || settledRef.current) return;+ settledRef.current = true;+ onSettled?.();+ }, [working, onSettled]);++ return (+ <div+ key={variant}+ className="flex w-full max-w-95 flex-col"+ style={{+ minHeight: working || expanded ? 176 : undefined,+ transition: "min-height 400ms cubic-bezier(0.23,1,0.32,1)",+ }}+ >+ {/* header — shared across variants */}+ <button+ type="button"+ aria-expanded={expanded}+ onClick={() => setManualExpanded((current) => !(current ?? autoExpanded))}+ className="-mx-1.5 flex w-fit items-center gap-2 rounded-control px-1.5 py-1+ transition-colors duration-100 hover:bg-hover-2"+ >+ <svg width="16" height="16" viewBox="0 0 24 24" fill={working ? "var(--ink-2)" : "var(--ink-3)"}>+ <path d="M12 2l2.4 7.2L22 12l-7.6 2.8L12 22l-2.4-7.2L2 12l7.6-2.8z" />+ </svg>+ <span role="status" className="contents">+ {working ? (+ <span+ className="bg-clip-text text-[13px] font-medium whitespace-nowrap text-transparent"+ style={{+ backgroundImage:+ "linear-gradient(90deg, var(--ink-3) 35%, var(--ink) 50%, var(--ink-3) 65%)",+ backgroundSize: "200% 100%",+ animation: "shimmer-text 1.4s linear infinite",+ }}+ >+ {v.active}+ </span>+ ) : (+ <span+ className="text-[13px] font-medium whitespace-nowrap text-ink-2"+ style={{ animation: "fade-in 350ms ease-out both" }}+ >+ {v.done}+ </span>+ )}+ </span>+ <svg+ width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--ink-3)" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"+ className="transition-transform duration-300"+ style={{ transform: expanded ? "rotate(180deg)" : "rotate(0)" }}+ >+ <path d="M6 9l6 6 6-6" />+ </svg>+ </button>++ {/* expandable trace */}+ <div+ className="grid transition-[grid-template-rows,opacity] duration-400"+ style={{+ gridTemplateRows: expanded ? "1fr" : "0fr",+ opacity: expanded ? 1 : 0,+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ }}+ >+ <div className="overflow-hidden">+ <div className="relative mt-1 ml-[5px] pl-4">+ <span+ aria-hidden+ className="absolute left-[3px] w-px bg-line"+ style={{ top: -8, height: lineHeight ? lineHeight - 2 : 0, transition: "height 500ms cubic-bezier(0.23,1,0.32,1)" }}+ />+ <div ref={traceRef} className="flex flex-col gap-1 py-1">+ {v.query && (+ <div className="flex h-6 items-center gap-2 px-1.5" style={{ animation: expanded ? "fade-up 300ms cubic-bezier(0.23,1,0.32,1) both" : undefined }}>+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--ink-3)" strokeWidth="2" strokeLinecap="round" className="shrink-0">+ <circle cx="11" cy="11" r="7" />+ <path d="M21 21l-4.3-4.3" />+ </svg>+ <span className="text-[12.5px] text-ink-2">{v.query}</span>+ </div>+ )}+ {v.rows.slice(0, visible).map((row, i) => {+ const content = (+ <>+ {variant === "Search" && <Dot tone={TONES[i % 3]} />}+ {variant === "Steps" && (+ i < visible - 1 || !working ? (+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--ink-3)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" className="shrink-0">+ <path d="M20 6L9 17l-5-5" />+ </svg>+ ) : (+ <span className="size-3 shrink-0 rounded-full border-[1.5px] border-line-strong border-t-ink-2" style={{ animation: "spin 700ms linear infinite" }} />+ )+ )}+ <span className={`min-w-0 truncate text-[12.5px] ${variant === "Reasoning" ? "whitespace-normal leading-relaxed text-ink-2" : "font-medium text-ink"} ${variant === "Search" ? "animated-underline" : ""}`}>+ {row.primary}+ </span>+ {row.secondary && (+ <span className={`shrink-0 text-[11.5px] text-ink-3 ${row.mono ? "font-mono" : ""}`}>+ {row.secondary}+ </span>+ )}+ {row.add !== undefined && (+ <span className="shrink-0 font-mono text-[11px] tabular-nums">+ <span className="text-green">+{row.add}</span>{" "}+ <span className="text-red">−{row.del}</span>+ </span>+ )}+ </>+ );+ const rowClass = "flex min-h-7 w-full items-center gap-2 rounded-[6px] px-1.5 py-0.5 text-left";+ const animation = { animation: `fade-up 320ms cubic-bezier(0.23,1,0.32,1) ${i * 120}ms both` };++ if (variant === "Search") {+ return (+ <a+ key={row.primary}+ href={row.href}+ target="_blank"+ rel="noreferrer"+ className={`${rowClass} transition-colors duration-150 hover:bg-hover`}+ style={animation}+ >+ {content}+ </a>+ );+ }++ if (variant === "Coding") {+ const selected = selectedTool === row.primary;+ return (+ <button+ key={row.primary}+ type="button"+ aria-pressed={selected}+ onClick={() => setSelectedTool(selected ? null : row.primary)}+ className={`${rowClass} transition-colors duration-150 ${selected ? "bg-inset" : "hover:bg-hover"}`}+ style={animation}+ >+ {content}+ </button>+ );+ }++ return (+ <div key={row.primary} className={rowClass} style={animation}>+ {content}+ </div>+ );+ })}+ {variant === "Search" && stage >= 3 && (+ <span className="text-[12px] text-ink-3" style={{ animation: "fade-in 300ms ease-out both" }}>+ +7 more+ </span>+ )}+ </div>+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/native/components/primitives/ToolChips.tsx b/apps/native/components/primitives/ToolChips.tsxnew file mode 100644index 00000000..4799e5a9--- /dev/null+++ b/apps/native/components/primitives/ToolChips.tsx@@ -0,0 +1,319 @@+"use client";++import { useEffect, useState } from "react";+import { createPortal } from "react-dom";++/* ─────────────────────────────────────────────────────────+ * TOOL CHIPS+ * An agent run as compact rows: tool calls with inline+ * chips, then file-diff chips summarizing the edits.+ * Hover a row to reveal its chevron; every row expands+ * to show what the tool actually did.+ * ───────────────────────────────────────────────────────── */++const STEP_MS = 700;++const Icons: Record<string, React.ReactNode> = {+ think: <path d="M12 2l2.4 7.2L22 12l-7.6 2.8L12 22l-2.4-7.2L2 12l7.6-2.8z" />,+ write: <g fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M17 3a2.8 2.8 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z" /></g>,+ run: <g fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M4 17l6-5-6-5M12 19h8" /></g>,+ read: <g fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><path d="M14 2v6h6" /></g>,+};++type DetailLine = { text: string; tone?: "add" };++const ROWS: { icon: string; label: string; chip: string; mono: boolean; detailMono: boolean; detail: DetailLine[] }[] = [+ {+ icon: "think", label: "Thinking", chip: "Planning the churn schedule…", mono: false, detailMono: false,+ detail: [+ { text: "Weekend demand carries pistachio, so it churns first." },+ { text: "Batch capacity leaves two evening freezer windows." },+ ],+ },+ {+ icon: "write", label: "Write 204 lines", chip: "ChurnSchedule.tsx", mono: true, detailMono: true,+ detail: [+ { text: "+ const windows = slots.filter((s) => s.temp <= -12)", tone: "add" },+ { text: "+ return schedule(windows, { hero: \"pistachio\" })", tone: "add" },+ ],+ },+ {+ icon: "run", label: "Rebuild and verify", chip: "npm run freeze", mono: true, detailMono: true,+ detail: [+ { text: "✓ built in 1.2s" },+ { text: "✓ 34 checks passed" },+ ],+ },+ {+ icon: "read", label: "Read image", chip: "flavor-chart.png", mono: true, detailMono: false,+ detail: [+ { text: "1280 × 720 · line chart, three summers." },+ { text: "Mint chip trends up 12% through July." },+ ],+ },+];++const DIFFS = [+ { file: "flavors.css", add: 13, del: 0 },+ { file: "ChurnSchedule.tsx", add: 74, del: 41 },+ { file: "menu.ts", add: 8, del: 2 },+];++/* hovering a file chip opens its diff — green added, red removed */+type DiffLine = { text: string; tone: "add" | "del" | "ctx" };+const DIFF_LINES: Record<string, DiffLine[]> = {+ "flavors.css": [+ { text: ".scoop-card {", tone: "ctx" },+ { text: " gap: 14px;", tone: "del" },+ { text: " gap: 12px;", tone: "add" },+ { text: " container-type: inline-size;", tone: "add" },+ { text: "}", tone: "ctx" },+ ],+ "ChurnSchedule.tsx": [+ { text: "const slots = coldSlots(week);", tone: "ctx" },+ { text: "const windows = slots;", tone: "del" },+ { text: "const windows = slots.filter(", tone: "add" },+ { text: " (s) => s.temp <= -12,", tone: "add" },+ { text: ");", tone: "add" },+ ],+ "menu.ts": [+ { text: "export const hero = \"mint-chip\";", tone: "del" },+ { text: "export const hero = \"pistachio\";", tone: "add" },+ ],+};++export type LiveToolRow = {+ id?: string;+ icon: string;+ label: string;+ chip: string;+ mono?: boolean;+ detailMono?: boolean;+ detail: { text: string; tone?: "add" }[];+};++export type LiveDiff = {+ file: string;+ add: number;+ del: number;+ lines?: { text: string; tone: "add" | "del" | "ctx" }[];+};++export default function ToolChips({+ rows: liveRows,+ diffs: liveDiffs,+}: {+ rows?: LiveToolRow[];+ diffs?: LiveDiff[];+} = {}) {+ const live = liveRows !== undefined;+ const rows = live ? liveRows : ROWS;+ const diffs = live ? (liveDiffs ?? []) : DIFFS;+ const diffLines: Record<string, { text: string; tone: "add" | "del" | "ctx" }[]> = live+ ? Object.fromEntries((liveDiffs ?? []).map((d) => [d.file, d.lines ?? []]))+ : DIFF_LINES;+ const [step, setStep] = useState(0);+ const [open, setOpen] = useState(true);+ const [openRows, setOpenRows] = useState<Set<string>>(new Set());+ /* Rendered in a body portal so animated/translated reply wrappers cannot+ * redefine the fixed-position coordinate system. */+ const [preview, setPreview] = useState<{+ file: string;+ x: number;+ top?: number;+ bottom?: number;+ } | null>(null);+ const openPreview = (file: string) => (event: React.SyntheticEvent) => {+ const rect = (event.currentTarget as Element).closest("[data-diffchip]")!.getBoundingClientRect();+ const previewHeight = 38 + (diffLines[file]?.length ?? 0) * 19;+ const fitsBelow = rect.bottom + 6 + previewHeight <= window.innerHeight - 12;+ setPreview({+ file,+ x: Math.max(12, Math.min(rect.left, window.innerWidth - 300)),+ ...(fitsBelow+ ? { top: rect.bottom + 6 }+ : { bottom: window.innerHeight - rect.top + 6 }),+ });+ };+ const closePreview = (file: string) => () =>+ setPreview((current) => (current?.file === file ? null : current));+ const total = live ? rows.length : ROWS.length + 1; // rows, then diff chips++ useEffect(() => {+ if (live) return;+ if (step >= total) return;+ const t = setTimeout(() => setStep((s) => s + 1), STEP_MS);+ return () => clearTimeout(t);+ }, [step, total, live]);++ const toggleRow = (label: string) =>+ setOpenRows((current) => {+ const next = new Set(current);+ next.has(label) ? next.delete(label) : next.add(label);+ return next;+ });++ return (+ <div className="min-h-[220px] w-full max-w-80 pb-1">+ {/* collapsed run header */}+ <button+ type="button"+ aria-expanded={open}+ onClick={() => setOpen((current) => !current)}+ className="-mx-1.5 flex w-fit items-center gap-1.5 rounded-control px-1.5 py-1 text-[12.5px] text-ink-2 transition-colors duration-100 hover:bg-hover-2"+ >+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" className="transition-transform duration-200" style={{ transform: open ? "rotate(0deg)" : "rotate(-90deg)" }}>+ <path d="M6 9l6 6 6-6" />+ </svg>+ <span className="tabular-nums">{live ? `${rows.length} tool calls` : "4 tool calls, 2 messages"}</span>+ </button>++ {/* tool call rows */}+ <div className="grid transition-[grid-template-rows,opacity] duration-300" style={{ gridTemplateRows: open ? "1fr" : "0fr", opacity: open ? 1 : 0 }}>+ {/* -mx-1 + px-1.5 keeps content at the same x while giving the+ row hover pills room inside this overflow-hidden clip box */}+ <div className="-mx-1 overflow-hidden px-1.5 pb-1">+ <div className="mt-1.5 flex flex-col gap-1">+ {(live ? rows : rows.slice(0, step)).map((row) => {+ const rowOpen = openRows.has(row.label);+ return (+ <div key={"id" in row && row.id ? row.id : row.label} style={{ animation: "fade-up 300ms cubic-bezier(0.23,1,0.32,1) both" }}>+ <button+ type="button"+ aria-expanded={rowOpen}+ onClick={() => toggleRow(row.label)}+ className="group/row -mx-[3px] flex h-7 w-[calc(100%+6px)] min-w-0 items-center gap-2 rounded-control px-[3px] text-left transition-colors duration-100 hover:bg-hover-2"+ >+ <span className="relative flex size-4 shrink-0 items-center justify-center text-ink-3">+ <svg+ width="13" height="13" viewBox="0 0 24 24" fill={row.icon === "think" ? "currentColor" : "none"} stroke="currentColor"+ className={`transition-opacity duration-100 group-hover/row:opacity-0 ${rowOpen ? "opacity-0" : ""}`}+ >+ {Icons[row.icon]}+ </svg>+ <svg+ width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"+ className={`absolute transition-[opacity,transform] duration-150 group-hover/row:opacity-100 ${rowOpen ? "opacity-100" : "opacity-0"}`}+ style={{ transform: rowOpen ? "rotate(0deg)" : "rotate(-90deg)" }}+ >+ <path d="M6 9l6 6 6-6" />+ </svg>+ </span>+ <span className="shrink-0 text-[12.5px] font-medium text-ink">{row.label}</span>+ <span+ className={`inline-flex h-5.5 min-w-0 flex-1 cursor-pointer items-center truncate rounded-chip bg-field px-1.5+ text-[11.5px] text-ink-2 shadow-hairline transition-colors duration-100 hover:bg-hover-2+ ${row.mono ? "font-mono" : ""}`}+ >+ {row.chip}+ </span>+ </button>++ {/* expanded detail */}+ <div+ className="grid transition-[grid-template-rows,opacity] duration-300"+ style={{ gridTemplateRows: rowOpen ? "1fr" : "0fr", opacity: rowOpen ? 1 : 0, transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)" }}+ >+ <div className="min-h-0 overflow-hidden">+ <div className="mt-0.5 mb-1 ml-2 flex flex-col gap-0.5 border-l border-line py-0.5 pl-3.5">+ {row.detail.map((line) => (+ <span+ key={line.text}+ className={`truncate text-[11.5px] leading-[1.6] ${row.detailMono ? "font-mono" : ""} ${line.tone === "add" ? "text-green" : "text-ink-2"}`}+ >+ {line.text}+ </span>+ ))}+ </div>+ </div>+ </div>+ </div>+ );+ })}+ </div>++ {/* file-diff chips */}+ {(live ? diffs.length > 0 : step >= total) && (+ <div className="mt-2.5 flex max-w-full flex-wrap gap-1.5 border-t border-line pt-2.5">+ {diffs.map((d, i) => (+ <span+ key={d.file}+ data-diffchip+ className="relative"+ onMouseEnter={openPreview(d.file)}+ onMouseLeave={closePreview(d.file)}+ >+ <button+ type="button"+ aria-expanded={preview?.file === d.file}+ aria-label={`Show diff for ${d.file}`}+ onFocus={openPreview(d.file)}+ onBlur={closePreview(d.file)}+ className="inline-flex h-7 max-w-full items-center gap-1.5 rounded-chip+ bg-surface px-2 font-mono text-[11.5px] text-ink shadow-btn+ transition-colors duration-100 hover:bg-hover"+ style={{ animation: `pop-in 250ms cubic-bezier(0.23,1,0.32,1) ${i * 80}ms both` }}+ >+ <span className="min-w-0 truncate">{d.file}</span>+ <span className="shrink-0 text-green tabular-nums">+{d.add}</span>+ {d.del > 0 && <span className="shrink-0 text-red tabular-nums">−{d.del}</span>}+ </button>++ </span>+ ))}+ <button+ type="button"+ className="inline-flex h-7 items-center rounded-chip px-1.5 font-mono text-[11.5px] text-ink-3+ underline decoration-transparent underline-offset-2 transition-colors duration-100+ hover:text-ink-2 hover:decoration-current"+ style={{ animation: `fade-in 300ms ease-out ${DIFFS.length * 80}ms both` }}+ >+ {live ? `${diffs.length} files` : "+2 more"}+ </button>+ </div>+ )}+ </div>+ </div>+ {preview && typeof document !== "undefined" && createPortal(+ <div+ className="fixed z-50 w-72 overflow-hidden rounded-[10px] bg-surface shadow-overlay"+ style={{+ left: preview.x,+ top: preview.top,+ bottom: preview.bottom,+ animation: "pop-in 160ms cubic-bezier(0.23,1,0.32,1) both",+ transformOrigin: preview.top === undefined ? "bottom left" : "top left",+ }}+ >+ <div className="flex items-center justify-between border-b border-line px-2.5 py-1.5 font-mono text-[11px]">+ <span className="min-w-0 truncate text-ink-2">{preview.file}</span>+ <span className="shrink-0 tabular-nums">+ <span className="text-green">+{diffs.find((diff) => diff.file === preview.file)?.add}</span>+ {(diffs.find((diff) => diff.file === preview.file)?.del ?? 0) > 0 && (+ <span className="text-red"> −{diffs.find((diff) => diff.file === preview.file)?.del}</span>+ )}+ </span>+ </div>+ <div className="py-1 font-mono text-[11px] leading-[1.8]">+ {(diffLines[preview.file] ?? []).map((line, index) => (+ <div+ key={index}+ className={`flex gap-2 px-2.5 whitespace-pre ${+ line.tone === "add"+ ? "bg-green-tint text-green"+ : line.tone === "del"+ ? "bg-red-tint text-red"+ : "text-ink-2"+ }`}+ >+ <span className="w-3 shrink-0 select-none">{line.tone === "add" ? "+" : line.tone === "del" ? "−" : " "}</span>+ <span className="min-w-0 truncate">{line.text}</span>+ </div>+ ))}+ </div>+ </div>,+ document.body,+ )}+ </div>+ );+}diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsxnew file mode 100644index 00000000..7bc05e10--- /dev/null+++ b/apps/native/components/site/GraffHarness.tsx@@ -0,0 +1,528 @@+"use client";++import { useEffect, useRef, useState, type CSSProperties } from "react";+import ApprovalCard from "@/components/primitives/ApprovalCard";+import LoadingState from "@/components/primitives/LoadingState";+import PromptBar from "@/components/primitives/PromptBar";+import SidebarNav from "@/components/primitives/SidebarNav";+import StreamingText from "@/components/primitives/StreamingText";+import TaskRows from "@/components/primitives/TaskRows";+import ThinkingState from "@/components/primitives/ThinkingState";+import ToolChips from "@/components/primitives/ToolChips";+import { ThemeToggle } from "@/components/site/ThemeToggle";+import {+ MODELS,+ STARTER_PROMPTS,+ answer,+ cancel,+ chat,+ checkHealth,+ createSession,+ setModel,+ type Health,+} from "@/lib/graff-client";+import {+ applyEvent,+ emptyTurn,+ type AssistantTurn,+} from "@/lib/graff-events";++const NAME = "there";++const HOME_REVEAL = {+ offsetY: 23,+ blur: 17,+ duration: 800,+ easing: "cubic-bezier(0.16, 1, 0.3, 1)",+};++function homeRevealStyle(visible: boolean): CSSProperties {+ return {+ opacity: visible ? 1 : 0,+ transform: visible ? "translate3d(0, 0, 0)" : `translate3d(0, ${HOME_REVEAL.offsetY}px, 0)`,+ filter: visible ? "blur(0px)" : `blur(${HOME_REVEAL.blur}px)`,+ transition: ["opacity", "transform", "filter"]+ .map((property) => `${property} ${HOME_REVEAL.duration}ms ${HOME_REVEAL.easing}`)+ .join(", "),+ };+}++function UserBubble({ text }: { text: string }) {+ return (+ <div className="flex justify-end pl-10 sm:pl-24" style={{ animation: "fade-up 300ms cubic-bezier(0.23,1,0.32,1) both" }}>+ <div className="rounded-xl bg-field px-3.5 py-2 text-[13px] leading-relaxed text-ink shadow-hairline">{text}</div>+ </div>+ );+}++function AssistantBody({+ turn,+ onAnswer,+}: {+ turn: AssistantTurn;+ onAnswer: (text: string, callId?: string) => void;+}) {+ const reasoningRows = turn.reasoning+ ? turn.reasoning+ .split(/\n+/)+ .map((line) => line.trim())+ .filter(Boolean)+ .map((primary) => ({ primary }))+ : [];+ const toolRows = turn.tools.map((tool) => ({+ id: tool.id,+ icon: tool.icon,+ label: tool.name,+ chip: tool.chip,+ mono: tool.icon === "run" || tool.icon === "write" || tool.icon === "read",+ detailMono: tool.icon === "run" || tool.icon === "write",+ detail: tool.detail,+ }));++ return (+ <article className="min-w-0" style={{ animation: "fade-up 450ms cubic-bezier(0.23,1,0.32,1) both" }}>+ {(turn.status === "thinking" || reasoningRows.length > 0) && (+ <ThinkingState+ variant="Reasoning"+ rows={reasoningRows.length ? reasoningRows : [{ primary: "Waiting on the model…" }]}+ activeLabel={turn.model ? `Thinking · ${turn.model}` : "Thinking"}+ doneLabel={turn.status === "thinking" ? "Thinking" : "Thought"}+ working={turn.status === "thinking"}+ />+ )}+ {toolRows.length > 0 && (+ <div className="mt-4">+ <ToolChips rows={toolRows} diffs={turn.diffs} />+ </div>+ )}+ {(turn.text || turn.status === "streaming") && (+ <div className="mt-4 max-w-[630px]">+ <StreamingText+ fill+ loop={false}+ text={turn.text}+ streaming={turn.status === "streaming" || turn.status === "thinking"}+ />+ </div>+ )}+ {turn.ask && (+ <div className="mt-5">+ <ApprovalCard+ resettable={false}+ questions={[+ {+ q: turn.ask.question,+ type: "radio",+ options: ["Continue", "Skip"],+ },+ ]}+ onSubmitted={(answers) => {+ const text = answers?.[0] && answers[0] !== "Skip" ? answers[0] : answers?.[0] === "Skip" ? "" : "continue";+ onAnswer(text || "continue", turn.ask?.callId);+ }}+ />+ </div>+ )}+ {turn.error && (+ <p className="mt-4 max-w-[620px] text-[13.5px] leading-[1.65] text-red">{turn.error}</p>+ )}+ {turn.recap && turn.status === "done" && (+ <p className="mt-3 text-[12px] text-ink-3">{turn.recap}</p>+ )}+ {turn.costUsd !== undefined && turn.status === "done" && (+ <p className="mt-1 font-mono text-[11px] text-ink-3">${turn.costUsd.toFixed(4)}</p>+ )}+ </article>+ );+}++type Msg =+ | { id: number; role: "user"; text: string }+ | { id: number; role: "assistant"; turn: AssistantTurn };++type Chat = { id: number; title: string | null; messages: Msg[] };++function EmptyState({+ onSend,+ health,+ offset,+ shuffle,+}: {+ onSend: (text: string) => void;+ health: Health | null;+ offset: number;+ shuffle: () => void;+}) {+ const shown = [0, 1, 2].map((i) => STARTER_PROMPTS[(offset + i) % STARTER_PROMPTS.length]);+ const [stage, setStage] = useState(0);+ useEffect(() => {+ const timers = [+ setTimeout(() => setStage(1), 170),+ setTimeout(() => setStage(2), 330),+ setTimeout(() => setStage(3), 400),+ setTimeout(() => setStage(4), 550),+ ];+ return () => timers.forEach(clearTimeout);+ }, []);++ return (+ <div className="mx-auto flex min-h-full max-w-[720px] flex-col justify-center px-4 py-10 sm:px-8">+ <h1 className="text-[26px] font-normal tracking-[-0.02em] text-ink">+ <span className="home-reveal block text-ink-3" style={homeRevealStyle(stage >= 1)}>+ Hello {NAME}+ </span>+ <span className="home-reveal block" style={homeRevealStyle(stage >= 2)}>+ What should graff work on?+ </span>+ </h1>++ <div className="home-reveal relative mt-7" style={homeRevealStyle(stage >= 3)}>+ <PromptBar+ demo={false}+ tall+ placeholder="Ask graff to read, edit, or review this workspace…"+ models={MODELS}+ onSend={onSend}+ disabled={health !== null && !health.ok}+ />+ {health && !health.ok && (+ <p className="mt-3 text-[12.5px] text-orange">+ graff serve is not reachable. From the repo root run{" "}+ <span className="font-mono text-ink">graff serve --port 8787</span>+ {health.detail ? ` — ${health.detail}` : ""}.+ </p>+ )}+ </div>++ <div className="home-reveal mt-6 flex flex-col" style={homeRevealStyle(stage >= 4)}>+ {shown.map((item) => (+ <button+ key={item.id}+ type="button"+ onClick={() => onSend(item.prompt)}+ className="-mx-2 flex items-center gap-3 rounded-control px-2 py-2.5 text-left text-[14px] text-ink transition-colors duration-150 hover:bg-hover"+ >+ <span className="text-ink-3">+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round" aria-hidden>+ <path d="M8 6l-5 6 5 6M16 6l5 6-5 6" />+ </svg>+ </span>+ <span className="min-w-0 truncate">{item.label}</span>+ </button>+ ))}+ <div className="mt-1 flex items-center gap-5 pl-0.5 text-[13px] text-ink-3">+ <span className="flex items-center gap-2 py-1">+ <span className={`size-1.5 rounded-full ${health?.ok ? "bg-green" : "bg-orange"}`} />+ {health?.ok ? "Connected to graff serve" : "Waiting for graff serve"}+ </span>+ <button type="button" onClick={shuffle} className="flex items-center gap-2 py-1 transition-colors duration-150 hover:text-ink">+ Shuffle suggestions+ </button>+ </div>+ </div>+ </div>+ );+}++export default function GraffHarness() {+ const [chats, setChats] = useState<Chat[]>([{ id: 1, title: null, messages: [] }]);+ const [activeId, setActiveId] = useState(1);+ const [offset, setOffset] = useState(0);+ const [health, setHealth] = useState<Health | null>(null);+ const [sessionId, setSessionId] = useState<string | null>(null);+ const [model, setModelKey] = useState(process.env.NEXT_PUBLIC_GRAFF_MODEL || MODELS[0].key);+ const [busy, setBusy] = useState(false);+ const chatIdRef = useRef(1);+ const msgIdRef = useRef(0);+ const sessionRef = useRef<string | null>(null);+ const scrollRef = useRef<HTMLDivElement>(null);++ const chatThread = chats.find((c) => c.id === activeId) ?? chats[0];+ const active = chatThread.messages.length > 0;+ const lastAssistant = [...chatThread.messages].reverse().find((m): m is Extract<Msg, { role: "assistant" }> => m.role === "assistant");++ useEffect(() => {+ let cancelled = false;+ (async () => {+ const h = await checkHealth();+ if (cancelled) return;+ setHealth(h);+ if (!h.ok) return;+ try {+ const info = await createSession({ model, yolo: true });+ if (cancelled) return;+ sessionRef.current = info.session_id;+ setSessionId(info.session_id);+ } catch (err) {+ if (!cancelled) {+ setHealth({ ok: false, detail: err instanceof Error ? err.message : String(err) });+ }+ }+ })();+ return () => {+ cancelled = true;+ };+ // session is created once per mount; model changes go through set_model+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);++ const patchAssistant = (chatId: number, msgId: number, next: AssistantTurn) => {+ setChats((current) =>+ current.map((c) =>+ c.id !== chatId+ ? c+ : {+ ...c,+ messages: c.messages.map((m) => (m.role === "assistant" && m.id === msgId ? { ...m, turn: next } : m)),+ },+ ),+ );+ };++ const ensureSession = async (): Promise<string> => {+ if (sessionRef.current) return sessionRef.current;+ const info = await createSession({ model, yolo: true });+ sessionRef.current = info.session_id;+ setSessionId(info.session_id);+ setHealth({ ok: true });+ return info.session_id;+ };++ const send = async (text: string) => {+ const trimmed = text.trim();+ if (!trimmed || busy) return;+ const userId = (msgIdRef.current += 1);+ const asstId = (msgIdRef.current += 1);+ const title = chatThread.title ?? (trimmed.length > 30 ? `${trimmed.slice(0, 30).trimEnd()}…` : trimmed);+ setChats((current) =>+ current.map((c) =>+ c.id !== chatThread.id+ ? c+ : {+ ...c,+ title,+ messages: [+ ...c.messages,+ { id: userId, role: "user", text: trimmed },+ { id: asstId, role: "assistant", turn: emptyTurn() },+ ],+ },+ ),+ );+ setBusy(true);+ let turn = emptyTurn();+ try {+ const id = await ensureSession();+ for await (const ev of chat(id, trimmed)) {+ turn = applyEvent(turn, ev);+ patchAssistant(chatThread.id, asstId, turn);+ }+ } catch (err) {+ turn = applyEvent(turn, { type: "error", message: err instanceof Error ? err.message : String(err) });+ patchAssistant(chatThread.id, asstId, turn);+ } finally {+ setBusy(false);+ }+ };++ const answerAsk = async (text: string, callId?: string) => {+ const id = sessionRef.current;+ if (!id || !lastAssistant) return;+ try {+ await answer(id, { text, callId });+ patchAssistant(chatThread.id, lastAssistant.id, { ...lastAssistant.turn, ask: undefined, status: "streaming" });+ } catch (err) {+ patchAssistant(chatThread.id, lastAssistant.id, {+ ...lastAssistant.turn,+ error: err instanceof Error ? err.message : String(err),+ status: "error",+ });+ }+ };++ const newChat = () => {+ const id = (chatIdRef.current += 1);+ setChats((current) => [...current, { id, title: null, messages: [] }]);+ setActiveId(id);+ };++ const closeChat = (id: number) => {+ const remaining = chats.filter((c) => c.id !== id);+ if (remaining.length === 0) {+ const nid = (chatIdRef.current += 1);+ setChats([{ id: nid, title: null, messages: [] }]);+ setActiveId(nid);+ return;+ }+ setChats(remaining);+ if (id === activeId) setActiveId(remaining[remaining.length - 1].id);+ };++ const pickRecent = (_id: string, label: string, prompt?: string) => {+ const existing = chats.find((c) => c.title === label);+ if (existing) {+ setActiveId(existing.id);+ return;+ }+ if (chatThread.messages.length === 0) {+ void send(prompt ?? label);+ return;+ }+ const id = (chatIdRef.current += 1);+ setChats((current) => [...current, { id, title: null, messages: [] }]);+ setActiveId(id);+ queueMicrotask(() => void send(prompt ?? label));+ };++ useEffect(() => {+ if (!active) return;+ const el = scrollRef.current;+ if (el) el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });+ }, [chatThread.messages, active, lastAssistant?.turn.text, lastAssistant?.turn.tools.length]);++ const recents = [+ ...STARTER_PROMPTS.map((p) => ({ id: p.id, label: p.label, prompt: p.prompt })),+ ...chats.filter((c) => c.title).map((c) => ({ id: `chat-${c.id}`, label: c.title as string, prompt: undefined })),+ ];++ const tabBar = (+ <div className="flex h-11 shrink-0 items-center gap-1 overflow-x-auto border-b border-line px-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">+ {chats.map((c) => (+ <div+ key={c.id}+ className={`group/tab flex h-7 w-36 shrink-0 items-center gap-0.5 rounded-[7px] pl-2.5 pr-1 text-[12.5px] font-medium transition-colors duration-100 ${+ c.id === activeId ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover hover:text-ink"+ }`}+ >+ <button type="button" aria-pressed={c.id === activeId} onClick={() => setActiveId(c.id)} title={c.title ?? "New chat"} className="min-w-0 flex-1 text-left">+ <span className="block truncate">{c.title ?? "New chat"}</span>+ </button>+ <button+ type="button"+ aria-label="Close tab"+ onClick={() => closeChat(c.id)}+ className="-my-1 flex size-6 shrink-0 items-center justify-center rounded-[5px] text-ink-3 transition-[background-color,color] duration-100 hover:bg-hover-2 hover:text-ink"+ >+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" aria-hidden>+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ </div>+ ))}+ <button+ type="button"+ aria-label="New chat"+ onClick={newChat}+ className="ml-0.5 flex size-7 shrink-0 items-center justify-center rounded-[7px] text-ink-3 transition-colors duration-100 hover:bg-hover hover:text-ink"+ >+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden>+ <path d="M12 5v14M5 12h14" />+ </svg>+ </button>+ <div className="ml-auto flex items-center gap-2 pr-1">+ <ThemeToggle />+ </div>+ </div>+ );++ const paneTodos = lastAssistant?.turn.todos ?? [];++ return (+ <main className="flex h-[100dvh] gap-0 bg-canvas p-2.5 text-ink lg:pl-0">+ <SidebarNav+ fill+ className="hidden lg:flex"+ recents={recents}+ activeTitle={chatThread.title}+ onPick={pickRecent}+ onNewChat={newChat}+ footerLabel={sessionId ? `Session ${sessionId.slice(0, 8)}` : "Connecting…"}+ onFooterClick={() => undefined}+ />++ <div className="flex min-w-0 flex-1 flex-col gap-2.5">+ <div className="flex min-h-0 flex-1 gap-2.5">+ <section className="flex min-w-0 flex-1 flex-col overflow-hidden rounded-[14px] border border-line bg-page">+ {tabBar}+ {active ? (+ <div className="flex min-h-0 flex-1 flex-col">+ <div ref={scrollRef} className="min-h-0 flex-1 overflow-y-auto overscroll-contain">+ <div className="mx-auto flex w-full max-w-[720px] flex-col gap-8 px-4 py-8 sm:px-8">+ {chatThread.messages.map((message) =>+ message.role === "user" ? (+ <UserBubble key={message.id} text={message.text} />+ ) : (+ <AssistantBody key={message.id} turn={message.turn} onAnswer={answerAsk} />+ ),+ )}+ {busy && lastAssistant?.turn.status === "thinking" && !lastAssistant.turn.reasoning && (+ <div className="flex min-h-6 items-center">+ <LoadingState label="Thinking" variant="Dots" />+ </div>+ )}+ </div>+ </div>+ <div className="shrink-0 bg-page px-4 pt-3 pb-6 sm:px-8">+ <div className="mx-auto max-w-[720px]">+ <PromptBar+ demo={false}+ tall+ placeholder={busy ? "Agent is working…" : "Reply"}+ models={MODELS}+ modelKey={model}+ onModelChange={(key) => {+ setModelKey(key);+ if (sessionRef.current) void setModel(sessionRef.current, key);+ }}+ onSend={send}+ disabled={busy}+ />+ {busy && (+ <button+ type="button"+ onClick={() => sessionRef.current && void cancel(sessionRef.current)}+ className="mt-2 text-[12px] text-ink-3 transition-colors hover:text-ink"+ >+ Cancel turn+ </button>+ )}+ </div>+ </div>+ </div>+ ) : (+ <div className="min-h-0 flex-1 overflow-y-auto">+ <EmptyState+ onSend={send}+ health={health}+ offset={offset}+ shuffle={() => setOffset((current) => (current + 3) % STARTER_PROMPTS.length)}+ />+ </div>+ )}+ </section>++ {active && paneTodos.length > 0 && (+ <aside+ className="hidden w-[360px] shrink-0 flex-col overflow-hidden rounded-[14px] border border-line bg-page lg:flex"+ style={{ animation: "fade-in 300ms ease both" }}+ >+ <div className="flex h-11 shrink-0 items-center border-b border-line px-4">+ <span className="text-[13px] font-semibold text-ink">Tasks</span>+ </div>+ <div className="min-h-0 flex-1 overflow-y-auto p-4">+ <TaskRows+ variant="List"+ items={paneTodos.map((todo) => ({+ key: todo.id,+ label: todo.content,+ status: todo.status === "in_progress" ? "in_progress" : todo.status === "completed" ? "completed" : "pending",+ }))}+ />+ </div>+ </aside>+ )}+ </div>+ </div>+ </main>+ );+}diff --git a/apps/native/components/site/ThemeSync.tsx b/apps/native/components/site/ThemeSync.tsxnew file mode 100644index 00000000..c6baf470--- /dev/null+++ b/apps/native/components/site/ThemeSync.tsx@@ -0,0 +1,19 @@+"use client";++import { useEffect } from "react";++/* React 19 reconciles <html>'s className during hydration, wiping the class+ * the pre-paint head script set. This re-applies the stored theme the moment+ * hydration finishes, on every page. */+export function ThemeSync() {+ useEffect(() => {+ try {+ const theme = localStorage.getItem("bui-theme");+ document.documentElement.classList.toggle("dark", theme !== "light");+ } catch {+ document.documentElement.classList.add("dark");+ }+ }, []);++ return null;+}diff --git a/apps/native/components/site/ThemeToggle.tsx b/apps/native/components/site/ThemeToggle.tsxnew file mode 100644index 00000000..9065dd69--- /dev/null+++ b/apps/native/components/site/ThemeToggle.tsx@@ -0,0 +1,69 @@+"use client";++import { useEffect, useState } from "react";++/** Sun/moon segmented pill from the refs. */+export function ThemeToggle() {+ const [dark, setDark] = useState<boolean | null>(null);++ useEffect(() => {+ /* localStorage is the source of truth — the html class can be stale+ * for a moment around hydration (see ThemeSync). */+ try {+ setDark(localStorage.getItem("bui-theme") !== "light");+ } catch {+ setDark(document.documentElement.classList.contains("dark"));+ }+ }, []);++ function apply(next: boolean) {+ if (next === dark) return;+ setDark(next);+ /* freeze all transitions while every token flips, so the theme change+ * is one clean swap instead of hundreds of mismatched color fades */+ const root = document.documentElement;+ root.classList.add("theme-switching");+ root.classList.toggle("dark", next);+ requestAnimationFrame(() => requestAnimationFrame(() => root.classList.remove("theme-switching")));+ try {+ localStorage.setItem("bui-theme", next ? "dark" : "light");+ } catch {}+ }++ return (+ <div className="relative inline-grid h-9 grid-cols-2 items-center rounded-full bg-field p-0.5">+ <span+ aria-hidden+ className="absolute inset-y-0.5 left-0.5 w-8 rounded-full bg-surface shadow-btn+ transition-transform duration-200"+ style={{+ transform: dark ? "translateX(32px)" : "translateX(0)",+ transitionTimingFunction: "cubic-bezier(0.23, 1, 0.32, 1)",+ opacity: dark === null ? 0 : 1,+ }}+ />+ <button+ aria-label="Light mode"+ onClick={() => apply(false)}+ className={`relative z-10 flex size-8 items-center justify-center rounded-full+ transition-colors duration-150 ${dark ? "text-ink-3 hover:text-ink-2" : "text-ink"}`}+ >+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round">+ <circle cx="12" cy="12" r="4" fill="currentColor" stroke="none" />+ <path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" />+ </svg>+ </button>+ <button+ aria-label="Dark mode"+ onClick={() => apply(true)}+ className={`relative z-10 flex size-8 items-center justify-center rounded-full+ transition-colors duration-150 ${dark ? "text-ink" : "text-ink-3 hover:text-ink-2"}`}+ >+ <svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor">+ <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />+ </svg>+ </button>++ </div>+ );+}diff --git a/apps/native/desktop/Info.plist b/apps/native/desktop/Info.plistnew file mode 100644index 00000000..ed746a66--- /dev/null+++ b/apps/native/desktop/Info.plist@@ -0,0 +1,24 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>CFBundleName</key>+ <string>Codegraff</string>+ <key>CFBundleDisplayName</key>+ <string>Codegraff</string>+ <key>CFBundleIdentifier</key>+ <string>dev.codegraff.native</string>+ <key>CFBundleVersion</key>+ <string>0.1.0</string>+ <key>CFBundleShortVersionString</key>+ <string>0.1.0</string>+ <key>CFBundleExecutable</key>+ <string>graff-native</string>+ <key>CFBundlePackageType</key>+ <string>APPL</string>+ <key>LSMinimumSystemVersion</key>+ <string>13.0</string>+ <key>NSHighResolutionCapable</key>+ <true/>+</dict>+</plist>diff --git a/apps/native/desktop/README.md b/apps/native/desktop/README.mdnew file mode 100644index 00000000..b43b1d1b--- /dev/null+++ b/apps/native/desktop/README.md@@ -0,0 +1,23 @@+# merjs desktop shell++Native window for the Beautiful UI harness. The interop is the merjs+`examples/desktop` pattern (Zig → ObjC runtime → `NSWindow` + `WKWebView`,+no Electron, no merjs SSR). merjs itself stays a separate repo; we only+copied the window shell.++```bash+# UI + graff serve (any OS)+cd apps/native && npm install && npm run dev+# in another terminal, from the repo root+./zig-out/bin/graff serve --port 8787++# macOS window (after the UI is listening)+zig build-exe apps/native/desktop/main.zig -O ReleaseSmall \+ -femit-bin=zig-out/bin/graff-native \+ -framework AppKit -framework WebKit+GRAFF_NATIVE_URL=http://127.0.0.1:3000 ./zig-out/bin/graff-native+```++On Linux the same `main.zig` prints the URL and tries `xdg-open`. WKWebView+is macOS-only — that is a merjs limitation, not a graff one. The existing+Tauri app in `gui/` is unchanged.diff --git a/apps/native/desktop/main.zig b/apps/native/desktop/main.zignew file mode 100644index 00000000..d3397aeb--- /dev/null+++ b/apps/native/desktop/main.zig@@ -0,0 +1,133 @@+//! merjs-style native shell for the Codegraff Beautiful UI harness.+//!+//! Copied from merjs `examples/desktop/main.zig` (ObjC / WKWebView, no+//! Electron): open a native window onto a local URL. Here the URL is the+//! Next.js UI (`apps/native`) instead of a merjs SSR server. On macOS this+//! is an NSWindow + WKWebView. Elsewhere it prints the URL (and tries+//! xdg-open) so the same binary is useful on Linux CI/dev hosts.+//!+//! zig build-exe apps/native/desktop/main.zig -O ReleaseSmall -femit-bin=zig-out/bin/graff-native+//! GRAFF_NATIVE_URL=http://127.0.0.1:3000 ./zig-out/bin/graff-native+const std = @import("std");+const builtin = @import("builtin");++fn openLinux(url: []const u8) void {+ std.log.info("merjs-style shell: open {s} in a browser (WKWebView is macOS-only)", .{url});+}++pub fn main(init: std.process.Init) !void {+ const url = init.environ_map.get("GRAFF_NATIVE_URL") orelse "http://127.0.0.1:3000";+ if (comptime builtin.os.tag == .macos) {+ try runMac(url);+ } else {+ openLinux(url);+ }+}++// ── macOS AppKit / WKWebView (merjs examples/desktop) ─────────────────++extern fn objc_getClass(name: [*:0]const u8) ?*anyopaque;+extern fn sel_registerName(name: [*:0]const u8) ?*anyopaque;+extern fn objc_msgSend() void;++const Id = ?*anyopaque;+const Sel = ?*anyopaque;+const CGFloat = f64;+const CGPoint = extern struct { x: CGFloat, y: CGFloat };+const CGSize = extern struct { width: CGFloat, height: CGFloat };+const CGRect = extern struct { origin: CGPoint, size: CGSize };+const NSUInteger = c_ulong;+const NSInteger = c_long;+const BOOL = i8;++const NSWindowStyleMaskTitled: NSUInteger = 1;+const NSWindowStyleMaskClosable: NSUInteger = 2;+const NSWindowStyleMaskMiniaturizable: NSUInteger = 4;+const NSWindowStyleMaskResizable: NSUInteger = 8;+const NSBackingStoreBuffered: NSUInteger = 2;+const NSApplicationActivationPolicyRegular: NSInteger = 0;+const YES: BOOL = 1;+const NO: BOOL = 0;++fn cls(name: [*:0]const u8) Id {+ return objc_getClass(name);+}+fn sel(name: [*:0]const u8) Sel {+ return sel_registerName(name);+}+fn send(recv: Id, s: Sel) Id {+ const F = *const fn (Id, Sel) callconv(.c) Id;+ return @as(F, @ptrCast(&objc_msgSend))(recv, s);+}+fn sendv(recv: Id, s: Sel) void {+ const F = *const fn (Id, Sel) callconv(.c) void;+ @as(F, @ptrCast(&objc_msgSend))(recv, s);+}+fn send1(recv: Id, s: Sel, a: Id) Id {+ const F = *const fn (Id, Sel, Id) callconv(.c) Id;+ return @as(F, @ptrCast(&objc_msgSend))(recv, s, a);+}+fn send1v(recv: Id, s: Sel, a: Id) void {+ const F = *const fn (Id, Sel, Id) callconv(.c) void;+ @as(F, @ptrCast(&objc_msgSend))(recv, s, a);+}+fn sendStr(recv: Id, s: Sel, str: [*:0]const u8) Id {+ const F = *const fn (Id, Sel, [*:0]const u8) callconv(.c) Id;+ return @as(F, @ptrCast(&objc_msgSend))(recv, s, str);+}+fn sendIntv(recv: Id, s: Sel, a: NSInteger) void {+ const F = *const fn (Id, Sel, NSInteger) callconv(.c) void;+ @as(F, @ptrCast(&objc_msgSend))(recv, s, a);+}+fn sendBoolv(recv: Id, s: Sel, a: BOOL) void {+ const F = *const fn (Id, Sel, BOOL) callconv(.c) void;+ @as(F, @ptrCast(&objc_msgSend))(recv, s, a);+}+fn sendWindowInit(recv: Id, s: Sel, rect: CGRect, style: NSUInteger, backing: NSUInteger, defer_: BOOL) Id {+ const F = *const fn (Id, Sel, CGRect, NSUInteger, NSUInteger, BOOL) callconv(.c) Id;+ return @as(F, @ptrCast(&objc_msgSend))(recv, s, rect, style, backing, defer_);+}+fn sendWebViewInit(recv: Id, s: Sel, frame: CGRect, config: Id) Id {+ const F = *const fn (Id, Sel, CGRect, Id) callconv(.c) Id;+ return @as(F, @ptrCast(&objc_msgSend))(recv, s, frame, config);+}++fn runMac(url: []const u8) !void {+ var url_buf: [256]u8 = undefined;+ const url_z = try std.fmt.bufPrintZ(&url_buf, "{s}", .{url});++ const app = send(cls("NSApplication"), sel("sharedApplication"));+ sendIntv(app, sel("setActivationPolicy:"), NSApplicationActivationPolicyRegular);++ const frame = CGRect{ .origin = .{ .x = 0, .y = 0 }, .size = .{ .width = 1280, .height = 820 } };+ const style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |+ NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;+ const window = sendWindowInit(+ send(cls("NSWindow"), sel("alloc")),+ sel("initWithContentRect:styleMask:backing:defer:"),+ frame,+ style,+ NSBackingStoreBuffered,+ NO,+ );+ const title = sendStr(cls("NSString"), sel("stringWithUTF8String:"), "Codegraff");+ send1v(window, sel("setTitle:"), title);++ const wkconfig = send(send(cls("WKWebViewConfiguration"), sel("alloc")), sel("init"));+ const webview = sendWebViewInit(+ send(cls("WKWebView"), sel("alloc")),+ sel("initWithFrame:configuration:"),+ frame,+ wkconfig,+ );+ send1v(window, sel("setContentView:"), webview);++ const ns_url_str = sendStr(cls("NSString"), sel("stringWithUTF8String:"), url_z.ptr);+ const ns_url = send1(cls("NSURL"), sel("URLWithString:"), ns_url_str);+ const request = send1(cls("NSURLRequest"), sel("requestWithURL:"), ns_url);+ _ = send1(webview, sel("loadRequest:"), request);++ send1v(window, sel("makeKeyAndOrderFront:"), null);+ sendBoolv(app, sel("activateIgnoringOtherApps:"), YES);+ sendv(app, sel("run"));+}diff --git a/apps/native/lib/graff-client.ts b/apps/native/lib/graff-client.tsnew file mode 100644index 00000000..2205b677--- /dev/null+++ b/apps/native/lib/graff-client.ts@@ -0,0 +1,157 @@+import { parseEventLine, type GraffEvent } from "./graff-events";++/** Browser client for `graff serve` via the Next.js `/api/graff` proxy.+ * Same request/event contract as `sdk/ts/remote.ts` (one POST = one+ * protocol request, streamed back as NDJSON until the terminal event). */++const BASE = "/api/graff";++export type SessionInfo = {+ session_id: string;+ resumed: boolean;+ last_seq: number;+};++export type Health = {+ ok: boolean;+ detail?: string;+};++async function* ndjson(res: Response): AsyncGenerator<GraffEvent> {+ const body = res.body;+ if (!body) throw new Error("bridge response had no body");+ const reader = body.getReader();+ const dec = new TextDecoder();+ let buf = "";+ try {+ while (true) {+ const { done, value } = await reader.read();+ if (done) break;+ buf += dec.decode(value, { stream: true });+ let i: number;+ while ((i = buf.indexOf("\n")) >= 0) {+ const line = buf.slice(0, i);+ buf = buf.slice(i + 1);+ const ev = parseEventLine(line);+ if (ev) yield ev;+ }+ }+ const tail = parseEventLine(buf);+ if (tail) yield tail;+ } finally {+ await reader.cancel().catch(() => {});+ }+}++async function req(method: string, path: string, body?: unknown): Promise<Response> {+ const res = await fetch(`${BASE}${path}`, {+ method,+ headers: { "content-type": "application/json" },+ body: body === undefined ? undefined : JSON.stringify(body),+ });+ if (!res.ok) {+ const detail = await res.text().catch(() => "");+ throw new Error(`graff ${method} ${path} → ${res.status}: ${detail.slice(0, 240)}`);+ }+ return res;+}++export async function checkHealth(): Promise<Health> {+ try {+ const res = await fetch(`${BASE}/healthz`, { cache: "no-store" });+ if (!res.ok) return { ok: false, detail: `healthz ${res.status}` };+ return { ok: true };+ } catch (err) {+ return { ok: false, detail: err instanceof Error ? err.message : String(err) };+ }+}++export async function createSession(opts?: {+ session?: string;+ model?: string;+ yolo?: boolean;+}): Promise<SessionInfo> {+ const body: Record<string, unknown> = {};+ if (opts?.session) body.session = opts.session;+ if (opts?.model) body.model = opts.model;+ if (opts?.yolo !== undefined) body.yolo = opts.yolo;+ const res = await req("POST", "/v1/sessions", body);+ return (await res.json()) as SessionInfo;+}++export async function* chat(+ sessionId: string,+ prompt: string,+ signal?: AbortSignal,+): AsyncGenerator<GraffEvent> {+ const res = await req("POST", `/v1/sessions/${encodeURIComponent(sessionId)}`, {+ type: "user",+ text: prompt,+ });+ if (signal?.aborted) {+ await cancel(sessionId);+ return;+ }+ let terminal = false;+ for await (const ev of ndjson(res)) {+ yield ev;+ if (ev.type === "turn" || ev.type === "error") {+ terminal = true;+ break;+ }+ }+ if (!terminal) throw new Error("bridge stream ended mid-turn (session process died?)");+}++export async function answer(+ sessionId: string,+ input: { text: string; callId?: string; cancelled?: boolean },+): Promise<void> {+ const res = await req("POST", `/v1/sessions/${encodeURIComponent(sessionId)}`, {+ type: "answer",+ text: input.text,+ cancelled: input.cancelled ?? false,+ call_id: input.callId,+ });+ await res.text();+}++export async function cancel(sessionId: string): Promise<void> {+ const res = await fetch(`${BASE}/v1/sessions/${encodeURIComponent(sessionId)}`, {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ type: "cancel" }),+ }).catch(() => null);+ if (res) await res.text().catch(() => {});+}++export async function setModel(sessionId: string, model: string, provider?: string): Promise<void> {+ const payload: Record<string, unknown> = { type: "set_model", model };+ if (provider) payload.provider = provider;+ const res = await req("POST", `/v1/sessions/${encodeURIComponent(sessionId)}`, payload);+ for await (const ev of ndjson(res)) {+ if (ev.type === "error") throw new Error(String((ev as { message?: string }).message ?? "set_model failed"));+ if (ev.type === "model") return;+ }+}++export async function closeSession(sessionId: string): Promise<void> {+ await fetch(`${BASE}/v1/sessions/${encodeURIComponent(sessionId)}`, { method: "DELETE" }).catch(+ () => {},+ );+}++export const STARTER_PROMPTS = [+ { id: "files", label: "What files are here?", prompt: "What files are in this workspace? Be brief." },+ { id: "readme", label: "Summarize README.md", prompt: "Read README.md and summarize it in a short paragraph." },+ { id: "review", label: "Review the last commit", prompt: "Review HEAD against the previous commit. Stay read-only." },+ { id: "todos", label: "What's on the checklist?", prompt: "Read the current todo list and tell me what's open." },+] as const;++export const MODELS = [+ { key: "gpt-5.5", name: "GPT-5.5", tag: "OpenAI" },+ { key: "claude-opus-4-8", name: "Opus 4.8", tag: "Anthropic" },+ { key: "codex", name: "Codex", tag: "ChatGPT" },+ { key: "grok-4.6", name: "Grok 4.6", tag: "xAI" },+ { key: "kimi-k2.6", name: "Kimi K2.6", tag: "Moonshot" },+];diff --git a/apps/native/lib/graff-events.test.ts b/apps/native/lib/graff-events.test.tsnew file mode 100644index 00000000..87a86296--- /dev/null+++ b/apps/native/lib/graff-events.test.ts@@ -0,0 +1,80 @@+import { describe, it } from "node:test";+import assert from "node:assert/strict";+import { applyEvent, emptyTurn, parseEventLine } from "./graff-events.ts";++describe("parseEventLine", () => {+ it("skips blanks and noise", () => {+ assert.equal(parseEventLine(""), null);+ assert.equal(parseEventLine("not-json"), null);+ });++ it("parses a typed event", () => {+ const ev = parseEventLine('{"seq":1,"type":"text","text":"hi"}');+ assert.deepEqual(ev, { seq: 1, type: "text", text: "hi" });+ });+});++describe("applyEvent", () => {+ it("streams text and reasoning onto a live turn", () => {+ let turn = emptyTurn();+ turn = applyEvent(turn, { type: "started", provider: "openai", model: "gpt-5.5" });+ turn = applyEvent(turn, { type: "reasoning", text: "look around" });+ turn = applyEvent(turn, { type: "text", text: "Hello" });+ turn = applyEvent(turn, { type: "text", text: " world" });+ assert.equal(turn.model, "gpt-5.5");+ assert.equal(turn.reasoning, "look around");+ assert.equal(turn.text, "Hello world");+ assert.equal(turn.status, "streaming");+ });++ it("maps tool_call / tool_result onto chips and edit diffs", () => {+ let turn = emptyTurn();+ turn = applyEvent(turn, {+ type: "tool_call",+ name: "edit_file",+ input: { path: "src/main.zig", old_string: "foo", new_string: "bar" },+ });+ assert.equal(turn.tools[0]?.status, "running");+ assert.equal(turn.tools[0]?.chip, "src/main.zig");+ turn = applyEvent(turn, {+ type: "tool_result",+ name: "edit_file",+ is_error: false,+ text: "replaced 1 span",+ });+ assert.equal(turn.tools[0]?.status, "ok");+ assert.equal(turn.diffs[0]?.file, "src/main.zig");+ });++ it("surfaces ask_user and settles on turn", () => {+ let turn = emptyTurn();+ turn = applyEvent(turn, {+ type: "ask_user",+ call_id: "q1",+ question: "Apply the edit?",+ input: {},+ });+ assert.equal(turn.status, "ask");+ assert.equal(turn.ask?.callId, "q1");+ turn = applyEvent(turn, { type: "turn", text: "done", context_tokens: 1, cost_usd: 0.01 });+ assert.equal(turn.status, "done");+ assert.equal(turn.ask, undefined);+ assert.equal(turn.costUsd, 0.01);+ });++ it("lifts todo_write items into the side pane", () => {+ let turn = emptyTurn();+ turn = applyEvent(turn, {+ type: "tool_call",+ name: "todo_write",+ input: {+ todos: [+ { id: "a", content: "Read README", status: "completed" },+ { id: "b", content: "Edit main", status: "in_progress" },+ ],+ },+ });+ assert.equal(turn.todos.length, 2);+ assert.equal(turn.todos[1]?.status, "in_progress");+ });+});diff --git a/apps/native/lib/graff-events.ts b/apps/native/lib/graff-events.tsnew file mode 100644index 00000000..7ca7b115--- /dev/null+++ b/apps/native/lib/graff-events.ts@@ -0,0 +1,346 @@+/** Graff `--json` / `graff serve` events that the native harness renders.+ * Mirrors `sdk/ts/remote.ts` Event, kept local so the UI does not import+ * Node-only SDK code. Unknown types are ignored (forward compatible). */++export type GraffEvent =+ | { seq?: number; type: "text"; text: string }+ | { seq?: number; type: "reasoning"; text: string }+ | { seq?: number; type: "started"; provider: string; model: string }+ | { seq?: number; type: "model_call_started"; provider: string; model: string }+ | { seq?: number; type: "model_call_finished"; provider: string; model: string; ok: boolean; ms: number }+ | { seq?: number; type: "tool_call"; name: string; input: Record<string, unknown> }+ | { seq?: number; type: "tool_call_started"; name: string; input: Record<string, unknown> }+ | {+ seq?: number;+ type: "tool_rejected";+ name: string;+ reason: string;+ input: Record<string, unknown>;+ message: string;+ }+ | { seq?: number; type: "ask_user"; call_id: string; question: string; input: Record<string, unknown> }+ | { seq?: number; type: "tool_result"; name: string; is_error: boolean; text: string }+ | { seq?: number; type: "tool_call_finished"; name: string; is_error: boolean; ms: number }+ | { seq?: number; type: "finalizing" }+ | {+ seq?: number;+ type: "session_recap";+ text: string;+ status: "needs_input" | "completed" | "failed";+ source: string;+ }+ | {+ seq?: number;+ type: "turn";+ text: string;+ context_tokens: number;+ cost_usd: number;+ complete?: boolean;+ }+ | { seq?: number; type: "error"; message: string }+ | { seq?: number; type: string; [key: string]: unknown };++export type ToolIcon = "think" | "write" | "run" | "read";++export type ToolRow = {+ id: string;+ name: string;+ icon: ToolIcon;+ chip: string;+ status: "running" | "ok" | "error";+ detail: { text: string; tone?: "add" }[];+ path?: string;+};++export type DiffChip = {+ file: string;+ add: number;+ del: number;+ lines: { text: string; tone: "add" | "del" | "ctx" }[];+};++export type TodoItem = {+ id: string;+ content: string;+ status: "pending" | "in_progress" | "completed";+};++export type AskPrompt = {+ callId: string;+ question: string;+};++export type TurnStatus = "thinking" | "streaming" | "ask" | "done" | "error";++export type AssistantTurn = {+ reasoning: string;+ text: string;+ tools: ToolRow[];+ diffs: DiffChip[];+ todos: TodoItem[];+ ask?: AskPrompt;+ recap?: string;+ error?: string;+ model?: string;+ provider?: string;+ costUsd?: number;+ status: TurnStatus;+};++export function emptyTurn(): AssistantTurn {+ return {+ reasoning: "",+ text: "",+ tools: [],+ diffs: [],+ todos: [],+ status: "thinking",+ };+}++function iconFor(name: string): ToolIcon {+ if (name === "bash" || name === "bash_output" || name === "bash_kill") return "run";+ if (name === "write_file" || name === "edit_file") return "write";+ if (name === "read_file" || name === "codedb" || name === "webfetch" || name === "skill") return "read";+ if (name === "todo_write" || name === "todo_read") return "think";+ return "think";+}++function chipFor(name: string, input: Record<string, unknown>): string {+ const path = typeof input.path === "string" ? input.path : undefined;+ const command = typeof input.command === "string" ? input.command : undefined;+ if (path) return path;+ if (command) return command.length > 48 ? `${command.slice(0, 47)}…` : command;+ if (typeof input.url === "string") return input.url;+ return name;+}++function toolId(name: string, input: Record<string, unknown>, tools: ToolRow[]): string {+ const hint = chipFor(name, input);+ const n = tools.filter((t) => t.name === name && t.chip === hint).length;+ return `${name}:${hint}:${n}`;+}++function upsertTool(turn: AssistantTurn, name: string, input: Record<string, unknown>): AssistantTurn {+ const chip = chipFor(name, input);+ const running = [...turn.tools]+ .reverse()+ .find((t) => t.name === name && t.status === "running" && t.chip === chip);+ if (running) return turn;+ const row: ToolRow = {+ id: toolId(name, input, turn.tools),+ name,+ icon: iconFor(name),+ chip,+ status: "running",+ detail: summarizeInput(name, input),+ path: typeof input.path === "string" ? input.path : undefined,+ };+ return { ...turn, tools: [...turn.tools, row], status: turn.status === "ask" ? "ask" : "streaming" };+}++function summarizeInput(name: string, input: Record<string, unknown>): { text: string; tone?: "add" }[] {+ if (name === "edit_file") {+ const oldS = typeof input.old_string === "string" ? input.old_string : "";+ const newS = typeof input.new_string === "string" ? input.new_string : "";+ const lines: { text: string; tone?: "add" }[] = [];+ if (oldS) lines.push({ text: firstLine(oldS) });+ if (newS) lines.push({ text: firstLine(newS), tone: "add" });+ return lines.length ? lines : [{ text: "staged edit" }];+ }+ if (name === "write_file") {+ const content = typeof input.content === "string" ? input.content : "";+ return [{ text: content ? `${content.split("\n").length} lines` : "write", tone: "add" }];+ }+ if (name === "bash" && typeof input.command === "string") {+ return [{ text: input.command }];+ }+ try {+ const json = JSON.stringify(input);+ return [{ text: json.length > 160 ? `${json.slice(0, 159)}…` : json }];+ } catch {+ return [{ text: name }];+ }+}++function firstLine(s: string): string {+ const line = s.split("\n")[0] ?? s;+ return line.length > 80 ? `${line.slice(0, 79)}…` : line;+}++function finishTool(turn: AssistantTurn, name: string, isError: boolean, text?: string): AssistantTurn {+ let idx = -1;+ for (let i = turn.tools.length - 1; i >= 0; i--) {+ if (turn.tools[i].name === name && turn.tools[i].status === "running") {+ idx = i;+ break;+ }+ }+ if (idx < 0) {+ if (!text) return turn;+ return {+ ...turn,+ tools: [+ ...turn.tools,+ {+ id: `${name}:result:${turn.tools.length}`,+ name,+ icon: iconFor(name),+ chip: name,+ status: isError ? "error" : "ok",+ detail: text ? [{ text: firstLine(text) }] : [],+ },+ ],+ };+ }+ const prev = turn.tools[idx];+ const detail = text+ ? [...prev.detail, { text: firstLine(text), tone: isError ? undefined : undefined }]+ : prev.detail;+ const tools = turn.tools.slice();+ tools[idx] = { ...prev, status: isError ? "error" : "ok", detail };+ const diffs = name === "edit_file" || name === "write_file" ? mergeDiff(turn.diffs, prev, text) : turn.diffs;+ return { ...turn, tools, diffs };+}++function mergeDiff(diffs: DiffChip[], tool: ToolRow, text?: string): DiffChip[] {+ const file = tool.path ?? tool.chip;+ if (!file || file === tool.name) return diffs;+ const add = tool.name === "write_file" ? 1 : countTone(tool.detail, "add");+ const del = tool.name === "edit_file" ? 1 : 0;+ const lines = (text ?? "")+ .split("\n")+ .slice(0, 8)+ .map((line) => ({+ text: line.slice(0, 80),+ tone: (line.startsWith("+") ? "add" : line.startsWith("-") ? "del" : "ctx") as DiffChip["lines"][number]["tone"],+ }));+ const existing = diffs.findIndex((d) => d.file === file);+ const chip: DiffChip = {+ file,+ add: Math.max(add, 1),+ del,+ lines: lines.length ? lines : tool.detail.map((d) => ({ text: d.text, tone: d.tone === "add" ? "add" : "ctx" })),+ };+ if (existing < 0) return [...diffs, chip];+ const next = diffs.slice();+ next[existing] = chip;+ return next;+}++function countTone(detail: ToolRow["detail"], tone: "add"): number {+ return detail.filter((d) => d.tone === tone).length;+}++function parseTodos(input: Record<string, unknown>): TodoItem[] {+ const raw = input.todos ?? input.items ?? input.list;+ if (!Array.isArray(raw)) return [];+ return raw.flatMap((item, i) => {+ if (!item || typeof item !== "object") return [];+ const rec = item as Record<string, unknown>;+ const content = typeof rec.content === "string" ? rec.content : typeof rec.text === "string" ? rec.text : "";+ if (!content) return [];+ const status = rec.status === "completed" || rec.status === "in_progress" || rec.status === "pending"+ ? rec.status+ : "pending";+ const id = typeof rec.id === "string" ? rec.id : `todo-${i}`;+ return [{ id, content, status }];+ });+}++export function applyEvent(turn: AssistantTurn, ev: GraffEvent): AssistantTurn {+ switch (ev.type) {+ case "started":+ case "model_call_started":+ return {+ ...turn,+ provider: typeof ev.provider === "string" ? ev.provider : turn.provider,+ model: typeof ev.model === "string" ? ev.model : turn.model,+ status: turn.status === "ask" ? "ask" : "thinking",+ };+ case "reasoning":+ return {+ ...turn,+ reasoning: `${turn.reasoning}${typeof ev.text === "string" ? ev.text : ""}`,+ status: turn.status === "ask" ? "ask" : "thinking",+ };+ case "text":+ return {+ ...turn,+ text: `${turn.text}${typeof ev.text === "string" ? ev.text : ""}`,+ status: turn.status === "ask" ? "ask" : "streaming",+ };+ case "tool_call":+ case "tool_call_started": {+ const name = typeof ev.name === "string" ? ev.name : "tool";+ const input = ev.input && typeof ev.input === "object" ? (ev.input as Record<string, unknown>) : {};+ const next = upsertTool(turn, name, input);+ const todos = name === "todo_write" ? parseTodos(input) : next.todos;+ return todos.length ? { ...next, todos } : next;+ }+ case "tool_result":+ return finishTool(+ turn,+ typeof ev.name === "string" ? ev.name : "tool",+ Boolean(ev.is_error),+ typeof ev.text === "string" ? ev.text : undefined,+ );+ case "tool_call_finished":+ return finishTool(turn, typeof ev.name === "string" ? ev.name : "tool", Boolean(ev.is_error));+ case "tool_rejected":+ return {+ ...turn,+ tools: [+ ...turn.tools,+ {+ id: `rejected:${String(ev.name)}:${turn.tools.length}`,+ name: String(ev.name ?? "tool"),+ icon: iconFor(String(ev.name ?? "")),+ chip: String(ev.reason ?? "rejected"),+ status: "error",+ detail: [{ text: String(ev.message ?? "rejected") }],+ },+ ],+ };+ case "ask_user":+ return {+ ...turn,+ ask: {+ callId: String(ev.call_id ?? ""),+ question: String(ev.question ?? "The agent needs a decision."),+ },+ status: "ask",+ };+ case "session_recap":+ return { ...turn, recap: typeof ev.text === "string" ? ev.text : turn.recap };+ case "turn":+ return {+ ...turn,+ text: turn.text || (typeof ev.text === "string" ? ev.text : turn.text),+ costUsd: typeof ev.cost_usd === "number" ? ev.cost_usd : turn.costUsd,+ ask: undefined,+ status: "done",+ };+ case "error":+ return {+ ...turn,+ error: typeof ev.message === "string" ? ev.message : "error",+ status: "error",+ };+ case "finalizing":+ return { ...turn, status: turn.status === "ask" ? "ask" : "streaming" };+ default:+ return turn;+ }+}++export function parseEventLine(line: string): GraffEvent | null {+ const trimmed = line.trim();+ if (!trimmed) return null;+ try {+ const ev = JSON.parse(trimmed) as GraffEvent;+ return ev && typeof ev.type === "string" ? ev : null;+ } catch {+ return null;+ }+}diff --git a/apps/native/lib/icons.tsx b/apps/native/lib/icons.tsxnew file mode 100644index 00000000..78fe025e--- /dev/null+++ b/apps/native/lib/icons.tsx@@ -0,0 +1,144 @@+import type { CSSProperties, ReactNode, SVGProps } from "react";++/** Free stroke icons that stand in for the commercial `@central-icons-react`+ * set. Same `size` / `className` surface SidebarNav already uses. */+type IconProps = {+ size?: number;+ className?: string;+ style?: CSSProperties;+};++function Svg({+ size = 18,+ className,+ style,+ children,+ fill = "none",+}: IconProps & { children: ReactNode; fill?: string }) {+ const props: SVGProps<SVGSVGElement> = {+ width: size,+ height: size,+ viewBox: "0 0 24 24",+ fill,+ stroke: fill === "none" ? "currentColor" : "none",+ strokeWidth: fill === "none" ? 1.8 : undefined,+ strokeLinecap: "round",+ strokeLinejoin: "round",+ className,+ style,+ "aria-hidden": true,+ };+ return <svg {...props}>{children}</svg>;+}++export function IconHome(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M4 10.5 12 4l8 6.5V20a1 1 0 0 1-1 1h-5v-6H10v6H5a1 1 0 0 1-1-1z" />+ </Svg>+ );+}++export function IconUserAdd(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M15 19a6 6 0 0 0-12 0" />+ <circle cx="9" cy="8" r="3.2" />+ <path d="M18 8v6M15 11h6" />+ </Svg>+ );+}++export function IconPlusMedium(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M12 5v14M5 12h14" />+ </Svg>+ );+}++export function IconSettingsGear1(p: IconProps) {+ return (+ <Svg {...p}>+ <circle cx="12" cy="12" r="3" />+ <path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.3.7.9 1.2 1.6 1.3H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z" />+ </Svg>+ );+}++export function IconArrowBoxLeft(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M10 7H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-4" />+ <path d="M14 4h6v6M20 4l-9 9" />+ </Svg>+ );+}++export function IconCheckmark1Small(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M20 6 9 17l-5-5" />+ </Svg>+ );+}++export function IconChevronDownSmall(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M6 9l6 6 6-6" />+ </Svg>+ );+}++export function IconCrossSmall(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M18 6 6 18M6 6l12 12" />+ </Svg>+ );+}++export function IconEditBig(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M12 20h9" />+ <path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z" />+ </Svg>+ );+}++export function IconMagnifyingGlass(p: IconProps) {+ return (+ <Svg {...p}>+ <circle cx="11" cy="11" r="7" />+ <path d="M21 21l-4.3-4.3" />+ </Svg>+ );+}++export function IconSidebarLeftArrow(p: IconProps) {+ return (+ <Svg {...p}>+ <rect x="3.5" y="4.5" width="17" height="15" rx="2.5" />+ <path d="M9.5 4.5v15M13 9l-3 3 3 3" />+ </Svg>+ );+}++/** Brand mark — graff G instead of the paid popsicle. */+export function IconPopsicle2(p: IconProps) {+ return (+ <Svg {...p} fill="currentColor">+ <path d="M7 4.5A5 5 0 0 1 17 8v6.5a2 2 0 0 1-2 2h-1.2V20a1.3 1.3 0 0 1-2.6 0v-3.5H9a2 2 0 0 1-2-2z" />+ </Svg>+ );+}++export function IconFolder(p: IconProps) {+ return (+ <Svg {...p}>+ <path d="M3 7.5A2 2 0 0 1 5 5.5h4.2l1.6 2H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />+ </Svg>+ );+}diff --git a/apps/native/next.config.ts b/apps/native/next.config.tsnew file mode 100644index 00000000..44fbc415--- /dev/null+++ b/apps/native/next.config.ts@@ -0,0 +1,7 @@+import type { NextConfig } from "next";++const nextConfig: NextConfig = {+ images: { unoptimized: true },+};++export default nextConfig;diff --git a/apps/native/package-lock.json b/apps/native/package-lock.jsonnew file mode 100644index 00000000..4adebdc3--- /dev/null+++ b/apps/native/package-lock.json@@ -0,0 +1,1748 @@+{+ "name": "@codegraff/native",+ "version": "0.1.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "@codegraff/native",+ "version": "0.1.0",+ "license": "Apache-2.0",+ "dependencies": {+ "glimm": "^0.3.0",+ "iconoir-react": "^7.11.1",+ "liveline": "^0.0.7",+ "next": "^15.3.3",+ "react": "^19.1.0",+ "react-dom": "^19.1.0",+ "shadow-plugin": "^2.1.0"+ },+ "devDependencies": {+ "@tailwindcss/postcss": "^4.1.8",+ "@types/node": "^22",+ "@types/react": "^19",+ "@types/react-dom": "^19",+ "tailwindcss": "^4.1.8",+ "typescript": "^5"+ }+ },+ "node_modules/@alloc/quick-lru": {+ "version": "5.2.0",+ "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz",+ "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/@emnapi/runtime": {+ "version": "1.11.3",+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",+ "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "tslib": "^2.4.0"+ }+ },+ "node_modules/@img/colour": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz",+ "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==",+ "license": "MIT",+ "optional": true,+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@img/sharp-darwin-arm64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.3.tgz",+ "integrity": "sha512-RMnFX7YQsMoh7lWfcM4NEHHymBX/rLuKNPVM84XE9ONPcaSCDgE7CHIHpSgPcO2xcRthgBy1HfNO319mwhIAkg==",+ "cpu": [+ "arm64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-darwin-arm64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-darwin-x64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.3.tgz",+ "integrity": "sha512-Xo+5uFBtLN0BKqieTxiFzFPQAUlBbbH5iBKyRX/z1JrbnYsHTfKJnUfL8+p2TPXr1pXqao4eeL4Rl144uDpK9w==",+ "cpu": [+ "x64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-darwin-x64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-freebsd-wasm32": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.3.tgz",+ "integrity": "sha512-lUxcqWIj2wMQ9BrwNjngcr1gWUr5xgaGThBRqPPalIC2n67Cqj1uPh8NnA/ZhAg8hUbKl+kVHKwgUIwe6ZYPrg==",+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "dependencies": {+ "@img/sharp-wasm32": "0.35.3"+ },+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-darwin-arm64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.2.tgz",+ "integrity": "sha512-9J6ypZFpQBj4YnePGoq/S38w6nz+vqg5WZLrLGY4YuSemdMq47GMLBPO42MzwdGwpg/agZ7xzZcFHa48xlywfg==",+ "cpu": [+ "arm64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "darwin"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-darwin-x64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.2.tgz",+ "integrity": "sha512-m2pW1n6cns9VaubNwsZ+c3CRYjxNQWgJ5gPlnL1nbBcpkBvFm6SCFN5o0psFHI8w9n11NKhFkeEDns98tiqbEw==",+ "cpu": [+ "x64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "darwin"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-arm": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.2.tgz",+ "integrity": "sha512-1eMLzy92I4J6rmi4mAT8yC3HxOtniyGELlzGbNMLLeqe052ahFQ0h6LFq+lh5DsDIdYViIDst08abvSbcEdLXQ==",+ "cpu": [+ "arm"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-arm64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.2.tgz",+ "integrity": "sha512-dqVSFynCox4C/J8kT16V7SIFAns0IjgLwkvYT7p8LQVmJ5OS5b6tI9IGflxTeuBS//zXeFIUbwt5dwxyZ17cnA==",+ "cpu": [+ "arm64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-ppc64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.2.tgz",+ "integrity": "sha512-3z0NHDxD6n5I9gc05U1eW1AyRm+Gznzq3naMrthPNqE6oYykcogW0l/jfpJdjYnuNl8R7yI9pNbE1XiUeyq0Aw==",+ "cpu": [+ "ppc64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-riscv64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.2.tgz",+ "integrity": "sha512-bsb4rI+NldGOsXuej2r8OdSS8+zXDVaCWxyWrcv6kneTOlgAHtZABRzBBCwdsPiD90J4myNJuHpg6kA20ImW/w==",+ "cpu": [+ "riscv64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-s390x": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.2.tgz",+ "integrity": "sha512-/ABshyj8gCpyIrNXnHn4LorDJ0HHm1VhXPBlxZ8zAtfVPAaSafXPGn+sUSIRiwaSBy0mmFjSjiXI5mkcwdChKQ==",+ "cpu": [+ "s390x"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-x64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.2.tgz",+ "integrity": "sha512-ITPEtgffGJ0S6G9dRyw/366tJQqFRcHWPHhC+Stpg3Z8AEMrDrTr2lhdz4f/Y/HMbRh//7Z5mBzEpVdi62Oc3w==",+ "cpu": [+ "x64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.2.tgz",+ "integrity": "sha512-zE9EdiUzUmg5mDT5a1rk5fYJ6GWPloTwWBYDS14naqHsL+EaMpDj1AWnpLgh3u0YCORv2Tt50wrcrpYqkP97Kw==",+ "cpu": [+ "arm64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {+ "version": "1.3.2",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.2.tgz",+ "integrity": "sha512-m0lrLiUt+lBYnCFr8qV/65yMR4E/c7/wf78I5eKTdkEakFAlZ9QlzEM3QIhhAwVeUhLAHLcCq7a7Vszq/oFNZQ==",+ "cpu": [+ "x64"+ ],+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-linux-arm": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.3.tgz",+ "integrity": "sha512-affVWCTLooy8TSxbDx2qkzuDeaWLNVBA+P//FNBirHsXpP2fuBhk5AuboYUnrDnzoXes8GFjpTx0SBFOCRg+FA==",+ "cpu": [+ "arm"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-arm": "1.3.2"+ }+ },+ "node_modules/@img/sharp-linux-arm64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.3.tgz",+ "integrity": "sha512-QgKDspHPnrU+GQ55XPhGwyhC8acLVOOSyAvo1oVfFmrIXLkDNmGWzAfDZ4xK8oSA1qBQrALcHX0G5UZni/SuFQ==",+ "cpu": [+ "arm64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-arm64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-linux-ppc64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.3.tgz",+ "integrity": "sha512-sMd8rDxmpLOwv/7N44klFjOD5DUO7FLdjiXDI0hoxYaf7Ar262dQIEkosE98bps+5HPLtp/EvNqeqQtOycP/IA==",+ "cpu": [+ "ppc64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-ppc64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-linux-riscv64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.3.tgz",+ "integrity": "sha512-0Eob78yjlYPfL5vMNWAW55l3R9Y6BQS/gOfe0ZcP9mEz9ohhKSt4im1hayiknXgf8AWrFqMvJcKIdmLmEe7yeQ==",+ "cpu": [+ "riscv64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-riscv64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-linux-s390x": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.3.tgz",+ "integrity": "sha512-KgAxQ0DxpNOq1rG2t5cgTgShJFGSuU7XO45cqC+1NVOuZnP6tlgZRuSYOfNupGkHID0o3cJOsw4DVeJpMovcGw==",+ "cpu": [+ "s390x"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-s390x": "1.3.2"+ }+ },+ "node_modules/@img/sharp-linux-x64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.3.tgz",+ "integrity": "sha512-8pqvxubL2PGdhlPy6GLqzDYMUjyRmKAwKHYKixpdJYBUK7PJ0C029XdsnpFIdgRZG68fZiGdHVWcKPvtiPB4cA==",+ "cpu": [+ "x64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-x64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-linuxmusl-arm64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.3.tgz",+ "integrity": "sha512-Vz0iQjzzcSX3HCbfwFfCSG/9SCIqyO0mH2sXyiHaAYfBk0cRsCWXRyQYX0ovCK/PAQBbTzQ0dsPQHh5MAFL59w==",+ "cpu": [+ "arm64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-linuxmusl-x64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.3.tgz",+ "integrity": "sha512-6O1NPKcDVj9QEdg7Hx549EX8U0rp6yXQERqru6yRN7fGBn32UvIRJUlWnk+8xDCiG76hXVBbX82NZ/ZKr0euIg==",+ "cpu": [+ "x64"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linuxmusl-x64": "1.3.2"+ }+ },+ "node_modules/@img/sharp-wasm32": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.3.tgz",+ "integrity": "sha512-cZ0XkcYGpHZkqW6iCkqTcmUC0CD9DhD5d/qeZlZkfRBn6GnHniZXLUo5+9xw8Iv76YE6LQFN9YNBlKREcCG76w==",+ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",+ "optional": true,+ "dependencies": {+ "@emnapi/runtime": "^1.11.1"+ },+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-webcontainers-wasm32": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.3.tgz",+ "integrity": "sha512-2rnq7bX3NzeR2T4YWgz8qiG4h3TSdMe+vN1iQXpJleSJ3SM5zQ8Fy2SyyXAWlbxpEZ2Y+Z4u1BePgJEYbSy80Q==",+ "cpu": [+ "wasm32"+ ],+ "license": "Apache-2.0",+ "optional": true,+ "dependencies": {+ "@img/sharp-wasm32": "0.35.3"+ },+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-win32-arm64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.3.tgz",+ "integrity": "sha512-4bPwFdMbeC4JQ8L8LOyWp6nsHcboP5fxkp6iPOXz2Vg49R42TuMs2whkJ5OAP4/Ul035qOzy0AecOF9VOscn4w==",+ "cpu": [+ "arm64"+ ],+ "license": "Apache-2.0 AND LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-win32-ia32": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.3.tgz",+ "integrity": "sha512-r53mXsBN6lFUDiST764SvgwUdHAqM4rPAiDzAmf4fLoB6X/rkfyTrLCg6+g17wJJiCmB3JYgHuUldCWUIRFSXw==",+ "cpu": [+ "ia32"+ ],+ "license": "Apache-2.0 AND LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-win32-x64": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.3.tgz",+ "integrity": "sha512-D4y1vNeZrIIJCN+uHaWVtH86B+aCrdMYYjicy9pXHvbGZeGYLLSd3wdVuC37FxVXlU1ARsk84eKWfWMXGYEqvA==",+ "cpu": [+ "x64"+ ],+ "license": "Apache-2.0 AND LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@jridgewell/gen-mapping": {+ "version": "0.3.13",+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.0",+ "@jridgewell/trace-mapping": "^0.3.24"+ }+ },+ "node_modules/@jridgewell/remapping": {+ "version": "2.3.5",+ "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",+ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/gen-mapping": "^0.3.5",+ "@jridgewell/trace-mapping": "^0.3.24"+ }+ },+ "node_modules/@jridgewell/resolve-uri": {+ "version": "3.1.2",+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6.0.0"+ }+ },+ "node_modules/@jridgewell/sourcemap-codec": {+ "version": "1.5.5",+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",+ "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@jridgewell/trace-mapping": {+ "version": "0.3.31",+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/resolve-uri": "^3.1.0",+ "@jridgewell/sourcemap-codec": "^1.4.14"+ }+ },+ "node_modules/@next/env": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.24.tgz",+ "integrity": "sha512-mBDF7T0XKZjs9SpUAl0buizVO+O02ULjOvWX8o/AZo/5AGw/UAS1Zzcylmd4pqbftzmKQi+L/nB4jgBYKEAl5Q==",+ "license": "MIT"+ },+ "node_modules/@next/swc-darwin-arm64": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.24.tgz",+ "integrity": "sha512-AGdNLvxZNY6eR2iSnV+6wUa8CiHTMr4F7g3uHH7fT4ICIJBE00R9u4tzN/Vuwsw0cOi8MTD2HJcTCb6siMH88Q==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-darwin-x64": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.24.tgz",+ "integrity": "sha512-9HrQajBMmGcrrrvDfRimiCrbAPh3E6uHJmwBovYr6Yrmi9p9PZqI876BrXX280wICh3o2XwUlp4blkB0NNBqFg==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-arm64-gnu": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.24.tgz",+ "integrity": "sha512-rl9LSfE75si0WT3cDgdUC1XYCKS+TgxC+/IjitmeycrAG18X/plIP1/vy8dd/HPycYcIvE688PD7FuvEAiEAew==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-arm64-musl": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.24.tgz",+ "integrity": "sha512-TlNAnpsjxSF3aAUtqnfmtXXf8m9sIDBlmF3c7bTAlnshUYu2U0OxN2uf5d0gcFwqHVEdivJNBcCaqNOwPGNimw==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-x64-gnu": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.24.tgz",+ "integrity": "sha512-7dwtlhr0SLndqTG1z9ncRkbJswDZiKWlxzFyXDvJ2RDZRDRHp8zyMJ4D9UH/FgnQeXxxB6gZy2pMcIUoNKQ4pA==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-x64-musl": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.24.tgz",+ "integrity": "sha512-kGZxM+WhkYs0276lFrMkj7PRtXT3Btp6cwvfSO/cCVLxJJttB5Ccnl2niaCgUja8HgSbEVnMHpg3FJWoOJ9e/g==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-win32-arm64-msvc": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.24.tgz",+ "integrity": "sha512-jBDDkZ/qKAqkWivWDMkJSXUzbzV0QKRBKJjEHUAvSB97Hzw7NLzJ6yV56Lts/wjir7s4P31GYgpbS6ZL+hasAA==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-win32-x64-msvc": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.24.tgz",+ "integrity": "sha512-JqtwjvvorjacQ0spgjmUJoxySoYgPwdT1sFdQ0/zmW4iMlP2hjYlCoJIyS7o6Epb4Fug8eco3HXFoBDUCDeH7Q==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@swc/helpers": {+ "version": "0.5.15",+ "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz",+ "integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==",+ "license": "Apache-2.0",+ "dependencies": {+ "tslib": "^2.8.0"+ }+ },+ "node_modules/@tailwindcss/node": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.3.tgz",+ "integrity": "sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/remapping": "^2.3.5",+ "enhanced-resolve": "^5.24.1",+ "jiti": "^2.7.0",+ "lightningcss": "1.32.0",+ "magic-string": "^0.30.21",+ "source-map-js": "^1.2.1",+ "tailwindcss": "4.3.3"+ }+ },+ "node_modules/@tailwindcss/oxide": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.3.tgz",+ "integrity": "sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 20"+ },+ "optionalDependencies": {+ "@tailwindcss/oxide-android-arm64": "4.3.3",+ "@tailwindcss/oxide-darwin-arm64": "4.3.3",+ "@tailwindcss/oxide-darwin-x64": "4.3.3",+ "@tailwindcss/oxide-freebsd-x64": "4.3.3",+ "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.3",+ "@tailwindcss/oxide-linux-arm64-gnu": "4.3.3",+ "@tailwindcss/oxide-linux-arm64-musl": "4.3.3",+ "@tailwindcss/oxide-linux-x64-gnu": "4.3.3",+ "@tailwindcss/oxide-linux-x64-musl": "4.3.3",+ "@tailwindcss/oxide-wasm32-wasi": "4.3.3",+ "@tailwindcss/oxide-win32-arm64-msvc": "4.3.3",+ "@tailwindcss/oxide-win32-x64-msvc": "4.3.3"+ }+ },+ "node_modules/@tailwindcss/oxide-android-arm64": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.3.tgz",+ "integrity": "sha512-Y85A2gmPSkl5Ve5qR86GL4HT509cFqQh1aes9p3sSkyTPwt0Pppf3GkwGe4JPACcRYjgJIEhQgM6dBClnr0NYw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-darwin-arm64": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.3.tgz",+ "integrity": "sha512-BiaWatpBcERQFDlOjRDpIVXuFK5PJez5SA4JMg6VYZdBYU+qKfV/vqjcIs+IYmtitf1xYQZTwXvU/8y4lfZUGw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-darwin-x64": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.3.tgz",+ "integrity": "sha512-fAeUqfV5ndhxRwai8cXGzdLvul9utWOmeTkv69unv4ZXixjn61Z+p9lCWdwOwA3TYboG3BwdVuN/RDjhBRl0mw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-freebsd-x64": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.3.tgz",+ "integrity": "sha512-iyf5bV6+wnAlflVeEy7R25dupxTNECZN5QMI0qNT6eT+EgaGdZcKhGkr5SdoaWiLJ3spLqIY9VCeSGrwmtg4kw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.3.tgz",+ "integrity": "sha512-aAYUprJAJQWWbRrPvtjdroZ56Md+JM8pMiopS6xGEwDfLhqj+2ver2p4nU4Mb3CRqcMmNBjo8KkUgcxhkzVQGQ==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-linux-arm64-gnu": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.3.tgz",+ "integrity": "sha512-nDxldcEENOxZRzC2uu9jrutZdAAQtb+8WWDCSnWL1zvBk1+FN+x6MtDViPB5AJMfttVCUhehGWus3XBPgatM/w==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-linux-arm64-musl": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.3.tgz",+ "integrity": "sha512-Md44bD6veX/PC5iyF8cDVnw4HBIANZepRZZ7a8DQOvkfo5WUBwcp6iAuCUz23u+4SUkhJlD3eL7hNdW8ezd/kA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-linux-x64-gnu": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.3.tgz",+ "integrity": "sha512-tx7us1muwOKAKWao2v/GaafFeQboE6aj88vC6ziN2NCGcRm8gWUhwjzg+YdVB1e4boAtdtma4L43onunI6NS4w==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-linux-x64-musl": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.3.tgz",+ "integrity": "sha512-SJxX60smvHgasZoBy11dX6YRjXJFovwWBoedhbQPOBzgFWBHGB+TVPWB9BxzR7TTxU8FQZAI2AyiNCMzFm8Img==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-wasm32-wasi": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.3.tgz",+ "integrity": "sha512-jx1+rPhY/5Ympkktd656HBWEBLxP7dH06losBLjjf5vgCODXvi9KhtftWcMIwTFIDqBr7cRnQkdLnAG+IOlGvQ==",+ "bundleDependencies": [+ "@napi-rs/wasm-runtime",+ "@emnapi/core",+ "@emnapi/runtime",+ "@tybys/wasm-util",+ "@emnapi/wasi-threads",+ "tslib"+ ],+ "cpu": [+ "wasm32"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@emnapi/core": "^1.11.1",+ "@emnapi/runtime": "^1.11.1",+ "@emnapi/wasi-threads": "^1.2.2",+ "@napi-rs/wasm-runtime": "^1.1.4",+ "@tybys/wasm-util": "^0.10.2",+ "tslib": "^2.8.1"+ },+ "engines": {+ "node": ">=14.0.0"+ }+ },+ "node_modules/@tailwindcss/oxide-win32-arm64-msvc": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.3.tgz",+ "integrity": "sha512-3rc292Ca2ceK6Ulcc/bAVnTs/3nDtoPhyEKlgPv+yQJQi/JS/AMJlqzxvlDacL1nekbrcf6bTqp/jV4qgnPxNQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/oxide-win32-x64-msvc": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.3.tgz",+ "integrity": "sha512-yJ0pwIVc/nYeGoV02WtsN8KYyLQv7kyI2wDnkezyJlGGjkd4QLwDGAwl47YpPJeuI0M0ObaXGSPjvWDPeTPggw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 20"+ }+ },+ "node_modules/@tailwindcss/postcss": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/@tailwindcss/postcss/-/postcss-4.3.3.tgz",+ "integrity": "sha512-JTSZZGQi1AyKirbLN3azmjVzef92tcX7h+iSqPdaeStyFpGpDlKvvpxeOE8njhbUanbRwr3z8DyzhICWnMtQeg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@alloc/quick-lru": "^5.2.0",+ "@tailwindcss/node": "4.3.3",+ "@tailwindcss/oxide": "4.3.3",+ "postcss": "^8.5.16",+ "tailwindcss": "4.3.3"+ }+ },+ "node_modules/@types/node": {+ "version": "22.20.1",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz",+ "integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "undici-types": "~6.21.0"+ }+ },+ "node_modules/@types/react": {+ "version": "19.2.18",+ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz",+ "integrity": "sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "csstype": "^3.2.2"+ }+ },+ "node_modules/@types/react-dom": {+ "version": "19.2.5",+ "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.5.tgz",+ "integrity": "sha512-fMPwH9v7r/pp43yUd2/Mbiex5KouJwwR3dzHkhLREUC6764VyDsqxhAxv6OFEYR1RhjOyD1naqba8ECDBe7ZQg==",+ "dev": true,+ "license": "MIT",+ "peerDependencies": {+ "@types/react": "^19.2.0"+ }+ },+ "node_modules/caniuse-lite": {+ "version": "1.0.30001810",+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz",+ "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==",+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/browserslist"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/caniuse-lite"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "CC-BY-4.0"+ },+ "node_modules/client-only": {+ "version": "0.0.1",+ "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz",+ "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==",+ "license": "MIT"+ },+ "node_modules/csstype": {+ "version": "3.2.3",+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",+ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/detect-libc": {+ "version": "2.1.2",+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",+ "devOptional": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/enhanced-resolve": {+ "version": "5.24.5",+ "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.5.tgz",+ "integrity": "sha512-L1l8TNvomm6UVW5B253AGxQagSQr+vGwhMlrrfRS2qmhx46AMpMVJKQYLvWYbysTMY8VoicOvzHzoHMbyzB+4A==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "graceful-fs": "^4.2.4",+ "tapable": "^2.3.3"+ },+ "engines": {+ "node": ">=10.13.0"+ }+ },+ "node_modules/glimm": {+ "version": "0.3.0",+ "resolved": "https://registry.npmjs.org/glimm/-/glimm-0.3.0.tgz",+ "integrity": "sha512-Maw5WJnUsgyfsHl7Vp95wa8G1uaFhUOSoQzAVPX1DxdHxmWNBa9VtDRNPplH1A+bIazn956ZP/wQvH4ZSxKN9Q==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "next": ">=14",+ "react": ">=18"+ },+ "peerDependenciesMeta": {+ "next": {+ "optional": true+ },+ "react": {+ "optional": true+ }+ }+ },+ "node_modules/graceful-fs": {+ "version": "4.2.11",+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",+ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",+ "dev": true,+ "license": "ISC"+ },+ "node_modules/iconoir-react": {+ "version": "7.12.1",+ "resolved": "https://registry.npmjs.org/iconoir-react/-/iconoir-react-7.12.1.tgz",+ "integrity": "sha512-e+Lwgqr10ruCwrCrFjG5RD0axwENFxPzLP1cESiQPEMH9UC/W6dk6u0MYwLoG0MBVsmBYAhVBb5GqO1aSljeGQ==",+ "license": "MIT",+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/iconoir"+ },+ "peerDependencies": {+ "react": "18 || 19"+ }+ },+ "node_modules/jiti": {+ "version": "2.7.0",+ "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",+ "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==",+ "dev": true,+ "license": "MIT",+ "bin": {+ "jiti": "lib/jiti-cli.mjs"+ }+ },+ "node_modules/lightningcss": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz",+ "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==",+ "dev": true,+ "license": "MPL-2.0",+ "dependencies": {+ "detect-libc": "^2.0.3"+ },+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ },+ "optionalDependencies": {+ "lightningcss-android-arm64": "1.32.0",+ "lightningcss-darwin-arm64": "1.32.0",+ "lightningcss-darwin-x64": "1.32.0",+ "lightningcss-freebsd-x64": "1.32.0",+ "lightningcss-linux-arm-gnueabihf": "1.32.0",+ "lightningcss-linux-arm64-gnu": "1.32.0",+ "lightningcss-linux-arm64-musl": "1.32.0",+ "lightningcss-linux-x64-gnu": "1.32.0",+ "lightningcss-linux-x64-musl": "1.32.0",+ "lightningcss-win32-arm64-msvc": "1.32.0",+ "lightningcss-win32-x64-msvc": "1.32.0"+ }+ },+ "node_modules/lightningcss-android-arm64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz",+ "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-darwin-arm64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz",+ "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-darwin-x64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz",+ "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-freebsd-x64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz",+ "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm-gnueabihf": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz",+ "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm64-gnu": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz",+ "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm64-musl": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz",+ "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-x64-gnu": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz",+ "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-x64-musl": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz",+ "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-win32-arm64-msvc": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz",+ "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-win32-x64-msvc": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz",+ "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/liveline": {+ "version": "0.0.7",+ "resolved": "https://registry.npmjs.org/liveline/-/liveline-0.0.7.tgz",+ "integrity": "sha512-S1Weo1kmefiOCNaW/WFXErqJXlV8A/ldIkIthaOeT57I2ZhqhKLKQDJ1wfabtMSK9vJeU8PeMNHd8Sr8TLByWQ==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "react": ">=18"+ }+ },+ "node_modules/magic-string": {+ "version": "0.30.21",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/nanoid": {+ "version": "3.3.18",+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",+ "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "bin": {+ "nanoid": "bin/nanoid.cjs"+ },+ "engines": {+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"+ }+ },+ "node_modules/next": {+ "version": "15.5.24",+ "resolved": "https://registry.npmjs.org/next/-/next-15.5.24.tgz",+ "integrity": "sha512-Y+xn8EQCoC3ZbsFPyzE+tE8XOdrWeUdUF7NeXbmg9DsgAxl5UYxlsrvgVESHTyTGigoTa1bCUrxn70F5bqt0Gw==",+ "license": "MIT",+ "dependencies": {+ "@next/env": "15.5.24",+ "@swc/helpers": "0.5.15",+ "caniuse-lite": "^1.0.30001579",+ "postcss": "8.4.31",+ "styled-jsx": "5.1.6"+ },+ "bin": {+ "next": "dist/bin/next"+ },+ "engines": {+ "node": "^18.18.0 || ^19.8.0 || >= 20.0.0"+ },+ "optionalDependencies": {+ "@next/swc-darwin-arm64": "15.5.24",+ "@next/swc-darwin-x64": "15.5.24",+ "@next/swc-linux-arm64-gnu": "15.5.24",+ "@next/swc-linux-arm64-musl": "15.5.24",+ "@next/swc-linux-x64-gnu": "15.5.24",+ "@next/swc-linux-x64-musl": "15.5.24",+ "@next/swc-win32-arm64-msvc": "15.5.24",+ "@next/swc-win32-x64-msvc": "15.5.24",+ "sharp": "^0.34.3 || ^0.35.3"+ },+ "peerDependencies": {+ "@opentelemetry/api": "^1.1.0",+ "@playwright/test": "^1.51.1",+ "babel-plugin-react-compiler": "*",+ "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",+ "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",+ "sass": "^1.3.0"+ },+ "peerDependenciesMeta": {+ "@opentelemetry/api": {+ "optional": true+ },+ "@playwright/test": {+ "optional": true+ },+ "babel-plugin-react-compiler": {+ "optional": true+ },+ "sass": {+ "optional": true+ }+ }+ },+ "node_modules/next/node_modules/postcss": {+ "version": "8.4.31",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",+ "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==",+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/postcss"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "nanoid": "^3.3.6",+ "picocolors": "^1.0.0",+ "source-map-js": "^1.0.2"+ },+ "engines": {+ "node": "^10 || ^12 || >=14"+ }+ },+ "node_modules/picocolors": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",+ "license": "ISC"+ },+ "node_modules/postcss": {+ "version": "8.5.26",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",+ "integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",+ "dev": true,+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/postcss"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "nanoid": "^3.3.17",+ "picocolors": "^1.1.1",+ "source-map-js": "^1.2.1"+ },+ "engines": {+ "node": "^10 || ^12 || >=14"+ }+ },+ "node_modules/react": {+ "version": "19.2.8",+ "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",+ "integrity": "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==",+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/react-dom": {+ "version": "19.2.8",+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.8.tgz",+ "integrity": "sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==",+ "license": "MIT",+ "dependencies": {+ "scheduler": "^0.27.0"+ },+ "peerDependencies": {+ "react": "^19.2.8"+ }+ },+ "node_modules/scheduler": {+ "version": "0.27.0",+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",+ "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",+ "license": "MIT"+ },+ "node_modules/semver": {+ "version": "7.8.5",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",+ "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",+ "license": "ISC",+ "optional": true,+ "bin": {+ "semver": "bin/semver.js"+ },+ "engines": {+ "node": ">=10"+ }+ },+ "node_modules/shadow-plugin": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/shadow-plugin/-/shadow-plugin-2.1.0.tgz",+ "integrity": "sha512-LPzD22Hsa5+DPIc4iOZAswuTDzgs8Ypy6GS2kf+nh7FvADa4Yq5WtRBkdAuIomVljRxluhgdMuOWcckuoBALKQ==",+ "license": "MIT"+ },+ "node_modules/sharp": {+ "version": "0.35.3",+ "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.3.tgz",+ "integrity": "sha512-ej0zVHuZGHCiABXcNxeYhpRnPNPAcvbG8RMdBAhDAxLKkCRVSpK3Iyu7qbqw3JMzoj0REeM6f3tJLtVwl0023Q==",+ "license": "Apache-2.0",+ "optional": true,+ "dependencies": {+ "@img/colour": "^1.1.0",+ "detect-libc": "^2.1.2",+ "semver": "^7.8.5"+ },+ "engines": {+ "node": ">=20.9.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-darwin-arm64": "0.35.3",+ "@img/sharp-darwin-x64": "0.35.3",+ "@img/sharp-freebsd-wasm32": "0.35.3",+ "@img/sharp-libvips-darwin-arm64": "1.3.2",+ "@img/sharp-libvips-darwin-x64": "1.3.2",+ "@img/sharp-libvips-linux-arm": "1.3.2",+ "@img/sharp-libvips-linux-arm64": "1.3.2",+ "@img/sharp-libvips-linux-ppc64": "1.3.2",+ "@img/sharp-libvips-linux-riscv64": "1.3.2",+ "@img/sharp-libvips-linux-s390x": "1.3.2",+ "@img/sharp-libvips-linux-x64": "1.3.2",+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.2",+ "@img/sharp-libvips-linuxmusl-x64": "1.3.2",+ "@img/sharp-linux-arm": "0.35.3",+ "@img/sharp-linux-arm64": "0.35.3",+ "@img/sharp-linux-ppc64": "0.35.3",+ "@img/sharp-linux-riscv64": "0.35.3",+ "@img/sharp-linux-s390x": "0.35.3",+ "@img/sharp-linux-x64": "0.35.3",+ "@img/sharp-linuxmusl-arm64": "0.35.3",+ "@img/sharp-linuxmusl-x64": "0.35.3",+ "@img/sharp-webcontainers-wasm32": "0.35.3",+ "@img/sharp-win32-arm64": "0.35.3",+ "@img/sharp-win32-ia32": "0.35.3",+ "@img/sharp-win32-x64": "0.35.3"+ },+ "peerDependenciesMeta": {+ "@types/node": {+ "optional": true+ }+ }+ },+ "node_modules/source-map-js": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",+ "license": "BSD-3-Clause",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/styled-jsx": {+ "version": "5.1.6",+ "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz",+ "integrity": "sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==",+ "license": "MIT",+ "dependencies": {+ "client-only": "0.0.1"+ },+ "engines": {+ "node": ">= 12.0.0"+ },+ "peerDependencies": {+ "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0"+ },+ "peerDependenciesMeta": {+ "@babel/core": {+ "optional": true+ },+ "babel-plugin-macros": {+ "optional": true+ }+ }+ },+ "node_modules/tailwindcss": {+ "version": "4.3.3",+ "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz",+ "integrity": "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/tapable": {+ "version": "2.3.3",+ "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz",+ "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/webpack"+ }+ },+ "node_modules/tslib": {+ "version": "2.8.1",+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",+ "license": "0BSD"+ },+ "node_modules/typescript": {+ "version": "5.9.3",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",+ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",+ "dev": true,+ "license": "Apache-2.0",+ "bin": {+ "tsc": "bin/tsc",+ "tsserver": "bin/tsserver"+ },+ "engines": {+ "node": ">=14.17"+ }+ },+ "node_modules/undici-types": {+ "version": "6.21.0",+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",+ "dev": true,+ "license": "MIT"+ }+ }+}diff --git a/apps/native/package.json b/apps/native/package.jsonnew file mode 100644index 00000000..9698fa2d--- /dev/null+++ b/apps/native/package.json@@ -0,0 +1,32 @@+{+ "name": "@codegraff/native",+ "private": true,+ "type": "module",+ "version": "0.1.0",+ "license": "Apache-2.0",+ "scripts": {+ "dev": "NEXT_TELEMETRY_DISABLED=1 next dev --port 3000",+ "build": "NEXT_TELEMETRY_DISABLED=1 next build",+ "start": "NEXT_TELEMETRY_DISABLED=1 next start --port 3000",+ "mock-serve": "node scripts/mock-serve.mjs",+ "lint": "next lint",+ "test": "node --experimental-strip-types --test lib/graff-events.test.ts"+ },+ "dependencies": {+ "glimm": "^0.3.0",+ "iconoir-react": "^7.11.1",+ "liveline": "^0.0.7",+ "next": "^15.3.3",+ "react": "^19.1.0",+ "react-dom": "^19.1.0",+ "shadow-plugin": "^2.1.0"+ },+ "devDependencies": {+ "@tailwindcss/postcss": "^4.1.8",+ "@types/node": "^22",+ "@types/react": "^19",+ "@types/react-dom": "^19",+ "tailwindcss": "^4.1.8",+ "typescript": "^5"+ }+}diff --git a/apps/native/postcss.config.mjs b/apps/native/postcss.config.mjsnew file mode 100644index 00000000..c7bcb4b1--- /dev/null+++ b/apps/native/postcss.config.mjs@@ -0,0 +1,5 @@+const config = {+ plugins: ["@tailwindcss/postcss"],+};++export default config;diff --git a/apps/native/scripts/mock-serve.mjs b/apps/native/scripts/mock-serve.mjsnew file mode 100644index 00000000..54d4ea0b--- /dev/null+++ b/apps/native/scripts/mock-serve.mjs@@ -0,0 +1,83 @@+#!/usr/bin/env node+/** Offline stand-in for `graff serve` so the UI can be exercised without a+ * provider key. Speaks the same /healthz + /v1/sessions NDJSON contract. */+import http from "node:http";++const PORT = Number(process.env.PORT ?? 8787);++function ndjson(res, events) {+ res.writeHead(200, {+ "content-type": "application/x-ndjson",+ "cache-control": "no-store",+ });+ for (const ev of events) res.write(`${JSON.stringify(ev)}\n`);+ res.end();+}++function readBody(req) {+ return new Promise((resolve) => {+ const chunks = [];+ req.on("data", (c) => chunks.push(c));+ req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));+ });+}++const server = http.createServer(async (req, res) => {+ const url = new URL(req.url ?? "/", `http://127.0.0.1:${PORT}`);+ if (req.method === "GET" && url.pathname === "/healthz") {+ res.writeHead(200, { "content-type": "application/json" });+ res.end(JSON.stringify({ status: "ok", mock: true }));+ return;+ }+ if (req.method === "POST" && url.pathname === "/v1/sessions") {+ res.writeHead(200, { "content-type": "application/json" });+ res.end(JSON.stringify({ session_id: "mock000000000001", resumed: false, last_seq: 0 }));+ return;+ }+ const session = url.pathname.match(/^\/v1\/sessions\/([^/]+)$/);+ if (session && req.method === "POST") {+ const raw = await readBody(req);+ let body = {};+ try {+ body = JSON.parse(raw || "{}");+ } catch {+ body = {};+ }+ if (body.type === "answer" || body.type === "cancel") {+ res.writeHead(200, { "content-type": "application/json" });+ res.end(JSON.stringify({ ok: true }));+ return;+ }+ if (body.type === "set_model") {+ ndjson(res, [{ seq: 1, type: "model", ok: true, provider: "mock", model: body.model ?? "gpt-5.5", context: 0, note: "" }]);+ return;+ }+ const prompt = String(body.text ?? "");+ ndjson(res, [+ { seq: 1, type: "started", provider: "mock", model: "gpt-5.5" },+ { seq: 2, type: "reasoning", text: "I'll inspect the workspace, then answer." },+ {+ seq: 3,+ type: "tool_call",+ name: "read_file",+ input: { path: "README.md" },+ },+ { seq: 4, type: "tool_result", name: "read_file", is_error: false, text: "# codegraff\nZig coding harness" },+ { seq: 5, type: "text", text: `Heard: ${prompt || "(empty)"}\n\n` },+ { seq: 6, type: "text", text: "This is a mock graff serve stream. Point GRAFF_SERVE_URL at a real `graff serve` for the live agent." },+ { seq: 7, type: "turn", text: "", context_tokens: 12, cost_usd: 0, input_tokens: 0, uncached_input_tokens: 0, cache_read_tokens: 0, output_tokens: 0, api_calls: 0, subscription_calls: 0, unpriced_calls: 0 },+ ]);+ return;+ }+ if (session && req.method === "DELETE") {+ res.writeHead(200, { "content-type": "application/json" });+ res.end(JSON.stringify({ ok: true }));+ return;+ }+ res.writeHead(404);+ res.end("not found");+});++server.listen(PORT, "127.0.0.1", () => {+ console.log(`mock graff serve on http://127.0.0.1:${PORT}`);+});diff --git a/apps/native/tsconfig.json b/apps/native/tsconfig.jsonnew file mode 100644index 00000000..c51be7a8--- /dev/null+++ b/apps/native/tsconfig.json@@ -0,0 +1,21 @@+{+ "compilerOptions": {+ "target": "ES2022",+ "lib": ["dom", "dom.iterable", "esnext"],+ "allowJs": true,+ "skipLibCheck": true,+ "strict": true,+ "noEmit": true,+ "esModuleInterop": true,+ "module": "esnext",+ "moduleResolution": "bundler",+ "resolveJsonModule": true,+ "isolatedModules": true,+ "jsx": "preserve",+ "incremental": true,+ "plugins": [{ "name": "next" }],+ "paths": { "@/*": ["./*"] }+ },+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],+ "exclude": ["node_modules", "out", "lib/*.test.ts"]+}