Skip to content

fix(add): warn when --list or --heading will not resolve, accept a uuid, read tags once - #343

Merged
ryanlewis merged 3 commits into
mainfrom
fix/tag-list-resolution
Oct 3, 2026
Merged

ryanlewis merged 3 commits into
mainfrom
fix/tag-list-resolution

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

Follow-ups from the reviews of #330 and #332: add now says when Things will file a to-do somewhere other than where you asked, a project or area UUID now works, and edit reads the tag list once.

What was wrong

  • An unknown --list, --project or --heading gave no warning. I added throwaway zz things-cli test to-dos to the real app to see what Things does. It matches list against open, untrashed projects and areas by title, ignoring case. If nothing matches, it puts the to-do in the Inbox and says nothing. That happens for an unknown name, a completed project and a trashed project. A heading that the project doesn't have is dropped, and the to-do goes into the project with no heading. A heading given without a list is ignored, and the to-do goes to the Inbox. Heading names also match ignoring case.
  • add --project <uuid> landed in the Inbox, even though the help says "Project name or UUID". Things matches list by title only. The today-due worker hit the same bug.
  • edit read the tag list twice. The unknown-tag check (verifyTags) and the no-op check (droppedTags, from fix(edit): treat tags Things does not have as no change in the no-op check #330) each called db.UnknownTags.

What changed

  • New db.AddTarget (internal/db/lists.go) resolves list and heading the way Things did in those tests. list matches an open, untrashed project or an area, by title ignoring case or by UUID. heading matches an untrashed heading of that project, ignoring case. If open projects differ only in case, the CLI checks the one whose title matches exactly. Which one Things picks is unknown.
  • add warns on stderr and still sends the write:
    • warning: Things has no open project or area called "Nowhere"; it will put the to-do in the Inbox
    • warning: "Tools" has no heading "Later"; Things will add the to-do there without a heading
    • warning: --heading "Later" needs --list or --project; Things will ignore it and put the to-do in the Inbox
      If the database can't be read, this check stays quiet. The tag check or the read-back already reports that.
  • When --list or --project is the UUID of an open project or area, add sends it as list-id (new AddParams.ListID). A title is still sent as list. I checked this against the real app: a project UUID, an area UUID, and a project UUID with --heading (both the exact name and a different case) all landed in the right place.
  • verifyTags now returns the names Things will drop. edit uses that list for its no-op check, and droppedTags is replaced by a small foldTags helper, so the tag list is read once.
  • docs/content/commands.md and internal/skill/SKILL.md describe the warnings and UUID support.

Not changed

Item 3 from the follow-up list (tags in add/edit output in a different order from show) is dropped. On the live database, all 132 items with more than one tag come back in the same order from show's query and from both read-back queries. The order comes from GROUP_CONCAT, which SQLite does not define, and all three queries share it.

Tests

Written first and shown failing on the unfixed code:

  • TestEditReadsTagListOnce wraps the SQLite connection to count queries against the tag list. It counted 2 reads before this change and counts 1 after.
  • TestAddWarnsOnUnresolvedListOrHeading checks no warning for a known project, area, project UUID, area UUID and heading, and a warning for an unknown list, a completed project, a completed project's UUID, an unknown heading, a heading under an area and a heading with no list. The write is sent in every case.
  • TestAddSendsUUIDAsListID checks that a UUID goes as list-id with no list beside it, and that a title goes as list. Both UUID cases fail with the fix turned off.
  • TestAddTarget and TestAddTargetPrefersExactCase cover the DB lookup.

make test and make lint pass. Two /code-review medium --fix passes ran. The first added the exact-case preference. The second found nothing.

Every throwaway to-do used in testing, and the one throwaway project, is in the Trash.

…gs once

- add warns on stderr when --list/--project names no open project or area
  (Things files the to-do in the Inbox) or --heading names no heading of
  that project (Things drops it). The add still goes ahead.
- verifyTags returns the names Things will drop, so edit's no-op check uses
  them instead of reading the tag list a second time.
Things matches list by title only, so add --project <uuid> landed in the
Inbox. A uuid of an open project or area now goes as list-id. AddTarget
also prefers an exact-case title when open projects differ only in case.
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.

1 participant