Skip to content

Mount Columns and Sort on the search page - #3432

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

elizabetdev wants to merge 10 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: 602 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: 602 (+ 387 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.

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

4 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 • 464 passed • 1 skipped • 1323s

Status Count
✅ Passed 464
❌ Failed 0
⚠️ Flaky 4
⏭️ 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

Scope: PR #3432 — elizabet/search-columns-sort vs base 743c3c1a. 8 production files + tests (~597 production lines). Frontend TypeScript/React (Mantine) + SCSS.

Intent: Move SELECT (Columns) and ORDER BY (Sort) editing off the search query form onto the results-table toolbar as popovers, shown only in results analysis mode; drop a removed column from the sort; confirm before discarding unsaved clause edits; reflow the where/time controls below 900px.

✅ No critical issues found. No P0/P1 defects were confirmed in the changed code. The two most significant prior-review items are addressed in this diff: the broken-sort-on-removed-alias bug (orderByAfterRemovingSelectItem in packages/app/src/utils.ts now matches bare, double-quoted, and backtick-quoted alias forms) and the "confirm before discarding unsaved edits" request (clauseDirty + requestClose + useConfirm in ClausePopover.tsx).

🟡 P2 -- recommended

  • packages/app/src/utils.ts:1296 -- orderByAfterRemovingSelectItem only drops an ORDER BY key when the entire key equals the removed alias, so a key that references the alias inside a larger expression (e.g. Sort SQL mode holds lower(message) DESC while Columns removes upper(Body) AS message) is kept and the resubmitted query then references a non-existent alias and errors.
    • Fix: Also drop keys whose referenced identifiers include the removed alias, or guard resubmission when an orphaned alias remains in ORDER BY.
🔵 P3 nitpicks (2)
  • packages/app/src/utils.ts:1295 -- The alias match set is rebuilt from the unquoted alias via `"${alias}"` / `\`${alias}\ ``, so an alias written with escaped embedded quotes in ORDER BY will not match its stored form and its sort key will not be cleaned.
    • Fix: Compare against the identifier parsed from each ORDER BY key rather than string-reconstructing the quoted forms.
  • packages/app/src/components/SearchResultsToolbar/ClausePopover.tsx:112 -- The confirm(...).then(...) callback flips confirmingRef/setOpened with no guard against the component having unmounted while the modal was open.
    • Fix: Ignore the resolution if the component is no longer mounted, or accept the no-op if confirmed harmless.

Reviewers (1 completed of 10 dispatched): agent-native (no agent-native gaps — select/orderBy remain react-hook-form/query-state driven, no new user-only capability). The persona fan-out (correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, adversarial, previous-comments, learnings) was dispatched but had not returned at synthesis time; the P2/P3 findings above come from direct orchestrator-level analysis of the diff, not from those agents.

Testing gaps: orderByAfterRemovingSelectItem coverage for backtick-quoted and multi-key ORDER BY, and the dirty/confirm-discard close flow, were not verified as tested in this pass — confirm __tests__/utils.test.ts and the popover tests exercise the bare/backtick alias and discard-confirm paths.

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: 977658f

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 16, 2026 3:38pm UTC
hyperdx-storybook Ready Ready Preview Nov 16, 2026 3:38pm 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>
</>
);
};
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 cleanup from toggleColumn

toggleColumn (lines 1851-1860) already does this: read getValues('orderBy'), apply orderByAfterRemovingSelectItem with defaultSearchConfig.orderBy, then setValue('orderBy'). Move it into one local helper, e.g. orderByWithout(items: string[]), and call it from both places so the two removal paths can't drift apart. The helper should also skip setValue when nothing changed, as toggleColumn does.

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 — No test covers the Columns and Sort apply logic on the search page

The PR says a removed column is also dropped from ORDER BY, but no test checks this. The DBSearchPage unit test mocks ColumnsPopover, SortPopover and useClauseFieldOptions with empty stubs. The changed e2e specs only read the button title. Add a test that removes a SELECT item that is also in ORDER BY through the Columns popover, then checks the submitted orderBy (or the search-sort-button title) after Apply.

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

Typing in the popover reopens the completion list over Apply, so the saved-search click never lands.

Co-authored-by: Cursor <cursoragent@cursor.com>
);
};
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 duplicates toggleColumn's logic for pruning the sort and resubmitting

toggleColumn (DBSearchPage.tsx:1838) already sets select, runs orderByAfterRemovingSelectItem with defaultSearchConfig.orderBy, and calls onSubmit. That is the same as applySelect(newSelect, selected ? [selected] : []). Declare applySelect before toggleColumn and have toggleColumn call it, so the removal-to-sort rule lives in one place.

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 =
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.

🔵 minor — A new toolbarLeading element on every render cancels the memo on DBSqlRowTable and RawLogTable

Every other prop passed to DBSqlRowTableWithSideBar is wrapped in useMemo or useCallback (rowTableContext, onSortingChange, initialSortBy, …). resultsClauseEditors is fresh JSX on each render, so the memoized DBSqlRowTable and RawLogTable in DBRowTable.tsx now re-render the virtualized results table on every page render. Wrap resultsClauseEditors in useMemo, keyed on its inputs.

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

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>
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 for an untouched draft whenever the stored value equals the default text, so saved searches prompt 'Discard unsaved changes?' on a no-op close

When you open a saved search, the form's select is savedSearch.select and defaultSelect is that same string (DBSearchPage.tsx:2352). orderBy and defaultSearchConfig.orderBy match the same way. onOpen sets the draft to that value. storedClause matches the default and returns '', and '' !== value, so dirty is true. Clicking outside or toggling the button then asks for confirmation even though nothing changed. Fix: compare the effective clauses, e.g. draft.trim() !== (value || defaultValue).trim(), and add a test where value === defaultValue is non-empty.

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

]) {
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

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 977658f1 Deployed Nov 16, 2026 by vercel[bot]
Preview – hyperdx-storybook — 977658f1 Deployed Nov 16, 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