Skip to content

#187 (part 1): paste answers by stage, never a blind retry, with value-free diagnostics - #254

Merged
SSFSKIM merged 6 commits into
mainfrom
fix/187-paste-clipboard-timeout
Nov 1, 2026
Merged

SSFSKIM merged 6 commits into
mainfrom
fix/187-paste-clipboard-timeout

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

When cua types through the clipboard (type_text under a non-layout input source such as Korean 2-Set, and paste), every failure answered one sentence: "Timed out waiting for the application to read the clipboard". That sentence covered three different things:

  • the app was never able to take ⌘V (preparation);
  • ⌘V was posted but nothing read the clipboard (delivery);
  • the app read the text but cua saw no change in the field (acknowledgment).

The last case often means the text did arrive, and a model that retried blindly typed it twice (MAWS dogfood). OpenAI's helper has the same flaw: it remaps its effect timeout to the read-timeout sentence (FUN_1001b534c).

This PR makes the answer honest about which stage failed, and tells the model to look before any retry. It doesn't yet make background Chrome take the paste; that needs a live A/B, planned below. Refs #187 (not Closes: #187's criterion is that those rows deliver).

What changes (native/engine/Sources/Engine/Paste.swift, Pasteboard.swift, Enablement.swift, Input.swift; src/services/engine/service.mjs)

Answers by stage:

what happened answer
no read of the pasted text within the wait clipboardReadTimedOut: "Timed out waiting for the application to read the clipboard: ⌘V was sent, but no app read the pasted text in time. Whether anything was entered is unknown: observe the field with get_app_state before any retry, and never retry blindly."
read after ⌘V, a trusted way to see the field, and no change in the wait pasteUnconfirmed (new): "The paste could not be confirmed: ⌘V was sent and the pasted text was read from the clipboard, but no change was seen in the field. The text may have arrived: observe the field with get_app_state before any retry, and never retry blindly."
the only read came before ⌘V (another reader, e.g. a clipboard manager) pasteUnconfirmed
read after ⌘V, but no trusted way to see the field (no selection or length to compare, no trusted notification source) success, with a note in the result text: "Pasted, unconfirmed: the app read the text after ⌘V, but this field can't be read back, so the change couldn't be seen. Observe the field if the next step depends on it." _meta gets confirmed: false and the stage. This replaces the vendor's blind 100 ms success with a success that says it is unconfirmed, gated on the read's timing.
the change count moved (someone else wrote the clipboard) clipboardConflict, as before
  • type_text puts its progress in the error text, since the model doesn't read _meta: e.g. "Confirmed entered: 3 of 8 characters (1 of 3 lines complete); line 2 is in an unknown state." Unconfirmed-success lines continue, and the final text counts them ("3 lines pasted, 1 unconfirmed…").
  • Trusted notifications: AX SelectedTextChanged/ValueChanged from a Chromium or Electron process (principal class BrowserCrApplication/AtomApplication) count only while macOS engine: the first observation of a freshly enabled Chromium/Electron app returns an incomplete tree (vendor's is complete) #244's web-accessibility enablement holds for that process (WebAccessibility.enablementHolds). Basic mode from the role read alone doesn't make them send.
  • Deadline: both waits are bounded by the request's remaining deadline as well as their 2 s. Each effect-poll AX read gets the time left as its messaging timeout (at most 1 s, at least 50 ms, the observation's rule). A reading that comes back past the budget is rejected, and the stage's error is answered with deadline recorded.
  • Diagnostics (cua/paste in the response meta, value-free, with no clipboard or field contents):
    • the stage and how it ended;
    • the read's time relative to ⌘V's post, signed, so a read before ⌘V shows;
    • main-thread lag at ⌘V;
    • whether a trusted channel or a baseline existed;
    • the restore outcome (restored/skippedChanged/notTaken);
    • keyFocusAtPaste, with its inputs: is the app frontmost, or is the key-focus process the app's or the keys' target's, and is the app's focused element in the window route 3 prepared? It is record-only here: it never refuses. Refusal on it waits for the slot to show it separates delivered rows from undelivered ones.
  • Restore, concealed-input refusal and the change-count guard are unchanged.

Limits

  • Background Chrome still doesn't deliver. Hold 3's 18 composing rows answered after about 2.06 s with the field empty: a real non-delivery, most likely preparation. Route 3's clickless activation never gives Chrome's page key focus. The vendor runs SyntheticAppFocusEnforcer.safelyEnforceActiveState and targetForKeyboardEvent before ⌘V. Fixing that (3b) needs the attended A/B; if it fails, 3a's refusal ends Fix Chrome background paste clipboard-read timeouts in composing@textedit rows #187 as a stated gap.
  • A ⌘V handled late, after the restore, would paste the person's previous clipboard into the app. Not observed; the vendor shares it.
  • "Pasted, unconfirmed" is a success without proof. It trusts that a read after ⌘V means delivery. A field that can't be read back gives no evidence either way.
  • keyFocusAtPaste is a heuristic. Its value on real apps is unvalidated until the slot.

Tests

  • Engine (XCTest), full suite 688/688 with the desktop gate closed, using the runPaste, PasteEffect (fake clock), TestPasteboard and PasteboardAccess seams. Covered:
    • each stage's answer and text;
    • a read before ⌘V;
    • no channel answering success with the note, and the multi-line count;
    • an untrusted Chromium observer;
    • conflict precedence;
    • a deadline shorter than either wait, and a read that consumes the remaining time;
    • the diagnostics fields;
    • the restore on every path;
    • enablementHolds.
  • JS: test/services-engine-service.test.mjs (the note and the error text pass to the model unchanged; cua/paste per call).
  • Review (reviewer-high):
    • One P2: an effect poll's AX reads weren't bounded by the deadline. Fixed in 934c637.
    • The re-review found it resolved; it accepted the shared 50 ms messaging-timeout floor as a bounded tolerance, since late readings are rejected.
    • The re-review raised one P2 on the refinement: the no-channel decision looked only at the first read, so a multi-representation paste whose target read HTML after ⌘V (while another reader took the plain text before) answered pasteUnconfirmed. Fixed in e252884: the decision keys on any handover at or after ⌘V (firstReadAfterPostMs), with a regression test. I verified the two-line decision change myself.
  • CI: ci-gate on ce64855 GREEN: sandbox-live, plugin, engine-swift and test (run 41304301404). The PR's own checks are green (run 41304289990).

