Skip to content

Clear chat drafts and stale document keys on sign-out #444

Closed

Description

@HMarzban

Summary

On a shared device, two things outlive sign-out. Chat drafts are stored per workspace and room, not per user, so the next person who opens that chat sees the previous person's unsent text. Four localStorage keys also keep the last document's id, slug and Pad title, including a Private one; nothing reads them.

Where

  • Drafts key: apps/webapp/src/db/messageComposerDB.ts:58 (${workspaceId}::${roomId}), kept up to 120 days.
  • Unused keys written: apps/webapp/src/hooks/useDocumentMetadata.ts:15-19 (docId, padName, slug, title).
  • Sign-out: apps/webapp/src/components/settings/hooks/useSignOut.ts.

Fix plan

  1. Delete the four localStorage.setItem calls in useDocumentMetadata.ts, after a repo grep confirms nothing reads those keys. On sign-out, remove the four keys once, for existing browsers.
  2. On sign-out, clear the composer draft store (memory map and its IndexedDB table) in messageComposerDB.ts, through one exported function that useSignOut calls before signOut().
  3. Do not add a user id to the draft key; clearing on sign-out is enough and keeps the store simple.

Acceptance criteria

  • After sign-out and a new sign-in on the same browser, no previous draft appears.
  • localStorage holds no docId, padName, slug or title key after sign-out.
  • Drafts still survive a reload for a signed-in user.

Verify

  • Manual: type a draft, sign out, sign in as another user, open the same chat.
  • grep -rn "localStorage.getItem('\(docId\|padName\|slug\|title\)')" apps/webapp/src returns nothing before step 1.

Related

Activity

  1. added theissue type on Oct 6, 2026
  2. added
    bugSomething isn't working
    ChatRelated to chat features
    SecuritySecurity, access control, and data exposure
    on Oct 6, 2026
  3. HMarzban commented on Oct 9, 2026

    @HMarzban
    CollaboratorAuthor

    Fixed and live.

    • Commits: bdce7bd5b
    • Deployed in bbdaae66c (production run 37976785981, green).
    • Sign-out clears all composer drafts after signOut(), cancelling queued writes first, and removes the four stale localStorage keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AuthChatRelated to chat featuresSecuritySecurity, access control, and data exposurebugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions