Skip to content

feat: persist unsent chat draft per session in localStorage - #72

Open
Elompenta wants to merge 1 commit into
deflating:mainfrom
Elompenta:textarea-persist-storage
Open

feat: persist unsent chat draft per session in localStorage#72
Elompenta wants to merge 1 commit into
deflating:mainfrom
Elompenta:textarea-persist-storage

Conversation

@Elompenta

Copy link
Copy Markdown
Contributor

Summary

  • Debounced-saves the message textarea's value to localStorage keyed by session file, so unsent text survives a page reload.
  • Restores the draft on session switch / mirror sync, clears it on send, and flushes on beforeunload so the debounce window can't lose the last keystrokes.

Covers the currently active (writable) chat right away. Historical sessions stay read-only for now, so they never get a draft to save; once a "resume a sidebar session" change lands and makes them writable too, drafts will start covering all chats automatically, since this hooks the same switchSession() entry point.

Test plan

  • Typed text in the chat input without sending, reloaded the page - text reappeared.
  • Typed, then sent - draft cleared.
  • Switched sessions in the sidebar - draft is scoped per session.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

Debounced-saves the message textarea's value to localStorage keyed by
session file, restores it on switchSession()/mirrorSync, and flushes
on send and beforeunload so a reload never loses in-progress text.

This covers the current chat right away. Historical sessions stay
read-only for now, so their drafts never get written; once the
"resume a sidebar session" branch merges and makes them writable
too, drafts start covering all chats automatically, since it hooks
the same switchSession() entry point.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant