Skip to content

Move open diff baseline lookup off main thread - #6497

Merged
lawrencecchen merged 11 commits into
mainfrom
feat-open-diff-background-baseline
Jun 21, 2026
Merged

lawrencecchen merged 11 commits into
mainfrom
feat-open-diff-background-baseline

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Move agent last-turn baseline JSON scanning for Open Diff Viewer into a detached task.
  • Keep live-agent context generic through SharedLiveAgentIndex snapshots, so all supported coding agents use the same session-id path.
  • Keep directory fallback synchronous and avoid any baseline-store read when no active agent session is focused.

Testing

  • ./scripts/reload-cloud.sh --tag odbg
  • Tagged preflight on /tmp/cmux-debug-odbg.sock with a 24 MB ~/.cmuxterm/agent-turn-diff-baselines.json
  • Triggered Open Diff Viewer shortcut in the tagged app.
  • Verified cmux diff --last-turn --session odbg-session rendered Last turn diff with story.txt +two.
  • Screenshot: /var/folders/rr/vmfx6xh12dz2tlvgtmyvjmf80000gn/T/cmux-screenshots/2026-06-20T09-25-02Z_6B0626F4.png

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Medium Risk
Changes the production keyboard/command-palette diff launch path and adds concurrent task state on AppDelegate; behavior is more async but reduces main-thread hang risk on large baseline files.

Overview
Open Diff Viewer no longer parses agent-turn-diff-baselines.json synchronously on the main actor when a focused agent session exists. The shortcut path now reads SharedLiveAgentIndex.shared snapshots on the main thread, then runs baseline/repo-root resolution in a Task.detached task before hopping back to launch cmux diff. Repeated shortcuts for the same workspace/surface/session are deduplicated, and completion re-checks focus so stale launches are skipped or opened without stealing focus. Non–agent-context opens stay on the existing synchronous working-directory fallback.

Review automation is updated in parallel: CodeRabbit, Greptile, and swift-expensive-sync-load.md now treat unbounded agent-history JSON/transcript/trajectory loads on interactive paths as failures and document the detached-parser pattern this PR implements.

Reviewed by Cursor Bugbot for commit 87d5707. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes / Performance
    • Improved “Open Diff Viewer” agent-context launches by deduplicating concurrent requests, validating the focused/stale context more reliably, and choosing a more accurate working directory/repo root before opening diffs.
    • Updated diff viewer process launching to support an explicit focus setting.
  • Chores / Documentation
    • Refined Swift performance review rules (including greptile config) to better detect and prevent synchronous, unbounded agent-history disk/JSON/transcript/trajectory loads and parsing on main/interactive paths, with clearer allowed/off-main guidance and reporting requirements.

@vercel

vercel Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jun 21, 2026 12:35am
cmux-staging Building Building Preview, Comment Jun 21, 2026 12:35am

@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

AppDelegate's diff viewer agent-context path is refactored to resolve the working directory, session id, and last-turn repo root asynchronously via a detached task using SharedLiveAgentIndex and baseline JSON lookup, then dispatch launchDiffViewerProcess back on the main actor. Deduplication prevents concurrent redundant baseline-parsing tasks. Baseline lookup, context verification, and normalization helpers are extracted into a new file. The launchDiffViewerProcess method gains a focus parameter to control whether the spawned cmux diff CLI captures focus. Concurrently, a new "expensive synchronous agent loads" review rule is established and documented across CodeRabbit, Greptile, and rule markdown, flagging unbounded agent-history disk/JSON/transcript operations on main-actor or interactive paths and requiring off-main execution via background loaders or detached tasks.

Changes

Async agent-context diff viewer launch

Layer / File(s) Summary
Baseline lookup and normalization helpers
Sources/OpenDiffViewerAgentBaselineLookup.swift
New file provides latestAgentTurnDiffRepoRoot to read and parse the baseline JSON, filter by normalized workspace/surface/session, validate repo root paths, and return the newest match. Adds agentTurnDiffBaselineStoreURL to compute the baseline store path with environment override support. Provides openDiffViewerAgentContextTaskKey for deterministic dedup key generation, openDiffViewerAgentContextShouldFocus to verify focused context still matches, and three normalization helpers for identifiers, session ids, and paths.
Async entry point and deduplication
Sources/AppDelegate.swift
openDiffViewerForFocusedWorkspace now adds openDiffViewerAgentContextTasks in-flight map and spawns a detached task when an agent snapshot provides a normalized sessionId, using openDiffViewerAgentContextTaskKey to deduplicate concurrent baseline-parsing tasks. The detached task resolves the last-turn repo root, computes useLastTurnSource, hops back to MainActor to verify context still matches, then calls launchDiffViewerProcess.
Fallback paths, focus control, and process launch
Sources/AppDelegate.swift
Non-detached fallback path uses focusedAgentWorkingDirectoryContext returning only (cwd, sessionId) without computing useLastTurnSource, launching with useLastTurnSource: false. launchDiffViewerProcess gains a focus: Bool = true parameter and now passes --focus <true|false> to cmux diff CLI instead of hard-coding focus, allowing async launches to control focus behavior.
Xcode project integration
cmux.xcodeproj/project.pbxproj
OpenDiffViewerAgentBaselineLookup.swift is added to the Xcode project with PBXBuildFile and PBXFileReference entries, included in the Sources group and PBXSourcesBuildPhase.

Expensive synchronous agent-load review rule

Layer / File(s) Summary
Swift expensive synchronous agent load rule definition
.github/review-bot-rules/swift-expensive-sync-load.md
Introduces a rule that flags expensive synchronous agent-history disk/JSON/transcript/trajectory/directory reads and parsing performed on the main actor or interactive UI paths. Compliance guidance directs unavoidable large-file operations off-main using Task.detached or background actors, with explicit hops back to @MainActor only for UI/process-launch work. Emphasizes bounding scans early to focused workspace/surface/session and avoiding whole-file materialization.
CodeRabbit path instructions and pre-merge checks
.coderabbit.yaml
Updates CodeRabbit's path_instructions and pre_merge_checks for the swift-expensive-sync-load rule, expanding the enumerated set of expensive synchronous agent-history load sources, broadening required off-main routing mechanisms beyond only SharedLiveAgentIndex.shared, and refining pass conditions to emphasize background/cache loaders and nil-guarded cold-cache fallbacks.
Greptile rule configuration and registration
.greptile/config.json, .greptile/files.json
Registers the new cmux-swift-expensive-sync-load rule in Greptile's config with high severity and scope limited to Swift/Package.swift files. Adds the corresponding rule file entry with description and scope globs.
Cmux review rules documentation
.greptile/rules.md
Refines the generic expensive-load review bullet to specifically target main-actor/interactive-path synchronous agent-history disk/JSON/transcript/directory/syscall operations. Adds a dedicated "Swift Expensive Synchronous Agent Loads" section detailing disallowed operations (sync reads/decodes/parses/scans and per-record filesystem loops) and acceptable off-main cached/background loader alternatives with pass conditions.

Sequence Diagram(s)

sequenceDiagram
  participant MainActor as Main Actor
  participant InFlightMap as openDiffViewerAgentContextTasks
  participant DetachedTask as Detached Task
  participant BaselineHelpers as Baseline Helpers

  MainActor->>MainActor: compute taskKey = workspaceId:surfaceId:sessionId
  MainActor->>InFlightMap: check if taskKey already in flight
  alt Already in flight
    MainActor->>MainActor: skip duplicate launch
  else New launch
    MainActor->>InFlightMap: record taskKey as in-flight
    MainActor->>DetachedTask: spawn Task.detached
    DetachedTask->>BaselineHelpers: latestAgentTurnDiffRepoRoot(storeURL, workspaceId, surfaceId, sessionId)
    BaselineHelpers-->>DetachedTask: repoRoot or nil → useLastTurnSource
    DetachedTask->>MainActor: openDiffViewerAgentContextShouldFocus(workspaceId, surfaceId, sessionId)
    MainActor-->>DetachedTask: still focused?
    DetachedTask->>MainActor: launchDiffViewerProcess(cwd, useLastTurnSource, sessionId, focus)
    MainActor->>InFlightMap: clear taskKey
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • manaflow-ai/cmux#6468: Extends the cmux_open CLI to accept --session and filter repo/patch selection by record.sessionId from the same baseline store that this PR populates via latestAgentTurnDiffRepoRoot and baseline JSON lookup.

  • manaflow-ai/cmux#5178: Both PRs modify Sources/AppDelegate.swift's diff-viewer launch path (openDiffViewerForFocusedWorkspace), with the retrieved PR centralizing routing and the main PR changing the same launch implementation to support agent-context de-duplication and updated launch parameters.

Poem

🐇 Hoppity hop, the diff task detaches,
No blocking the main, the async one latches!
Baseline roots from JSON files found,
Session contexts verified and bound.
Rules catch expensive loads with a sniff—
Off-main they must hop, no synchronous stiff! 🥕

🚥 Pre-merge checks | ✅ 21 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description includes a summary and testing details, but lacks complete documentation as required by the template. Add Demo Video section with a video URL/attachment; ensure all checklist items are explicitly addressed or completed before merging.
✅ Passed checks (21 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change—moving baseline lookup off the main thread—and is clear and specific without noise.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Swift Actor Isolation ✅ Passed PR correctly implements Swift 6 actor isolation: @MainActor AppDelegate methods safely use Task.detached with nonisolated static helpers; MainActor state access is guarded by await MainActor.run bl...
Cmux Swift Blocking Runtime ✅ Passed PR introduces no blocking or timing-based synchronization primitives. Instead, it REDUCES main-thread blocking by moving expensive JSON file parsing (24 MB agent-turn-diff-baselines.json) from sync...
Cmux Expensive Synchronous Load ✅ Passed The expensive agent-history baseline JSON read is moved to Task.detached (off-main), hops back to MainActor only for UI/focus work, uses cached SharedLiveAgentIndex.shared on main, and synchronous...
Cmux Cache Substitution Correctness ✅ Passed The PR uses cached sessionId from SharedLiveAgentIndex snapshots but handles cold/stale caches correctly: cold cache falls through to synchronous fallback, and stale snapshots are detected by re-va...
Cmux No Hacky Sleeps ✅ Passed PR contains only Swift code and configuration files, not TypeScript/JavaScript/shell runtime scripts covered by the rule. Swift sleeps are out of scope per runtime-no-hacky-sleeps.md.
Cmux Algorithmic Complexity ✅ Passed The expensive baseline JSON parsing is moved to Task.detached (off-main-thread), avoiding hot-path violations. Window iteration in openDiffViewerAgentContextShouldFocus is over fixed-size collectio...
Cmux Swift Concurrency ✅ Passed PR uses modern Swift concurrency (Task.detached, async/await, MainActor) appropriately. No new DispatchQueues, Combine, or completion handlers. Task.detached is properly tracked in a dictionary wit...
Cmux Swift @Concurrent ✅ Passed PR properly handles Swift concurrency: expensive file I/O (JSON read/parse, file checks) in latestAgentTurnDiffRepoRoot is correctly moved to Task.detached (explicit actor hop from @MainActor), the...
Cmux Swift File And Package Boundaries ✅ Passed New 108-line AppDelegate extension file contains small UI/persistence glue for shortcut coordination; AppDelegate itself decreases by 10 lines net; aligns with rule's allowed cases for small AppKit...
Cmux Swiftpm Lockfiles ✅ Passed No SwiftPM package dependency or package-reference changes in this PR; cmux.xcodeproj modification only adds source file to build phases, not SwiftPM dependencies.
Cmux Swift Logging ✅ Passed No violations of swift-logging rule found. New code in OpenDiffViewerAgentBaselineLookup.swift and modified AppDelegate functions contain no print/debugPrint/dump/NSLog statements in production pat...
Cmux User-Facing Error Privacy ✅ Passed PR adds no new user-facing errors, alerts, or exposed sensitive data; sessionId passed to cmux internally via CLI arg, stdout/stderr not displayed to users, environment variables used only for inte...
Cmux Full Internationalization ✅ Passed PR introduces no user-facing Swift text strings; all new code contains only JSON dictionary keys, environment variable names, and file paths (literal tokens per full-internationalization.md allowed...
Cmux Swiftui State Layout ✅ Passed PR adds only AppDelegate helper methods and configuration changes; no new SwiftUI state patterns (@Published, @Observable, @StateObject, GeometryReader, or lazy list store refs) introduced.
Cmux Architecture Rethink ✅ Passed PR avoids all swift-architectural-rethink violations: no sleeps/delays/locks/polling, single entrypoint convergence, clear state ownership (mainWindowContexts), explicit focus-still-active invarian...
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PR does not add or materially change any standalone cmux-owned windows. OpenDiffViewerAgentBaselineLookup.swift only checks properties of existing main workspace windows; launchDiffViewerProcess la...
Cmux Source Artifacts ✅ Passed All 8 changed files are intentional source code, configuration files, or review rule documentation. No local tool output, generated logs, screenshots, temp folders, caches, build artifacts, or Deri...
Cmux No Test Or Debug Seam In Production Source ✅ Passed The new production file OpenDiffViewerAgentBaselineLookup.swift contains no test/debug seams: no #if DEBUG blocks, no test-naming patterns (debug*, ForTesting*, TestHook*, etc.), and all methods...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-open-diff-background-baseline

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves the synchronous agent-turn-diff-baselines.json scan (Data read + JSONSerialization of an unbounded file) off the main thread by wrapping it in a Task.detached, using SharedLiveAgentIndex.shared snapshots for session context and a deduplication map to coalesce repeated shortcut triggers into a single in-flight parse per (workspaceId, surfaceId, sessionId).

  • Off-main baseline lookup: latestAgentTurnDiffRepoRoot is now nonisolated static and runs inside Task.detached(priority: .userInitiated), returning to @MainActor only for process launch; the synchronous fallback path retains directory-based context without reading the baseline store.
  • Request coalescing: openDiffViewerAgentContextTasks / openDiffViewerAgentContextPendingRequests deduplicate rapid shortcuts — only the latest pending request is processed after the in-flight task completes, preventing multiple 24 MB parses from fanning out.
  • Stale-focus validation: openDiffViewerAgentContextShouldFocus re-checks workspace/panel/session and window key-status on @MainActor after the task finishes, passing --focus false to cmux diff when the user has moved away.

Confidence Score: 5/5

Safe to merge — the diff correctly moves all unbounded baseline-store I/O off the main thread and the deduplication + stale-focus logic follows the established async-launch pattern.

The synchronous Data(contentsOf:) + JSONSerialization call that was previously on the main shortcut path is now fully inside Task.detached, hopping back to @mainactor only for process launch. Deduplication prevents fan-out on rapid triggers, and openDiffViewerAgentContextShouldFocus re-validates workspace/session/focus before launching. No data races, actor isolation violations, or logic bugs found.

No files require special attention.

Important Files Changed

Filename Overview
Sources/OpenDiffViewerAgentBaselineLookup.swift New file: houses the Task.detached baseline-lookup logic, deduplication helpers, and all nonisolated static utilities extracted from AppDelegate. Structure is correct — synchronous JSON parse runs fully off main thread before hopping back to MainActor for launch.
Sources/OpenDiffViewerAgentContextRequest.swift New Sendable value type capturing all parameters needed for the detached task. Clean, no issues.
Sources/AppDelegate.swift Removes synchronous latestAgentTurnDiffRepoRoot / agentTurnDiffBaselineStoreURL from the shortcut path, replaces with async task dispatch via SharedLiveAgentIndex snapshot. openDiffViewerAgentContextTasks and openDiffViewerAgentContextPendingRequests are internal (not private) as required for cross-file extension access.
.github/review-bot-rules/swift-expensive-sync-load.md Rule expanded to cover agent-turn-diff-baselines.json, transcript/trajectory files, JSONL logs, and large JSON/JSONL parsing — matches the class of problem this PR fixes.
.greptile/config.json Adds the new cmux-swift-expensive-sync-load rule entry. Consistent with the updated rules.md and review-bot-rules doc.
.coderabbit.yaml Expands the expensive-sync-load review instruction to cover the broader set of agent-history file types. Routine tooling update.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant AppDelegate (MainActor)
    participant SharedLiveAgentIndex
    participant Task.detached
    participant FS as Filesystem (24 MB JSON)

    User->>AppDelegate (MainActor): Trigger Open Diff Viewer shortcut
    AppDelegate (MainActor)->>SharedLiveAgentIndex: snapshot(workspaceId, panelId)
    SharedLiveAgentIndex-->>AppDelegate (MainActor): snapshot (sessionId, workingDirectory)
    AppDelegate (MainActor)->>AppDelegate (MainActor): build OpenDiffViewerAgentContextRequest
    alt in-flight task exists for taskKey
        AppDelegate (MainActor)->>AppDelegate (MainActor): store as pendingRequest (coalesce)
    else no in-flight task
        AppDelegate (MainActor)->>Task.detached: startOpenDiffViewerAgentContextTask(request)
        Task.detached->>FS: Data(contentsOf: storeURL) + JSONSerialization
        FS-->>Task.detached: records []
        Task.detached->>Task.detached: filter by workspaceId/surfaceId/sessionId
        Task.detached->>Task.detached: per-record fileExists/stat
        Task.detached-->>AppDelegate (MainActor): await MainActor.run → finishOpenDiffViewerAgentContextTask
    end
    AppDelegate (MainActor)->>AppDelegate (MainActor): return true (async path accepted)

    Note over AppDelegate (MainActor): (async completion)
    AppDelegate (MainActor)->>AppDelegate (MainActor): check pendingRequest → start new task if present
    AppDelegate (MainActor)->>AppDelegate (MainActor): openDiffViewerAgentContextShouldFocus → Bool?
    alt nil (workspace/session gone)
        AppDelegate (MainActor)->>AppDelegate (MainActor): silent return (no launch)
    else false/true (focus state)
        AppDelegate (MainActor)->>AppDelegate (MainActor): launchDiffViewerProcess(focus: shouldFocus)
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant AppDelegate (MainActor)
    participant SharedLiveAgentIndex
    participant Task.detached
    participant FS as Filesystem (24 MB JSON)

    User->>AppDelegate (MainActor): Trigger Open Diff Viewer shortcut
    AppDelegate (MainActor)->>SharedLiveAgentIndex: snapshot(workspaceId, panelId)
    SharedLiveAgentIndex-->>AppDelegate (MainActor): snapshot (sessionId, workingDirectory)
    AppDelegate (MainActor)->>AppDelegate (MainActor): build OpenDiffViewerAgentContextRequest
    alt in-flight task exists for taskKey
        AppDelegate (MainActor)->>AppDelegate (MainActor): store as pendingRequest (coalesce)
    else no in-flight task
        AppDelegate (MainActor)->>Task.detached: startOpenDiffViewerAgentContextTask(request)
        Task.detached->>FS: Data(contentsOf: storeURL) + JSONSerialization
        FS-->>Task.detached: records []
        Task.detached->>Task.detached: filter by workspaceId/surfaceId/sessionId
        Task.detached->>Task.detached: per-record fileExists/stat
        Task.detached-->>AppDelegate (MainActor): await MainActor.run → finishOpenDiffViewerAgentContextTask
    end
    AppDelegate (MainActor)->>AppDelegate (MainActor): return true (async path accepted)

    Note over AppDelegate (MainActor): (async completion)
    AppDelegate (MainActor)->>AppDelegate (MainActor): check pendingRequest → start new task if present
    AppDelegate (MainActor)->>AppDelegate (MainActor): openDiffViewerAgentContextShouldFocus → Bool?
    alt nil (workspace/session gone)
        AppDelegate (MainActor)->>AppDelegate (MainActor): silent return (no launch)
    else false/true (focus state)
        AppDelegate (MainActor)->>AppDelegate (MainActor): launchDiffViewerProcess(focus: shouldFocus)
    end
Loading

Reviews (8): Last reviewed commit: "Replace in-flight diff baseline lookups" | Re-trigger Greptile

Comment thread Sources/AppDelegate.swift Outdated
Comment thread Sources/AppDelegate.swift

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/AppDelegate.swift`:
- Around line 6166-6170: The guard check in mainWindowContexts.values.contains
is using a cached snapshot from SharedLiveAgentIndex.shared.snapshot() which may
be stale, and it does not verify the window context is still the active one. If
the focus moved or the agent session was replaced while the baseline parse was
running, the old session could still be launched. Add an additional check to
verify the window context is currently active and obtain a fresh (or provably
fresh-enough) snapshot instead of relying on the cached value. If cache
freshness cannot be guaranteed, fall back to using directory diff rather than
the old session's cmux diff command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 80e6212a-e492-4208-ae2e-7108ecc0eef0

📥 Commits

Reviewing files that changed from the base of the PR and between 9453675 and f2ba6d2.

📒 Files selected for processing (1)
  • Sources/AppDelegate.swift

Comment thread Sources/AppDelegate.swift Outdated
Comment thread Sources/AppDelegate.swift
Comment thread Sources/AppDelegate.swift Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/OpenDiffViewerAgentBaselineLookup.swift`:
- Around line 5-30: The openDiffViewerAgentContextShouldFocus method uses a
tri-state Bool? return type with non-obvious semantics that need documentation
for maintainability. Add a documentation comment above the
openDiffViewerAgentContextShouldFocus function definition explaining the three
return cases: nil means no matching context exists, false means context exists
but focus has moved, and true means context is still focused. This will clarify
the intent at all call sites without requiring developers to reverse-engineer
the logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b3ab721a-5735-46ef-9681-fbedb7699a6a

📥 Commits

Reviewing files that changed from the base of the PR and between 0478eb4 and 620ef7d.

📒 Files selected for processing (2)
  • Sources/AppDelegate.swift
  • Sources/OpenDiffViewerAgentBaselineLookup.swift

Comment thread Sources/OpenDiffViewerAgentBaselineLookup.swift
NSApp.isActive,
(context.window?.isKeyWindow == true || context.window?.isMainWindow == true) else {
return false
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Focus check skips origin window

Medium Severity

In openDiffViewerAgentContextShouldFocus, when a window context matches the workspace and session but its windowId is not originWindowId, the loop returns false instead of continuing. If multiple MainWindowContext entries share the same TabManager, iteration order can pick a non-origin window first and mis-report focus before the origin window is checked.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e75a481. Configure here.

@lawrencecchen
lawrencecchen force-pushed the feat-open-diff-background-baseline branch from e75a481 to 87d5707 Compare June 20, 2026 23:52

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 87d5707. Configure here.

sessionId: request.sessionId,
originWindowId: request.originWindowId
) else {
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale async abort silent

Medium Severity

When the detached baseline task finishes, openDiffViewerAgentContextShouldFocus returning nil exits without launching the diff viewer or beeping. The shortcut path already returned true from openDiffViewerForFocusedWorkspace, so callers skip their failure beep and the user gets no feedback after a slow parse.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 87d5707. Configure here.

@lawrencecchen
lawrencecchen merged commit b486e9d into main Jun 21, 2026
30 of 32 checks passed
@lawrencecchen
lawrencecchen deleted the feat-open-diff-background-baseline branch June 21, 2026 00:09
azooz2003-bit added a commit that referenced this pull request Jul 3, 2026
…essionId/focus (#6497), add AppDelegate launchDiffViewerProcess forwarder + agent-context task/pending dicts (round 78-fix)
@lawrencecchen
lawrencecchen restored the feat-open-diff-background-baseline branch July 18, 2026 10:24

This branch was successfully deployed

1 active deployment
Preview – cmux — 87d57074 Deployed Jun 21, 2026 by vercel[bot]
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