Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/apps/cli/src/modes/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ impl ChatMode {
Ok(exit_reason)
}

#[allow(clippy::too_many_arguments)]
fn handle_key_event(
&self,
key: KeyEvent,
Expand Down
21 changes: 7 additions & 14 deletions src/apps/cli/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,13 @@ impl Session {
/// Add or update text flow of the last message
pub fn update_last_message_text_flow(&mut self, content: String, is_streaming: bool) {
if let Some(last_message) = self.messages.last_mut() {
if let Some(last_item) = last_message.flow_items.last_mut() {
if let FlowItem::Text {
content: ref mut c,
is_streaming: ref mut s,
} = last_item
{
*c = content.clone();
*s = is_streaming;
} else {
last_message.flow_items.push(FlowItem::Text {
content: content.clone(),
is_streaming,
});
}
if let Some(FlowItem::Text {
content: ref mut c,
is_streaming: ref mut s,
}) = last_message.flow_items.last_mut()
{
*c = content.clone();
*s = is_streaming;
} else {
last_message.flow_items.push(FlowItem::Text {
content: content.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/apps/cli/src/ui/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl ChatView {

fn render_messages(&mut self, frame: &mut Frame, area: Rect) {
let title = if self.browse_mode {
format!(" Conversation [Browse Mode ↕] ")
" Conversation [Browse Mode ↕] ".to_string()
} else {
" Conversation ".to_string()
};
Expand Down
2 changes: 1 addition & 1 deletion src/apps/cli/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl MarkdownRenderer {
}

// Remove trailing empty lines
while lines.last().map_or(false, |line| {
while lines.last().is_some_and(|line| {
line.spans.is_empty() || (line.spans.len() == 1 && line.spans[0].content.is_empty())
}) {
lines.pop();
Expand Down
23 changes: 9 additions & 14 deletions src/apps/cli/src/ui/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,12 @@ impl StartupPage {
lines.push(Line::from(""));

if use_fancy_logo {
let logo = vec![
" ██████╗ ██╗████████╗███████╗██╗ ██╗███╗ ██╗",
let logo = [" ██████╗ ██╗████████╗███████╗██╗ ██╗███╗ ██╗",
" ██╔══██╗██║╚══██╔══╝██╔════╝██║ ██║████╗ ██║",
" ██████╔╝██║ ██║ █████╗ ██║ ██║██╔██╗ ██║",
" ██╔══██╗██║ ██║ ██╔══╝ ██║ ██║██║╚██╗██║",
" ██████╔╝██║ ██║ ██║ ╚██████╔╝██║ ╚████║",
" ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝",
];
" ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝"];

let colors = [
Color::Rgb(255, 0, 100),
Expand All @@ -336,13 +334,11 @@ impl StartupPage {
)));
}
} else {
let logo = vec![
" ____ _ _ _____ ",
let logo = [" ____ _ _ _____ ",
" | __ )(_) |_| ___| _ _ __ ",
" | _ \\| | __| |_ | | | | '_ \\ ",
" | |_) | | |_| _|| |_| | | | |",
" |____/|_|\\__|_| \\__,_|_| |_|",
];
" |____/|_|\\__|_| \\__,_|_| |_|"];

let colors = [
Color::Cyan,
Expand Down Expand Up @@ -887,7 +883,9 @@ impl StartupPage {
PageState::Finished(StartupResult::Exit),
);

let result = match page_state {


match page_state {
PageState::MainMenu => {
self.page_state = PageState::MainMenu;
self.handle_main_menu_key(key)
Expand Down Expand Up @@ -956,9 +954,7 @@ impl StartupPage {
self.page_state = PageState::Finished(result);
Ok(())
}
};

result
}
}

fn handle_main_menu_key(&mut self, key: KeyEvent) -> Result<()> {
Expand Down Expand Up @@ -1091,9 +1087,8 @@ impl StartupPage {
let path = path.trim();

// Handle paths starting with ~
if path.starts_with('~') {
if let Some(rest) = path.strip_prefix('~') {
if let Some(home) = dirs::home_dir() {
let rest = &path[1..];
return home
.join(rest.trim_start_matches('/'))
.to_string_lossy()
Expand Down
2 changes: 1 addition & 1 deletion src/apps/cli/src/ui/string_utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// String processing utilities
//! String processing utilities
/// Safely truncate string to specified byte length
pub fn truncate_str(s: &str, max_bytes: usize) -> String {
Expand Down
12 changes: 6 additions & 6 deletions src/apps/desktop/src/api/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,7 @@ pub async fn open_remote_workspace(
let stable_workspace_id = remote_workspace_stable_id(&ssh_host, &remote_path);

let display_name = remote_path
.split('/')
.filter(|s| !s.is_empty())
.last()
.split('/').rfind(|s| !s.is_empty())
.unwrap_or(remote_path.as_str())
.to_string();

Expand Down Expand Up @@ -1596,8 +1594,10 @@ pub async fn write_file_content(
}

let full_path = request.file_path;
let mut options = FileOperationOptions::default();
options.backup_on_overwrite = false;
let options = FileOperationOptions {
backup_on_overwrite: false,
..FileOperationOptions::default()
};

match state
.filesystem_service
Expand Down Expand Up @@ -2000,7 +2000,7 @@ pub async fn reveal_in_explorer(request: RevealInExplorerRequest) -> Result<(),
} else {
let normalized_path = request.path.replace("/", "\\");
bitfun_core::util::process_manager::create_command("explorer")
.args(&["/select,", &normalized_path])
.args(["/select,", &normalized_path])
.spawn()
.map_err(|e| format!("Failed to open explorer: {}", e))?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/desktop/src/api/computer_use_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub async fn computer_use_open_system_settings(
#[cfg(target_os = "windows")]
{
let _ = request;
return Err("Open system settings is not wired for Windows yet.".to_string());
Err("Open system settings is not wired for Windows yet.".to_string())
}
#[cfg(target_os = "linux")]
{
Expand Down
10 changes: 5 additions & 5 deletions src/apps/desktop/src/api/config_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub async fn get_mode_configs(_state: State<'_, AppState>) -> Result<Value, Stri
.await
.map_err(|e| format!("Failed to get mode configs: {}", e))?;

Ok(to_json_value(mode_configs, "mode configs")?)
to_json_value(mode_configs, "mode configs")
}

#[tauri::command]
Expand All @@ -262,7 +262,7 @@ pub async fn get_mode_config(
.await
.map_err(|e| format!("Failed to get mode config: {}", e))?;

Ok(to_json_value(config, "mode config")?)
to_json_value(config, "mode config")
}

#[tauri::command]
Expand Down Expand Up @@ -361,8 +361,8 @@ pub async fn get_subagent_configs(state: State<'_, AppState>) -> Result<Value, S

for subagent in all_subagents {
let subagent_id = subagent.id;
if !subagent_configs.contains_key(&subagent_id) {
subagent_configs.insert(subagent_id, SubAgentConfig { enabled: true });
if let std::collections::hash_map::Entry::Vacant(e) = subagent_configs.entry(subagent_id) {
e.insert(SubAgentConfig { enabled: true });
needs_save = true;
}
}
Expand All @@ -383,7 +383,7 @@ pub async fn get_subagent_configs(state: State<'_, AppState>) -> Result<Value, S
}
}

Ok(to_json_value(subagent_configs, "subagent configs")?)
to_json_value(subagent_configs, "subagent configs")
}

#[tauri::command]
Expand Down
2 changes: 1 addition & 1 deletion src/apps/desktop/src/api/i18n_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn i18n_set_language(
_app: tauri::AppHandle,
request: SetLanguageRequest,
) -> Result<String, String> {
let supported = vec!["zh-CN", "en-US"];
let supported = ["zh-CN", "en-US"];
if !supported.contains(&request.language.as_str()) {
return Err(format!("Unsupported language: {}", request.language));
}
Expand Down
6 changes: 1 addition & 5 deletions src/apps/desktop/src/api/mcp_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ pub async fn get_mcp_servers(state: State<'_, AppState>) -> Result<Vec<MCPServer
} else {
false
};
let oauth_enabled = if matches!(config.server_type, MCPServerType::Remote) {
true
} else {
false
};
let oauth_enabled = matches!(config.server_type, MCPServerType::Remote);
let oauth_auth_configured = if oauth_enabled {
has_stored_oauth_credentials(&config.id)
.await
Expand Down
36 changes: 25 additions & 11 deletions src/apps/desktop/src/api/remote_connect_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ async fn ensure_service() -> Result<(), String> {
}
drop(guard);

let mut config = RemoteConnectConfig::default();
config.mobile_web_dir = detect_mobile_web_dir();
let config = RemoteConnectConfig {
mobile_web_dir: detect_mobile_web_dir(),
..RemoteConnectConfig::default()
};
let service =
RemoteConnectService::new(config).map_err(|e| format!("init remote connect: {e}"))?;
*holder.write().await = Some(service);
Expand Down Expand Up @@ -478,8 +480,10 @@ pub async fn remote_connect_configure_custom_server(url: String) -> Result<(), S
let holder = get_service_holder();
let mut guard = holder.write().await;
if guard.is_none() {
let mut config = RemoteConnectConfig::default();
config.custom_server_url = Some(url);
let config = RemoteConnectConfig {
custom_server_url: Some(url),
..RemoteConnectConfig::default()
};
let service = RemoteConnectService::new(config).map_err(|e| format!("init: {e}"))?;
*guard = Some(service);
}
Expand Down Expand Up @@ -530,13 +534,23 @@ pub async fn remote_connect_configure_bot(request: ConfigureBotRequest) -> Resul
};

if guard.is_none() {
let mut config = RemoteConnectConfig::default();
config.mobile_web_dir = detect_mobile_web_dir();
match &bot_config {
BotConfig::Feishu { .. } => config.bot_feishu = Some(bot_config),
BotConfig::Telegram { .. } => config.bot_telegram = Some(bot_config),
BotConfig::Weixin { .. } => config.bot_weixin = Some(bot_config),
}
let config = match bot_config {
BotConfig::Feishu { .. } => RemoteConnectConfig {
mobile_web_dir: detect_mobile_web_dir(),
bot_feishu: Some(bot_config),
..RemoteConnectConfig::default()
},
BotConfig::Telegram { .. } => RemoteConnectConfig {
mobile_web_dir: detect_mobile_web_dir(),
bot_telegram: Some(bot_config),
..RemoteConnectConfig::default()
},
BotConfig::Weixin { .. } => RemoteConnectConfig {
mobile_web_dir: detect_mobile_web_dir(),
bot_weixin: Some(bot_config),
..RemoteConnectConfig::default()
},
};
let service = RemoteConnectService::new(config).map_err(|e| format!("init: {e}"))?;
*guard = Some(service);
} else if let Some(service) = guard.as_mut() {
Expand Down
12 changes: 4 additions & 8 deletions src/apps/desktop/src/api/skill_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,18 +890,14 @@ async fn fill_market_descriptions(client: &Client, base_url: &str, items: &mut [
});

if join_set.len() >= MARKET_DESC_FETCH_CONCURRENCY {
if let Some(result) = join_set.join_next().await {
if let Ok((skill_id, Some(desc))) = result {
fetched.insert(skill_id, desc);
}
if let Some(Ok((skill_id, Some(desc)))) = join_set.join_next().await {
fetched.insert(skill_id, desc);
}
}
}

while let Some(result) = join_set.join_next().await {
if let Ok((skill_id, Some(desc))) = result {
fetched.insert(skill_id, desc);
}
while let Some(Ok((skill_id, Some(desc)))) = join_set.join_next().await {
fetched.insert(skill_id, desc);
}

if fetched.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/desktop/src/api/snapshot_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ pub async fn get_file_change_history(
.await
.map_err(|e| format!("Failed to get file change history: {}", e))?;

Ok(serde_json::to_value(changes).map_err(|e| format!("Serialization failed: {}", e))?)
serde_json::to_value(changes).map_err(|e| format!("Serialization failed: {}", e))
}

#[tauri::command]
Expand Down
4 changes: 2 additions & 2 deletions src/apps/desktop/src/api/storage_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub async fn cleanup_storage(state: State<'_, AppState>) -> Result<CleanupResult
let path_manager = workspace_service.path_manager();

let policy = CleanupPolicy::default();
let cleanup_service = CleanupService::new((&**path_manager).clone(), policy);
let cleanup_service = CleanupService::new((**path_manager).clone(), policy);

cleanup_service
.cleanup_all()
Expand All @@ -97,7 +97,7 @@ pub async fn cleanup_storage_with_policy(
let workspace_service = &state.workspace_service;
let path_manager = workspace_service.path_manager();

let cleanup_service = CleanupService::new((&**path_manager).clone(), policy);
let cleanup_service = CleanupService::new((**path_manager).clone(), policy);

cleanup_service
.cleanup_all()
Expand Down
7 changes: 3 additions & 4 deletions src/apps/desktop/src/api/subagent_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ fn validate_agent_name(name: &str) -> Result<(), String> {
return Err("Name cannot be empty".to_string());
}
let mut chars = name.chars();
if !chars.next().map_or(false, |c| c.is_ascii_alphabetic()) {
if !chars.next().is_some_and(|c| c.is_ascii_alphabetic()) {
return Err("Name must start with a letter".to_string());
}
for c in chars {
Expand All @@ -214,11 +214,10 @@ pub async fn create_subagent(
validate_agent_name(name)?;
let workspace = workspace_root_from_request(request.workspace_path.as_deref());

if request.level == SubagentLevel::Project {
if workspace.is_none() {
if request.level == SubagentLevel::Project
&& workspace.is_none() {
return Err("Project-level Agent requires opening a workspace first".to_string());
}
}

let modes = state.agent_registry.get_modes_info().await;
let subagents = state
Expand Down
2 changes: 1 addition & 1 deletion src/apps/desktop/src/api/system_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub async fn run_system_command(
.env
.map(|vars| vars.into_iter().map(|v| (v.key, v.value)).collect());

let env_ref: Option<&[(String, String)]> = env_vars.as_ref().map(|v| v.as_slice());
let env_ref: Option<&[(String, String)]> = env_vars.as_deref();

let result = system::run_command(
&request.command,
Expand Down
4 changes: 2 additions & 2 deletions src/apps/desktop/src/api/terminal_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ impl TerminalState {
*initialized = true;
}

Ok(TerminalApi::from_singleton()
.map_err(|e| format!("Terminal API not initialized: {}", e))?)
TerminalApi::from_singleton()
.map_err(|e| format!("Terminal API not initialized: {}", e))
}

/// Get the scripts directory path for shell integration
Expand Down
Loading
Loading