Skip to content

Add the column and sort editors - #3431

Merged
jordan-simonovski merged 6 commits into
mainfrom
elizabet/column-sort-editors
Oct 23, 2026
Merged

jordan-simonovski merged 6 commits into
mainfrom
elizabet/column-sort-editors

Conversation

@elizabetdev

Copy link
Copy Markdown
Member

Summary

Adds the Columns and Sort editors, and the clause parsing they share. The search page does not show them yet; mounting them is the next PR.

Removing a column already updates the sort. When that column is one field in a multi-field sort, only that field is dropped. A comma inside a backtick-quoted name stays inside that field. A sort the parser does not understand, such as Timestamp DESC NULLS LAST, is left as written.

How to reproduce

Starting point: yarn app:dev:local connected to the demo server, or the Vercel preview.

On main:

  1. Open a log search.
  2. The toolbar has Group by. It does not have Columns or Sort.

On this branch:

  1. Open the same search.
  2. The toolbar is unchanged. Columns and Sort are not mounted yet.
  3. The sort change is covered by orderByAfterRemovingSelectItem and splitClauseList in packages/app/src/__tests__/utils.test.ts. The editors are covered by the tests under packages/app/src/components/SearchResultsToolbar/__tests__/.

How to test on Vercel preview

N/A — the editors are not mounted, so nothing new is visible on the search page.

References

Made with Cursor

