fix: treat decorated HTML page requests as WeChat immediate context
Memind CI / Test, build, and release guards (push) Successful in 4m32s
Memind CI / Test, build, and release guards (push) Successful in 4m32s
Match phrases like「生成一个精美的 HTML 页面」so poem follow-ups skip fresh-thumbnail forcing and reuse the same session poem context. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+17
-1
@@ -975,8 +975,24 @@ export function shouldForceNewWechatAgentSession(wechatIntent, resetCandidate) {
|
||||
);
|
||||
}
|
||||
|
||||
const WECHAT_IMMEDIATE_CONTEXT_PAGE_DECORATORS =
|
||||
'(?:精美(?:的)?|漂亮(?:的)?|好看(?:的)?|简约(?:的)?|优雅(?:的)?)';
|
||||
const WECHAT_IMMEDIATE_CONTEXT_PAGE_PATTERN =
|
||||
/^(?:(?:请|麻烦|可以|能不能)\s*)?(?:(?:帮我|帮忙|给我)\s*)?(?:(?:把\s*)?(?:这个|刚才(?:的)?(?:诗|文章|内容)?|上面(?:的)?|前面(?:的)?|上一条|它|这首(?:诗)?|这篇(?:文章)?|这段(?:内容)?)\s*)?(?:继续\s*)?(?:做|弄|改|转|写|排版|生成|制作)(?:成|为)?\s*(?:一个|个)?\s*(?:h5|html)?\s*(?:页面|网页)(?:吧|呀|呢|一下)?[。.!!\s]*$/iu;
|
||||
new RegExp(
|
||||
'^'
|
||||
+ '(?:(?:请|麻烦|可以|能不能)\\s*)?'
|
||||
+ '(?:(?:帮我|帮忙|给我)\\s*)?'
|
||||
+ '(?:(?:把\\s*)?(?:这个|刚才(?:的)?(?:诗|文章|内容)?|上面(?:的)?|前面(?:的)?|上一条|它|这首(?:诗)?|这篇(?:文章)?|这段(?:内容)?)\\s*)?'
|
||||
+ '(?:继续\\s*)?'
|
||||
+ '(?:做|弄|改|转|写|排版|生成|制作)(?:成|为)?\\s*'
|
||||
+ '(?:一个|个)?'
|
||||
+ '(?:(?:\\s*'
|
||||
+ WECHAT_IMMEDIATE_CONTEXT_PAGE_DECORATORS
|
||||
+ '){1,3}\\s*(?:h5|html)|(?:\\s*(?:h5|html)))?'
|
||||
+ '\\s*(?:页面|网页)(?:吧|呀|呢|一下)?[。.!!\\s]*'
|
||||
+ '$',
|
||||
'iu',
|
||||
);
|
||||
|
||||
export function isWechatImmediateContextFollowup(wechatIntent, text) {
|
||||
if (wechatIntent?.kind !== 'page.generate') return false;
|
||||
|
||||
@@ -341,6 +341,9 @@ test('WeChat immediate-context page guard does not match complete page requests'
|
||||
const pageIntent = { kind: 'page.generate' };
|
||||
assert.equal(isWechatImmediateContextFollowup(pageIntent, '帮我做成页面吧'), true);
|
||||
assert.equal(isWechatImmediateContextFollowup(pageIntent, '把刚才的诗做成页面'), true);
|
||||
assert.equal(isWechatImmediateContextFollowup(pageIntent, '生成一个精美的 HTML 页面'), true);
|
||||
assert.equal(isWechatImmediateContextFollowup(pageIntent, '生成一个HTML页面'), true);
|
||||
assert.equal(isWechatImmediateContextFollowup(pageIntent, '生成一个上海旅游攻略页面'), false);
|
||||
assert.equal(isWechatImmediateContextFollowup(pageIntent, '帮我做一个上海旅游页面'), false);
|
||||
assert.equal(
|
||||
isWechatImmediateContextFollowup({ kind: 'chat.general' }, '帮我做成页面吧'),
|
||||
|
||||
Reference in New Issue
Block a user