Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: language switch stuck loading

cycong_14e175988dd3e
diff --git a/jiuwenswarm/channels/web/frontend/src/features/historyRestore.ts b/jiuwenswarm/channels/web/frontend/src/features/historyRestore.ts
index d99e6d36c2..a8ebb7ce57 100644
--- a/jiuwenswarm/channels/web/frontend/src/features/historyRestore.ts
+++ b/jiuwenswarm/channels/web/frontend/src/features/historyRestore.ts
@@ -24,8 +24,6 @@ const ALLOWED_ASSISTANT_EVENT_TYPES = new Set([
const HISTORY_RESTORE_DONE_CONTENT = 'done';
/** 流式 chunk 之间的兜底:正常情况由 `done` / `page_complete` 等结束帧关闭;仅当缺少明确结束标记时使用 */
const HISTORY_RESTORE_IDLE_MS = 500;
-/** 首帧兜底:订阅已建立但后端未发任何 history.message 时,避免 UI 一直 loading */
-const HISTORY_RESTORE_FIRST_FRAME_MS = 10_000;
export interface HistoryToolReplayItem {
kind: 'tool_call' | 'tool_result';
@@ -485,9 +483,6 @@ export function beginHistoryRestore(options: BeginHistoryRestoreOptions): Histor
const entries: HistoryTimelineEntry[] = [];
let totalPages: number | null = null;
let idleTimer: number | null = null;
- let firstFrameTimer: number | null = window.setTimeout(() => {
- finalize();
- }, HISTORY_RESTORE_FIRST_FRAME_MS);
let disposed = false;
const clearIdleTimer = () => {
@@ -496,13 +491,6 @@ export function beginHistoryRestore(options: BeginHistoryRestoreOptions): Histor
idleTimer = null;
}
};
- const clearFirstFrameTimer = () => {
- if (firstFrameTimer !== null) {
- window.clearTimeout(firstFrameTimer);
- firstFrameTimer = null;
- }
- };
-
const unsubscribe = webClient.on(HISTORY_MESSAGE_EVENT, (event: WsEvent) => {
if (disposed || generation !== restoreGeneration) {
return;
@@ -512,7 +500,6 @@ export function beginHistoryRestore(options: BeginHistoryRestoreOptions): Histor
if (!shouldProcessHistoryPayload(payload, options.sessionId)) {
return;
}
- clearFirstFrameTimer();
if (typeof payload.total_pages === 'number' && Number.isFinite(payload.total_pages)) {
totalPages = payload.total_pages;
@@ -549,7 +536,6 @@ export function beginHistoryRestore(options: BeginHistoryRestoreOptions): Histor
if (disposed) return;
disposed = true;
clearIdleTimer();
- clearFirstFrameTimer();
unsubscribe();
if (activeRestore?.generation === generation) {
activeRestore = null;
@@ -669,9 +655,6 @@ export function fetchHistoryPage(options: FetchHistoryPageOptions): HistoryResto
const entries: HistoryTimelineEntry[] = [];
let totalPages: number | null = null;
let idleTimer: number | null = null;
- let firstFrameTimer: number | null = window.setTimeout(() => {
- finalize();
- }, HISTORY_RESTORE_FIRST_FRAME_MS);
let disposed = false;
const clearIdleTimer = () => {
@@ -680,13 +663,6 @@ export function fetchHistoryPage(options: FetchHistoryPageOptions): HistoryResto
idleTimer = null;
}
};
- const clearFirstFrameTimer = () => {
- if (firstFrameTimer !== null) {
- window.clearTimeout(firstFrameTimer);
- firstFrameTimer = null;
- }
- };
-
const unsubscribe = webClient.on(HISTORY_MESSAGE_EVENT, (event: WsEvent) => {
if (disposed || generation !== restoreGeneration) {
return;
@@ -696,7 +672,6 @@ export function fetchHistoryPage(options: FetchHistoryPageOptions): HistoryResto
if (!shouldProcessHistoryPayload(payload, options.sessionId, options.pageIdx)) {
return;
}
- clearFirstFrameTimer();
if (typeof payload.total_pages === 'number' && Number.isFinite(payload.total_pages)) {
totalPages = payload.total_pages;
@@ -733,7 +708,6 @@ export function fetchHistoryPage(options: FetchHistoryPageOptions): HistoryResto
if (disposed) return;
disposed = true;
clearIdleTimer();
- clearFirstFrameTimer();
unsubscribe();
activePageFetchDispose = null;
if (activeRestore?.generation === generation) {