Skip to content

fix(composer): persist unsent drafts across session switches (#605) - #643

Open
cagdasyurekli wants to merge 1 commit into
andrewyng:mainfrom
cagdasyurekli:fix/issue-605-composer-draft-persistence
Open

fix(composer): persist unsent drafts across session switches (#605)#643
cagdasyurekli wants to merge 1 commit into
andrewyng:mainfrom
cagdasyurekli:fix/issue-605-composer-draft-persistence

Conversation

@cagdasyurekli

Copy link
Copy Markdown

Closes #605

Summary

Fixes an issue where unsent message drafts, attachments, and chosen skills in the composer were unconditionally wiped whenever the user switched conversations or navigated away and returned.

Changes

  • Persistence: Added localStorage-backed draft persistence keyed by session (ocw:composer-draft:${sessionId}).
  • Save & Restore:
    • Automatically saves the draft while typing.
    • On conversation switch (resetKey / sessionId change), saves the outgoing session's draft and restores the incoming session's draft (or leaves it empty if none exists).
    • Preserves draft across component unmount/remount (e.g. navigating to Settings or Inbox and back).
    • Clears stored draft once message is sent or when content is erased.
  • Doorway Prefill Compatibility: Kept session switch layout effect before prefill effect so doorway prefills continue to apply cleanly.
  • Automated Tests: Added tests in Composer.skills.test.tsx covering draft persistence across session switches, draft clearance on send, and remount restoration.

…ng#605)

- Persist draft text, attachments, and pendingSkill per session in localStorage
- Restore draft when switching back to a conversation or remounting Composer
- Clear stored draft upon send or when draft content is emptied
- Add automated regression tests covering draft persistence across session switches, unmount/remount, and clearing on send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsent message in composer is lost when changing the page / switching conversations (no draft persistence)

1 participant