Skip to content

fix(raw): scroll every pane together in the raw view (#9) - #11

Merged
imgul merged 1 commit into
mainfrom
arena/736ba841-env-compare
Oct 20, 2026
Merged

imgul merged 1 commit into
mainfrom
arena/736ba841-env-compare

Conversation

@imgul

@imgul imgul commented Oct 20, 2026

Copy link
Copy Markdown
Member

Closes #9.

Side-by-side raw panes scrolled independently, so a glance across the gutter landed on a different region in each file — the reader had to steer both scrollers by hand, which is exactly the work the raw view exists to remove.

What changed

Panes now mirror each other proportionally:

ratio      = source.scrollTop / (source.scrollHeight - source.clientHeight)
target.top = ratio * (target.scrollHeight - target.clientHeight)

Proportional rather than line-for-line, because the files are rarely the same length — that is usually why they are being compared. Equal fractions keep the eye in the same relative place; aligning line 40 of a 60-line file with line 40 of a 400-line file just runs off the end of the shorter one.

Three details that decide whether it is usable:

  • Echo guard. Writing scrollTop fires a scroll event on the pane we just moved; treating that as reader input makes the panes chase each other frame after frame. Each pane records the value last written to it and ignores a matching event.
  • Panes that fit are skipped. A six-line file cannot drag the others to the top as the pointer crosses it.
  • A visible toggle (aria-pressed, on by default, hidden with a single file) — the PRD's US-14 already specified a toggleable sync scroll, and it keeps a stuck pane from looking like a bug.

While in the file: each pane is now tabIndex={0} and focus-visible ringed (a scroll region that cannot be focused cannot be scrolled without a mouse), and each <section> carries the file name as its accessible name.

Verification

  • tests/component/raw-view.test.tsx — 7 tests: proportional mirroring across panes of different lengths, every pane following (not just the second), the echo guard, sync off, a source pane with no overflow, keyboard reachability, pane labels. jsdom has no layout, so geometry is stubbed — the sync is arithmetic on those numbers.
  • e2e/tool.spec.ts — a case that measures real layout in the CI browser matrix (120-line vs 60-line files, half-scroll, then toggle off and confirm the pane stays put).
  • npm run check — 402 tests / 22 files, tsc clean, build ✓, privacy guard ✓.
  • Suite grew 395 → 402, so the generated tests badge and the README line moved with it.

Closes #9.

Side-by-side raw panes scrolled independently, so a glance across the gutter
landed on a different region in each file and the reader had to steer both
scrollers by hand.

Panes now mirror each other proportionally:
scrollTop / (scrollHeight - clientHeight), applied to every other pane. The
files are rarely the same length, which is usually why they are being
compared, so equal fractions keep the eye in the same relative place where
equal line numbers would run off the shorter file.

Three details that decide whether it is usable:

- an echo guard: writing scrollTop fires a scroll event on the pane we just
  moved, and treating that as input makes the panes chase each other. Each
  pane records what was last written to it and ignores a matching event.
- panes that fit are skipped, so a six-line file cannot drag the others to
  the top as the pointer crosses it.
- a visible toggle (aria-pressed, on by default), which PRD US-14 already
  asked for and which keeps a stuck pane from looking like a bug.

Each pane is also focusable and focus-visible ringed, because a scroll region
that cannot be focused cannot be scrolled without a mouse, and each section is
named by its file.

Covered by tests/component/raw-view.test.tsx (7, with geometry stubbed since
jsdom has no layout) and an e2e case that measures real layout in the CI
browser matrix. Suite is 402 tests; the generated badge moved with it.
@imgul
imgul merged commit f71b0b3 into main Oct 20, 2026
1 check failed
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.

Sync auto-scroll across all env cards/files in Raw mode

1 participant