Skip to content

The agent that grows with you

feat(desktop): list, name and rename several accounts per connector

Siddharth Balyan9a83171db58e
diff --git a/apps/desktop/src/app/capabilities/connectors/accounts-section.test.tsx b/apps/desktop/src/app/capabilities/connectors/accounts-section.test.tsx
new file mode 100644
index 00000000000..44bdc7ee9c5
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/connectors/accounts-section.test.tsx
@@ -0,0 +1,160 @@
+import type { ConnectorAccountRow, ConnectorAccountsRenameParams, ConnectorAccountsResult } from '@hermes/shared'
+import { JsonRpcGatewayError } from '@hermes/shared'
+import { QueryClientProvider, useQuery } from '@tanstack/react-query'
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { useState } from 'react'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import { I18nProvider } from '@/i18n'
+import { queryClient } from '@/lib/query-client'
+import { setPrimaryGateway } from '@/store/gateway'
+
+import { type AccountEdit, AccountsSection } from './accounts-section'
+import { connectorsAccountsQueryKey } from './data/keys'
+import { useRenameAccount } from './data/mutations'
+
+const SCOPE = 'default'
+
+const ACCOUNTS: ConnectorAccountsResult = {
+ accounts: [
+ {
+ active: true,
+ alias: 'work',
+ connection_id: 'ca_work',
+ connector: 'gmail',
+ created_at: '2026-10-05T00:00:00Z',
+ label: 'Gmail account',
+ status: 'active',
+ updated_at: '2026-10-05T00:00:00Z'
+ },
+ {
+ active: true,
+ alias: 'home',
+ connection_id: 'ca_home',
+ connector: 'gmail',
+ created_at: '2026-10-01T00:00:00Z',
+ label: 'Gmail account',
+ status: 'active',
+ updated_at: '2026-10-01T00:00:00Z'
+ }
+ ]
+}
+
+function Harness() {
+ // A refetch never answers, so only the rename's own reconcile or rollback can change the row.
+ const accounts = useQuery({
+ queryFn: () => new Promise<ConnectorAccountsResult>(() => undefined),
+ queryKey: connectorsAccountsQueryKey(SCOPE),
+ staleTime: Number.POSITIVE_INFINITY
+ })
+
+ const renamer = useRenameAccount(SCOPE)
+ const [edit, setEdit] = useState<AccountEdit | null>(null)
+
+ return (
+ <AccountsSection
+ accounts={accounts.data?.accounts ?? []}
+ edit={edit}
+ onAdd={async () => ({ ok: true })}
+ onEditChange={setEdit}
+ onReconnect={() => undefined}
+ onRemove={() => undefined}
+ onRename={renamer.rename}
+ reconnecting={false}
+ retired={[]}
+ />
+ )
+}
+
+function renderSection() {
+ queryClient.setQueryData(connectorsAccountsQueryKey(SCOPE), ACCOUNTS)
+
+ return render(
+ <QueryClientProvider client={queryClient}>
+ <I18nProvider>
+ <Harness />
+ </I18nProvider>
+ </QueryClientProvider>
+ )
+}
+
+async function renameWork(to: string) {
+ fireEvent.click(screen.getAllByRole('button', { name: 'Rename' })[0])
+ fireEvent.change(screen.getByRole('textbox', { name: 'New name for work' }), { target: { value: to } })
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+}
+
+/** The primary socket answers `connectors.accounts.rename` with `rename`; every other method stays unanswered. */
+function serveRename(rename: () => Promise<ConnectorAccountRow>) {
+ const request = vi.fn((method: string, _params: ConnectorAccountsRenameParams) =>
+ method === 'connectors.accounts.rename' ? rename() : new Promise(() => undefined)
+ )
+
+ // SAFETY: the connector RPC layer calls only `request` on the primary socket in these tests.
+ setPrimaryGateway({ request } as never)
+
+ return request
+}
+
+const renameCalls = (request: ReturnType<typeof serveRename>) =>
+ request.mock.calls.filter(([method]) => method === 'connectors.accounts.rename').map(([, params]) => params)
+
+afterEach(() => {
+ cleanup()
+ queryClient.clear()
+ setPrimaryGateway(null)
+})
+
+describe('AccountsSection rename', () => {
+ it('sends the account id and the new name, and shows the new name before the answer', async () => {
+ let answer: (row: ConnectorAccountRow) => void = () => undefined
+
+ const request = serveRename(
+ () =>
+ new Promise(resolve => {
+ answer = resolve
+ })
+ )
+
+ renderSection()
+ await renameWork('office')
+
+ await waitFor(() => expect(screen.getByText('office')).toBeTruthy())
+ expect(renameCalls(request)).toEqual([{ alias: 'office', connection_id: 'ca_work' }])
+
+ answer({ ...ACCOUNTS.accounts[0], alias: 'office' })
+ await waitFor(() => expect(screen.getByText('office')).toBeTruthy())
+ })
+
+ it('restores the old name and says why when the gateway refuses the name', async () => {
+ serveRename(() =>
+ Promise.reject(
+ new JsonRpcGatewayError('That name is already used.', { code: 4090, data: { reason: 'ALIAS_TAKEN' } })
+ )
+ )
+
+ renderSection()
+ await renameWork('office')
+
+ await waitFor(() => expect(screen.getByRole('alert').textContent).toBe('That name is already used.'))
+ expect(
+ queryClient.getQueryData<ConnectorAccountsResult>(connectorsAccountsQueryKey(SCOPE))?.accounts[0].alias
+ ).toBe('work')
+ expect(screen.queryByText('office')).toBeNull()
+ })
+
+ it('refuses a duplicate or malformed name without calling the gateway', async () => {
+ const request = serveRename(() => Promise.resolve(ACCOUNTS.accounts[0]))
+
+ renderSection()
+ await renameWork('home')
+
+ expect(screen.getByRole('alert').textContent).toBe('That name is already used.')
+
+ fireEvent.change(screen.getByRole('textbox', { name: 'New name for work' }), { target: { value: '-work' } })
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+
+ expect(screen.getByRole('alert').textContent).toMatch(/lowercase letters/)
+ expect(renameCalls(request)).toEqual([])
+ })
+})
diff --git a/apps/desktop/src/app/capabilities/connectors/accounts-section.tsx b/apps/desktop/src/app/capabilities/connectors/accounts-section.tsx
new file mode 100644
index 00000000000..1ed06eac036
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/connectors/accounts-section.tsx
@@ -0,0 +1,326 @@
+import { type ReactNode, useState } from 'react'
+
+import { ListRow } from '@/app/settings/primitives'
+import { Badge } from '@/components/ui/badge'
+import { Button } from '@/components/ui/button'
+import { Codicon } from '@/components/ui/codicon'
+import { Input } from '@/components/ui/input'
+import { useI18n } from '@/i18n'
+import type { Translations } from '@/i18n/types'
+import { readableError } from '@/store/notifications'
+
+import { aliasProblem } from './data/alias'
+import { accountName } from './data/join'
+import type { WriteOutcome } from './data/mutations'
+import type { AccountRow } from './types'
+
+type AccountsCopy = Translations['connectorsPage']['accounts']
+type BadgeVariant = 'destructive' | 'muted' | 'warn'
+
+/** Statuses a reconnect repairs; `pending` waits for a sign-in and `active` needs nothing. */
+const STATUS_VIEW = {
+ expired: { reconnect: true, variant: 'warn' },
+ failed: { reconnect: true, variant: 'warn' },
+ inactive: { reconnect: true, variant: 'muted' },
+ pending: { reconnect: false, variant: 'muted' },
+ revoked: { reconnect: true, variant: 'destructive' }
+} satisfies Record<Exclude<AccountRow['status'], 'active'>, { reconnect: boolean; variant: BadgeVariant }>
+
+/** The name being typed: for one account, or for an account still to add. A refused write reopens it with the error. */
+export type AccountEdit =
+ | { connectionId: string; draft?: string; error?: string; kind: 'rename' }
+ | {
+ draft?: string
+ error?: string
+ kind: 'add'
+ }
+
+export interface AccountsSectionProps {
+ accounts: readonly AccountRow[]
+ edit: AccountEdit | null
+ onAdd: (alias: string) => Promise<WriteOutcome>
+ onEditChange: (edit: AccountEdit | null) => void
+ onReconnect: (account: AccountRow) => void
+ onRemove: (account: AccountRow) => void
+ onRename: (connectionId: string, alias: string) => Promise<WriteOutcome>
+ reconnecting: boolean
+ retired: readonly AccountRow[]
+}
+
+export function AccountsSection({
+ accounts,
+ edit,
+ onAdd,
+ onEditChange,
+ onReconnect,
+ onRemove,
+ onRename,
+ reconnecting,
+ retired
+}: AccountsSectionProps) {
+ const { t } = useI18n()
+ const copy = t.connectorsPage.accounts
+ const everyAccount = [...accounts, ...retired]
+ const [adding, setAdding] = useState(false)
+
+ if (accounts.length === 0 && retired.length === 0) {
+ return null
+ }
+
+ const refusal = (outcome: WriteOutcome): string | undefined =>
+ outcome.ok
+ ? undefined
+ : outcome.error.reason === 'ALIAS_TAKEN'
+ ? copy.aliasTaken
+ : readableError(outcome.error, t.connectorsPage.page.writeFailed).message
+
+ // The row shows the new name as soon as the editor closes; a refusal restores the old name and reopens the editor.
+ const rename = async (connectionId: string, alias: string) => {
+ onEditChange(null)
+
+ const error = refusal(await onRename(connectionId, alias))
+
+ if (error) {
+ onEditChange({ connectionId, draft: alias, error, kind: 'rename' })
+ }
+ }
+
+ const add = async (alias: string) => {
+ setAdding(true)
+
+ const error = refusal(await onAdd(alias))
+
+ setAdding(false)
+ onEditChange(error ? { draft: alias, error, kind: 'add' } : null)
+ }
+
+ return (
+ <section
+ aria-label={copy.heading}
+ className="grid shrink-0 border-b border-(--ui-stroke-tertiary) px-3.5 py-1"
+ data-slot="connector-accounts"
+ >
+ {accounts.map(account =>
+ edit?.kind === 'rename' && edit.connectionId === account.connection_id ? (
+ <AliasEditor
+ accounts={everyAccount}
+ error={edit.error}
+ initial={edit.draft ?? account.alias ?? ''}
+ key={account.connection_id}
+ label={copy.renameLabel(accountName(account))}
+ onCancel={() => onEditChange(null)}
+ onSubmit={alias => void rename(account.connection_id, alias)}
+ self={account.connection_id}
+ submitLabel={t.common.save}
+ unchanged={account.alias ?? ''}
+ />
+ ) : (
+ <AccountLine
+ account={account}
+ actions={
+ <>
+ {account.status !== 'active' && STATUS_VIEW[account.status].reconnect ? (
+ <Button disabled={reconnecting} onClick={() => onReconnect(account)} size="xs" variant="secondary">
+ {t.connectorsPage.card.verb.reconnect}
+ </Button>
+ ) : null}
+ <Button
+ onClick={() => onEditChange({ connectionId: account.connection_id, kind: 'rename' })}
+ size="xs"
+ variant="text"
+ >
+ {copy.rename}
+ </Button>
+ <Button onClick={() => onRemove(account)} size="xs" variant="text">
+ {copy.remove}
+ </Button>
+ </>
+ }
+ copy={copy}
+ key={account.connection_id}
+ />
+ )
+ )}
+
+ {retired.length > 0 ? <RetiredFold accounts={retired} copy={copy} onRemove={onRemove} /> : null}
+
+ {edit?.kind === 'add' ? (
+ <AliasEditor
+ accounts={everyAccount}
+ busy={adding}
+ error={edit.error}
+ hint={copy.aliasHint}
+ initial={edit.draft ?? ''}
+ label={copy.aliasLabel}
+ onCancel={() => onEditChange(null)}
+ onSubmit={alias => void add(alias)}
+ submitLabel={copy.add}
+ />
+ ) : accounts.length > 0 ? (
+ <div className="py-2">
+ <Button onClick={() => onEditChange({ kind: 'add' })} size="xs" variant="secondary">
+ {copy.addAnother}
+ </Button>
+ </div>
+ ) : null}
+ </section>
+ )
+}
+
+function AccountLine({ account, actions, copy }: { account: AccountRow; actions: ReactNode; copy: AccountsCopy }) {
+ const named = account.alias ? account.label : undefined
+ const status = account.status === 'active' ? null : account.status
+
+ return (
+ <ListRow
+ action={actions}
+ description={
+ named || status ? (
+ <span className="flex min-w-0 items-center gap-1.5">
+ {named ? <span className="truncate">{named}</span> : null}
+ {status ? (
+ <Badge size="xs" variant={STATUS_VIEW[status].variant}>
+ {copy.status[status]}
+ </Badge>
+ ) : null}
+ </span>
+ ) : undefined
+ }
+ title={<span className="truncate">{accountName(account)}</span>}
+ wide
+ />
+ )
+}
+
+function RetiredFold({
+ accounts,
+ copy,
+ onRemove
+}: {
+ accounts: readonly AccountRow[]
+ copy: AccountsCopy
+ onRemove: (account: AccountRow) => void
+}) {
+ return (
+ <details className="group py-1.5" data-slot="connector-accounts-retired">
+ <summary className="flex cursor-pointer list-none items-center gap-1.5 text-[0.72rem] text-(--ui-text-tertiary)">
+ <Codicon
+ className="shrink-0 transition-transform duration-100 group-open:rotate-90"
+ name="chevron-right"
+ size="0.75rem"
+ />
+ {copy.retiredCount(accounts.length)}
+ </summary>
+ {accounts.map(account => (
+ <ListRow
+ action={
+ <Button onClick={() => onRemove(account)} size="xs" variant="text">
+ {copy.remove}
+ </Button>
+ }
+ description={copy.status.retired}
+ key={account.connection_id}
+ title={<span className="truncate">{accountName(account)}</span>}
+ wide
+ />
+ ))}
+ </details>
+ )
+}
+
+interface AliasEditorProps {
+ accounts: readonly AccountRow[]
+ busy?: boolean
+ error?: string
+ hint?: string
+ initial: string
+ label: string
+ onCancel: () => void
+ onSubmit: (alias: string) => void
+ self?: string
+ submitLabel: string
+ /** Submitting this value closes the editor without a write. */
+ unchanged?: string
+}
+
+function AliasEditor({
+ accounts,
+ busy = false,
+ error: refused,
+ hint,
+ initial,
+ label,
+ onCancel,
+ onSubmit,
+ self,
+ submitLabel,
+ unchanged
+}: AliasEditorProps) {
+ const { t } = useI18n()
+ const copy = t.connectorsPage.accounts
+ const [value, setValue] = useState(initial)
+ const [invalid, setInvalid] = useState<null | string>(null)
+ const [edited, setEdited] = useState(false)
+ const error = invalid ?? (edited ? undefined : refused)
+
+ const submit = () => {
+ const alias = value.trim()
+
+ if (alias === unchanged) {
+ onCancel()
+
+ return
+ }
+
+ const problem = aliasProblem(alias, accounts, self)
+
+ if (problem) {
+ setInvalid(problem === 'taken' ? copy.aliasTaken : copy.aliasInvalid)
+
+ return
+ }
+
+ onSubmit(alias)
+ }
+
+ return (
+ <form
+ className="grid gap-1.5 py-2"
+ data-slot="connector-alias-editor"
+ onSubmit={event => {
+ event.preventDefault()
+ submit()
+ }}
+ >
+ <div className="flex items-center gap-2">
+ <Input
+ aria-invalid={error ? true : undefined}
+ aria-label={label}
+ autoFocus
+ maxLength={32}
+ onChange={event => {
+ setValue(event.target.value.toLowerCase())
+ setInvalid(null)
+ setEdited(true)
+ }}
+ placeholder={label}
+ size="sm"
+ value={value}
+ />
+ <Button loading={busy} size="xs" type="submit">
+ {submitLabel}
+ </Button>
+ <Button disabled={busy} onClick={onCancel} size="xs" type="button" variant="text">
+ {t.common.cancel}
+ </Button>
+ </div>
+ {error ? (
+ <p className="text-[0.7rem] text-destructive" role="alert">
+ {error}
+ </p>
+ ) : hint ? (
+ <p className="text-[0.7rem] text-(--ui-text-tertiary)">{hint}</p>
+ ) : null}
+ </form>
+ )
+}
diff --git a/apps/desktop/src/app/capabilities/connectors/connector-dialog.tsx b/apps/desktop/src/app/capabilities/connectors/connector-dialog.tsx
index f91f9ca2b99..c077f9a9d68 100644
--- a/apps/desktop/src/app/capabilities/connectors/connector-dialog.tsx
+++ b/apps/desktop/src/app/capabilities/connectors/connector-dialog.tsx
@@ -42,6 +42,8 @@ const RULEABLE = {
const ruleable = (way: ConnectorWayHosted | null): boolean => way !== null && way.connected && RULEABLE[way.state]
export interface ConnectorDialogProps {
+ /** The app's account list, drawn between the lead and the tools. */
+ accounts?: ReactNode
advanced?: ReactNode
card: ConnectorCardModel
connectElement?: ReactNode
@@ -52,6 +54,8 @@ export interface ConnectorDialogProps {
onAuthenticate?: () => void
onConnect?: () => void
onDisconnect?: () => void
+ /** Escape inside the dialog; return true when it cancelled something, so the dialog stays open. */
+ onEscape?: () => boolean
onInstall?: (env: Record<string, string>) => void
onOpenAdmin?: () => void
onOpenChange: (open: boolean) => void
@@ -70,7 +74,15 @@ export interface ConnectorDialogProps {
const localTarget = (card: ConnectorCardModel): string | undefined => card.ways.local?.target
-export function ConnectorDialog({ card, onOpenChange, open, tools, ...rest }: ConnectorDialogProps) {
+export function ConnectorDialog({
+ accounts,
+ card,
+ onEscape,
+ onOpenChange,
+ open,
+ tools,
+ ...rest
+}: ConnectorDialogProps) {
const { t } = useI18n()
const local = card.residency === 'local'
const titleRef = useRef<HTMLHeadingElement>(null)
@@ -80,6 +92,12 @@ export function ConnectorDialog({ card, onOpenChange, open, tools, ...rest }: Co
<DialogContent
bodyClassName="gap-0 overflow-hidden p-0"
className="max-h-[85vh] max-w-lg"
+ onEscapeKeyDown={event => {
+ // One cancel gesture does one thing: Escape abandons an open name edit first.
+ if (onEscape?.()) {
+ event.preventDefault()
+ }
+ }}
onOpenAutoFocus={event => {
event.preventDefault()
titleRef.current?.focus()
@@ -91,6 +109,8 @@ export function ConnectorDialog({ card, onOpenChange, open, tools, ...rest }: Co
<div className="flex min-h-0 flex-1 flex-col">
{card.ways.hosted ? <HostedLead card={card} {...rest} /> : <LocalLead card={card} {...rest} />}
+ {accounts}
+
{tools}
{local ? <LocalFoot card={card} {...rest} /> : <HostedFoot card={card} {...rest} />}
@@ -102,7 +122,7 @@ export function ConnectorDialog({ card, onOpenChange, open, tools, ...rest }: Co
)
}
-type PartProps = Omit<ConnectorDialogProps, 'onOpenChange' | 'open' | 'tools'>
+type PartProps = Omit<ConnectorDialogProps, 'accounts' | 'onEscape' | 'onOpenChange' | 'open' | 'tools'>
function Header({ card, titleRef, ...rest }: PartProps & { titleRef: RefObject<HTMLHeadingElement | null> }) {
const { t } = useI18n()
diff --git a/apps/desktop/src/app/capabilities/connectors/connector-row-card.tsx b/apps/desktop/src/app/capabilities/connectors/connector-row-card.tsx
index 1f6068415a0..0c68b1a7ed1 100644
--- a/apps/desktop/src/app/capabilities/connectors/connector-row-card.tsx
+++ b/apps/desktop/src/app/capabilities/connectors/connector-row-card.tsx
@@ -110,6 +110,8 @@ export function ConnectorRowCard({
{showsCatalogMark(card) ? <CatalogMark /> : null}
+ <AccountSummary card={card} />
+
{twin ? (
<Badge className="shrink-0" size="xs" variant="muted">
{twin === 'hostedTwin' ? copy.hostedTwin : copy.alsoLocal}
@@ -189,6 +191,22 @@ function CardLane({
)
}
+/** The connected account's name, or how many accounts the app has when there are several. */
+function AccountSummary({ card }: { card: ConnectorCardModel }) {
+ const { t } = useI18n()
+ const accounts = card.ways.hosted?.accounts ?? []
+ const summary = accounts.length > 1 ? t.connectorsPage.accounts.count(accounts.length) : accounts[0]?.alias
+
+ return summary ? (
+ <span
+ className="min-w-0 truncate text-[0.6875rem] text-(--ui-text-secondary)"
+ data-slot="connector-account-summary"
+ >
+ {summary}
+ </span>
+ ) : null
+}
+
function SecondLine({ card, reason }: { card: ConnectorCardModel; reason?: string }) {
if (reason) {
return <p className={cn('truncate text-[0.72rem]', REASON_TONE[card.state])}>{reason}</p>
diff --git a/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx b/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx
index 4716c36d8c7..10f510e6dfa 100644
--- a/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx
+++ b/apps/desktop/src/app/capabilities/connectors/connectors-tab.tsx
@@ -1,14 +1,13 @@
import { useStore } from '@nanostores/react'
-import { useEffect, useMemo, useState } from 'react'
+import { useCallback, useEffect, useMemo, useState } from 'react'
import { useLocation, useNavigate } from 'react-router'
import { Button } from '@/components/ui/button'
-import { ConfirmDialog } from '@/components/ui/confirm-dialog'
import type { HermesGateway, ProfileScope } from '@/hermes'
import { useI18n } from '@/i18n'
import { $freeTierStatus } from '@/store/free-tier'
import { openFreeTierSignIn } from '@/store/free-tier-sign-in'
-import { notifyError, readableError } from '@/store/notifications'
+import { notifyError } from '@/store/notifications'
import { installBundledEntry } from '../mcp/install-catalog-entry'
import { useMcpServers } from '../mcp/use-mcp-servers'
@@ -17,7 +16,7 @@ import { AddServerDialog } from './add-dialog'
import { ConnectorsDirectory } from './connectors-directory'
import { $abandonedConnects, $accountOperations, abandonConnect, accountOperationFor } from './data/account-operations'
import { joinBundledEntries, joinLocalServers, pickAccount } from './data/join'
-import { useConnectConnector, useConnectorSwitch, useDisconnectAccount } from './data/mutations'
+import { useConnectConnector, useConnectorSwitch, useDisconnectAccount, useRenameAccount } from './data/mutations'
import { seedLocalServers, startConnectorPersistence, storeLocalServers } from './data/persist'
import { prefetchConnectorTools, usePrefetchConnectedTools } from './data/prefetch'
import { useHostedConnectors, usePluginServers } from './data/queries'
@@ -29,11 +28,12 @@ import {
hostedCardKey,
localServerName
} from './derive'
+import { DisconnectConfirm, type Disconnecting } from './disconnect-confirm'
import { HostedConnectorDialog } from './hosted-dialog'
import { LocalConnectorDialog } from './local-dialog'
import { RemoveServerConfirm } from './local-slots'
import { openToolsList, resetOpenedTools } from './tools-summary'
-import type { ConnectorCardModel, ConnectorsFilter, HostedPhase } from './types'
+import type { AccountRow, ConnectorCardModel, ConnectorsFilter, HostedPhase } from './types'
const toolsListKey = (card: ConnectorCardModel) => (card.residency === 'local' ? localServerName(card) : card.slug)
@@ -55,12 +55,15 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {
const connector = useConnectConnector(profile)
const switcher = useConnectorSwitch(profile)
const remover = useDisconnectAccount(profile)
+ const renamer = useRenameAccount(profile)
const [filter, setFilter] = useState<ConnectorsFilter>(EMPTY_CONNECTORS_FILTER)
const [openKey, setOpenKey] = useState<null | string>(null)
const [addOpen, setAddOpen] = useState(false)
const [removeServer, setRemoveServer] = useState<null | ConnectorCardModel>(null)
- const [disconnecting, setDisconnecting] = useState<null | ConnectorCardModel>(null)
+ const [disconnecting, setDisconnecting] = useState<Disconnecting | null>(null)
+ const [pendingRename, setPendingRename] = useState<null | string>(null)
+ const renameOpened = useCallback(() => setPendingRename(null), [])
const [installing, setInstalling] = useState<null | string>(null)
const local = useMemo(
@@ -113,7 +116,7 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {
const openCard = useMemo(() => cards.find(card => cardKey(card) === openKey) ?? null, [cards, openKey])
- useOpenFromRoute(cards, setOpenKey)
+ useOpenFromRoute(cards, setOpenKey, setPendingRename)
const write = async (pending: Promise<{ error?: unknown; ok: boolean }>) => {
const outcome = await pending
@@ -123,19 +126,27 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {
}
}
- const startConnect = async (card: ConnectorCardModel, reconnect: boolean) => {
- const outcome = await connector.connect(card.slug, { reconnect })
+ const connectAccount = async (card: ConnectorCardModel, reconnect: boolean, alias?: string) => {
+ const outcome = await connector.connect(card.slug, { alias, reconnect })
- if (!outcome.ok) {
- notifyError(outcome.error, t.connectors.connectErrorFor(card.name))
+ if (outcome.ok) {
+ const url = outcome.operation.targets.find(target => target.connectUrl)?.connectUrl
- return
+ if (url) {
+ void window.hermesDesktop?.openExternal?.(url)
+ }
}
- const url = outcome.operation.targets.find(target => target.connectUrl)?.connectUrl
+ return outcome
+ }
+
+ const startConnect = async (card: ConnectorCardModel, reconnect: boolean, alias?: string) => {
+ const outcome = await connectAccount(card, reconnect, alias ?? reconnectAlias(reconnect, hosted.accounts, card))
- if (url) {
- void window.hermesDesktop?.openExternal?.(url)
+ if (!outcome.ok) {
+ notifyError(outcome.error, t.connectors.connectErrorFor(card.name))
+
+ return
}
setOpenKey(cardKey(card))
@@ -274,6 +285,19 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {
{openCard?.ways.hosted ? (
<HostedConnectorDialog
+ accountActions={{
+ add: async alias => {
+ const outcome = await connectAccount(openCard, false, alias)
+
+ return outcome.ok ? { ok: true } : outcome
+ },
+ pendingRename,
+ reconnect: (account: AccountRow) => void startConnect(openCard, true, account.alias ?? undefined),
+ reconnecting: connector.pending === openCard.slug,
+ remove: (account: AccountRow) => setDisconnecting({ account, card: openCard }),
+ rename: renamer.rename,
+ renameOpened
+ }}
card={openCard}
controller={mcp}
hosted={hosted}
@@ -281,7 +305,7 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {
installing={installing === cardKey(openCard)}
onClose={() => setOpenKey(null)}
onConnect={() => void startConnect(openCard, false)}
- onDisconnect={() => setDisconnecting(openCard)}
+ onDisconnect={() => setDisconnecting({ card: openCard })}
onGiveUp={opId => void write(connector.giveUp(opId))}
onInstall={env => void startInstall(openCard, env)}
onReconnect={() => void startConnect(openCard, true)}
@@ -302,38 +326,21 @@ export function ConnectorsTab({ gateway, profile }: ConnectorsTabProps) {
onRemoved={() => setOpenKey(null)}
/>
- <ConfirmDialog
- confirmLabel={copy.dialog.disconnect}
- description={copy.dialog.disconnectBody}
- destructive
+ <DisconnectConfirm
+ accounts={hosted.accounts}
+ disconnect={remover.disconnect}
onClose={() => setDisconnecting(null)}
- onConfirm={async () => {
- const card = disconnecting
- const account = card ? pickAccount(hosted.accounts, card.slug) : null
-
- if (!account) {
- throw new Error(copy.page.disconnectNoAccount)
- }
-
- const outcome = await remover.disconnect(account.connection_id)
-
- if (!outcome.ok) {
- throw new Error(
- outcome.error.reason === 'ACCOUNTS_UNAVAILABLE'
- ? copy.page.disconnectRefused
- : readableError(outcome.error, copy.page.writeFailed).message
- )
- }
-
- setOpenKey(null)
- }}
- open={disconnecting !== null}
- title={copy.dialog.disconnectTitle(disconnecting?.name ?? '')}
+ onDisconnected={() => setOpenKey(null)}
+ target={disconnecting}
/>
</div>
)
}
+// A reconnect names the account it repairs, so the gateway mints a replacement for that one and deletes nothing.
+const reconnectAlias = (reconnect: boolean, accounts: readonly AccountRow[], card: ConnectorCardModel) =>
+ reconnect ? (pickAccount(accounts, card.slug)?.alias ?? undefined) : undefined
+
function HostedNotice({ hasGuest, phase }: { hasGuest: boolean; phase: HostedPhase }) {
const { t } = useI18n()
const copy = t.connectorsPage.page
@@ -356,7 +363,11 @@ function HostedNotice({ hasGuest, phase }: { hasGuest: boolean; phase: HostedPha
return hasGuest ? <p className="shrink-0 text-[0.7rem] text-(--ui-text-tertiary)">{copy.freeTierNote}</p> : null
}
-function useOpenFromRoute(cards: readonly ConnectorCardModel[], open: (key: string) => void): void {
+function useOpenFromRoute(
+ cards: readonly ConnectorCardModel[],
+ open: (key: string) => void,
+ rename: (alias: string) => void
+): void {
const { hash, pathname, search } = useLocation()
const navigate = useNavigate()
@@ -381,12 +392,19 @@ function useOpenFromRoute(cards: readonly ConnectorCardModel[], open: (key: stri
openToolsList(toolsListKey(target))
}
+ const alias = params.get('rename')
+
+ if (alias) {
+ rename(alias)
+ }
+
open(cardKey(target))
params.delete('server')
params.delete('connector')
params.delete('tool')
+ params.delete('rename')
const query = params.toString()
navigate({ hash, pathname, search: query ? `?${query}` : '' }, { replace: true })
- }, [cards, hash, navigate, open, pathname, search])
+ }, [cards, hash, navigate, open, pathname, rename, search])
}
diff --git a/apps/desktop/src/app/capabilities/connectors/data/alias.ts b/apps/desktop/src/app/capabilities/connectors/data/alias.ts
new file mode 100644
index 00000000000..db72e568e03
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/connectors/data/alias.ts
@@ -0,0 +1,15 @@
+import type { AccountRow } from '../types'
+
+/** The gateway's account-name format (`ConnectorAlias` in the connector contracts). */
+const ACCOUNT_ALIAS = /^[a-z0-9][a-z0-9-]{0,31}$/
+
+export type AliasProblem = 'invalid' | 'taken'
+
+/** Why `alias` cannot name an account among `accounts`, or null when it can. `self` is the account being renamed. */
+export function aliasProblem(alias: string, accounts: readonly AccountRow[], self?: string): AliasProblem | null {
+ if (!ACCOUNT_ALIAS.test(alias)) {
+ return 'invalid'
+ }
+
+ return accounts.some(account => account.alias === alias && account.connection_id !== self) ? 'taken' : null
+}
diff --git a/apps/desktop/src/app/capabilities/connectors/data/deep-link.ts b/apps/desktop/src/app/capabilities/connectors/data/deep-link.ts
index 4c0fea1fcfb..7b5ce7f9265 100644
--- a/apps/desktop/src/app/capabilities/connectors/data/deep-link.ts
+++ b/apps/desktop/src/app/capabilities/connectors/data/deep-link.ts
@@ -6,6 +6,10 @@ import { wakeAccountOperation } from './rpc'
const connectorRoute = (slug: string): string =>
`${CAPABILITIES_ROUTE}?tab=connectors&connector=${encodeURIComponent(slug)}`
+/** The Connectors tab with one app's dialog open and the named account's rename editor open. */
+export const accountRenameRoute = (slug: string, alias: string): string =>
+ `${connectorRoute(slug)}&rename=${encodeURIComponent(alias)}`
+
export async function resumeAccountConnect(opId: string, navigate: (to: string) => void): Promise<boolean> {
const operation = $accountOperations.get()[opId]
diff --git a/apps/desktop/src/app/capabilities/connectors/data/join.test.ts b/apps/desktop/src/app/capabilities/connectors/data/join.test.ts
new file mode 100644
index 00000000000..20c2b3b67e5
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/connectors/data/join.test.ts
@@ -0,0 +1,65 @@
+import type { ConnectorCatalogRow } from '@hermes/shared'
+import { describe, expect, it } from 'vitest'
+
+import type { AccountRow } from '../types'
+
+import { EMPTY_POLICY, joinHostedConnectors } from './join'
+
+const GMAIL: ConnectorCatalogRow = { category: 'mail', description: 'Mail', name: 'Gmail', slug: 'gmail' }
+
+function account(overrides: Partial<AccountRow>): AccountRow {
+ return {
+ active: true,
+ alias: null,
+ connection_id: 'ca_1',
+ connector: 'gmail',
+ created_at: '2026-10-01T00:00:00Z',
+ label: 'Gmail account',
+ status: 'active',
+ updated_at: '2026-10-01T00:00:00Z',
+ ...overrides
+ }
+}
+
+const join = (accounts: AccountRow[]) =>
+ joinHostedConnectors({ accounts, catalog: [GMAIL], list: [], policy: EMPTY_POLICY })[0]
+
+describe('joinHostedConnectors with several accounts', () => {
+ it('keeps one row per account, the active one first, then the newest', () => {
+ const row = join([
+ account({ alias: 'home', connection_id: 'ca_home', created_at: '2026-10-01T00:00:00Z' }),
+ account({
+ active: false,
+ alias: 'old',
+ connection_id: 'ca_old',
+ status: 'expired',
+ created_at: '2026-10-09T00:00:00Z'
+ }),
+ account({ alias: 'work', connection_id: 'ca_work', created_at: '2026-10-05T00:00:00Z' })
+ ])
+
+ expect(row.accounts?.map(entry => entry.connection_id)).toEqual(['ca_work', 'ca_home', 'ca_old'])
+ })
+
+ it('names the summary by the account alias, falling back to the vendor label', () => {
+ expect(join([account({ alias: 'work' })]).accountLabel).toBe('work')
+ expect(join([account({ alias: null, label: '[email protected]' })]).accountLabel).toBe('[email protected]')
+ })
+
+ it('folds a retired account out of the list and the summary, and still reports it', () => {
+ const row = join([
+ account({ alias: 'work', connection_id: 'ca_new', created_at: '2026-10-01T00:00:00Z' }),
+ account({
+ active: false,
+ connection_id: 'ca_replaced',
+ created_at: '2026-10-09T00:00:00Z',
+ disabled: true,
+ status: 'inactive'
+ })
+ ])
+
+ expect(row.accounts?.map(entry => entry.connection_id)).toEqual(['ca_new'])
+ expect(row.retiredAccounts?.map(entry => entry.connection_id)).toEqual(['ca_replaced'])
+ expect(row.connectionStatus).toBe('active')
+ })
+})
diff --git a/apps/desktop/src/app/capabilities/connectors/data/join.ts b/apps/desktop/src/app/capabilities/connectors/data/join.ts
index b352339dd87..cd83dfbeb6a 100644
--- a/apps/desktop/src/app/capabilities/connectors/data/join.ts
+++ b/apps/desktop/src/app/capabilities/connectors/data/join.ts
@@ -16,6 +16,7 @@ import { type McpServers, serverEnabled } from '@/lib/mcp-servers'
import { canAuthenticate } from '../../mcp/mcp-status'
import { toolRows } from '../derive-tools'
import type {
+ AccountRow,
BundledEntryInput,
ConnectorAuthType,
HostedConnectorInput,
@@ -130,7 +131,7 @@ export function connectorToolRows(
}
export interface HostedJoinInput {
- accounts: readonly ConnectorAccountRow[]
+ accounts: readonly AccountRow[]
catalog: readonly ConnectorCatalogRow[]
list: readonly ConnectorListRow[]
policy: ConnectorPolicyView
@@ -140,11 +141,26 @@ export interface HostedJoinInput {
const text = (value: null | string | undefined): string | undefined =>
value !== null && value !== undefined && value.trim() !== '' ? value : undefined
-export function pickAccount(accounts: readonly ConnectorAccountRow[], slug: string): ConnectorAccountRow | undefined {
- const mine = accounts.filter(account => account.connector === slug)
- const rank = (account: ConnectorAccountRow) => (account.active ? 0 : 1)
+export const isRetired = (account: AccountRow): boolean => account.disabled === true
- return [...mine].sort((a, b) => rank(a) - rank(b) || b.created_at.localeCompare(a.created_at))[0]
+export const accountName = (account: ConnectorAccountRow): string => text(account.alias) ?? account.label
+
+const rank = (account: ConnectorAccountRow) => (account.active ? 0 : 1)
+
+/** One app's live accounts, active first, then newest. Retired accounts are left out. */
+export function accountsFor(accounts: readonly AccountRow[], slug: string): AccountRow[] {
+ return accounts
+ .filter(account => account.connector === slug && !isRetired(account))
+ .sort((a, b) => rank(a) - rank(b) || b.created_at.localeCompare(a.created_at))
+}
+
+export function retiredAccountsFor(accounts: readonly AccountRow[], slug: string): AccountRow[] {
+ return accounts.filter(account => account.connector === slug && isRetired(account))
+}
+
+/** The one account the app's summary speaks for. */
+export function pickAccount(accounts: readonly AccountRow[], slug: string): AccountRow | undefined {
+ return accountsFor(accounts, slug)[0]
}
export function connectorTitles(input: Pick<HostedJoinInput, 'catalog' | 'list'>) {
@@ -179,11 +195,13 @@ export function joinHostedConnectors({
return hostedSlugs({ catalog, list }).map(slug => {
const entry = catalog.find(row => row.slug === slug)
const row = list.find(candidate => candidate.connector === slug)
- const account = pickAccount(accounts, slug)
+ const mine = accountsFor(accounts, slug)
+ const account = mine[0]
const off = rulesReadable ? memberDisabledTools(policy, slug) : (row?.gateway_disabled_tools ?? [])
return {
- accountLabel: account?.label,
+ accountLabel: account ? accountName(account) : undefined,
+ accounts: mine,
connected: account !== undefined || row?.connected === true,
connectedAt: account?.created_at,
connectionStatus: account?.status ?? row?.connection_status ?? undefined,
@@ -192,6 +210,7 @@ export function joinHostedConnectors({
enabled: memberEnables(policy, slug) && row?.enabled !== false,
inCatalog: entry !== undefined,
orgLocked: orgLocks(policy, slug),
+ retiredAccounts: retiredAccountsFor(accounts, slug),
slug,
statusReason: text(account?.status_reason) ?? text(row?.status_reason),
toolsOff: off.length > 0 ? off.length : undefined
diff --git a/apps/desktop/src/app/capabilities/connectors/data/mutations.ts b/apps/desktop/src/app/capabilities/connectors/data/mutations.ts
index 343fa6a744d..1ee3ad8c8f6 100644
--- a/apps/desktop/src/app/capabilities/connectors/data/mutations.ts
+++ b/apps/desktop/src/app/capabilities/connectors/data/mutations.ts
@@ -1,4 +1,4 @@
-import type { ConnectionAnswer, ConnectorPolicyGetResult } from '@hermes/shared'
+import type { ConnectionAnswer, ConnectorAccountsResult, ConnectorPolicyGetResult } from '@hermes/shared'
import { useCallback, useRef, useState } from 'react'
import type { ProfileScope } from '@/hermes'
@@ -16,7 +16,7 @@ import {
startAccountOperation
} from './account-operations'
import { memberDisabledTools, memberRevision, readPolicy } from './join'
-import { connectorsPolicyQueryKey, invalidateConnectors } from './keys'
+import { connectorsAccountsQueryKey, connectorsPolicyQueryKey, invalidateConnectors } from './keys'
import {
asConnectorError,
connectAccountConnectors,
@@ -24,6 +24,7 @@ import {
type ConnectorRpcError,
isConnectorReason,
removeConnectorAccount,
+ renameConnectorAccount,
respondToAccountOperation,
setConnectorPolicy
} from './rpc'
@@ -183,10 +184,69 @@ export function useDisconnectAccount(scope: ProfileScope): AccountDisconnect {
return { disconnect, pending }
}
+export interface AccountRename {
+ pending: null | string
+ rename: (connectionId: string, alias: string) => Promise<WriteOutcome>
+}
+
+function writeAlias(scope: ProfileScope, connectionId: string, alias: null | string | undefined): void {
+ queryClient.setQueryData<ConnectorAccountsResult>(connectorsAccountsQueryKey(scope), data =>
+ data
+ ? {
+ ...data,
+ accounts: data.accounts.map(row => (row.connection_id === connectionId ? { ...row, alias } : row))
+ }
+ : data
+ )
+}
+
+/** Paints the new name in the accounts cache at once; the RPC answer reconciles it, a refusal restores the old one. */
+export function useRenameAccount(scope: ProfileScope): AccountRename {
+ const [pending, setPending] = useState<null | string>(null)
+
+ const rename = useCallback(
+ async (connectionId: string, alias: string): Promise<WriteOutcome> => {
+ const key = connectorsAccountsQueryKey(scope)
+
+ const before = queryClient
+ .getQueryData<ConnectorAccountsResult>(key)
+ ?.accounts.find(row => row.connection_id === connectionId)
+
+ setPending(connectionId)
+ await queryClient.cancelQueries({ queryKey: key })
+ writeAlias(scope, connectionId, alias)
+
+ try {
+ const row = await renameConnectorAccount(scope, connectionId, alias)
+
+ writeAlias(scope, connectionId, row.alias)
+
+ return { ok: true }
+ } catch (error) {
+ writeAlias(scope, connectionId, before?.alias)
+
+ return failed(asConnectorError(error))
+ } finally {
+ setPending(null)
+ invalidateConnectors(scope, 'accounts')
+ }
+ },
+ [scope]
+ )
+
+ return { pending, rename }
+}
+
export type ConnectOutcome = { error: ConnectorRpcError; ok: false } | { ok: true; operation: AccountOperation }
+export interface ConnectOptions {
+ /** The account's name: a new account takes it; with `reconnect`, only that account is repaired. */
+ alias?: string
+ reconnect?: boolean
+}
+
export interface ConnectorConnect {
- connect: (slug: string, options?: { reconnect?: boolean }) => Promise<ConnectOutcome>
+ connect: (slug: string, options?: ConnectOptions) => Promise<ConnectOutcome>
giveUp: (opId: string) => Promise<WriteOutcome>
pending: null | string
}
@@ -195,11 +255,11 @@ export function useConnectConnector(scope: ProfileScope): ConnectorConnect {
const [pending, setPending] = useState<null | string>(null)
const connect = useCallback(
- async (slug: string, options?: { reconnect?: boolean }): Promise<ConnectOutcome> => {
+ async (slug: string, options?: ConnectOptions): Promise<ConnectOutcome> => {
setPending(slug)
try {
- const snapshot = await connectAccountConnectors(scope, [slug], options?.reconnect ?? false)
+ const snapshot = await connectAccountConnectors(scope, [slug], options?.reconnect ?? false, options?.alias)
return { ok: true, operation: startAccountOperation(scope, [slug], snapshot) }
} catch (error) {
diff --git a/apps/desktop/src/app/capabilities/connectors/data/rpc.ts b/apps/desktop/src/app/capabilities/connectors/data/rpc.ts
index cf6bddcae6b..c1f50f5a34f 100644
--- a/apps/desktop/src/app/capabilities/connectors/data/rpc.ts
+++ b/apps/desktop/src/app/capabilities/connectors/data/rpc.ts
@@ -135,8 +135,27 @@ export const setConnectorPolicy = (
export const removeConnectorAccount = (scope: ProfileScope, connectionId: string) =>
call(scope, 'connectors.accounts.remove', { connection_id: connectionId }, 'foreground')
-export const connectAccountConnectors = (scope: ProfileScope, connectors: readonly string[], reconnect = false) =>
- call(scope, 'connectors.connect', { connectors: [...connectors], owner: ACCOUNT_OWNER, reconnect }, 'foreground')
+export const renameConnectorAccount = (scope: ProfileScope, connectionId: string, alias: string) =>
+ call(scope, 'connectors.accounts.rename', { alias, connection_id: connectionId }, 'foreground')
+
+export function connectAccountConnectors(
+ scope: ProfileScope,
+ connectors: readonly string[],
+ reconnect = false,
+ alias?: string
+) {
+ const params: RpcMethods['connectors.connect']['params'] = {
+ connectors: [...connectors],
+ owner: ACCOUNT_OWNER,
+ reconnect
+ }
+
+ if (alias) {
+ params.alias = alias
+ }
+
+ return call(scope, 'connectors.connect', params, 'foreground')
+}
export const wakeAccountOperation = (scope: ProfileScope, opId: string) =>
call(scope, 'connectors.operation.wake', { op_id: opId, owner: ACCOUNT_OWNER }, 'foreground')
diff --git a/apps/desktop/src/app/capabilities/connectors/derive.ts b/apps/desktop/src/app/capabilities/connectors/derive.ts
index fda8afb9499..c2f357c8693 100644
--- a/apps/desktop/src/app/capabilities/connectors/derive.ts
+++ b/apps/desktop/src/app/capabilities/connectors/derive.ts
@@ -78,9 +78,11 @@ const LOCAL_WORDS = {
export function hostedWay(row: HostedConnectorInput): ConnectorWayHosted {
const base = {
accountLabel: row.accountLabel,
+ accounts: row.accounts ?? [],
connected: row.connected,
connectedAt: row.connectedAt,
- disabledTools: row.disabledTools
+ disabledTools: row.disabledTools,
+ retiredAccounts: row.retiredAccounts ?? []
}
if (row.orgLocked) {
@@ -252,7 +254,14 @@ export function forgetAbandoned(
): HostedConnectorInput[] {
return rows.map(row =>
abandoned.has(row.slug) && row.connectionStatus === 'pending'
- ? { ...row, accountLabel: undefined, connected: false, connectedAt: undefined, connectionStatus: undefined }
+ ? {
+ ...row,
+ accountLabel: undefined,
+ accounts: row.accounts?.filter(account => account.status !== 'pending'),
+ connected: false,
+ connectedAt: undefined,
+ connectionStatus: undefined
+ }
: row
)
}
diff --git a/apps/desktop/src/app/capabilities/connectors/disconnect-confirm.tsx b/apps/desktop/src/app/capabilities/connectors/disconnect-confirm.tsx
new file mode 100644
index 00000000000..0e7cb4f828b
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/connectors/disconnect-confirm.tsx
@@ -0,0 +1,64 @@
+import { ConfirmDialog } from '@/components/ui/confirm-dialog'
+import { useI18n } from '@/i18n'
+import { readableError } from '@/store/notifications'
+
+import { accountName, pickAccount } from './data/join'
+import type { WriteOutcome } from './data/mutations'
+import type { AccountRow, ConnectorCardModel } from './types'
+
+/** A remove scoped to one account, or the app-level disconnect of the account its summary speaks for. */
+export interface Disconnecting {
+ account?: AccountRow
+ card: ConnectorCardModel
+}
+
+export interface DisconnectConfirmProps {
+ accounts: readonly AccountRow[]
+ disconnect: (connectionId: string) => Promise<WriteOutcome>
+ onClose: () => void
+ /** The app-level disconnect finished; a one-account remove keeps the dialog open on the other accounts. */
+ onDisconnected: () => void
+ target: Disconnecting | null
+}
+
+export function DisconnectConfirm({ accounts, disconnect, onClose, onDisconnected, target }: DisconnectConfirmProps) {
+ const { t } = useI18n()
+ const copy = t.connectorsPage
+ const scoped = target?.account
+
+ return (
+ <ConfirmDialog
+ confirmLabel={scoped ? copy.accounts.remove : copy.dialog.disconnect}
+ description={scoped ? copy.accounts.removeBody : copy.dialog.disconnectBody}
+ destructive
+ onClose={onClose}
+ onConfirm={async () => {
+ const account = target ? (target.account ?? pickAccount(accounts, target.card.slug)) : undefined
+
+ if (!account) {
+ throw new Error(copy.page.disconnectNoAccount)
+ }
+
+ const outcome = await disconnect(account.connection_id)
+
+ if (!outcome.ok) {
+ throw new Error(
+ outcome.error.reason === 'ACCOUNTS_UNAVAILABLE'
+ ? copy.page.disconnectRefused
+ : readableError(outcome.error, copy.page.writeFailed).message
+ )
+ }
+
+ if (!scoped) {
+ onDisconnected()
+ }
+ }}
+ open={target !== null}
+ title={
+ scoped && target
+ ? copy.accounts.removeTitle(target.card.name, accountName(scoped))
+ : copy.dialog.disconnectTitle(target?.card.name ?? '')
+ }
+ />
+ )
+}
diff --git a/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsx b/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsx
index ad4249cc0a0..a1099ae7a7e 100644
--- a/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsx
+++ b/apps/desktop/src/app/capabilities/connectors/hosted-dialog.tsx
@@ -6,6 +6,7 @@ import { openFreeTierSignIn } from '@/store/free-tier-sign-in'
import type { McpServersController } from '../mcp/use-mcp-servers'
+import { type AccountEdit, AccountsSection } from './accounts-section'
import { ConnectElement } from './connect-element'
import { ConnectorDialog } from './connector-dialog'
import {
@@ -14,6 +15,7 @@ import {
accountOperationFor,
clearAccountOperation
} from './data/account-operations'
+import type { WriteOutcome } from './data/mutations'
import { openConnectorsAdmin } from './data/portal'
import { type HostedConnectorsView, useConnectorTools } from './data/queries'
import { localServerName } from './derive'
@@ -22,10 +24,11 @@ import { localCost } from './local-dialog'
import type { InstallField } from './local-server-control'
import { LocalAdvanced } from './local-slots'
import { HostedToolsPanel, LocalToolsPanel, orgDisabledCount } from './tools-panel'
-import type { ConnectorCardModel } from './types'
+import type { AccountRow, ConnectorCardModel } from './types'
import { type WayChoice, wayInUse } from './ways-section'
export interface HostedConnectorDialogProps {
+ accountActions: HostedAccountActions
card: ConnectorCardModel
controller: McpServersController
hosted: HostedConnectorsView
@@ -44,7 +47,19 @@ export interface HostedConnectorDialogProps {
togglePending: boolean
}
+export interface HostedAccountActions {
+ add: (alias: string) => Promise<WriteOutcome>
+ /** An account name a deep link asked to rename; the dialog opens its editor once the account is listed. */
+ pendingRename: null | string
+ reconnect: (account: AccountRow) => void
+ reconnecting: boolean
+ remove: (account: AccountRow) => void
+ rename: (connectionId: string, alias: string) => Promise<WriteOutcome>
+ renameOpened: () => void
+}
+
export function HostedConnectorDialog({
+ accountActions,
card,
controller,
hosted,
@@ -73,6 +88,19 @@ export function HostedConnectorDialog({
}
}, [inUse])
+ const [edit, setEdit] = useState<AccountEdit | null>(null)
+ const accounts = card.ways.hosted?.accounts ?? []
+ const retired = card.ways.hosted?.retiredAccounts ?? []
+ const { pendingRename, renameOpened } = accountActions
+ const renameTarget = pendingRename === null ? undefined : accounts.find(row => row.alias === pendingRename)
+
+ useEffect(() => {
+ if (renameTarget) {
+ setEdit({ connectionId: renameTarget.connection_id, kind: 'rename' })
+ renameOpened()
+ }
+ }, [renameOpened, renameTarget])
+
const local = card.ways.local
const serverName = localServerName(card)
const installed = local?.installed === true && card.plugin === undefined
@@ -98,6 +126,19 @@ export function HostedConnectorDialog({
return (
<ConnectorDialog
+ accounts={
+ <AccountsSection
+ accounts={accounts}
+ edit={edit}
+ onAdd={accountActions.add}
+ onEditChange={setEdit}
+ onReconnect={accountActions.reconnect}
+ onRemove={accountActions.remove}
+ onRename={accountActions.rename}
+ reconnecting={accountActions.reconnecting}
+ retired={retired}
+ />
+ }
advanced={
installed ? <LocalAdvanced controller={controller} name={serverName} onRemove={onRemoveServer} /> : undefined
}
@@ -108,14 +149,23 @@ export function HostedConnectorDialog({
installing={installing}
menu={
<ConnectorDialogMenu
- onDisconnect={card.ways.hosted?.connected === true ? onDisconnect : undefined}
- onReconnect={onReconnect}
+ onDisconnect={card.ways.hosted?.connected === true && accounts.length === 0 ? onDisconnect : undefined}
+ onReconnect={menuReconnect(accounts, onReconnect, accountActions.reconnect)}
onRefreshTools={tools.refresh}
/>
}
onAuthenticate={() => void controller.authenticate(localServerName(card))}
onConnect={onConnect}
onDisconnect={onDisconnect}
+ onEscape={() => {
+ if (edit === null) {
+ return false
+ }
+
+ setEdit(null)
+
+ return true
+ }}
onInstall={onInstall}
onOpenAdmin={() => void openConnectorsAdmin()}
onOpenChange={next => {
@@ -151,3 +201,18 @@ export function HostedConnectorDialog({
function stillOpen(operation: AccountOperation | null): operation is AccountOperation {
return operation !== null && (!operation.settled || !operation.targets.every(target => target.state === 'connected'))
}
+
+/** The menu's Reconnect speaks for the app only while it has one account; with several, each row has its own. */
+function menuReconnect(
+ accounts: readonly AccountRow[],
+ reconnectApp: () => void,
+ reconnectAccount: (account: AccountRow) => void
+): (() => void) | undefined {
+ if (accounts.length > 1) {
+ return undefined
+ }
+
+ const only = accounts[0]
+
+ return only ? () => reconnectAccount(only) : reconnectApp
+}
diff --git a/apps/desktop/src/app/capabilities/connectors/types.ts b/apps/desktop/src/app/capabilities/connectors/types.ts
index 3eaeaaff3b7..f85b2a494f7 100644
--- a/apps/desktop/src/app/capabilities/connectors/types.ts
+++ b/apps/desktop/src/app/capabilities/connectors/types.ts
@@ -1,9 +1,18 @@
+import type { ConnectorAccountRow } from '@hermes/shared'
+
export type ConnectorResidency = 'hosted' | 'local'
export type LocalServerStatus = 'error' | 'needs-auth' | 'off' | 'ok' | 'probing' | 'unknown'
+/** The account rows a newer gateway sends; `disabled` marks an account a reconnect replaced. */
+export interface AccountRow extends ConnectorAccountRow {
+ disabled?: boolean | null
+}
+
export interface HostedConnectorInput {
accountLabel?: string
+ /** The app's live accounts, active first, then newest. */
+ accounts?: readonly AccountRow[]
connected: boolean
connectedAt?: string
connectionStatus?: string
@@ -12,6 +21,8 @@ export interface HostedConnectorInput {
enabled: boolean
inCatalog?: boolean
orgLocked?: boolean
+ /** Accounts a reconnect replaced: listed, never counted, never offered for reconnect. */
+ retiredAccounts?: readonly AccountRow[]
slug: string
statusReason?: string
toolsOff?: number
@@ -91,12 +102,14 @@ export type ConnectorVerb =
export interface ConnectorWayHosted {
accountLabel?: string
+ accounts: readonly AccountRow[]
connected: boolean
connectedAt?: string
disabledTools?: readonly string[]
fact?: ConnectorFact
offBy?: ConnectorOffBy
reason?: ConnectorReason
+ retiredAccounts: readonly AccountRow[]
state: ConnectorState
verb?: ConnectorVerb
}
diff --git a/apps/desktop/src/components/assistant-ui/connector-tool.test.tsx b/apps/desktop/src/components/assistant-ui/connector-tool.test.tsx
index 086e50dcf42..59b649dc608 100644
--- a/apps/desktop/src/components/assistant-ui/connector-tool.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/connector-tool.test.tsx
@@ -1,6 +1,7 @@
import type { ToolCallMessagePartProps } from '@assistant-ui/react'
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { atom } from 'nanostores'
+import { MemoryRouter, Route, Routes, useLocation } from 'react-router'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { type SessionView, SessionViewProvider } from '@/app/chat/session-view'
@@ -119,6 +120,36 @@ afterEach(() => {
vi.clearAllMocks()
})
+function Where() {
+ const { pathname, search } = useLocation()
+
+ return <output data-testid="where">{`${pathname}${search}`}</output>
+}
+
+describe('ConnectorOffer named-account notice', () => {
+ it('says which name Hermes chose once the account connected, and Rename opens that account on the Connectors tab', () => {
+ const request = { ...REQUEST, settled: true, targets: [{ ...GMAIL, alias: 'work', state: 'connected' as const }] }
+
+ setConnectionRequest(request)
+ render(
+ <I18nProvider configClient={null} initialLocale="en">
+ <MemoryRouter initialEntries={['/chat']}>
+ <Routes>
+ <Route element={<ConnectorOffer owner={PRIMARY_OWNER} request={request} />} path="/chat" />
+ <Route element={<Where />} path="*" />
+ </Routes>
+ </MemoryRouter>
+ </I18nProvider>
+ )
+
+ expect(screen.getAllByText('Hermes named this Gmail account work.')).toHaveLength(1)
+
+ fireEvent.click(screen.getByRole('button', { name: 'Rename' }))
+
+ expect(screen.getByTestId('where').textContent).toBe('/capabilities?tab=connectors&connector=gmail&rename=work')
+ })
+})
+
describe('ConnectorTool operation card', () => {
it('offers one verb per row and Continue below; nothing per row says no', () => {
renderOffer({
diff --git a/apps/desktop/src/components/assistant-ui/connector-tool.tsx b/apps/desktop/src/components/assistant-ui/connector-tool.tsx
index d174ab2364a..91c0f351555 100644
--- a/apps/desktop/src/components/assistant-ui/connector-tool.tsx
+++ b/apps/desktop/src/components/assistant-ui/connector-tool.tsx
@@ -2,7 +2,9 @@ import type { ToolCallMessagePartProps } from '@assistant-ui/react'
import type { ConnectionTargetState, ConnectorsConnectResult } from '@hermes/shared'
import { useStore } from '@nanostores/react'
import { type RefObject, useEffect, useMemo, useRef, useState } from 'react'
+import { useInRouterContext, useNavigate } from 'react-router'
+import { accountRenameRoute } from '@/app/capabilities/connectors/data/deep-link'
import { useSessionView } from '@/app/chat/session-view'
import { sessionRoute } from '@/app/routes'
import { ToolFallback } from '@/components/assistant-ui/tool/fallback'
@@ -327,6 +329,7 @@ export function ConnectorOffer({ owner, request }: ConnectorOfferProps) {
/>
)
})}
+ <NamedAccountNotices targets={request.targets} />
</div>
)
}
@@ -375,6 +378,7 @@ export function ConnectorOffer({ owner, request }: ConnectorOfferProps) {
)
})}
</ConnectorCard>
+ <NamedAccountNotices targets={request.targets} />
{unresolved ? (
<div className="px-3.5">
<Button onClick={() => void continueConnectionRequest(request)} size="xs" variant="textStrong">
@@ -386,6 +390,47 @@ export function ConnectorOffer({ owner, request }: ConnectorOfferProps) {
)
}
+/** One line per account Hermes named and connected; Rename opens that account's editor on the Connectors tab. */
+function NamedAccountNotices({ targets }: { targets: readonly ConnectionTarget[] }) {
+ const named = targets.filter(target => target.state === 'connected' && target.alias)
+
+ if (named.length === 0) {
+ return null
+ }
+
+ return (
+ <div className="grid gap-1 px-3.5" data-slot="connector-named-account">
+ {named.map(target => (
+ <NamedAccountNotice alias={target.alias ?? ''} key={target.name} name={target.name} />
+ ))}
+ </div>
+ )
+}
+
+function NamedAccountNotice({ alias, name }: { alias: string; name: string }) {
+ const { t } = useI18n()
+ const inRouter = useInRouterContext()
+
+ return (
+ <p className="flex flex-wrap items-center gap-x-1.5 text-[length:var(--conversation-caption-font-size)] text-(--ui-text-secondary)">
+ {t.connectors.namedAccount(connectorTitle(name), alias)}
+ {inRouter ? <RenameAccountLink alias={alias} name={name} /> : null}
+ </p>
+ )
+}
+
+// useNavigate() throws outside a Router; the parent mounts this only inside one.
+function RenameAccountLink({ alias, name }: { alias: string; name: string }) {
+ const { t } = useI18n()
+ const navigate = useNavigate()
+
+ return (
+ <Button onClick={() => navigate(accountRenameRoute(name, alias))} size="inline" variant="textStrong">
+ {t.connectors.renameAccount}
+ </Button>
+ )
+}
+
const MISSING_CALL_RESULT = { error: 'No result for this call.' }
/** Keep execution output in the standard disclosure, with one row per inner call.
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index d8525d8c1c5..bd3959fb7ad 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -45,7 +45,9 @@ export const deOverrides = {
openInBrowser: 'Im Browser öffnen',
setupCancel: 'Abbrechen',
authorizedToolsUnavailable: 'Autorisiert. Tools nicht verfügbar.',
- required: 'Erforderlich'
+ required: 'Erforderlich',
+ namedAccount: (app: string, alias: string) => `Hermes hat dieses ${app}-Konto ${alias} genannt.`,
+ renameAccount: 'Umbenennen'
},
connectorsPage: {
title: 'Konnektoren',
@@ -203,6 +205,32 @@ export const deOverrides = {
advanced: 'Erweitert',
advancedHint: 'der mcp.json-Eintrag und die Logs'
},
+
+ accounts: {
+ heading: 'Konten',
+ count: (count: number) => `${count} ${count === 1 ? 'Konto' : 'Konten'}`,
+ addAnother: 'Weiteres Konto hinzufügen',
+ aliasLabel: 'Kontoname',
+ aliasHint: 'Kleinbuchstaben, Ziffern und Bindestriche, höchstens 32. Zum Beispiel arbeit oder privat.',
+ aliasInvalid:
+ 'Verwenden Sie Kleinbuchstaben, Ziffern und Bindestriche, beginnend mit einem Buchstaben oder einer Ziffer.',
+ aliasTaken: 'Dieser Name wird bereits verwendet.',
+ add: 'Verbinden',
+ rename: 'Umbenennen',
+ renameLabel: (name: string) => `Neuer Name für ${name}`,
+ remove: 'Entfernen',
+ removeTitle: (app: string, name: string) => `Das ${app}-Konto ${name} entfernen?`,
+ removeBody: 'Hermes handelt nicht mehr über dieses Konto. Ihre anderen Konten bleiben verbunden.',
+ retiredCount: (count: number) => `${count} ersetzt`,
+ status: {
+ expired: 'Zugriff abgelaufen',
+ failed: 'Verbindung fehlgeschlagen',
+ inactive: 'Inaktiv',
+ pending: 'Wartet auf Anmeldung',
+ retired: 'Durch erneutes Verbinden ersetzt',
+ revoked: 'Zugriff widerrufen'
+ }
+ },
tools: {
title: 'Tools',
notInstalledBody: 'Installieren Sie ihn auf diesem Gerät, um seine Tools zu sehen.',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 5d47bb45c78..4360e46d613 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -60,7 +60,9 @@ export const en: Translations = {
openInBrowser: 'Open in browser',
setupCancel: 'Cancel',
authorizedToolsUnavailable: 'Authorized. Tools unavailable.',
- required: 'Required'
+ required: 'Required',
+ namedAccount: (app: string, alias: string) => `Hermes named this ${app} account ${alias}.`,
+ renameAccount: 'Rename'
},
// `connectors.*` above stays the onboarding and chat vocabulary; these are the page's own, and the two are not shared.
@@ -227,6 +229,31 @@ export const en: Translations = {
advancedHint: 'the mcp.json entry and logs'
},
+ accounts: {
+ heading: 'Accounts',
+ count: (count: number) => `${count} account${count === 1 ? '' : 's'}`,
+ addAnother: 'Add another account',
+ aliasLabel: 'Account name',
+ aliasHint: 'Lowercase letters, numbers and dashes, up to 32. For example work or home.',
+ aliasInvalid: 'Use lowercase letters, numbers and dashes, starting with a letter or number.',
+ aliasTaken: 'That name is already used.',
+ add: 'Connect',
+ rename: 'Rename',
+ renameLabel: (name: string) => `New name for ${name}`,
+ remove: 'Remove',
+ removeTitle: (app: string, name: string) => `Remove the ${name} ${app} account?`,
+ removeBody: 'Hermes stops acting as this account. Your other accounts stay connected.',
+ retiredCount: (count: number) => `${count} retired`,
+ status: {
+ expired: 'Access expired',
+ failed: 'Could not connect',
+ inactive: 'Inactive',
+ pending: 'Waiting for sign-in',
+ retired: 'Replaced by a reconnect',
+ revoked: 'Access revoked'
+ }
+ },
+
tools: {
title: 'Tools',
notInstalledBody: 'Install it on this device to see the tools it brings.',
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index f790ecdfed7..4bc1016483d 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -45,7 +45,9 @@ export const esOverrides = {
openInBrowser: 'Abrir en el navegador',
setupCancel: 'Cancelar',
authorizedToolsUnavailable: 'Autorizado. Herramientas no disponibles.',
- required: 'Obligatorio'
+ required: 'Obligatorio',
+ namedAccount: (app: string, alias: string) => `Hermes llamó ${alias} a esta cuenta de ${app}.`,
+ renameAccount: 'Cambiar nombre'
},
connectorsPage: {
title: 'Conectores',
@@ -203,6 +205,31 @@ export const esOverrides = {
advanced: 'Avanzado',
advancedHint: 'la entrada de mcp.json y los registros'
},
+
+ accounts: {
+ heading: 'Cuentas',
+ count: (count: number) => `${count} cuenta${count === 1 ? '' : 's'}`,
+ addAnother: 'Añadir otra cuenta',
+ aliasLabel: 'Nombre de la cuenta',
+ aliasHint: 'Minúsculas, números y guiones, hasta 32. Por ejemplo trabajo o casa.',
+ aliasInvalid: 'Usa minúsculas, números y guiones, empezando por una letra o un número.',
+ aliasTaken: 'Ese nombre ya está en uso.',
+ add: 'Conectar',
+ rename: 'Cambiar nombre',
+ renameLabel: (name: string) => `Nuevo nombre para ${name}`,
+ remove: 'Quitar',
+ removeTitle: (app: string, name: string) => `¿Quitar la cuenta ${name} de ${app}?`,
+ removeBody: 'Hermes deja de actuar con esta cuenta. Tus otras cuentas siguen conectadas.',
+ retiredCount: (count: number) => `${count} retirada${count === 1 ? '' : 's'}`,
+ status: {
+ expired: 'Acceso caducado',
+ failed: 'No se pudo conectar',
+ inactive: 'Inactiva',
+ pending: 'Esperando el inicio de sesión',
+ retired: 'Sustituida al reconectar',
+ revoked: 'Acceso revocado'
+ }
+ },
tools: {
title: 'Herramientas',
notInstalledBody: 'Instálalo en este dispositivo para ver las herramientas que incluye.',
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index b9f7914cc56..994e44b4f99 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -45,7 +45,9 @@ export const frOverrides = {
openInBrowser: 'Ouvrir dans le navigateur',
setupCancel: 'Annuler',
authorizedToolsUnavailable: 'Autorisé. Outils indisponibles.',
- required: 'Obligatoire'
+ required: 'Obligatoire',
+ namedAccount: (app: string, alias: string) => `Hermes a nommé ce compte ${app} ${alias}.`,
+ renameAccount: 'Renommer'
},
connectorsPage: {
title: 'Connecteurs',
@@ -203,6 +205,32 @@ export const frOverrides = {
advanced: 'Avancé',
advancedHint: "l'entrée mcp.json et les journaux"
},
+
+ accounts: {
+ heading: 'Comptes',
+ count: (count: number) => `${count} compte${count === 1 ? '' : 's'}`,
+ addAnother: 'Ajouter un autre compte',
+ aliasLabel: 'Nom du compte',
+ aliasHint: 'Lettres minuscules, chiffres et tirets, 32 au plus. Par exemple travail ou maison.',
+ aliasInvalid:
+ 'Utilisez des lettres minuscules, des chiffres et des tirets, en commençant par une lettre ou un chiffre.',
+ aliasTaken: 'Ce nom est déjà utilisé.',
+ add: 'Connecter',
+ rename: 'Renommer',
+ renameLabel: (name: string) => `Nouveau nom pour ${name}`,
+ remove: 'Retirer',
+ removeTitle: (app: string, name: string) => `Retirer le compte ${app} ${name} ?`,
+ removeBody: "Hermes cesse d'agir avec ce compte. Vos autres comptes restent connectés.",
+ retiredCount: (count: number) => `${count} retiré${count === 1 ? '' : 's'}`,
+ status: {
+ expired: 'Accès expiré',
+ failed: 'Connexion impossible',
+ inactive: 'Inactif',
+ pending: 'En attente de connexion',
+ retired: 'Remplacé par une reconnexion',
+ revoked: 'Accès révoqué'
+ }
+ },
tools: {
title: 'Outils',
notInstalledBody: "Installez-le sur cet appareil pour voir les outils qu'il apporte.",
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index d789f91afd4..12ab238e34e 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -124,6 +124,8 @@ export interface Translations extends NoticeTranslations {
setupCancel: string
authorizedToolsUnavailable: string
required: string
+ namedAccount: (app: string, alias: string) => string
+ renameAccount: string
}
connectorsPage: {
title: string
@@ -278,6 +280,30 @@ export interface Translations extends NoticeTranslations {
advanced: string
advancedHint: string
}
+ accounts: {
+ heading: string
+ count: (count: number) => string
+ addAnother: string
+ aliasLabel: string
+ aliasHint: string
+ aliasInvalid: string
+ aliasTaken: string
+ add: string
+ rename: string
+ renameLabel: (name: string) => string
+ remove: string
+ removeTitle: (app: string, name: string) => string
+ removeBody: string
+ retiredCount: (count: number) => string
+ status: {
+ expired: string
+ failed: string
+ inactive: string
+ pending: string
+ retired: string
+ revoked: string
+ }
+ }
tools: {
title: string
notInstalledBody: string
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index b6aab686e08..9ee6c2281e0 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -49,7 +49,9 @@ export const zhOverrides = {
openInBrowser: '在浏览器中打开',
setupCancel: '取消',
authorizedToolsUnavailable: '已授权。工具不可用。',
- required: '必填'
+ required: '必填',
+ namedAccount: (app, alias) => `Hermes 已将这个 ${app} 账户命名为 ${alias}。`,
+ renameAccount: '重命名'
},
sessionImport: {
title: '从其他应用继续',
diff --git a/apps/desktop/src/store/connection-request.ts b/apps/desktop/src/store/connection-request.ts
index b67b7ad9339..e397cb0af90 100644
--- a/apps/desktop/src/store/connection-request.ts
+++ b/apps/desktop/src/store/connection-request.ts
@@ -90,6 +90,8 @@ export interface ConnectionTarget {
connectUrl: null | string
/** The vendor account of a managed target once a mint named one; empty before that and on MCP targets. */
connectionId: string
+ /** The account name a managed target connects under; absent when the account has none. */
+ alias?: null | string
/** Toolkit metadata on connector targets; empty on an MCP target. */
tools: string[]
/** Credentials an MCP install is still waiting for; empty on every other target. */
@@ -255,6 +257,7 @@ export function parseConnectionTarget(entry: ConnectionOperationTarget): Connect
state: targetState(entry.state) ?? 'pending',
tools: entry.tools ?? [],
connectionId: entry.connection_id ?? '',
+ alias: entry.alias ?? null,
requiredEnv: envFields(entry.required_env),
instructions: entry.instructions ?? null,
discoveryError: entry.discovery_error ?? null
@@ -334,26 +337,28 @@ function mergeLiveTarget(target: ConnectionTarget, live: ConnectionOperationTarg
state: live.state,
tools: live.tools ?? target.tools,
connectionId: live.connection_id ?? target.connectionId,
+ alias: live.alias === undefined ? target.alias : live.alias,
requiredEnv: live.required_env ? envFields(live.required_env) : target.requiredEnv,
instructions: live.instructions === undefined ? target.instructions : live.instructions,
discoveryError: live.discovery_error === undefined ? target.discoveryError : live.discovery_error
}
- const same =
- next.catalog === target.catalog &&
- next.connectUrl === target.connectUrl &&
- next.connectionId === target.connectionId &&
- next.detail === target.detail &&
- next.instructions === target.instructions &&
- next.discoveryError === target.discoveryError &&
- next.state === target.state &&
- next.tools.length === target.tools.length &&
- next.tools.every((tool, index) => tool === target.tools[index]) &&
- sameEnvFields(next.requiredEnv, target.requiredEnv)
-
- return same ? target : next
+ return sameTarget(next, target) ? target : next
}
+const sameTarget = (next: ConnectionTarget, target: ConnectionTarget): boolean =>
+ next.catalog === target.catalog &&
+ next.connectUrl === target.connectUrl &&
+ next.connectionId === target.connectionId &&
+ next.alias === target.alias &&
+ next.detail === target.detail &&
+ next.instructions === target.instructions &&
+ next.discoveryError === target.discoveryError &&
+ next.state === target.state &&
+ next.tools.length === target.tools.length &&
+ next.tools.every((tool, index) => tool === target.tools[index]) &&
+ sameEnvFields(next.requiredEnv, target.requiredEnv)
+
// Every frame carries a fresh array, so identity would churn the row and remount its open inputs.
const sameEnvFields = (next: SetupField[], previous: SetupField[]): boolean =>
next.length === previous.length &&