From 3700ca4a549381f54dc138572f027e2946e9d896 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sat, 18 Jul 2026 23:20:32 -0400 Subject: [PATCH] fix(cli): restore session cwd on mid-chat /resume (transplant to mixin) Dusk1e's fix wired _restore_session_cwd into _handle_resume_command, but that handler was extracted from cli.py into hermes_cli/cli_commands_mixin.py (094aa85c3) after the PR's base, so the original cli.py hunk no longer applied (a naive cherry-pick fuzzily misplaced it inside new_session(), where session_meta is undefined). Transplanted the call to the end of the handler in its current home; /sessions delegates here so both command forms are covered. Dusk1e's regression tests carry over unchanged. Co-authored-by: Dusk1e --- hermes_cli/cli_commands_mixin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.py index 4e65155b602..8f9e6b8e886 100644 --- a/hermes_cli/cli_commands_mixin.py +++ b/hermes_cli/cli_commands_mixin.py @@ -834,6 +834,14 @@ class CLICommandsMixin: else: _cprint(f" ↻ Resumed session {target_id}{title_part} — no messages, starting fresh.") + # Retarget the process + tool cwd to where the session was started, so a + # mid-chat /resume (and /sessions , which delegates here) lands in the + # same directory as a startup `hermes -c`/`--resume`. The startup resume + # paths already call this; without it, the terminal/code-exec tools and + # relative-path resolution keep operating in the wrong repo. Idempotent + # and a no-op when the session recorded no cwd. See #38562. + self._restore_session_cwd(session_meta) + def _handle_sessions_command(self, cmd_original: str) -> None: """Handle /sessions [list|] — browse or resume previous sessions.