Skip to content

[Bug] Multi-file Annotate Back returns to the top instead of restoring scroll position (#2082 follow-up) #2128

Closed

Description

@zane668

What happened?

The scroll restoration from #2082 / #2084 still fails in multi-file Annotate sessions. From the middle of a bundle document, follow a link to another Markdown file or a local HTML module, then click the in-app Back control: the correct source file returns, but at its beginning rather than the previous reading position.

The same document in a single-file session restores its reading position. This is a bundle-specific follow-up, not a request to reimplement the already-fixed single-file case.

Minimal fixture

Create these files in one directory with Python 3 (standard library only):

from pathlib import Path

p = Path('scroll-back-repro')
p.mkdir(exist_ok=True)
sections = ['# Review document\n\n']
for i in range(1, 81):
    sections.append(
        f'## Section {i}\n\n'
        '[Open linked Markdown](linked.md) · [Open HTML module](module.html)\n\n'
        + 'Plain sample text for a long document. ' * 12 + '\n\n'
    )
(p / 'review-alpha.md').write_text(''.join(sections))
(p / 'review-beta.md').write_text('# Second document\n\nSample text.\n')
(p / 'linked.md').write_text('# Linked document\n\nSample text.\n')
(p / 'module.html').write_text(
    '<!doctype html><html><head><title>Sample module</title></head>'
    '<body><h1>Sample module</h1><p>Sample text.</p></body></html>'
)

Run:

plannotator annotate scroll-back-repro/review-alpha.md scroll-back-repro/review-beta.md
  1. In review-alpha.md, scroll to around Section 40.
  2. Click Open linked Markdown there.
  3. Click Back to review-alpha.md in the file sidebar. Do not touch the wheel/keyboard while it restores; wait at least 3 seconds.
  4. The source file is back at the top.
  5. Scroll back to Section 40, click Open HTML module, then use the header's Back control. The source file again returns at the top.

Control: run plannotator annotate scroll-back-repro/review-alpha.md alone and repeat. That restores the source document near the position it was left.

Measured comparison

A synthetic long document with those links, 80 sections, and a sample image above them was tested at 1440×1000. Measurements are of the actual document <main> scroll container, not window.scrollY:

Session Destination Before opening After Back + settling
Two-file bundle Markdown 11088 px 0 px
Two-file bundle HTML 11088 px 0 px
Single file Markdown 11088 px 11088 px
Single file HTML 11088 px 11129 px

The single-file HTML return stays near the original reading position, not the document beginning. Its content height also increased by 41 px; that observation alone does not prove why its scroll position changed. The bundle returns to zero both after 1 second and after 3 seconds. No uncaught page errors were observed. Tests used ordinary link/button clicks in real Chromium via Playwright; no mocked React state or injected scroll restoration.

Source pointer

At release commit bbcaa97c1478fd5d75697022c10086878f8beef0 (also main when checked):

  • App.tsx:2253–2266: handleLinkedDocBack calls openBundleFile(bundleBackPath, ...) and returns early for bundles, bypassing linkedDocHook.back().
  • useLinkedDoc.ts:494–527: the scroll anchor is saved for the original root, while navigating onward from an already-linked document caches content/annotations without a per-document scroll anchor.

These are plausible reasons the existing root-document fix does not cover bundle Back; I have not instrumented the runtime call path to prove the exact internal cause.

Expected

Back from a linked Markdown/HTML document should restore the place in the originating bundle file, just as the single-file flow does. Regression coverage should exercise the full multi-file editor navigation, both sidebar Back and HTML header Back, not only the root hook's back() method.

Plannotator version

plannotator 0.28.30 (latest release when checked, 2026-10-24)

OS

macOS 27.0.1 (26A434), arm64

Agent

Pi; reproduction uses the standalone CLI with isolated HOME/data and synthetic files, no local viewer wrapper or source patches.

Where did it happen?

Annotate → multiple file arguments → link from an active bundle file → in-app Back. Chromium 155.0.8059.12 (headless), 1440×1000. Browser-toolbar Back and Safari/mobile were not tested.

Activity

  1. added
    bug
    on Oct 24, 2026
  2. backnotprop commented on Oct 24, 2026

    @backnotprop
    Owner

    Fixed in #2129.

  3. added a commit that references this issue on Oct 24, 2026
    0b3d331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions