← Back to Pull requests

fix(paste): preserve newer clipboard updates #835

Merged
steipete merged 21 files (2417 lines) on Sep 27, 2026 00:08 UTC
View on GitHub
steipete steipete commented on Sep 26, 2026 22:51 UTC
Author

Summary

Automatic CLI/MCP paste cleanup previously restored or cleared the clipboard unconditionally. If the user or another application copied something while paste was settling, cleanup overwrote that newer content. The per-user paste lock only serializes Peekaboo clients; it does not own other applications' clipboard writes.

Use one shared temporary-write owner in AutomationKit. It captures the generation returned by the native declaration before payload writes can fail, materializes complete ordered prior items, and performs one-shot cancellation-independent cleanup only while the observed generation is still owned. A superseding copy is preserved even when its bytes are identical. Explicit manual clipboard save/restore, current-clipboard paste, and clipboard-free background text retain their existing paths.

Expose cleanup status separately from input delivery. A hotkey refusal after a real temporary clipboard claim remains retry-unsafe without inventing a Cmd+V dispatch, receiver target, or exact combined mutation count. Existing dispatched partial outcomes retain their counts and evidence. Providers without ownership-aware temporary-write support now refuse before clipboard access or foreground setup instead of silently using unsafe restoration.

On macOS 15.4+, automatic General-clipboard snapshots also require native alwaysAllow read access before inspecting contents. default, ask, and alwaysDeny refuse with a canonical permission reason instead of deliberately triggering an alert. Foreground mode is not an exception. Named pasteboards/manual commands are unchanged; older systems do not expose this preflight.

CLI/MCP share the production ownership state machine and an in-memory test fixture; several duplicate mocks are removed. Command help, documentation, and the Unreleased changelog describe the changed cleanup contract, including custom-provider migration.

