Skip to content

fix(mobile): reuse gallery resources for workspace image taps - #40576

Merged
juliusmarminge merged 6 commits into
pingdotgg:mainfrom
StiensWout:t3/1280-mobile-chat-shows-the-same-workspace-ima
Nov 21, 2026
Merged

juliusmarminge merged 6 commits into
pingdotgg:mainfrom
StiensWout:t3/1280-mobile-chat-shows-the-same-workspace-ima

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Mobile chat built different resource identities for a tapped workspace image and its gallery entry, creating an extra page. Thumbnails and gallery entries now use the same resolved resource, so the gallery opens on the tapped image in message order and preserves its URL fragment.

Fixes #40575

Reproduction on main

Commit da57ea2bf9 (main). The gallery opens at 1 of 3 and the first swipe advances to a second copy of the red image. The cause is at apps/mobile/src/lib/filePreviewGallery.ts:8. Followed the steps under Evidence in the app on iPhone 18 Pro (iOS 27.0): With two synthetic workspace PNGs and the exact Markdown supplied by a replay, tapping the red image opened the viewer at 1 of 3. One left swipe advanced to 2 of 3 and showed the same red image again.

Evidence

Environment: iPhone 18 Pro, iOS 27.0, iOS Simulator on macOS

Steps:

  1. Open T3 Code on an iPhone simulator paired to a development environment.
  2. In a project thread with file access, ask the agent to create two distinct PNGs named red.png and blue.png in the thread's workspace and reply with exactly this Markdown, outside a code fence:

Red

Blue
3. Tap the red image in the final reply.
4. Swipe left once in the full-screen viewer.

Proven: the bug shows on main at da57ea2bf9 and no longer shows on head 145b323f90.

Before After
Commit da57ea2bf9 145b323f90
Result Shows: With two synthetic workspace PNGs and the exact Markdown supplied by a replay, tapping the red image opened the viewer at 1 of 3. One left swipe advanced to 2 of 3 and showed the same red image again. Does not show: With two pre-seeded synthetic PNGs and the exact Markdown returned by a replay, tapping the red image in the reply opened the gallery at 1 of 2. One left swipe showed the blue image at 2 of 2.
Gallery on open Before: Gallery on open After: Gallery on open
Gallery after one left swipe Before: Gallery after one left swipe After: Gallery after one left swipe
Reproduction recording Before: Reproduction recording After: Reproduction recording

Tests

  • 9c12c6049b adds the failing test, alone, before the fix.
  • pnpm exec vp test run apps/mobile/src/lib/filePreview.test.ts -t 'one page per workspace image' passed on head.
  • pnpm exec vp run check:changed passed on head.

Not in this change

  • Empty Markdown, blocked paths, and relative paths without a workspace root produce no gallery entry.
  • Direct URLs use the existing direct image path, and absolute host paths keep their existing access policy.
  • Attachments, draft previews, and tool output images use their own resource construction.
  • Equivalent files authored with distinct path spellings keep their existing identities.
  • Asset failures, late responses, and out-of-order URL refreshes are handled during preview resolution.
  • The expanded viewer keeps its existing SVG rendering behavior.
  • Web and desktop use a separate chat renderer, and both mobile platforms share the corrected resource selection.

Who did the work

  • Written by GPT 6.2 Sol, in Codex
  • Review findings fixed by GPT 6.2 Sol, in Codex
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, each on its own
  • Also reviewed by cubic, run locally by a program, with no score
  • Reproduced on the device, on main and on the head, by GPT 6.2 Sol, in Codex
  • Checks run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol and Claude Opus 5.5

StiensWout and others added 4 commits November 21, 2026 22:41
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
ThreadMarkdownImage already treats a missing srcFragment as empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ThreadFeed now renders non-direct markdown images through resolved image media backed by a media-file resource. Image previews include a defined source fragment. Tests check preview data and workspace-image gallery ordering.

Changes: Workspace image gallery

Layer / File(s) Summary
Resolve workspace images and verify gallery previews
apps/mobile/src/features/threads/ThreadFeed.tsx, apps/mobile/src/features/threads/ThreadMarkdownImage.tsx, apps/mobile/src/features/threads/ThreadMarkdownImage.test.tsx, apps/mobile/src/lib/filePreview.test.ts
Non-direct markdown images render through resolved image media backed by a media-file resource. Preview sources include a defined fragment. Tests check preview resource, fragment, gallery entries, and message-order selection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to eeb97

