mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
fix: Fix review showing empty files + propagate diff errors to UI (#200)
* 🐛 fix: force standard a/b diff prefix to handle mnemonic prefix config When diff.mnemonicPrefix is enabled in git config, `git diff` uses context-dependent prefixes (c/ for commit, w/ for worktree, i/ for index) instead of the standard a/b. Both the internal parseDiffToFiles and @pierre/diffs library expect a/b prefixes, causing silent parse failures that result in an empty file list. Add --src-prefix=a/ --dst-prefix=b/ to all git diff invocations to ensure consistent output regardless of user git configuration. * ✨ feat: propagate git diff errors to review UI Previously, git diff errors were silently caught and returned as empty patches. The UI showed "No changes" with no indication of failure. - Add error field to DiffResult and propagate through ReviewServerOptions - Include error in /api/diff and /api/diff/switch responses - Show distinct error state in review UI (red icon + error message) - Clear/set error state on diff type switch * Fix mnemonic prefix handling in pi-extension runGitDiff Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Michael Ramos <mdramos8@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,8 @@ export interface ReviewServerOptions {
|
||||
rawPatch: string;
|
||||
/** Git ref used for the diff (e.g., "HEAD", "main..HEAD", "--staged") */
|
||||
gitRef: string;
|
||||
/** Error message if git diff failed */
|
||||
error?: string;
|
||||
/** HTML content to serve for the UI */
|
||||
htmlContent: string;
|
||||
/** Origin identifier for UI customization */
|
||||
@@ -89,6 +91,7 @@ export async function startReviewServer(
|
||||
let currentPatch = options.rawPatch;
|
||||
let currentGitRef = options.gitRef;
|
||||
let currentDiffType: DiffType = options.diffType || "uncommitted";
|
||||
let currentError = options.error;
|
||||
|
||||
const isRemote = isRemoteSession();
|
||||
const configuredPort = getServerPort();
|
||||
@@ -132,6 +135,7 @@ export async function startReviewServer(
|
||||
sharingEnabled,
|
||||
shareBaseUrl,
|
||||
repoInfo,
|
||||
...(currentError && { error: currentError }),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,11 +160,13 @@ export async function startReviewServer(
|
||||
currentPatch = result.patch;
|
||||
currentGitRef = result.label;
|
||||
currentDiffType = newDiffType;
|
||||
currentError = result.error;
|
||||
|
||||
return Response.json({
|
||||
rawPatch: currentPatch,
|
||||
gitRef: currentGitRef,
|
||||
diffType: currentDiffType,
|
||||
...(currentError && { error: currentError }),
|
||||
});
|
||||
} catch (err) {
|
||||
const message =
|
||||
|
||||
Reference in New Issue
Block a user