Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

feat(ui): redesign the popup and side panel

Shahriard8c7ca2a99e5
diff --git a/components/daemon-link.tsx b/components/daemon-link.tsx
index 198602e..e5d4e60 100644
--- a/components/daemon-link.tsx
+++ b/components/daemon-link.tsx
@@ -6,7 +6,6 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { BRIDGE_CHANNEL, type ActionResult } from '@/lib/actions/protocol';
import { useDaemonState } from '@/lib/bridge/use-daemon-state';
-import { cn } from '@/lib/utils';
export function DaemonLink() {
const daemon = useDaemonState();
@@ -38,54 +37,59 @@ export function DaemonLink() {
}
return (
- <div className="space-y-2">
- <p className="flex items-center gap-1.5 text-xs text-muted-foreground">
- <span
- className={cn(
- 'size-1.5 shrink-0 rounded-full',
- connected ? 'bg-emerald-500' : paired ? 'bg-amber-500' : 'bg-muted-foreground/40',
- )}
- />
- {connected
- ? `Agent control active · port ${daemon?.port}`
- : paired
- ? 'Paired · reconnecting…'
- : 'Agent control off'}
- </p>
+ <section className="space-y-2">
+ <div className="flex items-baseline justify-between gap-2">
+ <h2 className="font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase">Browser link</h2>
+ {connected && (
+ <span className="font-mono text-[10px] text-ink-faint">127.0.0.1:{daemon?.port}</span>
+ )}
+ </div>
{paired ? (
- <Button variant="outline" size="sm" className="w-full" onClick={disconnect} disabled={busy}>
- <Link2Off /> Disconnect
- </Button>
- ) : (
- <form
- className="flex gap-1.5"
- onSubmit={(event) => {
- event.preventDefault();
- void pair();
- }}
- >
- <Input
- value={code}
- onChange={(event) => setCode(event.target.value)}
- placeholder="Pairing code"
- aria-label="Pairing code from browsentic-mcp pair"
- className="h-8 font-mono text-xs uppercase"
- autoComplete="off"
- spellCheck={false}
- />
- <Button type="submit" size="sm" disabled={busy || !code.trim()}>
- {busy ? <Loader2 className="animate-spin" /> : <Link2 />} Connect
+ <>
+ <p className="text-[11px] leading-relaxed text-ink-dim">
+ {connected
+ ? 'The daemon is driving this browser. Disconnecting revokes the key — you will need a new pairing code.'
+ : 'Paired, but the daemon is not answering. Start it with browsentic-mcp, or disconnect to pair again.'}
+ </p>
+ <Button variant="outline" size="sm" className="w-full" onClick={disconnect} disabled={busy}>
+ {busy ? <Loader2 className="animate-spin" /> : <Link2Off />} Disconnect
</Button>
- </form>
+ </>
+ ) : (
+ <>
+ <p className="text-[11px] leading-relaxed text-ink-dim">
+ Run <code className="rounded bg-surface px-1 py-px font-mono text-ink">browsentic-mcp pair</code> in a
+ terminal and paste the code it prints.
+ </p>
+ <form
+ className="flex gap-1.5"
+ onSubmit={(event) => {
+ event.preventDefault();
+ void pair();
+ }}
+ >
+ <Input
+ value={code}
+ onChange={(event) => setCode(event.target.value)}
+ placeholder="Pairing code"
+ aria-label="Pairing code from browsentic-mcp pair"
+ className="h-8 font-mono text-xs tracking-widest uppercase"
+ autoComplete="off"
+ spellCheck={false}
+ />
+ <Button type="submit" size="sm" disabled={busy || !code.trim()}>
+ {busy ? <Loader2 className="animate-spin" /> : <Link2 />} Connect
+ </Button>
+ </form>
+ </>
)}
- {error && <p className="text-xs text-destructive">{error}</p>}
- {!paired && !error && (
- <p className="text-xs text-muted-foreground">
- Run <code className="font-mono">browsentic-mcp pair</code> for a code.
+ {error && (
+ <p className="rounded-lg border border-destructive/40 bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive">
+ {error}
</p>
)}
- </div>
+ </section>
);
}
diff --git a/components/markdown.tsx b/components/markdown.tsx
index 21bf05a..ca91205 100644
--- a/components/markdown.tsx
+++ b/components/markdown.tsx
@@ -1,16 +1,49 @@
-import { useMemo, type ReactNode } from 'react';
+import { memo, useMemo, useRef, type ReactNode } from 'react';
import { cn } from '@/lib/utils';
-export function Markdown({ text, className }: { text: string; className?: string }) {
- const blocks = useMemo(() => parseBlocks(text), [text]);
+/*
+ * `streaming` marks the reply that is still arriving: every word mounts with a
+ * blur-in and a caret trails the last block. The marker stays on as `done`
+ * afterwards so the words still in flight when the run ends finish settling
+ * rather than snapping. A reply read back from a transcript never gets it.
+ *
+ * Blocks are memoized on their own shape, so a delta only re-renders the block
+ * it lands in.
+ */
+export function Markdown({
+ text,
+ streaming,
+ className,
+}: {
+ text: string;
+ streaming?: boolean;
+ className?: string;
+}) {
+ const arrivedLive = useRef(false);
+ if (streaming) arrivedLive.current = true;
+
+ const blocks = useMemo(
+ () => parseBlocks(text).map((block) => ({ block, sig: JSON.stringify(block) })),
+ [text],
+ );
return (
- <div className={cn('flex min-w-0 flex-col gap-2', className)}>
- {blocks.map((block, index) => renderBlock(block, String(index)))}
+ <div
+ data-stream={streaming ? 'live' : arrivedLive.current ? 'done' : undefined}
+ className={cn('flex min-w-0 flex-col gap-2', className)}
+ >
+ {blocks.map(({ block, sig }, index) => (
+ <MemoBlock key={index} block={block} sig={sig} />
+ ))}
</div>
);
}
+const MemoBlock = memo(
+ ({ block }: { block: Block; sig: string }) => renderBlock(block, '0'),
+ (before, after) => before.sig === after.sig,
+);
+
type Align = 'left' | 'center' | 'right';
type Block =
@@ -213,7 +246,7 @@ function leading(line: string): number {
const dedent = (line: string, by: number) => line.replace(/^[ \t]+/, (ws) => ws.replace(/\t/g, ' ').slice(by));
-const CHIP = 'rounded bg-black/8 px-1 py-px font-mono text-[0.85em] dark:bg-white/12';
+const CHIP = 'rounded bg-surface px-1 py-px font-mono text-[0.85em] text-ink';
function renderBlock(block: Block, key: string): ReactNode {
switch (block.kind) {
@@ -237,7 +270,7 @@ function renderBlock(block: Block, key: string): ReactNode {
return (
<pre
key={key}
- className="max-w-full overflow-x-auto rounded-md bg-black/8 p-2 text-xs whitespace-pre dark:bg-white/12"
+ className="max-w-full overflow-x-auto rounded-lg border border-line bg-ground/70 p-2 text-xs whitespace-pre"
>
<code className="font-mono">{block.text}</code>
</pre>
@@ -264,7 +297,7 @@ function renderBlock(block: Block, key: string): ReactNode {
return (
<blockquote
key={key}
- className="flex flex-col gap-2 border-l-2 border-black/15 pl-2.5 opacity-80 dark:border-white/20"
+ className="flex flex-col gap-2 border-l-2 border-brand/40 pl-2.5 text-ink-dim"
>
{block.blocks.map((inner, index) => renderBlock(inner, String(index)))}
</blockquote>
@@ -279,7 +312,7 @@ function renderBlock(block: Block, key: string): ReactNode {
{block.head.map((cell, index) => (
<th
key={index}
- className={cn('border-b border-black/15 px-1.5 py-1 font-semibold dark:border-white/20', ALIGN[block.align[index] ?? 'left'])}
+ className={cn('border-b border-line-strong px-1.5 py-1 font-semibold', ALIGN[block.align[index] ?? 'left'])}
>
{renderInline(cell)}
</th>
@@ -292,7 +325,7 @@ function renderBlock(block: Block, key: string): ReactNode {
{row.map((cell, index) => (
<td
key={index}
- className={cn('border-b border-black/8 px-1.5 py-1 align-top dark:border-white/10', ALIGN[block.align[index] ?? 'left'])}
+ className={cn('border-b border-line px-1.5 py-1 align-top', ALIGN[block.align[index] ?? 'left'])}
>
{renderInline(cell)}
</td>
@@ -305,7 +338,7 @@ function renderBlock(block: Block, key: string): ReactNode {
);
case 'rule':
- return <hr key={key} className="border-black/10 dark:border-white/15" />;
+ return <hr key={key} className="border-line" />;
}
}
@@ -351,13 +384,31 @@ const INLINE: InlineRule[] = [
{ re: /https?:\/\/[^\s<>"'`]*[^\s<>"'`.,;:!?)\]}]/y, linking: true, node: (m, key, depth) => link(m[0], m[0], key, depth) },
];
+/*
+ * Each word is its own span so a growing reply only ever mounts the words it
+ * just gained — the blur-in animation is mount-only, and settled text never
+ * replays it. Keys come from the start of the run, which never shifts as the
+ * text is appended to.
+ */
+const WORD = /(?<=\s)(?=\S)/;
+
function renderInline(text: string, depth = 0, inLink = false): ReactNode[] {
const out: ReactNode[] = [];
let plain = '';
+ let plainAt = 0;
let pos = 0;
const flush = () => {
- if (plain) out.push(plain);
+ if (plain) {
+ plain.split(WORD).forEach((word, index) => {
+ out.push(
+ <span key={`t${plainAt}.${index}`} className="tok">
+ {word}
+ </span>,
+ );
+ });
+ }
plain = '';
+ plainAt = pos + 1;
};
let closeAt = text.indexOf(')');
diff --git a/components/monitor-bar.tsx b/components/monitor-bar.tsx
index 9c10b8f..c0e6d58 100644
--- a/components/monitor-bar.tsx
+++ b/components/monitor-bar.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
-import { Square } from 'lucide-react';
+import { Radar, Square } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { formatEta, type MonitorState } from '@/lib/monitor/events';
@@ -9,28 +9,29 @@ export function MonitorBar({ state, onStop }: { state: MonitorState; onStop: ()
const percent = state.percent != null ? Math.round(state.percent) : null;
return (
- <div className="mb-2 rounded-md border border-sky-500/40 bg-sky-500/5 p-2.5">
+ <div className="enters mb-2 rounded-xl border border-magenta/35 bg-magenta/8 p-2.5">
<div className="flex items-center gap-2">
- <span className="size-2 shrink-0 animate-pulse rounded-full bg-sky-500" />
- <span className="min-w-0 truncate text-xs font-medium">Watching {state.label ?? state.host}</span>
- <span className="font-mono text-xs tabular-nums text-muted-foreground">{clock(elapsed)}</span>
- <span className="flex-1 text-right font-mono text-[11px] tabular-nums text-muted-foreground">
- {percent != null ? `${percent}%` : ''}
+ <Radar className="size-3.5 shrink-0 animate-pulse text-magenta" />
+ <span className="min-w-0 flex-1 truncate text-xs font-medium text-ink">
+ Watching {state.label ?? state.host}
</span>
- <Button
- size="sm"
- className="h-6 shrink-0 bg-sky-600 px-2 text-xs text-white shadow-xs hover:bg-sky-700"
- onClick={onStop}
- >
+ <span className="shrink-0 font-mono text-[11px] tabular-nums text-ink-faint">
+ {clock(elapsed)}
+ {percent != null && ` · ${percent}%`}
+ </span>
+ <Button size="sm" variant="ghost" className="shrink-0 text-magenta hover:text-magenta" onClick={onStop}>
<Square className="size-3 fill-current" /> Stop
</Button>
</div>
{percent != null && (
- <div className="mt-1.5 h-1 overflow-hidden rounded-full bg-sky-500/15">
- <div className="h-full rounded-full bg-sky-500 transition-[width]" style={{ width: `${percent}%` }} />
+ <div className="mt-2 h-1 overflow-hidden rounded-full bg-magenta/15">
+ <div
+ className="glow-dot h-full rounded-full bg-magenta text-magenta transition-[width] duration-500"
+ style={{ width: `${percent}%` }}
+ />
</div>
)}
- <p className="mt-1.5 text-[11px] leading-relaxed text-muted-foreground">{statusLine(state, left)}</p>
+ <p className="mt-1.5 text-[11px] leading-relaxed text-ink-faint">{statusLine(state, left)}</p>
</div>
);
}
diff --git a/components/recording-bar.tsx b/components/recording-bar.tsx
index de51b56..cdbc734 100644
--- a/components/recording-bar.tsx
+++ b/components/recording-bar.tsx
@@ -8,23 +8,18 @@ export function RecordingBar({ state, onStop }: { state: RecordingState; onStop:
const left = Math.max(0, MAX_RECORDING_MS - elapsed);
return (
- <div className="mb-2 rounded-md border border-red-500/40 bg-red-500/5 p-2.5">
+ <div className="enters mb-2 rounded-xl border border-destructive/40 bg-destructive/8 p-2.5">
<div className="flex items-center gap-2">
- <span className="size-2 shrink-0 animate-pulse rounded-full bg-red-500" />
- <span className="text-xs font-medium">Recording {state.host}</span>
- <span className="font-mono text-xs tabular-nums text-muted-foreground">{clock(elapsed)}</span>
- <span className="flex-1 text-[11px] text-muted-foreground">
- {state.events} {state.events === 1 ? 'step' : 'steps'}
+ <span className="glow-dot size-2 shrink-0 animate-pulse rounded-full bg-destructive text-destructive" />
+ <span className="min-w-0 flex-1 truncate text-xs font-medium text-ink">Recording {state.host}</span>
+ <span className="shrink-0 font-mono text-[11px] tabular-nums text-ink-faint">
+ {clock(elapsed)} · {state.events} {state.events === 1 ? 'step' : 'steps'}
</span>
- <Button
- size="sm"
- className="h-6 shrink-0 bg-red-600 px-2 text-xs text-white shadow-xs hover:bg-red-700"
- onClick={onStop}
- >
+ <Button size="sm" variant="ghost" className="shrink-0 text-destructive hover:text-destructive" onClick={onStop}>
<Square className="size-3 fill-current" /> Stop
</Button>
</div>
- <p className="mt-1.5 text-[11px] leading-relaxed text-muted-foreground">
+ <p className="mt-1.5 text-[11px] leading-relaxed text-ink-faint">
{state.warning ?? `Stops automatically in ${clock(left)}.`}
{!state.captureValues && ' Typed values are not being saved.'}
</p>
diff --git a/components/recording-list.tsx b/components/recording-list.tsx
index e1057ae..170f5d8 100644
--- a/components/recording-list.tsx
+++ b/components/recording-list.tsx
@@ -17,17 +17,18 @@ export function RecordingList({
}) {
if (recordings.length === 0) {
return (
- <p className="px-1 py-1 text-[11px] leading-relaxed text-muted-foreground">
- No recordings yet. Press Record above to capture what you do on a site — the clicks, the fields you fill, the
- pages you move through — and Browsentic turns it into steps the assistant can repeat later. A recording runs for
- at most 15 minutes.
- </p>
+ <div className="dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center">
+ <Clapperboard className="mx-auto size-5 text-ink-faint" />
+ <p className="mt-2 text-[11px] leading-relaxed text-ink-faint">
+ No recordings yet. Press Record above and walk through the flow you want repeated.
+ </p>
+ </div>
);
}
return (
<div className="flex min-w-0 flex-col gap-1.5">
{busy && (
- <p className="px-1 pb-1 text-[11px] text-muted-foreground">
+ <p className="px-1 pb-1 text-[11px] text-ink-faint">
Waiting on the current run — stop it to replay a recording.
</p>
)}
@@ -59,15 +60,15 @@ function RecordingRow({
const ready = recording.status === 'ready';
return (
- <div className="flex items-start gap-2 rounded-md border bg-background/60 px-2.5 py-1.5 text-xs">
- <Clapperboard className="mt-0.5 size-3.5 shrink-0 text-muted-foreground" />
+ <div className="flex items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-2 text-xs">
+ <Clapperboard className="mt-0.5 size-3.5 shrink-0 text-ink-faint" />
<div className="min-w-0 flex-1">
{editing === null ? (
<div className="flex items-center gap-1.5">
- <span className="truncate font-medium">{recording.name}</span>
+ <span className="truncate font-medium text-ink">{recording.name}</span>
{recording.capturedValues && (
- <Badge variant="outline" className="h-4 shrink-0 gap-0.5 px-1 text-[10px]">
- <KeyRound className="size-2.5" /> values
+ <Badge variant="warning">
+ <KeyRound /> values
</Badge>
)}
</div>
@@ -85,7 +86,7 @@ function RecordingRow({
}
}}
aria-label="Recording name"
- className="h-6 text-xs"
+ className="h-7 text-xs"
/>
<button
type="button"
@@ -94,23 +95,23 @@ function RecordingRow({
setEditing(null);
}}
aria-label="Save name"
- className="shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
+ className="shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink"
>
<Check className="size-3" />
</button>
</div>
)}
- <span className="mt-0.5 flex items-center gap-1 font-mono text-[10px] text-muted-foreground">
+ <span className="mt-0.5 flex items-center gap-1 font-mono text-[10px] text-ink-faint">
<Globe className="size-2.5 shrink-0" />
<span className="truncate">{recording.host}</span>
</span>
{recording.goal && recording.goal !== recording.name && (
- <p className="mt-0.5 line-clamp-2 text-[11px] text-muted-foreground">{recording.goal}</p>
+ <p className="mt-0.5 line-clamp-2 text-[11px] text-ink-dim">{recording.goal}</p>
)}
- <span className="mt-0.5 flex items-center gap-1 text-[11px] text-muted-foreground">
+ <span className="mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint">
{recording.status === 'analyzing' ? (
<>
<Loader2 className="size-3 animate-spin" /> Splitting into steps…
@@ -130,7 +131,7 @@ function RecordingRow({
type="button"
onClick={() => onReplay(recording)}
disabled={busy}
- className="mt-1 flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-primary hover:bg-muted disabled:opacity-50"
+ className="mt-1.5 inline-flex items-center gap-1 rounded-full bg-brand/12 px-2 py-0.5 text-[11px] text-brand transition-colors hover:bg-brand/20 disabled:opacity-50"
>
<Play className="size-3" /> Do this again
</button>
@@ -142,7 +143,7 @@ function RecordingRow({
type="button"
onClick={() => setEditing(recording.name)}
aria-label={`Rename ${recording.name}`}
- className="rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
+ className="rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink"
>
<Pencil className="size-3" />
</button>
@@ -150,7 +151,7 @@ function RecordingRow({
type="button"
onClick={() => onRemove(recording.id)}
aria-label={`Delete ${recording.name}`}
- className="rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
+ className="rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink"
>
<X className="size-3" />
</button>
diff --git a/components/recording-panel.tsx b/components/recording-panel.tsx
index 4f21715..576f773 100644
--- a/components/recording-panel.tsx
+++ b/components/recording-panel.tsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import { Circle, Clapperboard, Square } from 'lucide-react';
+import { Circle, Square } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { RecordingList } from '@/components/recording-list';
import type { StoredRecordingMeta } from '@/lib/bridge/recording-store';
@@ -30,54 +30,44 @@ export function RecordingPanel({
const recordable = !busy && !recording && /^https?:/.test(tabUrl);
return (
- <div className="mb-2 rounded-md border bg-muted/30 p-2.5">
- <div className="mb-2 flex items-center gap-1.5">
- <Clapperboard className="size-3.5 shrink-0 text-muted-foreground" />
- <span className="flex-1 text-xs font-medium">Recordings</span>
- {recordings.length > 0 && (
- <span className="text-[11px] text-muted-foreground">{recordings.length} saved</span>
- )}
- </div>
+ <div className="flex min-w-0 flex-col gap-3 p-3">
+ <p className="text-[11px] leading-relaxed text-ink-dim">
+ Capture what you do on a site — the clicks, the fields you fill, the pages you move through — and the agent can
+ repeat it later. A recording runs for at most 15 minutes.
+ </p>
{recording ? (
- <Button
- size="sm"
- className="mb-2 w-full bg-red-600 text-white shadow-xs hover:bg-red-700"
- onClick={onStop}
- >
- <Square className="size-3 fill-current" /> Stop recording
+ <Button variant="destructive" onClick={onStop}>
+ <Square className="fill-current" /> Stop recording
</Button>
) : (
<Button
- size="sm"
- className="mb-2 w-full bg-red-600 text-white shadow-xs hover:bg-red-700 disabled:bg-muted disabled:text-muted-foreground"
+ variant="destructive"
onClick={() => onStart(captureValues)}
disabled={!recordable}
title={recordable ? `Record what you do on ${host}` : 'Open an http(s) page, with nothing else running'}
>
- <Circle className="size-3 fill-current" />
+ <Circle className="fill-current" />
<span className="truncate">Record {host || 'this page'}</span>
</Button>
)}
{!recording && (
- <label className="mb-2 flex cursor-pointer items-start gap-1.5 px-1 text-[11px] leading-relaxed text-muted-foreground">
+ <label className="flex cursor-pointer items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-2 text-[11px] leading-relaxed text-ink-dim">
<input
type="checkbox"
checked={captureValues}
onChange={(e) => setCaptureValues(e.target.checked)}
- className="mt-0.5 size-3 shrink-0 accent-red-500"
+ className="mt-0.5 size-3 shrink-0 accent-destructive"
/>
<span>
- Save what I type. Off by default — every field becomes a placeholder the assistant asks you to fill.
- Passwords and card numbers are never saved either way. Recording stops after 15 minutes.
+ <span className="font-medium text-ink">Save what I type.</span> Off by default — every field becomes a
+ placeholder the agent asks you to fill. Passwords and card numbers are never saved either way.
</span>
</label>
)}
- <div className="max-h-56 overflow-y-auto">
- <RecordingList recordings={recordings} busy={busy} onReplay={onReplay} onRemove={onRemove} />
- </div>
+ <RecordingList recordings={recordings} busy={busy} onReplay={onReplay} onRemove={onRemove} />
</div>
);
}
diff --git a/components/run-timeline.tsx b/components/run-timeline.tsx
index caf3882..1d1dffe 100644
--- a/components/run-timeline.tsx
+++ b/components/run-timeline.tsx
@@ -1,4 +1,29 @@
-import { AlertTriangle, Bot, Check, Info, Terminal, User, Wrench, X, Zap } from 'lucide-react';
+import {
+ Camera,
+ Check,
+ Clapperboard,
+ Compass,
+ CornerDownLeft,
+ ExternalLink,
+ Eye,
+ Highlighter,
+ Hourglass,
+ Info,
+ Keyboard,
+ ListChecks,
+ MousePointerClick,
+ MoveVertical,
+ Paperclip,
+ Radar,
+ Terminal,
+ TextCursorInput,
+ TriangleAlert,
+ Type,
+ Wrench,
+ X,
+ Zap,
+ type LucideIcon,
+} from 'lucide-react';
import { Markdown } from '@/components/markdown';
import { Button } from '@/components/ui/button';
@@ -8,78 +33,125 @@ import { cn } from '@/lib/utils';
interface RunTimelineProps {
items: RunItem[];
- onDecide: (toolId: string, allow: boolean) => void;
+ running: boolean;
+ onDecide: (toolId: string, allow: boolean, remember?: boolean) => void;
}
-export function RunTimeline({ items, onDecide }: RunTimelineProps) {
+export function RunTimeline({ items, running, onDecide }: RunTimelineProps) {
+ const last = items.at(-1);
+ const streaming = running && last?.kind === 'assistant';
+ const awaiting = running && !streaming;
+
return (
- <div className="flex min-w-0 flex-col gap-4 p-4">
- {items.map((item) =>
+ <div className="flex min-w-0 flex-col gap-2.5 p-3">
+ {items.map((item, index) =>
item.kind === 'tool' ? (
<ToolRow key={item.id} item={item} onDecide={onDecide} />
) : item.kind === 'notice' ? (
<Notice key={item.id} item={item} />
+ ) : item.kind === 'user' ? (
+ <UserBubble key={item.id} text={item.text} />
) : (
- <Bubble key={item.id} item={item} />
+ <Reply key={item.id} text={item.text} streaming={streaming && index === items.length - 1} />
),
)}
+ {awaiting && <Thinking />}
</div>
);
}
-function Bubble({ item }: { item: Extract<RunItem, { kind: 'user' | 'assistant' }> }) {
- const isAssistant = item.kind === 'assistant';
+function UserBubble({ text }: { text: string }) {
return (
- <div className={cn('flex min-w-0 gap-2', !isAssistant && 'flex-row-reverse')}>
- <div
- className={cn(
- 'flex size-7 shrink-0 items-center justify-center rounded-full',
- isAssistant
- ? 'bg-gradient-to-br from-violet-500 to-indigo-600 text-white'
- : 'bg-muted text-muted-foreground',
- )}
- >
- {isAssistant ? <Bot className="size-4" /> : <User className="size-4" />}
- </div>
- <div
- className={cn(
- 'min-w-0 max-w-[85%] rounded-2xl px-3 py-2 text-sm',
- isAssistant ? 'rounded-tl-sm bg-muted' : 'rounded-tr-sm bg-primary text-primary-foreground',
- )}
- >
- {isAssistant ? (
- <Markdown text={item.text} />
- ) : (
- <span className="whitespace-pre-wrap wrap-anywhere">{item.text}</span>
- )}
+ <div className="enters flex min-w-0 justify-end">
+ <div className="min-w-0 max-w-[88%] rounded-2xl rounded-br-md border border-brand/30 bg-brand/10 px-3 py-2 text-sm whitespace-pre-wrap wrap-anywhere text-ink">
+ {text}
</div>
</div>
);
}
+function Reply({ text, streaming }: { text: string; streaming: boolean }) {
+ return (
+ <div className="enters min-w-0">
+ <Markdown
+ text={text}
+ streaming={streaming}
+ className="panel-card rounded-2xl rounded-tl-md px-3 py-2.5 text-sm leading-relaxed text-ink"
+ />
+ </div>
+ );
+}
+
+function Thinking() {
+ return (
+ <div className="flex items-center gap-2 px-1">
+ <span className="flex items-center gap-1">
+ {[0, 1, 2].map((dot) => (
+ <span key={dot} className="think-dot size-1.5 rounded-full bg-brand" />
+ ))}
+ </span>
+ <span className="font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase">Working</span>
+ </div>
+ );
+}
+
function ToolRow({
item,
onDecide,
}: {
item: Extract<RunItem, { kind: 'tool' }>;
- onDecide: (toolId: string, allow: boolean) => void;
+ onDecide: (toolId: string, allow: boolean, remember?: boolean) => void;
}) {
+ const name = item.action.replace(/^page\./, '');
+ const Icon = ICONS[name] ?? Wrench;
+ const pending = item.ok === undefined && !item.awaiting;
+
return (
- <div className="ml-9 flex min-w-0 flex-col gap-1.5">
- <div className="flex min-w-0 items-center gap-2 text-xs">
- <StatusIcon ok={item.ok} awaiting={item.awaiting} />
- <span className="shrink-0 font-mono text-muted-foreground">{item.action.replace(/^page\./, '')}</span>
- {item.source === 'local' && (
- <Zap className="size-3 shrink-0 text-amber-500" aria-label="Handled in the browser" />
- )}
- {item.source === 'external' && (
- <Terminal className="size-3 shrink-0 text-sky-500" aria-label="Run by a connected MCP client" />
- )}
- {item.summary && (
- <span className={cn('min-w-0 truncate', item.ok === false ? 'text-destructive' : 'text-muted-foreground')}>
- {item.summary}
- </span>
+ <div className="enters flex min-w-0 flex-col gap-1.5">
+ <div
+ className={cn(
+ 'relative flex min-w-0 items-start gap-2 overflow-hidden rounded-lg border px-2 py-1.5 transition-colors',
+ item.awaiting
+ ? 'border-ember/45 bg-ember/10'
+ : item.ok === false
+ ? 'border-destructive/40 bg-destructive/8'
+ : 'border-line bg-ground/40',
+ pending && 'sweep',
)}
+ >
+ <Icon
+ className={cn(
+ 'mt-0.5 size-3 shrink-0',
+ item.awaiting
+ ? 'text-ember'
+ : item.ok === false
+ ? 'text-destructive'
+ : item.source === 'local'
+ ? 'text-amber'
+ : item.source === 'external'
+ ? 'text-magenta'
+ : 'text-brand',
+ )}
+ />
+ <div className="min-w-0 flex-1">
+ <div className="flex min-w-0 items-center gap-1.5">
+ <span className="truncate font-mono text-[10px] text-ink">{name}</span>
+ {item.source === 'local' && <Tag tone="amber" icon={Zap} label="local" />}
+ {item.source === 'external' && <Tag tone="magenta" icon={Terminal} label="mcp" />}
+ </div>
+ {item.summary && (
+ <p
+ className={cn(
+ 'mt-0.5 truncate text-[10px]',
+ item.ok === false ? 'text-destructive' : 'text-ink-faint',
+ )}
+ >
+ {item.summary}
+ </p>
+ )}
+ </div>
+ {item.ok === true && <Check className="mt-0.5 size-3 shrink-0 text-lime/80" />}
+ {item.ok === false && <X className="mt-0.5 size-3 shrink-0 text-destructive" />}
</div>
{item.preview && (
@@ -87,25 +159,35 @@ function ToolRow({
type="button"
onClick={() => void openScreenshot(item.preview!)}
title={`Open the ${item.preview.full ? 'full-size' : 'captured'} screenshot in a new tab`}
- className="group max-w-[85%] overflow-hidden rounded-lg border bg-muted/40 transition hover:border-primary/60 hover:opacity-90"
+ className="group max-w-[88%] overflow-hidden rounded-xl border border-line bg-ground/60 transition-colors hover:border-brand/50"
>
<img
src={item.preview.thumbnail}
alt={`Screenshot, ${item.preview.width}×${item.preview.height}`}
width={item.preview.width}
height={item.preview.height}
- className="block h-auto w-full"
+ className="block h-auto w-full transition-opacity group-hover:opacity-85"
/>
</button>
)}
{item.awaiting && (
- <div className="flex items-center gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-2.5 py-2">
- <p className="flex-1 text-xs">Allow this action?</p>
- <Button size="sm" variant="outline" className="h-7" onClick={() => onDecide(item.id, false)}>
+ <div className="flex flex-wrap items-center gap-1.5 rounded-lg border border-ember/45 bg-ember/10 px-2.5 py-2">
+ <p className="flex-1 text-xs text-ink">Allow this action?</p>
+ <Button size="sm" variant="ghost" onClick={() => onDecide(item.id, false)}>
Deny
</Button>
- <Button size="sm" className="h-7" onClick={() => onDecide(item.id, true)}>
+ {item.site && (
+ <Button
+ size="sm"
+ variant="ghost"
+ onClick={() => onDecide(item.id, true, true)}
+ title={`Stop asking for ${name} on ${item.site}. Undo with “browsentic-mcp approvals clear”.`}
+ >
+ Always on {item.site}
+ </Button>
+ )}
+ <Button size="sm" onClick={() => onDecide(item.id, true)}>
Allow
</Button>
</div>
@@ -114,11 +196,18 @@ function ToolRow({
);
}
-function StatusIcon({ ok, awaiting }: { ok?: boolean; awaiting?: boolean }) {
- if (awaiting) return <AlertTriangle className="size-3.5 shrink-0 text-amber-500" />;
- if (ok === true) return <Check className="size-3.5 shrink-0 text-emerald-500" />;
- if (ok === false) return <X className="size-3.5 shrink-0 text-destructive" />;
- return <Wrench className="size-3.5 shrink-0 animate-pulse text-muted-foreground" />;
+function Tag({ tone, icon: Icon, label }: { tone: 'amber' | 'magenta'; icon: LucideIcon; label: string }) {
+ return (
+ <span
+ className={cn(
+ 'inline-flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-px font-mono text-[8px] tracking-[0.1em] uppercase',
+ tone === 'amber' ? 'bg-amber/15 text-amber' : 'bg-magenta/15 text-magenta',
+ )}
+ >
+ <Icon className="size-2" />
+ {label}
+ </span>
+ );
}
function Notice({ item }: { item: Extract<RunItem, { kind: 'notice' }> }) {
@@ -126,16 +215,48 @@ function Notice({ item }: { item: Extract<RunItem, { kind: 'notice' }> }) {
return (
<div
className={cn(
- 'ml-9 flex items-start gap-2 rounded-lg px-2.5 py-2 text-xs',
- isError ? 'bg-destructive/10 text-destructive' : 'text-muted-foreground',
+ 'enters flex items-start gap-2 rounded-lg px-2.5 py-1.5 text-[11px] leading-relaxed',
+ isError ? 'border border-destructive/35 bg-destructive/8 text-destructive' : 'text-ink-faint',
)}
>
{isError ? (
- <AlertTriangle className="mt-px size-3.5 shrink-0" />
+ <TriangleAlert className="mt-px size-3 shrink-0" />
) : (
- <Info className="mt-px size-3.5 shrink-0" />
+ <Info className="mt-px size-3 shrink-0" />
)}
<span className="min-w-0 break-words">{item.text}</span>
</div>
);
}
+
+const ICONS: Record<string, LucideIcon> = {
+ getPageInfo: Eye,
+ extractText: Eye,
+ findProgress: Eye,
+ clickElement: MousePointerClick,
+ trustedClick: MousePointerClick,
+ hoverElement: MousePointerClick,
+ fillInput: Type,
+ typeText: Type,
+ focusInput: TextCursorInput,
+ selectText: TextCursorInput,
+ pressKey: Keyboard,
+ submitForm: CornerDownLeft,
+ selectOption: ListChecks,
+ navigate: Compass,
+ openTab: ExternalLink,
+ switchTab: ExternalLink,
+ closeTab: X,
+ screenshot: Camera,
+ scrollTo: MoveVertical,
+ highlightElement: Highlighter,
+ waitForElement: Hourglass,
+ attachFile: Paperclip,
+ listFiles: Paperclip,
+ startMonitor: Radar,
+ stopMonitor: Radar,
+ monitorStatus: Radar,
+ awaitMonitor: Radar,
+ listRecordings: Clapperboard,
+ readRecording: Clapperboard,
+};
diff --git a/components/session-list.tsx b/components/session-list.tsx
index 278b771..1af4c0b 100644
--- a/components/session-list.tsx
+++ b/components/session-list.tsx
@@ -1,4 +1,4 @@
-import { Globe, Loader2, MessageSquare, X } from 'lucide-react';
+import { Globe, Loader2, MessagesSquare, X } from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { isNaming, type StoredSessionMeta } from '@/lib/bridge/session-store';
import { cn } from '@/lib/utils';
@@ -18,16 +18,20 @@ export function SessionList({
}) {
if (sessions.length === 0) {
return (
- <p className="p-4 text-xs leading-relaxed text-muted-foreground">
- No saved conversations yet. Every conversation is kept here automatically — the button beside this one closes
- the current conversation out and starts a fresh one.
- </p>
+ <div className="p-3">
+ <div className="dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center">
+ <MessagesSquare className="mx-auto size-5 text-ink-faint" />
+ <p className="mt-2 text-[11px] leading-relaxed text-ink-faint">
+ Every conversation lands here on its own. Start one in Chat, and “New chat” in the header closes it out.
+ </p>
+ </div>
+ </div>
);
}
return (
<div className="flex min-w-0 flex-col gap-1.5 p-3">
{busy && (
- <p className="px-1 pb-1 text-[11px] text-muted-foreground">
+ <p className="px-1 pb-1 text-[11px] text-ink-faint">
Waiting on the current run — stop it to reopen another conversation.
</p>
)}
@@ -62,8 +66,8 @@ function SessionRow({
return (
<div
className={cn(
- 'flex items-start gap-2 rounded-md border bg-background/60 px-2.5 py-1.5 text-xs',
- current && 'border-primary/40 bg-primary/5',
+ 'flex items-start gap-2 rounded-xl border px-2.5 py-2 text-xs transition-colors',
+ current ? 'border-brand/35 bg-brand/8' : 'border-line bg-ground/40 hover:border-line-strong',
)}
>
<button
@@ -73,23 +77,19 @@ function SessionRow({
className="flex min-w-0 flex-1 items-start gap-2 text-left disabled:opacity-50"
title={session.url}
>
- <MessageSquare className="mt-0.5 size-3.5 shrink-0 text-muted-foreground" />
+ <MessagesSquare className={cn('mt-0.5 size-3.5 shrink-0', current ? 'text-brand' : 'text-ink-faint')} />
<span className="min-w-0 flex-1">
<span className="flex items-center gap-1.5">
- <span className="truncate font-medium">{label}</span>
- {current && (
- <Badge variant="secondary" className="h-4 shrink-0 px-1 text-[10px]">
- open
- </Badge>
- )}
+ <span className="truncate font-medium text-ink">{label}</span>
+ {current && <Badge>open</Badge>}
</span>
{session.host && (
- <span className="mt-0.5 flex items-center gap-1 font-mono text-[10px] text-muted-foreground">
+ <span className="mt-0.5 flex items-center gap-1 font-mono text-[10px] text-ink-faint">
<Globe className="size-2.5 shrink-0" />
<span className="truncate">{session.host}</span>
</span>
)}
- <span className="mt-0.5 flex items-center gap-1 text-[11px] text-muted-foreground">
+ <span className="mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint">
{isNaming(session) && !session.title ? (
<>
<Loader2 className="size-3 animate-spin" /> Naming…
@@ -106,7 +106,7 @@ function SessionRow({
type="button"
onClick={() => onRemove(session.id)}
aria-label={`Delete ${label}`}
- className="mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
+ className="mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink"
>
<X className="size-3" />
</button>
diff --git a/components/site-map-review.tsx b/components/site-map-review.tsx
index 0469bab..9c9d100 100644
--- a/components/site-map-review.tsx
+++ b/components/site-map-review.tsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import { AlertTriangle, Check, FolderOpen, Images, Trash2 } from 'lucide-react';
+import { Check, FolderOpen, Images, Trash2, TriangleAlert } from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
@@ -18,11 +18,11 @@ export function SiteMapReview({
const matching = exactHost ? draft.host : draft.domain;
return (
- <div className="mb-2 overflow-hidden rounded-md border border-amber-500/40 bg-amber-500/5">
- <div className="flex items-start gap-2 border-b border-amber-500/30 px-2.5 py-2">
+ <div className="enters mb-2 overflow-hidden rounded-xl border border-amber/40 bg-amber/8">
+ <div className="flex items-start gap-2 border-b border-amber/25 px-2.5 py-2">
<div className="min-w-0 flex-1">
- <p className="text-xs font-medium">Mapped {draft.host}</p>
- <p className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground">
+ <p className="truncate text-xs font-medium text-ink">Mapped {draft.host}</p>
+ <p className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-ink-faint">
<span>{draft.pages} pages</span>
<span className="inline-flex items-center gap-0.5">
<Images className="size-2.5" /> {draft.screenshots}
@@ -30,59 +30,57 @@ export function SiteMapReview({
<span>{new Date(draft.generatedAt).toLocaleString()}</span>
</p>
</div>
- <Badge variant="secondary" className="h-4 shrink-0 px-1 text-[10px]">
- not active yet
- </Badge>
+ <Badge variant="warning">not active yet</Badge>
</div>
<div className="px-2.5 py-2">
- <p className="mb-1.5 text-[11px] leading-relaxed text-muted-foreground">
+ <p className="mb-2 text-[11px] leading-relaxed text-ink-dim">
This was written from pages the agent read. Once you activate it, it joins the instructions for every future
- request on <span className="font-mono">{matching}</span>. Read it first.
+ request on <span className="font-mono text-ink">{matching}</span>. Read it first.
</p>
{draft.warnings.length > 0 && (
- <div className="mb-1.5 rounded bg-amber-500/15 px-2 py-1.5">
+ <div className="mb-2 space-y-1 rounded-lg bg-amber/12 px-2 py-1.5">
{draft.warnings.map((warning) => (
- <p key={warning} className="flex gap-1.5 text-[11px] text-amber-700 dark:text-amber-400">
- <AlertTriangle className="mt-0.5 size-3 shrink-0" />
+ <p key={warning} className="flex gap-1.5 text-[11px] leading-snug text-amber">
+ <TriangleAlert className="mt-0.5 size-3 shrink-0" />
<span>{warning}</span>
</p>
))}
</div>
)}
- <div className="max-h-56 overflow-x-hidden overflow-y-auto rounded border bg-background/60">
- <pre className="px-2 py-1.5 font-mono text-[10px] leading-relaxed break-words whitespace-pre-wrap">
+ <div className="max-h-56 overflow-x-hidden overflow-y-auto rounded-lg border border-line bg-ground/70">
+ <pre className="px-2 py-1.5 font-mono text-[10px] leading-relaxed break-words whitespace-pre-wrap text-ink-dim">
{draft.markdown}
</pre>
</div>
- <p className="mt-1.5 flex items-start gap-1 text-[10px] break-all text-muted-foreground">
+ <p className="mt-1.5 flex items-start gap-1 font-mono text-[10px] break-all text-ink-faint">
<FolderOpen className="mt-0.5 size-2.5 shrink-0" />
{draft.directory}
</p>
{draft.screenshots > 0 && (
- <p className="mt-0.5 text-[10px] text-muted-foreground">
+ <p className="mt-0.5 text-[10px] text-ink-faint">
Screenshots may show pages you were signed in to. They stay on this machine.
</p>
)}
- <label className="mt-2 flex items-center gap-1.5 text-[11px] text-muted-foreground">
+ <label className="mt-2 flex items-center gap-1.5 text-[11px] text-ink-dim">
<input
type="checkbox"
checked={exactHost}
onChange={(event) => setExactHost(event.target.checked)}
- className="size-3"
+ className="size-3 accent-brand"
/>
- Only on <span className="font-mono">{draft.host}</span>, not its subdomains
+ Only on <span className="font-mono text-ink">{draft.host}</span>, not its subdomains
</label>
- <div className="mt-2 flex gap-1">
- <Button variant="ghost" size="sm" className="h-7 flex-1 text-xs" onClick={onDiscard}>
+ <div className="mt-2.5 flex gap-1.5">
+ <Button variant="ghost" size="sm" className="flex-1" onClick={onDiscard}>
<Trash2 className="size-3" /> Discard
</Button>
- <Button size="sm" className="h-7 flex-1 text-xs" onClick={() => onActivate(exactHost)}>
+ <Button size="sm" className="flex-1" onClick={() => onActivate(exactHost)}>
<Check className="size-3" /> Activate
</Button>
</div>
diff --git a/components/skills-panel.tsx b/components/skills-panel.tsx
index 4be5e75..cc616ea 100644
--- a/components/skills-panel.tsx
+++ b/components/skills-panel.tsx
@@ -26,8 +26,8 @@ export function SkillsPanel({
}: {
tabUrl: string;
connected: boolean;
- onMapSite?: () => void;
- mapping?: boolean;
+ onMapSite: () => void;
+ mapping: boolean;
}) {
const skills = useStoredSkills();
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -36,7 +36,7 @@ export function SkillsPanel({
const [error, setError] = useState<string | null>(null);
const host = hostnameOf(tabUrl);
- const mappable = !!onMapSite && connected && !mapping && /^https?:/.test(tabUrl);
+ const mappable = connected && !mapping && /^https?:/.test(tabUrl);
const alreadyMapped = skills.some(
(skill) => skill.origin === 'generated' && hostMatchesDomains(host, skill.domains),
);
@@ -78,30 +78,28 @@ export function SkillsPanel({
}
return (
- <div className="mb-2 rounded-md border bg-muted/30 p-2.5">
- <div className="mb-2 flex items-center gap-1.5">
- <BookOpen className="size-3.5 shrink-0 text-muted-foreground" />
- <span className="flex-1 text-xs font-medium">Skills</span>
- {!draft && (
- <>
- {onMapSite && (
- <Button
- variant="ghost"
- size="sm"
- className="h-6 px-2 text-xs"
- onClick={onMapSite}
- disabled={!mappable}
- title={mappable ? `Map ${host}` : 'Open an http(s) page, with no run in progress'}
- >
- <Compass className="size-3" /> {alreadyMapped ? 'Re-map' : 'Map'} {host || 'site'}
- </Button>
- )}
- <Button variant="ghost" size="sm" className="h-6 px-2 text-xs" onClick={() => fileInputRef.current?.click()}>
- <Upload className="size-3" /> Upload
- </Button>
- </>
- )}
- </div>
+ <div className="flex min-w-0 flex-col gap-3 p-3">
+ <p className="text-[11px] leading-relaxed text-ink-dim">
+ Notes about a site — where things are, how its lists load — that join the agent’s instructions only while you
+ are on that site. Let the agent write them for you, or upload your own markdown.
+ </p>
+
+ {!draft && (
+ <div className="grid grid-cols-2 gap-1.5">
+ <Button
+ size="sm"
+ onClick={onMapSite}
+ disabled={!mappable}
+ title={mappable ? `Map ${host}` : 'Open an http(s) page, with no run in progress'}
+ >
+ {mapping ? <Loader2 className="animate-spin" /> : <Compass />}
+ <span className="truncate">{alreadyMapped ? 'Re-map' : 'Map'} this site</span>
+ </Button>
+ <Button variant="outline" size="sm" onClick={() => fileInputRef.current?.click()}>
+ <Upload /> Upload notes
+ </Button>
+ </div>
+ )}
{draft ? (
<SkillForm
@@ -159,7 +157,8 @@ function SkillForm({
}) {
const isSite = draft.category === 'site-exploration';
return (
- <div className="flex flex-col gap-2">
+ <div className="panel-card flex flex-col gap-2 rounded-xl p-2.5">
+ <p className="font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase">New skill</p>
<Input
value={draft.name}
onChange={(e) => onChange({ name: e.target.value.toLowerCase() })}
@@ -175,11 +174,11 @@ function SkillForm({
className="h-8 text-xs"
/>
- <div className="flex gap-1">
+ <div className="flex gap-1.5">
<Button
variant={isSite ? 'outline' : 'default'}
size="sm"
- className="h-7 flex-1 text-xs"
+ className="flex-1"
onClick={() => onChange({ category: 'general' })}
>
General
@@ -187,10 +186,10 @@ function SkillForm({
<Button
variant={isSite ? 'default' : 'outline'}
size="sm"
- className="h-7 flex-1 text-xs"
+ className="flex-1"
onClick={() => onChange({ category: 'site-exploration' })}
>
- <Globe className="size-3" /> Site notes
+ <Globe /> Site notes
</Button>
</div>
@@ -204,25 +203,23 @@ function SkillForm({
/>
)}
- <p className="line-clamp-3 rounded bg-background/60 px-2 py-1.5 text-[11px] leading-relaxed text-muted-foreground">
+ <p className="line-clamp-3 rounded-lg border border-line bg-ground/70 px-2 py-1.5 text-[11px] leading-relaxed text-ink-faint">
{draft.body || 'This file has no instructions in it.'}
</p>
{error && (
- <p className="rounded-md bg-amber-500/10 px-2 py-1.5 text-[11px] text-amber-600 dark:text-amber-400">{error}</p>
+ <p className="rounded-lg border border-amber/40 bg-amber/10 px-2 py-1.5 text-[11px] text-amber">{error}</p>
)}
- <div className="flex gap-1">
- <Button variant="ghost" size="sm" className="h-7 flex-1 text-xs" onClick={onCancel}>
+ <div className="flex gap-1.5">
+ <Button variant="ghost" size="sm" className="flex-1" onClick={onCancel}>
Cancel
</Button>
- <Button size="sm" className="h-7 flex-1 text-xs" onClick={onSave} disabled={!connected}>
- <Check className="size-3" /> Save skill
+ <Button size="sm" className="flex-1" onClick={onSave} disabled={!connected}>
+ <Check /> Save skill
</Button>
</div>
- {!connected && (
- <p className="text-center text-[10px] text-muted-foreground">Pair the browser to save skills.</p>
- )}
+ {!connected && <p className="text-center text-[10px] text-ink-faint">Pair the browser to save skills.</p>}
</div>
);
}
@@ -230,15 +227,16 @@ function SkillForm({
function SkillList({ skills, host }: { skills: StoredSkillMeta[]; host: string }) {
if (skills.length === 0) {
return (
- <p className="px-1 py-1 text-[11px] leading-relaxed text-muted-foreground">
- Upload a markdown file of notes about a site — where things are, how its lists load — and tag it with that
- site&apos;s domain. It joins the agent&apos;s instructions whenever you are on that site, and stays out of the
- way everywhere else.
- </p>
+ <div className="dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center">
+ <BookOpen className="mx-auto size-5 text-ink-faint" />
+ <p className="mt-2 text-[11px] leading-relaxed text-ink-faint">
+ No skills yet. Mapping a site writes one for you; uploading a markdown file adds your own.
+ </p>
+ </div>
);
}
return (
- <div className="flex max-h-48 flex-col gap-1.5 overflow-y-auto">
+ <div className="flex min-w-0 flex-col gap-1.5">
{skills.map((skill) => (
<SkillRow key={skill.id} skill={skill} host={host} />
))}
@@ -251,30 +249,27 @@ function SkillRow({ skill, host }: { skill: StoredSkillMeta; host: string }) {
const generated = skill.origin === 'generated';
const Icon = generated ? Compass : BookOpen;
return (
- <div className="flex items-start gap-2 rounded-md border bg-background/60 px-2.5 py-1.5 text-xs">
- <Icon className={cn('mt-0.5 size-3.5 shrink-0', activeHere ? 'text-emerald-500' : 'text-muted-foreground')} />
+ <div
+ className={cn(
+ 'flex items-start gap-2 rounded-xl border px-2.5 py-2 text-xs',
+ activeHere ? 'border-brand/35 bg-brand/8' : 'border-line bg-ground/40',
+ )}
+ >
+ <Icon className={cn('mt-0.5 size-3.5 shrink-0', activeHere ? 'text-brand' : 'text-ink-faint')} />
<div className="min-w-0 flex-1">
<div className="flex items-center gap-1.5">
- <span className="truncate font-medium">{skill.name}</span>
- {generated && (
- <Badge variant="outline" className="h-4 shrink-0 px-1 text-[10px]">
- mapped
- </Badge>
- )}
- {activeHere && (
- <Badge variant="secondary" className="h-4 shrink-0 px-1 text-[10px]">
- on this site
- </Badge>
- )}
+ <span className="truncate font-medium text-ink">{skill.name}</span>
+ {generated && <Badge variant="outline">mapped</Badge>}
+ {activeHere && <Badge>on this site</Badge>}
</div>
{skill.domains.length > 0 && (
- <p className="mt-0.5 truncate font-mono text-[10px] text-muted-foreground">{skill.domains.join(', ')}</p>
+ <p className="mt-0.5 truncate font-mono text-[10px] text-ink-faint">{skill.domains.join(', ')}</p>
)}
{skill.description && (
- <p className="mt-0.5 line-clamp-2 text-[11px] text-muted-foreground">{skill.description}</p>
+ <p className="mt-0.5 line-clamp-2 text-[11px] text-ink-dim">{skill.description}</p>
)}
{skill.status === 'pending' && (
- <span className="mt-0.5 flex items-center gap-1 text-[11px] text-muted-foreground">
+ <span className="mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint">
<Loader2 className="size-3 animate-spin" /> Saving…
</span>
)}
@@ -288,7 +283,7 @@ function SkillRow({ skill, host }: { skill: StoredSkillMeta; host: string }) {
void browser.runtime.sendMessage({ channel: BRIDGE_CHANNEL, op: 'removeSkill', skillId: skill.id })
}
aria-label={`Remove ${skill.name}`}
- className="mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
+ className="mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink"
>
<X className="size-3" />
</button>
diff --git a/entrypoints/popup/App.tsx b/entrypoints/popup/App.tsx
index 31f5580..2882aee 100644
--- a/entrypoints/popup/App.tsx
+++ b/entrypoints/popup/App.tsx
@@ -1,41 +1,53 @@
import { useState } from 'react';
-import { AudioLines, Mic, MicOff, PanelRightOpen, Send, Sparkles } from 'lucide-react';
+import { Mic, MicOff, PanelRightOpen, Send } from 'lucide-react';
+import { AgentPicker } from '@/components/agent-picker';
+import { Wordmark } from '@/components/brand';
import { DaemonLink } from '@/components/daemon-link';
-import { Badge } from '@/components/ui/badge';
+import { StatusPill, describeStatus, type StatusBlocker } from '@/components/status-pill';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { useDaemonState } from '@/lib/bridge/use-daemon-state';
+import { openSidePanel } from '@/lib/bridge/side-panel';
import { useRun } from '@/lib/bridge/use-run';
import { useVoiceComposer } from '@/lib/bridge/use-voice-composer';
import { cn } from '@/lib/utils';
+const BLOCKED: Record<StatusBlocker, string> = {
+ unpaired: 'Pair this browser to start',
+ offline: 'The daemon isn’t answering — start browsentic-mcp',
+ agent: 'That agent cannot run — pick another below',
+};
+
export default function App() {
const daemon = useDaemonState();
const run = useRun();
const [micOn, setMicOn] = useState(false);
- const connected = daemon?.connected ?? false;
+ const paired = daemon?.paired ?? false;
- async function openSidePanel() {
+ async function revealPanel() {
const win = await browser.windows.getCurrent();
if (win.id != null) {
- await browser.sidePanel.open({ windowId: win.id });
+ await openSidePanel(win.id);
window.close();
}
}
const voice = useVoiceComposer({
- active: micOn && connected,
+ active: micOn && (daemon?.connected ?? false),
onSubmit: (text) => {
setMicOn(false);
run.send(text);
- void openSidePanel();
+ void revealPanel();
},
});
+ const status = describeStatus(daemon, { running: run.running, listening: micOn && voice.listening });
+ const ready = status.ready;
+
function submit() {
- if (!connected) return;
+ if (!ready) return;
voice.submitNow();
}
@@ -48,84 +60,86 @@ export default function App() {
setMicOn((on) => !on);
}
- const hint = !connected
- ? 'Pair this browser to start'
+ const hint = status.blocker
+ ? BLOCKED[status.blocker]
: voice.error
- ? voice.error
- : micOn && voice.listening
- ? voice.interim || 'Listening… speak, then pause'
- : run.running
- ? 'Working — open the side panel to watch'
- : voice.supported
- ? 'Tap to talk, or type below'
- : 'Type your instruction below';
+ ? voice.error
+ : micOn && voice.listening
+ ? voice.interim || 'Listening… speak, then pause'
+ : run.running
+ ? 'Working — open the side panel to watch'
+ : voice.supported
+ ? 'Tap to talk, or type below'
+ : 'Type your instruction below';
return (
- <div className="flex w-80 flex-col">
- <header className="flex items-center gap-2.5 border-b px-4 py-3">
- <div className="flex size-8 items-center justify-center rounded-lg bg-gradient-to-br from-violet-500 to-indigo-600 text-white">
- <AudioLines className="size-4" />
- </div>
- <div className="flex-1">
- <h1 className="text-sm leading-none font-semibold">Browsentic</h1>
- <p className="mt-1 text-xs text-muted-foreground">AI voice assistant</p>
- </div>
- <Badge variant="secondary">
- <Sparkles /> Beta
- </Badge>
+ <div className="flex w-[22rem] flex-col">
+ <header className="flex items-center gap-2 px-4 py-3">
+ <Wordmark className="flex-1" />
+ <StatusPill tone={status.tone}>{status.label}</StatusPill>
</header>
- <main className="flex flex-col items-center gap-4 px-4 py-6">
- <button
- type="button"
- aria-label={micOn ? 'Stop listening' : 'Start listening'}
- onClick={toggleMic}
- disabled={!connected || !voice.supported}
- className={cn(
- 'relative flex size-20 items-center justify-center rounded-full text-white shadow-lg transition-all outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50',
- (!connected || !voice.supported) && 'opacity-40',
- micOn
- ? 'bg-destructive'
- : 'bg-gradient-to-br from-violet-500 to-indigo-600 enabled:hover:scale-105',
- )}
- >
- {micOn && voice.listening && (
- <span className="absolute inset-0 animate-ping rounded-full bg-destructive/40" />
- )}
- {micOn ? <MicOff className="size-8" /> : <Mic className="size-8" />}
- </button>
-
- <p className={cn('text-center text-sm', voice.error ? 'text-amber-600 dark:text-amber-400' : 'text-muted-foreground')}>
- {hint}
- </p>
-
- <form
- className="flex w-full gap-1.5"
- onSubmit={(event) => {
- event.preventDefault();
- submit();
- }}
- >
- <Input
- value={voice.input}
- onChange={(event) => voice.setInput(event.target.value)}
- placeholder="What should I do?"
- aria-label="Instruction for Browsentic"
- className="h-8 text-xs"
- disabled={!connected}
- />
- <Button type="submit" size="sm" disabled={!connected || !voice.input.trim()}>
- <Send />
+ {paired && (
+ <main className="dot-grid flex flex-col items-center gap-4 border-y border-line px-4 py-6">
+ <button
+ type="button"
+ aria-label={micOn ? 'Stop listening' : 'Start listening'}
+ onClick={toggleMic}
+ disabled={!ready || !voice.supported}
+ className={cn(
+ 'relative flex size-20 items-center justify-center rounded-full border transition-all outline-none',
+ 'focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2 focus-visible:ring-offset-ground',
+ (!ready || !voice.supported) && 'opacity-40',
+ micOn
+ ? 'border-magenta/60 bg-magenta/15 text-magenta'
+ : 'glow-brand border-brand/50 bg-brand/10 text-brand enabled:hover:scale-105 enabled:hover:bg-brand/20',
+ )}
+ >
+ {micOn && voice.listening && (
+ <span className="absolute inset-0 animate-ping rounded-full bg-magenta/25" />
+ )}
+ {micOn ? <MicOff className="size-8" /> : <Mic className="size-8" />}
+ </button>
+
+ <p
+ className={cn(
+ 'min-h-8 text-center text-xs leading-relaxed',
+ voice.error || !status.ready ? 'text-amber' : 'text-ink-dim',
+ )}
+ >
+ {hint}
+ </p>
+
+ <form
+ className="flex w-full gap-1.5"
+ onSubmit={(event) => {
+ event.preventDefault();
+ submit();
+ }}
+ >
+ <Input
+ value={voice.input}
+ onChange={(event) => voice.setInput(event.target.value)}
+ placeholder="What should I do?"
+ aria-label="Instruction for Browsentic"
+ className="h-8 text-xs"
+ disabled={!ready}
+ />
+ <Button type="submit" size="sm" aria-label="Send" disabled={!ready || !voice.input.trim()}>
+ <Send />
+ </Button>
+ </form>
+
+ <Button variant="outline" size="sm" className="w-full" onClick={revealPanel}>
+ <PanelRightOpen /> Open the side panel
</Button>
- </form>
- </main>
+ </main>
+ )}
- <footer className="space-y-2 border-t p-3">
- <Button variant="outline" className="w-full" onClick={openSidePanel}>
- <PanelRightOpen /> Open chat side panel
- </Button>
+ <div className="space-y-4 p-4">
<DaemonLink />
- </footer>
+ <AgentPicker />
+ </div>
</div>
);
}
diff --git a/entrypoints/popup/index.html b/entrypoints/popup/index.html
index 71a6957..9eb1896 100644
--- a/entrypoints/popup/index.html
+++ b/entrypoints/popup/index.html
@@ -1,7 +1,8 @@
<!doctype html>
-<html lang="en">
+<html lang="en" class="dark" style="background-color: #1a1512">
<head>
<meta charset="UTF-8" />
+ <meta name="color-scheme" content="dark" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Browsentic</title>
</head>
diff --git a/entrypoints/popup/main.tsx b/entrypoints/popup/main.tsx
index 2156e43..c4f6514 100644
--- a/entrypoints/popup/main.tsx
+++ b/entrypoints/popup/main.tsx
@@ -3,10 +3,6 @@ import ReactDOM from 'react-dom/client';
import App from './App';
import '@/assets/globals.css';
-if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
- document.documentElement.classList.add('dark');
-}
-
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
diff --git a/entrypoints/sidepanel/App.tsx b/entrypoints/sidepanel/App.tsx
index c41edbe..d33bfb5 100644
--- a/entrypoints/sidepanel/App.tsx
+++ b/entrypoints/sidepanel/App.tsx
@@ -1,21 +1,26 @@
-import { useEffect, useRef, useState, type MouseEvent } from 'react';
-import { AudioLines, Bot, BookOpen, Circle, FileText, FileUp, History, Loader2, Mic, MicOff, Paperclip, RotateCcw, Send, Square, X } from 'lucide-react';
+import { useEffect, useRef, useState } from 'react';
+import { ArrowDown, SquarePen } from 'lucide-react';
import { browser } from 'wxt/browser';
import { invokeInActiveTab } from '@/lib/actions/client';
import { getPageInfo } from '@/lib/actions/page/get-page-info';
import { BRIDGE_CHANNEL } from '@/lib/actions/protocol';
+import { Wordmark } from '@/components/brand';
+import { Composer } from '@/components/composer';
+import { ConnectionSheet } from '@/components/connection-sheet';
+import { Greeting } from '@/components/greeting';
import { MonitorBar } from '@/components/monitor-bar';
+import { PanelNav, type PanelTab } from '@/components/panel-nav';
import { RecordingBar } from '@/components/recording-bar';
import { RecordingPanel } from '@/components/recording-panel';
import { RunTimeline } from '@/components/run-timeline';
import { SessionList } from '@/components/session-list';
import { SiteMapReview } from '@/components/site-map-review';
import { SkillsPanel } from '@/components/skills-panel';
+import { StatusPill, describeStatus } from '@/components/status-pill';
import { Button } from '@/components/ui/button';
import { ScrollArea } from '@/components/ui/scroll-area';
-import { Textarea } from '@/components/ui/textarea';
-import { putFile, removeFile, type StoredFileMeta } from '@/lib/bridge/file-store';
+import { putFile, removeFile } from '@/lib/bridge/file-store';
import { removeRecording, type StoredRecordingMeta } from '@/lib/bridge/recording-store';
import { removeSession } from '@/lib/bridge/session-store';
import { useActiveTabUrl } from '@/lib/bridge/use-active-tab-url';
@@ -24,27 +29,27 @@ import { useRun } from '@/lib/bridge/use-run';
import { useStoredFiles } from '@/lib/bridge/use-stored-files';
import { useStoredRecordings } from '@/lib/bridge/use-stored-recordings';
import { useStoredSessions } from '@/lib/bridge/use-stored-sessions';
+import { useStoredSkills } from '@/lib/bridge/use-stored-skills';
import { useVoiceComposer } from '@/lib/bridge/use-voice-composer';
import { useVoiceEnabled } from '@/lib/bridge/use-speech';
-import { cn } from '@/lib/utils';
const MAX_FILE_BYTES = 10 * 1024 * 1024;
+const PINNED_SLACK_PX = 56;
export default function App() {
const daemon = useDaemonState();
const run = useRun({ persist: true });
const [voiceEnabled, setVoiceEnabled] = useVoiceEnabled();
- const bottomRef = useRef<HTMLDivElement>(null);
- const fileInputRef = useRef<HTMLInputElement>(null);
- const composerRef = useRef<HTMLTextAreaElement>(null);
const files = useStoredFiles();
const sessions = useStoredSessions();
+ const recordings = useStoredRecordings();
+ const skills = useStoredSkills();
const tabUrl = useActiveTabUrl();
const [attachError, setAttachError] = useState<string | null>(null);
- const [skillsOpen, setSkillsOpen] = useState(false);
- const [recordingsOpen, setRecordingsOpen] = useState(false);
- const [historyOpen, setHistoryOpen] = useState(false);
- const recordings = useStoredRecordings();
+ const [tab, setTab] = useState<PanelTab>('chat');
+ const [connectionOpen, setConnectionOpen] = useState(false);
+ const viewport = useRef<HTMLDivElement>(null);
+ const [pinned, setPinned] = useState(true);
const connected = daemon?.connected ?? false;
@@ -53,50 +58,74 @@ export default function App() {
onSubmit: (text) => run.send(text),
});
+ const status = describeStatus(daemon, { running: run.running, listening: voice.listening });
+
+ useEffect(() => {
+ const element = viewport.current;
+ if (!element) return;
+ const onScroll = () => {
+ const distance = element.scrollHeight - element.scrollTop - element.clientHeight;
+ setPinned(distance < PINNED_SLACK_PX);
+ };
+ element.addEventListener('scroll', onScroll, { passive: true });
+ return () => element.removeEventListener('scroll', onScroll);
+ }, []);
+
useEffect(() => {
- bottomRef.current?.scrollIntoView({ behavior: 'smooth' });
- }, [run.items, run.running]);
+ if (!pinned || tab !== 'chat') return;
+ const element = viewport.current;
+ if (element) element.scrollTop = element.scrollHeight;
+ }, [run.items, run.running, pinned, tab]);
+
+ function goToLatest() {
+ const element = viewport.current;
+ if (element) element.scrollTo({ top: element.scrollHeight, behavior: 'smooth' });
+ setPinned(true);
+ }
+
+ function open(next: PanelTab) {
+ setConnectionOpen(false);
+ if (next === tab) return;
+ setTab(next);
+ setPinned(next === 'chat');
+ if (viewport.current) viewport.current.scrollTop = 0;
+ }
function handleSend() {
if (run.running || !connected) return;
- setHistoryOpen(false);
+ open('chat');
voice.submitNow();
}
function openSession(sessionId: string) {
- setHistoryOpen(false);
+ open('chat');
void run.restore(sessionId);
}
function replayRecording(recording: StoredRecordingMeta) {
- setRecordingsOpen(false);
- setHistoryOpen(false);
- run.send(`Replay my recording "${recording.name}" (id ${recording.id}).`);
+ open('chat');
+ run.send(`Replay my recording “${recording.name}” (id ${recording.id}).`);
}
- function focusComposer(event: MouseEvent<HTMLDivElement>) {
- if ((event.target as HTMLElement).closest('button, textarea')) return;
- composerRef.current?.focus();
+ function mapSite() {
+ open('chat');
+ run.mapSite();
}
async function attachPageContext() {
const result = await invokeInActiveTab(getPageInfo, {});
if (!result.ok) {
- voice.setInput(`${voice.input}\n[couldn't read this page: ${result.error.message}]\n`);
+ voice.setInput(`${voice.input}\n[couldn’t read this page: ${result.error.message}]\n`);
return;
}
const { document: doc, selection } = result.data;
- const snippet = selection ? `\nSelection: "${selection}"` : '';
+ const snippet = selection ? `\nSelection: “${selection}”` : '';
voice.setInput(`${voice.input ? `${voice.input}\n\n` : ''}[Page: ${doc.title} — ${doc.url}${snippet}]\n`);
}
- async function onPickFile() {
- const input = fileInputRef.current;
- const file = input?.files?.[0];
- if (input) input.value = '';
- if (!file) return;
+ async function attachFile(file: File) {
if (file.size > MAX_FILE_BYTES) {
- setAttachError(`"${file.name}" is larger than ${MAX_FILE_BYTES / 1024 / 1024} MB.`);
+ setAttachError(`“${file.name}” is larger than ${MAX_FILE_BYTES / 1024 / 1024} MB.`);
return;
}
setAttachError(null);
@@ -128,311 +157,132 @@ export default function App() {
setVoiceEnabled(false);
}
- const status = run.running ? 'Working…' : voice.listening ? 'Listening…' : connected ? 'Ready' : 'Not connected';
+ const offChatRun = run.running && tab !== 'chat';
+ const hasBanners = offChatRun || !!run.recording || run.monitors.length > 0 || !!run.draft;
return (
<div className="flex h-screen flex-col">
- <header className="flex items-center gap-2.5 border-b px-4 py-3">
- <div className="flex size-8 items-center justify-center rounded-lg bg-gradient-to-br from-violet-500 to-indigo-600 text-white">
- <AudioLines className="size-4" />
- </div>
- <div className="flex-1">
- <h1 className="text-sm leading-none font-semibold">Browsentic</h1>
- <p className="mt-1 flex items-center gap-1.5 text-xs text-muted-foreground">
- <span
- className={cn(
- 'size-1.5 shrink-0 rounded-full',
- run.running
- ? 'animate-pulse bg-violet-500'
- : voice.listening
- ? 'animate-pulse bg-rose-500'
- : connected
- ? 'bg-emerald-500'
- : 'bg-muted-foreground/40',
- )}
- />
- {status}
- </p>
- </div>
+ <header className="flex shrink-0 items-center gap-2 px-3 py-2.5">
+ <Wordmark className="flex-1" />
+ <StatusPill
+ tone={status.tone}
+ expanded={connectionOpen}
+ onClick={() => setConnectionOpen((open) => !open)}
+ >
+ {status.label}
+ </StatusPill>
<Button
- variant={historyOpen ? 'default' : 'ghost'}
- size="icon"
- aria-label={historyOpen ? 'Back to the conversation' : 'Saved conversations'}
- onClick={() => setHistoryOpen(!historyOpen)}
+ variant="ghost"
+ size="icon-sm"
+ title="New chat"
+ aria-label="Start a new conversation"
+ onClick={() => {
+ open('chat');
+ run.clear();
+ }}
>
- <History />
- </Button>
- <Button variant="ghost" size="icon" aria-label="Start a new conversation" onClick={run.clear}>
- <RotateCcw />
+ <SquarePen className="size-3.5" />
</Button>
</header>
- <ScrollArea className="min-h-0 flex-1">
- {historyOpen ? (
- <SessionList
- sessions={sessions}
- currentId={run.sessionId}
- busy={run.running}
- onOpen={openSession}
- onRemove={(id) => void removeSession(id)}
- />
- ) : run.items.length === 0 ? (
- <Greeting connected={connected} voiceOn={voiceEnabled && voice.supported} />
- ) : (
- <RunTimeline items={run.items} onDecide={run.decide} />
- )}
- <div ref={bottomRef} className="h-4" />
- </ScrollArea>
+ {connectionOpen && <ConnectionSheet onClose={() => setConnectionOpen(false)} />}
- <footer className="border-t p-3">
- {attachError && (
- <p className="mb-2 rounded-md bg-amber-500/10 px-2.5 py-1.5 text-xs text-amber-600 dark:text-amber-400">
- {attachError}
- </p>
- )}
- {run.recording && <RecordingBar state={run.recording} onStop={run.stopRecording} />}
- {run.monitors.map((monitor) => (
- <MonitorBar key={monitor.monitorId} state={monitor} onStop={() => run.stopMonitor(monitor.monitorId)} />
- ))}
- {run.draft && (
- <SiteMapReview draft={run.draft} onActivate={run.activateMap} onDiscard={run.discardMap} />
- )}
- {recordingsOpen && (
- <RecordingPanel
- tabUrl={tabUrl}
- recordings={recordings}
- recording={run.recording}
- busy={run.running}
- onStart={run.startRecording}
- onStop={run.stopRecording}
- onReplay={replayRecording}
- onRemove={(id) => void removeRecording(id)}
- />
- )}
- {skillsOpen && (
- <SkillsPanel
- tabUrl={tabUrl}
- connected={connected}
- onMapSite={() => {
- setSkillsOpen(false);
- run.mapSite();
- }}
- mapping={run.running}
- />
- )}
- <FilesList files={files} onRemove={(id) => void removeFile(id)} />
- <VoiceStatus voice={voice} voiceEnabled={voiceEnabled} connected={connected} />
+ <PanelNav
+ tab={tab}
+ counts={{ history: sessions.length, skills: skills.length, recordings: recordings.length }}
+ onSelect={open}
+ />
- <div
- onClick={focusComposer}
- className={cn(
- 'flex flex-col rounded-xl border border-input shadow-xs transition-[color,box-shadow] dark:bg-input/30',
- 'has-[textarea:focus]:border-ring has-[textarea:focus]:ring-[3px] has-[textarea:focus]:ring-ring/50',
- connected && 'cursor-text',
+ {hasBanners && (
+ <div className="max-h-[45%] shrink-0 overflow-y-auto px-3 pt-2">
+ {offChatRun && (
+ <button
+ type="button"
+ onClick={() => open('chat')}
+ className="enters mb-2 flex w-full items-center gap-2 rounded-xl border border-brand/35 bg-brand/8 px-2.5 py-2 text-left transition-colors hover:bg-brand/12"
+ >
+ <span className="glow-dot size-1.5 shrink-0 animate-pulse rounded-full bg-brand text-brand" />
+ <span className="flex-1 text-xs text-ink">A run is in progress</span>
+ <span className="shrink-0 font-mono text-[10px] tracking-[0.12em] text-brand uppercase">Watch</span>
+ </button>
)}
- >
- <Textarea
- ref={composerRef}
- value={voice.input}
- onChange={(e) => voice.setInput(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === 'Enter' && !e.shiftKey) {
- e.preventDefault();
- handleSend();
- }
- }}
- placeholder={connected ? 'Speak, or type what to do on this page…' : 'Pair the browser to get started'}
- disabled={!connected}
- rows={2}
- className="max-h-48 min-h-16 resize-none rounded-none border-0 bg-transparent px-3 pt-2.5 pb-0 text-sm shadow-none focus-visible:ring-0 dark:bg-transparent"
- />
+ {run.recording && <RecordingBar state={run.recording} onStop={run.stopRecording} />}
+ {run.monitors.map((monitor) => (
+ <MonitorBar key={monitor.monitorId} state={monitor} onStop={() => run.stopMonitor(monitor.monitorId)} />
+ ))}
+ {run.draft && <SiteMapReview draft={run.draft} onActivate={run.activateMap} onDiscard={run.discardMap} />}
+ </div>
+ )}
- <div className="flex items-center gap-0.5 px-1.5 pb-1.5">
- <Button
- variant="ghost"
- size="icon"
- className="size-8"
- aria-label="Attach page context"
- onClick={attachPageContext}
- disabled={!connected}
- >
- <Paperclip />
- </Button>
- <Button
- variant="ghost"
- size="icon"
- className="size-8"
- aria-label="Attach a file"
- onClick={() => fileInputRef.current?.click()}
- disabled={!connected}
- >
- <FileUp />
- </Button>
- <Button
- variant={skillsOpen ? 'default' : 'ghost'}
- size="icon"
- className="size-8"
- aria-label={skillsOpen ? 'Hide skills' : 'Show skills'}
- onClick={() => setSkillsOpen(!skillsOpen)}
- >
- <BookOpen />
- </Button>
- <Button
- variant={recordingsOpen ? 'default' : 'ghost'}
- size="icon"
- className="size-8"
- aria-label={recordingsOpen ? 'Hide recordings' : 'Record this session'}
- onClick={() => setRecordingsOpen(!recordingsOpen)}
- >
- <Circle
- className={cn(
- run.recording && 'animate-pulse fill-red-500 text-red-500',
- !run.recording && !recordingsOpen && 'text-red-500',
- )}
+ <div className="relative min-h-0 flex-1">
+ <ScrollArea viewportRef={viewport} className="h-full">
+ {tab === 'chat' ? (
+ run.items.length === 0 ? (
+ <Greeting
+ blocker={status.blocker}
+ voiceOn={voiceEnabled && voice.supported}
+ onGo={open}
+ onFix={() => setConnectionOpen(true)}
+ onUse={voice.setInput}
/>
- </Button>
- <Button
- variant={voiceEnabled && !voice.error ? 'default' : 'ghost'}
- size="icon"
- aria-label={voiceEnabled ? 'Turn voice off' : 'Turn voice on'}
- title={voice.supported ? undefined : 'Voice input is not available in this browser'}
- onClick={toggleVoice}
- disabled={!voice.supported}
- className={cn('size-8', voiceEnabled && voice.listening && 'relative')}
- >
- {voiceEnabled && voice.listening && (
- <span className="absolute inset-0 animate-ping rounded-md bg-primary/30" />
- )}
- {voiceEnabled && !voice.error ? <Mic /> : <MicOff />}
- </Button>
- {run.running ? (
- <Button
- size="icon"
- variant="destructive"
- className="ml-auto size-8"
- aria-label="Stop the agent"
- onClick={run.cancel}
- >
- <Square />
- </Button>
) : (
- <Button
- size="icon"
- className="ml-auto size-8"
- aria-label="Send message"
- onClick={handleSend}
- disabled={!voice.input.trim() || !connected}
- >
- <Send />
- </Button>
- )}
- </div>
- </div>
- <input ref={fileInputRef} type="file" className="hidden" onChange={onPickFile} />
- <p className="mt-2 text-center text-[10px] text-muted-foreground">
- {voiceEnabled && voice.supported
- ? 'Speak and pause to send · Enter to send now · Shift+Enter for a new line'
- : 'Enter to send · Shift+Enter for a new line'}
- </p>
- </footer>
- </div>
- );
-}
-
-function VoiceStatus({
- voice,
- voiceEnabled,
- connected,
-}: {
- voice: ReturnType<typeof useVoiceComposer>;
- voiceEnabled: boolean;
- connected: boolean;
-}) {
- if (voiceEnabled && voice.error) {
- return (
- <p className="mb-2 rounded-md bg-amber-500/10 px-2.5 py-1.5 text-xs text-amber-600 dark:text-amber-400">
- {voice.error}
- </p>
- );
- }
+ <RunTimeline items={run.items} running={run.running} onDecide={run.decide} />
+ )
+ ) : tab === 'history' ? (
+ <SessionList
+ sessions={sessions}
+ currentId={run.sessionId}
+ busy={run.running}
+ onOpen={openSession}
+ onRemove={(id) => void removeSession(id)}
+ />
+ ) : tab === 'skills' ? (
+ <SkillsPanel tabUrl={tabUrl} connected={connected} onMapSite={mapSite} mapping={run.running} />
+ ) : (
+ <RecordingPanel
+ tabUrl={tabUrl}
+ recordings={recordings}
+ recording={run.recording}
+ busy={run.running}
+ onStart={run.startRecording}
+ onStop={run.stopRecording}
+ onReplay={replayRecording}
+ onRemove={(id) => void removeRecording(id)}
+ />
+ )}
+ <div className="h-3" />
+ </ScrollArea>
- if (voice.pendingSend) {
- return (
- <div className="mb-2 flex items-center gap-2 rounded-md bg-primary/10 px-2.5 py-1.5 text-xs text-primary">
- <span className="relative flex-1 overflow-hidden rounded-full bg-primary/20">
- <span
- className="block h-1 rounded-full bg-primary"
- style={{ animation: `browsentic-countdown ${voice.autoSendMs}ms linear forwards` }}
- />
- </span>
- <span className="shrink-0">Sending…</span>
- <button
- type="button"
- onClick={voice.cancelPending}
- className="flex shrink-0 items-center gap-0.5 rounded px-1 py-0.5 hover:bg-primary/15"
- aria-label="Cancel sending"
- >
- <X className="size-3" /> Edit
- </button>
+ {tab === 'chat' && !pinned && run.items.length > 0 && (
+ <Button
+ size="sm"
+ variant="outline"
+ className="enters absolute bottom-3 left-1/2 -translate-x-1/2 backdrop-blur"
+ onClick={goToLatest}
+ >
+ <ArrowDown className="size-3" /> Latest
+ </Button>
+ )}
</div>
- );
- }
-
- if (voiceEnabled && voice.listening) {
- return (
- <p className="mb-2 flex items-center gap-1.5 px-1 text-xs text-muted-foreground">
- <span className="inline-flex size-1.5 shrink-0 animate-pulse rounded-full bg-rose-500" />
- {voice.interim ? <span className="truncate italic">{voice.interim}</span> : <span>Listening…</span>}
- </p>
- );
- }
-
- if (voiceEnabled && connected && !voice.supported) {
- return (
- <p className="mb-2 px-1 text-xs text-muted-foreground">Voice input isn&apos;t available in this browser.</p>
- );
- }
-
- return null;
-}
-function FilesList({ files, onRemove }: { files: StoredFileMeta[]; onRemove: (id: string) => void }) {
- if (files.length === 0) return null;
- return (
- <div className="mb-2 flex max-h-40 flex-col gap-1.5 overflow-y-auto">
- {files.map((file) => (
- <div
- key={file.id}
- className="flex items-start gap-2 rounded-md border bg-muted/40 px-2.5 py-1.5 text-xs"
- >
- <FileText className="mt-0.5 size-3.5 shrink-0 text-muted-foreground" />
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-1.5">
- <span className="truncate font-medium">{file.name}</span>
- <span className="shrink-0 text-[10px] text-muted-foreground">{formatBytes(file.size)}</span>
- </div>
- {file.status === 'pending' && (
- <span className="mt-0.5 flex items-center gap-1 text-[11px] text-muted-foreground">
- <Loader2 className="size-3 animate-spin" /> Analyzing…
- </span>
- )}
- {file.status === 'ready' && file.summary && (
- <p className="mt-0.5 line-clamp-2 text-[11px] text-muted-foreground">{file.summary}</p>
- )}
- {file.status === 'error' && (
- <span className="mt-0.5 block text-[11px] text-destructive">{file.error ?? 'Analysis failed'}</span>
- )}
- </div>
- <button
- type="button"
- onClick={() => onRemove(file.id)}
- aria-label={`Remove ${file.name}`}
- className="mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
- >
- <X className="size-3" />
- </button>
- </div>
- ))}
+ {tab === 'chat' && (
+ <footer className="shrink-0 border-t border-line p-3">
+ <Composer
+ voice={voice}
+ voiceEnabled={voiceEnabled}
+ connected={connected}
+ running={run.running}
+ files={files}
+ attachError={attachError}
+ onSend={handleSend}
+ onStop={run.cancel}
+ onToggleVoice={toggleVoice}
+ onAttachPage={() => void attachPageContext()}
+ onAttachFile={(file) => void attachFile(file)}
+ onRemoveFile={(id) => void removeFile(id)}
+ />
+ </footer>
+ )}
</div>
);
}
@@ -448,35 +298,3 @@ function readAsBase64(file: File): Promise<string> {
reader.readAsDataURL(file);
});
}
-
-function formatBytes(n: number): string {
- if (n < 1024) return `${n} B`;
- if (n < 1024 * 1024) return `${Math.round(n / 1024)} KB`;
- return `${(n / 1024 / 1024).toFixed(1)} MB`;
-}
-
-function Greeting({ connected, voiceOn }: { connected: boolean; voiceOn: boolean }) {
- return (
- <div className="flex flex-col gap-4 p-4">
- <div className="flex gap-2">
- <div className="flex size-7 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-violet-500 to-indigo-600 text-white">
- <Bot className="size-4" />
- </div>
- <div className="min-w-0 max-w-[85%] rounded-2xl rounded-tl-sm bg-muted px-3 py-2 text-sm wrap-anywhere">
- {connected ? (
- <>
- Hi, I&apos;m Browsentic.{' '}
- {voiceOn ? 'Just talk' : 'Tell me'} what to do on this page — read it, fill something in, click through a
- flow — and you&apos;ll see every action I take as I take it.
- </>
- ) : (
- <>
- This browser isn&apos;t paired yet. Run <code className="font-mono text-xs">browsentic-mcp pair</code> and
- enter the code in the Browsentic popup.
- </>
- )}
- </div>
- </div>
- </div>
- );
-}
diff --git a/entrypoints/sidepanel/index.html b/entrypoints/sidepanel/index.html
index 980c295..67d9200 100644
--- a/entrypoints/sidepanel/index.html
+++ b/entrypoints/sidepanel/index.html
@@ -1,7 +1,8 @@
<!doctype html>
-<html lang="en">
+<html lang="en" class="dark" style="background-color: #1a1512">
<head>
<meta charset="UTF-8" />
+ <meta name="color-scheme" content="dark" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Browsentic Chat</title>
</head>
diff --git a/entrypoints/sidepanel/main.tsx b/entrypoints/sidepanel/main.tsx
index 2156e43..c4f6514 100644
--- a/entrypoints/sidepanel/main.tsx
+++ b/entrypoints/sidepanel/main.tsx
@@ -3,10 +3,6 @@ import ReactDOM from 'react-dom/client';
import App from './App';
import '@/assets/globals.css';
-if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
- document.documentElement.classList.add('dark');
-}
-
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />