diff --git a/lib/constants/music_services.dart b/lib/constants/music_services.dart index 4851c397..9ad708a6 100644 --- a/lib/constants/music_services.dart +++ b/lib/constants/music_services.dart @@ -1,6 +1,6 @@ /// Canonical service / provider identifiers shared across the app. /// -/// These values must stay in sync with the provider ids reported by the Go +/// These values must stay in sync with the provider ids reported by the native /// backend and by extensions; use them instead of raw string literals when /// comparing or dispatching on a service id. abstract final class MusicServices { diff --git a/lib/main.dart b/lib/main.dart index 3c2a9fcf..8e56399a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -39,7 +39,7 @@ void main() { _startupBenchmark = _StartupBenchmark(); } // Catch uncaught Dart errors so a failing async path is logged, not fatal. - // Native (Go) crashes still can't be caught here. + // Native backend crashes still can't be caught here. runZonedGuarded( () async { WidgetsFlutterBinding.ensureInitialized(); diff --git a/lib/providers/download_queue_provider.dart b/lib/providers/download_queue_provider.dart index c4740dfb..b8313f4a 100644 --- a/lib/providers/download_queue_provider.dart +++ b/lib/providers/download_queue_provider.dart @@ -594,7 +594,7 @@ class DownloadQueueNotifier extends Notifier { _log.e('Failed to flush expired iOS queue: $error'); }), ); - // The native expiration callback cancels Go synchronously before this + // The native expiration callback cancels the download synchronously before this // asynchronous event reaches Dart. If foregrounding won that race, still // requeue the cancelled item, then immediately let the running queue loop // continue instead of misclassifying it as a skipped download. diff --git a/lib/screens/settings/log_screen.dart b/lib/screens/settings/log_screen.dart index 51fcf856..241a4509 100644 --- a/lib/screens/settings/log_screen.dart +++ b/lib/screens/settings/log_screen.dart @@ -43,13 +43,13 @@ class _LogScreenState extends State { void initState() { super.initState(); LogBuffer().addListener(_onLogUpdate); - LogBuffer().startGoLogPolling(); + LogBuffer().startNativeLogPolling(); } @override void dispose() { LogBuffer().removeListener(_onLogUpdate); - LogBuffer().stopGoLogPolling(); + LogBuffer().stopNativeLogPolling(); _scrollController.dispose(); _searchController.dispose(); super.dispose(); @@ -624,7 +624,7 @@ class _LogEntryTile extends StatelessWidget { ), ), ), - if (entry.isFromGo) ...[ + if (entry.isFromNative) ...[ const SizedBox(width: 4), Container( padding: const EdgeInsets.symmetric( diff --git a/lib/services/platform_bridge.dart b/lib/services/platform_bridge.dart index ff3db418..e533c93a 100644 --- a/lib/services/platform_bridge.dart +++ b/lib/services/platform_bridge.dart @@ -2334,7 +2334,7 @@ class PlatformBridge { } /// Streaming-platform links for a track, keyed by song.link platform ID. - /// Served from the Go-side memory cache; throws when the lookup fails. + /// Served from the native backend's memory cache; throws when the lookup fails. static Future> getTrackPlatformLinks({ String spotifyId = '', String isrc = '', @@ -2847,7 +2847,7 @@ class PlatformBridge { }); if (result['success'] != true) return result; - // The Go/Rust result uses new_file_path; the queue consumes file_path. + // The native result uses new_file_path; the queue consumes file_path. // SAF publishes back to its document URI after processing a temporary file. final uri = result['new_file_uri']; final path = result['new_file_path']; diff --git a/lib/utils/logger.dart b/lib/utils/logger.dart index aa0f340e..77aa0945 100644 --- a/lib/utils/logger.dart +++ b/lib/utils/logger.dart @@ -80,7 +80,7 @@ class LogEntry { final String tag; final String message; final String? error; - final bool isFromGo; + final bool isFromNative; LogEntry({ required this.timestamp, @@ -88,7 +88,7 @@ class LogEntry { required this.tag, required this.message, this.error, - this.isFromGo = false, + this.isFromNative = false, }); String get formattedTime { @@ -106,7 +106,7 @@ class LogEntry { @override String toString() { final errorPart = error != null ? ' | $error' : ''; - final nativePart = isFromGo ? ' [Native]' : ''; + final nativePart = isFromNative ? ' [Native]' : ''; return '[$formattedTime] [$level]$nativePart [$tag] $message$errorPart'; } } @@ -122,13 +122,13 @@ class LogBuffer extends ChangeNotifier { static const int maxEntries = 500; static const _nativeLogs = NativeLogSource(); - static const Duration _goLogPollingInterval = Duration(milliseconds: 800); + static const Duration _nativeLogPollingInterval = Duration(milliseconds: 800); final Queue _entries = Queue(); - Timer? _goLogTimer; - int _lastGoLogIndex = 0; - bool _isFetchingGoLogs = false; - int _goLogGeneration = 0; - Future? _pendingGoLogClear; + Timer? _nativeLogTimer; + int _lastNativeLogIndex = 0; + bool _isFetchingNativeLogs = false; + int _nativeLogGeneration = 0; + Future? _pendingNativeLogClear; static bool _loggingEnabled = false; static bool get loggingEnabled => _loggingEnabled; @@ -177,7 +177,7 @@ class LogBuffer extends ChangeNotifier { tag: entry.tag, message: sanitizedMessage, error: sanitizedError, - isFromGo: entry.isFromGo, + isFromNative: entry.isFromNative, ); if (_entries.length >= maxEntries) { @@ -187,36 +187,36 @@ class LogBuffer extends ChangeNotifier { return true; } - void startGoLogPolling() { - _goLogTimer?.cancel(); - _goLogGeneration++; - _goLogTimer = Timer.periodic(_goLogPollingInterval, (_) async { - if (_isFetchingGoLogs) return; - _isFetchingGoLogs = true; + void startNativeLogPolling() { + _nativeLogTimer?.cancel(); + _nativeLogGeneration++; + _nativeLogTimer = Timer.periodic(_nativeLogPollingInterval, (_) async { + if (_isFetchingNativeLogs) return; + _isFetchingNativeLogs = true; try { - await _fetchGoLogs(_goLogGeneration); + await _fetchNativeLogs(_nativeLogGeneration); } finally { - _isFetchingGoLogs = false; + _isFetchingNativeLogs = false; } }); } - void stopGoLogPolling() { - _goLogTimer?.cancel(); - _goLogTimer = null; - _goLogGeneration++; + void stopNativeLogPolling() { + _nativeLogTimer?.cancel(); + _nativeLogTimer = null; + _nativeLogGeneration++; // The stopped poll still owns the in-flight slot until its call completes. } - Future _fetchGoLogs(int generation) async { + Future _fetchNativeLogs(int generation) async { try { - final clearing = _pendingGoLogClear; + final clearing = _pendingNativeLogClear; if (clearing != null) await clearing; - if (generation != _goLogGeneration) return; - final result = await _nativeLogs.getSince(_lastGoLogIndex); - if (generation != _goLogGeneration) return; + if (generation != _nativeLogGeneration) return; + final result = await _nativeLogs.getSince(_lastNativeLogIndex); + if (generation != _nativeLogGeneration) return; final logs = result['logs'] as List? ?? []; - final nextIndex = result['next_index'] as int? ?? _lastGoLogIndex; + final nextIndex = result['next_index'] as int? ?? _lastNativeLogIndex; final keepNonErrorLogs = _loggingEnabled; final entries = []; @@ -256,13 +256,13 @@ class LogBuffer extends ChangeNotifier { level: level, tag: tag, message: message, - isFromGo: true, + isFromNative: true, ), ); } addAll(entries); - if (generation == _goLogGeneration) _lastGoLogIndex = nextIndex; + if (generation == _nativeLogGeneration) _lastNativeLogIndex = nextIndex; } catch (e) { if (kDebugMode) { debugPrint('Failed to fetch native backend logs: $e'); @@ -272,19 +272,19 @@ class LogBuffer extends ChangeNotifier { void clear() { _entries.clear(); - _lastGoLogIndex = 0; - _goLogGeneration++; + _lastNativeLogIndex = 0; + _nativeLogGeneration++; late final Future clearing; clearing = - (_pendingGoLogClear?.then((_) => _nativeLogs.clear()) ?? + (_pendingNativeLogClear?.then((_) => _nativeLogs.clear()) ?? _nativeLogs.clear()) .catchError((_) {}) .whenComplete(() { - if (identical(_pendingGoLogClear, clearing)) { - _pendingGoLogClear = null; + if (identical(_pendingNativeLogClear, clearing)) { + _pendingNativeLogClear = null; } }); - _pendingGoLogClear = clearing; + _pendingNativeLogClear = clearing; notifyListeners(); } @@ -359,7 +359,7 @@ class LogBuffer extends ChangeNotifier { int warnCount = 0; int infoCount = 0; int debugCount = 0; - int goCount = 0; + int nativeCount = 0; for (final entry in _entries) { switch (entry.level) { @@ -377,14 +377,14 @@ class LogBuffer extends ChangeNotifier { debugCount++; break; } - if (entry.isFromGo) goCount++; + if (entry.isFromNative) nativeCount++; } buffer.writeln('Errors: $errorCount'); buffer.writeln('Warnings: $warnCount'); buffer.writeln('Info: $infoCount'); buffer.writeln('Debug: $debugCount'); - buffer.writeln('From Native Backend: $goCount'); + buffer.writeln('From Native Backend: $nativeCount'); buffer.writeln(); buffer.writeln('=' * 60); diff --git a/test/log_selection_test.dart b/test/log_selection_test.dart index 3b1382ed..94e64ea7 100644 --- a/test/log_selection_test.dart +++ b/test/log_selection_test.dart @@ -52,7 +52,7 @@ void main() { tag: 'Download', message: 'second', error: 'failed', - isFromGo: true, + isFromNative: true, ), ]; diff --git a/test/native_log_polling_test.dart b/test/native_log_polling_test.dart index 0c2a8427..b7c75e3f 100644 --- a/test/native_log_polling_test.dart +++ b/test/native_log_polling_test.dart @@ -21,7 +21,7 @@ void main() { const interval = Duration(milliseconds: 800); tearDown(() { - buffer.stopGoLogPolling(); + buffer.stopNativeLogPolling(); messenger.setMockMethodCallHandler(channel, null); }); @@ -39,12 +39,12 @@ void main() { buffer.clear(); await tester.pump(); - buffer.startGoLogPolling(); + buffer.startNativeLogPolling(); await tester.pump(interval); expect(indexes, [0]); - buffer.stopGoLogPolling(); - buffer.startGoLogPolling(); + buffer.stopNativeLogPolling(); + buffer.startNativeLogPolling(); await tester.pump(interval); expect(indexes, [0]); @@ -58,7 +58,7 @@ void main() { await tester.pump(interval); expect(indexes, [0, 0, 4]); - buffer.stopGoLogPolling(); + buffer.stopNativeLogPolling(); }); testWidgets('clear rejects old logs and waits for native cursor reset', ( @@ -81,7 +81,7 @@ void main() { buffer.clear(); await tester.pump(); - buffer.startGoLogPolling(); + buffer.startNativeLogPolling(); await tester.pump(interval); expect(indexes, [0]); @@ -102,6 +102,6 @@ void main() { await tester.pump(interval); expect(indexes, [0, 0, 1]); - buffer.stopGoLogPolling(); + buffer.stopNativeLogPolling(); }); }