fix(cli): restore session cwd on mid-chat /resume and /sessions - #38614
fix(cli): restore session cwd on mid-chat /resume and /sessions#38614Dusk1e wants to merge 1 commit into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the interactive-resume parity gap. The underlying bug is still present on current main: hermes_cli/cli_commands_mixin.py:669-825 restores the transcript and session state but never calls _restore_session_cwd, while startup paths do so at hermes_cli/cli_agent_setup_mixin.py:311 and :502.
Problems
- The submitted
cli.pyhunk no longer applies because the slash-command handlers were extracted by094aa85c3intohermes_cli/cli_commands_mixin.py; GitHub currently reports this PR as conflicting.
Suggested changes
- Transplant the helper call after
hermes_cli/cli_commands_mixin.py:825./sessions <id>already delegates to this handler at:857, so that single placement covers both command forms. - Preserve the focused regression tests for recorded and absent
cwdmetadata.
Automated hermes-sweeper review.
| @@ -7032,6 +7032,14 @@ def _handle_resume_command(self, cmd_original: str) -> None: | |||
| else: | |||
There was a problem hiding this comment.
The fix direction is correct, but this handler has moved on current main. Transplant this call after the display branches in hermes_cli/cli_commands_mixin.py:825; /sessions <id> still delegates to that handler.
|
Rebased onto current Superseding here; will close once #67287 merges. Thanks @Dusk1e — clean fix, it just had to follow the handler to its new file. |
fix(cli): restore session cwd on mid-chat /resume and /sessions (supersedes #38614)
…614-resume-cwd fix(cli): restore session cwd on mid-chat /resume and /sessions (supersedes NousResearch#38614)
What & Why
A startup
hermes -c/--resumecorrectly relaunches a session in thedirectory it was started from (#38562). The same guarantee was missing for
the interactive
/resumeand/sessions <id>commands._restore_session_cwd()was only wired into the startup resume paths, so amid-conversation
/resumeloaded the transcript but left the process andTERMINAL_CWDpointing at wherever the user happened to be. As a result theterminalandexecute_codetools — and all relative-path resolution — ranagainst the wrong project, with a real risk of writes landing in the wrong
repository.
Change
_handle_resume_command()now calls_restore_session_cwd(session_meta)after the session is loaded, matching the startup behavior. Because
/sessions <id>delegates to the same handler, a single call fixes bothcommands.
The helper is idempotent and safe: it no-ops when the session recorded no
cwd(gateway/remote/older sessions) or when already in that directory, anddegrades to a single dim warning when the directory no longer exists.
How to Test
hermesin project A and exchange a message (session A is created)./resume <session A>(or/sessions <session A>).terminal,read_file,patch, and relative paths now resolve there.Tests
Added regression coverage in
tests/cli/test_cli_resume_command.py(
TestCliResumeRestoresCwd):/resumerestores the recordedcwd(os.chdir+TERMINAL_CWD)/resumeis a no-op when nocwdwas recorded/sessions <id>restores thecwdvia delegationResults
tests/cli/test_cli_resume_command.py(incl. 3 new)tests/cli/test_cli_init.pytests/cli/test_resume_display.pytests/cli/test_cwd_env_respect.pytests/cli/test_resume_quiet_stderr.pytests/gateway/test_resume_command.pyNo regressions in the resume/session/cwd paths.
Closes #38562 (interactive resume parity).