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:增加上下文压缩显示
xiaoyao425ce50277ff15
diff --git a/jiuwenswarm/channels/web/frontend/package.json b/jiuwenswarm/channels/web/frontend/package.jsonindex 1e5b600b6b..222240ba7d 100644--- a/jiuwenswarm/channels/web/frontend/package.json+++ b/jiuwenswarm/channels/web/frontend/package.json@@ -16,6 +16,7 @@"clsx": "^2.1.0","i18next": "^25.8.18","i18next-browser-languagedetector": "^8.2.1",+ "lucide-react": "1.16.0","qrcode.react": "^4.2.0","react": "^18.2.0","react-dom": "^18.2.0",diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/MessageItem.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/MessageItem.tsxindex 68ae22a421..88780bd6b5 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/MessageItem.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/MessageItem.tsx@@ -6,8 +6,19 @@import { useState, useCallback, useEffect, useRef } from 'react';import type { ReactNode } from 'react';+import {+ Copy,+ Info,+ Square,+ Volume2,+} from 'lucide-react';import { useTranslation } from 'react-i18next';-import { Message, FileDownloadItem } from '../../types';+import {+ Message,+ FileDownloadItem,+ ContextCompressionRuntime,+ ContextCompressionSummary,+} from '../../types';import { StreamingContent } from './StreamingContent';import { ToolCallDisplay } from './ToolCallDisplay';import { MediaRenderer } from './MediaRenderer';@@ -196,6 +207,54 @@ function TeamLeaderPlainTextMessage({);}+export function ContextCompressionLines({+ runtime,+ summary,+ showSummary = true,+}: {+ runtime?: ContextCompressionRuntime;+ summary?: ContextCompressionSummary;+ showSummary?: boolean;+}) {+ const { t } = useTranslation();+ const showRuntime = Boolean(runtime?.summary);+ const finalSummary = !runtime && showSummary && summary && summary.count > 0 ? summary : null;+ if (!showRuntime && !finalSummary) return null;++ const isRunning = runtime?.status === 'running';+ const isFailed = runtime?.status === 'failed';+ const summaryItems = (finalSummary?.summaries ?? []).filter(Boolean);+ const detailText = summaryItems+ .map((item, index) => `${index + 1}. ${item}`)+ .join('\n');++ return (+ <>+ {showRuntime && (+ <div className={clsx(+ 'mt-2 flex items-center gap-1.5 text-xs',+ isFailed ? 'text-danger' : 'text-text-muted'+ )}>+ <span className={clsx(isRunning && 'context-compression-running-text')}>+ {runtime?.summary}+ </span>+ </div>+ )}+ {finalSummary && (+ <div+ className="mt-2 flex items-center gap-1.5 text-xs text-text-muted"+ title={detailText || undefined}+ >+ <Info className="h-3.5 w-3.5" strokeWidth={1.8} />+ <span>+ {t('chat.contextCompressionCompleted', { count: finalSummary.count })}+ </span>+ </div>+ )}+ </>+ );+}+export function getMessageActor(message: Message): string | null {if (message.role !== 'system') {return null;@@ -519,6 +578,10 @@ export function MessageItem({);const showCopy = Boolean(content) && !isStreaming;const isPlaying = audioBase64 ? isAudioPlaying : isSpeaking;+ const visibleMediaItems = mediaItems?.length ? mediaItems : null;+ const visibleFileItems = fileItems?.length ? fileItems : null;+ const hasBubbleContent =+ isUser || Boolean(content) || Boolean(visibleMediaItems) || Boolean(visibleFileItems);return (<div className={clsx(@@ -530,38 +593,40 @@ export function MessageItem({<div className="hidden" data-testid="thinking-summary" aria-hidden="true" />)}- <div- className={clsx(- 'chat-bubble relative group',- isUser ? 'user' : 'assistant',- !isUser && !isStreaming && 'markdown',- isStreaming && 'streaming'- )}- data-testid={!isUser ? 'thinking-panel' : undefined}- >- {isStreaming ? (- <StreamingContent content={content} isStreaming={true} />- ) : (- <>- {isUser ? (- <div className="chat-text">- <span className="whitespace-pre-wrap">{content}</span>- </div>- ) : (- <MarkdownMessageBody- content={content}- testId="thinking-body"- />- )}- {mediaItems && mediaItems.length > 0 && (- <MediaRenderer items={mediaItems} />- )}- {fileItems && fileItems.length > 0 && (- <FileDownloadList files={fileItems} />- )}- </>- )}- </div>+ {hasBubbleContent && (+ <div+ className={clsx(+ 'chat-bubble relative group',+ isUser ? 'user' : 'assistant',+ !isUser && !isStreaming && 'markdown',+ isStreaming && 'streaming'+ )}+ data-testid={!isUser ? 'thinking-panel' : undefined}+ >+ {isStreaming ? (+ <StreamingContent content={content} isStreaming={true} />+ ) : (+ <>+ {isUser ? (+ <div className="chat-text">+ <span className="whitespace-pre-wrap">{content}</span>+ </div>+ ) : (+ <MarkdownMessageBody+ content={content}+ testId="thinking-body"+ />+ )}+ {visibleMediaItems && (+ <MediaRenderer items={visibleMediaItems} />+ )}+ {visibleFileItems && (+ <FileDownloadList files={visibleFileItems} />+ )}+ </>+ )}+ </div>+ )}{/* Token usage summary */}{!isUser && !isStreaming && message.usageSummary && message.usageSummary.total_tokens > 0 && (@@ -596,9 +661,7 @@ export function MessageItem({className="p-1.5 rounded-md transition-colors hover:text-accent hover:bg-secondary"title={t('chatUi.copyMessage')}>- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={1.5}>- <path strokeLinecap="round" strokeLinejoin="round" d="M8.25 6.75h7.5m-7.5 3h7.5m-7.5 3h4.5M6.75 3h7.5A2.25 2.25 0 0116.5 5.25v13.5A2.25 2.25 0 0114.25 21h-7.5A2.25 2.25 0 014.5 18.75V5.25A2.25 2.25 0 016.75 3z" />- </svg>+ <Copy className="w-4 h-4" strokeWidth={1.5} /></button>)}@@ -614,13 +677,9 @@ export function MessageItem({title={isPlaying ? t('chatUi.stopReading') : t('chatUi.readMessage')}>{isPlaying ? (- <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">- <rect x="6" y="6" width="12" height="12" rx="2" />- </svg>+ <Square className="w-4 h-4 fill-current" strokeWidth={1.5} />) : (- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={1.5}>- <path strokeLinecap="round" strokeLinejoin="round" d="M19.114 5.636a9 9 0 010 12.728M16.463 8.288a5.25 5.25 0 010 7.424M6.75 8.25l4.72-4.72a.75.75 0 011.28.53v15.88a.75.75 0 01-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.01 9.01 0 012.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75z" />- </svg>+ <Volume2 className="w-4 h-4" strokeWidth={1.5} />)}</button>)}diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/index.tsxindex df6298ad37..a8d9359cbc 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/index.tsx@@ -5,10 +5,12 @@*/import React, { useRef, useEffect, useLayoutEffect, useCallback } from 'react';+import { ArrowRight, Sparkles } from 'lucide-react';import { useTranslation } from 'react-i18next';import { useChatStore } from '../../stores';import { AgentMode, UserAnswer } from '../../types';import { MessageList } from './MessageList';+import { ContextCompressionLines } from './MessageItem';import { InputArea } from './InputArea';import { SubtaskProgress } from './SubtaskProgress';import { InlineQuestionCard } from './InlineQuestionCard';@@ -52,13 +54,9 @@ function ThinkingIndicator() {function SuggestionCard({ text, onClick }: { text: string; onClick: () => void }) {return (<button className="chat-suggestion-card" onClick={onClick}>- <svg className="chat-suggestion-card__icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2}>- <path strokeLinecap="round" strokeLinejoin="round" d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z" />- </svg>+ <Sparkles className="chat-suggestion-card__icon" strokeWidth={2} /><span className="chat-suggestion-card__text">{text}</span>- <svg className="chat-suggestion-card__arrow" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2}>- <path strokeLinecap="round" strokeLinejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />- </svg>+ <ArrowRight className="chat-suggestion-card__arrow" strokeWidth={2} /></button>);}@@ -93,7 +91,13 @@ export function ChatPanel({historyPager = null,}: ChatPanelProps) {const { t } = useTranslation();- const { messages, isThinking, toolExecutionOrder } = useChatStore();+ const {+ messages,+ isThinking,+ toolExecutionOrder,+ contextCompressionRuntime,+ contextCompressionSummary,+ } = useChatStore();const messagesEndRef = useRef<HTMLDivElement>(null);const scrollContainerRef = useRef<HTMLDivElement>(null);const prependScrollSnapRef = useRef<{ sh: number; st: number } | null>(null);@@ -148,7 +152,7 @@ export function ChatPanel({behavior: historyPager?.loadedPages === 1 ? 'auto' : 'smooth',});}- }, [messages, isThinking, historyPager]);+ }, [messages, isThinking, contextCompressionRuntime, contextCompressionSummary, historyPager]);useLayoutEffect(() => {if (!historyPager) {@@ -226,6 +230,10 @@ export function ChatPanel({<InlineQuestionCard onSubmit={onUserAnswer} />{/* 思考中指示器 */}{isThinking && <ThinkingIndicator />}+ <ContextCompressionLines+ runtime={contextCompressionRuntime}+ summary={contextCompressionSummary}+ /></>) : (<div className="flex items-center justify-center h-32">diff --git a/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts b/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.tsindex 75d215c372..59d0ba18fb 100644--- a/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts+++ b/jiuwenswarm/channels/web/frontend/src/hooks/useWebSocket.ts@@ -24,6 +24,8 @@ import {ToolCall,UsageSummary,FileDownloadItem,+ ContextCompressionRuntime,+ ContextCompressionSummary,} from '../types';import { useChatStore, useTodoStore, useSessionStore, useHarnessStore } from '../stores';import { webClient } from '../services/webClient';@@ -89,6 +91,20 @@ interface UseWebSocketReturn {getInflightCount: () => number;}+interface ContextCompressionStatePayload {+ status: string;+ summary: string;+ operation_id: string;+ phase: string;+ processor: string;+}++interface PendingContextCompressionStart {+ timer: ReturnType<typeof setTimeout>;+ runtimeState: Omit<ContextCompressionRuntime, 'status'>;+ shown: boolean;+}+function normalizeAgentMode(rawMode: unknown): AgentMode {if (typeof rawMode !== 'string') return 'agent.plan';const normalized = rawMode.trim().toLowerCase();@@ -99,6 +115,7 @@ function normalizeAgentMode(rawMode: unknown): AgentMode {}const EVENT_DEDUP_WINDOW_MS = 1500;+const CONTEXT_COMPRESSION_START_DELAY_MS = 300;function normalizeEventTimestampIso(value: unknown): string {if (typeof value === 'number' && Number.isFinite(value)) {@@ -167,6 +184,12 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {const sendMessageRef = useRef<typeof sendMessage>();const recentEventRef = useRef<Map<string, number>>(new Map());const eventDedupDroppedRef = useRef<Record<string, number>>({});+ const contextCompressionSummaryRef = useRef<ContextCompressionSummary>({+ count: 0,+ summaries: [],+ });+ const pendingContextCompressionStartRef =+ useRef<PendingContextCompressionStart | null>(null);// Storesconst {@@ -189,6 +212,7 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {setPendingQuestion,removeFromTaskQueue,addFileItems,+ setContextCompressionStatus,} = useChatStore();const { setTodos, clearTodos } = useTodoStore();const {@@ -348,11 +372,112 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {}}, [updateMessage]);+ const clearPendingContextCompressionStart = useCallback(() => {+ const pending = pendingContextCompressionStartRef.current;+ if (pending) {+ clearTimeout(pending.timer);+ pendingContextCompressionStartRef.current = null;+ }+ }, []);++ const resetContextCompressionTurn = useCallback(() => {+ clearPendingContextCompressionStart();+ contextCompressionSummaryRef.current = { count: 0, summaries: [] };+ setContextCompressionStatus(undefined);+ }, [clearPendingContextCompressionStart, setContextCompressionStatus]);++ const finishContextCompressionTurn = useCallback(() => {+ clearPendingContextCompressionStart();+ const summary = contextCompressionSummaryRef.current;+ setContextCompressionStatus(undefined, summary.count > 0 ? summary : undefined);+ }, [clearPendingContextCompressionStart, setContextCompressionStatus]);++ const handleContextCompressionState = useCallback(+ (payload: ContextCompressionStatePayload) => {+ const status = payload.status.trim().toLowerCase();+ const summary = payload.summary.trim();+ if (!status || !summary) return;++ const operationId = payload.operation_id.trim();+ const phase = payload.phase.trim() || undefined;+ const processor = payload.processor.trim() || undefined;+ const runtimeState = {+ summary,+ operationId,+ phase,+ processor,+ };++ if (status === 'completed') {+ clearPendingContextCompressionStart();+ const current = contextCompressionSummaryRef.current;+ const nextSummary = {+ count: current.count + 1,+ summaries: [...current.summaries, summary],+ };+ contextCompressionSummaryRef.current = nextSummary;+ setContextCompressionStatus({+ ...runtimeState,+ status: 'completed',+ });+ return;+ }++ if (status === 'started' || status === 'running') {+ clearPendingContextCompressionStart();+ const pending: PendingContextCompressionStart = {+ runtimeState,+ shown: false,+ timer: setTimeout(() => {+ if (pendingContextCompressionStartRef.current !== pending) return;+ pending.shown = true;+ setContextCompressionStatus({+ ...pending.runtimeState,+ status: 'running',+ });+ }, CONTEXT_COMPRESSION_START_DELAY_MS),+ };+ pendingContextCompressionStartRef.current = pending;+ return;+ }++ if (status === 'noop' || status === 'skipped') {+ const pending = pendingContextCompressionStartRef.current;+ if (pending && !pending.shown) {+ clearPendingContextCompressionStart();+ return;+ }+ if (pending) {+ clearPendingContextCompressionStart();+ }+ setContextCompressionStatus({+ ...runtimeState,+ status: 'unchanged',+ });+ return;+ }++ if (status === 'failed' || status === 'error') {+ clearPendingContextCompressionStart();+ setContextCompressionStatus({+ ...runtimeState,+ status: 'failed',+ });+ }+ },+ [clearPendingContextCompressionStart, setContextCompressionStatus]+ );++ useEffect(() => {+ return clearPendingContextCompressionStart;+ }, [clearPendingContextCompressionStart]);+// 发送聊天消息const sendMessage = useCallback(async (content: string, sessionId: string) => {if (!content.trim()) return;+ resetContextCompressionTurn();userInputVersionRef.current += 1;stopAllTts();@@ -401,7 +526,7 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {});}},- [addMessage, request, setProcessing, setThinking]+ [addMessage, request, resetContextCompressionTurn, setProcessing, setThinking]);// 存储sendMessage函数到ref@@ -418,6 +543,7 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {) => {const newInput = options?.newInput;if (intent === 'supplement' && newInput) {+ resetContextCompressionTurn();userInputVersionRef.current += 1;stopAllTts();if (useSessionStore.getState().mode === 'team') {@@ -451,7 +577,13 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {onErrorRef.current?.(webError.message || i18n.t('network.interruptFailed'));}},- [addMessage, closeActiveTeamLeaderMessages, request, setConnectionStats]+ [+ addMessage,+ closeActiveTeamLeaderMessages,+ request,+ resetContextCompressionTurn,+ setConnectionStats,+ ]);// 暂停 - 显式暂停当前任务@@ -733,6 +865,7 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {const currentMode = useSessionStore.getState().mode;const content = normalizeFinalContent(payload);+ finishContextCompressionTurn();// team 模式下,将 chat.final 作为 team_leader 消息处理if (currentMode === 'team' && content) {@@ -942,6 +1075,13 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {tokens_used: tokensUsed,});}),+ webClient.on<ContextCompressionStatePayload>(+ 'context.compression_state',+ ({ payload }) => {+ if (!shouldHandleSessionEvent(payload)) return;+ handleContextCompressionState(payload);+ }+ ),webClient.on('heartbeat.relay', ({ payload }) => {const heartbeatText =typeof payload.heartbeat === 'string' ? payload.heartbeat : '';@@ -1412,7 +1552,9 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {addToolResult,appendStreamContent,clearSubtasks,+ finishContextCompressionTurn,handleConnectionAck,+ handleContextCompressionState,handleTtsPlayback,setMode,setPaused,diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.jsonindex b53fc07386..4c191582bc 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json@@ -126,6 +126,7 @@"modeSwitchConfirm": "Current session has history messages. Switching mode will create a new session. Continue?","teamPause": "Pause","teamPauseHint": "After pausing a team, send the next message to continue",+ "contextCompressionCompleted": "Completed context compression {{count}} time(s) this turn","historyPager": {"loadedOfTotal": "Loaded {{loaded}} / {{total}} pages","loadingMore": "Loading...",diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.jsonindex b7ca25814a..e5561d0b12 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json@@ -126,6 +126,7 @@"modeSwitchConfirm": "当前会话有历史消息,切换模式将新建会话。是否继续?","teamPause": "暂停","teamPauseHint": "团队暂停后,直接发送下一条消息即可继续",+ "contextCompressionCompleted": "本轮完成上下文压缩 {{count}} 次","historyPager": {"loadedOfTotal": "历史已加载 {{loaded}} / {{total}} 页","loadingMore": "加载中…",diff --git a/jiuwenswarm/channels/web/frontend/src/index.css b/jiuwenswarm/channels/web/frontend/src/index.cssindex 3f290c4534..20428d1219 100644--- a/jiuwenswarm/channels/web/frontend/src/index.css+++ b/jiuwenswarm/channels/web/frontend/src/index.css@@ -360,6 +360,21 @@ select {}}+@keyframes text-muted-breath {+ 0% {+ color: var(--text);+ opacity: 0.78;+ }+ 50% {+ color: #e4e4e7;+ opacity: 1;+ }+ 100% {+ color: var(--text);+ opacity: 0.78;+ }+}+@keyframes pulse-subtle {0%,100% {@@ -861,6 +876,12 @@ select {line-height: 1.7142857;}+ .context-compression-running-text {+ display: inline-block;+ color: var(--text);+ animation: text-muted-breath 2.8s ease-in-out infinite;+ }+/* Chat input task queue */.chat-input-task-queue {margin-bottom: 12px;diff --git a/jiuwenswarm/channels/web/frontend/src/services/webClient.ts b/jiuwenswarm/channels/web/frontend/src/services/webClient.tsindex be95e2054d..f032896c14 100644--- a/jiuwenswarm/channels/web/frontend/src/services/webClient.ts+++ b/jiuwenswarm/channels/web/frontend/src/services/webClient.ts@@ -12,6 +12,7 @@ import { getWsBase } from '../utils/env';import i18n from '../i18n';type EventHandler = (event: WsEvent) => void;+type TypedEventHandler<TPayload> = (event: WsEvent & { payload: TPayload }) => void;type StateHandler = (state: WebConnectionState) => void;interface PendingRequest {@@ -97,9 +98,13 @@ class WebClient {};}- on(eventName: string, handler: EventHandler): () => void {+ on<TPayload = Record<string, unknown>>(+ eventName: string,+ handler: TypedEventHandler<TPayload>+ ): () => void {const set = this.handlers.get(eventName) ?? new Set<EventHandler>();- set.add(handler);+ const eventHandler = handler as EventHandler;+ set.add(eventHandler);this.handlers.set(eventName, set);return () => {@@ -107,7 +112,7 @@ class WebClient {if (!target) {return;}- target.delete(handler);+ target.delete(eventHandler);if (target.size === 0) {this.handlers.delete(eventName);}diff --git a/jiuwenswarm/channels/web/frontend/src/stores/chatStore.ts b/jiuwenswarm/channels/web/frontend/src/stores/chatStore.tsindex 0689e5cafb..e8917195d6 100644--- a/jiuwenswarm/channels/web/frontend/src/stores/chatStore.ts+++ b/jiuwenswarm/channels/web/frontend/src/stores/chatStore.ts@@ -15,6 +15,8 @@ import {EvolutionStatusPayload,UsageSummary,FileDownloadItem,+ ContextCompressionRuntime,+ ContextCompressionSummary,} from '../types';import { useTodoStore } from './todoStore';@@ -69,6 +71,8 @@ interface ChatState {toolExecutions: Map<string, ToolExecution>;toolExecutionOrder: string[];orphanResults: Map<string, ToolResult>;+ contextCompressionRuntime?: ContextCompressionRuntime;+ contextCompressionSummary?: ContextCompressionSummary;toolMetrics: {toolCallDedupDropped: number;toolResultDedupDropped: number;@@ -114,6 +118,10 @@ interface ChatState {setUsageSummary: (messageId: string, usage: UsageSummary) => void;// File download itemsaddFileItems: (files: FileDownloadItem[]) => void;+ setContextCompressionStatus: (+ runtime?: ContextCompressionRuntime,+ summary?: ContextCompressionSummary+ ) => void;}export const useChatStore = create<ChatState>((set, get) => ({@@ -134,6 +142,8 @@ export const useChatStore = create<ChatState>((set, get) => ({toolExecutions: new Map(),toolExecutionOrder: [],orphanResults: new Map(),+ contextCompressionRuntime: undefined,+ contextCompressionSummary: undefined,toolMetrics: {toolCallDedupDropped: 0,toolResultDedupDropped: 0,@@ -548,6 +558,8 @@ export const useChatStore = create<ChatState>((set, get) => ({toolExecutions: new Map(),toolExecutionOrder: [],orphanResults: new Map(),+ contextCompressionRuntime: undefined,+ contextCompressionSummary: undefined,toolMetrics: {toolCallDedupDropped: 0,toolResultDedupDropped: 0,@@ -626,4 +638,11 @@ export const useChatStore = create<ChatState>((set, get) => ({),}));},++ setContextCompressionStatus: (runtime, summary) => {+ set({+ contextCompressionRuntime: runtime,+ contextCompressionSummary: summary,+ });+ },}));diff --git a/jiuwenswarm/channels/web/frontend/src/types/message.ts b/jiuwenswarm/channels/web/frontend/src/types/message.tsindex d831e5352d..81fb728e82 100644--- a/jiuwenswarm/channels/web/frontend/src/types/message.ts+++ b/jiuwenswarm/channels/web/frontend/src/types/message.ts@@ -29,6 +29,19 @@ export interface FileDownloadItem {download_token: string;}+export interface ContextCompressionRuntime {+ status: 'running' | 'completed' | 'unchanged' | 'failed';+ summary: string;+ operationId: string;+ phase?: string;+ processor?: string;+}++export interface ContextCompressionSummary {+ count: number;+ summaries: string[];+}+export interface Message {id: string;role: MessageRole;@@ -83,4 +96,4 @@ export interface Conversation {messages: Message[];createdAt: string;updatedAt: string;-}\ No newline at end of file+}