Fix AtlasChat crash: guard renderContent and message render against null content

Made-with: Cursor
This commit is contained in:
2026-03-02 19:57:59 -08:00
parent 7732b5fbea
commit c8d8deb2cc

View File

@@ -16,7 +16,8 @@ interface AtlasChatProps {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Markdown-lite renderer — handles **bold**, newlines, numbered/bullet lists // Markdown-lite renderer — handles **bold**, newlines, numbered/bullet lists
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function renderContent(text: string) { function renderContent(text: string | null | undefined) {
if (!text) return null;
return text.split("\n").map((line, i) => { return text.split("\n").map((line, i) => {
const parts = line.split(/(\*\*.*?\*\*)/g).map((seg, j) => const parts = line.split(/(\*\*.*?\*\*)/g).map((seg, j) =>
seg.startsWith("**") && seg.endsWith("**") seg.startsWith("**") && seg.endsWith("**")
@@ -205,7 +206,8 @@ export function AtlasChat({ projectId }: AtlasChatProps) {
} }
}; };
const isEmpty = messages.length === 0 && !isStreaming; const visibleMessages = messages.filter(msg => msg.content);
const isEmpty = visibleMessages.length === 0 && !isStreaming;
return ( return (
<div style={{ <div style={{
@@ -258,7 +260,7 @@ export function AtlasChat({ projectId }: AtlasChatProps) {
> >
Reset Reset
</button> </button>
{messages.map((msg, i) => ( {visibleMessages.map((msg, i) => (
<MessageRow key={i} msg={msg} userInitial={userInitial} /> <MessageRow key={i} msg={msg} userInitial={userInitial} />
))} ))}
{isStreaming && <TypingIndicator />} {isStreaming && <TypingIndicator />}