Fix jj large-file warnings leaking into UI output#71
Conversation
Majutsu's responsive `process-file` replacement handled `(STDOUT STDERR)` destinations differently from Emacs' `process-file`: when callers passed `(list t nil)` to capture stdout and discard stderr, stderr was still inherited by the main process buffer and mixed into stdout. That made benign jj stderr warnings visible to callers that expected plain machine-readable output, including completion readers. In a repository with large untracked files, jj can emit "Refused to snapshot some files" while still exiting successfully; those warning lines were then parsed as bookmark or revision candidates. Route explicit nil stderr destinations to a throwaway stderr process instead of allowing them to merge into stdout. Keep the existing behavior for a single stdout destination, where stderr intentionally remains mixed with stdout. Add a regression test for `(list t nil)` so future changes preserve the `process-file` destination contract.
`majutsu-jj-wash` rendered successful jj commands by running jj with stdout
inserted directly into the destination buffer. Because stderr was not kept
separate, successful commands could still prepend warning text to UI output.
This is especially visible in repositories with large untracked files. jj
refuses to snapshot those files, exits successfully for commands such as
`status`, `diff`, and completion/listing queries, and writes a warning like:
Warning: Refused to snapshot some files:
file.bin: 7.1MiB; the maximum size allowed is 1.0MiB
Majutsu then treated that warning as part of the command's stdout. The text
could appear at the top of diff/status buffers and, for machine-readable
queries, leak into completion menus such as bookmark movement.
Capture stderr separately in `majutsu-jj-wash`. On successful commands,
render only stdout. On failures, continue to include stderr when the caller
asked to keep error output so genuine jj errors remain visible.
Add regression coverage for both successful warning stderr and failure stderr
preservation.
WalkthroughThe process runner ( Changesstderr discard and keep-error handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
majutsu-jj.el (1)
872-884: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winColorize kept stderr before returning.
These new
insert-file-contentspaths run after the existing ANSI pass, soKEEP-ERRORnow inserts raw stderr escape sequences into the buffer. Since Majutsu runs jj with--color=alwaysby default, failing commands can render unreadable control bytes here.Suggested fix
(when keep-error - (insert-file-contents err-file)) + (let ((err-beg (point))) + (insert-file-contents err-file) + (when (and majutsu-process-apply-ansi-colors + (> (point) err-beg)) + (let ((ansi-color-apply-face-function + #'ansi-color-apply-text-property-face)) + (ansi-color-apply-on-region err-beg (point)))))) @@ (when keep-error - (insert-file-contents err-file)) + (let ((err-beg (point))) + (insert-file-contents err-file) + (when (and majutsu-process-apply-ansi-colors + (> (point) err-beg)) + (let ((ansi-color-apply-face-function + #'ansi-color-apply-text-property-face)) + (ansi-color-apply-on-region err-beg (point))))))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@majutsu-jj.el` around lines 872 - 884, Kept stderr is being inserted without ANSI cleanup in the `keep-error` and failure-path branches of `majutsu-jj.el`, so raw escape sequences can reach the buffer after the existing color-processing step. Update the `insert-file-contents` handling in the `wash-jj-output` flow to run the same ANSI stripping/colorization logic on `err-file` before inserting it, especially in the `keep-error` path and the nonzero-exit failure branch. Use the surrounding `keep-error`, `wash-anyway`, and `exit` handling in this function to ensure all retained stderr is rendered consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@majutsu-jj.el`:
- Around line 872-884: Kept stderr is being inserted without ANSI cleanup in the
`keep-error` and failure-path branches of `majutsu-jj.el`, so raw escape
sequences can reach the buffer after the existing color-processing step. Update
the `insert-file-contents` handling in the `wash-jj-output` flow to run the same
ANSI stripping/colorization logic on `err-file` before inserting it, especially
in the `keep-error` path and the nonzero-exit failure branch. Use the
surrounding `keep-error`, `wash-anyway`, and `exit` handling in this function to
ensure all retained stderr is rendered consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 27e46d86-7cc3-4601-9245-49b542445e67
📒 Files selected for processing (4)
majutsu-jj.elmajutsu-process.eltest/majutsu-jj-test.eltest/majutsu-process-test.el
Summary
Fix jj stderr warnings leaking into Majutsu UI output when jj refuses to snapshot large untracked files, such as binary/reference files above
snapshot.max-new-file-size.The leak showed up in two places:
majutsu-jj-washinserted jj output with stderr mixed into stdout;process-filereplacement did not honor explicit nil stderr destinations like(list t nil), allowing warnings to be parsed as candidates.Changes
process-filesemantics.majutsu-jj-wash.Validation
majutsu-process-test.elandmajutsu-jj-test.eltest files together: 66/66 passed.Summary by CodeRabbit
Bug Fixes
Tests