feat(terminal): persist tmux layout and last-attached view #83
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_router!83
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_tmux_persist_session"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Make tmux terminal sessions in hero_router persist their layout and window state across two kinds of "reconnect":
tmux(which always creates a fresh session) totmux new-session -A -s <name>— attach if a tmux server-side session named<name>already exists, otherwise create one. The tmux serversetsid()s itself off the PTY child, so it survives the hero_proc PTY job being killed; on next launch with the same hero_router session name, splits / window names / scrollback are reattached automatically.localStorageand restore it on/terminalpage load when the URL hash is empty. Without this, clicking another nav tab (Home / Router / Admin / Docs / API / MCP) and clicking Terminal back leaves the terminal pane blank ("No session attached") even though the underlying job is still alive.Related Issue
Closes #70
Changes
crates/hero_router/src/server/terminal.rstmux_session_name(name) -> Stringhelper that maps a hero_router session name to a tmux-server-side session name (/→_; remaining allowed chars are already valid in tmux).create_session()ShellType::Tmuxarm: launchtmux new-session -A -s <tmux_name>instead oftmux.NuandBasharms unchanged.#[cfg(test)] mod tmux_naming_tests(3 unit tests) pinning the naming contract: pass-through of flat names,/→_substitution, no tmux-reserved chars (:,.,/,) in the output.crates/hero_router/static/js/terminal.jsDEEP_LINK_KEY = 'hero_router.term.deepLink'constant alongside the existingFS_KEY/NAV_REVEAL_KEY.updateHashParams()now mirrors the deep-link string tolocalStorage[DEEP_LINK_KEY](or removes it when there is nothing to persist)./terminalpage load, whenlocation.hashis empty/just#, the load handler falls back to the persisted value before parsing forpanes=/session=/fullscreen=. The existing "session no longer exists" guard makes the restore safe across server restarts.No changes to
templates/,partials/,base.html, or any RPC method shapes. Total diff: +76 / -7 across the two files.Test Results
cargo build -p hero_router)tmux_naming_tests+ 99 pre-existing)End-to-end persistence verification (delete PTY job, recreate same name, splits return) requires a live tmux + hero_proc environment and was performed manually per the spec.
Acceptance Criteria
tmux new-session -A -s <name>semantics).-Aflag).Pull request closed