Skip to content

fix: persist column widths in search results table#2327

Merged
kodiakhq[bot] merged 3 commits into
mainfrom
persist-column-widths
May 22, 2026
Merged

fix: persist column widths in search results table#2327
kodiakhq[bot] merged 3 commits into
mainfrom
persist-column-widths

Conversation

@teeohhem
Copy link
Copy Markdown
Contributor

@teeohhem teeohhem commented May 21, 2026

Summary

Column widths in the search results table now survive page refresh and session restarts. Scoped per saved search (db-search-saved-<id>) when one is loaded, otherwise per source (db-search-source-<id>) for ad-hoc searches; persisted in localStorage, no backend changes.

The persistence machinery already existed in RawLogTable but was gated on a tableId prop that no caller in the search-page chain was passing, so columnSizing fell back to TanStack Table's in-memory state and reset on every mount. This wires tableId through DBSqlRowTable and DBSqlRowTableWithSideBar and derives a stable key in DBSearchPage. As a side benefit, the "Reset Column Widths" header button and wrap-lines persistence (same root cause) now work in the search view too.

Screenshots or video

UI is unchanged at rest — the only newly-visible affordance is the existing "Reset Column Widths" button in the table header, which now appears once a column has been resized.

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Open /search and wait for the results table to render.
  2. Drag the resize handle on the right edge of the Timestamp column header to shrink it to roughly half its starting width.
  3. Reload the page.
  4. Verify the Timestamp column header retains the resized width (does not snap back to the default ~170px).
  5. Verify the "Reset Column Widths" icon button is visible in the rightmost header cell; click it and confirm the column returns to its default width.

References

Ref: HDX-4322

  • Related PRs:

Column widths now survive page refresh. Scoped per saved search
(db-search-saved-<id>) when one is loaded, else per source for ad-hoc
searches (db-search-source-<id>). Stored in localStorage.

The persistence machinery already existed in RawLogTable but was gated
on a tableId prop that no caller in the search-page chain was passing,
so columnSizing fell back to TanStack Table's in-memory state and reset
on every mount. This wires tableId through DBSqlRowTable and
DBSqlRowTableWithSideBar and derives a stable key in DBSearchPage. The
"Reset Column Widths" header button and wrap-lines persistence (same
root cause) now work in the search view too.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: 448d2cf

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
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

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

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment May 22, 2026 5:02pm

Request Review

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

🔵 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: 15 (+ 54 in test files, excluded from tier calculation)
  • Branch: persist-column-widths
  • Author: teeohhem

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

Persist column widths in the search results table to enhance user experience.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

E2E Test Results

All tests passed • 179 passed • 3 skipped • 1243s

Status Count
✅ Passed 179
❌ Failed 0
⚠️ Flaky 3
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

context={rowTableContext}
config={dbSqlRowTableConfig}
sourceId={searchedConfig.source}
tableId={columnSizeTableId}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

all the plumbing was already there, we just lacked the tableid

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Deep Review

✅ No critical issues found.

🟡 P2 -- recommended

  • packages/app/src/DBSearchPage.tsx:1317 -- The new dynamic columnSizeTableId makes the RawLogTable tableId flip at runtime (saved-search → ad-hoc, or one source to another), and useLocalStorage at packages/app/src/utils.ts:192-208 only updates storedValue when the new key has an entry, so the next resize merges the previous scope's widths into the new key via setColumnSizeStorage at packages/app/src/components/DBRowTable.tsx:698.
    • Fix: In useLocalStorage's key-change effect, reset storedValue to initialValue when the new key has no stored entry so a scope change does not carry the previous scope's value forward.
    • correctness, julik-frontend-races
🔵 P3 nitpicks (4)
  • packages/app/src/components/__tests__/DBRowTable.test.tsx:193 -- The "isolates stored widths per tableId" test uses .not.toBe('250px'), which would pass even if t2's width were undefined or any unrelated default, so it does not actually verify per-tableId isolation.

    • Fix: Store a distinct value under t2-column-sizes and assert it is applied, or assert a concrete expected default for t2.
    • testing, kieran-typescript
  • packages/app/src/DBSearchPage.tsx:1317 -- The local columnSizeTableId is named for column sizes only, but the same tableId keys ${tableId}-wrap-lines at packages/app/src/components/DBRowTable.tsx:547 and is also used as the table DOM id at packages/app/src/components/DBRowTable.tsx:981.

    • Fix: Rename to searchTableId (or similar) and broaden the comment so a future change to wrap-lines or DOM-id assumptions doesn't miss the same derivation.
    • maintainability, kieran-typescript
  • packages/app/src/components/__tests__/DBRowTable.test.tsx:147 -- No test exercises a tableId transition on a mounted table, which is the exact regime this PR newly enables and where the P2 cross-scope leak above lives.

    • Fix: Add a test that mounts RawLogTable with tableId="t1", drives a resize through the React Table handler, rerenders with tableId="t2", and asserts t1-column-sizes is preserved while t2-column-sizes does not inherit t1's values.
    • correctness, testing, julik-frontend-races
  • packages/app/src/components/__tests__/DBRowTable.test.tsx:147 -- The Reset Column Widths button and the now-active wrap-lines persistence (both called out as side benefits of the wiring) have no new coverage in the search view.

    • Fix: Add one smoke test per side effect: clicking the reset control clears ${tableId}-column-sizes, and toggling wrap reads/writes ${tableId}-wrap-lines.
    • testing

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

Testing gaps:

  • No coverage for the cross-scope tableId transition this PR newly enables.
  • No coverage for the Reset Column Widths control or wrap-lines persistence in the search view.
  • No assertion of the write path (resize → localStorage) under the expected ${tableId}-column-sizes key.

Copy link
Copy Markdown
Contributor

@pulpdrew pulpdrew left a comment

Choose a reason for hiding this comment

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

LGTM

@kodiakhq kodiakhq Bot merged commit b94b8ef into main May 22, 2026
18 checks passed
@kodiakhq kodiakhq Bot deleted the persist-column-widths branch May 22, 2026 17:07
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.

2 participants