capture and dialogue: name two TTLs, fix a drifted comment (V-581)

Sweep of internal/capture and internal/dialogue. Both packages were already in
good shape, so this is four small corrections rather than a rework.

windowBytes truncated the STT window to whole seconds. A sub-second window
therefore came out as zero bytes, which transcribeFile reads as "no window" and
answers by handing the transcriber the whole meeting in one call. The
multiplication is now done in float, so a fractional window is a real window.

Peek's comment claimed expired entries below the top are left alone. The code
deletes the whole stack, which is what Pop and TakeExpired both document and
what the clock argues for. The comment now says so, and it names the ordering
the silent drop depends on: TakeExpired has to run before Peek on a turn or the
expiry notice becomes unreachable.

The two store default TTLs were unnamed literals. They are DefaultClarifyTTL
and DefaultSessionTTL now, next to DefaultMaxAttempts, and the comment on each
says why the clarify one is the shorter of the two.

PendingQuestion was not gofmt clean and ChunkText copied a slice one element at
a time.

Full suite passes with -race.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 03:12:18 +04:00
parent 316fb197a8
commit 901354002e
4 changed files with 28 additions and 13 deletions
+4 -1
View File
@@ -626,6 +626,9 @@ func windowBytes(f audio.Format, window time.Duration) int64 {
if bps <= 0 || f.SampleRate <= 0 || window <= 0 {
return 0
}
per := int64(window.Seconds()) * bytesPerSecond(f)
// Fractional seconds count. Truncating the window to whole seconds turned
// any sub-second window into zero bytes, which the caller reads as "no
// window" and answers by handing the transcriber the entire meeting at once.
per := int64(window.Seconds() * float64(bytesPerSecond(f)))
return per - per%bps
}
+1 -3
View File
@@ -193,9 +193,7 @@ func ChunkText(text string, maxRunes int) []string {
// Oversized sentence: emit what is buffered, then cut this one on
// word boundaries.
flush()
for _, piece := range splitWords(sr, maxRunes) {
out = append(out, piece)
}
out = append(out, splitWords(sr, maxRunes)...)
continue
}
if len(cur)+len(sr) > maxRunes {