fix(sandbox): detect repository root when the requested path is nested inside a repo (#65)#75
Open
shadaj wants to merge 1 commit into
Open
fix(sandbox): detect repository root when the requested path is nested inside a repo (#65)#75shadaj wants to merge 1 commit into
shadaj wants to merge 1 commit into
Conversation
Deploying infinity with
|
| Latest commit: |
0a2fd62
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://24c19e77.infinity-dc7.pages.dev |
| Branch Preview URL: | https://sandbox-35738e94-eb27-402f-9.infinity-dc7.pages.dev |
…d inside a repo (#65) * Add `sandbox_core::find_repo_root`, which walks up from a path to the closest ancestor containing a `.jj` directory or a `.git` entry (directory, or file for worktrees/submodules). This makes jj repos detectable when the cwd is inside a nested folder — jj subdirectories carry no marker of their own, so the previous `path.join(".jj")` check silently fell through to git mode (or failed entirely for non-colocated jj repos). * `LocalBackend::init_repo` now resolves the requested path to the repository root before storing it as the remote URI, so sandboxes are always created from the repo root. Falls back to the path as given when no root is found, preserving existing error paths. * `clone_repo` and `open_sandbox_direct` responses now include a note when the detected repository root differs from the requested path, telling the agent that the sandbox operates on the whole repository and that file paths are relative to the root. * The migration-import cwd check also walks up to the repo root instead of requiring cwd to be the root itself. * Add integration tests (`nested_repo_root.rs`) covering jj and git clones from nested directories (mode detection + root note + reads relative to the root) and the no-note case when cloning from the root. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #75
shadaj
marked this pull request as ready for review
July 14, 2026 21:39
shadaj
force-pushed
the
sandbox-35738e94-eb27-402f-94c2-ac6f42eec405
branch
from
July 14, 2026 21:52
ac1263e to
0a2fd62
Compare
MingweiSamuel
approved these changes
Jul 17, 2026
Comment on lines
+565
to
+569
| Ok(match root_note { | ||
| Some(note) => format!("{msg}{note}"), | ||
| None => msg, | ||
| }) | ||
| } |
Member
There was a problem hiding this comment.
nit: prefer if let Some(x) = on options
| tracing::info!(group_id = %invocation.group_id, remote = %remote_uri, "opened direct sandbox"); | ||
| Ok("Repository initialized (Direct mode — file edits require approval, commands run without file write access unless write-orig is granted).".to_owned()) | ||
| let mut msg = "Repository initialized (Direct mode — file edits require approval, commands run without file write access unless write-orig is granted).".to_owned(); | ||
| if let Some(note) = repo_root_note(&args.repo, Path::new(&remote_uri)) { |
Member
There was a problem hiding this comment.
what is the difference between repo and remote_uri here? Is it possible to have a direct sandbox on a non-VCS directory?
also nit: would be nice if the msg ++ note concatenation was the same in both methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sandbox_core::find_repo_root, which walks up from a path to theclosest ancestor containing a
.jjdirectory or a.gitentry(directory, or file for worktrees/submodules). This makes jj repos
detectable when the cwd is inside a nested folder — jj subdirectories
carry no marker of their own, so the previous
path.join(".jj")checksilently fell through to git mode (or failed entirely for
non-colocated jj repos).
LocalBackend::init_reponow resolves the requested path to therepository root before storing it as the remote URI, so sandboxes are
always created from the repo root. Falls back to the path as given
when no root is found, preserving existing error paths.
clone_repoandopen_sandbox_directresponses now include a notewhen the detected repository root differs from the requested path,
telling the agent that the sandbox operates on the whole repository
and that file paths are relative to the root.
of requiring cwd to be the root itself.
nested_repo_root.rs) covering jj and gitclones from nested directories (mode detection + root note + reads
relative to the root) and the no-note case when cloning from the root.
Fixes #65