Add smart ACK provider for WeChat MP replies

Replace fixed ackText with a rule-based AckProvider that picks
response templates by message type and intent (translate, summary,
rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync,
zero I/O, auto-falls back to config.ackText on any error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
john
2026-06-26 15:19:03 +08:00
parent 9ed4fd48d7
commit 9b4a25799f
162 changed files with 17276 additions and 2054 deletions
@@ -51,6 +51,8 @@ export function MindSpacePagePreviewPanel({
const [thumbNotice, setThumbNotice] = useState<string | null>(null);
const [thumbError, setThumbError] = useState<string | null>(null);
const uploadInputRef = useRef<HTMLInputElement>(null);
const thumbnailRefreshTokenRef = useRef(0);
const latestDraftRef = useRef({ title, summary, content });
const thumbnailUrl = `/api/mindspace/v1/pages/${pageId}/thumbnail?v=${thumbnailVersion}`;
@@ -62,6 +64,38 @@ export function MindSpacePagePreviewPanel({
setThumbnailFailed(false);
}, [thumbnailUrl]);
useEffect(() => {
latestDraftRef.current = { title, summary, content };
}, [content, summary, title]);
useEffect(() => {
let cancelled = false;
const refreshToken = ++thumbnailRefreshTokenRef.current;
const { title: draftTitle, summary: draftSummary, content: draftContent } = latestDraftRef.current;
const syncThumbnail = async () => {
try {
const result = await regenerateMindSpacePageThumbnail(pageId, {
title: draftTitle,
summary: draftSummary,
content: draftContent,
});
if (cancelled || thumbnailRefreshTokenRef.current !== refreshToken) return;
setThumbnailVersion(result.updatedAt ?? Date.now());
setThumbnailFailed(false);
} catch {
if (cancelled || thumbnailRefreshTokenRef.current !== refreshToken) return;
setThumbnailFailed(false);
}
};
void syncThumbnail();
return () => {
cancelled = true;
};
}, [pageId, reloadKey]);
const bumpThumbnail = () => {
setThumbnailVersion(Date.now());
setThumbnailFailed(false);