Repository navigation
Description
Overview
Replace all #[tauri::command] handler implementations with thin gRPC proxy wrappers that forward calls to nodespaced on localhost:50051. After this change, the Tauri app contains no business logic — it is a pure gRPC client that translates Tauri IPC into gRPC calls and maps responses back.
Problem Statement
Approximately 30 #[tauri::command] handlers in packages/desktop-app/src-tauri/src/commands/ contain direct calls into packages/core ops. Under ADR-031, all business logic moves to nodespaced. The Tauri process must become a thin client; keeping direct ops calls creates two competing code paths and prevents the daemon architecture from working correctly.
Proposed Solution
For each existing Tauri command handler:
- Remove the direct
packages/coreops invocation - Replace with a gRPC call to
nodespacedusing a sharedtonicclient - Map gRPC response back to the expected Tauri command return type
- Map gRPC errors to
tauri::Erroror command-specific error types
The Tauri app initializes one gRPC client on startup and passes it to all command handlers via Tauri's managed state.
Acceptance Criteria
- All
#[tauri::command]handlers that previously calledpackages/coreops now callnodespacedvia gRPC - No direct
packages/coreimports remain inpackages/desktop-app/src-tauri/src/commands/ - gRPC client initialized on Tauri startup and stored in
tauri::State - All existing Tauri command return types preserved (frontend calls unchanged)
- Commands work end-to-end: Tauri frontend → gRPC proxy → nodespaced → response
- Error cases propagate correctly (gRPC status codes → command errors)
-
cargo build -p desktop-appsucceeds - All frontend tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Files to modify
packages/desktop-app/src-tauri/src/commands/— all command files; replace ops calls with gRPC callspackages/desktop-app/src-tauri/src/main.rs— initialize gRPC client, add to Tauri managed statepackages/desktop-app/src-tauri/Cargo.toml— addtonic,prostdependencies; addpackages/daemonas path dependency for generated types
gRPC client state pattern
// src-tauri/src/main.rs
struct GrpcClient {
node_service: NodeServiceClient<Channel>,
}
tauri::Builder::default()
.manage(GrpcClient::connect("http://[::1]:50051").await?)
// ...Command proxy pattern
// Before
#[tauri::command]
async fn get_node(id: String, service: State<'_, NodeService>) -> Result<Node, String> {
service.get_node(&id).await.map_err(|e| e.to_string())
}
// After
#[tauri::command]
async fn get_node(id: String, client: State<'_, GrpcClient>) -> Result<Node, String> {
let response = client.node_service
.get_node(GetNodeRequest { id })
.await
.map_err(|e| e.to_string())?;
Ok(response.into_inner().into())
}Commands to migrate
All handlers in:
packages/desktop-app/src-tauri/src/commands/nodes.rspackages/desktop-app/src-tauri/src/commands/search.rspackages/desktop-app/src-tauri/src/commands/schema.rs- Any other command files with direct core ops calls
Error mapping
tonic::Status → command error string, preserving the status code in the message for debuggability.
Reference files
packages/desktop-app/src-tauri/src/commands/— current command implementationspackages/daemon/proto/node_service.proto— gRPC interface (from Define protobuf schema and set up tonic/prost build pipeline for nodespaced #1111)
Dependencies
- Define protobuf schema and set up tonic/prost build pipeline for nodespaced #1111 (proto schema)
- Implement nodespaced binary: gRPC server startup and NodeService registration #1112 (nodespaced must be running for end-to-end testing)
Non-Goals
WatchNodesstreaming for UI reactivity (separate issue)- ACP/MCP command handlers (deleted separately, not proxied)
- CLI binary
Activity
malibio commentedon May 17, 2026
Scope Clarification (2026-05-17)
This issue is narrowed to Node + AgentSession handlers only.
The proto currently covers two services:
NodeServiceandAgentSessionService. There are ~50 additional Tauri command handlers (collections, embeddings, schemas, settings, import, local_agent, chat_models, db, diagnostics) that have no gRPC destination yet — their proto definitions and nodespaced handlers are tracked in follow-up issues (see below).What to implement in this issue
Migrate only the handlers that have an existing proto + nodespaced handler:
commands/nodes.rs→NodeServicegRPC proxycommands/collections.rs→NodeServicegRPC proxy (collections are NodeService operations)commands/schemas.rs→NodeServicegRPC proxy (schema reads are NodeService operations)Do not attempt to proxy the following in this PR — leave them calling
packages/coredirectly until their follow-up issues land:commands/embeddings.rs→ tracked in Add Gemma 4 E4B and 31B as downloadable model options (#1094) #1134commands/import.rs→ tracked in Add EmbeddingsService gRPC: proto definition, nodespaced handler, and Tauri proxy #1135commands/local_agent.rs→ tracked in Add ImportService gRPC: proto definition, nodespaced handler, and Tauri proxy #1136commands/settings.rs→ tracked in Add LocalAgentService gRPC: proto definition, nodespaced handler, and Tauri proxy #1137commands/db.rs→switch_databaseis vestigial under ADR-031 and will be deleted;init_servicesbecomes daemon startupcommands/diagnostics.rs→ tracked in Add SettingsService gRPC: daemon config via RPC, display prefs stay in Tauri #1138 (CLI subcommand, not gRPC service)Why this approach
The Tauri app remains fully functional throughout: unmigrated handlers continue calling
packages/coredirectly with no regression. As each follow-up service issue lands (proto + nodespaced handler + Tauri proxy), those handlers flip to gRPC. Eventually all handlers are proxies andpackages/coreis no longer imported by the Tauri app.Updated acceptance criteria
The AC "No direct
packages/coreimports remain inpackages/desktop-app/src-tauri/src/commands/" is not achievable in this issue and should be read as the end-state across all service migration issues. For this PR, the criterion is: allnodes.rs,collections.rs, andschemas.rshandlers proxy via gRPC; all other handlers continue calling core directly and are explicitly left for follow-up issues.malibio commentedon May 17, 2026
Baseline (2026-05-17, worktree issue-1113-grpc-proxy from 5e7ef28):
Frontend: 128 test files passed, 3918 tests passed (Duration 41.00s)
Note: required
bunx svelte-kit syncin this worktree to generate.svelte-kit/tsconfig.jsonbeforebun run testwould start (vitest's tsconfig extends chain otherwise fails to resolve in a fresh worktree).Working on the narrowed scope per the 2026-05-17 scope-clarification comment:
commands/nodes.rs,commands/collections.rs,commands/schemas.rs→ NodeService gRPC proxy. Other handler files left untouched per their tracking issues.malibio commentedon May 17, 2026
WIP handoff @ commit 5d1b7f1 on branch
worktree-issue-1113-grpc-proxy.Completed (Phase 1 of 5): Extended
packages/daemon/proto/node_service.protowith +328 LOC. Added 28 new RPCs covering all in-scope handlers, plus ~30 new message types. ExistingCreateNodeRequestgainedidandinsert_after_node_idfields to match the Tauri CreateNodeInput shape.Remaining phases:
cargo build -p nodespace-daemonto validate proto compiles (was blocked by sibling worktree's target lock during this session)packages/daemon/src/services/node_service.rs(~800 LOC)nodes.rs(19 handlers),collections.rs(12),schemas.rs(2)See WIP commit message for full handoff context, including design decisions baked into the proto (tri-state TaskNodeUpdate encoding, generic NodeResponse for SchemaNode/TaskNode reads, dedicated CollectionInfo message, etc.).
WIP: gRPC proxy migration for #1113 — Phases 2-4 of 5 complete
malibio commentedon May 17, 2026
WIP handoff @ commit d6f9975 on branch
worktree-issue-1113-grpc-proxy.Completed (Phases 2-4 of 5):
cargo build -p nodespace-daemonsucceeds)packages/daemon/src/services/node_service.rs(+~900 LOC net). All 28 in-scope RPCs now have impls; only WatchNodes/Chat remain stubbed (tracked separately). Includes tri-state TaskNodeUpdate decoding, schema reads via raw Node fetch, and consistent CollectionService usage.services/grpc_client.rsspawns an in-process tonic server on127.0.0.1:0(OS-chosen port) reusing the sameArc<NodeService>AppServices already owns — no second DB open. Registered viaapp.manage()after AppServices init.Build status: Both
cargo build -p nodespace-daemonandcargo build -p nodespace-appsucceed with no warnings.Remaining (Phase 5): Mechanical migration of
commands/nodes.rs(19 handlers),commands/collections.rs(12),commands/schemas.rs(2) to proxy throughState<'_, GrpcClient>. All proto types and core handlers are wired through — the migration is now: replace inner ops calls with gRPC calls and map responses back to existing CommandError/Value/Node return types.See WIP commit message d6f9975 for full Phase 5 implementation guidance and design decisions baked in (tri-state encoding, schema reconstruction, etc.).
Address review: extend NodeDeleted with node_type, doc clones/serial …
Implement WatchNodes gRPC streaming, add Tauri watcher.rs (closes #1114…
Migrate Tauri command handlers to proxy via gRPC (closes #1113) — Pha…
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) (#…