fix: preserve block streaming order
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
### Fixes
|
### Fixes
|
||||||
- Telegram: chunk block-stream replies to avoid “message is too long” errors (#124) — thanks @mukhtharcm.
|
- Telegram: chunk block-stream replies to avoid “message is too long” errors (#124) — thanks @mukhtharcm.
|
||||||
- Block streaming: default to text_end and suppress duplicate block sends while in-flight.
|
- Block streaming: default to text_end and suppress duplicate block sends while in-flight.
|
||||||
|
- Block streaming: drop final payloads after soft chunking to keep Discord order intact.
|
||||||
- Gmail hooks: resolve gcloud Python to a real executable when PATH uses mise shims — thanks @joargp.
|
- Gmail hooks: resolve gcloud Python to a real executable when PATH uses mise shims — thanks @joargp.
|
||||||
- Control UI: generate UUIDs when `crypto.randomUUID()` is unavailable over HTTP — thanks @ratulsarna.
|
- Control UI: generate UUIDs when `crypto.randomUUID()` is unavailable over HTTP — thanks @ratulsarna.
|
||||||
- Agent: add soft block-stream chunking (800–1200 chars default) with paragraph/newline preference.
|
- Agent: add soft block-stream chunking (800–1200 chars default) with paragraph/newline preference.
|
||||||
|
|||||||
@@ -1133,6 +1133,7 @@ export async function getReplyFromConfig(
|
|||||||
const streamedPayloadKeys = new Set<string>();
|
const streamedPayloadKeys = new Set<string>();
|
||||||
const pendingStreamedPayloadKeys = new Set<string>();
|
const pendingStreamedPayloadKeys = new Set<string>();
|
||||||
const pendingBlockTasks = new Set<Promise<void>>();
|
const pendingBlockTasks = new Set<Promise<void>>();
|
||||||
|
let didStreamBlockReply = false;
|
||||||
const buildPayloadKey = (payload: ReplyPayload) => {
|
const buildPayloadKey = (payload: ReplyPayload) => {
|
||||||
const text = payload.text?.trim() ?? "";
|
const text = payload.text?.trim() ?? "";
|
||||||
const mediaList = payload.mediaUrls?.length
|
const mediaList = payload.mediaUrls?.length
|
||||||
@@ -2239,6 +2240,7 @@ export async function getReplyFromConfig(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pendingStreamedPayloadKeys.add(payloadKey);
|
pendingStreamedPayloadKeys.add(payloadKey);
|
||||||
|
didStreamBlockReply = true;
|
||||||
const task = (async () => {
|
const task = (async () => {
|
||||||
await startTypingOnText(cleaned);
|
await startTypingOnText(cleaned);
|
||||||
await opts.onBlockReply?.(blockPayload);
|
await opts.onBlockReply?.(blockPayload);
|
||||||
@@ -2345,11 +2347,15 @@ export async function getReplyFromConfig(
|
|||||||
(payload.mediaUrls && payload.mediaUrls.length > 0),
|
(payload.mediaUrls && payload.mediaUrls.length > 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
const filteredPayloads = blockStreamingEnabled
|
const shouldDropFinalPayloads =
|
||||||
? replyTaggedPayloads.filter(
|
blockStreamingEnabled && blockReplyChunking && didStreamBlockReply;
|
||||||
(payload) => !streamedPayloadKeys.has(buildPayloadKey(payload)),
|
const filteredPayloads = shouldDropFinalPayloads
|
||||||
)
|
? []
|
||||||
: replyTaggedPayloads;
|
: blockStreamingEnabled
|
||||||
|
? replyTaggedPayloads.filter(
|
||||||
|
(payload) => !streamedPayloadKeys.has(buildPayloadKey(payload)),
|
||||||
|
)
|
||||||
|
: replyTaggedPayloads;
|
||||||
|
|
||||||
if (filteredPayloads.length === 0) return finalizeWithFollowup(undefined);
|
if (filteredPayloads.length === 0) return finalizeWithFollowup(undefined);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user