Skip to content

Mount Columns and Sort on the search page - #3432

Open
elizabetdev wants to merge 11 commits into
mainfrom
elizabet/search-columns-sort
Open

elizabetdev wants to merge 11 commits into
mainfrom
elizabet/search-columns-sort

Conversation

@elizabetdev

@elizabetdev elizabetdev commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Moves SELECT and ORDER BY off the query form. On a results search, Columns and Sort sit on the results table and edit those clauses. Event Deltas and Event Patterns do not show them. On a form narrower than 900px, the where clause and the time controls each take a full row, with the where clause first. Columns and Sort wrap with the table actions instead of overlapping them.

The editors landed in #3431.

Screenshots were not captured.

Screenshots or video

Before After

How to reproduce

Starting point: yarn app:dev:local connected to the demo server, or the Vercel preview. Open a log search and run it.

On main:

  1. The query form has SELECT and ORDER BY fields.
  2. The results table has no Columns or Sort button.

On this branch:

  1. The query form has no SELECT or ORDER BY field. Group by is still there.
  2. Above the results table, Columns and Sort are next to the table controls.
  3. Click Columns. Fields lists the columns; SQL edits the SELECT clause. Reset, then Apply. A removed column is dropped from the sort when it is one of the sort fields.
  4. Click Sort. Fields lists sort fields with direction; SQL edits the ORDER BY clause. Apply runs the search.
  5. Narrow the window below 900px. The where clause takes the first row and the time controls wrap onto the next. Columns and Sort wrap with the table controls; a multi-field summary shows only the count.

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Open /search, choose a log source, and run the search.
  2. Confirm the query form has no SELECT or ORDER BY field.
  3. Confirm Columns and Sort appear with the results table controls.
  4. Click Columns. Confirm Fields and SQL are shown, then click Cancel.
  5. Click Sort. Confirm Fields and SQL are shown, then click Cancel.
  6. Confirm Group by is still in the query form.

References

@github-actions github-actions Bot added the review/tier-4 Critical — deep review + domain expert sign-off label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Tier 3 — Standard

Introduces new logic, modifies core functionality, or touches areas with non-trivial risk.

Why this tier:

  • Diff size: 606 production lines changed (Tier 2 max: < 250)

Review process: Full human review — logic, architecture, edge cases.
SLA: First-pass feedback within 1 business day.

Stats
  • Production files changed: 9
  • Production lines changed: 606 (+ 437 in test files, excluded from tier calculation)
  • Branch: elizabet/search-columns-sort
  • Author: elizabetdev

To override this classification, remove the review/tier-3 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 108 in total (1.18%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

const knownColumns = new Set(columns.map(column => column.name));
// Field discovery is off for some teams, and `useAllFields` then returns
// [] rather than "still loading". Scalar columns are still known.
const keys =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 major — Columns and Sort pickers never offer Timestamp or other DateTime fields, nor whole Map/JSON columns

getSqlSourceKeys/getSqlSourceColumnKeys (packages/app/src/components/AdhocDashboardFilter/useAdhocFilterOptions.ts:63-88) belong to the ad hoc filter. They drop every key where isAdhocComparableDataType (common-utils/src/filters.ts:963, !/\bDateTime/) is false, and they skip non-scalar top-level columns. So Timestamp/TimestampTime, the most common sort fields, never show up under 'Add sort' or 'Search columns', and neither does a whole column such as LogAttributes. Build the clause options from all columns plus map/JSON subpaths without the DateTime filter. Add a hook test with a DateTime64 column. The popover tests pass a hardcoded fieldOptions=['Body','Timestamp'], so they cannot catch this.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

export const toRows = (keys: SortKey[] | null): SortRow[] | null =>
keys?.map(key => newSortRow(key.id, key.desc)) ?? null;

/** A comma inside backticks cannot be split without breaking the identifier. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — hasCommaInsideBackticks re-implements the backtick scan that splitClauseList already does, and less accurately

splitClauseList (packages/app/src/utils.ts:1302) in this same PR splits around backtick-quoted names through replaceBacktickedIdentifiers (common-utils/src/core/utils.ts:462). That helper also skips string literals, which this scanner does not: position(Body, ',') DESCis wrongly treated as a custom sort. UsesplitClauseListinparseSortKeysinstead of bailing out tonull`, and delete this helper.

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

isFieldMetadataDisabled || fields == null
? getSqlSourceColumnKeys(columns)
: getSqlSourceKeys(fields, columns);
return Array.from(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Keys are quoted twice; the second toQuotedClickHouseKeyExpression pass and its knownColumns set can't change anything

getSqlSourceKeys and getSqlSourceColumnKeys already run every key through toQuotedKeys → toQuotedClickHouseKeyExpression (useAdhocFilterOptions.ts:54-57), and that function leaves already-quoted input alone. Drop the extra .map(...) and the knownColumns set, and just dedupe and sort the keys.

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

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

6 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 6 minor

6 posted as inline comment(s) on the changed lines.


Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@elizabetdev
elizabetdev changed the base branch from main to elizabet/column-sort-editors October 21, 2026 15:59
@elizabetdev
elizabetdev added this pull request to stack #3433 October 21, 2026 16:00
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 467 passed • 1 skipped • 996s

Status Count
✅ Passed 467
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This refactor moves SELECT/ORDER BY editing off the query form into ColumnsPopover and SortPopover on the results table. The core logic is sound: applySelect reads getValues('orderBy') at call time (no stale closure), orderByAfterRemovingSelectItem now matches bare, double-quoted, and backtick-quoted aliases (closing the prior P1), and the confirm-on-discard dialog is correctly layered above the popover (overlay z-index 400 > popover 300). All four prior review items are addressed. The findings below are hardening and coverage, not blockers.

Note: one reported P2 (confirm dialog hidden behind the popover because overlay was assumed to be z-index 200) was dropped — Mantine's overlay elevation is 400, above the popover's 300, so the dialog renders in front as intended.

🟡 P2 -- recommended

  • packages/app/src/components/SearchResultsToolbar/ClausePopover.tsx:148 -- ColumnsPopover and SortPopover own independent opened state, so clicking the sibling clause button while the first popover is dirty opens its discard-confirm (the first stays opened) while the second also opens, leaving two dropdowns open after Cancel.
    • Fix: Coordinate open state so only one clause editor is open at a time, e.g. close siblings when one opens or hoist a single "active clause" owner.
    • frontend-races, adversarial
  • packages/app/src/components/DBRowTable.tsx:1121 -- The new above-table toolbar branches (controlsAboveTable, toolbarLeading, and the relocated row-selection menu / lastItemButtons path) have no component-test assertions, so a regression that drops or misplaces controls in one mode would not be caught.
    • Fix: Add a RawLogTable test with controlsAboveTable and toolbarLeading asserting the leading node and controls render above the table and the row-selection menu appears in the toolbar, not the header.
    • testing, kieran-typescript, maintainability
🔵 P3 nitpicks (6)
  • packages/app/src/utils.ts:1297 -- orderByAfterRemovingSelectItem only drops a top-level key equal to the alias (after stripping ASC|DESC), so an ORDER BY that references the removed alias inside an expression (length(message) DESC) or with a trailing modifier (NULLS LAST, WITH FILL, COLLATE) is kept and the query errors once the column is gone.
    • Fix: Detect alias references within ORDER BY expressions and after trailing modifiers, or document the unsupported forms.
  • packages/app/src/components/SearchResultsToolbar/ColumnsPopover.tsx:140 -- removedItems is computed by exact-string diff, so editing a SELECT item's expression while keeping its alias (upper(Body) AS message → upperUTF8(Body) AS message) is treated as a removal and silently drops the still-valid sort on that alias.
    • Fix: Diff removed items on alias identity rather than exact expression text.
  • packages/app/src/components/SearchResultsToolbar/ClausePopover.tsx:116 -- confirmingRef relies on the shared useConfirm promise always resolving; an overlapping confirm() from another consumer replaces the provider state without resolving the prior promise, leaving confirmingRef stuck true so outside-click/toggle can no longer close the popover.
    • Fix: Reset confirmingRef in a finally, and resolve any in-flight confirm before replacing provider state.
  • packages/app/src/components/SearchResultsToolbar/ClausePopover.tsx:118 -- A same-page source/analysisMode change that unmounts the popover while the discard-confirm is open leaves the confirm modal dangling (it is owned by the provider, not the popover) and resolves setOpened on an unmounted component.
    • Fix: Dismiss the confirm in an effect cleanup when the editor unmounts.
  • packages/app/src/DBSearchPage.tsx:2709 -- resultsClauseEditors is rendered in three branches with divergent padding (pt="sm", pt="xs", unwrapped), and a future fourth results state would silently omit the editors.
    • Fix: Wrap the editors in one shared helper with consistent padding.
  • packages/app/src/components/DBRowTable.tsx:1121 -- The controlsAboveTable boolean drives control placement across four conditional sites (rowSelectionMenu in two spots, tableControls in two spots) that must be kept in sync by hand.
    • Fix: Centralize placement in a single renderControls(placement) or a dedicated toolbar sub-component.

Reviewers (10): correctness, adversarial, frontend-races, kieran-typescript, testing, maintainability, previous-comments, project-standards, agent-native, learnings-researcher.

Testing gaps:

  • The responsive container-query layout (SearchPage.module.scss, 900px stacking of where/time controls) has no unit or e2e coverage.
  • applySelect's multi-removal loop and onSubmit wiring are only exercised by e2e — unit suites mock the popovers out, so removing two sorted columns in one Apply is untested.
  • defaultSelect saved-search-vs-source-default branches and the pure helpers clauseDirty/storedClause lack direct unit tests.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

Comment thread packages/app/src/DBSearchPage.tsx Resolved

// SELECT and ORDER BY shape the results table, so they sit on that table
// and stay hidden on Event Deltas and Event Patterns.
const resultsClauseEditors =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — New toolbar element on every render defeats the memo on DBSqlRowTable and RawLogTable

resultsClauseEditors is a new JSX element on every DBSearchPageContent render. It is passed as toolbarLeading through DBSqlRowTableWithSideBar into the memoized DBSqlRowTable (components/DBRowTable.tsx:2071) and RawLogTable. The page memoizes every other prop to that table (useCallback/useMemo), but now any page render re-renders the whole virtualized table, for example each keystroke in the time picker input. Wrap resultsClauseEditors in useMemo, with its inputs as dependencies.

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

</>
);
};
const applySelect = useCallback(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — applySelect repeats toggleColumn's logic for pruning ORDER BY

applySelect repeats toggleColumn's steps (lines 1838-1872): set select, read orderBy with getValues, call orderByAfterRemovingSelectItem with defaultSearchConfig.orderBy, then setValue('orderBy'). Move this into one helper, for example pruneOrderByForRemovedItems(items), and call it from both places, so a change to the pruning rule cannot reach only one of them.

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

@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: afc20f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Minor
@hyperdx/api Minor
@hyperdx/otel-collector Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 17, 2026 11:31am UTC
hyperdx-storybook Ready Ready Preview Nov 17, 2026 11:31am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect the search page and its results-table workflow.

Fix sort cleanup for removed aliases before merging.

Fix All in Claude CodeFindings

  1. P1 Removed columns leave broken sorts ▶

Summary

Moves SELECT and ORDER BY into Columns and Sort popovers above search results.

  • Search results put Columns and Sort beside the table.
  • Table actions stay above the results while the table scrolls.
  • Narrow search forms put WHERE above the time controls.

The earlier toolbar-overlap thread is addressed by wrapping the controls. elizabetdev kept the where field first to preserve reading order; Greptile agreed that this matches the updated description. Both supplied threads are unnumbered.

Reviews (6) · Last reviewed commit: "fix(app): keep the clause footer above t..." · Reviewed by Greptile

Base automatically changed from elizabet/column-sort-editors to main October 23, 2026 11:59
SELECT and ORDER BY move off the query form onto the results table, and the
where row wraps under the time controls on a narrow form.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jordan-simonovski
jordan-simonovski force-pushed the elizabet/search-columns-sort branch from 2096af9 to b5442e5 Compare October 23, 2026 11:59
@github-actions github-actions Bot added review/tier-3 Standard — full human review required and removed review/tier-4 Critical — deep review + domain expert sign-off labels Oct 23, 2026
// SELECT and ORDER BY shape the results table, so they sit on that table
// and stay hidden on Event Deltas and Event Patterns.
const resultsClauseEditors =
analysisMode === 'results' ? (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 major — resultsClauseEditors is a new element on every page render, so the memoized results table re-renders on every keystroke

toolbarLeading={resultsClauseEditors} gets a fresh JSX element each time DBSearchPageContent renders. That breaks memo on both DBSqlRowTable and RawLogTable (DBRowTable.tsx:2074 and :391), whose other props from DBSqlRowTableWithSidebar are stable. The page re-renders on every WHERE keystroke because of useWatch({ name: 'where' }) at line 1631, so the virtualized table now re-renders on each one. Fix: wrap resultsClauseEditors in useMemo, keyed on analysisMode, inputSelect, inputOrderBy, clauseFieldOptions, knownColumns, applySelect, applyOrderBy, inputSourceTableConnection, inputSource and searchedTimeRange.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

);
};
const applySelect = useCallback(
(select: string, removedItems: string[]) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — applySelect repeats the ORDER BY pruning that toggleColumn already does

Lines 2307-2316 copy the getValues('orderBy') → orderByAfterRemovingSelectItem(..., defaultSearchConfig.orderBy) → setValue('orderBy') sequence from toggleColumn at lines 1851-1860. Move it into one local helper, for example pruneOrderByForRemoved(items: string[]), and call it from both, so the two column-removal paths can't drift apart.

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

Columns, Sort, and the table actions move onto another line instead of
overlapping when the results panel is narrow.

Co-authored-by: Cursor <cursoragent@cursor.com>
elizabetdev and others added 2 commits October 26, 2026 16:29
An empty SELECT is shown as the source default. That default followed the URL source, so opening Columns after a source switch copied the previous source's column list.

Co-authored-by: Cursor <cursoragent@cursor.com>
The raised footer also covered Fields autocomplete options that open inside the popover.

Co-authored-by: Cursor <cursoragent@cursor.com>

// SELECT and ORDER BY shape the results table, so they sit on that table
// and stay hidden on Event Deltas and Event Patterns.
const resultsClauseEditors =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — resultsClauseEditors is a new JSX element on every render, which defeats the memo on DBSqlRowTable and RawLogTable

DBSqlRowTable and RawLogTable are both wrapped in memo (components/DBRowTable.tsx:355 and :2078). Passing a fresh toolbarLeading element means every DBSearchPageContent render now re-renders the whole results table. Wrap the element in useMemo, keyed on analysisMode, inputSelect, inputOrderBy, defaultSelect, clauseFieldOptions, the two apply callbacks, the connection, the source and the date range. Or pass the popovers' props down and let the table render them.

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

// The dropdown source can move before the URL source does. An empty SELECT
// is shown as this default, so it has to follow the dropdown, the same way
// the sort default follows useDefaultOrderBy(inputSource).
const savedSelect =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — defaultSelect copies defaultSearchConfig's saved-search check and creates a second SELECT default

savedSelect repeats the _savedSearch gating in defaultSearchConfig (line ~1218). The only difference is that it uses inputSourceObj, while defaultSearchConfig.select uses searchedSource. Header column toggles (displayedColumns/toggleColumn, ~1832) and the Columns popover can therefore start from different defaults while the dropdown and URL sources differ. Expose the gated saved search (or both defaults) from the one memo instead of rebuilding the logic here.

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

);
};
const applySelect = useCallback(
(select: string, removedItems: string[]) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — applySelect repeats toggleColumn's rule for pruning ORDER BY

toggleColumn (~line 1851) already runs getValues('orderBy'), then orderByAfterRemovingSelectItem(..., defaultSearchConfig.orderBy), then setValue. applySelect now does the same thing in a loop. Move this into one helper, e.g. orderByAfterRemovingSelectItems(items, orderBy, default) in utils.ts next to orderByAfterRemovingSelectItem, and call it from both places so the rule can't drift.

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

wrap="nowrap"
// The SQL completion list overflows the editor onto these buttons.
// Fields mode uses an in-popover Autocomplete, which must stay above them.
style={

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — The SQL-mode footer sits above the completion list and hides suggestions under Reset/Cancel/Apply

With zIndex: var(--mantine-z-index-max) on the footer, completion items that spill past the editor go underneath the footer's transparent row. Users see them overlap the button labels and cannot click them. Fix the list staying open after blur, which is the case the e2e applyClause works around. Or give the editor area room or a max height for the list, rather than layering the footer over it.

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

);
};
const applySelect = useCallback(
(select: string, removedItems: string[]) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — No test covers the new Columns-apply wiring that drops removed columns from the sort

The PR description says removing a column drops it from the sort, but nothing tests the applySelect path. The e2e tests only set SELECT/ORDER BY through SQL, and DBSearchPage.directTrace.test mocks ColumnsPopover out. Add a test that removes an aliased column used in ORDER BY via Apply, and assert the resulting orderBy in the form or URL (including the fallback to the default sort).

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

Comment on lines +2309 to +2313
orderBy = orderByAfterRemovingSelectItem(
item,
orderBy,
defaultSearchConfig.orderBy ?? '',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Removed columns leave broken sorts

Select upper(Body) AS message, set Sort to message DESC, then remove that column through Columns and Apply. applySelect calls orderByAfterRemovingSelectItem, but that helper only matches "message", not message. The search then fails because the removed alias no longer exists. Match valid quoted and unquoted alias references when dropping sort fields.

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

onRelativeSearch={onTimePickerRelativeSearch}
showLive={analysisMode === 'results'}
isLiveMode={isLive}
// Default to relative time mode if the user has made changes to interval and reloaded.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

My only major feedback is this works, but the page has 5 rows of elements before the search results appear. We should in the future consider how we can save vertical space. it looks very off with the amount of empty space is in the source/save column.. i feel like we could compact/rearrange further.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think once we add Saved Views to the first row, along with Favorite and Share, the row will grow a little. Also in some scenarios we can have alerts.
However, table actions shouldn’t be placed in the last column. So even if we don’t add the columns and sorting controls, moving these elements out of the last column would create a new row anyway.

}
: undefined
}
>

@brandon-pereira brandon-pereira Nov 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback on this form: I got bit by this twice (I thought it was broken) so worth considering:

Image

I added SeverityNumber but did NOT hit apply, it felt like clicking 'add' was saving. Then I clicked outside the popover and lost all my work. At the very least, we should confirm when closing without saving

// The dropdown source can move before the URL source does. An empty SELECT
// is shown as this default, so it has to follow the dropdown, the same way
// the sort default follows useDefaultOrderBy(inputSource).
const savedSelect =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Default SELECT is now computed in two places that have to be kept in sync by hand

savedSelect/sourceDefaultSelect repeat the saved-search gating and Log/Trace defaultTableSelectExpression lookup that defaultSearchConfig.select already does (~line 1215). The only difference is inputSourceObj versus searchedSource. Either parameterize defaultSearchConfig (expose an input-source variant next to the searched one) or pull the logic into one helper that takes the source, so a later change to how the default is picked can't update the table and the Columns popover differently.

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

</>
);
};
const applySelect = useCallback(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — applySelect copies the ORDER BY pruning from toggleColumn

toggleColumn (~line 1856) already does getValues('orderBy') → orderByAfterRemovingSelectItem(item, orderBy, defaultSearchConfig.orderBy) → setValue. Move that into one helper, e.g. pruneOrderByForRemovedItems(items), and call it from both places, so a fix to the pruning rule reaches both the column-header remove and the Columns popover.

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

{resultsClauseEditors}
</Box>
)}
<EmptyState

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Empty state keeps h="100%" beside the new toolbar, so the column overflows

In the !queryReady branch the Flex column is h="100%" and holds the Columns/Sort Box plus an EmptyState that is also h="100%". Together they are taller than the container by the toolbar's height, which pushes the empty state down or adds a scrollbar. Give EmptyState flex: 1 / mih={0} instead of h="100%".

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

wrap="nowrap"
// The SQL completion list overflows the editor onto these buttons.
// Fields mode uses an in-popover Autocomplete, which must stay above them.
style={

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Raising the footer to max z-index hides SQL completion items behind it

In SQL mode the Reset/Cancel/Apply row is lifted above everything, and the comment says the completion list overflows onto that row. So any suggestions drawn over the footer are covered and can't be clicked: the row's transparent area still takes pointer events. Keep the completion tooltip on top instead (for example, give the editor room or keep the tooltip inside the popover), and stop the list being re-opened on blur rather than hiding it behind the buttons.

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

}

/** The SELECT the table runs with; the Columns button carries it as its title. */
async getSelectValue(): Promise<string> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — getSelectValue reads the button title (form value or default), not the SELECT the table ran

The title is value || defaultValue, built from unsubmitted form state and the new defaultSelect fallback, so the doc comment "The SELECT the table runs with" is wrong. The rewritten saved-search and search specs would still pass if Apply stopped submitting, or if the table used a different default. Fix the comment, and in the key specs also assert on the select URL param or on the rendered table headers.

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

Closing the Columns or Sort popover with an outside click, Escape, or the
trigger button discarded an unapplied draft without warning. Ask first when
Apply would change the stored clause. Cancel still discards immediately.

The confirm dialog now renders above popovers, and the Columns hint says to
add the column and then click Apply.

Co-authored-by: Cursor <cursoragent@cursor.com>
draft: string,
value: string,
defaultValue: string,
) => storedClause(draft, value, defaultValue) !== value;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 major — clauseDirty is true on open whenever the stored clause equals the default, so closing an unedited popover asks to discard

