fix(agent-api-keys): design-squad copy for A5 (older copy, one-line account failure, this computer, → paths)

This commit is contained in:
Neil
2026-11-10 07:03:14 -08:00
parent 94aaaf4ccf
commit 36aef5fe87
7 changed files with 81 additions and 80 deletions
@@ -35,8 +35,35 @@ export function AgentApiKeyCloudLine({
await onSaveToAccount()
setSaving(false)
}
// A failed account write replaces the status line: one line says what happened and offers retry.
if (failure && canSave && (state === 'local' || state === 'stale')) {
const transport = failure === 'unavailable' || failure === 'timeout' || failure === 'unknown'
return (
<div className="pl-[22px]">
<InlineError
density="compact"
title={
state === 'stale'
? t(
'agentApiKeys.cloud.updateFailed',
'Saved on this computer. Couldn’t update your Orca account, so cloud workspaces still use the older copy.'
)
: t(
'agentApiKeys.cloud.saveFailedLocal',
'Saved on this computer. Couldn’t save it to your Orca account.'
)
}
// Transport copy says "Nothing was changed", which isn't true after a local save.
detail={transport ? undefined : cloudSecretsErrorCopy(failure, t)}
retryLabel={t('agentApiKeys.cloud.retry', 'Try again')}
retrying={saving}
onRetry={() => void save()}
/>
</div>
)
}
return (
<div className="space-y-1 pl-[22px]">
<div className="pl-[22px]">
<div className="flex min-h-6 items-center gap-2 text-xs text-muted-foreground">
{state === 'synced' ? (
<>
@@ -59,8 +86,8 @@ export function AgentApiKeyCloudLine({
)
: state === 'stale'
? t(
'agentApiKeys.cloud.stale',
'Your Orca account has an earlier copy · cloud workspaces still use it'
'agentApiKeys.cloud.staleCopy',
'Your Orca account has an older copy. Cloud workspaces still use it.'
)
: t('agentApiKeys.cloud.local', 'Only on this computer')}
</span>
@@ -72,37 +99,26 @@ export function AgentApiKeyCloudLine({
className="shrink-0 aria-disabled:pointer-events-none"
aria-disabled={saving || undefined}
aria-busy={saving || undefined}
aria-label={t(
'agentApiKeys.cloud.saveLabel',
'Save {{name}} to your Orca account',
{
name: envName
}
)}
aria-label={
state === 'stale'
? t('agentApiKeys.cloud.updateLabel', 'Update {{name}} in your Orca account', {
name: envName
})
: t('agentApiKeys.cloud.saveLabel', 'Save {{name}} to your Orca account', {
name: envName
})
}
onClick={() => void save()}
>
{saving ? <Loader2 className="motion-safe:animate-spin" /> : null}
{t('agentApiKeys.cloud.save', 'Save to your Orca account')}
{state === 'stale'
? t('agentApiKeys.cloud.update', 'Update your Orca account')
: t('agentApiKeys.cloud.save', 'Save to your Orca account')}
</Button>
) : null}
</>
)}
</div>
{failure && (state === 'local' || state === 'stale') ? (
<InlineError
layout="line"
title={t(
'agentApiKeys.cloud.saveFailed',
'Saved on this computer, but not in your Orca account.'
)}
detail={
// The generic transport copy says "Nothing was changed", which isn't true here.
failure === 'unavailable' || failure === 'timeout' || failure === 'unknown'
? t('agentApiKeys.cloud.saveFailedRetry', 'Couldn’t reach Orca Cloud. Try again.')
: cloudSecretsErrorCopy(failure, t)
}
/>
) : null}
</div>
)
}
@@ -134,7 +150,7 @@ export function AgentApiKeyRemoveFromAccountConfirm({
</p>
<div className="flex flex-wrap items-center justify-end gap-1.5">
<Button variant="ghost" size="xs" onClick={onCancel}>
{t('auto.components.settings.agentApiKeys.keep', 'Keep')}
{t('agentApiKeys.remove.cancel', 'Cancel')}
</Button>
<Button variant="outline" size="xs" onClick={() => onRemove(false)}>
{t('agentApiKeys.remove.thisComputerOnly', 'Remove from this computer only')}
@@ -147,10 +163,7 @@ export function AgentApiKeyRemoveFromAccountConfirm({
)
}
export type AgentApiKeysNoticeState =
| { kind: 'kept'; envName: string }
| { kind: 'imported'; count: number }
| null
export type AgentApiKeysNoticeState = { kind: 'kept' } | { kind: 'imported'; count: number } | null
/** One line above the list: the last removal or import, or what failed. */
export function AgentApiKeysNotice({
@@ -170,11 +183,9 @@ export function AgentApiKeysNotice({
tone="neutral"
density="compact"
title={t(
'agentApiKeys.remove.kept',
'Removed from this computer. {{name}} is still in your Orca account.',
{ name: notice.envName }
'agentApiKeys.remove.stillInAccount',
'Still in your Orca account. Manage it in Settings → Orca Cloud → Cloud secrets.'
)}
detail={t('agentApiKeys.remove.keptDetail', 'Manage it in Settings › Cloud secrets.')}
/>
)
}
@@ -13,7 +13,6 @@ import {
defaultImportSelection,
importOutcome,
importSourceLabel,
isMacPlatform,
signInProviderLabel,
type ImportScanState
} from './agent-api-keys-import'
@@ -71,9 +70,6 @@ export function AgentApiKeysImportPanel({
onClose: () => void
}): React.JSX.Element {
const t = useTranslate()
const place = isMacPlatform()
? t('agentApiKeys.import.thisMac', 'this Mac')
: t('agentApiKeys.import.thisComputer', 'this computer')
const [selected, setSelected] = useState<string[] | null>(null)
const [importing, setImporting] = useState(false)
const [failed, setFailed] = useState(false)
@@ -99,7 +95,7 @@ export function AgentApiKeysImportPanel({
>
<div className="space-y-1">
<h4 id="agent-api-keys-import-title" className="text-sm font-medium">
{t('agentApiKeys.import.title', 'Keys found on {{place}}', { place })}
{t('agentApiKeys.import.title', 'Keys found on this computer')}
</h4>
<p className="text-xs text-muted-foreground">
{signedIn
@@ -123,9 +119,7 @@ export function AgentApiKeysImportPanel({
) : scan.kind === 'failed' ? (
<InlineError
density="compact"
title={t('agentApiKeys.import.scanFailed', 'Couldn’t look for keys on {{place}}.', {
place
})}
title={t('agentApiKeys.import.scanFailed', 'Couldn’t look for keys on this computer.')}
retryLabel={t('agentApiKeys.import.retry', 'Try again')}
onRetry={onRetry}
/>
@@ -190,7 +184,7 @@ export function AgentApiKeysImportPanel({
<span className="min-w-0 flex-1">
{t(
'agentApiKeys.import.signIn',
'{{agent}} is signed in with {{provider}}. Sign in once in Settings › Agent accounts.',
'{{agent}} is signed in with {{provider}}. Sign in once in Settings → Agent accounts.',
{
agent: getAgentLabel(signIn.agent),
provider: signInProviderLabel(signIn)
@@ -234,15 +234,23 @@ export const importScanning = defineFixture({
)
})
/** An edit that didn't reach the account: the account still holds the earlier value. */
const STALE: AgentApiKeysState = {
...SIGNED_IN,
cloud: { signedIn: true, synced: [], managed: ['synced'] }
}
/** The account holds an older copy of a key this computer saved there. */
export const cloudStale = defineFixture({
width: 720,
render: () => <AgentApiKeysPane model={model(STALE)} hosts={HOSTS} />
})
/** An edit saved here, but the account write failed: one line, with retry. */
export const cloudStaleFailed = defineFixture({
width: 720,
render: () => (
<AgentApiKeysPane
model={model(
{ ...SIGNED_IN, cloud: { signedIn: true, synced: [], managed: ['synced'] } },
{ cloudFailures: { synced: 'timeout' } }
)}
model={model(STALE, { cloudFailures: { synced: 'timeout' } })}
hosts={HOSTS}
/>
)
@@ -43,7 +43,7 @@ import {
type AgentApiKeysNoticeState
} from './AgentApiKeyCloudLine'
import { AgentApiKeysImportPanel, useAgentApiKeysImport } from './AgentApiKeysImportPanel'
import { isMacPlatform, type ImportScanState } from './agent-api-keys-import'
import type { ImportScanState } from './agent-api-keys-import'
type Editing = { agent: TuiAgent; keyId: string | null } | null
@@ -191,7 +191,7 @@ export function AgentApiKeysPane({
const error = await model.remove(apiKey.id, fromAccount)
setFailure(error)
if (!error && asked && !fromAccount) {
setNotice({ kind: 'kept', envName: apiKey.envName })
setNotice({ kind: 'kept' })
}
}
const [extraAgents, setExtraAgents] = useState<TuiAgent[]>(
@@ -225,8 +225,8 @@ export function AgentApiKeysPane({
<ShieldCheck className="mt-0.5 size-4 shrink-0" />
<p>
{t(
'auto.components.settings.agentApiKeys.promise',
'Keys are sealed in your OS keychain. When an agent starts, here, on an SSH host or on a paired machine, Orca passes it the key for that run only and never writes it to that machine.'
'agentApiKeys.promiseAccount',
'Keys are sealed on this computer. When you’re signed in to Orca, they’re also saved in your Orca account for cloud workspaces. On SSH hosts and paired machines, Orca passes a key for that run only and never writes it there.'
)}
</p>
</div>
@@ -350,9 +350,7 @@ export function AgentApiKeysPane({
{model.scanThisComputer && !importer.scan ? (
<Button variant="outline" size="sm" disabled={!canEdit} onClick={importer.start}>
<Download />
{isMacPlatform()
? t('agentApiKeys.import.open', 'Import from this Mac')
: t('agentApiKeys.import.openComputer', 'Import from this computer')}
{t('agentApiKeys.import.openComputer', 'Import from this computer')}
</Button>
) : null}
{otherAgents.length > 0 ? (
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { defaultImportSelection, isMacPlatform, signInProviderLabel } from './agent-api-keys-import'
import { defaultImportSelection, signInProviderLabel } from './agent-api-keys-import'
describe('agent API key import helpers', () => {
it('checks every found key the vault does not already hold', () => {
@@ -26,11 +26,6 @@ describe('agent API key import helpers', () => {
).toEqual(['OPENAI_API_KEY'])
})
it('says "this Mac" only on macOS', () => {
expect(isMacPlatform('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)')).toBe(true)
expect(isMacPlatform('Mozilla/5.0 (Windows NT 10.0; Win64; x64)')).toBe(false)
})
it('labels known sign-in providers', () => {
expect(signInProviderLabel({ agent: 'opencode', provider: 'github-copilot' })).toBe(
'GitHub Copilot'
@@ -16,11 +16,6 @@ export function defaultImportSelection(scan: AgentApiKeysScanResult): string[] {
return scan.keys.filter((key) => !key.alreadySaved).map((key) => key.name)
}
/** "this Mac" on macOS, "this computer" elsewhere. */
export function isMacPlatform(userAgent: string = globalThis.navigator?.userAgent ?? ''): boolean {
return /Mac/i.test(userAgent)
}
export function importSourceLabel(source: LocalAgentKeySource, t: Translate): string {
switch (source) {
case 'opencode-auth':
+13 -13
View File
@@ -14288,7 +14288,6 @@
"confirmRemove": "Remove key",
"edit": "Edit key",
"remove": "Remove key",
"promise": "Keys are sealed in your OS keychain. When an agent starts, here, on an SSH host or on a paired machine, Orca passes it the key for that run only and never writes it to that machine.",
"unavailableTitle": "Orca won't store API keys on this computer",
"noKey": "No key. The agent uses its own sign-in.",
"addKey": "Add key",
@@ -27390,44 +27389,45 @@
"local": "Only on this computer",
"saveLabel": "Save {{name}} to your Orca account",
"save": "Save to your Orca account",
"saveFailed": "Saved on this computer, but not in your Orca account.",
"stale": "Your Orca account has an earlier copy · cloud workspaces still use it",
"saveFailedRetry": "Couldn’t reach Orca Cloud. Try again."
"updateFailed": "Saved on this computer. Couldn’t update your Orca account, so cloud workspaces still use the older copy.",
"saveFailedLocal": "Saved on this computer. Couldn’t save it to your Orca account.",
"retry": "Try again",
"staleCopy": "Your Orca account has an older copy. Cloud workspaces still use it.",
"updateLabel": "Update {{name}} in your Orca account",
"update": "Update your Orca account"
},
"remove": {
"confirmLabel": "Remove {{name}}",
"fromAccountQuestion": "Also remove it from your Orca account? Cloud workspaces will stop using it.",
"thisComputerOnly": "Remove from this computer only",
"both": "Remove from both",
"kept": "Removed from this computer. {{name}} is still in your Orca account.",
"keptDetail": "Manage it in Settings › Cloud secrets."
"cancel": "Cancel",
"stillInAccount": "Still in your Orca account. Manage it in Settings → Orca Cloud → Cloud secrets."
},
"import": {
"title": "Keys found on {{place}}",
"title": "Keys found on this computer",
"detailSignedIn": "Orca shows names only. Imported keys are sealed on this computer, used on every host, and saved in your Orca account.",
"detailSignedOut": "Orca shows names only. Imported keys are sealed on this computer and used on every host.",
"scanning": "Looking for keys…",
"scanFailed": "Couldn’t look for keys on {{place}}.",
"scanFailed": "Couldn’t look for keys on this computer.",
"retry": "Try again",
"empty": "No agent API keys found in your shell environment, OpenCode or ~/.gemini/.env.",
"alreadySaved": "Already saved for {{agent}}",
"signIn": "{{agent}} is signed in with {{provider}}. Sign in once in Settings › Agent accounts.",
"signIn": "{{agent}} is signed in with {{provider}}. Sign in once in Settings → Agent accounts.",
"failed": "Couldn’t import. Nothing was changed.",
"cancel": "Cancel",
"submitOne": "Import 1 key",
"submit": "Import {{count}} keys",
"thisMac": "this Mac",
"thisComputer": "this computer",
"doneOne": "Imported 1 key.",
"done": "Imported {{count}} keys.",
"cloudFailed": "{{name}} is saved on this computer, but not in your Orca account.",
"open": "Import from this Mac",
"openComputer": "Import from this computer",
"source": {
"opencode": "OpenCode sign-in file",
"geminiEnv": "~/.gemini/.env",
"shell": "Shell environment"
}
}
},
"promiseAccount": "Keys are sealed on this computer. When you’re signed in to Orca, they’re also saved in your Orca account for cloud workspaces. On SSH hosts and paired machines, Orca passes a key for that run only and never writes it there."
}
}