Download frontend/src/App.tsx from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 7.74 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/frontend/src/App.tsx
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/frontend/src/App.tsx
-
curl -L -o App.tsx https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/frontend/src/App.tsx
7.74 kB
| import { useEffect, useState } from 'react'; | |
| import { api } from './api'; | |
| import type { Health } from './types'; | |
| import Workspace from './components/Workspace'; | |
| import EvalPage from './components/EvalPage'; | |
| import HistoryPage from './components/HistoryPage'; | |
| import GpuMonitor from './components/GpuMonitor'; | |
| import ComparePage from './components/ComparePage'; | |
| import ExperimentsPage from './components/ExperimentsPage'; | |
| import Connections from './components/Connections'; | |
| import AutomationPage from './components/AutomationPage'; | |
| import TrackingPage from './components/TrackingPage'; | |
| import { useSettings } from './settings'; | |
| import { LangSwitch, useI18n } from './i18n'; | |
| import { ThemeSwitch } from './theme'; | |
| type Page = 'workspace' | 'eval' | 'compare' | 'experiments' | 'automation' | 'history' | 'tracking'; | |
| function readHash(): { page: Page; job?: string; key?: string } { | |
| const h = window.location.hash.replace(/^#\/?/, ''); | |
| const [p, id] = h.split('/'); | |
| if (p === 'eval') return { page: 'eval' }; | |
| if (p === 'history') return { page: 'history' }; | |
| if (p === 'compare') return { page: 'compare' }; | |
| if (p === 'experiments') return { page: 'experiments' }; | |
| if (p === 'automation') return { page: 'automation' }; | |
| if (p === 'tracking') return { page: 'tracking', key: id }; | |
| if (p === 'job' && id) return { page: 'workspace', job: id }; | |
| return { page: 'workspace' }; | |
| } | |
| export default function App() { | |
| const { t, lang } = useI18n(); | |
| const [route, setRoute] = useState(readHash()); | |
| const [health, setHealth] = useState<Health | null>(null); | |
| const [healthErr, setHealthErr] = useState<string | null>(null); | |
| useEffect(() => { | |
| const onHash = () => setRoute(readHash()); | |
| window.addEventListener('hashchange', onHash); | |
| return () => window.removeEventListener('hashchange', onHash); | |
| }, []); | |
| const load = () => api.health().then((h) => { setHealth(h); setHealthErr(null); }) | |
| .catch((e) => setHealthErr(String(e.message || e))); | |
| const autoActive = !!health?.automation?.active; | |
| useEffect(() => { | |
| load(); | |
| const t = setInterval(load, autoActive ? 5000 : 15000); | |
| return () => clearInterval(t); | |
| }, [autoActive]); // eslint-disable-line react-hooks/exhaustive-deps | |
| // Otomasyon bitince: üstte kalıcı uyarı + (izin verildiyse) masaüstü bildirimi | |
| const { prefs } = useSettings(); | |
| const fin = health?.automation?.finished || null; | |
| const act = health?.automation?.active || null; | |
| useEffect(() => { | |
| if (!fin) return; | |
| let last = ''; | |
| try { last = localStorage.getItem('testajani.autoNotified') || ''; } catch { /* yoksay */ } | |
| if (last === fin.id) return; | |
| try { localStorage.setItem('testajani.autoNotified', fin.id); } catch { /* yoksay */ } | |
| if (prefs['auto.notify'] !== false && 'Notification' in window && Notification.permission === 'granted') { | |
| try { | |
| new Notification(fin.status === 'done' ? t('auto.done.title') : t('auto.done.stopped'), | |
| { body: t('auto.notif.body', { d: fin.done, t: fin.total, g: fin.green }), tag: `lta-${fin.id}` }); | |
| } catch { /* yoksay */ } | |
| } | |
| }, [fin?.id]); // eslint-disable-line react-hooks/exhaustive-deps | |
| const fmtDur = (sec: number) => { | |
| const h = Math.floor(sec / 3600), m = Math.round((sec % 3600) / 60); | |
| return h ? t('exp.dur.hm', { h, m }) : sec < 60 ? `${sec} ${t('auto.sec')}` : t('exp.dur.min', { m }); | |
| }; | |
| const dismiss = async () => { if (fin) { try { await api.seenAuto(fin.id); } catch { /* yoksay */ } load(); } }; | |
| const go = (hash: string) => { window.location.hash = hash; }; | |
| const ollamaOk = health?.ollama.ok; | |
| const pillTitle = [health?.ollama.error || health?.ollama.url || healthErr || '', | |
| health?.version ? t('top.version', { v: health.version }) : ''].filter(Boolean).join('\n'); | |
| return ( | |
| <> | |
| <header className="topbar"> | |
| <div className="brand"> | |
| <span className="brand-mark" aria-hidden> | |
| <svg width="16" height="16" viewBox="0 0 32 32"><path d="M7 17l6 6 12-14" stroke="#fff" strokeWidth="4" fill="none" strokeLinecap="round" strokeLinejoin="round" /></svg> | |
| </span> | |
| TestAjanı | |
| {health?.version && <span className="app-version hide-narrow" title={t('top.version', { v: health.version })}>v{health.version.split('-')[0]}</span>} | |
| </div> | |
| <nav className="nav" aria-label={t('nav.aria')}> | |
| <button aria-current={route.page === 'workspace' ? 'page' : undefined} onClick={() => go('/')}>{t('nav.workspace')}</button> | |
| <button aria-current={route.page === 'eval' ? 'page' : undefined} onClick={() => go('/eval')}>{t('nav.eval')}</button> | |
| <button aria-current={route.page === 'compare' ? 'page' : undefined} onClick={() => go('/compare')}>{t('nav.compare')}</button> | |
| <button aria-current={route.page === 'experiments' ? 'page' : undefined} onClick={() => go('/experiments')}>{t('nav.experiments')}</button> | |
| <button aria-current={route.page === 'automation' ? 'page' : undefined} onClick={() => go('/automation')}>{t('nav.automation')}</button> | |
| <button aria-current={route.page === 'history' ? 'page' : undefined} onClick={() => go('/history')}>{t('nav.history')}</button> | |
| <button aria-current={route.page === 'tracking' ? 'page' : undefined} onClick={() => go('/tracking')}>{t('nav.tracking')}</button> | |
| </nav> | |
| <div className="spacer" /> | |
| {act && route.page !== 'automation' && ( | |
| <a className="status-pill auto-chip" href="#/automation" | |
| title={t('auto.chip.title', { c: act.current ? (lang === 'en' ? act.current[0] : act.current[1]) : '…' })}> | |
| <span className="dot ok pulse" /><span className="label"><span className="hide-narrow">{t('nav.automation')} </span>{act.done}/{act.total}</span> | |
| </a> | |
| )} | |
| <GpuMonitor /> | |
| <div className="status-pill" title={pillTitle}> | |
| <span className={`dot ${healthErr ? 'bad' : ollamaOk ? 'ok' : health ? 'bad' : ''}`} /> | |
| <span className="label"> | |
| {healthErr ? t('top.unreachable') : !health ? t('top.connecting') : ollamaOk | |
| ? t('top.ollamaOk', { n: health.ollama.models.length }) : t('top.ollamaDown')} | |
| </span> | |
| {health && <span className="label muted hide-wide">· {t('top.sandbox', { mode: health.sandbox_mode })}</span>} | |
| </div> | |
| <Connections health={health} onChange={load} /> | |
| <LangSwitch /> | |
| <ThemeSwitch /> | |
| </header> | |
| {fin && ( | |
| <div className={`done-banner${fin.status === 'done' ? '' : ' stopped'}`} role="status"> | |
| <span className="done-ico">{fin.status === 'done' ? '✓' : '!'}</span> | |
| <div><strong>{fin.status === 'done' ? t('auto.done.title') : t('auto.done.stopped')}</strong> | |
| <div className="small">{t('auto.done.text', { t: fin.total, d: fin.done, g: fin.green, f: fin.failed, s: fmtDur(fin.duration_s) })}</div></div> | |
| <span className="spacer" /> | |
| <button className="btn primary btn-sm" onClick={() => { go('/automation'); dismiss(); }}>{t('auto.done.view')}</button> | |
| <button className="btn btn-sm" onClick={dismiss}>{t('auto.done.dismiss')}</button> | |
| </div> | |
| )} | |
| {route.page === 'workspace' && <Workspace health={health} jobId={route.job} />} | |
| {route.page === 'eval' && <EvalPage health={health} />} | |
| {route.page === 'compare' && <ComparePage />} | |
| {route.page === 'experiments' && <ExperimentsPage health={health} />} | |
| {route.page === 'automation' && <AutomationPage health={health} />} | |
| {route.page === 'history' && <HistoryPage />} | |
| {route.page === 'tracking' && <TrackingPage health={health} initial={route.key} />} | |
| </> | |
| ); | |
| } | |