@@ -3,8 +3,14 @@ import { useAppContext } from '../utils/app.context';
33import { Message , PendingMessage } from '../utils/types' ;
44import { classNames } from '../utils/misc' ;
55import MarkdownDisplay , { CopyButton } from './MarkdownDisplay' ;
6- import { ChevronLeftIcon , ChevronRightIcon } from '@heroicons/react/24/outline' ;
6+ import {
7+ ArrowPathIcon ,
8+ ChevronLeftIcon ,
9+ ChevronRightIcon ,
10+ PencilSquareIcon ,
11+ } from '@heroicons/react/24/outline' ;
712import ChatInputExtraContextItem from './ChatInputExtraContextItem' ;
13+ import { BtnWithTooltips } from '../utils/common' ;
814
915interface SplitMessage {
1016 content : PendingMessage [ 'content' ] ;
@@ -138,31 +144,11 @@ export default function ChatMessage({
138144 { /* render message as markdown */ }
139145 < div dir = "auto" >
140146 { thought && (
141- < details
142- className = "collapse bg-base-200 collapse-arrow mb-4"
143- open = { isThinking && config . showThoughtInProgress }
144- >
145- < summary className = "collapse-title" >
146- { isPending && isThinking ? (
147- < span >
148- < span
149- v-if = "isGenerating"
150- className = "loading loading-spinner loading-md mr-2"
151- style = { { verticalAlign : 'middle' } }
152- > </ span >
153- < b > Thinking</ b >
154- </ span >
155- ) : (
156- < b > Thought Process</ b >
157- ) }
158- </ summary >
159- < div className = "collapse-content" >
160- < MarkdownDisplay
161- content = { thought }
162- isGenerating = { isPending }
163- />
164- </ div >
165- </ details >
147+ < ThoughtProcess
148+ isThinking = { ! ! isThinking && ! ! isPending }
149+ content = { thought }
150+ open = { config . showThoughtInProgress }
151+ />
166152 ) }
167153
168154 < MarkdownDisplay
@@ -236,38 +222,80 @@ export default function ChatMessage({
236222 ) }
237223 { /* user message */ }
238224 { msg . role === 'user' && (
239- < button
240- className = "badge btn-mini show-on-hover"
225+ < BtnWithTooltips
226+ className = "btn-mini show-on-hover w-8 h-8 "
241227 onClick = { ( ) => setEditingContent ( msg . content ) }
242228 disabled = { msg . content === null }
229+ tooltipsContent = "Edit message"
243230 >
244- ✍️ Edit
245- </ button >
231+ < PencilSquareIcon className = "h-4 w-4" />
232+ </ BtnWithTooltips >
246233 ) }
247234 { /* assistant message */ }
248235 { msg . role === 'assistant' && (
249236 < >
250237 { ! isPending && (
251- < button
252- className = "badge btn-mini show-on-hover mr-2 "
238+ < BtnWithTooltips
239+ className = "btn-mini show-on-hover w-8 h-8 "
253240 onClick = { ( ) => {
254241 if ( msg . content !== null ) {
255242 onRegenerateMessage ( msg as Message ) ;
256243 }
257244 } }
258245 disabled = { msg . content === null }
246+ tooltipsContent = "Regenerate response"
259247 >
260- 🔄 Regenerate
261- </ button >
248+ < ArrowPathIcon className = "h-4 w-4" />
249+ </ BtnWithTooltips >
262250 ) }
263251 </ >
264252 ) }
265253 < CopyButton
266- className = "badge btn-mini show-on-hover mr-2 "
254+ className = "btn-mini show-on-hover w-8 h-8 "
267255 content = { msg . content }
268256 />
269257 </ div >
270258 ) }
271259 </ div >
272260 ) ;
273261}
262+
263+ function ThoughtProcess ( {
264+ isThinking,
265+ content,
266+ open,
267+ } : {
268+ isThinking : boolean ;
269+ content : string ;
270+ open : boolean ;
271+ } ) {
272+ return (
273+ < div
274+ tabIndex = { 0 }
275+ className = { classNames ( {
276+ 'collapse bg-none' : true ,
277+ 'collapse-open' : open ,
278+ } ) }
279+ >
280+ < input type = "checkbox" />
281+ < div className = "collapse-title px-0" >
282+ { isThinking ? (
283+ < span >
284+ < span
285+ className = "loading loading-spinner loading-md mr-2"
286+ style = { { verticalAlign : 'middle' } }
287+ > </ span >
288+ < b > Thinking</ b >
289+ </ span >
290+ ) : (
291+ < b > Thought Process</ b >
292+ ) }
293+ </ div >
294+ < div className = "collapse-content text-base-content/70 text-sm p-1" >
295+ < div className = "border-l-2 border-base-content/20 pl-4 mb-4" >
296+ < MarkdownDisplay content = { content } />
297+ </ div >
298+ </ div >
299+ </ div >
300+ ) ;
301+ }
0 commit comments