Skip to content

clipboard: a copy can be reported as successful when the helper actually failed #231

Closed

Description

@KooshaPari

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

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:

  1. 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).
  2. 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.
  3. 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

  1. coderabbitai commented on Nov 3, 2026

    @coderabbitai
    🔗 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 plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 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:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added
    kilo-triaged
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kilo-triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions