Skip to content

Commit 498d69c

Browse files
authored
Merge pull request #5 from devohmycode/0.5.0
Add notes feature, sysinfo, and auth window (v0.5.0)
2 parents 31b683b + 0f0a0de commit 498d69c

23 files changed

Lines changed: 2775 additions & 59 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- Generated by SpecStory, Markdown v2.1.0 -->
2+
3+
<!-- cursor Session e1e9239a-c980-49bb-9d93-9a048b088b44 (2026-02-23 16:43Z) -->
4+
5+
# Produire une description de Pull Request pour la branche Git (2026-02-23 16:43Z)
6+
7+
_**User**_
8+
9+
Produire une description de Pull Request pour la branche Git actuelle en analysant les derniers commit effectués sur celle-ci et en respectant les standards GitHub de nommage, syntaxe et formatage. Ne pas inclure de captures d'écrans et ne pas indiquer de clotures d'issue GitHub.
10+
11+
---
12+
13+
_**Agent (model default, mode Agent)**_
14+
15+
16+
17+
---
18+

‎index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>SuperFlux</title>
88
<link rel="preconnect" href="https://fonts.googleapis.com">
99
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10-
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300;1,9..40,400&display=swap" rel="stylesheet">
10+
<link href="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300;1,9..40,400&display=swap" rel="stylesheet">
1111
<script>
1212
(function() {
1313
var t = localStorage.getItem('theme');

‎src-tauri/Cargo.lock‎

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src-tauri/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ url = "2"
2121
open = "5.3.3"
2222
tts = "0.26"
2323
base64 = "0.22"
24+
sysinfo = "0.32"

‎src-tauri/capabilities/default.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
"$schema": "https://raw.githubusercontent.com/nicegui-org/nicegui/main/tauri-capabilities-schema.json",
33
"identifier": "default",
44
"description": "Capability for the main window",
5-
"windows": ["main"],
5+
"windows": ["main", "auth"],
66
"permissions": [
77
"core:default",
8+
"core:event:default",
9+
"core:webview:allow-create-webview-window",
810
"core:window:allow-minimize",
911
"core:window:allow-toggle-maximize",
1012
"core:window:allow-close",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"default":{"identifier":"default","description":"Capability for the main window","local":true,"windows":["main"],"permissions":["core:default","core:window:allow-minimize","core:window:allow-toggle-maximize","core:window:allow-close","core:window:allow-is-maximized","core:window:allow-start-dragging","core:window:allow-set-minimizable","core:window:allow-set-size","core:window:allow-inner-size","core:window:allow-set-min-size","core:window:allow-set-resizable","core:window:allow-outer-position","core:window:allow-set-position","core:window:allow-set-focus","core:window:allow-set-always-on-top","core:window:allow-set-effects"]}}
1+
{"default":{"identifier":"default","description":"Capability for the main window","local":true,"windows":["main","auth"],"permissions":["core:default","core:event:default","core:webview:allow-create-webview-window","core:window:allow-minimize","core:window:allow-toggle-maximize","core:window:allow-close","core:window:allow-is-maximized","core:window:allow-start-dragging","core:window:allow-set-minimizable","core:window:allow-set-size","core:window:allow-inner-size","core:window:allow-set-min-size","core:window:allow-set-resizable","core:window:allow-outer-position","core:window:allow-set-position","core:window:allow-set-focus","core:window:allow-set-always-on-top","core:window:allow-set-effects"]}}

‎src-tauri/src/lib.rs‎

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,88 @@ async fn http_request(
261261
})
262262
}
263263

264+
#[tauri::command]
265+
fn get_cpu_usage() -> f32 {
266+
use sysinfo::System;
267+
static SYS: OnceLock<Mutex<System>> = OnceLock::new();
268+
let mtx = SYS.get_or_init(|| {
269+
let mut sys = System::new();
270+
sys.refresh_cpu_usage();
271+
Mutex::new(sys)
272+
});
273+
let mut sys = mtx.lock().unwrap();
274+
sys.refresh_cpu_usage();
275+
sys.global_cpu_usage()
276+
}
277+
278+
#[derive(Serialize)]
279+
struct MemoryInfo {
280+
used_gb: f64,
281+
total_gb: f64,
282+
percent: f32,
283+
}
284+
285+
#[tauri::command]
286+
fn get_memory_usage() -> MemoryInfo {
287+
use sysinfo::System;
288+
let mut sys = System::new();
289+
sys.refresh_memory();
290+
let total = sys.total_memory() as f64;
291+
let used = sys.used_memory() as f64;
292+
let gb = 1_073_741_824.0; // 1 GiB
293+
MemoryInfo {
294+
used_gb: (used / gb * 10.0).round() / 10.0,
295+
total_gb: (total / gb * 10.0).round() / 10.0,
296+
percent: if total > 0.0 { (used / total * 100.0) as f32 } else { 0.0 },
297+
}
298+
}
299+
300+
#[derive(Serialize)]
301+
struct NetSpeed {
302+
download_kbps: f64,
303+
upload_kbps: f64,
304+
}
305+
306+
#[tauri::command]
307+
fn get_net_speed() -> NetSpeed {
308+
use sysinfo::Networks;
309+
use std::time::Instant;
310+
311+
static NET: OnceLock<Mutex<(Networks, Instant, u64, u64)>> = OnceLock::new();
312+
let mtx = NET.get_or_init(|| {
313+
let mut nets = Networks::new_with_refreshed_list();
314+
nets.refresh();
315+
let (rx, tx) = nets.iter().fold((0u64, 0u64), |(r, t), (_name, data)| {
316+
(r + data.total_received(), t + data.total_transmitted())
317+
});
318+
Mutex::new((nets, Instant::now(), rx, tx))
319+
});
320+
321+
let mut guard = mtx.lock().unwrap();
322+
let (ref mut nets, ref mut last_time, ref mut last_rx, ref mut last_tx) = *guard;
323+
324+
nets.refresh();
325+
let now = Instant::now();
326+
let elapsed = now.duration_since(*last_time);
327+
let secs = elapsed.as_secs_f64().max(0.1);
328+
329+
let (rx, tx) = nets.iter().fold((0u64, 0u64), |(r, t), (_name, data)| {
330+
(r + data.total_received(), t + data.total_transmitted())
331+
});
332+
333+
let dl = (rx.saturating_sub(*last_rx) as f64) / secs / 1024.0; // KB/s
334+
let ul = (tx.saturating_sub(*last_tx) as f64) / secs / 1024.0;
335+
336+
*last_time = now;
337+
*last_rx = rx;
338+
*last_tx = tx;
339+
340+
NetSpeed {
341+
download_kbps: (dl * 10.0).round() / 10.0,
342+
upload_kbps: (ul * 10.0).round() / 10.0,
343+
}
344+
}
345+
264346
#[tauri::command]
265347
fn open_external(url: String) -> Result<(), String> {
266348
open::that(&url).map_err(|e| format!("Failed to open URL: {e}"))
@@ -507,14 +589,51 @@ async fn tts_speak_elevenlabs(
507589
Ok(STANDARD.encode(&bytes))
508590
}
509591

592+
#[cfg(not(target_os = "android"))]
593+
#[tauri::command]
594+
async fn open_auth_window(app: tauri::AppHandle, url: String) -> Result<(), String> {
595+
use tauri::{Emitter, WebviewUrl, WebviewWindowBuilder};
596+
597+
// Close any existing auth window
598+
if let Some(existing) = app.get_webview_window("auth") {
599+
let _ = existing.close();
600+
}
601+
602+
let parsed_url: Url = url.parse().map_err(|e: url::ParseError| format!("Invalid URL: {e}"))?;
603+
let app_handle = app.clone();
604+
605+
WebviewWindowBuilder::new(&app, "auth", WebviewUrl::External(parsed_url))
606+
.title("Sign in")
607+
.inner_size(500.0, 700.0)
608+
.on_navigation(move |nav_url| {
609+
let url_str = nav_url.as_str();
610+
// Intercept redirect to our callback URL
611+
if url_str.starts_with("http://localhost/auth/callback") {
612+
let _ = app_handle.emit("auth-callback", url_str.to_string());
613+
return false; // Block navigation to localhost
614+
}
615+
true
616+
})
617+
.build()
618+
.map_err(|e| format!("Failed to create auth window: {e}"))?;
619+
620+
Ok(())
621+
}
622+
623+
#[cfg(target_os = "android")]
624+
#[tauri::command]
625+
async fn open_auth_window(_url: String) -> Result<(), String> {
626+
Ok(())
627+
}
628+
510629
#[cfg_attr(mobile, tauri::mobile_entry_point)]
511630
pub fn run() {
512631
tauri::Builder::default()
513632
.manage(AppState {
514633
#[cfg(not(target_os = "android"))]
515634
saved: Mutex::new(None),
516635
})
517-
.invoke_handler(tauri::generate_handler![fetch_url, http_request, open_external, collapse_window, expand_window, check_network, set_window_effect, tts_speak, tts_stop, tts_speak_elevenlabs])
636+
.invoke_handler(tauri::generate_handler![fetch_url, http_request, open_external, get_cpu_usage, get_memory_usage, get_net_speed, collapse_window, expand_window, check_network, set_window_effect, tts_speak, tts_stop, tts_speak_elevenlabs, open_auth_window])
518637
.setup(|_app| {
519638
#[cfg(not(target_os = "android"))]
520639
{

‎src-tauri/tauri.conf.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-config-schema/schema.json",
33
"productName": "SuperFlux",
4-
"version": "0.4.0",
4+
"version": "0.5.0",
55
"identifier": "com.ohmycode.superflux",
66
"build": {
77
"beforeDevCommand": "npm run dev:app",

0 commit comments

Comments
 (0)