Skip to content

feat(add): read back the created item and print it as show does - #332

Merged
ryanlewis merged 2 commits into
mainfrom
feat/add-readback
Oct 3, 2026
Merged

ryanlewis merged 2 commits into
mainfrom
feat/add-readback

Conversation

@ryanlewis

@ryanlewis ryanlewis commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

edit and project edit confirm their write and print the item, but add and project add printed nothing. Now they find the item they created and print it the way things show does. This is a follow-up to #280.

Visible change

things add and things project add now print to stdout. Before, they printed nothing.

  • On success they print the new item exactly as things show <uuid> does, in plain text and under --json.
  • If the item never shows up within the read-back wait (5s by default, --verify-timeout), they exit non-zero with add not confirmed: … and tell you to run things search before retrying.
  • --no-verify (or no_verify = true) skips the read-back. It prints Sent to Things, not confirmed (--no-verify): "<title>", or under --json it prints {"title", "confirmed": false, "reason": "no-verify"}.

How the item is found

things:///add returns no UUID, so the CLI looks for the item.

  1. Before the write, it notes the time minus 1s and the items already created since then.
  2. After the write, it polls TasksCreatedSince for an item of the right type with the same title (whitespace trimmed) that was not there before.
  3. Trashed rows don't count. Neither do repeating templates or the instances Things generates from them (rt1_repeatingTemplate, probed like the recurrence column).

What happens in each case:

  • One match: printed through printItem, like things show.
  • More than one match visible together when the read-back settles (the same title added elsewhere at the same moment): the CLI does not guess. After the first round that finds a match it polls two more rounds, so an item saved a moment later still counts. It exits 0 with an unconfirmed line listing the candidate UUIDs. Under --json the reason is ambiguous and candidates lists the UUIDs.
  • Database can't be read, before the write or for the whole read-back: the add is still sent. The CLI prints a warning and an unconfirmed line with reason unreadable, and exits 0.

Out of scope

  • import, which already reads back its status changes.
  • A warning when --list or --heading didn't resolve.

Docs

  • commands.md (Capturing, and the verify-timeout paragraph)
  • agents.md
  • configuration.md (the no_verify row and the agent notes)
  • SKILL.md
  • the --no-verify flag help

Tests

New cmd/things/add_test.go:

  • confirmed add and project add print the same output as show, plain and --json
  • an item with the same title created inside the window but before the write is skipped
  • not found fails with the search hint: dropped add, other title, other type, repeating template, generated instance
  • two candidates give the ambiguous output
  • --no-verify and an unreadable database give the unconfirmed output, with no uuid

The template and instance cases fail when their filters are removed. Existing tag tests that call add and aren't about the read-back now pass --no-verify.

make test and make lint pass.

Not verified:

  • Against the real Things app. All tests use dbtest fixtures and a mocked exec.
  • How Things stores titles that contain a newline or other characters it may rewrite. Only surrounding whitespace is normalised.

things:///add returns no uuid, so add and project add now find the item
they created (same type and title, created after the write started, not
there before it) and print it through printItem. A dropped add exits
non-zero and says to search before retrying. Two candidates, --no-verify,
or an unreadable database print an unconfirmed line and exit 0.
… errors

Poll two more rounds after the first match, so a same-titled item saved a
moment later is reported as ambiguous instead of missed. A read error that
lasts to the deadline now warns and prints the unconfirmed line (exit 0)
rather than failing. The not-found hint shell-quotes the title.

Also correct the docs that said write commands print nothing, and the
README's read-back lines.
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