fix(debug-controller): drop recorded actions when recording session ends - #42458
Conversation
The debug controller accumulates recorder actions in a closure and re-sends the full list in every `sourceChanged` event. The list was never cleared when recording was disabled, so a subsequent recording session on the same page leaked the previous session's actions: a late signal (dialog, navigation, popup) re-rendered a stale action as the last one, and clients that diff by count - like the VS Code extension's "Record at cursor" - inserted that stale action into the editor. Clear the accumulated actions when the recorder mode switches to 'none', so each session starts from a clean list. Fixes: microsoft#42218
| // Recording session has ended: drop the accumulated actions, so that the | ||
| // next session does not leak them into the emitted source (the client | ||
| // would re-insert the stale last action into the editor). | ||
| if (mode === 'none') |
There was a problem hiding this comment.
Shouldn't this include 'standby' as well?
There was a problem hiding this comment.
Good point, added — standby is what the toolbar's record toggle switches to when you pause, so it clears the list now as well.
One wrinkle: the protocol only accepts inspecting/recording/none, so the test drives the actual record button in the toolbar instead of calling setRecorderMode directly.
The firefox failure turned out to be my test's fault, not the fix — setContent is recorded as a goto('about:blank') there, so the second session was legitimately emitting one extra action. Switched that part to swapping innerHTML directly and it's green on both engines now.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…refox test Address review feedback: 'standby' (recorder toolbar pause) is a session end as well, so it clears the accumulated actions too. The firefox failure was a test expectation issue: setContent is recorded as a goto on firefox, so session 2 now avoids navigation; the standby path is covered through the real toolbar toggle since 'standby' is not settable via the protocol.
Test results for "tests 1"7 flaky51283 passed, 1241 skipped Merge workflow run. |
Test results for "MCP"1 failed 8304 passed, 1367 skipped Merge workflow run. |
|
Looks good, thank you for the PR. |
b34b234
into
microsoft:main
Add a regression test for the cross-session variant of the issue, fixed core-side in microsoft/playwright#42458. The test is skipped until the bundled @playwright/test includes that fix (1.63.0+). Also wait for the recorded action insert to fully settle (text present and selection spanning it) before simulating the user edit, so the mid-recording test does not race the extension's editor updates. Fixes: microsoft/playwright#42218
Summary
none, so the next recording session on the same page starts from a clean listAddresses the cross-session variant of #42218. The mid-recording variant is fixed on the extension side: microsoft/playwright-vscode#807
Related: #42461 keeps the browser open after stopping a debug session, extending the record-after-debug workflow (#37822).