Viewer: - Toolbar: Ctrl+Alt+Del, clipboard paste, monitor picker, file transfer, chat, WoL buttons - Multi-monitor: agent sends monitor_list on connect, viewer can switch via dropdown - Clipboard sync: agent polls local clipboard → sends to viewer; viewer paste → agent sets remote clipboard - File transfer panel: drag-drop upload to agent, directory browser, download files from remote - Chat panel: bidirectional text chat forwarded through relay Agent: - Multi-monitor capture with set_monitor/set_quality message handlers - exec_key_combo for Ctrl+Alt+Del and arbitrary combos - Clipboard polling via pyperclip (both directions) - File upload/download/list_files with base64 chunked protocol - Attended mode (--attended): zenity/kdialog/PowerShell consent dialog before accepting stream - Auto-update: heartbeat checks version, downloads new binary and exec-replaces self (Linux) - Reports MAC address on registration (for WoL) Relay: - Forwards monitor_list, clipboard_content, file_chunk, file_list, chat_message agent→viewer - Session recording: when RECORDING_DIR env set, saves JPEG frames as .remrec files - ALLOWED_ORIGINS CORS now set from NEXT_PUBLIC_APP_URL in docker-compose Database: - groups table (id, name, description, created_by) - machines: group_id, mac_address, notes, tags text[] - Migration 0003 applied Dashboard: - Machines page: search, tag filter, group filter, inline notes/tags/rename editing - MachineCard: inline tag management, group picker, notes textarea - Admin page: new Groups tab (create/list/delete groups) - API: PATCH /api/machines/[id] (name, notes, tags, groupId) - API: GET/POST/DELETE /api/groups - API: POST /api/machines/wol (broadcast magic packet) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
106 lines
3.3 KiB
TypeScript
106 lines
3.3 KiB
TypeScript
'use client'
|
|
|
|
import { useState, useEffect, useRef } from 'react'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Input } from '@/components/ui/input'
|
|
import { ScrollArea } from '@/components/ui/scroll-area'
|
|
import { X, Send } from 'lucide-react'
|
|
|
|
interface ChatMessage {
|
|
id: string
|
|
from: 'technician' | 'agent'
|
|
text: string
|
|
timestamp: Date
|
|
}
|
|
|
|
interface ChatPanelProps {
|
|
onClose: () => void
|
|
sendEvent: (event: Record<string, unknown>) => void
|
|
incomingMessage: Record<string, unknown> | null
|
|
}
|
|
|
|
export function ChatPanel({ onClose, sendEvent, incomingMessage }: ChatPanelProps) {
|
|
const [messages, setMessages] = useState<ChatMessage[]>([])
|
|
const [input, setInput] = useState('')
|
|
const scrollRef = useRef<HTMLDivElement>(null)
|
|
|
|
useEffect(() => {
|
|
if (!incomingMessage) return
|
|
if (incomingMessage.type === 'chat_message') {
|
|
setMessages(prev => [...prev, {
|
|
id: crypto.randomUUID(),
|
|
from: 'agent',
|
|
text: incomingMessage.text as string,
|
|
timestamp: new Date(),
|
|
}])
|
|
}
|
|
}, [incomingMessage])
|
|
|
|
useEffect(() => {
|
|
// Auto-scroll to bottom on new messages
|
|
if (scrollRef.current) {
|
|
scrollRef.current.scrollTop = scrollRef.current.scrollHeight
|
|
}
|
|
}, [messages])
|
|
|
|
const send = () => {
|
|
const text = input.trim()
|
|
if (!text) return
|
|
sendEvent({ type: 'chat_message', text })
|
|
setMessages(prev => [...prev, {
|
|
id: crypto.randomUUID(),
|
|
from: 'technician',
|
|
text,
|
|
timestamp: new Date(),
|
|
}])
|
|
setInput('')
|
|
}
|
|
|
|
const fmt = (d: Date) =>
|
|
d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
|
|
return (
|
|
<div className="w-72 border-l border-border/50 bg-card flex flex-col h-full">
|
|
<div className="flex items-center justify-between p-3 border-b border-border/50">
|
|
<span className="text-sm font-medium">Session Chat</span>
|
|
<Button variant="ghost" size="icon" className="h-6 w-6" onClick={onClose}>
|
|
<X className="h-3.5 w-3.5" />
|
|
</Button>
|
|
</div>
|
|
|
|
<div ref={scrollRef} className="flex-1 overflow-y-auto p-3 space-y-3">
|
|
{messages.length === 0 && (
|
|
<p className="text-xs text-muted-foreground text-center pt-8">
|
|
Messages sent here are forwarded to the remote machine.
|
|
</p>
|
|
)}
|
|
{messages.map((m) => (
|
|
<div key={m.id} className={`flex flex-col gap-0.5 ${m.from === 'technician' ? 'items-end' : 'items-start'}`}>
|
|
<div className={`max-w-[85%] rounded-lg px-3 py-1.5 text-xs ${
|
|
m.from === 'technician'
|
|
? 'bg-primary text-primary-foreground'
|
|
: 'bg-muted text-foreground'
|
|
}`}>
|
|
{m.text}
|
|
</div>
|
|
<span className="text-[10px] text-muted-foreground">{fmt(m.timestamp)}</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
|
|
<div className="p-2 border-t border-border/50 flex gap-1.5">
|
|
<Input
|
|
value={input}
|
|
onChange={e => setInput(e.target.value)}
|
|
onKeyDown={e => { if (e.key === 'Enter') send() }}
|
|
placeholder="Type a message…"
|
|
className="h-8 text-xs"
|
|
/>
|
|
<Button size="icon" className="h-8 w-8 shrink-0" onClick={send} disabled={!input.trim()}>
|
|
<Send className="h-3.5 w-3.5" />
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|