Repository navigation
feat: worktrees git diff viewer - #90
Conversation
- full diff viewer using Monaco DiffEditor with file sidebar, folder tree grouping, collapsible file sections, and lazy content fetching - two API endpoints: GET /worktrees/:id/diff (file list) and GET /worktrees/:id/diff/file (per-file content) with support for uncommitted and committed-vs-base-branch changes - custom execCmd wrapper using callback-form execFile to avoid stdout being undefined in bundled contexts (promisify loses encoding option) - Monaco configured with local workers via Vite ?worker imports to prevent cross-origin script errors from CDN loading - resizable sidebar with persisted width, folder-grouped file tree with compact single-child chains, and dynamic editor height sizing - moved diff stats from detail header to Changes tab, unified diff stat colors across sidebar and diff viewer
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughImplemented a comprehensive diff viewer feature with backend git integration and frontend React components. Added two API endpoints for fetching file diffs and content, created git command wrappers for change detection and file content retrieval, and built a multi-component UI with Monaco diff editor, collapsible file sections, and resizable sidebar. Includes test coverage and documentation. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DiffViewerTab
participant API
participant Server
participant Git
participant DiffFileSidebar
participant DiffFileSection
participant Monaco
User->>DiffViewerTab: Tab becomes visible
DiffViewerTab->>API: fetchDiffFiles(worktreeId, includeCommitted)
API->>Server: GET /api/worktrees/:id/diff
Server->>Git: getChangedFiles(path, baseBranch, includeCommitted)
Git->>Git: Run git diff, git ls-files
Git-->>Server: {files[], baseBranch, error?}
Server-->>API: DiffListResponse
API-->>DiffViewerTab: {success, files[], baseBranch, error?}
DiffViewerTab->>DiffFileSidebar: Render with files
User->>DiffFileSidebar: Click file
DiffFileSidebar->>DiffFileSection: onToggle/expanded=true
DiffFileSection->>API: fetchDiffFileContent(worktreeId, path, status, ...)
API->>Server: GET /api/worktrees/:id/diff/file?path=...
Server->>Git: getFileContent(path, fileStatus, baseBranch, ...)
Git->>Git: git show HEAD:path, read disk file
Git-->>Server: {oldContent, newContent, error?}
Server-->>API: DiffFileContentResponse
API-->>DiffFileSection: {success, oldContent, newContent, error?}
DiffFileSection->>Monaco: Render diff with original/modified
Monaco-->>User: Display side-by-side or unified diff
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (6)
docs/FRONTEND.md (1)
254-260: Please mirror this feature inREADME.mdtoo.
docs/FRONTEND.mdis updated nicely, but the repo convention also asks for user-facing features to land in the main README so the new Changes tab is discoverable from the entrypoint docs.Happy to draft a short README blurb if useful. Based on learnings, "When adding/changing user-facing features, update README.md."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/FRONTEND.md` around lines 254 - 260, Add a concise user-facing summary of the FRONTEND.md changes into README.md: mention the new "Changes" tab and the updated Tab bar agent quick-actions (+ Claude, + Codex, + Gemini, + OpenCode) with restore-first behavior for Claude/Codex, the Git action toolbar (Commit/Push/PR inline forms), LogsViewer, TerminalView session/reattach behavior (scoped sessions, serialized terminal-state snapshot, explicit launch intent semantics), HooksTab realtime hook UI, DiffViewerTab with Monaco diff editors and lazy loading, and the Recover Task action for LOCAL-* worktrees; keep it short, link to docs/FRONTEND.md for full details, and add the repo guideline note "When adding/changing user-facing features, update README.md."apps/web-app/src/types.ts (1)
349-370: Reuse the shared diff contracts instead of duplicating them here.
libs/shared/src/worktree-types.tsalready exports these three interfaces. Copying them intoapps/web-app/src/types.tscreates a second copy of the API contract that can drift from the backend.Suggested simplification
// ─── Diff Viewer ──────────────────────────────────────────────── - -export interface DiffFileInfo { - path: string; - oldPath?: string; - status: "modified" | "added" | "deleted" | "renamed" | "untracked"; - linesAdded: number; - linesRemoved: number; - isBinary: boolean; -} - -export interface DiffListResponse { - success: boolean; - files: DiffFileInfo[]; - baseBranch: string; - error?: string; -} - -export interface DiffFileContentResponse { - success: boolean; - oldContent: string; - newContent: string; - error?: string; -} +export type { + DiffFileInfo, + DiffFileContentResponse, + DiffListResponse, +} from "@openkit/shared/worktree-types";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/types.ts` around lines 349 - 370, The three duplicated interfaces (DiffFileInfo, DiffListResponse, DiffFileContentResponse) should be removed from this file and imported from the shared worktree-types module instead; replace the local interface definitions with a single import like import { DiffFileInfo, DiffListResponse, DiffFileContentResponse } from the shared worktree-types module, update any local references to use the imported types, and ensure exports remain consistent so the app uses the shared API contract rather than a copy.libs/shared/src/worktree-types.ts (1)
223-246: Import Diff types fromlibs/sharedto avoid duplication.
DiffFileInfo,DiffListResponse, andDiffFileContentResponseare duplicated inapps/web-app/src/types.ts(lines 349-369). Remove these definitions and import them fromlibs/sharedinstead. This maintains a single source of truth and aligns with the project's pattern of consuming shared types from the library's public API.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@libs/shared/src/worktree-types.ts` around lines 223 - 246, Remove the duplicated type definitions for DiffFileInfo, DiffListResponse, and DiffFileContentResponse from apps/web-app/src/types.ts and replace them with imports from the shared library; specifically, delete the local interfaces named DiffFileInfo, DiffListResponse, and DiffFileContentResponse and add an import that brings those types from libs/shared (the module that exports the same interfaces in worktree-types.ts), then update any local references to use the imported types to keep a single source of truth.apps/web-app/src/components/detail/__test__/DiffFileSidebar.test.tsx (1)
43-46: Prefer visible-text queries overgetByTitle()here.These assertions are tied to the
titleattribute instead of the rendered status label. Query the badges by visible text or accessible name so the test keeps checking user-facing output rather than a tooltip implementation detail.As per coding guidelines: "Component tests use React Testing Library: query by role/label/text, use userEvent, never test implementation details."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/__test__/DiffFileSidebar.test.tsx` around lines 43 - 46, The test in DiffFileSidebar.test.tsx uses implementation-detail queries like screen.getByTitle("modified") / "added" / "deleted" / "untracked"; update these assertions to query the rendered status badges by visible text or accessible name (e.g., screen.getByText("M") or screen.getByRole(...) with the badge's accessible name) so the test asserts the user-facing label rather than the title attribute; modify the four expectations that reference screen.getByTitle(...) to use getByText or an appropriate getByRole/getByLabelText query targeting the visible badge content.apps/web-app/src/components/detail/DiffViewerTab.tsx (1)
99-109: This effect issues a second diff request on mount.
useEffectruns once after the first render, so whenvisibleis true the initial tab open callsfetchFiles()here and again in the visibility effect above. That doubles the git diff work for every open.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffViewerTab.tsx` around lines 99 - 109, The second useEffect in DiffViewerTab.tsx causes a duplicate fetchFiles() on mount because both the visibility effect and the hasUncommitted effect run once after first render; change the hasUncommitted effect to avoid running on initial mount by gating it with a mounted flag and visible check (e.g., use a ref like mountedRef and set it after the first render), or remove the second effect and instead trigger a best-effort refresh from the primary effect when worktree.hasUncommitted transitions; ensure the effect references fetchFiles, visible, and worktree.hasUncommitted and only calls fetchFiles() when mountedRef.current && visible to prevent the duplicate request.apps/web-app/src/components/detail/DiffMonacoEditor.tsx (1)
73-85: Use shared theme tokens for these Monaco diff colors.The inserted/removed backgrounds here are ad-hoc green/red variants instead of being derived from
palette. Please move them behind shared tokens or derive them from the existing semantic colors so the diff viewer stays aligned with the rest of the app.As per coding guidelines: "
apps/web-app/src/**/*.{ts,tsx}: Always use the standard shared color palette and tokens from apps/web-app/src/theme.ts. Do not introduce ad-hoc lighter/darker color variants for existing control patterns."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 73 - 85, The hardcoded hex colors in DiffMonacoEditor ("diffEditor.insertedTextBackground", "diffEditor.insertedLineBackground", "diffEditor.removedTextBackground", "diffEditor.removedLineBackground", "diffEditorGutter.insertedLineBackground", "diffEditorGutter.removedLineBackground", "diffEditorOverview.insertedForeground", "diffEditorOverview.removedForeground", "editorOverviewRuler.addedForeground", "editorOverviewRuler.deletedForeground", etc.) must be replaced with shared theme tokens from the app theme (use palette/semantic tokens exported by theme.ts); if appropriate tokens don't exist, add new semantic tokens (e.g. diffInsertedBackground, diffRemovedBackground, diffInsertedGutter, diffRemovedGutter, diffOverviewAdded, diffOverviewDeleted) to theme.ts and use those tokens in DiffMonacoEditor.tsx instead of ad‑hoc hex values so the diff colors derive from the central palette and remain consistent with the app.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/server/src/routes/github.ts`:
- Around line 330-356: The handler casts fileStatus from the query but doesn't
validate it and always wraps getFileContent responses in success: true, hiding
invalid inputs and backend errors; before calling getFileContent validate that
the parsed fileStatus is one of the allowed DiffFileInfo["status"] values (e.g.,
"modified","added","deleted","renamed") and if fileStatus === "renamed" ensure
oldPath is provided, returning a 400 JSON response with success: false on
malformed input; after calling getFileContent, check result.error and if present
return c.json({ success: false, error: result.error, oldContent: "", newContent:
"" }, /* appropriate status - use 500 or map from result if available */)
instead of always returning success: true so real failures propagate to the
client.
In `@apps/web-app/package.json`:
- Line 49: The package.json currently lists "monaco-editor" as a devDependency
but it is imported at runtime from apps/web-app/src/monaco-setup.ts (via the app
entry point main.tsx), so move "monaco-editor" from devDependencies to
dependencies in package.json; update the package.json dependencies block to
include the same version string (e.g., "^0.55.1"), remove it from
devDependencies, and re-run install to ensure lockfiles are updated so
production installs (pnpm install --prod or CI/CD) will include monaco-editor.
In `@apps/web-app/src/components/detail/DiffFileSection.tsx`:
- Around line 52-64: The current logic infers "File too large to display" from
empty strings in res.oldContent/res.newContent which incorrectly treats
legitimate empty files as errors; update the handling in DiffFileSection (where
setContent/setError are used and the later 137-140 branch) to rely on an
explicit API flag or the presence of res.error (e.g., res.unavailableDueToSize
or res.isTruncated) instead of checking for empty strings, so: accept empty
old/new content as valid, only setError to "File too large to display" when the
explicit flag or a non-empty res.error indicates that condition, and mirror this
change in both places that currently infer size issues from empty content.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx`:
- Around line 114-115: The two flags keepCurrentOriginalModel and
keepCurrentModifiedModel in DiffMonacoEditor prevent Monaco ITextModel instances
from being disposed and are causing orphaned models on repeated mount/unmount
(e.g., when DiffFileSection collapses); remove these flags (or set them to
false) from the Monaco diff editor options passed by DiffMonacoEditor and ensure
any models created by DiffMonacoEditor are explicitly disposed in the
component's cleanup (useEffect return or componentWillUnmount) so models are not
retained in Monaco's global model registry.
In `@apps/web-app/src/components/detail/DiffViewerTab.tsx`:
- Around line 63-76: The fetch branch currently ignores res.error when the
request succeeds; update the logic in the DiffViewerTab fetch handler (the block
using fetchDiffFiles, fetchId/fetchCountRef, setFiles, setError, and log.error)
so that if res.error exists and res.files is empty treat it as a load failure:
log the error, call setError(res.error ?? "Failed to load changes"),
setFiles([]) and return; if res.error exists but res.files is non-empty, still
render the files (setFiles(res.files)) and surface the message to the user via
the project toast helper (showPersistentErrorToast or
reportPersistentErrorToast) while not preventing rendering; keep the stale
fetchId check intact.
In `@apps/web-app/src/main.tsx`:
- Around line 1-2: Add a 1–3 sentence JSDoc block at the top of
apps/web-app/src/main.tsx describing the file's responsibility (bootstrapping
Monaco workers via "./monaco-setup" and starting the React app), so the file
meets the project header requirement; place the comment before the existing
imports and ensure it succinctly explains what the file does and is updated if
its responsibilities change.
In `@libs/integrations/src/github/git-diff.ts`:
- Around line 309-337: The switch uses unvalidated filePath/oldPath passed
directly to readWorkingCopy() and gitShow(), allowing path escapes; before the
switch (in the function handling the diff), resolve and normalize filePath and
oldPath against worktreePath (e.g., use path.resolve(worktreePath, filePath)),
then verify the resolved paths are inside worktreePath (e.g., ensure
path.relative(worktreePath, resolvedPath) does not start with '..'); if a path
is outside the worktree reject the request (throw or return an error) so only
safe, normalized paths are passed to readWorkingCopy() and gitShow().
- Line 303: The current assignment for ref (`const ref = includeCommitted ?
\`origin/${normalizeBaseBranch(baseBranch)}\` : "HEAD";`) forces use of
origin/<baseBranch> even when that remote ref is missing; update the logic in
getFileContent() so that when includeCommitted is true you first verify the
existence of `origin/${normalizeBaseBranch(baseBranch)}` (reuse the same check
used in getChangedFiles() or a helper that determines if the base ref exists)
and only set ref to that origin ref if it exists, otherwise fall back to "HEAD";
reference symbols: getFileContent(), getChangedFiles(), includeCommitted,
normalizeBaseBranch, baseBranch, and the local variable ref.
- Around line 353-375: Both gitShow and readWorkingCopy swallow errors and
return empty strings which masks real failures; update gitShow to catch the
error, log it via the module logger (including ref, filePath and the original
error) and rethrow or return a distinct error indicator so callers can handle it
(referencing gitShow and execCmd), and update readWorkingCopy to check file size
before loading by using a stat call (referencing readWorkingCopy, readFile and
MAX_FILE_SIZE) — if the file exceeds MAX_FILE_SIZE log a warning with path/size
and return an explicit error or null, and on any I/O error log the full error
(with path) instead of returning "" so getFileContent can surface/log the
failure appropriately.
- Around line 236-250: The current merge of committed (baseRef...HEAD) and
HEAD-only diffs mixes bases; when includeCommitted is true, prefer the committed
diff as the single source of truth so getFileContent() (which compares against
origin/<baseBranch>) sees a consistent base. Change the logic around
includeCommitted in the code that calls parseNameStatus and populates
filesByPath so that when includeCommitted is true you populate filesByPath only
from the committed result (the parseNameStatus of `${baseRef}...HEAD`) and do
not retain/merge entries coming from the HEAD-only diff; update any
deduplication to prefer the committed entry (using file.path keys) and keep
references to normalizeBaseBranch, hasRef, parseNameStatus and filesByPath to
locate where to change the merge behavior.
---
Nitpick comments:
In `@apps/web-app/src/components/detail/__test__/DiffFileSidebar.test.tsx`:
- Around line 43-46: The test in DiffFileSidebar.test.tsx uses
implementation-detail queries like screen.getByTitle("modified") / "added" /
"deleted" / "untracked"; update these assertions to query the rendered status
badges by visible text or accessible name (e.g., screen.getByText("M") or
screen.getByRole(...) with the badge's accessible name) so the test asserts the
user-facing label rather than the title attribute; modify the four expectations
that reference screen.getByTitle(...) to use getByText or an appropriate
getByRole/getByLabelText query targeting the visible badge content.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx`:
- Around line 73-85: The hardcoded hex colors in DiffMonacoEditor
("diffEditor.insertedTextBackground", "diffEditor.insertedLineBackground",
"diffEditor.removedTextBackground", "diffEditor.removedLineBackground",
"diffEditorGutter.insertedLineBackground",
"diffEditorGutter.removedLineBackground",
"diffEditorOverview.insertedForeground", "diffEditorOverview.removedForeground",
"editorOverviewRuler.addedForeground", "editorOverviewRuler.deletedForeground",
etc.) must be replaced with shared theme tokens from the app theme (use
palette/semantic tokens exported by theme.ts); if appropriate tokens don't
exist, add new semantic tokens (e.g. diffInsertedBackground,
diffRemovedBackground, diffInsertedGutter, diffRemovedGutter, diffOverviewAdded,
diffOverviewDeleted) to theme.ts and use those tokens in DiffMonacoEditor.tsx
instead of ad‑hoc hex values so the diff colors derive from the central palette
and remain consistent with the app.
In `@apps/web-app/src/components/detail/DiffViewerTab.tsx`:
- Around line 99-109: The second useEffect in DiffViewerTab.tsx causes a
duplicate fetchFiles() on mount because both the visibility effect and the
hasUncommitted effect run once after first render; change the hasUncommitted
effect to avoid running on initial mount by gating it with a mounted flag and
visible check (e.g., use a ref like mountedRef and set it after the first
render), or remove the second effect and instead trigger a best-effort refresh
from the primary effect when worktree.hasUncommitted transitions; ensure the
effect references fetchFiles, visible, and worktree.hasUncommitted and only
calls fetchFiles() when mountedRef.current && visible to prevent the duplicate
request.
In `@apps/web-app/src/types.ts`:
- Around line 349-370: The three duplicated interfaces (DiffFileInfo,
DiffListResponse, DiffFileContentResponse) should be removed from this file and
imported from the shared worktree-types module instead; replace the local
interface definitions with a single import like import { DiffFileInfo,
DiffListResponse, DiffFileContentResponse } from the shared worktree-types
module, update any local references to use the imported types, and ensure
exports remain consistent so the app uses the shared API contract rather than a
copy.
In `@docs/FRONTEND.md`:
- Around line 254-260: Add a concise user-facing summary of the FRONTEND.md
changes into README.md: mention the new "Changes" tab and the updated Tab bar
agent quick-actions (+ Claude, + Codex, + Gemini, + OpenCode) with restore-first
behavior for Claude/Codex, the Git action toolbar (Commit/Push/PR inline forms),
LogsViewer, TerminalView session/reattach behavior (scoped sessions, serialized
terminal-state snapshot, explicit launch intent semantics), HooksTab realtime
hook UI, DiffViewerTab with Monaco diff editors and lazy loading, and the
Recover Task action for LOCAL-* worktrees; keep it short, link to
docs/FRONTEND.md for full details, and add the repo guideline note "When
adding/changing user-facing features, update README.md."
In `@libs/shared/src/worktree-types.ts`:
- Around line 223-246: Remove the duplicated type definitions for DiffFileInfo,
DiffListResponse, and DiffFileContentResponse from apps/web-app/src/types.ts and
replace them with imports from the shared library; specifically, delete the
local interfaces named DiffFileInfo, DiffListResponse, and
DiffFileContentResponse and add an import that brings those types from
libs/shared (the module that exports the same interfaces in worktree-types.ts),
then update any local references to use the imported types to keep a single
source of truth.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3f48418f-c64f-4c72-bc57-ccbbfe1eae15
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (23)
apps/server/src/__test__/git-diff.test.tsapps/server/src/routes/github.tsapps/web-app/package.jsonapps/web-app/src/components/WorktreeItem.tsxapps/web-app/src/components/detail/DetailHeader.tsxapps/web-app/src/components/detail/DetailPanel.test.tsxapps/web-app/src/components/detail/DetailPanel.tsxapps/web-app/src/components/detail/DiffFileSection.tsxapps/web-app/src/components/detail/DiffFileSidebar.tsxapps/web-app/src/components/detail/DiffMonacoEditor.tsxapps/web-app/src/components/detail/DiffViewerTab.tsxapps/web-app/src/components/detail/__test__/DiffFileSection.test.tsxapps/web-app/src/components/detail/__test__/DiffFileSidebar.test.tsxapps/web-app/src/components/detail/__test__/DiffViewerTab.test.tsxapps/web-app/src/components/detail/diff-constants.tsapps/web-app/src/hooks/api.tsapps/web-app/src/main.tsxapps/web-app/src/monaco-setup.tsapps/web-app/src/types.tsdocs/API.mddocs/FRONTEND.mdlibs/integrations/src/github/git-diff.tslibs/shared/src/worktree-types.ts
| "@vitejs/plugin-react": "^5.1.4", | ||
| "happy-dom": "^20.8.3", | ||
| "hono": "^4.12.3", | ||
| "monaco-editor": "^0.55.1", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n --glob '*.{ts,tsx}' 'monaco-editor|@monaco-editor/react' apps/web-app/src
python - <<'PY'
import json
from pathlib import Path
pkg = json.loads(Path("apps/web-app/package.json").read_text())
print({
"dependencies.monaco-editor": pkg.get("dependencies", {}).get("monaco-editor"),
"devDependencies.monaco-editor": pkg.get("devDependencies", {}).get("monaco-editor"),
})
PYRepository: fum4/openkit
Length of output: 2081
🏁 Script executed:
# Find where monaco-setup.ts is imported
rg -n 'monaco-setup' apps/web-app/src
# Check vite configuration
find apps/web-app -name 'vite.config.*' -o -name 'tsconfig.json' | head -5 | xargs cat -n
# Check if there are any build scripts that prune devDependencies
rg -n 'devDependencies|prune' apps/web-app/package.jsonRepository: fum4/openkit
Length of output: 3328
🏁 Script executed:
# Check for CI/build workflows that might prune devDependencies
find . -name "*.yml" -o -name "*.yaml" | grep -E "(github|gitlab|build|ci|deploy)" | head -10
# Check Dockerfile if exists
find . -name "Dockerfile*" | head -5
# Check package.json build scripts
rg -A 5 '"scripts"' apps/web-app/package.json
# Check root package.json for build/deploy patterns
rg -A 10 '"scripts"' package.json | head -30Repository: fum4/openkit
Length of output: 1213
🏁 Script executed:
# Check the build workflow for dependency pruning patterns
cat .github/workflows/build.yml
# Check package release workflow
cat .github/workflows/package-release.yml | head -100Repository: fum4/openkit
Length of output: 5222
🏁 Script executed:
# Check the setup-deps action to understand how dependencies are installed
cat .github/actions/setup-deps/action.yml
# Also check if there's any nx or other tool that might affect dependency handling
rg -n 'prod|production|--only' .github/workflows/ || echo "No production-only patterns found"Repository: fum4/openkit
Length of output: 1832
Move monaco-editor to dependencies—it's a runtime import, not dev-only.
apps/web-app/src/monaco-setup.ts directly imports monaco-editor at the app's entry point (main.tsx). While this codebase's CI installs all dependencies (so the current setup works there), placing runtime dependencies in devDependencies violates package.json semantics and will break:
- Local installs with
pnpm install --prod - Any deployment using production-only install strategies
- Developers copying this pattern to other projects
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/package.json` at line 49, The package.json currently lists
"monaco-editor" as a devDependency but it is imported at runtime from
apps/web-app/src/monaco-setup.ts (via the app entry point main.tsx), so move
"monaco-editor" from devDependencies to dependencies in package.json; update the
package.json dependencies block to include the same version string (e.g.,
"^0.55.1"), remove it from devDependencies, and re-run install to ensure
lockfiles are updated so production installs (pnpm install --prod or CI/CD) will
include monaco-editor.
| keepCurrentOriginalModel | ||
| keepCurrentModifiedModel |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
What do keepCurrentOriginalModelandkeepCurrentModifiedModeldo in@monaco-editor/react DiffEditor? Do they keep Monaco models alive after the component unmounts?
💡 Result:
In @monaco-editor/react’s DiffEditor, these props control whether the Monaco ITextModels for each side of the diff are disposed when the React component unmounts:
keepCurrentOriginalModel: iftrue, the original (left) model is notdispose()’d on unmount; iffalse(default), it is disposed. [1][2]keepCurrentModifiedModel: iftrue, the modified (right) model is notdispose()’d on unmount; iffalse(default), it is disposed. [1][2]
So yes: they can keep the Monaco models alive after the component unmounts—but the diff editor instance itself is still disposed; only the selected model(s) are spared from model.dispose() and will remain in Monaco until you dispose them yourself (or reuse them via model paths). [1]
🏁 Script executed:
cd /repo && fd -t f "DiffMonacoEditor.tsx" --exec wc -l {}Repository: fum4/openkit
Length of output: 111
🏁 Script executed:
cd /repo && cat -n apps/web-app/src/components/detail/DiffMonacoEditor.tsx | head -130 | tail -30Repository: fum4/openkit
Length of output: 111
🏁 Script executed:
cd /repo && fd -t f "DiffFileSection.tsx" --exec wc -l {}Repository: fum4/openkit
Length of output: 111
🏁 Script executed:
cd /repo && rg -A 5 -B 5 "DiffMonacoEditor" apps/web-app/src/components/detail/DiffFileSection.tsxRepository: fum4/openkit
Length of output: 111
🏁 Script executed:
fd -t f "DiffMonacoEditor.tsx"Repository: fum4/openkit
Length of output: 111
🏁 Script executed:
wc -l apps/web-app/src/components/detail/DiffMonacoEditor.tsxRepository: fum4/openkit
Length of output: 115
🏁 Script executed:
cat -n apps/web-app/src/components/detail/DiffMonacoEditor.tsx | sed -n '100,130p'Repository: fum4/openkit
Length of output: 1227
🏁 Script executed:
fd -t f "DiffFileSection.tsx"Repository: fum4/openkit
Length of output: 110
🏁 Script executed:
wc -l apps/web-app/src/components/detail/DiffFileSection.tsxRepository: fum4/openkit
Length of output: 114
🏁 Script executed:
cat -n apps/web-app/src/components/detail/DiffFileSection.tsxRepository: fum4/openkit
Length of output: 6206
🏁 Script executed:
rg "DiffMonacoEditor|keepCurrentOriginalModel|keepCurrentModifiedModel" apps/web-app/src/components/detail/ -B 2 -A 2Repository: fum4/openkit
Length of output: 3857
🏁 Script executed:
cat -n apps/web-app/src/components/detail/DiffMonacoEditor.tsx | head -50Repository: fum4/openkit
Length of output: 1621
🏁 Script executed:
cat -n apps/web-app/src/components/detail/DiffMonacoEditor.tsxRepository: fum4/openkit
Length of output: 5519
🏁 Script executed:
rg "modelPath|dispose|originalModelPath|modifiedModelPath" apps/web-app/src/components/detail/DiffMonacoEditor.tsxRepository: fum4/openkit
Length of output: 38
🏁 Script executed:
rg "keepCurrent" apps/web-app/src/ -B 3 -A 3Repository: fum4/openkit
Length of output: 752
🏁 Script executed:
git log --oneline -n 20 -- apps/web-app/src/components/detail/DiffMonacoEditor.tsx 2>/dev/null || echo "Git log not available"Repository: fum4/openkit
Length of output: 131
Remove keepCurrentOriginalModel and keepCurrentModifiedModel flags to prevent model orphaning.
These flags prevent Monaco ITextModels from being disposed when the component unmounts. Since DiffFileSection unmounts editors on collapse and DiffMonacoEditor passes content as strings (not model paths for reuse), each collapse cycle leaves models resident in Monaco's memory. Repeated expand/collapse cycles accumulate orphaned models, causing a memory leak.
Suggested change
- keepCurrentOriginalModel
- keepCurrentModifiedModel📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| keepCurrentOriginalModel | |
| keepCurrentModifiedModel |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 114 -
115, The two flags keepCurrentOriginalModel and keepCurrentModifiedModel in
DiffMonacoEditor prevent Monaco ITextModel instances from being disposed and are
causing orphaned models on repeated mount/unmount (e.g., when DiffFileSection
collapses); remove these flags (or set them to false) from the Monaco diff
editor options passed by DiffMonacoEditor and ensure any models created by
DiffMonacoEditor are explicitly disposed in the component's cleanup (useEffect
return or componentWillUnmount) so models are not retained in Monaco's global
model registry.
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (3)
apps/web-app/src/components/detail/DiffMonacoEditor.tsx (1)
75-88: Consider deriving diff highlight colors frompalettetokens.Several Monaco theme colors use ad-hoc hex values (e.g.,
#22543d25,#74202025) rather than deriving from the sharedpalette. While functional, this creates maintenance overhead if the color scheme changes.You could compute these as alpha-adjusted variants of
palette.greenandpalette.red, or extendpalettewith diff-specific tokens likediffInsertedBg/diffRemovedBg.As per coding guidelines: "Always use the standard shared color palette and tokens from apps/web-app/src/theme.ts; do not introduce ad-hoc lighter/darker variants."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 75 - 88, DiffMonacoEditor.tsx is using hard-coded hex colors for Monaco diff tokens (e.g., "diffEditor.insertedTextBackground", "diffEditor.removedTextBackground"); replace those ad-hoc values with palette-derived tokens by either adding diff-specific tokens to the shared palette (e.g., diffInsertedBg, diffRemovedBg, diffInsertedGutter, diffRemovedGutter) in apps/web-app/src/theme.ts or compute alpha variants from existing palette.green / palette.red and use those tokens in the theme object inside DiffMonacoEditor.tsx; update the theme keys ("diffEditor.insertedTextBackground", "diffEditor.removedTextBackground", "diffEditorGutter.insertedLineBackground", etc.) to reference the new palette tokens instead of literal hex strings so the diff highlights follow the shared color scheme.apps/web-app/src/components/detail/DetailPanel.tsx (1)
416-422: Consider movingAGENT_TABSoutside the component.
AGENT_TABSis a constant Set that gets recreated on every render. Moving it to module scope would avoid the small allocation overhead.♻️ Suggested refactor
+const AGENT_TABS = new Set<WorktreeTab>(["claude", "codex", "gemini", "opencode"]); + export function DetailPanel({ // ... }) { // ... - const AGENT_TABS = new Set<WorktreeTab>(["claude", "codex", "gemini", "opencode"]); const agentTabOpenSets: Record<string, Set<string>> = {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DetailPanel.tsx` around lines 416 - 422, AGENT_TABS is being recreated on every render inside the DetailPanel component; move the declaration of AGENT_TABS to module scope (top-level of the file) so it is allocated once, and leave agentTabOpenSets and other per-render values inside the component; update any imports/exports or references if necessary to reference the top-level constant AGENT_TABS instead of a local variable within the DetailPanel function.apps/server/src/routes/github.ts (1)
339-346: Consider validatingoldPathis provided whenstatus === "renamed".For renamed files,
oldPathis needed to show the correct original content. If omitted,getFileContentfalls back tofilePathwhich may produce incorrect diffs. While the frontend should always provideoldPathfor renames, server-side validation would be defensive.🛡️ Suggested validation
if (!validStatuses.has(rawStatus)) { return c.json( { success: false, oldContent: "", newContent: "", error: `Invalid status: ${rawStatus}` }, 400, ); } const fileStatus = rawStatus as DiffFileInfo["status"]; const oldPath = c.req.query("oldPath") || undefined; + if (fileStatus === "renamed" && !oldPath) { + return c.json( + { success: false, oldContent: "", newContent: "", error: "oldPath is required for renamed files" }, + 400, + ); + } const resolved = manager.resolveWorktree(id);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/server/src/routes/github.ts` around lines 339 - 346, When handling file status, ensure that if fileStatus (derived from rawStatus) equals "renamed", the request includes a non-empty oldPath; if oldPath is missing or empty return a 400 JSON error (same shape used elsewhere) explaining that oldPath is required for renamed files. Update the block around rawStatus/fileStatus/oldPath (references: rawStatus, fileStatus, oldPath, DiffFileInfo, and getFileContent) to perform this validation before calling getFileContent so the server doesn't fall back to filePath for renames.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web-app/src/components/detail/DetailPanel.tsx`:
- Around line 424-438: The catch blocks in resolveTab (and similarly in
setActiveTab) silently swallow localStorage errors; update them to log the
caught error using the app's logger (e.g., log.error or console.error) and
include contextual text (like "failed reading openkit:detail-tab" or "failed
writing openkit:detail-tab") so failures show up in logs; keep the existing
fallback behavior (return "changes" or default tab) after logging, and reference
resolveTab, setActiveTab, AGENT_TABS and agentTabOpenSets when making the
changes.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx`:
- Around line 67-106: The handleMount callback closes over props like onReady
but currently has an empty dependency array, causing a stale closure; update the
useCallback dependency list to include onReady (and any other external values
used inside such as setEditorHeight, palette/OPENKIT_THEME if they come from
props/context, and themeRegistered if mutable) so the latest onReady is called;
ensure dependencies reflect all referenced symbols (handleMount uses editor,
monaco, onReady, setEditorHeight, themeRegistered, OPENKIT_THEME) and keep the
function body unchanged otherwise.
In `@apps/web-app/src/components/detail/DiffViewerTab.tsx`:
- Around line 80-85: When res.error exists but res.files is non-empty (partial
failure) we currently only call log.warn; instead call the project's
user-visible toast helper (e.g., showPersistentErrorToast or
reportPersistentErrorToast) to surface the error while still rendering files. In
the DiffViewerTab component, update the branch that now does log.warn("Partial
diff error", { domain: "diff", error: res.error }) to also invoke
showPersistentErrorToast(res.error) (or reportPersistentErrorToast with a
descriptive message and error), keeping setError only for the fully-failed
branch where res.files.length === 0; preserve the existing warning log in
addition to the toast so debugging info is retained.
In `@libs/integrations/src/github/git-diff.ts`:
- Around line 139-147: The catch block inside the loop over filePaths currently
swallows read errors and sets counts to 0; update the catch to log a warning
with the filePath and the caught error (e.g., logger.warn or log.warn) before
setting result.set(filePath, 0) so failures from readFile(join(worktreePath,
filePath), "utf-8") are visible; reference the variables filePaths, readFile,
worktreePath and result to locate the loop and ensure the logged message
includes both the path and error details for debugging.
---
Nitpick comments:
In `@apps/server/src/routes/github.ts`:
- Around line 339-346: When handling file status, ensure that if fileStatus
(derived from rawStatus) equals "renamed", the request includes a non-empty
oldPath; if oldPath is missing or empty return a 400 JSON error (same shape used
elsewhere) explaining that oldPath is required for renamed files. Update the
block around rawStatus/fileStatus/oldPath (references: rawStatus, fileStatus,
oldPath, DiffFileInfo, and getFileContent) to perform this validation before
calling getFileContent so the server doesn't fall back to filePath for renames.
In `@apps/web-app/src/components/detail/DetailPanel.tsx`:
- Around line 416-422: AGENT_TABS is being recreated on every render inside the
DetailPanel component; move the declaration of AGENT_TABS to module scope
(top-level of the file) so it is allocated once, and leave agentTabOpenSets and
other per-render values inside the component; update any imports/exports or
references if necessary to reference the top-level constant AGENT_TABS instead
of a local variable within the DetailPanel function.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx`:
- Around line 75-88: DiffMonacoEditor.tsx is using hard-coded hex colors for
Monaco diff tokens (e.g., "diffEditor.insertedTextBackground",
"diffEditor.removedTextBackground"); replace those ad-hoc values with
palette-derived tokens by either adding diff-specific tokens to the shared
palette (e.g., diffInsertedBg, diffRemovedBg, diffInsertedGutter,
diffRemovedGutter) in apps/web-app/src/theme.ts or compute alpha variants from
existing palette.green / palette.red and use those tokens in the theme object
inside DiffMonacoEditor.tsx; update the theme keys
("diffEditor.insertedTextBackground", "diffEditor.removedTextBackground",
"diffEditorGutter.insertedLineBackground", etc.) to reference the new palette
tokens instead of literal hex strings so the diff highlights follow the shared
color scheme.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e3abd18e-fb15-4039-8ced-5e00f9ca203c
📒 Files selected for processing (10)
apps/server/src/__test__/git-diff.test.tsapps/server/src/routes/github.tsapps/web-app/src/components/detail/DetailPanel.tsxapps/web-app/src/components/detail/DiffFileSection.tsxapps/web-app/src/components/detail/DiffMonacoEditor.tsxapps/web-app/src/components/detail/DiffViewerTab.tsxapps/web-app/src/components/detail/__test__/DiffFileSection.test.tsxapps/web-app/src/main.tsxapps/web-app/src/types.tslibs/integrations/src/github/git-diff.ts
✅ Files skipped from review due to trivial changes (2)
- apps/web-app/src/main.tsx
- apps/server/src/test/git-diff.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- apps/web-app/src/components/detail/test/DiffFileSection.test.tsx
- apps/web-app/src/components/detail/DiffFileSection.tsx
| const resolveTab = (tab: WorktreeTab | undefined, wId: string): WorktreeTab => { | ||
| if (!tab) { | ||
| // Try persisted preference | ||
| try { | ||
| const stored = localStorage.getItem("openkit:detail-tab") as WorktreeTab | null; | ||
| if (stored && !AGENT_TABS.has(stored)) return stored; | ||
| } catch {} | ||
| return "changes"; | ||
| } | ||
| // If the stored tab is an agent tab, check if it's open for this worktree | ||
| if (AGENT_TABS.has(tab) && !agentTabOpenSets[tab]?.has(wId)) { | ||
| return "changes"; | ||
| } | ||
| return tab; | ||
| }; |
There was a problem hiding this comment.
Silent catch {} blocks should log errors.
The try/catch at lines 427-430 and 456-460 silently swallow localStorage errors. Per coding guidelines, every catch block should do something meaningful.
🔧 Suggested fix
const resolveTab = (tab: WorktreeTab | undefined, wId: string): WorktreeTab => {
if (!tab) {
// Try persisted preference
try {
const stored = localStorage.getItem("openkit:detail-tab") as WorktreeTab | null;
if (stored && !AGENT_TABS.has(stored)) return stored;
- } catch {}
+ } catch (err) {
+ log.warn("Failed to read detail-tab from localStorage", { domain: "detail-panel", error: err });
+ }
return "changes";
}And similarly for setActiveTab:
if (!AGENT_TABS.has(tab)) {
try {
localStorage.setItem("openkit:detail-tab", tab);
- } catch {}
+ } catch (err) {
+ log.warn("Failed to persist detail-tab to localStorage", { domain: "detail-panel", error: err });
+ }
}As per coding guidelines: "**/*.{ts,tsx,js,jsx}: Treat error handling as a first-class concern. Every catch block... must do something meaningful: log through logger (log.error()/log.warn())."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const resolveTab = (tab: WorktreeTab | undefined, wId: string): WorktreeTab => { | |
| if (!tab) { | |
| // Try persisted preference | |
| try { | |
| const stored = localStorage.getItem("openkit:detail-tab") as WorktreeTab | null; | |
| if (stored && !AGENT_TABS.has(stored)) return stored; | |
| } catch {} | |
| return "changes"; | |
| } | |
| // If the stored tab is an agent tab, check if it's open for this worktree | |
| if (AGENT_TABS.has(tab) && !agentTabOpenSets[tab]?.has(wId)) { | |
| return "changes"; | |
| } | |
| return tab; | |
| }; | |
| const resolveTab = (tab: WorktreeTab | undefined, wId: string): WorktreeTab => { | |
| if (!tab) { | |
| // Try persisted preference | |
| try { | |
| const stored = localStorage.getItem("openkit:detail-tab") as WorktreeTab | null; | |
| if (stored && !AGENT_TABS.has(stored)) return stored; | |
| } catch (err) { | |
| log.warn("Failed to read detail-tab from localStorage", { domain: "detail-panel", error: err }); | |
| } | |
| return "changes"; | |
| } | |
| // If the stored tab is an agent tab, check if it's open for this worktree | |
| if (AGENT_TABS.has(tab) && !agentTabOpenSets[tab]?.has(wId)) { | |
| return "changes"; | |
| } | |
| return tab; | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DetailPanel.tsx` around lines 424 - 438,
The catch blocks in resolveTab (and similarly in setActiveTab) silently swallow
localStorage errors; update them to log the caught error using the app's logger
(e.g., log.error or console.error) and include contextual text (like "failed
reading openkit:detail-tab" or "failed writing openkit:detail-tab") so failures
show up in logs; keep the existing fallback behavior (return "changes" or
default tab) after logging, and reference resolveTab, setActiveTab, AGENT_TABS
and agentTabOpenSets when making the changes.
| const handleMount: DiffOnMount = useCallback((editor, monaco) => { | ||
| if (!themeRegistered) { | ||
| monaco.editor.defineTheme(OPENKIT_THEME, { | ||
| base: "vs-dark", | ||
| inherit: true, | ||
| rules: [], | ||
| colors: { | ||
| "editor.background": palette.bg1, | ||
| "diffEditor.insertedTextBackground": "#22543d25", | ||
| "diffEditor.insertedLineBackground": "#22543d18", | ||
| "diffEditor.removedTextBackground": "#74202025", | ||
| "diffEditor.removedLineBackground": "#74202018", | ||
| "diffEditorGutter.insertedLineBackground": "#22543d35", | ||
| "diffEditorGutter.removedLineBackground": "#74202035", | ||
| "diffEditorOverview.insertedForeground": "#34d39960", | ||
| "diffEditorOverview.removedForeground": "#f8717160", | ||
| "editorLineNumber.foreground": palette.text2, | ||
| "editor.lineHighlightBackground": "#00000000", | ||
| "editorOverviewRuler.addedForeground": "#34d39950", | ||
| "editorOverviewRuler.deletedForeground": "#f8717150", | ||
| "editorOverviewRuler.modifiedForeground": "#fbbf2450", | ||
| }, | ||
| }); | ||
| themeRegistered = true; | ||
| } | ||
| monaco.editor.setTheme(OPENKIT_THEME); | ||
|
|
||
| const updateHeight = () => { | ||
| const modifiedHeight = editor.getModifiedEditor().getContentHeight(); | ||
| const originalHeight = editor.getOriginalEditor().getContentHeight(); | ||
| const contentHeight = Math.max(Math.max(modifiedHeight, originalHeight), MIN_EDITOR_HEIGHT); | ||
| setEditorHeight(contentHeight); | ||
| }; | ||
|
|
||
| // Give Monaco a tick to compute the diff and measure content, then show | ||
| setTimeout(() => { | ||
| updateHeight(); | ||
| onReady?.(); | ||
| }); | ||
| }, []); |
There was a problem hiding this comment.
Missing onReady in useCallback dependency array causes stale closure.
The handleMount callback references onReady from props but has an empty dependency array. If the parent re-renders with a different onReady callback, the stale version will be invoked.
🔧 Proposed fix
- }, []);
+ }, [onReady]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 67 -
106, The handleMount callback closes over props like onReady but currently has
an empty dependency array, causing a stale closure; update the useCallback
dependency list to include onReady (and any other external values used inside
such as setEditorHeight, palette/OPENKIT_THEME if they come from props/context,
and themeRegistered if mutable) so the latest onReady is called; ensure
dependencies reflect all referenced symbols (handleMount uses editor, monaco,
onReady, setEditorHeight, themeRegistered, OPENKIT_THEME) and keep the function
body unchanged otherwise.
| // Surface partial/full errors from git operations | ||
| if (res.error && res.files.length === 0) { | ||
| setError(res.error); | ||
| } else if (res.error) { | ||
| log.warn("Partial diff error", { domain: "diff", error: res.error }); | ||
| } |
There was a problem hiding this comment.
Surface partial errors to the user via toast notification.
When res.error exists but files are returned (partial failure), the error is only logged. Per coding guidelines, user-facing errors should be surfaced through toast notifications. Consider importing and using showPersistentErrorToast or reportPersistentErrorToast to notify the user while still rendering the available files.
🔧 Suggested fix
+import { reportPersistentErrorToast } from "../../hooks/useErrorToast";
// ...
// Surface partial/full errors from git operations
if (res.error && res.files.length === 0) {
setError(res.error);
} else if (res.error) {
log.warn("Partial diff error", { domain: "diff", error: res.error });
+ reportPersistentErrorToast(res.error, "diff-partial");
}As per coding guidelines: "apps/web-app/src/**/*.{ts,tsx}: Always surface user-facing errors through toast notifications (showPersistentErrorToast/reportPersistentErrorToast); never use silent catch {} blocks."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffViewerTab.tsx` around lines 80 - 85,
When res.error exists but res.files is non-empty (partial failure) we currently
only call log.warn; instead call the project's user-visible toast helper (e.g.,
showPersistentErrorToast or reportPersistentErrorToast) to surface the error
while still rendering files. In the DiffViewerTab component, update the branch
that now does log.warn("Partial diff error", { domain: "diff", error: res.error
}) to also invoke showPersistentErrorToast(res.error) (or
reportPersistentErrorToast with a descriptive message and error), keeping
setError only for the fully-failed branch where res.files.length === 0; preserve
the existing warning log in addition to the toast so debugging info is retained.
| for (const filePath of filePaths) { | ||
| try { | ||
| const content = await readFile(join(worktreePath, filePath), "utf-8"); | ||
| const count = content.split("\n").length; | ||
| result.set(filePath, count); | ||
| } catch { | ||
| result.set(filePath, 0); | ||
| } | ||
| } |
There was a problem hiding this comment.
Log errors when counting untracked file lines.
The catch block silently sets the count to 0, hiding potential read errors for untracked files. Consider logging a warning.
🔧 Suggested fix
try {
const content = await readFile(join(worktreePath, filePath), "utf-8");
const count = content.split("\n").length;
result.set(filePath, count);
} catch (err) {
+ log.warn("Failed to count lines in untracked file", {
+ domain: "diff",
+ filePath,
+ error: err,
+ });
result.set(filePath, 0);
}As per coding guidelines: "**/*.{ts,tsx,js,jsx}: Every catch block... must do something meaningful: log through logger (log.error()/log.warn())."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@libs/integrations/src/github/git-diff.ts` around lines 139 - 147, The catch
block inside the loop over filePaths currently swallows read errors and sets
counts to 0; update the catch to log a warning with the filePath and the caught
error (e.g., logger.warn or log.warn) before setting result.set(filePath, 0) so
failures from readFile(join(worktreePath, filePath), "utf-8") are visible;
reference the variables filePaths, readFile, worktreePath and result to locate
the loop and ensure the logged message includes both the path and error details
for debugging.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web-app/src/components/detail/DiffFileSection.tsx`:
- Around line 105-109: The component is using ad-hoc hex color classes (e.g.
text-[`#6b7280`], text-[`#9ca3af`], text-red-400) which bypass the shared palette;
update the JSX around Loader2, Chevron, the filename <span> and the other
occurrences noted (around lines 118 and 136-140) to use the standard shared
color tokens exported from theme.ts instead of hard-coded hex Tailwind classes —
replace the hex classes on the Loader2 and Chevron wrappers and the span showing
file.path (and the red error class) with the corresponding theme token utility
classes or mapped token names from apps/web-app/src/theme.ts so styling uses the
centralized palette.
- Around line 64-85: The fetch failure branches in DiffFileSection (the
res.success === false branch and the catch block) only log and set local error
state; update both to also call the user-facing persistent toast API
(showPersistentErrorToast or reportPersistentErrorToast) with a clear message
and the error object so users see persistent notifications; keep the existing
log.error and setError calls, include file.path and error details when invoking
the toast, and ensure the toast is invoked in both the failed-response branch
and the .catch handler (where msg and err are available).
- Around line 62-85: The early return inside the .then handler leaves
fetchingRef.current set to true which blocks future retries; update the .then
branch in doFetch so fetchingRef.current is reset (to false) in both the
!res.success case and the success path before returning/after setContent,
ensuring fetchingRef (used by doFetch/fetchingRef) is cleared regardless of
result; also ensure the .catch already clears fetchingRef.current (it does) so
behavior is consistent across success, failure, and error paths.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f7ff510c-adbd-4c7f-8ffa-19cee1e4217b
📒 Files selected for processing (1)
apps/web-app/src/components/detail/DiffFileSection.tsx
| .then((res) => { | ||
| setLoading(false); | ||
| if (!res.success) { | ||
| log.error("Failed to fetch file content", { | ||
| domain: "diff", | ||
| filePath: file.path, | ||
| error: res.error, | ||
| }); | ||
| setError(res.error ?? "Failed to load file content"); | ||
| return; | ||
| } | ||
| setContent({ oldContent: res.oldContent, newContent: res.newContent }); | ||
| }) | ||
| .catch((err) => { | ||
| setLoading(false); | ||
| fetchingRef.current = false; | ||
| const msg = err instanceof Error ? err.message : "Failed to load file content"; | ||
| log.error("Failed to fetch file content", { | ||
| domain: "diff", | ||
| filePath: file.path, | ||
| error: err, | ||
| }); | ||
| setError(msg); | ||
| }); |
There was a problem hiding this comment.
Reset fetchingRef after resolved requests to preserve retry behavior.
On Line 64 (!res.success) the function returns without clearing fetchingRef.current, so future doFetch() calls are blocked until external invalidation.
Suggested fix
fetchDiffFileContent(
worktreeId,
file.path,
file.status,
includeCommitted,
file.oldPath,
serverUrl,
)
.then((res) => {
- setLoading(false);
if (!res.success) {
log.error("Failed to fetch file content", {
domain: "diff",
filePath: file.path,
error: res.error,
});
setError(res.error ?? "Failed to load file content");
return;
}
setContent({ oldContent: res.oldContent, newContent: res.newContent });
})
.catch((err) => {
- setLoading(false);
- fetchingRef.current = false;
const msg = err instanceof Error ? err.message : "Failed to load file content";
log.error("Failed to fetch file content", {
domain: "diff",
filePath: file.path,
error: err,
});
setError(msg);
- });
+ })
+ .finally(() => {
+ setLoading(false);
+ fetchingRef.current = false;
+ });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 62 - 85,
The early return inside the .then handler leaves fetchingRef.current set to true
which blocks future retries; update the .then branch in doFetch so
fetchingRef.current is reset (to false) in both the !res.success case and the
success path before returning/after setContent, ensuring fetchingRef (used by
doFetch/fetchingRef) is cleared regardless of result; also ensure the .catch
already clears fetchingRef.current (it does) so behavior is consistent across
success, failure, and error paths.
| if (!res.success) { | ||
| log.error("Failed to fetch file content", { | ||
| domain: "diff", | ||
| filePath: file.path, | ||
| error: res.error, | ||
| }); | ||
| setError(res.error ?? "Failed to load file content"); | ||
| return; | ||
| } | ||
| setContent({ oldContent: res.oldContent, newContent: res.newContent }); | ||
| }) | ||
| .catch((err) => { | ||
| setLoading(false); | ||
| fetchingRef.current = false; | ||
| const msg = err instanceof Error ? err.message : "Failed to load file content"; | ||
| log.error("Failed to fetch file content", { | ||
| domain: "diff", | ||
| filePath: file.path, | ||
| error: err, | ||
| }); | ||
| setError(msg); | ||
| }); |
There was a problem hiding this comment.
Surface fetch failures with persistent toasts, not only inline text.
Lines 64-71 and 75-85 log and set local error state, but they do not trigger the required user-facing persistent toast (showPersistentErrorToast/reportPersistentErrorToast). As per coding guidelines, apps/web-app/src/**/*.{ts,tsx}: "Always surface user-facing errors through toast notifications (showPersistentErrorToast/reportPersistentErrorToast); never use silent catch {} blocks".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 64 - 85,
The fetch failure branches in DiffFileSection (the res.success === false branch
and the catch block) only log and set local error state; update both to also
call the user-facing persistent toast API (showPersistentErrorToast or
reportPersistentErrorToast) with a clear message and the error object so users
see persistent notifications; keep the existing log.error and setError calls,
include file.path and error details when invoking the toast, and ensure the
toast is invoked in both the failed-response branch and the .catch handler
(where msg and err are available).
| <Loader2 className="w-3.5 h-3.5 text-[#6b7280] animate-spin flex-shrink-0" /> | ||
| ) : ( | ||
| <Chevron className="w-3.5 h-3.5 text-[#6b7280] flex-shrink-0" /> | ||
| )} | ||
| <span className="text-[11px] text-[#9ca3af] truncate text-left">{file.path}</span> |
There was a problem hiding this comment.
Replace ad-hoc color literals with shared theme tokens.
Hard-coded colors (text-[#6b7280], text-[#9ca3af], text-red-400) bypass the shared palette and make styling inconsistent with app theming. As per coding guidelines, apps/web-app/src/**/*.{ts,tsx}: "Always use the standard shared color palette and tokens from apps/web-app/src/theme.ts; do not introduce ad-hoc lighter/darker variants".
Also applies to: 118-118, 136-140
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 105 -
109, The component is using ad-hoc hex color classes (e.g. text-[`#6b7280`],
text-[`#9ca3af`], text-red-400) which bypass the shared palette; update the JSX
around Loader2, Chevron, the filename <span> and the other occurrences noted
(around lines 118 and 136-140) to use the standard shared color tokens exported
from theme.ts instead of hard-coded hex Tailwind classes — replace the hex
classes on the Loader2 and Chevron wrappers and the span showing file.path (and
the red error class) with the corresponding theme token utility classes or
mapped token names from apps/web-app/src/theme.ts so styling uses the
centralized palette.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (5)
apps/web-app/src/components/detail/DiffFileSection.tsx (3)
62-74:⚠️ Potential issue | 🟠 MajorReset
fetchingRef.currentfor all resolved outcomes.
fetchingRef.currentis set totruebefore fetch, but never reset in the.thenbranch. On!res.success, retries are blocked until external invalidation.Suggested change
fetchDiffFileContent( worktreeId, file.path, file.status, includeCommitted, file.oldPath, serverUrl, ) .then((res) => { - setLoading(false); if (!res.success) { log.error("Failed to fetch file content", { domain: "diff", filePath: file.path, error: res.error, }); setError(res.error ?? "Failed to load file content"); return; } setContent({ oldContent: res.oldContent, newContent: res.newContent }); }) .catch((err) => { - setLoading(false); - fetchingRef.current = false; const msg = err instanceof Error ? err.message : "Failed to load file content"; log.error("Failed to fetch file content", { domain: "diff", filePath: file.path, error: err, }); setError(msg); - }); + }) + .finally(() => { + setLoading(false); + fetchingRef.current = false; + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 62 - 74, The .then handler never resets fetchingRef.current, so after a failed fetch retries are blocked; update the Promise .then callback in DiffFileSection (the block that calls setLoading(false), log.error, setError, and setContent) to always set fetchingRef.current = false for all outcomes—place fetchingRef.current = false before early returns on !res.success and also after successful setContent so both failure and success paths clear the flag.
64-85:⚠️ Potential issue | 🟠 MajorAlso raise persistent toast notifications for fetch failures.
These branches currently log and render inline error text, but they do not trigger the required persistent user-facing toast.
Based on learnings: "Always surface user-facing errors through toast notifications (showPersistentErrorToast/reportPersistentErrorToast)." and "Errors that surface as toasts must also be logged through the logger—toasts are for users, logs are for debugging. Both are required."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 64 - 85, When a fetch for file content fails (both the non-success branch handling res.success and the catch block), in addition to logging via log.error and calling setError, call the project-standard persistent toast helper (e.g., showPersistentErrorToast or reportPersistentErrorToast) with the same user-facing message; ensure you pass a clear message (use res.error or the derived msg) and keep the existing log.error calls intact (references: setContent, setError, log.error, fetchingRef). This will surface the error to users while preserving current logging/debug behavior.
105-109:⚠️ Potential issue | 🟡 MinorReplace hard-coded text color classes with shared theme tokens.
text-[#6b7280],text-[#9ca3af], andtext-red-400bypass the shared palette.As per coding guidelines: "
apps/web-app/src/**/*.{ts,tsx}: Always use the standard shared color palette and tokens fromapps/web-app/src/theme.ts; do not introduce ad-hoc lighter/darker variants".Also applies to: 118-118, 136-140
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 105 - 109, The component DiffFileSection is using ad-hoc color classes (text-[`#6b7280`], text-[`#9ca3af`], text-red-400) on elements like Loader2, Chevron, and the file path span; replace those hard-coded hex classes with the shared color tokens exported from apps/web-app/src/theme.ts (use the appropriate token names for the muted/secondary text and error color) so the component uses the centralized palette; update all occurrences in DiffFileSection (including the Loader2/Chevron icon classNames and the span displaying file.path) to reference the theme tokens instead of hex values.apps/web-app/src/components/detail/DiffMonacoEditor.tsx (2)
129-130:⚠️ Potential issue | 🟠 MajorAvoid retaining Monaco models unless you explicitly manage disposal.
keepCurrentOriginalModel/keepCurrentModifiedModelkeep models alive after unmount. With collapsible sections, this risks model accumulation across expand/collapse cycles.Suggested change
- keepCurrentOriginalModel - keepCurrentModifiedModel🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 129 - 130, The DiffMonacoEditor is passing keepCurrentOriginalModel and keepCurrentModifiedModel which prevents Monaco models from being disposed when the editor unmounts; remove those props (or set them to false) from the DiffMonacoEditor/monaco DiffEditor instantiation so models are disposed automatically, or if you intentionally want to retain models implement explicit disposal in the component's cleanup (dispose original/modified models in the unmount/effect cleanup where models are created). Target the keepCurrentOriginalModel and keepCurrentModifiedModel usage in the DiffMonacoEditor component and either remove them or replace with an explicit dispose-on-unmount cleanup that calls model.dispose() for the original and modified models.
73-116:⚠️ Potential issue | 🟡 MinorInclude
onReadyinhandleMountdependencies to avoid stale callback.
handleMountcloses overonReadybutuseCallbackuses[], so a newonReadyfrom parent renders won’t be invoked.Suggested change
- }, []); + }, [onReady]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 73 - 116, handleMount is memoized with useCallback([]) but closes over the onReady prop, causing a stale callback; update the dependency array for the handleMount callback to include onReady (and any other external variables it uses that may change) so the latest onReady is called after mount, while keeping references like setEditorHeight or monaco constants only if they can change; specifically adjust the useCallback invocation that defines handleMount to list onReady in its dependencies.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx`:
- Around line 69-71: The useEffect in DiffMonacoEditor currently calls
ensureMonacoConfigured().then(() => setMonacoReady(true)) without handling
rejections; update that effect to handle promise rejection by catching errors
from ensureMonacoConfigured, call the app logger (e.g., log.error or
logger.error) with the caught error and a descriptive message, and surface a
user-facing persistent toast (use showPersistentErrorToast or
reportPersistentErrorToast) with a friendly message so users know Monaco failed
to initialize; keep setMonacoReady(false) or leave it unset on failure and avoid
silent catches.
- Around line 81-94: The Monaco theme in DiffMonacoEditor.tsx uses hard-coded
color literals for keys like "diffEditor.insertedTextBackground",
"diffEditor.removedTextBackground", "diffEditorGutter.insertedLineBackground",
"diffEditorOverview.insertedForeground", "editorOverviewRuler.addedForeground",
etc.; replace these literal hex variants with the appropriate shared
palette/tokens exported from apps/web-app/src/theme.ts (import the theme/palette
used elsewhere in this file) and map each Monaco setting to the nearest semantic
token (e.g., success/green, danger/red, muted/overlay tokens) instead of
introducing ad-hoc shades so the editor colors come from the centralized theme.
---
Duplicate comments:
In `@apps/web-app/src/components/detail/DiffFileSection.tsx`:
- Around line 62-74: The .then handler never resets fetchingRef.current, so
after a failed fetch retries are blocked; update the Promise .then callback in
DiffFileSection (the block that calls setLoading(false), log.error, setError,
and setContent) to always set fetchingRef.current = false for all outcomes—place
fetchingRef.current = false before early returns on !res.success and also after
successful setContent so both failure and success paths clear the flag.
- Around line 64-85: When a fetch for file content fails (both the non-success
branch handling res.success and the catch block), in addition to logging via
log.error and calling setError, call the project-standard persistent toast
helper (e.g., showPersistentErrorToast or reportPersistentErrorToast) with the
same user-facing message; ensure you pass a clear message (use res.error or the
derived msg) and keep the existing log.error calls intact (references:
setContent, setError, log.error, fetchingRef). This will surface the error to
users while preserving current logging/debug behavior.
- Around line 105-109: The component DiffFileSection is using ad-hoc color
classes (text-[`#6b7280`], text-[`#9ca3af`], text-red-400) on elements like Loader2,
Chevron, and the file path span; replace those hard-coded hex classes with the
shared color tokens exported from apps/web-app/src/theme.ts (use the appropriate
token names for the muted/secondary text and error color) so the component uses
the centralized palette; update all occurrences in DiffFileSection (including
the Loader2/Chevron icon classNames and the span displaying file.path) to
reference the theme tokens instead of hex values.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx`:
- Around line 129-130: The DiffMonacoEditor is passing keepCurrentOriginalModel
and keepCurrentModifiedModel which prevents Monaco models from being disposed
when the editor unmounts; remove those props (or set them to false) from the
DiffMonacoEditor/monaco DiffEditor instantiation so models are disposed
automatically, or if you intentionally want to retain models implement explicit
disposal in the component's cleanup (dispose original/modified models in the
unmount/effect cleanup where models are created). Target the
keepCurrentOriginalModel and keepCurrentModifiedModel usage in the
DiffMonacoEditor component and either remove them or replace with an explicit
dispose-on-unmount cleanup that calls model.dispose() for the original and
modified models.
- Around line 73-116: handleMount is memoized with useCallback([]) but closes
over the onReady prop, causing a stale callback; update the dependency array for
the handleMount callback to include onReady (and any other external variables it
uses that may change) so the latest onReady is called after mount, while keeping
references like setEditorHeight or monaco constants only if they can change;
specifically adjust the useCallback invocation that defines handleMount to list
onReady in its dependencies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c1faea87-f38c-4cc3-8f23-8cb8da67968c
📒 Files selected for processing (4)
apps/web-app/src/components/detail/DiffFileSection.tsxapps/web-app/src/components/detail/DiffMonacoEditor.tsxapps/web-app/src/main.tsxapps/web-app/src/monaco-setup.ts
✅ Files skipped from review due to trivial changes (1)
- apps/web-app/src/main.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/web-app/src/monaco-setup.ts
| useEffect(() => { | ||
| ensureMonacoConfigured().then(() => setMonacoReady(true)); | ||
| }, []); |
There was a problem hiding this comment.
Handle Monaco setup failures explicitly.
If ensureMonacoConfigured() rejects, the component stays blank (return null) with no log/toast. Please handle the rejection path and surface it to users (persistent toast) in addition to logging.
As per coding guidelines: "Treat error handling as a first-class concern. Every catch block, fallback branch, and error callback must do something meaningful: log through logger (log.error()/log.warn()) or surface to user via toast." and "Always surface user-facing errors through toast notifications (showPersistentErrorToast/reportPersistentErrorToast); never use silent catch {} blocks".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 69 -
71, The useEffect in DiffMonacoEditor currently calls
ensureMonacoConfigured().then(() => setMonacoReady(true)) without handling
rejections; update that effect to handle promise rejection by catching errors
from ensureMonacoConfigured, call the app logger (e.g., log.error or
logger.error) with the caught error and a descriptive message, and surface a
user-facing persistent toast (use showPersistentErrorToast or
reportPersistentErrorToast) with a friendly message so users know Monaco failed
to initialize; keep setMonacoReady(false) or leave it unset on failure and avoid
silent catches.
| "diffEditor.insertedTextBackground": "#22543d25", | ||
| "diffEditor.insertedLineBackground": "#22543d18", | ||
| "diffEditor.removedTextBackground": "#74202025", | ||
| "diffEditor.removedLineBackground": "#74202018", | ||
| "diffEditorGutter.insertedLineBackground": "#22543d35", | ||
| "diffEditorGutter.removedLineBackground": "#74202035", | ||
| "diffEditorOverview.insertedForeground": "#34d39960", | ||
| "diffEditorOverview.removedForeground": "#f8717160", | ||
| "editorLineNumber.foreground": palette.text2, | ||
| "editor.lineHighlightBackground": "#00000000", | ||
| "editorOverviewRuler.addedForeground": "#34d39950", | ||
| "editorOverviewRuler.deletedForeground": "#f8717150", | ||
| "editorOverviewRuler.modifiedForeground": "#fbbf2450", | ||
| }, |
There was a problem hiding this comment.
Replace ad-hoc Monaco color literals with shared theme tokens.
This theme block introduces several hard-coded color variants (#22543d.., #742020.., etc.) instead of using centralized theme tokens.
As per coding guidelines: "apps/web-app/src/**/*.{ts,tsx}: Always use the standard shared color palette and tokens from apps/web-app/src/theme.ts; do not introduce ad-hoc lighter/darker variants".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 81 -
94, The Monaco theme in DiffMonacoEditor.tsx uses hard-coded color literals for
keys like "diffEditor.insertedTextBackground",
"diffEditor.removedTextBackground", "diffEditorGutter.insertedLineBackground",
"diffEditorOverview.insertedForeground", "editorOverviewRuler.addedForeground",
etc.; replace these literal hex variants with the appropriate shared
palette/tokens exported from apps/web-app/src/theme.ts (import the theme/palette
used elsewhere in this file) and map each Monaco setting to the nearest semantic
token (e.g., success/green, danger/red, muted/overlay tokens) instead of
introducing ad-hoc shades so the editor colors come from the centralized theme.
There was a problem hiding this comment.
♻️ Duplicate comments (6)
apps/web-app/src/components/detail/DiffMonacoEditor.tsx (3)
67-110:⚠️ Potential issue | 🟡 MinorInclude
onReadyinhandleMountdependencies to avoid stale callback capture.
onReadyis referenced inhandleMountbut the dependency list is empty. If parent-provided callback semantics change, Line 108 can call an outdated closure.Suggested change
- }, []); + }, [onReady]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 67 - 110, The handleMount callback captures onReady but has an empty dependency array, risking a stale closure; update the useCallback dependency list for the handleMount function to include onReady (i.e., ensure onReady is referenced in the array passed to useCallback for handleMount) so the most recent parent-provided callback is used when setTimeout calls onReady; adjust dependencies similarly if other external values used inside handleMount change.
75-88:⚠️ Potential issue | 🟡 MinorReplace ad-hoc Monaco color literals with shared theme tokens.
Lines 75-88 define several custom hex variants (
#22543d..,#742020.., etc.) instead of using centralized theme tokens/palette mappings.As per coding guidelines: "apps/web-app/src/**/*.{ts,tsx}: Always use the standard shared color palette and tokens from apps/web-app/src/theme.ts; do not introduce ad-hoc lighter/darker variants."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 75 - 88, Replace the hardcoded Monaco color hex literals in DiffMonacoEditor (the object keys like "diffEditor.insertedTextBackground", "diffEditor.removedLineBackground", "diffEditorGutter.insertedLineBackground", "diffEditorOverview.insertedForeground", etc.) with the shared theme tokens from apps/web-app/src/theme.ts (use the palette/token names used across the app rather than ad‑hoc `#22543d`.. or `#742020`.. variants); update the object to reference those palette properties (e.g., palette.* or token names exposed by theme.ts) and ensure any required alpha/transparency is produced by the shared color helpers or token utilities instead of embedding new hex variants.
121-122:⚠️ Potential issue | 🟠 MajorRemove model-retention flags unless models are explicitly lifecycle-managed.
keepCurrentOriginalModelandkeepCurrentModifiedModelretain Monaco text models after unmount. With collapsible sections remounting editors, this can accumulate orphaned models unless you explicitly reuse/dispose them.Suggested change
- keepCurrentOriginalModel - keepCurrentModifiedModel🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx` around lines 121 - 122, Remove the model-retention flags from the DiffMonacoEditor usage: delete the keepCurrentOriginalModel and keepCurrentModifiedModel props (or set them false) so editors don't implicitly keep models alive; instead, manage model lifecycle explicitly inside the DiffMonacoEditor component (e.g., reuse cached models or call model.dispose() in the component's cleanup/useEffect unmount logic where original/modified models are created), and update any related model-creation helpers in DiffMonacoEditor to ensure models are disposed or reused rather than left orphaned.apps/web-app/src/components/detail/DiffFileSection.tsx (3)
62-85:⚠️ Potential issue | 🟠 MajorReset
fetchingRef.currenton all request outcomes to preserve retry behavior.
fetchingRef.currentis set true at Line 50 but not cleared on successful resolve or!res.successresolve. After one resolved attempt, laterdoFetch()calls are blocked.Suggested change
fetchDiffFileContent( worktreeId, file.path, file.status, includeCommitted, file.oldPath, serverUrl, ) .then((res) => { - setLoading(false); if (!res.success) { log.error("Failed to fetch file content", { domain: "diff", filePath: file.path, error: res.error, }); setError(res.error ?? "Failed to load file content"); return; } setContent({ oldContent: res.oldContent, newContent: res.newContent }); }) .catch((err) => { - setLoading(false); - fetchingRef.current = false; const msg = err instanceof Error ? err.message : "Failed to load file content"; log.error("Failed to fetch file content", { domain: "diff", filePath: file.path, error: err, }); setError(msg); - }); + }) + .finally(() => { + setLoading(false); + fetchingRef.current = false; + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 62 - 85, The code sets fetchingRef.current = true before calling the fetch but only clears it in the catch path, which blocks future doFetch() calls after any resolved promise; update the promise handlers so fetchingRef.current is reset to false on all outcomes: inside the .then handler clear fetchingRef.current before returning on !res.success and again after setting content on success, and ensure the .catch handler still clears it (keep the existing clearing there); reference fetchingRef, doFetch, setLoading, setError, and setContent when making these changes.
64-85:⚠️ Potential issue | 🟠 MajorSurface fetch failures via persistent toast in both failure branches.
Lines 64-71 and 75-85 only log/set inline error. For user-facing operational failures, trigger
showPersistentErrorToast/reportPersistentErrorToastin both branches (while keeping logs).As per coding guidelines: "apps/web-app/src/**/*.{ts,tsx}: Always surface user-facing errors through toast notifications (showPersistentErrorToast/reportPersistentErrorToast); never use silent catch {} blocks."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 64 - 85, When a fetch for file content fails (both the res.success === false branch and the .catch(err) branch) add calls to the user-facing toast helpers (showPersistentErrorToast or reportPersistentErrorToast) in addition to the existing log.error and setError calls: in the res.success false block (where you currently call log.error and setError with res.error) invoke showPersistentErrorToast/reportPersistentErrorToast with a clear message and the error payload (res.error), and in the .catch(err) block (where you compute msg and call log.error/setError) also call the same toast helper with msg or err; keep the existing log.error and setError behavior and ensure you reference the existing symbols (res.error, res.oldContent/res.newContent, setError, log.error, file.path) so the changes are applied to the correct failure handlers.
104-106:⚠️ Potential issue | 🟡 MinorReplace hard-coded text/error color classes with shared theme tokens.
These lines use ad-hoc color classes (
text-[#6b7280],text-[#9ca3af],text-red-400) instead of centralized tokenized styling.As per coding guidelines: "apps/web-app/src/**/*.{ts,tsx}: Always use the standard shared color palette and tokens from apps/web-app/src/theme.ts; do not introduce ad-hoc lighter/darker variants."
Also applies to: 114-114, 132-132, 136-136
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-app/src/components/detail/DiffFileSection.tsx` around lines 104 - 106, Replace ad-hoc hex color classes used in the DiffFileSection component (e.g., the Chevron element with class "text-[`#6b7280`]", the file.path span "text-[`#9ca3af`]", and any "text-red-400" usages at lines referenced) with the shared theme tokens exported from apps/web-app/src/theme.ts; locate the elements in DiffFileSection.tsx (the Chevron JSX, the span showing file.path, and the other spans that show error/changed state) and swap the hard-coded classes for the appropriate tokenized classNames or utility references (import the theme tokens from theme.ts and apply the matching neutral/error token names) so all colors follow the centralized palette.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/web-app/src/components/detail/DiffFileSection.tsx`:
- Around line 62-85: The code sets fetchingRef.current = true before calling the
fetch but only clears it in the catch path, which blocks future doFetch() calls
after any resolved promise; update the promise handlers so fetchingRef.current
is reset to false on all outcomes: inside the .then handler clear
fetchingRef.current before returning on !res.success and again after setting
content on success, and ensure the .catch handler still clears it (keep the
existing clearing there); reference fetchingRef, doFetch, setLoading, setError,
and setContent when making these changes.
- Around line 64-85: When a fetch for file content fails (both the res.success
=== false branch and the .catch(err) branch) add calls to the user-facing toast
helpers (showPersistentErrorToast or reportPersistentErrorToast) in addition to
the existing log.error and setError calls: in the res.success false block (where
you currently call log.error and setError with res.error) invoke
showPersistentErrorToast/reportPersistentErrorToast with a clear message and the
error payload (res.error), and in the .catch(err) block (where you compute msg
and call log.error/setError) also call the same toast helper with msg or err;
keep the existing log.error and setError behavior and ensure you reference the
existing symbols (res.error, res.oldContent/res.newContent, setError, log.error,
file.path) so the changes are applied to the correct failure handlers.
- Around line 104-106: Replace ad-hoc hex color classes used in the
DiffFileSection component (e.g., the Chevron element with class
"text-[`#6b7280`]", the file.path span "text-[`#9ca3af`]", and any "text-red-400"
usages at lines referenced) with the shared theme tokens exported from
apps/web-app/src/theme.ts; locate the elements in DiffFileSection.tsx (the
Chevron JSX, the span showing file.path, and the other spans that show
error/changed state) and swap the hard-coded classes for the appropriate
tokenized classNames or utility references (import the theme tokens from
theme.ts and apply the matching neutral/error token names) so all colors follow
the centralized palette.
In `@apps/web-app/src/components/detail/DiffMonacoEditor.tsx`:
- Around line 67-110: The handleMount callback captures onReady but has an empty
dependency array, risking a stale closure; update the useCallback dependency
list for the handleMount function to include onReady (i.e., ensure onReady is
referenced in the array passed to useCallback for handleMount) so the most
recent parent-provided callback is used when setTimeout calls onReady; adjust
dependencies similarly if other external values used inside handleMount change.
- Around line 75-88: Replace the hardcoded Monaco color hex literals in
DiffMonacoEditor (the object keys like "diffEditor.insertedTextBackground",
"diffEditor.removedLineBackground", "diffEditorGutter.insertedLineBackground",
"diffEditorOverview.insertedForeground", etc.) with the shared theme tokens from
apps/web-app/src/theme.ts (use the palette/token names used across the app
rather than ad‑hoc `#22543d`.. or `#742020`.. variants); update the object to
reference those palette properties (e.g., palette.* or token names exposed by
theme.ts) and ensure any required alpha/transparency is produced by the shared
color helpers or token utilities instead of embedding new hex variants.
- Around line 121-122: Remove the model-retention flags from the
DiffMonacoEditor usage: delete the keepCurrentOriginalModel and
keepCurrentModifiedModel props (or set them false) so editors don't implicitly
keep models alive; instead, manage model lifecycle explicitly inside the
DiffMonacoEditor component (e.g., reuse cached models or call model.dispose() in
the component's cleanup/useEffect unmount logic where original/modified models
are created), and update any related model-creation helpers in DiffMonacoEditor
to ensure models are disposed or reused rather than left orphaned.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b300610d-2446-42a2-88ab-7d897cf9725b
📒 Files selected for processing (3)
apps/web-app/src/components/detail/DiffFileSection.tsxapps/web-app/src/components/detail/DiffMonacoEditor.tsxapps/web-app/src/errorToasts.tsx
Summary by CodeRabbit
Release Notes
New Features
Tests
Documentation