Repository navigation
Stress Nerd Stats: show the index, level and score behind the score - #632
Conversation
A score clamped to 0 left nothing on screen to say why. The index and level are the unclamped facts; read from the viewed day's own payload, no new series key.
Reviewer's GuideThe PR adds a localized Stress index table to Nerd Stats by decoding each viewed day’s own stress payload off the UI isolate, without changing stress computation, schema, series keys, or algorithm version; it also hardens missing-data handling and adds widget/database-path tests. Sequence diagram for loading and displaying viewed-day stress factssequenceDiagram
participant User
participant Investigate as InvestigateScreen
participant Load as InvestigateData.load
participant Isolate
participant DB as LocalRepository
User->>Investigate: Open stress Nerd Stats
Investigate->>Load: load(repo, stress, day)
Load->>DB: Read viewed day payload_json
DB-->>Load: payload_json
Load->>Isolate: Isolate.run(_stressFacts(payload))
Isolate->>Isolate: jsonDecode(payload)
Isolate-->>Load: stress block, imported, source
Load-->>Investigate: InvestigateData(stress)
Investigate->>Investigate: _stressPanels(context, data)
Investigate-->>User: Localized Stress index table
Flow diagram for stress index table data handlingflowchart TD
A[Viewed day stress payload] --> B{Payload decodes?}
B -- No --> C[Show no stress table]
B -- Yes --> D{Finite SI present?}
D -- No --> C
D -- Yes --> E[Show Index SI]
E --> F[Show localized known level or dash]
E --> G[Show finite score or dash]
F --> H[Stress index table]
G --> H
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Load stress details lib/ui2/screens/investigate.dart |
The screen decodes stress data and import metadata in an isolate and passes the stress map through InvestigateData. |
Display and localize stress details lib/ui2/screens/investigate.dart, lib/l10n/app_{de,en,es,fr,hi,ru,zh}.arb |
The screen displays finite SI values, recognized stress levels, and finite scores. The localization files add labels for the stress section and its values. |
Estimated code review effort: 3 (Moderate) | ~15 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant InvestigateScreen
participant Isolate
participant InvestigateData
InvestigateScreen->>Isolate: Decode stress payload and import metadata
Isolate-->>InvestigateScreen: Return stress facts
InvestigateScreen->>InvestigateData: Store loaded stress map
Suggested reviewers: abdulsaheel
Merge Risk: 
Minimal · up to 66566
-
The stress details are ready to merge after normal checks.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title names the main change: the Stress Nerd Stats section now shows the Baevsky stress index, the stress level, and the 0-100 score. The raw summary confirms that the investigate screen now displays these rows, and the PR objectives state the same goal. The title is specific and matches the changeset.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- 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.
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="lib/ui2/screens/investigate.dart" line_range="178" />
<code_context>
+ // An optional side table: a payload that will not decode is an absent
+ // table, not a screen that fails to load.
+ try {
+ final f = await Isolate.run(() => _stressFacts(payload));
+ stress = (f['stress'] as Map).cast<String, dynamic>();
+ if (f['imported'] == true) {
</code_context>
<issue_to_address>
**Stress facts bypass repository seam**
When the investigation screen loads the `stress` key for a day with a payload, `InvestigateData.load` decodes the viewed day’s payload through `_stressFacts` in the screen layer, so the new stress shape is built outside the repository read seam.
Move the viewed-day stress extraction behind the `LocalRepositoryImpl` read seam and have `InvestigateData.load` consume that screen-ready shape.
</issue_to_address>Sourcery assessment
Approved.
the wellness screen already exports one; two public copies made health_screen's imports ambiguous.
|
@coderabbitai review |
Action not completed
|
Stress Nerd Stats now shows the index, level and score behind the stress score.
A score clamped to 0 gave no hint why. The stored stress block has the unclamped facts: the Baevsky index (SI), the level and the score. This reads them from the viewed day's own payload and shows them as a "Stress index" table. The payload is decoded in an isolate.
stress_sistays absent on purpose), nokAlgoVersionbump, and no change to how stress is computed.Part of #631. This only makes the cause visible. The score still reads 0 when SI is below 20; the follow-up discussed in the issue is a baseline-relative score.
Tests:
test/investigate_stress_index_test.dart(widget) andtest/investigate_stress_load_test.dart(DB load path).low_readiness_*andhealth_workout_export_delete_gate_testalso fail on main and are unrelated.Summary by Sourcery
Expose the underlying stress index and level so users can understand the score shown for a viewed day.
New Features:
Bug Fixes:
Enhancements:
Tests:
Summary by CodeRabbit