@@ -3,7 +3,13 @@ import { classNames } from '../utils/misc';
33import { Conversation } from '../utils/types' ;
44import StorageUtils from '../utils/storage' ;
55import { useNavigate , useParams } from 'react-router' ;
6- import { EllipsisVerticalIcon , XMarkIcon } from '@heroicons/react/24/outline' ;
6+ import {
7+ ArrowDownTrayIcon ,
8+ EllipsisVerticalIcon ,
9+ PencilIcon ,
10+ TrashIcon ,
11+ XMarkIcon ,
12+ } from '@heroicons/react/24/outline' ;
713import { BtnWithTooltips } from '../utils/common' ;
814import { useAppContext } from '../utils/app.context' ;
915import toast from 'react-hot-toast' ;
@@ -106,6 +112,19 @@ export default function Sidebar() {
106112 document . body . removeChild ( a ) ;
107113 URL . revokeObjectURL ( url ) ;
108114 } }
115+ onRename = { ( ) => {
116+ if ( isGenerating ( conv . id ) ) {
117+ toast . error ( 'Cannot rename conversation while generating' ) ;
118+ return ;
119+ }
120+ const newName = window . prompt (
121+ 'Enter new name for the conversation' ,
122+ conv . name
123+ ) ;
124+ if ( newName && newName . trim ( ) . length > 0 ) {
125+ StorageUtils . updateConversationName ( conv . id , newName ) ;
126+ }
127+ } }
109128 />
110129 ) ) }
111130 < div className = "text-center text-xs opacity-40 mt-auto mx-4" >
@@ -123,17 +142,19 @@ function ConversationItem({
123142 onSelect,
124143 onDelete,
125144 onDownload,
145+ onRename,
126146} : {
127147 conv : Conversation ;
128148 isCurrConv : boolean ;
129149 onSelect : ( ) => void ;
130150 onDelete : ( ) => void ;
131151 onDownload : ( ) => void ;
152+ onRename : ( ) => void ;
132153} ) {
133154 return (
134155 < div
135156 className = { classNames ( {
136- 'group flex flex-row btn btn-ghost justify-start items-center font-normal' :
157+ 'group flex flex-row btn btn-ghost justify-start items-center font-normal pr-2 ' :
137158 true ,
138159 'btn-soft' : isCurrConv ,
139160 } ) }
@@ -160,13 +181,25 @@ function ConversationItem({
160181 { /* dropdown menu */ }
161182 < ul
162183 tabIndex = { 0 }
163- className = "dropdown-content menu bg-base-100 rounded-box z-[1] w-32 p-2 shadow"
184+ className = "dropdown-content menu bg-base-100 rounded-box z-[1] p-2 shadow"
164185 >
186+ < li onClick = { onRename } >
187+ < a >
188+ < PencilIcon className = "w-4 h-4" />
189+ Rename
190+ </ a >
191+ </ li >
165192 < li onClick = { onDownload } >
166- < a > Download</ a >
193+ < a >
194+ < ArrowDownTrayIcon className = "w-4 h-4" />
195+ Download
196+ </ a >
167197 </ li >
168198 < li className = "text-error" onClick = { onDelete } >
169- < a > Delete</ a >
199+ < a >
200+ < TrashIcon className = "w-4 h-4" />
201+ Delete
202+ </ a >
170203 </ li >
171204 </ ul >
172205 </ div >
0 commit comments