fix: prevent duplicate history loading
This commit is contained in:
parent
e8411affc1
commit
ef4479866e
@ -122,6 +122,7 @@ const appOptions = {
|
|||||||
skipConversationLoadedEvent: false,
|
skipConversationLoadedEvent: false,
|
||||||
skipConversationHistoryReload: false,
|
skipConversationHistoryReload: false,
|
||||||
_scrollListenerReady: false,
|
_scrollListenerReady: false,
|
||||||
|
historyLoading: false,
|
||||||
|
|
||||||
// 工具控制菜单
|
// 工具控制菜单
|
||||||
icons: ICONS,
|
icons: ICONS,
|
||||||
@ -844,16 +845,6 @@ const appOptions = {
|
|||||||
this.ensureScrollListener();
|
this.ensureScrollListener();
|
||||||
});
|
});
|
||||||
|
|
||||||
const activeConversationId = this.currentConversationId;
|
|
||||||
if (activeConversationId && !activeConversationId.startsWith('temp_')) {
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.currentConversationId === activeConversationId) {
|
|
||||||
this.fetchAndDisplayHistory();
|
|
||||||
this.fetchConversationTokenStatistics();
|
|
||||||
this.updateCurrentContextTokens();
|
|
||||||
}
|
|
||||||
}, 250);
|
|
||||||
}
|
|
||||||
this.logMessageState('resetAllStates:after-cleanup', { reason });
|
this.logMessageState('resetAllStates:after-cleanup', { reason });
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1099,6 +1090,12 @@ const appOptions = {
|
|||||||
// 关键功能:获取并显示历史对话内容
|
// 关键功能:获取并显示历史对话内容
|
||||||
// ==========================================
|
// ==========================================
|
||||||
async fetchAndDisplayHistory() {
|
async fetchAndDisplayHistory() {
|
||||||
|
if (this.historyLoading) {
|
||||||
|
console.log('历史消息正在加载,跳过重复请求');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.historyLoading = true;
|
||||||
|
try {
|
||||||
console.log('开始获取历史对话内容...');
|
console.log('开始获取历史对话内容...');
|
||||||
this.logMessageState('fetchAndDisplayHistory:start', { conversationId: this.currentConversationId });
|
this.logMessageState('fetchAndDisplayHistory:start', { conversationId: this.currentConversationId });
|
||||||
|
|
||||||
@ -1172,6 +1169,9 @@ const appOptions = {
|
|||||||
this.messages = [];
|
this.messages = [];
|
||||||
this.logMessageState('fetchAndDisplayHistory:error-cleared');
|
this.logMessageState('fetchAndDisplayHistory:error-cleared');
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.historyLoading = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user