@@ -83,13 +83,20 @@ export default function ChatMessage({
8383
8484 if ( ! viewingChat ) return null ;
8585
86+ const isUser = msg . role === 'user' ;
87+
8688 return (
87- < div className = "group" id = { id } >
89+ < div
90+ className = "group"
91+ id = { id }
92+ role = "group"
93+ aria-description = { `Message from ${ msg . role } ` }
94+ >
8895 < div
8996 className = { classNames ( {
9097 chat : true ,
91- 'chat-start' : msg . role !== 'user' ,
92- 'chat-end' : msg . role === 'user' ,
98+ 'chat-start' : ! isUser ,
99+ 'chat-end' : isUser ,
93100 } ) }
94101 >
95102 { msg . extra && msg . extra . length > 0 && (
@@ -99,7 +106,7 @@ export default function ChatMessage({
99106 < div
100107 className = { classNames ( {
101108 'chat-bubble markdown' : true ,
102- 'chat-bubble bg-transparent' : msg . role !== 'user' ,
109+ 'chat-bubble bg-transparent' : ! isUser ,
103110 } ) }
104111 >
105112 { /* textarea for editing message */ }
@@ -142,7 +149,7 @@ export default function ChatMessage({
142149 ) : (
143150 < >
144151 { /* render message as markdown */ }
145- < div dir = "auto" >
152+ < div dir = "auto" tabIndex = { 0 } >
146153 { thought && (
147154 < ThoughtProcess
148155 isThinking = { ! ! isThinking && ! ! isPending }
@@ -196,13 +203,18 @@ export default function ChatMessage({
196203 } ) }
197204 >
198205 { siblingLeafNodeIds && siblingLeafNodeIds . length > 1 && (
199- < div className = "flex gap-1 items-center opacity-60 text-sm" >
206+ < div
207+ className = "flex gap-1 items-center opacity-60 text-sm"
208+ role = "navigation"
209+ aria-description = { `Message version ${ siblingCurrIdx + 1 } of ${ siblingLeafNodeIds . length } ` }
210+ >
200211 < button
201212 className = { classNames ( {
202213 'btn btn-sm btn-ghost p-1' : true ,
203214 'opacity-20' : ! prevSibling ,
204215 } ) }
205216 onClick = { ( ) => prevSibling && onChangeSibling ( prevSibling ) }
217+ aria-label = "Previous message version"
206218 >
207219 < ChevronLeftIcon className = "h-4 w-4" />
208220 </ button >
@@ -215,6 +227,7 @@ export default function ChatMessage({
215227 'opacity-20' : ! nextSibling ,
216228 } ) }
217229 onClick = { ( ) => nextSibling && onChangeSibling ( nextSibling ) }
230+ aria-label = "Next message version"
218231 >
219232 < ChevronRightIcon className = "h-4 w-4" />
220233 </ button >
@@ -223,7 +236,7 @@ export default function ChatMessage({
223236 { /* user message */ }
224237 { msg . role === 'user' && (
225238 < BtnWithTooltips
226- className = "btn-mini show-on-hover w-8 h-8"
239+ className = "btn-mini w-8 h-8"
227240 onClick = { ( ) => setEditingContent ( msg . content ) }
228241 disabled = { msg . content === null }
229242 tooltipsContent = "Edit message"
@@ -236,7 +249,7 @@ export default function ChatMessage({
236249 < >
237250 { ! isPending && (
238251 < BtnWithTooltips
239- className = "btn-mini show-on-hover w-8 h-8"
252+ className = "btn-mini w-8 h-8"
240253 onClick = { ( ) => {
241254 if ( msg . content !== null ) {
242255 onRegenerateMessage ( msg as Message ) ;
@@ -250,10 +263,7 @@ export default function ChatMessage({
250263 ) }
251264 </ >
252265 ) }
253- < CopyButton
254- className = "btn-mini show-on-hover w-8 h-8"
255- content = { msg . content }
256- />
266+ < CopyButton className = "btn-mini w-8 h-8" content = { msg . content } />
257267 </ div >
258268 ) }
259269 </ div >
@@ -271,6 +281,8 @@ function ThoughtProcess({
271281} ) {
272282 return (
273283 < div
284+ role = "button"
285+ aria-label = "Toggle thought process display"
274286 tabIndex = { 0 }
275287 className = { classNames ( {
276288 'collapse bg-none' : true ,
@@ -292,7 +304,11 @@ function ThoughtProcess({
292304 ) }
293305 </ div >
294306 </ div >
295- < div className = "collapse-content text-base-content/70 text-sm p-1" >
307+ < div
308+ className = "collapse-content text-base-content/70 text-sm p-1"
309+ tabIndex = { 0 }
310+ aria-description = "Thought process content"
311+ >
296312 < div className = "border-l-2 border-base-content/20 pl-4 mb-4" >
297313 < MarkdownDisplay content = { content } />
298314 </ div >
0 commit comments