Skip to content

fix(web): verify composer attachment persistence after flush#1305

Open
UtkarshUsername wants to merge 1 commit intopingdotgg:mainfrom
UtkarshUsername:fix/composer-draft-persist-badge
Open

fix(web): verify composer attachment persistence after flush#1305
UtkarshUsername wants to merge 1 commit intopingdotgg:mainfrom
UtkarshUsername:fix/composer-draft-persist-badge

Conversation

@UtkarshUsername
Copy link
Contributor

@UtkarshUsername UtkarshUsername commented Mar 22, 2026

Fixes #1304

What Changed

Fixed composer image attachment persistence verification in apps/web.

The draft store now flushes pending debounced composer draft writes before checking which attachment IDs actually landed in persisted storage. This removes the false warning state where image attachments were marked non-persisted simply because the storage write had not fired yet.

Also added regression coverage for:

  • successful persistence after flushing the pending write
  • real persistence failure when storage flush/write throws

Why

The previous logic staged persisted attachments in Zustand state and then immediately checked storage on the next microtask. That check raced the 300ms debounced persistence write and could conclude that attachments were not saved even though the write was only still pending.

This made the orange warning badge show up incorrectly and undermined image draft persistence across refresh/navigation.

Flushing only at the point of attachment verification keeps normal draft persistence debounced for performance, while making the warning badge reflect actual storage failure.

UI Changes

None

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

Fix composer attachment persistence after flushing debounced draft storage

  • Adds flushComposerDraftStorage in composerDraftStore.ts that wraps composerDebouncedStorage.flush() in a try/catch, returning a boolean for success or failure.
  • syncPersistedAttachments now calls this flush before reading persisted attachment IDs from storage; if the flush fails, all attachments are treated as non-persisted.
  • Adds two tests in composerDraftStore.test.ts verifying attachments remain persisted on successful flush and are marked non-persisted when storage throws.

Macroscope summarized 6a25a63.

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 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: ab9e0a7f-8d63-47de-8da8-473f484bbdc8

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.

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

@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 Mar 22, 2026
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.

[Bug]: Composer image attachments are marked non-persisted due to premature draft storage verification

1 participant