Skip to content

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

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#14828
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
@zwcf5200 zwcf5200 closed this Apr 24, 2026
@zwcf5200 zwcf5200 deleted the test/upstream-pr-7802-cwd-fix branch April 24, 2026 00:33
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management backend/ssh SSH remote execution labels Apr 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #9798 — same fix: cd into configured cwd before init_session() snapshot capture. See also #7802, #12983.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #9798 — same fix: cd into configured cwd before init_session() snapshot capture. See also #7802, #12983.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/ssh SSH remote execution P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants