You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(dj): accept the sandbox fallback scratch dir - #1013
Closes#1011. the_agent_scratch_dir_is_not_the_current_directory failed in the Nix sandbox at assert!(scratch.ends_with("dj-scratch")).
In the sandbox HOME cannot be created, so agent_scratch_dir uses its fallback (#478): a private dir from fresh_private_dir(temp, "spotatui-dj-scratch"), named spotatui-dj-scratch-<pid>-<nanos>-<n>. Path::ends_with compares whole components, so that name never matches dj-scratch. The code was right; the test only knew the state-dir case.
The test now checks what it guards: the scratch dir is not the current directory, it is absolute, and its last component contains dj-scratch, which holds for both the state dir and the fallback. No production code changes.
With HOME=/nonexistent/sandbox-home XDG_STATE_HOME= (CARGO_HOME and RUSTUP_HOME pointed at the real ones), the same test fails on main at session.rs:678 and passes with this change.
Additional notes
Not run inside a real Nix build. If it holds there, doCheck = !withAiDj; in nixpkgs' spotatui/package.nix can go.
💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit
Tests
Updated scratch-directory validation to support both configured directories and uniquely named temporary fallback directories.
No actionable comments were generated in the recent review.
Walkthrough
The scratch-directory test now accepts both the configured dj-scratch directory and a uniquely named temporary fallback. It checks that the selected path is absolute and that its final component contains dj-scratch.
Changes: Scratch directory test
Layer / File(s)
Summary
Scratch path validation src/infra/dj/session.rs
The test checks that the scratch path is absolute and that its final component contains dj-scratch. This replaces the exact suffix check.
This updates a test so the AI DJ-enabled Nix sandbox build no longer fails on the scratch-directory check. No production behavior changes, and no merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title uses the conventional-commit prefix test(dj) and an imperative subject, which matches the configured title requirements. It names the sandbox fallback scratch directory, which is the main ch…
Linked Issues check
Issue #1011 asks that the_agent_scratch_dir_is_not_the_current_directory no longer fails in a Nix sandbox. The failing assertion was assert!(scratch.ends_with("dj-scratch")). The production code a…
Out of Scope Changes check
The whole-PR diff against the merge base changes one file, src/infra/dj/session.rs, with +8/-1 lines. The only change is inside the the_agent_scratch_dir_is_not_the_current_directory test body. It…
Full details: Title check
Explanation
The title uses the conventional-commit prefix test(dj) and an imperative subject, which matches the configured title requirements. It names the sandbox fallback scratch directory, which is the main change: the scratch-directory test now accepts the sandbox fallback naming pattern as well as the configured dj-scratch directory.
Full details: Linked Issues check
Explanation
Issue #1011 asks that the_agent_scratch_dir_is_not_the_current_directory no longer fails in a Nix sandbox. The failing assertion was assert!(scratch.ends_with("dj-scratch")). The production code at head uses scratch_dir_from, which falls back to fresh_private_dir(temp, "spotatui-dj-scratch") when the state dir is unusable (#478). That fallback yields spotatui-dj-scratch-<pid>-<nanos>-<n>, so Path::ends_with never matches it. The diff replaces that assertion in src/infra/dj/session.rs with three checks: the path differs from the current directory (kept), the path is absolute, and its final component contains dj-scratch. Both the state-dir case and the fallback satisfy these checks. The test now passes under the sandbox condition, as the PR reports for a local HOME override. The fix is coding work in automated tests, which the issue requires. Not verified: a real Nix build, which the PR states was not run.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base changes one file, src/infra/dj/session.rs, with +8/-1 lines. The only change is inside the the_agent_scratch_dir_is_not_the_current_directory test body. It directly implements the #1011 objective. No production code changes. No unrelated files or hunks appear in the reviewed diff.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Simplify code
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between d36f53d and 6d35c2e.
Files selected for processing: 1
src/infra/dj/session.rs
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
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
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.
Summary
Closes #1011.
the_agent_scratch_dir_is_not_the_current_directoryfailed in the Nix sandbox atassert!(scratch.ends_with("dj-scratch")).In the sandbox
HOMEcannot be created, soagent_scratch_diruses its fallback (#478): a private dir fromfresh_private_dir(temp, "spotatui-dj-scratch"), namedspotatui-dj-scratch-<pid>-<nanos>-<n>.Path::ends_withcompares whole components, so that name never matchesdj-scratch. The code was right; the test only knew the state-dir case.The test now checks what it guards: the scratch dir is not the current directory, it is absolute, and its last component contains
dj-scratch, which holds for both the state dir and the fallback. No production code changes.Testing
HOME=/nonexistent/sandbox-home XDG_STATE_HOME=(CARGO_HOME and RUSTUP_HOME pointed at the real ones), the same test fails onmainatsession.rs:678and passes with this change.Additional notes
Not run inside a real Nix build. If it holds there,
doCheck = !withAiDj;in nixpkgs'spotatui/package.nixcan go.💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit