Skip to content

Prevent generic Copy probing in terminal grabs - #7

Merged
c-wri merged 1 commit into
mainfrom
agent/5-terminal-grab-input
Aug 20, 2026
Merged

Prevent generic Copy probing in terminal grabs#7
c-wri merged 1 commit into
mainfrom
agent/5-terminal-grab-input

Conversation

@c-wri

@c-wri c-wri commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Why

COSMIC Terminal live qualification exposed a terminal-input safety defect: when a primary-first grab could not use an affine primary selection, ClipReg injected the global CTRL+INSERT probe before the terminal-specific CTRL+SHIFT+C fallback. In a terminal, that generic Insert-family probe can reach the PTY as a CSI sequence instead of acting as Copy, producing visible ...~ residue.

This PR addresses #5 only. The unrelated clipboard-paste / primary-affinity composition problem remains tracked in #6.

What

  • Introduce an explicit grab Copy plan derived from the application profile.
  • primary-only: never inject Copy.
  • primary-first: use affine primary when available; otherwise inject exactly the profile-defined Copy chord, with no generic probe first.
  • ordinary copy: retain the generic safe probe and optional profile fallback behavior.
  • Update architecture and app-profile authority to describe the same policy.
  • Add a lowest-layer runtime regression that fails if primary-first is routed through the generic probe.

For COSMIC Terminal, the only injected Copy fallback is now CTRL+SHIFT+C.

Validation

Automated/local:

  • make check PASS on Pop!_OS 24.04, including strict native compile, runtime lifecycle regressions, binary self-test, client/autostart tests, install rebuild planning, and sanitizers.
  • Native rebuild/self-test PASS for 0.2.0-beta.1+g96bd9e674a3b.
  • GitHub CI / Check PASS on Ubuntu 24.04.

Live COSMIC Terminal:

  • normal affine-primary grabs produced no synthetic terminal residue;
  • forced fallback with primary_affinity=invalid produced seven grab-profile-copy attempts and zero grab-safe-copy attempts;
  • all seven intentionally failed grabs returned bounded ETIMEDOUT because nothing was selected;
  • F12 remained unchanged (REGISTER ONE TEST, same metadata/timestamp), proving failed grabs do not overwrite the register;
  • rapid consecutive fallback grabs produced no ...5~, ...14~, CSI residue, or SIGINT;
  • NRestarts remained 0 -> 0 and post-test list, doctor, and app remained responsive.

Release impact

#5 acceptance is complete. No version bump or prerelease tag is introduced by this corrective PR. The separate #6 blocker still prevents v0.2.0-rc.1 promotion.

Open / deferred

Make primary-first capture use an affine primary selection or the explicit application Copy chord directly. Keep generic Ctrl+Insert probing limited to ordinary copy profiles, and regression-protect the input policy.
@c-wri
c-wri marked this pull request as ready for review August 20, 2026 21:43
@c-wri
c-wri merged commit 87b4822 into main Aug 20, 2026
1 check passed
@c-wri
c-wri deleted the agent/5-terminal-grab-input branch August 20, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant