feat(session): warn before a session ends and say when protection stops
Review findings #1-#3 in internal/APP_REVIEW_2026-10-16.md: every session end dropped the user onto their real IP with no warning, and the app showed no errors at all. - RevoltAlerts (vendored runtime) owns both alerts: a high-importance channel, ids 2 and 3, posted from whichever process is alive - XrayVPNService schedules a 5-minute warning off the deadline it already holds, best effort (a warning that cannot be armed never stops a tunnel), with its own request code so it cannot clobber the expiry alarm - the warning intent is handled above the command dispatch: without that it would fall through to the final else and stop the tunnel 5 minutes early - SessionTimer._doDisconnect takes endedMessage: set for ends the user did not ask for, which both posts the alert and gives the UI a sentence - the API being unreachable no longer disconnects a working tunnel; it is a display state now, with expiry still enforced natively and server-side - status_bar.dart renders connect errors, connecting progress and the session-end reason flutter analyze clean; debug APK builds (Kotlin compiles). Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
37753c6396
commit
742f37683e
7 files changed
+401
-26
No files matched your search
@@ -5,6 +5,44 @@ import 'package:revoltvpn/logic/app_colors.dart';
|
||||
import 'package:revoltvpn/logic/session_timer.dart';
|
||||
import 'package:revoltvpn/logic/vpn_connection.dart';
|
||||
|
||||
// Nothing rendered the connection's own messages, so they are collected here
|
||||
// in one place: whatever the user most needs to know right now, and whether it
|
||||
// is a problem (red) or just progress (dim).
|
||||
class _StatusDetail {
|
||||
const _StatusDetail(this.text, {this.isProblem = false});
|
||||
|
||||
final String text;
|
||||
final bool isProblem;
|
||||
}
|
||||
|
||||
_StatusDetail? _detail(VpnConnection vpn, SessionTimer timer) {
|
||||
final error = vpn.errorMessage;
|
||||
if (error != null && error.isNotEmpty) {
|
||||
return _StatusDetail(error.replaceAll('\n', ' '), isProblem: true);
|
||||
}
|
||||
|
||||
if (vpn.status == VpnStatus.connecting ||
|
||||
vpn.status == VpnStatus.disconnecting) {
|
||||
return _StatusDetail(vpn.statusMessage);
|
||||
}
|
||||
|
||||
// The tunnel still carries traffic; only the control plane is missing, so
|
||||
// this is a warning, not a disconnect (review #2).
|
||||
if (vpn.status == VpnStatus.connected && timer.serverUnreachable) {
|
||||
return const _StatusDetail(
|
||||
'Can\'t reach the server — still connected',
|
||||
isProblem: true,
|
||||
);
|
||||
}
|
||||
|
||||
if (vpn.status != VpnStatus.connected) {
|
||||
final ended = timer.lastEndMessage;
|
||||
if (ended != null) return _StatusDetail(ended, isProblem: true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
class StatusBar extends StatelessWidget {
|
||||
const StatusBar({super.key});
|
||||
|
||||
@@ -24,6 +62,8 @@ class StatusBar extends StatelessWidget {
|
||||
? 'Connecting…'
|
||||
: (vpn.serverReachable ? 'Ready' : 'Offline'));
|
||||
|
||||
final detail = _detail(vpn, timer);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
@@ -96,6 +136,23 @@ class StatusBar extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// Until this existed, a failed connect, an expired session and a
|
||||
// cap kill all just turned the button back to idle - the user
|
||||
// could not tell protected from unprotected (review #3).
|
||||
if (detail != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
detail.text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: detail.isProblem
|
||||
? AppColors.red
|
||||
: AppColors.textDim,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user