处理#[allow(dead_code)]代码
This commit is contained in:
@@ -115,6 +115,7 @@ async fn build_agent(
|
|||||||
app_handle: &tauri::AppHandle,
|
app_handle: &tauri::AppHandle,
|
||||||
) -> Result<AcpAgent, AcpError> {
|
) -> Result<AcpAgent, AcpError> {
|
||||||
let meta = registry::get_agent_meta(agent_type);
|
let meta = registry::get_agent_meta(agent_type);
|
||||||
|
debug_assert_eq!(meta.agent_type, agent_type);
|
||||||
|
|
||||||
match meta.distribution {
|
match meta.distribution {
|
||||||
AgentDistribution::Npx {
|
AgentDistribution::Npx {
|
||||||
|
|||||||
@@ -10,14 +10,8 @@ pub enum AcpError {
|
|||||||
Protocol(String),
|
Protocol(String),
|
||||||
#[error("agent process exited unexpectedly")]
|
#[error("agent process exited unexpectedly")]
|
||||||
ProcessExited,
|
ProcessExited,
|
||||||
#[allow(dead_code)]
|
|
||||||
#[error("conversation error: {0}")]
|
|
||||||
Conversation(String),
|
|
||||||
#[error("binary download failed: {0}")]
|
#[error("binary download failed: {0}")]
|
||||||
DownloadFailed(String),
|
DownloadFailed(String),
|
||||||
#[allow(dead_code)]
|
|
||||||
#[error("agent not found: {0}")]
|
|
||||||
AgentNotFound(String),
|
|
||||||
#[error("platform not supported: {0}")]
|
#[error("platform not supported: {0}")]
|
||||||
PlatformNotSupported(String),
|
PlatformNotSupported(String),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,8 @@ static UVX_ENV_CACHE: Mutex<Option<Vec<CheckItem>>> = Mutex::new(None);
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub enum FixActionKind {
|
pub enum FixActionKind {
|
||||||
OpenUrl,
|
OpenUrl,
|
||||||
RedownloadBinary,
|
|
||||||
RetryConnection,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
@@ -57,6 +54,7 @@ pub struct PreflightResult {
|
|||||||
|
|
||||||
pub async fn run_preflight(agent_type: AgentType) -> PreflightResult {
|
pub async fn run_preflight(agent_type: AgentType) -> PreflightResult {
|
||||||
let meta = registry::get_agent_meta(agent_type);
|
let meta = registry::get_agent_meta(agent_type);
|
||||||
|
debug_assert_eq!(meta.agent_type, agent_type);
|
||||||
let checks = match &meta.distribution {
|
let checks = match &meta.distribution {
|
||||||
AgentDistribution::Npx { node_required, .. } => check_npx_environment(*node_required).await,
|
AgentDistribution::Npx { node_required, .. } => check_npx_environment(*node_required).await,
|
||||||
AgentDistribution::Uvx { .. } => check_uvx_environment().await,
|
AgentDistribution::Uvx { .. } => check_uvx_environment().await,
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ pub struct PlatformBinary {
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AcpAgentMeta {
|
pub struct AcpAgentMeta {
|
||||||
#[allow(dead_code)]
|
|
||||||
pub agent_type: AgentType,
|
pub agent_type: AgentType,
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
pub description: &'static str,
|
pub description: &'static str,
|
||||||
@@ -127,7 +126,6 @@ pub fn registry_id_for(agent_type: AgentType) -> &'static str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn from_registry_id(id: &str) -> Option<AgentType> {
|
pub fn from_registry_id(id: &str) -> Option<AgentType> {
|
||||||
match id {
|
match id {
|
||||||
"auggie" => Some(AgentType::Auggie),
|
"auggie" => Some(AgentType::Auggie),
|
||||||
@@ -155,6 +153,7 @@ pub fn from_registry_id(id: &str) -> Option<AgentType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_agent_meta(agent_type: AgentType) -> AcpAgentMeta {
|
pub fn get_agent_meta(agent_type: AgentType) -> AcpAgentMeta {
|
||||||
|
debug_assert_eq!(from_registry_id(registry_id_for(agent_type)), Some(agent_type));
|
||||||
match agent_type {
|
match agent_type {
|
||||||
AgentType::Auggie => AcpAgentMeta {
|
AgentType::Auggie => AcpAgentMeta {
|
||||||
agent_type,
|
agent_type,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use serde::Serialize;
|
|||||||
|
|
||||||
use crate::db::error::DbError;
|
use crate::db::error::DbError;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug, Clone, Copy, Serialize)]
|
#[derive(Debug, Clone, Copy, Serialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum AppErrorCode {
|
pub enum AppErrorCode {
|
||||||
@@ -98,7 +97,6 @@ impl AppCommandError {
|
|||||||
Self::new(AppErrorCode::TaskExecutionFailed, message)
|
Self::new(AppErrorCode::TaskExecutionFailed, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn io(err: std::io::Error) -> Self {
|
pub fn io(err: std::io::Error) -> Self {
|
||||||
let code = match err.kind() {
|
let code = match err.kind() {
|
||||||
std::io::ErrorKind::NotFound => AppErrorCode::NotFound,
|
std::io::ErrorKind::NotFound => AppErrorCode::NotFound,
|
||||||
|
|||||||
@@ -421,10 +421,7 @@ fn parse_error_to_app_error(error: ParseError) -> AppCommandError {
|
|||||||
AppCommandError::invalid_input("Failed to parse conversation file")
|
AppCommandError::invalid_input("Failed to parse conversation file")
|
||||||
.with_detail(err.to_string())
|
.with_detail(err.to_string())
|
||||||
}
|
}
|
||||||
ParseError::Db(err) => AppCommandError::new(
|
ParseError::Db(err) => AppCommandError::database_error("Database operation failed")
|
||||||
crate::app_error::AppErrorCode::DatabaseError,
|
.with_detail(err.to_string()),
|
||||||
"Database operation failed",
|
|
||||||
)
|
|
||||||
.with_detail(err.to_string()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ pub enum DbError {
|
|||||||
Database(#[from] sea_orm::DbErr),
|
Database(#[from] sea_orm::DbErr),
|
||||||
#[error("migration error: {0}")]
|
#[error("migration error: {0}")]
|
||||||
Migration(String),
|
Migration(String),
|
||||||
#[allow(dead_code)]
|
|
||||||
#[error("database not initialized")]
|
|
||||||
NotInitialized,
|
|
||||||
#[error("io error: {0}")]
|
#[error("io error: {0}")]
|
||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use error::DbError;
|
|||||||
use migration::Migrator;
|
use migration::Migrator;
|
||||||
|
|
||||||
pub struct AppDatabase {
|
pub struct AppDatabase {
|
||||||
#[allow(dead_code)]
|
|
||||||
pub conn: DatabaseConnection,
|
pub conn: DatabaseConnection,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ pub enum ParseError {
|
|||||||
Db(#[from] sea_orm::DbErr),
|
Db(#[from] sea_orm::DbErr),
|
||||||
#[error("Conversation not found: {0}")]
|
#[error("Conversation not found: {0}")]
|
||||||
ConversationNotFound(String),
|
ConversationNotFound(String),
|
||||||
#[allow(dead_code)]
|
|
||||||
#[error("Invalid data: {0}")]
|
#[error("Invalid data: {0}")]
|
||||||
InvalidData(String),
|
InvalidData(String),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ use super::types::{TerminalEvent, TerminalInfo};
|
|||||||
struct TerminalInstance {
|
struct TerminalInstance {
|
||||||
write_tx: mpsc::Sender<Vec<u8>>,
|
write_tx: mpsc::Sender<Vec<u8>>,
|
||||||
master: Box<dyn MasterPty + Send>,
|
master: Box<dyn MasterPty + Send>,
|
||||||
#[allow(dead_code)]
|
_child: Box<dyn portable_pty::Child + Send>,
|
||||||
child: Box<dyn portable_pty::Child + Send>,
|
|
||||||
title: String,
|
title: String,
|
||||||
owner_window_label: String,
|
owner_window_label: String,
|
||||||
}
|
}
|
||||||
@@ -185,7 +184,7 @@ impl TerminalManager {
|
|||||||
let instance = TerminalInstance {
|
let instance = TerminalInstance {
|
||||||
write_tx,
|
write_tx,
|
||||||
master: pair.master,
|
master: pair.master,
|
||||||
child,
|
_child: child,
|
||||||
title: "Terminal".to_string(),
|
title: "Terminal".to_string(),
|
||||||
owner_window_label,
|
owner_window_label,
|
||||||
};
|
};
|
||||||
@@ -264,7 +263,7 @@ impl TerminalManager {
|
|||||||
// Windows ConPTY may not always surface EOF promptly; reconcile exited
|
// Windows ConPTY may not always surface EOF promptly; reconcile exited
|
||||||
// child processes here so frontend running-state can recover reliably.
|
// child processes here so frontend running-state can recover reliably.
|
||||||
for (id, instance) in terminals.iter_mut() {
|
for (id, instance) in terminals.iter_mut() {
|
||||||
match instance.child.try_wait() {
|
match instance._child.try_wait() {
|
||||||
Ok(Some(_)) => exited_terminal_ids.push(id.clone()),
|
Ok(Some(_)) => exited_terminal_ids.push(id.clone()),
|
||||||
Ok(None) => {}
|
Ok(None) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -332,8 +331,8 @@ impl TerminalManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn terminate_terminal(instance: &mut TerminalInstance) {
|
fn terminate_terminal(instance: &mut TerminalInstance) {
|
||||||
let _ = instance.child.kill();
|
let _ = instance._child.kill();
|
||||||
let _ = instance.child.wait();
|
let _ = instance._child.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_loop(mut writer: Box<dyn Write + Send>, rx: mpsc::Receiver<Vec<u8>>) {
|
fn write_loop(mut writer: Box<dyn Write + Send>, rx: mpsc::Receiver<Vec<u8>>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user