A setup is a machine, and it carries what that machine can run
Providers and hosts were two independent lists, and a session named one of each. They were never independent: a provider only exists on a machine where that program is installed, so the spawn screen offered the whole cross-product, including "the Claude CLI on the box that hasn't got it". The picker could not know, because nothing in the model said. Now a setup is a machine -- optional ssh, plus the providers it has -- and spawning is two choices in order: pick a setup, then one of its providers. The impossible pairs stop being expressible rather than being validated against. Provider names are unique within a setup and only within one, so two machines can each have a `claude-cli`, which was previously either a name collision or two entries called things like "claude" and "claude on the vm". It also settles the "Run on" problem properly. That control was offered for every provider but honoured only by the Claude driver -- an echo session sent to a host ran locally and said otherwise. There is no such control now: the machine is chosen first, and echo is a provider of the setup with no ssh, where it belongs, since it runs in-process and has no transport to cross. The built-in echo provider is gone as a concept. It used to be conjured at read time and never written to the file, which meant a provider nobody could see or edit; it is now seeded into the config on first run alongside claude-cli. What the file says is what there is, and deleting it is a choice rather than a state to be repaired. A config in the old shape is refused with instructions rather than loaded. `Config` defaults unknown fields away, so `providers:` and `hosts:` would otherwise have vanished into an empty config that was then seeded over -- a migration nobody would notice until their setups were gone. Verified against a running server and on the emulator: a fresh install seeds "this machine" with echo and claude-cli and the file reads cleanly; a two-setup config lists both with their own providers; spawning on a setup works and the session row names it; asking for a provider a setup lacks says which it offers, and an unknown setup says which exist. On the phone, selecting "dev vm" narrows the provider chips to that machine's one and shows its address. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xn8nHw1tw1R6PtiY1eEtw
This commit is contained in:
1 parent
7cf36005ae
commit
ecac404fd4
10 files changed
+422
-328
No files matched your search
@@ -24,7 +24,7 @@ use std::path::{Path, PathBuf};
|
||||
use anyhow::{Context, Result};
|
||||
use tokio::process::Child;
|
||||
|
||||
use crate::config::HostConfig;
|
||||
use crate::config::SshConfig;
|
||||
|
||||
/// What a driver needs run in order to exist as a process.
|
||||
///
|
||||
@@ -51,17 +51,21 @@ impl Launch {
|
||||
pub enum Transport {
|
||||
/// The machine this server is running on.
|
||||
Here,
|
||||
/// Reached with the system `ssh` client. Owns its host entry rather
|
||||
/// than borrowing it, so a session keeps working against the config it
|
||||
/// was spawned with even if that entry is edited afterwards.
|
||||
Ssh(HostConfig),
|
||||
/// Reached with the system `ssh` client. Owns its entry rather than
|
||||
/// borrowing it, so a session keeps working against the config it was
|
||||
/// spawned with even if the setup is edited afterwards. Carries the
|
||||
/// setup's name only to say where things are running.
|
||||
Ssh { name: String, ssh: SshConfig },
|
||||
}
|
||||
|
||||
impl Transport {
|
||||
/// The transport a session's configured host names; absent is [`Self::Here`].
|
||||
pub fn for_host(host: Option<&HostConfig>) -> Self {
|
||||
match host {
|
||||
Some(host) => Self::Ssh(host.clone()),
|
||||
/// The transport a setup describes; a setup with no `ssh` is here.
|
||||
pub fn for_setup(setup: &crate::config::SetupConfig) -> Self {
|
||||
match &setup.ssh {
|
||||
Some(ssh) => Self::Ssh {
|
||||
name: setup.name.clone(),
|
||||
ssh: ssh.clone(),
|
||||
},
|
||||
None => Self::Here,
|
||||
}
|
||||
}
|
||||
@@ -75,14 +79,15 @@ impl Transport {
|
||||
pub fn spawn(&self, launch: &Launch) -> Result<Child> {
|
||||
let host = match self {
|
||||
Self::Here => None,
|
||||
Self::Ssh(host) => Some(host),
|
||||
Self::Ssh { ssh, .. } => Some(ssh),
|
||||
};
|
||||
crate::ssh::command(host, &launch.program, &launch.args, launch.cwd.as_deref())
|
||||
.spawn()
|
||||
.with_context(|| match self {
|
||||
Self::Ssh(host) => format!(
|
||||
"couldn't start ssh to run \"{}\" on {} -- is the ssh client installed here?",
|
||||
launch.program, host.name,
|
||||
Self::Ssh { name, .. } => format!(
|
||||
"couldn't start ssh to run \"{}\" on {name} -- is the ssh client installed \
|
||||
here?",
|
||||
launch.program,
|
||||
),
|
||||
Self::Here => format!(
|
||||
"couldn't run \"{}\" on this machine -- is it installed and on PATH? If it \
|
||||
@@ -96,7 +101,7 @@ impl Transport {
|
||||
pub fn describe(&self) -> String {
|
||||
match self {
|
||||
Self::Here => "on this machine".to_string(),
|
||||
Self::Ssh(host) => format!("on {} ({})", host.name, host.address),
|
||||
Self::Ssh { name, ssh } => format!("on {name} ({})", ssh.address),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user