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:切换mode下方执行栏不显示
openJiuwen-botbbbdfe7044ca
diff --git a/jiuwenclaw/web/src/App.tsx b/jiuwenclaw/web/src/App.tsxindex ef25258bec..57c9911466 100644--- a/jiuwenclaw/web/src/App.tsx+++ b/jiuwenclaw/web/src/App.tsx@@ -753,6 +753,12 @@ function AppContent() {if (mode === 'team' && sessionId) {cancel(sessionId);}+ // 切换模式/新建会话时直接设置状态,避免闪现+ useChatStore.getState().setSwitchingMode(true);+ useChatStore.getState().setInterruptResult(null);+ useChatStore.getState().setProcessing(false);+ useChatStore.getState().setThinking(false);+ useChatStore.getState().setPaused(false);disposeInFlightHistoryHandles();setHistoryPagerMeta(null);setHistoryLoadingMore(false);@@ -792,6 +798,10 @@ function AppContent() {setNewSessionToastVisible(false);newSessionToastTimerRef.current = null;}, 2000);+ // 延迟重置切换模式状态+ setTimeout(() => {+ useChatStore.getState().setSwitchingMode(false);+ }, 300);}, [cancel,clearMessages,@@ -812,6 +822,11 @@ function AppContent() {// 切换模式const handleSwitchMode = useCallback((mode: AgentMode) => {if (!sessionId || sessionId === 'new') return;+ // 切换模式时直接设置状态,避免闪现+ useChatStore.getState().setSwitchingMode(true);+ useChatStore.getState().setProcessing(false);+ useChatStore.getState().setThinking(false);+ useChatStore.getState().setPaused(false);void switchMode(sessionId, mode);}, [sessionId, switchMode]);diff --git a/jiuwenclaw/web/src/components/StatusBar/index.tsx b/jiuwenclaw/web/src/components/StatusBar/index.tsxindex f9ad95e8d1..c5becccdf2 100644--- a/jiuwenclaw/web/src/components/StatusBar/index.tsx+++ b/jiuwenclaw/web/src/components/StatusBar/index.tsx@@ -17,8 +17,8 @@ interface StatusBarProps {export function StatusBar({ onPause, onCancel, onResume }: StatusBarProps) {const { t } = useTranslation();- const { isProcessing, isPaused, pausedTask, interruptResult } = useChatStore();- const showExec = isProcessing || isPaused;+ const { isProcessing, isPaused, pausedTask, interruptResult, switchingMode } = useChatStore();+ const showExec = (isProcessing || isPaused) && !switchingMode;/** 有中断结果文案时,统一只显示居中的横条(任务已暂停/恢复/取消/切换/已中断) */const showInterruptBarOnly = Boolean(interruptResult?.message);diff --git a/jiuwenclaw/web/src/hooks/useWebSocket.ts b/jiuwenclaw/web/src/hooks/useWebSocket.tsindex a7c85d1214..8753b7ec72 100644--- a/jiuwenclaw/web/src/hooks/useWebSocket.ts+++ b/jiuwenclaw/web/src/hooks/useWebSocket.ts@@ -407,21 +407,31 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {// 切换模式const switchMode = useCallback(async (sessionId: string, mode: AgentMode) => {+ // 标记正在切换模式+ useChatStore.getState().setSwitchingMode(true);++ // 只有在有任务执行时才调用 interruptif (sessionId && sessionId !== 'new') {- try {- await interrupt(sessionId, 'cancel');- } catch {- // 忽略中断错误,继续切换模式+ const state = useChatStore.getState();+ if (state.isProcessing || state.isPaused) {+ try {+ await interrupt(sessionId, 'cancel');+ } catch {+ // 忽略中断错误+ }}}- setProcessing(false);- setThinking(false);+setMode(mode);if (sessionId && sessionId !== 'new') {updateSession(sessionId, { mode });}+ // 延迟重置标志+ setTimeout(() => {+ useChatStore.getState().setSwitchingMode(false);+ }, 300);},- [setMode, updateSession, setProcessing, setThinking, interrupt]+ [setMode, updateSession, interrupt]);// 发送用户回答@@ -765,6 +775,8 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {webClient.on('chat.processing_status', ({ payload }) => {if (!shouldHandleSessionEvent(payload)) return;if (shouldDropDuplicatedEvent('chat.processing_status', payload)) return;+ // 切换模式时忽略处理状态更新+ if (useChatStore.getState().switchingMode) return;const isProcessingNow = Boolean(payload.is_processing);setProcessing(isProcessingNow);if (!isProcessingNow) {@@ -812,6 +824,8 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {webClient.on('chat.interrupt_result', ({ payload }) => {if (!shouldHandleSessionEvent(payload)) return;if (shouldDropDuplicatedEvent('chat.interrupt_result', payload)) return;+ // 切换模式时忽略中断结果+ if (useChatStore.getState().switchingMode) return;const resultPayload = payload as unknown as InterruptResultPayload;setInterruptResult(resultPayload);if (resultPayload.intent === 'pause') {diff --git a/jiuwenclaw/web/src/stores/chatStore.ts b/jiuwenclaw/web/src/stores/chatStore.tsindex acc3b4436c..ee50ab1f1c 100644--- a/jiuwenclaw/web/src/stores/chatStore.ts+++ b/jiuwenclaw/web/src/stores/chatStore.ts@@ -58,6 +58,7 @@ interface ChatState {isPaused: boolean; // 任务是否暂停pausedTask: string | null; // 暂停的任务描述interruptResult: InterruptResultPayload | null; // 最近的中断结果+ switchingMode: boolean; // 是否正在切换模式currentStreamContent: string;currentStreamId: string | null;streamBuffers: Map<string, string>;@@ -87,6 +88,7 @@ interface ChatState {setEvolutionStatus: (status: EvolutionStatusPayload | null) => void;setPaused: (paused: boolean, task?: string | null) => void;setInterruptResult: (result: InterruptResultPayload | null) => void;+ setSwitchingMode: (switching: boolean) => void;addToolCall: (toolCall: ToolCall, options?: { startedAt?: string }) => void;addToolResult: (toolResult: ToolResult, options?: { updatedAt?: string }) => void;markTimedOutExecutions: () => void;@@ -115,6 +117,7 @@ export const useChatStore = create<ChatState>((set, get) => ({isPaused: false,pausedTask: null,interruptResult: null,+ switchingMode: false,currentStreamContent: '',currentStreamId: null,streamBuffers: new Map(),@@ -231,6 +234,21 @@ export const useChatStore = create<ChatState>((set, get) => ({}},+ setSwitchingMode: (switching) => {+ // 切换模式时,同时重置所有相关状态+ if (switching) {+ set({+ switchingMode: true,+ isProcessing: false,+ isPaused: false,+ pausedTask: null,+ interruptResult: null+ });+ } else {+ set({ switchingMode: false });+ }+ },+addToolCall: (toolCall, options) => {set((state) => {if (!toolCall.id) {@@ -508,6 +526,7 @@ export const useChatStore = create<ChatState>((set, get) => ({isPaused: false,pausedTask: null,interruptResult: null,+ switchingMode: false,activeSubtasks: new Map(),toolExecutions: new Map(),toolExecutionOrder: [],