Skip to content

Commit 29d2af0

Browse files
authored
fix(app): tighten the search results row (#3855)
## Summary The row above the search histogram spreads a lot of text over both sides: `553 Results`, `Group by`, then `Scanned Rows: 2,895 | Elapsed Time: 216ms` next to the actions. This tightens it. - **Group by comes first**, since it is the control. The count and query stats follow it as read-only context. - **Count and stats sit together.** `553 results · 2,895 rows scanned · 216ms` all describe the same query, so they no longer sit on opposite sides. - **Only actions are on the right:** `Resume live tail` and the generated SQL button. - **Shorter, sentence-case copy.** `Scanned Rows: …` / `Elapsed Time: …` become `… rows scanned · …ms`. `Results`, `Resume Live Tail`, `Show Generated SQL` and `Generated SQL (Timeline)` are now sentence case. - `SearchNumRows` now renders only the stats. The SQL button and modal moved to a new `GeneratedSqlButton` so they can sit on the other side. - The pattern view gets the same layout. ### Screenshots or video I couldn't capture these (no browser available in the session that opened this PR). Left for the author to fill in. #### Before <img width="1240" height="43" alt="Screenshot 2026-11-28 at 12 15 00" src="https://github.com/user-attachments/assets/0578c997-0e80-47de-b92d-8b2580ba1f22" /> #### After <img width="1240" height="43" alt="Screenshot 2026-11-28 at 12 08 06" src="https://github.com/user-attachments/assets/15b9d3fb-5d38-4a24-bfe0-42f21e2e0673" /> ### How to reproduce **Starting point:** `yarn app:dev:local` connected to the demo server (onboarding → "Connect to Demo Server"), or the Vercel preview. **On `main`:** 1. Open **Search** and pick a log source. 2. Look at the row above the histogram: `553 Results`, `Group by`, then `Scanned Rows: … | Elapsed Time: …` on the right. **On this branch:** 1. Open **Search** and pick a log source. 2. The row reads `Group by` · `N results · N rows scanned · Nms` on the left, with `Resume live tail` (when scrolled back from live) and the `</>` button on the right. 3. Switch to the **Event patterns** tab. The same layout applies. ### How to test on Vercel preview **Preview routes:** /search **Steps:** 1. Open /search and select a log source. 2. Verify the first item in the row above the histogram is the `Group by` button. 3. Verify the text after it reads like `N results · N rows scanned · Nms`. 4. Click the `</>` icon on the right and verify the `Generated SQL` modal opens. ### References - Linear Issue: - Related PRs: --- > [!NOTE] > **Low Risk** > UI layout and copy changes on the search page only; behavior (explain query, SQL preview, live-tail flicker guards) is preserved and covered by updated tests. > > **Overview** > Reorganizes the search page stats bar above the histogram so **Group by** leads on the left, then **result count** and a single dimmed stats line (`N results` stays separate; `N rows scanned · Nms` from `SearchNumRows`), with **Resume live tail** and the SQL icon grouped on the right. The same layout applies to **Results** and **Event patterns**. > > **`SearchNumRows`** now only renders scan/elapsed stats (middot-separated, shorter loading copy). The generated-SQL modal and icon move to a new **`GeneratedSqlButton`**, placed with the other right-side actions. **`SearchResultsCountGroup`** takes explicit `groupBy` and `stats` slots instead of wrapping children. > > User-facing copy shifts to **sentence case** (`results`, `Resume live tail`, `Show generated SQL`, `Generated SQL (timeline)`). Unit and e2e tests follow the new strings and component split. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f861156. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
1 parent 3bdf617 commit 29d2af0

6 files changed

Lines changed: 174 additions & 154 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@hyperdx/app': patch
3+
---
4+
5+
fix: tighten the search results row. Group by now comes first, followed by the
6+
result count and a shorter `2,895 rows scanned · 216ms` summary, with the
7+
actions on the right. Copy is now sentence case.

‎packages/app/src/DBSearchPage.tsx‎

Lines changed: 124 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ function ResumeLiveTailButton({
324324
onClick={handleResumeLiveTail}
325325
leftSection={<IconBolt size={14} />}
326326
>
327-
Resume Live Tail
327+
Resume live tail
328328
</Button>
329329
);
330330
}
@@ -368,52 +368,50 @@ function SearchResultsCountGroup({
368368
onExpandFilters,
369369
totalCountConfig,
370370
enableParallelQueries,
371-
children,
371+
groupBy,
372+
stats,
372373
}: {
373374
isFilterSidebarCollapsed: boolean;
374375
onExpandFilters: () => void;
375376
totalCountConfig: BuilderChartConfigWithDateRange;
376377
enableParallelQueries?: boolean;
377-
children?: ReactNode;
378+
groupBy?: ReactNode;
379+
stats?: ReactNode;
378380
}) {
379381
return (
380382
<Group gap="sm" align="center">
381-
<Group gap={4} align="center">
382-
{isFilterSidebarCollapsed && (
383-
<ExpandFiltersButton onExpand={onExpandFilters} />
384-
)}
385-
<SearchTotalCountChart
386-
config={totalCountConfig}
387-
queryKeyPrefix={QUERY_KEY_PREFIX}
388-
enableParallelQueries={enableParallelQueries}
389-
/>
390-
</Group>
391-
{children}
383+
{isFilterSidebarCollapsed && (
384+
<ExpandFiltersButton onExpand={onExpandFilters} />
385+
)}
386+
{groupBy}
387+
<SearchTotalCountChart
388+
config={totalCountConfig}
389+
queryKeyPrefix={QUERY_KEY_PREFIX}
390+
enableParallelQueries={enableParallelQueries}
391+
/>
392+
{stats}
392393
</Group>
393394
);
394395
}
395396

397+
/** Rows scanned and elapsed time, e.g. `2,895 rows scanned · 216 ms`. */
396398
export function SearchNumRows({
397399
config,
398-
sqlConfig,
399400
enabled,
400401
searchElapsedMs,
401402
isSearching,
402403
isLiveTail = false,
403404
}: {
404405
config: ChartConfigWithDateRange;
405-
sqlConfig?: ChartConfigWithDateRange;
406406
enabled: boolean;
407407
searchElapsedMs: number | null;
408408
isSearching: boolean;
409409
isLiveTail?: boolean;
410410
}) {
411-
const [statsOpened, { open: openStats, close: closeStats }] =
412-
useDisclosure(false);
413411
const { data, isLoading, error } = useExplainQuery(config, {
414412
enabled,
415413
// Keep the previous row count on screen while a new EXPLAIN runs so the
416-
// "Scanned Rows" value doesn't flash a loading state on every live-tail
414+
// "rows scanned" value doesn't flash a loading state on every live-tail
417415
// poll (each poll changes the dateRange, and thus the query key).
418416
placeholderData: keepPreviousData,
419417
});
@@ -422,63 +420,79 @@ export function SearchNumRows({
422420
return null;
423421
}
424422

425-
const explainRow = data?.[0];
426-
const numRows = explainRow?.rows;
427-
const hasData = !isLoading && !error && numRows != null;
423+
const numRows = data?.[0]?.rows;
428424

429425
// During live tail we keep showing the last measured elapsed time and never
430-
// flash the "..." loading state, so the value doesn't flicker between polls.
426+
// flash the "…" loading state, so the value doesn't flicker between polls.
431427
const showElapsedLoading = isSearching && !isLiveTail;
432428
const showElapsed = showElapsedLoading || searchElapsedMs != null;
433429

430+
const parts: string[] = [];
431+
if (isLoading) {
432+
parts.push('… rows scanned');
433+
} else if (!error && numRows != null) {
434+
parts.push(`${Number(numRows).toLocaleString()} rows scanned`);
435+
}
436+
if (showElapsed) {
437+
parts.push(showElapsedLoading ? '…ms' : formatDurationMs(searchElapsedMs!));
438+
}
439+
440+
if (parts.length === 0) {
441+
return null;
442+
}
443+
444+
return (
445+
<>
446+
<Text size="xs" c="dimmed" aria-hidden>
447+
&middot;
448+
</Text>
449+
<Text size="xs" c="dimmed">
450+
{parts.join(' · ')}
451+
</Text>
452+
</>
453+
);
454+
}
455+
456+
export function GeneratedSqlButton({
457+
config,
458+
sqlConfig,
459+
enabled,
460+
}: {
461+
config: ChartConfigWithDateRange;
462+
sqlConfig?: ChartConfigWithDateRange;
463+
enabled: boolean;
464+
}) {
465+
const [opened, { open, close }] = useDisclosure(false);
466+
467+
if (!enabled) {
468+
return null;
469+
}
470+
471+
// The preview is derived purely from config, not the explain query, so it
472+
// renders unconditionally. Gating it on explain loading/data would make it
473+
// flicker on every live-tail poll, since each poll changes the dateRange
474+
// (and thus the explain queryKey).
434475
return (
435476
<>
436477
<Modal
437-
opened={statsOpened}
438-
onClose={closeStats}
439-
title={sqlConfig != null ? 'Generated SQL (Timeline)' : 'Generated SQL'}
478+
opened={opened}
479+
onClose={close}
480+
title={sqlConfig != null ? 'Generated SQL (timeline)' : 'Generated SQL'}
440481
size="xl"
441482
>
442483
<ChartSQLPreview config={sqlConfig ?? config} enableCopy />
443484
</Modal>
444-
<Group gap={4} align="center">
445-
<Text size="xs">
446-
{isLoading
447-
? 'Scanned Rows ...'
448-
: error || numRows == null
449-
? ''
450-
: `Scanned Rows: ${Number(numRows).toLocaleString()}`}
451-
</Text>
452-
{showElapsed && (
453-
<>
454-
{(hasData || isLoading) && (
455-
<Text size="xs" c="dimmed">
456-
|
457-
</Text>
458-
)}
459-
<Text size="xs">
460-
{showElapsedLoading
461-
? 'Elapsed Time: ...'
462-
: `Elapsed Time: ${formatDurationMs(searchElapsedMs!)}`}
463-
</Text>
464-
</>
465-
)}
466-
{/* The generated-SQL preview is derived purely from config, not the
467-
explain query, so it renders unconditionally. Gating it on explain
468-
loading/data would make it flicker on every live-tail poll, since
469-
each poll changes the dateRange (and thus the explain queryKey). */}
470-
<Tooltip label="Show Generated SQL" position="top">
471-
<ActionIcon
472-
variant="subtle"
473-
size="sm"
474-
color="gray"
475-
onClick={openStats}
476-
aria-label="Show Generated SQL"
477-
>
478-
<IconCode size={16} />
479-
</ActionIcon>
480-
</Tooltip>
481-
</Group>
485+
<Tooltip label="Show generated SQL" position="top">
486+
<ActionIcon
487+
variant="subtle"
488+
size="sm"
489+
color="gray"
490+
onClick={open}
491+
aria-label="Show generated SQL"
492+
>
493+
<IconCode size={16} />
494+
</ActionIcon>
495+
</Tooltip>
482496
</>
483497
);
484498
}
@@ -926,7 +940,9 @@ function formatDroppedFiltersMessage(count: number): string {
926940

927941
function formatDroppedGroupByMessage(dropped: string[]): string {
928942
const verb = dropped.length === 1 ? 'was' : 'were';
929-
return `Group by ${dropped.join(', ')} didn't apply to this source and ${verb} removed.`;
943+
return `Group by ${dropped.join(
944+
', ',
945+
)} didn't apply to this source and ${verb} removed.`;
930946
}
931947

932948
// This is outside as it needs to be a stable reference
@@ -2615,12 +2631,18 @@ function DBSearchPageContent() {
26152631
format="short"
26162632
/>
26172633
{savedSearch.updatedBy
2618-
? ` by ${savedSearch.updatedBy.name || savedSearch.updatedBy.email}`
2634+
? ` by ${
2635+
savedSearch.updatedBy.name ||
2636+
savedSearch.updatedBy.email
2637+
}`
26192638
: ''}
26202639
</>
26212640
}
26222641
>
2623-
<span>{`Updated ${formatDistanceToNow(new Date(savedSearch.updatedAt), { addSuffix: true })}.`}</span>
2642+
<span>{`Updated ${formatDistanceToNow(
2643+
new Date(savedSearch.updatedAt),
2644+
{ addSuffix: true },
2645+
)}.`}</span>
26242646
</Tooltip>
26252647
)}
26262648
</Text>
@@ -2947,19 +2969,27 @@ function DBSearchPageContent() {
29472969
isFilterSidebarCollapsed={filtersCollapsed}
29482970
onExpandFilters={expandFilters}
29492971
totalCountConfig={totalCountConfig}
2950-
>
2951-
{histogramGroupBySelect}
2952-
</SearchResultsCountGroup>
2953-
<SearchNumRows
2972+
groupBy={histogramGroupBySelect}
2973+
stats={
2974+
<SearchNumRows
2975+
config={{
2976+
...chartConfig,
2977+
dateRange: searchedTimeRange,
2978+
}}
2979+
enabled={isReady}
2980+
searchElapsedMs={searchElapsedMs}
2981+
isSearching={isAnyQueryFetching}
2982+
isLiveTail={isLive ?? false}
2983+
/>
2984+
}
2985+
/>
2986+
<GeneratedSqlButton
29542987
config={{
29552988
...chartConfig,
29562989
dateRange: searchedTimeRange,
29572990
}}
29582991
sqlConfig={histogramTimeChartConfig ?? undefined}
29592992
enabled={isReady}
2960-
searchElapsedMs={searchElapsedMs}
2961-
isSearching={isAnyQueryFetching}
2962-
isLiveTail={isLive ?? false}
29632993
/>
29642994
</Group>
29652995
</Box>
@@ -3055,12 +3085,25 @@ function DBSearchPageContent() {
30553085
onExpandFilters={expandFilters}
30563086
totalCountConfig={totalCountConfig}
30573087
enableParallelQueries
3058-
>
3059-
{/* The heatmap doesn't group. */}
3060-
{isHeatmapChartVisible
3061-
? null
3062-
: histogramGroupBySelect}
3063-
</SearchResultsCountGroup>
3088+
// The heatmap doesn't group.
3089+
groupBy={
3090+
isHeatmapChartVisible
3091+
? null
3092+
: histogramGroupBySelect
3093+
}
3094+
stats={
3095+
<SearchNumRows
3096+
config={{
3097+
...chartConfig,
3098+
dateRange: searchedTimeRange,
3099+
}}
3100+
enabled={isReady}
3101+
searchElapsedMs={searchElapsedMs}
3102+
isSearching={isAnyQueryFetching}
3103+
isLiveTail={isLive ?? false}
3104+
/>
3105+
}
3106+
/>
30643107
<Group gap="sm" align="center">
30653108
{traceChartsSource != null && (
30663109
<SegmentedControl
@@ -3088,7 +3131,7 @@ function DBSearchPageContent() {
30883131
handleResumeLiveTail={handleResumeLiveTail}
30893132
/>
30903133
)}
3091-
<SearchNumRows
3134+
<GeneratedSqlButton
30923135
config={{
30933136
...chartConfig,
30943137
dateRange: searchedTimeRange,
@@ -3097,9 +3140,6 @@ function DBSearchPageContent() {
30973140
histogramTimeChartConfig ?? undefined
30983141
}
30993142
enabled={isReady}
3100-
searchElapsedMs={searchElapsedMs}
3101-
isSearching={isAnyQueryFetching}
3102-
isLiveTail={isLive ?? false}
31033143
/>
31043144
</Group>
31053145
</Group>

0 commit comments

Comments
 (0)