Skip to content

fix(list): file closed items by the calendar day, not manualLogDate - #233

Merged
ryanlewis merged 1 commit into
mainfrom
fix/issue-230-logbook-today-boundary
Sep 10, 2026
Merged

ryanlewis merged 1 commit into
mainfrom
fix/issue-230-logbook-today-boundary

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

Closes #230

What changed

Things moves a closed item out of Today and into the Logbook when the day rolls over, or sooner if you run "Log Completed Now". The CLI keyed both views on TMSettings.manualLogDate alone, so an item ticked off today appeared in logbook while the app still had it under Today.

An item now stays under Today while it was closed on the current calendar day and its stop date is after manualLogDate. logbook is the complement.

This narrows today --include-completed — worth a release note. It used to return every item closed since manualLogDate, which on this data was 39 rows spread over four days. It now returns the items closed today that are still unlogged, which is 6.

Why the rule is a pair, not a swap

Measured against the app on 10 Sep 2026 by uuid, with manualLogDate five days old:

rows
app Today, closed items (all closed that day) 6
app Logbook, closed on the 3 previous days 40
of those 40, stop date after manualLogDate 40

So manualLogDate cannot be the boundary on its own, or those 40 would still be under Today. It stays as the second condition because it is what "Log Completed Now" sets: it files the day's closed items early instead of waiting for midnight, and dropping it would leave that command with no effect. Both conditions held for all 6 rows throughout, so they could only be told apart by closing something in the live app, which the measurement deliberately did not do.

The complement is taken over what Today holds, not over the day

/code-review --fix caught this and it is the substantive part of the change. Subtracting "closed today" from the Logbook unconditionally is wrong, because the today view only holds rows with start = 1, startBucket IN (0,1) and a start date. A to-do ticked off in the Inbox, in Anytime, or ahead of its date in Upcoming is never under Today, so withholding it from the Logbook on the day would leave it listed nowhere at all. The same argument covers a to-do whose parent project is trashed, which every view but trash and logbook drops.

The Logbook therefore withholds exactly heldByToday, and COALESCE(..., 0) = 0 keeps the negation null-safe over the nullable scheduling columns.

One residual: this data had no item closed today from outside Today, so the app's same-day handling of that case is reasoned from the view definitions rather than measured. The failure mode is bounded — such an item reaches logbook immediately rather than at midnight — and the alternative left it in no list at all.

How verified

By uuid against the app on live data:

check result
today --include-completed vs the app's Today 27 vs 27, no difference either way
logbook rows dropped exactly 6
those 6 vs the app's Today-closed rows identical
logbook rows added 0

Tests: the today filtering test now asserts both views at each phase, so the partition is what is checked rather than one side of it. TestTodayAndLogbookPartitionClosedItems asserts a closed item is in exactly one list across the day and manualLogDate grid. TestLogbookKeepsItemsClosedTodayOutsideToday and TestLogbookKeepsClosedTodayUnderTrashedProject cover the bug above; both fail against the first formulation, which I confirmed by reverting the clause.

Four fixtures closed items an hour ago, which the day rule now reads as today, and were moved to an earlier day. The today fixture closes at the current instant rather than a minute back so it cannot fall on the previous day near midnight.

make test and make lint are clean.

Docs

internal/skill/SKILL.md, docs/content/commands.md, docs/content/agents.md and the README describe the boundary and say that anything closed outside Today reaches logbook at once. The agent-facing text now says a day's closes need both lists, not just today --include-completed.

Things moves a closed item out of Today and into the Logbook when the day
rolls over, or sooner if you run "Log Completed Now". The CLI keyed both
views on manualLogDate alone, so an item ticked off today appeared in the
logbook while the app still had it under Today, and today --include-completed
went on showing items closed days ago.

Measured against the app on 10 Sep 2026 by uuid. manualLogDate was five days
old. The app's Today held six closed items, all closed that day; its Logbook
held forty items closed on the three previous days, every one of them with a
stopDate after manualLogDate. So manualLogDate cannot be the boundary on its
own, or those forty would still be under Today.

Both conditions now hold together: an item stays under Today while it was
closed on the current calendar day and its stopDate is after manualLogDate.
Keeping manualLogDate is what leaves "Log Completed Now" an effect.

The Logbook takes the complement over the set Today can actually hold, not
over the calendar day. A to-do ticked off in the Inbox, in Anytime, or ahead
of its date in Upcoming is never under Today, so the Logbook takes it the
moment it closes; subtracting the day alone would have left those rows listed
nowhere. The same argument covers a to-do whose parent project is trashed.
COALESCE keeps the negation null-safe over the nullable scheduling columns.

This narrows today --include-completed: it was every item closed since
manualLogDate, and is now the items closed today that are still unlogged.

After the change, today --include-completed returns 27 rows, uuid-identical
to the app's Today, and the logbook drops exactly the 6 rows the app keeps
under Today. No row moved in either direction beyond those.

Four fixtures closed items an hour ago, which the day rule reads as today;
they now close on an earlier day. The today fixture closes at the current
instant rather than a minute back, so it cannot fall on the previous day when
the suite runs near midnight.

Closes #230
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: logbook shows items closed today that the app still keeps under Today

1 participant