Commit graph

932 commits

Author SHA1 Message Date
esdrasrenan
0e0bd9a49c Otimizações de performance e correções no chat ao vivo
- Corrigir acentuações (sessão, sessões, duração)
- Auto-minimizar chat nativo quando sessão termina
- Corrigir race condition em markMachineMessagesRead (Promise.all)
- Adicionar paginação no cron autoEndInactiveSessions (.take(50))
- Otimizar listMachineMessages com limite de 100 mensagens
- Corrigir memory leak no ChatWidget (limite de 200 mensagens)
- Exibir estado offline quando não há sessão ativa

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 15:14:47 -03:00
esdrasrenan
115c5128a6 Consolidate chat timeline events + auto-end inactive sessions
Timeline consolidation:
- Replace multiple LIVE_CHAT_STARTED/ENDED events with single LIVE_CHAT_SUMMARY
- Show total duration accumulated across all sessions
- Display session count (e.g., "23min 15s total - 3 sessoes")
- Show "Ativo" badge when session is active

Auto-end inactive chat sessions:
- Add cron job running every minute to check inactive sessions
- Automatically end sessions after 5 minutes of client inactivity
- Mark auto-ended sessions with "(encerrado por inatividade)" flag

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 14:44:34 -03:00
esdrasrenan
409da8afda Fix duration format and minimized chat layout
- Format duration as hours+minutes when > 60min (e.g., 2h 26min)
- Change minimized chat to compact chip style (matching web)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 14:37:28 -03:00
esdrasrenan
229c9aa1c7 Match desktop chat layout with web version
- Change agent icon from Headphones to MessageCircle
- Adjust avatar size to size-7 and icons to size-3.5
- Reposition attach button next to send button (textarea -> attach -> send)
- Add Online indicator in header with animated green dot
- Implement minimized state (collapsed view like web)
- Hide web chat widget when running in Tauri context (avoid duplicate)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 13:58:36 -03:00
esdrasrenan
7e270bcd3b Update chat layout to match web version
- Client messages on left with white background and border
- Agent messages on right with black background
- Added circular avatars (User icon for client, Headphones for agent)
- Improved spacing and visual consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 13:24:40 -03:00
esdrasrenan
fd0e29514a fix(desktop): restore custom chat window header
Revert to frameless window with custom header containing
minimize/close buttons and drag region.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 13:20:35 -03:00
esdrasrenan
c217a40030 feat(desktop): add file attachments and native chat window
- Add file upload support in chat (PDF, images, txt, docs, xlsx)
  - Limited to 10MB max file size
  - Only allowed extensions for security
- Use native Windows decorations for chat window
- Remove ChatFloatingWidget (replaced by native window)
- Simplify chat event listeners (window managed by Rust)
- Fix typo "sessao" -> "sessão"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 13:09:55 -03:00
esdrasrenan
2f89fa33fe fix(desktop): use correct store path in chat widgets
ChatWidget and ChatFloatingWidget were using relative path
"machine-agent.json" instead of the full path with appLocalDataDir().
This caused "Maquina nao registrada" error in chat window.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 12:46:32 -03:00
esdrasrenan
d00c59e0b5 feat(desktop): auto-open chat window on new message
When a new message arrives from a support agent, the chat window
now opens automatically without user interaction.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 12:34:37 -03:00
esdrasrenan
faa6e28765 Add visual debug indicator to chat widget
Shows unread count and sessions count next to the chat button
for debugging purposes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 12:18:46 -03:00
esdrasrenan
b10548157e Add debug logs for chat and red border to end chat button
- Add detailed debug logs in Rust (chat.rs) to trace polling flow
- Add console.log in frontend (main.tsx) to trace event reception
- Add red border to "Encerrar" button in chat panels for better visibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 12:03:40 -03:00
esdrasrenan
4f81f62429 Fix unread badge - increment unreadByMachine when agent sends message
The unreadByMachine counter was never being incremented when agents sent
chat messages, causing the badge to always show 0. Now when an agent
(ADMIN/MANAGER/AGENT) posts a message to a ticket with an active chat
session, the counter is incremented properly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 11:34:47 -03:00
esdrasrenan
88a3b37f2f Fix chat session management and add floating widget
- Fix session sync: events now send complete ChatSession data instead of
  partial ChatSessionSummary, ensuring proper ticket/agent info display
- Add session-ended event detection to remove closed sessions from client
- Add ChatFloatingWidget component for in-app chat experience
- Restrict endSession to ADMIN/MANAGER/AGENT roles only
- Improve polling logic to detect new and ended sessions properly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 11:16:56 -03:00
esdrasrenan
e4f8f465de Fix chat window behavior - remove auto-open on session start
- Remove automatic window opening when agent starts a chat session
- Remove automatic window focus when new messages arrive
- Only show Windows notification, user opens chat manually via tray icon
- Update notification message to instruct user to click Raven icon

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 04:07:38 -03:00
esdrasrenan
cd4b702198 Fix Tauri ACL permissions for chat windows
- Add chat-* window pattern to allow chat popup windows
- Add event permissions (listen, unlisten, emit)
- Add window permissions (close, hide, show, set-focus)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 03:58:49 -03:00
esdrasrenan
9c6f19f9a5 Fix chat permission for machine-linked users
Allow COLLABORATOR users who are linked to the ticket's machine
(via assignedUserId or linkedUserIds) to access the chat, not
just the ticket requester.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 03:49:09 -03:00
esdrasrenan
ebeda62cfb Fix lint errors and improve chat UI
Lint fixes:
- Move HIDDEN_EVENT_TYPES constant outside component to fix useMemo dependency
- Add eslint-disable comments for img elements using blob URLs

Chat widget improvements:
- Add view and download buttons with loading and success indicators
- Click image to open in new tab, download button to save file
- Show check icon after successful download

Chat history fixes:
- Fix title to "Histórico de chat" with proper accents
- Change agent icon from Headphones to MessageCircle
- Change agent icon background from primary to gray

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 03:39:14 -03:00
esdrasrenan
f0882c612f Fix ticket link hover color to black
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 03:20:45 -03:00
esdrasrenan
d766de4fda Add chat widget improvements and chat history component
Widget improvements:
- Pulsating badge with unread message count on floating button
- Clickable ticket reference link in chat header
- ExternalLink icon on hover

Desktop (Raven) improvements:
- Track previous unread count for new message detection
- Send native Windows notifications for new messages
- Focus chat window when new messages arrive

