From 4efe306b3acb5ae7b8defb45945c690266c9389c Mon Sep 17 00:00:00 2001 From: Bossiara13 <236771060+DmitryBykov-ISPO@users.noreply.github.com> Date: Sat, 16 May 2026 00:48:23 +0300 Subject: [PATCH] feat(gui): profile switcher chip in header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Visible visual indicator of the active profile + click-to-swap dropdown. Closes the last small UX gap pointed out in earlier sessions. Tauri (crates/jarvis-gui/src/tauri_commands/profile.rs) - profile_list() → Vec of available profile names - profile_active() → {name, description, icon, greeting} - profile_set(name) → swaps active profile, returns new active Frontend (frontend/src/components/Header.svelte) - Polls profile_active every 5 seconds. - Shows a coloured chip with icon+name when profile != "default" (orange tint, attention-grabbing). For "default" — muted star chip. - Click opens a dropdown listing all profile names; click one → swap. - Dropdown closes on outside-click (shared handler with lang dropdown). - SCSS styled to match existing aesthetic. Build: cargo build --release -p jarvis-gui green (2m). Now the user can see at a glance which profile is active (e.g. "💼 work") without having to ask voice or open Settings. --- crates/jarvis-gui/src/main.rs | 5 + crates/jarvis-gui/src/tauri_commands.rs | 6 +- .../jarvis-gui/src/tauri_commands/profile.rs | 38 ++++ frontend/src/components/Header.svelte | 182 +++++++++++++++++- 4 files changed, 225 insertions(+), 6 deletions(-) create mode 100644 crates/jarvis-gui/src/tauri_commands/profile.rs diff --git a/crates/jarvis-gui/src/main.rs b/crates/jarvis-gui/src/main.rs index 312a19a..ed7fec8 100644 --- a/crates/jarvis-gui/src/main.rs +++ b/crates/jarvis-gui/src/main.rs @@ -128,6 +128,11 @@ fn main() { tauri_commands::memory_remember, tauri_commands::memory_forget, tauri_commands::memory_search, + + // Profile switching + tauri_commands::profile_list, + tauri_commands::profile_active, + tauri_commands::profile_set, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/crates/jarvis-gui/src/tauri_commands.rs b/crates/jarvis-gui/src/tauri_commands.rs index c507333..776a448 100644 --- a/crates/jarvis-gui/src/tauri_commands.rs +++ b/crates/jarvis-gui/src/tauri_commands.rs @@ -53,4 +53,8 @@ pub use scheduler::*; // Long-term memory facts mod memory; -pub use memory::*; \ No newline at end of file +pub use memory::*; + +// Profile switching +mod profile; +pub use profile::*; \ No newline at end of file diff --git a/crates/jarvis-gui/src/tauri_commands/profile.rs b/crates/jarvis-gui/src/tauri_commands/profile.rs new file mode 100644 index 0000000..659e0c6 --- /dev/null +++ b/crates/jarvis-gui/src/tauri_commands/profile.rs @@ -0,0 +1,38 @@ +//! Tauri commands for profile switching. + +use serde::Serialize; + +#[derive(Serialize)] +pub struct ProfileInfo { + pub name: String, + pub description: String, + pub icon: String, + pub greeting: String, +} + +#[tauri::command] +pub fn profile_list() -> Vec { + jarvis_core::profiles::list() +} + +#[tauri::command] +pub fn profile_active() -> ProfileInfo { + let p = jarvis_core::profiles::active(); + ProfileInfo { + name: p.name, + description: p.description, + icon: p.icon, + greeting: p.greeting, + } +} + +#[tauri::command] +pub fn profile_set(name: String) -> Result { + let p = jarvis_core::profiles::set_active(&name)?; + Ok(ProfileInfo { + name: p.name, + description: p.description, + icon: p.icon, + greeting: p.greeting, + }) +} diff --git a/frontend/src/components/Header.svelte b/frontend/src/components/Header.svelte index c6a8161..fe42496 100644 --- a/frontend/src/components/Header.svelte +++ b/frontend/src/components/Header.svelte @@ -1,9 +1,9 @@ - +