2026-02-16 10:16:33 -08:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { X, Send } from 'lucide-react';
|
|
|
|
|
import { ThreadView, type ThreadItem } from './thread-view';
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
|
|
|
|
|
interface ThreadDrawerProps {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
title: string;
|
|
|
|
|
id: string;
|
|
|
|
|
items?: ThreadItem[];
|
2026-02-16 23:50:20 -08:00
|
|
|
embedded?: boolean; // New prop for embedded mode
|
2026-02-16 10:16:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sample data for demo
|
|
|
|
|
const SAMPLE_ITEMS: ThreadItem[] = [
|
|
|
|
|
{
|
|
|
|
|
id: '1',
|
|
|
|
|
type: 'status_change',
|
|
|
|
|
from: 'backlog',
|
|
|
|
|
to: 'in_progress',
|
|
|
|
|
timestamp: new Date(Date.now() - 2 * 60 * 60 * 1000),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: '2',
|
|
|
|
|
type: 'comment',
|
|
|
|
|
author: 'zenchantlive',
|
|
|
|
|
content: 'Started working on this task.',
|
|
|
|
|
timestamp: new Date(Date.now() - 1 * 60 * 60 * 1000),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: '3',
|
|
|
|
|
type: 'protocol_event',
|
|
|
|
|
event: 'HANDOFF',
|
|
|
|
|
content: 'Handed off to agent',
|
|
|
|
|
timestamp: new Date(Date.now() - 30 * 60 * 1000),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2026-02-16 23:50:20 -08:00
|
|
|
export function ThreadDrawer({ isOpen, onClose, title, id, items = SAMPLE_ITEMS, embedded = false }: ThreadDrawerProps) {
|
2026-02-16 10:16:33 -08:00
|
|
|
const [comment, setComment] = useState('');
|
|
|
|
|
|
|
|
|
|
if (!isOpen) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
2026-02-16 21:45:27 -08:00
|
|
|
<div
|
2026-02-16 23:50:20 -08:00
|
|
|
className="h-full flex flex-col"
|
2026-02-16 21:45:27 -08:00
|
|
|
style={{
|
2026-02-16 23:50:20 -08:00
|
|
|
width: embedded ? '100%' : '24rem', // Full width when embedded
|
2026-02-16 21:45:27 -08:00
|
|
|
backgroundColor: 'var(--color-bg-card)',
|
2026-02-16 23:50:20 -08:00
|
|
|
borderLeft: embedded ? 'none' : '1px solid rgba(255, 255, 255, 0.1)',
|
|
|
|
|
boxShadow: embedded ? 'none' : '-4px 0 20px rgba(0, 0, 0, 0.3)',
|
2026-02-16 21:45:27 -08:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* Header */}
|
2026-02-16 10:16:33 -08:00
|
|
|
<div
|
2026-02-16 23:50:20 -08:00
|
|
|
className="flex items-center justify-between p-4 border-b flex-shrink-0"
|
2026-02-16 21:45:27 -08:00
|
|
|
style={{ borderColor: 'rgba(255, 255, 255, 0.1)' }}
|
2026-02-16 10:16:33 -08:00
|
|
|
>
|
2026-02-16 21:45:27 -08:00
|
|
|
<div className="flex-1 min-w-0 mr-4">
|
|
|
|
|
<span className="text-teal-400 font-mono text-sm">
|
|
|
|
|
{id}
|
|
|
|
|
</span>
|
|
|
|
|
<h2
|
|
|
|
|
className="text-sm font-semibold truncate"
|
|
|
|
|
style={{ color: 'var(--color-text-primary)' }}
|
|
|
|
|
title={title}
|
2026-02-16 10:16:33 -08:00
|
|
|
>
|
2026-02-16 21:45:27 -08:00
|
|
|
{title}
|
|
|
|
|
</h2>
|
2026-02-16 10:16:33 -08:00
|
|
|
</div>
|
2026-02-16 21:45:27 -08:00
|
|
|
<button
|
|
|
|
|
onClick={onClose}
|
|
|
|
|
className="p-1.5 rounded-md hover:bg-white/10 transition-colors flex-shrink-0"
|
|
|
|
|
aria-label="Close"
|
|
|
|
|
>
|
|
|
|
|
<X size={18} style={{ color: 'var(--color-text-muted)' }} />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2026-02-16 10:16:33 -08:00
|
|
|
|
2026-02-16 21:45:27 -08:00
|
|
|
{/* Thread Content */}
|
2026-02-16 23:50:20 -08:00
|
|
|
<div className="flex-1 overflow-y-auto p-4 custom-scrollbar">
|
2026-02-16 21:45:27 -08:00
|
|
|
<ThreadView items={items} />
|
|
|
|
|
</div>
|
2026-02-16 10:16:33 -08:00
|
|
|
|
2026-02-16 21:45:27 -08:00
|
|
|
{/* Compose */}
|
|
|
|
|
<div
|
2026-02-16 23:50:20 -08:00
|
|
|
className="p-4 border-t flex-shrink-0"
|
2026-02-16 21:45:27 -08:00
|
|
|
style={{ borderColor: 'rgba(255, 255, 255, 0.1)' }}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={comment}
|
|
|
|
|
onChange={(e) => setComment(e.target.value)}
|
|
|
|
|
placeholder="Add a comment..."
|
2026-02-16 23:50:20 -08:00
|
|
|
className="flex-1 px-3 py-2 rounded-md text-sm outline-none focus:ring-1 focus:ring-teal-500/50 transition-all"
|
2026-02-16 21:45:27 -08:00
|
|
|
style={{
|
|
|
|
|
backgroundColor: 'var(--color-bg-input)',
|
|
|
|
|
color: 'var(--color-text-primary)',
|
|
|
|
|
border: '1px solid rgba(255, 255, 255, 0.1)',
|
|
|
|
|
}}
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
if (e.key === 'Enter' && comment.trim()) {
|
|
|
|
|
setComment('');
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<button
|
2026-02-16 23:50:20 -08:00
|
|
|
className="p-2 rounded-md hover:opacity-90 transition-opacity"
|
2026-02-16 21:45:27 -08:00
|
|
|
style={{
|
|
|
|
|
backgroundColor: 'var(--color-accent-green)',
|
|
|
|
|
color: '#fff',
|
|
|
|
|
}}
|
|
|
|
|
aria-label="Send comment"
|
|
|
|
|
>
|
|
|
|
|
<Send size={16} />
|
|
|
|
|
</button>
|
2026-02-16 10:16:33 -08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-02-16 21:45:27 -08:00
|
|
|
</div>
|
2026-02-16 10:16:33 -08:00
|
|
|
);
|
2026-02-16 23:50:20 -08:00
|
|
|
}
|