Skip to content

Persist task markdown across devices in cross-device sync#22

Merged
super3 merged 1 commit into
mainfrom
claude/wizardly-bohr-XV0QD
May 21, 2026
Merged

Persist task markdown across devices in cross-device sync#22
super3 merged 1 commit into
mainfrom
claude/wizardly-bohr-XV0QD

Conversation

@super3
Copy link
Copy Markdown
Owner

@super3 super3 commented May 21, 2026

Summary

This PR fixes a cross-device sync regression where task markdown (todo lists) was not being persisted to the database or restored when signing in on a new device. Previously, tasks were hardcoded to empty strings when pulling chats from the server, causing the tasks panel to appear blank after cross-device sync.

Key Changes

  • Database schema: Added todo_markdown column to conversations table via migration to store task state alongside message history
  • Server persistence: Modified /api/chat endpoint to extract and persist task markdown from assistant responses, with fallback to client-supplied currentTasks when the response contains no tasks
  • Database layer: Updated saveConversation() to accept and persist todoMarkdown parameter; updated getConversation() and listConversationsByUser() to retrieve stored task markdown
  • Client-side sync:
    • When merging server conversations, adopt server-side todoMarkdown for new chats instead of defaulting to empty string
    • For existing chats, only overwrite local tasks when server has non-empty tasks (preserves in-progress local edits)
    • Refresh the visible chat's task view when server tasks change during cross-device sync
  • Test coverage: Added three new test cases covering fresh device sign-in, task updates on shared chats, and protection against clobbering local unsaved tasks

Implementation Details

The solution uses a "server is source of truth, but only when present" approach:

  • When syncing, server tasks only overwrite local tasks if non-empty (prevents losing local edits that haven't been chatted yet)
  • The saveConversation() function uses COALESCE() in the SQL upsert to preserve existing task markdown when a request doesn't include new tasks
  • Task extraction happens server-side from the assistant response, ensuring consistency across all devices

https://claude.ai/code/session_01CvAyUuVJ3eJLdHaUjXXoqx

The tasks panel was empty after signing in on a new device because the
conversations table only stored chat messages — the task markdown lived
only in localStorage. mergeServerConversations also hardcoded
todoMarkdown: '' for any chat pulled from the server, so even if the
column had existed, the new device wouldn't have read it.

Add a todo_markdown column (migration 003), pass it through
saveConversation / getConversation / listConversationsByUser, and
persist the post-turn task state on every /api/chat — either the freshly
extracted sections from the response or, when the response is task-free,
the currentTasks the client just sent. On the client, adopt the
server's tasks for chats arriving via mergeServerConversations and
refresh the visible chat's tasks panel when the server's copy changes.
Leave a non-empty local todoMarkdown alone when the server's copy is
empty, so in-progress local edits aren't wiped by the sync.
@railway-app railway-app Bot temporarily deployed to padtask / padtask-pr-22 May 21, 2026 16:18 Destroyed
@railway-app
Copy link
Copy Markdown

railway-app Bot commented May 21, 2026

🚅 Deployed to the padtask-pr-22 environment in padtask

Service Status Web Updated (UTC)
padtask ✅ Success (View Logs) Web May 21, 2026 at 4:19 pm

@super3 super3 merged commit 165f0e9 into main May 21, 2026
3 checks passed
@super3 super3 deleted the claude/wizardly-bohr-XV0QD branch May 21, 2026 16:20
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