PAPER-08: Wire Today dossier to real backend APIs#1056
Conversation
Exposes getCadence, getStreak, sealDay, getSealStatus, getTomorrowNote, and saveTomorrowNote matching the backend TodayController contract. Refs #1004
Replace synchronous stub-only dossier with live API calls for cadence, streak, seal status, and tomorrow-note. Stubs remain as graceful fallback when any endpoint fails. sealDay() now calls POST /today/seal; saveLineForTomorrow() debounces to PUT /today/tomorrow-note. Refs #1004
Add todayApi mock to PaperTodayView and TodayCover tests so they work with the composable's new async API calls. Update sealDay idempotency test to await the async return. Refs #1004
Covers getCadence, getStreak, sealDay, getSealStatus, getTomorrowNote (200 and 204), and saveTomorrowNote. Refs #1004
Tests live cadence/streak/seal/note mapping, stub fallback on API failure, sealDay idempotency, and data re-fetch on date change. Refs #1004
There was a problem hiding this comment.
Code Review
This pull request integrates the Today Dossier feature with a backend API, moving away from static stubs. It adds a new todayApi module and updates the useTodayDossier composable to fetch live cadence, streak, and note data, while also implementing debounced autosaving for notes. Key feedback includes addressing a timezone inconsistency in cadence mapping, fixing optimistic state updates in the sealDay error path, and ensuring that "no content" API responses correctly clear the UI instead of reverting to mock data. Further improvements are suggested for error handling in both the composable and the view, as well as completing the integration of the note-saving functionality in the frontend.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e496a8499e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Adversarial Code ReviewCRITICAL
HIGH
MEDIUM
LOW
Bot Comments Addressed
Summary0 CRITICAL, 2 HIGH, 2 MEDIUM, 2 LOW. Fixing HIGH #1, HIGH #2, MEDIUM #1, and LOW #1 now. MEDIUM #2 is a known gap deferred to a follow-up. LOW #2 not fixing per task instructions. |
- Add fetch generation counter to discard stale fetchLiveData results when now changes rapidly - Return sealed: false on sealDay API failure so user can retry - Flush pending autosave on scope dispose instead of silently dropping
getTomorrowNote was only accepting 200 and 204, which would silently reject other valid 2xx responses without hitting the error interceptor.
Adversarial Review -- Fixes Applied
All fixable findings addressed. CI status: PENDING (required checks running). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df6917febb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…e, add sealDay guard - CRITICAL: Wire saveLineForTomorrow @save handler in PaperTodayView so tomorrow-note autosave actually persists to backend - CRITICAL: 204 (no note) now returns empty string instead of falling back to stub text - IMPORTANT: Add sealDay in-flight guard to prevent duplicate POST on double-click - IMPORTANT: Log autosave errors via logError instead of swallowing - IMPORTANT: Remove redundant validateStatus (204 is already in 2xx)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 062e9a493d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
When sealDay returns sealed:false (API failure or in-flight guard), show an error toast instead of the misleading success message.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: caffa362e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a76f72b52
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c84d7155d9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return bucket?.eventCount ?? 0 | ||
| }) | ||
|
|
||
| const peakHourIndex = response.peakHour ?? 0 |
There was a problem hiding this comment.
Preserve null peak hour instead of defaulting to 00:00
When the backend returns an empty cadence day (peakHour: null), this fallback sets peakHourIndex to 0, so TodayCadence highlights midnight as the peak bar even though peakAction says no peak. This creates contradictory and misleading UI on no-activity days. Keep the "no peak" state through to rendering (e.g., nullable/sentinel peak index) so no bar is emphasized when there is no peak hour.
Useful? React with 👍 / 👎.
Summary
todayApi.tsHTTP client module for cadence, streak, seal, and tomorrow-note endpointsuseTodayDossiercomposable to real APIs with graceful stub fallback on failuresealDay()toPOST /api/today/seal(async, idempotent)saveLineForTomorrow()with debounced autosave toPUT /api/today/tomorrow-noteGET /api/today/tomorrow-noteTest plan
Refs #996
Closes #1004