feat: Implement server-side SSH session persistence and recovery - #13707
Open
HynoR wants to merge 5 commits into
Open
feat: Implement server-side SSH session persistence and recovery#13707HynoR wants to merge 5 commits into
HynoR wants to merge 5 commits into
Conversation
Split the terminal ws handling into a Session (pty + ssh backend) and an Attachment (one websocket). A session outlives its websocket: a clean close (1000) ends the pty, any other disconnect keeps it for a 30-minute grace period and it can be reattached via `?session=<id>`. Output goes through a fixed 128KB ring buffer so a reattaching client gets the recent tail, with a truncation marker if it fell behind. Sessions are owner-scoped; a second attachment kicks the first (4409), unknown ids get 4404. New endpoints under /hosts/terminal/sessions (search, close) let the frontend list and recover sessions after a tab or browser is closed.
Terminals now live in a layout-level host and are teleported into whichever view shows them, so leaving the terminal page no longer kills them. A dock handle on the right edge opens a non-modal dialog from any page with every live session, a picker for local shell / ssh hosts, minimize, and close-all. On page load the store recovers sessions the server still holds, so an accidentally closed tab or browser can resume within the grace period. The menu-tab label shows the live session count.
With the terminal menu tab locked (keep-alive), leaving the page deactivates it instead of unmounting it, so the slot ref callback never re-runs on return. After the dock had taken the Terminal over and released it, nobody claimed it for the page again and it stayed parked in the hidden host. Claim/release slots explicitly on mount, activated, deactivated and unmount, the same ownership rule the dock uses, instead of relying on the ref callback.
HynoR
force-pushed
the
pr/terminal-dock
branch
from
September 4, 2026 03:13
9db160c to
0d26d7e
Compare
A logged-out panel has nobody watching it, so nothing it left running should survive: core now tells the local agent to close all terminal sessions when the user logs out, changes the password, or changes the bind domain. Until now the teardown relied on the logging-out tab sending close code 1000; a second tab or a websocket held outside the SPA kept its shell after logout. Agent: terminal.CloseAll and POST /hosts/terminal/sessions/closeAll. Core: LogOut / deleteCurrentSession / BindDomain call it via proxy_local, best effort.
The node a local shell connects to was resolved from the current node every time the websocket was built, so after switching nodes a reconnect carried the old session id to the new node (4404) and then opened a shell there instead. Store the operateNode on the entry when it is created; ssh shells keep going to the master. Shells on a non-master node get the node name in their title so a restore in another node's view can tell them apart.
HynoR
force-pushed
the
pr/terminal-dock
branch
from
September 4, 2026 03:15
0d26d7e to
eb52aba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
ref: #13671
Summary of your change
agent 端独立管理 ssh 会话;在右下角添加终端工具栏,支持随时在页面调用 ssh 窗口,避免关闭或者误切换导致的 ssh 关闭。打开的会话会在前端无缝切换



Please indicate you've done the following: