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(web-frontend): Scrolling upwards to load historical messages fails to display the bottom status bar

openJiuwen-bot6e33f7e8d1ef
diff --git a/jiuwenswarm/channels/web/frontend/src/App.tsx b/jiuwenswarm/channels/web/frontend/src/App.tsx
index 3e191239ef..38ac42349c 100644
--- a/jiuwenswarm/channels/web/frontend/src/App.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/App.tsx
@@ -194,20 +194,10 @@ function AppContent() {
/** 为 true 表示刚从「会话列表」恢复;history 为空时在 useEffect 的 onEmpty 中提示一次 */
const historyRestoreFromPanelHintRef = useRef(false);
- const disposeInFlightHistoryHandles = useCallback(() => {
- historyLoadingMoreRef.current = false;
- historyRestoreHandleRef.current?.dispose();
- historyRestoreHandleRef.current = null;
- historyPageHandleRef.current?.dispose();
- historyPageHandleRef.current = null;
- }, []);
-
useEffect(() => {
sessionIdRef.current = sessionId;
}, [sessionId]);
- useEffect(() => () => disposeInFlightHistoryHandles(), [disposeInFlightHistoryHandles]);
-
const { setCurrentSession, setSessions, setAvailableModels, setMode, mode, heartbeatMessage, heartbeatUpdatedAt, teamTaskEvents, teamMembers } = useSessionStore();
const {
clearMessages,
@@ -217,10 +207,23 @@ function AppContent() {
addToolResult,
prependMessages,
isProcessing,
+ isLoadingHistory,
setProcessing,
setThinking,
+ setLoadingHistory,
setPaused,
} = useChatStore();
+
+ const disposeInFlightHistoryHandles = useCallback(() => {
+ historyLoadingMoreRef.current = false;
+ setLoadingHistory(false);
+ historyRestoreHandleRef.current?.dispose();
+ historyRestoreHandleRef.current = null;
+ historyPageHandleRef.current?.dispose();
+ historyPageHandleRef.current = null;
+ }, [setLoadingHistory]);
+
+ useEffect(() => () => disposeInFlightHistoryHandles(), [disposeInFlightHistoryHandles]);
const { todos, clearTodos } = useTodoStore();
const { extensionReady, reset: resetHarnessStore } = useHarnessStore();
@@ -578,11 +581,13 @@ function AppContent() {
setHistoryPagerMeta(null);
setHistoryLoadingMore(false);
+ setLoadingHistory(true);
// 开始历史会话加载
const restoreHandle = beginHistoryRestore({
sessionId: sessionId,
onReady: (messages, totalPages) => {
if (sessionIdRef.current !== sessionId) {
+ setLoadingHistory(false);
return;
}
historyRestoreFromPanelHintRef.current = false;
@@ -592,12 +597,14 @@ function AppContent() {
loadedPages: 1,
totalPages: totalPages ?? 1,
});
+ setLoadingHistory(false);
queueMicrotask(() => {
historyRestoreHandleRef.current = null;
});
},
onEmpty: (emptyTotalPages) => {
if (sessionIdRef.current !== sessionId) {
+ setLoadingHistory(false);
return;
}
clearMessages();
@@ -614,6 +621,7 @@ function AppContent() {
timestamp: new Date().toISOString(),
});
}
+ setLoadingHistory(false);
historyRestoreHandleRef.current = null;
},
onToolReplay: (items) => {
@@ -694,6 +702,7 @@ function AppContent() {
},
onError: (message) => {
console.warn('[history.restore]', message);
+ setLoadingHistory(false);
},
});
historyRestoreHandleRef.current = restoreHandle;
@@ -712,6 +721,7 @@ function AppContent() {
// 发生错误时,设置 historyPagerMeta 为 null,显示欢迎信息
setHistoryPagerMeta(null);
console.error('Failed to load history:', error);
+ setLoadingHistory(false);
// 忽略 "invalid page_idx or session history not found" 错误,因为这是新会话的正常情况
const errorMessage = error instanceof Error ? error.message : String(error);
if (sessionIdRef.current === sessionId && !errorMessage.includes('invalid page_idx or session history not found')) {
@@ -737,6 +747,7 @@ function AppContent() {
clearMessages,
clearSubtasks,
disposeInFlightHistoryHandles,
+ setLoadingHistory,
]);
// 新建会话:立即生成可用的 session_id,避免停留在 'new' 导致无法发送消息
@@ -885,10 +896,12 @@ function AppContent() {
const finishLoadingMore = () => {
historyLoadingMoreRef.current = false;
setHistoryLoadingMore(false);
+ setLoadingHistory(false);
};
historyLoadingMoreRef.current = true;
setHistoryLoadingMore(true);
+ setLoadingHistory(true);
const pageHandle = fetchHistoryPage({
sessionId: sid,
pageIdx: nextPage,
@@ -1144,6 +1157,7 @@ function AppContent() {
<StatusBar
onCancel={mode === 'team' ? undefined : handleCancel}
teamMode={mode === 'team'}
+ isLoadingHistory={isLoadingHistory}
/>
)}
</div>
@@ -1156,10 +1170,11 @@ function AppContent() {
{/* StatusBar - 当没有右侧面板时,单独显示在底部 */}
{!toolPanelHasContent && (
- <div className="card">
+ <div className={`transition-opacity duration-200 ${isLoadingHistory ? 'opacity-0 pointer-events-none' : ''}`}>
<StatusBar
onCancel={mode === 'team' ? undefined : handleCancel}
teamMode={mode === 'team'}
+ isLoadingHistory={isLoadingHistory}
/>
</div>
)}
diff --git a/jiuwenswarm/channels/web/frontend/src/components/StatusBar/StatusBar.css b/jiuwenswarm/channels/web/frontend/src/components/StatusBar/StatusBar.css
index 474c6002c3..79fc4d35aa 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/StatusBar/StatusBar.css
+++ b/jiuwenswarm/channels/web/frontend/src/components/StatusBar/StatusBar.css
@@ -4,6 +4,7 @@
margin-top: auto;
border-top: 1px solid var(--border);
background: var(--panel);
+ transition: opacity 0.2s ease;
}
.statusbar-center {
diff --git a/jiuwenswarm/channels/web/frontend/src/components/StatusBar/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/StatusBar/index.tsx
index 23024fca5e..681d270b43 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/StatusBar/index.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/StatusBar/index.tsx
@@ -12,17 +12,19 @@ import './StatusBar.css';
interface StatusBarProps {
onCancel?: () => void;
teamMode?: boolean;
+ isLoadingHistory?: boolean;
}
-export function StatusBar({ onCancel, teamMode = false }: StatusBarProps) {
+export function StatusBar({ onCancel, teamMode = false, isLoadingHistory: propIsLoadingHistory }: StatusBarProps) {
const { t } = useTranslation();
- const { isProcessing, isPaused, pausedTask, interruptResult, switchingMode } = useChatStore();
- const showExec = (isProcessing || isPaused) && !switchingMode;
+ const { isProcessing, isPaused, pausedTask, interruptResult, switchingMode, isLoadingHistory: storeIsLoadingHistory } = useChatStore();
+ const isLoadingHistory = propIsLoadingHistory ?? storeIsLoadingHistory;
+ const showExec = (isProcessing || isPaused) && !switchingMode && !isLoadingHistory;
/** 有中断结果文案时,统一只显示居中的横条(任务已暂停/恢复/取消/切换/已中断) */
- const showInterruptBarOnly = Boolean(interruptResult?.message);
+ const showInterruptBarOnly = Boolean(interruptResult?.message) && !isLoadingHistory;
return (
- <div className="statusbar-root">
+ <div className={`statusbar-root ${isLoadingHistory ? 'opacity-0 pointer-events-none' : ''}`}>
<div className="statusbar-center">
{showInterruptBarOnly && !teamMode ? (
<div
diff --git a/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts b/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts
index 9594f64837..f067bd8389 100644
--- a/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts
+++ b/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts
@@ -966,6 +966,8 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
if (shouldDropDuplicatedEvent('chat.processing_status', payload)) return;
// 切换模式时忽略处理状态更新
if (useChatStore.getState().switchingMode) return;
+ // 加载历史消息时忽略处理状态更新
+ if (useChatStore.getState().isLoadingHistory) return;
// 如果 interrupt_result 指示任务已完成,忽略 processing_status=true
const { interruptResult } = useChatStore.getState();
if (interruptResult && interruptResult.intent === 'resume' && interruptResult.success && interruptResult.has_active_task === false) {
diff --git a/jiuwenswarm/channels/web/frontend/src/stores/chatStore.ts b/jiuwenswarm/channels/web/frontend/src/stores/chatStore.ts
index 20b02b9c15..6d39a7f336 100644
--- a/jiuwenswarm/channels/web/frontend/src/stores/chatStore.ts
+++ b/jiuwenswarm/channels/web/frontend/src/stores/chatStore.ts
@@ -55,6 +55,7 @@ interface ChatState {
messages: Message[];
isProcessing: boolean;
isThinking: boolean; // 思考中状态(显示闪烁动画)
+ isLoadingHistory: boolean; // 正在加载历史消息
evolutionStatus: EvolutionStatusPayload | null;
isPaused: boolean; // 任务是否暂停
pausedTask: string | null; // 暂停的任务描述
@@ -86,6 +87,7 @@ interface ChatState {
stopStreaming: (streamKey?: string) => void;
setProcessing: (status: boolean) => void;
setThinking: (status: boolean) => void;
+ setLoadingHistory: (status: boolean) => void;
setEvolutionStatus: (status: EvolutionStatusPayload | null) => void;
setPaused: (paused: boolean, task?: string | null) => void;
setInterruptResult: (result: InterruptResultPayload | null) => void;
@@ -116,6 +118,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
messages: [],
isProcessing: false,
isThinking: false,
+ isLoadingHistory: false,
evolutionStatus: null,
isPaused: false,
pausedTask: null,
@@ -198,6 +201,10 @@ export const useChatStore = create<ChatState>((set, get) => ({
set({ isThinking: status });
},
+ setLoadingHistory: (status) => {
+ set({ isLoadingHistory: status });
+ },
+
setEvolutionStatus: (status) => {
if (evolutionStatusClearTimer) {
clearTimeout(evolutionStatusClearTimer);