microsoft / microsoft/playwright
[Bug]: Record at cursor inserts stale/previous action after editing test while recording (browser focus loss)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 96.3k
- Forks
- 6.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 180
Description
### Version
@playwright/test: 1.62.1, Playwright Test for VS Code extension: 1.1.19, macOS
### Steps to reproduce
1. Enable Show browser in the Playwright Testing sidebar.
2. Run a test so the browser is left open at a useful page state.
3. Place the cursor inside the test where new steps should be inserted.
4. Click Record at cursor.
5. Perform a few actions in the browser — they are inserted correctly at the cursor.
6. Switch focus to the editor and manually edit the test (e.g. tidy a locator, add a comment, delete a generated line, move the cursor).
7. Switch back to the browser without stopping recording.
8. Perform one more click/action in the browser.
### Expected behavior
Only the new action is appended at the current cursor position.
### Actual behavior
The new action is recorded, and an extra stale action is also inserted — typically the last (or penultimate) action from earlier in the same recording session, or sometimes from a previous recording session.
### Additional context
### Workaround
Stop recording before editing the file. After editing, click Record at cursor again and continue. That avoids the stale action, but significantly slows the record → tidy → continue workflow.
### Notes
If I stay entirely in the browser and never edit mid-recording, generation behaves correctly.
The failure is specifically tied to leaving the browser / editing the file while recording remains active, then resuming clicks.
This feels like the recorder’s internal action buffer / document rewrite getting out of sync with the editor buffer (similar class of issue to editing-while-recording problems discussed in #17771).
### Environment
```shell
@playwright/test: 1.62.1
Playwright VS Code extension: 1.1.19
IDE: Cursor (VS Code-compatible)
OS: macOS Darwin 25.x
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with Record at cursor: perform browser actions, edit the test in the editor, then resume recording. Trace the recorder and document-rewrite flow across the browser/editor focus transition, using the behavior described in #17771 as context. Done means resuming recording inserts only the new action at the current cursor position, with no stale action from the current or a previous session.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- playwright, typescript, vscode
- Domain
- developer-experience, devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100