feat(agent-office): notification badges + CEO desk document panel + telegram test
- Add notification state management with badge counts in useAgentManager - Render exclamation badge on agent sprites (separate from status icons) - Add CEO desk document icon with click-to-open activity panel - Create DocumentPanel with unified activity feed + per-agent detail tabs - Add telegram test button to stock agent ChatPanel - Remove TaskHistory + bottom toolbar (replaced by DocumentPanel) - Add getActivityFeed API helper Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ export function useAgentManager() {
|
||||
const [agents, setAgents] = useState({});
|
||||
const [pendingTasks, setPendingTasks] = useState([]);
|
||||
const [connected, setConnected] = useState(false);
|
||||
const [notifications, setNotifications] = useState({});
|
||||
const wsRef = useRef(null);
|
||||
const reconnectTimer = useRef(null);
|
||||
|
||||
@@ -58,6 +59,12 @@ export function useAgentManager() {
|
||||
[msg.agent]: { ...prev[msg.agent], lastCommand: msg.result },
|
||||
}));
|
||||
break;
|
||||
case 'notification':
|
||||
setNotifications(prev => ({
|
||||
...prev,
|
||||
[msg.agent]: (prev[msg.agent] || 0) + 1,
|
||||
}));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -84,5 +91,13 @@ export function useAgentManager() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
return { agents, pendingTasks, connected, sendCommand, sendApproval };
|
||||
const clearNotifications = useCallback((agentId) => {
|
||||
setNotifications(prev => {
|
||||
const next = { ...prev };
|
||||
delete next[agentId];
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
return { agents, pendingTasks, connected, notifications, sendCommand, sendApproval, clearNotifications };
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useRef, useEffect, useCallback } from 'react';
|
||||
import { OfficeRenderer } from '../canvas/OfficeRenderer';
|
||||
import officeMap from '../assets/office-map.json';
|
||||
|
||||
export function useOfficeCanvas(containerRef, onAgentClick) {
|
||||
export function useOfficeCanvas(containerRef, onAgentClick, onCeoClick) {
|
||||
const rendererRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -30,6 +30,10 @@ export function useOfficeCanvas(containerRef, onAgentClick) {
|
||||
if (onAgentClick) onAgentClick(agentId);
|
||||
});
|
||||
|
||||
renderer.setOnCeoClick(() => {
|
||||
if (onCeoClick) onCeoClick();
|
||||
});
|
||||
|
||||
const handleClick = (e) => {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
@@ -48,7 +52,7 @@ export function useOfficeCanvas(containerRef, onAgentClick) {
|
||||
containerRef.current.removeChild(canvas);
|
||||
}
|
||||
};
|
||||
}, [containerRef, onAgentClick]);
|
||||
}, [containerRef, onAgentClick, onCeoClick]);
|
||||
|
||||
const updateAgentState = useCallback((agentId, state, detail) => {
|
||||
rendererRef.current?.updateAgentState(agentId, state, detail);
|
||||
@@ -58,5 +62,13 @@ export function useOfficeCanvas(containerRef, onAgentClick) {
|
||||
rendererRef.current?.moveAgent(agentId, target);
|
||||
}, []);
|
||||
|
||||
return { updateAgentState, moveAgent };
|
||||
const setAgentNotification = useCallback((agentId, count) => {
|
||||
rendererRef.current?.setAgentNotification(agentId, count);
|
||||
}, []);
|
||||
|
||||
const setCeoDocBadge = useCallback((count) => {
|
||||
rendererRef.current?.setCeoDocBadge(count);
|
||||
}, []);
|
||||
|
||||
return { updateAgentState, moveAgent, setAgentNotification, setCeoDocBadge };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user