Spaces:
Runtime error
Runtime error
Merge pull request #168 from builderz-labs/fix/165-agent-modal-ui
Browse files
src/components/panels/agent-squad-panel-phase3.tsx
CHANGED
|
@@ -65,6 +65,13 @@ const statusColors: Record<string, string> = {
|
|
| 65 |
error: 'bg-red-500',
|
| 66 |
}
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
const statusIcons: Record<string, string> = {
|
| 69 |
offline: '-',
|
| 70 |
idle: 'o',
|
|
@@ -494,6 +501,17 @@ function AgentDetailModalPhase3({
|
|
| 494 |
const [heartbeatData, setHeartbeatData] = useState<HeartbeatResponse | null>(null)
|
| 495 |
const [loadingHeartbeat, setLoadingHeartbeat] = useState(false)
|
| 496 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
// Load SOUL templates
|
| 498 |
useEffect(() => {
|
| 499 |
const loadTemplates = async () => {
|
|
@@ -593,44 +611,71 @@ function AgentDetailModalPhase3({
|
|
| 593 |
}
|
| 594 |
|
| 595 |
const tabs = [
|
| 596 |
-
{ id: 'overview', label: 'Overview', icon: '
|
| 597 |
-
{ id: 'soul', label: 'SOUL', icon: '
|
| 598 |
-
{ id: 'memory', label: 'Memory', icon: '
|
| 599 |
-
{ id: 'tasks', label: 'Tasks', icon: '
|
| 600 |
-
{ id: 'config', label: 'Config', icon: '
|
| 601 |
-
{ id: 'activity', label: 'Activity', icon: '
|
| 602 |
]
|
| 603 |
|
| 604 |
return (
|
| 605 |
-
<div
|
| 606 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 607 |
{/* Modal Header */}
|
| 608 |
-
<div className="p-6 border-b border-border">
|
| 609 |
-
<div className="flex justify-between items-start">
|
| 610 |
-
<div>
|
| 611 |
-
<
|
| 612 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 613 |
</div>
|
| 614 |
<div className="flex items-center gap-3">
|
| 615 |
-
<
|
| 616 |
-
|
| 617 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 618 |
</div>
|
| 619 |
</div>
|
| 620 |
|
| 621 |
{/* Tab Navigation */}
|
| 622 |
-
<div className="flex gap-1 mt-
|
| 623 |
{tabs.map(tab => (
|
| 624 |
<button
|
| 625 |
key={tab.id}
|
| 626 |
onClick={() => setActiveTab(tab.id as any)}
|
| 627 |
-
className={`px-
|
| 628 |
activeTab === tab.id
|
| 629 |
-
? 'bg-primary text-primary-foreground'
|
| 630 |
-
: 'bg-secondary text-muted-foreground hover:bg-surface-2'
|
| 631 |
}`}
|
| 632 |
>
|
| 633 |
-
<span>{tab.icon}</span>
|
| 634 |
{tab.label}
|
| 635 |
</button>
|
| 636 |
))}
|
|
|
|
| 65 |
error: 'bg-red-500',
|
| 66 |
}
|
| 67 |
|
| 68 |
+
const statusBadgeStyles: Record<string, string> = {
|
| 69 |
+
offline: 'bg-slate-500/15 text-slate-300 border-slate-500/30',
|
| 70 |
+
idle: 'bg-emerald-500/15 text-emerald-300 border-emerald-500/30',
|
| 71 |
+
busy: 'bg-amber-500/15 text-amber-300 border-amber-500/30',
|
| 72 |
+
error: 'bg-rose-500/15 text-rose-300 border-rose-500/30',
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
const statusIcons: Record<string, string> = {
|
| 76 |
offline: '-',
|
| 77 |
idle: 'o',
|
|
|
|
| 501 |
const [heartbeatData, setHeartbeatData] = useState<HeartbeatResponse | null>(null)
|
| 502 |
const [loadingHeartbeat, setLoadingHeartbeat] = useState(false)
|
| 503 |
|
| 504 |
+
const formatLastSeen = (timestamp?: number) => {
|
| 505 |
+
if (!timestamp) return 'Never'
|
| 506 |
+
const diffMs = Date.now() - (timestamp * 1000)
|
| 507 |
+
const diffMinutes = Math.floor(diffMs / (1000 * 60))
|
| 508 |
+
const diffHours = Math.floor(diffMs / (1000 * 60 * 60))
|
| 509 |
+
if (diffMinutes < 1) return 'Just now'
|
| 510 |
+
if (diffMinutes < 60) return `${diffMinutes}m ago`
|
| 511 |
+
if (diffHours < 24) return `${diffHours}h ago`
|
| 512 |
+
return new Date(timestamp * 1000).toLocaleDateString()
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
// Load SOUL templates
|
| 516 |
useEffect(() => {
|
| 517 |
const loadTemplates = async () => {
|
|
|
|
| 611 |
}
|
| 612 |
|
| 613 |
const tabs = [
|
| 614 |
+
{ id: 'overview', label: 'Overview', icon: 'O' },
|
| 615 |
+
{ id: 'soul', label: 'SOUL', icon: 'S' },
|
| 616 |
+
{ id: 'memory', label: 'Memory', icon: 'M' },
|
| 617 |
+
{ id: 'tasks', label: 'Tasks', icon: 'T' },
|
| 618 |
+
{ id: 'config', label: 'Config', icon: 'C' },
|
| 619 |
+
{ id: 'activity', label: 'Activity', icon: 'A' }
|
| 620 |
]
|
| 621 |
|
| 622 |
return (
|
| 623 |
+
<div
|
| 624 |
+
className="fixed inset-0 z-50 bg-black/70 backdrop-blur-md flex items-center justify-center p-4"
|
| 625 |
+
onClick={onClose}
|
| 626 |
+
>
|
| 627 |
+
<div
|
| 628 |
+
className="bg-card border border-border/80 rounded-xl shadow-2xl shadow-black/40 max-w-5xl w-full max-h-[90vh] flex flex-col overflow-hidden"
|
| 629 |
+
onClick={(e) => e.stopPropagation()}
|
| 630 |
+
>
|
| 631 |
{/* Modal Header */}
|
| 632 |
+
<div className="p-6 border-b border-border bg-gradient-to-r from-surface-1 via-card to-surface-1">
|
| 633 |
+
<div className="flex justify-between items-start gap-4">
|
| 634 |
+
<div className="flex items-start gap-3 min-w-0">
|
| 635 |
+
<AgentAvatar name={agent.name} size="md" />
|
| 636 |
+
<div className="min-w-0">
|
| 637 |
+
<h3 className="text-2xl font-bold text-foreground leading-tight truncate">{agent.name}</h3>
|
| 638 |
+
<p className="text-muted-foreground mt-0.5 truncate">{agent.role}</p>
|
| 639 |
+
<div className="flex flex-wrap items-center gap-2 mt-3">
|
| 640 |
+
<span className={`inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full border ${statusBadgeStyles[agent.status]}`}>
|
| 641 |
+
<span className={`w-2 h-2 rounded-full ${statusColors[agent.status]}`} />
|
| 642 |
+
{agent.status}
|
| 643 |
+
</span>
|
| 644 |
+
<span className="inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full border border-border bg-surface-1 text-muted-foreground">
|
| 645 |
+
Last seen {formatLastSeen(agent.last_seen)}
|
| 646 |
+
</span>
|
| 647 |
+
{agent.session_key && (
|
| 648 |
+
<span className="inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full border border-cyan-500/30 bg-cyan-500/10 text-cyan-300">
|
| 649 |
+
Session active
|
| 650 |
+
</span>
|
| 651 |
+
)}
|
| 652 |
+
</div>
|
| 653 |
+
</div>
|
| 654 |
</div>
|
| 655 |
<div className="flex items-center gap-3">
|
| 656 |
+
<button
|
| 657 |
+
onClick={onClose}
|
| 658 |
+
aria-label="Close agent details"
|
| 659 |
+
className="h-9 w-9 inline-flex items-center justify-center rounded-md bg-secondary text-muted-foreground hover:bg-surface-2 hover:text-foreground transition-smooth"
|
| 660 |
+
>
|
| 661 |
+
×
|
| 662 |
+
</button>
|
| 663 |
</div>
|
| 664 |
</div>
|
| 665 |
|
| 666 |
{/* Tab Navigation */}
|
| 667 |
+
<div className="flex gap-1.5 mt-5 overflow-x-auto pb-1">
|
| 668 |
{tabs.map(tab => (
|
| 669 |
<button
|
| 670 |
key={tab.id}
|
| 671 |
onClick={() => setActiveTab(tab.id as any)}
|
| 672 |
+
className={`px-3.5 py-2 text-sm rounded-md border flex items-center gap-2 transition-smooth whitespace-nowrap ${
|
| 673 |
activeTab === tab.id
|
| 674 |
+
? 'bg-primary/90 text-primary-foreground border-primary/60 shadow-[0_0_0_1px_rgba(56,189,248,0.25)]'
|
| 675 |
+
: 'bg-secondary/70 text-muted-foreground border-border/70 hover:bg-surface-2 hover:text-foreground'
|
| 676 |
}`}
|
| 677 |
>
|
| 678 |
+
<span className="inline-flex h-4 w-4 items-center justify-center rounded-sm bg-black/20 text-[10px] font-semibold">{tab.icon}</span>
|
| 679 |
{tab.label}
|
| 680 |
</button>
|
| 681 |
))}
|