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
feat:1.会话新增agentteam模式(前端样式)2.会话发送时页面滚动到底部
openJiuwen-bot374f1078c3b4
diff --git a/jiuwenclaw/web/src/components/ChatPanel/ChatPanel.css b/jiuwenclaw/web/src/components/ChatPanel/ChatPanel.cssindex 8571c020b1..9239005f18 100644--- a/jiuwenclaw/web/src/components/ChatPanel/ChatPanel.css+++ b/jiuwenclaw/web/src/components/ChatPanel/ChatPanel.css@@ -96,7 +96,7 @@--chat-mode-pad: 4px;position: relative;display: grid;- grid-template-columns: repeat(2, minmax(0, 1fr));+ grid-template-columns: repeat(3, minmax(0, 1fr));gap: var(--chat-mode-gap);padding: var(--chat-mode-pad);border-radius: var(--radius-full);@@ -109,7 +109,7 @@top: var(--chat-mode-pad);left: var(--chat-mode-pad);bottom: var(--chat-mode-pad);- width: calc((100% - (var(--chat-mode-pad) * 2) - var(--chat-mode-gap)) / 2);+ width: calc((100% - (var(--chat-mode-pad) * 2) - (var(--chat-mode-gap) * 2)) / 3);border-radius: var(--radius-full);transform: translateX(calc(var(--chat-mode-index, 0) * (100% + var(--chat-mode-gap))));background: var(--accent);diff --git a/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx b/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsxindex adfcab4260..e0c3e53e58 100644--- a/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx+++ b/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx@@ -11,7 +11,7 @@ interface InputAreaProps {onInterrupt: (newInput?: string) => void;onSwitchMode: (mode: AgentMode) => void;isProcessing: boolean;- onNewSession: () => void;+ onNewSession: () => Promise<void>;}export function InputArea({@@ -43,6 +43,11 @@ export function InputArea({<path strokeLinecap="round" strokeLinejoin="round" d="M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437l1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008z" /></svg>)},+ { value: 'agentteam', label: 'Agent Team', icon: (+ <svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>+ <path strokeLinecap="round" strokeLinejoin="round" d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z" />+ </svg>+ )},];const {@@ -196,14 +201,14 @@ export function InputArea({[handleVoiceEnd]);- const handleNewSession = useCallback(() => {+ const handleNewSession = useCallback(async () => {if (isListening || isInterruptible) return;setInputValue('');setPendingVoiceText('');if (textareaRef.current) {textareaRef.current.style.height = 'auto';}- onNewSession();+ await onNewSession();}, [isListening, isInterruptible, onNewSession, setInputValue]);const displayValue = isListening@@ -289,8 +294,12 @@ export function InputArea({<buttontype="button"key={m.value}- onClick={() => {+ onClick={async () => {if (mode !== m.value) {+ // 切换到 AgentTeam 模式时新建 session+ if (m.value === 'agentteam') {+ await onNewSession();+ }onSwitchMode(m.value);}}}diff --git a/jiuwenclaw/web/src/components/ChatPanel/index.tsx b/jiuwenclaw/web/src/components/ChatPanel/index.tsxindex 6a7d21f3b3..e15164507d 100644--- a/jiuwenclaw/web/src/components/ChatPanel/index.tsx+++ b/jiuwenclaw/web/src/components/ChatPanel/index.tsx@@ -27,7 +27,7 @@ interface ChatPanelProps {onInterrupt: (newInput?: string) => void;onSwitchMode: (mode: AgentMode) => void;isProcessing: boolean;- onNewSession: () => void;+ onNewSession: () => Promise<void>;onUserAnswer: (requestId: string, answers: UserAnswer[]) => void;/** 自会话管理恢复历史后出现;支持分页加载更早消息 */historyPager?: ChatHistoryPagerProps | null;@@ -79,6 +79,7 @@ export function ChatPanel({const prependScrollSnapRef = useRef<{ sh: number; st: number } | null>(null);const wasHistoryLoadingRef = useRef(false);const suppressNextScrollToEndRef = useRef(false);+ const [isSending, setIsSending] = React.useState(false);const suggestions = [t('chat.welcomeSuggestions.journey'),t('chat.welcomeSuggestions.skills'),@@ -155,9 +156,24 @@ export function ChatPanel({wasHistoryLoadingRef.current = false;}, [historyPager, messages.length]);+ // 包装发送消息函数,添加滚动逻辑+ const handleSendMessage = useCallback((content: string) => {+ setIsSending(true);+ onSendMessage(content);+ }, [onSendMessage]);++ // 当发送消息时强制滚动到底部+ useEffect(() => {+ if (isSending) {+ messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });+ userScrolledUpRef.current = false;+ setIsSending(false);+ }+ }, [isSending]);+const handleSuggestion = useCallback(- (text: string) => onSendMessage(text),- [onSendMessage],+ (text: string) => handleSendMessage(text),+ [handleSendMessage],);return (@@ -209,7 +225,7 @@ export function ChatPanel({<div className="chat-compose px-3 pb-4"><InputArea- onSubmit={onSendMessage}+ onSubmit={handleSendMessage}onInterrupt={onInterrupt}onSwitchMode={onSwitchMode}isProcessing={isProcessing}diff --git a/jiuwenclaw/web/src/hooks/useWebSocket.ts b/jiuwenclaw/web/src/hooks/useWebSocket.tsindex 19e4b6086d..4c1b493c2d 100644--- a/jiuwenclaw/web/src/hooks/useWebSocket.ts+++ b/jiuwenclaw/web/src/hooks/useWebSocket.ts@@ -83,7 +83,7 @@ interface UseWebSocketReturn {function normalizeAgentMode(rawMode: unknown): AgentMode {if (typeof rawMode !== 'string') return 'plan';const normalized = rawMode.trim().toLowerCase();- return normalized === 'agent' ? 'agent' : 'plan';+ return normalized === 'agent' ? 'agent' : normalized === 'agentteam' ? 'agentteam' : 'plan';}const EVENT_DEDUP_WINDOW_MS = 1500;@@ -277,10 +277,11 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {setThinking(true);try {const currentMode = useSessionStore.getState().mode;+ const sendMode = currentMode === 'agentteam' ? 'team' : currentMode;await request('chat.send', {session_id: sessionId,content,- mode: currentMode,+ mode: sendMode,});} catch (error) {const webError = error as WebError;diff --git a/jiuwenclaw/web/src/stores/sessionStore.ts b/jiuwenclaw/web/src/stores/sessionStore.tsindex 42d12f61c1..2b81801a36 100644--- a/jiuwenclaw/web/src/stores/sessionStore.ts+++ b/jiuwenclaw/web/src/stores/sessionStore.ts@@ -32,7 +32,7 @@ const DEFAULT_MODE: AgentMode = 'plan';function normalizeAgentMode(mode: unknown): AgentMode {if (typeof mode !== 'string') return DEFAULT_MODE;const normalized = mode.trim().toLowerCase();- return normalized === 'agent' ? 'agent' : 'plan';+ return normalized === 'agent' ? 'agent' : normalized === 'agentteam' ? 'agentteam' : 'plan';}function normalizeSession(session: Session): Session {diff --git a/jiuwenclaw/web/src/types/index.ts b/jiuwenclaw/web/src/types/index.tsindex 93b6ecde01..552044e5bf 100644--- a/jiuwenclaw/web/src/types/index.ts+++ b/jiuwenclaw/web/src/types/index.ts@@ -22,7 +22,7 @@ export interface Session {tools?: string[];}-export type AgentMode = 'agent' | 'plan';+export type AgentMode = 'agent' | 'plan' | 'agentteam';export type SessionStatus = 'active' | 'paused' | 'completed' | 'interrupted';export interface OffloadFileListResponse {