Docs

Native-engine design spec: a Decision Log entry (#187, 2026-11-01) for the stage split, the text contract, the departure from the vendor's single sentence, the no-channel rule with the #244 trust condition and the read-timing gate, the diagnostics with the record-only 3a predicate, and the deadline binding. The Design "Paste" paragraph and the Interfaces meta and error lists are updated to match.

Plugin 0.20.5 (its own commit).

Refs #187

Sminos-Session: cursor235#b93055dd (cua on macbook)

…diagnostics (refs #187)

The paste route's two waits no longer share the vendor's read sentence:
- no read in time stays clipboardReadTimedOut; a read with no effect seen is
  the new pasteUnconfirmed, an error. A moved change count is still the
  conflict for both.
- both sentences say delivery is unknown and to observe the field with
  get_app_state before any retry, never blindly; type_text's add the
  confirmed units and lines and that the failed line's state is unknown.
- no confirmation channel (empty baseline and no trusted notification
  source) answers pasteUnconfirmed at once after the read. A Chromium or
  Electron observer is trusted only while #244's enablement holds for the
  process (WebAccessibility.enablementHolds).
- both waits end at the request's deadline too, with that stage's error.
- every paste records meta.paste (cua/paste): which wait ended it and how,
  the read's signed time against the Cmd-V post, the main thread's lag, the
  restore outcome, the notification source, an empty baseline, and the 3a
  predicate keyFocusAtPaste with its inputs, recorded only.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…no-channel rule, diagnostics and deadline (refs #187)

Names the departure from the vendor's single sentence (FUN_1001b534c remaps
the effect timeout to the read sentence), the new pasteUnconfirmed, the two
texts, the no-channel rule with #244's trust condition for Chromium and
Electron, the value-free diagnostics with the record-only keyFocusAtPaste
predicate (refusal after a live slot), and the deadline binding. Design's
Paste paragraph and Interfaces' meta and error names follow.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…irmed note (refs #187)

The design session's refinement of rule 4: "no channel" (cua can't look)
is not "looked and saw nothing".
- empty baseline and no trusted notification source, first hand-over at or
  after the Cmd-V post: success, meta.paste.confirmed false with the stage,
  and the result's note ("Pasted, unconfirmed: ..."), which the service adds
  to the tool result's content with nodeRepl.emitContentItem (the facade
  returns nothing of an input's result to model code).
- type_text goes on to the next line; its note counts them ("3 lines
  pasted, 1 unconfirmed: ..."), and a later line's error says how many of
  the complete lines were unconfirmed.
- the only read before Cmd-V (a foreign reader): pasteUnconfirmed.
- a channel and no change, and no read at all: unchanged.
The Decision Log entry, Design's Paste sentence and Interfaces follow.

Sminos-Session: cursor235#b93055dd (cua on macbook)
#187, review P2)

Each of effectReading's three AX requests takes the effect wait's time
left as its messaging timeout (boundedMessagingTimeout: at most 1 s, at
least 50 ms, the rule the observation's deadlineBounded already used), none
is sent once the time is spent, and the application element's usual
timeout is put back after. A changed reading that came back after the time
ran out is no longer accepted, so a slow target's late reply answers
pasteUnconfirmed instead of confirming a line and moving multi-line typing
on. Regression: a read that itself uses up the remaining time.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…the first read (refs #187, re-review P2)

Each representation of an item (HTML, RTF, plain) is handed over on its
own, so a clipboard manager taking the plain text before Cmd-V and the
target taking the HTML after it are two hand-overs. PasteEffect now keeps,
beside the first hand-over's time (readAfterPostMs, diagnostics), the
first at or after the Cmd-V post (firstReadAfterPostMs), and the
no-channel success or pasteUnconfirmed decision keys on that. Regression:
several representations, one read before Cmd-V and another after.

Sminos-Session: cursor235#b93055dd (cua on macbook)
#187)

Sminos-Session: cursor235#b93055dd (cua on macbook)
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-01T11:59:02.833998Z
We couldn’t complete this review. Comment @codex review to try again.
ce64855 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@SSFSKIM
SSFSKIM merged commit 18cad98 into main Nov 1, 2026
6 checks passed
SSFSKIM added a commit that referenced this pull request Nov 1, 2026
…71-m3

Main moved again: #254 (#187 part 1, the macOS paste route: answers by
stage, never a blind retry, value-free diagnostics).

The overlapping files and how each was resolved:
- .claude-plugin/plugin.json, marketplace.json (conflict): this
  branch's 0.21.0 kept, still the next minor above main's 0.20.5.
No other file overlaps. #254 touches the macOS engine (native/engine/),
scripts/native-matrix/, its spec, and src/services/engine/service.mjs,
the macOS engine service, additively (it acts only on a `note` the
engine sends on paste or type_text, or a `paste` meta key, which
cua-engine never sends). Nothing under native/linux-engine/,
scripts/linux-engine-diff/ or src/services/engine/linux/ changes.

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
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.

Fix Chrome background paste clipboard-read timeouts in composing@textedit rows

1 participant