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

feat:agentTeam模式前端按钮隐藏

openJiuwen-botbcaa99a5bc46
diff --git a/jiuwenclaw/web/src/components/ChatPanel/ChatPanel.css b/jiuwenclaw/web/src/components/ChatPanel/ChatPanel.css
index 9239005f18..45821d705d 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(3, minmax(0, 1fr));
+ grid-template-columns: repeat(2, 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)) / 3);
+ width: calc((100% - (var(--chat-mode-pad) * 2) - (var(--chat-mode-gap) * 1)) / 2);
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.tsx
index e0c3e53e58..9574c48efa 100644
--- a/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx
+++ b/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx
@@ -22,16 +22,20 @@ export function InputArea({
onNewSession,
}: InputAreaProps) {
const [pendingVoiceText, setPendingVoiceText] = useState('');
+ const [showModeSwitchModal, setShowModeSwitchModal] = useState(false);
+ const [pendingMode, setPendingMode] = useState<AgentMode | null>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const autoSendTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const isComposingRef = useRef(false);
const activePointerIdRef = useRef<number | null>(null);
const isVoicePressingRef = useRef(false);
const { t } = useTranslation();
- const { isPaused, taskQueue, addToTaskQueue, removeFromTaskQueue, inputValue, setInputValue } = useChatStore();
+ const { isPaused, taskQueue, addToTaskQueue, removeFromTaskQueue, inputValue, setInputValue, messages } = useChatStore();
const { mode } = useSessionStore();
const isInterruptible = isProcessing || isPaused;
const isAgentMode = mode === 'agent';
+ const isTeamMode = mode === 'agentteam';
+ const hasHistoryMessages = messages.length > 0;
const modes: Array<{ value: AgentMode; label: string; icon: JSX.Element }> = [
{ value: 'plan', label: t('chat.modePlan'), icon: (
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
@@ -43,11 +47,6 @@ 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 {
@@ -83,7 +82,9 @@ export function InputArea({
setPendingVoiceText('');
setTimeout(() => {
- if (isInterruptible) {
+ if (isTeamMode) {
+ onSubmit(finalText);
+ } else if (isInterruptible) {
onInterrupt(finalText);
} else {
onSubmit(finalText);
@@ -95,7 +96,7 @@ export function InputArea({
}, 150);
}
}
- }, [isListening, pendingVoiceText, inputValue, isInterruptible, onSubmit, onInterrupt, setInputValue]);
+ }, [isListening, pendingVoiceText, inputValue, isInterruptible, isTeamMode, onSubmit, onInterrupt, setInputValue]);
useEffect(() => {
return () => {
@@ -113,12 +114,12 @@ export function InputArea({
stopListening();
}
- if (isInterruptible) {
+ if (isTeamMode) {
+ onSubmit(trimmed);
+ } else if (isInterruptible) {
if (isAgentMode) {
- // 智能执行模式下,将任务添加到队列
addToTaskQueue(trimmed);
} else {
- // 其他模式下,中断当前任务
onInterrupt(trimmed);
}
} else {
@@ -130,7 +131,7 @@ export function InputArea({
if (textareaRef.current) {
textareaRef.current.style.height = 'auto';
}
- }, [inputValue, pendingVoiceText, isInterruptible, isListening, onSubmit, onInterrupt, stopListening, isAgentMode, addToTaskQueue, setInputValue]);
+ }, [inputValue, pendingVoiceText, isInterruptible, isListening, onSubmit, onInterrupt, stopListening, isAgentMode, isTeamMode, addToTaskQueue, setInputValue]);
const handleKeyDown = useCallback(
(e: KeyboardEvent<HTMLTextAreaElement>) => {
@@ -211,6 +212,38 @@ export function InputArea({
await onNewSession();
}, [isListening, isInterruptible, onNewSession, setInputValue]);
+ const handleModeSwitch = useCallback(async (targetMode: AgentMode) => {
+ if (mode === targetMode) return;
+
+ // 只有切换到 agentteam 模式时才需要 newSession
+ if (targetMode === 'agentteam') {
+ if (hasHistoryMessages) {
+ setPendingMode(targetMode);
+ setShowModeSwitchModal(true);
+ } else {
+ await onNewSession();
+ onSwitchMode(targetMode);
+ }
+ } else {
+ // plan 和 agent 模式切换不 newSession
+ onSwitchMode(targetMode);
+ }
+ }, [mode, hasHistoryMessages, onNewSession, onSwitchMode]);
+
+ const confirmModeSwitch = useCallback(async () => {
+ if (pendingMode) {
+ setShowModeSwitchModal(false);
+ await onNewSession();
+ onSwitchMode(pendingMode);
+ setPendingMode(null);
+ }
+ }, [pendingMode, onNewSession, onSwitchMode]);
+
+ const cancelModeSwitch = useCallback(() => {
+ setShowModeSwitchModal(false);
+ setPendingMode(null);
+ }, []);
+
const displayValue = isListening
? inputValue + pendingVoiceText + interimTranscript
: inputValue + pendingVoiceText;
@@ -294,15 +327,7 @@ export function InputArea({
<button
type="button"
key={m.value}
- onClick={async () => {
- if (mode !== m.value) {
- // 切换到 AgentTeam 模式时新建 session
- if (m.value === 'agentteam') {
- await onNewSession();
- }
- onSwitchMode(m.value);
- }
- }}
+ onClick={() => handleModeSwitch(m.value)}
className={clsx(
'chat-mode-btn',
mode === m.value ? 'chat-mode-btn--active' : 'chat-mode-btn--inactive'
@@ -374,6 +399,31 @@ export function InputArea({
</button>
</div>
</div>
+
+ {showModeSwitchModal && (
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
+ <div className="bg-bg border border-border rounded-xl p-4 shadow-lg max-w-sm w-full mx-4">
+ <h3 className="text-base font-medium text-text mb-2">{t('chat.modeSwitchTitle')}</h3>
+ <p className="text-sm text-text-muted mb-4">{t('chat.modeSwitchConfirm')}</p>
+ <div className="flex justify-end gap-2">
+ <button
+ type="button"
+ onClick={cancelModeSwitch}
+ className="px-3 py-1.5 text-sm rounded-lg bg-secondary text-text-muted hover:bg-secondary/80"
+ >
+ {t('common.cancel')}
+ </button>
+ <button
+ type="button"
+ onClick={confirmModeSwitch}
+ className="px-3 py-1.5 text-sm rounded-lg bg-accent text-white hover:bg-accent/80"
+ >
+ {t('common.confirm')}
+ </button>
+ </div>
+ </div>
+ </div>
+ )}
</div>
);
}
diff --git a/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsx b/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsx
index ee0eb58e8b..a1a14d5e98 100644
--- a/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsx
+++ b/jiuwenclaw/web/src/components/ChatPanel/MessageItem.tsx
@@ -209,7 +209,153 @@ export function MessageItem({ message, autoSpeak = false }: MessageItemProps) {
);
}
}
-
+
+ // 检查是否为团队消息
+ if (content && content.startsWith('team.event:')) {
+ const [, jsonStr] = content.split('team.event:');
+ try {
+ const payload = JSON.parse(jsonStr);
+
+ const event = payload.event || payload.payload?.event;
+
+ if (event) {
+ const { type, from_member, to_member, content: messageContent, timestamp: eventTimestamp } = event;
+
+ const isP2P = type?.endsWith('.p2p');
+ const isBroadcast = type?.endsWith('.broadcast');
+ const isTeamLeaderMessage = from_member === 'team_leader' && !isP2P && !isBroadcast;
+
+ const formatEventTime = (ts: number) => {
+ if (!ts) return '';
+ const date = new Date(ts);
+ return date.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
+ };
+
+ // team_leader 发给用户的消息(不是 p2p 也不是 broadcast)
+ if (isTeamLeaderMessage) {
+ return (
+ <div className="flex justify-center my-2 animate-fade-in">
+ <div className="max-w-[85%] w-full rounded-xl border border-border bg-secondary/50 p-3 shadow-sm">
+ <div className="flex items-center gap-2 mb-1.5">
+ <div className="w-2 h-2 rounded-full bg-accent" />
+ <span className="font-medium text-sm text-text">
+ {from_member || 'Unknown'}
+ </span>
+ <span className="text-xs text-text-muted">
+ {formatEventTime(eventTimestamp)}
+ </span>
+ </div>
+ <div className="text-sm text-text leading-relaxed">
+ <span>{messageContent}</span>
+ </div>
+ </div>
+ </div>
+ );
+ }
+
+ // p2p 和 broadcast 消息展示
+ return (
+ <div className="flex justify-center my-2 animate-fade-in">
+ <div className="max-w-[85%] w-full rounded-xl border border-border bg-secondary/50 p-3 shadow-sm">
+ <div className="flex items-center gap-2 mb-1.5">
+ <div className="w-2 h-2 rounded-full bg-accent" />
+ <span className="font-medium text-sm text-text">
+ {from_member || 'Unknown'}
+ </span>
+ <span className="text-xs text-text-muted">
+ {formatEventTime(eventTimestamp)}
+ </span>
+ </div>
+ <div className="text-sm text-text leading-relaxed">
+ {isP2P && to_member && (
+ <span className="inline-flex items-center px-1.5 py-0.5 rounded bg-info/20 text-info text-xs mr-1.5">
+ @{to_member}
+ </span>
+ )}
+ {isBroadcast && (
+ <span className="inline-flex items-center px-1.5 py-0.5 rounded bg-warning/20 text-warning text-xs mr-1.5">
+ @所有人
+ </span>
+ )}
+ <span>{messageContent}</span>
+ </div>
+ </div>
+ </div>
+ );
+ }
+ } catch (e) {
+ return (
+ <div className="flex justify-center my-4 animate-fade-in">
+ <div className="px-4 py-2 rounded-full bg-secondary border border-border text-text-muted text-sm">
+ {content}
+ </div>
+ </div>
+ );
+ }
+ }
+
+ // 检查是否为 team_leader 消息(chat.delta/chat.final 累积的消息)
+ // 支持两种格式:1. team.leader: 2. 直接的 content(但需要 isStreaming 标记)
+ if (content && (content.startsWith('team.leader:') || (role === 'system' && isStreaming === true && !content.startsWith('team.event:') && !content.startsWith('chat.')))) {
+ let messageContent = content;
+ let eventTimestamp: number | undefined;
+
+ if (content.startsWith('team.leader:')) {
+ const [, jsonStr] = content.split('team.leader:');
+ try {
+ const data = JSON.parse(jsonStr);
+ messageContent = data.content;
+ eventTimestamp = data.timestamp;
+ } catch (e) {
+ }
+ }
+
+ const formatEventTime = (ts: number | undefined) => {
+ if (!ts) return '';
+ const date = new Date(ts);
+ return date.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
+ };
+
+ return (
+ <div className="flex justify-start my-3">
+ <div className="max-w-[82%] min-w-0">
+ <div className="flex items-start gap-3">
+ <div className="w-8 h-8 rounded-full bg-accent/20 flex items-center justify-center flex-shrink-0 mt-1">
+ <svg className="w-4 h-4 text-accent" 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 0z" />
+ </svg>
+ </div>
+ <div className="flex-1 min-w-0">
+ <div className="flex items-center gap-2 mb-1">
+ <span className="font-medium text-sm text-text">team_leader</span>
+ <span className="text-xs text-text-muted">{formatEventTime(eventTimestamp)}</span>
+ </div>
+ <div className="chat-text">
+ <ReactMarkdown
+ remarkPlugins={[remarkGfm]}
+ components={{
+ a: ({ node, href, children, ...props }) => (
+ <a
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ {...props}
+ >
+ {children}
+ </a>
+ )
+ }}
+ >
+ {messageContent}
+ </ReactMarkdown>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+ }
+
return (
<div className="flex justify-center my-4 animate-fade-in">
<div className="px-4 py-2 rounded-full bg-secondary border border-border text-text-muted text-sm">
diff --git a/jiuwenclaw/web/src/components/TeamArea.tsx b/jiuwenclaw/web/src/components/TeamArea.tsx
new file mode 100644
index 0000000000..1d26e37787
--- /dev/null
+++ b/jiuwenclaw/web/src/components/TeamArea.tsx
@@ -0,0 +1,84 @@
+/**
+ * TeamArea 组件
+ *
+ * 显示团队信息,包括团队名称、成员列表和成员状态
+ */
+
+import { useTodoStore } from '../stores';
+
+interface TeamMember {
+ id: string;
+ member_id: string;
+ status: string;
+ timestamp: number;
+ currentTask?: string;
+}
+
+interface TeamAreaProps {
+ teamName: string;
+ members: TeamMember[];
+}
+
+export function TeamArea({ teamName, members }: TeamAreaProps) {
+ const { todos } = useTodoStore();
+
+ // 获取每个成员正在执行的任务
+ const getMemberCurrentTask = (memberId: string) => {
+ return todos.find(todo => todo.claimedBy === memberId && todo.status === 'in_progress');
+ };
+
+ const getStatusColor = (status: TeamMember['status']) => {
+ switch (status) {
+ case 'ready':
+ return 'bg-ok';
+ case 'busy':
+ return 'bg-warning';
+ case 'completed':
+ return 'bg-success';
+ case 'idle':
+ return 'bg-text-muted';
+ case 'completing':
+ return 'bg-info';
+ default:
+ return 'bg-text-muted';
+ }
+ };
+
+ const formatTime = (timestamp: number) => {
+ const date = new Date(timestamp);
+ return date.toLocaleTimeString();
+ };
+
+ return (
+ <div className="h-full flex flex-col">
+ <div className="p-4 flex-1 overflow-hidden flex flex-col">
+ <h3 className="text-[11px] font-medium text-text-muted uppercase tracking-wider mb-4">
+ {teamName}
+ </h3>
+ <div className="flex-1 overflow-y-auto space-y-3">
+ {members.map((member) => {
+ const currentTask = getMemberCurrentTask(member.member_id);
+ return (
+ <div key={member.id} className="space-y-1">
+ <div className="flex items-center gap-2">
+ <span className={`w-2 h-2 rounded-full ${getStatusColor(member.status)}`} />
+ {/* <span className="text-sm font-medium">{member.name}</span> */}
+ <span className="text-xs text-text-muted">{member.member_id}</span>
+ <span className="ml-auto text-xs text-text-muted">{formatTime(member.timestamp)}</span>
+ </div>
+ <div className="text-xs text-text-muted ml-4">
+ 状态: {member.status}
+ </div>
+ {currentTask && (
+ <div className="text-xs text-text-muted ml-4 truncate max-w-[120px]">
+ 正在执行: {currentTask.content}
+ </div>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/jiuwenclaw/web/src/components/TeamTaskEvents.tsx b/jiuwenclaw/web/src/components/TeamTaskEvents.tsx
new file mode 100644
index 0000000000..7f0869c1e3
--- /dev/null
+++ b/jiuwenclaw/web/src/components/TeamTaskEvents.tsx
@@ -0,0 +1,56 @@
+/**
+ * TeamTaskEvents 组件
+ *
+ * 显示团队任务相关的事件日志
+ */
+
+interface TeamTaskEvent {
+ id: string;
+ type: string;
+ team_id: string;
+ task_id: string;
+ status: string;
+ timestamp: number;
+}
+
+interface TeamTaskEventsProps {
+ events: TeamTaskEvent[];
+}
+
+export function TeamTaskEvents({ events }: TeamTaskEventsProps) {
+
+ const formatTime = (timestamp: number) => {
+ const date = new Date(timestamp);
+ return date.toLocaleTimeString();
+ };
+
+ const getEventName = (type: string) => {
+ // 从 type 中提取 task 后的部分作为事件名称
+ const match = type.match(/team\.task\.(\w+)/);
+ return match ? match[1] : type;
+ };
+
+ return (
+ <div className="h-full flex flex-col">
+ <div className="p-4 flex-1 overflow-hidden flex flex-col">
+ <h3 className="text-[11px] font-medium text-text-muted uppercase tracking-wider mb-4">
+ 任务事件日志
+ </h3>
+ <div className="flex-1 overflow-y-auto space-y-2">
+ {events.map((event) => (
+ <div key={event.id} className="bg-secondary/50 rounded-md p-2 space-y-1">
+ <div className="flex items-center justify-between text-xs">
+ <span className="font-medium text-text">{getEventName(event.type)}</span>
+ <span className="text-text-muted">{formatTime(event.timestamp)}</span>
+ </div>
+ <div className="flex items-center gap-3 text-xs text-text-muted">
+ <span>任务: <span className="text-text">{event.task_id}</span></span>
+ <span>状态: <span className="text-text">{event.status}</span></span>
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/jiuwenclaw/web/src/components/TodoList/TodoItem.tsx b/jiuwenclaw/web/src/components/TodoList/TodoItem.tsx
index ee3c69869a..5862b6e235 100644
--- a/jiuwenclaw/web/src/components/TodoList/TodoItem.tsx
+++ b/jiuwenclaw/web/src/components/TodoList/TodoItem.tsx
@@ -42,22 +42,36 @@ export function TodoItem({ todo }: TodoItemProps) {
data-testid={`todo-item-${todo.id}`}
data-todo-status={todo.status}
className={clsx(
- 'flex items-start gap-2 py-1.5 px-2 rounded-md text-sm transition-colors',
+ 'flex flex-col gap-1 py-1.5 px-2 rounded-md text-sm transition-colors',
todo.status === 'in_progress' && 'bg-accent-subtle',
todo.status === 'completed' && 'opacity-60'
)}
>
- {getStatusIcon()}
- <span
- className={clsx(
- 'flex-1 leading-tight',
- todo.status === 'completed' && 'line-through text-text-muted',
- todo.status === 'in_progress' && 'text-text-strong',
- todo.status === 'pending' && 'text-text'
- )}
- >
- {todo.status === 'in_progress' && todo.activeForm ? todo.activeForm : todo.content}
- </span>
+ <div className="flex items-start gap-2">
+ {getStatusIcon()}
+ <span
+ className={clsx(
+ 'flex-1 leading-tight',
+ todo.status === 'completed' && 'line-through text-text-muted',
+ todo.status === 'in_progress' && 'text-text-strong',
+ todo.status === 'pending' && 'text-text'
+ )}
+ >
+ {todo.status === 'in_progress' && todo.activeForm ? todo.activeForm : todo.content}
+ </span>
+ </div>
+ {/* 任务依赖 */}
+ {todo.depends && todo.depends.length > 0 && (
+ <div className="text-xs text-text-muted ml-6">
+ 依赖: {todo.depends.join(', ')}
+ </div>
+ )}
+ {/* 被认领信息 */}
+ {todo.claimedBy && (
+ <div className="text-xs text-info ml-6">
+ 被认领: {todo.claimedBy}
+ </div>
+ )}
</div>
);
}
diff --git a/jiuwenclaw/web/src/components/TodoList/index.tsx b/jiuwenclaw/web/src/components/TodoList/index.tsx
index 9130e87388..c059e652fa 100644
--- a/jiuwenclaw/web/src/components/TodoList/index.tsx
+++ b/jiuwenclaw/web/src/components/TodoList/index.tsx
@@ -29,56 +29,58 @@ export function TodoList() {
const completed = todos.filter((t) => t.status === 'completed');
return (
- <div data-testid="todo-list" className="p-4 space-y-4">
+ <div data-testid="todo-list" className="h-full flex flex-col p-4 space-y-4">
<h3 className="text-[11px] font-medium text-text-muted uppercase tracking-wider flex items-center justify-between">
<span>{t('todoList.title')}</span>
<span className="px-1.5 py-0.5 bg-secondary rounded text-[10px]">{todos.length}</span>
</h3>
- {/* 进行中 */}
- {inProgress.length > 0 && (
- <div className="space-y-2">
- <div className="flex items-center gap-2 text-xs font-medium text-info">
- <span className="w-1.5 h-1.5 rounded-full bg-info animate-pulse" />
- {t('todoList.inProgress')}
+ <div className="flex-1 overflow-y-auto space-y-4">
+ {/* 进行中 */}
+ {inProgress.length > 0 && (
+ <div className="space-y-2">
+ <div className="flex items-center gap-2 text-xs font-medium text-info">
+ <span className="w-1.5 h-1.5 rounded-full bg-info animate-pulse" />
+ {t('todoList.inProgress')}
+ </div>
+ <div className="space-y-1">
+ {inProgress.map((todo) => (
+ <TodoItem key={todo.id} todo={todo} />
+ ))}
+ </div>
</div>
- <div className="space-y-1">
- {inProgress.map((todo) => (
- <TodoItem key={todo.id} todo={todo} />
- ))}
- </div>
- </div>
- )}
+ )}
- {/* 待处理 */}
- {pending.length > 0 && (
- <div className="space-y-2">
- <div className="flex items-center gap-2 text-xs font-medium text-text-muted">
- <span className="w-1.5 h-1.5 rounded-full bg-text-muted" />
- {t('todoList.pending')}
- </div>
- <div className="space-y-1">
- {pending.map((todo) => (
- <TodoItem key={todo.id} todo={todo} />
- ))}
+ {/* 待处理 */}
+ {pending.length > 0 && (
+ <div className="space-y-2">
+ <div className="flex items-center gap-2 text-xs font-medium text-text-muted">
+ <span className="w-1.5 h-1.5 rounded-full bg-text-muted" />
+ {t('todoList.pending')}
+ </div>
+ <div className="space-y-1">
+ {pending.map((todo) => (
+ <TodoItem key={todo.id} todo={todo} />
+ ))}
+ </div>
</div>
- </div>
- )}
+ )}
- {/* 已完成 */}
- {completed.length > 0 && (
- <div className="space-y-2">
- <div className="flex items-center gap-2 text-xs font-medium text-ok">
- <span className="w-1.5 h-1.5 rounded-full bg-ok" />
- {t('todoList.completed')}
+ {/* 已完成 */}
+ {completed.length > 0 && (
+ <div className="space-y-2">
+ <div className="flex items-center gap-2 text-xs font-medium text-ok">
+ <span className="w-1.5 h-1.5 rounded-full bg-ok" />
+ {t('todoList.completed')}
+ </div>
+ <div className="space-y-1">
+ {completed.map((todo) => (
+ <TodoItem key={todo.id} todo={todo} />
+ ))}
+ </div>
</div>
- <div className="space-y-1">
- {completed.map((todo) => (
- <TodoItem key={todo.id} todo={todo} />
- ))}
- </div>
- </div>
- )}
+ )}
+ </div>
</div>
);
}
diff --git a/jiuwenclaw/web/src/components/ToolPanel/index.tsx b/jiuwenclaw/web/src/components/ToolPanel/index.tsx
index bf6d049e0c..24cef6a1d4 100644
--- a/jiuwenclaw/web/src/components/ToolPanel/index.tsx
+++ b/jiuwenclaw/web/src/components/ToolPanel/index.tsx
@@ -10,6 +10,8 @@ import { useEffect, useState } from 'react';
import { webRequest } from '../../services/webClient';
import { HeartbeatMessageModal } from '../../features/HeartbeatMessageModal';
import { TodoList } from '../TodoList';
+import { TeamArea } from '../TeamArea';
+import { TeamTaskEvents } from '../TeamTaskEvents';
import './ToolPanel.css';
export function ToolPanel() {
@@ -24,6 +26,9 @@ export function ToolPanel() {
heartbeatState,
heartbeatMessage,
heartbeatUpdatedAt,
+ mode,
+ teamTaskEvents,
+ teamMembers,
} = useSessionStore();
const [heartbeatModalOpen, setHeartbeatModalOpen] = useState(false);
@@ -114,10 +119,33 @@ export function ToolPanel() {
style={{ width: 'var(--tool-panel-width)' }}
>
<div className="h-full bg-panel flex flex-col overflow-hidden">
- {/* Todo 列表 */}
- <div className="flex-1 overflow-y-auto">
- <TodoList />
- </div>
+ {/* 任务事件日志 */}
+ {mode === 'agentteam' ? (
+ <div className="flex-1 overflow-y-auto mb-4">
+ <div className="bg-card rounded-lg border border-border overflow-hidden h-full">
+ <TeamTaskEvents events={teamTaskEvents} />
+ </div>
+ </div>
+ ) : (
+ /* Todo 列表 */
+ <div className="flex-1 overflow-y-auto mb-4">
+ <div className="bg-card rounded-lg border border-border overflow-hidden h-full">
+ <TodoList />
+ </div>
+ </div>
+ )}
+
+ {/* 团队区域 */}
+ {mode === 'agentteam' && (
+ <div className="flex-1 overflow-y-auto">
+ <div className="bg-card rounded-lg border border-border overflow-hidden h-full">
+ <TeamArea
+ teamName="团队成员"
+ members={teamMembers}
+ />
+ </div>
+ </div>
+ )}
{/* 状态显示 */}
<div className="toolpanel-status-card">
diff --git a/jiuwenclaw/web/src/hooks/useWebSocket.ts b/jiuwenclaw/web/src/hooks/useWebSocket.ts
index 4c1b493c2d..7a2829fc75 100644
--- a/jiuwenclaw/web/src/hooks/useWebSocket.ts
+++ b/jiuwenclaw/web/src/hooks/useWebSocket.ts
@@ -275,9 +275,11 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
setProcessing(true);
setThinking(true);
+
+ // 正常调用接口
+ const currentMode = useSessionStore.getState().mode;
+ const sendMode = currentMode === 'agentteam' ? 'team' : currentMode;
try {
- const currentMode = useSessionStore.getState().mode;
- const sendMode = currentMode === 'agentteam' ? 'team' : currentMode;
await request('chat.send', {
session_id: sessionId,
content,
@@ -400,12 +402,14 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
// 切换模式
const switchMode = useCallback(
async (sessionId: string, mode: AgentMode) => {
+ setProcessing(false);
+ setThinking(false);
setMode(mode);
if (sessionId && sessionId !== 'new') {
updateSession(sessionId, { mode });
}
},
- [setMode, updateSession]
+ [setMode, updateSession, setProcessing, setThinking]
);
// 发送用户回答
@@ -496,7 +500,41 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
}),
webClient.on('chat.delta', ({ payload }) => {
if (!shouldHandleSessionEvent(payload)) return;
+
+ const currentMode = useSessionStore.getState().mode;
const content = typeof payload.content === 'string' ? payload.content : '';
+
+ // team 模式下,累积 chat.delta 内容
+ if (currentMode === 'agentteam' && content) {
+ setThinking(false);
+
+ const { messages } = useChatStore.getState();
+ const existingMsg = messages.find(m =>
+ m.id.startsWith('team-leader-') &&
+ (m as { isStreaming?: boolean }).isStreaming === true
+ );
+
+ if (existingMsg) {
+ const existingContent = existingMsg.content || '';
+ const newContent = existingContent + content;
+ const updatePayload: { content: string; isStreaming?: boolean } = { content: newContent };
+ if (content.includes('MEDIA:')) {
+ updatePayload.isStreaming = false;
+ }
+ updateMessage(existingMsg.id, updatePayload);
+ } else {
+ const msgId = `team-leader-${Date.now()}`;
+ addMessage({
+ id: msgId,
+ role: 'system',
+ content: content,
+ timestamp: new Date().toISOString(),
+ isStreaming: true,
+ });
+ }
+ return;
+ }
+
const { currentStreamId } = useChatStore.getState();
setThinking(false);
if (!currentStreamId && content) {
@@ -514,7 +552,34 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
}),
webClient.on('chat.final', ({ payload }) => {
if (!shouldHandleSessionEvent(payload)) return;
+
+ const currentMode = useSessionStore.getState().mode;
const content = normalizeFinalContent(payload);
+
+ // team 模式下,将 chat.final 作为 team_leader 消息处理
+ if (currentMode === 'agentteam' && content) {
+ setThinking(false);
+
+ const { messages } = useChatStore.getState();
+ const existingMsg = messages.find(m =>
+ m.id.startsWith('team-leader-') &&
+ (m as { isStreaming?: boolean }).isStreaming === true
+ );
+
+ if (existingMsg) {
+ updateMessage(existingMsg.id, { content, isStreaming: false });
+ } else {
+ const timestamp = payload.timestamp || Date.now();
+ addMessage({
+ id: `team-leader-${Date.now()}`,
+ role: 'system',
+ content: `team.leader:${JSON.stringify({ content, timestamp })}`,
+ timestamp: new Date().toISOString(),
+ });
+ }
+ return;
+ }
+
const { currentStreamId, messages } = useChatStore.getState();
const payloadSessionId =
typeof payload.session_id === 'string' ? payload.session_id.trim() : '';
@@ -828,6 +893,74 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
};
addToolResult(sessionResult);
}),
+ webClient.on('team.event', ({ payload }) => {
+ if (shouldDropDuplicatedEvent('team.event', payload)) {
+ return;
+ }
+ setThinking(false);
+ addMessage({
+ id: `team-event-${Date.now()}`,
+ role: 'system',
+ content: `team.event:${JSON.stringify(payload)}`,
+ timestamp: new Date().toISOString(),
+ });
+ }),
+ webClient.on('team.message', ({ payload }) => {
+ if (shouldDropDuplicatedEvent('team.message', payload)) {
+ return;
+ }
+ setThinking(false);
+ addMessage({
+ id: `team-message-${Date.now()}`,
+ role: 'system',
+ content: `team.event:${JSON.stringify(payload)}`,
+ timestamp: new Date().toISOString(),
+ });
+ }),
+ webClient.on('team.task', ({ payload }) => {
+ if (shouldDropDuplicatedEvent('team.task', payload)) {
+ return;
+ }
+ setThinking(false);
+ const p = payload as { payload?: { event?: unknown }; event?: unknown };
+ const event = p.payload?.event || p.event;
+ if (event) {
+ const e = event as { type?: string; team_id?: string; task_id?: string; status?: string; timestamp?: number };
+ useSessionStore.getState().addTeamTaskEvent({
+ id: `task-${Date.now()}`,
+ type: e.type || '',
+ team_id: e.team_id || '',
+ task_id: e.task_id || '',
+ status: e.status || '',
+ timestamp: e.timestamp || Date.now(),
+ });
+ }
+ }),
+ webClient.on('team.member', ({ payload }) => {
+ if (shouldDropDuplicatedEvent('team.member', payload)) {
+ return;
+ }
+ setThinking(false);
+ const p = payload as { payload?: { event?: unknown }; event?: unknown };
+ const event = p.payload?.event || p.event;
+ if (event) {
+ const e = event as { type?: string; member_id?: string; status?: string; new_status?: string; timestamp?: number };
+ if (e.type === 'team.member.status_changed' && e.member_id && e.new_status) {
+ useSessionStore.getState().updateTeamMemberStatus(
+ e.member_id,
+ e.new_status,
+ e.timestamp
+ );
+ } else {
+ useSessionStore.getState().addTeamMember({
+ id: `member-${Date.now()}`,
+ member_id: e.member_id || '',
+ status: e.status || '',
+ timestamp: e.timestamp || Date.now(),
+ });
+ }
+ }
+ }),
];
return () => {
diff --git a/jiuwenclaw/web/src/i18n/locales/en.json b/jiuwenclaw/web/src/i18n/locales/en.json
index 004a3ca406..5cf7c0116e 100644
--- a/jiuwenclaw/web/src/i18n/locales/en.json
+++ b/jiuwenclaw/web/src/i18n/locales/en.json
@@ -50,8 +50,9 @@
},
"newSession": "New Session",
"sessionCreated": "Session created",
- "modePlan": "Task Planning",
- "modeAgent": "Smart Execution",
+ "modePlan": "Planning Mode",
+ "modeAgent": "Performance Mode",
+ "modeAgentTeam": "Cluster Mode",
"recording": "Recording... (release to send)",
"waitingTasks": "Waiting tasks",
"waitingTasksCount": "Waiting tasks ({{count}})",
@@ -59,6 +60,8 @@
"holdToSpeak": "Hold to speak",
"send": "Send (Enter)",
"newSessionDisabled": "Cannot create session while processing or recording",
+ "modeSwitchTitle": "Switch Mode",
+ "modeSwitchConfirm": "Current session has history messages. Switching mode will create a new session. Continue?",
"historyPager": {
"loadedOfTotal": "Loaded {{loaded}} / {{total}} pages",
"loadingMore": "Loading...",
diff --git a/jiuwenclaw/web/src/i18n/locales/zh.json b/jiuwenclaw/web/src/i18n/locales/zh.json
index 2ab72cc47c..1981511314 100644
--- a/jiuwenclaw/web/src/i18n/locales/zh.json
+++ b/jiuwenclaw/web/src/i18n/locales/zh.json
@@ -50,8 +50,9 @@
},
"newSession": "新建会话",
"sessionCreated": "已新建会话",
- "modePlan": "任务规划",
- "modeAgent": "智能执行",
+ "modePlan": "规划模式",
+ "modeAgent": "性能模式",
+ "modeAgentTeam": "集群模式",
"recording": "正在录音...(松开按钮自动发送)",
"waitingTasks": "等待任务",
"waitingTasksCount": "等待任务 ({{count}})",
@@ -59,6 +60,8 @@
"holdToSpeak": "按住说话",
"send": "发送 (Enter)",
"newSessionDisabled": "处理中或录音中不可新建",
+ "modeSwitchTitle": "切换模式",
+ "modeSwitchConfirm": "当前会话有历史消息,切换模式将新建会话。是否继续?",
"historyPager": {
"loadedOfTotal": "历史已加载 {{loaded}} / {{total}} 页",
"loadingMore": "加载中…",
diff --git a/jiuwenclaw/web/src/index.css b/jiuwenclaw/web/src/index.css
index 2f520688fc..32604f1d4e 100644
--- a/jiuwenclaw/web/src/index.css
+++ b/jiuwenclaw/web/src/index.css
@@ -1251,7 +1251,7 @@ select {
.theme-toggle__track {
position: relative;
display: grid;
- grid-template-columns: repeat(3, var(--theme-item));
+ grid-template-columns: repeat(2, var(--theme-item));
gap: var(--theme-gap);
padding: var(--theme-pad);
border-radius: var(--radius-full);
diff --git a/jiuwenclaw/web/src/stores/sessionStore.ts b/jiuwenclaw/web/src/stores/sessionStore.ts
index 2b81801a36..8ca18d345e 100644
--- a/jiuwenclaw/web/src/stores/sessionStore.ts
+++ b/jiuwenclaw/web/src/stores/sessionStore.ts
@@ -67,6 +67,22 @@ interface ContextCompressionStats {
afterCompressed: number | null;
}
+interface TeamTaskEvent {
+ id: string;
+ type: string;
+ team_id: string;
+ task_id: string;
+ status: string;
+ timestamp: number;
+}
+
+interface TeamMember {
+ id: string;
+ member_id: string;
+ status: string;
+ timestamp: number;
+}
+
interface SessionState {
currentSession: Session | null;
sessions: Session[];
@@ -82,6 +98,8 @@ interface SessionState {
heartbeatMessage: string | null;
heartbeatUpdatedAt: string | null;
heartbeatHistory: HeartbeatHistoryItem[];
+ teamTaskEvents: TeamTaskEvent[];
+ teamMembers: TeamMember[];
// Actions
setCurrentSession: (session: Session | null) => void;
@@ -101,6 +119,11 @@ interface SessionState {
message?: string | null,
updatedAt?: string | null
) => void;
+ setTeamTaskEvents: (events: TeamTaskEvent[]) => void;
+ addTeamTaskEvent: (event: TeamTaskEvent) => void;
+ setTeamMembers: (members: TeamMember[]) => void;
+ addTeamMember: (member: TeamMember) => void;
+ updateTeamMemberStatus: (memberId: string, newStatus: string, timestamp?: number) => void;
}
export const useSessionStore = create<SessionState>((set) => ({
@@ -125,6 +148,8 @@ export const useSessionStore = create<SessionState>((set) => ({
heartbeatMessage: null,
heartbeatUpdatedAt: null,
heartbeatHistory: [],
+ teamTaskEvents: [],
+ teamMembers: [],
setCurrentSession: (session) => {
const normalizedSession = session ? normalizeSession(session) : null;
@@ -282,4 +307,59 @@ export const useSessionStore = create<SessionState>((set) => ({
};
});
},
+ setTeamTaskEvents: (events) => {
+ set({ teamTaskEvents: events });
+ },
+ addTeamTaskEvent: (event) => {
+ set((state) => {
+ const existingIndex = state.teamTaskEvents.findIndex(
+ (e) => e.task_id === event.task_id
+ );
+ if (existingIndex >= 0) {
+ const updatedEvents = [...state.teamTaskEvents];
+ updatedEvents[existingIndex] = {
+ ...updatedEvents[existingIndex],
+ ...event,
+ };
+ return { teamTaskEvents: updatedEvents };
+ }
+ return { teamTaskEvents: [event, ...state.teamTaskEvents] };
+ });
+ },
+ setTeamMembers: (members) => {
+ set({ teamMembers: members });
+ },
+ addTeamMember: (member) => {
+ set((state) => {
+ const existingIndex = state.teamMembers.findIndex(
+ (m) => m.member_id === member.member_id
+ );
+ if (existingIndex >= 0) {
+ const updatedMembers = [...state.teamMembers];
+ updatedMembers[existingIndex] = {
+ ...updatedMembers[existingIndex],
+ ...member,
+ };
+ return { teamMembers: updatedMembers };
+ }
+ return { teamMembers: [member, ...state.teamMembers] };
+ });
+ },
+ updateTeamMemberStatus: (memberId, newStatus, timestamp) => {
+ set((state) => {
+ const existingIndex = state.teamMembers.findIndex(
+ (m) => m.member_id === memberId
+ );
+ if (existingIndex >= 0) {
+ const updatedMembers = [...state.teamMembers];
+ updatedMembers[existingIndex] = {
+ ...updatedMembers[existingIndex],
+ status: newStatus,
+ timestamp: timestamp || Date.now(),
+ };
+ return { teamMembers: updatedMembers };
+ }
+ return state;
+ });
+ },
}));
diff --git a/jiuwenclaw/web/src/types/todo.ts b/jiuwenclaw/web/src/types/todo.ts
index 279c373ccb..bc5572d10d 100644
--- a/jiuwenclaw/web/src/types/todo.ts
+++ b/jiuwenclaw/web/src/types/todo.ts
@@ -11,4 +11,6 @@ export interface TodoItem {
status: TodoStatus;
createdAt: string;
updatedAt: string;
+ depends?: string[];
+ claimedBy?: string;
}