Terminal restore hook: run a command when terminal tab is re-opened after restart #49509
Replies: 1 comment
-
|
For reference, Zed's Agent Panel already supports session history restoration for external agents as of v0.225.9 (see Discussion #41140, PR #49449). However, this only covers the Agent Panel integration. What we still need is the ability to restore external agent sessions from Zed Terminal tabs — which is exactly what this discussion is about. Many users (myself included) run agents like Claude Code, OpenCode, etc. directly in terminal tabs rather than through the Agent Panel. When Zed restarts, these terminal processes are killed and we lose the active session. A lightweight restore hook — where the agent registers a restore command (e.g., |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What are you proposing?
A way to configure a terminal tab so that when Zed restarts and restores the workspace, it runs a specified command to restore the previous session in that terminal tab.
This could be a per-terminal setting, an escape sequence the program emits to register a restore command, or a hook in Zed's terminal configuration.
Why does this matter?
I run OpenCode (a terminal-based AI coding agent) across multiple terminal tabs in Zed. When Zed restarts (e.g., after an update), all terminal processes are killed and the tabs re-open as empty shells. There's no way for a program like OpenCode to automatically resume its session in the restored terminal tab.
Having a restore hook would allow terminal-based tools to register a command that Zed runs on restart, enabling seamless session recovery without manual intervention.
Are there any examples or context?
opencode --restore <session-id>)Possible approach
Beta Was this translation helpful? Give feedback.
All reactions