mirror of
https://github.com/R0m1k3/EveFlow.git
synced 2026-10-11 17:29:03 +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
82 lines
2.9 KiB
TypeScript
82 lines
2.9 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { bridge } from '../../lib/bridge';
|
|
import { httpFetch } from '../../lib/transport';
|
|
import { useSettings } from '../../state/settings';
|
|
import { hermesBaseUrl } from '../../services/hermes/client';
|
|
|
|
const cache = new Map<string, string>();
|
|
const failures = new Map<string, string>();
|
|
|
|
interface Props {
|
|
src?: string;
|
|
alt?: string;
|
|
onOpen?: (src: string) => void;
|
|
}
|
|
|
|
/**
|
|
* Renders images coming from Hermes: data URLs, http(s), Windows/file paths (read through the
|
|
* main process) and server-side absolute paths (fetched from the Hermes host with auth).
|
|
*/
|
|
export function ResilientImage({ src = '', alt, onOpen }: Props) {
|
|
const [resolved, setResolved] = useState<string>(() => cache.get(src) ?? '');
|
|
const [error, setError] = useState<string>(() => failures.get(src) ?? '');
|
|
const hermes = useSettings((s) => s.settings.hermes);
|
|
|
|
useEffect(() => {
|
|
if (!src) return;
|
|
let cancelled = false;
|
|
const ok = (value: string) => {
|
|
cache.set(src, value);
|
|
if (!cancelled) {
|
|
setResolved(value);
|
|
setError('');
|
|
}
|
|
};
|
|
const fail = (message: string) => {
|
|
failures.set(src, message);
|
|
if (!cancelled) setError(message);
|
|
};
|
|
if (cache.has(src)) {
|
|
setResolved(cache.get(src)!);
|
|
return;
|
|
}
|
|
if (failures.has(src)) {
|
|
setError(failures.get(src)!);
|
|
return;
|
|
}
|
|
if (src.startsWith('data:') || src.startsWith('blob:') || /^https?:\/\//i.test(src)) {
|
|
ok(src);
|
|
return;
|
|
}
|
|
const api = bridge();
|
|
const isLocal = src.startsWith('file://') || /^[a-zA-Z]:[\\/]/.test(src);
|
|
const fromHermes = async () => {
|
|
if (!hermes.url) throw new Error('chemin local inaccessible');
|
|
const base = hermesBaseUrl(hermes.url);
|
|
const path = src.replace(/^file:\/\//, '').replace(/\\/g, '/');
|
|
const headers: Record<string, string> = {};
|
|
if (hermes.apiKey) headers.Authorization = `Bearer ${hermes.apiKey}`;
|
|
const res = await httpFetch({ url: `${base}/${path.replace(/^\//, '')}`, headers, responseType: 'binary', timeoutMs: 15_000 });
|
|
if (!res.ok || !res.binary) throw new Error(`HTTP ${res.status}`);
|
|
const type = res.headers['content-type'] || 'image/png';
|
|
const bytes = new Uint8Array(res.binary);
|
|
return URL.createObjectURL(new Blob([bytes], { type }));
|
|
};
|
|
const task = isLocal && api ? api.files.readLocal(src).catch(fromHermes) : fromHermes();
|
|
task.then(ok).catch((err: Error) => fail(err.message || 'image inaccessible'));
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, [src, hermes.url, hermes.apiKey]);
|
|
|
|
if (error && !resolved) {
|
|
return (
|
|
<span className="img-error" title={src}>
|
|
Image inaccessible ({error})
|
|
</span>
|
|
);
|
|
}
|
|
if (!resolved) return <span className="img-error pulse">chargement…</span>;
|
|
return <img src={resolved} alt={alt ?? 'image'} loading="lazy" onClick={() => onOpen?.(resolved)} />;
|
|
}
|