Skip to content

The agent that grows with you

fix(desktop): Passwords & Logins asks the connection it shows, not the primary

teknium1924e47003013
diff --git a/apps/desktop/src/app/settings/vault-settings.owner.test.tsx b/apps/desktop/src/app/settings/vault-settings.owner.test.tsx
index f388470dafa..7de39c4151e 100644
--- a/apps/desktop/src/app/settings/vault-settings.owner.test.tsx
+++ b/apps/desktop/src/app/settings/vault-settings.owner.test.tsx
@@ -15,7 +15,7 @@ let respond: (profile: string, method: string) => Promise<unknown> = async () =>
vi.mock('@/store/gateway', async importActual => ({
...(await importActual<Record<string, unknown>>()),
- requestGatewayForProfile: (profile: string, method: string, params?: Record<string, unknown>) => {
+ requestGatewayForAgent: (_connectionId: null | string, profile: string, method: string, params?: Record<string, unknown>) => {
calls.push({ method, params: params ?? {}, profile })
return respond(profile, method)
diff --git a/apps/desktop/src/app/settings/vault-settings.test.tsx b/apps/desktop/src/app/settings/vault-settings.test.tsx
index 487f5c07968..ab31d27f975 100644
--- a/apps/desktop/src/app/settings/vault-settings.test.tsx
+++ b/apps/desktop/src/app/settings/vault-settings.test.tsx
@@ -5,24 +5,24 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { stubResizeObserver } from '@/test/jsdom'
-const { requestGateway, requestGatewayForProfile } = vi.hoisted(() => ({
+const { requestGateway, requestGatewayForAgent } = vi.hoisted(() => ({
requestGateway: vi.fn(),
- requestGatewayForProfile: vi.fn()
+ requestGatewayForAgent: vi.fn()
}))
-// The panel routes every RPC through the owner profile's socket (never the ambient gateway);
-// the mock receives (method, params) after the profile argument.
+// The panel routes every RPC through the owner (connection, profile) socket (never the ambient
+// gateway); the mock receives (method, params) after the connectionId + profile arguments.
vi.mock('@/store/gateway', async importActual => ({
...(await importActual<Record<string, unknown>>()),
- requestGatewayForProfile: (...args: [string, string, Record<string, unknown>?, ...unknown[]]) => {
- requestGatewayForProfile(...args)
+ requestGatewayForAgent: (...args: [null | string, string, string, Record<string, unknown>?, ...unknown[]]) => {
+ requestGatewayForAgent(...args)
- return requestGateway(args[1], args[2] ?? {})
+ return requestGateway(args[2], args[3] ?? {})
}
}))
import { queryClient } from '@/lib/query-client'
-import { $gatewayState } from '@/store/session'
+import { $connection, $gatewayState } from '@/store/session'
import { VaultSettings } from './vault-settings'
@@ -49,8 +49,9 @@ const LOGIN_ITEM = {
beforeEach(() => {
requestGateway.mockReset()
- requestGatewayForProfile.mockReset()
+ requestGatewayForAgent.mockReset()
queryClient.clear()
+ $connection.set(null)
$gatewayState.set('open')
})
@@ -68,7 +69,28 @@ describe('VaultSettings', () => {
expect(requestGateway).toHaveBeenCalledWith('vault.list', {})
// The scoped Settings dial must be foreground so a cold profile spawn is not
// queued behind background work (#111651).
- expect(requestGatewayForProfile).toHaveBeenCalledWith(
+ expect(requestGatewayForAgent).toHaveBeenCalledWith(
+ null,
+ expect.any(String),
+ 'vault.list',
+ {},
+ undefined,
+ undefined,
+ { spawnPriority: 'foreground' }
+ )
+ })
+
+ // Two connections both serving `default` (this device + a remote gateway): a bare profile
+ // name would resolve onto the PRIMARY socket and the panel would show the other machine's
+ // vault (#94811). The RPC must name the connection the panel claims to show.
+ it('routes every vault RPC through the active connection, not a bare profile name', async () => {
+ requestGateway.mockResolvedValue({ items: [] })
+ $connection.set({ connectionId: 'this-device', mode: 'local' } as never)
+ renderVault()
+
+ await waitFor(() => expect(requestGateway).toHaveBeenCalledWith('vault.list', {}))
+ expect(requestGatewayForAgent).toHaveBeenCalledWith(
+ 'this-device',
expect.any(String),
'vault.list',
{},
diff --git a/apps/desktop/src/app/settings/vault-settings.tsx b/apps/desktop/src/app/settings/vault-settings.tsx
index 3c1457bd421..d0bd0c39ecc 100644
--- a/apps/desktop/src/app/settings/vault-settings.tsx
+++ b/apps/desktop/src/app/settings/vault-settings.tsx
@@ -22,7 +22,7 @@ import { useI18n } from '@/i18n'
import { triggerHaptic } from '@/lib/haptics'
import { KeyRound, Lock, Plus, ShieldLock, Trash2 } from '@/lib/icons'
import { $activeConnectionId } from '@/store/connections'
-import { requestGatewayForProfile } from '@/store/gateway'
+import { requestGatewayForAgent } from '@/store/gateway'
import { notify, notifyError } from '@/store/notifications'
import { $gatewayState } from '@/store/session'
import { $settingsScopeProfile } from '@/store/settings-scope'
@@ -156,17 +156,22 @@ export function VaultSettings() {
const gatewayState = useStore($gatewayState)
const queryClient = useQueryClient()
// The owner this panel edits: every RPC below goes through the owner's socket with an explicit
- // profile — never the ambient foreground gateway. The mount site keys the panel by this same
- // owner, so a profile switch / connection swap remounts it: dialogs close and drafts (including a
- // typed master password) are gone by construction rather than by cleanup code.
+ // (connection, profile) — never the ambient foreground gateway, and never a bare profile name:
+ // a bare name equal to the primary profile resolves onto the PRIMARY socket, so two connections
+ // both serving `default` would have this device's panel answered by the other machine (#94811).
+ // The mount site keys the panel by this same owner, so a profile switch / connection swap
+ // remounts it: dialogs close and drafts (including a typed master password) are gone by
+ // construction rather than by cleanup code.
const scopeProfile = useStore($settingsScopeProfile)
const connectionId = useStore($activeConnectionId)
const owner = vaultOwnerKey(connectionId, scopeProfile)
const requestGateway = useCallback(
<T,>(method: string, params: Record<string, unknown> = {}) =>
- requestGatewayForProfile<T>(scopeProfile, method, params, undefined, undefined, { spawnPriority: 'foreground' }),
- [scopeProfile]
+ requestGatewayForAgent<T>(connectionId, scopeProfile, method, params, undefined, undefined, {
+ spawnPriority: 'foreground'
+ }),
+ [connectionId, scopeProfile]
)
const VAULT_QUERY_KEY = useMemo(() => vaultQueryKey(owner), [owner])
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]
new file mode 100644
index 00000000000..08d605dd81d
--- /dev/null
+++ b/contributors/emails/[email protected]
@@ -0,0 +1 @@
+lorencato23