Skip to content

Conversation

@YadavAkhileshh
Copy link

@YadavAkhileshh YadavAkhileshh commented Jan 7, 2026

Description

Fixed the print() statement issue in whisper_transcription_controller.dart

Changes

  • Replaced print() with log() for better debugging
  • Added segment index so we know which segment failed
  • Added stack trace capture
  • Added snackbar to let users know if something goes wrong during transcription

Fixes

Fixes #680

Testing

Checked the code follows existing patterns in the project. The snackbar uses the same customSnackbar widget used elsewhere in the app.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling during transcription processing with user-friendly notifications when segments fail to process.
    • Enhanced error logging for better diagnostics of transcription-related issues.

✏️ Tip: You can customize this high-level summary in your review settings.

…r transcription

- Changed print() to log() with proper error context
- Added segment index to identify which segment failed
- Captured stack trace for debugging
- Added snackbar to notify users when transcription errors occur
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🎉 Welcome @YadavAkhileshh!
Thank you for your pull request! Our team will review it soon. 🔍

  • Please ensure your PR follows the contribution guidelines. ✅
  • All automated tests should pass before merging. 🔄
  • If this PR fixes an issue, link it in the description. 🔗

We appreciate your contribution! 🚀

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

This PR refactors error handling in the whisper transcription controller by replacing a generic catch clause with comprehensive error handling that captures stack traces, provides segment index context, and displays user-visible error notifications via snackbar.

Changes

Cohort / File(s) Summary
Error Handling & Logging Improvements
lib/controllers/whisper_transcription_controller.dart
Replaced enhanced-for loop with index-based loop for segment iteration; expanded catch clause to capture (e, stackTrace); added logging calls with segment index context; introduced snackbar notifications for user-visible Transcription Error feedback; added imports for log_type and snackbar utilities.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Deploy v2.5 of Resonate App #564: Introduced the convertToLrc and _parseTranscriptionSegment logic that this PR enhances with improved error handling and logging.

Poem

🐰 With logs now crisp and snackbars bright,
Each segment error's in the light—
No silent fails, just truthful trace,
Stack traces show us where we fall,
A rabbit's fix for errors all! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: improving error handling in the whisper_transcription_controller, which is the core objective of this PR.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #680: replacing print() with log(), adding segment index context, capturing stack traces, and adding user-visible error notification via snackbar.
Out of Scope Changes check ✅ Passed All changes are directly related to the objectives in issue #680; no out-of-scope modifications detected. The addition of customSnackbar is a minor enhancement to surface errors to users.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @lib/controllers/whisper_transcription_controller.dart:
- Around line 73-84: In the catch block inside the transcription loop (the code
that currently logs errors with log(...) and calls customSnackbar), stop calling
customSnackbar per-segment; instead, collect failed segment indices (e.g., push
i or i+1 into a local List<int> failedSegments) and continue logging as before;
after the loop that invokes segment processing (the scope around the try/catch
that uses i), check if failedSegments is not empty and then call customSnackbar
once with a concise summary message (e.g., count and optional small list or
range of failed segment numbers) to inform the user of aggregated failures; keep
the detailed log(...) calls untouched so stack traces remain available for
debugging.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cd109b and 92d6c88.

📒 Files selected for processing (1)
  • lib/controllers/whisper_transcription_controller.dart
🔇 Additional comments (2)
lib/controllers/whisper_transcription_controller.dart (2)

8-9: LGTM! Necessary imports for enhanced error handling.

The added imports support the new logging type enumeration and user notification functionality.


64-66: LGTM! Index-based iteration enables precise error reporting.

The refactoring from an enhanced for-loop to an index-based loop correctly enables segment index reporting in error messages, which was a key objective of this PR.

Comment on lines +73 to 84
} catch (e, stackTrace) {
log(
'Error converting transcription segment at index $i: ${e.toString()}',
error: e,
stackTrace: stackTrace,
);
customSnackbar(
'Transcription Error',
'Failed to process segment ${i + 1}. Some content may be missing.',
LogType.error,
);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Refactor to avoid spamming users with multiple snackbars.

The enhanced error handling correctly captures stack traces and logs detailed information, which addresses the PR objectives well. However, showing a snackbar for each failed segment creates a poor user experience if multiple segments fail during transcription.

For example, if 5 segments out of 100 fail, the user will see 5 separate snackbars in rapid succession.

Consider refactoring to collect failed segment indices during the loop and display a single summary snackbar after processing completes.

♻️ Proposed refactor to show one summary snackbar
  String convertToLrc(List<WhisperTranscribeSegment?> transcriptionSegments) {
    final StringBuffer lrcContent = StringBuffer();
    lrcContent.writeln('[re:Resonate App - AOSSIE]');
    lrcContent.writeln('[ve:v1.0.0]');
+   final List<int> failedIndices = [];
    for (int i = 0; i < transcriptionSegments.length; i++) {
      try {
        final segment = transcriptionSegments[i];
        // Parse the log line
        final segmentString = _parseTranscriptionSegment(segment);
        if (segmentString != null) {
          // Convert to LRC format and add to content
          lrcContent.writeln(segmentString);
        }
      } catch (e, stackTrace) {
        log(
          'Error converting transcription segment at index $i: ${e.toString()}',
          error: e,
          stackTrace: stackTrace,
        );
-       customSnackbar(
-         'Transcription Error',
-         'Failed to process segment ${i + 1}. Some content may be missing.',
-         LogType.error,
-       );
+       failedIndices.add(i);
      }
    }
+   
+   if (failedIndices.isNotEmpty) {
+     final count = failedIndices.length;
+     final total = transcriptionSegments.length;
+     customSnackbar(
+       'Transcription Warning',
+       'Failed to process $count of $total segments. Some content may be missing.',
+       LogType.error,
+     );
+   }

    return lrcContent.toString();
  }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In @lib/controllers/whisper_transcription_controller.dart around lines 73 - 84,
In the catch block inside the transcription loop (the code that currently logs
errors with log(...) and calls customSnackbar), stop calling customSnackbar
per-segment; instead, collect failed segment indices (e.g., push i or i+1 into a
local List<int> failedSegments) and continue logging as before; after the loop
that invokes segment processing (the scope around the try/catch that uses i),
check if failedSegments is not empty and then call customSnackbar once with a
concise summary message (e.g., count and optional small list or range of failed
segment numbers) to inform the user of aggregated failures; keep the detailed
log(...) calls untouched so stack traces remain available for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Replace print() statement with proper logging in whisper_transcription_controller

1 participant