Skip to content

refactor: improve WS cancellation, fix config updates, and format code#43

Merged
zenyanle merged 2 commits intomainfrom
fix-config-save
Nov 23, 2025
Merged

refactor: improve WS cancellation, fix config updates, and format code#43
zenyanle merged 2 commits intomainfrom
fix-config-save

Conversation

@zenyanle
Copy link
Member

No description provided.

@zenyanle
Copy link
Member Author

@copilot

Copy link

Copilot AI commented Nov 23, 2025

@zenyanle I've opened a new pull request, #44, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'.

Suggested change
return Err("Capture session is already running.".into());
return Err("Capture session is not running.".into());

Copilot uses AI. Check for mistakes.
Comment on lines 13 to +15
Event as PbEvent,
Heartbeat as PbHeartbeat,
LogEntry as PbLogEntry,
log_entry, // oneof payload 的内部模块
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
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,

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 的内部模块
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
log_entry, // oneof payload 的内部模块
log_entry, // internal module for oneof payload

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

🔧 Debug Build Complete (PR 43, RunID 19611079347)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@zenyanle zenyanle merged commit 7313ff9 into main Nov 23, 2025
16 checks passed
@cfc4n cfc4n deleted the fix-config-save branch November 23, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants