Skip to content
This repository was archived by the owner on Apr 25, 2026. It is now read-only.

Sync browser viewport with page pagination#10

Merged
4fuu merged 3 commits into
mainfrom
copilot/fix-page-navigation-viewport
Apr 13, 2026
Merged

Sync browser viewport with page pagination#10
4fuu merged 3 commits into
mainfrom
copilot/fix-page-navigation-viewport

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

page --next / --prev only changed the CLI-rendered slice of the snapshot; the browser itself stayed at the old scroll position. This updates pagination to move the real viewport first, then render from the refreshed page state.

  • CLI pagination flow

    • page() now resolves the target page, computes its scrollTop, sends a browser scroll action, and then fetches a fresh snapshot before rendering.
    • This applies to --next, --prev, and explicit page selection.
  • Protocol + extension support

    • Added a new scroll action to the shared protocol.
    • Routed scroll through the extension service worker to the content script.
    • Implemented a content-side scroll handler with window.scrollTo(...) so pagination updates the actual browser viewport.
  • Focused pagination logic

    • Extracted page/scroll helpers in Rust for:
      • current page resolution
      • total page calculation
      • target scroll offset clamping on the last page
  • Targeted coverage

    • Added focused Rust tests for adjacent page navigation, explicit page clamping, and maximum scroll offset handling.
let resolved_page = resolve_requested_page(&snapshot, page_num, next, prev);

if let Some(target_page) = resolved_page {
    send_ok(Request::new(
        actions::SCROLL,
        json!({
            "session_id": session_id,
            "top": scroll_top_for_page(&snapshot, target_page),
        }),
    ))
    .await?;
}

let snapshot = fetch_snapshot(session_id, actions::GET_PAGE_FRESH).await?;

Copilot AI and others added 2 commits April 13, 2026 14:21
Copilot AI changed the title [WIP] Fix browser viewport position not updating during pagination Sync browser viewport with page pagination Apr 13, 2026
Copilot AI requested a review from 4fuu April 13, 2026 14:27
Copilot finished work on behalf of 4fuu April 13, 2026 14:27
@4fuu 4fuu marked this pull request as ready for review April 13, 2026 14:30
@4fuu 4fuu merged commit e3af7e5 into main Apr 13, 2026
2 checks passed
@4fuu 4fuu deleted the copilot/fix-page-navigation-viewport branch April 13, 2026 15:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

page --next/--prev 翻页时浏览器视口不会跟着滚动

2 participants