Repository navigation
Fix clipboard stale offer overwrite (C1) - #22
Conversation
ElSargo
left a comment
There was a problem hiding this comment.
Brood QA — PR #22
Verdict: APPROVE (posted as comment — gh as ElSargo cannot formally APPROVE own PRs)
What this fixes
Audit C1 / ui-concurrency clipboard race: offer reader threads no longer unconditionally write latest_content. Reads are stamped with a selection generation (begin_offer_epoch → clear_clipboard_slot); commits go through commit_clipboard_slot and apply only while that epoch is still current. ClipboardBridge::set_text also bumps the generation so a slow prior offer cannot overwrite an explicit copy.
CI
Red job is infra ENOSPC (No space left on device while unpacking rust-std wasm target), not a compile/clippy/test failure on this diff. Not a merge blocker for correctness.
Verification
- Reviewed
clipboard.rsepoch helpers,ext_selection/wlr_selection,spawn_offer_reader, and bridgeset_text/content. - Friction remittance in
docs/frictions/ui-concurrency.mdmatches the code. - Local:
RUSTFLAGS='-C linker=cc' cargo test -p brood-client --lib clipboard::→ 4 passed.
Residual (accepted)
- Superseded readers still finish pipe I/O and drop the result (no FD cancel).
- Flush/pipe failure after
begin_offer_epochcan leave an empty slot with no reader (pre-existing clear-before-receive). - Optional manual churn test in the PR body remains unchecked; unit tests cover the epoch commit race.
No correctness blockers. Ship when convenient (re-run CI if you want a green check for process).
ElSargo
left a comment
There was a problem hiding this comment.
Brood QA review
Checked: diff/view; CI 35146185249; audit C1; friction doc update in-PR.
Code: Correct C1 fix. Selection generation via begin_offer_epoch / clear_clipboard_slot / set_clipboard_slot; commit_clipboard_slot drops stale offer commits; set_text bumps generation so in-flight readers cannot overwrite. Module unit tests cover stale vs current commits and superseded epochs. Residual (acknowledged): superseded readers still finish pipe I/O; flush failure after epoch bump can leave empty slot (pre-existing).
CI: FAILURE — runner ENOSPC during Nix build. Infra, not clipboard logic. Author: 4 clipboard:: tests passed locally.
Race-doc: Clipboard friction remitted accurately.
Desktop verify: Blocked (no nix / Wayland client build here). Manual rapid-selection paste still recommended once buildable.
Residual / merge: Doc conflicts with sibling remittance PRs. Re-run CI after disk relief before merge.
— Brood QA
Stamp each selection read with a generation and only commit when that epoch is still current, so a slow offer A cannot replace selection B or an intervening set_text. Mark the ui-concurrency friction remitted and cover the race with module unit tests.
ec8276b to
bdeffef
Compare
Summary
begin_offer_epoch/clear_clipboard_slot/set_clipboard_slot) so commits only apply when the epoch is still current.spawn_offer_readerusescommit_clipboard_slot; a slow read of selection A can no longer overwrite selection B or an interveningClipboardBridge::set_text.docs/frictions/ui-concurrency.md.clipboard.rs.Test plan
RUSTFLAGS='-C linker=cc' cargo test -p brood-client --lib clipboard::(4 passed)Residual risks
begin_offer_epochcan leave an empty slot with no reader (pre-existing clear-before-receive behavior).