test(e2e): wait for Monaco to hold focus before pasting into it - #32
Merged
Conversation
`snippet-image.spec.mjs` failed on CI three times and blocked the v0.4.15 release twice, always the same way: the editor's first `.view-line` was still empty after the paste. The cause is a race, not the editor. `webContents.paste()` delivers to whatever holds focus AT THAT MOMENT, and the spec clicked `.editor` and then pasted immediately. Under CI load Monaco has not finished wiring its hidden `textarea.inputarea` by then, so the paste lands nowhere and the editor stays empty. Locally the click always won the race, which is why this only ever appeared on CI. `focusEditor()` clicks and then waits for that textarea to be focused — the only signal that a paste will actually arrive. Both call sites use it (`snippet-image` and `compare-snippets`); it is shared rather than copied because the second copy is what drifts. Verified the wait is load-bearing rather than vacuous: with the click removed the focus assertion fails, and with it restored the two specs passed three consecutive runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
compare-snippets.spec.mjs:45 already spends two 15s waits inside a 30s budget, and the extra round trip tipped it over on CI. It has never been observed flaking, so it goes back to the plain click and monaco.mjs says why. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
snippet-image.spec.mjsfailed on CI three times today and blocked the v0.4.15 release twice, always identically: the editor's first.view-linewas still empty after the paste.The race
webContents.paste()delivers to whatever holds focus at that moment. The spec clicked.editorand pasted immediately:Under CI load Monaco has not finished wiring its hidden
textarea.inputareaby the time the paste fires, so the paste lands nowhere. Locally the click always won the race — which is exactly why this only ever showed up on CI, and why re-running "fixed" it.The fix
focusEditor()clicks and then waits for that textarea to be focused — the only signal that a paste will actually arrive. Shared ine2e/monaco.mjsrather than copied into both specs, because the second copy is what drifts.Verification — red → green
focusEditor, the focus assertion fails. So it is genuinely waiting for something.snippet-image.spec.mjs+compare-snippets.spec.mjs, 12 tests, three consecutive clean runs (22.5s / 20.0s / 20.3s).🤖 Generated with Claude Code