fix(wechat): isolate page data sessions

This commit is contained in:
john
2026-07-12 21:11:12 +08:00
parent cef3750ac6
commit ca4805533b
5 changed files with 97 additions and 11 deletions
+10
View File
@@ -16,6 +16,7 @@ import {
loadWechatMpConfig,
maybeAttachPublishedHtmlLink,
shouldRetryHtmlGenerationReply,
shouldForceNewWechatAgentSession,
splitWechatText,
verifyWechatMpSignature,
verifyWechatMpUrlChallenge,
@@ -144,6 +145,15 @@ test('splitWechatText respects WeChat 2048-byte customer service limit', () => {
assert.equal(chunks.join(''), longChinese);
});
test('Page Data requests always rotate away from an existing WeChat route', () => {
assert.equal(
shouldForceNewWechatAgentSession({ kind: 'chat.general' }, '做一个问卷,后台可以查看提交数据'),
true,
);
assert.equal(shouldForceNewWechatAgentSession({ kind: 'chat.general' }, '继续聊德川家康'), false);
assert.equal(shouldForceNewWechatAgentSession({ kind: 'session.reset' }, '继续聊德川家康'), true);
});
test('buildWechatAgentPrompt requires docx generation before html when Word download is requested', () => {
const prompt = buildWechatAgentPrompt({
msgType: 'text',