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(extension): a Profile section on the settings page — the fields a form asks for, details of your own and rules for every task — saved in one go

Shahriar573568ba43f4
diff --git a/src/extension/components/guardrail-settings.tsx b/src/extension/components/guardrail-settings.tsx
index 6cbe3d8..c614de9 100644
--- a/src/extension/components/guardrail-settings.tsx
+++ b/src/extension/components/guardrail-settings.tsx
@@ -1,37 +1,16 @@
-import { useCallback, useEffect, useState, type ReactNode } from 'react';
-import { browser } from 'wxt/browser';
+import type { ReactNode } from 'react';
import { GuardrailPolicy } from '@/extension/components/guardrail-policy';
-import { BRIDGE_CHANNEL, type ActionResult } from '@/lib/actions/protocol';
-import { useDaemonState } from '@/lib/bridge/use-daemon-state';
+import { usePreferences } from '@/lib/bridge/use-preferences';
import type { GuardrailValue } from '@/lib/settings/guardrails';
-import type { PreferenceChange, Preferences } from '@/lib/settings/preferences';
export function GuardrailSettings() {
- const daemon = useDaemonState();
- const connected = daemon?.connected ?? false;
- const settings = daemon?.preferences?.guardrails;
- const [busy, setBusy] = useState<string | null>(null);
- const [error, setError] = useState<string | null>(null);
+ const { paired, connected, preferences, busy, error, reload, change } = usePreferences();
+ const settings = preferences?.guardrails;
- const ask = useCallback(async (request: { op: 'preferences' } | { op: 'setPreference'; change: PreferenceChange }, marker: string) => {
- setBusy(marker);
- setError(null);
- const result = (await browser.runtime
- .sendMessage({ channel: BRIDGE_CHANNEL, ...request })
- .catch(() => null)) as ActionResult<Preferences> | null;
- setBusy(null);
- if (!result?.ok) setError(result?.error.message ?? 'The daemon did not answer.');
- }, []);
+ const write = (setting: string, value: GuardrailValue) => void change({ kind: 'guardrail', setting, value }, setting);
- useEffect(() => {
- if (connected && !settings) void ask({ op: 'preferences' }, 'load');
- }, [connected, settings, ask]);
-
- const write = (setting: string, value: GuardrailValue) =>
- void ask({ op: 'setPreference', change: { kind: 'guardrail', setting, value } }, setting);
-
- if (!daemon?.paired) {
+ if (!paired) {
return <Empty>Pair this browser to see what the agent is allowed to do. The Connection section has the steps.</Empty>;
}
if (!connected) {
@@ -41,17 +20,9 @@ export function GuardrailSettings() {
return <Empty>{error ?? 'Reading the policy…'}</Empty>;
}
- return (
- <GuardrailPolicy
- settings={settings}
- busy={busy}
- error={error}
- onWrite={write}
- onReload={() => void ask({ op: 'preferences' }, 'load')}
- />
- );
+ return <GuardrailPolicy settings={settings} busy={busy} error={error} onWrite={write} onReload={() => void reload()} />;
}
-function Empty({ children }: { children: ReactNode }) {
+export function Empty({ children }: { children: ReactNode }) {
return <p className="panel-card rounded-xl px-6 py-10 text-center text-sm leading-relaxed text-ink-faint">{children}</p>;
}
diff --git a/src/extension/components/profile-settings.tsx b/src/extension/components/profile-settings.tsx
new file mode 100644
index 0000000..df26512
--- /dev/null
+++ b/src/extension/components/profile-settings.tsx
@@ -0,0 +1,227 @@
+import { useState, type ReactNode } from 'react';
+import { Check, Loader2, Plus, X } from 'lucide-react';
+
+import { Empty } from '@/extension/components/guardrail-settings';
+import { Button } from '@/extension/components/ui/button';
+import { Input } from '@/extension/components/ui/input';
+import { Textarea } from '@/extension/components/ui/textarea';
+import { usePreferences } from '@/lib/bridge/use-preferences';
+import {
+ normalizeProfile,
+ PROFILE_FIELDS,
+ PROFILE_LIMITS,
+ sameProfile,
+ type ProfileDetail,
+ type ProfileFieldId,
+ type UserProfile,
+} from '@/lib/settings/profile';
+import { cn } from '@/lib/utils';
+
+const GROUPS: { title: string; fields: ProfileFieldId[] }[] = [
+ { title: 'You', fields: ['givenName', 'familyName', 'email', 'phone'] },
+ { title: 'Address', fields: ['street', 'city', 'region', 'postalCode', 'country'] },
+ { title: 'Work', fields: ['company', 'jobTitle'] },
+];
+
+const FIELD = Object.fromEntries(PROFILE_FIELDS.map((field) => [field.id, field])) as Record<
+ ProfileFieldId,
+ (typeof PROFILE_FIELDS)[number]
+>;
+
+const MARKER = 'profile';
+
+export function ProfileSettings() {
+ const { paired, connected, preferences, busy, error, change } = usePreferences();
+ const [draft, setDraft] = useState<UserProfile | null>(null);
+ const [saved, setSaved] = useState(false);
+ const stored = preferences?.profile;
+
+ if (!paired) {
+ return <Empty>Pair this browser to give the agent your details. The Connection section has the steps.</Empty>;
+ }
+ if (!connected) {
+ return <Empty>The daemon is offline. Your profile lives in its profile.json, so it loads when it reconnects.</Empty>;
+ }
+ if (!stored) {
+ return <Empty>{error ?? 'Reading your profile…'}</Empty>;
+ }
+
+ const profile = draft ?? stored;
+ const dirty = draft !== null && !sameProfile(draft, stored);
+ const unlabelled = profile.details.some((detail) => detail.value.trim() && !detail.label.trim());
+ const saving = busy === MARKER;
+
+ const edit = (next: UserProfile) => {
+ setSaved(false);
+ setDraft(next);
+ };
+ const setField = (id: ProfileFieldId, value: string) => edit({ ...profile, fields: { ...profile.fields, [id]: value } });
+ const setDetail = (index: number, next: ProfileDetail) =>
+ edit({ ...profile, details: profile.details.map((detail, at) => (at === index ? next : detail)) });
+
+ const save = async () => {
+ if (!draft) return;
+ if (await change({ kind: 'profile', profile: normalizeProfile(draft) }, MARKER)) {
+ setDraft(null);
+ setSaved(true);
+ }
+ };
+
+ return (
+ <form
+ className="space-y-8"
+ onSubmit={(event) => {
+ event.preventDefault();
+ void save();
+ }}
+ >
+ {GROUPS.map(({ title, fields }) => (
+ <Group key={title} title={title}>
+ <div className="grid gap-3 p-4 sm:grid-cols-2">
+ {fields.map((id) => {
+ const { label, autocomplete } = FIELD[id];
+ const common = {
+ value: profile.fields[id] ?? '',
+ autoComplete: autocomplete,
+ maxLength: PROFILE_LIMITS.value,
+ disabled: saving,
+ };
+ return (
+ <Field key={id} label={label} wide={id === 'street'}>
+ {id === 'street' ? (
+ <Textarea rows={2} {...common} onChange={(event) => setField(id, event.target.value)} />
+ ) : (
+ <Input
+ type={id === 'email' ? 'email' : id === 'phone' ? 'tel' : 'text'}
+ {...common}
+ onChange={(event) => setField(id, event.target.value)}
+ />
+ )}
+ </Field>
+ );
+ })}
+ </div>
+ </Group>
+ ))}
+
+ <Group title="More details" note="Anything else a site might ask for — a loyalty number, a date of birth, a delivery note. Give each one a label the agent can match to a form field.">
+ <div className="space-y-2.5 p-4">
+ {profile.details.map((detail, index) => (
+ <div key={index} className="flex items-center gap-2">
+ <Input
+ aria-label="Label"
+ placeholder="Label"
+ className="w-36 shrink-0 sm:w-44"
+ value={detail.label}
+ maxLength={PROFILE_LIMITS.label}
+ disabled={saving}
+ aria-invalid={Boolean(detail.value.trim() && !detail.label.trim())}
+ onChange={(event) => setDetail(index, { ...detail, label: event.target.value })}
+ />
+ <Input
+ aria-label={detail.label.trim() || 'Value'}
+ placeholder="Value"
+ value={detail.value}
+ maxLength={PROFILE_LIMITS.value}
+ disabled={saving}
+ onChange={(event) => setDetail(index, { ...detail, value: event.target.value })}
+ />
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ aria-label={`Remove ${detail.label.trim() || 'this detail'}`}
+ disabled={saving}
+ onClick={() => edit({ ...profile, details: profile.details.filter((_, at) => at !== index) })}
+ >
+ <X />
+ </Button>
+ </div>
+ ))}
+ {profile.details.length < PROFILE_LIMITS.details && (
+ <Button
+ type="button"
+ variant="subtle"
+ size="sm"
+ disabled={saving}
+ onClick={() => edit({ ...profile, details: [...profile.details, { label: '', value: '' }] })}
+ >
+ <Plus /> Add a detail
+ </Button>
+ )}
+ </div>
+ </Group>
+
+ <Group
+ title="Instructions"
+ note="Rules the agent keeps on every task, as firmly as its own. They cannot switch off Browsentic’s guardrails or skip an approval."
+ >
+ <div className="space-y-1.5 p-4">
+ <Textarea
+ aria-label="Instructions"
+ className="min-h-28"
+ placeholder={'Reply in British English.\nAlways choose the cheapest shipping.\nNever sign up for newsletters or accept optional cookies.'}
+ value={profile.instructions}
+ maxLength={PROFILE_LIMITS.instructions}
+ disabled={saving}
+ onChange={(event) => edit({ ...profile, instructions: event.target.value })}
+ />
+ <p className="text-right font-mono text-[10px] tracking-[0.1em] text-ink-faint">
+ {profile.instructions.length} / {PROFILE_LIMITS.instructions}
+ </p>
+ </div>
+ </Group>
+
+ <p className="text-xs leading-relaxed text-ink-faint">
+ Everything filled in here goes to the agent’s model with every side-panel run and scheduled task, so it uses these exact
+ values instead of guessing. It is kept on this computer, in <span className="font-mono text-ink-dim">profile.json</span>{' '}
+ beside the daemon’s config. Leave out passwords and card numbers — Browsentic seals those in the browser and never hands
+ them to a model.
+ </p>
+
+ <div className="sticky bottom-4 z-10 flex flex-wrap items-center gap-3 rounded-xl border border-line bg-ground-2/90 px-4 py-3 backdrop-blur">
+ <p className={cn('min-w-0 flex-1 text-xs leading-relaxed', error ? 'text-destructive' : 'text-ink-faint')}>
+ {error ??
+ (unlabelled ? (
+ 'Give each detail a label before saving.'
+ ) : dirty ? (
+ 'Unsaved changes.'
+ ) : saved ? (
+ <span className="inline-flex items-center gap-1.5 text-brand">
+ <Check className="size-3.5" /> Saved. The next run uses it.
+ </span>
+ ) : (
+ 'Up to date.'
+ ))}
+ </p>
+ <Button type="button" variant="ghost" size="sm" disabled={!draft || saving} onClick={() => setDraft(null)}>
+ Discard
+ </Button>
+ <Button type="submit" size="sm" disabled={!dirty || unlabelled || saving}>
+ {saving && <Loader2 className="animate-spin" />} Save
+ </Button>
+ </div>
+ </form>
+ );
+}
+
+function Group({ title, note, children }: { title: string; note?: string; children: ReactNode }) {
+ return (
+ <section className="space-y-2.5">
+ <header className="space-y-1">
+ <h3 className="font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase">{title}</h3>
+ {note && <p className="text-xs leading-relaxed text-ink-faint">{note}</p>}
+ </header>
+ <div className="panel-card overflow-hidden rounded-xl">{children}</div>
+ </section>
+ );
+}
+
+function Field({ label, wide, children }: { label: string; wide?: boolean; children: ReactNode }) {
+ return (
+ <label className={cn('block space-y-1.5', wide && 'sm:col-span-2')}>
+ <span className="text-xs font-medium text-ink-dim">{label}</span>
+ {children}
+ </label>
+ );
+}
diff --git a/src/extension/entrypoints/options/App.tsx b/src/extension/entrypoints/options/App.tsx
index a04d39a..99f3721 100644
--- a/src/extension/entrypoints/options/App.tsx
+++ b/src/extension/entrypoints/options/App.tsx
@@ -1,18 +1,19 @@
import { useEffect, useState, type ReactNode } from 'react';
-import { Link2, Palette, ShieldCheck, Sparkles, type LucideIcon } from 'lucide-react';
+import { Link2, Palette, ShieldCheck, Sparkles, UserRound, type LucideIcon } from 'lucide-react';
import { browser } from 'wxt/browser';
import { AgentPicker } from '@/extension/components/agent-picker';
import { Wordmark } from '@/extension/components/brand';
import { DaemonLink } from '@/extension/components/daemon-link';
import { GuardrailSettings } from '@/extension/components/guardrail-settings';
+import { ProfileSettings } from '@/extension/components/profile-settings';
import { StatusPill, describeStatus } from '@/extension/components/status-pill';
import { ThemePicker } from '@/extension/components/theme-picker';
import { useDaemonState } from '@/lib/bridge/use-daemon-state';
import { useTheme } from '@/lib/bridge/use-theme';
import { cn } from '@/lib/utils';
-type SectionId = 'appearance' | 'guardrails' | 'agent' | 'connection';
+type SectionId = 'appearance' | 'profile' | 'guardrails' | 'agent' | 'connection';
const SECTIONS: { id: SectionId; label: string; icon: LucideIcon; blurb: string }[] = [
{
@@ -21,6 +22,12 @@ const SECTIONS: { id: SectionId; label: string; icon: LucideIcon; blurb: string
icon: Palette,
blurb: 'How the side panel, the popup and this page look. Every paired browser follows the same choice, and the desktop app can change it too.',
},
+ {
+ id: 'profile',
+ label: 'Profile',
+ icon: UserRound,
+ blurb: 'What the agent may use about you — for forms, sign-ups and checkouts — and rules it keeps to on every task. Anything filled in here reaches the model with each run, so it uses these exact values instead of guessing.',
+ },
{
id: 'guardrails',
label: 'Guardrails',
@@ -117,6 +124,8 @@ export default function App() {
<div key={section} className="enters mt-8">
{section === 'appearance' ? (
<Appearance />
+ ) : section === 'profile' ? (
+ <ProfileSettings />
) : section === 'guardrails' ? (
<GuardrailSettings />
) : section === 'agent' ? (
diff --git a/src/lib/bridge/use-preferences.ts b/src/lib/bridge/use-preferences.ts
new file mode 100644
index 0000000..3484a35
--- /dev/null
+++ b/src/lib/bridge/use-preferences.ts
@@ -0,0 +1,40 @@
+import { useCallback, useEffect, useState } from 'react';
+import { browser } from 'wxt/browser';
+
+import { BRIDGE_CHANNEL, type ActionResult } from '@/lib/actions/protocol';
+import type { PreferenceChange, Preferences } from '@/lib/settings/preferences';
+import { useDaemonState } from './use-daemon-state';
+
+type PreferenceRequest = { op: 'preferences' } | { op: 'setPreference'; change: PreferenceChange };
+
+/**
+ * The settings the daemon last pushed to this browser, and a way to change them, for a settings
+ * screen. `busy` names what is in flight — `load`, or the marker a change was sent with.
+ */
+export function usePreferences() {
+ const daemon = useDaemonState();
+ const connected = daemon?.connected ?? false;
+ const preferences = daemon?.preferences;
+ const [busy, setBusy] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+
+ const ask = useCallback(async (request: PreferenceRequest, marker: string) => {
+ setBusy(marker);
+ setError(null);
+ const result = (await browser.runtime
+ .sendMessage({ channel: BRIDGE_CHANNEL, ...request })
+ .catch(() => null)) as ActionResult<Preferences> | null;
+ setBusy(null);
+ if (!result?.ok) setError(result?.error.message ?? 'The daemon did not answer.');
+ return result?.ok === true;
+ }, []);
+
+ useEffect(() => {
+ if (connected && !preferences) void ask({ op: 'preferences' }, 'load');
+ }, [connected, preferences, ask]);
+
+ const reload = useCallback(() => ask({ op: 'preferences' }, 'load'), [ask]);
+ const change = useCallback((next: PreferenceChange, marker: string) => ask({ op: 'setPreference', change: next }, marker), [ask]);
+
+ return { paired: daemon?.paired ?? false, connected, preferences, busy, error, reload, change };
+}