Merged
Conversation
Reviewer's GuideThis PR introduces a centralized "Stop All" action in the notification center, refactors the foreground service to emit a merged notification for SSH sessions, and hooks that action through a broadcast receiver into Flutter's session manager, with a minor UI string tweak. Sequence diagram for the new 'Stop All' notification action flowsequenceDiagram participant User as actor User participant Notification as Notification Center participant ForegroundService as ForegroundService participant MainActivity as MainActivity participant Flutter as Flutter (SessionManager) User->>Notification: Presses "Stop All" button Notification->>ForegroundService: ACTION_STOP_FOREGROUND intent ForegroundService->>MainActivity: Broadcast STOP_ALL_CONNECTIONS MainActivity->>Flutter: invokeMethod("stopAllConnections") Flutter->>Flutter: TermSessionManager.stopAllConnections() Flutter->>ForegroundService: All sessions disconnected ForegroundService->>Notification: Update notification (no active sessions) Entity relationship diagram for session management entrieserDiagram TERM_SESSION_MANAGER ||--o| SESSION_ENTRY : manages TERM_SESSION_MANAGER { entries activeId } SESSION_ENTRY { id disconnect } Updated class diagram for MethodChans and TermSessionManagerclassDiagram class MethodChans { +registerHandler(onDisconnect: Function, onStopAll: VoidCallback?) } class TermSessionManager { +init() +stopAllConnections() +add() } MethodChans --> TermSessionManager : calls stopAllConnections via handler File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Use LocalBroadcastManager or set the Intent’s package/permission when broadcasting STOP_ALL_CONNECTIONS to avoid exposing a public broadcast and ensure it’s scoped to your app.
- Consider extracting the common Notification.Builder setup (channel, icon, flags) into a shared helper to reduce duplication in createMergedNotification.
- Move hardcoded strings such as “Stop All” and notification titles/text into Android string resources to improve localization support.
Prompt for AI Agents
Please address the comments from this code review: ## Overall Comments - Use LocalBroadcastManager or set the Intent’s package/permission when broadcasting STOP_ALL_CONNECTIONS to avoid exposing a public broadcast and ensure it’s scoped to your app. - Consider extracting the common Notification.Builder setup (channel, icon, flags) into a shared helper to reduce duplication in createMergedNotification. - Move hardcoded strings such as “Stop All” and notification titles/text into Android string resources to improve localization support. ## Individual Comments ### Comment 1 <location> `lib/data/ssh/session_manager.dart:67` </location> <code_context> } + /// Called when Android notification "Stop All" button is pressed + static void stopAllConnections() { + // Disconnect all sessions + final disconnectCallbacks = _entries.values.map((e) => e.disconnect).where((cb) => cb != null).toList(); </code_context> <issue_to_address> Consider handling disconnect errors individually in stopAllConnections. Currently, if a disconnect callback throws an error, subsequent sessions may not be disconnected. Wrapping each callback in a try/catch will allow all sessions to be processed regardless of individual errors. </issue_to_address> <suggested_fix> <<<<<<< SEARCH for (final disconnect in disconnectCallbacks) { disconnect!(); } ======= for (final disconnect in disconnectCallbacks) { try { disconnect!(); } catch (e, stack) { // Optionally log the error, e.g. using print or a logger print('Error disconnecting session: $e\n$stack'); } } >>>>>>> REPLACE </suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines +70 to +72
| for (final disconnect in disconnectCallbacks) { | ||
| disconnect!(); | ||
| } |
There was a problem hiding this comment.
suggestion: Consider handling disconnect errors individually in stopAllConnections.
Currently, if a disconnect callback throws an error, subsequent sessions may not be disconnected. Wrapping each callback in a try/catch will allow all sessions to be processed regardless of individual errors.
Suggested change
| for (final disconnect in disconnectCallbacks) { | |
| disconnect!(); | |
| } | |
| for (final disconnect in disconnectCallbacks) { | |
| try { | |
| disconnect!(); | |
| } catch (e, stack) { | |
| // Optionally log the error, e.g. using print or a logger | |
| print('Error disconnecting session: $e\n$stack'); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #891
Summary by Sourcery
Unify SSH session notifications into one merged notification with a Stop All button that broadcasts to Flutter, implement the stopAllConnections flow on both Android and Dart sides, and fix the success rate formatting.
New Features:
Bug Fixes:
Enhancements: