feat(hub): rolling chat summary to cap AI context and prevent mid-session failures
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3498,8 +3498,10 @@
|
||||
}
|
||||
|
||||
const ARCHIVE_QUOTE_AI_KEY = "hub_archive_quote_ai";
|
||||
let archiveQuoteAiPending = false;
|
||||
|
||||
async function consumeArchiveQuoteAiPending() {
|
||||
if (archiveQuoteAiPending || aiChatLoading) return;
|
||||
let raw = "";
|
||||
try {
|
||||
raw = sessionStorage.getItem(ARCHIVE_QUOTE_AI_KEY) || "";
|
||||
@@ -3526,6 +3528,7 @@
|
||||
applyAiMobileTab("trading");
|
||||
}
|
||||
|
||||
archiveQuoteAiPending = true;
|
||||
setAiChatBusy(true);
|
||||
renderAiChatMessages(aiChatSessionCache, {
|
||||
pendingUser: content,
|
||||
@@ -3547,12 +3550,14 @@
|
||||
showToast("复盘语录已发送给交易教练");
|
||||
} catch (e) {
|
||||
showToast(String(e), true);
|
||||
if (input) input.value = content;
|
||||
try {
|
||||
await loadAiChatSession();
|
||||
} catch (_) {
|
||||
renderAiChatMessages(aiChatSessionCache);
|
||||
}
|
||||
} finally {
|
||||
archiveQuoteAiPending = false;
|
||||
setAiChatBusy(false);
|
||||
}
|
||||
}
|
||||
@@ -3604,6 +3609,7 @@
|
||||
const files = fileInput && fileInput.files ? Array.from(fileInput.files) : [];
|
||||
if (!text && !files.length) return;
|
||||
const pendingAttachments = files.map((f) => ({ name: f.name, kind: f.type.startsWith("image/") ? "image" : "text" }));
|
||||
const savedText = text;
|
||||
if (input) input.value = "";
|
||||
setAiChatBusy(true);
|
||||
renderAiChatMessages(aiChatSessionCache, {
|
||||
@@ -3629,6 +3635,7 @@
|
||||
}
|
||||
} catch (e) {
|
||||
showToast(String(e), true);
|
||||
if (input && savedText) input.value = savedText;
|
||||
try {
|
||||
await loadAiChatSession();
|
||||
} catch (_) {
|
||||
|
||||
Reference in New Issue
Block a user