Skip to content

fix(wework): replace local executor socket with stdio - #2056

Merged
qdaxb merged 1 commit into
mainfrom
fix/wework-stdio-ipc
Jul 19, 2026
Merged

qdaxb merged 1 commit into
mainfrom
fix/wework-stdio-ipc

Conversation

@qdaxb

@qdaxb qdaxb commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • replace Wework's local executor socket/address-file transport with a parent-owned JSONL stdio channel
  • keep the executor and stdio channel alive when the macOS window/WebView is closed to the tray, and terminate the owned process group only when the app exits
  • reconcile a running local task from its persisted transcript after the renderer is recreated, so a terminal event missed while the window was closed is restored
  • keep the remote Backend Socket.IO relay, standalone Local Executor, and cloud executor connection paths unchanged

Root cause

The local executor lifetime was longer than the renderer event subscription, while socket discovery/reconnection was managed independently. Closing or suspending the window could destroy the WebView listener without stopping the task. On resume, the UI no longer had the terminal event, and restart could also encounter stale socket/address discovery state, leaving the workbench on the organizing screen even though the executor task continued.

Implementation

  • reserve executor stdout for the Wework JSONL protocol and route diagnostics to stderr/rolling logs
  • select stdio only for Wework-owned children via WEGENT_APP_IPC_DEVICE_ID; standalone Local Executor launches retain the existing Backend Socket.IO transport
  • make Tauri own exactly one child stdin/stdout pair with generation guards and per-request timeouts
  • preserve the child/channel across close-to-tray; kill the process group on real app shutdown
  • remove obsolete local IPC socket environment variables, cleanup, diagnostics, tests, and docs
  • poll persisted transcripts only for running local-device tasks after renderer recreation
  • add a real macOS lifecycle E2E that verifies the same app/executor PID survives close/reopen and captures the full four-step UI chain

Verification

  • cargo fmt --manifest-path executor/Cargo.toml --check
  • cargo test --manifest-path executor/Cargo.toml -- --test-threads=1
  • cargo test --manifest-path executor/Cargo.toml --test app_startup_contract -- --test-threads=1
  • cargo check --release --manifest-path executor/Cargo.toml
  • cargo fmt --manifest-path wework/src-tauri/Cargo.toml --check
  • cargo test --manifest-path wework/src-tauri/Cargo.toml
  • cargo check --release --manifest-path wework/src-tauri/Cargo.toml
  • pnpm --dir wework test
  • pnpm --dir wework typecheck
  • pnpm --dir wework lint
  • pnpm --dir wework build (through the real Tauri E2E build)
  • pnpm --dir wework e2e:desktop:lifecycle
  • pre-push ESLint, TypeScript, unit tests, Executor library tests, fmt, and clippy

Lifecycle evidence: one executor ready event; unchanged app and executor PIDs; renderer ready count increases from 1 to 2; task remains running after reopen and completes from persisted transcript.

Summary by CodeRabbit

  • New Features

    • Local desktop communication now uses managed stdin/stdout JSONL, improving reliability across platforms.
    • Local executor status and diagnostics now report transport readiness and connectivity more clearly.
    • Running local tasks can automatically reconcile and display completion when terminal events are missed.
    • Added lifecycle verification for desktop executor startup, shutdown, and background-task behavior.
  • Bug Fixes

    • Improved cleanup when the local executor exits or its communication channel closes.
    • Updated startup troubleshooting and diagnostics to provide clearer guidance for connection failures.
  • Documentation

    • Updated English and Chinese guides for local-device configuration, executor lifecycle, Windows support, and performance diagnostics.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4fe3e770-9636-4b61-b32d-5a8617961460

📥 Commits

Reviewing files that changed from the base of the PR and between 744ffe4 and d964edf.

📒 Files selected for processing (32)
  • docs/en/developer-guide/local-device-architecture.md
  • docs/en/developer-guide/wework-cloud-connection.md
  • docs/en/developer-guide/wework-performance-diagnostics.md
  • docs/en/developer-guide/wework-windows.md
  • docs/en/user-guide/ai-devices/local-device-support.md
  • docs/zh/developer-guide/local-device-architecture.md
  • docs/zh/developer-guide/wework-cloud-connection.md
  • docs/zh/developer-guide/wework-performance-diagnostics.md
  • docs/zh/developer-guide/wework-windows.md
  • docs/zh/user-guide/ai-devices/local-device-support.md
  • executor/docs/LOCAL_MODE.md
  • executor/src/agents/codex.rs
  • executor/src/app/mod.rs
  • executor/src/bin/wegent-executor-dev.rs
  • executor/src/local/app_ipc.rs
  • executor/src/local/backend.rs
  • executor/src/logging.rs
  • executor/tests/app_startup_contract.rs
  • executor/tests/local_app_ipc_contract.rs
  • wework/AGENTS.md
  • wework/e2e/desktop/task-flow.e2e.mjs
  • wework/package.json
  • wework/scripts/ai-verify-environment.mjs
  • wework/scripts/ai-verify-environment.test.mjs
  • wework/scripts/ai-verify.mjs
  • wework/src-tauri/src/local_executor.rs
  • wework/src/components/layout/useWorkbenchPaneSession.ts
  • wework/src/e2e/automation.ts
  • wework/src/features/local-runtime/LocalRuntimeInitializer.test.tsx
  • wework/src/features/local-runtime/LocalRuntimeInitializer.tsx
  • wework/src/features/workbench/WorkbenchProvider.test.tsx
  • wework/src/tauri/localExecutor.ts

