Skip to content

fix(web, native): make the image viewer work in Rune and on phones - #491

Merged
Makisuo merged 1 commit into
mainfrom
t3/fix-mobile-image-carousel
Nov 15, 2026
Merged

Makisuo merged 1 commit into
mainfrom
t3/fix-mobile-image-carousel

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • One image at a time: when Rune draws the app (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.
  • Layering: a new Mount, ImageViewerNativeModal, shows the viewer over the whole window as a modal, and Escape closes it. The message hover toolbar no longer draws over it.
  • iPhone swipe: a new hook, 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.
  • CSS: the rule that hides the arrows on phones is split into two single queries, because Rune's style converter skips a query list.

Web (mobile)

  • Tapping a thumbnail or arrow while a swipe was still coasting was dropped, so the track stopped on a different slide than the counter showed. Now it lands on the slide you tapped once the swipe stops.
  • A resize mid-swipe (a phone's address bar showing or hiding) no longer snaps the slide back under the finger.
  • Once a pull, pan or pinch is under way, the browser no longer starts its own scroll or zoom over it.

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

  • New browser test: tapping a thumbnail while the track is still moving lands on that thumbnail. It fails on the old gestures.ts.
  • apps/web-foldkit: typecheck; vitest (709); viewer browser tests (10).
  • apps/native: typecheck; vitest (79); cargo check for the iOS simulator target.
  • Run by hand in the headless Mac Rune host and on an iPhone 17 Pro simulator, with temporary fixture images that aren't in this diff. Checked: open, arrows, thumbnails, arrow keys, Escape, swiping left and right, Close, and swiping back after closing.
  • Not tried yet: the mobile web changes in a real phone browser.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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-bot

maple-review-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Maple review

🟡 Confidence 6/10 · needs attention. Held at 6 because a correctness warning is open.
1 warning −1

Findings

🟠 Warning · F1 · pending ??= active on resize makes a mid-swipe resize undo the swipe

correctness · apps/web-foldkit/src/chat/viewer/gestures.ts:676-679

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.

			// 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 this finding with an AI agent
Findings from an automated review of commit 8d87961d65cffde5827f2582fcc4641d60668c26. Verify each one against the current code before changing anything, fix only those that still apply, and keep each fix to the lines it names.

---

F1 · Warning · correctness · 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)

8d87961 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@Makisuo
Makisuo merged commit c88e3f6 into main Nov 15, 2026
6 of 8 checks passed
@Makisuo
Makisuo deleted the t3/fix-mobile-image-carousel branch November 15, 2026 23:52

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline note from Maple's review. The score and summary are in the review comment above.

Comment on lines +676 to +679
// 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Suggested change
// 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.

@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 74.07% 37747 / 50960
🔵 Statements 73.04% 42945 / 58793
🔵 Functions 61.82% 13524 / 21876
🔵 Branches 61.54% 21406 / 34783
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/native/src/mounts.ts 100% 100% 100% 100%
apps/web-foldkit/src/chat/image-viewer.ts 27.38% 37.06% 15.58% 28.16% 70, 76-78, 84-107, 111-112, 116-120, 129-154, 157-158, 166-228, 239-249, 257-264, 464-468, 497-506
apps/web-foldkit/src/chat/viewer/gestures.ts 4.16% 0% 0% 4.75% 65-76, 79-730
apps/web-foldkit/src/page/chat/overlay-views.ts 71.73% 89.47% 50% 75% 28-29, 31-32, 34-35, 37-38, 43-54, 115-119, 191-202
apps/web-foldkit/src/platform/renderer.ts 100% 100% 100% 100%
apps/web-foldkit/src/platform/system-ui.ts 100% 100% 100% 100%
Generated in workflow #2366 for commit 8d87961 by the Vitest Coverage Report Action

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.

1 participant