Repository navigation
Conflict forecast: warn when parallel worktrees are heading for a merge conflict (#249) - #369
Merged
currentbits merged 3 commits intoAug 17, 2026
Conversation
Wires git:conflictForecast end to end with a stub implementation so the backend and UI can be built in parallel against a fixed shape. Co-Authored-By: Claude Opus 5 <[email protected]>
Scan active worktree threads for overlapping file edits vs the base branch, then run git merge-tree to distinguish auto-mergeable overlap from real collisions. Cache per project for 15s; never throw.
Surface the shared forecast on Sidebar and Kanban thread cards: red "conflict" when git would collide, amber "overlap" for shared files, with a tooltip of the other thread and the hotspot paths.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/conflict-forecast-predict-merge-conflict-5c2056
branch
October 3, 2026 16:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #249.
With several agents editing the same repo in parallel worktrees, you only find out two threads collided when the second one merges. This adds a proactive signal: thread cards now warn while both threads are still running.
How it works
git merge-tree --write-tree --name-onlyalready performs a real dry-run 3-way merge between two branches without touching a working tree — so there is no heuristic function/class parsing here, git itself answers the question.For each project,
conflictForecast()inelectron/worktrees.js:git diff --name-only <base>...<branch>unioned with its uncommittedgit status --porcelain.overlap.merge-treeon those pairs only; the files it reports on exit 1 becomeconflicts.So
conflictsnon-empty means "these two will collide", while overlap-only means "same files, still auto-mergeable". Results are memoized 15s per project, and the function never throws — a project without a repo simply returns no pairs.What you see
A chip on thread cards in the Sidebar and the Kanban board (Kanban reuses
ThreadCard, so there is one badge implementation):conflictwhen any pair involving that thread has a real collisionoverlapwhen the threads only share files· Nwhen the thread is in more than one pairThe native tooltip names the other thread and lists up to four hotspot paths.
Not on the Planboard — those cards are GitHub issues, not threads.
Wiring
New
git:conflictForecastIPC channel through the usual five seams (src/shared/ipc.ts,electron/preload.js,electron/ipc.js,src/useCoder.ts) plus the two transports that must stay in sync (src/wireClient.ts,src/devCoder.ts— the dev mock fabricates a pair sonpm run dev:browserrenders the badge). The renderer refetches when the thread list changes; no new polling loop was added, since the main-process side is cached.Deliberately left out
merge-treeover uncommitted work: uncommitted edits contribute tooverlap, but git cannot dry-run merge what is not committed. In practice checkpoints auto-commit each turn, so this rarely matters.Tests
electron/test/conflict-forecast.test.js— real temp repo and real worktrees: disjoint files produce no pair, same file in far-apart regions produces overlap with no conflict, same line produces a conflict, and an uncommitted-only change still contributes to overlap.test/conflictForecast.test.ts— the purepairsForThreadhelper.test/conflictForecastBadge.test.tsx— loud badge, quiet badge, and no badge.Verified on this branch:
npm run typecheckclean, and the electron plus renderer suites for these files pass (6/6 and 13/13). The full electron suite is baseline-clean — the pre-existingweb-integrationreconnect failure also fails on unmodifiedmain.