refactor: improve WS cancellation, fix config updates, and format code#43
refactor: improve WS cancellation, fix config updates, and format code#43
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors WebSocket cancellation logic to use tokio::select! for proper graceful shutdown, fixes configuration update persistence, and applies code formatting improvements throughout the codebase. The changes improve the reliability of service shutdown and ensure configuration changes are properly saved and reloaded.
Key changes:
- Improved WebSocket reconnection logic to respect cancellation signals using
tokio::select! - Fixed config update flow to reload configuration after saving to ensure state consistency
- Applied consistent code formatting (spacing, line breaks, import ordering)
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src-tauri/src/tauri_bridge/state.rs | Fixed spacing in variable assignment |
| src-tauri/src/tauri_bridge/converters.rs | Removed trailing space from doc comment |
| src-tauri/src/tauri_bridge/commands.rs | Refactored clone operations to use references, improved config update flow with reload step, removed trailing whitespace |
| src-tauri/src/services/websocket.rs | Enhanced WS reconnection with proper cancellation handling via tokio::select!, refactored clone to reference |
| src-tauri/src/services/push_service.rs | Removed trailing whitespace |
| src-tauri/src/lib.rs | Reformatted long println statement for readability |
| src-tauri/src/core/queries.rs | Reformatted format! calls for consistency |
| src-tauri/src/core/data_processing.rs | Adjusted import order and formatting, simplified struct initialization |
| src-tauri/src/core/actor.rs | Reformatted function signature for readability |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub async fn stop_capture(state: tauri::State<'_, AppState>) -> Result<(), String> { | ||
| if let RunState::NotCapturing = *state.status.read().await { | ||
| if let RunState::NotCapturing = &*state.status.read().await { | ||
| return Err("Capture session is already running.".into()); |
There was a problem hiding this comment.
The error message is incorrect. When the state is NotCapturing, the error should say 'Capture session is not running' or 'Capture session is already stopped', not 'already running'.
| return Err("Capture session is already running.".into()); | |
| return Err("Capture session is not running.".into()); |
| Event as PbEvent, | ||
| Heartbeat as PbHeartbeat, | ||
| LogEntry as PbLogEntry, | ||
| log_entry, // oneof payload 的内部模块 |
There was a problem hiding this comment.
[nitpick] The log_entry import should appear before the re-exported types (PbEvent, PbHeartbeat, PbLogEntry) to follow Rust's convention of organizing imports alphabetically and by type (modules before type imports). The standard practice is to group imports from the same module together with submodules listed first.
| Event as PbEvent, | |
| Heartbeat as PbHeartbeat, | |
| LogEntry as PbLogEntry, | |
| log_entry, // oneof payload 的内部模块 | |
| log_entry, // oneof payload 的内部模块 | |
| Event as PbEvent, | |
| Heartbeat as PbHeartbeat, | |
| LogEntry as PbLogEntry, |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Event as PbEvent, | ||
| Heartbeat as PbHeartbeat, | ||
| LogEntry as PbLogEntry, | ||
| log_entry, // oneof payload 的内部模块 |
There was a problem hiding this comment.
[nitpick] The comment moved to line 15 contains Chinese characters (内部模块). While this may be intentional, it could be beneficial to use English comments for better accessibility across the development team unless there's a specific reason for using Chinese.
| log_entry, // oneof payload 的内部模块 | |
| log_entry, // internal module for oneof payload |
|
🔧 Debug Build Complete (PR 43, RunID 19611079347) 📦 Download Links: ⏰ Files will be retained for 7 days, please download and test promptly. |
No description provided.