diff --git a/frontend/src/components/CardCatalog.tsx b/frontend/src/components/CardCatalog.tsx index 86eda4b..dd22223 100644 --- a/frontend/src/components/CardCatalog.tsx +++ b/frontend/src/components/CardCatalog.tsx @@ -15,7 +15,11 @@ export function CardCatalog({ activeCardId }: { activeCardId: string | null }) { if (data) return try { setFailed(false) - setData(await fetchCards()) + const res = await fetchCards() + setData({ + cards: [...res.cards].sort((a, b) => a.card_id.localeCompare(b.card_id)), + wild_cards: res.wild_cards, + }) } catch { setFailed(true) } diff --git a/frontend/src/components/ChatPanel.tsx b/frontend/src/components/ChatPanel.tsx index b3e1a99..2582752 100644 --- a/frontend/src/components/ChatPanel.tsx +++ b/frontend/src/components/ChatPanel.tsx @@ -18,6 +18,22 @@ const STEP_LABELS: Record = { } const stepLabel = (s: string) => STEP_LABELS[s] ?? s +// 봇 스크립트가 한 덩어리 문단일 때 가독성을 위해 2문장씩 끊는다 (표시 전용). +// 서버가 이미 넣어둔 줄바꿈은 유지하고, 긴 줄만 종결어미("~다."/"~요.") 경계에서 나눈다. +function paragraphize(text: string): string { + return text + .split('\n') + .map((line) => { + if (line.length < 90) return line + const sentences = line.split(/(?<=[다요]\.)\s+/) + if (sentences.length < 3) return line + const chunks: string[] = [] + for (let i = 0; i < sentences.length; i += 2) chunks.push(sentences.slice(i, i + 2).join(' ')) + return chunks.join('\n\n') + }) + .join('\n') +} + export function ChatPanel({ messages, nego, busy, started, error, demoCase, cases, finalPrice, onAnswer, onOffer, onRestart, onSelect, }: { @@ -143,7 +159,7 @@ export function ChatPanel({ : 'bg-base-200 text-base-content' }`} > - {m.text} + {m.role === 'bot' ? paragraphize(m.text) : m.text} ))}