Repository navigation
feat: reopen every document where the reader left it - #48
Merged
Merged
Conversation
A PDF returns to its page, a sheet to its tab and row, and text that reflows — Markdown, Labs, Word, plain text and code — to the block and the share of it the reader had scrolled past, which survives a change of width or text size where a pixel offset would not. Images and diagrams that finish after the text push it down, so the place is applied again as the content settles, until the reader does anything. Readers stay pure: each takes a defaultPosition when it mounts and reports onPositionChange, like an uncontrolled input. The shared mutable scroll map they used to write is gone. Positions live in the workspace store beside the tabs and are written by the one place that already saves the tabs, under the same key, a second after the reader pauses and before the page goes away. A position lasts as long as its tab.
This was referenced Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #40
What
HTML, p5 sketches and images are unchanged.
Text that reflows is anchored to a block, not to pixels: after the width or text size changes, the same paragraph is on top. Images, formulas and diagrams render after the text, so the anchor is applied again on each content resize until the reader's first wheel, touch, key or pointer input.
Shape
defaultPositiononce on mount and report throughonPositionChange, the same contract as an uncontrolled input'sdefaultValueandonChange. The shared mutablescrollPositionsmap that readers wrote into is removed.tabs.setPositionandcloseDocumentsare pure reducers.use-workspacealready saves the tabs. It now also writes positions, under the samegamma-reader.workspacekey, with a 1 s debounce and an immediate write onpagehideand unmount. No new storage key, so project deletion cleanup already covers it.core/reading-position.tsas pure functions with unit tests. All DOM timing is contained inmarkdown-reader/use-flow-position.ts.Checks
pnpm checkpasses: 246 unit and 50 integration tests.Start here.mdscrolled to block 10 at a 678px width reopens on block 10 after narrowing to 495px. The pixel offset moved from 665 to 804.