Files
tty7/docs/remote/sftp.mdx
T
l0ng-ai 0295a98915 feat(sftp): open remote text files in the built-in editor
A click on a file in the SSH Files panel used to start a download; the
only way to change a remote file was download, edit, re-upload. Now a
click opens it in the built-in editor and Cmd-S saves straight back over
the pane's own SFTP channel, matching what the Files panel already does
locally and over a remote workspace.

- protocol: SftpOp::ReadFile/WriteFile and SftpOpResult::File, bytes as
  base64; the reply carries the body plus the stat it was read under
- daemon: ReadFile enforces the caller's size ceiling before and during
  the read; WriteFile rewrites in place (truncate, not temp-and-rename)
  so the file keeps its mode and ownership
- SftpHost: a Host over the pane's SFTP route, so the editor's existing
  open/save path works unchanged; git/search/watch honestly Unsupported
- editor: an open buffer holds the host it was read from, and
  save/reload/dedup/watch key on (host, path) instead of the active host
- panel: single click opens (dirs navigate, text files edit), the same
  gesture as the local tree; binary or oversized files get the local
  tree's toast, and Download moves to the context menu

Review follow-ups, in this PR: the SFTP host stays out of HostRegistry,
which means "a machine this window has a link to" and is swept as such —
filing the pane's channel there made Cmd-S return silently once a
workspace deletion took it back out. The cursor-jump lookup, the status
bar's path, and the SCM panel's repository all key on the buffer's own
host now. Closes #656.
2026-08-16 18:53:27 +08:00

57 lines
2.1 KiB
Plaintext

---
title: "SFTP"
description: "A file browser for the machine on the other end of the connection."
---
While a pane is in an SSH session, *SSH: Remote Files* (command palette) slides
a file panel in over it. It is a real SFTP client on the same connection — no
second login, no second password.
<Frame caption="Placeholder — screenshot: the SFTP panel over a pane, with a transfer in progress">
<img src="/images/placeholder.svg" alt="The tty7 SFTP panel" />
</Frame>
## Browsing
The panel opens on the remote home directory. **Go to Shell Directory** in the
overflow menu jumps it to wherever the pane's shell currently is, which is
usually where you actually want to be.
Right-click a row for **Edit** (**Open** on a directory), **Download**,
**Follow Symlink**, **Rename**, **chmod…**, and delete. The overflow menu adds
**New Folder**, **New File**, **Upload…**, and **Refresh**.
## Editing
Click a text file and it opens in the [built-in
editor](/window/side-panel), the same gesture as the local file tree; saving
writes straight back over the same connection. Files the editor cannot hold —
binary, or over its 4 MB limit — say so instead; right-click → **Download**
for those.
## Transferring
| Direction | How |
|---|---|
| Download | Right-click → **Download** |
| Upload | **Upload…**, or drag files into the panel |
Uploads are written under a temporary name and renamed into place at the end, so
a half-finished file never looks like a finished one. A name that is already
taken asks before replacing.
**Transfer History** in the overflow menu shows every transfer with its
progress, and lets you cancel one in flight. The panel header summarises what is
happening — *"2 transferring · 64%"*.
## Permissions
**chmod…** takes an octal mode (`755`, `600`). The current mode is shown in the
row's editor before you change it.
<Tip>
For files in a [remote workspace](/remote/workspaces) you can often skip SFTP
entirely — the Files panel reads and writes across the link directly, and the
built-in editor saves back to the remote machine.
</Tip>