Skip to content

Persist unsent draft prompt across Zed restarts#49541

Merged
eholk merged 2 commits intomainfrom
persist-draft-prompt
Mar 3, 2026
Merged

Persist unsent draft prompt across Zed restarts#49541
eholk merged 2 commits intomainfrom
persist-draft-prompt

Conversation

@eholk
Copy link
Copy Markdown
Contributor

@eholk eholk commented Feb 18, 2026

Store the user's unsent message editor text in DbThread so it survives quitting and reloading Zed. The draft flows through Thread → AcpThread → AcpThreadView on load, and back via a debounced observer on the message editor for saves.

Currently works for native Zed agents only; external ACP agents will pick this up once general ACP history persistence lands.

Changes

  • DbThread / Thread: New draft_prompt: Option<String> field, included in to_db()/from_db()
  • AcpThread: Bridge field with getter/setter, populated during register_session()
  • NativeAgent::save_thread(): Copies draft from AcpThreadThread before persisting
  • AcpThreadView: Restores draft into MessageEditor on load; syncs editor text → AcpThread via observer; debounced (500ms) Thread notify triggers DB save

Release notes:

  • Draft prompts are now saved across Zed restarts

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 18, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 18, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

zed-industries-bot commented Feb 18, 2026

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 9b5003b

@eholk
Copy link
Copy Markdown
Contributor Author

eholk commented Mar 2, 2026

We also need to make sure the rich text bits like @selection deserialize correctly.

Store the user's unsent message editor text in DbThread so it
survives quitting and reloading Zed. The draft flows through
Thread → AcpThread → AcpThreadView on load, and back via a
debounced observer on the message editor for saves.

Currently works for native Zed agents only; external ACP agents
will pick this up once general ACP history persistence lands.

Co-authored-by: Anthony Eid <anthony@zed.dev>
@eholk eholk force-pushed the persist-draft-prompt branch from 6bb860c to 54998b7 Compare March 2, 2026 23:08
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
@eholk eholk marked this pull request as ready for review March 3, 2026 00:49
@eholk eholk enabled auto-merge (squash) March 3, 2026 00:51
@eholk eholk merged commit 42ba961 into main Mar 3, 2026
29 checks passed
@eholk eholk deleted the persist-draft-prompt branch March 3, 2026 00:57
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
Store the user's unsent message editor text in DbThread so it survives
quitting and reloading Zed. The draft flows through Thread → AcpThread →
AcpThreadView on load, and back via a debounced observer on the message
editor for saves.

Currently works for native Zed agents only; external ACP agents will
pick this up once general ACP history persistence lands.

## Changes

- **`DbThread`** / **`Thread`**: New `draft_prompt: Option<String>`
field, included in `to_db()`/`from_db()`
- **`AcpThread`**: Bridge field with getter/setter, populated during
`register_session()`
- **`NativeAgent::save_thread()`**: Copies draft from `AcpThread` →
`Thread` before persisting
- **`AcpThreadView`**: Restores draft into `MessageEditor` on load;
syncs editor text → `AcpThread` via observer; debounced (500ms) Thread
notify triggers DB save

Co-authored-by: Anthony Eid <anthony@zed.dev>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
wzulfikar pushed a commit to wzulfikar/zed that referenced this pull request Mar 4, 2026
Store the user's unsent message editor text in DbThread so it survives
quitting and reloading Zed. The draft flows through Thread → AcpThread →
AcpThreadView on load, and back via a debounced observer on the message
editor for saves.

Currently works for native Zed agents only; external ACP agents will
pick this up once general ACP history persistence lands.

## Changes

- **`DbThread`** / **`Thread`**: New `draft_prompt: Option<String>`
field, included in `to_db()`/`from_db()`
- **`AcpThread`**: Bridge field with getter/setter, populated during
`register_session()`
- **`NativeAgent::save_thread()`**: Copies draft from `AcpThread` →
`Thread` before persisting
- **`AcpThreadView`**: Restores draft into `MessageEditor` on load;
syncs editor text → `AcpThread` via observer; debounced (500ms) Thread
notify triggers DB save

Co-authored-by: Anthony Eid <anthony@zed.dev>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants