fix(cli): resume the selected chat when a bare number follows /resume#34588
Closed
Bartok9 wants to merge 1 commit into
Closed
fix(cli): resume the selected chat when a bare number follows /resume#34588Bartok9 wants to merge 1 commit into
Bartok9 wants to merge 1 commit into
Conversation
A bare `/resume` printed the recent-sessions list but armed no selection state, so typing just `3` on the next line was sent to the agent as chat instead of resuming session #3. `/resume 3` worked, but the natural list-then-pick flow did not. Arm a one-shot pending-resume prompt when bare `/resume` shows the list, and consume the next bare numeric input as the selection (out-of-range is reported, non-numeric/other commands disarm it). Resolves against the same _list_recent_sessions(limit=10) list used everywhere else. Closes NousResearch#34584.
Contributor
|
Merged via #34834. Your commit was cherry-picked onto current main with your authorship preserved in git log (edfdc77). I added a small follow-up fix for an unrelated pre-existing CI flake (test_notification_poller_requeues_when_busy raced on the process-global completion_queue under parallel load). Thanks for the clean fix and the precise root-cause writeup. |
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.
Summary
/resume(no args) now arms a one-shot prompt so typing just a number on the next line resumes that session.Motivation
Closes #34584.
Running bare
/resumeprints the recent-sessions list and tells the user to "Use /resume ". But it armed no selection state, so when the user typed just3on the next line, the digit was routed to the agent as a normal chat message and no session was resumed. (/resume 3always worked — only the natural list-then-type-a-number flow was broken.)The fix arms
self._pending_resume_sessionswhen bare/resumeshows the list, then consumes the next bare numeric input as the selection. It is one-shot: any other input (free text, another slash command, blank) disarms it so a later number the user means as chat is never hijacked. Out-of-range numbers are reported, not sent to the agent. Index resolution goes through the same_list_recent_sessions(limit=10)list used everywhere else, so the displayed numbers and the resolved sessions always match.The single intercept lives in
process_loopwhere_pending_inputis consumed, which covers both the prompt_toolkit TUI path (idle input is queued to_pending_input) and the fallback input loop.Verification
python3 -m pytest tests/cli/test_cli_resume_command.py— 12 passed (5 existing + 7 new)/resume, not arming when no sessions exist, numbered selection resuming, out-of-range handling, non-numeric fall-through + disarm, no-pending no-op, and disarm-on-other-command.python3 -m pytest tests/cli/test_resume_quiet_stderr.py tests/hermes_cli/test_tui_resume_flow.py— pass.Note for maintainers (pre-existing, unrelated)
tests/cli/test_resume_quiet_stderr.py::test_session_not_found_goes_to_stdout_in_full_modefails when run aftertests/cli/test_cli_init.pyin the same process — on cleanorigin/mainas well as on this branch (verified bygit stash). It passes in isolation. This is pre-existing cross-test state pollution, independent of this change; flagging rather than absorbing it.