feat(TalkerWrapper): Enhance UI Feedback, Support Warning/Info messages#466
feat(TalkerWrapper): Enhance UI Feedback, Support Warning/Info messages#466huanguan1978 wants to merge 2 commits intoFrezyx:masterfrom
Conversation
…rt Warning/Info Messages.
Reviewer's GuideAdds support in TalkerWrapper for displaying UI alerts for generic TalkerLog messages (including warning/info levels), wires TalkerLog through the error handler pipeline, and updates examples to demonstrate the new behavior and default log level handling. Sequence diagram for TalkerLog handling and UI alert displaysequenceDiagram
actor User
participant Button_HandleLog as Button_HandleLog
participant Talker as Talker
participant TalkerErrorHandler as TalkerErrorHandler
participant TalkerWrapper as TalkerWrapper
participant SnackbarContent as SnackbarContent
participant UI as UI
User->>Button_HandleLog: onPressed()
activate Button_HandleLog
Button_HandleLog->>Talker: handle(TalkerLog log)
deactivate Button_HandleLog
activate Talker
Talker->>TalkerErrorHandler: handle(log, null)
activate TalkerErrorHandler
TalkerErrorHandler-->>Talker: TalkerLog(log)
deactivate TalkerErrorHandler
Talker->>Talker: _handleLogData(log, logLevel)
Note right of Talker: logLevel = log.logLevel or LogLevel.info
Talker-->>TalkerWrapper: stream emits TalkerLog
deactivate Talker
activate TalkerWrapper
TalkerWrapper->>TalkerWrapper: if data is TalkerLog and options.enableLogAlerts
TalkerWrapper->>SnackbarContent: create(message, title)
activate SnackbarContent
SnackbarContent-->>TalkerWrapper: instance
deactivate SnackbarContent
TalkerWrapper->>UI: showAlert(SnackbarContent)
deactivate TalkerWrapper
UI-->>User: Log snackbar visible
Class diagram for updated TalkerWrapperOptions and Talker log handlingclassDiagram
class Talker {
+void handle(Object error, StackTrace? stack, String? message)
-void _handleLogData(TalkerLog data, LogLevel logLevel)
}
class TalkerErrorHandler {
+TalkerData? handle(Object exception, StackTrace? stack)
}
class TalkerWrapperOptions {
<<immutable>>
+String exceptionTitle = Error occurred
+String errorTitle = Error occurred
+String logTitle = Log message
+TalkerExceptionBuilder? exceptionAlertBuilder
+TalkerErrorBuilder? errorAlertBuilder
+TalkerDataBuilder? logAlertBuilder
+bool enableErrorAlerts = false
+bool enableExceptionAlerts = true
+bool enableLogAlerts = true
}
class TalkerWrapper {
+TalkerWrapper(Talker talker, TalkerWrapperOptions options, Widget child)
+Widget build(BuildContext context)
-String _mapErrorMessage(String message)
}
class TalkerLog {
+String message
+String? title
+TalkerLogLevel? logLevel
+String get displayMessage()
}
class SnackbarContent {
+String message
+String title
}
class TalkerException {
}
class TalkerData {
}
class LogLevel {
<<enum>>
+info
+warning
+error
}
class TalkerLogLevel {
<<enum>>
+info
+warning
+error
}
Talker ..> TalkerLog : uses
Talker ..> LogLevel : uses
TalkerErrorHandler ..> TalkerLog : returns
TalkerErrorHandler ..> TalkerException : returns
TalkerErrorHandler ..> TalkerData : returns
TalkerWrapper ..> Talker : observes data from
TalkerWrapper ..> TalkerWrapperOptions : configures
TalkerWrapper ..> SnackbarContent : creates
TalkerWrapper ..> TalkerLog : handles
TalkerLog --> TalkerData : extends
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The doc comment for
enableLogAlertsstill says "will show exceptions message"; update it to reflect that it controls log messages instead to avoid confusion. - Treating
TalkerLogas a passthrough case inTalkerErrorHandler.reportalongsideTalkerExceptionmay be confusing semantically; consider either a dedicated branch/handler for logs or clarifying the naming to distinguish logs from exceptions.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The doc comment for `enableLogAlerts` still says "will show exceptions message"; update it to reflect that it controls log messages instead to avoid confusion.
- Treating `TalkerLog` as a passthrough case in `TalkerErrorHandler.report` alongside `TalkerException` may be confusing semantically; consider either a dedicated branch/handler for logs or clarifying the naming to distinguish logs from exceptions.
## Individual Comments
### Comment 1
<location> `packages/talker_flutter/lib/src/ui/talker_wrapper/talker_wrapper_options.dart:41-42` </location>
<code_context>
/// [TalkerWrapper] will show error message if field is [true]
final bool enableErrorAlerts;
/// [TalkerWrapper] will show exceptions message if field is [true]
final bool enableExceptionAlerts;
+
+ /// [TalkerWrapper] will show exceptions message if field is [true]
+ final bool enableLogAlerts;
}
</code_context>
<issue_to_address>
**suggestion:** The doc comment for `enableLogAlerts` appears to be copy-pasted from the exception flag and is misleading.
This field controls log alerts, but its doc still refers to exceptions. Please update the wording to describe log messages/log alerts so it matches the actual behavior.
```suggestion
/// [TalkerWrapper] will show log messages if field is [true]
final bool enableLogAlerts;
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
packages/talker_flutter/lib/src/ui/talker_wrapper/talker_wrapper_options.dart
Outdated
Show resolved
Hide resolved
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #466 +/- ##
==========================================
- Coverage 98.63% 91.01% -7.62%
==========================================
Files 3 13 +10
Lines 146 267 +121
==========================================
+ Hits 144 243 +99
- Misses 2 24 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
feat(TalkerWrapper): Enhance Logging and UI Feedback Mechanism, Support Warning/Info messages.
Summary by Sourcery
Extend TalkerWrapper and core logging to surface generic TalkerLog messages in the UI and treat them consistently in the error handling pipeline.
New Features:
Enhancements: