The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a sign-in in one profile no longer locks another profile's accounts
Siddharth Balyan49c396d20a71
diff --git a/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx b/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsxindex ea7a5008800..61eaecd4ac4 100644--- a/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx+++ b/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx@@ -179,7 +179,7 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {}const runVerb = (card: ConnectorCardModel) => {- const open = accountOperationFor(operations, card.slug)+ const open = accountOperationFor(operations, card.slug, profile)switch (card.verb) {case 'authenticate':diff --git a/apps/desktop/src/app/capabilities/connectors/data/account-operations.test.ts b/apps/desktop/src/app/capabilities/connectors/data/account-operations.test.tsnew file mode 100644index 00000000000..36cae42a143--- /dev/null+++ b/apps/desktop/src/app/capabilities/connectors/data/account-operations.test.ts@@ -0,0 +1,27 @@+import { describe, expect, it } from 'vitest'++import { type AccountOperation, accountOperationFor } from './account-operations'++const operation = (opId: string, scope: AccountOperation['scope'], settled = false): AccountOperation => ({+ connectors: ['gmail'],+ deadlineAt: 1_800_000_000,+ opId,+ scope,+ seq: 0,+ settled,+ settledBy: null,+ targets: []+})++describe('accountOperationFor', () => {+ it('answers only with an operation started in the same profile scope', () => {+ const operations = {+ a: operation('a', 'work-profile'),+ b: operation('b', { connectionId: 'remote', profile: 'home' })+ }++ expect(accountOperationFor(operations, 'gmail', 'work-profile')?.opId).toBe('a')+ expect(accountOperationFor(operations, 'gmail', { connectionId: 'remote', profile: 'home' })?.opId).toBe('b')+ expect(accountOperationFor(operations, 'gmail', 'other')).toBeNull()+ })+})diff --git a/apps/desktop/src/app/capabilities/connectors/data/account-operations.ts b/apps/desktop/src/app/capabilities/connectors/data/account-operations.tsindex fd268e703be..85b6bf1a90b 100644--- a/apps/desktop/src/app/capabilities/connectors/data/account-operations.ts+++ b/apps/desktop/src/app/capabilities/connectors/data/account-operations.ts@@ -6,7 +6,7 @@ import type {} from '@hermes/shared'import { atom } from 'nanostores'-import type { ProfileScope } from '@/hermes'+import { type ProfileScope, profileScopeKey } from '@/hermes'import { type ConnectionTarget, parseConnectionTarget } from '@/store/connection-request'import { invalidateConnectors } from './keys'@@ -44,11 +44,17 @@ function resumeConnect(slugs: readonly string[]): void {const parseTargets = (targets: ConnectionUpdatePayload['targets']): ConnectionTarget[] =>targets.map(parseConnectionTarget).filter((target): target is ConnectionTarget => target !== null)+/** The open (else newest) operation for one app in one profile scope; other profiles' sign-ins are not this one's. */export function accountOperationFor(operations: Readonly<Record<string, AccountOperation>>,- slug: string+ slug: string,+ scope: ProfileScope): AccountOperation | null {- const mine = Object.values(operations).filter(operation => operation.connectors.includes(slug))+ const key = profileScopeKey(scope)++ const mine = Object.values(operations).filter(+ operation => operation.connectors.includes(slug) && profileScopeKey(operation.scope) === key+ )return mine.find(operation => !operation.settled) ?? mine[mine.length - 1] ?? null}diff --git a/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsx b/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsxindex 234fbf6e0f9..b20c285f9fd 100644--- a/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsx+++ b/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsx@@ -83,7 +83,7 @@ export function HostedConnectorDialog({togglePending}: HostedConnectorDialogProps) {const tools = useConnectorTools(profile, card.slug, hosted.listSlugs.has(card.slug))- const operation = accountOperationFor(useStore($accountOperations), card.slug)+ const operation = accountOperationFor(useStore($accountOperations), card.slug, profile)const inUse = wayInUse(card.ways)const [way, setWay] = useState<WayChoice>(inUse ?? 'hosted')