From d20ebf741608931ab5afbcf0b4b2148acd968e83 Mon Sep 17 00:00:00 2001 From: rever-tecnologia Date: Tue, 9 Dec 2025 13:06:03 -0300 Subject: [PATCH] fix(chat): ajustes de texto, layout e icone do menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Mudar texto 'Chat #' para 'Ticket #' no desktop - Passar ticketRef via URL para exibir numero correto - Ajustar tamanho da janela minimizada (240px) - Incluir ticketRef no checkMachineUpdates (Convex) - Ajustar padding dos botoes no chat web - Mudar icone 'Todos os tickets' para ClipboardList 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/desktop/src-tauri/src/chat.rs | 15 ++++++++------- apps/desktop/src/chat/ChatWidget.tsx | 11 ++++++----- apps/desktop/src/chat/convexMachineClient.ts | 2 +- apps/desktop/src/chat/index.tsx | 5 +++-- apps/desktop/src/main.tsx | 6 +++--- convex/liveChat.ts | 17 ++++++++++++----- src/components/app-sidebar.tsx | 2 +- src/components/tickets/ticket-chat-panel.tsx | 2 +- 8 files changed, 35 insertions(+), 25 deletions(-) diff --git a/apps/desktop/src-tauri/src/chat.rs b/apps/desktop/src-tauri/src/chat.rs index c212a95..80b3a56 100644 --- a/apps/desktop/src-tauri/src/chat.rs +++ b/apps/desktop/src-tauri/src/chat.rs @@ -70,6 +70,7 @@ pub struct ChatPollResponse { #[serde(rename_all = "camelCase")] pub struct ChatSessionSummary { pub ticket_id: String, + pub ticket_ref: u64, pub unread_count: u32, pub last_activity_at: i64, } @@ -923,7 +924,7 @@ async fn process_chat_update( if let Some(session) = current_sessions.first() { let label = format!("chat-{}", session.ticket_id); if app.get_webview_window(&label).is_none() { - let _ = open_chat_window(app, &session.ticket_id); + let _ = open_chat_window(app, &session.ticket_id, session.ticket_ref); // Minimizar imediatamente após abrir let _ = set_chat_minimized(app, &session.ticket_id, true); } @@ -950,7 +951,7 @@ async fn process_chat_update( // WINDOW MANAGEMENT // ============================================================================ -fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str) -> Result<(), String> { +fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str, ticket_ref: u64) -> Result<(), String> { let label = format!("chat-{}", ticket_id); // Verificar se ja existe @@ -980,7 +981,7 @@ fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str) -> Result< }; // Usar query param ao inves de path para compatibilidade com SPA - let url_path = format!("index.html?view=chat&ticketId={}", ticket_id); + let url_path = format!("index.html?view=chat&ticketId={}&ticketRef={}", ticket_id, ticket_ref); WebviewWindowBuilder::new( app, @@ -989,7 +990,7 @@ fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str) -> Result< ) .title("Chat de Suporte") .inner_size(380.0, 520.0) - .min_inner_size(220.0, 52.0) // Tamanho minimo para modo minimizado com badge + .min_inner_size(240.0, 52.0) // Tamanho minimo para modo minimizado com badge .position(x, y) .decorations(false) // Sem decoracoes nativas - usa header customizado .transparent(true) // Permite fundo transparente @@ -1005,8 +1006,8 @@ fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str) -> Result< Ok(()) } -pub fn open_chat_window(app: &tauri::AppHandle, ticket_id: &str) -> Result<(), String> { - open_chat_window_internal(app, ticket_id) +pub fn open_chat_window(app: &tauri::AppHandle, ticket_id: &str, ticket_ref: u64) -> Result<(), String> { + open_chat_window_internal(app, ticket_id, ticket_ref) } pub fn close_chat_window(app: &tauri::AppHandle, ticket_id: &str) -> Result<(), String> { @@ -1032,7 +1033,7 @@ pub fn set_chat_minimized(app: &tauri::AppHandle, ticket_id: &str, minimized: bo // Tamanhos - chip minimizado com margem extra para badge (absolute -top-1 -right-1) let (width, height) = if minimized { - (220.0, 52.0) // Tamanho com folga para badge que fica fora do chip + (240.0, 52.0) // Tamanho com folga para "Ticket #XXX" e badge } else { (380.0, 520.0) // Tamanho expandido }; diff --git a/apps/desktop/src/chat/ChatWidget.tsx b/apps/desktop/src/chat/ChatWidget.tsx index 99330f7..9b77a0a 100644 --- a/apps/desktop/src/chat/ChatWidget.tsx +++ b/apps/desktop/src/chat/ChatWidget.tsx @@ -38,9 +38,10 @@ function getFileIcon(fileName: string) { interface ChatWidgetProps { ticketId: string + ticketRef?: number } -export function ChatWidget({ ticketId }: ChatWidgetProps) { +export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) { const [messages, setMessages] = useState([]) const [inputValue, setInputValue] = useState("") const [isLoading, setIsLoading] = useState(true) @@ -267,7 +268,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
- {ticketInfo ? `Chat #${ticketInfo.ref}` : "Chat"} + {ticketRef ? `Ticket #${ticketRef}` : ticketInfo?.ref ? `Ticket #${ticketInfo.ref}` : "Chat"} Offline @@ -287,7 +288,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) { > - Chat #{ticketInfo?.ref} + Ticket #{ticketRef ?? ticketInfo?.ref} @@ -321,9 +322,9 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) { Online
- {ticketInfo && ( + {(ticketRef || ticketInfo) && (

- #{ticketInfo.ref} - {ticketInfo.agentName ?? "Suporte"} + Ticket #{ticketRef ?? ticketInfo?.ref} - {ticketInfo?.agentName ?? "Suporte"}

)} diff --git a/apps/desktop/src/chat/convexMachineClient.ts b/apps/desktop/src/chat/convexMachineClient.ts index 55f17d6..2ea3510 100644 --- a/apps/desktop/src/chat/convexMachineClient.ts +++ b/apps/desktop/src/chat/convexMachineClient.ts @@ -30,7 +30,7 @@ let cached: ClientCache | null = null type MachineUpdatePayload = { hasActiveSessions: boolean - sessions: Array<{ ticketId: string; unreadCount: number; lastActivityAt: number }> + sessions: Array<{ ticketId: string; ticketRef: number; unreadCount: number; lastActivityAt: number }> totalUnread: number } diff --git a/apps/desktop/src/chat/index.tsx b/apps/desktop/src/chat/index.tsx index 7e99526..02e7f13 100644 --- a/apps/desktop/src/chat/index.tsx +++ b/apps/desktop/src/chat/index.tsx @@ -1,9 +1,10 @@ import { ChatWidget } from "./ChatWidget" export function ChatApp() { - // Obter ticketId da URL + // Obter ticketId e ticketRef da URL const params = new URLSearchParams(window.location.search) const ticketId = params.get("ticketId") + const ticketRef = params.get("ticketRef") if (!ticketId) { return ( @@ -13,7 +14,7 @@ export function ChatApp() { ) } - return + return } export { ChatWidget } diff --git a/apps/desktop/src/main.tsx b/apps/desktop/src/main.tsx index 9cc3e59..84cff66 100644 --- a/apps/desktop/src/main.tsx +++ b/apps/desktop/src/main.tsx @@ -1098,10 +1098,10 @@ const resolvedAppUrl = useMemo(() => { // Abre/minimiza chat quando aparecem novas não lidas if (hasSessions && totalUnread > prevUnread) { - const ticketId = payload.sessions[0].ticketId - invoke("open_chat_window", { ticketId }).catch(console.error) + const session = payload.sessions[0] + invoke("open_chat_window", { ticketId: session.ticketId, ticketRef: session.ticketRef }).catch(console.error) // Minimiza para não ser intrusivo - invoke("set_chat_minimized", { ticketId, minimized: true }).catch(console.error) + invoke("set_chat_minimized", { ticketId: session.ticketId, minimized: true }).catch(console.error) } prevUnread = totalUnread diff --git a/convex/liveChat.ts b/convex/liveChat.ts index dca3a35..f252439 100644 --- a/convex/liveChat.ts +++ b/convex/liveChat.ts @@ -524,11 +524,18 @@ export const checkMachineUpdates = query({ } } - const sessionSummaries = sessions.map((s) => ({ - ticketId: s.ticketId, - unreadCount: s.unreadByMachine ?? 0, - lastActivityAt: s.lastActivityAt, - })) + // Buscar tickets para obter o reference + const sessionSummaries = await Promise.all( + sessions.map(async (s) => { + const ticket = await ctx.db.get(s.ticketId) + return { + ticketId: s.ticketId, + ticketRef: ticket?.reference ?? 0, + unreadCount: s.unreadByMachine ?? 0, + lastActivityAt: s.lastActivityAt, + } + }) + ) const totalUnread = sessionSummaries.reduce((sum, s) => sum + s.unreadCount, 0) diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index db91ac6..4940ad9 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -81,7 +81,7 @@ const navigation: NavigationGroup[] = [ icon: Ticket, requiredRole: "staff", children: [ - { title: "Todos os tickets", url: "/tickets", icon: Ticket, requiredRole: "staff" }, + { title: "Todos os tickets", url: "/tickets", icon: ClipboardList, requiredRole: "staff" }, { title: "Resolvidos", url: "/tickets/resolved", icon: ShieldCheck, requiredRole: "staff" }, ], }, diff --git a/src/components/tickets/ticket-chat-panel.tsx b/src/components/tickets/ticket-chat-panel.tsx index c5abc4c..7753113 100644 --- a/src/components/tickets/ticket-chat-panel.tsx +++ b/src/components/tickets/ticket-chat-panel.tsx @@ -210,7 +210,7 @@ export function TicketChatPanel({ ticketId }: TicketChatPanelProps) { return ( {/* Header */} - +