Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crates/ally-cli/src/commands/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! current project's copy, or in the Agent's home folder when there is no project.
use crate::client::{self, Refused, unexpected};
use crate::forward::{Forwarding, Shown};
use crate::project::{self, Local};
use crate::route;
use crate::ssh::{self, RemoteCommand};
Expand Down Expand Up @@ -54,6 +55,15 @@ pub async fn attach(
&place,
style.colored(),
);
let forwarding = Forwarding::start(
target,
Shown::Session {
tmux: session.tmux.clone(),
socket: session.socket.clone(),
id: session.job.id.clone(),
label: label.clone(),
},
);
let mut remote = RemoteCommand::to(
target,
session.tmux,
Expand All @@ -67,6 +77,7 @@ pub async fn attach(
presentation::row("Return", "ally attach").trim_end()
);
let code = super::run::interact(target, &remote, lost).await?;
forwarding.stop().await;
if pulls_after(code)
&& let Err(error) = after_leaving(target, local.as_ref(), &session.job.id).await
{
Expand Down
3 changes: 3 additions & 0 deletions crates/ally-cli/src/commands/run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! `ally run <cmd>`: sync the project, then run a command in the Agent copy.
use crate::client::{self, Refused};
use crate::forward::{Forwarding, Shown};
use crate::project::{self, Local};
use crate::route;
use crate::ssh::{Disconnected, RemoteCommand};
Expand Down Expand Up @@ -62,7 +63,9 @@ pub async fn run(agent: Option<String>, cmd: Vec<String>) -> anyhow::Result<i32>
);

let remote = RemoteCommand::to(target, target.program().to_string(), args);
let forwarding = Forwarding::start(target, Shown::Terminal { raw: remote.tty });
let code = interact(target, &remote, lost_connection(&target.name)).await?;
forwarding.stop().await;
eprintln!("\n{}", finished(code, started.elapsed(), style));
Ok(code)
}
Expand Down
Loading
Loading