Skip to content

fix(cli): restore session cwd on mid-chat /resume and /sessions (supersedes #38614) - #67287

Merged
OutThisLife merged 2 commits into
mainfrom
bb/salvage-38614-resume-cwd
Jul 19, 2026
Merged

fix(cli): restore session cwd on mid-chat /resume and /sessions (supersedes #38614)#67287
OutThisLife merged 2 commits into
mainfrom
bb/salvage-38614-resume-cwd

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Summary

Salvages #38614 (@Dusk1e) — rebased onto current main. Startup hermes -c/--resume restores a session's original directory (#38562), but interactive /resume and /sessions <id> did not: they loaded the transcript while leaving the process + TERMINAL_CWD in whatever dir the user had cd'd into, so terminal/execute_code/relative paths ran against the wrong project. The handler now calls _restore_session_cwd(session_meta) after load (idempotent; no-op when the session recorded no cwd; dim warning if the dir is gone).

Why supersede

#38614 was stale: the slash-command handlers were extracted from cli.py into hermes_cli/cli_commands_mixin.py (094aa85) after the PR's base, so the original cli.py hunk no longer applied. A naive cherry-pick fuzzily misplaced the call inside new_session(), where session_meta is undefined (NameError + semantically wrong). Transplanted it to the end of _handle_resume_command in its current home; /sessions <id> delegates there, so one placement covers both forms — exactly as teknium's sweeper review noted. Dusk1e's regression tests carry over unchanged (authorship preserved via cherry-pick).

Test plan

  • scripts/run_tests.sh tests/cli/test_cli_resume_command.py tests/cli/test_cwd_env_respect.py tests/cli/test_resume_display.py72 pass (incl. the 3 new TestCliResumeRestoresCwd: recorded-cwd restore, no-op without cwd, /sessions delegation)

Closes #38562.

Dusk1e and others added 2 commits July 18, 2026 23:20
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
(094aa85) 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 <id> delegates here so both command forms are
covered. Dusk1e's regression tests carry over unchanged.

Co-authored-by: Dusk1e <yusufalweshdemir@gmail.com>
@OutThisLife
OutThisLife enabled auto-merge July 19, 2026 03:22
@OutThisLife
OutThisLife merged commit d015500 into main Jul 19, 2026
31 checks passed
@OutThisLife
OutThisLife deleted the bb/salvage-38614-resume-cwd branch July 19, 2026 03:25
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades needs-decision Awaiting maintainer decision before any implementation labels Jul 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #38614: it has the same intended repair but its live patch edits the retired cli.py location. This PR rehomes the call in the current hermes_cli/cli_commands_mixin.py handler; please choose the current-main salvage.

randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
…614-resume-cwd

fix(cli): restore session cwd on mid-chat /resume and /sessions (supersedes NousResearch#38614)
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 needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants