Skip to content

PAPER-08: Wire Today dossier to real backend APIs#1056

Open
Chris0Jeky wants to merge 13 commits into
mainfrom
paper/1004-today-dossier-api-wiring
Open

PAPER-08: Wire Today dossier to real backend APIs#1056
Chris0Jeky wants to merge 13 commits into
mainfrom
paper/1004-today-dossier-api-wiring

Conversation

@Chris0Jeky
Copy link
Copy Markdown
Owner

Summary

  • Create todayApi.ts HTTP client module for cadence, streak, seal, and tomorrow-note endpoints
  • Wire useTodayDossier composable to real APIs with graceful stub fallback on failure
  • Wire sealDay() to POST /api/today/seal (async, idempotent)
  • Add saveLineForTomorrow() with debounced autosave to PUT /api/today/tomorrow-note
  • Load initial tomorrow-note text from GET /api/today/tomorrow-note

Test plan

  • todayApi module tests with mocked HTTP (6 tests covering all endpoints)
  • useTodayDossier composable tests with live and fallback paths (8 tests)
  • Existing TodayCover and PaperTodayView tests updated and passing
  • npm run typecheck clean
  • npm run lint clean (0 errors)
  • npx vitest --run passing (264 files, 3185 tests)

Refs #996
Closes #1004

Chris0Jeky added 6 commits May 9, 2026 11:03
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
Copilot AI review requested due to automatic review settings May 9, 2026 10:04
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts
Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts
Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts
Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts Outdated
Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts Outdated
Comment thread frontend/taskdeck-web/src/views/paper/PaperTodayView.vue
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts Outdated
Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts Outdated
@Chris0Jeky
Copy link
Copy Markdown
Owner Author

Adversarial Code Review

CRITICAL

  • None

HIGH

  1. Race condition in fetchLiveData: The watch with immediate: true fires fetchLiveData() without awaiting. If now changes rapidly (e.g., day-rollover edge), two concurrent fetches can race and a stale response can overwrite fresh data. Fix: add a generation counter and discard results from superseded fetches.
  2. sealDay catch sets sealed = true on network error: On API failure, the catch block sets sealed.value = true and returns { sealed: true, alreadySealed: false }, preventing the user from retrying the seal. Fix: return { sealed: false, alreadySealed: false } on error so the user can retry.

MEDIUM

  1. Pending autosave lost on scope dispose: onScopeDispose clears the autosave timer but does not flush the pending write. If the user types and the component unmounts within 800ms, the note is silently lost. Fix: flush the pending save before clearing the timer.
  2. saveLineForTomorrow not wired to TodayLineForTomorrow component: The composable exposes saveLineForTomorrow() but PaperTodayView.vue does not connect it to the TodayLineForTomorrow component's @save event. This is a known gap -- the component still saves to localStorage. Wiring this requires component prop/event changes beyond the scope of this PR (tracked separately).

LOW

  1. validateStatus in getTomorrowNote too narrow: status === 200 || status === 204 silently accepts only those two codes but rejects all others (including valid 2xx). A 201 or similar would be rejected without hitting the error interceptor. Fix: widen to (status >= 200 && status < 300) || status === 204.
  2. JSDoc comments removed: Several useful interface/function doc comments were stripped. The task says "don't add comments explaining what the code does" but removing existing documentation degrades maintainability. Not fixing in this pass to respect task instructions.

Bot Comments Addressed

  • None (no bot comments found)

Summary

0 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.

Chris0Jeky added 2 commits May 9, 2026 11:10
- 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.
@Chris0Jeky
Copy link
Copy Markdown
Owner Author

Adversarial Review -- Fixes Applied

Finding Severity Fix Commit Verified
Race condition in fetchLiveData (stale response overwrites) HIGH 0bd4ba0b tests pass (3185/3185)
sealDay catch falsely sets sealed=true on error HIGH 0bd4ba0b tests pass
Pending autosave lost on scope dispose MEDIUM 0bd4ba0b tests pass
validateStatus too narrow in getTomorrowNote LOW df6917fe tests pass
saveLineForTomorrow not wired to component MEDIUM deferred tracked separately -- requires component prop/event changes
JSDoc comments removed LOW skipped per task instructions

All fixable findings addressed. CI status: PENDING (required checks running).

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts Outdated
Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts Outdated
…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)
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread frontend/taskdeck-web/src/views/paper/PaperTodayView.vue
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Chris0Jeky added 2 commits May 9, 2026 11:46
When sealDay returns sealed:false (API failure or in-flight guard),
show an error toast instead of the misleading success message.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts
Comment thread frontend/taskdeck-web/src/views/paper/PaperTodayView.vue
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread frontend/taskdeck-web/src/composables/useTodayDossier.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending

Development

Successfully merging this pull request may close these issues.

PAPER-08 · Today / End-of-day dossier in Paper

2 participants