The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a directory tile's label and click come from the same sign-in
alt-glitch28606c35ee05
diff --git a/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx b/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsxindex e8e39c21b8f..29ff58722b6 100644--- a/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx+++ b/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx@@ -61,7 +61,7 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {onStarted: card => setOpenKey(cardKey(card))})- const { connectAccount, connector, remover, startConnect, switcher, write } = hostedActions+ const { connectAccount, connector, remover, retry, startConnect, switcher, write } = hostedActionsconst renamer = useRenameAccount(profile)const [addOpen, setAddOpen] = useState(false)@@ -229,15 +229,7 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {pendingRename,reconnect: (account: AccountRow) => void startConnect(openCard, true, account),reconnecting: connector.pending === openCard.slug,- retry: operation => {- const { reconnect, ...address } = operation.request-- void connectAccount(openCard, reconnect, address).then(outcome => {- if (!outcome.ok) {- notifyError(outcome.error, t.connectors.connectErrorFor(openCard.name))- }- })- },+ retry: operation => retry(openCard, operation),remove: (account: AccountRow) => setDisconnecting({ account, card: openCard }),rename: renamer.rename,renameOpeneddiff --git a/apps/desktop/src/app/capabilities/connectors/data/hosted-actions.ts b/apps/desktop/src/app/capabilities/connectors/data/hosted-actions.tsindex 67a606a99c2..bbeb2fda202 100644--- a/apps/desktop/src/app/capabilities/connectors/data/hosted-actions.ts+++ b/apps/desktop/src/app/capabilities/connectors/data/hosted-actions.ts@@ -6,7 +6,7 @@ import { notifyError } from '@/store/notifications'import type { AccountRow, ConnectorCardModel } from '../types'-import { $accountOperations, abandonConnect, accountOperationFor } from './account-operations'+import { $accountOperations, abandonConnect, type AccountOperation, accountOperationFor } from './account-operations'import { accountAddress, pickAccount } from './join'import {type AccountDisconnect,@@ -25,6 +25,8 @@ export interface HostedActions {connectAccount: (card: ConnectorCardModel, reconnect: boolean, address?: ConnectAddress) => Promise<ConnectOutcome>connector: ConnectorConnectremover: AccountDisconnect+ /** Runs a failed sign-in's own request again, so it mints a fresh link for the same account. */+ retry: (card: ConnectorCardModel, operation: AccountOperation) => void/** Runs a hosted card's verb; false when the verb is not a hosted one (a local server's). */runHostedVerb: (card: ConnectorCardModel) => booleanstartConnect: (card: ConnectorCardModel, reconnect: boolean, account?: AccountRow) => Promise<void>@@ -90,6 +92,16 @@ export function useHostedActions(onStarted?.(card)}+ const retry = (card: ConnectorCardModel, operation: AccountOperation) => {+ const { reconnect, ...address } = operation.request++ void connectAccount(card, reconnect, address).then(outcome => {+ if (!outcome.ok) {+ notifyError(outcome.error, t.connectors.connectErrorFor(card.name))+ }+ })+ }+const stopWaiting = (card: ConnectorCardModel) => {const open = accountOperationFor(operations, card.slug, scope)@@ -142,6 +154,7 @@ export function useHostedActions(connectAccount,connector,remover,+ retry,runHostedVerb,startConnect,switcher,diff --git a/apps/desktop/src/components/assistant-ui/connector-directory-card.tsx b/apps/desktop/src/components/assistant-ui/connector-directory-card.tsxindex 71b9e9d1432..cb1aeadeb1e 100644--- a/apps/desktop/src/components/assistant-ui/connector-directory-card.tsx+++ b/apps/desktop/src/components/assistant-ui/connector-directory-card.tsx@@ -4,6 +4,7 @@ import { useMemo, useState } from 'react'import {$abandonedConnects,$accountOperations,+ type AccountOperation,accountOperationFor,retryable} from '@/app/capabilities/connectors/data/account-operations'@@ -136,27 +137,43 @@ function DirectoryBody({ onContinue, owner, returnRoute, suggested = NO_SUGGESTI})}- // An open sign-in shows on its tile; a failed one says so, and clicking the tile starts the same sign-in again.- const signInSub = (card: ConnectorCardModel): string | undefined => {+ // An open sign-in decides both the tile's label and its click, so the two never disagree with a stale row.+ const openSignIn = (card: ConnectorCardModel) => {const operation = accountOperationFor(operations, card.slug, owner)- if (!operation || operation.settled) {- return undefined- }-- return retryable(operation) ? copy.directory.signInFailed : copy.directory.finishInBrowser+ return operation && !operation.settled ? operation : null}- const tileSub = (card: ConnectorCardModel, busy: boolean): string | undefined => {+ const tileSub = (card: ConnectorCardModel, busy: boolean, open: AccountOperation | null): string | undefined => {if (busy) {return copy.opening}- return signInSub(card) ?? (card.state === 'available' ? undefined : t.connectorsPage.card.state[card.stateWord])+ if (open) {+ return retryable(open) ? copy.directory.signInFailed : copy.directory.finishInBrowser+ }++ return card.state === 'available' ? undefined : t.connectorsPage.card.state[card.stateWord]+ }++ // Failed: the same request again. Waiting: the link again. Otherwise the app's own verb.+ const press = (card: ConnectorCardModel, open: AccountOperation | null) => {+ if (open && retryable(open)) {+ actions.retry(card, open)+ } else if (open) {+ const url = open.targets.find(target => target.connectUrl)?.connectUrl++ if (url) {+ void window.hermesDesktop?.openExternal?.(url)+ }+ } else {+ actions.runHostedVerb(card)+ }}const tile = (card: ConnectorCardModel) => {const busy = actions.busySlug === card.slug+ const open = openSignIn(card)return (<Chip@@ -172,10 +189,10 @@ function DirectoryBody({ onContinue, owner, returnRoute, suggested = NO_SUGGESTIon={card.state === 'connected'}onToggle={() => {if (!busy) {- actions.runHostedVerb(card)+ press(card, open)}}}- sub={tileSub(card, busy)}+ sub={tileSub(card, busy, open)}/>)}diff --git a/tests/tools/test_connectors_display.py b/tests/tools/test_connectors_display.pyindex 259e50c9363..f662c990ebb 100644--- a/tests/tools/test_connectors_display.py+++ b/tests/tools/test_connectors_display.py@@ -7,7 +7,6 @@ Contracts:"""import json-import threadingfrom unittest.mock import patchimport pytest@@ -45,16 +44,13 @@ def test_display_waits_for_the_user_and_reports_what_they_connected(ending):seen = []def card(payload):+ # The user connects Slack while the card is open, then presses Continue or walks away.seen.append(payload)+ gw.connected.add("slack")+ if ending == "continue":+ apply_answer(live.get("s1", payload["op_id"]), json.dumps({"settled_by": "continue"}))- def user_connects_slack():- gw.connected.add("slack")- if ending == "continue":- apply_answer(live.get("s1", payload["op_id"]), json.dumps({"settled_by": "continue"}))-- threading.Timer(0.05, user_connects_slack).start()-- with patch("tools.connectors.operation.OPERATION_DEADLINE_SECONDS", 0.5 if ending == "deadline" else 60):+ with patch("tools.connectors.operation.OPERATION_DEADLINE_SECONDS", 2 if ending == "deadline" else 60):out = _display(gw, callback=card, card_surface=True)(payload,) = seen