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(error-tracking): open Explain in Max side panel with issue context (#62532)

Paul D'Ambra060b689c138f
diff --git a/products/error_tracking/frontend/components/ExplainIssueTool.tsx b/products/error_tracking/frontend/components/ExplainIssueTool.tsx
index 2ba344e299fb..034a9c6e2552 100644
--- a/products/error_tracking/frontend/components/ExplainIssueTool.tsx
+++ b/products/error_tracking/frontend/components/ExplainIssueTool.tsx
@@ -1,4 +1,9 @@
-import { useOpenAi } from 'scenes/max/useOpenAi'
+import { useActions, useValues } from 'kea'
+
+import { maxContextLogic } from 'scenes/max/maxContextLogic'
+
+import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
+import { SidePanelTab } from '~/types'
export interface UseErrorTrackingExplainIssueReturn {
isMaxOpen: boolean
@@ -6,20 +11,24 @@ export interface UseErrorTrackingExplainIssueReturn {
}
/**
- * Hook to open Max AI side panel with a prompt to explain an error tracking issue.
- * In side panel mode, the issue context is automatically provided via the maxContext selector.
- * In new tab mode, the issue ID is passed for context restoration.
+ * Hook to open the Max AI side panel with a prompt to explain an error tracking issue.
+ * The issue is added to Max's context so the explanation is grounded in the current issue.
*
* @param issueId - The error tracking issue ID to explain
*/
export function useErrorTrackingExplainIssue(issueId: string): UseErrorTrackingExplainIssueReturn {
- const { isMaxOpen, openAi } = useOpenAi()
+ const { sidePanelOpen, selectedTab } = useValues(sidePanelStateLogic)
+ const { openSidePanel } = useActions(sidePanelStateLogic)
+ const { addOrUpdateContextErrorTrackingIssue } = useActions(maxContextLogic)
+
+ const isMaxOpen = sidePanelOpen && selectedTab === SidePanelTab.Max
return {
isMaxOpen,
- openMax: () =>
- openAi('Explain this issue to me', {
- errorTrackingIssue: { id: issueId },
- }),
+ openMax: () => {
+ addOrUpdateContextErrorTrackingIssue({ id: issueId })
+ // Leading "!" auto-runs the prompt once the side panel opens.
+ openSidePanel(SidePanelTab.Max, '!Explain this issue to me')
+ },
}
}