Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

DiagnosticsSettings.tsx

1,331 lines48.7 KB

1import { ProcessSignalActions } from "./ProcessSignalActions";
2import { resolveUsageAccess } from "@t3tools/client-runtime/state/usage-access";
3import { environmentSession } from "../../state/session";
4import { AuthOrchestrationOperateScope } from "@t3tools/contracts";
5import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
6import { AuthEnvironmentMaintainScope } from "@t3tools/contracts";
7import { RefreshIcon } from "~/components/ui/refresh-icon";
8import {
9 AlertTriangleIcon,
10 CopyIcon,
11 FolderOpenIcon,
12 InfoIcon,
13 ChevronDownIcon,
14 ChevronRightIcon,
15} from "lucide-react";
16import {
17 isAtomCommandInterrupted,
18 squashAtomCommandFailure,
19} from "@t3tools/client-runtime/state/runtime";
20import { useRef, useState, type ReactNode } from "react";
21import type {
22 ServerProcessDiagnosticsEntry,
23 ServerProcessResourceHistorySummary,
24 ServerProcessSignal,
25} from "@t3tools/contracts";
26import * as DateTime from "effect/DateTime";
27import * as Option from "effect/Option";
28​
29import { formatBytes } from "../../lib/formatBytes";
30import { cn } from "../../lib/utils";
31import { ensureLocalApi } from "../../localApi";
32import { useOpenInPreferredEditor } from "../../editorPreferences";
33import { useRelativeTimeState } from "../../hooks/useRelativeTimeState";
34import { useEnvironmentQuery } from "../../state/query";
35import { serverEnvironment } from "../../state/server";
36import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
37import { Button } from "../ui/button";
38import { ScrollArea } from "../ui/scroll-area";
39import { Toggle, ToggleGroup } from "../ui/toggle-group";
40import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
41import { toastManager } from "../ui/toast";
42import { ExpandableText } from "./ExpandableText";
43import { ResourceTelemetryDiagnostics } from "./ResourceTelemetryDiagnostics";
44import { SettingsPageContainer, SettingsSection } from "./settingsLayout";
45import { useAtomCommand } from "../../state/use-atom-command";
46import { useSettingsScope } from "./SettingsScopeContext";
47import { TelemetryExportSettings } from "./TelemetryExportSettings";
48​
49const NUMBER_FORMAT = new Intl.NumberFormat();
50​
51function formatCount(value: number): string {
52 return NUMBER_FORMAT.format(value);
54​
55function formatDuration(value: number): string {
56 if (value < 1_000) return `${Math.round(value)} ms`;
57 return `${(value / 1_000).toFixed(value >= 10_000 ? 1 : 2).replace(/\.0+$/, "")} s`;
59​
60function RelativeTimeNoWrap(props: { value: DateTime.Utc }) {
61 const relative = useRelativeTimeState(DateTime.formatIso(props.value));
62 if (relative.status !== "relative") return null;
63 return relative.suffix ? `${relative.value}\u00a0${relative.suffix}` : relative.value;
65​
66function shortenTraceId(traceId: string): string {
67 if (traceId.length <= 32) return traceId;
68 return `${traceId.slice(0, 18)}...${traceId.slice(-10)}`;
70​
71function isStaleProcessSignalMessage(message: string | undefined): boolean {
72 return message?.includes("not a live descendant") ?? false;
74​
75function StatBlock({
76 label,
77 value,
78 tooltip,
79 tone = "default",
80}: {
81 label: string;
82 value: string;
83 tooltip?: ReactNode;
84 tone?: "default" | "warning" | "danger";
85}) {
86 return (
87 <div className="min-w-0 border-border/60 px-4 py-3 sm:px-5">
88 <div className="flex min-w-0 items-center gap-1.5 text-2xs font-medium uppercase tracking-widest text-muted-foreground/70">
89 <span className="min-w-0 truncate">{label}</span>
90 {tooltip ? (
91 <Tooltip>
92 <TooltipTrigger
93 render={
94 <button
95 type="button"
96 className="cursor-pointer inline-flex size-3.5 shrink-0 items-center justify-center rounded-sm text-muted-foreground/60 hover:text-foreground"
97 aria-label={`${label} details`}
98 >
99 <InfoIcon className="size-3" />
100 </button>
101 }
102 />
103 <TooltipPopup side="top">{tooltip}</TooltipPopup>
104 </Tooltip>
105 ) : null}
106 </div>
107 <div
108 className={cn(
109 "mt-1 truncate font-mono text-lg font-semibold tabular-nums text-foreground",
110 tone === "warning" && "text-warning-foreground",
111 tone === "danger" && "text-destructive",
112 )}
113 >
114 {value}
115 </div>
116 </div>
117 );
119​
120function StatsGrid({ children }: { children: ReactNode }) {
121 return (
122 <div className="relative grid grid-cols-2 sm:grid-cols-4">
123 <span
124 className="pointer-events-none absolute inset-y-0 left-1/2 w-px bg-border/60"
125 aria-hidden
126 />
127 <span
128 className="pointer-events-none absolute inset-x-0 top-1/2 h-px bg-border/60 sm:hidden"
129 aria-hidden
130 />
131 <span
132 className="pointer-events-none absolute inset-y-0 left-1/4 hidden w-px bg-border/60 sm:block"
133 aria-hidden
134 />
135 <span
136 className="pointer-events-none absolute inset-y-0 left-3/4 hidden w-px bg-border/60 sm:block"
137 aria-hidden
138 />
139 {children}
140 </div>
141 );
143​
144function EmptyRows({ label }: { label: string }) {
145 return <div className="px-4 py-4 text-xs text-muted-foreground sm:px-5">{label}</div>;
147​
148function DiagnosticsTable({
149 headers,
150 children,
151 minTableWidth = "min-w-[640px]",
152 columnWidths,
153}: {
154 headers: ReadonlyArray<string>;
155 children: ReactNode;
156 minTableWidth?: string;
157 columnWidths?: ReadonlyArray<string>;
158}) {
159 return (
160 <ScrollArea
161 radius="none"
162 chainVerticalScroll
163 scrollFade
164 hideScrollbars
165 className="w-full max-w-full"
166 >
167 <table
168 className={cn("w-full text-left text-xs", minTableWidth, columnWidths && "table-fixed")}
169 >
170 {columnWidths ? (
171 <colgroup>
172 {headers.map((header, index) => (
173 <col key={header} className={columnWidths[index]} />
174 ))}
175 </colgroup>
176 ) : null}
177 <thead className="border-b border-border/60 text-2xs uppercase tracking-widest text-muted-foreground/70">
178 <tr>
179 {headers.map((header, index) => (
180 <th
181 key={header}
182 className={cn(
183 "whitespace-nowrap px-4 py-2.5 font-semibold first:sm:pl-5 last:sm:pr-5",
184 !columnWidths && index === headers.length - 1 && "w-px",
185 )}
186 >
187 {header.replaceAll(" ", "\u00a0")}
188 </th>
189 ))}
190 </tr>
191 </thead>
192 <tbody className="divide-y divide-border/60">{children}</tbody>
193 </table>
194 </ScrollArea>
195 );
197​
198function TraceIdCell({ traceId }: { traceId: string }) {
199 const { copyToClipboard, isCopied: copied } = useCopyToClipboard({
200 target: "trace ID",
201 timeout: 1_200,
202 });
203​
204 return (
205 <div className="flex w-full min-w-0 max-w-full items-center gap-2">
206 <Tooltip>
207 <TooltipTrigger
208 render={
209 <span className="min-w-0 flex-1 truncate font-mono text-2xs">
210 {shortenTraceId(traceId)}
211 </span>
212 }
213 />
214 <TooltipPopup side="top" variant="code">
215 {traceId}
216 </TooltipPopup>
217 </Tooltip>
218 <Tooltip>
219 <TooltipTrigger
220 render={
221 <Button
222 size="icon-micro"
223 variant="ghost-muted"
224 aria-label={copied ? "Copied trace ID" : "Copy trace ID"}
225 onClick={() => copyToClipboard(traceId)}
226 >
227 <CopyIcon className="size-3" />
228 </Button>
229 }
230 />
231 <TooltipPopup side="top">{copied ? "Copied" : "Copy full trace ID"}</TooltipPopup>
232 </Tooltip>
233 </div>
234 );
236​
237function formatProcessName(command: string): string {
238 const firstToken = command.trim().split(/\s+/)[0];
239 if (!firstToken) return command;
240 const normalized = firstToken.replace(/^['"]|['"]$/g, "");
241 const segments = normalized.split(/[\\/]/).filter(Boolean);
242 return segments.at(-1) ?? normalized;
244​
245function formatProcessType(process: ServerProcessDiagnosticsEntry): string {
246 if (process.depth > 0) return "Subprocess";
247 if (/\b(codex|claude|opencode|cursor)\b/i.test(process.command)) return "Agent";
248 return "Process";
250​
251function ProcessNameCell({
252 process,
253 isExpanded,
254 onToggle,
255}: {
256 process: ServerProcessDiagnosticsEntry;
257 isExpanded: boolean;
258 onToggle: (pid: number) => void;
259}) {
260 const name = formatProcessName(process.command);
261 const hasChildren = process.childPids.length > 0;
262​
263 return (
264 <div
265 className="grid min-w-0 grid-cols-[1.25rem_0.375rem_minmax(0,1fr)] items-center gap-2"
266 style={{ paddingLeft: `${Math.min(process.depth, 6) * 10}px` }}
267 >
268 {hasChildren ? (
269 <Button
270 size="icon-micro"
271 variant="ghost-muted"
272 aria-label={isExpanded ? `Collapse ${name}` : `Expand ${name}`}
273 onClick={() => onToggle(process.pid)}
274 >
275 {isExpanded ? (
276 <ChevronDownIcon className="size-3.5" />
277 ) : (
278 <ChevronRightIcon className="size-3.5" />
279 )}
280 </Button>
281 ) : (
282 <span className="size-5 shrink-0" aria-hidden="true" />
283 )}
284 <span className="size-1.5 shrink-0 rounded-full bg-success/80" />
285 <Tooltip>
286 <TooltipTrigger
287 render={<span className="min-w-0 truncate font-medium text-foreground">{name}</span>}
288 />
289 <TooltipPopup side="top" variant="code">
290 {process.command}
291 </TooltipPopup>
292 </Tooltip>
293 </div>
294 );
296​
297function visibleProcessTree(
298 processes: ReadonlyArray<ServerProcessDiagnosticsEntry>,
299 collapsedPids: ReadonlySet<number>,
300) {
301 const visible: ServerProcessDiagnosticsEntry[] = [];
302 let hiddenChildDepth: number | null = null;
303​
304 for (const process of processes) {
305 if (hiddenChildDepth !== null) {
306 if (process.depth > hiddenChildDepth) continue;
307 hiddenChildDepth = null;
308 }
309​
310 visible.push(process);
311 if (collapsedPids.has(process.pid)) {
312 hiddenChildDepth = process.depth;
313 }
314 }
315​
316 return visible;
318​
319function ProcessDiagnosticsTable({
320 processes,
321 canMaintainEnvironment,
322 signalingPid,
323 onSignal,
324 emptyLabel,
325}: {
326 processes: ReadonlyArray<ServerProcessDiagnosticsEntry>;
327 canMaintainEnvironment: boolean;
328 signalingPid: number | null;
329 onSignal: (pid: number, signal: ServerProcessSignal) => void;
330 emptyLabel?: string;
331}) {
332 const [collapsedPids, setCollapsedPids] = useState<ReadonlySet<number>>(() => new Set());
333 const visibleProcesses = visibleProcessTree(processes, collapsedPids);
334​
335 const toggleProcess = (pid: number) => {
336 setCollapsedPids((previous) => {
337 const next = new Set(previous);
338 if (next.has(pid)) {
339 next.delete(pid);
340 } else {
341 next.add(pid);
342 }
343 return next;
344 });
345 };
346​
347 return (
348 <div className="border-t border-border/60">
349 <ScrollArea
350 radius="none"
351 chainVerticalScroll
352 scrollFade
353 hideScrollbars
354 className="max-h-[min(64vh,44rem)] w-full max-w-full"
355 >
356 <table className="w-full min-w-[1040px] table-fixed text-left text-xs">
357 <colgroup>
358 <col className="w-[24%]" />
359 <col className="w-[8%]" />
360 <col className="w-[10%]" />
361 <col className="w-[33%]" />
362 <col className="w-[8%]" />
363 <col className="w-[11%]" />
364 <col className="w-[6%]" />
365 </colgroup>
366 <thead className="sticky top-0 z-10 border-b border-border/60 bg-card text-2xs uppercase tracking-widest text-muted-foreground/70">
367 <tr>
368 <th className="px-4 py-2 font-semibold sm:pl-5">Name</th>
369 <th className="px-3 py-2 text-right font-semibold">CPU</th>
370 <th className="px-3 py-2 text-right font-semibold">Memory</th>
371 <th className="px-3 py-2 font-semibold">Command</th>
372 <th className="px-3 py-2 text-right font-semibold">PID</th>
373 <th className="px-3 py-2 font-semibold">Type</th>
374 <th className="p-2 text-right font-semibold sm:pr-4">Kill</th>
375 </tr>
376 </thead>
377 <tbody className="divide-y divide-border/50">
378 {visibleProcesses.length === 0 ? (
379 <tr>
380 <td colSpan={7} className="px-4 py-4 text-xs text-muted-foreground sm:px-5">
381 {emptyLabel ?? "No live descendant processes found."}
382 </td>
383 </tr>
384 ) : null}
385 {visibleProcesses.map((process) => (
386 <tr key={process.pid} className="hover:bg-muted/20">
387 <td className="px-4 py-2 align-middle sm:pl-5">
388 <ProcessNameCell
389 process={process}
390 isExpanded={!collapsedPids.has(process.pid)}
391 onToggle={toggleProcess}
392 />
393 </td>
394 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums">
395 {process.cpuPercent.toFixed(1)}%
396 </td>
397 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums">
398 {formatBytes(process.rssBytes)}
399 </td>
400 <td className="px-3 py-2 align-middle text-muted-foreground">
401 <Tooltip>
402 <TooltipTrigger
403 render={<span className="block truncate">{process.command}</span>}
404 />
405 <TooltipPopup side="top" variant="code">
406 {process.command}
407 </TooltipPopup>
408 </Tooltip>
409 </td>
410 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums text-muted-foreground">
411 {process.pid}
412 </td>
413 <td className="truncate px-3 py-2 align-middle text-muted-foreground">
414 {formatProcessType(process)}
415 </td>
416 <td className="p-2 align-middle sm:pr-4">
417 <ProcessSignalActions
418 disabled={!canMaintainEnvironment || signalingPid === process.pid}
419 onSignal={(signal) => onSignal(process.pid, signal)}
420 />
421 </td>
422 </tr>
423 ))}
424 </tbody>
425 </table>
426 </ScrollArea>
427 </div>
428 );
430​
431const RESOURCE_HISTORY_WINDOWS = [
432 { label: "5m", windowMs: 5 * 60_000, bucketMs: 30_000 },
433 { label: "15m", windowMs: 15 * 60_000, bucketMs: 60_000 },
434 { label: "30m", windowMs: 30 * 60_000, bucketMs: 2 * 60_000 },
435 { label: "1h", windowMs: 60 * 60_000, bucketMs: 5 * 60_000 },
436] as const;
437​
438function formatCpuTime(seconds: number): string {
439 if (seconds < 60) return `${seconds.toFixed(seconds >= 10 ? 1 : 2).replace(/\.0+$/, "")}s`;
440 const minutes = seconds / 60;
441 if (minutes < 60) return `${minutes.toFixed(minutes >= 10 ? 1 : 2).replace(/\.0+$/, "")}m`;
442 return `${(minutes / 60).toFixed(2).replace(/\.0+$/, "")}h`;
444​
445function formatShortProcessName(command: string): string {
446 const name = formatProcessName(command);
447 return name.length > 42 ? `${name.slice(0, 39)}...` : name;
449​
450function ResourceHistoryProcessNameCell({
451 process,
452 visualDepth,
453}: {
454 process: ServerProcessResourceHistorySummary;
455 visualDepth: number;
456}) {
457 const name = formatShortProcessName(process.command);
458​
459 return (
460 <div
461 className="grid min-w-0 grid-cols-[1.25rem_0.375rem_minmax(0,1fr)] items-center gap-2"
462 style={{ paddingLeft: `${Math.min(visualDepth, 6) * 10}px` }}
463 aria-label={`${process.isServerRoot ? "Root" : "Child"} process ${name}`}
464 >
465 <span className="size-5 shrink-0" aria-hidden="true" />
466 <span
467 className={cn(
468 "size-1.5 shrink-0 rounded-full",
469 process.isServerRoot ? "bg-warning/90" : "bg-success/80",
470 )}
471 />
472 <Tooltip>
473 <TooltipTrigger
474 render={<span className="min-w-0 truncate font-medium text-foreground">{name}</span>}
475 />
476 <TooltipPopup side="top" variant="code">
477 {process.command}
478 </TooltipPopup>
479 </Tooltip>
480 </div>
481 );
483​
484function ProcessResourceHistoryChart({
485 buckets,
486}: {
487 buckets: ReadonlyArray<{
488 readonly startedAt: DateTime.Utc;
489 readonly avgCpuPercent: number;
490 readonly maxCpuPercent: number;
491 }>;
492}) {
493 const maxCpuPercent = Math.max(1, ...buckets.map((bucket) => bucket.maxCpuPercent));
494​
495 return (
496 <div className="border-t border-border/60 px-4 py-3 sm:px-5">
497 <div className="flex h-28 items-end gap-1 overflow-hidden rounded-sm bg-muted/10 p-2">
498 {buckets.map((bucket) => {
499 const peakHeight = Math.max(2, (bucket.maxCpuPercent / maxCpuPercent) * 100);
500 const averageHeight = Math.max(2, (bucket.avgCpuPercent / maxCpuPercent) * 100);
501 return (
502 <Tooltip key={DateTime.formatIso(bucket.startedAt)}>
503 <TooltipTrigger
504 render={
505 <div className="flex h-full min-w-1 flex-1 items-end">
506 <div
507 className="relative h-full w-full"
508 aria-label={`Average CPU ${bucket.avgCpuPercent.toFixed(1)}%, peak CPU ${bucket.maxCpuPercent.toFixed(1)}%`}
509 >
510 <div
511 className="absolute inset-x-0 bottom-0 rounded-t-sm bg-foreground/15 transition-colors"
512 style={{ height: `${peakHeight}%` }}
513 />
514 <div
515 className="absolute inset-x-0 bottom-0 rounded-t-sm bg-foreground/60 transition-colors"
516 style={{ height: `${averageHeight}%` }}
517 />
518 </div>
519 </div>
520 }
521 />
522 <TooltipPopup side="top">
523 Avg {bucket.avgCpuPercent.toFixed(1)}%, peak {bucket.maxCpuPercent.toFixed(1)}%
524 </TooltipPopup>
525 </Tooltip>
526 );
527 })}
528 </div>
529 </div>
530 );
532​
533function ResourceHistoryWindowSelector({
534 selectedWindowMs,
535 onSelect,
536}: {
537 selectedWindowMs: number;
538 onSelect: (windowMs: number) => void;
539}) {
540 return (
541 <ToggleGroup
542 aria-label="Process history period"
543 variant="segmented"
544 value={[String(selectedWindowMs)]}
545 onValueChange={(next) => {
546 const selected = RESOURCE_HISTORY_WINDOWS.find(
547 (option) => String(option.windowMs) === next[0],
548 );
549 if (selected) onSelect(selected.windowMs);
550 }}
551 >
552 {RESOURCE_HISTORY_WINDOWS.map((option) => (
553 <Toggle key={option.windowMs} value={String(option.windowMs)}>
554 {option.label}
555 </Toggle>
556 ))}
557 </ToggleGroup>
558 );
560​
561function ProcessResourceHistoryTable({
562 processes,
563 emptyLabel,
564}: {
565 processes: ReadonlyArray<ServerProcessResourceHistorySummary>;
566 emptyLabel: string;
567}) {
568 const shallowestChildDepth = processes.reduce<number | null>((minDepth, process) => {
569 if (process.isServerRoot) return minDepth;
570 return minDepth === null ? process.depth : Math.min(minDepth, process.depth);
571 }, null);
572​
573 return (
574 <div className="border-t border-border/60">
575 <ScrollArea
576 chainVerticalScroll
577 scrollFade
578 hideScrollbars
579 className="max-h-[min(64vh,44rem)] w-full max-w-full"
580 >
581 <table className="w-full min-w-[980px] table-fixed text-left text-xs">
582 <colgroup>
583 <col className="w-[24%]" />
584 <col className="w-[10%]" />
585 <col className="w-[10%]" />
586 <col className="w-[10%]" />
587 <col className="w-[10%]" />
588 <col className="w-[10%]" />
589 <col className="w-[16%]" />
590 <col className="w-[10%]" />
591 </colgroup>
592 <thead className="sticky top-0 z-10 border-b border-border/60 bg-card text-2xs uppercase tracking-widest text-muted-foreground/70">
593 <tr>
594 <th className="px-4 py-2 font-semibold sm:pl-5">Process</th>
595 <th className="px-3 py-2 text-right font-semibold">CPU Time</th>
596 <th className="px-3 py-2 text-right font-semibold">Current</th>
597 <th className="px-3 py-2 text-right font-semibold">Average</th>
598 <th className="px-3 py-2 text-right font-semibold">Peak</th>
599 <th className="px-3 py-2 text-right font-semibold">Max Mem</th>
600 <th className="px-3 py-2 font-semibold">Command</th>
601 <th className="px-3 py-2 text-right font-semibold sm:pr-5">PID</th>
602 </tr>
603 </thead>
604 <tbody className="divide-y divide-border/50">
605 {processes.length === 0 ? (
606 <tr>
607 <td colSpan={8} className="px-4 py-4 text-xs text-muted-foreground sm:px-5">
608 {emptyLabel}
609 </td>
610 </tr>
611 ) : null}
612 {processes.map((process) => (
613 <tr key={process.processKey} className="hover:bg-muted/20">
614 <td className="px-4 py-2 align-middle sm:pl-5">
615 <ResourceHistoryProcessNameCell
616 process={process}
617 visualDepth={
618 process.isServerRoot || shallowestChildDepth === null
619 ? 0
620 : Math.max(1, process.depth - shallowestChildDepth + 1)
621 }
622 />
623 </td>
624 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums">
625 {formatCpuTime(process.cpuSecondsApprox)}
626 </td>
627 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums">
628 {process.currentCpuPercent.toFixed(1)}%
629 </td>
630 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums">
631 {process.avgCpuPercent.toFixed(1)}%
632 </td>
633 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums">
634 {process.maxCpuPercent.toFixed(1)}%
635 </td>
636 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums">
637 {formatBytes(process.maxRssBytes)}
638 </td>
639 <td className="px-3 py-2 align-middle text-muted-foreground">
640 <Tooltip>
641 <TooltipTrigger
642 render={<span className="block truncate">{process.command}</span>}
643 />
644 <TooltipPopup side="top" variant="code">
645 {process.command}
646 </TooltipPopup>
647 </Tooltip>
648 </td>
649 <td className="px-3 py-2 text-right align-middle font-mono tabular-nums text-muted-foreground sm:pr-5">
650 {process.pid}
651 </td>
652 </tr>
653 ))}
654 </tbody>
655 </table>
656 </ScrollArea>
657 </div>
658 );
660​
661function DiagnosticsLastChecked({ checkedAt }: { checkedAt: DateTime.Utc | null }) {
662 const relative = useRelativeTimeState(checkedAt ? DateTime.formatIso(checkedAt) : null);
663​
664 if (relative.status === "missing") {
665 return <span className="text-2xs text-muted-foreground/50">Checking</span>;
666 }
667​
668 if (relative.status === "invalid") {
669 return <span className="text-2xs text-muted-foreground/50">Checked unavailable</span>;
670 }
671​
672 return (
673 <span className="text-2xs text-muted-foreground/60">
674 {relative.suffix ? (
675 <>
676 Checked <span className="font-mono tabular-nums">{relative.value}</span> {relative.suffix}
677 </>
678 ) : (
679 <>Checked {relative.value}</>
680 )}
681 </span>
682 );
684​
685function DiagnosticsRefreshButton({
686 isPending,
687 label,
688 onClick,
689}: {
690 isPending: boolean;
691 label: string;
692 onClick: () => void;
693}) {
694 return (
695 <Tooltip>
696 <TooltipTrigger
697 render={
698 <Button
699 size="icon-xs"
700 variant="ghost-muted"
701 disabled={isPending}
702 onClick={onClick}
703 aria-label={label}
704 >
705 <RefreshIcon refreshing={isPending} />
706 </Button>
707 }
708 />
709 <TooltipPopup side="top">{label}</TooltipPopup>
710 </Tooltip>
711 );
713​
714export function DiagnosticsSettingsPanel() {
715 const { environment } = useSettingsScope();
716 // Signals and pending UI state belong to one environment, so a scope switch starts fresh.
717 return <DiagnosticsSettingsBody key={environment?.environmentId ?? ""} />;
719​
720function DiagnosticsSettingsBody() {
721 const { environment } = useSettingsScope();
722 const environmentId = environment?.environmentId ?? null;
723 const canMaintainEnvironment = useEnvironmentScope(environmentId, AuthEnvironmentMaintainScope);
724 const observability = environment?.serverConfig?.observability;
725 const availableEditors = environment?.serverConfig?.availableEditors;
726 const canOpenHostEditor = useEnvironmentScope(environmentId, AuthOrchestrationOperateScope);
727 const session = useEnvironmentQuery(
728 environmentId === null ? null : environmentSession.sessionStateAtom(environmentId),
729 );
730 const diagnosticsAccess = resolveUsageAccess({
731 connectionPhase: environment?.connection.phase ?? "available",
732 session: session.data,
733 hasSessionError: session.error !== null,
734 });
735 const canReadDiagnostics = diagnosticsAccess.canReadDiagnostics;
736 const signalServerProcess = useAtomCommand(serverEnvironment.signalProcess, {
737 reportFailure: false,
738 });
739 const openInEditor = useOpenInPreferredEditor(environmentId, availableEditors ?? []);
740 const [resourceWindowMs, setResourceWindowMs] = useState(15 * 60_000);
741 const selectedResourceWindow =
742 RESOURCE_HISTORY_WINDOWS.find((option) => option.windowMs === resourceWindowMs) ??
743 RESOURCE_HISTORY_WINDOWS[1];
744 const { data, error, isPending, refresh } = useEnvironmentQuery(
745 environmentId === null || !canReadDiagnostics
746 ? null
747 : serverEnvironment.traceDiagnostics({ environmentId, input: {} }),
748 );
749 const {
750 data: processData,
751 error: processError,
752 isPending: isProcessPending,
753 refresh: refreshProcesses,
754 } = useEnvironmentQuery(
755 environmentId === null || !canReadDiagnostics
756 ? null
757 : serverEnvironment.processDiagnostics({ environmentId, input: {} }),
758 );
759 const {
760 data: resourceData,
761 error: resourceError,
762 isPending: isResourcePending,
763 refresh: refreshResources,
764 } = useEnvironmentQuery(
765 environmentId === null || !canReadDiagnostics
766 ? null
767 : serverEnvironment.processResourceHistory({
768 environmentId,
769 input: {
770 windowMs: selectedResourceWindow.windowMs,
771 bucketMs: selectedResourceWindow.bucketMs,
772 },
773 }),
774 );
775 const [isOpeningLogsDirectory, setIsOpeningLogsDirectory] = useState(false);
776 const [openLogsDirectoryError, setOpenLogsDirectoryError] = useState<string | null>(null);
777 const [signalingPid, setSignalingPid] = useState<number | null>(null);
778 const signalingPidRef = useRef<number | null>(null);
779​
780 const openLogsDirectory = () => {
781 const logsDirectoryPath = observability?.logsDirectoryPath ?? null;
782 if (!logsDirectoryPath) return;
783​
784 if (
785 environmentId === null ||
786 !readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)
787 ) {
788 return;
789 }
790​
791 setIsOpeningLogsDirectory(true);
792 setOpenLogsDirectoryError(null);
793 void (async () => {
794 const result = await openInEditor(logsDirectoryPath);
795 setIsOpeningLogsDirectory(false);
796 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
797 const error = squashAtomCommandFailure(result);
798 setOpenLogsDirectoryError(
799 error instanceof Error ? error.message : "Unable to open logs folder.",
800 );
801 }
802 })();
803 };
804​
805 const isInitialLoading = isPending && data === null;
806 const isProcessInitialLoading = isProcessPending && processData === null;
807 const isResourceInitialLoading = isResourcePending && resourceData === null;
808 // Wait for initial tables to stabilize search targets; later loads must preserve export drafts.
809 const [exportFormEnvironmentId, setExportFormEnvironmentId] =
810 useState<typeof environmentId>(null);
811 if (
812 exportFormEnvironmentId !== environmentId &&
813 canReadDiagnostics &&
814 !isInitialLoading &&
815 !isProcessInitialLoading &&
816 !isResourceInitialLoading
817 ) {
818 setExportFormEnvironmentId(environmentId);
819 }
820 const signalProcess = async (pid: number, signal: ServerProcessSignal) => {
821 const targetEnvironmentId = environmentId;
822 const process = processData?.processes.find((entry) => entry.pid === pid);
823 if (
824 targetEnvironmentId === null ||
825 process === undefined ||
826 !readEnvironmentScope(targetEnvironmentId, AuthEnvironmentMaintainScope)
827 )
828 return;
829 if (signalingPidRef.current !== null) return;
830 signalingPidRef.current = pid;
831 setSignalingPid(pid);
832 const clearSignaling = () => {
833 signalingPidRef.current = null;
834 setSignalingPid(null);
835 };
836 if (signal === "SIGKILL") {
837 let confirmed = false;
838 try {
839 confirmed = await ensureLocalApi().dialogs.confirm(
840 `Send SIGKILL to process ${pid}? This cannot be handled by the process.`,
841 { variant: "destructive" },
842 );
843 } catch (error) {
844 clearSignaling();
845 toastManager.add({
846 type: "error",
847 title: "Could not confirm signal",
848 description: error instanceof Error ? error.message : `Failed to send ${signal}.`,
849 });
850 return;
851 }
852 if (!confirmed) {
853 clearSignaling();
854 return;
855 }
856 }
857 // The server rejects a pid whose start time no longer matches, so a process that exited
858 // during confirmation is never signaled by mistake.
859 if (!readEnvironmentScope(targetEnvironmentId, AuthEnvironmentMaintainScope)) {
860 clearSignaling();
861 return;
862 }
863​
864 const result = await signalServerProcess({
865 environmentId: targetEnvironmentId,
866 input: { pid, startTimeMs: process.startTimeMs, signal },
867 });
868 clearSignaling();
869 if (result._tag === "Failure") {
870 if (!isAtomCommandInterrupted(result)) {
871 const error = squashAtomCommandFailure(result);
872 toastManager.add({
873 type: "error",
874 title: `Could not send ${signal}`,
875 description: error instanceof Error ? error.message : `Failed to send ${signal}.`,
876 });
877 }
878 return;
879 }
880 if (!result.value.signaled) {
881 const message = Option.getOrUndefined(result.value.message);
882 refreshProcesses();
883 if (isStaleProcessSignalMessage(message)) {
884 toastManager.add({
885 type: "info",
886 title: "Process already exited",
887 description: "The process is not a child of the T3 Server. It might already have exited.",
888 });
889 return;
890 }
891​
892 toastManager.add({
893 type: "error",
894 title: `Could not send ${signal}`,
895 description: message ?? `Failed to send ${signal}.`,
896 });
897 return;
898 }
899 refreshProcesses();
900 };
901​
902 const processDiagnosticsError = processData ? Option.getOrNull(processData.error) : null;
903 const processResourceError = resourceData ? Option.getOrNull(resourceData.error) : null;
904 const traceDiagnosticsError = data ? Option.getOrNull(data.error) : null;
905 const traceDiagnosticsPartialFailure = data
906 ? Option.getOrElse(data.partialFailure, () => false)
907 : false;
908​
909 if (!canReadDiagnostics) {
910 return (
911 <SettingsPageContainer>
912 <p className="text-sm text-muted-foreground">
913 {environmentId === null
914 ? "Connect an environment to see diagnostics."
915 : diagnosticsAccess.isPending
916 ? "Checking diagnostics access…"
917 : diagnosticsAccess.error}
918 </p>
919 </SettingsPageContainer>
920 );
921 }
922​
923 return (
924 <SettingsPageContainer width="expanded" className="gap-10">
925 <ResourceTelemetryDiagnostics environmentId={environmentId} />
926​
927 <SettingsSection
928 title="Live Processes"
929 headerAction={
930 <div className="flex items-center gap-1.5">
931 <DiagnosticsLastChecked checkedAt={processData?.readAt ?? null} />
932 <DiagnosticsRefreshButton
933 isPending={isProcessPending}
934 label="Refresh process diagnostics"
935 onClick={refreshProcesses}
936 />
937 </div>
938 }
939 >
940 <StatsGrid>
941 <StatBlock
942 label="Child Processes"
943 value={processData ? formatCount(processData.processCount) : "..."}
944 />
945 <StatBlock
946 label="CPU"
947 value={processData ? `${processData.totalCpuPercent.toFixed(1)}%` : "..."}
948 tooltip="Total CPU across live child processes of the current server process. The desktop shell and other parent processes are not included."
949 />
950 <StatBlock
951 label="Memory"
952 value={processData ? formatBytes(processData.totalRssBytes) : "..."}
953 tooltip="Total resident memory across live child processes of the current server process. The desktop shell and other parent processes are not included."
954 />
955 <StatBlock
956 label="Server PID"
957 value={processData ? String(processData.serverPid) : "..."}
958 />
959 </StatsGrid>
960 {processDiagnosticsError || processError ? (
961 <div className="space-y-2 border-t border-border/60 px-4 py-3 text-xs text-muted-foreground sm:px-5">
962 {processDiagnosticsError ? (
963 <div className="flex items-start gap-2 text-destructive">
964 <AlertTriangleIcon className="size-3.5 h-lh shrink-0" />
965 <span>{processDiagnosticsError.message}</span>
966 </div>
967 ) : null}
968 {processError ? (
969 <div className="flex items-start gap-2 text-destructive">
970 <AlertTriangleIcon className="size-3.5 h-lh shrink-0" />
971 <span>{processError}</span>
972 </div>
973 ) : null}
974 </div>
975 ) : null}
976 <ProcessDiagnosticsTable
977 processes={processData?.processes ?? []}
978 canMaintainEnvironment={canMaintainEnvironment}
979 signalingPid={signalingPid}
980 onSignal={signalProcess}
981 emptyLabel={
982 isProcessInitialLoading
983 ? "Loading live processes..."
984 : "No live descendant processes found."
985 }
986 />
987 </SettingsSection>
988​
989 <SettingsSection
990 title="Resource History"
991 headerAction={
992 <div className="flex items-center gap-1.5">
993 <ResourceHistoryWindowSelector
994 selectedWindowMs={resourceWindowMs}
995 onSelect={setResourceWindowMs}
996 />
997 <DiagnosticsLastChecked checkedAt={resourceData?.readAt ?? null} />
998 <DiagnosticsRefreshButton
999 isPending={isResourcePending}
1000 label="Refresh resource history"
1001 onClick={refreshResources}
1002 />
1003 </div>
1006 <StatsGrid>
1007 <StatBlock
1008 label="CPU Time"
1009 value={resourceData ? formatCpuTime(resourceData.totalCpuSecondsApprox) : "..."}
1010 tooltip="Approximate active CPU time for the T3 server root process and its descendants during the selected window. It grows only while sampled processes use CPU and older samples leave as the window moves."
1011 />
1012 <StatBlock
1013 label="Samples"
1014 value={resourceData ? formatCount(resourceData.retainedSampleCount) : "..."}
1015 tooltip="In-memory process samples retained by the server. The server samples only while diagnostics is open, and this resets when the server restarts."
1016 />
1017 <StatBlock
1018 label="Interval"
1019 value={
1020 resourceData
1021 ? resourceData.sampleIntervalMs === 0
1022 ? "On demand"
1023 : formatDuration(resourceData.sampleIntervalMs)
1024 : "..."
1026 />
1027 <StatBlock
1028 label="Processes"
1029 value={resourceData ? formatCount(resourceData.topProcesses.length) : "..."}
1030 />
1031 </StatsGrid>
1032 {processResourceError || resourceError ? (
1033 <div className="space-y-2 border-t border-border/60 px-4 py-3 text-xs text-muted-foreground sm:px-5">
1034 {processResourceError ? (
1035 <div className="flex items-start gap-2 text-destructive">
1036 <AlertTriangleIcon className="size-3.5 h-lh shrink-0" />
1037 <span>{processResourceError.message}</span>
1038 </div>
1039 ) : null}
1040 {resourceError ? (
1041 <div className="flex items-start gap-2 text-destructive">
1042 <AlertTriangleIcon className="size-3.5 h-lh shrink-0" />
1043 <span>{resourceError}</span>
1044 </div>
1045 ) : null}
1046 </div>
1047 ) : null}
1048 <ProcessResourceHistoryChart buckets={resourceData?.buckets ?? []} />
1049 <ProcessResourceHistoryTable
1050 processes={resourceData?.topProcesses ?? []}
1051 emptyLabel={
1052 isResourceInitialLoading
1053 ? "Collecting process resource samples..."
1054 : "No process resource samples found for this window."
1056 />
1057 </SettingsSection>
1058​
1059 <SettingsSection
1060 title="Trace Diagnostics"
1061 headerAction={
1062 <div className="flex items-center gap-1.5">
1063 <DiagnosticsLastChecked checkedAt={data?.readAt ?? null} />
1064 <Tooltip>
1065 <TooltipTrigger
1066 render={
1067 <Button
1068 size="icon-xs"
1069 variant="ghost-muted"
1070 disabled={
1071 !canOpenHostEditor ||
1072 !observability?.logsDirectoryPath ||
1073 isOpeningLogsDirectory
1075 onClick={openLogsDirectory}
1076 aria-label="Open logs folder"
1078 <FolderOpenIcon />
1079 </Button>
1081 />
1082 <TooltipPopup side="top">Open logs folder</TooltipPopup>
1083 </Tooltip>
1084 <DiagnosticsRefreshButton
1085 isPending={isPending}
1086 label="Refresh trace diagnostics"
1087 onClick={refresh}
1088 />
1089 </div>
1092 <StatsGrid>
1093 <StatBlock label="Spans" value={data ? formatCount(data.recordCount) : "..."} />
1094 <StatBlock
1095 label="Failures"
1096 value={data ? formatCount(data.failureCount) : "..."}
1097 tone={data && data.failureCount > 0 ? "danger" : "default"}
1098 />
1099 <StatBlock
1100 label="Slow Spans"
1101 value={data ? formatCount(data.slowSpanCount) : "..."}
1102 tooltip={
1103 data
1104 ? `Spans with a duration of ${formatDuration(data.slowSpanThresholdMs)} or longer.`
1105 : "Spans at or above the configured slow-span threshold."
1107 tone={data && data.slowSpanCount > 0 ? "warning" : "default"}
1108 />
1109 <StatBlock
1110 label="Parse Errors"
1111 value={data ? formatCount(data.parseErrorCount) : "..."}
1112 tone={data && data.parseErrorCount > 0 ? "warning" : "default"}
1113 />
1114 </StatsGrid>
1115 {openLogsDirectoryError || traceDiagnosticsError || error ? (
1116 <div className="space-y-2 border-t border-border/60 px-4 py-3 text-xs text-muted-foreground sm:px-5">
1117 {openLogsDirectoryError ? (
1118 <div className="flex items-start gap-2 text-destructive">
1119 <AlertTriangleIcon className="size-3.5 h-lh shrink-0" />
1120 <span>{openLogsDirectoryError}</span>
1121 </div>
1122 ) : null}
1123 {traceDiagnosticsError ? (
1124 <div
1125 className={cn(
1126 "flex items-start gap-2",
1127 traceDiagnosticsPartialFailure ? "text-warning-foreground" : "text-destructive",
1128 )}
1130 <AlertTriangleIcon className="size-3.5 h-lh shrink-0" />
1131 <span>
1132 {traceDiagnosticsPartialFailure
1133 ? `Some trace files could not be read, so diagnostics may be incomplete. ${traceDiagnosticsError.message}`
1134 : traceDiagnosticsError.message}
1135 </span>
1136 </div>
1137 ) : null}
1138 {error ? (
1139 <div className="flex items-start gap-2 text-destructive">
1140 <AlertTriangleIcon className="size-3.5 h-lh shrink-0" />
1141 <span>{error}</span>
1142 </div>
1143 ) : null}
1144 </div>
1145 ) : null}
1146 </SettingsSection>
1147​
1148 <SettingsSection title="Latest Failures">
1149 {data && data.latestFailures.length > 0 ? (
1150 <DiagnosticsTable headers={["Span", "Cause", "Duration", "Ended"]}>
1151 {data.latestFailures.map((failure) => (
1152 <tr key={`${failure.traceId}:${failure.spanId}`}>
1153 <td className="px-4 py-3 align-top text-xs font-medium text-foreground first:sm:pl-5">
1154 {failure.name}
1155 </td>
1156 <td className="max-w-[360px] px-4 py-3 align-top text-muted-foreground">
1157 <ExpandableText text={failure.cause} />
1158 </td>
1159 <td className="px-4 py-3 align-top font-mono tabular-nums">
1160 {formatDuration(failure.durationMs)}
1161 </td>
1162 <td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground last:sm:pr-5">
1163 <RelativeTimeNoWrap value={failure.endedAt} />
1164 </td>
1165 </tr>
1166 ))}
1167 </DiagnosticsTable>
1168 ) : (
1169 <EmptyRows label={isInitialLoading ? "Loading failures..." : "No failed spans found."} />
1170 )}
1171 </SettingsSection>
1172​
1173 <SettingsSection title="Most Common Failures">
1174 {data && data.commonFailures.length > 0 ? (
1175 <DiagnosticsTable
1176 headers={["Span", "Count", "Cause", "Last Seen"]}
1177 minTableWidth="min-w-[760px]"
1179 {data.commonFailures.map((failure) => (
1180 <tr key={`${failure.name}:${failure.cause}`}>
1181 <td className="px-4 py-3 align-top text-xs font-medium text-foreground first:sm:pl-5">
1182 {failure.name}
1183 </td>
1184 <td className="px-4 py-3 align-top font-mono tabular-nums">
1185 {formatCount(failure.count)}
1186 </td>
1187 <td className="max-w-[360px] px-4 py-3 align-top text-muted-foreground">
1188 <ExpandableText text={failure.cause} />
1189 </td>
1190 <td className="w-px whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground last:sm:pr-5">
1191 <RelativeTimeNoWrap value={failure.lastSeenAt} />
1192 </td>
1193 </tr>
1194 ))}
1195 </DiagnosticsTable>
1196 ) : (
1197 <EmptyRows
1198 label={isInitialLoading ? "Loading failure groups..." : "No repeated failures found."}
1199 />
1200 )}
1201 </SettingsSection>
1202​
1203 <SettingsSection title="Slowest Spans">
1204 {data && data.slowestSpans.length > 0 ? (
1205 <DiagnosticsTable
1206 headers={["Span", "Duration", "Ended", "Trace"]}
1207 minTableWidth="min-w-[900px]"
1208 columnWidths={["w-[44%]", "w-[14%]", "w-[12%]", "w-[30%]"]}
1210 {data.slowestSpans.map((span) => (
1211 <tr key={`${span.traceId}:${span.spanId}`}>
1212 <td className="px-4 py-3 align-top text-xs font-medium text-foreground first:sm:pl-5">
1213 {span.name}
1214 </td>
1215 <td className="px-4 py-3 align-top font-mono tabular-nums">
1216 {formatDuration(span.durationMs)}
1217 </td>
1218 <td className="w-px whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground">
1219 <RelativeTimeNoWrap value={span.endedAt} />
1220 </td>
1221 <td className="min-w-0 whitespace-nowrap px-4 py-3 align-top text-muted-foreground last:sm:pr-5">
1222 <TraceIdCell traceId={span.traceId} />
1223 </td>
1224 </tr>
1225 ))}
1226 </DiagnosticsTable>
1227 ) : (
1228 <EmptyRows label={isInitialLoading ? "Loading slow spans..." : "No spans found."} />
1229 )}
1230 </SettingsSection>
1231​
1232 <SettingsSection title="Span Logs">
1233 {data && data.latestWarningAndErrorLogs.length > 0 ? (
1234 <ScrollArea
1235 radius="none"
1236 chainVerticalScroll
1237 scrollFade
1238 hideScrollbars
1239 className="w-full max-w-full"
1241 <table className="w-full min-w-[920px] table-fixed text-left text-xs">
1242 <colgroup>
1243 <col className="w-[11%]" />
1244 <col className="w-[9%]" />
1245 <col className="w-[24%]" />
1246 <col className="w-[26%]" />
1247 <col className="w-[30%]" />
1248 </colgroup>
1249 <thead className="border-b border-border/60 text-2xs uppercase tracking-widest text-muted-foreground/70">
1250 <tr>
1251 <th className="whitespace-nowrap px-4 py-2.5 font-semibold sm:pl-5">Time</th>
1252 <th className="whitespace-nowrap px-4 py-2.5 font-semibold">Level</th>
1253 <th className="whitespace-nowrap px-4 py-2.5 font-semibold">Span</th>
1254 <th className="whitespace-nowrap px-4 py-2.5 font-semibold">Message</th>
1255 <th className="whitespace-nowrap px-4 py-2.5 font-semibold sm:pr-5">Trace</th>
1256 </tr>
1257 </thead>
1258 <tbody className="divide-y divide-border/60">
1259 {data.latestWarningAndErrorLogs.map((event) => (
1260 <tr
1261 key={`${event.traceId}:${event.spanId}:${DateTime.formatIso(event.seenAt)}:${event.message}`}
1262 className="hover:bg-muted/15"
1264 <td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground sm:pl-5">
1265 <RelativeTimeNoWrap value={event.seenAt} />
1266 </td>
1267 <td className="px-4 py-3 align-top">
1268 <span className="inline-flex rounded bg-muted px-1.5 py-0.5 font-mono text-2xs font-medium uppercase text-foreground/80">
1269 {event.level}
1270 </span>
1271 </td>
1272 <td className="px-4 py-3 align-top">
1273 <div className="truncate font-medium text-foreground">{event.spanName}</div>
1274 </td>
1275 <td className="px-4 py-3 align-top text-muted-foreground">
1276 <ExpandableText
1277 collapsedClassName="line-clamp-2"
1278 expandLabel="Show full message"
1279 text={event.message}
1280 />
1281 </td>
1282 <td className="min-w-0 whitespace-nowrap px-4 py-3 align-top text-muted-foreground sm:pr-5">
1283 <TraceIdCell traceId={event.traceId} />
1284 </td>
1285 </tr>
1286 ))}
1287 </tbody>
1288 </table>
1289 </ScrollArea>
1290 ) : (
1291 <EmptyRows
1292 label={isInitialLoading ? "Loading recent logs..." : "No warnings or errors found."}
1293 />
1294 )}
1295 </SettingsSection>
1296​
1297 <SettingsSection title="Top Span Names">
1298 {data && data.topSpansByCount.length > 0 ? (
1299 <DiagnosticsTable
1300 headers={["Span", "Count", "Failures", "Average", "Max"]}
1301 minTableWidth="min-w-[760px]"
1302 columnWidths={["w-[48%]", "w-[13%]", "w-[13%]", "w-[13%]", "w-[13%]"]}
1304 {data.topSpansByCount.map((span) => (
1305 <tr key={span.name}>
1306 <td className="px-4 py-3 align-top text-xs font-medium text-foreground first:sm:pl-5">
1307 {span.name}
1308 </td>
1309 <td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums">
1310 {formatCount(span.count)}
1311 </td>
1312 <td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums">
1313 {formatCount(span.failureCount)}
1314 </td>
1315 <td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums">
1316 {formatDuration(span.averageDurationMs)}
1317 </td>
1318 <td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums last:sm:pr-5">
1319 {formatDuration(span.maxDurationMs)}
1320 </td>
1321 </tr>
1322 ))}
1323 </DiagnosticsTable>
1324 ) : (
1325 <EmptyRows label={isInitialLoading ? "Loading span names..." : "No spans found."} />
1326 )}
1327 </SettingsSection>
1328 {exportFormEnvironmentId === environmentId && <TelemetryExportSettings />}
1329 </SettingsPageContainer>
1330 );