From 09e59c7c28e76911e965ecc3a9dc5b3d503ef007 Mon Sep 17 00:00:00 2001 From: Zaki Date: Sun, 22 Mar 2026 18:28:09 -0700 Subject: [PATCH] style(agent): use match as expression for parsed_thread_uuid Refactor mutable variable + match arm assignment into idiomatic Rust match-as-expression pattern. Also remove unused uuid::Uuid import that was left behind after the parse-once optimization. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/agent/agent_loop.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/agent/agent_loop.rs b/src/agent/agent_loop.rs index a9a3481d..deb09f52 100644 --- a/src/agent/agent_loop.rs +++ b/src/agent/agent_loop.rs @@ -10,7 +10,6 @@ use std::sync::Arc; use futures::StreamExt; -use uuid::Uuid; use crate::agent::context_monitor::ContextMonitor; use crate::agent::heartbeat::spawn_heartbeat; @@ -1005,22 +1004,21 @@ impl Agent { // Hydrate thread from DB if it's a historical thread not in memory. // Capture the parsed UUID to avoid redundant re-parsing downstream. - let mut parsed_thread_uuid: Option = None; - if let Some(external_thread_id) = message.conversation_scope() { + let parsed_thread_uuid = if let Some(external_thread_id) = message.conversation_scope() { tracing::trace!( message_id = %message.id, thread_id = %external_thread_id, "Hydrating thread from DB" ); match self.maybe_hydrate_thread(message, external_thread_id).await { - Ok(uuid) => { - parsed_thread_uuid = uuid; - } + Ok(uuid) => uuid, Err(rejection) => { return Ok(Some(format!("Error: {}", rejection))); } } - } + } else { + None + }; // Resolve session and thread. Approval submissions are allowed to // target an already-loaded owned thread by UUID across channels so the