Repository navigation
Avoid the clipboard when hidden Monaco models can be verified - #754
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Model discovery and operations cli/src/native/monaco_model*, scripts/monaco-model.test.js, .github/workflows/ci.yml |
Adds bounded CDP discovery and exact-editor matching. Native model reads and writes validate focus and readback. Tests cover matching, cleanup, and failure cases; CI now runs the helper tests. |
Fill and read integration cli/src/native/interaction.rs, cli/src/native/element.rs, cli/src/native/mod.rs, cli/src/output.rs, README*, docs/*, skill-data/core/references/commands.md |
fill tries native model access before clipboard fallback. Value reads use the same native access path before falling back to clipboard. Help and documentation describe these paths and their failure behavior. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant fill as fill
participant access as monaco_model::access
participant model as Monaco model
participant fallback as Clipboard fallback
fill->>access: Request native fill for target editor
access->>model: Focus, insert text, read and verify
alt Model found and verified
model-->>fill: Return verified value
else No usable model found before input
access-->>fill: Return no model
fill->>fallback: Use existing clipboard path
end
Possibly related issues
leeguooooo/chrome-use#747— Adds the requested clipboard-free Monaco path, but retains the clipboard fallback and its concurrency limitations.leeguooooo/chrome-use#745— Adds editor API detection for Monaco fill; the reported Ace editor case is not covered.
Suggested reviewers: leeguooooo
Merge Risk: 
Minimal · up to cd91d
-
The native Monaco path and its clipboard fallback have no established issue requiring a change before merge. Discovery failures remain visible errors rather than triggering another action.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title states the main change: fill and get value on Monaco editors avoid the shared clipboard when a hidden Monaco model API can be verified. The changeset matches this. It adds a CDP-based native input path, reads models directly, and keeps the clipboard only as a fallback.
Full details: Description check
-
Explanation
The description follows the required template. It explains the change and motivation, addresses stealth behavior and gating, lists comprehensive tests and environments, and confirms documentation updates. Changelog entries are explicitly deferred to release preparation, which is acceptable for this change.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 8 files. (8 skipped: 8 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
What and why
Hidden Monaco APIs currently send
fillandget valuethrough the shared system clipboard. This adds avoidable clipboard ownership and restoration risks when the editor's public model API is still retained in its handler module scopes.Resolve that API through bounded CDP descriptor inspection, match its editor to the exact DOM root, then use native select-all/insert-text and verify the same live model.
get valuereads the model directly. This path reportsengine: monaco-native, never accesses the Clipboard API, and refuses changed models, lost focus and mismatched readback without retrying through the clipboard.If discovery finds no usable API before input, the existing clipboard fallback remains. This is a measured mitigation for #747, not a claim of atomic clipboard restoration or compatibility with every Monaco bundle. Native clipboard formats, context loss and the fallback's separate compare/write operations retain their documented limitations. The existing global Monaco API path is unchanged.
Stealth mode
No added globals, DOM properties, attributes, styles, listeners or network requests. Discovery reads existing handler descriptors and skips global scopes; read-only public model access uses the existing rich-editor main-world exception. Private handles belong to a CDP object group released on ordinary exits. Input uses CDP and the existing per-process humanize cadence. There is no synthetic copy/paste or event fallback in the new path.
Tests
All execution uses disposable GitHub-hosted runners and fresh fixture profiles, retaining the Chrome sandbox for headed acceptance. No local browser, user clipboard or authenticated profile was used.
df898066. Additional hosted controls verified refusal after real model swaps, lost focus and rejected input, and preserved concurrent clipboard writes in both modes. The first additional run failed in fixture cleanup when it tried to restore an automatically disposed model. The corrected rerun passed all 36 checks, including all eight live focus/model/input/concurrent-write controls and all 24 fill/read cases. Tested combined sourcea04cb180, with production Monaco source matching this PR; binary SHA-2565dd2a48076101c8b0af657227b0eaee373b930a9d9d85ef3f5397b67a8388d8b. All upstream CI checks pass atcd91dd94. The same run reproduced the remaining fallback restore race: a real clipboard write between comparison and restoration is overwritten despite successful editor readback. This is evidence of the limitation, not a safety pass; the proposed residual contract remains open.Docs
Part of #747. Please retain that tracker for the residual clipboard/platform contract rather than treating this PR as resolving every limitation.