Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(aio): guard trace comment quote-insert against unmounted logic (#72909)

Radu Raicea1ccc526eaaf9
diff --git a/products/ai_observability/frontend/ConversationDisplay/MessageActionsMenu.tsx b/products/ai_observability/frontend/ConversationDisplay/MessageActionsMenu.tsx
index e06911492def..11353a251b84 100644
--- a/products/ai_observability/frontend/ConversationDisplay/MessageActionsMenu.tsx
+++ b/products/ai_observability/frontend/ConversationDisplay/MessageActionsMenu.tsx
@@ -41,6 +41,11 @@ export const MessageActionsMenu = ({ content, traceId }: MessageActionsMenuProps
}
const insertQuoteIntoEditor = (quotedContent: string, retries = 0): void => {
+ // The logic can be unmounted before this deferred callback runs (e.g. the user navigates
+ // away or switches traces), so bail out rather than reading `.values` off a torn-down store.
+ if (!commentsLogicInstance.isMounted()) {
+ return
+ }
// Access editor via .values to get the latest value at retry time, not render time
const editor = commentsLogicInstance.values.richContentEditor
if (editor) {
diff --git a/products/ai_observability/frontend/text-view/components/LineWithNumber.tsx b/products/ai_observability/frontend/text-view/components/LineWithNumber.tsx
index 1b1e217db501..1b9d284f0bf0 100644
--- a/products/ai_observability/frontend/text-view/components/LineWithNumber.tsx
+++ b/products/ai_observability/frontend/text-view/components/LineWithNumber.tsx
@@ -64,6 +64,11 @@ export function LineWithNumber({
}
const insertQuoteIntoEditor = (quotedContent: string, retries = 0): void => {
+ // The logic can be unmounted before this deferred callback runs (e.g. the user navigates
+ // away or switches traces), so bail out rather than reading `.values` off a torn-down store.
+ if (!commentsLogicInstance.isMounted()) {
+ return
+ }
const editor = commentsLogicInstance.values.richContentEditor
if (editor) {
editor.clear()