storedClause turns a draft that matches the default into ''. If value is a non-empty copy of defaultValue, '' does not equal value, so the untouched popover counts as dirty. This is the normal state for a saved search. The landing effect in DBSearchPage.tsx (~L1293) copies savedSearch.select and savedSearch.orderBy into the form, and defaultSelect/defaultSearchConfig.orderBy resolve to those same strings. So on any saved search with a custom SELECT or ORDER BY, opening Columns or Sort and clicking away pops 'Discard unsaved changes?'. Fix: compare the draft against the baseline, e.g. draft.trim() !== (value || defaultValue).trim(). Add a test where value === defaultValue.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

// The dropdown source can move before the URL source does. An empty SELECT
// is shown as this default, so it has to follow the dropdown, the same way
// the sort default follows useDefaultOrderBy(inputSource).
const savedSelect =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Second default-SELECT derivation duplicates defaultSearchConfig.select with a different source

savedSelect/sourceDefaultSelect repeat the saved-search guard in defaultSearchConfig (~L1215), but they use inputSourceObj where that code uses searchedSource. Before a source switch is submitted, the Columns button shows the new source's default while displayedColumns and the table still use the old one. Fix: keep one source of truth, e.g. expose both an input-based and a searched-based default from one memo, rather than restating the guard by hand.

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

