+ {showSuggestions && (
+
+
Suggested questions
+ {suggestions.map((q) => (
+
+ ))}
+
+ )}
+
+ {messages.map((msg, i) => {
+ if (msg.role === "user") {
+ return (
+
+ {msg.text}
+
+ );
+ }
+
+ // Assistant message
+ return (
+
+ {msg.error ? (
+
{msg.error}
+ ) : (
+ <>
+ {parseCitations(msg.text, msg.sources)}
+ {!msg.done &&
}
+ {msg.done && msg.sources.length > 0 && (
+
+
Sources
+
+ {msg.sources.map((src) => {
+ const href = src.section_anchor
+ ? `/techniques/${src.slug}#${src.section_anchor}`
+ : `/techniques/${src.slug}`;
+ return (
+ -
+ {src.number}
+
+ {src.title}
+ {src.section_heading ? ` — ${src.section_heading}` : ""}
+
+
+ );
+ })}
+
+
+ )}
+ >
+ )}
+
+ );
+ })}
+
+ {/* Typing indicator during loading before first token */}
+ {streaming &&
+ messages.length > 0 &&
+ messages[messages.length - 1]?.role === "assistant" &&
+ messages[messages.length - 1]?.text === "" &&
+ !messages[messages.length - 1]?.error && (
+
+
+
+
+
+ )}
+
+
+