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

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ predicates = "3"
proptest = "1"
rhai = "1"
rhai-autodocs = "0.11"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tempfile = "3"
thiserror = "2"
tokio = { version = "1", features = ["fs", "io-util", "macros", "net", "process", "rt-multi-thread", "signal", "sync", "time"] }
Expand Down
1 change: 1 addition & 0 deletions crates/embers-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
serde.workspace = true
thiserror.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
14 changes: 8 additions & 6 deletions crates/embers-core/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct PtySize {
pub cols: u16,
pub rows: u16,
Expand All @@ -17,19 +19,19 @@ impl PtySize {
}
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Point {
pub x: i32,
pub y: i32,
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Size {
pub width: u16,
pub height: u16,
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Rect {
pub origin: Point,
pub size: Size,
Expand All @@ -44,7 +46,7 @@ impl Rect {
}
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct FloatGeometry {
pub x: u16,
pub y: u16,
Expand All @@ -63,7 +65,7 @@ impl FloatGeometry {
}
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum SplitDirection {
#[default]
Horizontal,
Expand Down
3 changes: 2 additions & 1 deletion crates/embers-protocol/schema/embers.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ enum ActivityStateWire : ubyte {
enum BufferStateWire : ubyte {
Created = 0,
Running = 1,
Exited = 2,
Interrupted = 2,
Exited = 3,
}

enum NodeRecordKindWire : ubyte {
Expand Down
2 changes: 2 additions & 0 deletions crates/embers-protocol/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,7 @@ fn encode_buffer_record<'a>(
let state = match record.state {
BufferRecordState::Created => fb::BufferStateWire::Created,
BufferRecordState::Running => fb::BufferStateWire::Running,
BufferRecordState::Interrupted => fb::BufferStateWire::Interrupted,
BufferRecordState::Exited => fb::BufferStateWire::Exited,
};

Expand Down Expand Up @@ -2371,6 +2372,7 @@ fn decode_buffer_record(record: fb::BufferRecord) -> Result<BufferRecord, Protoc
let state = match record.state() {
fb::BufferStateWire::Created => BufferRecordState::Created,
fb::BufferStateWire::Running => BufferRecordState::Running,
fb::BufferStateWire::Interrupted => BufferRecordState::Interrupted,
fb::BufferStateWire::Exited => BufferRecordState::Exited,
_ => return Err(ProtocolError::InvalidMessage("unknown buffer state")),
};
Expand Down
1 change: 1 addition & 0 deletions crates/embers-protocol/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ impl ClientMessage {
pub enum BufferRecordState {
Created,
Running,
Interrupted,
Exited,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/embers-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ alacritty_terminal = "0.25.1"
embers-core = { path = "../embers-core" }
embers-protocol = { path = "../embers-protocol" }
portable-pty.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
tracing.workspace = true

Expand Down
3 changes: 3 additions & 0 deletions crates/embers-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub const SOCKET_ENV_VAR: &str = "EMBERS_SOCKET";
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ServerConfig {
pub socket_path: PathBuf,
pub workspace_path: PathBuf,
pub buffer_env: BTreeMap<String, OsString>,
}

Expand All @@ -17,8 +18,10 @@ impl ServerConfig {
SOCKET_ENV_VAR.to_owned(),
socket_path.as_os_str().to_owned(),
);
let workspace_path = socket_path.with_extension("workspace.json");
Self {
socket_path,
workspace_path,
buffer_env,
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/embers-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod state;

mod buffer_runtime;
mod config;
mod persist;
mod protocol;
mod server;
mod terminal_backend;
Expand All @@ -11,7 +12,7 @@ pub use buffer_runtime::{BufferRuntimeCallbacks, BufferRuntimeHandle};
pub use config::{SOCKET_ENV_VAR, ServerConfig};
pub use model::{
Buffer, BufferAttachment, BufferState, BufferViewNode, BufferViewState, ExitedBuffer,
FloatingWindow, Node, RunningBuffer, Session, SplitNode, TabEntry, TabsNode,
FloatingWindow, InterruptedBuffer, Node, RunningBuffer, Session, SplitNode, TabEntry, TabsNode,
};
pub use server::{Server, ServerHandle};
pub use state::ServerState;
Expand Down
6 changes: 6 additions & 0 deletions crates/embers-server/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ pub struct RunningBuffer {
pub pid: Option<u32>,
}

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct InterruptedBuffer {
pub last_known_pid: Option<u32>,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ExitedBuffer {
pub exit_code: Option<i32>,
Expand All @@ -48,6 +53,7 @@ pub enum BufferState {
#[default]
Created,
Running(RunningBuffer),
Interrupted(InterruptedBuffer),
Exited(ExitedBuffer),
}

Expand Down
Loading
Loading