From 256f34c62143215b533965a7f1cb1e9c49de3c07 Mon Sep 17 00:00:00 2001 From: zLeoAlex Date: Sun, 7 Jun 2026 16:03:59 +0800 Subject: [PATCH] fix(cache): set temp spillover root in cache_inspect test to survive nix sandbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test cache_inspect_displays_tool_result_budget_metadata relied on a writable $HOME/.codewhale/tool_outputs/ for tool-result wire-dedup persistence. nix build sandboxes have a read-only home tree, so the first tool-result SHA spillover write failed, the dedup hash table was never populated, and the second identical tool result was not marked deduplicated — causing the expect("repeat tool-result sighting should report dedup metadata") assertion to fail. Set TEST_SPILLOVER_ROOT to a tempdir inside the test (matching the with_tool_result_sha_spillover_root pattern in chat.rs), so the wire-dedup path works in any environment without depending on $HOME. --- crates/tui/src/commands/debug.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/tui/src/commands/debug.rs b/crates/tui/src/commands/debug.rs index eee41bb5..bcc88b85 100644 --- a/crates/tui/src/commands/debug.rs +++ b/crates/tui/src/commands/debug.rs @@ -1183,6 +1183,22 @@ mod tests { let _spill_guard = crate::tools::truncate::TEST_SPILLOVER_GUARD .lock() .unwrap_or_else(|err| err.into_inner()); + // Set a temporary spillover root so wire-dedup can persist + // SHA-addressed tool-result files without depending on a + // writable $HOME (nix sandboxes have a read-only home tree). + let tmp = tempfile::tempdir().expect("tempdir"); + let _restore = { + let prior = crate::tools::truncate::set_test_spillover_root(Some( + tmp.path().join(".deepseek").join("tool_outputs"), + )); + struct Restore(Option); + impl Drop for Restore { + fn drop(&mut self) { + crate::tools::truncate::set_test_spillover_root(self.0.take()); + } + } + Restore(prior) + }; let mut app = create_test_app(); let long_output = format!("{}{}", "A".repeat(7_000), "Z".repeat(7_000)); app.api_messages.push(Message {