Skip to content

Commit f4beca7

Browse files
feat(chat): a stop button next to the agent that reads aloud
With several messages read one after the other the button of the one that is read can be out of sight. While anything is read aloud, #hush shows next to the agent on the stage; a click stops it and drops what waits in the queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 589c11c commit f4beca7

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎views/chat.html‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,34 @@
437437
#status::after {
438438
content: attr(data-since);
439439
}
440+
/* stops reading aloud, next to the agent that reads, whichever message
441+
it is (chat.js) */
442+
#hush {
443+
flex: none;
444+
display: inline-flex;
445+
align-items: center;
446+
gap: 0.35rem;
447+
min-height: 2.25rem;
448+
padding: 0.2rem 0.8rem 0.2rem 0.6rem;
449+
border-radius: 999px;
450+
border-color: rgba(var(--hl), 0.55);
451+
color: rgb(var(--hl));
452+
font-size: 0.9em;
453+
white-space: nowrap;
454+
}
455+
#hush[hidden] {
456+
display: none;
457+
}
458+
#hush .icon {
459+
font-size: 1.25em;
460+
}
461+
#hush:hover,
462+
#hush:focus-visible {
463+
background: rgba(var(--hl), 0.12);
464+
}
465+
.lia-variant-dark #hush {
466+
color: color-mix(in srgb, rgb(var(--hl)) 60%, white);
467+
}
440468
/* the way to the open form or to new messages out of sight */
441469
#jump {
442470
flex: none;
@@ -856,6 +884,17 @@
856884
<div id="log" role="log" aria-live="polite"></div>
857885
<div id="stage">
858886
<span id="bot"></span>
887+
<button
888+
id="hush"
889+
type="button"
890+
title="Stop reading"
891+
data-t-title="Stop reading"
892+
aria-label="Stop reading"
893+
data-t-aria-label="Stop reading"
894+
hidden
895+
>
896+
<i class="icon" aria-hidden="true">&#xEA5B;</i><span data-t="Stop">Stop</span>
897+
</button>
859898
<div class="lines">
860899
<div id="status" role="status" hidden></div>
861900
<div id="hint" role="status" hidden></div>

‎views/chat.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,9 +1404,18 @@ function sentences(text) {
14041404
// single letters for z. B., d. h., e. g.; numbers for 1. and dates
14051405
var ABBREVIATION = /(^|[\s(])(ca|bzw|usw|vgl|Nr|Min|Std|Mio|Mrd|Dr|Prof|etc|evtl|ggf|inkl|Abb|Kap|vs|Fig|No|Mr|Mrs|Ms|\p{L}|\d+)\.\s*$/u
14061406

1407+
// Stop next to the agent on the stage: with several messages read one after
1408+
// the other the button of the one that is read can be out of sight
1409+
var hush = document.getElementById('hush')
1410+
hush.addEventListener('click', function () {
1411+
queue = []
1412+
stop()
1413+
})
1414+
14071415
function stop() {
14081416
var item = reading
14091417
reading = undefined
1418+
if (hush) hush.hidden = true
14101419
if (item && item.button) idle(item.button)
14111420
if (item && item.msg) item.msg.classList.remove('reading')
14121421
try {
@@ -1487,6 +1496,7 @@ function read(item) {
14871496
}
14881497

14891498
reading = item
1499+
hush.hidden = false
14901500
var button = item.button
14911501
if (button) {
14921502
button.textContent = '\uEA5B' // stop

0 commit comments

Comments
 (0)