Skip to content

fix(mobile): resize Android image previews with the window - #13859

Merged
juliusmarminge merged 14 commits into
pingdotgg:mainfrom
dylan1020:t3code/fix-foldable-image-viewer
Oct 20, 2026
Merged

juliusmarminge merged 14 commits into
pingdotgg:mainfrom
dylan1020:t3code/fix-foldable-image-viewer

Conversation

@dylan1020

@dylan1020 dylan1020 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Android image previews use the current window size when opened and after a fold, split-screen, width change, or height change. The dependency previously cached its startup dimensions, leaving the image, loading indicator, and pan bounds at the old size.

The dependency patch refits the image and resets zoom, paging, and header controls on resize. It keeps the nearest gallery image reported by scroll events, including during a swipe, and ignores callbacks from the replaced list. A native page movement whose scroll event has not yet reached JavaScript remains an unresolved timing case. The image list remounts while the header retains its state, so resizing no longer aborts a share download. Both MediaImagePreview and FilePreview use the patched boundary. iOS keeps its existing geometry and momentum-end indexing. Stable animation values are shared; the first gallery image can now unmount after paging away and briefly reload when returning, matching the other pages. Include this in the iOS regression pass.

Credit to @dylan1020 for the original fix in #13859. The takeover preserves the original commits, merges current main, and handles galleries now present on main. The dependency changes are candidates for upstreaming; no upstream PR was opened.

Validation:

  • Existing focused Vitest suites: 85/85 tests across eight files, before and after; no permanent tests added. These do not execute the native image viewer.
  • Mobile typecheck, targeted entry-point lint/format, frozen-lockfile installation, and patch integrity checks passed.
  • Temporary diagnostics execute the real dependency JavaScript with React and a simulated native boundary. Original patch: 3/4 cases passed, with a gallery jump during resize before momentum-end. Rebuilt patch: 4/4 original cases and 9/9 extended cases passed. The four original cases are a subset of the nine. A fractional-density probe also passes at all three sampled densities after fixing the native-float/window-double width comparison. The expanded diagnostic now passes both valid pre-commit crossing-event cases and rejects a re-laid-out list. It reports 12 pass / 1 conditional failure across 13 cases: withholding the page-crossing event until after remount still loses the unseen selection. Whether Android delivers this exact ordering is unverified. These 13 cases include the original nine. This is diagnostic evidence, not native proof.

Diagnostic output: original patch gallery failure, current head, including pre-commit events and the unresolved conditional ordering, fractional-width before, fractional-width after.

Header lifecycle diagnostic: before, after. This checks component preservation, not a native share sheet.

Native proof is still required. Device access is disabled in this environment, so there are no current-head Android or iOS screenshots/recordings. Verify both preview entry paths on Android: fold/unfold or split-screen, height-only resize, delayed image loading, zoom/pan then resize, and resize during gallery dragging/momentum. Confirm native event ordering, fractional-density gallery paging and save/share targets, close controls, safe-area/Modal behavior, and iOS regressions. macOS, Windows, and Electron desktop were not exercised; those surfaces use separate image preview UIs.

Independent full-diff review: round 1 found the fractional-density regression (fixed) and the conditional delayed-scroll case (unresolved native verification). Round 2 identified a guard that discarded valid pre-commit events (fixed by deletion). Round 3 identified a header remount that aborted a pending share (fixed by moving the resize key to the list). Round 4 returned no confirmed code defects from either reviewer. The minor first-cell retention change is accepted and documented above. Current-head build/typecheck, lint, test jobs, release smoke, Rust, and native fingerprint checks passed. An earlier cancelled fingerprint run was superseded by a successful run. Macroscope correctness passed; approvability requires human review of the native runtime changes. This PR is not ready for merge without native proof.

Implemented with Codex gpt-6.1-sol; test analysis with Codex gpt-6-astra; adversarial review with Claude Opus 5.5 and Codex gpt-6-sol, through T3 Code.

