Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(assistant-ui): handle missing assistant message in markdown rendering

Steven Enamakela3dce041dcdd
diff --git a/app/src/components/assistant-ui/markdown-text.tsx b/app/src/components/assistant-ui/markdown-text.tsx
index d834eb593a..ab998ecd27 100644
--- a/app/src/components/assistant-ui/markdown-text.tsx
+++ b/app/src/components/assistant-ui/markdown-text.tsx
@@ -96,7 +96,18 @@ const MarkdownTextImpl = () => {
// renders: the gate must not flip mid-reveal.
const { text } = useMessagePartText();
const hasMath = hasLatexContent(text);
- const sources = useAuiState(state => sourcePartsToCitations(state.message.parts));
+ // Some callers (e.g. a bare `TextMessagePartProvider` in tests, or a tool
+ // result rendered through `MarkdownText` outside a full message scope)
+ // provide a message-PART scope with no message-level `state.message` — the
+ // proxy throws reading it. No sources to linkify is the correct fallback,
+ // not a crash.
+ const sources = useAuiState(state => {
+ try {
+ return sourcePartsToCitations(state.message.parts);
+ } catch {
+ return EMPTY_CITATION_SOURCES;
+ }
+ });
const preprocess = (input: string): string => {
const withCitations = linkifyCitationMarkers(input, sources.length);
diff --git a/crates/openhuman-core/src/web_chat/presentation.rs b/crates/openhuman-core/src/web_chat/presentation.rs
index be60a0204c..e3c1798065 100644
--- a/crates/openhuman-core/src/web_chat/presentation.rs
+++ b/crates/openhuman-core/src/web_chat/presentation.rs
@@ -212,6 +212,7 @@ pub(crate) async fn deliver_response(
}
// Final chat_done with full text (for deduplication / state sync).
+ #[allow(clippy::needless_update)]
publish_web_channel_event(WebChannelEvent {
event: "chat_done".to_string(),
client_id: client_id.to_string(),