mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
fix(reply): preserve distinct streamed location replies (#128846)
This commit is contained in:
committed by
GitHub
parent
2a39c50227
commit
998128abd8
@@ -56,6 +56,9 @@ describe("createBlockReplyContentKey", () => {
|
||||
});
|
||||
expect(a).toBe(b);
|
||||
expect(a).not.toBe(c);
|
||||
expect(createBlockReplyContentKey({ location: { latitude: 1, longitude: 2 } })).not.toBe(
|
||||
createBlockReplyContentKey({ location: { latitude: 3, longitude: 4 } }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -192,6 +195,17 @@ describe("createBlockReplyPipeline dedup with threading", () => {
|
||||
{ text: "After", audioAsVoice: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "distinct portable location replies",
|
||||
payloads: [
|
||||
{ location: { latitude: 1, longitude: 2 } },
|
||||
{ location: { latitude: 3, longitude: 4 } },
|
||||
],
|
||||
expected: [
|
||||
{ location: { latitude: 1, longitude: 2 } },
|
||||
{ location: { latitude: 3, longitude: 4 } },
|
||||
],
|
||||
},
|
||||
])("preserves streamed delivery order for $name", async ({ payloads, expected }) => {
|
||||
const sent: ReplyPayload[] = [];
|
||||
const pipeline = createBlockReplyPipeline({
|
||||
|
||||
@@ -53,35 +53,34 @@ export function createAudioAsVoiceBuffer(params: {
|
||||
};
|
||||
}
|
||||
|
||||
/** Creates a stable duplicate key for a complete outbound payload. */
|
||||
function createBlockReplyPayloadKey(payload: ReplyPayload): string {
|
||||
function createBlockReplyContentIdentity(payload: ReplyPayload) {
|
||||
const reply = resolveSendableOutboundReplyParts(payload);
|
||||
return JSON.stringify({
|
||||
statusNotice: isReplyPayloadStatusNotice(payload),
|
||||
return {
|
||||
text: reply.trimmedText,
|
||||
mediaList: reply.mediaUrls,
|
||||
presentation: payload.presentation ?? null,
|
||||
presentationTextMode: payload.presentationTextMode ?? null,
|
||||
interactive: payload.interactive ?? null,
|
||||
channelData: payload.channelData ?? null,
|
||||
location: payload.location ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
/** Creates a stable duplicate key for a complete outbound payload. */
|
||||
function createBlockReplyPayloadKey(payload: ReplyPayload): string {
|
||||
return JSON.stringify({
|
||||
...createBlockReplyContentIdentity(payload),
|
||||
statusNotice: isReplyPayloadStatusNotice(payload),
|
||||
replyToId: payload.replyToId ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
/** Creates a duplicate key that ignores reply target for final suppression. */
|
||||
export function createBlockReplyContentKey(payload: ReplyPayload): string {
|
||||
const reply = resolveSendableOutboundReplyParts(payload);
|
||||
// Content-only key used for final-payload suppression after block streaming.
|
||||
// This intentionally ignores replyToId so a streamed threaded payload and the
|
||||
// later final payload still collapse when they carry the same content.
|
||||
return JSON.stringify({
|
||||
text: reply.trimmedText,
|
||||
mediaList: reply.mediaUrls,
|
||||
presentation: payload.presentation ?? null,
|
||||
presentationTextMode: payload.presentationTextMode ?? null,
|
||||
interactive: payload.interactive ?? null,
|
||||
channelData: payload.channelData ?? null,
|
||||
});
|
||||
return JSON.stringify(createBlockReplyContentIdentity(payload));
|
||||
}
|
||||
|
||||
function resolveBlockReplyTimeoutMs(timeoutMs: number): number {
|
||||
|
||||
Reference in New Issue
Block a user