Skip to content

The agent that grows with you

fix(desktop): refresh vault source detection on mount

KoNit-Kc89a4404fda2
diff --git a/apps/desktop/src/app/settings/vault-settings.test.tsx b/apps/desktop/src/app/settings/vault-settings.test.tsx
index b5965180b87..a6cd6fa599b 100644
--- a/apps/desktop/src/app/settings/vault-settings.test.tsx
+++ b/apps/desktop/src/app/settings/vault-settings.test.tsx
@@ -201,4 +201,36 @@ describe('VaultSettings', () => {
expect(screen.queryByPlaceholderText('Master password')).toBeNull()
expect(screen.getByRole('button', { name: 'Lock' })).toBeTruthy()
})
+
+ it('refreshes password-manager detection when the page is reopened', async () => {
+ let installed = false
+ requestGateway.mockImplementation(async (method: string) => {
+ if (method === 'vault.sources') {
+ return {
+ sources: [
+ {
+ name: 'onepassword',
+ display_name: '1Password',
+ enabled: false,
+ needs_unlock: true,
+ unlocked: false,
+ installed
+ }
+ ]
+ }
+ }
+
+ return { items: [] }
+ })
+
+ const first = renderVault()
+ await screen.findByText('Not detected')
+ first.unmount()
+
+ installed = true
+ renderVault()
+
+ await waitFor(() => expect(screen.getByRole('switch', { name: '1Password' })).toBeTruthy())
+ expect(requestGateway.mock.calls.filter(([method]) => method === 'vault.sources')).toHaveLength(2)
+ })
})
diff --git a/apps/desktop/src/app/settings/vault-settings.tsx b/apps/desktop/src/app/settings/vault-settings.tsx
index 1cb6d1c08c3..ce0873e6098 100644
--- a/apps/desktop/src/app/settings/vault-settings.tsx
+++ b/apps/desktop/src/app/settings/vault-settings.tsx
@@ -188,6 +188,9 @@ export function VaultSettings() {
const { data: sourcesData } = useQuery({
enabled: gatewayState === 'open',
queryKey: VAULT_SOURCES_QUERY_KEY,
+ // Manager detection can change while this settings page is closed. Always ask the
+ // local backend again on mount instead of reusing the shared cache's 60s fresh value.
+ refetchOnMount: 'always',
queryFn: async () => {
const result = await requestGateway<{ sources: VaultSource[] }>('vault.sources', {})