fix(emulator): ignore external serve-sim helpers (#9071)

* fix(emulator): ignore external serve-sim helpers

Co-authored-by: Orca <help@stably.ai>

* docs(reliability): align backpressure evidence

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-07-16 14:44:55 -07:00
committed by GitHub
co-authored by Orca
parent fc6570da67
commit f102972cc1
7 changed files with 8 additions and 708 deletions
+1 -12
View File
@@ -7,7 +7,6 @@ import {
} from '../emulator/emulator-availability'
import { resolveDefaultAttachDevice } from '../emulator/emulator-default-attach-device'
import { setConfiguredAndroidSdkPath } from '../emulator/android/android-sdk-host-discovery'
import { serveSimStateWatcher } from '../emulator/serve-sim-state-watcher'
import type { EmulatorGesturePoint } from '../emulator/emulator-gesture-sender'
import type { EmulatorSessionInfo } from '../emulator/emulator-types'
import type { SimulatorDevice } from '../emulator/simctl-simulator-devices'
@@ -148,7 +147,6 @@ export class RuntimeEmulatorCommands {
if (reusable) {
// Why: renderer remounts should reconnect to the existing stream, not
// kill it and create the stream-disconnected reload loop users see.
serveSimStateWatcher.markOrcaManaged(reusable)
this.notifyRendererEmulatorAutoAttach(worktreeId, reusable)
if (params.focus) {
this.notifyRendererEmulatorPaneFocus(worktreeId)
@@ -157,15 +155,11 @@ export class RuntimeEmulatorCommands {
}
// A different requested device is an explicit switch; the bridge keeps a
// slow-to-boot Android emulator alive for instant switch-back.
const stoppedUdid = await bridge.stopActiveForSwitch(worktreeId)
if (stoppedUdid) {
serveSimStateWatcher.unmarkOrcaManaged(stoppedUdid)
}
await bridge.stopActiveForSwitch(worktreeId)
}
const info = await bridge.startHelperForDevice(device)
if (worktreeId) {
bridge.registerActiveEmulator(worktreeId, info, { managed: true })
serveSimStateWatcher.markOrcaManaged(info)
this.notifyRendererEmulatorAutoAttach(worktreeId, info)
if (params.focus) {
this.notifyRendererEmulatorPaneFocus(worktreeId)
@@ -281,7 +275,6 @@ export class RuntimeEmulatorCommands {
const bridge = this.requireEmulatorBridge()
const worktreeId = await this.resolveWorktreeId(params.worktree)
const killedUdid = await bridge.kill(params.device ?? params.emulator, worktreeId)
serveSimStateWatcher.unmarkOrcaManaged(killedUdid)
return { ok: true, deviceUdid: killedUdid }
}
@@ -295,13 +288,9 @@ export class RuntimeEmulatorCommands {
const worktreeId = await this.resolveWorktreeId(params.worktree)
if (params.managedOnly && worktreeId && !params.device && !params.emulator) {
const shutdownUdid = await bridge.shutdownActiveManagedForWorktree(worktreeId)
if (shutdownUdid) {
serveSimStateWatcher.unmarkOrcaManaged(shutdownUdid)
}
return { ok: true, deviceUdid: shutdownUdid ?? undefined }
}
const shutdownUdid = await bridge.shutdown(params.device ?? params.emulator, worktreeId)
serveSimStateWatcher.unmarkOrcaManaged(shutdownUdid)
return { ok: true, deviceUdid: shutdownUdid }
}
-20
View File
@@ -349,7 +349,6 @@ import {
buildHeadlessTabGroupSplit
} from './headless-tab-group-split-layout'
import { RuntimeEmulatorCommands, setEmulatorBridge } from './orca-runtime-emulator'
import { serveSimStateWatcher } from '../emulator/serve-sim-state-watcher'
import type { EmulatorBridge } from '../emulator/emulator-bridge'
import { RuntimeFileCommands } from './orca-runtime-files'
import { RuntimeGitCommands } from './orca-runtime-git'
@@ -5882,7 +5881,6 @@ export class OrcaRuntimeService {
// `Network: https://local.example.com:3001/`) so the workspace ports
// panel can surface them in place of the kernel bind address.
advertisedUrlWatcher.ingest(ptyId, data, at)
serveSimStateWatcher.ingestPtyOutput(ptyId, data)
// Why: reply ownership is captured per chunk, here at ingestion — the
// same module state and tick as the hidden-gate drop sites — and rides
// the writeChain link. A mark/setting/subscriber flip before the queued
@@ -8705,7 +8703,6 @@ export class OrcaRuntimeService {
onPtyExit(ptyId: string, exitCode: number): void {
advertisedUrlWatcher.unbindPty(ptyId)
serveSimStateWatcher.unbindPty(ptyId)
// Clean up new mobile state for this PTY
this.mobileSubscribers.delete(ptyId)
this.remoteTerminalViewSubscriberCounts.delete(ptyId)
@@ -17608,7 +17605,6 @@ export class OrcaRuntimeService {
// purge history and process-local caches before the ID points at new state.
store.removeWorktreeMeta(worktreeId)
advertisedUrlWatcher.forgetWorktree(worktreeId)
serveSimStateWatcher.forgetWorktree(worktreeId)
deleteWorktreeHistoryDir(worktreeId)
this.closeHeadlessBrowserPagesForWorktree(worktreeId)
}
@@ -21084,7 +21080,6 @@ export class OrcaRuntimeService {
// Why: restored/controller-discovered PTYs learn their worktree here
// without registerPty(), so URL enrichment must bind at this source.
advertisedUrlWatcher.bindPty(ptyId, worktreeId)
serveSimStateWatcher.bindPty(ptyId, worktreeId)
return pty
}
@@ -21120,7 +21115,6 @@ export class OrcaRuntimeService {
// Why: recordPtyWorktree is the common lifecycle point for every path that
// resolves a PTY's worktree, including renderer restore and controller list.
advertisedUrlWatcher.bindPty(ptyId, worktreeId)
serveSimStateWatcher.bindPty(ptyId, worktreeId)
return pty
}
@@ -21233,8 +21227,6 @@ export class OrcaRuntimeService {
}
private dropDisconnectedPtyRecord(ptyId: string): void {
// Why: pruning can remove a PTY without the normal exit callback.
serveSimStateWatcher.unbindPty(ptyId)
this.ptysById.delete(ptyId)
this.recentPtyOutputById.delete(ptyId)
this.clearWaitBlockedCheckState(ptyId)
@@ -25726,18 +25718,6 @@ export class OrcaRuntimeService {
emulatorUnregisterActive: RuntimeEmulatorCommands['emulatorUnregisterActive'] =
this.emulatorCommands.emulatorUnregisterActive.bind(this.emulatorCommands)
// Why: serve-sim-state-watcher runs from main/index.ts startup; keep window IPC behind runtime (getAuthoritativeWindow is private).
notifyEmulatorAutoAttachFromWatcher(
worktreeId: string,
info: { deviceUdid: string; streamUrl: string; wsUrl: string; axUrl?: string }
): void {
try {
this.getAuthoritativeWindow().webContents.send('ui:emulatorAutoAttach', { worktreeId, info })
} catch {
// Window may not exist during shutdown
}
}
private getAuthoritativeWindow(): BrowserWindow {
const win = this.getAvailableAuthoritativeWindow()
if (!win || win.isDestroyed()) {