RocketChat / RocketChat/Rocket.Chat
Bug: Unsent message draft is lost when the user's session expires during composition
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Bug: Unsent message draft is lost when the user's session expires during composition
Summary
When a user's session expires while they are composing a message, clicking Send redirects them to the login page after receiving an authentication error. Once they log in again, the message they were writing is lost.
This can result in accidental loss of lengthy or important messages, especially in enterprise environments where users often spend several minutes drafting detailed responses.
Current Behavior
- Open any room or direct message.
- Start writing a long message.
- Let the session expire (or simulate it by invalidating the session).
- Click Send.
- The client receives an authentication error and redirects the user to the login page.
- After logging in again, the message draft is no longer available.
The user has to rewrite the entire message from scratch.
Expected Behavior
If the session expires while a user is composing a message, the draft should be preserved before redirecting to the login page.
After successful authentication, Rocket.Chat should restore the unsent draft so the user can continue editing or send it without losing their work.
Why this is a problem
Losing message drafts can be frustrating, particularly when:
- Writing long technical discussions or incident reports.
- Preparing detailed support responses.
- Sharing meeting notes or documentation.
- Working in environments with shorter session timeouts.
From a user's perspective, the application unexpectedly discards their work even though they didn't intentionally leave the page or clear the draft.
Proposed Solution
Before redirecting the user to the login page after receiving a 401 Unauthorized response:
- Save the current draft locally (for example, using local storage or IndexedDB).
- Store the associated room ID along with the draft.
- After the user logs in successfully, check for any saved draft for that room.
- Automatically restore the draft and display a small notification such as:
"Your unsent draft has been restored."
The draft should only be removed after the message is successfully sent or the user explicitly discards it.
Benefits
- Prevents accidental loss of user-generated content.
- Improves the overall messaging experience.
- Makes session expiration much less disruptive.
- Requires only client-side handling without affecting existing messaging workflows.
I believe this would be a valuable usability improvement, especially for organizations where users frequently compose long messages or work with strict authentication timeouts.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named in the issue. Start by tracing the client-side 401 redirect from Send and the post-login flow, then identify where the current room's draft is held. Done means the draft survives re-authentication, is restored for the room, and is removed only after sending or explicit discard.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100