Skip to content

Virtualize the packet list and hex dump with tanstack virtual - #18

Merged
DHUKK merged 1 commit into
mainfrom
virtualize-with-tanstack-virtual
Aug 18, 2026
Merged

DHUKK merged 1 commit into
mainfrom
virtualize-with-tanstack-virtual

Conversation

@DHUKK

@DHUKK DHUKK commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the hand rolled offset tables and scroll math in PacketList.tsx and HexDump.tsx (lib/packetWindow.ts, lib/hexWindow.ts) with @tanstack/react-virtual.
  • Drops the packet list's off screen RowProbe and its font settled tracking: the library measures each mounted row's real height directly, so a session badge or a font swap changing a row's wrap corrects itself automatically.
  • Moves vertical padding on both scroll containers from CSS into the virtualizer's paddingStart/paddingEnd, since the library's row offsets and the container's native scrollTop need to agree on where row 0 starts. Horizontal padding is untouched.
  • Deletes packetWindow.ts and its tests outright; trims hexWindow.ts down to the row math still used (rowCountFor, rowForOffset, highlightEdge).

Test plan

  • go test ./... unaffected (no Go changes)
  • npm run typecheck
  • npm test (178 tests)
  • npm run build
  • Manually verified in the browser: keyboard stepping past the virtualization window, hex field reveal spanning rows, merged multi session view with badges, focus following selection through Space/Enter activation

Both lists hand rolled their own offset tables, scroll math and edge cases.
The packet list also carried an off screen probe just to measure a plain row
and a gap marked row, plus a font settled flag to remeasure once the shipped
faces swapped in. tanstack virtual measures each mounted row for real, so
none of that survives: a badge narrowing a row's text or a font swap
changing its wrap now correct themselves through the same ResizeObserver the
library already needs.

Vertical padding on both scroll containers moves from CSS into the
virtualizer's own paddingStart and paddingEnd, since a real padding top would
shift rows on screen without shifting the offsets the library computes for
them. Horizontal padding is unaffected and stays in CSS.
@DHUKK
DHUKK merged commit dfb3e38 into main Aug 18, 2026
2 checks passed
@DHUKK
DHUKK deleted the virtualize-with-tanstack-virtual branch August 18, 2026 08:20
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