fix(chat): correções de SSE, inicialização e área de clique
- Substituir WebSocket por SSE para real-time (chat.rs) - Corrigir inicialização do chat runtime em lib.rs - Iniciar unreadByMachine em 0 ao criar sessão (liveChat.ts) - Corrigir área de clique do chip minimizado (pointer-events) - Corrigir roteamento SPA no Tauri (index.html?view=chat) - Corrigir estado inicial isMinimized como true 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3aee1a6694
commit
3c2d1824fb
7 changed files with 213 additions and 256 deletions
|
|
@ -118,28 +118,9 @@ export const startSession = mutation({
|
|||
)
|
||||
)
|
||||
|
||||
const cutoff = lastEndedSession?.endedAt ?? 0
|
||||
|
||||
const machineUserIds = [
|
||||
machine.assignedUserId,
|
||||
...(machine.linkedUserIds ?? []),
|
||||
ticket.requesterId,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.map((id) => id!.toString())
|
||||
|
||||
const unreadByMachine = await ctx.db
|
||||
.query("ticketChatMessages")
|
||||
.withIndex("by_ticket_created", (q) => q.eq("ticketId", ticketId))
|
||||
.collect()
|
||||
.then((messages) =>
|
||||
messages.filter((msg) => {
|
||||
if (msg.createdAt <= cutoff) return false
|
||||
return !machineUserIds.includes(msg.authorId.toString())
|
||||
}).length
|
||||
)
|
||||
|
||||
// Criar nova sessao
|
||||
// unreadByMachine inicia em 0 - a janela de chat só abrirá quando o agente
|
||||
// efetivamente enviar uma mensagem nova (incrementado em tickets.postChatMessage)
|
||||
const sessionId = await ctx.db.insert("liveChatSessions", {
|
||||
tenantId: ticket.tenantId,
|
||||
ticketId,
|
||||
|
|
@ -153,7 +134,7 @@ export const startSession = mutation({
|
|||
status: "ACTIVE",
|
||||
startedAt: now,
|
||||
lastActivityAt: now,
|
||||
unreadByMachine,
|
||||
unreadByMachine: 0,
|
||||
unreadByAgent: 0,
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue