Repository navigation
fix(web, native): make the image viewer work in Rune and on phones - #491
Conversation
Rune never runs the viewer's DOM gestures, so it got a model-driven paged mode: one fitted slide, arrows, thumbnails and arrow keys that move it, a portalled modal Escape closes, and on iOS a horizontal swipe that pages (SystemUi.setSwipePager) instead of going back. On the web, a slide asked for mid-swipe is no longer dropped (the track and the counter could disagree), a resize mid-swipe no longer yanks the slide back, and pull, pan and pinch keep their touches from the browser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Maple review🟡 Confidence 6/10 · needs attention. Held at 6 because a correctness warning is open. Findings🟠 Warning · F1 ·
|
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
| // A phone's toolbar showing or hiding resizes the viewer mid-swipe: jumping then would | ||
| // yank the slide back under the finger, so the jump waits for the track to stop. | ||
| if (isScrolling) pending ??= active | ||
| else jump(active) |
There was a problem hiding this comment.
Warning
pending ??= active on resize makes a mid-swipe resize undo the swipe
F1 · Warning · correctness
A resize during a swipe (a phone's address bar showing or hiding) sets pending to the slide active held before the swipe, and syncActive then stops following the track (gestures.ts:155). At the settle jump(asked) drags the track back to that slide: the swipe is undone and the counter never moves.
Skip the jump while the track scrolls, as it did before, and let the settle sync the selection to where the track came to rest.
| // A phone's toolbar showing or hiding resizes the viewer mid-swipe: jumping then would | |
| // yank the slide back under the finger, so the jump waits for the track to stop. | |
| if (isScrolling) pending ??= active | |
| else jump(active) | |
| // A phone's toolbar showing or hiding resizes the viewer mid-swipe: a jump then would | |
| // yank the slide back under the finger, so only a settled track is realigned; the | |
| // track's own snap settles it, and the next settle syncs the selection to it. | |
| if (!isScrolling) jump(active) |
🤖 Prompt to fix with an AI agent
In `apps/web-foldkit/src/chat/viewer/gestures.ts:676-679`: `pending ??= active` on resize makes a mid-swipe resize undo the swipe.
A resize during a swipe (a phone's address bar showing or hiding) sets `pending` to the slide `active` held before the swipe, and `syncActive` then stops following the track (`gestures.ts:155`). At the settle `jump(asked)` drags the track back to that slide: the swipe is undone and the counter never moves.
Replace those lines with:
// A phone's toolbar showing or hiding resizes the viewer mid-swipe: a jump then would
// yank the slide back under the finger, so only a settled track is realigned; the
// track's own snap settles it, and the next settle syncs the selection to it.
if (!isScrolling) jump(active)
Verify the problem exists at that location before changing it, and keep the fix to those lines.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Why
The image viewer barely worked in the Rune app and was worst on the phone. Rune never runs the viewer's swipe and zoom code, which needs a browser. So the viewer wasn't layered over the page, and Next, the thumbnails and the arrow keys changed the counter but never the image. On iOS the picture spilled off the screen, and a right swipe left the channel.
Rune
isNativeRenderer(),platform/renderer.ts), the viewer shows only the selected image, fitted and centered. The arrows, thumbnails and arrow keys change it; zoom is hidden.ImageViewerNativeModal, shows the viewer over the whole window as a modal, and Escape closes it. The message hover toolbar no longer draws over it.SystemUi.setSwipePager, makes a horizontal swipe page left or right with a selection haptic while the viewer is open, instead of going back. The iOS host (system.rs,bridge.rs) reuses its existing swipe recognizer for this. Swiping back works again once the viewer closes.Web (mobile)
Screenshots
Mac Rune app, before (the Next arrow changed the counter but not the image; the hover toolbar sat on top):

Mac Rune app, after (the thumbnail selected the second image):

iPhone simulator, after: opened, then swiped left

Testing
gestures.ts.apps/web-foldkit: typecheck; vitest (709); viewer browser tests (10).apps/native: typecheck; vitest (79);cargo checkfor the iOS simulator target.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.