Skip to content

fix(staged): sort timeline items by completion time so queued items appear before completed ones#568

Merged
matt2e merged 2 commits intomainfrom
queued-items-appear-before-others
Apr 2, 2026
Merged

fix(staged): sort timeline items by completion time so queued items appear before completed ones#568
matt2e merged 2 commits intomainfrom
queued-items-appear-before-others

Conversation

@matt2e
Copy link
Copy Markdown
Contributor

@matt2e matt2e commented Apr 1, 2026

Summary

  • Adds a completed_at column to commits, notes, and reviews tables to track when AI sessions finish producing items
  • Uses completed_at (falling back to createdAt) for timeline sorting so that items still being generated (queued/in-progress) naturally sort before completed items instead of appearing interleaved based on creation time
  • Includes a database migration (0007) that backfills existing rows with updated_at as the best approximation

Test plan

  • Verify queued items appear at the top of the timeline before completed items
  • Verify completed items sort by their completion time, not creation time
  • Verify the database migration runs cleanly on existing data
  • Verify notes and reviews created via the UI still populate completed_at correctly

🤖 Generated with Claude Code

@matt2e matt2e requested review from baxen and wesbillman as code owners April 1, 2026 03:50
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54be5523fc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

conn.execute(
"UPDATE reviews SET commit_sha = ?1, updated_at = ?2 WHERE id = ?3",
params![commit_sha, now_timestamp(), id],
"UPDATE reviews SET commit_sha = ?1, updated_at = ?2, completed_at = COALESCE(completed_at, ?3) WHERE id = ?4",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid marking reviews completed in update_review_commit_sha

drain_queued_sessions always calls update_review_commit_sha before the queued review session starts (see session_commands.rs), but this update now also sets completed_at via COALESCE. That marks queued reviews as completed at drain/start time, and later completion cannot fix the timestamp because COALESCE preserves the earlier value, so timeline ordering by completedAt will be wrong for queued reviews.

Useful? React with 👍 / 👎.

UPDATE notes SET completed_at = updated_at WHERE content != '';

ALTER TABLE reviews ADD COLUMN completed_at INTEGER;
UPDATE reviews SET completed_at = updated_at WHERE title IS NOT NULL;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Backfill completed_at for reviews without titles

The migration only backfills reviews.completed_at when title IS NOT NULL, but completed reviews can legitimately have no title (the review parser can fail title extraction while still saving comments), so those rows remain NULL after upgrade and will keep sorting by createdAt instead of completion time. This leaves part of existing data in the old incorrect ordering behavior.

Useful? React with 👍 / 👎.

@matt2e matt2e force-pushed the queued-items-appear-before-others branch from 826dbd7 to 3fcb6d1 Compare April 2, 2026 02:59
matt2e added 2 commits April 2, 2026 16:47
Add write-once completion timestamps for notes, reviews, and project notes so timeline ordering reflects when items actually finished instead of when they were queued or later touched.

Also align displayed times with completion sorting, restamp adopted auto reviews when they become visible, and cover the new behavior with migration and store tests.
@matt2e matt2e force-pushed the queued-items-appear-before-others branch from 37dc5d7 to d834f02 Compare April 2, 2026 05:53
@matt2e matt2e merged commit 0934904 into main Apr 2, 2026
4 checks passed
@matt2e matt2e deleted the queued-items-appear-before-others branch April 2, 2026 06:01
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