Skip to content

fix: run an edited Order By on a chart table instead of the last column header sort - #3746

Open
pulpdrew wants to merge 1 commit into
mainfrom
drew/chart-table-order-by-override
Open

pulpdrew wants to merge 1 commit into
mainfrom
drew/chart-table-order-by-override

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Issue

In the chart explorer, Table display type:

  1. Click a column header whose sort produces a bad ORDER BY (e.g. a formula
    aliased duration min, which sorts as unquoted duration min ASC). The
    query errors.
  2. Fix the Order By field by hand ("duration min" ASC) and resubmit.
  3. The same error comes back. The query still uses the unquoted sort from the
    header click.

Fix

  • Parser: the preview now uses the search page's Order By parser (parseAsSortingStateString), so names with spaces like "duration min" ASC parse. The older helpers (orderByStringToSortingState and sortingStateToOrderByString) are removed.
  • No fallback: when the Order By can't be shown as a header sort (no direction, NULLS LAST, or empty), the preview passes an empty sort. The table then runs the Order By as written rather than reusing the old header click

Screenshots or video

Before

Screen.Recording.2026-11-20.at.2.49.41.PM.mov

After

Screen.Recording.2026-11-20.at.2.51.16.PM.mov

How to test on Vercel preview

Take the steps depicted in the attached videos.

References

  • Linear Issue: Closes HDX-6137
  • Related PRs:

@pulpdrew
pulpdrew requested a review from a team as a code owner November 20, 2026 19:20
@vercel

vercel Bot commented Nov 20, 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 20, 2026 8:38pm UTC
hyperdx-storybook Ready Ready Preview Nov 20, 2026 8:38pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3f85609

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

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 4
  • Production lines changed: 95 (+ 422 in test files, excluded from tier calculation)
  • Branch: drew/chart-table-order-by-override
  • Author: pulpdrew

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

@github-actions

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.13%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Nov 20, 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:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • 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
    priority. Reply with one sentence; if it is P0, 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.

1 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 1 P3

No inline comments. 1 P3 folded at the bottom.

🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/DBEditTimeChartForm/utils.ts:287 — orderByToTableSortState re-implements Order By key splitting that parseSortKeys already does → parseSortKeys in packages/app/src/components/SearchResultsToolbar/sortClause.ts already splits an Order By with splitAndTrimWithBracket and parses each part with parseAsSortingStateString. Build on it instead, e.g. const keys = parseSortKeys(orderBy); return keys?.length === 1 ? keys : [];. If (a, b) DESC really has to stay a single header key here (parseSortKeys expands it into two keys), add a doc comment naming parseSortKeys as the twin and saying why the two differ. As written there are two Order By → sort-key parsers that can drift apart, which the repo's DRY convention calls out.

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. This is a focused, well-tested bug fix. The core behavioral change — defaulting the preview table's sort to [] (truthy) instead of undefined so effectiveSort = controlledSort || sort suppresses the stale header-click sort and runs the typed Order By as written — is correct and intentional. The new render-phase setState in DBTableChart follows React's supported "adjust state during render" pattern and cannot loop. No dangling references to the removed helpers remain, and the multi-key guard correctly keeps bracketed tuple sorts while rejecting true multi-key strings.

🔵 P3 nitpicks (2)
  • packages/app/src/components/DBEditTimeChartForm/utils.ts:610 — the new orderByToTableSortState/tableSortStateToOrderBy helpers wrap the generic parseAsSortingStateString parser but live in the chart-form utils, so sort↔Order-By conversion logic is now split across this file and utils/queryParsers.ts after the old home in src/utils.ts was removed.
    • Fix: Colocate these thin wrappers next to parseAsSortingStateString or add a cross-reference comment so the conversion logic is discoverable from one place.
    • maintainability, kieran-typescript
  • packages/app/src/components/DBEditTimeChartForm/ChartPreviewPanel.tsx:235 — the tableSortState memo's empty-array branch and the onTableSortingChange wiring are exercised only through the new e2e specs, not a component-level unit test.
    • Fix: Optionally add a ChartPreviewPanel test asserting that an unrepresentable Order By (multi-key / trailing modifier) produces an empty sort prop so DBTableChart queries the raw Order By.
    • testing

Reviewers (8): correctness, testing, maintainability, kieran-typescript, julik-frontend-races, project-standards, learnings-researcher, previous-comments.

Testing gaps: Helper functions, the uncontrolled clear-sort behavior, and the end-to-end edit-Order-By flow are all covered (unit + component + e2e); the only untested seam is the ChartPreviewPanel wiring itself, which is indirectly covered by chart-explorer.spec.ts.

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 Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 469 passed • 1 skipped • 1148s

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

Tests ran across 4 shards in parallel.

View full report →

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 3f856093 Deployed Nov 20, 2026 by vercel[bot]
Preview – hyperdx-storybook — 3f856093 Deployed Nov 20, 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-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant