Skip to content

Keep chat and comment-thread drafts when switching files - #88

Merged
shreyashankar merged 4 commits into
mainfrom
cursor/persist-chat-across-tabs-8400
Aug 27, 2026
Merged

Keep chat and comment-thread drafts when switching files#88
shreyashankar merged 4 commits into
mainfrom
cursor/persist-chat-across-tabs-8400

Conversation

@shreyashankar

@shreyashankar shreyashankar commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Typed chat text was disappearing when switching tabs. There was no existing GitHub issue for it.

Two compose surfaces had the same failure mode (tab switch remounts the editor / used to remount the dock):

  1. Agent Chat (dock compose box) — stays open and keeps the draft across file switches.
  2. Comment threads (gutter reply box) — unsent reply text and the open thread come back when you return to the file.

Cause

  • switchTab flips docLoaded to remount TiptapEditor. The agent dock was gated on the same flag, so it remounted too and local $state (open + draft) reset.
  • A document-level click-outside handler closed Chat on file-tree / tab clicks.
  • Comment reply drafts lived in CommentGutter local state. Tab clicks also collapsed the open thread (handleOutsideMousedown) before switchTab could remember it.

Fix

  • Mount AgentDockShell on a one-shot appReady flag so tab switches no longer tear it down.
  • Lift the Chat compose draft (open, message, plan mode, images) into a session store.
  • Ignore workspace clicks when dismissing Chat. Escape / ✕ / Send still close it.
  • Store comment reply drafts by thread id, remember the last open thread per tab, ignore tab/file-tree clicks as “outside the gutter,” and restore the thread after the editor remounts.

Videos

Agent Chat draft survives a file switch:

Agent Chat draft survives a file switch

Comment-thread reply survives a tab switch:

Comment-thread reply survives a tab switch

Screenshots

Chat draft still open after switching to chapter-two.md:

Chat draft still open after switching to chapter-two.md

Same Chat draft after returning to chapter-one.md:

Chat draft restored on chapter-one.md

Comment thread reply still present after switching tabs and coming back:

Comment thread reply still present after switching tabs and coming back

Unsent Chat draft indicator after closing the popover with Escape:

Chat button showing draft dot after closing the popover

Open in Web Open in Cursor 

Tab switches remounted the editor by flipping docLoaded, which also
tore down the agent dock and wiped whatever was in the Chat box.
Keep the dock mounted independently, store the draft in session
state, and don't dismiss the popover when clicking the workspace.

Co-authored-by: ss.shankar505 <ss.shankar505@gmail.com>
@shreyashankar
shreyashankar marked this pull request as ready for review August 25, 2026 23:45
cursoragent and others added 2 commits August 25, 2026 23:48
The editor remounts on every tab switch, which wiped unsent replies
and collapsed the open gutter thread. Store the draft by thread id
and remember which thread was open on each tab so a quick peek at
another file restores both.

Co-authored-by: ss.shankar505 <ss.shankar505@gmail.com>
Tab and file-tree clicks were treated as outside the gutter, which
collapsed the thread before switchTab could remember it. Ignore those
clicks, keep the last opened thread id per tab, and flush the reply
box on unmount so the draft survives the editor remount.

Co-authored-by: ss.shankar505 <ss.shankar505@gmail.com>
@cursor cursor Bot changed the title Keep the Chat draft when switching files Keep chat and comment-thread drafts when switching files Aug 26, 2026
GitHub strips HTML video tags unless the file is drag-dropped as an
attachment. These GIFs play inline in the description instead.

Co-authored-by: ss.shankar505 <ss.shankar505@gmail.com>
@shreyashankar
shreyashankar merged commit 2189e87 into main Aug 27, 2026
5 of 6 checks passed
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.

2 participants