Add detailed logging to updateTask and syncToServer

This commit is contained in:
OpenClaw Bot 2026-02-19 21:01:11 -06:00
parent 6ef31132b6
commit 30d8d7022b
2 changed files with 13 additions and 2 deletions

View File

@ -456,7 +456,7 @@
"updatedAt": "2026-02-20T01:52:57.259Z"
}
],
"lastUpdated": 1771555515806,
"lastUpdated": 1771556223745,
"sprints": [
{
"name": "Sprint 1",

View File

@ -377,12 +377,20 @@ const defaultTasks: Task[] = [
// Helper to sync to server
async function syncToServer(projects: Project[], tasks: Task[], sprints: Sprint[]) {
console.log('syncToServer: saving', tasks.length, 'tasks')
const t2 = tasks.find(t => t.id === '2')
if (t2) console.log('syncToServer: task 2 sprintId:', t2.sprintId)
try {
await fetch('/api/tasks', {
const res = await fetch('/api/tasks', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ projects, tasks, sprints }),
})
if (res.ok) {
console.log('syncToServer: saved successfully')
} else {
console.error('syncToServer: failed with status', res.status)
}
} catch (error) {
console.error('Failed to sync to server:', error)
}
@ -489,10 +497,13 @@ export const useTaskStore = create<TaskStore>()(
},
updateTask: (id, updates) => {
console.log('updateTask called:', id, updates)
set((state) => {
const newTasks = state.tasks.map((t) =>
t.id === id ? { ...t, ...updates, updatedAt: new Date().toISOString() } : t
)
const updatedTask = newTasks.find(t => t.id === id)
console.log('updateTask: updated task:', updatedTask)
syncToServer(state.projects, newTasks, state.sprints)
return { tasks: newTasks }
})