fix: add embedded run logs and typing ttl

This commit is contained in:
Peter Steinberger
2026-01-03 14:09:19 +00:00
parent 4fcd89c3d9
commit 48731f494b
4 changed files with 90 additions and 11 deletions

View File

@@ -782,17 +782,41 @@ export async function getReplyFromConfig(
const typingIntervalSeconds =
typeof configuredTypingSeconds === "number" ? configuredTypingSeconds : 6;
const typingIntervalMs = typingIntervalSeconds * 1000;
const typingTtlMs = Math.min(
Math.max(15_000, typingIntervalMs * 5),
60_000,
);
const cleanupTyping = () => {
if (typingTtlTimer) {
clearTimeout(typingTtlTimer);
typingTtlTimer = undefined;
}
if (typingTimer) {
clearInterval(typingTimer);
typingTimer = undefined;
}
};
let typingTtlTimer: NodeJS.Timeout | undefined;
const refreshTypingTtl = () => {
if (!typingIntervalMs || typingIntervalMs <= 0) return;
if (typingTtlMs <= 0) return;
if (typingTtlTimer) {
clearTimeout(typingTtlTimer);
}
typingTtlTimer = setTimeout(() => {
if (!typingTimer) return;
defaultRuntime.warn?.(
`typing TTL reached (${typingTtlMs}ms); stopping typing indicator`,
);
cleanupTyping();
}, typingTtlMs);
};
const startTypingLoop = async () => {
if (!opts?.onReplyStart) return;
if (typingIntervalMs <= 0) return;
if (typingTimer) return;
await onReplyStart();
refreshTypingTtl();
typingTimer = setInterval(() => {
void triggerTyping();
}, typingIntervalMs);
@@ -801,6 +825,7 @@ export async function getReplyFromConfig(
const trimmed = text?.trim();
if (!trimmed) return;
if (trimmed === SILENT_REPLY_TOKEN) return;
refreshTypingTtl();
await startTypingLoop();
};
let transcribedText: string | undefined;