Skip to content

Clipboard paste must preserve unrelated terminal primary-selection affinity #6

Description

@c-wri

Observed

During live COSMIC Terminal qualification, grabbing selected text immediately after a successful ClipReg paste could fail even though the service remained command-ready.

The runtime path explains the behavior:

  • COSMIC Terminal profile pastes with CTRL+SHIFT+V, i.e. the regular clipboard.
  • command_paste() nevertheless stages both SEL_CLIPBOARD and SEL_PRIMARY whenever global stage_primary_for_paste is enabled.
  • Paste restore then unconditionally sets primary_affinity_valid = false.
  • The next terminal primary-first grab cannot use the affine primary-selection fast path and falls into application Copy fallback instead.

The live journal shows successful pastes entering paste-stage-primary, followed by subsequent grabs taking the fallback transaction path rather than immediate primary capture.

Violated invariant

A paste transaction should mutate only the selection domains required by the selected paste behavior. A clipboard-only paste accelerator must not disturb an unrelated primary selection or discard trustworthy primary affinity merely as collateral staging state.

Investigation / design direction

Make the selection source consumed by a paste accelerator explicit enough that transaction staging/restoration follows that contract rather than globally staging both selections. Avoid brittle assumptions for configurable application profiles; if selection semantics need to become profile data, design that contract directly rather than inferring arbitrary custom chords by string coincidence.

The synthetic terminal-input leakage from generic Copy probing is tracked separately in #5.

Acceptance

  • COSMIC Terminal CTRL+SHIFT+V paste stages/restores the regular clipboard without replacing primary selection solely for paste compatibility.
  • A trustworthy terminal primary selection/affinity present before a clipboard-only paste remains usable for an immediate primary-first grab afterward, unless the application itself changed it.
  • Primary-selection paste paths (for example an explicitly supported Shift+Insert policy) continue to stage the primary selection when actually required.
  • Add a durable policy/lifecycle regression proving clipboard-only paste does not invalidate unrelated primary affinity.
  • Live COSMIC Terminal qualification: select text, paste a register, then grab the still-valid/newly selected terminal text without requiring a synthetic generic Copy probe or service restart.

This blocks v0.2.0-rc.1 because supported terminal grab/paste composition is part of live qualification.

Metadata

Metadata

Assignees

Labels

area:runtimeNative daemon, protocol, transaction, or persistence behaviorbugSomething is not workingpriority:blockerBlocks the next release promotionrelease:0.2Targets the v0.2.0 line

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions