Updated dependencies, fixed some clippy warnings

This commit is contained in:
Dave
2026-01-26 18:15:29 +00:00
parent c2da7f9f18
commit 1f1f5f6dac
5 changed files with 299 additions and 289 deletions
+17 -13
View File
@@ -111,15 +111,17 @@ pub async fn get_current_project(
.store(STORE_PATH)
.map_err(|e| format!("Failed to access store: {}", e))?;
if let Some(val) = store.get(KEY_LAST_PROJECT) {
if let Some(path_str) = val.as_str() {
let p = PathBuf::from(path_str);
if p.exists() && p.is_dir() {
// Update session state
let mut root = state.project_root.lock().map_err(|e| e.to_string())?;
*root = Some(p.clone());
return Ok(Some(path_str.to_string()));
}
if let Some(path_str) = store
.get(KEY_LAST_PROJECT)
.as_ref()
.and_then(|val| val.as_str())
{
let p = PathBuf::from(path_str);
if p.exists() && p.is_dir() {
// Update session state
let mut root = state.project_root.lock().map_err(|e| e.to_string())?;
*root = Some(p.clone());
return Ok(Some(path_str.to_string()));
}
}
@@ -132,10 +134,12 @@ pub async fn get_model_preference(app: AppHandle) -> Result<Option<String>, Stri
.store(STORE_PATH)
.map_err(|e| format!("Failed to access store: {}", e))?;
if let Some(val) = store.get(KEY_SELECTED_MODEL) {
if let Some(model) = val.as_str() {
return Ok(Some(model.to_string()));
}
if let Some(model) = store
.get(KEY_SELECTED_MODEL)
.as_ref()
.and_then(|val| val.as_str())
{
return Ok(Some(model.to_string()));
}
Ok(None)
}
+13 -16
View File
@@ -2,7 +2,7 @@ use crate::llm::types::{
CompletionResponse, FunctionCall, Message, Role, ToolCall, ToolDefinition,
};
use futures::StreamExt;
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
use reqwest::header::{CONTENT_TYPE, HeaderMap, HeaderValue};
use serde::{Deserialize, Serialize};
use serde_json::json;
use tauri::{AppHandle, Emitter};
@@ -270,13 +270,12 @@ impl AnthropicProvider {
match event.event_type.as_str() {
"content_block_start" => {
// Check if this is a tool use block
if let Some(content_block) = event.data.get("content_block") {
if content_block.get("type") == Some(&json!("tool_use")) {
let id = content_block["id"].as_str().unwrap_or("").to_string();
let name =
content_block["name"].as_str().unwrap_or("").to_string();
current_tool_use = Some((id, name, String::new()));
}
if let Some(content_block) = event.data.get("content_block")
&& content_block.get("type") == Some(&json!("tool_use"))
{
let id = content_block["id"].as_str().unwrap_or("").to_string();
let name = content_block["name"].as_str().unwrap_or("").to_string();
current_tool_use = Some((id, name, String::new()));
}
}
"content_block_delta" => {
@@ -290,14 +289,12 @@ impl AnthropicProvider {
}
}
// Tool input delta
else if delta.get("type") == Some(&json!("input_json_delta")) {
if let Some((_, _, input_json)) = &mut current_tool_use {
if let Some(partial) =
delta.get("partial_json").and_then(|p| p.as_str())
{
input_json.push_str(partial);
}
}
else if delta.get("type") == Some(&json!("input_json_delta"))
&& let Some((_, _, input_json)) = &mut current_tool_use
&& let Some(partial) =
delta.get("partial_json").and_then(|p| p.as_str())
{
input_json.push_str(partial);
}
}
}