fix: preserve quoted message context across channels

This commit is contained in:
xmanrui 2026-09-02 01:27:35 +08:00
parent c2be2389b0
commit 94e114b9b3
46 changed files with 4242 additions and 321 deletions

View file

@ -35,7 +35,6 @@ import {
hasInboundImages,
imagePromptDiagnostic,
imagePromptUserMessage,
promptContentForMessage,
} from './image-prompt.mjs';
import {
hasInboundFiles,
@ -47,6 +46,10 @@ import {
validHarnessQuestion,
} from './harness-question.mjs';
import { deliverOutboundArtifacts } from './semantic/artifact-delivery.mjs';
import {
hasReplyReference,
promptContentForInboundMessage,
} from './semantic/reply-reference.mjs';
import {
createDeliveryReceipt,
createTextDeliveryBlock,
@ -283,7 +286,8 @@ export class TextHarnessBridge {
plainText: Boolean(text)
&& normalized.plainText !== false
&& !hasInboundImages(normalized)
&& !hasInboundFiles(normalized),
&& !hasInboundFiles(normalized)
&& !hasReplyReference(normalized),
});
if (batch.handled) {
if (batch.kind === 'submit') {
@ -301,7 +305,8 @@ export class TextHarnessBridge {
plainText: Boolean(text)
&& normalized.plainText !== false
&& !hasInboundImages(normalized)
&& !hasInboundFiles(normalized),
&& !hasInboundFiles(normalized)
&& !hasReplyReference(normalized),
});
if (batch.handled) {
return this.#finishLocalMessage(normalized, messageId, batch.message);
@ -575,7 +580,8 @@ export class TextHarnessBridge {
}
const hasImages = hasInboundImages(message);
const hasFiles = hasInboundFiles(message);
if (!text && !hasImages && !hasFiles) {
const hasReply = hasReplyReference(message);
if (!text && !hasImages && !hasFiles && !hasReply) {
await this.#bot.sendText(target, t('目前支持文字、图片和文件消息。'));
return;
}
@ -669,8 +675,8 @@ export class TextHarnessBridge {
);
}
}
let content = hasImages
? await promptContentForMessage(message, { signal: this.#signal })
let content = hasImages || hasReply
? await promptContentForInboundMessage(message, { signal: this.#signal })
: undefined;
const snapshot = this.#acceptedMessageIds.get(messageId);
let contextEnhanced = false;