Skip to content

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

Merged
juliusmarminge merged 4 commits intopingdotgg:mainfrom
shivamhwp:attachment-bug
Mar 24, 2026
Merged

fix(web): avoid false draft attachment persistence warnings#1153
juliusmarminge merged 4 commits intopingdotgg:mainfrom
shivamhwp:attachment-bug

Conversation

@shivamhwp
Copy link
Copy Markdown
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 a86d562.

@coderabbitai
Copy link
Copy Markdown

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: b4ff7439-9572-4dc6-9419-012b98432051

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: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
@juliusmarminge juliusmarminge merged commit e11fb6e into pingdotgg:main Mar 24, 2026
9 checks passed
Chrono-byte pushed a commit to Chrono-byte/t3code that referenced this pull request Mar 24, 2026
aaditagrawal added a commit to aaditagrawal/t3code that referenced this pull request Mar 24, 2026
sfncore pushed a commit to sfncore/t3code that referenced this pull request Mar 24, 2026
…draft threads, settings refactor

Merges 18 upstream commits including:
- feat: terminal toggle button in chat header (pingdotgg#633)
- feat: resizable chat sidebar (pingdotgg#1347)
- feat: stream git hook progress events (pingdotgg#1214)
- feat: configurable base directory (pingdotgg#826)
- feat: persist model options (pingdotgg#1121)
- refactor: simplify settings layout (pingdotgg#1288)
- refactor: flatten Git service layer (pingdotgg#1255)
- fix: draft-thread project scripts (pingdotgg#1178)
- fix: draft attachment persistence warnings (pingdotgg#1153)
- fix: PTY adapter runtime loading (pingdotgg#1311)
- fix: Claude SDK filesystem settings (pingdotgg#1334)
- Various UI fixes and polish

Co-Authored-By: Claude Opus 4.6 <[email protected]>
ranvier2d2 added a commit to Ranvier-Technologies/t3code-OTP that referenced this pull request Mar 24, 2026
Cherry-picked from pingdotgg/t3code:
- 843d6d8 fix: add license field to npm package (pingdotgg#1272)
- e11fb6e fix(web): avoid false draft attachment persistence warnings (pingdotgg#1153)
- 2b08d86 Add resizable chat sidebar (pingdotgg#1347)
- e823f8f ci(github): exclude test files from mixed PR size calculation (pingdotgg#1105)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
ranvier2d2 added a commit to Ranvier-Technologies/t3code-OTP that referenced this pull request Mar 24, 2026
Cherry-picked from pingdotgg/t3code:
- 843d6d8 fix: add license field to npm package (pingdotgg#1272)
- e11fb6e fix(web): avoid false draft attachment persistence warnings (pingdotgg#1153)
- 2b08d86 Add resizable chat sidebar (pingdotgg#1347)
- e823f8f ci(github): exclude test files from mixed PR size calculation (pingdotgg#1105)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
gabrielMalonso pushed a commit to gabrielMalonso/t3code that referenced this pull request Mar 24, 2026
apexsloth pushed a commit to apexslothforks/t3code that referenced this pull request Mar 26, 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: Always getting Draft attachment couldn't be saved when pasting images

2 participants