This change fixes duplicate workspace images in the mobile chat gallery and keeps URL fragments when a preview opens. Tests cover the gallery ordering and the fragment. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(mobile): reuse gallery resources for workspace image taps" follows conventional commit format and names the main change: workspace image taps in the mobile gallery now reuse the same re…
Description check Passed The description is mostly complete. It explains the problem (duplicate gallery page for a tapped workspace image) and the change (thumbnails and gallery entries share one resolved resource). It links …
Linked Issues check Passed [#40575] requires that, with two distinct workspace PNGs and the reported relative-path Markdown, tapping red opens the gallery at 1 of 2 and one left swipe shows blue. The whole-PR diff (merge base t…
Out of Scope Changes check Passed The ThreadFeed.tsx diff changes only the markdown image branch. It removes the Blocked check and the media-file construction, and it removes the markdownImageSourceFragment import, which is now unused…
Full details: Title check

Explanation

The title "fix(mobile): reuse gallery resources for workspace image taps" follows conventional commit format and names the main change: workspace image taps in the mobile gallery now reuse the same resolved resource as the gallery entry. The raw summary and objectives confirm that ThreadFeed and ThreadMarkdownImage now pass the resolved media-file resource to the gallery, and that the fix targets duplicate pages in the mobile gallery.

Full details: Description check

Explanation

The description is mostly complete. It explains the problem (duplicate gallery page for a tapped workspace image) and the change (thumbnails and gallery entries share one resolved resource). It links issue #40575 and gives reproduction steps, before/after evidence, and test commands. It also covers scope exclusions and the authorship of the work. The template's Scope section asks for a bug-fix justification and a linked issue, which the description provides through the issue link. The template's Problem and Change headings are not used as literal headings, but the content maps onto them.

Full details: Linked Issues check

Explanation

[#40575] requires that, with two distinct workspace PNGs and the reported relative-path Markdown, tapping red opens the gallery at 1 of 2 and one left swipe shows blue. The whole-PR diff (merge base to head eeb9772) shows that ThreadFeed.tsx no longer builds a separate media-file resource from props.environmentId, props.threadId, and the classified path. It now passes media.source.environmentId, media.source.resource, media.source.srcFragment, and media.source.actionsSource from resolveMarkdownMediaPreview to ThreadMarkdownImage. The thumbnail and the gallery entry therefore share one resource. filePreviewGallery.ts at head dedupes items by filePreviewKey. That key covers environmentId and resource fields but excludes mimeType and fileName. srcFragment is not part of the key, so the selected source replaces its matching gallery item and yields one page per image. The author reports a device reproduction on head showing 1 of 2 and blue on swipe, plus a passing targeted test. Limitation: the test diffs were not read in this review. The verdict relies on the ThreadFeed diff, the head file content, and the author's reported evidence. The change from the previous reviewed head 145b323 was not isolated, but the whole-PR diff covers it.

Full details: Out of Scope Changes check

Explanation

The ThreadFeed.tsx diff changes only the markdown image branch. It removes the Blocked check and the media-file construction, and it removes the markdownImageSourceFragment import, which is now unused. The branch now renders an image only when resolveMarkdownMediaPreview yields a media-file image. Otherwise it renders ThreadMarkdownImageUnavailable. Direct image URLs take the earlier classified direct path, as the PR description states. The other changed files, ThreadMarkdownImage.tsx, ThreadMarkdownImage.test.tsx, and filePreview.test.ts, are tests or a srcFragment pass-through that support the same markdown-image resource path. The change does not touch attachments, draft previews, tool output, or web/desktop code, as the PR description states. Limitation: the test diffs were not read in this review, so this verdict relies on the ThreadFeed diff and the file list from the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 145b323 and eeb9772.

Files selected for processing: 1

  • apps/mobile/src/lib/filePreview.test.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 21, 2026
juliusmarminge and others added 2 commits November 21, 2026 22:08
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Pooled iPhone 18 Pro, iOS 27.2, same viewport and appearance. Each commit used its own fresh server database and Metro bundle. Synthetic workspace PNGs and the exact assistant Markdown reply were seeded through the scenario helpers and replay provider.

Open the thread, tap red, then swipe left once. Base repeats red; head advances directly to blue.

Step Before After
Commit 404dd5bad2 eeb97720ff
Tap red Before: red, 1 of 3 After: red, 1 of 2
One left swipe Before: duplicate red, 2 of 3 After: blue, 2 of 2
Recording Before tap and swipe After tap and swipe

Directly tapping blue on head also selects page 2 of 2: recording.

Seed script · Stable capture script

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 21, 2026
@juliusmarminge
juliusmarminge merged commit d3242f8 into pingdotgg:main Nov 21, 2026
58 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mobile chat shows the same workspace image twice in its gallery

2 participants