// Extension-local preferences: state that belongs to this browser install, not to the // daemon's Settings bag. The protocol draws a hard line here — settings.set and // rules.upsert are privileged, uds-only methods (METHODS in shared/protocol) — so an // Options page reachable only over the WebSocket transport cannot write the daemon's // capture policy no matter what the UI looks like. Rather than inventing a protocol // field to work around that (CLAUDE.md §2 forbids exactly this), the extension: // - mirrors the daemon's capture policy read-only via capture.getRules (works on // both transports, and is what shouldCapture() itself already trusts), and // - keeps the one piece of "options" state that genuinely is the extension's own — // which category new captures/context-menu downloads default to — in // browser.storage.local, exactly like the pairing token and transport override. // Editing the mirrored capture policy is only offered when connected via NativeTransport, // where settings.set is allowed; see options.ts. const KEY = { defaultCategoryId: 'velox.defaultCategoryId' } as const; export async function getDefaultCategoryId(): Promise { const bag = await browser.storage.local.get(KEY.defaultCategoryId); return (bag[KEY.defaultCategoryId] as string | undefined) ?? null; } export async function setDefaultCategoryId(categoryId: string | null): Promise { if (categoryId === null) await browser.storage.local.remove(KEY.defaultCategoryId); else await browser.storage.local.set({ [KEY.defaultCategoryId]: categoryId }); }