Verification

  • Reproduced both empty/populated prior-state losses on the old cleanup: two cases failed four assertions; the newer synthetic copy was cleared or overwritten.

  • Focused final gates passed: 32 AutomationKit XCTest cases, 96 Core/MCP tests, and 64 CLI tests. Coverage includes superseding identical bytes, cancellation, partial writes, refused input after a claim, legacy-provider refusal, silent-access permission metadata, and existing exact-target/outcome contracts.

  • Actual native tests use only unique private NSPasteboards: empty restoration, ordered multi-item/multi-representation restoration, identical-byte supersession, invalid payloads, Unicode text, and binary text companions. No general clipboard or UI input is used by these tests.

  • Additional real private-pasteboard regressions show that supplied lazy data is materialized/restored, unresolved promised data refuses without losing its readable companion or changing ownership, and zero-length marker data is preserved. The silent-access matrix uses General/non-General names and all four native access modes without inspecting the General clipboard.

  • On integrated predecessor 6998663, full AutomationKit passed: 1,808 Swift Testing tests plus 280 XCTest cases, with ambient and input automation disabled.

  • On that predecessor, full integrated Core passed: 2,760 / 106 / 79 / 512 tests (3,457 total), including current dependency/model changes and the scalar-schema/cancellation-fixture fixes.

  • On that predecessor, full integrated CLI passed: 1,365 / 50 / 144 / 571 tests (2,130 total), using the actual built CLI. The first runtime attempt used a nonexistent conventional build path and failed; correcting only that invocation produced a clean complete rerun. The original failure is retained. CLI help and both stricter default unknown-version values were independently checked. These predecessor results do not replace final-head hosted validation.

  • Independent owning-source/SDK review and integrated isolated Codex review found no accepted/actionable blocker at the default P0 threshold. Scoped format/lint, documentation, and whitespace checks pass.
  • NSPasteboard has no atomic compare-and-swap. Adjacent generation checks and native writes cannot exclude every cross-process race; this change preserves observed newer ownership rather than claiming universal race freedom. Native snapshots preserve materialized representations, not the original lazy provider identity. This is not a general-clipboard end-to-end or full input-isolation certification.

    Merged as f86135fda2da36428c4959a1f3c78901414c4c76 with the identical tree of final candidate 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Final-head macOS, supplemental/full-safe, and CodeQL all passed on attempt 1.

    The separate signed native check is deliberately qualified: one background RTF dispatch remained unverified and produced no observed insertion. Clipboard cleanup reported restoration and independent aggregate fingerprints matched; the source-blind audit did not accept the complete ordered/generation-fenced measurement contract from those receipts alone. Fixture values were preserved. This is not a successful full paste workflow or full input-isolation proof.

    Diff: 2417 lines (+1933 / -484) across 21 files Reviewer: steipete Review duration: 76m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.86) × (1 − Review Confidence (0.79)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.86 · 2417 lines diff across 21 files
    0.86
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.88 · 5 substantive comment(s)
    0.88
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    78%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    11 items
    clawsweeper[bot] clawsweeper[bot] commented on Sep 26, 2026 22:51 UTC
    Bot

    <!-- clawsweeper-pr-ack:opened item=835 -->
    🦞👀
    ClawSweeper picked this up.

    Pull request received. I will update this pull request when review starts.

    <!-- clawsweeper-review-progress:start -->

    ClawSweeper review complete

    ClawSweeper finished reviewing this revision. The review result is being finalized.

    View the workflow run.
    <!-- clawsweeper-review-progress:end -->

    cursor[bot] cursor[bot] commented on Sep 26, 2026 22:52 UTC
    Bot

    PR Summary

    <!-- CURSOR_SUMMARY -->
    Medium Risk
    Changes shared clipboard mutation, permission gating, and paste failure semantics across CLI, MCP, and AutomationKit—high user impact but bounded by extensive tests and explicit refusal when ownership cannot be proven.

    Overview
    Paste with an explicit payload no longer uses unconditional save/restore slots. CLI and MCP paste now go through a shared ownership-aware temporary clipboard transaction that snapshots complete prior pasteboard state, tracks the generation claimed by the write, and runs one-shot cleanup only while that generation is still owned. If the user or another app copies newer contents during the operation (including identical bytes), cleanup preserves that update instead of restoring the pre-paste clipboard.

    AutomationKit adds ClipboardTemporaryWriteProviding / OwnedClipboardTemporaryWriteTransaction, generation checks on native ClipboardService writes, and macOS 15.4+ refusal when the general pasteboard is not silently readable. Legacy clipboard providers without the capability refuse before reads, focus, or input. Failure paths expose clipboard_cleanup_status (restored, preserved_newer_contents, not_needed) in CLI JSON, MCP metadata, and human messages; hotkey refusals after a real clipboard claim stay retry-unsafe without inventing Cmd+V dispatch counts or target receipts.

    Tests consolidate on ScriptedClipboardService with new ownership suites; docs and changelog describe the updated cleanup contract.

    <sup>Reviewed by Cursor Bugbot for commit 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>
    <!-- /CURSOR_SUMMARY -->

    clawsweeper[bot] clawsweeper[bot] commented on Sep 26, 2026 22:56 UTC
    Bot

    Codex review: needs maintainer review before merge. _Reviewed September 26, 2026, 8:06 PM ET / September 27, 2026, 00:06 UTC (Revision 2)._

    ClawSweeper review

    What this changes

    The branch changes CLI and MCP payload paste to use a shared clipboard ownership transaction that preserves newer copies during cleanup and reports the cleanup outcome.

    Merge readiness

    ✅ Ready for maintainer review

    Keep this PR open. Current main still restores the clipboard without checking for a newer copy, and the final head addresses that gap. The prior compatibility concern has an explicit maintainer decision and migration guidance; no separate blocking defect is established by this review.

    Priority: P1
    Reviewed head: 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf

    Review scores

    | Measure | Result | What it means |
    |---|---|---|
    | Overall readiness | 🐚 platinum hermit (4/6) | The shared implementation has focused native and adapter coverage, a documented upgrade boundary, and no supported blocking finding on the final head. |
    | Proof confidence | 🐚 platinum hermit (4/6) | Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes. |
    | Patch quality | 🐚 platinum hermit (4/6) | No actionable review findings were identified. |

    Verification

    | Check | Result | Evidence |
    |---|---|---|
    | Real behavior | Not applicable | Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes. |
    | Evidence reviewed | 8 items | Current main still has the reported failure path: The CLI's previous cleanup restores the saved clipboard after paste without comparing clipboard generations. MCP has the same unconditional restore path.<br>Shared ownership check: The introduced transaction records the native write claim, checks the generation before cleanup, and returns preservedNewerContents when another write supersedes it.<br>Native final-effect coverage: Tests use unique native NSPasteboards to check ordered restoration, lazy and unreadable representations, and preservation of a newer claim with identical payload bytes. The reported focused native suite passed; this review did not execute it. |
    | Findings | None | None. |
    | Security | None | None. |

    How this fits together

    Peekaboo's CLI and MCP paste commands put a temporary payload on the macOS clipboard before sending paste input. The shared AutomationKit clipboard service snapshots the previous contents and handles cleanup after input settles.

    flowchart LR
      A[CLI or MCP paste request] --> B[Temporary clipboard provider]
      B --> C[Snapshot prior items]
      C --> D[Write payload and record generation]
      D --> E[Send paste input]
      E --> F{Generation still owned?}
      F -->|Yes| G[Restore prior items]
      F -->|No| H[Preserve newer copy]
    

    Before merge

    None.

    <details>
    <summary><strong>Agent review details</strong></summary>

    Security

    None.

    Review metrics

    | Metric | Value | Why it matters |
    |---|---|---|
    | Code delta | production +648/-183; tests +1259/-298 | The substantial shared implementation is accompanied by native clipboard and CLI/MCP regression coverage. |

    Technical review

    Best possible solution:

    Use the shared ownership-aware transaction for automatic payload paste and retain clear permission and custom-provider migration guidance.

    Do we have a high-confidence way to reproduce the issue?

    Yes. Current-main source unconditionally restores or clears the clipboard after paste; a newer copy made during the settle interval is therefore overwritten. The PR reports failing old-path cases, but this read-only review did not run them.

    Is this the best way to solve the issue?

    Yes. A generation check in the shared clipboard owner covers both command paths and preserves an observed newer claim; the intentional refusal cases have migration and permission guidance.

    AGENTS.md: found and applied where relevant.

    Codex review notes: model internal, reasoning high; reviewed against 30fc7316fd34.

    Labels

    Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes.

  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • Label justifications:

  • P1: Automatic paste can overwrite a user's newer clipboard copy on current main.

  • merge-risk: 🚨 compatibility: The accepted safety boundary makes legacy custom providers and General-clipboard readers without silent-read permission refuse automatic payload paste.

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes.
  • Evidence

    What I checked:

  • Current main still has the reported failure path: The CLI's previous cleanup restores the saved clipboard after paste without comparing clipboard generations. MCP has the same unconditional restore path. (Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift:246, 30fc7316fd34)

  • Shared ownership check: The introduced transaction records the native write claim, checks the generation before cleanup, and returns preservedNewerContents when another write supersedes it. (Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardTemporaryWrite.swift:169, 73e1c2fdedd5)

  • Native final-effect coverage: Tests use unique native NSPasteboards to check ordered restoration, lazy and unreadable representations, and preservation of a newer claim with identical payload bytes. The reported focused native suite passed; this review did not execute it. (Core/PeekabooAutomationKit/Tests/PeekabooAutomationKitTests/ClipboardTemporaryWriteTests.swift:358, 73e1c2fdedd5)

  • Adapter coverage: CLI and MCP tests check preserved newer contents, partial writes, permission refusals, and refusal of providers lacking ownership-aware temporary writes. (Apps/CLI/Tests/CLIAutomationTests/PasteClipboardOwnershipTests.swift:11, 73e1c2fdedd5)

  • Accepted compatibility boundary: The collaborator explicitly accepted refusal for legacy clipboard providers, complete-snapshot refusal, and silent-read permission preflight in https://github.com/openclaw/peekaboo/pull/835#issuecomment-5850825062. The documentation gives custom-provider migration guidance. (docs/commands/paste.md:68, 73e1c2fdedd5)

  • Prior review resolved: The earlier review asked for a legacy-provider upgrade decision. The final head adds migration documentation, and the collaborator's dated comment explicitly accepts the refusal contract.
  • Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

  • Sebastien Tardif: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Rating scale

    | Score | Internal tier | Crab rank | Meaning |
    |---:|:---:|---|---|
    | 6/6 | S | 🦀 challenger crab | Exceptional readiness |
    | 5/6 | A | 🦞 diamond lobster | Very strong readiness |
    | 4/6 | B | 🐚 platinum hermit | Good normal PR; ordinary maintainer review |
    | 3/6 | C | 🦐 gold shrimp | Useful, but confidence is limited |
    | 2/6 | D | 🦪 silver shellfish | Proof or implementation needs work |
    | 1/6 | F | 🧂 unranked krab | Not merge-ready |
    | N/A | NA | 🌊 off-meta tidepool | Rating does not apply |

    Overall follows the weaker of proof and patch quality.
    Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

    Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.

  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.

  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.

  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.

  • Maintainers can also comment @clawsweeper review to request a fresh review only.

  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.

  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.

  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  • History

    <details>
    <summary>Review history (1 earlier review cycle)</summary>

    <!-- clawsweeper-review-history v=1 total=1 -->

  • reviewed 2026-09-26T22:55:03.872Z sha 6998663248503bc56e59c8586949e3aaf1aa5c53 :: blocked before merge. :: [P1] Define the upgrade path for existing clipboard providers
  • </details>

    </details>

    <!-- clawsweeper-verdict:needs-human item=835 sha=73e1c2fdedd5cda3c839d7b52462986f0a5c76bf confidence=high updated_at=2026-09-27T00:04:31Z reviewed_at=2026-09-27T00:06:24.983Z lease_owner=github-run-36281325741-1 lease_comment_id=5851122116 source_revision=21d164a46dcf2e81ead43c4abb983bf0b37f8800626079604a34930bf0578277 live_verification=absent -->
    <!-- clawsweeper-review-state:ready item=835 sha=73e1c2fdedd5cda3c839d7b52462986f0a5c76bf v=1 -->

    <!-- clawsweeper-review-version item=835 reviewed_at=2026-09-27T00:06:24.983Z sha=73e1c2fdedd5cda3c839d7b52462986f0a5c76bf source_revision=21d164a46dcf2e81ead43c4abb983bf0b37f8800626079604a34930bf0578277 lease_owner=github-run-36281325741-1 lease_comment_id=5851122116 v=1 -->

    <!-- clawsweeper-review item=835 -->

    cursor[bot] cursor[bot] commented on code on Sep 26, 2026 22:56 UTC
    Code Review
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardService.swift:1
    @@ -248,6 +248,89 @@ public final class ClipboardService: ClipboardServiceActionResultProviding {
             self.sizeLimit = sizeLimit
         }
     
    +    public func prepareTemporaryWrite() throws -> any ClipboardTemporaryWriteTransaction {
    +        let originalChangeCount = self.pasteboard.changeCount
    +        let items = try self.temporarySnapshotItems()
    +        guard self.pasteboard.changeCount == originalChangeCount else {
    +            throw ClipboardTemporaryWriteError.snapshotChanged
    +        }
    +        return OwnedClipboardTemporaryWriteTransaction(
    +            priorClipboardPresent: !items.isEmpty,
    +            originalChangeCount: originalChangeCount,
    +            access: ClipboardTemporaryWriteAccess(
    +                changeCount: { self.pasteboard.changeCount },
    +                write: { request, expectedChangeCount, didClaim in
    +                    var didDispatch = false
    +                    return try self.set(
    +                        request,
    +                        didDispatch: &didDispatch,
    +                        expectedChangeCount: expectedChangeCount,
    +                        didClaim: didClaim)
    +                },
    +                restore: { expectedChangeCount in
    +                    try self.restoreTemporaryItems(
    +                        items,
    +                        expectedChangeCount: expectedChangeCount)
    +                }))
    +    }
    +
    +    private func temporarySnapshotItems() throws -> [[ClipboardRepresentation]] {
    +        guard let items = self.pasteboard.pasteboardItems else {
    +            throw ClipboardTemporaryWriteError.snapshotUnavailable
    +        }
    +        guard !items.isEmpty else {
    +            guard let types = self.pasteboard.types, types.isEmpty else {
    +                throw ClipboardTemporaryWriteError.snapshotUnavailable
    +            }
    +            return []
    +        }
    +        return try items.map { item in
    +            guard !item.types.isEmpty else {
    +                throw ClipboardTemporaryWriteError.snapshotUnavailable
    +            }
    +            return try item.types.map { type in
    +                guard let data = item.data(forType: type) else {
    +                    throw ClipboardTemporaryWriteError.snapshotUnavailable
    +                }
    +                return ClipboardRepresentation(utiIdentifier: type.rawValue, data: data)
    +            }
    +        }
    +    }

    Snapshot refuses common clipboard types

    High Severity

    <!-- DESCRIPTION START -->
    temporarySnapshotItems throws snapshotUnavailable if any declared type returns nil data, so payload paste is refused whenever the current clipboard has promised, converted, or marker types. The existing snapshotRepresentations path already skips those unreadables and still saves the readable items. Finder files, Safari/Chrome copies, and transient markers commonly include such types, so peekaboo paste "text" can fail before writing even though a complete readable snapshot was available.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: c09449d0-fee0-4364-ac62-f74faa484941 -->

    <!-- LOCATIONS START
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardService.swift#L276-L298
    LOCATIONS END -->
    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmY5ZGQwYTA4LWUyZDMtNDZlNy1iNzcxLTc1Y2E5NzJkZjM2NSIsImVuY3J5cHRpb25LZXkiOiJ0TUtOaGRsb095d1VSNW1ya2MtRjNFSERHMnJKMW9EZExPU2tfdmw2MEJrIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmY5ZGQwYTA4LWUyZDMtNDZlNy1iNzcxLTc1Y2E5NzJkZjM2NSIsImVuY3J5cHRpb25LZXkiOiJ0TUtOaGRsb095d1VSNW1ya2MtRjNFSERHMnJKMW9EZExPU2tfdmw2MEJrIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByTnVtYmVyIjo4MzUsImNvbW1pdFNoYSI6IjY5OTg2NjMyNDg1MDNiYzU2ZTU5Yzg1ODY5NDllM2FhZjFhYTVjNTMiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>

    <sup>Reviewed by Cursor Bugbot for commit 6998663248503bc56e59c8586949e3aaf1aa5c53. Configure here.</sup>

    cursor[bot] cursor[bot] commented on Sep 26, 2026 22:56 UTC
    Reviewer

    <!-- BUGBOT_REVIEW -->
    <!-- BUGBOT_REVIEW_STALE -->
    Stale Bugbot comment from a previous run.

    steipete steipete commented on Sep 26, 2026 23:17 UTC
    Author

    Maintainer decision: the ownership capability is an intentional compatibility boundary for automatic temporary-payload paste. A ClipboardServiceProtocol-only provider cannot prove it still owns the clipboard, so retaining the old unconditional restore fallback would retain the data-loss bug. The built-in ClipboardService supports the capability; the command documentation now includes forwarding/migration guidance for wrappers and the required transaction contract for custom backends. Plain background text, current-clipboard paste, and explicit manual clipboard commands retain their existing paths. Foreground authority does not bypass the ownership check.

    The unreadable-representation finding was checked against the SDK contract and real private pasteboards. Nil is not generically an empty marker: it can represent an unfulfilled promise or a stale item. Skipping it would silently discard a representation; synthesizing empty bytes would change it. The new native tests demonstrate successful lazy-data restoration, refusal of an unresolved promised representation without changing the original ownership/readable companion, and preservation of actual zero-length marker data. The deliberate completeness refusal is retained and documented. No unsafe skip/fallback was added.

    That inspection also identified a separate no-interruption requirement: programmatic General-clipboard reads can request permission on macOS 15.4+. The updated owner checks accessBehavior before snapshot access and requires alwaysAllow; default/ask/deny refuse, even for an empty General board or foreground paste. Named boards and manual commands are unchanged. Documentation explains the deliberate permission setup, older-OS availability, and check/read race limit. It does not promise that an application at default is already listed in Settings or automatically trigger an alert to create that entry.

    Final focused proof: 32 native/policy Kit cases, 96 Core/MCP tests, and 64 CLI tests passed. Permission refusal retains its canonical reason, zero mutation, safe retry, and zero input delivery in both adapters. Final scoped lint/format/docs and isolated review pass. Fresh hosted checks for 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf are required before merge; predecessor CI is not the landing gate.

    cursor[bot] cursor[bot] commented on code on Sep 26, 2026 23:22 UTC
    Code Review
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardService.swift:1
    @@ -248,6 +248,108 @@ public final class ClipboardService: ClipboardServiceActionResultProviding {
             self.sizeLimit = sizeLimit
         }
     
    +    public func prepareTemporaryWrite() throws -> any ClipboardTemporaryWriteTransaction {
    +        if #available(macOS 15.4, *) {
    +            try Self.requireTemporaryReadAccess(
    +                pasteboardName: self.pasteboard.name,
    +                accessBehavior: self.pasteboard.accessBehavior)
    +        }

    Permission check runs after focus

    Medium Severity

    <!-- DESCRIPTION START -->
    The new silent-read preflight only runs inside prepareTemporaryWrite, after CLI/MCP foreground focus. On macOS 15.4+ the common default policy now refuses with permission_denied after the user's focused app has already changed, even though that refusal claims no clipboard mutation and is treated as retry-safe.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: fec05d94-fd36-4d1e-9a3c-ac1ffd2fc998 -->

    <!-- LOCATIONS START
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardService.swift#L250-L256
    Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift#L110-L238
    Core/PeekabooCore/Sources/PeekabooAgentRuntime/MCP/Tools/PasteTool.swift#L201-L555
    LOCATIONS END -->
    <details>
    <summary>Additional Locations (2)</summary>

  • Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift#L110-L238

  • Core/PeekabooCore/Sources/PeekabooAgentRuntime/MCP/Tools/PasteTool.swift#L201-L555
  • </details>

    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmU0NjhkY2ZjLTY1NGMtNDBjNS04OTk4LTA0NzUyNGVhOTZmMCIsImVuY3J5cHRpb25LZXkiOiJ5ZnRWYURlQUxjMkNJVWp3SWw3cEhybmQ3eHMzckpTUmlPdzJHTVVpZ1NZIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmU0NjhkY2ZjLTY1NGMtNDBjNS04OTk4LTA0NzUyNGVhOTZmMCIsImVuY3J5cHRpb25LZXkiOiJ5ZnRWYURlQUxjMkNJVWp3SWw3cEhybmQ3eHMzckpTUmlPdzJHTVVpZ1NZIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByTnVtYmVyIjo4MzUsImNvbW1pdFNoYSI6IjczZTFjMmZkZWRkNWNkYTNjODM5ZDdiNTI0NjI5ODZmMGE1Yzc2YmYiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>

    <sup>Reviewed by Cursor Bugbot for commit 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Configure here.</sup>

    cursor[bot] cursor[bot] commented on Sep 26, 2026 23:22 UTC
    Reviewer

    <!-- BUGBOT_REVIEW -->
    Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

    <!-- BUGBOT_FIX_ALL -->
    <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTo3Y2FmODM2Ny1mMDhhLTRhZjItOWQzZS1jOWY2MWExYTE4OGQiLCJlbmNyeXB0aW9uS2V5IjoiT1E0eURWT25sSEhqNDRzM2w3eldUY2hHel8wU0daTE1XQUxFekhZMHRJQSIsImJyYW5jaCI6ImNvZGV4L2NsaXBib2FyZC1vd25lcnNoaXAiLCJyZXBvT3duZXIiOiJvcGVuY2xhdyIsInJlcG9OYW1lIjoiUGVla2Fib28iLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
    <!-- /BUGBOT_FIX_ALL -->

    <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
    <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.</sup>
    <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->

    <sup>Reviewed by Cursor Bugbot for commit 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Configure here.</sup>

    steipete steipete commented on code on Sep 26, 2026 23:35 UTC
    Code Review
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardService.swift:1
    @@ -248,6 +248,108 @@ public final class ClipboardService: ClipboardServiceActionResultProviding {
             self.sizeLimit = sizeLimit
         }
     
    +    public func prepareTemporaryWrite() throws -> any ClipboardTemporaryWriteTransaction {
    +        if #available(macOS 15.4, *) {
    +            try Self.requireTemporaryReadAccess(
    +                pasteboardName: self.pasteboard.name,
    +                accessBehavior: self.pasteboard.accessBehavior)
    +        }

    The ordering observation is correct for explicitly requested foreground setup, but the claimed retry-safe final result is not. The new permission test uses a background fixture; its zero-mutation/retry-safe expectation does not describe the foreground path.

    On this head, CLI focus is recorded before preparation, and every transaction error passes through preservingPasteSequence / CommandActionSequenceAccumulator.preservingFailure. Prior dispatched focus plus a permission refusal is composed into an indeterminate, retry-unsafe result with the focus count/receipt retained. The observation-invalidation guard also checks that prior dispatch before allowing no-effect cleanup. See the CLI composition and the shared accumulator.

    MCP likewise keeps setupFocusResult, composes the preparation failure through preservingFailure, and makes the canonical aggregate authoritative when projecting metadata. It does not return the raw retry-safe permission leaf after dispatched focus. MCP composition.

    Earlier permission checking before an explicitly authorized foreground focus is a possible UX improvement, not the reported lost-effect/retry-safety defect. Default background calls do not perform that focus. Existing shared accumulator and paste composition tests cover retention of prior focus; no additional capability API or unconditional failure rewrite is justified here. A targetless foreground request or confirmed no-change focus can correctly remain retry-safe because there was no preceding mutation.

    steipete steipete commented on Sep 27, 2026 00:22 UTC
    Author

    Landed as f86135fda2da36428c4959a1f3c78901414c4c76. Its tree exactly matches reviewed candidate 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf; main is synchronized. This closes the owned PR queue, not the broader computer-use parity goal.

    Final focused proof ran actual builds through the checkout-local workspace wrapper with ambient/live/input automation disabled: swift test --package-path Core/PeekabooAutomationKit for the clipboard temporary-write/write-request suites (32 XCTest cases); swift test --package-path Core/PeekabooCore for the six clipboard, paste, target, and outcome suite selectors (96 tests); and swift test --package-path Apps/CLI -Xswiftc -DPEEKABOO_SKIP_AUTOMATION for the six paste/clipboard/admission selectors (64 tests). All used locked resolution, two build jobs, and serial execution. The native cases use unique private pasteboards; no test drops unresolved representations. Final scoped format/lint, 28 docs/guidance tests, and isolated review passed.

    Every final-head product workflow passed on attempt 1: macOS, supplemental/full-safe, and CodeQL. No final-head workflow retry was needed. Both inline review questions are resolved with the documented compatibility decision and existing foreground-effect composition. The separate automated reviewer did not publish a fresh final-head verdict; that is not represented as a clean review. The required isolated review covered the final candidate.

    One actual signed CLI/native check used this candidate with compatible GUI source 316bbccd. It sent exactly one background RTF paste to a freshly observed visible test field. The result correctly remained dispatched-unverified and retry-unsafe; no insertion was observed, so this was not a successful end-to-end paste. Clipboard cleanup reported restored, and independent aggregate fingerprints matched before/after. A source-blind audit retained the delivery failure and stricter evidence limits around full ordered fingerprint coverage/generation fencing; no clipboard corruption was observed. Accepted fixture values and the Controls tab were preserved, and the private recovery snapshot was removed. Bounded activation observers are not keyboard/cursor isolation proof. No release, installation, or independent-engine parity is implied.

    Reviewers
    Assignees
    steipete steipete
    Labels
    risk: low confidence: 78.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 85.5% (HIGH) · Higher = larger blast radius
    85.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 78.8% · Lower = rushed or shallow review
    78.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.1% · Safe to merge
    18.1%