Repository navigation
Conversation
|
/review |
There was a problem hiding this comment.
This PR is a large refactor (+3413/-934, 40 files) that migrates the Changes and Pull-Request diff panes from the single-file DiffWorkspace onto a new multi-file @pierre/diffs CodeView (via ChangesCodeViewDiffPane and PullRequestCodeViewDiffPane), replaces single-document LSP syncing with useCurrentLspDocuments (plural), adds multi-file diagnostics + a diagnostics summary banner, and introduces a git command error-log feature with a RepoActionErrorDialog. The direction is sound and the new panes are well-structured, but there are several issues that should be addressed before merge.
Highest priority: (1) patches/@pierre__diffs@1.2.4.patch is added but never wired up — there is no pnpm.patchedDependencies entry in the root package.json, and the filename version (1.2.4) does not match the pinned @pierre/diffs@1.2.7. The patch fixes VirtualizedFileDiff forceRender behavior in advanced mode; if that fix is required for the new CodeView to render correctly, it is silently missing. (2) The root package.json now declares electron: ^42.3.0 as a runtime dependency while apps/desktop pins electron: 41.0.2 in devDependencies — two divergent Electron versions in the workspace, and a runtime dep on a private root package that has no runtime.
Secondary: the new git error-log writer stores full git stdout/stderr (which can contain file contents/secrets) in a shared, world-readable tmpdir using predictable filenames with default permissions and no cleanup, and a module-level singleton that any concurrent failed git command overwrites — so the dialog can surface the wrong command's output. Test coverage is light for the volume of new logic (no tests for git error logging, buildRepoActionError, useMultiDiffDiagnostics, useParsedMultiFileDiffs, or LspDiagnosticsSummaryNotice).
General comments
- Test coverage is thin for the amount of new logic. The only behavioral test added is
LspSymbolPeekscroll positioning. There are no tests for:writeGitCommandErrorLog/getLastGitCommandErrorLogPath(electron),buildRepoActionError/firstErrorLine/stripAnsi(actions.ts),useParsedMultiFileDiffscache/microtask behavior,useMultiDiffDiagnosticsre-paint effect,LspDiagnosticsSummaryNoticepending/unavailable counting, orbuildMultiDiffScrollbarMarkers/buildDiffScrollbarMarkersmath. Given these drive rendering and git-failure UX, unit tests for the pure helpers (marker math, ANSI/error-line stripping, diagnostics summary counts) would be high-value and low-cost. - Behavior change worth flagging:
PullRequestFiles.tsx/PullRequestReviewFilesScreen.tsxdrop the per-fileuseThrottledDiffSelection/useGetBranchFileVersionsQuery(single-file) flow in favor of eagerly subscribing to branch-file-version queries for ALL files viauseEnsureBranchFileVersionQueries(one RTK Query subscription per file). For PRs with many changed files this is a meaningful increase in concurrent git IPC + subscriptions; verify that scales acceptably and that unsubscriptions on target changes are timely (they look correct — keyed offtargetKey). useCurrentLspDocumentsnow syncs an LSP document for every file with availablenewFilecontents across all multi-diff targets, not just the active file. On large diffs this opens many LSP documents simultaneously. Confirm the LSP session manager tolerates this and that it's the intended behavior (vs. syncing only the active + visible items)..vite-hooks/pre-commitnow runspnpm precommit(=pnpm lint && pnpm fmt:check), and a newprecommit:fixscript exists — fine. Just note the pre-commit hook no longer runs typecheck/tests, matching the prior behavior, so CI is the gate for those.
| "check": "pnpm lint && pnpm typecheck && pnpm test && pnpm fmt:check" | ||
| }, | ||
| "dependencies": { | ||
| "electron": "^42.3.0" |
There was a problem hiding this comment.
Two concerns here:
electronis added as a runtime dependency of the root package, but the root package is"private": truewith nomain/runtime — Electron belongs indevDependencies(or only inapps/desktop).- This pins
^42.3.0whileapps/desktop/package.jsonstill pins"electron": "41.0.2". The workspace now resolves two different Electron majors, which can lead to the wrong binary being used by tooling/electron-builder. Was this intended? If the goal was just to allowonlyBuiltDependenciesto take effect, it should be a devDependency matching the desktop workspace version.
| }, | ||
| "packageManager": "pnpm@10.28.0" | ||
| "packageManager": "pnpm@10.28.0", | ||
| "pnpm": { |
There was a problem hiding this comment.
There is a patches/@pierre__diffs@1.2.4.patch in this PR but no pnpm.patchedDependencies field anywhere (verified: no matches in the repo). pnpm will not apply patches from patches/ without this config. Additionally the patch filename targets 1.2.4 while @pierre/diffs is pinned to 1.2.7, so even with the config the version qualifier wouldn't match. The patch edits VirtualizedFileDiff to force-render in advanced mode — if that change is needed for the new CodeView rendering to behave, the fix is currently dead. Either add the patchedDependencies entry keyed to 1.2.7 (and regenerate with pnpm patch) or drop the file if it's no longer needed.
| const GIT_TIMEOUT_MS = 30_000; | ||
| const GIT_WRITE_RETRY_COUNT = 3; | ||
| const GIT_WRITE_RETRY_DELAY_MS = 120; | ||
| const GIT_ERROR_LOG_DIR = path.join(os.tmpdir(), "open-warden-git-logs"); |
There was a problem hiding this comment.
os.tmpdir() resolves to /tmp on many Linux setups, which is world-readable. The log content includes full git stdout/stderr (repo path, command, and potentially file contents/diff text), so other local users could read it. Prefer a 0o700 directory under the user's data/cache dir (e.g. app.getPath('temp')/userData), or fs.mkdir(..., { mode: 0o700 }) and write with mode: 0o600. There's also no eviction/cleanup, so logs accumulate for the process lifetime.
| }) { | ||
| try { | ||
| await fs.mkdir(GIT_ERROR_LOG_DIR, { recursive: true }); | ||
| const logPath = path.join(GIT_ERROR_LOG_DIR, `git-${Date.now()}-${process.pid}.log`); |
There was a problem hiding this comment.
The filename git-${Date.now()}-${process.pid}.log is predictable, and fs.writeFile follows existing entries — a pre-placed symlink at that path (classic /tmp symlink attack) would let another user overwrite an arbitrary file the app user can write. Use a random suffix (crypto.randomUUID()) and write with flag: 'wx' (exclusive create) plus a restrictive mode to mitigate both guessing and symlink races.
| 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; |
There was a problem hiding this comment.
lastGitCommandErrorLog is a process-wide singleton overwritten by every failed git command (the runGit catch on line 165 calls writeGitCommandErrorLog unconditionally). If any other git operation fails between a commit failure and the getLastGitCommandErrorLogPath(repoPath) lookup in toGitErrorResult (e.g. a concurrent snapshot poll, stage, or discard — all of which also go through runGit), the RepoActionErrorDialog will display the wrong command's output. Only repoPath is filtered, not the args/command identity. Consider returning the logPath on the thrown GitCommandError (it already carries it) and reading it from the error instead of via this singleton lookup.
| return { data: await commitStaged(repoPath, message) }; | ||
| } catch (error) { | ||
| return { error: toErrorResult(error) }; | ||
| return { error: await toGitErrorResult(error, repoPath) }; |
There was a problem hiding this comment.
Only commitStaged uses toGitErrorResult (with the log path); discardFile(s)/All, stageAll, unstageAll, and hunk operations still use plain toErrorResult. That may be intentional (commit is where verbose pre-commit output matters), but runRepoAction/buildRepoActionError apply to all actions, so non-commit failures will always show logPath: null and no "Open Git Log" button. Worth confirming this asymmetry is deliberate.
| }; | ||
|
|
||
| type FileVersionData = { | ||
| oldFile: DiffFile | null; |
There was a problem hiding this comment.
The effect closes over requests but lists only [requestKey] as a dep. It works today because requestKey is derived from requests, but when every request is already cached you still schedule a queueMicrotask(forceUpdate) on each requestKey change — that's an extra render per cache change. Consider gating the microtask on whether forceUpdate was already triggered for this key, or just unconditionally calling forceUpdate() after the loadParsedDiff settle. Not a correctness bug, just a note.
| const message = error instanceof Error ? error.message : String(error); | ||
| toast.error(`Failed to ${repoActionLabel(action)}: ${message}`); | ||
| const actionError = buildRepoActionError(action, error); | ||
| dispatch(setRepoActionError(actionError)); |
There was a problem hiding this comment.
runRepoAction now both shows a toast and dispatches setRepoActionError (rendered as a modal RepoActionErrorDialog). For commit failures the user gets two simultaneous notifications for the same error. If the modal is the intended primary surface, consider dropping the toast (or vice versa) to avoid duplicate/noisy feedback.
| @@ -0,0 +1,178 @@ | |||
| import { useCallback, type PointerEvent, type RefObject } from "react"; | |||
There was a problem hiding this comment.
This duplicates the DiffScrollbarMarkers component that still lives in DiffViewer.tsx (the one used by DiffWorkspace). The two have already diverged slightly (this new one is the exported, multi-diff-aware version). Consider reusing one implementation to avoid future drift, or renaming to make the split explicit.
| hunk.hunkContent.forEach((content, contentIndex) => { | ||
| if (content.type === "context") { | ||
| splitOffset += content.lines; | ||
| unifiedOffset += content.lines; | ||
| return; | ||
| } | ||
|
|
||
| const splitStart = hunk.splitLineStart + splitOffset; | ||
| const unifiedStart = hunk.unifiedLineStart + unifiedOffset; | ||
| const splitRows = Math.max(content.additions, content.deletions); | ||
|
|
||
| if (content.deletions > 0) { | ||
| const start = diffStyle === "split" ? splitStart : unifiedStart; | ||
| const rows = diffStyle === "split" ? splitRows : content.deletions; | ||
| markers.push({ | ||
| key: `${hunkIndex}-${contentIndex}-deletions`, | ||
| type: "deletion", | ||
| top: clampPercent((start / totalLines) * 100), | ||
| height: clampPercent((Math.max(1, rows) / totalLines) * 100), | ||
| }); | ||
| } |
|
|
||
| if (content.additions > 0) { | ||
| const start = diffStyle === "split" ? splitStart : unifiedStart + content.deletions; | ||
| const rows = diffStyle === "split" ? splitRows : content.additions; |
|
/orc what is the deal with this pr |
|
This is a "Pierre diffs update" PR with an empty description, but the diff is large (~40 files). It does three related things: 1. Upgrades
2. Better git error reporting
3. LSP + UX polish that comes with multi-file view
Loose ends worth questioning
|
|
/review |
1 similar comment
|
/review |
| for (const [key, nextDocument] of nextDocuments) { | ||
| const currentDocument = activeDocumentsRef.current.get(key); | ||
| if (currentDocument?.text === nextDocument.text) continue; |
There was a problem hiding this comment.
Bug: Skipping syncLspDocument when text hasn't unchanged prevents re-syncing after LSP server restart. If the LSP server crashes and restarts while documents are open, they won't be re-synced because their text content hasn't changed. This causes the LSP server to operate on stale or missing document state. The backend should handle deduplication, so always call syncLspDocument for active documents.
No description provided.