mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 11:07:14 +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;
|
setThinking: () => Promise<void> | void;
|
||||||
setTool: (toolName?: string) => Promise<void> | void;
|
setTool: (toolName?: string) => Promise<void> | void;
|
||||||
setCompacting: () => Promise<void> | void;
|
setCompacting: () => Promise<void> | void;
|
||||||
|
/** Cancel any pending debounced emoji (useful before forcing a state transition). */
|
||||||
|
cancelPending: () => void;
|
||||||
setDone: () => Promise<void>;
|
setDone: () => Promise<void>;
|
||||||
setError: () => Promise<void>;
|
setError: () => Promise<void>;
|
||||||
clear: () => Promise<void>;
|
clear: () => Promise<void>;
|
||||||
@@ -314,6 +316,11 @@ export function createStatusReactionController(params: {
|
|||||||
scheduleEmoji(emojis.compacting);
|
scheduleEmoji(emojis.compacting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cancelPending(): void {
|
||||||
|
clearDebounceTimer();
|
||||||
|
pendingEmoji = "";
|
||||||
|
}
|
||||||
|
|
||||||
function finishWithEmoji(emoji: string): Promise<void> {
|
function finishWithEmoji(emoji: string): Promise<void> {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
@@ -384,6 +391,7 @@ export function createStatusReactionController(params: {
|
|||||||
setThinking,
|
setThinking,
|
||||||
setTool,
|
setTool,
|
||||||
setCompacting,
|
setCompacting,
|
||||||
|
cancelPending,
|
||||||
setDone,
|
setDone,
|
||||||
setError,
|
setError,
|
||||||
clear,
|
clear,
|
||||||
|
|||||||
@@ -779,6 +779,7 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
|
|||||||
if (isProcessAborted(abortSignal)) {
|
if (isProcessAborted(abortSignal)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
statusReactions.cancelPending();
|
||||||
await statusReactions.setThinking();
|
await statusReactions.setThinking();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -717,7 +717,10 @@ export const dispatchTelegramMessage = async ({
|
|||||||
? () => statusReactionController.setCompacting()
|
? () => statusReactionController.setCompacting()
|
||||||
: undefined,
|
: undefined,
|
||||||
onCompactionEnd: statusReactionController
|
onCompactionEnd: statusReactionController
|
||||||
? () => statusReactionController.setThinking()
|
? async () => {
|
||||||
|
statusReactionController.cancelPending();
|
||||||
|
await statusReactionController.setThinking();
|
||||||
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
onModelSelected,
|
onModelSelected,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user