Skip to content

Commit 61fb165

Browse files
author
PR Batch Tester
committed
fix(devices): keep warning details in the existing notice
1 parent 0ecee4b commit 61fb165

4 files changed

Lines changed: 51 additions & 43 deletions

File tree

‎apps/web/src/components/device/DeviceDiscoveryStatus.tsx‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎apps/web/src/components/device/DevicePanel.tsx‎

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
type RightPanelSurface,
1717
} from "~/rightPanelStore";
1818
import { Button } from "~/components/ui/button";
19+
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "~/components/ui/collapsible";
1920
import { DiscoveryList } from "~/components/ui/discovery-list";
2021
import { Dialog } from "~/components/ui/dialog";
2122
import { WizardPopup } from "~/components/ui/wizard";
@@ -30,7 +31,6 @@ import {
3031
} from "~/state/device";
3132
import { formatEnvironmentQueryError } from "~/state/query";
3233
import { useAtomCommand } from "~/state/use-atom-command";
33-
import { DeviceDiscoveryStatus } from "./DeviceDiscoveryStatus";
3434
import { DeviceLoadingView } from "./DeviceLoadingView";
3535
import { DeviceSetup, deviceHubReadiness, isAndroidDiscoveryUncertain } from "./DeviceSetup";
3636
import { DeviceWorkspace } from "./DeviceWorkspace";
@@ -212,8 +212,8 @@ export function DevicePanel(props: {
212212
>
213213
<div hidden={!!activeDevice}>
214214
{diagnostics.map((diagnostic) => (
215-
<DeviceDiscoveryStatus
216-
key={`${environmentId}\u0000${diagnostic.hostId}`}
215+
<DeviceDiscoveryWarning
216+
key={`${environmentId}\u0000${diagnostic.hostId}\u0000${diagnostic.detail}`}
217217
label={diagnostic.label}
218218
detail={diagnostic.detail}
219219
/>
@@ -227,7 +227,9 @@ export function DevicePanel(props: {
227227
</div>
228228
) : null}
229229
{operationError ? (
230-
<DeviceError onDismiss={() => setOperation(null)}>{operationError}</DeviceError>
230+
<DeviceNotice tone="error" onDismiss={() => setOperation(null)}>
231+
{operationError}
232+
</DeviceNotice>
231233
) : null}
232234
</div>
233235
<div className="@container relative flex min-h-0 flex-1">
@@ -238,7 +240,9 @@ export function DevicePanel(props: {
238240
device={activeDevice}
239241
hostLabel={activeHost?.label ?? "Device host"}
240242
simlock={activeHost?.kind === "simlock"}
241-
hostDiagnostics={diagnostics.find(({ hostId }) => hostId === activeDevice.hostId)}
243+
hostDiagnostics={
244+
diagnostics.find(({ hostId }) => hostId === activeDevice.hostId)?.detail
245+
}
242246
visible={props.visible}
243247
onFloat={floatActive}
244248
onClose={() => closeActive(false)}
@@ -360,11 +364,20 @@ export function DevicePanel(props: {
360364
);
361365
}
362366

363-
function DeviceError(props: { readonly onDismiss: () => void; readonly children: ReactNode }) {
367+
function DeviceNotice(props: {
368+
readonly tone: "warning" | "error";
369+
readonly onDismiss: () => void;
370+
readonly children: ReactNode;
371+
}) {
364372
return (
365373
<div
366374
role="alert"
367-
className="flex items-start gap-2 border-b bg-destructive/5 px-3 py-2 text-xs text-destructive"
375+
className={cn(
376+
"flex items-start gap-2 border-b px-3 py-2 text-xs",
377+
props.tone === "warning"
378+
? "bg-warning-surface text-warning-foreground"
379+
: "bg-destructive/5 text-destructive",
380+
)}
368381
>
369382
<CircleAlert className="mt-1 size-3.5 shrink-0" />
370383
<div
@@ -376,7 +389,7 @@ function DeviceError(props: { readonly onDismiss: () => void; readonly children:
376389
<Button
377390
size="icon-xs"
378391
variant="ghost"
379-
aria-label="Dismiss device error"
392+
aria-label={props.tone === "warning" ? "Dismiss device warning" : "Dismiss device error"}
380393
onClick={props.onDismiss}
381394
>
382395
<X />
@@ -385,6 +398,29 @@ function DeviceError(props: { readonly onDismiss: () => void; readonly children:
385398
);
386399
}
387400

401+
function DeviceDiscoveryWarning(props: { readonly label: string; readonly detail: string }) {
402+
const [open, setOpen] = useState(false);
403+
return (
404+
<Collapsible open={open} onOpenChange={setOpen}>
405+
<div
406+
role="status"
407+
className="flex items-center gap-2 border-b px-3 py-1.5 text-xs text-muted-foreground"
408+
>
409+
<CircleAlert className="size-3.5 shrink-0" />
410+
<span className="min-w-0 flex-1 truncate">
411+
Some devices on {props.label} could not be listed.
412+
</span>
413+
<CollapsibleTrigger className="shrink-0 hover:text-foreground">Details</CollapsibleTrigger>
414+
</div>
415+
<CollapsiblePanel>
416+
<DeviceNotice tone="warning" onDismiss={() => setOpen(false)}>
417+
{props.detail}
418+
</DeviceNotice>
419+
</CollapsiblePanel>
420+
</Collapsible>
421+
);
422+
}
423+
388424
function groupDevices(state: DeviceServiceState) {
389425
const groups: Array<{ platform: DevicePlatform; devices: DeviceSummary[] }> = [];
390426
for (const platform of ["ios", "android"] as const) {

‎apps/web/src/components/device/DeviceToolsPanel.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { Spinner } from "~/components/ui/spinner";
1818
import { Switch } from "~/components/ui/switch";
1919
import { Toggle, ToggleGroup } from "~/components/ui/toggle-group";
2020
import { cn } from "~/lib/utils";
21-
import { DeviceDiscoveryStatus } from "./DeviceDiscoveryStatus";
2221
import type { DeviceControls } from "./useDeviceControls";
2322
import { deviceEventLogAtom } from "./deviceHubAtoms";
2423

@@ -79,7 +78,7 @@ const LOCATION_PRESETS = [
7978

8079
export function DeviceToolsPanel(props: {
8180
readonly controls: DeviceControls;
82-
readonly hostDiagnostics: { readonly label: string; readonly detail: string } | undefined;
81+
readonly hostDiagnostics: string | undefined;
8382
readonly device: DeviceSummary;
8483
readonly access: DeviceHubAccess | null;
8584
readonly axOverlay: boolean;
@@ -120,10 +119,11 @@ export function DeviceToolsPanel(props: {
120119
) : null}
121120

122121
{props.hostDiagnostics ? (
123-
<DeviceDiscoveryStatus
124-
label={props.hostDiagnostics.label}
125-
detail={props.hostDiagnostics.detail}
126-
/>
122+
<Section title="Host diagnostics">
123+
<p className="whitespace-pre-line text-xs text-muted-foreground">
124+
{props.hostDiagnostics}
125+
</p>
126+
</Section>
127127
) : null}
128128

129129
<Section title="App">

‎apps/web/src/components/device/DeviceWorkspace.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function DeviceWorkspace(props: {
1818
hostLabel: string;
1919
/** Leased from a Simlock pool: serve-sim input, no host commands. */
2020
simlock?: boolean;
21-
hostDiagnostics: { readonly label: string; readonly detail: string } | undefined;
21+
hostDiagnostics: string | undefined;
2222
visible: boolean;
2323
onFloat: () => void;
2424
onClose: () => void;

0 commit comments

Comments
 (0)