Skip to content

fix(staged): hide rebased-away reviews from session branch history#780

Merged
matt2e merged 1 commit into
mainfrom
hidden-code-reviews-in-branch-history
Jun 10, 2026
Merged

fix(staged): hide rebased-away reviews from session branch history#780
matt2e merged 1 commit into
mainfrom
hidden-code-reviews-in-branch-history

Conversation

@matt2e

@matt2e matt2e commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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:

  • Extract review_is_visible_in_timeline in timeline.rs into a shared, pub(crate) helper that takes a sha_is_visible closure instead of a borrowed HashSet<&str>.
  • Add parse_commit_shas in session_commands.rs to extract the set of commit SHAs from the timestamped git log, mirroring the visible-SHA set the branch card builds from its commit list.
  • Thread those visible SHAs through build_branch_context, build_remote_branch_context, and build_branch_timeline_summary into review_timeline_entries, which now skips reviews whose commit has left the branch.

Tests

Adds unit coverage for the new behavior:

  • review hidden when its commit left the branch
  • review kept when its commit is still present
  • review kept (commit gone) when a user comment keeps it alive
  • parse_commit_shas extracts full SHAs from the log format

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>
@matt2e matt2e requested review from baxen and wesbillman as code owners June 10, 2026 07:39

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

Copy link
Copy Markdown

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: 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,

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 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 👍 / 👎.

@matt2e matt2e merged commit 594897c into main Jun 10, 2026
5 checks passed
@matt2e matt2e deleted the hidden-code-reviews-in-branch-history branch June 10, 2026 07:56
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