Skip to content

fix(packets): align Unified Packet Monitor headers with columns#3567

Merged
Yeraze merged 1 commit into
mainfrom
fix/unified-packet-monitor-header-align
Jun 19, 2026
Merged

fix(packets): align Unified Packet Monitor headers with columns#3567
Yeraze merged 1 commit into
mainfrom
fix/unified-packet-monitor-header-align

Conversation

@Yeraze

@Yeraze Yeraze commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

The Unified Packet Monitor's column headers no longer lined up with the data beneath them. The fix makes the virtualized body rows size identically to the sticky header row so every header sits directly above its column.

Root cause

The stream uses the standard two-table virtualization pattern: one <table> for the sticky header and a second for the virtualized body, with each body <tr> given inline display: table; tableLayout: fixed so @tanstack/react-virtual can absolutely position it. When a <tr> becomes display: table it forms its own table box, so the body <table>'s <colgroup> no longer propagates to the row. Column widths in this page came only from the colgroup and the <th>/<td> cells carried no widths — so the header table honored the colgroup while each body row fell back to tableLayout: fixed equal-distribution, leaving headers misaligned.

The single-source PacketMonitorPanel does not have this bug because it sets an explicit width on every <th> and <td>.

Changes

  • Added explicit width (matching the existing <colgroup>) to all 15 <th> cells in the header row of UnifiedPacketMonitorPage.tsx.
  • Added the same explicit width to all 15 <td> cells in each virtualized body row, merging with existing inline styles (e.g. packet-number text-align, portnum color).
  • No CSS, logic, or data changes; colgroups left intact.

Issues Resolved

None (reported directly).

Documentation Updates

No documentation changes needed — internal layout fix with no behavior or API change.

Testing

  • Unit tests pass (7491 tests, 0 failures, 0 failed suites)
  • TypeScript compiles cleanly (npm run typecheck)
  • Manually verified in the dev container: headers (#, Source, Dir, Via, Date, Time, From, To, Type, Slot, SNR, RSSI, Hops, Size, Content) align over their columns, including while scrolling the virtualized list and toggling the filters/charts panels

🤖 Generated with Claude Code

The body rows use display:table + tableLayout:fixed (required for
absolute-positioned virtualization), which makes each <tr> its own
table — so the body <table>'s <colgroup> does not propagate to the
rows. The header table honored the colgroup while body cells
equal-distributed, leaving headers misaligned with their columns.

Add explicit per-cell widths to every <th> and <td> (matching the
colgroup), mirroring the working single-source PacketMonitorPanel,
so fixed-layout rows size identically to the header.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Peq865k9vuH4PvKTFhQuNq
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

Claude finished @Yeraze's task —— View job


PR Review: fix(packets): align Unified Packet Monitor headers with columns

Tasks:

  • Gather context
  • Read changed file
  • Provide review feedback

Summary

This is a well-targeted, minimal fix for a real layout bug caused by the interaction between @tanstack/react-virtual's absolute-positioned row technique and CSS table layout. The root cause explanation in the PR description is accurate and clear. Here's my detailed assessment:


Code Quality ✅

The approach is correct and idiomatic — matching explicit width on <th> and <td> is the right fix for display: table rows that don't inherit from a <colgroup>. The implementation in UnifiedPacketMonitorPage.tsx now mirrors how PacketMonitorPanel.tsx solves the same problem.

One minor observation: The <colgroup> entries inside the body <table> (lines 345–361) are now redundant — with explicit widths on every <td>, those <col> elements have no effect on display: table rows and can't affect the sticky header table either. They're harmless, but could cause confusion later when someone tries to "fix alignment" by editing the colgroup widths and wonders why nothing changes. A comment or removal would reduce future confusion.

// These colgroup entries no longer affect layout for display:table rows —
// widths are now controlled by the explicit width on each <td>.
<colgroup>
  <col style={{ width: '50px' }} />
  ...
</colgroup>

Potential Bugs 🟡

Width consistency between <th> and <td>: All 15 columns match correctly between header and body. No mismatches found.

Loader row (colSpan={15}): The "load more / loading more" sentinel row at line 374 uses colSpan={15} with no per-column widths — it's a single full-width cell, which is fine and doesn't affect alignment.

minWidth vs width on Content column: The last column uses minWidth: '200px' (lines 322, 339, 360, 425). This is consistent across header and body cells, but minWidth behaves differently from width in a fixed-layout table. In practice the content column should still stretch correctly since table-layout: fixed computes remaining space after all fixed-width columns are satisfied, but it's worth noting this differs from all other columns using width.


Performance ✅

No performance concerns — the change is purely presentational. Inline style objects on <td> cells are recomputed on every render, but this is unchanged from the existing <tr> inline styles and is acceptable for a virtualized list that only renders ~10–20 rows at a time.


Security ✅

No security concerns. This is a pure layout fix with no data handling, API calls, or user-input processing.


Test Coverage 🟡

The PR notes all 7491 unit tests pass. There are no new tests for the layout fix, which is expected — pixel-level column alignment is impractical to unit test with Vitest/Testing Library. Manual verification in the dev container (documented in the PR) is the appropriate testing strategy here.

The existing PacketMonitorPanel doesn't have alignment tests either, so no regression gap is introduced.


Minor Suggestions (non-blocking)

  1. Remove or comment out the now-redundant <colgroup> in the body <table> — it clutters the code and may mislead future maintainers.

  2. Consider extracting column widths to a constant array — both the header table and body table define identical column width sequences in three places each (two <colgroup> blocks + the cell width props). A shared COLUMN_WIDTHS constant would make future column additions or reordering less error-prone:

const COLUMN_WIDTHS = ['50px', '120px', '35px', '45px', '55px', '110px',
  '140px', '140px', '120px', '70px', '60px', '60px', '60px', '60px', '200px'] as const;

This is a refactor for a follow-up, not a blocker.


Verdict

The fix is correct, minimal, and well-explained. The only non-trivial note is the now-redundant <colgroup> in the body table, but that's cosmetic. Approved for merge.

@Yeraze Yeraze merged commit f7caf13 into main Jun 19, 2026
16 checks passed
@Yeraze Yeraze deleted the fix/unified-packet-monitor-header-align branch June 19, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant