Skip to content

Commit 74a3e9c

Browse files
fix(clients): hold the discovered machine icon across relay refreshes
Discovery empties its map at the start of every refresh, so a saved but unreached row blinked back to the generic server glyph each time. Keep the last descriptor seen. Also drop a dead unsupported guard on the web subtitle tone and keep the unsupported tooltip on the compatibility text. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent c1b2ed6 commit 74a3e9c

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

‎apps/mobile/src/features/connection/CloudEnvironmentRows.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ function ConnectedCloudEnvironmentRow(props: {
235235
);
236236
const unsupported = props.environment.connectionState === "unsupported";
237237
const enabled = props.environment.isEnabled && !unsupported;
238+
// Discovery empties its map on every refresh; hold the last descriptor seen
239+
// so the glyph does not blink back to the generic one each time.
240+
const [lastDescriptor, setLastDescriptor] = useState(props.descriptor);
241+
if (props.descriptor !== undefined && props.descriptor !== lastDescriptor) {
242+
setLastDescriptor(props.descriptor);
243+
}
238244
return (
239245
<Pressable
240246
accessibilityHint="Long press to remove from this device"
@@ -248,8 +254,7 @@ function ConnectedCloudEnvironmentRow(props: {
248254
errorExpanded={props.errorExpanded}
249255
label={props.environment.environmentLabel}
250256
machine={resolveEnvironmentMachineKind(
251-
serverConfig ??
252-
(props.descriptor === undefined ? null : { environment: props.descriptor }),
257+
serverConfig ?? (lastDescriptor === undefined ? null : { environment: lastDescriptor }),
253258
)}
254259
onValueChange={props.onSetEnabled}
255260
onToggleError={props.onToggleError}

‎apps/web/src/components/settings/ConnectionsSettings.tsx‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,14 +1523,20 @@ function SavedBackendListRow({
15231523
const serverVersion = environment.serverConfig?.environment.serverVersion ?? null;
15241524
// A saved T3 Connect machine this device has never reached (unsupported,
15251525
// or not yet connected) still has a descriptor from relay discovery, so
1526-
// it can wear its detected glyph instead of the generic server.
1526+
// it can wear its detected glyph instead of the generic server. Discovery
1527+
// empties its map on every refresh, so hold the last descriptor seen or
1528+
// the glyph would blink back to the generic one each time.
15271529
const relayDiscovery = useRelayEnvironmentDiscovery();
15281530
const discoveredDescriptor = Option.getOrNull(
15291531
relayDiscovery.environments.get(environmentId)?.status ?? Option.none(),
15301532
)?.descriptor;
1533+
const [lastDescriptor, setLastDescriptor] = useState(discoveredDescriptor);
1534+
if (discoveredDescriptor !== undefined && discoveredDescriptor !== lastDescriptor) {
1535+
setLastDescriptor(discoveredDescriptor);
1536+
}
15311537
const machineKind = resolveEnvironmentMachineKind(
15321538
environment.serverConfig ??
1533-
(discoveredDescriptor === undefined ? null : { environment: discoveredDescriptor }),
1539+
(lastDescriptor === undefined ? null : { environment: lastDescriptor }),
15341540
);
15351541
const subtitleText = [
15361542
environmentTransportLabel(environment),
@@ -1560,19 +1566,16 @@ function SavedBackendListRow({
15601566
<span
15611567
className={cn(
15621568
"block truncate",
1563-
(enabled || unsupported) &&
1564-
status.tone === "error" &&
1565-
!resumingServerUpdate &&
1566-
"text-destructive",
1569+
enabled && status.tone === "error" && !resumingServerUpdate && "text-destructive",
15671570
)}
15681571
/>
15691572
}
15701573
>
15711574
{subtitleText}
15721575
</TooltipTrigger>
15731576
<TooltipPopup side="top" className="max-w-80 whitespace-pre-wrap leading-tight">
1574-
{unsupported && environment.connection.error
1575-
? environment.connection.error
1577+
{unsupported
1578+
? (environment.connection.error ?? connectionStatusText(environment.connection))
15761579
: enabled
15771580
? connectionStatusText(environment.connection)
15781581
: "Switched off"}

0 commit comments

Comments
 (0)