Skip to content

feat(agent): commit divider for stale reviews + commit-aware planning context - #216

Merged
huhamhire merged 2 commits into
devfrom
feat/agent-run-commit-divider
Jul 27, 2026
Merged

feat(agent): commit divider for stale reviews + commit-aware planning context#216
huhamhire merged 2 commits into
devfrom
feat/agent-run-commit-divider

Conversation

@huhamhire

Copy link
Copy Markdown
Owner

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 through StartReviewRunInput / 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.

  • Appears as soon as the code changes, whether or not a new run has been started against it.
  • Suppressed while a run is active (it's already processing the current head).
  • CommitDivider is 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.
  • Runs predating the field have no headSha and are not used as a baseline (no spurious divider on cold start).
  • i18n: chatPane.commitDividerTitle in 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:

  • Each recorded conversation message is stamped with the PR head SHA at turn time (AgentMessage.headSha).
  • buildConversationContext interleaves 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.
  • Same pr.sourceRef.sha basis as the UI divider, so the two stay consistent (seeing the divider ⟺ the marker is in the agent's context).
  • The 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. pr-agent tool runs (/review etc.) 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.

huhamhire and others added 2 commits July 27, 2026 12:01
… 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>
@huhamhire huhamhire added the enhancement New feature or request label Jul 27, 2026
@huhamhire
huhamhire merged commit 6005b59 into dev Jul 27, 2026
1 check passed
@huhamhire
huhamhire deleted the feat/agent-run-commit-divider branch July 27, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant