Skip to content

fix: Reduce DB calls when saving archived day edits#131

Merged
AdamJ merged 2 commits into
mainfrom
claude/analyze-archive-autosave-KqC3k
May 15, 2026
Merged

fix: Reduce DB calls when saving archived day edits#131
AdamJ merged 2 commits into
mainfrom
claude/analyze-archive-autosave-KqC3k

Conversation

@AdamJ
Copy link
Copy Markdown
Owner

@AdamJ AdamJ commented May 15, 2026

Summary

Minimize the amount of calls to the database during archiving and editing of archived tasks. Simplifies three calls down to one.

Type of Change

  • New feature
  • Update to existing feature
  • Bug fix
  • Documentation update
  • Other (describe below)

Related Issue

Closes #

Changes Made

  • ArchiveEditDialog.tsx: Only include tasks in the update payload when tasks actually changed or the date changed (date shift re-stamps all task times). Currently it always passes tasks, triggering a SELECT + UPSERT even for notes-only edits.
  • TimeTrackingContext.tsx: On error, roll back just the one day using the pre-update snapshot instead of re-fetching all archived days from the DB
  • handleSaveDay now checks two conditions before including tasks in the update:
    • tasksContentChanged — user explicitly edited, deleted, or added a task
    • dateChanged — the date was moved (which re-stamps every task’s startTime/endTime)

Checklist

Complete all items that apply to your change. Check N/A for items that don't apply.

Documentation

Run sync-docs skill with Claude Code to automatically update relevant files.

  • Any notable changes added to the README.md
  • CHANGELOG.md updated accordingly
  • N/A — no README changes

General

  • Branch is up to date with main
  • No unrelated files included in this PR
  • Tested locally by invoking the npm run test, npm run lint, and npm run build

Notes for Reviewers

claude added 2 commits May 15, 2026 12:41
The save button in ArchiveEditDialog now mirrors the behaviour of
TaskEditDialog: it is disabled and reads "No Changes" when the form
is clean, switches to "Save Changes" when any field or task has been
modified, and shows a spinner ("Saving...") while the async persist
is in flight.

https://claude.ai/code/session_016b7TfPXSNPU8Jz7qyYMvRu
Two targeted improvements:

1. ArchiveEditDialog: only include tasks in the update payload when
   tasks were explicitly edited or the date changed (a date shift
   re-stamps all task timestamps). Previously tasks were always sent,
   causing an unnecessary SELECT + UPSERT even for notes-only edits.

2. TimeTrackingContext: on updateArchivedDay error, roll back only the
   affected day using its pre-update snapshot rather than re-fetching
   the entire archived-days collection from the database.

https://claude.ai/code/session_016b7TfPXSNPU8Jz7qyYMvRu
@AdamJ AdamJ changed the title Fix: Reduce DB calls when saving archived day edits fix: Reduce DB calls when saving archived day edits May 15, 2026
@AdamJ AdamJ merged commit 4d56f50 into main May 15, 2026
1 check passed
@AdamJ AdamJ deleted the claude/analyze-archive-autosave-KqC3k branch May 15, 2026 13:39
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