Skip to content

fix: prevent duplicate tasks from :TwAdd - #8

Merged
MattHandzel merged 1 commit into
mainfrom
agent/fix-twadd-duplicate
Jul 21, 2026
Merged

fix: prevent duplicate tasks from :TwAdd#8
MattHandzel merged 1 commit into
mainfrom
agent/fix-twadd-duplicate

Conversation

@MattHandzel

Copy link
Copy Markdown
Owner

Summary

  • request UUID-oriented output from task add with rc.verbose=new-uuid
  • distinguish Taskwarrior command success from UUID extraction success
  • never retry a parsed add merely because its successful output lacks a UUID
  • retain the raw fallback only when capture parsing itself cannot run
  • add an end-to-end regression that drives the real :TwAdd command and <CR> callback

Root cause

Taskwarrior normally reports a numeric working-set ID (Created task 1.), while tw_add only recognized permanent UUIDs. The first task add succeeded, but UUID extraction returned an empty string. Capture treated that as a failed mutation and ran a second raw task add, creating a duplicate.

The fix makes normal output deterministic using Taskwarrior's automation-oriented new-uuid verbosity token. It also treats mutation success and output parsing as separate facts: if the command succeeds but no UUID can be extracted, capture warns and does not retry.

User impact

:TwAdd creates one task across default and quiet Taskwarrior verbosity settings. Parsed fields such as due: and project: remain attached to that single task. Ambiguous successful output no longer causes either a duplicate or a false "add failed" message.

Validation

  • ./tests/e2e/run.sh capture_relative_dates_spec.lua — 5 passed
  • ./tests/lua/bootstrap.sh — all Lua tests passed
  • tests were run from a detached worktree containing only commit 4223246

Fixes #7

@MattHandzel
MattHandzel merged commit d63edfc into main Jul 21, 2026
4 checks passed
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.

Feedback: TwAdd adds task twice

1 participant