- Rust 88.4%
- Nix 11.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
Some checks failed
CI / Lint (pull_request) Successful in 1m50s
CI / Run tests (pull_request) Successful in 1m55s
CI / Mutation testing (pull_request) Successful in 3m44s
CI / Nix checks and package build (pull_request) Successful in 4m30s
CI / Nix checks and package build (push) Successful in 14s
CI / Lint (push) Successful in 30s
CI / Run tests (push) Successful in 37s
CI / Mutation testing (push) Failing after 13m6s
Finishing the work two agent sessions left pending, in one batch because the fixes share the files they touch. A terminal smaller than 72 columns or 8 rows is now refused, at start or after a resize: nothing is drawn, the terminal is restored, the size it got and the size it needs are printed, and the app exits with status 1. Nothing pending is applied. 72 columns is where every fixed line is whole - the longest, the list status hint, is 71 - so no key is ever shown cut in half; at 40 columns the choices line already loses `3: Do nothing`. Eight rows is what the confirm view needs for one change. The thumbnail width math now runs through copy count instead of a narrow terminal: 24 versions at 72 columns get three columns each - gutter, pixel, gutter - 25 drop the block and show metadata only. The confirm view crashed in an ordinary 80x24 terminal once 19 or more changes were pending. When the changes do not all fit, j/k, the arrows and Page Up/Down now scroll them; the warning says which are on screen (`4-6 of 7`) and the help bar gains `j/k: scroll`. Reopening the view starts at the first change again. A change whose files cannot be written - a read-only original - used to come back with nothing selected and no message. It now stays listed with the reason on its rows: `Could not apply: Permission denied (os error 13)`, so a failure never passes silently. An I/O error mid-run used to exit without leaving raw mode or the alternate screen, breaking the user's terminal. Terminal restore now runs however the run ends. A new pty test yanks the terminal the app draws to away mid-run and checks the keyboard terminal comes back in cooked mode. Fixtures can set file permissions (`[setup] permissions`), the dev shell gains cargo-llvm-cov (with rustc's own LLVM) for the line-coverage workflow in CLAUDE.md, and every line a user can reach now runs in some test. Verified: 108 tests, clippy and statix clean, `nix flake check` and `nix build` green, no missed mutants on the changed lines (45 caught, 7 unviable), line coverage 99.84% - only scanner.rs:108, a branch that cannot happen, is unrun. Co-Authored-By: MiMo 2.6 Pro <noreply@anthropic.com> |
||
| .cargo | ||
| .forgejo/workflows | ||
| examples | ||
| nix | ||
| src | ||
| tests | ||
| .envrc | ||
| .gitignore | ||
| build.rs | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CLAUDE.md | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| PLAN.md | ||
| README.md | ||
| spec.md | ||
deescalate
A TUI tool for resolving file sync conflicts, with a focus on Syncthing.
Note: This project is under active development. See
PLAN.mdfor current progress. The documentation below describes the planned feature set.
What It Does
When file synchronization tools like Syncthing detect that a file was modified on multiple devices simultaneously, they create conflict copies rather than silently overwriting changes. This leaves you with files like:
notes.md
notes.sync-conflict-20240115-143052-5CYLJKE.md
deescalate helps you resolve these conflicts by:
- Scanning directories recursively for conflict files
- Analyzing both versions using file-type-specific metadata
- Suggesting automatic resolution when one file is clearly newer or identical
- Showing diffs when manual decision is needed
- Confirming before making any disk changes
Installation
From crates.io
cargo install deescalate
With Nix
nix run github:cyplo/deescalate
Or add to your flake inputs:
{
inputs.deescalate.url = "github:cyplo/deescalate";
}
Usage
deescalate <DIRECTORY>
Scan a directory recursively for conflicts and open the TUI:
deescalate ~/Sync
TUI Controls
| Key | Action |
|---|---|
j/k or ↑/↓ |
Navigate list |
Enter |
Open conflict details |
Space |
Toggle selection |
a |
Auto-resolve selected |
d |
Show diff |
c |
Commit changes |
q |
Quit |
? |
Help |
Supported File Types
| Type | Extensions | Metadata Used | Diff Support |
|---|---|---|---|
| Text | .txt, .md, .json, .yaml, .xml, etc. | Line count, content hash | Full text diff |
| Images | .jpg, .jpeg, .png, .bmp | EXIF dates, dimensions | Side-by-side thumbnails |
| Word | .docx, .doc | Author, modified date, revision | diffoscope |
| Excel | .xlsx, .xls | Author, modified date | diffoscope |
| LibreOffice | .odt, .ods | Author, modified date, edit cycles | diffoscope |
| Author, creation/mod dates | diffoscope | ||
| Unknown | Any other extension | mtime, size, content hash | None (metadata only) |
Unknown file types are handled gracefully using filesystem metadata. You can still resolve conflicts based on modification times, file sizes, and whether the files are identical (via hash comparison).
How Resolution Works
Automatic Resolution
deescalate suggests automatic resolution when:
- One file is clearly newer (modification time differs by >1 hour)
- Files are identical (same content hash)
- One file is empty (keep the non-empty one)
You always confirm before any disk changes are made.
The confirm view lists every pending change; when they do not all fit, j/k
and Page Up/Down scroll through them.
When a change cannot be applied - a read-only original, a vanished copy -
the files are left as they are and the group stays listed, with the reason
on its rows.
deescalate needs a terminal of at least 72 columns and 8 rows. In a smaller one it leaves with a message saying so, without changing anything on disk.
Manual Resolution
When automatic resolution isn't confident, you see:
- Side-by-side metadata comparison
- Full diff view (text files) or structural diff (binary files via diffoscope)
- Options: keep original, keep conflict, keep both, skip
Optional Dependencies
For enhanced diff support:
- difftastic - Syntax-aware diffs for source code
- diffoscope - Deep comparison of binary files (Office docs, PDFs, images)
Without these, deescalate falls back to basic metadata comparison.
Development
Prerequisites
- Rust 1.75+ (uses edition 2024)
- Nix (optional, for reproducible dev environment)
Setup
# With Nix
nix develop
# Or manually
cargo build
Running Tests
This project always uses cargo-nextest for testing. Do not use cargo test.
cargo nextest run
Test Architecture
Tests are data-driven and auto-generated from the tests/test_data/ directory structure:
tests/test_data/
├── text/ # Text file conflict scenarios
│ ├── simple/ # Basic conflict detection
│ ├── multiple/ # Multiple conflicts for same file
│ ├── newer_original/ # Auto-resolution by mtime
│ └── identical/ # Identical content detection
├── image/ # Image conflict scenarios
├── operations/ # Resolutions applied to disk
├── display/ # What the screen shows
└── nested/ # Nested directory handling
Each test case directory contains:
- Conflict files - The actual files to test (original + conflict versions)
expected.toml- The keys a user presses and what should followscreen.snap- The final screen, text and styles
Example expected.toml:
name = "Keep the second of three conflict copies"
description = "b picks the copy labelled [b]; confirming replaces the original with it"
[setup]
keys = ["b", "c", "y"] # pick [b], confirm, apply
[expect.ui]
conflict_count = 0
[expect.files]
content = { "shopping.md" = "oat milk" }
The keys go through the same event loop as the real terminal. See
tests/test_data/SCHEMA.md for every field.
To add a new test case: Create a directory under tests/test_data/ with test files and an expected.toml. The test is automatically discovered and run. Its first run writes screen.snap.new; read it, then accept it with cargo insta accept. When a change alters a screen on purpose, review the differences with cargo insta review.
Tests that need the compiled program in a real terminal, such as its first frame or restoring the terminal on exit, live in tests/ui/pty.rs.
Mutation Testing
cargo mutants # every mutant
jj diff --git --from main > change.diff && cargo mutants --in-diff change.diff
cargo-mutants changes the code one small step at a time and checks that a test notices. Settings are in .cargo/mutants.toml; CI runs it on the lines each pull request changes.
Seeing the Screen
cargo run --example screen -- ~/Sync --keys "j enter" # text
cargo run --example screen -- ~/Sync --svg > screen.svg && resvg screen.svg screen.png
This prints what deescalate would show after those keys, without a terminal. It works on a temporary copy of the directory, so keys that apply resolutions never touch your files.
Project Structure (Target Architecture)
src/
├── main.rs # Entry point, CLI
├── lib.rs # Library root
├── scanner.rs # Find conflicts by pattern
├── types.rs # Core types
├── filetypes/ # File-type handlers (colocated logic)
│ ├── mod.rs # FileType trait, registry
│ ├── text.rs # Text: metadata, diff, resolution
│ ├── image.rs # Images: EXIF, metadata display
│ ├── office.rs # Office docs: OOXML/ODF metadata
│ ├── pdf.rs # PDF metadata
│ └── unknown.rs # Fallback: mtime, size, hash only
├── resolver.rs # Resolution logic
├── tui/ # Terminal UI
│ ├── app.rs # App state
│ ├── scan_view.rs # Conflict list
│ ├── detail_view.rs # Diff/metadata view
│ └── confirm_view.rs # Confirmation
└── operations.rs # File operations
See PLAN.md for implementation progress.
Adding a New File Type
- Create
src/filetypes/yourtype.rs - Implement the
FileTypetrait:matches()- detect files by extensionextract_metadata()- get comparison datasuggest_resolution()- auto-resolve if confidentgenerate_diff()- produce diff outputrender_details()- TUI display
- Register in
src/filetypes/mod.rs
All file-type logic is colocated in one file for easy understanding and modification.
Syncthing Conflict Format
Syncthing creates conflict files with this naming pattern:
<filename>.sync-conflict-<YYYYMMDD>-<HHMMSS>-<DEVICEID>.<ext>
- Date and time indicate when the conflict was detected
- Device ID (7 chars) identifies which device created the conflicting version
License
AGPL-3.0
Contributing
Contributions welcome! Please read the spec.md for detailed requirements before implementing features.