From d5311574be4a6653f0a0080ac0a3441408890bd3 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 11 Sep 2026 15:04:31 +0800 Subject: [PATCH] fix(flutter): show the quality monitor's Transport row on the web only The row was added for the web client, which has no session tab to name the transport on, but nothing gated it: a desktop session over WebRTC showed it too, duplicating the tab tooltip's "(WebRTC)". The getter now answers only on the web, as its own comment intended. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01QcJZZeJ3Nqb2MHxXuUadkb --- flutter/lib/models/model.dart | 6 ++-- .../test/quality_monitor_transport_test.dart | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 flutter/test/quality_monitor_transport_test.dart diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index c7a48280a..3572b9728 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -3601,9 +3601,11 @@ class QualityMonitorModel with ChangeNotifier { bool get show => _show; QualityMonitorData get data => _data; - // Only a WebRTC session names its transport here: web has no session tab - // to show it on, and WebRTC is the one path that can be direct or TURN. + // Only a WebRTC session on the web names its transport here: web has no + // session tab to show it on (the desktop tab's tooltip already does), and + // WebRTC is the one path that can be direct or TURN. String? get webrtcTransport { + if (!isWeb) return null; final ffiModel = parent.target?.ffiModel; if (ffiModel == null) return null; final streamType = ffiModel.cachedPeerData.streamType; diff --git a/flutter/test/quality_monitor_transport_test.dart b/flutter/test/quality_monitor_transport_test.dart new file mode 100644 index 000000000..dc38adc92 --- /dev/null +++ b/flutter/test/quality_monitor_transport_test.dart @@ -0,0 +1,28 @@ +import 'package:flutter_hbb/common.dart'; +import 'package:flutter_hbb/models/model.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:uuid/uuid.dart'; + +final _sessionId = UuidValue('00000000-0000-0000-0000-000000000000'); + +class _FakeFFI implements FFI { + @override + UuidValue get sessionId => _sessionId; + + @override + late final FfiModel ffiModel = FfiModel(WeakReference(this)); + + @override + dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); +} + +void main() { + test('the quality monitor names the WebRTC transport only on web', () { + final ffi = _FakeFFI(); + ffi.ffiModel.cachedPeerData.streamType = 'WebRTC'; + final model = QualityMonitorModel(WeakReference(ffi)); + // Off the web the session tab's tooltip already names the transport. + expect(isWeb, isFalse); + expect(model.webrtcTransport, isNull); + }); +}