📝 Walkthrough

Walkthrough

The PR replaces local executor socket IPC with stdio JSONL, updates executor and Tauri child-process lifecycle handling, changes transport diagnostics and configuration, adds local transcript reconciliation, expands desktop lifecycle E2E coverage, and aligns English and Chinese documentation.

Changes

Local executor stdio migration

Layer / File(s) Summary
Executor transport and startup dispatch
executor/src/app/mod.rs, executor/src/local/*, executor/src/logging.rs, executor/src/agents/codex.rs
Startup selects stdio App IPC or Socket.IO Backend transport; stdout is reserved for protocol frames and executor logs move to stderr when required.
Transport implementation and validation
executor/src/local/app_ipc.rs, executor/tests/*, executor/src/bin/*
App IPC serves JSONL over generic async IO, terminates on EOF, removes socket helpers, and tests stdio readiness, requests, shutdown, and startup-plan selection.

Desktop runtime integration

Layer / File(s) Summary
Tauri child lifecycle and request handling
wework/src-tauri/src/local_executor.rs, wework/scripts/*, wework/AGENTS.md
Tauri manages owned executor children through stdin/stdout, removes socket discovery and keepalive handling, updates timeout behavior, and removes socket environment/session wiring.
Runtime diagnostics and transcript recovery
wework/src/tauri/localExecutor.ts, wework/src/features/local-runtime/*, wework/src/components/layout/useWorkbenchPaneSession.ts, wework/src/features/workbench/WorkbenchProvider.test.tsx
Diagnostics report stdio transport state, while local running transcripts are refreshed until completion after missed terminal events.

Desktop lifecycle verification

Layer / File(s) Summary
Lifecycle scenario and control routing
wework/e2e/desktop/task-flow.e2e.mjs
The E2E harness adds a control server, readiness counters, lifecycle response coordination, stdio-ready checks, and a window_lifecycle scenario.
Desktop build and automation wiring
wework/e2e/desktop/task-flow.e2e.mjs, wework/src/e2e/automation.ts, wework/package.json
macOS desktop builds are wrapped and LaunchServices-managed, control and cloud URLs are separated, executor socket wiring is removed, and lifecycle automation actions are added.

Documentation alignment

Layer / File(s) Summary
Transport and lifecycle documentation
docs/en/..., docs/zh/..., executor/docs/LOCAL_MODE.md
Documentation now describes stdio JSONL, child ownership, configuration precedence, backend transport selection, lifecycle termination, diagnostics channels, and updated troubleshooting steps.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Wework as Wework Tauri App
  participant Sidecar as Executor Sidecar
  participant Backend as Backend
  Wework->>Sidecar: Spawn child and write JSONL requests to stdin
  Sidecar-->>Wework: Emit JSONL responses/events on stdout
  Sidecar->>Backend: Register local device through Socket.IO
  Backend-->>Sidecar: Send remote device requests
  Wework->>Sidecar: Close stdin during shutdown
  Sidecar-->>Wework: End stdio transport on EOF or child exit
Loading

Possibly related PRs

Suggested reviewers: micro66, icycrystal4

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wework-stdio-ipc

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.

@qdaxb
qdaxb force-pushed the fix/wework-stdio-ipc branch 3 times, most recently from b3f301e to 24fbf41 Compare July 19, 2026 20:51
@qdaxb
qdaxb force-pushed the fix/wework-stdio-ipc branch from 24fbf41 to d964edf Compare July 19, 2026 21:18
@qdaxb
qdaxb marked this pull request as ready for review July 19, 2026 21:34
@qdaxb
qdaxb merged commit 480fb05 into main Jul 19, 2026
29 of 30 checks passed
@qdaxb
qdaxb deleted the fix/wework-stdio-ipc branch July 19, 2026 21:34
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