~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

iOS: a tile comes back scrolled where it was

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/hud:ios/keep-scroll

On iOS, a feed tile that comes back now shows where you left it, not its top and posts you've already read.

Claude Opus 5.5 · low

What changes

A tile keeps its place. Step, which outlives a tile's view in Browser.tileSteps, keeps how far it was scrolled (offset). StepView's scroll view records it as it scrolls (onScrollGeometryChange) and goes back there once its result is drawn again (ScrollPosition.scrollTo(y:)). It doesn't record over the saved offset until it has gone back. This is the web tile's scrollTop, kept as it stops drawing, on iOS.

Why

A tile's scroll view is made again whenever the strip or the tile is rebuilt: switching canvas tabs (StripView(...).id(canvas)), or a tile moving between columns. It started at the top. A trial on the simulator hosted a 20-column strip of lazy columns, each a spinner first and then 300 rows of varying heights. It scrolled the first column to 4,000 pt, then:

withoutwith
swiped 19 columns away and back4000 (SwiftUI kept the scroll view)4000
strip rebuilt by .id and back04000

onScrollGeometryChange and ScrollPosition need iOS 18. On iOS 17 it starts at the top as before, gated the way Glass.swift gates iOS 26. Every device that runs iOS 17 runs 18.

How it was checked

The trial above, run with xcodebuild test on an iPhone 17 Pro simulator (iOS 26.5), then deleted. The app builds; harness/docs.mjs passes.

Shortcomings

Not tried by hand in the signed-in workspace. Which navigation reset the tile you used wasn't pinned down: swiping between columns already kept its place, so rebuilds are what this fixes. iOS 17 is unchanged.

Approved

This keeps each tile's scroll offset on Step, which outlives the view. The KeepsScroll modifier records the offset as the tile scrolls. Once the result is drawn again, it scrolls back to the saved offset. It doesn't record over the saved offset until it has gone back, so the fresh view's offset of 0 can't overwrite it. iOS 17 is gated out and unchanged, and docs/memory.md is updated to match.

I found nothing that must change. I read all three changed files and didn't build or run the code. The restored guard and the per-step identity handle a view that is reused for a different step.

One thing I couldn't confirm from the diff: restoring depends on a single Task.yield() leaving the content tall enough to reach the saved offset. If a tile's content ever laid out later than that, the scroll would clamp to the shorter content. restored would then be set and the clamped offset recorded. Your simulator trial with lazy columns covered this case and passed, and you note it wasn't tried by hand in the signed-in workspace, so it's worth a quick check there.

Merged as 4281512