Skip to content

Fix done status not persisting after reload - #42

Merged
sandervonk merged 1 commit into
mainfrom
cursor/fix-done-persist-e4b6
Sep 15, 2026
Merged

sandervonk merged 1 commit into
mainfrom
cursor/fix-done-persist-e4b6

Conversation

@sandervonk

Copy link
Copy Markdown
Member

Summary

Marking a task done in the Vue Portal updated the UI immediately but did not survive a full reload. Root cause was on the Vue client (with API contract notes below).

Cause

  1. Silent local stub on failed writes — patchMeTask treated 404 / 405 / 501 as success and returned an in-memory stub. set_finished then applied that stub to task_states and showed a success toast. Nothing was written server-side, so reload cleared done.
  2. Fragile path encoding — completion called PATCH /api/v1/me/tasks/:taskId with URL-encoded slash paths (classId%2FtaskId). Live API / Brief docs prefer board tilde refs (classId~taskId). Encoded / is brittle on single-segment Express routes behind Firebase Hosting; Brief batch done works because it sends tilde ids in the JSON body, not as path segments with %2F.
  3. Read-path lag — after a real write, the user-doc finished[] snapshot updated account_doc but did not merge into task_states (which is_task_completed prefers).

Fix (Vue only)

  • Encode /me/tasks/:taskId with tilde refs (classId~taskId); never put %2F in the path segment.
  • Prefer POST .../done / .../undo (and batch POST /api/v1/me/tasks/done|undo for multi-select) for completion — same contract Brief uses.
  • Never stub completed mutations; surface errors via the existing ErrorToast.
  • Parse done/undo envelopes that return id + numeric completed_at.
  • Sync users.finished[] into task_states on snapshot (including undo clears).
  • Same tilde encoding for workspace task-path URLs (path param only; no Drive/workspace chrome changes).

Tests

  • npm run test:me-tasks — board state merge
  • npm run test:paths — tilde encoding / normalize helpers (asserts no %2F)

Follow-up on mvtt-server (no PR there from this change)

  • Confirm production has deployed hybrid PATCH /api/v1/me/tasks/:taskId + task_state (functions/api/routes/workspace.ts / services/taskState.ts). README still documents done/undo more prominently than PATCH.
  • Optional hardening: reject or redirect slash/%2F path params more clearly, or document that clients must use tilde refs for :taskId (Brief already does).
  • Optional: ensure GET /api/v1/me/board tasks[].completed / finished[] stay aligned with hybrid hot maps after undo (Vue now dual-reads both).

No Drive OAuth, nested delete, or unrelated workspace UI changes.

Open in Web Open in Cursor 

Root cause: patchMeTask encoded task paths as classId%2FtaskId and on
404/405/501 silently stubbed success in memory, so the UI showed done
without a server write. Prefer tilde refs (classId~taskId) matching Brief,
POST done/undo first for completion, never stub completed writes, and sync
finished[] from the user doc into task_states.

Co-authored-by: Sander Vonk <sandervonk@users.noreply.github.com>
@sandervonk
sandervonk marked this pull request as ready for review September 15, 2026 22:30
@sandervonk
sandervonk merged commit 824304a into main Sep 15, 2026
1 check passed
@sandervonk
sandervonk deleted the cursor/fix-done-persist-e4b6 branch September 15, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants