Skip to content

fix(web): avoid false draft attachment persistence warnings#1153

Open
shivamhwp wants to merge 2 commits intopingdotgg:mainfrom
shivamhwp:attachment-bug
Open

fix(web): avoid false draft attachment persistence warnings#1153
shivamhwp wants to merge 2 commits intopingdotgg:mainfrom
shivamhwp:attachment-bug

Conversation

@shivamhwp
Copy link
Collaborator

@shivamhwp shivamhwp commented Mar 16, 2026

Summary

  • flush pending composer draft writes before verifying persisted image attachments
  • prevent draft attachments from being marked as unsaved during the debounce window
  • add a regression test covering attachment verification after the debounced write is flushed

Fixes #979

Before
image
After
image

Why

The composer draft store debounces localStorage writes, but attachment verification was reading storage immediately in a microtask. That could race the pending write and incorrectly flag persisted attachments as non-persisted, which surfaced the "Draft attachment could not be saved locally" warning even when persistence would have succeeded.

Test plan

  • bun fmt
  • bun lint
  • bun typecheck

UI evidence

  • This is a small UI behavior fix with no visual layout change.
  • The warning now only appears for real persistence failures instead of debounce timing.

Made with Cursor

Note

[!NOTE]

Fix false draft attachment persistence warnings in composer draft store

  • Extracts a verifyPersistedAttachments helper in composerDraftStore.ts that flushes pending debounced storage writes before reading persisted attachment IDs, preventing race conditions where attachments appeared unpersisted.
  • Storage read errors are now caught and treated as an empty persisted ID set instead of throwing.
  • Adds a test in composerDraftStore.test.ts that verifies nonPersistedImageIds is empty after the debounced write is flushed.

Macroscope summarized 5aa4f85.

@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 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: 9b475000-ae82-4b69-bdf9-fa3b39ebfc59

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
📝 Coding Plan
  • Generate coding plan for human review comments

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

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Mar 16, 2026
Flush pending composer draft writes before verifying persisted attachments so image drafts are not incorrectly marked as unsaved due to the debounce window.

Made-with: Cursor
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: Always getting Draft attachment couldn't be saved when pasting images

1 participant