@@ -25,6 +25,13 @@ export default async function ChatPage({
2525 const sections = await getMarkdownSections ( targetLang ! . id , targetPage ! . slug ) ;
2626 const targetSection = sections . find ( ( sec ) => sec . id === chatData . sectionId ) ;
2727
28+ const messagesAndDiffs = [
29+ ...chatData . messages . map ( ( msg ) => ( { type : "message" as const , ...msg } ) ) ,
30+ ...chatData . diff . map ( ( diff ) => ( { type : "diff" as const , ...diff } ) ) ,
31+ ] ;
32+ messagesAndDiffs . sort (
33+ ( a , b ) => new Date ( a . createdAt ) . getTime ( ) - new Date ( b . createdAt ) . getTime ( )
34+ ) ;
2835 return (
2936 < aside
3037 className = { clsx (
@@ -61,23 +68,45 @@ export default async function ChatPage({
6168 < Link className = "btn" href = "/chat" >
6269 閉じる
6370 </ Link >
64- { chatData ?. messages . map ( ( msg , index ) =>
65- msg . role === "user" ? (
66- < div key = { index } className = "chat chat-end" >
67- < div
68- className = "chat-bubble p-0.5! bg-secondary/30"
69- style = { { maxWidth : "100%" , wordBreak : "break-word" } }
70- >
71+ { messagesAndDiffs . map ( ( msg , index ) =>
72+ msg . type === "message" ? (
73+ msg . role === "user" ? (
74+ < div key = { index } className = "chat chat-end" >
75+ < div
76+ className = "chat-bubble p-0.5! bg-secondary/30"
77+ style = { { maxWidth : "100%" , wordBreak : "break-word" } }
78+ >
79+ < StyledMarkdown content = { msg . content } />
80+ </ div >
81+ </ div >
82+ ) : msg . role === "ai" ? (
83+ < div key = { index } className = "" >
7184 < StyledMarkdown content = { msg . content } />
7285 </ div >
73- </ div >
74- ) : msg . role === "ai" ? (
75- < div key = { index } className = "" >
76- < StyledMarkdown content = { msg . content } / >
77- </ div >
86+ ) : (
87+ < div key = { index } className = "text-error" >
88+ { msg . content }
89+ </ div >
90+ )
7891 ) : (
79- < div key = { index } className = "text-error" >
80- { msg . content }
92+ < div
93+ key = { index }
94+ className = { clsx (
95+ "bg-base-300 rounded-lg border border-2 border-secondary/50"
96+ ) }
97+ >
98+ { /* pb-0だとmargin collapsingが起きて変な隙間が空く */ }
99+ < del
100+ className = { clsx (
101+ "block p-2 pb-[1px] bg-error/10" ,
102+ "line-through decoration-[color-mix(in_oklab,var(--color-error)_70%,currentColor)]"
103+ ) }
104+ >
105+ < StyledMarkdown content = { msg . search } />
106+ </ del >
107+ < ins className = "block no-underline p-2 pt-[1px] bg-success/10" >
108+ < StyledMarkdown content = { msg . replace } />
109+ </ ins >
81110 </ div >
82111 )
83112 ) }
0 commit comments