@@ -31,7 +31,7 @@ import {
3131 applyWslEnableSelection ,
3232 connectDeviceName ,
3333 isWslSettingsRowVisible ,
34- missingTailscaleEndpointDescription ,
34+ tailscaleHttpsRow ,
3535 resolveLocalVersionStatusLabel ,
3636 resolveTailscaleServeBaseUrl ,
3737} from "./ConnectionsSettings.logic" ;
@@ -370,8 +370,10 @@ function ConnectionsSettingsContent({
370370 | { readonly kind : "wsl-only" ; readonly nextValue : boolean } ;
371371 const [ pendingWslChange , setPendingWslChange ] = useState < PendingWslChange | null > ( null ) ;
372372 const isWslConfirmDialogOpen = pendingWslChange !== null ;
373- const [ pendingTailscaleServeEndpoint , setPendingTailscaleServeEndpoint ] =
374- useState < AdvertisedEndpoint | null > ( null ) ;
373+ // Setup can start before Tailscale reports a MagicDNS name, so the endpoint may be null.
374+ const [ pendingTailscaleServeSetup , setPendingTailscaleServeSetup ] = useState < {
375+ readonly endpoint : AdvertisedEndpoint | null ;
376+ } | null > ( null ) ;
375377 const [ disableTailscaleServeDialogOpen , setDisableTailscaleServeDialogOpen ] = useState ( false ) ;
376378 const [ tailscaleServePortInput , setTailscaleServePortInput ] = useState (
377379 String ( DEFAULT_TAILSCALE_SERVE_PORT ) ,
@@ -469,7 +471,7 @@ function ConnectionsSettingsContent({
469471 parsedTailscaleServePort <= 65_535 ;
470472
471473 const pendingTailscaleServeBaseUrl = resolveTailscaleServeBaseUrl (
472- pendingTailscaleServeEndpoint ,
474+ pendingTailscaleServeSetup ?. endpoint ?? null ,
473475 parsedTailscaleServePort ,
474476 isTailscaleServePortValid ,
475477 ) ;
@@ -525,7 +527,7 @@ function ConnectionsSettingsContent({
525527 port : parsedTailscaleServePort ,
526528 } ) ;
527529 refreshDesktopNetworkAccessState ( ) ;
528- setPendingTailscaleServeEndpoint ( null ) ;
530+ setPendingTailscaleServeSetup ( null ) ;
529531 } ) ;
530532 if ( settled . _tag === "Failure" ) {
531533 const error = Cause . squash ( settled . cause ) ;
@@ -543,11 +545,11 @@ function ConnectionsSettingsContent({
543545 setIsUpdatingTailscaleServe ( false ) ;
544546 } ;
545547
546- const handleStartTailscaleServeSetup = ( endpoint : AdvertisedEndpoint ) => {
548+ const handleStartTailscaleServeSetup = ( endpoint : AdvertisedEndpoint | null ) => {
547549 setTailscaleServePortInput (
548550 String ( desktopServerExposureState ?. tailscaleServePort ?? DEFAULT_TAILSCALE_SERVE_PORT ) ,
549551 ) ;
550- setPendingTailscaleServeEndpoint ( endpoint ) ;
552+ setPendingTailscaleServeSetup ( { endpoint } ) ;
551553 } ;
552554
553555 const handleConfirmTailscaleServeDisable = async ( ) => {
@@ -1097,35 +1099,27 @@ function ConnectionsSettingsContent({
10971099 ) ;
10981100 } ;
10991101
1100- const renderTailscaleRow = ( ) => (
1101- < SettingsRow
1102- title = { searchableSetting ( "tailscale-https" ) . title }
1103- description = {
1104- tailscaleHttpsEndpoint
1105- ? tailscaleHttpsEndpoint . status === "available"
1106- ? tailscaleHttpsEndpoint . httpBaseUrl
1107- : "Use Tailscale Serve to expose this backend through a MagicDNS HTTPS URL."
1108- : missingTailscaleEndpointDescription ( desktopServerExposureState )
1109- }
1110- control = {
1111- tailscaleHttpsEndpoint ? (
1102+ const renderTailscaleRow = ( ) => {
1103+ const row = tailscaleHttpsRow ( desktopServerExposureState , tailscaleHttpsEndpoint ) ;
1104+ return (
1105+ < SettingsRow
1106+ title = { searchableSetting ( "tailscale-https" ) . title }
1107+ description = { row . description }
1108+ control = {
11121109 < Switch
1113- checked = { tailscaleHttpsEndpoint . status === "available" }
1110+ checked = { row . checked }
11141111 disabled = { isUpdatingTailscaleServe }
11151112 onCheckedChange = { ( checked ) => {
1116- if ( checked ) {
1117- handleStartTailscaleServeSetup ( tailscaleHttpsEndpoint ) ;
1118- return ;
1119- }
1120- handleStartTailscaleServeDisable ( tailscaleHttpsEndpoint ) ;
1113+ if ( checked ) handleStartTailscaleServeSetup ( tailscaleHttpsEndpoint ) ;
1114+ else setDisableTailscaleServeDialogOpen ( true ) ;
11211115 } }
11221116 aria-label = "Enable Tailscale HTTPS"
11231117 />
1124- ) : null
1125- }
1126- managed = { tailscaleHttpsEndpoint ?. status === "available" ? undefined : remoteClientsDenial }
1127- />
1128- ) ;
1118+ }
1119+ managed = { row . checked ? undefined : remoteClientsDenial }
1120+ />
1121+ ) ;
1122+ } ;
11291123 const newestPairingLink = visibleDesktopPairingLinks . find (
11301124 ( pairingLink ) => pairingLink . id === newestPairingLinkId ,
11311125 ) ;
@@ -1624,10 +1618,10 @@ function ConnectionsSettingsContent({
16241618 </ AlertDialogPopup >
16251619 </ AlertDialog >
16261620 < Dialog
1627- open = { pendingTailscaleServeEndpoint !== null }
1621+ open = { pendingTailscaleServeSetup !== null }
16281622 onOpenChange = { ( open ) => {
16291623 if ( isUpdatingTailscaleServe ) return ;
1630- if ( ! open ) setPendingTailscaleServeEndpoint ( null ) ;
1624+ if ( ! open ) setPendingTailscaleServeSetup ( null ) ;
16311625 } }
16321626 >
16331627 < DialogPopup className = "max-w-md" >
0 commit comments