@@ -1483,6 +1483,48 @@ function savedBackendStatus(environment: EnvironmentPresentation): {
14831483 }
14841484}
14851485
1486+ /**
1487+ * Renames a Connect host for every client. Manual connections keep the label
1488+ * saved on this device, so only Connect rows offer this.
1489+ */
1490+ function RemoteHostNameField ( { environment } : { readonly environment : EnvironmentPresentation } ) {
1491+ const environmentId = environment . environmentId ;
1492+ const updateSettings = useAtomCommand ( serverEnvironment . updateSettings , "Update host name" ) ;
1493+ const canUpdateSettings = useAtomValue (
1494+ serverEnvironment . updateSettings . permissionAtom ( environmentId ) ,
1495+ ) ;
1496+ const connected = environment . connection . phase === "connected" ;
1497+ const supported = environment . serverConfig ?. environment . capabilities . environmentLabel === true ;
1498+ return (
1499+ < div className = "mt-2 flex flex-col gap-1.5 border-t border-border/50 py-2" >
1500+ < DraftInput
1501+ size = "sm"
1502+ className = "w-full sm:w-64"
1503+ value = { environment . serverConfig ?. settings . environmentLabel ?? "" }
1504+ onCommit = { ( next ) =>
1505+ void updateSettings ( {
1506+ environmentId,
1507+ input : { patch : { environmentLabel : next . trim ( ) } } ,
1508+ } )
1509+ }
1510+ placeholder = "Use the machine’s name"
1511+ aria-label = { `Host name for ${ environment . label } ` }
1512+ disabled = { ! connected || ! supported || ! canUpdateSettings }
1513+ spellCheck = { false }
1514+ />
1515+ < p className = "text-xs text-muted-foreground" >
1516+ { ! connected
1517+ ? "Connect to this environment to change its host name."
1518+ : ! supported
1519+ ? "Update this environment to change its host name."
1520+ : ! canUpdateSettings
1521+ ? "You need permission to update this environment’s settings."
1522+ : "Shown to every client. Clear it to use the machine’s name." }
1523+ </ p >
1524+ </ div >
1525+ ) ;
1526+ }
1527+
14861528/**
14871529 * One added machine in the Environments list. The switch is the main action;
14881530 * the update icon appears only when that machine can take an update; the
@@ -1497,7 +1539,9 @@ function SavedBackendListRow({
14971539} : SavedBackendListRowProps ) {
14981540 const [ routesOpen , setRoutesOpen ] = useState ( false ) ;
14991541 const [ permissionsOpen , setPermissionsOpen ] = useState ( false ) ;
1542+ const [ hostNameOpen , setHostNameOpen ] = useState ( false ) ;
15001543 const environmentId = environment . environmentId ;
1544+ const isConnectHost = environment . entry . target . _tag === "RelayConnectionTarget" ;
15011545 const unsupported = environment . connection . phase === "unsupported" ;
15021546 const enabled = environment . entry . enabled && ! unsupported ;
15031547 const isConnected = environment . connection . phase === "connected" ;
@@ -1694,6 +1738,7 @@ function SavedBackendListRow({
16941738 }
16951739 detail = {
16961740 < >
1741+ { hostNameOpen && isConnectHost && < RemoteHostNameField environment = { environment } /> }
16971742 { routesOpen && (
16981743 < EnvironmentRoutesList
16991744 environment = { environment }
@@ -1774,6 +1819,11 @@ function SavedBackendListRow({
17741819 environmentId = { environmentId }
17751820 serverConfig = { environment . serverConfig }
17761821 />
1822+ { isConnectHost ? (
1823+ < MenuItem onClick = { ( ) => setHostNameOpen ( ( open ) => ! open ) } >
1824+ { hostNameOpen ? "Hide host name" : "Host name" }
1825+ </ MenuItem >
1826+ ) : null }
17771827 < MenuItem onClick = { ( ) => setRoutesOpen ( ( open ) => ! open ) } >
17781828 < RouteIcon />
17791829 { routesOpen ? "Hide routes" : "Routes" }
0 commit comments