Skip to content

feat(mark-viewed): pin the next file under the sticky header - #2

Merged
solcik merged 1 commit into
mainfrom
feat/gitlab-mark-viewed-pin-diff
Sep 2, 2026
Merged

feat(mark-viewed): pin the next file under the sticky header#2
solcik merged 1 commit into
mainfrom
feat/gitlab-mark-viewed-pin-diff

Conversation

@davidsolc-ai

Copy link
Copy Markdown
Collaborator

Problem

In GitLab's "show one file at a time" mode the diff swaps in place and the viewport stays where it was. A long commit message then sits between the top of the page and the file. Every v needs a manual scroll before the diff is readable.

Change

gitlab-mark-viewed.user.js 0.4.0 → 0.5.0.

After triggering GitLab's own "next file" shortcut, the script re-pins the newly focused file under whatever is sticky at the top edge.

  • fileKey(file) reads the diff container's id (the file hash), falling back to data-path.
  • pinNextFile(previousKey) runs a requestAnimationFrame loop for 400ms. The swap takes a few frames and the file grows as its lines render, so one scroll is not enough.
  • The loop only scrolls once the key differs from the file just marked. On the last file the key never changes, so nothing moves.

In multi-file mode GitLab's j already lands correctly and the pin agrees with it.

Verification

bun run lint and bun run format pass. format:fix also reflowed the README table, so that diff is wider than the one row edited.

Not tested against a live merge request.

https://claude.ai/code/session_01EkNmqezTVuLFRsSebUFKFq

GitLab's "show one file at a time" mode swaps the diff in place and
leaves the viewport where it was. A long commit message then sits
between the top of the page and the file, so every "v" needs a manual
scroll before the diff is readable.

After triggering GitLab's own "next file" shortcut, re-pin the newly
focused file under whatever is sticky at the top edge. The pin runs for
400ms, because the swap takes a few frames and the file grows as its
lines render. It waits for the file hash to change, so the last file
scrolls nothing.

Claude-Session: https://claude.ai/code/session_01EkNmqezTVuLFRsSebUFKFq
@solcik
solcik merged commit 7b8df9d into main Sep 2, 2026
2 checks passed
@solcik
solcik deleted the feat/gitlab-mark-viewed-pin-diff branch September 2, 2026 11:57
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.

2 participants