Skip to content

fix(notify): deep-link detected-workout notification to the log/adjust review (#113) - #114

Merged
abdulsaheel merged 2 commits into
OpenStrap:mainfrom
dannymcc:fix/notification-deep-link-detected-workout
Jul 21, 2026
Merged

fix(notify): deep-link detected-workout notification to the log/adjust review (#113)#114
abdulsaheel merged 2 commits into
OpenStrap:mainfrom
dannymcc:fix/notification-deep-link-detected-workout

Conversation

@dannymcc

@dannymcc dannymcc commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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 /workouts resolves to the Workouts tab only (tap_router.dart) — no focused screen. The suggestion does render as a _SuggestionCard on 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/suggestion sub-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 — new kRouteWorkoutSuggestion. _screenRoutes becomes a route → base tab map so a sub-screen can sit over any tab (briefing/journal stay over Today 0; the suggestion review sits over Workouts 4, so closing it lands you on the Workouts tab).
  • derivation_engine.dart — the auto-detect notification now uses kRouteWorkoutSuggestion.
  • app.dart_onScreenRequest pushes WorkoutSuggestionScreen for the new route.
  • workouts_screen.dart — extract a shared _logDetectedSession (so the tab card and the new screen write an identical session) and add WorkoutSuggestionScreen, 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 /workouts still 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

  • No parameterised payload. The review shows all currently-active suggestions rather than one specific id (the route string carries no id, matching the existing param-less sub-screen routes). In practice there's normally a single fresh suggestion; showing any others pending is fine.
  • Underlying tab refresh. After confirming, the Workouts tab beneath keeps its cached suggestion list until its next load (pull-to-refresh / re-open). Pre-existing coarseness, left out of scope to keep the change focused.
  • Couldn't run the analyzer/tests locally (no Flutter SDK on my machine, and CI only runs on tag push, not PRs). The change is self-contained and I've reviewed it against the surrounding code + conventions; a maintainer running flutter analyze / flutter test before merge would be the final check.

Summary by CodeRabbit

  • New Features
    • Added a dedicated screen for reviewing automatically detected workout suggestions.
    • Tapping workout suggestion notifications now opens directly to the Workouts tab and focused review view.
    • Users can confirm to log completed sessions or dismiss workout suggestions from the review screen.
  • Bug Fixes
    • Improved deep-link routing to place workout suggestion links on the correct tab while keeping existing navigation behavior for other routes.

…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
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e020609-9046-44f1-a618-6d982e8ff97f

📥 Commits

Reviewing files that changed from the base of the PR and between ee4bc3e and 189c32c.

📒 Files selected for processing (1)
  • lib/ui/workouts/workouts_screen.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/ui/workouts/workouts_screen.dart

📝 Walkthrough

Walkthrough

Workout 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.

Changes

Workout suggestion flow

Layer / File(s) Summary
Route definition and resolution
lib/notify/tap_router.dart, lib/compute/derivation_engine.dart, test/tap_router_test.dart
Defines /workouts/suggestion, maps it to tab 4, emits it from workout notifications, and tests route resolution.
Suggestion persistence and review UI
lib/ui/workouts/workouts_screen.dart
Centralizes detected-session logging and adds a screen for loading, confirming, dismissing, and clearing active suggestions.
Deep-link screen entry
lib/app.dart
Pushes WorkoutSuggestionScreen when the dedicated screen request is received.

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
Loading

Possibly related PRs

🚥 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 clearly matches the main change: routing the detected-workout notification to a dedicated review screen.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 24c336b and ee4bc3e.

📒 Files selected for processing (5)
  • lib/app.dart
  • lib/compute/derivation_engine.dart
  • lib/notify/tap_router.dart
  • lib/ui/workouts/workouts_screen.dart
  • test/tap_router_test.dart

Comment thread lib/ui/workouts/workouts_screen.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.
@abdulsaheel
abdulsaheel merged commit f90d969 into OpenStrap:main Jul 21, 2026
1 check passed
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.

Android: Clicking on a notification doesnt take the user to the correct page

2 participants