Skip to content

Fix remote turn diff display roots#23261

Merged
starr-openai merged 1 commit into
mainfrom
apply-patch-repro-20260517
May 18, 2026
Merged

Fix remote turn diff display roots#23261
starr-openai merged 1 commit into
mainfrom
apply-patch-repro-20260517

Conversation

@starr-openai
Copy link
Copy Markdown
Contributor

@starr-openai starr-openai commented May 18, 2026

Why

TurnDiffTracker computes a display root so turn diffs can be rendered repo-relative. For remote exec-server turns, the selected turn cwd may exist only inside the selected environment, but run_turn was discovering the git root through the local host filesystem. When that lookup failed, nested remote-session diffs fell back to the nested cwd and showed /tmp/...-prefixed paths instead of repo-relative paths.

What changed

  • Resolve the diff display root from the primary selected turn environment when one exists, using that environment's filesystem and cwd.
  • Add codex_git_utils::get_git_repo_root_with_fs(...) so git-root discovery can run against an ExecutorFileSystem, including remote environments.
  • Reuse that helper from resolve_root_git_project_for_trust(...) and add coverage for .git gitdir-pointer detection.

Validation

  • Devbox Bazel: //codex-rs/core:core-unit-tests --test_filter=get_git_repo_root_with_fs_detects_gitdir_pointer
  • Devbox Docker-backed remote-env repro: //codex-rs/core:core-all-test --test_filter=apply_patch_turn_diff_paths_stay_repo_relative_when_session_cwd_is_nested

@starr-openai starr-openai requested a review from a team as a code owner May 18, 2026 07:03
@starr-openai starr-openai force-pushed the apply-patch-repro-20260517 branch from bde168b to 8a032df Compare May 18, 2026 16:54
.await
.unwrap_or_else(|| turn_environment.cwd.clone())
.into_path_buf(),
None => get_git_repo_root(turn_context.cwd.as_path())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the fallback?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.primary() returns Option - so either we need a fallback or should throw

///
/// This mirrors [`get_git_repo_root`] for local paths, but works when `cwd`
/// only exists inside a selected remote environment.
pub async fn get_git_repo_root_with_fs(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we convert the original and pass LOCAL_FS where needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would need to convert existing callers to be async which blows this up a bit. im just fixing tests here, can do the LOCAL_FS conversion in a separate PR

@starr-openai starr-openai merged commit 9286ff2 into main May 18, 2026
31 checks passed
@starr-openai starr-openai deleted the apply-patch-repro-20260517 branch May 18, 2026 17:53
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants