Fix AtlasChat crash: guard renderContent and message render against null content
Made-with: Cursor
This commit is contained in:
@@ -16,7 +16,8 @@ interface AtlasChatProps {
|
||||
// ---------------------------------------------------------------------------
|
||||
// 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) => {
|
||||
const parts = line.split(/(\*\*.*?\*\*)/g).map((seg, j) =>
|
||||
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 (
|
||||
<div style={{
|
||||
@@ -258,7 +260,7 @@ export function AtlasChat({ projectId }: AtlasChatProps) {
|
||||
>
|
||||
Reset
|
||||
</button>
|
||||
{messages.map((msg, i) => (
|
||||
{visibleMessages.map((msg, i) => (
|
||||
<MessageRow key={i} msg={msg} userInitial={userInitial} />
|
||||
))}
|
||||
{isStreaming && <TypingIndicator />}
|
||||
|
||||
Reference in New Issue
Block a user