Skip to content

Add whole-page translation scan on current main - #29

Merged
smnexstudio merged 4 commits into
smnexstudio:mainfrom
marufmoinuddin:pr/whole-page-scan-v060
Nov 18, 2026
Merged

smnexstudio merged 4 commits into
smnexstudio:mainfrom
marufmoinuddin:pr/whole-page-scan-v060

Conversation

@marufmoinuddin

@marufmoinuddin marufmoinuddin commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Reapply the whole-page translation scan on upstream main at 48ab2e4 (0.6.0).
  • Add the scan plan, reader controls and scrolling translation flow.
  • Restore the original scroll position when the scan is cancelled.

Scope

Replacement for #8. This branch contains only the four scan commits, without the offline-model library or LAN HTTP changes.

Validation

  • Debug APK built successfully on the VPS in a combined integration worktree.
  • PageScanPlanTest passed in the integration worktree.
  • Phone-level testing has been performed in my Xiaomi 15 and its working fine.

The plan of a whole-page scan is pure logic, so it can be tested without a
WebView: where to stop (70% of the viewport a step, always the bottom of
the page), and what to keep when the patches do not fit in memory (the
farthest from the viewport go first).

translateViewportOnce is the body of translateViewport, extracted so a
scan can run a step without the two follow-up captures (a page that was
still loading, a canvas page with no text) that the continuous mode
starts on its own. Nothing else changes.
…es it

The three-dot menu gets a new item. It scrolls the page by itself, from the
top to the bottom, and translates every stop with the machinery that is
already there (capture, detect, OCR, translate, patches). The patches stay
while the user stays on the page.

The plan of the scan is pure logic (PageScanPlan): a step covers 70% of
the viewport, so 30% overlaps and a bubble cut by one screenshot's edge is
whole in the next; the last stop is always the bottom of the page.

While the page is held the usual pruning is replaced by a memory budget of
96 MB of decoded bitmap bytes, so a scan does not lose its results: above
the budget the patches farthest from the viewport go first, and those areas
are re-made by the continuous mode when the user scrolls there.

A scan that needs a key or runs on the device asks first how many screens
it will be. Cancel scan keeps the session and the patches and scrolls back
to where the scan started; a touch on the page stops it where the user is.
Transient failures are retried twice and then counted as gaps; a missing
key, an exceeded quota or a missing pack stop the scan at once and leave
the failure in the bottom bar, which already offers the fix.

Only pages that scroll as a window (vertical readers) are supported: a page
that does not scroll is translated only as far as it shows, with a note
saying so.

No pipeline, detector, OCR, engine or capture code is touched.
…s it

The scroll-back sat behind a local flag that was only set at the end of the
try block, so a cancel (which leaves the block through the cancellation)
never scrolled back: the page stayed wherever the scan had reached. The
flag is now the field that cancelScan already sets, so the button scrolls
back and a cancel by a touch (the user took over) does not.
@smnexstudio
smnexstudio merged commit f5271bc into smnexstudio:main Nov 18, 2026
2 checks passed
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