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

DiagnosticsSettings.tsx

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