mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:00:54 +00:00
fix(telegram): rotate previews after visible tool output
This commit is contained in:
@@ -555,6 +555,7 @@ export const dispatchTelegramMessage = async ({
|
||||
let splitReasoningOnNextStream = false;
|
||||
let skipNextAnswerMessageStartRotation = false;
|
||||
let pendingCompactionReplayBoundary = false;
|
||||
let discardAnswerPreviewOnNextRotation = false;
|
||||
let draftLaneEventQueue = Promise.resolve();
|
||||
const reasoningStepState = createTelegramReasoningStepState();
|
||||
const enqueueDraftLaneEvent = (task: () => Promise<void>): Promise<void> => {
|
||||
@@ -600,6 +601,7 @@ export const dispatchTelegramMessage = async ({
|
||||
const materializedId = await answerLane.stream?.materialize?.();
|
||||
const previewMessageId = materializedId ?? answerLane.stream?.messageId();
|
||||
if (
|
||||
!discardAnswerPreviewOnNextRotation &&
|
||||
typeof previewMessageId === "number" &&
|
||||
activePreviewLifecycleByLane.answer === "transient"
|
||||
) {
|
||||
@@ -613,6 +615,7 @@ export const dispatchTelegramMessage = async ({
|
||||
answerLane.stream?.forceNewMessage();
|
||||
didForceNewMessage = true;
|
||||
}
|
||||
discardAnswerPreviewOnNextRotation = false;
|
||||
resetDraftLaneState(answerLane);
|
||||
answerLaneHasAssistantContent = false;
|
||||
if (didForceNewMessage) {
|
||||
@@ -967,11 +970,12 @@ export const dispatchTelegramMessage = async ({
|
||||
if (isDispatchSuperseded()) {
|
||||
return;
|
||||
}
|
||||
const clearPendingCompactionReplayBoundaryOnVisibleBoundary = (
|
||||
didDeliver: boolean,
|
||||
) => {
|
||||
const markVisibleNonPreviewBoundary = (didDeliver: boolean) => {
|
||||
if (didDeliver && info.kind !== "final") {
|
||||
pendingCompactionReplayBoundary = false;
|
||||
if (answerLane.hasStreamedMessage) {
|
||||
discardAnswerPreviewOnNextRotation = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (payload.isError === true) {
|
||||
@@ -1047,6 +1051,8 @@ export const dispatchTelegramMessage = async ({
|
||||
});
|
||||
if (info.kind === "final") {
|
||||
emitPreviewFinalizedHook(result);
|
||||
} else if (segment.lane === "answer" && result.kind === "sent") {
|
||||
markVisibleNonPreviewBoundary(true);
|
||||
}
|
||||
if (segment.lane === "reasoning") {
|
||||
if (result.kind !== "skipped") {
|
||||
@@ -1069,7 +1075,7 @@ export const dispatchTelegramMessage = async ({
|
||||
if (reply.hasMedia) {
|
||||
const payloadWithoutSuppressedReasoning =
|
||||
typeof payload.text === "string" ? { ...payload, text: "" } : payload;
|
||||
clearPendingCompactionReplayBoundaryOnVisibleBoundary(
|
||||
markVisibleNonPreviewBoundary(
|
||||
await sendPayload(payloadWithoutSuppressedReasoning),
|
||||
);
|
||||
}
|
||||
@@ -1093,9 +1099,7 @@ export const dispatchTelegramMessage = async ({
|
||||
}
|
||||
return;
|
||||
}
|
||||
clearPendingCompactionReplayBoundaryOnVisibleBoundary(
|
||||
await sendPayload(payload),
|
||||
);
|
||||
markVisibleNonPreviewBoundary(await sendPayload(payload));
|
||||
if (info.kind === "final") {
|
||||
await flushBufferedFinalAnswer();
|
||||
pendingCompactionReplayBoundary = false;
|
||||
|
||||
Reference in New Issue
Block a user