Skip to content

Commit 77c995c

Browse files
committed
chore: cargo fmt
1 parent 923ca42 commit 77c995c

19 files changed

Lines changed: 170 additions & 199 deletions

File tree

‎Makefile‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help dev build lint check test ci release-retry release-patch release-minor release-major tag-delete
1+
.PHONY: help dev build fmt fmt-check lint check test ci release-retry release-patch release-minor release-major tag-delete
22

33
# Get current version from package.json
44
VERSION := $(shell node -p "require('./package.json').version")
@@ -16,6 +16,12 @@ build: ## Build the application
1616

1717
# CI/Linting targets
1818

19+
fmt: ## Format code with cargo fmt
20+
cd src-tauri && cargo fmt
21+
22+
fmt-check: ## Check code formatting (same as CI)
23+
cd src-tauri && cargo fmt -- --check
24+
1925
lint: ## Run clippy with warnings as errors (same as CI)
2026
cd src-tauri && cargo clippy -- -D warnings
2127

@@ -25,7 +31,7 @@ check: ## Run cargo check (fast compilation check)
2531
test: ## Run cargo tests
2632
cd src-tauri && cargo test
2733

28-
ci: lint test ## Run all CI checks locally (lint + test)
34+
ci: fmt-check lint test ## Run all CI checks locally (fmt + lint + test)
2935

3036
# Release management
3137

‎src-tauri/src/api/client.rs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ pub fn create_client() -> Client {
7575
);
7676

7777
// Set Accept header to prefer JSON responses
78-
default_headers.insert(
79-
header::ACCEPT,
80-
HeaderValue::from_static("application/json"),
81-
);
78+
default_headers.insert(header::ACCEPT, HeaderValue::from_static("application/json"));
8279

8380
Client::builder()
8481
// No default timeout - set per-request based on endpoint type

‎src-tauri/src/api/error.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ mod tests {
330330
let parsed: serde_json::Value = serde_json::from_str(&json).unwrap();
331331
assert_eq!(parsed["errorCode"], "unauthorized");
332332
assert_eq!(parsed["errorMsgKey"], "ErrUnauthorized");
333-
assert_eq!(parsed["errorMessage"], "Authentication failed - please login again");
333+
assert_eq!(
334+
parsed["errorMessage"],
335+
"Authentication failed - please login again"
336+
);
334337
}
335338

336339
#[test]

‎src-tauri/src/api/netdata.rs‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ impl NetdataApi {
8585
.map_err(|e| ApiError::ParseError(e.to_string()))
8686
} else {
8787
// Try to parse the error response body to extract Netdata error details
88-
let netdata_error: Option<NetdataErrorResponse> = response
89-
.json()
90-
.await
91-
.ok(); // If parsing fails, we'll use defaults
88+
let netdata_error: Option<NetdataErrorResponse> = response.json().await.ok(); // If parsing fails, we'll use defaults
9289

9390
Err(ApiError::from_response(status, netdata_error))
9491
}
@@ -1016,7 +1013,10 @@ mod tests {
10161013
let user: UserInfo = serde_json::from_str(json).unwrap();
10171014
assert_eq!(user.id, "user123");
10181015
assert_eq!(user.email, "test@example.com");
1019-
assert_eq!(user.avatar_url, Some("https://example.com/avatar.png".to_string()));
1016+
assert_eq!(
1017+
user.avatar_url,
1018+
Some("https://example.com/avatar.png".to_string())
1019+
);
10201020
}
10211021

10221022
#[test]
@@ -1030,6 +1030,9 @@ mod tests {
10301030

10311031
let space: Space = serde_json::from_str(json).unwrap();
10321032
assert_eq!(space.id, "space123");
1033-
assert_eq!(space.permissions, Some(vec!["read".to_string(), "write".to_string()]));
1033+
assert_eq!(
1034+
space.permissions,
1035+
Some(vec!["read".to_string(), "write".to_string()])
1036+
);
10341037
}
10351038
}

‎src-tauri/src/commands/autopilot.rs‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,21 @@ pub async fn get_autopilot_status(
8787
// Determine status based on context
8888
if is_all_nodes_room {
8989
// In All Nodes room - can toggle directly
90-
Ok(AutopilotStatus::available(all_nodes_enabled, has_credits, provider_info))
90+
Ok(AutopilotStatus::available(
91+
all_nodes_enabled,
92+
has_credits,
93+
provider_info,
94+
))
9195
} else if all_nodes_enabled {
9296
// In other room, but All Nodes is enabled - inherited, can't toggle here
9397
Ok(AutopilotStatus::via_all_nodes(has_credits, provider_info))
9498
} else {
9599
// In other room, All Nodes is not enabled - can toggle for this room
96-
Ok(AutopilotStatus::available(current_room_enabled, has_credits, provider_info))
100+
Ok(AutopilotStatus::available(
101+
current_room_enabled,
102+
has_credits,
103+
provider_info,
104+
))
97105
}
98106
}
99107

‎src-tauri/src/config/mod.rs‎

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
1212
pub mod types;
1313

14-
pub use types::{AiProvider, AutopilotStatus, ClaiConfig, ProviderInfo, SpaceAutopilot, SpaceConfig};
14+
pub use types::{
15+
AiProvider, AutopilotStatus, ClaiConfig, ProviderInfo, SpaceAutopilot, SpaceConfig,
16+
};
1517

1618
use std::fs;
1719
use std::io::Write;
@@ -80,9 +82,7 @@ impl ConfigManager {
8082
source: e,
8183
})?;
8284

83-
serde_json::from_str(&contents).map_err(|e| ConfigError::Parse {
84-
source: e,
85-
})
85+
serde_json::from_str(&contents).map_err(|e| ConfigError::Parse { source: e })
8686
}
8787

8888
/// Saves the current config to disk.
@@ -95,9 +95,8 @@ impl ConfigManager {
9595

9696
/// Saves config to file with atomic write.
9797
fn save_to_file(&self, config: &ClaiConfig) -> Result<(), ConfigError> {
98-
let json = serde_json::to_string_pretty(config).map_err(|e| ConfigError::Serialize {
99-
source: e,
100-
})?;
98+
let json = serde_json::to_string_pretty(config)
99+
.map_err(|e| ConfigError::Serialize { source: e })?;
101100

102101
// Write to temp file first
103102
let temp_path = self.config_path.with_extension("json.tmp");
@@ -107,10 +106,11 @@ impl ConfigManager {
107106
source: e,
108107
})?;
109108

110-
file.write_all(json.as_bytes()).map_err(|e| ConfigError::Io {
111-
operation: "write temp config file".to_string(),
112-
source: e,
113-
})?;
109+
file.write_all(json.as_bytes())
110+
.map_err(|e| ConfigError::Io {
111+
operation: "write temp config file".to_string(),
112+
source: e,
113+
})?;
114114

115115
file.sync_all().map_err(|e| ConfigError::Io {
116116
operation: "sync temp config file".to_string(),
@@ -152,11 +152,7 @@ impl ConfigManager {
152152
/// Gets config for a space.
153153
pub fn get_space_config(&self, space_id: &str) -> SpaceConfig {
154154
let config = self.config.lock().unwrap();
155-
config
156-
.spaces
157-
.get(space_id)
158-
.cloned()
159-
.unwrap_or_default()
155+
config.spaces.get(space_id).cloned().unwrap_or_default()
160156
}
161157

162158
// =========================================================================
@@ -176,10 +172,7 @@ impl ConfigManager {
176172
/// Enables auto-pilot for a room and saves config.
177173
pub fn enable_autopilot(&self, space_id: &str, room_id: &str) -> Result<(), ConfigError> {
178174
self.update(|config| {
179-
let space_config = config
180-
.spaces
181-
.entry(space_id.to_string())
182-
.or_default();
175+
let space_config = config.spaces.entry(space_id.to_string()).or_default();
183176
space_config.autopilot.enable_room(room_id);
184177
})
185178
}
@@ -321,7 +314,12 @@ mod tests {
321314

322315
// Load from file
323316
let loaded = ConfigManager::load_from_file(&manager.config_path).unwrap();
324-
assert!(loaded.spaces.get("space-1").unwrap().autopilot.is_room_enabled("room-1"));
317+
assert!(loaded
318+
.spaces
319+
.get("space-1")
320+
.unwrap()
321+
.autopilot
322+
.is_room_enabled("room-1"));
325323
}
326324

327325
#[test]

‎src-tauri/src/config/types.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ pub struct SpaceConfig {
9494
/// Auto-pilot settings for this space.
9595
#[serde(default)]
9696
pub autopilot: SpaceAutopilot,
97-
9897
// Future space-specific settings can be added here:
9998
// pub notifications: SpaceNotificationSettings,
10099
// pub default_room: Option<String>,
@@ -253,7 +252,6 @@ impl AutopilotStatus {
253252
message: Some("Requires AI credits".to_string()),
254253
}
255254
}
256-
257255
}
258256

259257
// =============================================================================
@@ -290,15 +288,22 @@ mod tests {
290288
let mut space_config = SpaceConfig::default();
291289
space_config.autopilot.enable_room("room-abc-123");
292290

293-
config.spaces.insert("space-xyz-456".to_string(), space_config);
291+
config
292+
.spaces
293+
.insert("space-xyz-456".to_string(), space_config);
294294

295295
let json = serde_json::to_string_pretty(&config).unwrap();
296296
assert!(json.contains("space-xyz-456"));
297297
assert!(json.contains("room-abc-123"));
298298

299299
let parsed: ClaiConfig = serde_json::from_str(&json).unwrap();
300300
assert!(parsed.spaces.contains_key("space-xyz-456"));
301-
assert!(parsed.spaces.get("space-xyz-456").unwrap().autopilot.is_room_enabled("room-abc-123"));
301+
assert!(parsed
302+
.spaces
303+
.get("space-xyz-456")
304+
.unwrap()
305+
.autopilot
306+
.is_room_enabled("room-abc-123"));
302307
}
303308

304309
#[test]

‎src-tauri/src/mcp/bridge.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ impl JsBridge {
344344
Ok(response.result.unwrap_or(serde_json::Value::Null))
345345
} else {
346346
Err(BridgeError::ToolFailed(
347-
response.error.unwrap_or_else(|| "Unknown error".to_string()),
347+
response
348+
.error
349+
.unwrap_or_else(|| "Unknown error".to_string()),
348350
))
349351
}
350352
}
@@ -418,10 +420,7 @@ mod tests {
418420

419421
#[test]
420422
fn test_bridge_error_display() {
421-
assert_eq!(
422-
BridgeError::Timeout.to_string(),
423-
"Tool request timed out"
424-
);
423+
assert_eq!(BridgeError::Timeout.to_string(), "Tool request timed out");
425424
assert_eq!(
426425
BridgeError::ChannelClosed.to_string(),
427426
"Response channel closed"

‎src-tauri/src/mcp/mod.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@ pub mod tools;
4444

4545
// Re-export types used by commands/bridge.rs
4646
pub use bridge::{complete_pending_request, ToolResponse};
47-

0 commit comments

Comments
 (0)