fix(clients): hold the discovered machine icon across relay refreshes (#12030)
Co-authored-by: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
c1b2ed6504
commit
6ee03240bc
2 files changed
+18
-10
No files matched your search
@@ -235,6 +235,12 @@ function ConnectedCloudEnvironmentRow(props: {
|
||||
);
|
||||
const unsupported = props.environment.connectionState === "unsupported";
|
||||
const enabled = props.environment.isEnabled && !unsupported;
|
||||
// Discovery empties its map on every refresh; hold the last descriptor seen
|
||||
// so the glyph does not blink back to the generic one each time.
|
||||
const [lastDescriptor, setLastDescriptor] = useState(props.descriptor);
|
||||
if (props.descriptor !== undefined && props.descriptor !== lastDescriptor) {
|
||||
setLastDescriptor(props.descriptor);
|
||||
}
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityHint="Long press to remove from this device"
|
||||
@@ -248,8 +254,7 @@ function ConnectedCloudEnvironmentRow(props: {
|
||||
errorExpanded={props.errorExpanded}
|
||||
label={props.environment.environmentLabel}
|
||||
machine={resolveEnvironmentMachineKind(
|
||||
serverConfig ??
|
||||
(props.descriptor === undefined ? null : { environment: props.descriptor }),
|
||||
serverConfig ?? (lastDescriptor === undefined ? null : { environment: lastDescriptor }),
|
||||
)}
|
||||
onValueChange={props.onSetEnabled}
|
||||
onToggleError={props.onToggleError}
|
||||
|
||||
@@ -1523,14 +1523,20 @@ function SavedBackendListRow({
|
||||
const serverVersion = environment.serverConfig?.environment.serverVersion ?? null;
|
||||
// A saved T3 Connect machine this device has never reached (unsupported,
|
||||
// or not yet connected) still has a descriptor from relay discovery, so
|
||||
// it can wear its detected glyph instead of the generic server.
|
||||
// it can wear its detected glyph instead of the generic server. Discovery
|
||||
// empties its map on every refresh, so hold the last descriptor seen or
|
||||
// the glyph would blink back to the generic one each time.
|
||||
const relayDiscovery = useRelayEnvironmentDiscovery();
|
||||
const discoveredDescriptor = Option.getOrNull(
|
||||
relayDiscovery.environments.get(environmentId)?.status ?? Option.none(),
|
||||
)?.descriptor;
|
||||
const [lastDescriptor, setLastDescriptor] = useState(discoveredDescriptor);
|
||||
if (discoveredDescriptor !== undefined && discoveredDescriptor !== lastDescriptor) {
|
||||
setLastDescriptor(discoveredDescriptor);
|
||||
}
|
||||
const machineKind = resolveEnvironmentMachineKind(
|
||||
environment.serverConfig ??
|
||||
(discoveredDescriptor === undefined ? null : { environment: discoveredDescriptor }),
|
||||
(lastDescriptor === undefined ? null : { environment: lastDescriptor }),
|
||||
);
|
||||
const subtitleText = [
|
||||
environmentTransportLabel(environment),
|
||||
@@ -1560,10 +1566,7 @@ function SavedBackendListRow({
|
||||
<span
|
||||
className={cn(
|
||||
"block truncate",
|
||||
(enabled || unsupported) &&
|
||||
status.tone === "error" &&
|
||||
!resumingServerUpdate &&
|
||||
"text-destructive",
|
||||
enabled && status.tone === "error" && !resumingServerUpdate && "text-destructive",
|
||||
)}
|
||||
/>
|
||||
}
|
||||
@@ -1571,8 +1574,8 @@ function SavedBackendListRow({
|
||||
{subtitleText}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top" className="max-w-80 whitespace-pre-wrap leading-tight">
|
||||
{unsupported && environment.connection.error
|
||||
? environment.connection.error
|
||||
{unsupported
|
||||
? (environment.connection.error ?? connectionStatusText(environment.connection))
|
||||
: enabled
|
||||
? connectionStatusText(environment.connection)
|
||||
: "Switched off"}
|
||||
|
||||
Reference in new issue
Block a user