diff --git a/apps/DocFlow/src/app/docs/_components/ChatPanel/chat-tab-bar.tsx b/apps/DocFlow/src/app/docs/_components/ChatPanel/chat-tab-bar.tsx index da06098..e6a7530 100644 --- a/apps/DocFlow/src/app/docs/_components/ChatPanel/chat-tab-bar.tsx +++ b/apps/DocFlow/src/app/docs/_components/ChatPanel/chat-tab-bar.tsx @@ -1,5 +1,6 @@ 'use client'; +import { useState, useRef, useEffect } from 'react'; import { X, Plus, Clock, Sparkles } from 'lucide-react'; import type { ChatTab } from '@/stores/chatStore'; @@ -23,6 +24,7 @@ interface ChatTabBarProps { onNewTab: () => void; onSwitchTab: (tabId: string) => void; onCloseTab: (tabId: string) => void; + onRenameTab: (tabId: string, newTitle: string) => void; onOpenSession: (session: SessionItem) => void; onRefreshSessions: () => void; onClosePanel: () => void; @@ -35,10 +37,45 @@ export function ChatTabBar({ onNewTab, onSwitchTab, onCloseTab, + onRenameTab, onOpenSession, onRefreshSessions, onClosePanel, }: ChatTabBarProps) { + const [editingTabId, setEditingTabId] = useState(null); + const [editValue, setEditValue] = useState(''); + const inputRef = useRef(null); + + useEffect(() => { + if (editingTabId && inputRef.current) { + inputRef.current.focus(); + inputRef.current.select(); + } + }, [editingTabId]); + + const handleDoubleClick = (tabId: string, title: string) => { + setEditingTabId(tabId); + setEditValue(title); + }; + + const handleRenameSubmit = () => { + if (editingTabId && editValue.trim()) { + onRenameTab(editingTabId, editValue.trim()); + } + + setEditingTabId(null); + setEditValue(''); + }; + + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + handleRenameSubmit(); + } else if (e.key === 'Escape') { + setEditingTabId(null); + setEditValue(''); + } + }; + return (
@@ -46,6 +83,7 @@ export function ChatTabBar({