From b457d19d9b2c634570300d0f73087e18b4ec4a4a Mon Sep 17 00:00:00 2001 From: wuhei Date: Thu, 19 Nov 2026 18:36:43 +0100 Subject: Enter keeps the sentence: green on screen, appended to a session log - Enter (kiosk) turns the sentence green and appends it to a Markdown session log, default sessions/session-.md, -log to override. Written lazily, so a run that kept nothing leaves no file. - logs the whole sentence rather than the 9 characters on screen; the snapshot waits 450ms so the model's lookahead has decoded the final syllables - the English in the log is a fresh translation of that sentence, done on a single ordered worker off the audio path, so it never delays recognition - green clears with the next sentence, like the red cut screen - double Enter within 2s does not duplicate a line - tests: keep state, sentence selection, log format and dedupe --- web/index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'web/index.html') diff --git a/web/index.html b/web/index.html index 677fe14..404b367 100644 --- a/web/index.html +++ b/web/index.html @@ -46,6 +46,9 @@ /* sentence alternates black-on-white and white-on-black; Backspace = red retake */ body.invert { background: #000; color: #fff; } body.cut { background: #d10d0d; color: #fff; } + /* Enter: the sentence was kept and written to the session log */ + body.keep { color: #0a7d3a; } + body.invert.keep { color: #4ade80; } @keyframes pop { from { opacity: .5; transform: scale(.955); } to { opacity: 1; transform: scale(1); } @@ -110,6 +113,11 @@ if (reserve) en.textContent = ''; } + function keep() { + body.classList.add('keep'); // instant feedback, server confirms it + fetch('/keep', { method: 'POST', keepalive: true }).catch(function () {}); + } + function cut() { body.classList.add('cut'); // instant feedback, server confirms it curZh = ''; curEn = ''; @@ -154,6 +162,11 @@ addEventListener('resize', function () { measurePad(); fit(); }); addEventListener('keydown', function (e) { + if (e.key === 'Enter') { + e.preventDefault(); + keep(); + return; + } if (e.key === 'Backspace' || e.key === 'Delete' || e.key === 'c') { // "that was wrong, say it again": red screen, then straight back to work e.preventDefault(); @@ -169,6 +182,7 @@ measurePad(); if (q.has('invert')) body.classList.add('invert'); + if (q.has('keep')) body.classList.add('keep'); if (q.has('cut')) { body.classList.add('cut'); return; } if (q.has('text')) { // design preview: index.html?en=1&text=你好&t=hello @@ -182,7 +196,9 @@ const s = JSON.parse(e.data); body.classList.toggle('invert', !!s.invert); body.classList.toggle('cut', !!s.cut); + body.classList.toggle('keep', !!s.keep); if (s.cut) { curZh = ''; curEn = ''; zh.textContent = ''; en.textContent = ''; return; } + if (s.keep && s.text === curZh) return; // only the colour changed render(s.text, s.en, s.cap); } catch (_) {} }; -- cgit v1.2.3