Skip to content

feat(native): add embedded local server process hosting (CN-LOCAL) - #459

Merged
rynfar merged 1 commit into
nativefrom
feat/native-local-server-host
Nov 20, 2026
Merged

rynfar merged 1 commit into
nativefrom
feat/native-local-server-host

Conversation

@rynfar

@rynfar rynfar commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Closes #241

Summary

Completes embedded local server process hosting (CN-LOCAL) for the native GPUI client, flipping CN-LOCAL in apps/native/parity/LEDGER.md from partial | #241 to done |.

Changes

  • Core lifecycle & launch builders (apps/native/crates/core/src/local_server.rs):
    • Added LocalServerLaunchSpec, serve_args, server_origin, readiness_url, UTF-8-safe append_output_tail, capped exponential restart_delay_ms, matches_hosted_runtime, and format_local_server_diagnostics.
    • Added pure LocalServerLifecycle state machine (LocalServerPhase, LocalServerEvent, LocalServerAction, LocalServerFailure, LocalServerFailureKind) mirroring DesktopBackendManager.ts (clean shutdown, managed-policy exit 77 and state-dir-owned exit 78 restart suppression, bounded crash backoff) with unit tests.
  • Managed subprocess host (apps/native/crates/client/src/local.rs):
    • Implemented LocalServerHost, LocalServerHostConfig, LocalServerHostError, and pair_with_cli to spawn the discovered t3 CLI (cli_candidates / T3_NATIVE_T3_BIN) in its own process group (process_group(0)), monitor stdout/stderr and exit codes, wait for readiness via event-driven Notify + exit-channel tokio::select!, pair automatically via t3 pair, and cleanly terminate ONLY the exact child PID it spawned (SIGTERM -> grace -> SIGKILL on stop()/shutdown(), immediate SIGKILL on Drop).
    • Added deterministic t3-client integration tests (using isolated temp T3CODE_HOME and mock CLI scripts with socket EOF sync, zero sleeps) covering start -> ready -> pair -> clean stop, exit-77 managed-policy refusal (no restart loop), startup crash diagnostics, and clean child termination on Drop.
  • Native UI & app lifecycle (apps/native/crates/app/src/{app_state.rs, connect.rs}):
    • Owned LocalServerHost inside AppState, wired reactive phase pump, start_local_server, stop_local_server, persisted set_local_server_auto_start, diagnostics copy helper, and graceful teardown in cx.on_app_quit.
    • Wired Start local server, Stop server, Auto-start toggle, status badges, and expandable/copyable failure diagnostics in ConnectView::render_local using crate::i18n::t(cx, ...) for matching labels, plus GPUI snapshot test coverage.
  • Parity ledger (apps/native/parity/LEDGER.md):
    • Updated CN-LOCAL row only (partial | #241 -> done |).

Verification

  • CARGO_INCREMENTAL=0 cargo clippy --workspace --all-targets -- -D warnings: pass (0 warnings)
  • CARGO_INCREMENTAL=0 cargo test -p t3-core: 1,860 unit + 8 conformance passed, 0 failed
  • CARGO_INCREMENTAL=0 cargo test -p t3-client: 167 passed, 0 failed
  • CARGO_INCREMENTAL=0 cargo test -p t3-native -- --test-threads=1 (isolated T3_NATIVE_HOME): 208 passed, 0 failed (--features snapshot connect::tests: 5 passed, 0 failed)
  • CARGO_INCREMENTAL=0 cargo build -p t3-native: pass
  • vp fmt --check apps/native/parity/LEDGER.md: pass
  • node apps/native/scripts/gen-theme.ts --check: pass
  • node apps/native/conformance/generate.ts --check: pass
  • node --test apps/native/parity/sync.test.ts: 47 passed, 0 failed

Generated with Antigravity.

@rynfar
rynfar merged commit f5fffd1 into native Nov 20, 2026
2 checks passed
@rynfar
rynfar deleted the feat/native-local-server-host branch November 20, 2026 05:08
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