Chat history:
- New query getTicketChatHistory for fetching chat sessions and messages
- New component TicketChatHistory displaying chat sessions
- Sessions can be expanded/collapsed to view messages
- Pagination support for long conversations
- Added to both dashboard and portal ticket views

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 03:20:22 -03:00
esdrasrenan
b194d77d57 Add Windows native notifications for chat sessions
- Add tauri-plugin-notification for native Windows notifications
- Send notification when new chat session is started
- Configure notification permissions in capabilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 03:13:41 -03:00
esdrasrenan
f45ee91804 Fix chat widget UI and allow attachment-only messages
- Allow sending messages with only attachments (no text required)
- Change "Chat Ativo" header to just "Chat"
- Replace Headphones icon with MessageCircle for own messages
- Replace PhoneOff icon with XCircle for end chat button

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 03:09:51 -03:00
esdrasrenan
60e98dd47c Retorna status da maquina mesmo sem sessao de chat ativa
A query getTicketSession agora sempre retorna machineOnline,
permitindo que o botao de chat seja habilitado corretamente
quando a maquina esta online mas nao ha sessao ativa.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 02:54:56 -03:00
esdrasrenan
0bd9e993d5 Corrige verificacao de machineId para botao de chat
Usa ticket.machine?.id ao inves de ticket.machineId inexistente
para determinar se o botao de chat deve aparecer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 02:42:22 -03:00
esdrasrenan
c9c08f8e38 Substitui emoji por icone no estado vazio de ticket
Troca o emoji de lupa pelo icone SearchX do lucide-react
para manter consistencia visual com o resto da plataforma.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 02:34:52 -03:00
esdrasrenan
3b1cde79df Melhora chat ao vivo com anexos e eventos de timeline
- Reestrutura visual do widget de chat (header branco, status emerald)
- Adiciona sistema de anexos com upload e drag-and-drop
- Substitui select nativo por componente Select do shadcn
- Adiciona eventos LIVE_CHAT_STARTED e LIVE_CHAT_ENDED na timeline
- Traduz labels de chat para portugues (Chat iniciado/finalizado)
- Filtra CHAT_MESSAGE_ADDED da timeline (apenas inicio/fim aparecem)
- Restringe inicio de chat a tickets com responsavel atribuido
- Exibe duracao da sessao ao finalizar chat

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 02:20:11 -03:00
esdrasrenan
9e676b06f9 Corrige widget de chat para nao quebrar sem API
- Verifica se api.liveChat.listAgentSessions existe antes de renderizar
- Retorna null no provider se Convex nao estiver sincronizado

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 01:32:34 -03:00
esdrasrenan
8c465008bf Adiciona widget de chat flutuante global
- Widget no canto inferior direito em todas as paginas
- Mostra sessoes de chat ativas do agente
- Suporta multiplas sessoes com seletor
- Badge com contador de mensagens nao lidas
- Pode minimizar ou fechar
- Query listAgentSessions para buscar sessoes ativas

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 01:31:00 -03:00
esdrasrenan
2a78d14a74 Redesenha widget de chat com visual moderno
- Layout estilo messenger com baloes de mensagem
- Avatares para agente (headphones) e usuario (user)
- Cores distintas: preto para agente, branco para cliente
- Header com status online/offline da maquina
- Input com Enter para enviar
- Scroll automatico para novas mensagens

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 01:24:33 -03:00
esdrasrenan
b7f150e2b7 Atualiza bun.lock apos remocao de dependencias
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 01:08:37 -03:00
esdrasrenan
5aa5736ba4 Remove dependencias nao utilizadas do desktop
Remove @assistant-ui/react, @assistant-ui/react-markdown e remark-gfm
que foram adicionadas mas nao estao sendo usadas (componente customizado)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 01:06:22 -03:00
esdrasrenan
ba91c1e0f5 Implementa sistema de chat em tempo real entre agente e cliente
- Adiciona tabela liveChatSessions no schema Convex
- Cria convex/liveChat.ts com mutations e queries para chat
- Adiciona API routes para maquinas (sessions, messages, poll)
- Cria modulo chat.rs no Tauri com ChatRuntime e polling
- Adiciona comandos de chat no lib.rs (start/stop polling, open/close window)
- Cria componentes React do chat widget (ChatWidget, types)
- Adiciona botao "Iniciar Chat" no dashboard (ticket-chat-panel)
- Implementa menu de chat no system tray
- Polling de 2 segundos para maior responsividade
- Janela de chat flutuante, frameless, always-on-top

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 01:00:27 -03:00
esdrasrenan
0c8d53c0b6 Add status badge to USB policy chip in device details
- Replace parentheses text with styled badge
- Use color-coded badges: success (green), warning (amber), error (red)
- Add APPLYING status support
- Match badge style with custom fields counter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:52:56 -03:00
esdrasrenan
71757a1d59 Use neutral gray colors for info card
- Info icon in black (text-foreground)
- Badges in gray (bg-slate-100, border-slate-200)
- Badge text in black (text-foreground)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:44:54 -03:00
esdrasrenan
a1292df245 Improve info card styling with system colors
- Use primary/accent colors instead of hardcoded blue
- Increase text sizes (text-sm for title, text-xs for chips and note)
- Increase icon and chip sizes for better readability
- Use text-secondary for chip text, text-muted-foreground for note

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:43:46 -03:00
esdrasrenan
3aa348dc4a Add info card showing affected USB devices
- Shows affected devices: pen drives, external HDs, SD cards
- Clarifies that keyboards, mice, printers are not affected
- Uses subtle blue info card design with device chips

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:42:39 -03:00
esdrasrenan
d476761f22 Improve USB policy filters layout and sizing
- Use grid layout with 2 columns for better space usage
- Increase filter height to h-9 for better readability
- Move "Limpar" button to header row
- Add proper padding and spacing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:26:07 -03:00
esdrasrenan
873305fa7f Improve USB policy history with filters and pagination
- Fix bug where APPLYING status would not transition to APPLIED
- Add status and date range filters to policy history
- Add cursor-based pagination with "Load more" button
- Use DateRangeButton component for date filtering
- Reset filters and pagination when switching filters

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:24:23 -03:00
esdrasrenan
5846c299ce Fix Convex validator to accept null for optional string fields
Rust serializes Option<String>::None as null, not undefined.
Updated reportUsbPolicyStatus mutation to accept both null and undefined
for error and currentPolicy fields.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:00:16 -03:00
esdrasrenan
20b63f4ad6 Fix USB policy reporting and improve agent reliability
- Fix Zod schema to accept null values (nullable) for error/currentPolicy
- Add robust logging system writing to raven-agent.log file
- Rewrite auto-start using winreg with validation
- Auto-start agent on app setup if credentials exist
- Reduce retry attempts to 2 (1 + 1 retry after 2s)
- Replace provider's remote access on ID change (prevents duplicates)
- Update agent to v0.2.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 22:43:15 -03:00
esdrasrenan
b60255fe03 Improve USB policy responsiveness and reliability
- Reduce USB policy polling from 60s to 15s for faster response
- Add retry with exponential backoff (2s, 4s, 8s) on report failures
- Add APPLYING state for real-time progress bar feedback
- Check if policy is already applied locally before re-applying
- Fix API schema to accept APPLYING status
- Update agent to v0.1.9

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 17:51:57 -03:00
esdrasrenan
23e7cf58ae Redesenho da UI de dispositivos e correcao de VRAM
- Reorganiza layout da tela de dispositivos admin
- Renomeia secao "Controles do dispositivo" para "Atalhos"
- Adiciona botao de Tickets com badge de quantidade
- Simplifica textos de botoes (Acesso, Resetar)
- Remove email da maquina do cabecalho
- Move empresa e status para mesma linha
- Remove chip de Build do resumo
- Corrige deteccao de VRAM para GPUs >4GB usando nvidia-smi
- Adiciona prefixo "VRAM" na exibicao de memoria da GPU
- Documenta sincronizacao RustDesk

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 17:01:40 -03:00
rever-tecnologia
c5150fee8f Fix useCallback missing dependency warning
Add config.machineId to openSystem dependency array

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 17:25:41 -03:00
rever-tecnologia
cf31e78edb Add requester filter and improve error messages
- Add requester filter to device tickets history page
- Create listMachineRequesters query to list unique requesters
- Add friendly API error formatting in desktop agent
- Translate validation errors to user-friendly Portuguese messages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 17:22:44 -03:00
rever-tecnologia
bb82efa9d3 Preserve machine identity based on hardware
- Add by_tenant_hostname index for hostname-based lookup
- Add third search in register mutation for hardware matching
- Search by hostname + MAC/serial when fingerprint/email differ
- Fallback to MAC/serial match across all tenant machines
- Preserves ticket history when user changes on same physical machine

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 17:00:19 -03:00
rever-tecnologia
376e81c9c7 Fix RustDesk remote access sync after agent install
- Reload config/token directly from store before syncing
- Avoid race condition when register() calls ensureRustdesk before React state updates
- Ensures machineId and token are always fresh from disk

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 16:52:05 -03:00
rever-tecnologia
bc41f6ae34 Update SMTP password
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 16:28:27 -03:00
rever-tecnologia
4b1198271d Add SMTP configuration and documentation
- Update .env.example with SMTP variables
- Create docs/SMTP.md with credentials and usage examples
- Tested successfully on 2025-12-05

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 16:14:15 -03:00
rever-tecnologia
bfcec46328 Fix RustDesk deep link to include self-hosted server
- Add RUSTDESK_SERVER and RUSTDESK_SERVER_KEY constants
- Update buildRustDeskUri to use ID@SERVER format
- Include server key in URI for proper server identification
- This allows 1-click connection without client pre-configuration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 16:10:30 -03:00
rever-tecnologia
90d2221240 Fix RustDesk sync before auto-launch redirect
The RustDesk data saved by Rust directly to file was not being
synced to the backend because the app redirected to the web platform
before the sync could complete.

- Reload store from disk in openSystem to get Rust-saved data
- Sync RustDesk before redirecting with 3s timeout
- Fire-and-forget sync to avoid blocking the redirect

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 15:38:35 -03:00
rever-tecnologia
2c47e84cab Salvar dados do RustDesk diretamente no machine-agent.json pelo Rust
- Resolve conflito entre Tauri Store (TypeScript) e escrita direta (Rust)
- O Rust agora salva a chave "rustdesk" no arquivo apos provisionamento
- O TypeScript pode ler os dados via Store.load() normalmente
- Garante que os dados do RustDesk estejam disponiveis para sincronizacao

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 14:56:12 -03:00