Conversation
`gather_git_info` spawns a background thread that shells out to `git` and writes the answer into a process-global cache. The first caller in a test binary sees `None`, but every test after it inherits the developer's real branch, ahead/behind and dirty counts, so frame assertions depended on how many tests ran before them and on whether the checkout was clean. `master` therefore reports different `jcode-tui --lib` failures on different machines and on different runs of the same machine. Tests now read that cache without ever spawning the probe, and `seed_git_info_cache_for_tests` remains the explicit way to opt in to git data for the tests that want it. This also narrows `test_background_task_markdown_is_suppressed_even_if_role_was_lost`, which asserted the frame contains no box-drawing character at all. Info-widget overlays legitimately draw their own bordered box in the right margin, and whether they are docked depends on how many frames the process has already rendered, so that assertion was order-dependent rather than a statement about the card under test. The card assertions themselves are unchanged. Measured on `master` (`cargo test -p jcode-tui --lib -- --test-threads=1`): 19 failed before, 17 failed after, with the remaining failures tracked separately (1jehuang#1340, 1jehuang#1342). Two of the failures this removes are the onboarding "recent project" tests that fail or pass depending on the developer's git state.
| #[cfg(test)] | ||
| { | ||
| return GIT_INFO_CACHE | ||
| .lock() | ||
| .ok() | ||
| .and_then(|guard| guard.as_ref().map(|(_, cached, _)| cached.clone())) | ||
| .flatten(); | ||
| } |
There was a problem hiding this comment.
This block can never compile: the enclosing function has #[cfg(not(test))], so test builds exclude the whole function, while non-test builds exclude this inner block. The active #[cfg(test)] implementation at lines 1094–1103 already provides the read-only cache behavior. Keeping this duplicate dead code makes the explanation misleading and creates a second implementation that can drift from the real test path.
| #[cfg(test)] | |
| { | |
| return GIT_INFO_CACHE | |
| .lock() | |
| .ok() | |
| .and_then(|guard| guard.as_ref().map(|(_, cached, _)| cached.clone())) | |
| .flatten(); | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-tui/src/tui/app/helpers.rs
Line: 1124-1131
Comment:
**Unreachable test cache branch**
This block can never compile: the enclosing function has `#[cfg(not(test))]`, so test builds exclude the whole function, while non-test builds exclude this inner block. The active `#[cfg(test)]` implementation at lines 1094–1103 already provides the read-only cache behavior. Keeping this duplicate dead code makes the explanation misleading and creates a second implementation that can drift from the real test path.
```suggestion
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| rt.block_on(async { | ||
| app.input = "/account switch openai2".to_string(); | ||
| app.input = format!("/account switch {assigned}"); | ||
| app.submit_input(); | ||
|
|
||
| assert_eq!( | ||
| crate::auth::codex::active_account_label().as_deref(), | ||
| Some("openai-1") | ||
| Some(assigned.as_str()) | ||
| ); |
There was a problem hiding this comment.
Switch test proves no transition
This test asserts that the only inserted OpenAI account is already active, then asks /account switch to select that same account. The final assertion would therefore still pass if command submission or the switch operation were a no-op. Create a second account and make a different account active before submitting the command so this remains a meaningful regression test.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-tui/src/tui/app/tests/commands_accounts_02/part_01.rs
Line: 560-567
Comment:
**Switch test proves no transition**
This test asserts that the only inserted OpenAI account is already active, then asks `/account switch` to select that same account. The final assertion would therefore still pass if command submission or the switch operation were a no-op. Create a second account and make a different account active before submitting the command so this remains a meaningful regression test.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
603e3b5 to
211067f
Compare
|
Closing this fork-side validation PR now that the corresponding upstream PR 1jehuang#1366 was merged. Keeping the branch untouched. |
Fork-side PR so this change is reviewed by Greptile here as well as upstream.
The same commit is open upstream as 1jehuang#1366
for issue 1jehuang#1365.
gather_git_infospawns a livegitprobe in test binaries again onmaster,so
jcode-tui --libfailure sets are order-dependent and differ per runner.This restores the
#[cfg(test)]read-only path from 1jehuang#1133 and narrows oneframe assertion that depended on how many frames the process had rendered.
cargo test -p jcode-tui --lib -- --test-threads=1: 19 failed before, 17 after(2332 -> 2334 passing).
The PR is not yet safe to merge because the updated account-clearing test selects a label that cannot exist and therefore fails before exercising the behavior under test.
Findings
Fix with agent prompt
Summary
This PR prevents test builds from probing the live Git repository and makes a background-task rendering assertion target the suppressed card rather than unrelated box-drawing UI.
Reviews (3) · Last reviewed commit: "fix(tui): stop the live git probe leakin..."