Skip to content

fix(repeating): treat to-dos inside a repeating project template as repeating - #340

Merged
ryanlewis merged 1 commit into
mainfrom
fix/repeating-template
Oct 3, 2026
Merged

ryanlewis merged 1 commit into
mainfrom
fix/repeating-template

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

Closes #174

The second half of #174, the note on an empty --project listing for a repeating project template, already shipped in #272. This PR does the first half: to-dos inside a repeating project template now count as repeating, so the writes Things drops silently on them are refused before anything is sent.

Row layout

I could not observe a real one. None of the ten daily backups on this machine (2026-09-24 to 2026-10-03) holds a row with rt1_recurrenceRule or rt1_repeatingTemplate, and an earlier check of the 2026-09-01 to 2026-09-10 backups found repeating to-dos only, no repeating project (see the issue comments). So the change rests on the layout the code already assumes since #171: a to-do inside a template project links to it through project, or through heading and the heading's project, and carries no rule of its own, so only the project row has rt1_recurrenceRule. The project Things generates from the template points back at it through rt1_repeatingTemplate and has no rule.

The check is conservative either way. A to-do counts as repeating if it has a rule itself or if its resolved parent project has one. If template children turn out to carry their own rule, nothing changes. To-dos inside a generated instance project are not flagged, because their parent has a template pointer, not a rule, and instances can be edited.

What changed

  • The task query's repeating flag now reads t.rt1_recurrenceRule OR p.rt1_recurrenceRule, where p is the parent project already resolved through COALESCE(t.project, h.project). The column is still probed, as before. On a schema without it, both references become NULL and nothing repeats.
  • Visible effects for a to-do inside a template project:
    • edit --when/--deadline/--complete/--cancel/--duplicate, complete, cancel and import updates are refused with the existing "is a repeating task" message. Before, they went out and Things dropped them.
    • show and --json mark it "repeating": true (it is only listed in trash and logbook, and show reaches it by uuid). The agent brief leaves out complete/cancel, as it does for other repeating items.
    • Exact-title lookup now prefers the ordinary to-do when one has the same title. things edit "Clear desk" goes to the ordinary to-do instead of showing the ambiguity list. This is the same rule preferInstances already applies to repeating to-do templates.
  • SKILL.md, commands.md and agents.md say that to-dos inside a template project count as repeating.

Tests

  • TestTemplateProjectChildrenReportRepeating (internal/db): a child directly in a template project and one under a heading in it are flagged. A child of a generated instance project (rt1_repeatingTemplate set, no rule) and one in an ordinary project are not.
  • TestRepeatingWritesAreRefusedUpFront (cmd/things): new cases for complete, edit --when and edit --deadline on a template child. They check the command is refused and no write is issued.
  • Both failed on the unfixed code. The list-query golden file is regenerated, and the only difference is the one select-list line.
  • make test and make lint pass.
  • Built binary against a copy of the 2026-10-03 backup, with synthetic template, instance and child rows added to the copy and open/osascript stubbed on PATH. The old binary sent the when and completed writes, which the stubs caught. The fixed binary refuses both before sending anything. show --json gives repeating: true for the template child and leaves it off for the instance child.

Not verified against the live app; no repeating project exists.

…epeating

A to-do inside a repeating project template carries no recurrence rule of
its own, so Task.Repeating was false and edit --when/--deadline, complete,
cancel and import updates on it were sent to Things, which drops them
silently. The flag now also reads the resolved parent project's rule, so
those writes are refused up front like they are on the template. To-dos
inside a project Things generated from the template stay ordinary.

Refs #174
@ryanlewis
ryanlewis merged commit e04b7c2 into main Oct 3, 2026
10 checks passed
@ryanlewis
ryanlewis deleted the fix/repeating-template branch October 3, 2026 20:50
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.

bug: to-dos inside a repeating project template are not treated as repeating for writes or filters

1 participant