WEFT_OS/crates/weft-appd/Cargo.toml

27 lines
721 B
TOML
Raw Permalink Normal View History

[package]
name = "weft-appd"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
[[bin]]
name = "weft-appd"
path = "src/main.rs"
[dependencies]
anyhow = "1.0"
weft-ipc-types = { path = "../weft-ipc-types" }
toml = "0.8"
feat(appd): implement runtime supervisor with process spawning and READY signal runtime.rs — process lifecycle manager: - supervise(session_id, app_id, registry): spawns the weft-runtime child process identified by WEFT_RUNTIME_BIN env var. If unset, logs debug and returns immediately (no-op until runtime binary is available). - Child process invoked as: <WEFT_RUNTIME_BIN> <app_id> <session_id> with stdout/stderr piped, stdin closed. - wait_for_ready(): reads stdout line-by-line; returns Ok(()) on first line matching 'READY'; returns Err if stdout closes without it. - 30-second READY_TIMEOUT via tokio::time::timeout; on expiry, kills the child and transitions session to Stopped. - On success: sets session state to Running, broadcasts AppReady to all connected WebSocket clients via registry broadcast channel. - drain_stderr(): async task that forwards child stderr lines to tracing at WARN level for observability. - On process exit: sets session state to Stopped regardless of exit code. main.rs — wiring: - SessionRegistry now owns broadcast::Sender<Response>; Default creates the channel internally. Added set_state(), subscribe(), broadcast() methods. Removed standalone broadcast_tx from run(); WS handlers subscribe via registry.lock().await.subscribe(). - dispatch::LaunchApp spawns a tokio task calling runtime::supervise immediately after creating the session. supervise is a no-op when WEFT_RUNTIME_BIN is unset, so existing tests are unaffected. Cargo.toml: added tokio 'process' and 'time' features.
2026-03-11 08:17:20 +00:00
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "io-util", "signal", "sync", "process", "time"] }
serde = { version = "1", features = ["derive"] }
rmp-serde = "1"
feat(appd): add WebSocket UI endpoint for Servo shell integration Implements the weft-appd WebSocket server that allows the system-ui.html page running inside Servo to send requests and receive push notifications without requiring custom SpiderMonkey bindings. ws.rs — WebSocket connection handler: - Accepts a tokio TcpStream, performs WebSocket handshake via tokio-tungstenite accept_async. - Reads JSON Text frames, deserializes as Request (serde_json), calls dispatch(), sends Response as JSON Text. - Subscribes to a broadcast::Receiver<Response> for server-push notifications (APP_READY, etc.); forwards to client via select!. - Handles close frames, partial errors, and lagged broadcast gracefully. main.rs — server changes: - broadcast::channel(16) created at startup; WebSocket handlers subscribe for push delivery. - TcpListener bound on 127.0.0.1:7410 (default) or WEFT_APPD_WS_PORT. - ws_port() / write_ws_port(): port written to XDG_RUNTIME_DIR/weft/appd.wsport for runtime discovery. - WS accept branch added to the main select! loop alongside Unix socket. ipc.rs — Response and AppStateKind now derive Clone (required by broadcast::Sender<Response>). system-ui.html — appd WebSocket client: - appdConnect(): opens ws://127.0.0.1:<port>/appd with exponential backoff reconnect (1s → 16s max). - On open: sends QUERY_RUNNING to populate taskbar with live sessions. - handleAppdMessage(): maps LAUNCH_ACK and RUNNING_APPS to taskbar entries; APP_READY shows a timed notification; APP_STATE::stopped removes the taskbar entry. - WEFT_APPD_WS_PORT window global overrides the default port. New deps: tokio-tungstenite 0.24, futures-util 0.3 (sink+std), serde_json 1.
2026-03-11 08:01:54 +00:00
serde_json = "1"
tokio-tungstenite = "0.24"
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
libc = "0.2"
[target.'cfg(unix)'.dependencies]
sd-notify = "0.4"