Skip to content

fix(emulator): settle gestures when the peer closes after the final point - #35329

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/emulator-gesture-close-settlement
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/emulator-gesture-close-settlement

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2

ELI5

If the simulator's gesture socket closes just after the final point is sent, report the interrupted sequence instead of leaving the caller waiting forever.

What Changed

Every socket close that happens before the gesture settles now rejects it. Previously, the close handler rejected only while index < points.length. After the final point, a peer close canceled the only remaining completion timer and skipped rejection, so the promise could never settle.

The completion timer now calls resolve() before ws.close(). This is defensive ordering only: ws never emits 'close' synchronously from the OPEN state, so the old order would also have resolved first. Point encoding, 16 ms pacing and the existing 50 ms completion grace are unchanged.

Why

The production route is emulator.gesture through the bridge and iOS backend to this socket helper. A disappearing or restarting simulator peer could leave that operation pending after its stream had already closed.

Trade-off

If the peer closes during the 50 ms grace after the final frame, the caller now gets Emulator gesture stream closed before sequence completion, even though the simulator may already have applied the gesture. The success path never confirms delivery either, so rejecting is the conservative choice, and it is strictly better than hanging indefinitely.

Visual Proof

N/A. This changes socket lifecycle and promise settlement; nothing presentational changed. A real loopback peer receives the final point, then closes the connection to reproduce the failure.

Testing

  • Before: the new real-socket regression stays pending until the 30-second test timeout, while the existing complete-gesture test passes.
  • After: rebased onto current main. 18/18 tests pass across emulator-gesture-sender.test.ts and ios-emulator-backend.test.ts.
  • ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: all 21 checks passed.
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/emulator/emulator-gesture-sender.test.ts src/main/emulator/backends/ios-emulator-backend.test.ts --maxWorkers=2
ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2

Review

No new timers, clients, dependencies or protocol fields. Normal completion latency is unchanged.

Only Linux loopback sockets were exercised. No physical simulator, macOS/iOS integration or Electron UI was run. Android uses its own gesture path. Remote protocol and workspace identity are unaffected. The helper still has no connection-establishment deadline; that predates this PR and is out of scope.

Agent skill upstream boundary

  • This change copies or mechanically translates no upstream skill-installer material.

@OrcaWin
OrcaWin force-pushed the OrcaWin/emulator-gesture-close-settlement branch from 9e710ca to c88231d Compare October 28, 2026 22:31
@OrcaWin
OrcaWin marked this pull request as ready for review October 28, 2026 23:15
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f28641d0-1bd9-4c28-b5fe-1a5ceefb3a1e
Commits

Reviewing files that changed from the base of the PR and between 79dbada and 05f1827.

Files selected for processing: 2
  • src/main/emulator/emulator-gesture-sender.test.ts
  • src/main/emulator/emulator-gesture-sender.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR rejects interrupted gestures when the peer closes after the final point, instead of leaving callers waiting.

  • iOS gestures reject when their socket closes before completion.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Send gesture points] --> B[Wait through completion grace]
  B -->|Timer fires| C[Resolve promise]
  C --> D[Close socket]
  B -->|Peer closes first| E[Clear timer]
  E --> F[Reject promise]
Loading

Reviews (2) · Last reviewed commit: "fix(emulator): settle gestures when the ..." · Reviewed by Greptile

@OrcaWin
OrcaWin force-pushed the OrcaWin/emulator-gesture-close-settlement branch from c88231d to 05f1827 Compare October 28, 2026 23:49
@OrcaWin
OrcaWin merged commit 34643c3 into main Oct 29, 2026
57 of 59 checks passed
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