A code review TUI that tries to reduce how many red and green squiggles you have to squint at
diff-viewer code-review llm

Files
README.md

Thresh #

[badges]

Yet another TUI code review thingy, but this one tries to both present your diffs as well as it can and reduce them here and there so you spend a bit less time puzzling over and squinting at those infernal red and green squiggles >.>

It has what I think are the basics

  • Syntax highlighting
  • Split and unified views
  • Long line wrapping
  • Breakpoints to behave differently on constrained viewports (like mobile)
  • Discussions

It has some really cool shit

  • View a range change by change
    • When a nice contributor has put thought into "right-sizing" their commits and ordering them in a reviewable way, reviewing them one by one and in that order is often so much nicer than lumping it all into one massive diff.
  • Round-based review with interdiffs
    • Review it once, leave feedback, contributor does some crazy rebase that completely rewrites history, then says it's ready for review round two. Usually, you have to read round 2 in full and mentally parse out what you've already seen and accepted vs what changed from round 1 to round 2 in response to your feedback. Thresh figures the diff between the diffs—the interdiff—out for you.
  • Moved lined detection
    • Diff viewers often just say a portion of code was removed from location A and a similar-looking portion was added to location B and you have to mentally parse out whether it's actually the same code just moved from A to B. Thresh finds those moved lines, adds a "Moved from line NN" label, and displays them slightly differently from lines that were added or removed.
  • LLM-based diff abridging (it needs its own section)

And I intend it to have some even cooler shit later on

  • Exchanging code review stuffs with external forges like GitHub, Forgejo, Tangled, etc. so I can never use their individually-crappy-in-different-ways UIs again
    (I know Thresh will also be crappy in some ways, it's inevitable in all software, but it'll be consistent kinds of crappy I can fix or live with instead of 84 different ones, three-quarters of which are proprietary and all of those three-quarters are constantly changing for the worse!)

Warning

The code in this main branch is currently just meat.dev with some light changes. I'm working on Thresh in another branch and using it every day as I review contributors', my, my bots', and my coworkers' code. Once I feel it's "ready" for others to use, I'll merge that branch into main.

Review rounds #

Opening a saved review restores its selected view without capturing workspace changes or selecting a newer round. Opening a new review captures its initial round. Once the TUI is open, its polling only reads saved review state.

To publish a new round, use v n in the TUI or the command line:

thresh round create [review-id-prefix] --repo PATH

An explicit capture leaves other readers on their current view. It prints the new round number when it captures changed, nonempty source and prints nothing for an unchanged or empty source.

Open retained source without capturing the workspace:

thresh diff --round 2
thresh diff --round 2 --since 1

--round opens that full round. --since opens the interdiff from the immediately preceding retained round, so its value must be --round - 1.

On a discussion, press c o to open its retained exact creation round or comparison at the authored source location. Press c b to restore the prior view, cursor, and file filter. This detour does not retarget the discussion or mark anything read or accepted.

Agent review commands #

Agents must pass --agent on every invocation, including read-only commands. For example:

thresh --agent discussion list --repo PATH
thresh --agent round create [review-id-prefix] --repo PATH
thresh --agent diff --round 2 --since 1
thresh --agent diff --discussion DISCUSSION_PREFIX

--discussion opens the discussion's retained original context without a fresh capture. Run diff from inside the repository, using the same source selection as the saved review. The recorded context determines the round or comparison and individual or continuous mode. Do not combine --discussion with --round, --since, --individual, or --continuous.

Compact and JSON discussion output report both the authored source provenance and the discussion's current placement. To inspect the exact source an inline discussion was authored against, print an excerpt from the retained snapshot:

thresh --agent discussion source DISCUSSION_ID_PREFIX --repo PATH --context 3

--context accepts 0 through 100 surrounding lines and defaults to 3. Add --json for stable structured output. The excerpt comes from retained authored source, so it does not depend on the current workspace still existing.

Abridging #

Thresh is for reviewing any kind of code, whether pecked out by fingers or generated by (G|C)PUs. Humans need to review code before it enters critical systems. But humans are already pretty great, and models are getting very good, at producing code; you might not need to review for style or nil-checks or imports, especially if you have good deterministic and stochastic systems in place to catch what they can before putting another human's eyes on that code.

Thresh uses an LLM to look through a diff and decide what does and doesn't need review, then presents the important bits first. Abridged regions are clearly marked and you can press e when on such a region to expand it and see the unabriged version.

Abridging is enabled by default. Use thresh diff --abridging=false to prevent model calls for one invocation, or set a default in your configuration:

[review]
abridging = false

Use thresh diff --abridging to override that setting for one invocation. Disabling abridging does not remove saved abridgments; an already selected one can still appear when you reopen a review. Press v e to read the source.

The idea of using an LLM to abridge your code and cut down how much you have to read is from meat.dev. I forked it and made some light changes so it works better inside Thresh. If you don't like Thresh, maybe upstream meat will better fit your needs, or if not, you can also fork it and make it do whatever you like 😃

Individual and continuous views #

Multi-change ranges can start in either continuous or individual view:

thresh diff --continuous 'abc::def'
thresh diff --individual 'abc::def'

--individual requires a selection containing at least two changes. To prefer individual view whenever the selected source supports it, put this in ~/.config/thresh/config.toml:

[review]
default_change_view = "individual"

The preference falls back to continuous view for a single-change selection. Either command-line flag overrides the configuration for that invocation. Individual view abridges several changes concurrently so abridgments of later changes are hopefully ready by the time you're done ready the first. Continuous view instead abridges the complete range as one aggregate diff, so its summary reflects the net change rather than the history of each change.