Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 3:44 PM ET / 19:44 UTC. ClawSweeper reviewWhat this changesThe PR makes Control UI’s legacy clipboard fallback retain its original document for deferred focus restoration and expands tests for teardown, focus replacement, and removed targets. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: current main still defers a callback that reads the global document after the copy fallback, while this branch binds that callback to the originating document and adds focused lifecycle coverage. The maintainer-owned PR should await exact-head CI and the normal owner merge decision. Priority: P3 Review scores
Verification
How this fits togetherControl UI copy controls call a shared clipboard helper, which uses the browser Clipboard API or a legacy execCommand fallback. The fallback briefly moves focus for selection, then restores it asynchronously without overwriting a newer user focus. flowchart LR
A[Control UI copy control] --> B[Shared clipboard helper]
B --> C{Clipboard API available}
C -->|yes| D[Browser clipboard write]
C -->|no or rejected| E[Legacy copy fallback]
E --> F[Deferred focus restoration]
F --> G[Original document state]
Decision needed
Why: The patch has no concrete correctness finding, but the protected maintainer label requires explicit maintainer handling and checks are still in progress. Before merge
Agent review detailsSecurityNone. PR surfaceSource +2, Tests +31. Total +33 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the direct owner-document capture in the shared helper; do not replace it with a callback catch, retry, or caller-specific teardown guard. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main’s delayed fallback callback reads the global document, so removing that global before timer execution produces the reported failure. This read-only review did not execute the test suite. Is this the best way to solve the issue? Yes. Capturing the textarea’s owner document moves the stale lookup to the object that owns the operation while preserving existing focus guards; catching the later error would mask the lifecycle defect. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f265c0dfb163. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
The exact two-file fix from this PR landed in #132878 as part of the combined Browser/clipboard integration repair. The combined head passed fresh hosted CI and all 101 focused owner/caller tests, with clean independent review; the original 21 clipboard tests, three real Chromium copy flows and native Vitest teardown reproduction also passed. Landed commit: 0dcbb90 Closing this PR as superseded after confirming that main contains both exact clipboard source/test blobs from e569965. This PR was not separately merged. |
What Problem This Solves
Resolves a problem where Control UI verification could finish every assertion successfully and then fail with an unhandled
ReferenceError: document is not definedduring environment teardown. This caused unnecessary reruns in release verification; this CI job passed all 4,093 assertions before failing in the clipboard callback.Why This Change Was Made
The shared clipboard fallback now retains the scratch textarea's owning document for deferred focus restoration. Vitest's JSDOM environment can remove the global document before the native timer fires; the callback must use its original owner. The zero-delay restoration, connected-target check, newer-focus protection, and
preventScrollbehavior remain intact. No retries, timeout changes, caller workarounds, or swallowed exceptions were added.User Impact
No intended visual or clipboard behavior change. Copy controls still restore focus after being re-enabled, preserve newly focused inputs, and ignore removed targets. Release verification no longer fails because this callback outlives its environment's global document.
Evidence
Reproduced on Node 24.20.0 with actual Vitest 4.1.11 JSDOM 29.1.1 setup, clipboard fallback, environment teardown, then native timer execution: baseline throws at
clipboard.ts:50; fixed code exits successfully.The added owner regression fails before the production change. The existing real-timer focus test now also covers newer focus and removed targets.
Final focused run covered
clipboard.test.ts, the originalchat-pane-task-suggestions.test.tscaller, and the three broader-suite failure files: all 53 assertions passed across five files.node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-flow.clipboard.e2e.test.ts -t 'message-copy failure|assistant code cannot be copied': all three selected Chromium checks passed against the bundled Control UI, including desktop/mobile copy feedback. No visual behavior changed.Changed-gate guards, dead-code checks, and i18n checks passed. Its first typecheck caught a cross-runtime timer-handle mock in the new regression; that mock was replaced with Vitest fake timers. The final core-test and UI typechecks, targeted Oxlint, Stylelint, formatting, and diff checks all passed. This is composed gate evidence, not an uninterrupted changed-gate pass.
The broader UI run passed 11,862 assertions and failed four 1-second lazy-module readiness assertions in
app-host-pairing-access.test.ts,lazy-shell-action.test.ts, andchat-tool-cards.highlight.test.ts, without a clipboard teardown exception. Those files pass in bounded runs on both the original helper and this fix. Full-suite ordering/load diagnosis is a separate follow-up; this PR does not weaken those assertions or claim the full suite is green.Production delta: +4/-2 (one document binding and its ownership comment); tests: +49/-18. The deferred global lookup is removed rather than guarded. Dependency source confirms Vitest teardown deletes populated globals while the native timer can remain pending. Codex autoreview completed with no findings. AI-assisted.