Skip to content

feat(app): double-click a column's resize handle to fit it in table charts - #3885

Open
alex-fedotyev wants to merge 4 commits into
mainfrom
alex/HDX-6247-fit-table-tiles
Open

alex-fedotyev wants to merge 4 commits into
mainfrom
alex/HDX-6247-fit-table-tiles

Conversation

@alex-fedotyev

@alex-fedotyev alex-fedotyev commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The double-click that fits a search results column to its content now works in table charts too: the Table view in Chart Explorer, and Table tiles on dashboards.

Double-click the handle at the right edge of a column header, and the column shrinks or grows to fit its widest value on screen, the same as in search results.

  • Columns with a handle. The last column of a table chart has no resize handle. It always takes the rest of the table's width, so it grows or shrinks when you fit another column.
  • Same as dragging. A fit sets the width the same way dragging the handle does. Table charts don't keep a dragged width after they reload, and they don't keep a fitted one either.
  • Same limits as search. It fits the rows on screen, up to 600px or half the table's width.

The group-by column is the last column by default, so to fit a text column like ServiceName, turn on Display Group By Columns on Left in Display Settings.

Screenshots or video

Chart Explorer, a count grouped by ServiceName with the group-by column on the left, after double-clicking the handle on the ServiceName header. On main nothing changes and the column stays 385px wide. On this branch it fits the longest name, "artillery-loadgen", at 141px.

Before (main) After
before light after light
before dark after dark

How to reproduce

Starting point: the Vercel preview on this PR, or yarn app:dev:local → onboarding → "Connect to Demo Server".

On main:

  1. Open Chart Explorer, pick Table and set Group By to ServiceName.
  2. In Display Settings, check Display Group By Columns on Left, then run.
  3. Double-click the resize handle at the right edge of the ServiceName header. Nothing changes.

On this branch:

  1. Repeat the steps above. ServiceName fits its longest name, and count() fills the rest.
  2. Add a Table tile to a dashboard and double-click a column's handle there. It fits the same way.

How to test on Vercel preview

Preview routes: /chart

Steps:

  1. Open /chart and click "Connect to Demo Server" if prompted.
  2. Click the "Table" tab in the chart type picker (data-testid="chart-type-input").
  3. Type ServiceName into the Group By editor, then click the run button (data-testid="chart-run-query-button").
  4. Wait for the results table with the "count()" and "ServiceName" columns.
  5. Double-click the resize handle (data-testid="column-resize-handle") at the right edge of the "count()" column header.
  6. Verify the "count()" column becomes narrower and its values are not cut off with "…".

How it works

Table charts are drawn by HDXMultiSeriesTableChart, which already used the search table's column header and resize handle. This connects the handle's double-click to fitColumn, a helper the search table now shares, which measures the column, caps the width and sets it the way a drag does.

It also fixes a measuring bug that only table charts hit. Rows with a click action render their cells as links with Bootstrap's w-100, which is width: 100% !important. That overrode the width of the copy used for measuring, so a fit measured the whole table and jumped to the cap. The copy's styles are now !important as well, and an inline !important wins over a stylesheet one.

Test plan

  • yarn lint, yarn tsc --noEmit in packages/app, and yarn knip
  • unit: a table chart fits a column to its widest value on a double-click, which fails without the handler wired or without the cell ids, and saves nothing. columnFit.test.ts covers fitColumn and the !important styles, each failing with its fix reverted.
  • e2e: chart-explorer.spec.ts narrows a column wider than its values and widens it back after a squeeze. It fails without the double-click wired, and it caught the w-100 bug.
  • the search results fit e2e (column-fit.spec.ts) still passes with the search table on the shared helper.
  • manual on the Vercel preview with the demo server, light and dark: ServiceName fits from 385px to 141px with the group-by column on the left, count() fits from 385px to 63px in the default order, and a dashboard Table tile 361px wide fits count() from 120px to 63px. No column widths were written to local storage.
  • viewport: Chart Explorer at 1440 x 900 and a dashboard tile 361px wide.

References

  • Linear Issue: HDX-6247

[ui-states: allow] Only column widths change. The table's empty, loading and error states are unchanged.


Note

Low Risk
UI-only column sizing shared with existing search behavior; no auth, data, or API changes.

Overview
Brings search-style “fit column to content” to table charts: Chart Explorer table results and dashboard table tiles (HDXMultiSeriesTableChart). Double-clicking a column’s resize handle measures visible cells and sets width like a drag (not persisted); the trailing column still has no handle.

Search tables now call a shared fitColumn helper in columnFit.ts instead of duplicating measure/set logic. measureColumnContentWidth applies !important on measurement probes so Bootstrap w-100 on linked row cells no longer inflates fits in chart tables. Chart bodies get data-column-id on cells for measurement.

Coverage: unit tests for fitColumn / !important, component tests on HDXMultiSeriesTableChart, and a Chart Explorer e2e for double-click fit.

Reviewed by Cursor Bugbot for commit fb0d118. Bugbot is set up for automated code reviews on this repo. Configure here.

Double-clicking a column's resize handle on a dashboard table tile, or
on the chart explorer's table, fits the column to its content as in
search results. The fitted width stays in the table's own state, like a
dragged one. The last data column already fills the tile and has no
handle.

Both tables now share fitColumn, which measures, caps and sets the
width. The measuring copies set their styles as important: tile cells
that link somewhere carry Bootstrap's w-100 (width: 100% !important),
which beat the copy's inline width and made a fit measure the whole
table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-fedotyev
alex-fedotyev requested a review from a team as a code owner December 1, 2026 21:27
@vercel

vercel Bot commented Dec 1, 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 Dec 1, 2026 11:17pm UTC
hyperdx-storybook Ready Ready Preview Dec 1, 2026 11:17pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fb0d118

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 added the review/tier-2 Low risk — AI review + quick human skim label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 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: 3
  • Production lines changed: 62 (+ 238 in test files, excluded from tier calculation)
  • Branch: alex/HDX-6247-fit-table-tiles
  • Author: alex-fedotyev

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

github-actions Bot commented Dec 1, 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 109 in total (1.10%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

✅ No issues found.

The column fit e2e asserted on a value read with getAttribute(), which
the playwright/prefer-web-first-assertions rule rejects in CI lint. It
now waits on toHaveAttribute() before reading the id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

❌ 1 test failed • 488 passed • 1 skipped • 1108s

Status Count
✅ Passed 488
❌ Failed 1
⚠️ Flaky 14
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a tightly scoped, well-tested UI change. Correctness review traced the fitColumn refactor and confirmed it is behavior-preserving for RawLogTable (same measure → cap → setColumnSizing), the null guards hold in both callers, Math.max(0, ...widths) on an empty column floors to MIN_COLUMN_WIDTH (no crash), and the fill column's disabled resizing is the sole—but currently sound—guard keeping it out of the fit path. The previous-comments pass verified all five prior deep-review fixes are present in the code and tests. Nothing rises to P2.

🔵 P3 nitpicks (5)
  • packages/app/src/__tests__/HDXMultiSeriesTableChart.test.tsx:720 — The "nothing persisted" assertion filters localStorage for -column-sizes keys, but this component has no persistence path at all, so the check passes regardless of whether the fit works or is even wired.
    • Fix: Assert the fitted width survives a re-render in in-memory state instead of asserting the absence of a storage key the component never writes.
    • testing
  • packages/app/tests/e2e/features/chart-explorer.spec.ts:505 — The "narrow a column wider than its values" step asserts the fitted width is less than the default against whatever live ServiceName-grouped demo data returns, which fails if the grouped values already fill the default column width.
    • Fix: Pin the measured column to one whose default width is guaranteed to exceed its content, or seed deterministic data as the search column-fit spec does.
    • testing
  • packages/app/src/components/DBTable/columnFit.ts:21 — measureColumnContentWidth only inspects virtualized rows that are currently mounted, so a fit can truncate a wider value that is scrolled out of view; this is intended but now newly reaches dashboard tiles.
    • Fix: Reword the handle tooltip so "fit" reads as "fit to currently rendered content," or document the limitation at the measurement site.
    • julik-frontend-races
  • packages/app/src/components/DBTable/columnFit.ts:22 — The data-column-id attribute is a stringly-typed contract read in columnFit.ts and written at three JSX sites, linked only by comments, and this PR widens its blast radius to a second component.
    • Fix: Export a shared constant for the attribute name and reference it at both the query site and each JSX render site so a rename breaks at compile time.
    • maintainability
  • packages/app/src/components/DBTable/columnFit.ts:15 — After the refactor, measureColumnContentWidth and getFittedColumnWidth have no production importers (only the internal fitColumn and the unit tests), so their export now signals external callers that do not exist.
    • Fix: Drop the export on both and test the measure/cap logic through fitColumn, or add a one-line note that the exports exist for unit coverage.
    • maintainability

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

Testing gaps:

  • The cap-at-600 / cap-at-half-visible-width and empty-column floor behaviors are exercised only at the columnFit unit level, not through a rendered tile.
  • Only the chart-explorer surface has e2e fit coverage; the dashboard table tile path relies on the shared component unit test, with no e2e asserting the double-click fit on an actual tile.
  • No test covers probe cleanup when getBoundingClientRect/cloneNode throws (the finally teardown path).

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

A unit test now fails if the measuring copy's styles stop being
important, which the jsdom layout mock couldn't catch before. The tile
fit test also checks that the fitted width isn't saved, and the tile's
fit notes why it has no last-column case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-fedotyev

Copy link
Copy Markdown
Contributor Author

Review findings, in e325c88:

  • No unit test pins the !important probe styles (deep-review P2): added sets the copy styles as important, so a class like w-100 cannot override the width. It fails with the plain inline width.
  • The tile's fit has no last-column case (P3): added a comment. The last data column fills the tile and can't be resized, so it never gets a fit.
  • The group column renders bare text (P3): keeping as is. Only groupColumnName adds that column, and DBTableChart never passes it.
  • Note the visible-rows limit (P3): the measureColumnContentWidth doc comment already says only the header and mounted rows count.
  • Nothing saved (testing gap): the tile fit test now checks that no column width ends up in local storage.

@alex-fedotyev alex-fedotyev changed the title feat(app): fit dashboard table tile columns to their content feat(app): double-click a column's resize handle to fit it in table charts Dec 1, 2026

This branch was successfully deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant