[codex] fix(vscode): fall back to git CLI for diffs#12091
[codex] fix(vscode): fall back to git CLI for diffs#12091yzlu0917 wants to merge 3 commits intocontinuedev:mainfrom
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="extensions/vscode/src/util/gitDiffFallback.ts">
<violation number="1" location="extensions/vscode/src/util/gitDiffFallback.ts:12">
P2: Diff splitting regex is not line-anchored, so hunk content containing `diff --git ...` can be misinterpreted as a new file header and corrupt split results.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| const GIT_DIFF_MAX_BUFFER = 10 * 1024 * 1024; | ||
|
|
||
| export function splitGitDiff(diffString: string): string[] { | ||
| const fileDiffHeaderRegex = /(?=diff --git a\/.* b\/.*)/; |
There was a problem hiding this comment.
P2: Diff splitting regex is not line-anchored, so hunk content containing diff --git ... can be misinterpreted as a new file header and corrupt split results.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/vscode/src/util/gitDiffFallback.ts, line 12:
<comment>Diff splitting regex is not line-anchored, so hunk content containing `diff --git ...` can be misinterpreted as a new file header and corrupt split results.</comment>
<file context>
@@ -0,0 +1,69 @@
+const GIT_DIFF_MAX_BUFFER = 10 * 1024 * 1024;
+
+export function splitGitDiff(diffString: string): string[] {
+ const fileDiffHeaderRegex = /(?=diff --git a\/.* b\/.*)/;
+ const diffs = diffString.split(fileDiffHeaderRegex);
+
</file context>
| const fileDiffHeaderRegex = /(?=diff --git a\/.* b\/.*)/; | |
| const fileDiffHeaderRegex = /(?=^diff --git a\/.* b\/.*$)/m; |
💡 Codex Reviewcontinue/gui/src/forms/AddModelForm.tsx Lines 75 to 76 in e030a32 The guard in continue/core/llm/fetchModels.ts Lines 180 to 181 in e030a32 Constructing the endpoint with ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
e030a32 to
5f109aa
Compare
Summary
git diff/git diff --cachedfrom workspace or repo roots when the Git API returns no diff contentWhy
In some remote environments such as WSL, Continue can end up with an empty diff from the VS Code Git API even though
git diffin the integrated terminal shows changes. That causes the@Git Diffcontext provider to incorrectly sayGit shows no current changes.This change preserves the existing fast path but adds a CLI fallback so diff context still works when the Git extension cannot provide the patch content.
Validation
npx vitest run src/util/gitDiffFallback.vitest.tsinextensions/vscodegit diff --checkCloses #9136
Summary by cubic
Add a CLI fallback for Git diffs in VS Code so the
@Git Diffcontext works when the Git API returns no content (e.g., WSL/remote). Also adds dynamic model fetching across providers with UI support to list available models by API key.Bug Fixes
git diff --cachedandgit difffrom repo/workspace roots discovered viagit rev-parse --show-toplevel(deduped, skip non-git, 10MB buffer).splitGitDiff; return only non-empty diffs.ideUtilswhen API diffs are empty; addedvitestcoverage for split logic and fallback behavior.New Features
"models/fetch"protocol andfetchModelsforollama,openrouter,anthropic,gemini, and generic providers vialistModels; surfaces errors via IDE toast.OpenAIresponses gating viaisOSeriesOrGpt5PlusModel; improved Gemma image support regex;OpenRoutersets defaultOPENROUTER_HEADERSfrom@continuedev/openai-adapters.Written for commit fa2ed25. Summary will update on new commits.