From af432de320db6de6550be4cf1c5d5059b52bb52b Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Fri, 24 Apr 2026 19:18:53 -0400 Subject: [PATCH] feat(ext/popup): fetch vault_settings on unlock; add to PopupState --- extension/src/popup/popup.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/extension/src/popup/popup.ts b/extension/src/popup/popup.ts index 95320f8..123731f 100644 --- a/extension/src/popup/popup.ts +++ b/extension/src/popup/popup.ts @@ -1,6 +1,6 @@ /// Popup entry point — state machine with view routing. /// -/// Views: setup | locked | list | detail | add | edit +/// Views: setup | locked | list | detail | add | edit | settings | settings-vault /// Navigation works by updating `currentState` and calling `render()`. import type { Request, Response } from '../shared/messages'; @@ -23,7 +23,7 @@ export function escapeHtml(str: string): string { // --- State --- -export type View = 'locked' | 'list' | 'detail' | 'add' | 'edit' | 'settings'; +export type View = 'locked' | 'list' | 'detail' | 'add' | 'edit' | 'settings' | 'settings-vault'; export interface PopupState { view: View; @@ -42,6 +42,8 @@ export interface PopupState { capturedTabId: number | null; capturedUrl: string; newType: import('../shared/types').ItemType | null; + vaultSettings: import('../shared/types').VaultSettings | null; + generatorDefaults: import('../shared/types').GeneratorRequest | null; } let currentState: PopupState = { @@ -57,6 +59,8 @@ let currentState: PopupState = { capturedTabId: null, capturedUrl: '', newType: null, + vaultSettings: null, + generatorDefaults: null, }; export function getState(): PopupState { @@ -175,6 +179,16 @@ async function init(): Promise { const listResp = await sendMessage({ type: 'list_items' }); if (listResp.ok) { const listData = listResp.data as { items: Array<[ItemId, ManifestEntry]> }; + // Fetch vault settings so subsequent screens (generator popover, + // settings-vault) can show current values without a round-trip. + // Failures swallow silently — list view still renders; consumers + // can show "settings not loaded" if needed. + const vsResp = await sendMessage({ type: 'get_vault_settings' }); + if (vsResp.ok) { + const vs = (vsResp.data as { settings: import('../shared/types').VaultSettings }).settings; + currentState.vaultSettings = vs; + currentState.generatorDefaults = vs.generator_defaults; + } navigate('list', { entries: listData.items }); return; }