Skip to content

chore(recorder): unify double click handling, drop action timestamps#41732

Open
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:chore-recorder-dblclick
Open

chore(recorder): unify double click handling, drop action timestamps#41732
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:chore-recorder-dblclick

Conversation

@dgozman

@dgozman dgozman commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

This is a preparation for recorder public api.

Unified double click handling

RecordActionTool stalls a single click for 200ms and reports a double click from dblclick, so a clickCount: 1 action never reaches the server. JsonRecordActionTool (used by recorderMode: 'api') had no such handling — it recorded every click as it arrived, so a double click produced two actions and relied on the click branch of shouldMergeAction() to collapse them into one.

The Json tool now stalls clicks the same way, and that branch of shouldMergeAction() is gone.

Two consequences:

  • API-mode click actions are now delivered up to 200ms late. recorder-api.spec.ts assertions become expect.poll.
  • A triple click records as clickCount: 2 rather than 3, matching what the regular recorder has always produced.

Pending click is no longer swallowed

Both tools opened onClick with an unconditional _cancelPendingClickAction(), which discarded a stalled click whenever another click arrived. Two clicks less than 200ms apart, even on different elements, silently lost the first one. Rare for a human, but routine for page.click() driving the API recorder.

Both tools now commit the pending click when the new click is detail === 1 (a genuinely new click), and only cancel it when detail > 1 (part of a multi-click, which dblclick reports). The commit/cancel also moved above the checkbox branch, so a stalled click followed by a checkbox click no longer records the two out of order.

This lets should record expect signal drop the poll it used to need to avoid losing its first click.

Timestamps removed

No client reads them:

  • ActionInContext.endTime — written only, never read.
  • SignalInContext.timestamp — written only, never read.
  • ActionInContext.startTime — one consumer, the navigation-signal threshold, now RecorderSignalProcessor._lastActionTimestamp.

Recorder no longer imports monotonicTime at all.

JsonRecordActionTool recorded every click as it arrived, so a double click
produced two actions that shouldMergeAction() had to collapse. Give it the
same stalled-click handling RecordActionTool has, and drop the click branch
of shouldMergeAction().

While stalling a click, a following click cancelled the pending one instead
of committing it, silently swallowing the first click. Both tools now commit
the pending click when a new single click arrives, and only cancel it when
the click continues a multi-click, which 'dblclick' reports instead.

Also remove ActionInContext.startTime/endTime and SignalInContext.timestamp.
endTime and timestamp were never read; startTime had a single consumer, the
navigation signal threshold, which now lives in
RecorderSignalProcessor._lastActionTimestamp.
@dgozman dgozman force-pushed the chore-recorder-dblclick branch from 1529b37 to 9d801c4 Compare July 12, 2026 15:58
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [chromium] › mcp/annotate.spec.ts:447 › should switch screencast to -s session on show --annotate @mcp-macos-latest-chromium
❌ [firefox] › mcp/annotate.spec.ts:110 › should abort annotation when last screenshot is removed @mcp-macos-latest-firefox
❌ [firefox] › mcp/annotate.spec.ts:230 › should capture annotations via show --annotate @mcp-macos-latest-firefox

7757 passed, 1249 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

4 flaky ⚠️ [chromium-library] › library/video.spec.ts:717 › screencast › should work with video+trace `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/har-websocket.spec.ts:231 › should embed websocket messages `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/video.spec.ts:717 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/heap.spec.ts:223 › should not leak workers `@firefox-ubuntu-22.04-node20`

49544 passed, 1161 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant