fix(staged): hide rebased-away reviews from session branch history#780
Conversation
The branch card timeline hides a code review once its originating commit is no longer on the branch (rebased/squashed away) unless it carries a user comment, but `review_timeline_entries` — which builds the branch history injected into a new session's context — applied no such filter. Reviews the user could not see in the UI were still rendered into the agent prompt. Apply the same commit-SHA visibility rule in the session path: - Extract the visibility predicate into a shared `timeline::review_is_visible_in_timeline`, generic over the SHA lookup, so the card and the session context can't drift apart. - Add `parse_commit_shas`, which recovers the `commit %H` SHAs from the timestamped git log already fetched for the timeline, and thread the resulting `visible_shas` set through `build_branch_context`, `build_remote_branch_context`, and `build_branch_timeline_summary` into `review_timeline_entries`. - Skip reviews that fail the visibility predicate before emitting them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c1e79ab91
ℹ️ 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".
| &branch.id, | ||
| workspace_name, | ||
| max_commit_ts, | ||
| &visible_shas, |
There was a problem hiding this comment.
Preserve reviews when no commit list is loaded
In project-level session context, build_branch_timeline_summary only populates visible_shas from a local worktree, so remote branches (or branches without a local checkout / with a git-log error) keep this set empty. Passing that empty set into review_timeline_entries now makes review_is_visible_in_timeline drop every review with a non-empty commit_sha and no user-authored comment, even when the commit is still on the branch; as a result project-level agents lose ordinary review history for those branches. Please either fetch the remote/current commit SHAs here too, or skip this visibility filter when no commit list was successfully loaded.
Useful? React with 👍 / 👎.
Summary
The branch card timeline already hides code reviews whose originating commit is no longer on the branch (e.g. rebased or squashed away), unless a user has commented on them. The session-context branch history did not apply this filter, so the agent could see reviews that the user can't see in the UI.
This change shares the visibility rule between both surfaces so they can't drift apart:
review_is_visible_in_timelineintimeline.rsinto a shared,pub(crate)helper that takes asha_is_visibleclosure instead of a borrowedHashSet<&str>.parse_commit_shasinsession_commands.rsto extract the set of commit SHAs from the timestamped git log, mirroring the visible-SHA set the branch card builds from its commit list.build_branch_context,build_remote_branch_context, andbuild_branch_timeline_summaryintoreview_timeline_entries, which now skips reviews whose commit has left the branch.Tests
Adds unit coverage for the new behavior:
parse_commit_shasextracts full SHAs from the log format