Refresh viewer sizing and gesture bounds after Android window changes, and remount the gallery at its current image to reset zoom. Fixes pingdotgg#13854.
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 26, 2026
Comment thread patches/react-native-image-viewing@0.2.2.patch Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — The PR applies a substantial third-party dependency patch to the production Android image-preview path, changing dimension handling, list remounting, gesture state, and scroll/index lifecycle. Because this is an existing-path runtime behavior change involving native resize timing, human review is warranted.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7623cf8-d90e-40e2-87bf-ebfc63e7daf4
📥 Commits

Reviewing files that changed from the base of the PR and between ca5884f and 23d4862.

⛔ Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 2
  • patches/react-native-image-viewing@0.2.2.patch
  • pnpm-workspace.yaml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

The image viewer patch uses current Android window dimensions for layout and gesture bounds. It resets viewport-related state, filters stale events, updates index tracking, and registers the patched dependency.

Changes: Android preview viewport

Layer / File(s) Summary
Synchronize viewport and list state
patches/react-native-image-viewing@0.2.2.patch
ImageViewing tracks the active viewport, resets animated and list state on Android resize, initializes the list index, and filters stale zoom and scroll events.
Apply current render dimensions
patches/react-native-image-viewing@0.2.2.patch, pnpm-workspace.yaml
ImageItem and ImageLoading use current dimensions for Android sizing. The workspace registers the patched dependency.
Refresh animation and gesture calculations
patches/react-native-image-viewing@0.2.2.patch
useAnimatedComponents accepts an optional reset key and refreshes memoized animated values. usePanResponder calculates gesture bounds from current window dimensions.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 23d48

No actionable preview defect is established. The change is mergeable after normal checks; native device validation remains advisable.

Architecture Summary

Architecture risk: 🔵 Low · up to 23d48

The change affects 2 systems.

Changed systems: patches, pnpm-workspace.yaml

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — patches (service) was modified; 1 changed file maps to changed impact.
  • observed — pnpm-workspace.yaml (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in patches/react-native-image-viewing@0.2.2.patch: ImageViewing now uses Android window dimensions for viewport width, passes the viewport to index tracking, resets animated controls and the virtualized list on Android resize, and filters stale zoom callbacks through the active callback reference. The list starts at the tracked current index and receives Android scroll handling with a 16 ms throttle.
  • observed — Modified behavior in patches/react-native-image-viewing@0.2.2.patch: Android ImageItem now reads window dimensions inside the component, includes onZoom in the zoom-effect dependencies, and applies computed dimensions inline instead of shared styles.
  • observed — Modified behavior in patches/react-native-image-viewing@0.2.2.patch: ImageLoading now selects Android window dimensions versus screen dimensions at render time and applies them directly to the loading view; obsolete size styles were removed.
  • observed — Modified behavior in patches/react-native-image-viewing@0.2.2.patch: The useAnimatedComponents declaration now accepts an optional string resetKey.
Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly summarizes the primary change: Android image previews now resize with the window.
Description check Passed The description explains the problem, implementation, affected preview paths, verification results, known limitations, and required native validation. It does not explicitly document maintainer approv…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, implementation, affected preview paths, verification results, known limitations, and required native validation. It does not explicitly document maintainer approval or explain why the change qualifies without prior approval, but the remaining content is detailed and relevant.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector
Comment thread patches/react-native-image-viewing@0.2.2.patch Outdated
@juliusmarminge juliusmarminge mentioned this pull request Oct 2, 2026
2 tasks done
@juliusmarminge juliusmarminge self-assigned this Oct 19, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Taking over this one for maintainer batch terminal-preview-13. I will bring it onto current main, keep the Android resize fix focused, and push the reviewed changes to this branch.

@juliusmarminge
juliusmarminge merged commit af17eb9 into pingdotgg:main Oct 20, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants