Commit graph

90 commits

Author SHA1 Message Date
Bennet Bo Fenner
0eb6bfd323
ssh remoting: Treat other message as heartbeat (#19219)
This improves the heartbeat detection logic. We now treat any other
incoming message from the ssh remote server
as a heartbeat message, meaning that we can detect re-connects earlier.

It also changes the connection handling to await futures detached.

Co-Authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
Co-authored-by: Antonio <antonio@zed.dev>
2024-10-15 16:37:56 +02:00
Thorsten Ball
be7b24fcf7
ssh remote: Shutdown SSH & server process correctly on app quit (#19210)
Release Notes:

- N/A

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-15 11:26:23 +02:00
Shish
7d5fe66b54
remote: Disable ControlPersist for master ssh connection (#19193)
remote: Disable ControlPersist for master ssh connection

`ControlPersist=yes` combined with `ControlMaster=yes` silently forces
`ForkAfterAuthentication=yes` (even when the user has explicitly set it
to `no` - reported upstream in [0]) - and the latter makes the ssh
subprocess disappear, which makes us think that the connection died

(This is only an issue for people who have `ControlPersist=yes` in their
`ssh_config`, and perhaps the answer is "if that option breaks things,
don't use that option?" - but it's an option that makes sense _most_ of
the time, it's just in this edge-case of "creating an ssh connection
with -N and expecting the process to stay in the foreground" where it
_must_ be set to no)

I think the alternative approach is to tell people "if you want to use
persistent connections, have a separate ~/.ssh/config entry for
servername (to ssh into) and servername-no-persist (to zed into)", which
is possible, but ugh. Kind of a messy situation >.<


Tests:

- Before: Connections to my server result in "Failed to connect: ." (The
error message is attempting to show stderr, but stderr is empty)

- After: Connections to my server work reliably


[0] https://bugzilla.mindrot.org/show_bug.cgi?id=3743


Release Notes:

- N/A
2024-10-14 15:36:31 +02:00
Mikayla Maki
bebe24ea77
Add remote server cross compilation (#19136)
This will allow us to compile debug builds of the remote-server for a
different architecture than the one we are developing on.

This also adds a CI step for building our remote server with minimal
dependencies.

Release Notes:

- N/A
2024-10-12 23:23:56 -07:00
Thorsten Ball
c21f26c419
ssh remote: Stream stderr from server via proxy to client (#19073)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-11 17:11:20 +02:00
Thorsten Ball
b75532fad7
ssh remote: Handle disconnect on project and show overlay (#19014)
Demo:



https://github.com/user-attachments/assets/e5edf8f3-8c15-482e-a792-6eb619f83de4


Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-10 12:59:09 +02:00
Thorsten Ball
bc4abd2b29
ssh session: Fix hang when doing state update in reconnect (#18934)
This snuck in last-minute.

Release Notes:

- Fixed a potential hang and panic when an SSH project goes through a
slow reconnect.
2024-10-09 19:40:09 +02:00
Kirill Bulatov
b6ba4fcc51 Silence the logs 2024-10-09 18:16:22 +03:00
Thorsten Ball
c674d73734
remote server: Do not spawn server when proxy reconnects (#18864)
This ensures that we only ever reconnect to a running server and not
spawn a new server with no state.

This avoids the problem of the server process crashing, `proxy`
reconnecting, starting a new server, and the user getting errors like
"unknown buffer id: ...".

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
2024-10-09 16:51:12 +02:00
Bennet Bo Fenner
fa85238c69
ssh: Limit amount of reconnect attempts (#18819)
Co-Authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-10-08 11:37:54 +02:00
Bennet Bo Fenner
a3b63448df
ssh: Do not cancel connection process if user is typing password (#18812)
Previously, the connection process would be cancelled after 10 seconds,
even if the connection was established successfully but the user was
still typing in a password.
We know recognize when the user is prompted for a password, and cancel
the timeout task.

Co-Authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-10-07 15:53:32 +02:00
Bennet Bo Fenner
25a97a6a2b
ssh: Detect timeouts when server is unresponsive (#18808)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
To detect connection timeouts we ping the remote server every X seconds
and attempt to reconnect if the server failed to respond.
Next up is showing some feedback in the UI to make this visible to the
user, and stop reconnecting after X amount of retries.

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-10-07 15:08:16 +02:00
Thorsten Ball
c03b8d6c48
ssh remoting: Enable reconnecting after connection losses (#18586)
Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-07 11:40:59 +02:00
Piotr Osiewicz
03c84466c2
chore: Fix some violations of 'needless_pass_by_ref_mut' lint (#18795)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
While this lint is allow-by-default, it seems pretty useful to get rid
of mutable borrows when they're not needed.

Closes #ISSUE

Release Notes:

- N/A
2024-10-07 01:29:58 +02:00
Piotr Osiewicz
19b186671b
ssh: Add session state indicator to title bar (#18645)
![image](https://github.com/user-attachments/assets/0ed6f59c-e0e7-49e6-8db7-f09ec5cdf653)
The indicator turns yellow when ssh client is trying to reconnect. Note
that the state tracking is probably not ideal (we'll see how it pans out
once we start dog-fooding), but at the very least "green=good" should be
a decent mental model for now.

Release Notes:

- N/A
2024-10-03 00:35:56 +02:00
Bennet Bo Fenner
b3cdd2ccff
ssh remoting: Fix ssh process not being cleaned up when connection is closed (#18623)
We introduced a memory leak in #18572, which meant that `Drop` was never
called on `SshRemoteConnection`, meaning that the ssh process kept
running

Co-Authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-10-02 13:21:19 +02:00
Thorsten Ball
7ce8797d78
ssh remoting: Add infrastructure to handle reconnects (#18572)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
This restructures the code in `remote` so that it's easier to replace
the current SSH connection with a new one in case of
disconnects/reconnects.

Right now, it successfully reconnects, BUT we're still missing the big
piece on the server-side: keeping the server process alive and
reconnecting to the same process that keeps the project-state.

Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-01 12:16:44 +02:00
Thorsten Ball
5199135b54
ssh remoting: Show error if opening connection timed out (#18401)
This shows an error if opening a connection to a remote host didn't work
in the timeout of 10s (maybe we'll need to make that configurable in the
future? for now it seems fine.)

![screenshot-2024-09-26-18 01
07@2x](https://github.com/user-attachments/assets/cbfa0e9f-9c29-4b6c-bade-07fdd7393c9d)


Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
2024-09-27 09:31:45 +02:00
Thorsten Ball
300bf87f77
ssh remoting: Kill SSH master process when dropping client (#18331)
This was a process leak. Since we use `.spawn()`, the process continued
to run in the background, even if our `SshClientState` was dropped.

Means we need to manually clean it up.

Release Notes:

- N/A

Co-authored-by: Bennet <bennet@zed.dev>
2024-09-25 12:45:53 +02:00
Thorsten Ball
9d197ddc99
ssh remoting: Fix SSH connection not being closed (#18329)
This fixes the `SshSession` being leaked.

There were two leaks:

1. `Arc<SshSession>` itself got leaked into the `SettingsObserver` that
   lives as long as the application. Fixed with a weak reference.
2. The two tasks spawned by an `SshSession` had a circular dependency
   and didn't exit while the other one was running. Fixed by fixing (1)
   and then attaching one of the tasks to the `SshSession`, which means
   it gets dropped with the session itself, which leads the other task
   to error and exit.

Co-authored-by: Bennet <bennet@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-09-25 12:03:24 +02:00
Stanislav Alekseev
8103ac12bf
ssh-remoting: Tidy up the code a bit after #18094 (#18102)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Release Notes:

- N/A
2024-09-19 21:36:50 -06:00
Conrad Irwin
fbbf0393cb
ssh-remoting: Fix go to definition out of worktree (#18094)
Release Notes:

- ssh-remoting: Fixed go to definition outside of worktree

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-09-19 14:04:46 -06:00
Thorsten Ball
e9f2e72ff0
Workspace persistence for SSH projects (#17996)
TODOs:

- [x] Add tests to `workspace/src/persistence.rs`
- [x] Add a icon for ssh projects
- [x] Fix all `TODO` comments
- [x] Use `port` if it's passed in the ssh connection options

In next PRs:
- Make sure unsaved buffers are persisted/restored, along with other
items/layout
- Handle multiple paths/worktrees correctly


Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
2024-09-19 17:51:28 +02:00
Conrad Irwin
8cc6df573c
SshLspAdapterDelegate (#17965)
Release Notes:

- N/A
2024-09-17 14:13:37 -06:00
Max Brunsfeld
01bb10f518
Move ProtoClient to RPC crate, behind feature flag disabled in collab (#17908)
This fixes a bug where we accidentally added a `gpui` transitive
dependency in `collab`.

Release Notes:

- N/A
2024-09-16 14:50:30 -07:00
Conrad Irwin
36eb1c15ea
use ssh lsp store (#17655)
Release Notes:

- ssh remoting: Added support for booting langauge servers (in limited
circumstances)

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-09-10 15:51:01 -04:00
Piotr Osiewicz
095a08d9c8
chore: Another round of style lints fixes (#17519)
Closes #ISSUE

Release Notes:

- N/A
2024-09-07 02:36:55 +02:00
Piotr Osiewicz
e6c1c51b37
chore: Fix several style lints (#17488)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
2024-09-06 11:58:39 +02:00
Max Brunsfeld
b8e6098f60
Consolidate logic for protobuf message handling between ssh and web socket clients (#17185)
This is a refactor to prepare for adding LSP support in SSH remote
projects.

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
2024-09-01 10:14:21 -07:00
Conrad Irwin
75d4c7981e
Extract an LspStore object from Project, to prepare for language support over SSH (#17041)
For ssh remoting lsps we'll need to have language server support
factored out of project.

Thus that begins

Release Notes:

- N/A

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-08-30 14:36:38 -07:00
Conrad Irwin
583b6235fb
SSH remoting: terminal & tasks (#15321)
This also rolls back the `TerminalWorkDir` abstraction I added for the
original remoting, and tidies up the terminal creation code to be clear
about whether we're creating a task *or* a terminal. The previous logic
was a little muddy because it assumed we could be doing both at the same
time (which was not true).

Release Notes:

- remoting alpha: Removed the ability to specify `gh cs ssh` or `gcloud
compute ssh` etc. See https://zed.dev/docs/remote-development for
alternatives.
- remoting alpha: Added support for terminal and tasks to new
experimental ssh remoting
2024-07-28 22:45:00 -06:00
rimuy
e9d0768e3c
Suppress unused parameter warning on remote/ssh_session.rs (#15315)
This was probably an oversight from
https://github.com/zed-industries/zed/pull/15129.


![image](https://github.com/user-attachments/assets/5867e307-f581-4b40-8492-2fb80e87c18c)

Release Notes:

- N/A
2024-07-26 21:11:28 -04:00
Conrad Irwin
3e31955b7f
SSH remote ui (#15129)
Still TODO:
* [x] hide this UI unless you have some ssh projects in settings
* [x] add the "open folder" flow with the new open picker
* [ ] integrate with recent projects / workspace restoration

Release Notes:

- N/A
2024-07-26 16:45:44 -06:00
Max Brunsfeld
5f7881fc1e
Improve ssh remote error handling and logging (#15035)
Release Notes:

- N/A
2024-07-23 13:29:56 -07:00
Kirill Bulatov
b2b9d4ccb6
Extend task templates with shell and hide fields to use custom shells and custom close behavior (#15031) 2024-07-23 22:58:36 +03:00
Max Brunsfeld
38e3182bef
Handle buffer diff base updates and file renames properly for SSH projects (#14989)
Release Notes:

- N/A

---------

Co-authored-by: Conrad <conrad@zed.dev>
2024-07-23 11:32:37 -07:00
Max Brunsfeld
e8bcc412b5
Fix usability issues with ssh connection modal (#14917)
Release Notes:

- N/A
2024-07-21 08:43:59 -07:00
Max Brunsfeld
022e662815 Start work on showing progress when initializing ssh remoting 2024-07-19 17:25:28 -07:00
Max Brunsfeld
fbe30c6f2e
Fixes for SSH remoting infrastructure (#14844)
* Fixed mis-named macOS remote server archives in actions and packaging
scripts
* Fixed an issue with the ask pass script on linux
* Download nightly versions of remote servers in dev mode (not stable)

Release Notes:

- N/A
2024-07-19 15:08:10 -07:00
Max Brunsfeld
b9a53ffa0b
Add the ability to edit remote directories over SSH (#14530)
This is a first step towards allowing you to edit remote projects
directly over SSH. We'll start with a pretty bare-bones feature set, and
incrementally add further features.

### Todo

Distribution
* [x] Build nightly releases of `zed-remote-server` binaries
    * [x] linux (arm + x86)
    * [x] mac (arm + x86)
* [x] Build stable + preview releases of `zed-remote-server`
* [x] download and cache remote server binaries as needed when opening
ssh project
* [x] ensure server has the latest version of the binary


Auth
* [x] allow specifying password at the command line
* [x] auth via ssh keys
* [x] UI password prompt

Features
* [x] upload remote server binary to server automatically
* [x] opening directories
* [x] tracking file system updates
* [x] opening, editing, saving buffers
* [ ] file operations (rename, delete, create)
* [ ] git diffs
* [ ] project search

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-07-19 10:27:26 -07:00