Skip to content

fix(traffic): keep the table header pinned while the list scrolls - #108

Merged
fylorn merged 1 commit into
devfrom
fix/traffic-sticky-header
Sep 22, 2026
Merged

fylorn merged 1 commit into
devfrom
fix/traffic-sticky-header

Conversation

@fylorn

@fylorn fylorn commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

The traffic table's header is meant to stay pinned while the list scrolls (the comment above it says so), but it scrolls away with the rows.

Why it broke

It worked in #8, when the header was a raw <thead> in a plain <table>. #15 moved it inside shadcn's Table, which wraps the table in <div data-slot="table-container" class="relative w-full overflow-x-auto">. A box that scrolls on one axis is a scroll container on both (the other axis's visible computes to auto), so that div became the header's sticky scroll container. It never scrolls vertically, so the header never sticks. Measured before this change: 600px down the list, the header sat 540px above the top of the scroller.

What changes

  • Table gets a scroll prop (default true, so every other table keeps scrolling sideways on its own). The request table passes scroll={false}, and the header sticks to the page's scroller.
  • That wrapper was doing real work: at the minimum window width (820px) with the sidebar expanded, the table is 808px in a 584px column. Without it the page's scroller also takes the horizontal overflow, which would slide the filter bar sideways with the table. So the page is split into three blocks:
    • the filter bar (with the no-upstream notice) and the footnote are direct children of the scroller with sticky left-0. As direct children they are exactly as wide as the visible area, and they stay put while the table scrolls sideways;
    • the table sits in a w-fit min-w-full block that grows with it, so the 20px right padding still scrolls into view.
      The top padding stays on an inner block, not on the scroller, as in fix(traffic): leave room between the title bar and the filter bar #106.
  • Two things that only showed up once the header actually stuck:
    • The table uses collapsed borders, and a collapsed border is painted by the table, not by the row, so the line under the header stayed behind and scrolled off with the rows. The header cells now draw it as an inset shadow, which moves with them.
    • The header background was neutral-50 / neutral-950, which no longer matches the window ground (#f7f8fa / #0c0e11); rows passing under it would show a band. It uses bg-background.
  • Three comments still pointed at Split (removed in Fold requests and sessions into one table #82) as the place the traffic page scrolls; they now point at the scroll layer that exists.

A side effect worth knowing: the horizontal scrollbar is now at the bottom of the window instead of under the last of up to two hundred rows.

Alternatives not taken

  • Pin the filter bar above a table that scrolls on both axes. Clean horizontally, but the filter bar would then take 60px of list height at every window size (96px when it wraps at narrow widths), about two rows, and the page's scrolling would change beyond this bug.
  • overflow-x: clip on the wrapper. Not a scroll container, so the header would stick, but at the minimum width it cuts off the last 224px, which is the token and cost columns.

Verification

Measured from the DOM in the isolated preview (mocked IPC, full App on the traffic page) in Chromium, and in the system WKWebView (offscreen, the engine Tauri uses on macOS). Flat and grouped (two sessions expanded), 820×560 and 1100×720, light and dark:

before after
header top vs. scroller, scrolled 600px −540px 0
header top, scrolled to the end off-screen 0
header x after scrolling fully right (820px, flat) — moves with the table (−203 / −205)
filter bar x after scrolling fully right — 20 (unchanged)
right padding at the far right 20 20
wrapper overflow-x / overflow-y auto / auto visible / visible

In WebKit, a pixel sample across the header's bottom edge shows the rule at the same place at rest and when stuck (dark: 50 on a 17 ground; light: 234 on 250); before the shadow change it vanished once the header stuck. At 1100×720 the flat table fits (no horizontal scroll). The no-match empty state renders below the filter bar at the visible width with no horizontal overflow.

pnpm typecheck, pnpm test (197 passed) and pnpm build pass.

🤖 Generated with Claude Code

The header has carried `sticky top-0` since #8, but it stopped sticking
in #15, when it moved inside shadcn's `Table`. That component wraps the
table in a div with `overflow-x: auto`, and a box that scrolls on one
axis is a scroll container on both: the other axis's `visible` computes
to `auto`. The header stuck to that div, which never scrolls vertically,
so it went up with the rows. 600px down the list it sat 540px above the
top of the scroller.

`Table` gets a `scroll` prop. The request table turns it off, so the
header sticks to the page's scroller instead.

The wrapper was doing real work, though. At the minimum window width
with the sidebar expanded the table is 808px in a 584px column, and
without the wrapper the page's scroller takes the horizontal overflow
too, which would slide the filter bar sideways with the table. So the
page is split into three blocks. The filter bar (with the no-upstream
notice) and the footnote are direct children of the scroller with
`sticky left-0`: that makes them exactly as wide as what is visible, and
they stay put while the table scrolls sideways. The table sits in a
`w-fit min-w-full` block that grows with it, so its right padding still
scrolls into view. The horizontal scrollbar now sits at the bottom of
the window rather than under the last of two hundred rows.

Two things only showed once the header actually stuck:

- The table uses collapsed borders, and a collapsed border is painted by
  the table, not the row, so the line under the header stayed behind and
  scrolled away with the rows. The header cells draw it as an inset
  shadow instead, which moves with them.
- The header's background was neutral-50/950, which no longer matches
  the window ground (#f7f8fa / #0c0e11); rows passing under it would
  show a band. It uses `bg-background` now.

Not taken: pinning the filter bar above a table that scrolls on both
axes costs 60-96px of list height at every window size, about two rows;
`overflow-x: clip` cuts off the cost column at the minimum width.

Also points three comments that still sent readers to `Split`, removed
in #82, at the scroll layer that exists now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 4b809b6 into dev Sep 22, 2026
2 checks passed
@fylorn
fylorn deleted the fix/traffic-sticky-header branch September 22, 2026 08:36
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