Skip to content

diffs#73

Merged
Kitenite merged 2 commits intomainfrom
diffs
Nov 12, 2025
Merged

diffs#73
Kitenite merged 2 commits intomainfrom
diffs

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Nov 12, 2025

Summary by CodeRabbit

Release Notes

  • Improvements

    • Main branch automatically detected for diff calculations instead of using configured branch.
    • Build artifacts, dependencies, and generated files excluded from diffs.
    • Diff loading performance optimized with improved observer logic and context limiting.
  • UI/Style

    • Tightened vertical spacing in diff view for more compact display.
    • Mode toggle hidden from task tabs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Detects the repository main branch (main/master) for diffs, switches diff commands to use three-dot comparisons against that branch, adds file exclusion and context-limiting while parsing diffs, and refactors renderer file-observation to use refs plus a MutationObserver; also hides the ModeToggle in the UI and tightens diff line spacing.

Changes

Cohort / File(s) Change Summary
Main branch detection & diff logic
apps/desktop/src/main/lib/worktree-manager.ts, apps/desktop/src/main/lib/workspace-ipcs.ts
Added detectMainBranch(repoPath) to probe common branch names and origin HEAD; replaced use of configured workspace branch with detected main branch in getGitDiffFileList(), getGitDiffFile(), and getGitDiff(); switched diffing to three-dot (main...HEAD); added shouldExcludeFile() to filter build/artifact/config files; added context-buffering/limiting in per-file diff parsing.
Renderer: diff UI spacing
apps/desktop/src/renderer/screens/main/components/DiffView/DiffContent.tsx
Removed py-0.5 from diff line elements to tighten vertical spacing; minor className formatting and whitespace adjustments.
Renderer: file observation & loading
apps/desktop/src/renderer/screens/main/components/DiffView/DiffContentArea.tsx
Introduced refs (loadedFilesRef, loadingFilesRef, loadFileContentRef) synced via useEffect; replaced stale-closure access with .current; added observeFiles() to selectively observe file elements, batch initial observation with timeout, and a MutationObserver to detect new elements; consolidated cleanup and reduced effect dependencies to viewMode.
UI visibility toggle
apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/ModeToggle.tsx
Added hidden class to outer container to remove component from UI while preserving internal logic and handlers.

Sequence Diagram(s)

sequenceDiagram
    participant Renderer as DiffContentArea (renderer)
    participant IO as IntersectionObserver
    participant MO as MutationObserver
    participant Loader as loadFileContent()

    Renderer->>Renderer: sync refs (loadedFilesRef, loadingFilesRef, loadFileContentRef)
    Renderer->>MO: observe DOM for new file elements
    Renderer->>Renderer: schedule observeFiles() (timeout batch)

    Note right of IO: Observes only unobserved elements

    IO->>Renderer: entry detected (uses refs.current)
    alt file not loaded
        Renderer->>Loader: loadFileContentRef.current(file)
        Loader-->>Renderer: content loaded
        Renderer->>Renderer: update loadedFilesRef.current
    end

    MO->>Renderer: new file element added
    Renderer->>Renderer: observeFiles() -> IO.observe(new elements)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay special attention to buffer/flush correctness and edge cases in getGitDiffFile() and getGitDiff() in worktree-manager.ts.
  • Verify detectMainBranch() correctness and fallbacks in workspace-ipcs.ts.
  • Inspect MutationObserver callback and intersection observe/unobserve logic in DiffContentArea.tsx for leaks or duplicate observations.

Possibly related PRs

  • diffs #73 — Adds detectMainBranch and switches per-file diff calls to use detected main branch; directly overlaps core diff and branch-detection changes.
  • open new window #59 — Modifies workspace IPC wiring; related to the IPC handler change in workspace-ipcs.ts that now calls detectMainBranch().

Poem

🐰 I sniff the main branch in the dark,
I skip the build, the cache, the bark,
I buffer whispers, trim the noise,
Observers dance, refs find their poise.
Hidden toggle naps — diffs hop light and smart.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch diffs

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b3944c and 3ffe0e5.

📒 Files selected for processing (5)
  • apps/desktop/src/main/lib/workspace-ipcs.ts (1 hunks)
  • apps/desktop/src/main/lib/worktree-manager.ts (10 hunks)
  • apps/desktop/src/renderer/screens/main/components/DiffView/DiffContent.tsx (3 hunks)
  • apps/desktop/src/renderer/screens/main/components/DiffView/DiffContentArea.tsx (3 hunks)
  • apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/ModeToggle.tsx (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kitenite Kitenite merged commit b5dd784 into main Nov 12, 2025
1 of 5 checks passed
@Kitenite Kitenite deleted the diffs branch November 12, 2025 18:22
@Kitenite Kitenite mentioned this pull request Nov 12, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Nov 14, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant