Skip to content
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
60 changes: 60 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ version = "0.1.0"
edition = "2024"

[dependencies]
eframe = { version = "0.35.0", features = ["default_fonts", "wgpu"] }
eframe = { version = "0.35.0", features = ["default_fonts", "wgpu", "persistence"] }
egui = "0.35.0"
egui-wgpu = "0.35.0"
env_logger = "0.11"
futures = "0.3"
image = "0.25"
log = "0.4"
parking_lot = { version = "0.12", features = ["deadlock_detection"] }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full", "parking_lot"] }
# egui-wgpu 0.35 requires wgpu ^29.0; "29.0" resolves to a compatible 29.0.x.
wgpu = "29.0"
Expand Down
12 changes: 11 additions & 1 deletion src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ pub struct ConnectSettings {
}

/// Which authentication method the connect form is editing.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, Default, serde::Serialize, serde::Deserialize,
)]
enum AuthMethod {
#[default]
ApiKey,
Expand All @@ -62,6 +64,12 @@ enum AuthMethod {
/// The root window: a welcome screen holding the only connect form in the app.
/// Each successful Connect click spawns a dedicated room window. Inputs for both
/// auth methods are kept so switching tabs doesn't lose what was typed.
///
/// Persisted between runs via eframe storage (see `AppRoot`); `#[serde(default)]`
/// lets a stored blob from an older version fall back to `Default` (env-seeded)
/// for any missing field.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(default)]
pub struct ConnectView {
method: AuthMethod,
url: String,
Expand All @@ -74,6 +82,8 @@ pub struct ConnectView {
auto_subscribe: bool,
dynacast: bool,
enable_e2ee: bool,
// Not persisted: secrets always start hidden on launch.
#[serde(skip)]
show_secrets: bool,
}

Expand Down
20 changes: 19 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ mod utils;

pub static APP_NAME: &str = "LiveKit Client";

/// eframe storage key under which the connect form is persisted between runs.
const CONNECT_STORAGE_KEY: &str = "connect";

/// A room window, shown as a deferred viewport so it repaints independently of
/// the connect screen and of other rooms.
struct WindowEntry {
Expand Down Expand Up @@ -45,8 +48,14 @@ impl AppRoot {
.build()
.unwrap();

// Restore the last-used connect form; fall back to env-seeded defaults.
let connect = cc
.storage
.and_then(|storage| eframe::get_value::<ConnectView>(storage, CONNECT_STORAGE_KEY))
.unwrap_or_default();

Self {
connect: ConnectView::default(),
connect,
render_state: cc.wgpu_render_state.clone().unwrap(),
async_runtime,
next_window_id: 0,
Expand Down Expand Up @@ -76,6 +85,15 @@ impl AppRoot {
}

impl eframe::App for AppRoot {
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, CONNECT_STORAGE_KEY, &self.connect);
}

/// Scope persistence to our own connect settings; don't persist egui memory.
fn persist_egui_memory(&self) -> bool {
false
}

fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
if let Some(request) = self.connect.ui(ui) {
self.open_room(request);
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ fn main() {
let options = eframe::NativeOptions {
viewport,
centered: true,
// Persist only the connect form (see AppRoot::save), not window geometry —
// the root window is fixed-size and centered.
persist_window: false,
..Default::default()
};

Expand Down
Loading