fix(chat): ajustes de texto, layout e icone do menu

- 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 <noreply@anthropic.com>
This commit is contained in:
rever-tecnologia 2025-12-09 13:06:03 -03:00
parent 3c2d1824fb
commit d20ebf7416
8 changed files with 35 additions and 25 deletions

View file

@ -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
};

View file

@ -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<ChatMessage[]>([])
const [inputValue, setInputValue] = useState("")
const [isLoading, setIsLoading] = useState(true)
@ -267,7 +268,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
<div className="pointer-events-auto flex items-center gap-2 rounded-full bg-slate-200 px-4 py-2 text-slate-600 shadow-lg">
<MessageCircle className="size-4" />
<span className="text-sm font-medium">
{ticketInfo ? `Chat #${ticketInfo.ref}` : "Chat"}
{ticketRef ? `Ticket #${ticketRef}` : ticketInfo?.ref ? `Ticket #${ticketInfo.ref}` : "Chat"}
</span>
<span className="size-2 rounded-full bg-slate-400" />
<span className="text-xs text-slate-500">Offline</span>
@ -287,7 +288,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
>
<MessageCircle className="size-4" />
<span className="text-sm font-medium">
Chat #{ticketInfo?.ref}
Ticket #{ticketRef ?? ticketInfo?.ref}
</span>
<span className="size-2 rounded-full bg-emerald-400" />
<ChevronUp className="size-4" />
@ -321,9 +322,9 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
Online
</span>
</div>
{ticketInfo && (
{(ticketRef || ticketInfo) && (
<p className="text-xs text-slate-500">
#{ticketInfo.ref} - {ticketInfo.agentName ?? "Suporte"}
Ticket #{ticketRef ?? ticketInfo?.ref} - {ticketInfo?.agentName ?? "Suporte"}
</p>
)}
</div>

View file

@ -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
}

View file

@ -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 <ChatWidget ticketId={ticketId} />
return <ChatWidget ticketId={ticketId} ticketRef={ticketRef ? Number(ticketRef) : undefined} />
}
export { ChatWidget }

View file

@ -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