-
-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Description
Symptom
After commit d5f0889 ("fix: stop typing after dispatcher idle"), the typing indicator stays on indefinitely and never clears.
Root Cause Analysis
In src/auto-reply/reply/typing.ts, the ensureStart() function resets the completion flags:
const ensureStart = async () => {
if (!active) {
active = true;
runComplete = false; // <-- Resets flag
dispatchIdle = false; // <-- Resets flag
}
if (started) return;
started = true;
await triggerTyping();
};The maybeStopOnIdle() function only calls cleanup() when BOTH runComplete AND dispatchIdle are true:
const maybeStopOnIdle = () => {
if (!active) return;
if (runComplete && dispatchIdle) cleanup();
};Race Condition
If the agent run completes quickly (before any output triggers typing):
- Agent finishes →
markRunComplete()setsrunComplete = true - Agent returns output → reply dispatcher starts delivering
- Delivery triggers
startTypingOnText()→ensureStart()runs ensureStart()setsrunComplete = false(because!activeis true)- Typing interval starts
markDispatchIdle()is called →maybeStopOnIdle()checks flagsrunCompleteis nowfalse→ cleanup never happens- Typing continues forever
Suggested Fix
Don't reset the completion flags in ensureStart(). The flags should only be set to false on initial construction or after a full cleanup():
const ensureStart = async () => {
if (!active) {
active = true;
// Don't reset runComplete/dispatchIdle here
}
if (started) return;
started = true;
await triggerTyping();
};Or track completion state separately from the "should stop" decision.
Environment
- Commit: d5f0889
- Surface: Discord (likely affects all surfaces)
Workaround
Revert to parent commit or apply the suggested fix above.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels