import React, { useState, useEffect, useRef } from 'react'; import { updateSession } from '../api/orchestration'; export default function SessionModal({ session, mode = 'settings', onRename, onDelete, onClose, projects = [] }) { const [name, setName] = useState(session?.name || ''); const [projectId, setProjectId] = useState(session?.project_id ?? ''); const inputRef = useRef(null); useEffect(() => { if (mode === 'settings') { inputRef.current?.focus(); inputRef.current?.select(); } }, [mode]); function handleSubmit() { const trimmed = name.trim(); if (!trimmed) return; onRename(session, trimmed, projectId || null); onClose(); } function handleKeyDown(e) { if (e.key === 'Enter' && mode === 'settings') handleSubmit(); if (e.key === 'Escape') onClose(); } if (!session) return null; return (
e.stopPropagation()} onKeyDown={handleKeyDown} style={{ background: 'var(--bg-surface)', border: '1px solid var(--border)', borderRadius: 'var(--radius-lg)', padding: '24px', width: '360px', display: 'flex', flexDirection: 'column', gap: '16px', }}> {mode === 'settings' ? ( <>

Session Settings

{/* Name */}
setName(e.target.value)} placeholder="Enter session name..." style={{ background: 'var(--bg-elevated)', border: '1px solid var(--border)', borderRadius: 'var(--radius-md)', padding: '8px 12px', color: 'var(--text-primary)', fontSize: '14px', outline: 'none', width: '100%', }} />
{/* Project assignment */}
) : ( <>

Delete Session

Are you sure you want to delete{' '} {session.name || session.external_id} ? This will permanently remove all messages in this conversation.

)}
); }