{p.title}
{p.word_count} words / {language === 'en' ? 'English' : 'Greek'}
import React, { useEffect, useRef, useState } from 'react'
import { PandaIllustration, Icon, LoopIcon } from './Icons.jsx'
import { api, postJson } from './api.js'
import { Session } from './Session.jsx'
import { clearDraft } from './useDraft.js'
import { Lab } from './Lab.jsx'
const policyNames = { fixed: 'Fixed practice', adaptive: 'Adaptive practice', comparison: 'Compare approaches', 'learning-fixed': 'Reading outcome: fixed', 'learning-epsilon': 'Reading outcome: epsilon greedy', 'learning-linucb': 'Reading outcome: LinUCB', 'learning-comparison': 'Reading outcome: randomized comparison' }
export function App() {
const [language, setLanguage] = useState('en')
const [split, setSplit] = useState('practice')
const [mode, setMode] = useState('fixed')
const [view, setView] = useState('reading')
const [catalog, setCatalog] = useState([])
const [sessions, setSessions] = useState([])
const [selected, setSelected] = useState(null)
const [health, setHealth] = useState(null)
const [report, setReport] = useState(null)
const [benchmark, setBenchmark] = useState(null)
const [error, setError] = useState('')
const [loading, setLoading] = useState(false)
const [opening, setOpening] = useState(false)
const [remove, setRemove] = useState(null)
const [attempt, setAttempt] = useState(0)
const pendingStart = useRef(null)
useEffect(() => {
const controller = new AbortController()
setLoading(true)
setError('')
setCatalog([]); setSessions([]); setReport(null)
Promise.all([
api('/health', { signal: controller.signal }),
api(`/passages?language=${language}&split=${split}`, { signal: controller.signal }),
api(`/sessions?language=${language}`, { signal: controller.signal }),
api(`/policy-report?language=${language}`, { signal: controller.signal }),
api('/benchmarks/latest', { signal: controller.signal }),
]).then(([status, passages, saved, comparison, measured]) => {
if (controller.signal.aborted) return
setHealth(status); setCatalog(passages); setSessions(saved); setReport(comparison); setBenchmark(measured)
if (status.pilot) {
setLanguage(status.pilot.language)
setMode(status.pilot.arm)
if (status.pilot.next) setSplit(status.pilot.next.stage === 'practice' ? 'practice' : 'evaluation')
}
}).catch(failure => { if (!controller.signal.aborted) setError(failure.message) }).finally(() => { if (!controller.signal.aborted) setLoading(false) })
return () => controller.abort()
}, [language, split, attempt])
async function openPassage(passageId) {
if (opening) return
setOpening(true); setError('')
try {
if (!pendingStart.current || pendingStart.current.passage_id !== passageId || pendingStart.current.mode !== mode) pendingStart.current = { id: health?.pilot?.next?.session_id || crypto.randomUUID(), passage_id: passageId, mode }
const created = await postJson('/sessions', pendingStart.current)
const saved = await api(`/sessions/${created.id}`)
pendingStart.current = null
setSelected(saved)
} catch (failure) { setError(failure.message); setAttempt(value => value + 1) }
finally { setOpening(false) }
}
async function resume(id) {
setOpening(true); setError('')
try { setSelected(await api(`/sessions/${id}`)) }
catch (failure) { setError(failure.message) }
finally { setOpening(false) }
}
async function deleteSaved() {
setOpening(true); setError('')
try { await api(`/sessions/${remove.id}`, { method: 'DELETE' }); clearDraft(remove.id); setRemove(null); setAttempt(value => value + 1) }
catch (failure) { setError(failure.message) }
finally { setOpening(false) }
}
function leave() { setSelected(null); setAttempt(value => value + 1) }
const visible = catalog.filter(p => split !== 'evaluation' || !sessions.some(session => session.passage_id === p.id))
const finished = sessions.filter(session => session.status === 'completed')
const active = sessions.filter(session => session.status === 'active')
const measured = benchmark?.languages?.find(item => item.language === language)
const pilot = health?.pilot
if (pilot && health.version === '0.10.0') return This participant uses the original study version. Open its preserved reading interface to continue.Continue your pilot
{view === 'reading' ? 'A short passage. Your own pace.' : 'Temporary progress for this visit. Separate results for each language.'}
{error}
Loading saved data...
} {pilot &&{pilot.notice}
For this pilot, save a recording and review its transcript before the exercise. You can type a transcript if recognition fails.
To stop, choose Leave session. To withdraw your data, contact: {pilot.contact}.
{pilot.code}Personal data deletion deadline: {new Date(pilot.delete_by).toLocaleDateString()}
{mode.startsWith('learning-') ? 'Experimental: chooses exercise type and reading support. A later reviewed practice reading supplies a delayed reward. This does not establish learning improvement.' : mode === 'fixed' ? 'Consistent rules choose an exercise from your word review.' : mode === 'adaptive' ? 'Uses past exercise answers in this language and occasionally tries another exercise.' : 'Randomly assigns fixed or adaptive selection for a fairer comparison. No approach is known to be better yet.'}
{pilot && split === 'practice' ? 'Follow the assigned practice sequence. The same two passages repeat in this feasibility pilot. ' : 'Unseen passages are kept separate from practice. '} Once opened, a passage stays marked as seen during this visit. Expiry or a server restart resets that record. These checks do not train the exercise policy.
} {active.length > 0 &&You have {active.length} unfinished session{active.length === 1 ? '' : 's'} in this language.
}{p.word_count} words / {language === 'en' ? 'English' : 'Greek'}
{pilot && !pilot.next ? 'All eight pilot readings are complete. The organiser can now prepare the human review.' : 'No unseen passages remain in this language. Resume an unfinished check from Progress, or return to practice.'}
}No unfinished sessions.
}No completed sessions yet.
}Text differences can come from recognition errors. These are not pronunciation scores. Passages are not calibrated for difficulty, so differences across sessions do not by themselves establish improvement.
{remove &&Delete this session’s transcript, recording, and result? This cannot be undone in the app. Existing backups may still contain it. Evaluation passages remain marked as seen.
Choose “Compare approaches” when starting practice to contribute an outcome. Directly selected fixed or adaptive sessions are excluded from this comparison.
| Approach | Assigned | Answered | Completed | Correct answers | 95% interval |
|---|---|---|---|---|---|
| {policyNames[arm.policy]} | {arm.assigned} | {arm.answered} | {arm.completed} | {arm.success_rate === null ? 'No data' : `${(arm.success_rate * 100).toFixed(1)}%`} | {arm.wilson_95 ? arm.wilson_95.map(value => `${(value * 100).toFixed(0)}%`).join(' to ') : 'No data'} |
{report?.notice}
Correct exercise answers are a useful check, but they do not prove better reading. Adaptive selection may favour easier exercises. No winner is declared.
{pilot ? 'This pilot participant has a separate local database.' : 'One temporary visitor profile, separate from other visitors.'} Progress and recordings expire after one hour of inactivity or a Space restart. Use Progress to resume or delete a session.
{pilot ? "The organiser manages pilot data and withdrawal. Avoid creating extra copies of participant recordings." : "The public demo does not provide durable storage or backups."}
Measured model: {benchmark.model}. The report describes this model, which may differ from an environment override.
{measured.samples} FLEURS {benchmark.partition === 'holdout' ? 'held-out' : 'test'} clips / {language === 'en' ? 'English' : 'Greek'} / CPU INT8.
{measured.failed_warm_runs} failed attempts out of {measured.warm_runs ?? measured.samples * 2} warm runs. Rejected clips remain in the accuracy result; successful runs alone determine the latency figures.
{benchmark.limitations}
> :This hosted inference adapter has not been benchmarked. Local CPU results do not describe this deployment.
}