feat(today): gate lookback card on collected-data span#143
Conversation
The Lookback / "Your day" card appeared immediately on the Today screen, even with only minutes of data, so it was empty and misleading on first run (OpenStrap#140, reported in OpenStrap#102). Gate its visibility on the span of collected data — from the earliest decoded record (MIN(rec_ts)) to now — loaded best-effort in fetch() and compared against a documented, tunable threshold (kLookbackMinDataHours, ~18h, localhoop's lower bound for a meaningful day). Below the threshold the card is hidden entirely rather than rendering a bare "No data yet" placeholder. The gate is a pure helper (shouldShowLookback) with tests.
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTodayScreen now computes the collected-data span during ChangesLookback visibility
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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/today/today_screen.dart`:
- Around line 141-153: The `_dataSpanHours` value is only recomputed during
`fetch()`, so it becomes stale when decoded data changes. Update the
decoded-count change handling to recompute the same first-record-to-now span
used in `fetch()` whenever counts change, or invoke a shared refresh helper from
that path, while preserving the existing mounted `setState` behavior.
🪄 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: c7ad5589-8929-4c70-9670-8d3c263cfa8d
📒 Files selected for processing (2)
lib/ui/today/today_screen.darttest/lookback_gate_test.dart
Store the earliest record timestamp rather than a span precomputed in fetch(), and derive `now - earliest` in the build path. The card now appears as soon as the collected span crosses kLookbackMinDataHours by elapsed wall-clock time, instead of waiting for the next loader refresh to recompute the span (CodeRabbit, OpenStrap#143). shouldShowLookback takes the earliest timestamp plus a live `now`; the test drives the "just crossed 18h on the clock alone" case.
What
The Lookback / "Your day" card on the Today screen appeared immediately, even with only minutes of collected data, so on first run it was empty and misleading.
This gates the card's appearance on having a meaningful span of collected data (~a full day). Below the threshold the card is hidden cleanly — no empty "No data yet today" placeholder.
How
MIN(rec_ts)via the existingLocalDb.firstAndLastRecordTs()) to now, loaded best-effort infetch()and held in_dataSpanHours.const kLookbackMinDataHours = 18(localhoop's lower bound for a meaningful day; the ~18–24h band).shouldShowLookback(double? dataSpanHours)wraps the card'scollection-ifin_content(). Null span (no data yet) → hidden.Scope is deliberately just the card's appearance on the Today screen — this does not touch
journey_screen.dart(day-navigation inside the JourneyScreen is a separate concern).Tests
Added
test/lookback_gate_test.dartcovering the gate helper: null/minutes-of-data → hidden, just-below threshold → hidden, at/above threshold → shown, and that the threshold sits in the documented ~18–24h band.No Flutter/Dart SDK was available in this environment, so the change is inspection-verified; the pure-helper tests are provided for CI to run.
Closes #140
Reported in #102.
Summary by CodeRabbit
New Features
Bug Fixes
Tests