Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion app/lib/providers/speech_profile_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_provider_utilities/flutter_provider_utilities.dart';
import 'package:omi/backend/http/api/conversations.dart' as conversations_api;
import 'package:omi/backend/http/api/speech_profile.dart';
import 'package:omi/backend/http/api/users.dart';
import 'package:omi/backend/preferences.dart';
Expand Down Expand Up @@ -481,6 +482,22 @@ class SpeechProfileProvider extends ChangeNotifier
}
}

/// Handles onboarding complete event - fetches the created conversation and finalizes
Future<void> _handleOnboardingComplete(OnboardingCompleteEvent event) async {
// Fetch the created conversation before finalizing
if (event.conversationId != null) {
try {
debugPrint('Fetching onboarding conversation: ${event.conversationId}');
conversation = await conversations_api.getConversationById(event.conversationId!);
debugPrint('Fetched onboarding conversation: ${conversation?.id}, title: ${conversation?.structured?.title}');
} catch (e) {
debugPrint('Error fetching onboarding conversation: $e');
}
Comment on lines +493 to +495
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This try-catch block silently swallows errors in production because debugPrint is a no-op in release builds. If getConversationById fails, conversation will remain null, and the original bug this PR aims to fix will reappear without any indication of what went wrong. This is a significant issue as it makes the fix incomplete.

It's critical to handle this error properly. At a minimum, the error should be logged using a production-safe logger (e.g., Logger.error) and reported to a crash reporting service. This will provide visibility into failures and help diagnose issues in production.

}

finalize();
}

@override
void onMessageEventReceived(MessageEvent event) {
debugPrint('onMessageEventReceived: ${event.eventType}');
Expand All @@ -496,7 +513,7 @@ class SpeechProfileProvider extends ChangeNotifier
notifyInfo('NEXT_QUESTION');
} else if (event is OnboardingCompleteEvent) {
debugPrint('Onboarding complete from backend: conversationId=${event.conversationId}');
finalize();
_handleOnboardingComplete(event);
}
}

Expand Down