Repository navigation
fix(app): tighten the search results row #3855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| fix: tighten the search results row. Group by now comes first, followed by the | ||
| result count and a shorter `2,895 rows scanned · 216ms` summary, with the | ||
| actions on the right. Copy is now sentence case. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,7 +324,7 @@ function ResumeLiveTailButton({ | |
| onClick={handleResumeLiveTail} | ||
| leftSection={<IconBolt size={14} />} | ||
| > | ||
| Resume Live Tail | ||
| Resume live tail | ||
| </Button> | ||
| ); | ||
| } | ||
|
|
@@ -368,52 +368,50 @@ function SearchResultsCountGroup({ | |
| onExpandFilters, | ||
| totalCountConfig, | ||
| enableParallelQueries, | ||
| children, | ||
| groupBy, | ||
| stats, | ||
| }: { | ||
| isFilterSidebarCollapsed: boolean; | ||
| onExpandFilters: () => void; | ||
| totalCountConfig: BuilderChartConfigWithDateRange; | ||
| enableParallelQueries?: boolean; | ||
| children?: ReactNode; | ||
| groupBy?: ReactNode; | ||
| stats?: ReactNode; | ||
| }) { | ||
| return ( | ||
| <Group gap="sm" align="center"> | ||
| <Group gap={4} align="center"> | ||
| {isFilterSidebarCollapsed && ( | ||
| <ExpandFiltersButton onExpand={onExpandFilters} /> | ||
| )} | ||
| <SearchTotalCountChart | ||
| config={totalCountConfig} | ||
| queryKeyPrefix={QUERY_KEY_PREFIX} | ||
| enableParallelQueries={enableParallelQueries} | ||
| /> | ||
| </Group> | ||
| {children} | ||
| {isFilterSidebarCollapsed && ( | ||
| <ExpandFiltersButton onExpand={onExpandFilters} /> | ||
| )} | ||
| {groupBy} | ||
| <SearchTotalCountChart | ||
| config={totalCountConfig} | ||
| queryKeyPrefix={QUERY_KEY_PREFIX} | ||
| enableParallelQueries={enableParallelQueries} | ||
| /> | ||
| {stats} | ||
| </Group> | ||
| ); | ||
| } | ||
|
|
||
| /** Rows scanned and elapsed time, e.g. `2,895 rows scanned · 216 ms`. */ | ||
| export function SearchNumRows({ | ||
| config, | ||
| sqlConfig, | ||
| enabled, | ||
| searchElapsedMs, | ||
| isSearching, | ||
| isLiveTail = false, | ||
| }: { | ||
| config: ChartConfigWithDateRange; | ||
| sqlConfig?: ChartConfigWithDateRange; | ||
| enabled: boolean; | ||
| searchElapsedMs: number | null; | ||
| isSearching: boolean; | ||
| isLiveTail?: boolean; | ||
| }) { | ||
| const [statsOpened, { open: openStats, close: closeStats }] = | ||
| useDisclosure(false); | ||
| const { data, isLoading, error } = useExplainQuery(config, { | ||
| enabled, | ||
| // Keep the previous row count on screen while a new EXPLAIN runs so the | ||
| // "Scanned Rows" value doesn't flash a loading state on every live-tail | ||
| // "rows scanned" value doesn't flash a loading state on every live-tail | ||
| // poll (each poll changes the dateRange, and thus the query key). | ||
| placeholderData: keepPreviousData, | ||
| }); | ||
|
|
@@ -422,63 +420,79 @@ export function SearchNumRows({ | |
| return null; | ||
| } | ||
|
|
||
| const explainRow = data?.[0]; | ||
| const numRows = explainRow?.rows; | ||
| const hasData = !isLoading && !error && numRows != null; | ||
| const numRows = data?.[0]?.rows; | ||
|
|
||
| // During live tail we keep showing the last measured elapsed time and never | ||
| // flash the "..." loading state, so the value doesn't flicker between polls. | ||
| // flash the "…" loading state, so the value doesn't flicker between polls. | ||
| const showElapsedLoading = isSearching && !isLiveTail; | ||
| const showElapsed = showElapsedLoading || searchElapsedMs != null; | ||
|
|
||
| const parts: string[] = []; | ||
| if (isLoading) { | ||
| parts.push('… rows scanned'); | ||
| } else if (!error && numRows != null) { | ||
| parts.push(`${Number(numRows).toLocaleString()} rows scanned`); | ||
| } | ||
| if (showElapsed) { | ||
| parts.push(showElapsedLoading ? '…ms' : formatDurationMs(searchElapsedMs!)); | ||
| } | ||
|
|
||
| if (parts.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <Text size="xs" c="dimmed" aria-hidden> | ||
| · | ||
| </Text> | ||
| <Text size="xs" c="dimmed"> | ||
| {parts.join(' · ')} | ||
| </Text> | ||
| </> | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Middot gets extra flex gapLow Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 8ab7bc2. Configure here. |
||
| } | ||
|
|
||
| export function GeneratedSqlButton({ | ||
| config, | ||
| sqlConfig, | ||
| enabled, | ||
| }: { | ||
| config: ChartConfigWithDateRange; | ||
| sqlConfig?: ChartConfigWithDateRange; | ||
| enabled: boolean; | ||
| }) { | ||
| const [opened, { open, close }] = useDisclosure(false); | ||
|
|
||
| if (!enabled) { | ||
| return null; | ||
| } | ||
|
|
||
| // The preview is derived purely from config, not the explain query, so it | ||
| // renders unconditionally. Gating it on explain loading/data would make it | ||
| // flicker on every live-tail poll, since each poll changes the dateRange | ||
| // (and thus the explain queryKey). | ||
| return ( | ||
| <> | ||
| <Modal | ||
| opened={statsOpened} | ||
| onClose={closeStats} | ||
| title={sqlConfig != null ? 'Generated SQL (Timeline)' : 'Generated SQL'} | ||
| opened={opened} | ||
| onClose={close} | ||
| title={sqlConfig != null ? 'Generated SQL (timeline)' : 'Generated SQL'} | ||
| size="xl" | ||
| > | ||
| <ChartSQLPreview config={sqlConfig ?? config} enableCopy /> | ||
| </Modal> | ||
| <Group gap={4} align="center"> | ||
| <Text size="xs"> | ||
| {isLoading | ||
| ? 'Scanned Rows ...' | ||
| : error || numRows == null | ||
| ? '' | ||
| : `Scanned Rows: ${Number(numRows).toLocaleString()}`} | ||
| </Text> | ||
| {showElapsed && ( | ||
| <> | ||
| {(hasData || isLoading) && ( | ||
| <Text size="xs" c="dimmed"> | ||
| | | ||
| </Text> | ||
| )} | ||
| <Text size="xs"> | ||
| {showElapsedLoading | ||
| ? 'Elapsed Time: ...' | ||
| : `Elapsed Time: ${formatDurationMs(searchElapsedMs!)}`} | ||
| </Text> | ||
| </> | ||
| )} | ||
| {/* The generated-SQL preview is derived purely from config, not the | ||
| explain query, so it renders unconditionally. Gating it on explain | ||
| loading/data would make it flicker on every live-tail poll, since | ||
| each poll changes the dateRange (and thus the explain queryKey). */} | ||
| <Tooltip label="Show Generated SQL" position="top"> | ||
| <ActionIcon | ||
| variant="subtle" | ||
| size="sm" | ||
| color="gray" | ||
| onClick={openStats} | ||
| aria-label="Show Generated SQL" | ||
| > | ||
| <IconCode size={16} /> | ||
| </ActionIcon> | ||
| </Tooltip> | ||
| </Group> | ||
| <Tooltip label="Show generated SQL" position="top"> | ||
| <ActionIcon | ||
| variant="subtle" | ||
| size="sm" | ||
| color="gray" | ||
| onClick={open} | ||
| aria-label="Show generated SQL" | ||
| > | ||
| <IconCode size={16} /> | ||
| </ActionIcon> | ||
| </Tooltip> | ||
| </> | ||
| ); | ||
| } | ||
|
|
@@ -926,7 +940,9 @@ function formatDroppedFiltersMessage(count: number): string { | |
|
|
||
| function formatDroppedGroupByMessage(dropped: string[]): string { | ||
| const verb = dropped.length === 1 ? 'was' : 'were'; | ||
| return `Group by ${dropped.join(', ')} didn't apply to this source and ${verb} removed.`; | ||
| return `Group by ${dropped.join( | ||
| ', ', | ||
| )} didn't apply to this source and ${verb} removed.`; | ||
| } | ||
|
|
||
| // This is outside as it needs to be a stable reference | ||
|
|
@@ -2615,12 +2631,18 @@ function DBSearchPageContent() { | |
| format="short" | ||
| /> | ||
| {savedSearch.updatedBy | ||
| ? ` by ${savedSearch.updatedBy.name || savedSearch.updatedBy.email}` | ||
| ? ` by ${ | ||
| savedSearch.updatedBy.name || | ||
| savedSearch.updatedBy.email | ||
| }` | ||
| : ''} | ||
| </> | ||
| } | ||
| > | ||
| <span>{`Updated ${formatDistanceToNow(new Date(savedSearch.updatedAt), { addSuffix: true })}.`}</span> | ||
| <span>{`Updated ${formatDistanceToNow( | ||
| new Date(savedSearch.updatedAt), | ||
| { addSuffix: true }, | ||
| )}.`}</span> | ||
| </Tooltip> | ||
| )} | ||
| </Text> | ||
|
|
@@ -2947,19 +2969,27 @@ function DBSearchPageContent() { | |
| isFilterSidebarCollapsed={filtersCollapsed} | ||
| onExpandFilters={expandFilters} | ||
| totalCountConfig={totalCountConfig} | ||
| > | ||
| {histogramGroupBySelect} | ||
| </SearchResultsCountGroup> | ||
| <SearchNumRows | ||
| groupBy={histogramGroupBySelect} | ||
| stats={ | ||
| <SearchNumRows | ||
| config={{ | ||
| ...chartConfig, | ||
| dateRange: searchedTimeRange, | ||
| }} | ||
| enabled={isReady} | ||
| searchElapsedMs={searchElapsedMs} | ||
| isSearching={isAnyQueryFetching} | ||
| isLiveTail={isLive ?? false} | ||
| /> | ||
| } | ||
| /> | ||
| <GeneratedSqlButton | ||
| config={{ | ||
| ...chartConfig, | ||
| dateRange: searchedTimeRange, | ||
| }} | ||
| sqlConfig={histogramTimeChartConfig ?? undefined} | ||
| enabled={isReady} | ||
| searchElapsedMs={searchElapsedMs} | ||
| isSearching={isAnyQueryFetching} | ||
| isLiveTail={isLive ?? false} | ||
| /> | ||
| </Group> | ||
| </Box> | ||
|
|
@@ -3055,12 +3085,25 @@ function DBSearchPageContent() { | |
| onExpandFilters={expandFilters} | ||
| totalCountConfig={totalCountConfig} | ||
| enableParallelQueries | ||
| > | ||
| {/* The heatmap doesn't group. */} | ||
| {isHeatmapChartVisible | ||
| ? null | ||
| : histogramGroupBySelect} | ||
| </SearchResultsCountGroup> | ||
| // The heatmap doesn't group. | ||
| groupBy={ | ||
| isHeatmapChartVisible | ||
| ? null | ||
| : histogramGroupBySelect | ||
| } | ||
| stats={ | ||
| <SearchNumRows | ||
| config={{ | ||
| ...chartConfig, | ||
| dateRange: searchedTimeRange, | ||
| }} | ||
| enabled={isReady} | ||
| searchElapsedMs={searchElapsedMs} | ||
| isSearching={isAnyQueryFetching} | ||
| isLiveTail={isLive ?? false} | ||
| /> | ||
| } | ||
| /> | ||
| <Group gap="sm" align="center"> | ||
| {traceChartsSource != null && ( | ||
| <SegmentedControl | ||
|
|
@@ -3088,7 +3131,7 @@ function DBSearchPageContent() { | |
| handleResumeLiveTail={handleResumeLiveTail} | ||
| /> | ||
| )} | ||
| <SearchNumRows | ||
| <GeneratedSqlButton | ||
| config={{ | ||
| ...chartConfig, | ||
| dateRange: searchedTimeRange, | ||
|
|
@@ -3097,9 +3140,6 @@ function DBSearchPageContent() { | |
| histogramTimeChartConfig ?? undefined | ||
| } | ||
| enabled={isReady} | ||
| searchElapsedMs={searchElapsedMs} | ||
| isSearching={isAnyQueryFetching} | ||
| isLiveTail={isLive ?? false} | ||
| /> | ||
| </Group> | ||
| </Group> | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 P2 — Elapsed placeholder
…mshardcodes a unit the real value may not useUse a unit-free placeholder such as
….formatDurationMs(packages/app/src/utils.ts:1079) returns seconds or minutes for longer searches, so a 2.3s search shows…mswhile loading and then jumps to2.3s.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond