mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-22 23:38:11 +00:00
fix: cancel pending compacting reaction before resuming thinking
When compaction finishes before the debounce window (700ms), the queued
setCompacting() emoji could fire after compaction ended, showing ✍
instead of 🤔. This adds cancelPending() to StatusReactionController
and calls it in onCompactionEnd before setThinking() to prevent the
race condition.
Addresses review feedback from chatgpt-codex-connector.
This commit is contained in:
@@ -40,6 +40,8 @@ export type StatusReactionController = {
|
||||
setThinking: () => Promise<void> | void;
|
||||
setTool: (toolName?: string) => Promise<void> | void;
|
||||
setCompacting: () => Promise<void> | void;
|
||||
/** Cancel any pending debounced emoji (useful before forcing a state transition). */
|
||||
cancelPending: () => void;
|
||||
setDone: () => Promise<void>;
|
||||
setError: () => Promise<void>;
|
||||
clear: () => Promise<void>;
|
||||
@@ -314,6 +316,11 @@ export function createStatusReactionController(params: {
|
||||
scheduleEmoji(emojis.compacting);
|
||||
}
|
||||
|
||||
function cancelPending(): void {
|
||||
clearDebounceTimer();
|
||||
pendingEmoji = "";
|
||||
}
|
||||
|
||||
function finishWithEmoji(emoji: string): Promise<void> {
|
||||
if (!enabled) {
|
||||
return Promise.resolve();
|
||||
@@ -384,6 +391,7 @@ export function createStatusReactionController(params: {
|
||||
setThinking,
|
||||
setTool,
|
||||
setCompacting,
|
||||
cancelPending,
|
||||
setDone,
|
||||
setError,
|
||||
clear,
|
||||
|
||||
@@ -779,6 +779,7 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
|
||||
if (isProcessAborted(abortSignal)) {
|
||||
return;
|
||||
}
|
||||
statusReactions.cancelPending();
|
||||
await statusReactions.setThinking();
|
||||
},
|
||||
},
|
||||
|
||||
@@ -717,7 +717,10 @@ export const dispatchTelegramMessage = async ({
|
||||
? () => statusReactionController.setCompacting()
|
||||
: undefined,
|
||||
onCompactionEnd: statusReactionController
|
||||
? () => statusReactionController.setThinking()
|
||||
? async () => {
|
||||
statusReactionController.cancelPending();
|
||||
await statusReactionController.setThinking();
|
||||
}
|
||||
: undefined,
|
||||
onModelSelected,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user