fix(staged): sort timeline items by completion time so queued items appear before completed ones - #568
Conversation
There was a problem hiding this comment.
💡 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", |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 👍 / 👎.
826dbd7 to
3fcb6d1
Compare
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.
37dc5d7 to
d834f02
Compare
…ktree-dis * origin/main: (45 commits) feat(penpal): persist recent files activity across restarts (#595) feat: persist open windows, tabs, and geometry across app restarts (#588) feat(staged): generate next prefill text when generating notes (#594) feat(staged): add "Run again" button to action output dialog (#593) feat: queue repo sessions in project MCP with async cancellation fix (#591) fix(staged): lowercase "building" subtitle for consistency (#592) fix(staged): use completedAt for commit prefill timeline ranking (#590) fix: add per-branch mutex to prevent worktree setup race condition (#589) feat: add diff commit session launcher (#585) fix: avoid error state for empty titled code reviews (#587) fix: cancel in-flight auto reviews before manual sessions (#584) feat(settings): add repo context search (#583) fix(staged): sort timeline items by completion time so queued items appear before completed ones (#568) fix: drain queued branch sessions from backend lifecycle (#579) fix: restore resume session metadata for resumed actions (#580) feat(staged): add purple diff comment theme (#578) fix(ui): hide branch actions during setup (#572) fix: validate parsed PR URLs before extraction (#577) fix: centralize staged relative time updates (#576) fix: avoid UI freezes when starting background sessions (#575) ... # Conflicts: # apps/penpal/internal/watcher/watcher.go
Summary
completed_atcolumn to commits, notes, and reviews tables to track when AI sessions finish producing itemscompleted_at(falling back tocreatedAt) for timeline sorting so that items still being generated (queued/in-progress) naturally sort before completed items instead of appearing interleaved based on creation timeupdated_atas the best approximationTest plan
completed_atcorrectly🤖 Generated with Claude Code