mirror of
https://github.com/R0m1k3/EveFlow.git
synced 2026-10-12 01:39:13 +02:00
Electron main - utility-process channel: sherpa output copied into V8 buffers (Electron rejects external buffers), audio exchanged as base64; worker restart on timeout, identity-safe exit handling, deterministic native unload by restart - webhook: loopback by default without secret, UTF-8-safe body assembly, clean restart, port validation - files IPC: realpath-based root check, openPath allow-list (reveal-only outside document folders), Windows reserved names; store: debounced async atomic writes with backup of corrupt files; logger: streaming writes with rotation; log message size cap - HTTP stream proxy: socket released on idle timeout / renderer destroyed, id validation - model manager: inactivity timeout, retrying rm/rename (Windows locks), engine stopped before replacing a model; WAV decoder handles float/24-bit; IPC payload validation - window: opaque rounded window on Windows, navigation lock-down, visibility events; Ctrl+Alt+Escape instead of the Task Manager shortcut; single-instance guard; EVEFLOW_USER_DATA Voice pipeline - abort semantics (SendHandle.aborted), abort before the stream opens, session id prefixes per transport - hands-free re-arm after replies without speech, start/stop race, no chime on auto re-arm, no silence shipped to STT (400 ms pre-roll), no transcription of empty manual stops - TTS: bounded prefetch, cancellable segments, non-interrupting notices, volume applied at play time - SSE CRLF split, usage in chat completions, finish_reason length, phonetic regex hoisted HUD - core renderer: no canvas shadows, cached colours, reusable spectrum buffer, theme read on change, 30 fps idle, stops when the window is hidden; ping flashes on send / tool / speech - deltas coalesced per animation frame; stable auto-scroll; narrow selectors everywhere - bundled fonts (offline), reduce-motion fix, error toasts, ops drawer below 1180 px, interim transcript and first-token latency in the core caption, Ctrl+K, dialog semantics, switch/aria roles, compact widget cleanup, Whisper small recommended for French - docs/ROADMAP.md: audit results, e2e results and the plan towards a real JARVIS Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Wn5VX9HNbJ7N54hR24u9Y
107 lines
4.2 KiB
TypeScript
107 lines
4.2 KiB
TypeScript
import { memo, useEffect, useRef, useState } from 'react';
|
|
import ReactMarkdown from 'react-markdown';
|
|
import remarkGfm from 'remark-gfm';
|
|
import { Copy, Volume2, Check } from 'lucide-react';
|
|
import { bridge } from '../../lib/bridge';
|
|
import { formatTime, preprocessMedia } from '../../lib/text';
|
|
import { speech } from '../../services/voice/speech';
|
|
import type { ChatMessage } from '../../state/chat';
|
|
import { ResilientImage } from './ResilientImage';
|
|
|
|
interface Props {
|
|
message: ChatMessage;
|
|
assistantName: string;
|
|
userName: string;
|
|
showReasoning: boolean;
|
|
compact?: boolean;
|
|
onOpenImage?: (src: string) => void;
|
|
}
|
|
|
|
function openLink(href: string): void {
|
|
const api = bridge();
|
|
if (/^(file:\/\/|[a-zA-Z]:[\\/])/.test(href) && api) {
|
|
api.files.openPath(href).catch(() => undefined);
|
|
return;
|
|
}
|
|
window.open(href, '_blank', 'noopener');
|
|
}
|
|
|
|
export const MessageBubble = memo(function MessageBubble({ message, assistantName, userName, showReasoning, compact, onOpenImage }: Props) {
|
|
const [copied, setCopied] = useState(false);
|
|
const copyTimer = useRef<number | null>(null);
|
|
useEffect(() => () => {
|
|
if (copyTimer.current) window.clearTimeout(copyTimer.current);
|
|
}, []);
|
|
const isUser = message.role === 'user';
|
|
const who = isUser ? userName || 'VOUS' : message.role === 'system' ? 'SYSTÈME' : assistantName;
|
|
const status = message.status ?? 'done';
|
|
|
|
const copy = () => {
|
|
navigator.clipboard.writeText(message.content).then(() => {
|
|
setCopied(true);
|
|
if (copyTimer.current) window.clearTimeout(copyTimer.current);
|
|
copyTimer.current = window.setTimeout(() => setCopied(false), 1200);
|
|
}).catch(() => undefined);
|
|
};
|
|
|
|
return (
|
|
<div className={`msg ${message.role}`}>
|
|
{!compact && (
|
|
<div className="msg-meta">
|
|
<span className="who">{who}</span>
|
|
<span>{formatTime(message.timestamp)}</span>
|
|
{message.source && message.source !== 'eveflow' && <span className={`src ${message.source}`}>{message.jobName ? `cron · ${message.jobName}` : message.source}</span>}
|
|
{message.transport && message.role === 'assistant' && <span className="src">{message.transport}</span>}
|
|
{message.usage?.total_tokens ? <span>{message.usage.total_tokens} tok</span> : null}
|
|
{message.role === 'assistant' && status === 'done' && (
|
|
<span className="msg-actions">
|
|
<button className="icon-btn" title="Copier" aria-label="Copier le message" onClick={copy}>{copied ? <Check size={13} /> : <Copy size={13} />}</button>
|
|
<button className="icon-btn" title="Lire à voix haute" aria-label="Lire à voix haute" onClick={() => speech.say(message.content)}><Volume2 size={13} /></button>
|
|
</span>
|
|
)}
|
|
</div>
|
|
)}
|
|
<div className={`bubble ${status}`}>
|
|
{message.images && message.images.length > 0 && (
|
|
<div className="msg-images">
|
|
{message.images.map((img, i) => (
|
|
<ResilientImage key={i} src={img} alt={`image ${i + 1}`} onOpen={onOpenImage} />
|
|
))}
|
|
</div>
|
|
)}
|
|
{showReasoning && message.reasoning && (
|
|
<details className="reasoning">
|
|
<summary>raisonnement</summary>
|
|
{message.reasoning}
|
|
</details>
|
|
)}
|
|
{message.role === 'user' ? (
|
|
<span style={{ whiteSpace: 'pre-wrap' }}>{message.content}</span>
|
|
) : (
|
|
<div className="md">
|
|
<ReactMarkdown
|
|
remarkPlugins={[remarkGfm]}
|
|
components={{
|
|
img: ({ src, alt }) => <ResilientImage src={typeof src === 'string' ? src : ''} alt={alt} onOpen={onOpenImage} />,
|
|
a: ({ href, children }) => (
|
|
<a
|
|
href={href}
|
|
onClick={(e) => {
|
|
e.preventDefault();
|
|
if (href) openLink(href);
|
|
}}
|
|
>
|
|
{children}
|
|
</a>
|
|
)
|
|
}}
|
|
>
|
|
{preprocessMedia(message.content) || (status === 'streaming' ? '' : '…')}
|
|
</ReactMarkdown>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
});
|