Repository navigation
Description
Summary
copy_via_clipboard_helper returns true when the helper is still running at the end of its 150 ms poll window, on the assumption that a surviving helper owns the selection. That inference cannot distinguish "resident owner serving paste requests" from "a helper that is going to fail but has not been scheduled yet".
When the second case happens, the caller is told the copy succeeded and the user sees a success status for a clipboard that was never written.
Deterministic reproduction
A child that exits non-zero after the window closes reproduces it every time:
// helper exits 1 at ~250 ms, i.e. past the 150 ms window
copy_via_clipboard_helper("sh", &["-c", "sleep 0.25; exit 1"], "x")Observed:
OLD logic reports copy = true (WRONG)
NEW logic reports copy = false (ok)
How it surfaced
Master CI, run 41547128038 job 125625340312, on a runner at load ~50:
test ...clipboard_helper::tests::helper_that_exits_nonzero_falls_through ... FAILED
assertion failed: !copy_via_clipboard_helper("false", &[], "hello")
The test was reporting a real defect. The same tree had passed minutes earlier at low load, which is why it reads as flake.
It also silently validated two unrelated image tests, which asserted status == "Image size: large" exactly; once the copy correctly reported failure they saw "Image size: large · Could not copy image". Those assertions were encoding the bug.
Relationship to the open PRs
- fix(tui): make the clipboard fail-fast window explicit so the test pins the contract #228 makes the poll window a parameter, so tests pin both sides of the boundary deterministically. This fixes the CI flake and is the right change for test determinism, but production behaviour is unchanged, so the false success remains for real users.
- fix(tui): do not report a copy when a slow clipboard helper fails #227 additionally made the function wait a bounded grace period so the helper's real exit status decides. That removes the false success at the cost of up to ~850 ms on the ambiguous path (only when a helper is genuinely resident or genuinely slow), and also fixed the two image-test assertions.
This issue tracks the remaining product question, deliberately separated from the test-determinism fix:
Should a copy be reported as successful before the helper's fate is known?
Options, none obviously wrong:
- Accept the ~850 ms bounded wait in the ambiguous case (what fix(tui): do not report a copy when a slow clipboard helper fails #227 did).
- Report optimistically and correct the status asynchronously if the helper later exits non-zero — no added latency, no false success. Requires a status-update channel from the background reaper.
- Keep the current heuristic and accept the false positive, documenting it as a known limitation.
Option 2 is probably the best of the three, and is a bigger change than either PR.
Acceptance for closing this
A test using the parameterised window from #228 that pins: a helper exiting non-zero after the window must not be reported as a copy, or an explicit documented decision that it may be.
Activity
coderabbitai commentedon Nov 3, 2026
🔗 Related PRs
#227 - fix(tui): do not report a copy when a slow clipboard helper fails [open]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
fix(tui): make issue #231 linux clipboard tests compile and pass
refactor(tui): keep the test list at its oversized-file budget (#231)
fix(tui): settle late clipboard outcomes on the remote tick too (#231)
refactor(tui): drop the unreachable expect from the clipboard poll (#231
fix(tui): stop reporting an unconfirmed clipboard helper as a copy (#231
fix(tui): report clipboard helper outcome as confirmed or unconfirmed
docs(clipboard): evidence-backed design and blockers for helper owner…
fix(clipboard): define the test-only settle API and stop the stub-PAT…
fix(tui): report clipboard helper outcomes truthfully instead of as p…