Skip to content

Report the pushed commit SHA from report_progress - #25

Merged
tiagonbotelho merged 1 commit into
mainfrom
tiagonbotelho-report-pushed-commit-sha
Aug 11, 2026
Merged

Report the pushed commit SHA from report_progress#25
tiagonbotelho merged 1 commit into
mainfrom
tiagonbotelho-report-pushed-commit-sha

Conversation

@tiagonbotelho

Copy link
Copy Markdown
Contributor

Closes #24.

What

report_progress commits and pushes, but the resulting commit SHA was never captured, so downstream consumers had no way to persist a "last pushed commit SHA" — the value was structurally unobtainable. github/sweagentd#15129 adds the server-side plumbing and currently sees an empty commit_sha 100% of the time.

Three additive changes:

  • src/git.ts — add commitSha?: string to CommitAndPushResult, resolved via git rev-parse HEAD after pushWithRebaseFallback succeeds, so the SHA always refers to a commit that is actually on the remote.
  • src/client.ts — widen sendReportProgress to accept commitSha and emit it as commit_sha, using the existing !== undefined guard style.
  • src/mcp-server.ts — thread gitResult.commitSha into the sendReportProgress call.

Safety notes

The rev-parse is deliberately isolated in its own try/catch. If it shared the caller's try, a rev-parse failure would report an already-successful push as an error, which can trigger a retry and a duplicate commit. On failure we log and leave commitSha undefined.

In mcp-server.ts the SHA stays undefined on both the local-only (config.push === false) and error paths, so a SHA that was not actually pushed is never sent.

Backward compatibility

Additive and safe in either rollout order. Absent keys are omitted from contentObj, so a pre-fix SDK sends content with no commit_sha and the server decodes it to "", skipping the update behind its existing != "" guard. Servers that don't understand commit_sha are unaffected.

Verification

npm run typecheck and npm run build both pass. The repo has no test framework (no test script, no test files, no test runner in devDependencies), so rather than scaffolding one I verified behavior against real git repositories:

  • commitAndPush returns the SHA, and that SHA is confirmed present on the remote after the push.
  • With a shimmed git where only rev-parse HEAD fails: the push still succeeds, commitSha is absent, and the branch has exactly 1 commit — no duplicate.
  • sendReportProgress omits commit_sha entirely when it is unset or explicitly undefined, and includes it when known.

Open questions for maintainers

  • Version. Not bumped here. package.json is at 0.1.0 while github/copilot-agent-runtime and sweagentd/agent-runtime both pin "@github/copilot-engine-sdk": "0.2.0" — worth confirming the intended next published version when cutting the release that carries this fix.
  • Remaining gap: finalizeChanges. That post-agent-loop safety net calls commitAndPush with no report_progress event afterwards, so the last reported SHA can still lag the true final SHA whenever that path fires. Left as-is here; worth deciding whether that push should report its SHA too.

report_progress commits and pushes, but the resulting commit SHA was never
captured, so consumers had no way to persist a "last pushed commit SHA".

- git.ts: add commitSha to CommitAndPushResult, resolved via `git rev-parse HEAD`
  after the push succeeds. The lookup is isolated in its own try/catch so a
  rev-parse failure can never turn an already-successful push into a reported
  error, which a caller could retry into a duplicate commit.
- client.ts: accept commitSha on sendReportProgress and emit it as commit_sha,
  using the existing `!== undefined` guard so the key stays absent when unknown.
- mcp-server.ts: thread the SHA from commitAndPush into sendReportProgress. It
  stays undefined on the local-only and error paths, so a SHA that was not
  actually pushed is never sent.

Closes #24

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 10, 2026 23:51
@tiagonbotelho
tiagonbotelho requested a review from a team as a code owner August 10, 2026 23:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds reporting of the successfully pushed commit SHA to downstream platform consumers.

Changes:

  • Resolves HEAD after a successful push without failing the operation if lookup fails.
  • Adds commit_sha to progress payloads when available.
  • Threads the SHA through the MCP progress-reporting flow.
Show a summary per file
File Description
src/git.ts Captures the pushed commit SHA.
src/client.ts Adds the SHA to progress payloads.
src/mcp-server.ts Forwards the pushed SHA to the platform client.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@tiagonbotelho
tiagonbotelho merged commit e90d522 into main Aug 11, 2026
8 checks passed
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

report_progress never reports the pushed commit SHA

3 participants