Skip to content

Add single-file mode and fix annotation input width#10

Merged
umputun merged 7 commits intomasterfrom
single-file-mode
Apr 3, 2026
Merged

Add single-file mode and fix annotation input width#10
umputun merged 7 commits intomasterfrom
single-file-mode

Conversation

@umputun
Copy link
Copy Markdown
Owner

@umputun umputun commented Apr 3, 2026

Summary

  • When diff has exactly one file, auto-hide the tree pane and give full terminal width to the diff view
  • Pane-switching keys (tab, h, l) and file navigation (n/p, f) become no-ops in single-file mode
  • Search navigation (n/N) still works when search is active
  • Fix annotation textinput width to use diffContentWidth instead of arbitrary offset, preventing cursor from extending past pane border

umputun added 6 commits April 3, 2026 14:03
Skip tree pane entirely when singleFile is set, giving the diff pane
full terminal width. handleResize sets treeWidth=0 and diffContentWidth
returns width-3 in single-file mode.
feat: verify acceptance criteria for single-file mode
fix: address code smell findings

fix: address code review findings

fix: address codex review findings
Use diffContentWidth instead of arbitrary offset to calculate textinput
width, preventing cursor from extending past the pane border.
Copilot AI review requested due to automatic review settings April 3, 2026 22:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the TUI layout and key handling by introducing an automatic “single-file mode” (hide the tree when only one file is present) and by fixing annotation input sizing to align with the actual diff content width.

Changes:

  • Add singleFile mode detection (exactly one changed file) and render the diff pane at full terminal width while hiding the tree.
  • Make pane-switching and file-navigation actions no-ops in single-file mode while preserving n/N search navigation when matches exist.
  • Fix annotation text input width to be derived from diffContentWidth() instead of an arbitrary offset, preventing overflow past the pane border.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ui/model.go Adds singleFile state, adjusts resize/layout rendering, and disables tree-related navigation in single-file mode.
ui/model_test.go Adds unit tests covering single-file mode behavior (layout, resize behavior, key no-ops, and search navigation).
ui/diffview.go Updates diffContentWidth() to correctly compute content width in single-file mode.
ui/annotate.go Uses diffContentWidth() to size annotation input consistently with the diff pane content width.
README.md Documents the new single-file auto-detection behavior.
docs/plans/completed/20260403-single-file-mode.md Adds an implementation plan/write-up for the completed feature.
CLAUDE.md Documents the single-file mode behavior and invariants for contributors.
.claude-plugin/skills/revdiff/references/usage.md Updates usage docs to mention single-file mode and key behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ui/model_test.go Outdated
assert.Equal(t, 1, model.searchCursor, "n should advance search cursor in single-file mode")
assert.Equal(t, 2, model.diffCursor, "cursor should move to second match")

// n should navigate to previous search match
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test comment says n navigates to the previous search match, but the test actually sends N. Update the comment to match the key being exercised to avoid confusion when reading/failing this test.

Suggested change
// n should navigate to previous search match
// N should navigate to previous search match

Copilot uses AI. Check for mistakes.
@umputun umputun merged commit 1b7974f into master Apr 3, 2026
2 checks passed
@umputun umputun deleted the single-file-mode branch April 3, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants