feat: synthesize decisions in health reports - #2301
Conversation
Keep report interpretation server-owned so web, mobile, and shared snapshots present the same evidence and caveats.\n\nRefs #2171
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Reviewer's GuideAdds server-owned decision synthesis for weekly and monthly health reports and renders it consistently across server, web, mobile, and shared report snapshots while preserving backward compatibility and expanding tests and Storybook coverage. Sequence diagram for decision synthesis in health reportssequenceDiagram
participant Client
participant WeeklyReportRepository
participant MonthlyReportRepository
participant ReportDecisionSynthesisModule
Client->>WeeklyReportRepository: getReport(weeks, endDate)
WeeklyReportRepository->>ReportDecisionSynthesisModule: buildWeeklyDecisionSynthesis(current, history)
WeeklyReportRepository-->>Client: WeeklyReportResult{current, history, decisionSupport}
Client->>MonthlyReportRepository: getReport(months)
MonthlyReportRepository->>ReportDecisionSynthesisModule: buildMonthlyDecisionSynthesis(current, history)
MonthlyReportRepository-->>Client: MonthlyReportResult{current, history, decisionSupport}
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by QodoSynthesize decision support for weekly/monthly health reports
AI Description
Diagram
High-Level Assessment
Files changed (27)
|
Mobile PreviewScan to open on device:
To test on device:
|
|
Storybook previews for This comment updates automatically on each PR push. |
📝 WalkthroughWalkthroughReports now receive deterministic server-generated decision-support narratives covering changes, associations, worked patterns, next steps, and confidence or missing data. Web and mobile report surfaces render the narratives while shared snapshots accept legacy data without the new field. ChangesDecision-oriented report synthesis
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ReportRepository
participant DecisionSynthesis
participant WebOrMobileReport
ReportRepository->>DecisionSynthesis: build synthesis from current and history
DecisionSynthesis-->>ReportRepository: return decisionSupport
ReportRepository->>WebOrMobileReport: provide report snapshot
WebOrMobileReport->>WebOrMobileReport: render five decision sections
Assessment against linked issues
| Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
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. Comment |
Code Review by Qodo
Context used✅ Compliance rules (platform):
202 rules✅ Skills:
fix-provider, write-tests, cloudflare 1.
|
Use display-rounded pluralization and occurrence-aware React keys, and document the canonical sandbox verification path.\n\nRefs #2171
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Exercise decision boundaries and missing-data combinations through the public builders so Stryker verifies the intended behavior.
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 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 `@docs/superpowers/plans/2026-07-29-decision-oriented-reports.md`:
- Line 5: Update the plan’s terminology from “iOS” to “mobile” consistently,
including the behavior, evidence, test, and task sections referenced in the
comment. Preserve explicit web/mobile parity and identify the concrete mobile
implementation files and verification commands rather than narrowing scope to
iOS.
In `@packages/mobile/app/reports.test.tsx`:
- Around line 38-44: Add a mobile reports test variant with decisionSupport set
to null, exercising the null guard in reports.tsx. Assert that “Decision
summary” is absent while the metric card still renders, preserving coverage of
the empty decision-support path.
In `@packages/mobile/components/ReportDecisionSynthesis.tsx`:
- Around line 6-24: Extract the shared sections table and keyedItems logic from
ReportDecisionSynthesis into `@dofek/format`, exposing shared symbols such as
reportDecisionSynthesisSections and keyedDecisionSynthesisItems. Update both the
mobile and web ReportDecisionSynthesis components to import and use these
exports, removing their local duplicated definitions while preserving the
existing keys, titles, and deduplication behavior.
In `@packages/server/src/repositories/report-decision-synthesis.ts`:
- Around line 194-200: Update the confidence message in the report-decision
synthesis flow so cases with periodCount >= 4 and missing.length > 0 describe
the missing metric as the limiting factor rather than attributing limited
confidence to the number of periods. Branch the reason on missing.length > 0
while preserving the existing moderate-confidence message when no metrics are
missing and the low/limited period-count wording when fewer than four periods
are available.
- Around line 34-42: Update formatDuration to return a non-empty duration for
positive sub-minute inputs that round to zero, while preserving the existing
hour/minute formatting for values rounding to at least one minute. Ensure
describeWeeklySleepChange callers never receive an empty string for valid
positive sleep durations.
In `@packages/web/src/components/ReportDecisionSynthesis.stories.tsx`:
- Around line 24-45: Add an Empty story alongside Default and MissingData in the
ReportDecisionSynthesis stories, passing a synthesis fixture with all section
arrays empty to cover the no-data state. Do not add a loading prop or loading
story, since loading remains parent-owned and ReportDecisionSynthesis has no
loading contract.
In `@packages/web/src/routes/health-report.tsx`:
- Around line 50-56: Update reportDecisionSynthesisSchema so each narrative
string in its arrays must be non-empty or contain text, while preserving support
for empty arrays. Apply the validation consistently to whatChanged,
likelyAssociations, whatWorked, whatToTryNext, and confidenceAndMissingData
before ReportDecisionSynthesis renders the items.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e9e055f2-7ab5-4c75-a110-2e165e4fc3eb
📒 Files selected for processing (27)
docs/superpowers/plans/2026-07-29-decision-oriented-reports.mdpackages/mobile/app/reports.test.tsxpackages/mobile/app/reports.tsxpackages/mobile/components/ReportDecisionSynthesis.stories.tsxpackages/mobile/components/ReportDecisionSynthesis.test.tsxpackages/mobile/components/ReportDecisionSynthesis.tsxpackages/server/src/repositories/monthly-report-repository.test.tspackages/server/src/repositories/monthly-report-repository.tspackages/server/src/repositories/report-decision-synthesis.test.tspackages/server/src/repositories/report-decision-synthesis.tspackages/server/src/repositories/weekly-report-repository.test.tspackages/server/src/repositories/weekly-report-repository.tspackages/server/src/routers/health-report.test.tspackages/server/src/types.tspackages/web/src/components/MonthlyReportContent.stories.tsxpackages/web/src/components/MonthlyReportContent.test.tsxpackages/web/src/components/MonthlyReportContent.tsxpackages/web/src/components/ReportDecisionSynthesis.stories.tsxpackages/web/src/components/ReportDecisionSynthesis.test.tsxpackages/web/src/components/ReportDecisionSynthesis.tsxpackages/web/src/components/WeeklyReportCard.stories.tsxpackages/web/src/components/WeeklyReportCard.test.tsxpackages/web/src/components/WeeklyReportCard.tsxpackages/web/src/routes/health-report.test.tsxpackages/web/src/routes/health-report.tsxpackages/web/src/routes/monthly-report.tsxpackages/web/src/routes/weekly-report.tsx
Expect the server-owned decision support field in empty weekly and monthly report responses.
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Update the SDK 57 compatibility set and release-age policy entries required by Expo dependency validation.
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Summary
Validation
pnpm lintpnpm typecheckpnpm spellcheckpnpm knippnpm test: clean full run before the final wording-only accuracy edit; post-edit rerun passed all 14,601 assertions but Vitest exited on a post-run worker RPC timeout (Timeout calling "onTaskUpdate")Fixes #2171
Summary by Sourcery
Add server-generated decision-oriented summaries to weekly and monthly health reports and render them consistently across web, mobile, and shared snapshots.
New Features:
Enhancements:
Documentation:
Tests:
Summary by cubic
Adds server-generated decision synthesis to weekly and monthly health reports and renders it consistently across web, mobile, and shared snapshots. Syncs Expo SDK 57 dependencies and release-age policy to satisfy validation, addressing #2171.
New Features
decisionSupportto weekly/monthly report results and exportsReportDecisionSynthesisfromdofek-server/types;@dofek/format/report-decision-synthesisdefines shared section order and stable item keys.ReportDecisionSynthesisbefore metrics; shared/snapshotted report schemas accept optionaldecisionSupportand pass it through while preserving legacy snapshots.Bug Fixes
decisionSupport(ornull) in empty-report responses and validate/trim it in web shared-report routes, rejecting blank narratives.Written for commit f979ed1. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Tests