@@ -170,6 +170,7 @@ import { RemoveT3ConnectEnvironmentDialog } from "../clerk/RemoveT3ConnectEnviro
170170import { useCloudLinkController } from "~/cloud/useCloudLinkController" ;
171171import { authEnvironment } from "~/state/auth" ;
172172import { environmentCatalog } from "~/connection/catalog" ;
173+ import { environmentReconnectActionLabel } from "~/connection/environmentReconnectAction" ;
173174import {
174175 connectPairing as connectPairingAtom ,
175176 connectSshEnvironment as connectSshEnvironmentAtom ,
@@ -1429,6 +1430,7 @@ type SavedBackendListRowProps = {
14291430 environment : EnvironmentPresentation ;
14301431 removingEnvironmentId : EnvironmentId | null ;
14311432 onSetEnabled : ( environmentId : EnvironmentId , enabled : boolean ) => void ;
1433+ onRetry : ( environmentId : EnvironmentId ) => void ;
14321434 onRemove : ( environment : EnvironmentPresentation ) => void ;
14331435 onAddRoute : ( environment : EnvironmentPresentation ) => void ;
14341436} ;
@@ -1468,6 +1470,7 @@ function SavedBackendListRow({
14681470 environment,
14691471 removingEnvironmentId,
14701472 onSetEnabled,
1473+ onRetry,
14711474 onRemove,
14721475 onAddRoute,
14731476} : SavedBackendListRowProps ) {
@@ -1527,6 +1530,12 @@ function SavedBackendListRow({
15271530 const resumingServerUpdate =
15281531 serverUpdateState . status === "running" && serverUpdateState . stage === "resuming" ;
15291532 const status = savedBackendStatus ( environment ) ;
1533+ // Only the backoff wait gets a new control. Offline and failed connections
1534+ // keep the switch and their existing recovery.
1535+ const retryNowLabel =
1536+ environmentReconnectActionLabel ( environment . connection . phase ) === "Retry now"
1537+ ? "Retry now"
1538+ : null ;
15301539 const serverVersion = environment . serverConfig ?. environment . serverVersion ?? null ;
15311540 // Discovery empties its map on every refresh, so hold the last descriptor
15321541 // seen or the glyph would blink back to the generic one each time.
@@ -1736,6 +1745,16 @@ function SavedBackendListRow({
17361745 appearance = "icon"
17371746 />
17381747 ) : null }
1748+ { retryNowLabel !== null ? (
1749+ < Button
1750+ size = "xs"
1751+ variant = "ghost"
1752+ disabled = { isRemoving }
1753+ onClick = { ( ) => onRetry ( environmentId ) }
1754+ >
1755+ { retryNowLabel }
1756+ </ Button >
1757+ ) : null }
17391758 < Tooltip >
17401759 < TooltipTrigger
17411760 render = {
@@ -2066,6 +2085,7 @@ export function ConnectionsSettings() {
20662085 const setEnvironmentEnabled = useAtomCommand ( environmentCatalog . setEnabled , {
20672086 reportFailure : false ,
20682087 } ) ;
2088+ const retryEnvironment = useAtomCommand ( environmentCatalog . retryNow , { reportFailure : false } ) ;
20692089 const primaryEnvironmentId = primaryEnvironment ?. environmentId ?? null ;
20702090 const primarySessionState = usePrimarySessionState ( ) ;
20712091 const currentSessionScopes = primarySessionState . data ?. authenticated
@@ -2687,6 +2707,20 @@ export function ConnectionsSettings() {
26872707 }
26882708 } ;
26892709
2710+ const handleRetrySavedBackend = async ( environmentId : EnvironmentId ) => {
2711+ const result = await retryEnvironment ( environmentId ) ;
2712+ if ( result . _tag === "Failure" && ! isAtomCommandInterrupted ( result ) ) {
2713+ const error = squashAtomCommandFailure ( result ) ;
2714+ toastManager . add (
2715+ stackedThreadToast ( {
2716+ type : "error" ,
2717+ title : "Could not reconnect environment" ,
2718+ description : error instanceof Error ? error . message : "Failed to reconnect." ,
2719+ } ) ,
2720+ ) ;
2721+ }
2722+ } ;
2723+
26902724 const handleSetSavedBackendEnabled = async ( environmentId : EnvironmentId , enabled : boolean ) => {
26912725 setSavedBackendError ( null ) ;
26922726 const result = await setEnvironmentEnabled ( { environmentId, enabled } ) ;
@@ -3973,6 +4007,7 @@ export function ConnectionsSettings() {
39734007 environment = { environment }
39744008 removingEnvironmentId = { removingSavedEnvironmentId }
39754009 onSetEnabled = { handleSetSavedBackendEnabled }
4010+ onRetry = { ( environmentId ) => void handleRetrySavedBackend ( environmentId ) }
39764011 onRemove = { handleRemoveSavedBackend }
39774012 onAddRoute = { ( target ) => {
39784013 setRouteTarget ( target ) ;
0 commit comments