Skip to content

briefing: say why, from reasons worked out on the phone - #1074

Open
abdulsaheel wants to merge 4 commits into
mainfrom
feat/briefing-reasons
Open

abdulsaheel wants to merge 4 commits into
mainfrom
feat/briefing-reasons

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

the morning briefing only restated numbers. now it gets up to three reasons (strain, short sleep, low hrv, high resting hr, alcohol) that are at least 1.5 robust-z off your own history over 14+ days, worded as 'came with', not 'because'. the alcohol/journal ones are off until you turn them on in the briefing settings. stacked on the language pr.

Summary by Sourcery

Give morning briefings concise, history-based context for recovery readings while keeping journal-derived reasons opt-in.

New Features:

  • Add up to three evidence-based morning briefing reasons for unusually high prior-day strain, short sleep, low HRV, high resting heart rate, or logged alcohol, compared with the user's history.

Enhancements:

  • Keep briefing explanations limited to listed associations and avoid presenting them as causes; omit reasons when recovery is unavailable or the data is insufficient.
  • Regenerate morning briefings when the journal-reasons setting changes, while leaving evening briefings unaffected.

Tests:

  • Add coverage for reason selection, journal opt-in behavior, cache invalidation, insufficient or unavailable data, and mid-generation setting changes.

Chores:

  • Add a default-off briefing setting to opt in to journal-derived reasons, and include that preference in backups.
  • Update English and translated briefing strings for the journal-reasons setting.

@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add the persisted journal-reasons preference and record the setting used to generate each briefing so cached notes can be compared with it.

  • lib/ai/ai_prefs.dart L18-21, L69-93 (+6 small edits)
  • lib/ai/briefing.dart L80-83 (+4 small edits)

API

Expose robust-history helpers for reason calculation and make briefing reads account for the journal-reasons setting when deciding whether a morning cache is stale.

  • lib/ai/briefing.dart L147-156, L193-200
  • lib/ai/briefing_engine.dart L115-646 (4 small edits)
  • lib/ai/nightly_sweep.dart L124-127

Uses of the API

Pass the current journal-reasons setting into cache lookup so the app refreshes a morning note when the setting changes.

  • lib/state/app_state.dart L2846-2849

Implementation

Select up to three deterministic, history-based association lines, optionally include yesterday’s journal alcohol metric, and constrain the prompt to those lines rather than invented causes.

  • lib/ai/briefing_engine.dart L238-291, L702-712, L741-748 (+7 small edits)
  • lib/ai/briefing_reasons.dart L1-98

UI

Show a morning-briefing opt-in switch with an explanation of when journal data may be sent, and update the briefing copy across supported languages.

  • lib/l10n/app_de.arb L4165-4167
  • lib/l10n/app_en.arb L18904-18911
  • lib/l10n/app_es.arb L4165-4167
  • lib/l10n/app_fr.arb L4165-4167
  • lib/l10n/app_hi.arb L4165-4167
  • lib/l10n/app_ru.arb L9495-9497
  • lib/l10n/app_th.arb L17673-17675
  • lib/l10n/app_zh.arb L4165-4167
  • lib/ui2/screens/ai_briefing.dart L58-80, L220-245 (+2 small edits)

Configuration

Include the new journal-reasons preference in backup preference type handling.

  • lib/data/backup_extras.dart L141

Tests

Cover reason selection and thresholds, journal opt-in and failures, prompt restrictions, cache invalidation, and preference persistence.

  • test/backup/settings_audit_guard_test.dart L27
  • test/briefing_reasons_test.dart L1-311

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9e8b816 and 24cbe26.

Files ignored due to path filters: 2

  • test/backup/settings_audit_guard_test.dart is excluded by !test/**
  • test/briefing_reasons_test.dart is excluded by !test/**
Files selected for processing: 16

  • lib/ai/ai_prefs.dart
  • lib/ai/briefing.dart
  • lib/ai/briefing_engine.dart
  • lib/ai/briefing_reasons.dart
  • lib/ai/nightly_sweep.dart
  • lib/data/backup_extras.dart
  • lib/l10n/app_de.arb
  • lib/l10n/app_en.arb
  • lib/l10n/app_es.arb
  • lib/l10n/app_fr.arb
  • lib/l10n/app_hi.arb
  • lib/l10n/app_ru.arb
  • lib/l10n/app_th.arb
  • lib/l10n/app_zh.arb
  • lib/state/app_state.dart
  • lib/ui2/screens/ai_briefing.dart
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 8 issues

Sourcery assessment

Needs a human reviewer. 8 findings to address first, and when a user opts in, yesterday’s alcohol units can be included in the briefing prompt sent to the configured model provider. Reverting stops future disclosures, but it cannot retrieve prompts already sent.

Blocking findings: lib/ui2/screens/ai_briefing.dart:68, lib/ai/briefing_engine.dart:654, lib/ai/briefing_engine.dart:266, lib/ai/briefing_reasons.dart:46, lib/ai/ai_prefs.dart:72, and 3 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread lib/ui2/screens/ai_briefing.dart Resolved
Comment thread lib/ai/briefing_engine.dart Resolved
Comment thread lib/ai/briefing_engine.dart Resolved
Comment thread lib/ai/briefing_reasons.dart Resolved
Comment thread lib/ai/ai_prefs.dart Resolved
Comment thread lib/ui2/screens/ai_briefing.dart Resolved
Comment thread lib/data/backup_extras.dart Resolved
Comment thread lib/ai/briefing.dart Resolved
@abdulsaheel
abdulsaheel changed the base branch from feat/coach-language to main December 6, 2026 10:00

This branch has not been deployed

No deployments
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.

1 participant