Skip to content

fix(terminal): honor configured cwd at session init#14830

Closed
zwcf5200 wants to merge 1 commit into
NousResearch:mainfrom
zwcf5200:test/upstream-pr-7802-cwd-fix
Closed

fix(terminal): honor configured cwd at session init#14830
zwcf5200 wants to merge 1 commit into
NousResearch:mainfrom
zwcf5200:test/upstream-pr-7802-cwd-fix

Conversation

@zwcf5200

Copy link
Copy Markdown
Contributor

Summary

Apply upstream PR #7802 behavior so BaseEnvironment.init_session() captures its initial snapshot after cd'ing into the configured cwd. This preserves SSH terminal.cwd instead of letting the remote login shell home directory overwrite it.

Upstream reference: #7802
Upstream commit: 12e3ef9

Changes

tools/environments/base.py

  • Added _quote_cwd_for_shell() static method to extract cwd quoting logic.
  • Modified init_session() bootstrap script to include cd {quoted_cwd} || exit 126 before writing pwd, so the initial snapshot captures environment from the configured working directory.
  • Refactored inline quoted_cwd computation in _wrap_command() to use the new static method.

tests/tools/test_base_environment.py

  • Added TestInitSessionFailure.test_init_session_bootstrap_changes_to_configured_cwd: verifies that init_session() runs a login shell with cd into the configured cwd and sets _snapshot_ready = True.
  • Updated existing test mocks to use _wait_for_process return values instead of raw process handles.

Testing

All 16 tests in tests/tools/test_base_environment.py pass (CI-parity via scripts/run_tests.sh).

Apply upstream PR NousResearch#7802 behavior so BaseEnvironment captures its initial snapshot after cd'ing into the configured cwd. This preserves SSH terminal.cwd instead of letting the remote login shell home directory overwrite it.

Upstream-PR: NousResearch#7802

Upstream-Commit: 12e3ef9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant