Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,10 @@ claude`.
project's allowlist for the next session.
- **Timeline**: if the session has snapshots, a slider picks a point in time
and the file list shows only what changed after it (read-only).
- **Conflicts**: files you changed yourself since the session started are
flagged in the list and above the diff, and are never overwritten.
- **Conflicts and merges**: files you changed yourself since the session
started are flagged in the list and above the diff, and are never
overwritten. When your changes and the agent's are in different lines of a
text file, the file is marked as a merge instead and applying keeps both.
- **Apply Selected** (⌘↩), **Apply All** (⇧⌘↩), **Undo** (⌥⌘Z) and
**Discard** (⌘⌫). Each apply can be undone in one step. Space toggles the
selected file.
Expand Down Expand Up @@ -1276,9 +1278,30 @@ point Mudroom at a file outside the session.
### How apply stays safe

For each path, Mudroom checks that the real project still has exactly what the
session started from. If you edited `README.md` while the agent was working,
`apply` reports a conflict for that file and leaves it alone; the rest still
applies. Other rules:
session started from. If you edited `README.md` while the agent was working
(or another session's apply changed it), Mudroom tries a three-way merge of
the session's base, your current file and the agent's copy:

- If the two sets of changes are in different lines, the merged file is
applied like any other change. `apply` prints it as `merged`, the review
marks it before you apply, and `undo` puts back your file exactly as it was
before the apply. A later apply of the same session merges again instead of
writing the agent's copy over it.
- If they change the same lines, or lines right next to each other, it's a
conflict: nothing is written to that file and the rest still applies. The
same goes for permissions changed on both sides.
- Only regular text files are merged. A binary file, a symlink, a mode-only
change, a change of type, a file one side deleted and the other edited, a
file both sides added, files over 4 MB and anything inside `.git` stay
conflicts.
- Line endings are part of each line, so CRLF files stay CRLF and a missing
final newline stays missing. Converting a whole file between CRLF and LF on
one side touches every line, so it conflicts with any edit on the other.
- Selected hunks merge the same way: the base plus the hunks you picked is
merged into your current file, so a hunk still goes in when you changed a
different part of the file.

Other rules:

- Files are written to a temp name and renamed into place.
- Directories are removed with `rmdir`, so a directory that gained a file on
Expand Down Expand Up @@ -1589,8 +1612,10 @@ safe](#how-apply-stays-safe).
<br>

Apply checks each file in your project against the session's starting copy.
A file you changed is reported as a conflict and left alone; the rest still
applies.
If you changed a text file in different lines from the agent, apply merges
the two and keeps both. If you changed the same or neighbouring lines, the file is reported
as a conflict and left alone; the rest still applies. The same happens when
two sessions on one project edit the same file and you apply both.

</details>

Expand Down
11 changes: 10 additions & 1 deletion Sources/MudroomApp/DiffView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ struct FileDetailView: View {
.padding(.vertical, 10)
Divider()
}
if entry.merges && !entry.isApplied && !entry.readOnly {
Banner(style: .info, title: "This file also changed in your project",
detail: "The changes are in different lines, so applying merges them: your version keeps its changes and gets the agent's. Undo puts your version back.")
.padding(.horizontal, 14)
.padding(.vertical, 10)
Divider()
}
if let conflict = entry.conflict {
Banner(style: .warning,
title: FileEntry.conflictTitle(conflict),
detail: "Mudroom won't overwrite your version, so this change can't be applied. Copy the parts you want by hand.")
detail: conflict.contains("overlap the agent's")
? "Your version and the agent's change the same or neighbouring lines, so Mudroom can't merge them. Copy the parts you want by hand."
: "Mudroom won't overwrite your version, so this change can't be applied. Copy the parts you want by hand.")
.help(conflict)
.padding(.horizontal, 14)
.padding(.vertical, 10)
Expand Down
6 changes: 4 additions & 2 deletions Sources/MudroomApp/ReviewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,15 @@ final class ReviewModel {
// contents aren't rows.
let rows = Set(baseFiles.map(\.path))
let n = report.applied.filter { rows.contains($0) }.count
let m = report.merged.count
let c = report.conflicts.count
if n == 0 && c == 0 {
lastResult = .init(style: .info, title: "Nothing to apply", detail: nil, offerUndo: false)
} else {
let files = n == 1 ? "1 file" : "\(n) files"
let detail = c == 0 ? "Undo puts the previous versions back."
: "\(c) \(c == 1 ? "path was" : "paths were") left alone because of conflicts."
let merged = m == 0 ? "" : "\(m == 1 ? "1 file was" : "\(m) files were") merged with changes in your project. "
let detail = merged + (c == 0 ? "Undo puts the previous versions back."
: "\(c) \(c == 1 ? "path was" : "paths were") left alone because of conflicts.")
lastResult = .init(style: c == 0 ? .success : .warning, title: "\(verb) \(files)",
detail: detail, offerUndo: n > 0)
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/MudroomApp/ReviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ struct FileRow: View {
.help(entry.conflict ?? "")
} else if entry.isApplied {
Image(systemName: "checkmark.circle.fill").foregroundStyle(.green).help("Applied")
} else if entry.merges {
Image(systemName: "arrow.triangle.merge")
.foregroundStyle(.blue)
.help("Also changed in your project, in other lines. Applying merges both.")
} else if !entry.appliedHunks.isEmpty {
Text("\(entry.appliedHunks.count)/\(entry.hunks.count)")
.font(.system(size: 10, weight: .semibold)).foregroundStyle(.green)
Expand Down
Loading
Loading