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:广播结束消息不回显
yuhaiquan6bc36113b3ff
diff --git a/jiuwenswarm/channels/web/frontend/src/App.tsx b/jiuwenswarm/channels/web/frontend/src/App.tsxindex 438c41e488..779954e527 100644--- a/jiuwenswarm/channels/web/frontend/src/App.tsx+++ b/jiuwenswarm/channels/web/frontend/src/App.tsx@@ -1708,7 +1708,7 @@ function AppContent() {]);const handleRestoreSession = useCallback(- async (targetSessionId: string, targetMode?: string, targetSession?: Session) => {+ async (targetSessionId: string, targetMode?: string, targetSession?: Session, options?: { skipHistoryLoad?: boolean }) => {if (!isRestorableSessionId(targetSessionId)) return;const resolvedMode = targetMode ?? targetSession?.mode ?? mode;@@ -1742,7 +1742,9 @@ function AppContent() {}setActiveNav('chat');navigate({ kind: 'chat-session', sessionId: targetSessionId });- setHistoryBootstrapKey((k) => k + 1);+ if (!options?.skipHistoryLoad) {+ setHistoryBootstrapKey((k) => k + 1);+ }requestComposerFocus();if (!targetSession) {void loadSessionMetadata(targetSessionId);@@ -2066,6 +2068,8 @@ function AppContent() {// 构造最小 Session 占位对象,让 upsertSessionMetadata 直接加入会话列表,// 避免 loadSessionMetadata 立即失败导致"对话不存在或已删除"。// 后续 cron 广播到达时会刷新会话列表补全完整元数据。+ // 跳过初始历史加载:session 是全新的,空响应的 replaceHistoryMessages+ // 会覆盖后续到达的广播消息。void handleRestoreSession(session, undefined, {session_id: session,title: '',@@ -2076,7 +2080,7 @@ function AppContent() {message_count: 0,created_at: new Date().toISOString(),updated_at: new Date().toISOString(),- });+ }, { skipHistoryLoad: true });return;}requestSessionNavigation(session);diff --git a/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts b/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.tsindex f4d1bbb7e9..037cada7e0 100644--- a/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts+++ b/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts@@ -1656,8 +1656,9 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {let sessionId = resolveEventSessionId(payload);// cron 广播 session_id 为空(后端对 web 通道置空),- // 优先使用 cronMeta.exec_session_id 路由到定时任务专属会话,- // 不再 fallback 到当前活跃会话,避免广播消息污染创建者会话。+ // 优先使用 cronMeta.exec_session_id 路由到定时任务专属会话。+ // 若后端未提供 exec_session_id,fallback 到当前活跃会话——仅当它是 cron_ 前缀时,+ // 避免污染普通会话(用户在"立即执行"后正在查看 cron session 的场景)。if (!sessionId && cronMeta) {const execSessionId =typeof cronMeta.exec_session_id === 'string'@@ -1666,6 +1667,11 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {if (execSessionId) {sessionId = execSessionId;ensureSessionRuntimes(sessionId);+ } else {+ const currentSid = useSessionStore.getState().currentSession?.session_id ?? '';+ if (currentSid.startsWith('cron_')) {+ sessionId = currentSid;+ }}}if (!sessionId) return;