Skip to content

fix(web): fall back to persisted draft bytes for transient image attachments#1836

Open
mawlicious wants to merge 2 commits intopingdotgg:mainfrom
mawlicious:fix/simulator-screenshot-attachments
Open

fix(web): fall back to persisted draft bytes for transient image attachments#1836
mawlicious wants to merge 2 commits intopingdotgg:mainfrom
mawlicious:fix/simulator-screenshot-attachments

Conversation

@mawlicious
Copy link
Copy Markdown

@mawlicious mawlicious commented Apr 8, 2026

What Changed

Uses the persisted draft image bytes as a fallback when sending image attachments if the original File can no longer be read.

This fixes a case where transient attachments, like iOS Simulator screenshots dragged directly into T3 Code, can disappear before send. If the live file is still readable, the existing behavior is unchanged.

Why

iOS Simulator screenshots can be short-lived when dragged directly from the simulator preview. By the time the message is sent, the file may already be gone, which causes the attachment send to fail even though the draft already persisted the image data locally.

This change reuses that persisted draft data as a fallback instead of introducing a new cache or special-case storage path.

UI Changes

No UI changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Changes the image-attachment send path to fall back to persisted draft data when FileReader fails, which could affect message sending and attachment integrity if IDs/matches are wrong. Scope is limited to web client composer attachment handling and is covered by new unit tests.

Overview
Improves reliability of sending image attachments. When building turn attachments, the web client now tries to read the live File bytes first and, if that fails, falls back to the matching persisted draft dataUrl (by attachment id).

This factors the logic into buildTurnImageAttachments and updates ChatView send/retry handling to snapshot and restore persistedAttachments alongside images, with new tests covering live-read, fallback, and hard-failure cases.

Reviewed by Cursor Bugbot for commit e33777f. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fall back to persisted draft bytes for transient image attachments on send

  • Extracts a new buildTurnImageAttachments helper in ChatView.logic.ts that reads live file bytes via readFileAsDataUrl, falling back to a matching persisted attachment's dataUrl when the live file is unreadable, and rejecting only if neither is available.
  • Updates ChatView.tsx to use buildTurnImageAttachments and snapshot persistedAttachments before send; on send failure, syncs the snapshot back into the composer draft to restore state.
  • Behavioral Change: image send no longer fails immediately if the live File object is stale or missing, as long as a persisted copy exists.

Macroscope summarized e33777f.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2c89ebbb-dd20-4c26-b9c9-2c755b6e0f8f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 8, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 8, 2026

Approvability

Verdict: Approved

This is a straightforward bug fix that adds a fallback mechanism when transient blob URLs for image attachments become unreadable. The change extracts existing logic into a testable helper, adds defensive error handling that falls back to persisted draft bytes, and includes comprehensive unit tests. The scope is narrow and self-contained.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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.

1 participant