Skip to content

fix: make native window tab projection non-blocking and add runner WS liveness - #723

Merged
timjang3 merged 3 commits into
mainfrom
fix/non-blocking-window-tab-projection
Nov 23, 2026
Merged

timjang3 merged 3 commits into
mainfrom
fix/non-blocking-window-tab-projection

Conversation

@timjang3

Copy link
Copy Markdown
Collaborator

Root Cause

When an enrolled secondary Mac's runner WebSocket went silently unresponsive (half-open TCP without a close frame), three Host behaviors compounded to stall local browser tab operations (tab.open, tab.close, resources.detail.get) for >25s until clients aborted with "Couldn't confirm this change.":

  1. window was the only tab kind performing synchronous remote RPCs during tab projection: NativeTabTargets.windowState() awaited a live window.resolve RPC (10s timeout + 6s grace = 16s) on every tab projection and every resources.detail.get (holding a PostgreSQL withPersonalSyncRead transaction open the entire time).
  2. TabService.#catalog() starvation loop: do { ... } while (current.dirty === null || current.dirty.size) behind one current.pending promise starved earlier callers indefinitely whenever a new changed() arrived mid-pass.
  3. Missing RFC 6455 Ping/Pong liveness on Runner sockets: attachRunnerSocket and attachRunnerAuxiliarySocket did not install installWebSocketLiveness(socket) (unlike client, personal sync, and display stream sockets), letting half-open dead runners linger for the full 120s stream lease. Additionally, onRunnerAttached / onRunnerDetached / onConnectionsChanged did not clear cached native window state or invalidate/announce tab resources.

Changes

  • Non-blocking NativeTabTargets.windowState() (apps/host/src/computer-use/native-tab-targets.ts, apps/host/src/tabs/ports.ts):
    • Evaluates ownership, app approval (row.windowApp), connectivity, active task users, and active owner views locally without awaiting remote queryWindow RPCs.
    • Maintains per-computer generation-fenced observed window state with a 30s refresh TTL, seeded from resolveWindow(), openOwnerView(), and observeView().
    • Deduplicates background queryWindow probes per (computerId, windowId) and notifies onWindowStateChanged only on state transitions.
    • Adds forgetComputer() to bump computer generation and discard stale/in-flight probes on disconnect/rebind.
  • Versioned single-flight TabService.#catalog() & surgical windowChanged() (apps/host/src/tabs/tab-service.ts):
    • Replaces the unbounded do ... while loop with versioned single-flight passes (version / projectedVersion) so earlier callers resolve as soon as their version finishes instead of starving behind later invalidations.
    • Adds windowChanged(ownerId, windowId) backed by a per-catalog windowIds map for single-tab invalidation.
  • Runtime lifecycle wiring (apps/host/src/runtime/runtime.ts):
    • Wires onWindowStateChanged, computerViews.changed → nativeTabs.observeView, and forgetComputer + tabs.changed() + announceResources("tab") across runner attach/detach, device invalidate/remove, and connection changes.
  • Runner WebSocket liveness (apps/host/src/server.ts):
    • Installs installWebSocketLiveness(socket) on both attachRunnerSocket and attachRunnerAuxiliarySocket.
  • Tests:
    • apps/host/src/computer-use/computer-repl/native-tab-binding.test.ts
    • apps/host/src/tabs/tab-service.test.ts
    • apps/host/src/runtime/tabs.integration.test.ts

Verification

  • pnpm --filter @opensteer/host typecheck — passed
  • pnpm --filter @opensteer/host exec vitest run src/computer-use/computer-repl/native-tab-binding.test.ts src/tabs/tab-service.test.ts src/server/websocket-liveness.test.ts src/computer-apps/computer-app-hub.test.ts src/runtime/runtime-wiring.test.ts — 5 files, 75/75 passed
  • pnpm test:integration:
    • apps/host/src/runtime/idle-runtime.integration.test.ts — 1/1 passed
    • apps/host/src/tabs/tab-authority.integration.test.ts — 6/6 passed
    • apps/host/src/devices/computer-use-journey.integration.test.ts — 59/59 passed
    • Note: re-running apps/host/src/runtime/tabs.integration.test.ts locally was blocked by the unrelated tests/quarantine.json entry expiring at 2026-11-23T02:10:51Z.

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
opensteer-marketing Skipped Skipped Nov 23, 2026 2:40am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[High impact] The PR changes tab reads and liveness checks across Host Runner connections.

Fix the two window-state bugs before merging.

Findings

  1. P1 Closed windows look open ▶
  2. P1 Older queries erase newer state ▶

Summary

This PR moves native window checks out of tab reads and adds Runner WebSocket liveness.

  • Window tab reads return while remote Mac state refreshes in the background.
  • Tab catalog reads finish without waiting behind later updates.
  • Runner sockets now drop connections that stop answering liveness checks.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Tab read] --> B[Check local access and connection]
  B --> C[Return cached window state]
  B --> D[Start background probe when needed]
  D --> E[Save observation]
  F[View update] --> E
  E --> G[Mark matching tab changed]
  G --> H[Announce tab resource change]
Loading

Reviews (1) · Last reviewed commit: "fix: make native window tab projection n..." · Reviewed by Greptile

@timjang3
timjang3 merged commit b6e1376 into main Nov 23, 2026
33 of 35 checks passed
@timjang3
timjang3 deleted the fix/non-blocking-window-tab-projection branch November 23, 2026 03:00
timjang3 added a commit that referenced this pull request Nov 23, 2026
…-smokes

One conflict, apps/host/src/server.ts: main moved the person's tab commands
into TabService.executeCommand; this branch added tab.group.close beside
tab.group.delete in the server's switch. Kept main's shape: tab.group.close
is one more case forwarded to executeCommand, which now handles it with
closeGroup.

Aligned without a textual conflict, apps/host/src/tabs/tab-service.ts:
main's tab mutations finish through tabMutationMeta and
#applyCatalogMutation (a replay ends no viewers and answers with the current
layout); closeGroup now does the same, as #close does.

Auto-merged and checked: browser-service.ts keeps E1 (the page ends only on
the tab's own not_found) and E2 (the witness is the row the bind wrote)
beside main's #723 and #725; tab-store.ts keeps closeGroup and bindPage's
row; tab-group.tsx keeps the selected title and the single tab.group.close;
tab-closer.tsx is main's; app-shell.tsx keeps the wait for the complete tab
list. The passwords package and the journey's policy fixture are unchanged
by the merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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