fix(cli/tui): split MRU resume + actual exit session - #16626
Merged
Conversation
- 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.
2 tasks
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.
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 joinsMAX(messages.timestamp)and orders bylast_active→hermes -cpicks true MRU, not newest-started._resolve_last_sessiondrops client-side sort, useslimit=1, closes DB infinally.mkstempJSON file (mode 0o600) viaHERMES_TUI_ACTIVE_SESSION_FILE; Python reads it in_print_tui_exit_summary, cleaned up infinally.Test plan
scripts/run_tests.sh tests/hermes_cli/test_resolve_last_session.py tests/hermes_cli/test_tui_resume_flow.py→ 13/13 passCloses #16336.