Repository navigation
feat: Tauri command layer wiring frontend to agent backend services - #1034
Conversation
…loses #1008) Creates Tauri command modules for local agent, model management, and ACP. Registers LocalAgentService and AcpClientService as independent managed state. Wires frontend stores to real Tauri invocations with mock fallback for development mode. Updates tauri-commands.ts with all new invoke wrappers. Co-Authored-By: Claude <[email protected]>
Pragmatic Code Review -- PR #1034Reviewer: Principal Engineer (automated) Overall AssessmentThis PR delivers a well-structured Tauri command layer that bridges all 18 specified commands across three modules (local agent, chat models, ACP). The architecture correctly places agent services as independent managed state outside The findings below are improvements to address before or shortly after merge -- none are blockers. FindingsSuggested Improvements1. [Improvement] RwLock read guard held across
// local_agent.rs -- local_agent_send (and all other commands)
let service = state.service().await; // acquires RwLockReadGuard
service.send_message(...).await // held across this .awaitFor Since the
This applies to all 6 2. [Improvement] The PR adds a private Extract a single canonical 3. [Improvement] fn extract_agent_id(session_id: &str) -> String {
let without_prefix = session_id.strip_prefix("acp-").unwrap_or(session_id);
if let Some(pos) = without_prefix.rfind('-') {
without_prefix[..pos].to_string()
} else {
without_prefix.to_string()
}
}This parses the convention Better approach: have 4. [Improvement] service.send_message(&agent_id, msg).await?;
match service.receive_message(&agent_id).await { ... }This means
5. [Improvement] let session_pairs = service.get_sessions().await;
for (id, _) in &session_pairs {
if let Some(session) = service.get_session(id).await {
sessions.push(session);
}
}
6. [Improvement] let sessions = service.get_sessions().await;
Ok(sessions.last().map(|(_, s)| s.clone()).unwrap_or(LocalAgentStatus::Idle))
7. [Improvement] Missing The issue spec defines: #[command] async fn acp_start_session(agent_id: String, context_node_ids: Vec<String>) -> Result<String, String>The implementation omits 8. [Improvement] Event listener leak potential in const unlistenChunk = await listen<StreamingChunk>(AGENT_EVENTS.LOCAL_AGENT_CHUNK, ...);
this.eventUnlisteners.push(unlistenChunk);If NitpicksNit: manager.set_progress_callback(Box::new(move |evt: DownloadEvent| { ... })).await;This replaces the global progress callback on every download invocation. If two downloads were somehow triggered concurrently, the second call would overwrite the first's callback. Not a real issue today (single download at a time), but worth a comment noting the assumption. Nit: The 1-token-per-4-chars heuristic is reasonable for a stub, but consider returning Nit: Unused import const log = createLogger('TauriCommands');The Nit: Mock fallback on error in if (this.agents.length === 0) {
this.agents = [...MOCK_AGENTS];
log.info('Fell back to mock agents after error');
}Silently falling back to mock data on Tauri errors could mask real issues. Consider at minimum logging the original error at Command Coverage AuditAll 18 commands from the spec are registered:
Architecture Alignment
SummaryThe PR fulfills all 18 command registrations, correctly implements the independent managed state pattern, and cleanly wires frontend stores with Tauri/mock duality. The RwLock guard lifetime (finding #1) and the Recommendation: Approve. Address findings #1 and #3 in a follow-up or in this PR before merge. |
malibio
left a comment
There was a problem hiding this comment.
Review verdict: Approve with improvements (no blockers). All 18 commands registered, independent managed state pattern correct, GPU lifecycle integrated, frontend stores wired with mock fallback. See detailed review comment above for 8 improvement suggestions. Key items to address: (1) RwLock guard held across long .await in local_agent commands, (2) fragile extract_agent_id string parsing, (3) isTauri() duplication.
…loses #1008) (#1034) Creates Tauri command modules for local agent, model management, and ACP. Registers LocalAgentService and AcpClientService as independent managed state. Wires frontend stores to real Tauri invocations with mock fallback for development mode. Updates tauri-commands.ts with all new invoke wrappers. Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Summary
local_agent.rs,chat_models.rs,acp.rsCloses #1008