fix(agent-office): unwrap {tasks}/{logs} response objects before .map

Backend returns {"tasks": [...]} and {"logs": [...]} but TaskTab and
LogTab stored the raw object and called .map on it, throwing
'l.map is not a function' the moment a user opened the Tasks or
Logs tab. Unwrap via Array.isArray check (also covers theoretical
bare-array responses).

Regression test for TaskTab covers all three response shapes:
wrapped object, bare array, and empty.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 08:34:08 +09:00
parent b713f00bf9
commit e6742e06ba
3 changed files with 38 additions and 2 deletions

View File

@@ -15,7 +15,7 @@ export default function LogTab({ agentId, refreshTrigger }) {
useEffect(() => {
let cancelled = false;
getAgentLogs(agentId, 50).then(data => {
if (!cancelled) setLogs(data || []);
if (!cancelled) setLogs(Array.isArray(data) ? data : (data?.logs || []));
});
return () => { cancelled = true; };
}, [agentId, refreshTrigger]);