Add getGitDiff read action and fix code-agent error semantics - #2976
Closed
George Ng (GeorgeNgMsft) wants to merge 2 commits into
Closed
Add getGitDiff read action and fix code-agent error semantics#2976George Ng (GeorgeNgMsft) wants to merge 2 commits into
George Ng (GeorgeNgMsft) wants to merge 2 commits into
Conversation
Implements the P0 VS Code read-capability improvements:
- New getGitDiff fast action for the code agent (MCP/catalog
discoverable, deterministic parameters/results) that returns a real,
bounded Git unified-diff patch (staged/unstaged/against an explicit
base ref), with per-file and per-section byte caps, file-count caps,
binary/rename/copy/deletion handling, and multi-root repository
selection. Implemented via the coda VS Code extension's vscode.git
API bridge (handleReadActions.ts / new gitDiffUtils.ts). Path
containment filters every section (including rename/copy old paths)
to files inside an open workspace folder.
- Fixes codeActionHandler.ts so operational read-action failures
reported by the coda extension (JSON { error: string } results, and
the "action not handled" fallback) resolve to a failed ActionResult
(createActionResultFromError) instead of a success-shaped result
whose display happens to mention an error.
- Preserves existing getWorkspaceChanges behavior unchanged.
Tests:
- packages/agents/code/test: new codeActionsSchemaDiscovery.spec.ts
(asserts getGitDiff is discoverable via the same schema/catalog
pipeline external MCP clients use, alongside
packages/actionSchema/test/regen.spec.ts's generic round-trip) and
codeActionErrorSemantics.spec.ts (extractOperationalError shape
detection, including the "not handled" fallback). 31/31 tests
passing across 4 suites.
- packages/coda/test: new gitDiffUtils.spec.ts (28 tests) covering
diff parsing/bounding/truncation across quoted/unquoted, spaced,
non-ASCII (both core.quotePath settings), binary, mode-only-change,
rename/copy, and deletion cases, verified against real git diff
byte output. Added a tsx --test based unit-test harness
(test:local) matching the existing onboarding-agent/typeagent-studio
convention, since coda previously had no unit-test infra.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
George Ng (GeorgeNgMsft)
marked this pull request as draft
September 4, 2026 04:35
Contributor
Author
|
Closing for now, will reopen when ready for review |
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.
What this does
Two small, related fixes to the Code Agent / Coda (VS Code extension bridge), both read-only:
getGitDiffaction — a deterministic, catalog-discoverable fast action for thecodeagent that returns the actual local Git diff: changed files plus bounded unified-diff patch/hunk text, split into staged and unstaged sections by default, or diffed against an explicit base ref (baseparameter) when given. It selects a repository explicitly or falls back to the single open repo/workspace folder (repositoryparameter, for multi-root workspaces). Binary files, renames, copies, and deletions are reported with clear status/flags instead of garbled or dropped patch text, and output is bounded (per-file byte cap, per-section byte cap, file-count cap) with truncation flags so callers always get a well-formed, complete response instead of a runaway payload.ActionResultinstead of a success-shaped result that merely happens to contain{"error": ...}in its text.getWorkspaceChangesis unchanged.Why this matters for external MCP clients
getGitDiffneeds no separate MCP wiring — it's defined the same way as every other code-agent action, so it's automatically visible through the existing active schema/catalog (the same pipelinepackages/actionSchema/test/regen.spec.tsround-trips andcommandExecutorreads for discovery). A new test (codeActionsSchemaDiscovery.spec.ts) proves it's present with a concise description and a stable, typed parameter list — deterministic and usable by an external tool-selecting client without going through TypeAgent's natural-language reasoning path.Highlights
packages/coda/src/gitDiffUtils.ts(new) — pure, unit-tested diff parsing: quoted/unquoted Git header paths (including non-ASCII under bothcore.quotePathsettings), trailing-tab disambiguation on spaced paths, binary/mode-only/rename/copy/deletion handling, and bounded truncation with reported caps.packages/coda/src/handleReadActions.ts—getGitDiffuses a singlerepo.diffWith()call per section (no serial per-file calls), filters output to paths inside an open workspace folder (checking both current and old paths for renames/copies), and reuses a sharedgetGitApi()helper.packages/agents/code/src/codeActionsSchema.ts— newGetGitDiffActionschema with a concise, standalone description andbase/repositoryparameters.packages/agents/code/src/codeActionHandler.ts— operational failures (JSON{error}results, and the "action not handled" fallback) now produce a failedActionResult.packages/coda/test/gitDiffUtils.spec.ts(newtest:localharness for coda, matching existing agent conventions) and 2 new suites inpackages/agents/code/test/(codeActionErrorSemantics.spec.ts,codeActionsSchemaDiscovery.spec.ts) — 31/31 code-agent tests, 28/28 coda tests passing.main.Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com