Skip to content

Fix closed_at timestamp on approve and close#55

Merged
marcus merged 1 commit intomarcus:mainfrom
alpjor:fix/closed-at-timestamp
Mar 9, 2026
Merged

Fix closed_at timestamp on approve and close#55
marcus merged 1 commit intomarcus:mainfrom
alpjor:fix/closed-at-timestamp

Conversation

@alpjor
Copy link
Contributor

@alpjor alpjor commented Mar 3, 2026

Summary

  • approveCmd and closeCmd both set ClosedAt to issue.UpdatedAt (the stale value from before the current transaction) instead of the current time
  • This causes closed_at to reflect when the issue was last modified, not when it was actually closed
  • Fix: use time.Now() instead of issue.UpdatedAt in both commands

Context

Discovered this when building a time-series dashboard that tracks tasks closed per hour. The closed_at timestamps were always backdated to previous updated_at values, so tasks approved today would appear as if they were closed days ago.

The spec in docs/td-serve-spec.md already documents the correct behavior:

POST /v1/issues/{id}/approveclosed_at = now

And docs/ticket-flow.mmd:

Set closed_at timestamp

The CLI implementation just wasn't matching the spec.

Test plan

  • All existing tests pass (go test ./... — all green including e2e)
  • Manual: td approve an issue → verify closed_at matches current time, not old updated_at

🤖 Generated with Claude Code

Both `approveCmd` and `closeCmd` set `ClosedAt` to `issue.UpdatedAt`
(the stale value from before the current transaction) instead of the
current time. This causes `closed_at` to reflect when the issue was
last modified, not when it was actually closed.

This breaks any tooling that queries closed_at to determine when
an issue was resolved (e.g., time-series dashboards, reporting).

Fix: use `time.Now()` instead of `issue.UpdatedAt`.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@marcus
Copy link
Owner

marcus commented Mar 3, 2026

Hey @alpjor! Starling here (AI assistant on the project). 👋

Nice catch — and the fix is clean. Using issue.UpdatedAt for closed_at is exactly the kind of subtle bug that's easy to miss in review but causes real downstream pain (as you found with your dashboard). The spec cross-references you included make this easy to verify.

Flagging @marcus for a look and merge. The change is minimal (+3/-2 in cmd/review.go) and the spec already documents the correct behavior, so this should be a quick one. ✦

@alpjor
Copy link
Contributor Author

alpjor commented Mar 9, 2026

@marcus Any feedback?

Copy link
Owner

@marcus marcus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great — clean fix, matches the spec. Thanks for catching this! 🙏

@marcus marcus merged commit 7902b29 into marcus:main Mar 9, 2026
@marcus
Copy link
Owner

marcus commented Mar 9, 2026

Hey @alpjor — the fix landed! 🎉 Your closed_at correction is exactly right: spec said now, implementation was using the stale UpdatedAt, and you caught it with real data (time-series dashboards don't lie). Clean PR, clear rationale, well-tested. Thanks for seeing it through. ✦

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.

2 participants