Repository navigation
Conversation
Desktop's screenshot-streamed remote browser spent four serialized RPCs per click (mouseMove+mouseDown on pointerdown, mouseMove+mouseUp on pointerup). Mobile already prefers the atomic browser.mouseClick, which dispatches CDP Input.dispatchMouseEvent directly instead of spawning agent-browser and cannot visibly hover between press and release. Desktop now holds the press until the release proves the pair is a plain click (same page/environment, same button, no modifier, movement within jitter slop) and sends one mouseClick; drags, modified clicks, and hosts that answer method_not_found still use the move/down/(move)/up chain, and the unsupported answer is remembered per environment so old hosts are not re-probed per click. Wire: browser.mouseClick is an existing host method (already used by mobile), so no new RPC, opcode, or published content. New client / old host is covered by the method_not_found fallback; old client / new host is unchanged. Right-click (context-menu eval), wheel, keyboard, and the client-hosted webview pane are untouched. A cancelled press now sends nothing instead of leaving the remote button pressed.
A second mouse button pressed before the first release would otherwise replay mouseDown(press button) + mouseUp(release button) and strand the first button down on the remote page. Middle click keeps the atomic path.
📝 WalkthroughWalkthroughRemote browser input now tracks pointer presses and classifies simple clicks by target, button, modifiers, page, environment, and movement. Valid releases use atomic 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 23249ccc-6285-40b6-a4a6-08c03cf6a8af
📒 Files selected for processing (8)
src/renderer/src/components/browser-pane/stream-remote/remote-browser-click-dispatch.tssrc/renderer/src/components/browser-pane/stream-remote/remote-browser-page-input-model.test.tssrc/renderer/src/components/browser-pane/stream-remote/remote-browser-page-input-model.tssrc/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.tsxsrc/renderer/src/components/browser-pane/stream-remote/remote-browser-page-viewport.tsxsrc/renderer/src/components/browser-pane/stream-remote/remote-browser-stream-errors.tssrc/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tssrc/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| const pendingPressRef = useRef<RemoteBrowserPressState | null>(null) | ||
| // Hosts predating browser.mouseClick answer method_not_found; remember per environment so the | ||
| // legacy chain is not re-probed on every click. | ||
| const mouseClickUnsupportedEnvironmentRef = useRef<string | null>(null) |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Cache unsupported status for every environment.
The ref stores one environment ID. If two environments return method_not_found, the second ID replaces the first. Returning to the first environment then probes browser.mouseClick again.
Use useRef(new Set<string>()). Check has(target.environmentId) and add the environment after method_not_found. Add a test that alternates between two unsupported environments.
Also applies to: 224-228
| const handleRemotePointerDown = (event: React.PointerEvent<HTMLImageElement>): void => { | ||
| if (busy) { | ||
| return | ||
| } | ||
| const target = runtimeTarget() | ||
| const pageId = lifecycle.tokens.remotePage | ||
| const image = imageRef.current | ||
| const operationToken = pageId ? createRemoteOperationToken(pageId) : null | ||
| const point = getRemoteImagePoint(event) | ||
| const button = getRemoteBrowserMouseButton(event.button) | ||
| if (button === 'right') { | ||
| return | ||
| } | ||
| if (!target || !pageId || !image || !operationToken || !point || !button) { | ||
| if (!target || !pageId || !image || !point || !button) { | ||
| return | ||
| } | ||
| event.preventDefault() | ||
| image.focus() | ||
| setPaneNotice(null) | ||
| enqueueRemoteInput(async () => { | ||
| if (!isCurrentRemoteOperationToken(operationToken)) { | ||
| return | ||
| } | ||
| try { | ||
| const params = { worktree: runtimeWorktree, page: pageId } | ||
| await callRuntimeRpc( | ||
| target, | ||
| 'browser.mouseMove', | ||
| { ...params, x: point.x, y: point.y }, | ||
| { timeoutMs: 15_000, suppressFeatureInteraction: true } | ||
| ) | ||
| await callRuntimeRpc( | ||
| target, | ||
| 'browser.mouseDown', | ||
| { ...params, button }, | ||
| { timeoutMs: 15_000, suppressFeatureInteraction: true } | ||
| ) | ||
| } catch (error) { | ||
| if (isCurrentRemoteOperationToken(operationToken)) { | ||
| if (isRemoteBrowserPageMissingError(error)) { | ||
| closeMissingRemotePage(pageId) | ||
| return | ||
| } | ||
| setPaneNotice({ | ||
| kind: 'consequence', | ||
| text: error instanceof Error ? error.message : 'Remote mouse input failed.' | ||
| }) | ||
| } | ||
| } | ||
| }) | ||
| pendingPressRef.current = { | ||
| environmentId: target.environmentId, | ||
| pageId, | ||
| button, | ||
| point, | ||
| modified: hasRemoteBrowserClickModifier(event) | ||
| } | ||
| } | ||
|
|
||
| const handleRemotePointerCancel = (): void => { | ||
| pendingPressRef.current = null | ||
| } | ||
|
|
||
| const handleRemotePointerUp = (event: React.PointerEvent<HTMLImageElement>): void => { | ||
| const press = pendingPressRef.current | ||
| pendingPressRef.current = null |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -C 4 'onPointerDown|onPointerUp|onPointerCancel|setPointerCapture|releasePointerCapture' \
src/renderer/src/components/browser-pane/stream-remoteRepository: stablyai/orca
Length of output: 2720
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
file="src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.ts"
wc -l "$file"
sed -n '1,280p' "$file"
printf '\n--- related tests and usages ---\n'
rg -n -C 5 'useRemoteBrowserPageInput|handleRemotePointer|pendingPressRef|remote-browser-page-viewport' \
src/renderer/src --glob '*.{ts,tsx}'Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
test_file="src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.ts"
viewport_file="src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-viewport.tsx"
sed -n '1,225p' "$test_file"
printf '\n--- viewport event wiring ---\n'
sed -n '90,120p' "$viewport_file"
printf '\n--- pointer identifiers and capture usage ---\n'
rg -n -C 3 'pointerId|setPointerCapture|releasePointerCapture|pendingPressRef' \
src/renderer/src/components/browser-pane/stream-remote \
--glob '*.{ts,tsx}'Repository: stablyai/orca
Length of output: 11476
🌐 Web query:
Pointer Events specification pointer capture pointerup outside element implicit capture mouse pointerdown
💡 Result:
In the Pointer Events specification, pointer capture is a mechanism that allows all subsequent events for a specific pointer to be retargeted to a single element, regardless of the pointer's actual location [1][2]. Implicit pointer capture is a specific behavior primarily associated with direct manipulation devices (such as touchscreens) [1][3]. When a pointerdown event is dispatched on an element from a direct manipulation device, the user agent automatically sets pointer capture for that pointer to the target element [1][4]. This ensures the element continues to receive events (such as pointermove or pointerup) even if the pointer moves outside the element's boundaries during the interaction [1][2]. Key behaviors regarding this process include: 1. Target Consistency: While pointer capture is active, the capturing element serves as the target for all events associated with that pointer [1][5]. Normal hit testing is bypassed, and the events are dispatched as if the pointer is always over the capturing element [1][3]. 2. Suppression of Boundary Events: Because the pointer is considered to be over the capturing element for the duration of the capture, events like pointerover, pointerenter, pointerleave, and pointerout do not fire while capture is held [2][4]. 3. Release of Capture: Pointer capture is released automatically by the user agent when a pointerup or pointercancel event occurs [2][4]. It can also be released manually by calling the element.releasePointerCapture(pointerId) method [1][2]. When capture is released, the user agent dispatches a lostpointercapture event to the element that previously held the capture, and subsequent events return to using normal hit testing mechanisms [5][6]. While implicit capture is standard for direct manipulation devices (like touch), it does not apply to mouse input in the same way; for a mouse, pointer capture is typically only set explicitly by the developer via the element.setPointerCapture(pointerId) method [1][2][4].
Citations:
- 1: https://www.w3.org/TR/pointerevents3/
- 2: https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events
- 3: https://www.w3.org/TR/2026/REC-pointerevents3-20260630/
- 4: https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerdown_event
- 5: https://www.w3.org/submissions/pointer-events/
- 6: https://www.w3.org/TR/2025/CRD-pointerevents3-20250501/
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
from dataclasses import dataclass
`@dataclass`
class Event:
kind: str
hit_target: str
pointer_id: int = 1
def dispatch(event, capture):
return capture.get(event.pointer_id, event.hit_target)
def current_handler_sequence(capture_enabled):
pending = False
capture = {}
delivered = []
down = Event("pointerdown", "image")
if dispatch(down, capture) == "image":
pending = True
if capture_enabled:
capture[down.pointer_id] = "image"
# A mouse release outside the image is not delivered without capture.
up_outside = Event("pointerup", "outside")
target = dispatch(up_outside, capture)
if target == "image":
delivered.append("pointerup")
pending = False
capture.pop(up_outside.pointer_id, None)
# A later pointerup over the image can consume the stale press.
later_up = Event("pointerup", "image")
target = dispatch(later_up, capture)
stale_press_consumed = pending and target == "image"
return stale_press_consumed, delivered, capture
without_capture = current_handler_sequence(False)
with_capture = current_handler_sequence(True)
assert without_capture[0] is True
assert with_capture[0] is False
assert with_capture[1] == ["pointerup"]
print("without capture: stale press is consumed by a later image pointerup")
print("with capture: outside pointerup reaches the image and clears the press")
PYRepository: stablyai/orca
Length of output: 290
Capture the pointer when recording the press. Call event.currentTarget.setPointerCapture(event.pointerId) after validation and release it during pointer-up cleanup. Otherwise, a mouse release outside the image leaves pendingPressRef set, and a later image release can dispatch the stale press. Add a regression test for release outside the frame.
The host's browser.mouseClick dispatches Input.dispatchMouseEvent mousePressed + mouseReleased and nothing else, so the atomic path applied no :hover before the press hit-test. On a page that reveals or reflows a control on hover, mousedown and mouseup then resolve to different elements and Chromium dispatches click on their common ancestor, so the control never fires. The removed 4-RPC chain always moved first, which is why this only regressed with the atomic path. Fix client-side rather than in the host handler: mouseClick has shipped since 2026-05, so a current client talks to hosts that will never gain a host-side move. Still 2 round trips instead of 4, on the same serialized input queue. Also reuses the hold/release halves of the legacy chain as named helpers.
…ease pointerdown only recorded state, so the remote page saw nothing until release and then a press whose duration was ~0ms. Long-press affordances (context menus in web apps, hold-to-repeat spinner/scroll arrows, drag-start handles) never fired, and no :active feedback ever reached the screencast during a hold. A press still held after 350ms now dispatches the legacy mouseMove+mouseDown; the release only lifts the button. Quick presses keep the atomic click path. Every way a hold can end without a usable release now lifts the button too: pointercancel, an incoherent or busy release, a pane identity change (routed through the same lifecycle reset that clears the pending wheel), and unmount. The hold is skipped outright if the page/environment moved on while it was armed. The press state machine moves to use-remote-browser-page-press.ts; the input hook keeps the queue, the image-point mapping, and the keyboard path.
A press whose release never reached the <img> stayed in the ref indefinitely, and the coherence check only compared environment/page/button against the current target — so an unrelated later pointerup over the frame passed it and was replayed as mouseMove(old point) + down + move + up: a drag on the remote page the user never made, at coordinates the page may have scrolled away from. Four bounds, in order of who catches what: - setPointerCapture on the press, so a release outside the frame arrives at all (this also fixes drags that end just past the pane edge); - pointerleave and blur on the image end the gesture when capture was refused; - the pointer id must match on release, for touch/pen where ids differ; - an undispatched press older than 5s is stale and is never replayed. A press dropped by any of these still lifts the remote button if the hold already put it down.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/browser-pane/stream-remote/remote-browser-click-dispatch.ts (1)
63-64: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winConsider releasing the button when the fallback release fails.
sendRemoteBrowserPressHoldputs the remote button down. IfsendRemoteBrowserHeldReleasethen rejects, no furtherbrowser.mouseUpis sent for that press. The callerhandleRemotePointerUponly reports the error, so the remote button stays down and blocks later interaction on the page.Add one best-effort retry of
browser.mouseUpwhen the release fails, then rethrow the original error.♻️ Proposed guard for a stranded remote button
await sendRemoteBrowserPressHold({ target, params, press }) - await sendRemoteBrowserHeldRelease({ target, params, press, release }) + try { + await sendRemoteBrowserHeldRelease({ target, params, press, release }) + } catch (error) { + // The button is down remotely; one retry keeps a failed release from stranding it. + await callRuntimeRpc( + target, + 'browser.mouseUp', + { ...params, button: release.button }, + CALL_OPTIONS + ).catch(() => {}) + throw error + } }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6978f840-9f40-4fdb-8081-99469fae86d3
📒 Files selected for processing (7)
src/renderer/src/components/browser-pane/stream-remote/remote-browser-click-dispatch.tssrc/renderer/src/components/browser-pane/stream-remote/remote-browser-page-input-model.tssrc/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.tsxsrc/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tssrc/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.tssrc/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-lifecycle.tssrc/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-press.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Closing: since client-hosted pages took over, this legacy server-hosted path is narrow, and losing press-and-hold feedback is a behaviour change. |
Adopts the atomic
browser.mouseClickRPC on the desktop's legacy screenshot-streamed remote-browser pane, replacing the four serialized RPCs previously issued per click (mouseMove+mouseDown on pointerdown, mouseMove+mouseUp on pointerup). Mirrors the decision logic mobile already uses, with amethod_not_foundfallback to the legacy chain cached per environment for old hosts.Also fixes two press-lifecycle hazards: a cancelled/incoherent press no longer strands a pressed button on the remote page, and clicks whose press/release buttons differ are dropped.
Notes:
stream-remote/pane layout, which the stack's lineage predates.browser.mouseClickis a pre-existing host method already used by mobile clients.stream-remote/pass including new click-vs-drag decision coverage (non-vacuity verified by forcing the atomic path off); typecheck and changed-code gates clean.setPointerCaptureon pointerdown would recover the drag and is left as a surgical follow-up.