fix(web): match provider settings layout for disconnected devices (#9619)

This commit is contained in:
oliver authored and GitHub committed 2026-09-04 12:51:06 -04:00
1 parent 8ccb933a8a
commit 8357eef14c
4 files changed
+151 -66

No files matched your search

@@ -38,6 +38,7 @@ import { Button } from "../ui/button";
import { ScrollArea } from "../ui/scroll-area";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { toastManager } from "../ui/toast";
import { ExpandableText } from "./ExpandableText";
import { ResourceTelemetryDiagnostics } from "./ResourceTelemetryDiagnostics";
import { SettingsPageContainer, SettingsSection, useRelativeTimeTick } from "./settingsLayout";
import { useAtomCommand } from "../../state/use-atom-command";
@@ -161,43 +162,6 @@ function EmptyRows({ label }: { label: string }) {
return <div className="px-4 py-4 text-xs text-muted-foreground sm:px-5">{label}</div>;
}
function ExpandableText({
text,
className,
collapsedClassName = "line-clamp-3",
expandLabel = "Show full error",
}: {
text: string;
className?: string;
collapsedClassName?: string;
expandLabel?: string;
}) {
const [expanded, setExpanded] = useState(false);
const canExpand = text.length > 180 || text.includes("\n");
return (
<div className={cn("min-w-0", className)}>
<div
className={cn(
"whitespace-pre-wrap break-words",
!expanded && canExpand ? collapsedClassName : null,
)}
>
{text}
</div>
{canExpand ? (
<button
type="button"
className="cursor-pointer mt-1 text-[11px] font-medium text-foreground/70 underline-offset-2 hover:text-foreground hover:underline"
onClick={() => setExpanded((value) => !value)}
>
{expanded ? "Show less" : expandLabel}
</button>
) : null}
</div>
);
}
function DiagnosticsTable({
headers,
children,
@@ -0,0 +1,44 @@
import { useState } from "react";
import { cn } from "../../lib/utils";
/**
* Long error text clamped to a few lines with a toggle to reveal the rest.
* Short single-line text renders as-is without the toggle.
*/
export function ExpandableText({
text,
className,
collapsedClassName = "line-clamp-3",
expandLabel = "Show full error",
}: {
text: string;
className?: string;
collapsedClassName?: string;
expandLabel?: string;
}) {
const [expanded, setExpanded] = useState(false);
const canExpand = text.length > 180 || text.includes("\n");
return (
<div className={cn("min-w-0", className)}>
<div
className={cn(
"whitespace-pre-wrap break-words",
!expanded && canExpand ? collapsedClassName : null,
)}
>
{text}
</div>
{canExpand ? (
<button
type="button"
className="cursor-pointer mt-1 text-[11px] font-medium text-foreground/70 underline-offset-2 hover:text-foreground hover:underline"
onClick={() => setExpanded((value) => !value)}
>
{expanded ? "Show less" : expandLabel}
</button>
) : null}
</div>
);
}
@@ -607,7 +607,11 @@ export function ProviderInstanceCard({
{instanceId}
</code>
) : null}
{versionCodeNode}
{versionLabel ? (
<code className="max-w-24 shrink-0 truncate text-xs text-muted-foreground">
{versionLabel}
</code>
) : null}
{versionAdvisory ? (
<span role="img" aria-label="Update available" className="inline-flex shrink-0">
<ArrowUpCircleIcon className="size-3.5 text-muted-foreground" />
@@ -1,5 +1,5 @@
import { useAtomValue } from "@effect/atom-react";
import { connectionStatusText } from "@t3tools/client-runtime/connection";
import { connectionStatusTitle } from "@t3tools/client-runtime/connection";
import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
import {
isAtomCommandInterrupted,
@@ -56,6 +56,14 @@ import {
type ProviderUpdateCandidate,
} from "../ProviderUpdateLaunchNotification.logic";
import { Button } from "../ui/button";
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "../ui/empty";
import {
NumberField,
NumberFieldDecrement,
@@ -67,6 +75,7 @@ import { ScrollArea } from "../ui/scroll-area";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { stackedThreadToast, toastManager } from "../ui/toast";
import { AddProviderInstanceDialog } from "./AddProviderInstanceDialog";
import { ExpandableText } from "./ExpandableText";
import { ProviderInstanceCard } from "./ProviderInstanceCard";
import { UsageProviderSettings } from "./UsageProviderSettings";
import { ProviderSetupSection, readAntigravityAuthMethod } from "./ProviderSetupSection";
@@ -159,7 +168,52 @@ function providerEnvironmentDetail(environment: EnvironmentPresentation): string
return environment.displayUrl ?? "Remote device";
}
function EnvironmentUnavailableRow({
const providerCardClassName = "rounded-xl border border-border/60 bg-card/40 shadow-xs/5";
// Shared by the editor grid and the placeholder states so switching devices
// never changes the card's footprint.
const providerCardHeightClassName = "lg:h-[min(44rem,calc(100dvh-11rem))] lg:min-h-[32rem]";
/**
* Same chrome as the provider editor (section heading, floating device tabs,
* tall card) for states that cannot render provider settings yet.
*/
function ProviderSettingsPlaceholder({
deviceTabs,
icon,
title,
description,
children,
}: {
readonly deviceTabs?: ReactNode;
readonly icon: ReactNode;
readonly title: string;
readonly description: string;
readonly children?: ReactNode;
}) {
return (
<SettingsSection {...searchableSetting("providers")} variant="plain">
{deviceTabs}
<div
className={cn(
providerCardClassName,
providerCardHeightClassName,
"flex overflow-x-hidden overflow-y-auto",
)}
>
<Empty className="min-h-88">
<EmptyMedia variant="icon">{icon}</EmptyMedia>
<EmptyHeader>
<EmptyTitle>{title}</EmptyTitle>
<EmptyDescription>{description}</EmptyDescription>
</EmptyHeader>
{children ? <EmptyContent className="max-w-xl">{children}</EmptyContent> : null}
</Empty>
</div>
</SettingsSection>
);
}
function EnvironmentUnavailablePlaceholder({
environment,
access,
deviceTabs,
@@ -174,18 +228,33 @@ function EnvironmentUnavailableRow({
: access.kind === "error"
? "Could not connect to this device"
: "Provider settings are unavailable";
// Keep the description to a short status; the raw failure can be a
// multi-paragraph CLI dump, so it goes below, clamped and expandable.
const description = isLoading
? access.reason === "permissions"
? "Checking what this session is allowed to change."
: `Waiting for ${environment.label}'s configuration.`
: connectionStatusText(environment.connection);
: connectionStatusTitle(environment.connection);
const error = isLoading ? null : environment.connection.error;
// No spinner: this state can persist indefinitely for a wedged device, and a
// continuously repainting animation would run the whole time.
return (
<SettingsSection {...searchableSetting("providers")}>
{deviceTabs}
<SettingsRow title={title} description={description} />
</SettingsSection>
<ProviderSettingsPlaceholder
deviceTabs={deviceTabs}
icon={
<EnvironmentMachineIcon kind={resolveEnvironmentMachineKind(environment.serverConfig)} />
}
title={title}
description={description}
>
{error ? (
<ExpandableText
key={environment.environmentId}
text={error}
className="w-full text-left font-mono text-xs leading-relaxed text-muted-foreground"
/>
) : null}
</ProviderSettingsPlaceholder>
);
}
@@ -260,7 +329,7 @@ function ProviderSettingsPanelContent(target: ProviderSettingsTarget) {
const machine = resolveEnvironmentMachineKind(environment.serverConfig);
const selected = environment.environmentId === effectiveEnvironmentId;
const detail = providerEnvironmentDetail(environment);
const statusText = connectionStatusText(environment.connection);
const statusText = connectionStatusTitle(environment.connection);
return (
<Tooltip key={environment.environmentId}>
<TooltipTrigger
@@ -302,25 +371,23 @@ function ProviderSettingsPanelContent(target: ProviderSettingsTarget) {
return (
<>
{targetEnvironmentMissing ? (
<SettingsSection {...searchableSetting("providers")}>
{deviceTabs}
<SettingsRow
title="Device unavailable"
description="Reconnect this device to set up its provider, or select another device."
/>
</SettingsSection>
<ProviderSettingsPlaceholder
deviceTabs={deviceTabs}
icon={<EnvironmentMachineIcon kind={resolveEnvironmentMachineKind(null)} />}
title="Device unavailable"
description="Reconnect this device to set up its provider, or select another device."
/>
) : null}
{options.length === 0 && !targetEnvironmentMissing ? (
<SettingsSection {...searchableSetting("providers")}>
<SettingsRow
title={isReady ? "No connected devices" : "Loading devices"}
description={
isReady
? "Connect an execution environment before configuring providers."
: "Reading connected execution environments."
}
/>
</SettingsSection>
<ProviderSettingsPlaceholder
icon={<EnvironmentMachineIcon kind={resolveEnvironmentMachineKind(null)} />}
title={isReady ? "No connected devices" : "Loading devices"}
description={
isReady
? "Connect an execution environment before configuring providers."
: "Reading connected execution environments."
}
/>
) : null}
{selectedEnvironment ? (
@@ -450,7 +517,7 @@ function AccessGatedProviderSettings({
});
if (access.kind !== "editable" && access.kind !== "read-only") {
return (
<EnvironmentUnavailableRow
<EnvironmentUnavailablePlaceholder
environment={environment}
access={access}
deviceTabs={deviceTabs}
@@ -967,14 +1034,20 @@ export function EnvironmentProviderSettings({
>
{deviceTabs}
{readOnly ? (
<div className="overflow-hidden rounded-xl border border-border/60 bg-card/40 shadow-xs/5">
<div className={cn(providerCardClassName, "overflow-hidden")}>
<SettingsRow
title="Limited permissions"
description={`This session can view ${environmentLabel}'s providers but can't change their settings.`}
/>
</div>
) : null}
<div className="overflow-hidden rounded-xl border border-border/60 bg-card/40 shadow-xs/5 lg:grid lg:h-[min(44rem,calc(100dvh-11rem))] lg:min-h-[32rem] lg:grid-cols-[17rem_minmax(0,1fr)]">
<div
className={cn(
providerCardClassName,
providerCardHeightClassName,
"overflow-hidden lg:grid lg:grid-cols-[17rem_minmax(0,1fr)]",
)}
>
<div className="border-b border-border/60 bg-muted/10 lg:flex lg:min-h-0 lg:flex-col lg:border-r lg:border-b-0">
<ScrollArea scrollFade chainVerticalScroll className="lg:min-h-0 lg:flex-1">
<div className="divide-y divide-border/50">