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
262 changes: 218 additions & 44 deletions desktop/src-tauri/Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "OpenCodex desktop shell"
authors = ["OpenCodex contributors"]
license = "MIT"
edition = "2021"
rust-version = "1.77"
rust-version = "1.88"

[lib]
name = "opencodex_desktop_lib"
Expand All @@ -18,8 +18,8 @@ tauri-build = { version = "=2.6.3", features = [] }
base64 = "=0.22.1"
hmac = "=0.12.1"
reqwest = { version = "=0.12.24", default-features = false, features = ["json", "rustls-tls"] }
serde = { version = "=1.0.219", features = ["derive"] }
serde_json = "=1.0.140"
serde = { version = "=1.0.229", features = ["derive"] }
serde_json = "=1.0.151"
sha2 = "=0.10.9"
uuid = { version = "=1.18.1", features = ["v4"] }
tauri = { version = "=2.11.6", features = ["tray-icon", "image-png", "macos-private-api"] }
Expand Down
9 changes: 4 additions & 5 deletions desktop/src-tauri/src/companion_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ pub fn selected(settings: &Value, row: &Value) -> bool {
let provider = text(row, "provider");
let model = text(row, "model");
!hidden(settings, provider)
&& match settings["models"].as_array() {
None => true,
Some(models) => models.iter().any(|item| {
&& settings["models"].as_array().is_none_or(|models| {
models.iter().any(|item| {
item.as_str()
.is_some_and(|item| item == model || item == format!("{provider}/{model}"))
}),
}
})
})
}

const TOTAL_KEYS: [&str; 9] = [
Expand Down
7 changes: 4 additions & 3 deletions desktop/src-tauri/src/native_tray_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ pub async fn load(
let value = if let Some(sources) = sources {
let selected = sources
.into_iter()
.filter(|source| match settings.as_ref() {
None => true,
Some(s) => !snapshot::hidden(s, &source.name),
.filter(|source| {
settings
.as_ref()
.is_none_or(|s| !snapshot::hidden(s, &source.name))
})
.collect();
Some(json!(load_providers(&proxy, selected).await))
Expand Down
2 changes: 1 addition & 1 deletion desktop/src-tauri/src/native_tray_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn display_settings(settings: Option<&Value>) -> Value {
json!({
"showToday": enabled("showToday"), "show30Days": settings.is_some(),
"showChart": enabled("showChart"), "showModels": enabled("showModels"),
"showAccounts": match settings { None => true, Some(s) => s["showAccounts"].as_bool() != Some(false) },
"showAccounts": settings.is_none_or(|s| s["showAccounts"].as_bool() != Some(false)),
"showCost": enabled("showCost"),
"chartStyle": settings.map(|s| text(s, "chartStyle")).unwrap_or("line")
})
Expand Down
4 changes: 2 additions & 2 deletions desktop/src-tauri/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ fn input(app: &AppHandle, stale_pid: bool, requested_restart: bool, attempts: u3
Input {
phase: supervision.map_or(ExitPhase::Draining, |s| s.phase),
wanted: supervision.is_some_and(|s| s.wanted),
reason_set: supervision.map_or(true, |s| s.reason_set),
reason_set: supervision.is_none_or(|s| s.reason_set),
startup_running: app
.try_state::<Startup>()
.is_some_and(|startup| startup.is_running()),
Expand All @@ -372,7 +372,7 @@ fn on_exit(app: &AppHandle, pid: u32, exit: SidecarExit) {
};
let stale = app
.try_state::<AppState>()
.map_or(true, |state| state.child_pid() != Some(pid));
.is_none_or(|state| state.child_pid() != Some(pid));
let requested = exit.code == Some(REQUESTED_RESTART_EXIT_CODE);
let attempts = supervisor.state().attempts;
let verdict = decide(input(app, stale, requested, attempts));
Expand Down
4 changes: 2 additions & 2 deletions desktop/src-tauri/src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ mod macos {
last_reload: Option<f64>,
now: f64,
) -> bool {
previous.map_or(true, |previous| displayed(previous) != displayed(snapshot))
&& last_reload.map_or(true, |last| now - last >= RELOAD_INTERVAL_SECONDS)
previous.is_none_or(|previous| displayed(previous) != displayed(snapshot))
&& last_reload.is_none_or(|last| now - last >= RELOAD_INTERVAL_SECONDS)
}

static LAST_RELOAD: std::sync::Mutex<Option<f64>> = std::sync::Mutex::new(None);
Expand Down
7 changes: 7 additions & 0 deletions structure/desktop-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ discovers the loopback proxy, lazily retries management authentication, starts
the bundled `ocx` sidecar only when the configured endpoint is unreachable,
and owns the tray, autostart, single-instance, and window lifecycle behavior.

The desktop Cargo package requires Rust 1.88 or newer. Its committed lockfile already
contains dependencies with that minimum; the package declaration must not advertise 1.77.
The lockfile selects patched `serde_with` and `time` releases, with compatible exact
`serde` and `serde_json` pins in `desktop/src-tauri/Cargo.toml`. Build and test with the
committed lockfile (`--locked`); the dependency update does not change app configuration,
the bundled model proxy, or the minimum supported operating-system versions.

`desktop/ui/` is the startup surface. Once the runtime reports healthy, a visible or manually
launched shell navigates the webview to the proxy's loopback dashboard (`/#/usage`) rather than
bundling or serving `gui/dist` itself. A hidden login launch retains the small bundled ready surface
Expand Down
Loading