[codex] Fix preview automation edge cases#3561
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Straightforward bug fixes for preview automation edge cases: adds macOS editing command support for Chromium synthetic key events and optimizes overlay waiting logic for empty tabs. Changes are well-tested and self-contained. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
<!--⚠️ READ BEFORE OPENING⚠️ We are not actively accepting contributions right now. You can still open a PR, but please do so knowing there is a high chance we may close it without merging it, or never review it. - Small, focused PRs are strongly preferred. Bug fixes are most likely to be merged. - New features will most likely just annoy us. - 1,000+ line PRs with a bunch of new features will probably get you banned from the repo. --> ## What Changed <!-- Describe the change clearly and keep scope tight. --> ## Why <!-- Explain the problem being solved and why this approach is the right one. --> ## UI Changes <!-- If this PR changes UI, include clear before/after screenshots. If the change involves motion or interaction, include a short video. Delete this section if not applicable. --> ## Checklist - [ ] This PR is small and focused - [ ] I explained what changed and why - [ ] I included before/after screenshots for any UI changes - [ ] I included a video for animation/interaction changes
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Why
This is a focused follow-up to #3548 based on the final installed-build smoke test.
Two small automation edge cases remained:
preview_pressdelivered trustedMeta+Akeyboard events, but Chromium did not perform the native Select All editing action. Agents could emit the chord while the focused field remained unchanged.preview_opencould time out even though the tab had been created successfully.Root cause
Chromium's debugger input API does not infer macOS editing commands from synthetic Meta chords. Those commands must be attached explicitly to the key-down packet.
The preview automation host also treated every open operation as if it needed navigated guest content. URL-less idle sessions only need the tab and panel state; requiring the rendered overlay made their completion depend on unrelated webview initialization.
How
preview_openis opening or reusing an idle tab without a URL. Opens with a URL and tabs with existing content retain the existing readiness wait.Validation
vp test apps/desktop/src/preview/PreviewKeyboard.test.ts apps/desktop/src/preview/Manager.test.ts apps/web/src/components/preview/previewAutomationOpenReadiness.test.ts— 27 tests passedvp check— passedvp run typecheck— all 15 packages passedNote
Fix preview automation edge cases for macOS key events and overlay wait conditions
commandsfield toPreviewAutomationKeyEventand populates it with Chromium editing commands when running on macOS hosts, so Meta-chord shortcuts (e.g. Cmd+C) are handled correctly in the preview.Manager.tsand passesisMactomakePreviewAutomationKeySequenceso platform-specific key sequences are generated correctly.previewAutomationOpenNeedsOverlayinpreviewAutomationOpenReadiness.tsto conditionally skip waiting for the desktop overlay when opening a preview into an empty tab with no URL.openno longer unconditionally waits for the desktop overlay; it waits only when a URL is provided or the tab already has rendered content.Macroscope summarized 4ba8c96.
Note
Low Risk
Targeted preview automation behavior with regression tests; no auth, data, or broad API surface changes.
Overview
Fixes two preview automation edge cases: macOS Meta shortcuts not performing native editing actions, and
preview_opentiming out on URL-less idle tabs.On darwin,
makePreviewAutomationKeySequencenow attaches Chromium CDPcommands(select all, copy/cut/paste, undo/redo, line/document navigation, etc.) to synthetic Meta chords;PreviewManagerreadsHostProcessPlatformand passesisMacinto key dispatch. Non-macOS packets are unchanged.For
open, the web automation host only waits for the desktop webview overlay whenpreviewAutomationOpenNeedsOverlaysays so—i.e. when a URL is provided or the session is not idle. Reusing or creating an empty idle tab no longer blocks on overlay readiness.Reviewed by Cursor Bugbot for commit 4ba8c96. Bugbot is set up for automated code reviews on this repo. Configure here.