From 9d8011677a4878c3f262a49bc5718070bf5f62bc Mon Sep 17 00:00:00 2001 From: barstoolbluz Date: Wed, 20 May 2026 12:22:33 -0400 Subject: [PATCH] fix(tui): set spillover root in dedup tests for Nix sandbox builds 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. --- crates/tui/src/client/chat.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/tui/src/client/chat.rs b/crates/tui/src/client/chat.rs index 8e9af335e..b54347ae3 100644 --- a/crates/tui/src/client/chat.rs +++ b/crates/tui/src/client/chat.rs @@ -2206,6 +2206,24 @@ mod stream_decoder_tests { //! directly to verify each "class of stream failure" the engine relies on. use super::*; use crate::models::{ContentBlockStart, Delta, StreamEvent}; + use std::path::PathBuf; + + struct SpilloverRootGuard { + prior: Option, + } + + impl SpilloverRootGuard { + fn new(path: PathBuf) -> Self { + let prior = crate::tools::truncate::set_test_spillover_root(Some(path)); + Self { prior } + } + } + + impl Drop for SpilloverRootGuard { + fn drop(&mut self) { + crate::tools::truncate::set_test_spillover_root(self.prior.take()); + } + } /// Decode a raw SSE-data JSON chunk into our internal events, mirroring /// the per-event call shape used by `handle_chat_completion_stream`. @@ -2715,6 +2733,14 @@ mod stream_decoder_tests { #[test] fn request_builder_deduplicates_large_identical_tool_results_with_retrieval_hint() { + let _lock = crate::tools::truncate::TEST_SPILLOVER_GUARD + .lock() + .unwrap_or_else(|err| err.into_inner()); + let tmp = tempfile::tempdir().unwrap(); + let _guard = SpilloverRootGuard::new( + tmp.path().join(".deepseek").join("tool_outputs"), + ); + let output = "A".repeat(2_000); let messages = vec![ tool_use_message("tool-1", "read_file", json!({"path": "README.md"})), @@ -2767,6 +2793,14 @@ mod stream_decoder_tests { #[test] fn cache_inspect_reports_tool_result_budget_metadata() { + let _lock = crate::tools::truncate::TEST_SPILLOVER_GUARD + .lock() + .unwrap_or_else(|err| err.into_inner()); + let tmp = tempfile::tempdir().unwrap(); + let _guard = SpilloverRootGuard::new( + tmp.path().join(".deepseek").join("tool_outputs"), + ); + let long_output = format!("{}{}", "A".repeat(7_000), "Z".repeat(7_000)); let request = MessageRequest { model: "deepseek-v4-flash".to_string(),