feat: add --path flag to filter diff to a specific file or directory#227
Merged
Conversation
Adds -p/--path <PATH> CLI flag that filters the diff view to only show files matching the given path (exact file match or directory prefix). When exactly one file matches, the file list is auto-hidden and the diff view is focused directly. When used without -r, --path implies --working-tree to skip the commit selector. This enables workflows like `tuicr --path plans/current-plan.md` for reviewing a single file's changes in isolation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The supports_keyboard_enhancement() call writes escape sequences to stdout before the /dev/tty redirect is established. When --stdout is used to capture export output, these sequences leak into the captured content. Skip the probe entirely in --stdout mode since keyboard enhancement is a minor UX improvement (Alt+Enter detection) that doesn't affect core functionality. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Allows `tuicr --file path/to/file.md` to open any file for review and annotation without requiring a git/hg/jj repository. The file is presented as a synthetic "all lines added" diff with syntax highlighting. Mutually exclusive with --path, -r, and -w. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
Ah @anpryl I realized late this was a draft PR, I converted it back. LMK when you're ready to merge and I will merge it. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
@agavra It is ready for review! |
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.
Summary
Adds several features for AI agent integration workflows:
--pathflag — filters diff view to a specific file or directory--fileflag — opens any file for annotation without requiring a VCS repository--stdoutescape fix — prevents garbage in captured export outputAlso fixes #203
Use Case: AI Agent Integration
tuicr's README describes the core workflow: "Let the agent loose, review the changes like a PR, drop comments where needed, and export everything as structured feedback." These features extend tuicr for document-driven review workflows.
The Problem
When using tuicr as part of an automated review workflow (e.g., an AI coding agent writes a design document, then opens tuicr for the user to annotate):
--pathproblem: Without it, tuicr shows every changed file in the working tree — the user has to manually navigate to the relevant file--fileproblem: The document may not be committed (or even tracked by git). Currently tuicr requires a VCS repository, so reviewing an arbitrary file means staging it first and cleaning up after--stdoutproblem: Keyboard enhancement probe writes escape sequences to stdout before the/dev/ttyredirect is established, leaking binary garbage into captured outputThe Solution
Real-World Workflow
This is used in a "review-plan" skill for Claude Code:
plans/feature-x.mdtuicr --file plans/feature-x.md --stdoutin a tmux popup:wq— comments are exported to stdoutNo
git addneeded. No VCS repo needed. Just a file and tuicr.Details
--fileflag (src/vcs/file.rs,src/vcs/traits.rs,src/app.rs,src/main.rs,src/theme/mod.rs)FileBackend(src/vcs/file.rs): NewVcsBackendimplementation that reads a file and presents it as a synthetic "all lines added" diff with syntax highlighting — no git, hg, or jj requiredVcsType::File(src/vcs/traits.rs): New variant for the file-only backendsrc/theme/mod.rs): Addsfile_path: Option<String>toCliArgs, parses--file <PATH>and--file=<PATH>formssrc/main.rs):--filecannot be combined with--path,-r, or-wsrc/app.rs): New code path inApp::newthat usesFileBackend, hides file list panel, and focuses on the diff view--pathflag (src/theme/mod.rs,src/app.rs,src/main.rs)src/theme/mod.rs): Addspath_filter: Option<String>toCliArgs, parses-p/--path <PATH>and--path=<PATH>forms with validationsrc/app.rs): Newfilter_by_path()method filtersDiffFiles by exact filename match or directory prefix. Applied consistently across all diff retrieval pathssrc/app.rs): When path filter matches exactly one file,show_file_listis set tofalseand focus moves to the diff panel--working-tree(src/main.rs):--pathimplies--working-treeunless-ris explicitly provided--stdoutescape fix (src/main.rs)supports_keyboard_enhancement()probe when--stdoutis active — keyboard enhancement is a minor UX improvement that doesn't affect core functionalityCompatibility
--stdoutfix only changes behavior when--stdoutis already in useTesting