Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Related: #32801 (the PR this applies to), #32034, #34204, #34186. This concerns code that exists only in #32801, so main is unaffected until that PR merges.
Area
apps/server
Steps to reproduce
With #32801, a streamed (server-runtime) Browser tab offers the text a site's own Copy button copies. If the click on that button reaches the page within a few milliseconds of a copy key (Cmd+C or Ctrl+C), the offer never appears.
The page-side recorder marks a copy key as in progress and clears that mark with a zero-delay timer. A click that the page handles before that timer runs is treated as part of the key.
Code on the PR head @ d09d9cc:
ServerBrowser.tsL505-L507:keying = true, thensetTimeout(() => { keying = false; }).ServerBrowser.tsL550: awriteTextreport is kept only when!keying, so it is dropped.ServerBrowser.tsL537: acopyevent whilekeyingis recorded onto the latest key entry, so anexecCommand("copy")button overwrites the key's text.
To reproduce in real Chromium, add a case of this shape to apps/server/src/preview/ServerBrowser.copies.test.ts (its page already has #write, #exec and #text). It sends the key, the press and the release one after another, each awaited, as the server does:
const box = (await page.locator("#write").boundingBox())!;
const at = { x: box.x + box.width / 2, y: box.y + box.height / 2, button: "left" as const, clickCount: 1 };
await page.locator("#text").selectText();
await cdp.send("Input.dispatchKeyEvent", { type: "rawKeyDown", key: "c", code: "KeyC", modifiers: 4, commands: ["copy"] });
await cdp.send("Input.dispatchMouseEvent", { type: "mousePressed", buttons: 1, ...at });
await cdp.send("Input.dispatchMouseEvent", { type: "mouseReleased", buttons: 0, ...at });
await page.locator("body[data-written=yes]").waitFor();
expect(await takeCopy(false)).toBe("selected");
expect(await takeCopy(true)).toBe("written"); // fails with ""Expected behavior
The copy key copies the selection, and the click on the site's Copy button produces its own "<host> wants to copy text" offer, however close together the two arrive.
Actual behavior
I ran that sequence against the recorder in headless Chromium, with a fresh context per run and a pause of the stated length between the key and the press.
| Site button | Page | Gap between key and click | Offers lost |
|---|---|---|---|
navigator.clipboard.writeText |
idle | 0 ms | 34 of 40 |
navigator.clipboard.writeText |
idle | 5 ms | 0 of 20 |
navigator.clipboard.writeText |
idle | 20 ms | 0 of 20 |
navigator.clipboard.writeText |
idle | 100 ms | 0 of 20 |
navigator.clipboard.writeText |
main thread runs 150 ms CPU slices | 0 ms | 1 of 20 |
navigator.clipboard.writeText |
main thread runs 150 ms CPU slices | 100 ms | 0 of 20 |
execCommand("copy") |
idle | 0 ms | 8 of 10 |
execCommand("copy") |
idle | 20 ms | 0 of 5 |
The key's own copy was read correctly in every writeText run.
In the 8 lost execCommand runs the recorder also held the button's text ("executed") as the key's copy in place of the selection ("selected"). I read the key's copy after the click in those runs. The server reads it straight after the key, so it would normally get the selection first. A frame that is slow to answer that read would let the click land before it. I have not driven that through the server end to end.
The no-mistakes live test on #32801 saw the lost offer once in the real app: Ctrl+C followed at once by a site Copy click while an embedded frame did CPU work. The key's clipboard message arrived, the site finished its write, and no copyOffer arrived within the 5 second window. Its second round repeated the sequence 10 times without a miss.
The viewer's clipboard still changes only on their copy key or on their choice of Copy in an offer. A page can already choose what a copy key copies through its own copy handler, so the execCommand case gives a page no new ability. The viewer gets the button's text where they expected their selection.
Impact
Minor bug or occasional failure
A person cannot click within 5 ms of a copy key on an idle page, so this mostly reaches automation and pages whose main thread stays busy from the key until the click. When it happens, clicking the site's Copy button again produces the offer.
Version or commit
Environment
macOS (Darwin 27), Node 26.12.1, headless Chromium from the repo's playwright-core.
Logs or stack traces
No response
Screenshots, recordings, or supporting files
No response
Workaround
Click the site's Copy button again.
One possible direction for a fix: end the key's window at the next trusted pointer press, so a click always starts its own copy, and give that its own case in ServerBrowser.copies.test.ts.
Written by Claude Fable 5.2 using Claude Code in T3 Code.
Activity
juliusmarminge commentedon Nov 14, 2026
I tried to reproduce this on the current build and could not.
Did not run the app: the behaviour is in code that exists only in open, unmerged PR #32801 (head d09d9cc). On origin/main 3b816cf, apps/server/src/preview/ has no site-copy offer at all (no copyOffer, no navigator.clipboard.writeText recording, no ServerBrowser.copies.test.ts), so the lost offer cannot occur there. Main's CLIPBOARD_SCRIPT (ServerBrowser.ts ~L483-525) has the same key window the PR builds on (keying=true, cleared by a zero-delay setTimeout). The reporter's secondary execCommand overwrite could reach main's key copy only if a click lands before the server's takeCopy read, which the reporter did not drive end to end. Since nothing failed on main, no failing test was written. The reporter's real-Chromium repro (the CDP key, press and release sequence in ServerBrowser.copies.test.ts on the PR head) is the right check to run against #32801.
Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.