Repository navigation
Description
Overview
Implement the WatchNodes server-streaming RPC so the Tauri desktop UI receives real-time graph update events from nodespaced without polling. This replaces the current Tauri event system as the mechanism for pushing node change notifications to the frontend.
Problem Statement
The Tauri frontend currently receives node update notifications via Tauri events emitted from within the same process. Under ADR-031, the Tauri app is a separate gRPC client process. Tauri events cannot cross process boundaries. Without a streaming RPC the UI must poll — unacceptable when agent sessions may be modifying the graph concurrently.
Proposed Solution
nodespaced maintains an internal tokio::sync::broadcast channel (the event bus). Every ops-layer mutation publishes a NodeEvent to it. The WatchNodes handler subscribes and streams those events to connected clients. The Tauri app opens a long-lived WatchNodes stream on startup and reconnects automatically on disconnection.
Acceptance Criteria
-
WatchNodesRPC is fully implemented innodespaced(not a stub returningUnimplemented) -
NodeEventproto message includes: event type (created/updated/deleted), node ID, and full node data for created/updated events - Every successful ops-layer mutation publishes to the event bus
- Tauri app opens a
WatchNodesstream on startup - Tauri app reconnects automatically on stream error using exponential backoff (start 1s, cap 30s)
- Frontend reactive state updates from watcher events without polling
- Multiple concurrent watchers supported simultaneously (e.g., Tauri UI + CLI)
- Stream closes gracefully when the client disconnects
- Integration test: mutate a node via gRPC, verify the watcher receives the corresponding event
- All frontend tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Files to create/modify
packages/daemon/src/event_bus.rs(NEW) —Arc<EventBus>wrapping abroadcast::Sender<NodeEvent>; exposespublish()andsubscribe()packages/daemon/src/services/node_service.rs— implementwatch_nodesusingasync_stream::stream!over a broadcast receiverpackages/desktop-app/src-tauri/src/watcher.rs(NEW) — spawns a task that opens theWatchNodesstream and re-emits events to the Svelte frontend via Tauriemitpackages/desktop-app/src/lib/— update reactive stores to consume watcher events
NodeEvent and WatchRequest proto additions
message WatchRequest {
repeated string node_ids = 1; // empty = watch all nodes
}
message NodeEvent {
enum EventType { CREATED = 0; UPDATED = 1; DELETED = 2; }
EventType event_type = 1;
string node_id = 2;
optional NodeResponse node = 3; // populated for CREATED and UPDATED
}Event bus pattern
pub struct EventBus {
sender: broadcast::Sender<NodeEvent>,
}
impl EventBus {
pub fn publish(&self, event: NodeEvent) { let _ = self.sender.send(event); }
pub fn subscribe(&self) -> broadcast::Receiver<NodeEvent> { self.sender.subscribe() }
}EventBus held in Arc, injected into both the ops layer and the NodeService gRPC handler.
WatchNodes handler skeleton
async fn watch_nodes(&self, _req: Request<WatchRequest>)
-> Result<Response<Self::WatchNodesStream>, Status>
{
let mut rx = self.event_bus.subscribe();
let stream = async_stream::stream! {
loop {
match rx.recv().await {
Ok(event) => yield Ok(event),
Err(RecvError::Lagged(_)) => continue,
Err(RecvError::Closed) => break,
}
}
};
Ok(Response::new(Box::pin(stream)))
}Reference files
packages/daemon/proto/node_service.proto— WatchNodes and NodeEvent definitions (from Define protobuf schema and set up tonic/prost build pipeline for nodespaced #1111)packages/desktop-app/src-tauri/src/commands/— existing Tauri emit patterns to replace
Dependencies
- Define protobuf schema and set up tonic/prost build pipeline for nodespaced #1111 (proto schema and build pipeline)
- Implement nodespaced binary: gRPC server startup and NodeService registration #1112 (nodespaced server)
- Migrate Tauri command handlers to thin gRPC proxy wrappers #1113 (Tauri gRPC proxy pattern established)
Non-Goals
- Filtering watch events by node type or parent (future)
- Persistent event log or replay from last-seen sequence number (future)
- Watching relationship changes (separate concern)
Activity
malibio commentedon May 17, 2026
Baseline test status (frontend, before implementation):
Test Files: 128 passed (128)
Tests: 3918 passed (3918)
Duration: 39.41s
Will compare against this baseline before opening PR.
WIP: gRPC proxy migration for #1113 — Phases 2-4 of 5 complete
malibio commentedon May 17, 2026
Implementation note — scope clarification for AC
The watcher.rs module will be implemented, tested at the unit/integration level, and committed as part of this PR, but its activation is gated on #1113:
AC reinterpretation:
This matches CLAUDE.md 'no dual-mode' rule: only one event source is live at a time. The watcher module exists inert in the codebase until #1113 flips the switch.
Proxy Tauri node/collection/schema commands via gRPC (closes #1113)
Proxy Tauri node/collection/schema commands via gRPC (closes #1113) (#…
Implement WatchNodes gRPC streaming, add Tauri watcher.rs (closes #1114…
Proxy Tauri node/collection/schema commands via gRPC (closes #1113) (#…