Skip to content

feat: file preview in interactive mode#58

Merged
nrjdalal merged 9 commits into
mainfrom
feat/file-preview
Mar 22, 2026
Merged

feat: file preview in interactive mode#58
nrjdalal merged 9 commits into
mainfrom
feat/file-preview

Conversation

@nrjdalal

Copy link
Copy Markdown
Owner

Summary

  • Press enter on a file in interactive mode to preview its content with line numbers
  • Navigate lines with arrow keys, current line has dark gray background highlight
  • File sizes shown right-aligned in tree view (files and folders)
  • Full file path shown in preview header
  • Symlink-to-folder jump: enter on a symlink expands ancestors and jumps cursor to target
  • Handles binary files, large files (>512KB), and symlinks
  • Responsive to terminal resize in preview mode

Test plan

  • gitpick nrjdalal/picksuite -i -b main - preview files with enter
  • Preview binary file - shows "(binary file: X KB)"
  • Enter on symdir -> folder/ - jumps to folder
  • Verify 132 tests still pass

🤖 Generated with Claude Code

nrjdalal and others added 9 commits March 22, 2026 06:06
Press enter on a file to view its content with line numbers.
Scroll with arrow keys, press esc/q to go back to the picker.
Handles binary files, large files, and symlinks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ines

- Navigate lines with up/down, current line has dark gray background
- Line number width adapts to total line count
- No empty padding lines when file is shorter than viewport

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…k folder jump

- File size right-aligned at end of line in tree view
- Preview header shows path • size format
- Enter on symlink-to-folder jumps cursor to target folder and expands it

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Folder sizes calculated from sum of children. Shown right-aligned
same as file sizes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
const ancestorPath = pathParts.slice(0, pi).join("/")
const ancestor = findNodeByPath(tree, ancestorPath)
if (ancestor && ancestor.type === "tree") ancestor.expanded = true
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Preview mode swaps the stdin key handler, but it never swaps the global resize handler. stream.on("resize", onResize) still points at the tree renderer, so resizing the terminal while preview is open redraws the main picker even though preview-mode key handling remains active. That leaves the UI and input state out of sync until the user exits preview.

@nrjdalal

Copy link
Copy Markdown
Owner Author

Review score: 7/10

The feature adds real value and the implementation is close, but I found two preview-mode issues that feel worth fixing before merge:

  1. Previewing a relative symlink resolves from the repo root instead of the symlink's directory, so some symlinked files open the wrong target or fail to open.
  2. Terminal resize events still render the tree view while preview mode is active, which leaves the screen and input handlers out of sync.

I left both notes inline on the relevant lines.

// Pad remaining
for (let i = visibleCount; i < viewportHeight; i++) {
out += "\n"
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

For symlink previews this path is resolved from basePath instead of from the symlink's parent directory. A relative link like docs/readme.md -> ../README.md will preview basePath/../README.md instead of resolving from docs/, so the wrong file gets opened or the preview falls back to unable to read file. This should use the same resolveSymlinkPath() helper used elsewhere before joining with basePath.

@nrjdalal nrjdalal merged commit a6e484a into main Mar 22, 2026
9 checks passed
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.

1 participant