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
76 changes: 76 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ serde_json = { version = "1.0.145" }
tokio = { version = "1.48", features = ["full"] }
tracing = { version = "0.1" }
tracing-appender = { version = "0.2" }
uuid = { version = "1.0", features = ["v4", "serde"] }
tracing-error = { version = "0.2" }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
vt100 = { version = "0" }
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ serde.workspace = true
tokio.workspace = true
tracing-appender.workspace = true
tracing-error.workspace = true
uuid.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
vt100.workspace = true
Expand Down
8 changes: 5 additions & 3 deletions cli/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{fmt::Debug, io::Stdout, time::Duration};

use bytes::Bytes;
use clap::FromArgMatches;
use color_eyre::eyre;
use derivative::Derivative;
use ratatui::{Terminal, prelude::CrosstermBackend, restore, widgets::ListState};
Expand All @@ -16,6 +15,7 @@ use tokio::{
sync::{broadcast, mpsc},
time::interval,
};
use uuid::Uuid;
use vt100::Parser;

use crate::{
Expand Down Expand Up @@ -95,11 +95,13 @@ pub struct App {
input_parser: InputParser,
stream: UnixStream,
bg_tasks: Vec<CliTask>,
id: Uuid,
}

impl App {
pub fn new(stream: UnixStream, daemon_state: DaemonState) -> Self {
pub fn new(id: Uuid, stream: UnixStream, daemon_state: DaemonState) -> Self {
Self {
id,
stream,
input_parser: InputParser::default(),
state: AppState {
Expand All @@ -125,7 +127,7 @@ impl App {
}
}

#[instrument(parent=None, skip(self), name="App")]
#[instrument(parent=None, skip(self), fields(id=?self.id), name="App")]
pub async fn run(&mut self) -> Result<()> {
let mut term = ratatui::init();
debug!("Starting app");
Expand Down
53 changes: 0 additions & 53 deletions cli/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use clap::{Parser, Subcommand};
use remux_core::messages::{CliRequestMessage, RequestBody, RequestBuilder, request};

#[derive(Parser, Debug)]
pub struct Args {
Expand All @@ -23,55 +22,3 @@ pub enum Commands {
pub enum SessionCommands {
List,
}

impl Commands {
pub fn into_request(self) -> CliRequestMessage<impl RequestBody> {
match self {
Self::Attach { session_id } => RequestBuilder::default()
.body(request::Attach {
session_id,
create: true,
})
.build(),
Self::Session { .. } => todo!(),
}
}
}

// #[allow(clippy::from_over_into)]
// impl<T: RequestBody> Into<RequestMessage<T>> for Commands {
// fn into(self) -> RequestMessage<T> {
// match self {
// Self::Attach { session_id } => RequestBuilder::default()
// .body(request::Attach {
// session_id,
// create: true,
// })
// .build(),
// Self::Session { action } => action.into(),
// }
// }
// }

// #[allow(clippy::from_over_into)]
// impl Into<RequestBody> for SessionCommands {
// fn into(self) -> RequestBody {
// match self {
// SessionCommands::List => RequestBody::SessionsList,
// }
// }
// }
// #[allow(clippy::from_over_into)]
// impl Into<RequestBody> for Commands {
// fn into(self) -> RequestBody {
// let body: RequestBody = self.into();
// RequestBuilder::default().body(body).build()
// }
// }
// #[allow(clippy::from_over_into)]
// impl Into<RequestBody> for SessionCommands {
// fn into(self) -> RequestBody {
// let body: RequestBody = self.into();
// RequestBuilder::default().body(body).build()
// }
// }
4 changes: 3 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use remux_core::{
},
};
use tokio::net::UnixStream;
use uuid::Uuid;

use crate::{
app::App,
Expand Down Expand Up @@ -95,6 +96,7 @@ async fn run(command: Commands) -> Result<()> {
stream,
RequestBuilder::default()
.body(request::Attach {
id: Uuid::new_v4(),
session_id,
create: true,
})
Expand All @@ -114,7 +116,7 @@ async fn attach(mut stream: UnixStream, attach_request: CliRequestMessage<Attach
debug!(daemon_state=?res.initial_daemon_state, "Recieved initial daemon state");

debug!("Starting app");
let mut app = App::new(stream, res.initial_daemon_state);
let mut app = App::new(attach_request.body.id, stream, res.initial_daemon_state);
app.run().await?;
debug!("App terminated");
disable_raw_mode()?;
Expand Down
6 changes: 2 additions & 4 deletions cli/src/ui/fuzzy_selector_widget.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use fuzzy_matcher::{FuzzyMatcher, skim::SkimMatcherV2};
use ratatui::widgets::{Padding, StatefulWidget};
use terminput::KeyCode;

use crate::{
app::{IndexedItem, SelectorState},
Expand All @@ -21,8 +20,7 @@ impl StatefulWidget for FuzzySelectorWidget {
widgets::{Block, Borders, List, Paragraph},
};

let mut list_state = &mut state.list_state;
let list = &state.list;
let list_state = &mut state.list_state;
let filtered_items = state
.displaying_list
.iter()
Expand Down Expand Up @@ -74,7 +72,7 @@ impl StatefulWidget for FuzzySelectorWidget {
);

display_block.render(chunks[0], buf);
StatefulWidget::render(&list, subchunks[1], buf, &mut list_state);
StatefulWidget::render(&list, subchunks[1], buf, list_state);
display_query.render(chunks[1], buf);
}
}
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ derive_more.workspace = true
serde_json.workspace = true
serde.workspace = true
tokio.workspace = true
uuid.workspace = true

bincode = "2.0.1"
fs2 = "0.4.3"
Expand Down
6 changes: 4 additions & 2 deletions core/src/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ pub async fn send_and_recv_message<B>(stream: &mut UnixStream, req: &CliRequestM
where
B: RequestBody + Serialize + for<'de> Deserialize<'de>,
{
let req_id = req.id;
// let req_id = req.id;
send_message(stream, req).await?;
let res: ResponseMessage<B::ResponseBody> = read_message(stream).await?;
let res_id = res.id;
// let res_id = res.id;
// if req_id != res_id {
// return Err(Error::Response(ResponseError::UnexpectedId { expected: req_id, actual: res_id }));
// }
Expand All @@ -80,6 +80,7 @@ mod test {
use std::{fs::remove_file, path::PathBuf};

use tokio::net::UnixListener;
use uuid::Uuid;

use super::*;
use crate::{
Expand All @@ -104,6 +105,7 @@ mod test {
let addr = listener.local_addr()?;

let attach = request::Attach {
id: Uuid::new_v4(),
session_id: 1,
create: true,
};
Expand Down
2 changes: 2 additions & 0 deletions core/src/messages/request.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::{
messages::{
Expand Down Expand Up @@ -35,6 +36,7 @@ impl Message for DaemonRequestMessage {}

#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Attach {
pub id: Uuid,
pub session_id: u32,
pub create: bool,
}
Expand Down
2 changes: 0 additions & 2 deletions core/src/messages/traits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt::Debug;

use serde::{Deserialize, Serialize, de::DeserializeOwned};

pub trait Message: Serialize + DeserializeOwned + for<'de> Deserialize<'de> {}
Expand Down
1 change: 1 addition & 0 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ crossterm.workspace = true
derive_more.workspace = true
itertools.workspace = true
serde.workspace = true
uuid.workspace = true
tokio.workspace = true
tracing-error.workspace = true
tracing-subscriber.workspace = true
Expand Down
Loading