</>
);
};
const applySelect = useCallback(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — applySelect repeats the orderBy-pruning loop from toggleColumn

toggleColumn (~L1856) already calls orderByAfterRemovingSelectItem with defaultSearchConfig.orderBy on removed items, then setValue('orderBy') and onSubmit. Fix: move a shared pruneOrderBy(removed[]) helper next to these handlers and call it from both, so the two removal paths can't drift.

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

mode === 'sql'
? {
position: 'relative',
zIndex: 'var(--mantine-z-index-max)',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Button row at --mantine-z-index-max hides SQL completion items behind Reset/Cancel/Apply

In SQL mode the CodeMirror completion list renders inside the dropdown and, as the comment says, overflows onto the button row. Raising the row to z-index max paints the buttons over any suggestions in that area, so the user can't see or click them. Fix: give the editor area enough room or limit the tooltip height. Another option is a CodeMirror tooltips({ parent: document.body }) config instead of covering the list.

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

Removing a SELECT item such as upper(Body) AS message kept ORDER BY message
DESC, because the sort was only matched against the double-quoted alias. The
search then failed on an alias that no longer exists. Match the bare,
double-quoted, and backtick-quoted forms.

Co-authored-by: Cursor <cursoragent@cursor.com>
]) {
for (const [open, field] of [
[() => searchPage.openSelectEditor(), searchPage.selectClauseField()],
[() => searchPage.openOrderByEditor(), searchPage.orderByClauseField()],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 major — Multiline SELECT/ORDER BY e2e test now hits the discard confirm and cannot reach the Sort popover

In the first iteration, expectExpandsAndStaysExpanded types 'first line\nsecond line' into the Columns SQL draft, so the draft is dirty. openOrderByEditor then clicks the Sort button, which is an outside click for the Columns popover. That opens the new useConfirm modal at overlay z-index, above the popover, and it blocks the click on the Sort SQL tab. Click Columns Cancel (or reset the draft) before opening the next editor, or have openClauseSqlTab close any open clause popover through Cancel.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

wrap="nowrap"
// The SQL completion list overflows the editor onto these buttons.
// Fields mode uses an in-popover Autocomplete, which must stay above them.
style={

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — SQL-mode button row is raised to z-index max, covering the CodeMirror completion list

The completion tooltip renders inside the popover and drops down over the Reset/Cancel/Apply row. The zIndex: var(--mantine-z-index-max) puts those buttons on top of the suggestions, so entries under them are hidden, and a click aimed at a suggestion hits Apply or Cancel instead. Leave the completion list on top (for example, give the editor/tooltip a higher stacking context or reserve space below the editor) rather than lifting the buttons over it.

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

// The dropdown source can move before the URL source does. An empty SELECT
// is shown as this default, so it has to follow the dropdown, the same way
// the sort default follows useDefaultOrderBy(inputSource).
const savedSelect =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — defaultSelect re-implements defaultSearchConfig.select with a different source object

savedSelect/sourceDefaultSelect repeat the saved-search and source-kind logic in defaultSearchConfig (DBSearchPage.tsx:1215). That memo keys off searchedSource, while this copy keys off inputSourceObj, and displayedColumns (line ~1837) still uses defaultSearchConfig.select. The two now drift by hand. Put the inputSource-based default in one place (a field on defaultSearchConfig or a shared helper) and use it from both.

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

The dirty check compared the draft with the stored clause after the
default was folded to "", so a saved search whose clause equals the
source default asked to discard on a no-op close. Compare the draft with
the clause the editor opened with.

Also stub the column lookup and confirm in the save-search page test,
which no longer had the React Query hook the page now calls. Cancel the
other clause popover before opening the next one in the e2e page object,
so the discard dialog does not block the second editor.

Co-authored-by: Cursor <cursoragent@cursor.com>
// is shown as this default, so it has to follow the dropdown, the same way
// the sort default follows useDefaultOrderBy(inputSource).
const savedSelect =
savedSearchId &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Default SELECT is now worked out in two places that can disagree

savedSelect/sourceDefaultSelect repeat the saved-search guards and the Log/Trace defaultTableSelectExpression lookup from defaultSearchConfig (lines 1215-1238). The only difference is that this copy keys off inputSourceObj while the original keys off searchedSource. Table-header column removal (displayedColumns/toggleColumn, line 1837) and the Columns popover therefore start from different defaults until the debounced submit catches up. Fix: derive the default SELECT once (or have defaultSearchConfig.select follow the input source) and use that value in both places.

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

</>
);
};
const applySelect = useCallback(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — applySelect copies toggleColumn's sort-pruning logic

The loop that calls orderByAfterRemovingSelectItem(item, getValues('orderBy'), defaultSearchConfig.orderBy) and then writes orderBy repeats toggleColumn (lines 1856-1866). The two paths that remove a column can drift apart. Fix: move 'set the select, prune the sort for removed items, submit' into one callback and call it from both places.

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

</>
);
};
const applySelect = useCallback(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — The page-level apply logic has no test

Both DBSearchPage suites mock ColumnsPopover, SortPopover and useClauseFieldOptions with stubs. Nothing checks that applying Columns writes select, drops removed aliases from orderBy (falling back to the default sort), and submits, or that Sort writes orderBy. Fix: add a page-level test with a real (or callback-capturing) ColumnsPopover that calls onApply with removed items, then assert the submitted orderBy.

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

Comment thread packages/app/src/utils.ts
}
const quoted = `"${alias}"`;
// An alias can be written bare, double-quoted, or backtick-quoted in ORDER BY
const aliasKeys = new Set([alias, `"${alias}"`, `\`${alias}\``]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Matching the bare alias also drops sorts that still work

The doc comment above orderByAfterRemovingSelectItem drops a sort because it 'stops resolving once the item is gone'. A bare alias that shadows a real column (e.g. removing lower(ServiceName) AS ServiceName while sorting by ServiceName ASC) still resolves to the table column. The user's sort is now silently replaced with the default. Fix: only drop a bare-alias key when the alias is not a table column (pass knownColumns in), or keep the bare match limited to aliases that are not table columns.

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

// The SQL completion list overflows the editor onto these buttons.
// Fields mode uses an in-popover Autocomplete, which must stay above them.
style={
mode === 'sql'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — In SQL mode the button row covers the autocomplete list

Giving the Reset/Cancel/Apply row z-index: var(--mantine-z-index-max) in SQL mode puts it above the CodeMirror completion list. Suggestions that overflow onto that row are hidden and can't be clicked. The new e2e applyClause helper has to work around this. Fix: give the popover body enough room, or let the completion tooltip render above the footer (e.g. portal it or position it above the editor), instead of burying it.

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


// SELECT and ORDER BY shape the results table, so they sit on that table
// and stay hidden on Event Deltas and Event Patterns.
const resultsClauseEditors =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — On phones the Columns/Sort popovers are wider than the screen

The editors now mount on compact viewports, which were previously collapsed behind a toggle for phones. ClausePopover uses a fixed width={440}, so on a 375px-wide phone the dropdown overflows the viewport and Popover's shift cannot fit it. Fix: cap the width, e.g. width="min(440px, calc(100vw - 16px))", or use a full-width layout when isCompact.

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

This branch was successfully deployed

2 active deployments
Preview – hyperdx-storybook — afc20f31 Deployed Nov 17, 2026 by vercel[bot]
Preview – hyperdx-oss — afc20f31 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants