Melhora UX do chat no desktop
All checks were successful
CI/CD Web + Desktop / Detect changes (push) Successful in 7s
CI/CD Web + Desktop / Deploy (VPS Linux) (push) Successful in 3m41s
CI/CD Web + Desktop / Deploy Convex functions (push) Has been skipped
Quality Checks / Lint, Test and Build (push) Successful in 4m5s

This commit is contained in:
rever-tecnologia 2025-12-18 23:53:24 -03:00
parent 9142446f06
commit 0a0f722bd8
4 changed files with 82 additions and 7 deletions

View file

@ -1060,6 +1060,21 @@ async fn process_chat_update(
// Serializa operacoes de janela para evitar race/deadlock no Windows (winit/WebView2).
static WINDOW_OP_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
fn hide_other_chat_windows(app: &tauri::AppHandle, active_label: &str) {
for (label, window) in app.webview_windows() {
if !label.starts_with("chat-") {
continue;
}
if label == active_label {
continue;
}
let _ = window.hide();
}
if let Some(hub) = app.get_webview_window(HUB_WINDOW_LABEL) {
let _ = hub.hide();
}
}
fn resolve_chat_window_position(
app: &tauri::AppHandle,
window: Option<&tauri::WebviewWindow>,
@ -1115,6 +1130,10 @@ fn open_chat_window_with_state(app: &tauri::AppHandle, ticket_id: &str, ticket_r
start_minimized
);
if !start_minimized {
hide_other_chat_windows(app, &label);
}
// Verificar se ja existe
if let Some(window) = app.get_webview_window(&label) {
let _ = window.set_ignore_cursor_events(false);
@ -1221,6 +1240,10 @@ fn set_chat_minimized_unlocked(app: &tauri::AppHandle, ticket_id: &str, minimize
let label = format!("chat-{}", ticket_id);
let window = app.get_webview_window(&label).ok_or("Janela não encontrada")?;
if minimized {
hide_other_chat_windows(app, &label);
}
// Tamanhos - chip minimizado com margem extra para badge (absolute -top-1 -right-1)
let (width, height) = if minimized {
(240.0, 52.0) // Tamanho com folga para "Ticket #XXX" e badge

View file

@ -410,9 +410,15 @@ async fn upload_chat_file(
}
#[tauri::command]
fn open_chat_window(app: tauri::AppHandle, ticket_id: String, ticket_ref: u64) -> Result<(), String> {
async fn open_chat_window(app: tauri::AppHandle, ticket_id: String, ticket_ref: u64) -> Result<(), String> {
log_info!("[CMD] open_chat_window called: ticket_id={}, ticket_ref={}", ticket_id, ticket_ref);
let result = chat::open_chat_window(&app, &ticket_id, ticket_ref);
let app_handle = app.clone();
let ticket_id_for_task = ticket_id.clone();
let result = tauri::async_runtime::spawn_blocking(move || {
chat::open_chat_window(&app_handle, &ticket_id_for_task, ticket_ref)
})
.await
.map_err(|err| format!("Falha ao abrir chat (join): {err}"))?;
log_info!("[CMD] open_chat_window result: {:?}", result);
result
}
@ -433,8 +439,13 @@ fn set_chat_minimized(app: tauri::AppHandle, ticket_id: String, minimized: bool)
}
#[tauri::command]
fn open_hub_window(app: tauri::AppHandle) -> Result<(), String> {
chat::open_hub_window(&app)
async fn open_hub_window(app: tauri::AppHandle) -> Result<(), String> {
let app_handle = app.clone();
tauri::async_runtime::spawn_blocking(move || {
chat::open_hub_window(&app_handle)
})
.await
.map_err(|err| format!("Falha ao abrir hub (join): {err}"))?
}
#[tauri::command]