Skip to content

feat(tui): add dual-pane SFTP file browser#34

Merged
lfaoro merged 9 commits into
mainfrom
feat/sftp
May 17, 2026
Merged

feat(tui): add dual-pane SFTP file browser#34
lfaoro merged 9 commits into
mainfrom
feat/sftp

Conversation

@vybraan
Copy link
Copy Markdown
Collaborator

@vybraan vybraan commented May 16, 2026

Implements the initial SFTP file transfer view for #8.

This adds dual-pane file browser with:

  • local and remote directory navigation
  • upload from local to remote
  • download from remote to local

- Merge upstream/main (go 1.26.2, charm.land imports, tests, linting, security)
- Update sftp.go to use charm.land import paths
- Fix sftpModel.View() to return tea.View
@vybraan vybraan requested a review from lfaoro May 16, 2026 23:59
@vybraan vybraan marked this pull request as ready for review May 17, 2026 00:00
@lfaoro
Copy link
Copy Markdown
Owner

lfaoro commented May 17, 2026

image should add ctrl+s to the list of commands expanded with ? pressing ctrl+s again should toggle back

@lfaoro
Copy link
Copy Markdown
Owner

lfaoro commented May 17, 2026

would it be hard to have the ability to select multiple files to transfer using spacebar for selection ?

@lfaoro
Copy link
Copy Markdown
Owner

lfaoro commented May 17, 2026

should add ctrl+s to readme, and update changelog with the new feature

@vybraan
Copy link
Copy Markdown
Collaborator Author

vybraan commented May 17, 2026

should add ctrl+s to readme, and update changelog with the new feature

sure,

would it be hard to have the ability to select multiple files to transfer via ?

i dont believe so, will check it.

@vybraan
Copy link
Copy Markdown
Collaborator Author

vybraan commented May 17, 2026

would it be hard to have the ability to select multiple files to transfer using spacebar for selection ?

@lfaoro I think for now i'm going to keep it imp for multiple individual files but excluding the folders, i guess it can become messy pretty quick if i happen to do for thousands of folders and nested folders. So to transfer files in a dir you'd have to select all files inside and transfer them. what do think?

@lfaoro
Copy link
Copy Markdown
Owner

lfaoro commented May 17, 2026

things I'd like to see:

  • start the sftp session from local folder (pwd where ssm was started) but remote starts in /tmp instead of $HOME
  • progress bar while the files are transferring
  • ability to change folders by path e.g. / -> /srv/data
  • sftp TUI theme respects the theme of ssm

@lfaoro
Copy link
Copy Markdown
Owner

lfaoro commented May 17, 2026

would it be hard to have the ability to select multiple files to transfer using spacebar for selection ?

@lfaoro I think for now i'm going to keep it imp for multiple individual files but excluding the folders, i guess it can become messy pretty quick if i happen to do for thousands of folders and nested folders. So to transfer files in a dir you'd have to select all files inside and transfer them. what do think?

sure, let's start with whatever makes it easier to implement to launch the feature faster

lfaoro added 4 commits May 17, 2026 18:44
Add 40+ tests covering:
- fileItem Title/Description/FilterValue
- fileKind with symlink detection
- humanSize formatting
- loadLocalDir with valid/invalid paths
- sftpModel lifecycle (Init, Update, close)
- pane focus toggle and switching
- handleEnter for directories and files
- confirm dialog acceptance/rejection
- handleDelete for local and remote panes
- history buffer capping at 50 entries
- progressWriter Write method
- transferMsgCmd message creation
Add SFTP and run-command key bindings to the main host list help:
- ctrl+s: open SFTP file browser
- ctrl+r: open run-command sub-model

Update TestInitKeys to expect 6 bindings instead of 4.
Core features:
- Dual-pane file browser (local ↔ remote) using github.com/pkg/sftp
- firstBoot pattern for submodel initialization (Init() not called on submodels)
- connectSFTP with onStarted callback for in-flight SSH process tracking
- close() kills connecting SSH process and closes client on Esc/q
- Upload/download with file size display and transfer history buffer (50 entries)
- Overwrite confirmation dialog for existing files
- Delete operation with y/n confirmation on both panes
- Symlink detection in directory listings (local and remote)
- SSH options: StrictHostKeyChecking=no, BatchMode=yes, RequestTTY=no
- Remote pane starts in /tmp instead of server home directory
- Local dir error fallback sets empty items to prevent stale UI

Design consistency:
- Solid background bar headers matching main TUI list title style
- Theme colors with lightDark() adaptive colors on delegate styles
- Help bar with • bullet separators matching main TUI help
- q/esc to exit, tab to switch pane, d to delete
CHANGELOG:
- Add SFTP file browser entry under [Unreleased] with all sub-features
- Update test count from 92 to 132+ tests

README:
- Add ctrl+s key binding to keys table

AGENTS:
- Add SFTP sub-model to pkg/tui/ description
- Add sftp_test.go to test file list
- Update test count to 132+ across 6 files
- Add SFTP constraint (github.com/pkg/sftp, BatchMode)
- Add SFTP security notes (BatchMode, RequestTTY=no, sync.Mutex)
@lfaoro lfaoro merged commit 4871d39 into main May 17, 2026
8 checks passed
@lfaoro lfaoro deleted the feat/sftp branch May 17, 2026 16:13
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