Skip to content

fix(cli/tui): split MRU resume + actual exit session - #16626

Merged
teknium1 merged 6 commits into
mainfrom
hermes/hermes-2327a806
Apr 27, 2026
Merged

fix(cli/tui): split MRU resume + actual exit session#16626
teknium1 merged 6 commits into
mainfrom
hermes/hermes-2327a806

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #16336 by @OutThisLife onto current main (her branch had a merge-commit so GitHub refused rebase-merge). All 6 of her commits cherry-picked individually with authorship preserved. One tiny merge conflict in a test assertion list (NODE_ENV + active-session file checks both kept).

Summary

  • search_sessions() now joins MAX(messages.timestamp) and orders by last_activehermes -c picks true MRU, not newest-started.
  • _resolve_last_session drops client-side sort, uses limit=1, closes DB in finally.
  • TUI writes live session_id to a mkstemp JSON file (mode 0o600) via HERMES_TUI_ACTIVE_SESSION_FILE; Python reads it in _print_tui_exit_summary, cleaned up in finally.

Test plan

  • scripts/run_tests.sh tests/hermes_cli/test_resolve_last_session.py tests/hermes_cli/test_tui_resume_flow.py → 13/13 pass

Closes #16336.

- order session listing by computed last_active in SessionDB so callers get MRU rows directly
- keep _resolve_last_session as a single-row lookup and add regression coverage for >20 session sampling
- use a grouped last_active join in search_sessions to avoid per-row correlated max lookups
- always close SessionDB in _resolve_last_session via finally and add regression coverage for search failure cleanup
- create HERMES_TUI_ACTIVE_SESSION_FILE with mkstemp instead of a predictable tmp path and always cleanup in finally
- add assertions that launch wiring uses a randomized session file path and removes it on exit
Validate that the temp active-session file exists while the TUI subprocess runs and is removed after launch cleanup to match mkstemp semantics.
@teknium1
teknium1 merged commit 42b917c into main Apr 27, 2026
9 of 11 checks passed
@teknium1
teknium1 deleted the hermes/hermes-2327a806 branch April 27, 2026 15:52
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants