diff --git a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetup.fixture.tsx b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetup.fixture.tsx index 359f85389a5..9771080139a 100644 --- a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetup.fixture.tsx +++ b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetup.fixture.tsx @@ -13,7 +13,13 @@ import { const NONE: CloudAgentReadiness = { claude: null, codex: null } const noop = (): void => {} -const actions = { onSave: async () => null, onDone: noop, onSignIn: noop, onLater: noop } +const actions = { + onSave: async () => null, + onDone: noop, + onSignIn: noop, + onCancelSignIn: noop, + onLater: noop +} const ENTRY: PendingWorktreeCreation = { creationId: 'fixture', diff --git a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupDialog.tsx b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupDialog.tsx index f93e5b74c39..07d1e256943 100644 --- a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupDialog.tsx +++ b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupDialog.tsx @@ -58,6 +58,15 @@ export function CloudAgentSetupDialog({ onSaved?: () => void }): React.JSX.Element { const t = useTranslate() + const [visit, setVisit] = useState(0) + const [wasOpen, setWasOpen] = useState(open) + // A fresh body per visit (fresh readiness, empty form) that stays mounted through the close animation. + if (open !== wasOpen) { + setWasOpen(open) + if (open) { + setVisit((value) => value + 1) + } + } return ( @@ -70,8 +79,7 @@ export function CloudAgentSetupDialog({ )} - {/* Mounted per open: every visit reads fresh readiness and starts with an empty form. */} - {open ? onOpenChange(false)} onSaved={onSaved} /> : null} + onOpenChange(false)} onSaved={onSaved} /> ) diff --git a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupFields.tsx b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupFields.tsx index 6153976b3f0..e6f63ac9d2d 100644 --- a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupFields.tsx +++ b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupFields.tsx @@ -1,6 +1,5 @@ import { ExternalLink } from 'lucide-react' import { useTranslate } from '@/i18n/use-translate' -import { Button } from '../ui/button' import { Checkbox } from '../ui/checkbox' import { Input } from '../ui/input' import { Label } from '../ui/label' @@ -34,15 +33,14 @@ const KEY_PAGES = { function GetKeyLink({ url }: { url: string }): React.JSX.Element { const t = useTranslate() return ( - + + ) } @@ -59,7 +57,7 @@ function Field({ label: string helpId?: string help?: string - error?: string | null + error?: React.ReactNode link?: React.ReactNode children: React.ReactNode }): React.JSX.Element { @@ -94,9 +92,12 @@ export function CloudAgentSetupFields({ failure, canShare, share, - onShare + onShare, + onSignInInstead }: { option: Exclude + /** Shown inline after a refused subscription token. */ + onSignInInstead?: () => void formId: string draft: CloudAgentSetupDraft onDraft: (patch: Partial) => void @@ -106,8 +107,24 @@ export function CloudAgentSetupFields({ onShare: (share: boolean) => void }): React.JSX.Element { const t = useTranslate() - const errorFor = (field: string): string | null => - failure?.field === field ? cloudSecretsErrorCopy(failure.error, t) : null + const errorFor = (field: string): React.ReactNode => + failure?.field === field ? ( + <> + {cloudSecretsErrorCopy(failure.error, t)} + {failure.error === 'subscription_token_refused' && onSignInInstead ? ( + <> + {' '} + + + ) : null} + + ) : null const ids = (field: string): { id: string; helpId: string } => ({ id: `${formId}-${field}`, helpId: `${formId}-${field}-help` @@ -122,7 +139,7 @@ export function CloudAgentSetupFields({ value={draft[field]} onChange={(event) => onDraft({ [field]: event.target.value })} placeholder={placeholder} - aria-invalid={errorFor(field) !== null || undefined} + aria-invalid={failure?.field === field || undefined} aria-describedby={ids(field).helpId} spellCheck={false} autoComplete="off" @@ -134,7 +151,7 @@ export function CloudAgentSetupFields({ id={ids('key').id} value={draft.key} onChange={(key) => onDraft({ key })} - invalid={errorFor('key') !== null || errorFor('token') !== null} + invalid={failure?.field === 'key' || failure?.field === 'token'} describedBy={ids('key').helpId} placeholder={placeholder} /> diff --git a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupView.tsx b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupView.tsx index 082e99f313c..99c1e7908e3 100644 --- a/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupView.tsx +++ b/src/renderer/src/components/cloud-agent-setup/CloudAgentSetupView.tsx @@ -101,6 +101,8 @@ export type CloudAgentSetupViewProps = { ) => Promise onSaved: (saved: CloudAgentSetupSaved) => void onCancel: () => void + /** Build sheet: the form opens from a button that unmounts, so focus moves into it. */ + focusOnOpen?: boolean /** Build sheet: a refused subscription token points back at in-VM sign-in. */ onSignInInstead?: () => void /** Fixtures only. */ @@ -117,6 +119,7 @@ export function CloudAgentSetupView({ onSaved, onCancel, onSignInInstead, + focusOnOpen = false, initialOption, initialFailure = null }: CloudAgentSetupViewProps): React.JSX.Element { @@ -194,6 +197,10 @@ export function CloudAgentSetupView({
void submit(event)} onKeyDown={(event) => { + // Escape from a portaled Select or menu bubbles here too; let it close only that. + if (!event.currentTarget.contains(event.target as Node)) { + return + } if (event.key === 'Escape' && !saving) { event.stopPropagation() onCancel() @@ -202,7 +209,12 @@ export function CloudAgentSetupView({ className="space-y-3" aria-label={t('cloudAgentSetup.title', 'Add an agent')} > - {summary ?

{summary}

: null} + {summary ? ( +

+ + {summary} +

+ ) : null} { @@ -216,7 +228,7 @@ export function CloudAgentSetupView({ > {options.map((entry) => ( - + {labels[entry].tab} ))} @@ -238,20 +250,9 @@ export function CloudAgentSetupView({ canShare={canShare} share={share} onShare={setShare} + onSignInInstead={includeSignIn ? () => setOption('sign-in') : onSignInInstead} /> )} - {entry === 'api-key' && - failure?.error === 'subscription_token_refused' && - (includeSignIn || onSignInInstead) ? ( - - ) : null} ))} diff --git a/src/renderer/src/components/cloud-agent-setup/VmBuildCloudAgentStep.tsx b/src/renderer/src/components/cloud-agent-setup/VmBuildCloudAgentStep.tsx index f681f860467..0f82a48de6c 100644 --- a/src/renderer/src/components/cloud-agent-setup/VmBuildCloudAgentStep.tsx +++ b/src/renderer/src/components/cloud-agent-setup/VmBuildCloudAgentStep.tsx @@ -38,6 +38,7 @@ export type VmBuildCloudAgentStepActions = { /** The step is done (saved, signing in, or skipped); remember that it ran. */ onDone: () => void onSignIn: () => void + onCancelSignIn: () => void onLater: () => void } @@ -110,8 +111,21 @@ export function VmBuildCloudAgentStepView({ title={t('cloudAgentSetup.signInPending', 'Agent sign-in')} detail={t( 'cloudAgentSetup.signInPendingDetail', - 'Opens when the VM is ready. Keep this tab open until then.' + 'Opens when the VM is ready. Keep Orca open until then.' )} + actions={ + + } /> ) @@ -122,7 +136,13 @@ export function VmBuildCloudAgentStepView({
  • { actions.onDone() @@ -300,6 +321,7 @@ export function VmBuildCloudAgentStep({ onSave: save, onDone: markDone, onSignIn: () => setSignInRequested(true), + onCancelSignIn: () => setSignInRequested(false), onLater: () => { markDone() setSkipped(true) diff --git a/src/renderer/src/components/settings/cloud-secrets/CloudSecretEditor.tsx b/src/renderer/src/components/settings/cloud-secrets/CloudSecretEditor.tsx index 61ceafea3a0..1f520c0e82f 100644 --- a/src/renderer/src/components/settings/cloud-secrets/CloudSecretEditor.tsx +++ b/src/renderer/src/components/settings/cloud-secrets/CloudSecretEditor.tsx @@ -67,6 +67,10 @@ export function CloudSecretEditor({ void submit(event)} onKeyDown={(event) => { + // Escape from a portaled Select or menu bubbles here too; let it close only that. + if (!event.currentTarget.contains(event.target as Node)) { + return + } if (event.key === 'Escape' && !saving) { event.stopPropagation() onCancel() @@ -100,11 +104,16 @@ export function CloudSecretEditor({ }} placeholder="DATABASE_URL" aria-invalid={errorIsName || undefined} - aria-describedby={`${formId}-status`} + aria-describedby={errorIsName ? `${formId}-status` : undefined} spellCheck={false} autoComplete="off" className="h-8" /> + {errorIsName && error ? ( + + ) : null}
    -
    - +