mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-26 23:50:17 +00:00
fix: convert remaining let-chains to nested ifs for MSRV compat
Refactor four let-chain patterns (`if let ... && ...`) in process_approval() to use nested `if`/`if let` blocks. Let-chains require `#![feature(let_chains)]` which is not available on our MSRV. Add `#[allow(clippy::collapsible_if)]` with a comment explaining why. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
+54
-49
@@ -945,6 +945,10 @@ impl Agent {
|
||||
}
|
||||
|
||||
/// Process an approval or rejection of a pending tool execution.
|
||||
// Nested `if` blocks are intentional: collapsing them would produce
|
||||
// `if let … && …` (let-chains), which require `#![feature(let_chains)]`
|
||||
// and are not available on our MSRV.
|
||||
#[allow(clippy::collapsible_if)]
|
||||
pub(super) async fn process_approval(
|
||||
&self,
|
||||
message: &IncomingMessage,
|
||||
@@ -987,14 +991,14 @@ impl Agent {
|
||||
};
|
||||
|
||||
// Verify request ID while still holding the lock — atomic with take
|
||||
if let Some(req_id) = request_id
|
||||
&& req_id != taken.request_id
|
||||
{
|
||||
// Restore atomically under same lock
|
||||
thread.await_approval(taken);
|
||||
return Ok(SubmissionResult::error(
|
||||
"Request ID mismatch. Use the correct request ID.",
|
||||
));
|
||||
if let Some(req_id) = request_id {
|
||||
if req_id != taken.request_id {
|
||||
// Restore atomically under same lock
|
||||
thread.await_approval(taken);
|
||||
return Ok(SubmissionResult::error(
|
||||
"Request ID mismatch. Use the correct request ID.",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
taken
|
||||
@@ -1079,20 +1083,20 @@ impl Agent {
|
||||
)
|
||||
.await;
|
||||
|
||||
if let Ok(ref output) = tool_result
|
||||
&& !output.is_empty()
|
||||
{
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(
|
||||
&message.channel,
|
||||
StatusUpdate::ToolResult {
|
||||
name: pending.tool_name.clone(),
|
||||
preview: output.clone(),
|
||||
},
|
||||
&message.metadata,
|
||||
)
|
||||
.await;
|
||||
if let Ok(ref output) = tool_result {
|
||||
if !output.is_empty() {
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(
|
||||
&message.channel,
|
||||
StatusUpdate::ToolResult {
|
||||
name: pending.tool_name.clone(),
|
||||
preview: output.clone(),
|
||||
},
|
||||
&message.metadata,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
// Build context including the tool result
|
||||
@@ -1345,20 +1349,20 @@ impl Agent {
|
||||
let mut deferred_auth: Option<String> = None;
|
||||
|
||||
for (tc, deferred_result) in exec_results {
|
||||
if let Ok(ref output) = deferred_result
|
||||
&& !output.is_empty()
|
||||
{
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(
|
||||
&message.channel,
|
||||
StatusUpdate::ToolResult {
|
||||
name: tc.name.clone(),
|
||||
preview: output.clone(),
|
||||
},
|
||||
&message.metadata,
|
||||
)
|
||||
.await;
|
||||
if let Ok(ref output) = deferred_result {
|
||||
if !output.is_empty() {
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(
|
||||
&message.channel,
|
||||
StatusUpdate::ToolResult {
|
||||
name: tc.name.clone(),
|
||||
preview: output.clone(),
|
||||
},
|
||||
&message.metadata,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize first, then record the cleaned version in thread.
|
||||
@@ -1395,20 +1399,21 @@ impl Agent {
|
||||
}
|
||||
|
||||
// Auth detection — defer return until all results are recorded
|
||||
if deferred_auth.is_none()
|
||||
&& let Some((ext_name, instructions)) =
|
||||
if deferred_auth.is_none() {
|
||||
if let Some((ext_name, instructions)) =
|
||||
check_auth_required(&tc.name, &deferred_result)
|
||||
{
|
||||
self.handle_auth_intercept(
|
||||
&session,
|
||||
thread_id,
|
||||
message,
|
||||
&deferred_result,
|
||||
ext_name,
|
||||
instructions.clone(),
|
||||
)
|
||||
.await;
|
||||
deferred_auth = Some(instructions);
|
||||
{
|
||||
self.handle_auth_intercept(
|
||||
&session,
|
||||
thread_id,
|
||||
message,
|
||||
&deferred_result,
|
||||
ext_name,
|
||||
instructions.clone(),
|
||||
)
|
||||
.await;
|
||||
deferred_auth = Some(instructions);
|
||||
}
|
||||
}
|
||||
|
||||
context_messages.push(ChatMessage::tool_result(&tc.id, &tc.name, deferred_content));
|
||||
|
||||
Reference in New Issue
Block a user