Making terminal threads persistent / adding support for resurrection #57428
Replies: 8 comments 4 replies
-
|
To expand on this, this should also be doable on the back of let's say tmux. But for that, #57427 needs to be implemented. Because then similar to normal terminal panels, I can configure a terminal thread to open in a new/existing tmux session. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @PrayagS , thanks for the feedback. This is already on our ToDo list. We just need a bit of time to figure out the best way to implement it in terminals. We'll keep this thread updated! |
Beta Was this translation helpful? Give feedback.
-
Possible implementation / reference designI think cmux's implementation is a very useful reference for this feature. From what I understand, cmux does not try to checkpoint arbitrary live terminal process memory. Instead, it separates normal terminal/session restoration from AI agent session restoration:
For example: A similar model could work well for Zed Terminal Agent Threads. Zed could persist a small metadata record for each Terminal Agent Thread, for example: Then, when Zed restarts, updates, or recovers from a crash, it could restore the Terminal Agent Thread entry in the Threads Sidebar and relaunch the correct agent using the agent's native resume command. This would be much more reliable than only restoring the terminal scrollback or reopening a default shell, because AI coding agents already have their own session model. Zed only needs to preserve the mapping between the Terminal Thread and the agent's native session ID. It may also be useful to provide settings such as: {
"terminal_agent_threads": {
"auto_resume": true,
"auto_resume_agents": ["claude", "codex", "opencode", "amp", "pi"]
}
}This would let users choose whether Zed should automatically resume agent sessions after reopening, while still allowing Zed to restore the layout without executing agent resume commands if the user disables auto-resume. I think this cmux-style approach would fit Terminal Agent Threads very well, because it treats AI terminal sessions differently from ordinary shell processes. For normal shell commands, best-effort terminal restore is enough. But for AI agents, preserving the agent session ID and calling the native resume command is the key part. |
Beta Was this translation helpful? Give feedback.
-
|
really appreciate all the work that is being put into making the editor a delight to use. The send to terminal thread came really handy in day to day. This is another missing piece that would really improve the quality of life. hope it arrives soon. |
Beta Was this translation helpful? Give feedback.
-
|
Love this proposal, primary reason I'm still using herdr. |
Beta Was this translation helpful? Give feedback.
-
|
Let me know if you have any feedback regarding the last change (see last comment) #58693 (comment) |
Beta Was this translation helpful? Give feedback.
-
|
been waiting for this feature for so long! please make it happen p.s. love zed |
Beta Was this translation helpful? Give feedback.
-
|
I have a working AgentDeck/tmux proof of concept for this: sessions survive Zed and macOS restarts, selecting a restored Terminal Thread reattaches to the existing tmux session, and a small bridge tracks session creation, renames, and removal. The remaining gap is live discovery. Stock Zed only sees externally added Terminal Thread metadata after an app reload. My prototype writes namespaced rows to Before preparing a PR, which first-class ingress would best fit the direction of Terminal Threads: typed local CLI IPC for idempotent register/update/unregister, a watched provider manifest, or stable Zed thread/workspace IDs plus hooks? I would keep If you can point me to the preferred seam, I would be happy to implement the smallest version with focused tests and a tmux demo. Disclosure: I used AI to verify the current code paths and tighten this note; I reviewed the proposal and tested the proof of concept locally. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What are you proposing?
After a while, the terminal thread's state is reset and the default shell is opened.
I'm not sure of the exact approach here but all major harnesses support resuming a session using a session identifier. If upon waking up an old thread, zed can use the corresponding harness' resume command, the experience will be much better.
Similar to how https://github.com/timvw/tmux-assistant-resurrect works.
How this information (the harness and the session identifier) is passed over to zed is up for debate. It could be something that the harness has to do, similar to how notifications work currently (terminal bell support is expected from the harness).
Beta Was this translation helpful? Give feedback.
All reactions