Skip to content

fix(traffic): arrow keys follow the rows on screen when grouped by session - #115

Merged
fylorn merged 1 commit into
devfrom
fix/traffic-grouped-keys
Sep 22, 2026
Merged

fylorn merged 1 commit into
devfrom
fix/traffic-grouped-keys

Conversation

@fylorn

@fylorn fylorn commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #111. The keyboard cursor in the traffic table was an index into rows, the filtered and sorted list. In the grouped view that is not what is on screen: sessions are ordered by their newest request, a session lists its requests oldest first, and requests in collapsed sessions are not rendered. Measured with about 200 rows in four sessions:

  • with the sessions expanded, 100 presses of ↓ from the top scrolled the list 57 times, 54 of them to the top edge (the highlight was moving up), and jumped from one session to another 5 times;
  • with sessions collapsed, which is how the grouped view opens, the cursor walked requests that are not in the table: the first 100 presses highlighted nothing on screen.

What changes

  • The cursor remembers which row it is on, a request id or a session header, not a position. New requests arriving at the top, another sort, or a session expanding above no longer move the highlight onto a different request.
  • ↑/↓ walk the rows in the order they are drawn. lines() in grouping.ts lists them the way RequestRows lays them out (a comment on each side points at the other), including the requests of collapsed sessions, marked as not shown; step() moves to the next shown row and stays put at either end. A cursor left on a request whose session was then collapsed continues from where that request was: ↓ goes to the first row below the session, ↑ to its header.
  • Session headers are rows. Enter opens the session, → expands it, ← collapses it, and ← on a request inside a session moves to its header, as in a Finder list view. Clicking a header puts the cursor on it, as clicking a request already did. ← and → are taken over only in those cases.
  • Header rows get the same scroll margins as request rows (fix(traffic): keep the keyboard-selected row in view #111), so they stop below the pinned header and never scroll the table sideways. The margins now sit on the table, for every body row.
  • The effect that pulled the index back when the list got shorter is gone: a request that leaves the list loses the highlight, and the next key press starts at the first row.

In the flat view the keys walk the same rows as before; the one difference is that the highlight stays on its request when new ones arrive.

Verification

Unit tests for lines and step: the order in the flat and grouped views, skipping collapsed sessions, both ends, a cursor left in a collapsed session (including the last one), and an empty table.

Isolated preview (mocked IPC, full App on the traffic page), in Chromium and in the system WKWebView (offscreen, the engine Tauri uses on macOS). The probe from #111 now also checks that every press moves the highlight by exactly one row, in the direction of the key. Grouped view with all four sessions expanded (207 rows), 820×560, light and dark: in WebKit down the whole list and back from scrollLeft 0, 100 and the far right; in Chromium the whole list from 0, and 40 presses each way from 100 and the far right:

Chromium WebKit
presses that moved the highlight more than one row 0 0
presses that moved it against the key 0 0
presses after which the selected row was not fully visible 0 0
scrolls to the edge opposite the key's direction 0 0
presses that changed scrollLeft 0 0

With real key events (NSEvent in the WKWebView): on a collapsed header → expands it (190 → 207 rows), ↓ ↓ reaches its second request, ← goes back to the header, ← again collapses it (207 → 190), Enter opens the session drawer and Esc closes it; scrollLeft stays 0 throughout, so ← and → did not also scroll the table. In Chromium (CDP keys), Enter on a request inside a session opens the request drawer and Enter on a header opens the session drawer. With only headers on screen, ↓ steps through the four headers and stops at the last.

With the cursor on the sixth row of the flat view, a new request arriving at the top leaves the highlight on the same request, now seventh, and ↓ continues from it. The flat view's walk from #111 gives the same numbers as before.

The header highlight shows in both themes: neutral-100 over the headers' neutral-50/60 (light), neutral-800 over neutral-900/40 (dark).

pnpm typecheck, pnpm test (228 passed) and pnpm build pass on top of #110.

🤖 Generated with Claude Code

…ssion

The keyboard cursor was an index into `rows`, the filtered and sorted
list. In the grouped view that is not what is on screen: sessions are
ordered by their newest request, a session lists its requests oldest
first, and requests in collapsed sessions are not rendered. So Down
moved the highlight up within a session, jumped between sessions and
landed on rows that were not in the table; with the sessions collapsed,
which is how the grouped view opens, it highlighted nothing at all.

- The cursor remembers which row it is on (a request id, or a session
  header) instead of a position. New requests arriving at the top,
  another sort, or a session expanding above no longer move the
  highlight to a different request.
- Up/Down walk the rows in the order they are drawn (`lines` in
  grouping.ts, next to the grouping it mirrors), skipping requests in
  collapsed sessions. A cursor left inside a session that was then
  collapsed continues from where that row was.
- Session headers are rows too: Enter opens the session, Right expands
  it, Left collapses it, and Left on a request inside a session moves
  to its header, as in a Finder list view. Clicking a header puts the
  cursor there, as clicking a request already did.
- Header rows get the same scroll margins as request rows, so they
  stop below the pinned header and never scroll the table sideways;
  the margins now sit on the table for every body row.
- The effect that pulled an index back when the list got shorter is
  gone: a request that leaves the list simply loses the highlight, and
  the next key press starts from the first row.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit b2443f5 into dev Sep 22, 2026
2 checks passed
@fylorn
fylorn deleted the fix/traffic-grouped-keys branch September 22, 2026 14: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