feat(agent): commit divider for stale reviews + commit-aware planning context - #216
Merged
Conversation
… advances When the PR's head commit moves past the commit the most recent agent run reviewed, the run timeline now shows a sawtooth "commit divider" at the bottom labelled with the new head's short SHA — signalling that the reviews above are based on stale code. It appears as soon as the code changes, whether or not a new run has been started against it, and is suppressed while a run is active (that run is already processing the current head). - Stamp the PR head SHA (pr.sourceRef.sha) onto each run at start (ReviewRun. headSha, threaded through StartReviewRunInput / startReviewRun / the executor) as the baseline to compare the live head against. Runs predating this field have no headSha and are not used as a baseline. - ChatPane derives staleHeadSha (live head vs the latest completed run's headSha) and renders a single CommitDivider below the run list. - CommitDivider is a masked-SVG zigzag rule flanking a commit-id chip (reusing the scope-badge chip vocabulary + CommitIcon); theme-aware via a token color. - i18n: chatPane.commitDividerTitle in all four locales. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The planning/orchestration agent replays the whole prior conversation into each turn, which can reference code from before a new commit landed. Give it soft awareness of that boundary without dropping any history: stamp the PR head SHA (pr.sourceRef.sha) onto each recorded conversation message, and in buildConversationContext interleave a "PR code updated to commit X" marker wherever the head differs between consecutive kept messages, plus a trailing marker when the current turn's head has advanced past the newest message. Mirrors the head SHA already stamped on runs (same pr.sourceRef.sha basis as the UI commit divider), so seeing the divider in the UI corresponds to the marker in the agent's context. Marker is an internal prompt artifact (English, no i18n) and, like the rest of the conversation history, is never passed through to pr-agent tools. Messages predating the field have no headSha and produce no marker. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the PR's code changes between agent interactions, the run history now signals that prior reviews are based on older code — both visually and in the agent's own context.
1. UI commit divider (
feat(chat))Each run is stamped with the PR head SHA it was executed against (
ReviewRun.headSha=pr.sourceRef.sha, threaded throughStartReviewRunInput/startReviewRun/ the run executor). When the current PR head has advanced past the commit the most recent completed run reviewed, ChatPane renders a single sawtooth "commit divider" at the bottom of the run timeline, labelled with the new head's short SHA — signalling prior reviews are now stale.CommitDivideris a masked-SVG zigzag rule flanking a commit-id chip (reusing the single-commit scope-badge chip vocabulary +CommitIcon); theme-aware via a token color.headShaand are not used as a baseline (no spurious divider on cold start).chatPane.commitDividerTitlein all four locales.2. Commit-aware planning context (
feat(agent))The planning/orchestration agent replays the whole prior conversation into each turn, which can reference code from before a new commit landed. It now gets soft awareness of that boundary without dropping any history:
AgentMessage.headSha).buildConversationContextinterleaves aPR code updated to commit Xmarker wherever the head differs between consecutive kept messages, plus a trailing marker when the current turn's head has advanced past the newest message.pr.sourceRef.shabasis as the UI divider, so the two stay consistent (seeing the divider ⟺ the marker is in the agent's context)./reviewetc.) remain stateless and always operate on the current diff.Not included (noted for follow-up)
Re-review
/ask(referencing an older finding to ask "is this still valid / fixed?") is not yet told the referenced finding's commit vs the current head. It works today (compares the referenced context against the current diff); adding the explicit boundary would sharpen the keep/replace/drop verdict. Deferred intentionally.Checks
lint+typecheck(all projects) +test(agent, poller) +build(desktop) pass locally.