mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-16 09:31:37 +00:00
fix(state): keep /branch sessions visible after parent reopen
/branch (aka /fork) sessions vanished from /resume and /sessions. Both surfaces funnel through list_sessions_rich(include_children=False), which hid any session with a parent_session_id unless identified as a branch via a heuristic — parent.end_reason == 'branched' AND child.started_at >= parent.ended_at. Two ways that heuristic failed: 1. CLI/gateway branches: once the parent was reopened (e.g. resumed) and re-ended with a different end_reason (tui_shutdown overwriting 'branched'), the heuristic stopped matching and the branch was hidden permanently. 2. TUI branches (tui_gateway session.branch): the TUI never ends the parent as 'branched' — it creates the child while the parent is still live — so the heuristic NEVER matched and TUI branches were hidden from the moment they were created (this is the macOS desktop app's primary symptom). Fix: persist a stable '_branched_from' marker in the branch session's model_config at creation time across ALL THREE branch paths (CLI cli.py, gateway gateway/run.py, and TUI tui_gateway/server.py), and OR a json_extract(model_config, '$._branched_from') IS NOT NULL check into the list_sessions_rich filter. The marker is immutable across the parent's lifecycle, so the branch stays visible regardless of how/whether the parent is ended. The legacy end_reason heuristic is kept (OR'd) so pre-existing branches remain visible. Subagent/compression children (no marker, parent not 'branched') stay correctly hidden. Fixes #20856. Approach by liuhao1024 (PR #20864); reimplemented on current main, extended to the TUI branch path (which the original missed), with regression tests for the reopen+re-end scenario and the TUI marker persistence.
This commit is contained in:
parent
d1367355d5
commit
a3fb48b2ce
6 changed files with 136 additions and 7 deletions
|
|
@ -3702,6 +3702,12 @@ def _(rid, params: dict) -> dict:
|
|||
new_key,
|
||||
source="tui",
|
||||
model=_resolve_model(),
|
||||
# Stable _branched_from marker so list_sessions_rich() keeps the
|
||||
# branch visible in /resume and /sessions. The TUI branch leaves
|
||||
# the parent live (no end_reason='branched'), so the legacy
|
||||
# end_reason heuristic never matches it — the marker is the only
|
||||
# thing that surfaces TUI branches. See issue #20856.
|
||||
model_config={"_branched_from": old_key},
|
||||
parent_session_id=old_key,
|
||||
cwd=_session_cwd(session),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue