Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(main): release 0.2.0 #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [0.2.0](https://github.com/willothy/sesh/compare/v0.1.12...v0.2.0) (2023-10-30)


### Features

* SessionList with id / name lookup ([84cd7bd](https://github.com/willothy/sesh/commit/84cd7bd5a8ffcf299314dc80f32ad8415e3efb4d))


### Performance Improvements

* reduce socket check delay when spawning server ([cb22456](https://github.com/willothy/sesh/commit/cb224561bc103a35343984727ea1cda16f6b1aa9))

## [0.1.12](https://github.com/willothy/sesh/compare/v0.1.11...v0.1.12) (2023-10-27)


Expand Down
21 changes: 11 additions & 10 deletions client/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use sesh_proto::{
sesh_cli_server::SeshCliServer, sesh_kill_request::Session, sesh_resize_request,
SeshResizeRequest, SeshStartRequest, WinSize,
};
use sesh_shared::term::process_exit;
use termion::color::{self, Fg};
use termion::{raw::IntoRawMode, screen::IntoAlternateScreen};
use tokio::sync::broadcast;
Expand Down Expand Up @@ -67,8 +66,10 @@ impl Ctx {
exit: (tx, rx),
})
}
}

fn copy(&self) -> Self {
impl Clone for Ctx {
fn clone(&self) -> Self {
Ctx {
client: self.client.clone(),
exit: (self.exit.0.clone(), self.exit.0.subscribe()),
Expand Down Expand Up @@ -100,8 +101,6 @@ async fn exec_session(
.write_all(format!("\x1B]0;{}\x07", program).as_bytes())
.await?;

let mut input = tokio::io::stdin();

let sock = PathBuf::from(&socket);
let sock_dir = sock
.parent()
Expand All @@ -127,14 +126,14 @@ async fn exec_session(
.into_split();

// Reads process output from the server and writes it to the terminal
let r_handle = tokio::task::spawn({
let mut r_handle = tokio::task::spawn({
let exit = ctx.exit.0.subscribe();
async move {
let mut packet = [0; 4096];
while exit.is_empty() {
let bytes = r_stream.read(&mut packet).await?;
if bytes == 0 {
continue;
break;
}
output
.write_all(&packet[..bytes])
Expand All @@ -147,10 +146,11 @@ async fn exec_session(
});

// Reads terminal input and sends it to the server to be handled by the process.
let w_handle = tokio::task::spawn({
let ctx = ctx.copy();
let mut w_handle = tokio::task::spawn({
let ctx = ctx.clone();
let name = name.clone();
async move {
let mut input = tokio::io::stdin();
while ctx.exit.1.is_empty() {
let mut packet = [0; 4096];

Expand Down Expand Up @@ -197,7 +197,7 @@ async fn exec_session(

tokio::task::spawn({
let name = name.clone();
let mut ctx = ctx.copy();
let mut ctx = ctx.clone();
async move {
let mut signal = signal(SignalKind::window_change())?;
loop {
Expand Down Expand Up @@ -229,11 +229,12 @@ async fn exec_session(
let mut alarm = signal(SignalKind::alarm())?;
let exit = tokio::select! {
kind = exit_rx.recv() => kind.unwrap_or(ExitKind::Quit),
_ = process_exit(pid) => ExitKind::Quit,
_ = quit.recv() => ExitKind::Quit,
_ = interrupt.recv() => ExitKind::Quit,
_ = terminate.recv() => ExitKind::Quit,
_ = alarm.recv() => ExitKind::Quit,
_ = &mut r_handle => ExitKind::Quit,
_ = &mut w_handle => ExitKind::Quit,
};

tokio::fs::remove_file(&client_server_sock).await.ok();
Expand Down