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.

refactor(settings): each profile field names how it is typed in, the profile is normalized and checked for secrets as data, and the comments that restated the code are gone

Shahriar132a8b96505f
diff --git a/src/daemon/agent/prompt.ts b/src/daemon/agent/prompt.ts
index 8f99ae8..abde985 100644
--- a/src/daemon/agent/prompt.ts
+++ b/src/daemon/agent/prompt.ts
@@ -106,9 +106,7 @@ export interface BuiltPrompt {
}
export interface PromptExtras {
- /** The user's standing instructions from the settings page. */
instructions?: string;
- /** The user's saved details, already rendered by `profileBlock`. */
profile?: string;
fetched?: string;
/** The element the user pointed at with A-Eye, already rendered as a block. */
diff --git a/src/daemon/agent/service.test.ts b/src/daemon/agent/service.test.ts
index 4343be2..d31569c 100644
--- a/src/daemon/agent/service.test.ts
+++ b/src/daemon/agent/service.test.ts
@@ -139,8 +139,6 @@ process.stdin.on('data', (chunk) => (heard += chunk)).on('end', () => {
});
});
-// The profile is read fresh for every run, so what the settings page saved reaches the next one — and a
-// follow-up in a conversation whose agent keeps its first prompt hears the change in its message.
describe("the user's profile in a run", () => {
test('reaches the system prompt, and a later edit reaches a resumed turn', async () => {
const dir = `${dirname(configPath)}/profile-turns`;
diff --git a/src/daemon/preferences.ts b/src/daemon/preferences.ts
index b690f47..450335c 100644
--- a/src/daemon/preferences.ts
+++ b/src/daemon/preferences.ts
@@ -69,15 +69,13 @@ function saveProfile(profile: UserProfile): ActionResult<Preferences> {
return success(preferencesNow());
}
-/** The label of the first entry that holds a secret. A phone number is never read as a card, however its digits add up. */
function secretIn(profile: UserProfile): string | undefined {
- const field = PROFILE_FIELDS.find(({ id }) =>
- findSecrets(profile.fields[id] ?? '').some((span) => id !== 'phone' || span.kind !== 'card'),
- );
- if (field) return field.label;
- const detail = profile.details.find((each) => findSecrets(`${each.label}: ${each.value}`).length);
- if (detail) return detail.label;
- return findSecrets(profile.instructions).length ? 'Instructions' : undefined;
+ const entries = [
+ ...PROFILE_FIELDS.map(({ id, label }) => ({ label, text: profile.fields[id] ?? '', phone: id === 'phone' })),
+ ...profile.details.map(({ label, value }) => ({ label, text: `${label}: ${value}`, phone: false })),
+ { label: 'Instructions', text: profile.instructions, phone: false },
+ ];
+ return entries.find(({ text, phone }) => findSecrets(text).some((span) => !(phone && span.kind === 'card')))?.label;
}
/** What config.json and profile.json hold right now, and the part of it a change of agent or model moves. */
diff --git a/src/daemon/profile.ts b/src/daemon/profile.ts
index 9c8a5b8..5ef6fb3 100644
--- a/src/daemon/profile.ts
+++ b/src/daemon/profile.ts
@@ -1,8 +1,4 @@
-/**
- * The user's profile, kept in its own file beside config.json so the config stays safe to paste
- * into a bug report. Read fresh on every run, like the config, and written only by the settings
- * page — an empty profile removes the file, so it only ever names what someone filled in.
- */
+/** Kept out of config.json so the config stays safe to paste into a bug report. */
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
diff --git a/src/extension/components/profile-settings.tsx b/src/extension/components/profile-settings.tsx
index df26512..e3d23f7 100644
--- a/src/extension/components/profile-settings.tsx
+++ b/src/extension/components/profile-settings.tsx
@@ -12,6 +12,7 @@ import {
PROFILE_LIMITS,
sameProfile,
type ProfileDetail,
+ type ProfileField,
type ProfileFieldId,
type UserProfile,
} from '@/lib/settings/profile';
@@ -23,10 +24,7 @@ const GROUPS: { title: string; fields: ProfileFieldId[] }[] = [
{ title: 'Work', fields: ['company', 'jobTitle'] },
];
-const FIELD = Object.fromEntries(PROFILE_FIELDS.map((field) => [field.id, field])) as Record<
- ProfileFieldId,
- (typeof PROFILE_FIELDS)[number]
->;
+const FIELD = Object.fromEntries(PROFILE_FIELDS.map((field) => [field.id, field])) as Record<ProfileFieldId, ProfileField>;
const MARKER = 'profile';
@@ -79,7 +77,7 @@ export function ProfileSettings() {
<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 { label, autocomplete, type = 'text', multiline } = FIELD[id];
const common = {
value: profile.fields[id] ?? '',
autoComplete: autocomplete,
@@ -87,15 +85,11 @@ export function ProfileSettings() {
disabled: saving,
};
return (
- <Field key={id} label={label} wide={id === 'street'}>
- {id === 'street' ? (
+ <Field key={id} label={label} wide={multiline}>
+ {multiline ? (
<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)}
- />
+ <Input type={type} {...common} onChange={(event) => setField(id, event.target.value)} />
)}
</Field>
);
diff --git a/src/lib/bridge/use-preferences.ts b/src/lib/bridge/use-preferences.ts
index 3484a35..d01ea96 100644
--- a/src/lib/bridge/use-preferences.ts
+++ b/src/lib/bridge/use-preferences.ts
@@ -7,10 +7,6 @@ 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;
diff --git a/src/lib/settings/profile.ts b/src/lib/settings/profile.ts
index 55a37dd..29b9b50 100644
--- a/src/lib/settings/profile.ts
+++ b/src/lib/settings/profile.ts
@@ -1,15 +1,16 @@
-/**
- * What the user tells the agent about themselves from the settings page: the details a form may
- * ask for, and rules for every task. The daemon keeps it in profile.json and puts whatever is
- * filled in into each side-panel run's system prompt, so the model uses these values rather than
- * guessing at them.
- */
+export interface ProfileField {
+ readonly id: string;
+ readonly label: string;
+ readonly autocomplete: string;
+ readonly type?: 'email' | 'tel';
+ readonly multiline?: boolean;
+}
export const PROFILE_FIELDS = [
{ id: 'givenName', label: 'First name', autocomplete: 'given-name' },
{ id: 'familyName', label: 'Last name', autocomplete: 'family-name' },
- { id: 'email', label: 'Email', autocomplete: 'email' },
- { id: 'phone', label: 'Phone', autocomplete: 'tel' },
+ { id: 'email', label: 'Email', autocomplete: 'email', type: 'email' },
+ { id: 'phone', label: 'Phone', autocomplete: 'tel', type: 'tel' },
{ id: 'street', label: 'Street address', autocomplete: 'street-address', multiline: true },
{ id: 'city', label: 'City', autocomplete: 'address-level2' },
{ id: 'region', label: 'State / region', autocomplete: 'address-level1' },
@@ -17,7 +18,7 @@ export const PROFILE_FIELDS = [
{ id: 'country', label: 'Country', autocomplete: 'country-name' },
{ id: 'company', label: 'Company', autocomplete: 'organization' },
{ id: 'jobTitle', label: 'Job title', autocomplete: 'organization-title' },
-] as const;
+] as const satisfies readonly ProfileField[];
export type ProfileFieldId = (typeof PROFILE_FIELDS)[number]['id'];
@@ -28,9 +29,7 @@ export interface ProfileDetail {
export interface UserProfile {
readonly fields: Partial<Record<ProfileFieldId, string>>;
- /** Anything the fixed fields do not cover, labelled by the user. */
readonly details: readonly ProfileDetail[];
- /** Rules the user wants kept on every task. */
readonly instructions: string;
}
@@ -64,23 +63,22 @@ export function isUserProfile(value: unknown): value is UserProfile {
);
}
-/** Trimmed, with every empty field and every detail missing a label or a value left out. */
export function normalizeProfile(profile: UserProfile): UserProfile {
- const fields: Partial<Record<ProfileFieldId, string>> = {};
- for (const { id } of PROFILE_FIELDS) {
- const text = profile.fields[id]?.trim();
- if (text) fields[id] = text;
- }
- const details = profile.details
- .map((detail) => ({ label: detail.label.trim(), value: detail.value.trim() }))
- .filter((detail) => detail.label && detail.value);
- return { fields, details, instructions: profile.instructions.trim() };
+ return {
+ fields: Object.fromEntries(
+ PROFILE_FIELDS.flatMap(({ id }) => {
+ const text = profile.fields[id]?.trim();
+ return text ? [[id, text]] : [];
+ }),
+ ),
+ details: profile.details
+ .map((detail) => ({ label: detail.label.trim(), value: detail.value.trim() }))
+ .filter((detail) => detail.label && detail.value),
+ instructions: profile.instructions.trim(),
+ };
}
-/**
- * What a hand-edited profile.json can be read as: every entry that fits kept, anything that does
- * not left out, never cut short — a truncated phone number is worse than none.
- */
+/** Drops what does not fit rather than cutting it short: a truncated phone number is worse than none. */
export function asUserProfile(value: unknown): UserProfile {
if (!isRecord(value)) return EMPTY_PROFILE;
const fields = isRecord(value.fields)