These editors are not on the search page yet. Removing a column now drops
only that field from a multi-field sort, including names that contain a comma.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the review/tier-3 Standard — full human review required 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: 864 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: 8
  • Production lines changed: 864 (+ 626 in test files, excluded from tier calculation)
  • Branch: elizabet/column-sort-editors
  • 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 116 in total (1.43%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@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 · 🟠 1 major · 🔵 5 minor

1 posted as inline comment(s) on the changed lines. 5 listed below.

Findings outside the changed lines

5 minor
  • 🔵 packages/app/src/components/SearchResultsToolbar/useClauseFieldOptions.ts:1569 — Field list query runs all the time and refetches on every dateRange tick → The hook calls useAllFields with no enabled flag and passes dateRange straight into the query key (useMetadata.tsx:286). With live tail, the key changes on every refresh, so getAllFields re-runs while the popover is closed, and the open Autocomplete lists reload. useGroupByKeyOptions (SearchGroupBy/useGroupByKeyOptions.ts) already handles this by passing enabled: opened and capturing dateRange when the popover opens. Add an enabled option and a captured date range here in the same way.
  • 🔵 packages/app/src/components/SearchResultsToolbar/ClausePopover.tsx:175 — storedClause's inner ternary is dead: it always returns draft → When value is non-empty, draft === value returns value, which equals draft. When value is empty, draft === defaultValue was already caught by matchesDefault. Simplify to matchesDefault(draft, defaultValue) ? '' : draft.
  • 🔵 packages/app/src/components/SearchResultsToolbar/ClausePopover.tsx:229 — renderPick's apply argument is unused by every caller → Both ColumnsPopover and SortPopover pass renderPick={() => ...} and ignore apply. Change the prop type to renderPick: () => ReactNode and call it as renderPick().
  • 🔵 packages/app/src/components/SearchResultsToolbar/ColumnsPopover.tsx:463 — Ad-hoc empty state breaks the REQUIRED EmptyState convention → The empty column list renders <Text size="xs" c="dimmed">No columns selected.</Text>. The repository conventions require EmptyState (@/components/EmptyState) for all empty states. Use <EmptyState title="No columns selected" />. The convention's title copy has no trailing period, so drop the period too.
  • 🔵 packages/app/src/components/SearchResultsToolbar/__tests__/SortPopover.test.tsx:1336 — Cancel test never checks that the draft was discarded → The test only asserts that onApply was not called after Cancel. It would still pass if a reopened popover kept the flipped direction. Reopen the popover and assert the direction control is back to 'desc', as ColumnsPopover.test.tsx's 'discards the draft on cancel' does.

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

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

Scope: 0b1e0784…HEAD — adds Columns and Sort editor popovers plus shared clause-parsing utilities (splitClauseList, parseSortKeys, orderByAfterRemovingSelectItem). The editors are not mounted on the search page in this PR.

✅ No critical issues found. No P0/P1 defects surfaced: the new clause parsing (splitClauseList, parseSortKeys, serializeSortKeys) handles backtick-quoted names, parenthesized single-direction lists, and unparseable sorts by falling back to raw SQL; orderByAfterRemovingSelectItem matches aliases by exact equality (no substring false-match); and drag-reorder ids are index-prefixed (${index}:${item}), so duplicate columns do not collide.

🟡 P2 — recommended

  • packages/app/src/components/SearchResultsToolbar/useClauseFieldOptions.ts:37 — A field-discovery failure makes useAllFields return data: [] with isError: true, but the hook only branches on fields == null/isFieldMetadataDisabled, so it calls getSqlSourceKeys([], …) and returns zero suggestions even though columns holds usable scalar fields.
    • Fix: Treat the hook's error state like the disabled/null case and fall back to getSqlSourceColumnKeys(columns, keepEveryType) so scalar columns are still offered.
    • orchestrator-verification, previous-comments
🔵 P3 nitpicks (3)
  • packages/app/src/components/SearchResultsToolbar/ColumnsPopover.tsx:96 — The dnd-kit sensors list has only MouseSensor and TouchSensor, so keyboard users can focus the grip handle but cannot reorder a column.

    • Fix: Add KeyboardSensor with sortableKeyboardCoordinates to the useSensors call.
  • packages/app/src/components/SearchResultsToolbar/ColumnsPopover.tsx:144 — The empty-column state renders an inline <Text c="dimmed">No columns selected.</Text>, which matches the BAD example for the EmptyState-required rule in agent_docs/code_style.md:260; the author declined this for the compact 220px popover and a prior reviewer concurred, so it is recorded for traceability rather than as an open defect.

    • Fix: Leave as-is or introduce a compact shared empty-state variant if the standard is tightened for in-popover placeholders.
  • packages/app/src/components/SearchResultsToolbar/ColumnsPopover.tsx:173 — The ignoreNextChangeRef guard that suppresses Mantine Autocomplete's write-back after onOptionSubmit is duplicated verbatim in SortPopover.tsx:182, so a future fix to the quirk must be applied in two places.

    • Fix: Extract the suppress-next-change behavior into a shared hook or wrapped Autocomplete.

Reviewers (3 returned): maintainability, project-standards, learnings-researcher. The orchestrator independently verified the prior-review-comment threads against the current source (confirming the useAllFields error path and the index-prefixed drag ids). Correctness, adversarial, testing, frontend-races, previous-comments, and agent-native reviewers were dispatched but had not returned when this report was synthesized; their absence means the clause-parsing logic has had lighter independent adversarial coverage than a full run would give.

Testing gaps: No test covers useClauseFieldOptions when useAllFields reports an error (data: [], isError: true) — the degraded path in the P2 finding. No learnings exist in docs/solutions/ for SQL clause/identifier parsing; capturing the backtick-aware splitting and ORDER BY rewriting after this lands would be worthwhile.

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

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 457 passed • 1 skipped • 1337s

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

Tests ran across 4 shards in parallel.

View full report →

@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 91fed66

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 Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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 Oct 23, 2026 11:11am UTC
hyperdx-storybook Ready Ready Preview Oct 23, 2026 11:11am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with two non-blocking usability issues left from the previous review.

Fix All in Claude CodeFindings

  1. P2 Keyboard users cannot reorder columns ▶
  2. P2 Field suggestions disappear ▶

Summary

Adds Columns and Sort editors without mounting them on the search page.

  • Search query clauses can be drafted in field lists or SQL editors.
  • Removing a selected column keeps unrelated sort fields in place.

Reviews (5) · Last reviewed commit: "Merge branch 'main' into elizabet/column..." · Reviewed by Greptile

Comment on lines +91 to +96
const sensors = useSensors(
useSensor(MouseSensor, { activationConstraint: { distance: 8 } }),
useSensor(TouchSensor, {
activationConstraint: { delay: 200, tolerance: 5 },
}),
);

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.

P2 Keyboard users cannot reorder columns

The reorder handles have no keyboard controls because sensors contains only MouseSensor and TouchSensor. Keyboard users can focus the handles but cannot move a column in the Fields tab. Add KeyboardSensor with sortableKeyboardCoordinates.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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

Apply stays off with nothing selected. A map key already in the list
cannot be added again, removing a duplicated column drops one row, and
a comma inside a backtick-quoted sort name stays one field.

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

Copy link
Copy Markdown
Member Author

Fix the quoted-name sort loss and satisfy the shared empty-state requirement before merging.

Greptile reviewed 4c20cbaa8. 804ed04c5 is after that.

  1. Quoted sort fields: parseSortKeys now splits with splitClauseList, so a backtick-quoted name is one field.
  2. Map fields appear twice: the option filter and the add guard use isColumnInSelect.
  3. Keyboard reorder is still open.
  4. Empty picker: EmptyState is a page heading. In this 220px list it crowds the popover, so the one-line "No columns selected." stays.

Comment thread packages/app/src/utils.ts
export function splitClauseList(input: string): string[] {
const { sqlWithReplacements, replacements } =
replaceBacktickedIdentifiers(input);
return splitAndTrimWithBracket(sqlWithReplacements).map(part =>

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 — Only the new code handles backtick names; DBSearchPage still splits a backtick name like a,b in two

splitClauseList handles backticks only for the new editors and orderByAfterRemovingSelectItem. DBSearchPage.tsx:1834 (displayedColumns, used by toggleColumn) still calls splitAndTrimWithBracket. Toggling a column from the table header turns `a,b` into `a and b`, and writes that broken SELECT back. The Columns editor would keep the same SELECT whole. Make splitAndTrimWithBracket in common-utils/src/core/utils.ts skip commas inside backticks, as it already does for ' and ". Every caller then gets the fix, and splitClauseList can go.

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

<SegmentedControl
size="xs"
fullWidth
value={mode}

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 — ClausePopover is a second copy of the Group by popover shell

SearchGroupBySelect.tsx:109-189 already has the same shell: a split button target, a Fields/SQL SegmentedControl, the draft reset on open, and Reset to default / Apply buttons. Now that ClausePopover exists, the two will drift; they already differ in Cancel vs Clear and in the subtle vs link variant for Reset. Move SearchGroupBySelect onto ClausePopover so all three toolbar clauses share one shell.

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 21, 2026 17:26
The ad hoc filter helpers drop DateTime types. These pickers need Timestamp.

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

@jordan-simonovski jordan-simonovski left a comment

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.

I've left a couple of comments to address some DRY stuff, but otherwise this looks good. Lmk when you've resolved those and I'm happy to approve!

Columns and Sort store a default the same way. The pickers reuse the
ad hoc key helpers and keep DateTime by passing their own type check.

Co-authored-by: Cursor <cursoragent@cursor.com>
// Field discovery is off for some teams, and `useAllFields` then returns
// [] rather than "still loading". Scalar columns are still known.
const keys =
isFieldMetadataDisabled || fields == null

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 — Field-metadata failure leaves the pickers with no options even though the columns are known

useMultipleAllFields (packages/app/src/hooks/useMetadata.tsx:309-316) catches a failed getAllFields and returns fields: [] with an error, so data is [], not null. getSqlSourceKeys([], columns) then returns [] and both Fields tabs have nothing to offer. Fall back to getSqlSourceColumnKeys when the fields list is empty or the result has an error, not only when isFieldMetadataDisabled || fields == null.

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

dateRange?: [Date, Date];
timestampValueExpression?: string;
}): string[] {
const { data: fields, isFieldMetadataDisabled } = useAllFields(

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 — Field options use the live dateRange with no enabled gate, unlike the Group by picker

SearchGroupBySelect (packages/app/src/components/SearchGroupBy/SearchGroupBySelect.tsx:47-55) saves dateRange when the popover opens and passes enabled: opened. Live tail moves dateRange on every refresh, and that refetches the keys and collapses the open list. This hook fetches every field even while the popover is closed. It also changes the query key on every tick, so fields drops to undefined and the options switch to the column-only fallback while the user is picking. Accept enabled and pin the dateRange in the same way.

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
* not a separator. Those names are tokenized first so a later join cannot
* insert a space inside one. The shared splitter stays unaware of backticks.
*/
export function splitClauseList(input: string): 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.

🟠 major — Backtick-aware splitting added only for the new editors; the live column toggle still splits a,b apart

splitClauseList wraps splitAndTrimWithBracket with backtick tokenization, but DBSearchPage.tsx:1834 (displayedColumns, used by toggleColumn) and SearchGroupBySelect.tsx:58/78/99 still call splitAndTrimWithBracket directly. On a SELECT such as "Timestamp, a,b, Body", toggling a column from the table header splits it into "a", "b", then joins it back as "a, b", which changes the identifier. The same SELECT now has two splitting rules: the new popover and orderByAfterRemovingSelectItem use one, and the toggle that feeds them uses the other. Move the backtick handling into splitAndTrimWithBracket in common-utils/src/core/utils.ts so every caller gets it, or at least switch displayedColumns to splitClauseList.

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

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.

the live column toggle still splits a,b apart

Not addressing in this PR: displayedColumns and the Group by splits already call splitAndTrimWithBracket on main. Reverting this PR would not change that toggle. splitClauseList stays a wrapper so the shared splitter does not learn about backticks. Switching the page over belongs with the page mount.

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.

@jordan-simonovski let me know if I should address this.

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.

I've created HDX-5797 to address this as a follow-up

@jordan-simonovski jordan-simonovski left a comment

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.

Approved. Will tackle the Major finding in a follow up as the bug wasn't introduced by your changes

@jordan-simonovski
jordan-simonovski merged commit 89ad276 into main Oct 23, 2026
36 checks passed
@kodiakhq
kodiakhq Bot deleted the elizabet/column-sort-editors branch October 23, 2026 11:59

This branch was successfully deployed

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

Labels

automerge review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants