generated from nhcarrigan/template
chore: linty lint
This commit is contained in:
@@ -2329,6 +2329,10 @@ mod tests {
|
|||||||
context_utilisation_percent: 0.0,
|
context_utilisation_percent: 0.0,
|
||||||
potential_cache_hits: 0,
|
potential_cache_hits: 0,
|
||||||
potential_cache_savings_tokens: 0,
|
potential_cache_savings_tokens: 0,
|
||||||
|
current_request_input: None,
|
||||||
|
current_request_output_chars: 0,
|
||||||
|
current_request_thinking_chars: 0,
|
||||||
|
current_request_tools: Vec::new(),
|
||||||
achievements: AchievementProgress::new(),
|
achievements: AchievementProgress::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-18
@@ -658,7 +658,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cost_calculation_sonnet() {
|
fn test_cost_calculation_sonnet() {
|
||||||
let cost = calculate_cost(1000, 2000, "claude-sonnet-4-20250514");
|
let cost = calculate_cost(1000, 2000, "claude-sonnet-4-20250514", None, None);
|
||||||
// 1000 input * $3/M = $0.003
|
// 1000 input * $3/M = $0.003
|
||||||
// 2000 output * $15/M = $0.030
|
// 2000 output * $15/M = $0.030
|
||||||
// Total = $0.033
|
// Total = $0.033
|
||||||
@@ -667,7 +667,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cost_calculation_opus() {
|
fn test_cost_calculation_opus() {
|
||||||
let cost = calculate_cost(1000, 2000, "claude-opus-4-20250514");
|
let cost = calculate_cost(1000, 2000, "claude-opus-4-20250514", None, None);
|
||||||
// 1000 input * $15/M = $0.015
|
// 1000 input * $15/M = $0.015
|
||||||
// 2000 output * $75/M = $0.150
|
// 2000 output * $75/M = $0.150
|
||||||
// Total = $0.165
|
// Total = $0.165
|
||||||
@@ -676,7 +676,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cost_calculation_opus_45() {
|
fn test_cost_calculation_opus_45() {
|
||||||
let cost = calculate_cost(1000, 2000, "claude-opus-4-5-20251101");
|
let cost = calculate_cost(1000, 2000, "claude-opus-4-5-20251101", None, None);
|
||||||
// Opus 4.5 pricing: $5/MTok input, $25/MTok output
|
// Opus 4.5 pricing: $5/MTok input, $25/MTok output
|
||||||
// 1000 input tokens = $0.005, 2000 output tokens = $0.05
|
// 1000 input tokens = $0.005, 2000 output tokens = $0.05
|
||||||
// Total = $0.055
|
// Total = $0.055
|
||||||
@@ -685,7 +685,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cost_calculation_haiku() {
|
fn test_cost_calculation_haiku() {
|
||||||
let cost = calculate_cost(1000, 2000, "claude-3-5-haiku-20241022");
|
let cost = calculate_cost(1000, 2000, "claude-3-5-haiku-20241022", None, None);
|
||||||
// 1000 input * $1/M = $0.001
|
// 1000 input * $1/M = $0.001
|
||||||
// 2000 output * $5/M = $0.010
|
// 2000 output * $5/M = $0.010
|
||||||
// Total = $0.011
|
// Total = $0.011
|
||||||
@@ -694,14 +694,14 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cost_calculation_unknown_defaults_to_sonnet() {
|
fn test_cost_calculation_unknown_defaults_to_sonnet() {
|
||||||
let cost = calculate_cost(1000, 2000, "some-unknown-model");
|
let cost = calculate_cost(1000, 2000, "some-unknown-model", None, None);
|
||||||
// Should default to Sonnet pricing
|
// Should default to Sonnet pricing
|
||||||
assert!((cost - 0.033).abs() < 0.0001);
|
assert!((cost - 0.033).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cost_calculation_legacy_sonnet() {
|
fn test_cost_calculation_legacy_sonnet() {
|
||||||
let cost = calculate_cost(1000, 2000, "claude-3-5-sonnet-20241022");
|
let cost = calculate_cost(1000, 2000, "claude-3-5-sonnet-20241022", None, None);
|
||||||
// Same as Sonnet 4 pricing
|
// Same as Sonnet 4 pricing
|
||||||
assert!((cost - 0.033).abs() < 0.0001);
|
assert!((cost - 0.033).abs() < 0.0001);
|
||||||
}
|
}
|
||||||
@@ -709,7 +709,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_usage_stats_accumulation() {
|
fn test_usage_stats_accumulation() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514");
|
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514", None, None);
|
||||||
|
|
||||||
assert_eq!(stats.total_input_tokens, 1000);
|
assert_eq!(stats.total_input_tokens, 1000);
|
||||||
assert_eq!(stats.total_output_tokens, 2000);
|
assert_eq!(stats.total_output_tokens, 2000);
|
||||||
@@ -721,8 +721,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_usage_stats_multiple_accumulations() {
|
fn test_usage_stats_multiple_accumulations() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(1000, 1000, "claude-sonnet-4-20250514");
|
stats.add_usage(1000, 1000, "claude-sonnet-4-20250514", None, None);
|
||||||
stats.add_usage(500, 500, "claude-sonnet-4-20250514");
|
stats.add_usage(500, 500, "claude-sonnet-4-20250514", None, None);
|
||||||
|
|
||||||
assert_eq!(stats.total_input_tokens, 1500);
|
assert_eq!(stats.total_input_tokens, 1500);
|
||||||
assert_eq!(stats.total_output_tokens, 1500);
|
assert_eq!(stats.total_output_tokens, 1500);
|
||||||
@@ -733,17 +733,17 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_usage_stats_model_updated() {
|
fn test_usage_stats_model_updated() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(1000, 1000, "claude-sonnet-4-20250514");
|
stats.add_usage(1000, 1000, "claude-sonnet-4-20250514", None, None);
|
||||||
assert_eq!(stats.model, Some("claude-sonnet-4-20250514".to_string()));
|
assert_eq!(stats.model, Some("claude-sonnet-4-20250514".to_string()));
|
||||||
|
|
||||||
stats.add_usage(500, 500, "claude-opus-4-20250514");
|
stats.add_usage(500, 500, "claude-opus-4-20250514", None, None);
|
||||||
assert_eq!(stats.model, Some("claude-opus-4-20250514".to_string()));
|
assert_eq!(stats.model, Some("claude-opus-4-20250514".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_session_reset() {
|
fn test_session_reset() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514");
|
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514", None, None);
|
||||||
stats.reset_session();
|
stats.reset_session();
|
||||||
|
|
||||||
assert_eq!(stats.total_input_tokens, 1000);
|
assert_eq!(stats.total_input_tokens, 1000);
|
||||||
@@ -970,7 +970,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_usage_stats_serialization() {
|
fn test_usage_stats_serialization() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514");
|
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514", None, None);
|
||||||
stats.increment_messages();
|
stats.increment_messages();
|
||||||
|
|
||||||
// UsageStats should be serializable (for events)
|
// UsageStats should be serializable (for events)
|
||||||
@@ -999,7 +999,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_stats_update_event_serialization() {
|
fn test_stats_update_event_serialization() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(100, 200, "claude-sonnet-4-20250514");
|
stats.add_usage(100, 200, "claude-sonnet-4-20250514", None, None);
|
||||||
|
|
||||||
let event = StatsUpdateEvent { stats };
|
let event = StatsUpdateEvent { stats };
|
||||||
let json = serde_json::to_string(&event).expect("Failed to serialize");
|
let json = serde_json::to_string(&event).expect("Failed to serialize");
|
||||||
@@ -1053,7 +1053,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_context_tracking_update() {
|
fn test_context_tracking_update() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(50_000, 10_000, "claude-sonnet-4-20250514");
|
stats.add_usage(50_000, 10_000, "claude-sonnet-4-20250514", None, None);
|
||||||
|
|
||||||
assert_eq!(stats.context_tokens_used, 50_000);
|
assert_eq!(stats.context_tokens_used, 50_000);
|
||||||
assert_eq!(stats.context_window_limit, 200_000);
|
assert_eq!(stats.context_window_limit, 200_000);
|
||||||
@@ -1063,8 +1063,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_context_tracking_accumulates() {
|
fn test_context_tracking_accumulates() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(50_000, 10_000, "claude-sonnet-4-20250514");
|
stats.add_usage(50_000, 10_000, "claude-sonnet-4-20250514", None, None);
|
||||||
stats.add_usage(50_000, 10_000, "claude-sonnet-4-20250514");
|
stats.add_usage(50_000, 10_000, "claude-sonnet-4-20250514", None, None);
|
||||||
|
|
||||||
assert_eq!(stats.context_tokens_used, 100_000);
|
assert_eq!(stats.context_tokens_used, 100_000);
|
||||||
assert!((stats.context_utilisation_percent - 50.0).abs() < 0.1);
|
assert!((stats.context_utilisation_percent - 50.0).abs() < 0.1);
|
||||||
@@ -1128,7 +1128,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_context_reset_on_session_reset() {
|
fn test_context_reset_on_session_reset() {
|
||||||
let mut stats = UsageStats::new();
|
let mut stats = UsageStats::new();
|
||||||
stats.add_usage(100_000, 20_000, "claude-sonnet-4-20250514");
|
stats.add_usage(100_000, 20_000, "claude-sonnet-4-20250514", None, None);
|
||||||
|
|
||||||
assert!(stats.context_tokens_used > 0);
|
assert!(stats.context_tokens_used > 0);
|
||||||
assert!(stats.context_utilisation_percent > 0.0);
|
assert!(stats.context_utilisation_percent > 0.0);
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ impl WslBridge {
|
|||||||
if tool_stats.call_count > 0 {
|
if tool_stats.call_count > 0 {
|
||||||
// Use session average tokens per call for this tool
|
// Use session average tokens per call for this tool
|
||||||
let avg_tokens = (tool_stats.estimated_input_tokens + tool_stats.estimated_output_tokens)
|
let avg_tokens = (tool_stats.estimated_input_tokens + tool_stats.estimated_output_tokens)
|
||||||
/ tool_stats.call_count as u64;
|
/ tool_stats.call_count;
|
||||||
tool_overhead_tokens += avg_tokens;
|
tool_overhead_tokens += avg_tokens;
|
||||||
println!("[COST ESTIMATION] Tool {} average: {} tokens", tool_name, avg_tokens);
|
println!("[COST ESTIMATION] Tool {} average: {} tokens", tool_name, avg_tokens);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,7 +341,9 @@ User: ${formattedMessage}`;
|
|||||||
// Get current working directory and granted tools before reconnecting
|
// Get current working directory and granted tools before reconnecting
|
||||||
const workingDir = await invoke<string>("get_working_directory", { conversationId });
|
const workingDir = await invoke<string>("get_working_directory", { conversationId });
|
||||||
const activeConversation = get(conversationsStore.activeConversation);
|
const activeConversation = get(conversationsStore.activeConversation);
|
||||||
const grantedTools = activeConversation ? Array.from(activeConversation.grantedTools) : [];
|
const grantedTools = activeConversation
|
||||||
|
? Array.from(activeConversation.grantedTools)
|
||||||
|
: [];
|
||||||
const config = configStore.getConfig();
|
const config = configStore.getConfig();
|
||||||
const allAllowedTools = [...new Set([...grantedTools, ...config.auto_granted_tools])];
|
const allAllowedTools = [...new Set([...grantedTools, ...config.auto_granted_tools])];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user