Skip to content

Pierre diffs update - #22

Closed
ShpetimA wants to merge 3 commits into
masterfrom
pierre-diffs-update
Closed

ShpetimA wants to merge 3 commits into
masterfrom
pierre-diffs-update

Conversation

@ShpetimA

Copy link
Copy Markdown
Owner

No description provided.

@ShpetimA

Copy link
Copy Markdown
Owner Author

/review

@orc-review orc-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is a large refactor that introduces multi-diff support via @pierre/diffs 1.2.7, adds new PullRequestCodeViewDiffPane and ChangesCodeViewDiffPane components, adds git error logging, and improves LSP diagnostics handling. There are several issues:

  1. Packaging bug: electron was added to the root package.json dependencies instead of devDependencies. This will bloat production installs and may cause Electron to be bundled inappropriately. apps/desktop/package.json already has electron as a devDependency.

  2. Unregistered pnpm patch: The patch patches/@pierre__diffs@1.2.4.patch was added but there is no patchedDependencies entry in package.json or pnpm-lock.yaml, so pnpm will not apply it.

  3. Concurrency risk in git error logging: lastGitCommandErrorLog in electron/git.ts is a single global mutable variable. If multiple git commands fail concurrently, the log path from the most recent failure overwrites the previous one, and getLastGitCommandErrorLogPath may return the wrong log for a repo. The log filename also uses Date.now() which can collide for concurrent failures in the same millisecond.

  4. Stale LSP document risk: useCurrentLspDocuments builds a documentsKey using only text.length. If a document's text changes while keeping the same length, the effect may not re-run and the LSP server will receive stale content.

  5. Missing scrollbar markers in Changes view: ChangesCodeViewDiffPane does not render DiffScrollbarMarkers while PullRequestCodeViewDiffPane does. This is an inconsistent UX omission.

  6. Duplicate code: DiffViewer.tsx still contains a duplicate DiffScrollbarMarkers implementation that is now shadowed by the new shared component. This should be cleaned up in a follow-up.

General comments

  • The buildHunkActionAnnotations function in ChangesCodeViewDiffPane.tsx correctly handles hunk content iteration and fallback when a hunk has only context lines. The logic is sound.
  • The useParsedMultiFileDiffs hook uses a forceUpdate pattern to trigger re-renders after async diff parsing. This is acceptable but could be simplified with a state variable if needed.
  • The new RepoActionErrorDialog component is a nice UX improvement but the openGitLog function opens a file in os.tmpdir(). Consider adding a TTL or cleanup mechanism for these log files since they are currently written without any deletion logic.
  • The useCurrentLspDocuments cleanup effect correctly closes all documents on unmount, but the documentsKey text-length issue noted above should be fixed to prevent stale syncs.

Findings not posted inline

  • apps/desktop/src/features/diff-view/components/DiffViewer.tsx:449 (RIGHT) — line is not commentable in the GitHub diff
    This file still contains a duplicate buildDiffScrollbarMarkers / DiffScrollbarMarkers implementation that is now shadowed by the new shared component in DiffScrollbarMarkers.tsx. The dead code should be removed in a follow-up.

Comment thread package.json
"format:check": "pnpm fmt:check",
"check": "pnpm lint && pnpm typecheck && pnpm test && pnpm fmt:check"
},
"dependencies": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Adding electron to the root dependencies is a packaging mistake. Electron should be a devDependency (it is already listed correctly in apps/desktop/package.json). This will cause Electron to be installed in production and may bloat/break the bundle.

Comment thread package.json
},
"packageManager": "pnpm@10.28.0"
"packageManager": "pnpm@10.28.0",
"pnpm": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The patches/@pierre__diffs@1.2.4.patch file was added but there is no patchedDependencies entry here, so pnpm will not apply the patch. Either add the patchedDependencies configuration or remove the unused patch file.

const GIT_WRITE_RETRY_DELAY_MS = 120;
const GIT_ERROR_LOG_DIR = path.join(os.tmpdir(), "open-warden-git-logs");

let lastGitCommandErrorLog: { repoPath: string; path: string } | null = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a single global mutable variable. If multiple git commands fail concurrently, the log path is overwritten by the most recent failure, and getLastGitCommandErrorLogPath may return the wrong log for a repo. Consider using a per-repo or per-promise map instead.

}) {
try {
await fs.mkdir(GIT_ERROR_LOG_DIR, { recursive: true });
const logPath = path.join(GIT_ERROR_LOG_DIR, `git-${Date.now()}-${process.pid}.log`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using Date.now() for the filename means two concurrent failures in the same millisecond could collide and overwrite the same file. Consider adding a counter or random suffix to ensure uniqueness.

const activeDocumentRef = useRef<ActiveDocument | null>(null);
const activeDocumentsRef = useRef(new Map<string, CurrentLspDocument>());
const documentsKey = documents
.map((document) => `${documentKey(document)}\u0000${document.text.length}`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The documentsKey only includes text.length. If a document's text changes while keeping the same length, the key won't change and the effect may not re-run, leaving the LSP server with stale content. Consider hashing the text or including a substring of the content.

) : parsedDiffs.length === 0 ? (
<div className="text-muted-foreground p-3 text-sm">No renderable diff content.</div>
) : null}
<div className="relative min-h-0 min-w-0 flex-1">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This multi-diff pane is missing <DiffScrollbarMarkers markers={scrollbarMarkers} viewportRef={viewportRef} /> while PullRequestCodeViewDiffPane includes it. This is an inconsistent UX omission.

@ShpetimA

Copy link
Copy Markdown
Owner Author

/review

@ShpetimA ShpetimA closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant