|
1 | 1 | import type { OutputColumnMetadata } from "@internal/clickhouse"; |
2 | 2 | import { formatDurationMilliseconds, MachinePresetName } from "@trigger.dev/core/v3"; |
| 3 | +import { useState } from "react"; |
3 | 4 | import { EnvironmentLabel } from "~/components/environments/EnvironmentLabel"; |
4 | 5 | import { MachineLabelCombo } from "~/components/MachineLabelCombo"; |
5 | 6 | import { DateTimeAccurate } from "~/components/primitives/DateTime"; |
@@ -86,17 +87,50 @@ function isBooleanType(type: string): boolean { |
86 | 87 | return type === "Bool" || type === "Nullable(Bool)"; |
87 | 88 | } |
88 | 89 |
|
| 90 | +/** |
| 91 | + * Wrapper component that tracks hover state and passes it to CellValue |
| 92 | + * This optimizes rendering by only enabling tooltips when the cell is hovered |
| 93 | + */ |
| 94 | +function CellValueWrapper({ |
| 95 | + value, |
| 96 | + column, |
| 97 | + prettyFormatting, |
| 98 | +}: { |
| 99 | + value: unknown; |
| 100 | + column: OutputColumnMetadata; |
| 101 | + prettyFormatting: boolean; |
| 102 | +}) { |
| 103 | + const [hovered, setHovered] = useState(false); |
| 104 | + |
| 105 | + return ( |
| 106 | + <span |
| 107 | + className="flex-1" |
| 108 | + onMouseEnter={() => setHovered(true)} |
| 109 | + onMouseLeave={() => setHovered(false)} |
| 110 | + > |
| 111 | + <CellValue |
| 112 | + value={value} |
| 113 | + column={column} |
| 114 | + prettyFormatting={prettyFormatting} |
| 115 | + hovered={hovered} |
| 116 | + /> |
| 117 | + </span> |
| 118 | + ); |
| 119 | +} |
| 120 | + |
89 | 121 | /** |
90 | 122 | * Render a cell value based on its type and optional customRenderType |
91 | 123 | */ |
92 | 124 | function CellValue({ |
93 | 125 | value, |
94 | 126 | column, |
95 | 127 | prettyFormatting = true, |
| 128 | + hovered = false, |
96 | 129 | }: { |
97 | 130 | value: unknown; |
98 | 131 | column: OutputColumnMetadata; |
99 | 132 | prettyFormatting?: boolean; |
| 133 | + hovered?: boolean; |
100 | 134 | }) { |
101 | 135 | // Plain text mode - render everything as monospace text with truncation |
102 | 136 | if (!prettyFormatting) { |
@@ -232,7 +266,7 @@ function CellValue({ |
232 | 266 | // DateTime types |
233 | 267 | if (isDateTimeType(type)) { |
234 | 268 | if (typeof value === "string") { |
235 | | - return <DateTimeAccurate date={value} />; |
| 269 | + return <DateTimeAccurate date={value} showTooltip={hovered} />; |
236 | 270 | } |
237 | 271 | return <span>{String(value)}</span>; |
238 | 272 | } |
@@ -405,13 +439,11 @@ export function TSQLResultsTable({ |
405 | 439 | alignment={isRightAlignedColumn(col) ? "right" : "left"} |
406 | 440 | value={valueToString(row[col.name])} |
407 | 441 | > |
408 | | - <span className="flex-1"> |
409 | | - <CellValue |
410 | | - value={row[col.name]} |
411 | | - column={col} |
412 | | - prettyFormatting={prettyFormatting} |
413 | | - /> |
414 | | - </span> |
| 442 | + <CellValueWrapper |
| 443 | + value={row[col.name]} |
| 444 | + column={col} |
| 445 | + prettyFormatting={prettyFormatting} |
| 446 | + /> |
415 | 447 | </CopyableTableCell> |
416 | 448 | ))} |
417 | 449 | </TableRow> |
|
0 commit comments