@@ -29,11 +29,6 @@ import {
2929} from './amrLoginPolling' ;
3030import { Icon } from './Icon' ;
3131import { amrConsoleUrlForProfile , amrProfileBadgeLabel } from '../runtime/amr-guidance' ;
32- import {
33- amrLoginFailureForOutcome ,
34- amrLoginFailureForSpawn ,
35- amrLoginReasonText ,
36- } from '../runtime/amr-login-failure' ;
3732
3833interface AmrLoginPillProps {
3934 className ?: string ;
@@ -49,12 +44,6 @@ interface AmrLoginPillProps {
4944 revealPendingCancelAction ?: boolean ;
5045 showConsoleAction ?: boolean ;
5146 iconOnlySignOut ?: boolean ;
52- // Suppress the inline error text inside the compact control. The host lifts
53- // the reason (via `onErrorChange`) and renders it somewhere with room to
54- // breathe — e.g. a full-width row under the Settings agent card — so the
55- // classified reason no longer wraps awkwardly next to the Authorize button.
56- hideInlineError ?: boolean ;
57- onErrorChange ?: ( message : string | null ) => void ;
5847 onStatusChange ?: ( status : VelaLoginStatus | null ) => void ;
5948}
6049
@@ -86,9 +75,6 @@ export interface AmrAccountControlProps {
8675 showConsoleAction ?: boolean ;
8776 consoleUrl ?: string ;
8877 iconOnlySignOut ?: boolean ;
89- // When true, the error status still styles the control (Authorize button) but
90- // the inline reason text is not rendered; the host shows it elsewhere.
91- hideInlineError ?: boolean ;
9278 showCancelSignInAction ?: boolean ;
9379 // Activation URL surfaced while signing in, so the user can re-open the
9480 // sign-in page when the browser did not auto-open. The URL already carries
@@ -137,7 +123,6 @@ export function AmrAccountControl({
137123 showConsoleAction = false ,
138124 consoleUrl,
139125 iconOnlySignOut = false ,
140- hideInlineError = false ,
141126 showCancelSignInAction = false ,
142127 activationUrl,
143128 browserOpenFailed = false ,
@@ -248,7 +233,7 @@ export function AmrAccountControl({
248233 { signInLabel ?? t ( 'settings.amrSignIn' ) }
249234 </ button >
250235 ) : null }
251- { hasError && ! hideInlineError ? (
236+ { hasError ? (
252237 < span className = "amr-account-control__error" role = "alert" >
253238 { loginErrorText }
254239 </ span >
@@ -293,8 +278,6 @@ export function AmrLoginPill({
293278 revealPendingCancelAction = false ,
294279 showConsoleAction = false ,
295280 iconOnlySignOut = false ,
296- hideInlineError = false ,
297- onErrorChange,
298281 onStatusChange,
299282} : AmrLoginPillProps ) {
300283 const { t } = useI18n ( ) ;
@@ -319,23 +302,9 @@ export function AmrLoginPill({
319302 if ( next ) {
320303 setStatus ( next ) ;
321304 onStatusChange ?.( next ) ;
322- // Persist the daemon's classified failure across ordinary reads
323- // (mount/focus), so a reload after a failed sign-in keeps the specific
324- // reason instead of resetting to a plain signed-out pill (issue #426).
325- // Assign unconditionally in the terminal signed-out/not-signing-in state
326- // so a later clean read (daemon restart drops the in-memory
327- // lastVelaLoginExit) also CLEARS a previously shown reason. The poll-stop
328- // branch overrides with the definitive outcome text on the same tick.
329- if ( ! next . loggedIn && ! next . loginInFlight ) {
330- setErrorMessage (
331- next . lastLoginFailure
332- ? amrLoginReasonText ( t , next . lastLoginFailure )
333- : null ,
334- ) ;
335- }
336305 }
337306 return next ;
338- } , [ onStatusChange , t ] ) ;
307+ } , [ onStatusChange ] ) ;
339308
340309 useEffect ( ( ) => {
341310 if ( ! skipInitialRefresh ) void refresh ( ) ;
@@ -361,32 +330,8 @@ export function AmrLoginPill({
361330 setPending ( null ) ;
362331 setCanceledVisible ( false ) ;
363332 }
364- // NOTE: keep this effect's deps to `[initialStatus, stopPolling]` — no `t`.
365- // A per-render `t` identity would re-run `setStatus(initialStatus)` on every
366- // render and clobber a local post-cancel status (loginInFlight:false) back
367- // to the host's still-in-flight snapshot, bouncing the pill to "Signing in…"
368- // (#3158). The classified-reason mapping that needs `t` lives in its own
369- // effect below.
370333 } , [ initialStatus , stopPolling ] ) ;
371334
372- // The Settings card mounts this pill with `initialStatus` + `skipInitialRefresh`
373- // and refetches on window focus, so a host-pushed signed-out snapshot never
374- // flows through `refresh()`. Mirror refresh()'s terminal mapping here (unless
375- // the pill's own login is mid-flight) so the classified reason surfaces on
376- // that surface after reload/focus too — and clears when the daemon no longer
377- // reports `lastLoginFailure` (restart drops the in-memory exit) (issue #426).
378- // Split off the status-sync effect (and thus off `setStatus`) so re-running on
379- // a fresh `t` only ever calls the idempotent setErrorMessage (#3158).
380- useEffect ( ( ) => {
381- if ( ! initialStatus || initialStatus . loggedIn ) return ;
382- if ( initialStatus . loginInFlight || loginPendingRef . current ) return ;
383- setErrorMessage (
384- initialStatus . lastLoginFailure
385- ? amrLoginReasonText ( t , initialStatus . lastLoginFailure )
386- : null ,
387- ) ;
388- } , [ initialStatus , t ] ) ;
389-
390335 useEffect ( ( ) => {
391336 if ( ! canceledVisible ) return ;
392337 const timeout = window . setTimeout ( ( ) => {
@@ -399,12 +344,6 @@ export function AmrLoginPill({
399344 onStatusChange ?.( status ) ;
400345 } , [ onStatusChange , status ] ) ;
401346
402- // Lift the resolved reason so a host that hides the inline error (e.g. the
403- // Settings agent card) can render it with room to breathe.
404- useEffect ( ( ) => {
405- onErrorChange ?.( errorMessage ) ;
406- } , [ onErrorChange , errorMessage ] ) ;
407-
408347 const startPolling = useCallback ( ( startedAt = Date . now ( ) ) => {
409348 stopPolling ( ) ;
410349 loginStartedAtRef . current = startedAt ;
@@ -437,9 +376,7 @@ export function AmrLoginPill({
437376 loginStartedAtRef . current = null ;
438377 loginPendingRef . current = false ;
439378 setPending ( null ) ;
440- setErrorMessage (
441- amrLoginReasonText ( t , amrLoginFailureForOutcome ( outcome , next ) ) ,
442- ) ;
379+ setErrorMessage ( t ( 'settings.amrLoginErrorCompact' ) ) ;
443380 }
444381 } ;
445382 pollRef . current = window . setInterval ( ( ) => {
@@ -539,7 +476,7 @@ export function AmrLoginPill({
539476 loginStartedAtRef . current = null ;
540477 loginPendingRef . current = false ;
541478 setPending ( null ) ;
542- setErrorMessage ( amrLoginReasonText ( t , amrLoginFailureForSpawn ( result ) ) ) ;
479+ setErrorMessage ( result . error || t ( 'settings.amrLoginErrorCompact' ) ) ;
543480 return ;
544481 }
545482 notifyAmrLoginStatusChanged ( 'login-started' ) ;
@@ -666,7 +603,6 @@ export function AmrLoginPill({
666603 signInLabel = { signInLabel }
667604 showConsoleAction = { showConsoleAction }
668605 iconOnlySignOut = { iconOnlySignOut }
669- hideInlineError = { hideInlineError }
670606 signInDisabled = { loginInFlight }
671607 signOutDisabled = { logoutInFlight }
672608 showCancelSignInAction = { revealPendingCancelAction && loginInFlight }
0 commit comments