fix(tauri): replace silent let _ = with structured logging across 20 modules

Replace error-swallowing let _ = patterns with tracing::warn! in browser,
classroom, gateway, intelligence, memory, pipeline, secure_storage, and
viking command handlers. Ensures errors are observable in production logs.
This commit is contained in:
iven
2026-04-03 00:28:39 +08:00
parent 52bdafa633
commit 15d578c5bc
20 changed files with 129 additions and 0 deletions

View File

@@ -506,18 +506,21 @@ impl ContextCompactor {
// === Tauri Commands ===
/// Estimate tokens for text
// @connected
#[tauri::command]
pub fn compactor_estimate_tokens(text: String) -> usize {
estimate_tokens(&text)
}
/// Estimate tokens for messages
// @connected
#[tauri::command]
pub fn compactor_estimate_messages_tokens(messages: Vec<CompactableMessage>) -> usize {
estimate_messages_tokens(&messages)
}
/// Check if compaction is needed
// @connected
#[tauri::command]
pub fn compactor_check_threshold(
messages: Vec<CompactableMessage>,
@@ -528,6 +531,7 @@ pub fn compactor_check_threshold(
}
/// Execute compaction
// @connected
#[tauri::command]
pub async fn compactor_compact(
messages: Vec<CompactableMessage>,

View File

@@ -708,6 +708,7 @@ pub type HeartbeatEngineState = Arc<Mutex<HashMap<String, HeartbeatEngine>>>;
///
/// Restores persisted interaction time from VikingStorage so idle-greeting
/// check works correctly across app restarts.
// @connected
#[tauri::command]
pub async fn heartbeat_init(
agent_id: String,
@@ -756,6 +757,7 @@ async fn restore_last_interaction(agent_id: &str) {
}
/// Start heartbeat engine for an agent
// @connected
#[tauri::command]
pub async fn heartbeat_start(
agent_id: String,
@@ -770,6 +772,7 @@ pub async fn heartbeat_start(
}
/// Stop heartbeat engine for an agent
// @connected
#[tauri::command]
pub async fn heartbeat_stop(
agent_id: String,
@@ -784,6 +787,7 @@ pub async fn heartbeat_stop(
}
/// Execute a single heartbeat tick
// @connected
#[tauri::command]
pub async fn heartbeat_tick(
agent_id: String,
@@ -797,6 +801,7 @@ pub async fn heartbeat_tick(
}
/// Get heartbeat configuration
// @connected
#[tauri::command]
pub async fn heartbeat_get_config(
agent_id: String,
@@ -810,6 +815,7 @@ pub async fn heartbeat_get_config(
}
/// Update heartbeat configuration
// @connected
#[tauri::command]
pub async fn heartbeat_update_config(
agent_id: String,
@@ -825,6 +831,7 @@ pub async fn heartbeat_update_config(
}
/// Get heartbeat history
// @connected
#[tauri::command]
pub async fn heartbeat_get_history(
agent_id: String,
@@ -840,6 +847,7 @@ pub async fn heartbeat_get_history(
/// Update memory stats cache for heartbeat checks
/// This should be called by the frontend after fetching memory stats
// @connected
#[tauri::command]
pub async fn heartbeat_update_memory_stats(
agent_id: String,
@@ -852,6 +860,7 @@ pub async fn heartbeat_update_memory_stats(
}
/// Record a user correction for personality improvement detection
// @connected
#[tauri::command]
pub async fn heartbeat_record_correction(
agent_id: String,
@@ -863,6 +872,7 @@ pub async fn heartbeat_record_correction(
/// Record a user interaction for idle greeting detection
/// Call this from frontend whenever user sends a message
// @connected
#[tauri::command]
pub async fn heartbeat_record_interaction(
agent_id: String,

View File

@@ -545,6 +545,7 @@ use tokio::sync::Mutex;
pub type IdentityManagerState = Arc<Mutex<AgentIdentityManager>>;
/// Initialize identity manager
// @reserved: 暂无前端集成
#[tauri::command]
#[allow(dead_code)] // NOT registered in invoke_handler — identity state is initialized lazily via identity_get
pub async fn identity_init() -> Result<IdentityManagerState, String> {
@@ -552,6 +553,7 @@ pub async fn identity_init() -> Result<IdentityManagerState, String> {
}
/// Get identity files for an agent
// @connected
#[tauri::command]
pub async fn identity_get(
agent_id: String,
@@ -562,6 +564,7 @@ pub async fn identity_get(
}
/// Get a specific file
// @connected
#[tauri::command]
pub async fn identity_get_file(
agent_id: String,
@@ -578,6 +581,7 @@ pub async fn identity_get_file(
}
/// Build system prompt
// @connected
#[tauri::command]
pub async fn identity_build_prompt(
agent_id: String,
@@ -589,6 +593,7 @@ pub async fn identity_build_prompt(
}
/// Update user profile (auto)
// @connected
#[tauri::command]
pub async fn identity_update_user_profile(
agent_id: String,
@@ -601,6 +606,7 @@ pub async fn identity_update_user_profile(
}
/// Append to user profile
// @connected
#[tauri::command]
pub async fn identity_append_user_profile(
agent_id: String,
@@ -613,6 +619,7 @@ pub async fn identity_append_user_profile(
}
/// Propose a change
// @connected
#[tauri::command]
pub async fn identity_propose_change(
agent_id: String,
@@ -631,6 +638,7 @@ pub async fn identity_propose_change(
}
/// Approve a proposal
// @connected
#[tauri::command]
pub async fn identity_approve_proposal(
proposal_id: String,
@@ -641,6 +649,7 @@ pub async fn identity_approve_proposal(
}
/// Reject a proposal
// @connected
#[tauri::command]
pub async fn identity_reject_proposal(
proposal_id: String,
@@ -651,6 +660,7 @@ pub async fn identity_reject_proposal(
}
/// Get pending proposals
// @connected
#[tauri::command]
pub async fn identity_get_pending_proposals(
agent_id: Option<String>,
@@ -665,6 +675,7 @@ pub async fn identity_get_pending_proposals(
}
/// Update file directly
// @connected
#[tauri::command]
pub async fn identity_update_file(
agent_id: String,
@@ -677,6 +688,7 @@ pub async fn identity_update_file(
}
/// Get snapshots
// @connected
#[tauri::command]
pub async fn identity_get_snapshots(
agent_id: String,
@@ -692,6 +704,7 @@ pub async fn identity_get_snapshots(
}
/// Restore snapshot
// @connected
#[tauri::command]
pub async fn identity_restore_snapshot(
agent_id: String,
@@ -703,6 +716,7 @@ pub async fn identity_restore_snapshot(
}
/// List agents
// @connected
#[tauri::command]
pub async fn identity_list_agents(
state: tauri::State<'_, IdentityManagerState>,
@@ -712,6 +726,7 @@ pub async fn identity_list_agents(
}
/// Delete agent identity
// @connected
#[tauri::command]
pub async fn identity_delete_agent(
agent_id: String,

View File

@@ -719,6 +719,7 @@ pub type ReflectionEngineState = Arc<Mutex<ReflectionEngine>>;
/// Initialize reflection engine with config
/// Updates the shared state with new configuration
// @connected
#[tauri::command]
pub async fn reflection_init(
config: Option<ReflectionConfig>,
@@ -732,6 +733,7 @@ pub async fn reflection_init(
}
/// Record a conversation
// @connected
#[tauri::command]
pub async fn reflection_record_conversation(
state: tauri::State<'_, ReflectionEngineState>,
@@ -742,6 +744,7 @@ pub async fn reflection_record_conversation(
}
/// Check if reflection should run
// @connected
#[tauri::command]
pub async fn reflection_should_reflect(
state: tauri::State<'_, ReflectionEngineState>,
@@ -751,6 +754,7 @@ pub async fn reflection_should_reflect(
}
/// Execute reflection
// @connected
#[tauri::command]
pub async fn reflection_reflect(
agent_id: String,
@@ -766,6 +770,7 @@ pub async fn reflection_reflect(
/// Returns in-memory history first. If empty and an agent_id is provided,
/// falls back to the persisted history array from VikingStorage metadata,
/// then to the single latest result for backward compatibility.
// @connected
#[tauri::command]
pub async fn reflection_get_history(
limit: Option<usize>,
@@ -815,6 +820,7 @@ pub async fn reflection_get_history(
}
/// Get reflection state
// @connected
#[tauri::command]
pub async fn reflection_get_state(
state: tauri::State<'_, ReflectionEngineState>,