Repository navigation
fix(tui): make the clipboard fail-fast window explicit so the test pins the contract - #228
KooshaPari wants to merge 1 commit into
Conversation
…ns the contract
`copy_via_clipboard_helper` polls a freshly spawned helper for 150ms and treats a
still-running child as the selection owner. That heuristic is the only thing that
separates "exited nonzero" from "owns the selection", so a helper that exits
nonzero *after* the window closes is reported as a copy.
`Build & Test (desk-linux)` in run 41547128038 failed
`helper_that_exits_nonzero_falls_through` with
`!copy_via_clipboard_helper("false", &[], "hello")` after ~154ms, i.e. the child
was not observed exiting inside the 150ms budget and the owner branch won.
The window is now a parameter (`copy_via_clipboard_helper_within`) with the
production value kept at 150ms via `HELPER_FAIL_FAST_WINDOW`. Tests pass their
own window so they assert the contract instead of racing the scheduler:
- settle window (30s) for every "exits nonzero" / "exits zero" case, so the exit
is always observed;
- 10ms live-owner window, so `sleep 30` is deterministically still running.
Adds `helper_that_exits_nonzero_late_still_falls_through`, which fails against
the old fixed-window code and passes now. Ordering tests use the same settle
window for the same reason.
tx-agent: jcode
tx-validated: manual
tx-scope: crates/jcode-tui/src/tui/app/helpers/clipboard_helper.rs
tx-intent: remove the scheduler race in the clipboard helper tests and document the window contract
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 31 minutes. View limit details
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. CodeRabbit Verify
|
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Reviewed by free · Input: 27.3K · Output: 985 · Cached: 107.7K |
|
|
FYI — this and #227 were opened concurrently for the same failure. Yours is the better change to land, so I am closing #227 and keeping your approach as the test-determinism fix. Context that may be useful: Your The production behaviour is unchanged by design in your patch, and that is a legitimate call, but it leaves a real user-facing gap: a helper that is going to fail but has not been scheduled yet is still reported as a successful copy. I filed #231 for that, with a deterministic reproduction ( Why my PR also touched One note on your current run: |
|
Closing under the host-ops closure audit (2026-11-11): conflicts with master. The branch |
…ship (#231) (#386) Issue #231 is that a helper still running at the 150 ms fail-fast deadline is reported as a successful copy. The only sound facts a helper provides are exit 0 (accepted) and nonzero (failed); "still running" is unknown, and the resident-helper case on a healthy Linux desktop never produces an exit. There is no honest mapping of that unknown into a `bool`. Records the verified starting state (HEAD 63d49fa, parent and live origin/master ac34906, clean tree, PR #228 open), the exact defect site, all eight call sites that consume the boolean, the existing status-notice and handle_tick plumbing that a late correction would use, and the three candidate contracts. Recommends a deferred-notice contract plus optional read-back verification as the only genuine observation of "what does paste give me". Does not change production code: every candidate contract needs a product decision on what the UI shows while a copy is unconfirmed, and the only honest resolution (read-back) cannot be measured here because the module is Linux-only while this workstation is macOS and the build host is Windows/MSYS. Blockers B1 (unconfirmed-copy wording), B2 (read-back in scope?), B3 (no Linux desktop to validate real helper behaviour), B4 (depends on PR #228's parameterised window), B5 (image copy paths share the defect). tx-agent: jcode tx-validated: none tx-scope: docs/design/clipboard-helper-ownership.md tx-intent: give issue #231 a decision-ready, evidence-backed design without shipping a time-based success claim



User description
Why
Build & Test (desk-linux)in run 41547128038 failed onmaster(dabaab5b8):2516 passed, 1 failed.
Root cause (observed, not assumed)
The failing test's timestamp is ~154 ms after the previous test finished, which matches the fixed
150 mspoll budget incopy_via_clipboard_helper. That function's contract is:The last branch is a heuristic, and it is the only thing separating "failed" from "owns the selection". On a loaded shared runner
falsewas not reaped inside 150 ms, so the owner branch won and the assertion failed. This is not just a flaky test: a realxclipfailing slowly would also be reported as a successful copy, which is the exact class of false "Copied" that 1jehuang#684 fixed.Reproduced deterministically on the extracted function:
sh -c 'sleep 1; exit 7'true(misclassified as owner)falsefalsefalseChange
copy_via_clipboard_helper_within(program, args, text, window); keep the public signature and the production window unchanged (HELPER_FAIL_FAST_WINDOW = 150 ms).TEST_SETTLE_WINDOW(30 s) for every "exits nonzero" / "exits 0" case;sleep 30is deterministically still running.helper_that_exits_nonzero_late_still_falls_throughfails against the old fixed-window code.ordering_tests::first_helper_that_winsuses the same settle window (it had the same race).Runtime behaviour is unchanged: no change to fallback order, no change to the production budget.
Validation
rustfmt --edition 2024 --checkclean.desk-linuxrunner in this PR's CI (the module iscfg'd out on macOS, where this was authored.BODY
)
CodeAnt-AI Description
Make clipboard-helper failure tests deterministic
What Changed
Impact
✅ Fewer timing-dependent clipboard test failures✅ Delayed helper failures covered in regression tests💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Closes #234
Refs #231. This PR does not fix the production false-success defect described in #231: runtime behaviour is unchanged, including the 150 ms
HELPER_FAIL_FAST_WINDOWheuristic. #231 remains open and must not be closed by this change.