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

DiagnosticsSettings.tsx

1,352 lines48.5 KB

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