-
Notifications
You must be signed in to change notification settings - Fork 231
feat(window): add cross-platform close confirm and shutdown KDF on exit #2853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(window): add cross-platform close confirm and shutdown KDF on exit #2853
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Visit the preview URL for this PR (updated for commit 43bc8ab): https://walletrc--pull-2853-merge-7gel4tk7.web.app (expires Tue, 15 Jul 2025 17:25:08 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc |
…ve-platforms' of https://github.com/KomodoPlatform/komodo-wallet into v2jl4p-codex/implement-showmessagebeforeunload-for-native-platforms
…d-for-native-platforms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds cross-platform window close confirmation and ensures proper disposal of the KomodoDefiSdk on exit.
- Introduces
WindowCloseHandler
widget and integratesflutter_window_close
plugin across desktop platforms. - Implements browser
beforeunload
handling and native mobile back-button interception. - Adds
dispose
method inMM2
for SDK cleanup and updates plugin registrations and dependencies.
Reviewed Changes
Copilot reviewed 13 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
windows/flutter/generated_plugins.cmake | Registered flutter_window_close in plugin list |
windows/flutter/generated_plugin_registrant.cc | Included and registered FlutterWindowClosePlugin |
pubspec.yaml | Added flutter_window_close: ^1.2.0 dependency |
macos/Flutter/GeneratedPluginRegistrant.swift | Imported and registered FlutterWindowClosePlugin |
linux/flutter/generated_plugins.cmake | Registered flutter_window_close in plugin list |
linux/flutter/generated_plugin_registrant.cc | Included and registered FlutterWindowClosePlugin |
lib/views/main_layout/main_layout.dart | Added web beforeunload hook using showMessageBeforeUnload |
lib/shared/utils/window/window_native.dart | Implemented _BeforeUnloadObserver and showMessageBeforeUnload |
lib/shared/utils/utils.dart | Minor formatting fix and added logger dispose TODO |
lib/shared/utils/platform_tuner.dart | Added isNativeMobile helper |
lib/sdk/widgets/window_close_handler.dart | New widget for handling window close across platforms |
lib/mm2/mm2.dart | Added dispose method to clean up SDK resources |
lib/main.dart | Integrated WindowCloseHandler into app root |
Comments suppressed due to low confidence (4)
lib/sdk/widgets/window_close_handler.dart:1
- [nitpick] Add unit or widget tests for
WindowCloseHandler
to validate its behavior on desktop, web, and mobile platforms, including confirmation dialogs and SDK disposal.
import 'package:flutter/foundation.dart';
lib/mm2/mm2.dart:31
- [nitpick] Add tests for
MM2.dispose()
to ensure the SDK is properly disposed and that exceptions are handled as expected.
Future<void> dispose() async {
lib/views/main_layout/main_layout.dart:33
- The function
showMessageBeforeUnload
is not imported in this file. Addimport 'package:web_dex/shared/utils/window/window_native.dart';
(or the appropriate window utility) to resolve it.
showMessageBeforeUnload('Are you sure you want to leave?');
lib/shared/utils/window/window_native.dart:26
scaffoldKey
is referenced but not defined or imported. Addimport 'package:web_dex/shared/utils/window/window.dart';
to access the sharedscaffoldKey
.
final context = scaffoldKey.currentContext;
Confirmed working as expected in linux. |
Testing on Windows via CI build: Encountered same dll error as previously reported Unable to complete further testing. It was expected that KomodoPlatform/komodo-defi-framework#2464 would resolve this, though KDF does not appear to be the problem (apart from defender complaining) when running manually from command prompt. MacOS CI builds failed. Is someone else able to build/test this PR for MacOS? |
…-showmessagebeforeunload-for-native-platforms # Conflicts: # lib/views/main_layout/main_layout.dart # packages/komodo_ui_kit/pubspec.lock # pubspec.lock
Installing the latest Microsoft Visual C++ Redistributable version should help. Most apps don’t include runtime libraries, as it’s assumed the user already has them installed.
As for signing, I still don’t have a key for it. Our Jenkins environment is already set up and ready for signing — we just need the key to proceed. |
Can it be safely assumed most windows users have installed this? Is it part of auto-updates? I'm running in a relatively fresh VM, installing latest updates now to retest. |
…ive-platforms - Resolved pubspec.lock conflicts by taking dev version - Merged showMessageBeforeUnload implementation for native platforms - Integrated Trezor SDK migration changes from dev - Updated plugin registrations to include FlutterWindowClosePlugin
This pull request introduces a robust window close handling mechanism across platforms, ensuring proper cleanup of resources, particularly the disposal of the
KomodoDefiSdk
. It also adds platform-specific utilities and integrates theflutter_window_close
plugin for desktop platforms. Below are the most significant changes grouped by theme:@DeckerSU: This complements another open PR (#2770), which restores the auth state in case the user terminates the app by means other than closing with confirmation.
Window Close Handling
WindowCloseHandler
widget to manage window close events and SDK disposal across platforms (lib/sdk/widgets/window_close_handler.dart
).WindowCloseHandler
into the main application widget tree (lib/main.dart
).Platform-Specific Utilities
PlatformTuner
withisNativeMobile
to identify mobile platforms (lib/shared/utils/platform_tuner.dart
)._BeforeUnloadObserver
for native platforms to intercept back button or window close requests (lib/shared/utils/window/window_native.dart
).Plugin Integration
flutter_window_close
plugin for Linux, macOS, and Windows platforms (linux/flutter/generated_plugin_registrant.cc
,macos/Flutter/GeneratedPluginRegistrant.swift
,windows/flutter/generated_plugin_registrant.cc
). [1] [2] [3]pubspec.yaml
to include theflutter_window_close
dependency (pubspec.yaml
).SDK Resource Management
dispose
method inMM2
class to clean up resources (lib/mm2/mm2.dart
).Web-Specific Enhancements
showMessageBeforeUnload
for browser beforeunload event handling (lib/views/main_layout/main_layout.dart
).TODO @takenagain: in near future PR, add lifecycle hooks listeners as a fallback to terminate KDF upon exit if user closes app by means other than the exit button. Afaik, this is only needed for platforms using the stand-alone binary.