fix(notify): deep-link detected-workout notification to the log/adjust review (#113) - #114
Merged
abdulsaheel merged 2 commits intoJul 21, 2026
Conversation
…t review The "Did you work out?" auto-detect notification routed to /workouts, which only selected the Workouts tab and left the detected activity as one card in the history list. Tapping it never clearly took the user to where the activity could be logged or adjusted (issue OpenStrap#113). Add a dedicated /workouts/suggestion sub-screen route (over the Workouts tab) that opens a focused review of the active suggestion(s) with the existing Log it / Dismiss actions, matching how the AI-briefing and journal notifications already push a focused screen. - tap_router: kRouteWorkoutSuggestion; _screenRoutes now maps each sub-screen route to the tab it sits over (suggestion → Workouts) - derivation_engine: auto-detect notification uses the new route - app: push WorkoutSuggestionScreen for the route - workouts_screen: extract shared _logDetectedSession; add the screen - tests: cover the new route resolution
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughWorkout suggestions now use a dedicated deep-link route mapped to the Workouts tab. The app opens a review screen where suggestions can be confirmed into completed sessions or dismissed. ChangesWorkout suggestion flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DerivationEngine
participant TapRouter
participant ShellState
participant WorkoutSuggestionScreen
participant LocalDb
DerivationEngine->>TapRouter: emit kRouteWorkoutSuggestion
TapRouter->>ShellState: resolve to Workouts tab and sub-screen
ShellState->>WorkoutSuggestionScreen: push review screen
WorkoutSuggestionScreen->>LocalDb: load active suggestions
WorkoutSuggestionScreen->>LocalDb: confirm or dismiss suggestion
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/ui/workouts/workouts_screen.dart`:
- Around line 1590-1603: Update the workout suggestion query flow near the
existing catch block to track a recoverable error separately from the loaded
suggestions, expose a retry action that reruns the query, and render the error
state instead of “Nothing to review” when loading fails. Update _confirm and
_dismiss to catch action failures and provide user-visible feedback while
preserving the existing success flow; show the empty state only after a
successful query with no suggestions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a5a1335-6075-4141-8ad3-52aa2bee93a6
📒 Files selected for processing (5)
lib/app.dartlib/compute/derivation_engine.dartlib/notify/tap_router.dartlib/ui/workouts/workouts_screen.darttest/tap_router_test.dart
…(CodeRabbit) WorkoutSuggestionScreen._load() previously caught a failed query and just fell through to the same UI as "no suggestions" — telling the user a still-active suggestion had already been handled when really the query just failed. Track load failure as separate state from the suggestion list (which is now left untouched on error, not blanked), and render a retryable StateCard instead of the empty-state text. _confirm/_dismiss now catch action failures too and surface a SnackBar instead of silently doing nothing — previously a failed confirm/dismiss gave no feedback at all, indistinguishable from success.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #113. When an activity is auto-detected, tapping the "Did you work out?" notification doesn't take you to where the detected activity can be logged or adjusted.
Root cause: the notification is emitted with
route: '/workouts'(lib/compute/derivation_engine.dart), and/workoutsresolves to the Workouts tab only (tap_router.dart) — no focused screen. The suggestion does render as a_SuggestionCardon that tab, but it's one card in the history list, so the tap never clearly lands the user on the log/adjust affordance. The other deep links (/ai/morning,/journal/compose,/breathing) each push a focused sub-screen; the detected-workout tap didn't.Fix
Add a dedicated
/workouts/suggestionsub-screen deep link that opens a focused review of the active suggestion(s) — the existing Log it / Dismiss actions — sitting on top of the Workouts tab, consistent with the existing sub-screen pattern.tap_router.dart— newkRouteWorkoutSuggestion._screenRoutesbecomes aroute → base tabmap so a sub-screen can sit over any tab (briefing/journal stay over Today0; the suggestion review sits over Workouts4, so closing it lands you on the Workouts tab).derivation_engine.dart— the auto-detect notification now useskRouteWorkoutSuggestion.app.dart—_onScreenRequestpushesWorkoutSuggestionScreenfor the new route.workouts_screen.dart— extract a shared_logDetectedSession(so the tab card and the new screen write an identical session) and addWorkoutSuggestionScreen, which reuses the existing_SuggestionCard. Confirming/dismissing the last suggestion pops back to the Workouts tab.test/tap_router_test.dart— covers the new route + a regression guard that plain/workoutsstill resolves to the tab with no sub-screen.Behaviour after
Tap the "Did you work out?" notification → land directly on a Detected activity screen with Log it / Dismiss, over the Workouts tab. Works on both warm and cold start (the shell already replays the launch route via a post-frame callback).
Notes / limitations
flutter analyze/flutter testbefore merge would be the final check.Summary by CodeRabbit