Tauri fixes

This commit is contained in:
Peter Steinberger 2025-06-23 18:36:45 +02:00
parent 8768bb0eb3
commit 7e4f5ab8c5
3 changed files with 47 additions and 3 deletions

View file

@ -1440,6 +1440,22 @@ pub async fn clear_debug_data(state: State<'_, AppState>) -> Result<(), String>
Ok(())
}
#[tauri::command]
pub async fn clear_debug_logs(state: State<'_, AppState>) -> Result<(), String> {
// For now, clear all debug data - could be enhanced to clear only logs
let debug_features_manager = &state.debug_features_manager;
debug_features_manager.clear_all_data().await;
Ok(())
}
#[tauri::command]
pub async fn clear_network_requests(state: State<'_, AppState>) -> Result<(), String> {
// For now, clear all debug data - could be enhanced to clear only network requests
let debug_features_manager = &state.debug_features_manager;
debug_features_manager.clear_all_data().await;
Ok(())
}
#[tauri::command]
pub async fn set_debug_mode(enabled: bool, state: State<'_, AppState>) -> Result<(), String> {
let debug_features_manager = &state.debug_features_manager;

View file

@ -325,6 +325,8 @@ fn main() {
run_benchmarks,
generate_diagnostic_report,
clear_debug_data,
clear_debug_logs,
clear_network_requests,
set_debug_mode,
get_debug_stats,
get_api_test_config,

View file

@ -1386,8 +1386,18 @@ export class SettingsApp extends TauriBase {
// Load debug logs
this.debugLogs = await this.safeInvoke('get_debug_logs', { limit: 100 }) || [];
// Load performance metrics
this.performanceMetrics = await this.safeInvoke('get_performance_metrics') || {};
// Load performance metrics - returns array
const metrics = await this.safeInvoke('get_performance_metrics', { limit: 10 }) || [];
// Convert metrics array to object for display
this.performanceMetrics = {
avg_response_time_ms: this._getMetricValue(metrics, 'response_time'),
requests_per_second: this._getMetricValue(metrics, 'requests_per_second'),
cpu_usage_percent: this._getMetricValue(metrics, 'cpu_usage'),
memory_usage_mb: this._getMetricValue(metrics, 'memory_usage'),
active_sessions: this._getMetricValue(metrics, 'active_sessions'),
total_requests: this._getMetricValue(metrics, 'total_requests')
};
// Load network requests
this.networkRequests = await this.safeInvoke('get_network_requests', { limit: 50 }) || [];
@ -1398,6 +1408,11 @@ export class SettingsApp extends TauriBase {
console.error('Failed to load debug data:', error);
}
}
private _getMetricValue(metrics: Array<any>, name: string): number {
const metric = metrics.find((m: any) => m.name === name);
return metric?.value || 0;
}
private _renderLogsTab(): TemplateResult {
const filteredLogs = this._filterLogs(this.debugLogs);
@ -1814,7 +1829,18 @@ export class SettingsApp extends TauriBase {
}
private async refreshPerformance(): Promise<void> {
this.performanceMetrics = await this.safeInvoke('get_performance_metrics') || {};
const metrics = await this.safeInvoke('get_performance_metrics', { limit: 10 }) || [];
// Convert metrics array to object for display
this.performanceMetrics = {
avg_response_time_ms: this._getMetricValue(metrics, 'response_time'),
requests_per_second: this._getMetricValue(metrics, 'requests_per_second'),
cpu_usage_percent: this._getMetricValue(metrics, 'cpu_usage'),
memory_usage_mb: this._getMetricValue(metrics, 'memory_usage'),
active_sessions: this._getMetricValue(metrics, 'active_sessions'),
total_requests: this._getMetricValue(metrics, 'total_requests')
};
this.requestUpdate();
}