Skip to content

fix(tui): set spillover root in dedup tests for Nix sandbox builds#1844

Open
barstoolbluz wants to merge 1 commit into
Hmbown:mainfrom
barstoolbluz:fix/nix-build-spillover-tests
Open

fix(tui): set spillover root in dedup tests for Nix sandbox builds#1844
barstoolbluz wants to merge 1 commit into
Hmbown:mainfrom
barstoolbluz:fix/nix-build-spillover-tests

Conversation

@barstoolbluz
Copy link
Copy Markdown

Summary

  • Two tool-result deduplication tests (request_builder_deduplicates_large_identical_tool_results_with_retrieval_hint and cache_inspect_reports_tool_result_budget_metadata) fail under nix build because the sandbox has no writable $HOME
  • The spillover write silently fails, dedup is skipped, and assertions break
  • Adds a temp-dir-backed SpilloverRootGuard (matching the existing pattern in tool_result_retrieval.rs) so the tests pass in both sandboxed and normal environments

Test plan

  • cargo test -p deepseek-tui --bin deepseek-tui -- stream_decoder_tests::request_builder_deduplicates_large stream_decoder_tests::cache_inspect_reports_tool_result passes
  • nix build .# succeeds (tests pass in sandbox)

Two tool-result deduplication tests fail under `nix build` because
the sandbox has no writable $HOME. The spillover write silently fails,
dedup is skipped, and assertions break. Add a temp-dir-backed
SpilloverRootGuard (matching the pattern in tool_result_retrieval.rs)
so the tests pass in sandboxed and normal environments.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a SpilloverRootGuard RAII struct and updates unit tests in crates/tui/src/client/chat.rs to use it for managing temporary spillover directories safely with a mutex. The review feedback recommends adding the #[must_use] attribute to the guard to prevent accidental immediate drops and suggests using the SPILLOVER_DIR_NAME constant instead of hardcoded strings to improve maintainability.

use crate::models::{ContentBlockStart, Delta, StreamEvent};
use std::path::PathBuf;

struct SpilloverRootGuard {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

RAII guards like SpilloverRootGuard should be marked with #[must_use] to prevent them from being accidentally dropped immediately (e.g., if the caller uses let _ = ... or forgets the binding), which would restore the prior state before the test logic executes.

Suggested change
struct SpilloverRootGuard {
#[must_use]
struct SpilloverRootGuard {

.unwrap_or_else(|err| err.into_inner());
let tmp = tempfile::tempdir().unwrap();
let _guard = SpilloverRootGuard::new(
tmp.path().join(".deepseek").join("tool_outputs"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use the SPILLOVER_DIR_NAME constant from crate::tools::truncate instead of hardcoding the string "tool_outputs". This ensures consistency if the directory name is changed in the future.

Suggested change
tmp.path().join(".deepseek").join("tool_outputs"),
tmp.path().join(".deepseek").join(crate::tools::truncate::SPILLOVER_DIR_NAME),

.unwrap_or_else(|err| err.into_inner());
let tmp = tempfile::tempdir().unwrap();
let _guard = SpilloverRootGuard::new(
tmp.path().join(".deepseek").join("tool_outputs"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use the SPILLOVER_DIR_NAME constant from crate::tools::truncate instead of hardcoding the string "tool_outputs". This ensures consistency if the directory name is changed in the future.

Suggested change
tmp.path().join(".deepseek").join("tool_outputs"),
tmp.path().join(".deepseek").join(crate::tools::truncate::SPILLOVER_DIR_NAME),

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.

3 participants