Skip to content

tw_caldav_sync: stop re-updating changed tasks on every run - #173

Open
gherardovarando wants to merge 1 commit into
bergercookie:masterfrom
gherardovarando:fix/tw-caldav-stable-updates
Open

gherardovarando wants to merge 1 commit into
bergercookie:masterfrom
gherardovarando:fix/tw-caldav-stable-updates

Conversation

@gherardovarando

Copy link
Copy Markdown

Problem

With tw_caldav_sync, a task that is changed on either side after the first sync never compares equal to its counterpart again. Every following run updates it, alternating sides (Items updated: 1 on Caldav, then on Taskwarrior, and so on). With a Taskwarrior data folder kept in git, that's a commit on every run.

Two causes, found with -vvv (Key [...] exists in one but not in other):

  1. x-syncall-tw-waiting is always set by convert_tw_to_caldav, but CaldavSide.update_item drops it (it pops the comparison keys and doesn't write this one back), and map_ics_to_item never reads it.
  2. TaskWarriorSide.items_are_identical compares scheduled (and the duration UDA), which CalDAV doesn't carry, so a task with a scheduled date always differs from what comes back.

Fix

  • write the waiting flag in update_item and read it in map_ics_to_item;
  • compare scheduled / duration only when both items have them.

Regression tests in tests/test_tw_caldav_stable_sync.py (they fail without the fix); tests/test_tw_caldav_conversions.py still passes. Tested against a SOGo server: after one settling run, repeated runs report no changes.

The priority problems (#151) are separate; there are already PRs for them (#133, #156, #171).

🤖 Generated with Claude Code

https://claude.ai/code/session_01V8Y9HQ5ahrGXsJGEoTmaou

Once a task was changed after the first sync, it never compared equal to its
counterpart again, so every run updated it, alternating between Taskwarrior and
CalDAV:

- the x-syncall-tw-waiting flag that convert_tw_to_caldav always sets was
  dropped by CaldavSide.update_item and never read back by map_ics_to_item;
- Taskwarrior's "scheduled" (and the duration UDA) were compared although
  CalDAV doesn't carry them.

Read and write the waiting flag, and compare scheduled/duration only when both
items have them. Adds regression tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8Y9HQ5ahrGXsJGEoTmaou
@shymega

shymega commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Please, use the PR description template. Your agent has overwritten it. Without that compliance, we cannot merge.

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