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.

feat(error-tracking): collapse summary and reports, say why no summary (#129223)

James Gill64d01d7e6f2b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2d3e035ee98b..be73422de5a7 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -11454,14 +11454,10 @@ snapshots:
hash: v1.k794b7964.7b967502dd276f40a0035c9f1fec6c4fff32e4558afd88b2605089ae34d79bf5.Qa-Nb2wVDvXbs1WAzJLiYFVpc-IJMDtPG31P0njv5lc
scenes-app-errortracking--group-page-today-rail-nav--light:
hash: v1.k794b7964.195f79c54a1021066a5212c8f778741cb247edc4a77fed677d59f09d2d8b9c98.DoLnAH2gz3VSkmqa-0j8TUEIO-gAuHe1oPz5NWZf0Dw
- scenes-app-errortracking--group-page-with-many-self-driving-reports--dark:
- hash: v1.k794b7964.80a2533ac0237e1c88e747da106127fb7f335c4dfbda4dcd9acc58d5fad4133d.-bwvh6NUGPl4apMtIctBlqZHzMtXaDazhCLw-q4AUtM
- scenes-app-errortracking--group-page-with-many-self-driving-reports--light:
- hash: v1.k794b7964.cac5cd3378c99cf8988fb1f32dca796f026c93895177bc965bd6c299a244a19e.snGyXTbaNbg4mTwZrJkxoE5S241i-4iLLBt6aa9LXpk
scenes-app-errortracking--group-page-with-self-driving--dark:
- hash: v1.k794b7964.741757ca4352b367eda183895a4ed348a05fc3f6b02c171f0ce0a0f25d0b2a1e.U1UUDdUkXrd9mGMqpIWYT_jooAq20250yZ7zlyC5vVQ
+ hash: v1.k794b7964.5b2ad716a364c83f57c4aec2fe6763b18b292b16587be3ea3dd70510e6a6d346.hy55pTTiWYd_eKLJ-L2bUXoolVsA_KhOrCaRguFMUZg
scenes-app-errortracking--group-page-with-self-driving--light:
- hash: v1.k794b7964.45b83e5c1a896fecd2b126a7c74a9d579bfa749f6aa201ee71bb7d5f36f60609.bSYjFVu9L-WBgCku9iTPRp2tkHve1EsW0J4An0VhWnU
+ hash: v1.k794b7964.e47e0a3fa8886a16bc9188230115e0a245b24438f550991ea5cf7a4bb5b378d7.yVT-RF802Fpyyu8QUEsNPKK2nbI_gz1nKqvNbC3Q0kM
scenes-app-errortracking--insights-page--dark:
hash: v1.k794b7964.27729f53309ad7771b8a5527630a7383c15a2bbd1742aabd327a45e437568b71.-4jlCTRkGbJr0JWdy21HbmPH-LCrwxrobOhgLMXDDL0
scenes-app-errortracking--insights-page--light:
@@ -11494,38 +11490,46 @@ snapshots:
hash: v1.k794b7964.502a216bbc9268301578d6cebf9f46d13d3a802734f4fd7bd2707bdf8f0c9911.kpruIOz8uQ8wg26EB5QjeBVvFyLZVQV9FI4UqZ4Egsg
scenes-app-errortracking--list-page-with-stacked-banners--light:
hash: v1.k794b7964.7f8d251eac06e80fcd07c83ecda7fd43de79caf8f2c6bfe47fad10ab5ae094eb.OgfZFV7i9PlPfw0x6u6BbDnZ6fzWxpn6M3moLNzCBd8
+ scenes-app-errortracking-issuesummary--closed--dark:
+ hash: v1.k794b7964.8d2bf7ea8efa8792d945308e5896d7a6a8ec056613fb29fc62ac7ebee3ec2112.cV0_aoeyDeyrZZKiSSsxnMW5FmCVLR8AwPNMkVUG3Z8
+ scenes-app-errortracking-issuesummary--closed--light:
+ hash: v1.k794b7964.66bea57cb7578e52b115b56ee3d547acffd546b501b3d6e066146c0b8c7f51fa.11bx35fqgpCWPg-3cBe9WqoZ7HIu-mh_Oyin9P_B7xo
scenes-app-errortracking-issuesummary--failed--dark:
- hash: v1.k794b7964.e9866a862497cb43eba375b641dace5125f87cd6aa990f46169414e991308aff.LK4UTwfs9n5fwkCo_xsXWeVI4uWhOFFHsWJcuCTdtmQ
+ hash: v1.k794b7964.8bf260a5e7bc81f0b71d6b4f38444f1b3851097619d3fb15c5c381bf432f9d1f.4bJgExgbQaCkSJFe1t3u82pmecQFz6UyRw9BFXd4tm0
scenes-app-errortracking-issuesummary--failed--light:
- hash: v1.k794b7964.9dadc3835482c9fc3cbf9c34d64d6d38d9b0b6dd7bcc29f6d6a761a5a02f2833.GGfML6hnbKuYv8EbpC9KDa1HKT9jwVfNZZBsvJlduX8
+ hash: v1.k794b7964.2f05aeb919a91f98a1750c096cb45ef6f8fba2da5cb49af69b05b3d46a1c0c2d.3BSK4Vb4XLu5k3xl0bmxB7IBDFf6FGMeWzxcCP__nLw
scenes-app-errortracking-issuesummary--ready--dark:
- hash: v1.k794b7964.fe6868c41309756ed8c4b534d93997abb07496dbf92209e6dc016eeb71b29e92.vn3eJyTK2iRSNJIaRCgQs2af1DkIDeykM41vy7lgzQ4
+ hash: v1.k794b7964.016391f18f589901276b0e7464d72361ad860376bdf7a3072c510578de056100.DhkeVJSd7s2Dix8aAb8H-zUzxnjrTXv_mUbTyxUk9P8
scenes-app-errortracking-issuesummary--ready--light:
- hash: v1.k794b7964.f9b453712b1a95ff2bda0a627a3a30c473708a9555fa565172f5e2d72531684f.E0MgsSYePdCgBsYg0nlVnWKgHq7crSB8JSfJjBEyWjk
+ hash: v1.k794b7964.381a32fe1d4bd815ec50962b5c7ce55e7e51bdc5cb84332d2946d2eacc54ad09.oFgC_bSSk1K2-uneY4Cypgf-BI7bzsCdaVV0mySomaM
scenes-app-errortracking-issuesummary--ready-wide--dark:
- hash: v1.k794b7964.82ad07ab5485a12668a8a0712e472df7757efc6a562fa091b72de3fe111b7ede.b4h-EVOIiCS0XANjVb2IdTPAbmv0HwfzZqnBgSBRUvo
+ hash: v1.k794b7964.9800696936aa46e7e951255bd72c28e46e7f5b3d78982bc4d22f8e629d192dcb.UmQw4MDdvAm-gZaGqKNKY_RkBallVAgscRnDW4sjBy8
scenes-app-errortracking-issuesummary--ready-wide--light:
- hash: v1.k794b7964.1cda021cd680fb893b3eed8ff42a32143d61d4254155ab4615c49339b8000065.OAa8yZLwYrB2pIeBaeaiGLXyAdcNANY9Q3YmuotnWs4
+ hash: v1.k794b7964.b9149c97e998f42899b6e26d640024ea73f3a2add9e08936c953f5bcb6d3745e.RYKP0_ToSbJrsXL8FFohOFX4ECOIskM6uIo4Nn3jUzk
scenes-app-errortracking-issuesummary--ready-without-likely-cause--dark:
- hash: v1.k794b7964.8badd7b9a6bc79ce305f96b1b676bd3dbb707d0ea3bfcf4632a1d529170e060e.LUgab_ixIuJjiNYi-A6Z_ZuU0KnzwQGdnCDh7RIhHe0
+ hash: v1.k794b7964.0603d5ec1969dc6018d808a0dbafc691be1f5ded72e3663b5addd8b3e6c7f012.U53rzceudE88rex9zYdsBBnVrNlZa3sU6Qei-SZpcM4
scenes-app-errortracking-issuesummary--ready-without-likely-cause--light:
- hash: v1.k794b7964.d10d73c16662e9d0818f4dbb1c2064ba9a41ad7d05a42570514f5efa02fae8f8.MywIqTJJIupufO8RbLXzWnVzc6V-6SG025VmrayQTYY
+ hash: v1.k794b7964.837433c867f3b75786c3b7eedfb73aa44d3acbb6a9fd724f03d9ab45e66435cc.JMZrUwZtldibYTb6qcP7M8d14Zul6z0empxVuftZOms
+ scenes-app-errortracking-linkedreports--closed--dark:
+ hash: v1.k794b7964.480433f95dd4dde2afef28aa3fc3d0c449896d19a6a7da665c410ed75b46e60b.j-hegj1EEBc5mddzRa7sseAw713tDWFGmjZoBQkMyTE
+ scenes-app-errortracking-linkedreports--closed--light:
+ hash: v1.k794b7964.82f16b0e3137d148794cf4be396096bd619a0e7e59b4d5ee2961cfb4f332c3e3.EfXRVTOwzZnpoRTe3rD77-h_Dg0_PQK-GYT25YJvu6A
scenes-app-errortracking-linkedreports--fix-proposed--dark:
- hash: v1.k794b7964.1b50022f8fafb4684dacd255b966bd2969f79e84d5c7c7daeb68291772a1e36d.9uyjrwufsjMCFx9c7cjsoIyabB3A4ZBnPSVUouM0RZE
+ hash: v1.k794b7964.4d94eddb99ada0e4c98e282f15bc6cc14354d452464ab1e28150106caa23afb4.LBtMsKCCB5coO8MMro63-8zKUaIgmkGqOvTw2bT9XAU
scenes-app-errortracking-linkedreports--fix-proposed--light:
- hash: v1.k794b7964.55ab1b408ab7d4610f66f2bb35d13dfabcf5188d4281f52f2a051b40392fb7b9.9jUiUdXP-J66RW2MssU_oFrMfC-C4TK3ereJqyATDLw
+ hash: v1.k794b7964.c5416d0b66abff54cc7083d8681a617142f85ec6475c223b1b17c7b122f65c58.kPPLkPB3WSi-V0IlQS65UAig8m3zItdrK1ryQjQdHC8
scenes-app-errortracking-linkedreports--many-reports--dark:
- hash: v1.k794b7964.8dfec237ec7416c9efc0f6a7e1fbcb0c1d3a770946b2083c05dee94b71c7f1ae.-i8u1CAXGwd7duJovq02YplVfMQmvsXn41x-bqwE6Fw
+ hash: v1.k794b7964.1cbd86ad2df8ce9f9bf6f05dcbd200fc8b8568f4dd6df41358d2d4c887cb9c1c.TSLDF4uYeBoPuNVlnc3zrbSL7U1quLKyXPjD1CYMe6k
scenes-app-errortracking-linkedreports--many-reports--light:
- hash: v1.k794b7964.f59e79fad838ce516ec002dad88207a5b973092276e15e8389455665353a8df2.-hk9_3EgUm8jt6NOL9MyEfQ1qzhlsB1o3H-tx74BL34
+ hash: v1.k794b7964.58d79db08e241b1d989778a16feadb932b7355d2f78a9e824439366a9a877dde.b6d85BXb6a26BIwUgekWyw9GAusKD-NBFjKg95YAYbQ
scenes-app-errortracking-linkedreports--narrow-pane--dark:
- hash: v1.k794b7964.d7527da21c5cb2847a7b40caa0767ff77c136491254ce50d3ce781ea0d3a3a9c.RQX9dwgdc9l1Xb8cETpKphmQTd3u0dBP5UKYfbWwe7E
+ hash: v1.k794b7964.d9bd47e09a72923b21ff6774c620c5974fe7bd837289351f4c6d7e551887939c.blJExy32TWKjxhn2qZ-efmfFvzKYEfIqBDKl49u6LjQ
scenes-app-errortracking-linkedreports--narrow-pane--light:
- hash: v1.k794b7964.6b648e58ee1ccea37ad71a538748a2fdb29b2dbf23f92f88c25c36b1e685a3bd.BaQlVB4KrfxkDGdwlfht7SFDOHNQ40PHeuEa8Ssp50U
+ hash: v1.k794b7964.7449ff1fd9a0b92c86ea9ec7524bc29b03710434b153a3d4fe17ba01524e1fec.Wcdxk_1VbGwm2gSKYb2gLVQS4SmkGE5vhs62Ms3NHf0
scenes-app-errortracking-linkedreports--several-reports-across-states--dark:
- hash: v1.k794b7964.71fdce87c3009faea6dd25e6ac817d5790ffed494cb15d66a7043b4ebe90cb60.rYWzblIjD-Ceyh15tkUkDm10Pu7exKRUm9n9TsB9B0Q
+ hash: v1.k794b7964.9f4aafd10bfe7c68fef01cd711d95b805afe2f0d544f2dcbd3cba2fa93886627.r5wrPlHEGgdfG1FKX8Q-YzXiqbGrxo_AU_9QMxTmCFM
scenes-app-errortracking-linkedreports--several-reports-across-states--light:
- hash: v1.k794b7964.fe2161a3bb0e898689ef58a342d071c353ded71ac270a62998ea566055359e7a.AnoCs1sNoTY6J1yl24yuZPh_1Jkjugz-jnYxHgY8ZyU
+ hash: v1.k794b7964.9f71d2f946e4d01845d5dfe3d9738dc257244ebe02bc8412812daefd11decad4.qsKwhxaV6ylFQN9u5I1wbPcUD_tB--D3WkmhiuCzZYI
scenes-app-errortracking-suppress-similar-issues-dialog--exact-message--dark:
hash: v1.k794b7964.84152ff066dc338cda47d926eb98d8ab94ad78875110b82b89c30147724c5a86.P-Z6JrxVkTel_pZXRwNiMPT6ClPcSSUfXk0vdxDauhI
scenes-app-errortracking-suppress-similar-issues-dialog--exact-message--light:
diff --git a/products/error_tracking/frontend/ErrorTracking.stories.tsx b/products/error_tracking/frontend/ErrorTracking.stories.tsx
index d8e64db3f9d6..42fac3690303 100644
--- a/products/error_tracking/frontend/ErrorTracking.stories.tsx
+++ b/products/error_tracking/frontend/ErrorTracking.stories.tsx
@@ -1,6 +1,6 @@
import { MOCK_DEFAULT_BASIC_USER, MOCK_DEFAULT_TEAM } from 'lib/api.mock'
-import { Decorator, Meta, StoryObj } from '@storybook/react'
+import { Meta, StoryObj } from '@storybook/react'
import { useActions } from 'kea'
import { useLayoutEffect, useState } from 'react'
@@ -1181,28 +1181,6 @@ export const GroupPageLoading: Story = {
],
}
-function selfDrivingReportsDecorator(count: number): Decorator {
- return mswDecorator({
- get: {
- '/api/projects/:team_id/signals/reports/': () => [
- 200,
- {
- next: null,
- results: Array.from({ length: count }, (_, index) => ({
- id: `019f9582-93e7-77c1-8912-4f541d70cb${String(index).padStart(2, '0')}`,
- status: index % 2 === 0 ? 'ready' : 'resolved',
- title: `fix(replay): guard against a missing snapshot index (${index + 1})`,
- summary: 'The player throws when a recording ends on a snapshot the index never received.',
- implementation_pr_url: `https://github.com/PostHog/posthog/pull/${64772 + index}`,
- implementation_pr_merged: index % 2 === 1,
- updated_at: '2024-07-08T21:00:00Z',
- })),
- },
- ],
- },
- })
-}
-
// Self-driving investigated this issue, so its section renders in the right pane above the exception
// card. This is the only coverage of the placement: the section's own story fabricates a pane around
// it, so it cannot show that the two header strips line up, that the section paints the background the
@@ -1247,14 +1225,3 @@ export const GroupPageWithSelfDriving: Story = {
}),
],
}
-
-// An issue the agent looked at many times. The section stops at half the pane and scrolls, so the
-// exception card and its stack trace stay on screen.
-export const GroupPageWithManySelfDrivingReports: Story = {
- name: 'Issue scene with many self-driving reports',
- parameters: {
- pageUrl: urls.errorTrackingIssue(ISSUE_ID),
- testOptions: { waitForLoadersToDisappear: false },
- },
- decorators: [selfDrivingReportsDecorator(12)],
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssuePaneSectionHeader.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssuePaneSectionHeader.tsx
new file mode 100644
index 000000000000..526d258cc138
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssuePaneSectionHeader.tsx
@@ -0,0 +1,50 @@
+import { ReactNode } from 'react'
+
+import { IconChevronDown, IconChevronRight } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { IssuePaneSectionName } from './IssuePaneSectionName'
+
+export interface IssuePaneSectionHeaderProps {
+ name: string
+ open: boolean
+ onToggle: () => void
+ preview?: ReactNode
+ /** Controls at the end of the strip. They sit beside the toggle, because a button cannot hold another. */
+ trailing?: ReactNode
+ dataAttr: string
+}
+
+export function IssuePaneSectionHeader({
+ name,
+ open,
+ onToggle,
+ preview,
+ trailing,
+ dataAttr,
+}: IssuePaneSectionHeaderProps): JSX.Element {
+ return (
+ <div className="flex h-[2rem] w-full shrink-0 items-center gap-1 border-b pl-0.5 pr-2">
+ <LemonButton
+ size="xsmall"
+ // LemonButton fills an expanded button like a pressed one. An open section is not pressed.
+ className="min-w-0 flex-1 [&[aria-expanded=true]:not(:hover)]:bg-transparent!"
+ icon={open ? <IconChevronDown /> : <IconChevronRight />}
+ onClick={onToggle}
+ aria-expanded={open}
+ data-attr={dataAttr}
+ >
+ <span className="flex min-w-0 items-center gap-2">
+ <IssuePaneSectionName name={name} />
+ {preview ? (
+ // The preview can quote exception data, so autocapture must not record its text.
+ <span className="ph-sensitive min-w-0 truncate text-xs font-normal text-secondary">
+ {preview}
+ </span>
+ ) : null}
+ </span>
+ </LemonButton>
+ {trailing}
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssuePaneSectionName.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssuePaneSectionName.tsx
new file mode 100644
index 000000000000..d3282436e9ad
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssuePaneSectionName.tsx
@@ -0,0 +1,11 @@
+import { IconLogomark } from '@posthog/icons'
+
+/** The name takes the AI color, which is how the app marks the work its own software did. */
+export function IssuePaneSectionName({ name }: { name: string }): JSX.Element {
+ return (
+ <span className="flex shrink-0 items-center gap-1">
+ <IconLogomark className="text-lg" />
+ <span className="text-sm font-normal text-ai">{name}</span>
+ </span>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.stories.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.stories.tsx
index 375beeb32630..faefda9f8107 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.stories.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.stories.tsx
@@ -32,6 +32,10 @@ function render(props: Partial<IssueSummarySectionProps>, width: 'narrow' | 'wid
view="ready"
summary={SUMMARY}
feedback={null}
+ open
+ canManageAiSettings
+ loading={false}
+ onToggle={noop}
onRetry={noop}
onFeedback={noop}
{...props}
@@ -49,3 +53,33 @@ export const ReadyWithoutLikelyCause: Story = {
}
export const Failed: Story = { render: () => render({ view: 'failed', summary: null }) }
+
+export const Closed: Story = { render: () => render({ open: false }) }
+
+// Each reason a summary is missing is one line. Snapshots of these add nothing the Failed row does not cover.
+const NO_SNAPSHOT = { testOptions: { snapshotBrowsers: [] } }
+
+export const Writing: Story = {
+ render: () => render({ view: 'writing', summary: null }),
+ parameters: NO_SNAPSHOT,
+}
+
+export const NotGenerated: Story = {
+ render: () => render({ view: 'not_generated', summary: null }),
+ parameters: NO_SNAPSHOT,
+}
+
+export const AiNotApproved: Story = {
+ render: () => render({ view: 'ai_not_approved', summary: null }),
+ parameters: NO_SNAPSHOT,
+}
+
+export const AiNotApprovedForMember: Story = {
+ render: () => render({ view: 'ai_not_approved', summary: null, canManageAiSettings: false }),
+ parameters: NO_SNAPSHOT,
+}
+
+export const Restricted: Story = {
+ render: () => render({ view: 'restricted', summary: null }),
+ parameters: NO_SNAPSHOT,
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.tsx
index b6c535a7f5da..a6514d2c6445 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/IssueSummary.tsx
@@ -1,27 +1,29 @@
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
-import {
- IconArrowRight,
- IconBug,
- IconLogomark,
- IconPeople,
- IconSearch,
- IconThumbsDown,
- IconThumbsUp,
-} from '@posthog/icons'
-import { LemonButton, LemonTag } from '@posthog/lemon-ui'
+import { IconArrowRight, IconBug, IconPeople, IconSearch, IconThumbsDown, IconThumbsUp } from '@posthog/icons'
+import { LemonButton, LemonTag, Link } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
+import { organizationLogic } from 'scenes/organizationLogic'
+import { AIAccessRequest } from 'scenes/settings/organization/AIAccessRequest'
+import { urls } from 'scenes/urls'
import type { ErrorTrackingStoredIssueSummaryApi } from '../../generated/api.schemas'
import { errorTrackingIssueSceneLogic } from './errorTrackingIssueSceneLogic'
+import { IssuePaneSectionHeader } from './IssuePaneSectionHeader'
+import { IssuePaneSectionName } from './IssuePaneSectionName'
+import { issuePaneSectionsLogic } from './issuePaneSectionsLogic'
import { IssueSummaryFeedback, IssueSummaryView, issueSummaryLogic } from './issueSummaryLogic'
export interface IssueSummarySectionProps {
view: IssueSummaryView
summary: ErrorTrackingStoredIssueSummaryApi | null
feedback: IssueSummaryFeedback | null
+ open: boolean
+ canManageAiSettings: boolean
+ loading: boolean
+ onToggle: () => void
onRetry: () => void
onFeedback: (feedback: IssueSummaryFeedback) => void
}
@@ -51,48 +53,127 @@ function SummaryField({
)
}
+function SummaryNote({
+ view,
+ canManageAiSettings,
+}: {
+ view: Exclude<IssueSummaryView, 'hidden' | 'ready'>
+ canManageAiSettings: boolean
+}): JSX.Element {
+ switch (view) {
+ case 'failed':
+ return <>Couldn't load the summary.</>
+ case 'writing':
+ return <>No summary yet. Summaries take a minute to write after an issue is first seen.</>
+ case 'not_generated':
+ return <>No summary. Summaries are written when an issue is first seen.</>
+ case 'restricted':
+ return <>No summary. Summaries use event data you don't have access to.</>
+ case 'ai_not_approved':
+ return canManageAiSettings ? (
+ <>
+ No summary. AI features are off for your organization.{' '}
+ <Link
+ to={urls.settings('organization-details', 'organization-ai-consent')}
+ className="whitespace-nowrap"
+ data-attr="error-tracking-issue-summary-ai-settings"
+ >
+ Manage AI settings
+ </Link>
+ </>
+ ) : (
+ <>
+ No summary. AI features are off for your organization.
+ <div className="mt-1">
+ <AIAccessRequest />
+ </div>
+ </>
+ )
+ }
+}
+
export function IssueSummarySection({
view,
summary,
feedback,
+ open,
+ canManageAiSettings,
+ loading,
+ onToggle,
onRetry,
onFeedback,
}: IssueSummarySectionProps): JSX.Element | null {
if (view === 'hidden') {
return null
}
+ if (view !== 'ready') {
+ return (
+ // The left padding puts the name under the name of a section that has a toggle. It is the header's
+ // pl-0.5 plus the toggle's chevron: an xsmall LemonButton's horizontal padding, icon and gap.
+ <div
+ className="flex min-h-[2rem] shrink-0 items-center gap-2 border-b py-1 pl-[1.625rem] pr-2 bg-surface-primary"
+ data-attr="error-tracking-issue-summary"
+ >
+ <IssuePaneSectionName name="Summary" />
+ <div className="min-w-0 flex-1 text-xs text-secondary leading-snug">
+ <SummaryNote view={view} canManageAiSettings={canManageAiSettings} />
+ </div>
+ {view === 'failed' || view === 'writing' ? (
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ onClick={onRetry}
+ loading={loading}
+ data-attr={
+ view === 'failed'
+ ? 'error-tracking-issue-summary-retry'
+ : 'error-tracking-issue-summary-check-again'
+ }
+ >
+ {view === 'failed' ? 'Try again' : 'Check again'}
+ </LemonButton>
+ ) : null}
+ </div>
+ )
+ }
+ if (!summary) {
+ return null
+ }
return (
// The section never takes more than 40% of the pane, so the exception card keeps its room.
<div className="min-h-0 max-h-[40%] flex flex-col bg-surface-primary" data-attr="error-tracking-issue-summary">
- <div className="flex justify-between h-[2rem] items-center w-full px-2 border-b shrink-0 gap-2">
- <div className="flex items-center gap-1 text-lg h-full min-w-0">
- <IconLogomark />
- <span className="text-sm text-ai truncate">Summary</span>
- </div>
- {view === 'ready' && (
- <div className="flex items-center gap-0.5 shrink-0">
- <LemonButton
- size="xsmall"
- icon={<IconThumbsUp />}
- active={feedback === 'good'}
- disabledReason={feedback ? 'Thanks for the feedback' : undefined}
- tooltip="This summary is helpful"
- onClick={() => onFeedback('good')}
- data-attr="error-tracking-issue-summary-feedback-good"
- />
- <LemonButton
- size="xsmall"
- icon={<IconThumbsDown />}
- active={feedback === 'bad'}
- disabledReason={feedback ? 'Thanks for the feedback' : undefined}
- tooltip="This summary is wrong or not helpful"
- onClick={() => onFeedback('bad')}
- data-attr="error-tracking-issue-summary-feedback-bad"
- />
- </div>
- )}
- </div>
- {view === 'ready' && summary ? (
+ <IssuePaneSectionHeader
+ name="Summary"
+ open={open}
+ onToggle={onToggle}
+ preview={open ? null : summary.what_happened}
+ dataAttr="error-tracking-issue-summary-toggle"
+ trailing={
+ open ? (
+ <div className="flex items-center gap-0.5 shrink-0">
+ <LemonButton
+ size="xsmall"
+ icon={<IconThumbsUp />}
+ active={feedback === 'good'}
+ disabledReason={feedback ? 'Thanks for the feedback' : undefined}
+ tooltip="This summary is helpful"
+ onClick={() => onFeedback('good')}
+ data-attr="error-tracking-issue-summary-feedback-good"
+ />
+ <LemonButton
+ size="xsmall"
+ icon={<IconThumbsDown />}
+ active={feedback === 'bad'}
+ disabledReason={feedback ? 'Thanks for the feedback' : undefined}
+ tooltip="This summary is wrong or not helpful"
+ onClick={() => onFeedback('bad')}
+ data-attr="error-tracking-issue-summary-feedback-bad"
+ />
+ </div>
+ ) : null
+ }
+ />
+ {open ? (
<div className="@container min-h-0 overflow-y-auto">
<dl className="m-0">
<SummaryField icon={<IconBug />} label="What happened" emphasis>
@@ -122,33 +203,28 @@ export function IssueSummarySection({
Generated <TZLabel time={summary.generated_at} />
</div>
</div>
- ) : (
- <div className="flex items-center justify-between gap-2 px-2 py-1.5">
- <span className="text-sm text-secondary min-w-0">Couldn't load the summary.</span>
- <LemonButton
- size="xsmall"
- type="secondary"
- onClick={onRetry}
- data-attr="error-tracking-issue-summary-retry"
- >
- Try again
- </LemonButton>
- </div>
- )}
+ ) : null}
</div>
)
}
export function IssueSummary(): JSX.Element | null {
- const { issueId } = useValues(errorTrackingIssueSceneLogic)
- const logic = issueSummaryLogic({ issueId })
- const { view, summary, feedback } = useValues(logic)
+ const { issueId, issue } = useValues(errorTrackingIssueSceneLogic)
+ const logic = issueSummaryLogic({ issueId, firstSeen: issue?.first_seen ?? null })
+ const { view, summary, feedback, summaryResponseLoading } = useValues(logic)
const { loadSummary, sendFeedback } = useActions(logic)
+ const { summaryOpen } = useValues(issuePaneSectionsLogic)
+ const { setSummaryOpen } = useActions(issuePaneSectionsLogic)
+ const { isAdminOrOwner } = useValues(organizationLogic)
return (
<IssueSummarySection
view={view}
summary={summary}
feedback={feedback}
+ open={summaryOpen}
+ canManageAiSettings={!!isAdminOrOwner}
+ loading={summaryResponseLoading}
+ onToggle={() => setSummaryOpen(!summaryOpen)}
onRetry={loadSummary}
onFeedback={sendFeedback}
/>
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.stories.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.stories.tsx
index b05f971f1189..8cb96ab0a293 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.stories.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.stories.tsx
@@ -17,6 +17,8 @@ export default meta
type Story = StoryObj<typeof LinkedReportsSection>
+const noop = (): void => {}
+
function makeReport(overrides: Partial<SignalReportApi> = {}): SignalReportApi {
return {
id: '019f9582-93e7-77c1-8912-4f541d70cb13',
@@ -42,7 +44,7 @@ function Pane({ children }: { children: React.ReactNode }): JSX.Element {
export const FixProposed: Story = {
render: () => (
<Pane>
- <LinkedReportsSection reports={[makeReport()]} />
+ <LinkedReportsSection reports={[makeReport()]} open onToggle={noop} />
</Pane>
),
}
@@ -51,6 +53,8 @@ export const SeveralReportsAcrossStates: Story = {
render: () => (
<Pane>
<LinkedReportsSection
+ open
+ onToggle={noop}
reports={[
makeReport(),
makeReport({
@@ -88,6 +92,8 @@ export const ManyReports: Story = {
<div className="w-[700px] h-[400px] flex flex-col">
<div className="flex flex-col flex-1 min-h-0">
<LinkedReportsSection
+ open
+ onToggle={noop}
reports={Array.from({ length: 12 }, (_, index) =>
makeReport({
id: `019f9582-93e7-77c1-8912-4f541d70cb${String(index).padStart(2, '0')}`,
@@ -107,7 +113,19 @@ export const ManyReports: Story = {
export const NarrowPane: Story = {
render: () => (
<div className="w-[375px]">
- <LinkedReportsSection reports={[makeReport()]} />
+ <LinkedReportsSection reports={[makeReport()]} open onToggle={noop} />
</div>
),
}
+
+export const Closed: Story = {
+ render: () => (
+ <Pane>
+ <LinkedReportsSection
+ reports={[makeReport(), makeReport({ id: '019f954a-8ed0-7a18-a198-3ffed1a2def0' })]}
+ open={false}
+ onToggle={noop}
+ />
+ </Pane>
+ ),
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.tsx
index 7267c6b04ea5..08a12048ec10 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/LinkedReports.tsx
@@ -1,7 +1,6 @@
-import { useValues } from 'kea'
+import { useActions, useValues } from 'kea'
-import { IconLogomark } from '@posthog/icons'
-import { Link, Tooltip } from '@posthog/lemon-ui'
+import { LemonBadge, Link, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import { SignalReportFixOrStatus } from 'lib/signals/SignalReportFixOrStatus'
@@ -15,6 +14,8 @@ import {
} from 'products/signals/frontend/inbox/utils/reportPresentation'
import { errorTrackingIssueSceneLogic } from './errorTrackingIssueSceneLogic'
+import { IssuePaneSectionHeader } from './IssuePaneSectionHeader'
+import { issuePaneSectionsLogic } from './issuePaneSectionsLogic'
/**
* One report, as a row of the right pane.
@@ -48,17 +49,22 @@ function LinkedReportRow({ report }: { report: SignalReportApi }): JSX.Element {
)
}
+export interface LinkedReportsSectionProps {
+ reports: SignalReportApi[]
+ open: boolean
+ onToggle: () => void
+}
+
/**
* Reports the inbox grouped this issue's signals into, most recently updated first.
*
* This is a section of the right pane, not a card sitting on top of one, so it wears the pane's own
- * chrome: square corners, no outer border, and rows that run the full width. The name takes the AI
- * color, which is how the app marks the work its own software did.
+ * chrome: square corners, no outer border, and rows that run the full width.
*
* The section never takes more than half the pane. An issue the agent looked at many times would
* otherwise push the exception card, and with it the stack trace, off the bottom of the pane.
*/
-export function LinkedReportsSection({ reports }: { reports: SignalReportApi[] }): JSX.Element | null {
+export function LinkedReportsSection({ reports, open, onToggle }: LinkedReportsSectionProps): JSX.Element | null {
if (reports.length === 0) {
return null
}
@@ -66,22 +72,27 @@ export function LinkedReportsSection({ reports }: { reports: SignalReportApi[] }
// The pane paints no background of its own on desktop, so this section paints the same one the
// exception card below it paints. Without it the rows show the page behind the pane.
<div className="min-h-0 max-h-[50%] flex flex-col bg-surface-primary">
- <div className="flex justify-between h-[2rem] items-center w-full px-2 border-b shrink-0">
- <div className="flex items-center gap-1 text-lg h-full">
- <IconLogomark />
- <span className="text-sm text-ai">Self-driving</span>
- </div>
- <Tooltip title="A PostHog agent that investigates errors against your codebase. Not a teammate.">
- <span className="text-xs text-muted-alt">PostHog agent</span>
- </Tooltip>
- </div>
+ <IssuePaneSectionHeader
+ name="Self-driving"
+ open={open}
+ onToggle={onToggle}
+ preview={<LemonBadge.Number count={reports.length} status="muted" size="small" maxDigits={2} />}
+ dataAttr="error-tracking-issue-reports-toggle"
+ trailing={
+ <Tooltip title="A PostHog agent that investigates errors against your codebase. Not a teammate.">
+ <span className="shrink-0 text-xs text-muted-alt">PostHog agent</span>
+ </Tooltip>
+ }
+ />
{/* The header stays put while the rows scroll, so the section keeps its name once the list
is longer than the space it has. */}
- <div className="min-h-0 overflow-y-auto">
- {reports.map((report) => (
- <LinkedReportRow key={report.id} report={report} />
- ))}
- </div>
+ {open ? (
+ <div className="min-h-0 overflow-y-auto">
+ {reports.map((report) => (
+ <LinkedReportRow key={report.id} report={report} />
+ ))}
+ </div>
+ ) : null}
</div>
)
}
@@ -89,5 +100,13 @@ export function LinkedReportsSection({ reports }: { reports: SignalReportApi[] }
/** Renders nothing when the inbox never investigated this issue, which is the common case. */
export function LinkedReports(): JSX.Element | null {
const { linkedReports } = useValues(errorTrackingIssueSceneLogic)
- return <LinkedReportsSection reports={linkedReports} />
+ const { reportsOpen } = useValues(issuePaneSectionsLogic)
+ const { setReportsOpen } = useActions(issuePaneSectionsLogic)
+ return (
+ <LinkedReportsSection
+ reports={linkedReports}
+ open={reportsOpen}
+ onToggle={() => setReportsOpen(!reportsOpen)}
+ />
+ )
}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issuePaneSectionsLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issuePaneSectionsLogic.ts
new file mode 100644
index 000000000000..c2767dee27fd
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issuePaneSectionsLogic.ts
@@ -0,0 +1,33 @@
+import { MakeLogicType, actions, kea, path, reducers } from 'kea'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface issuePaneSectionsLogicValues {
+ reportsOpen: boolean
+ summaryOpen: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface issuePaneSectionsLogicActions {
+ setReportsOpen: (open: boolean) => {
+ open: boolean
+ }
+ setSummaryOpen: (open: boolean) => {
+ open: boolean
+ }
+}
+
+export type issuePaneSectionsLogicType = MakeLogicType<issuePaneSectionsLogicValues, issuePaneSectionsLogicActions>
+
+/** Which sections of the issue page's right pane are open. One choice per browser, kept across issues and projects. */
+export const issuePaneSectionsLogic = kea<issuePaneSectionsLogicType>([
+ // pinned: the path is the localStorage key of the persisted reducers, so renaming it resets everyone's choice
+ path(['products', 'error_tracking', 'scenes', 'ErrorTrackingIssueScene', 'issuePaneSectionsLogic']),
+ actions({
+ setSummaryOpen: (open: boolean) => ({ open }),
+ setReportsOpen: (open: boolean) => ({ open }),
+ }),
+ reducers({
+ summaryOpen: [false, { persist: true }, { setSummaryOpen: (_, { open }) => open }],
+ reportsOpen: [false, { persist: true }, { setReportsOpen: (_, { open }) => open }],
+ }),
+])
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.test.ts
index ec8dcb4a28cd..67f48e0859fe 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.test.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.test.ts
@@ -1,4 +1,5 @@
import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
import { initKeaTests } from '~/test/init'
@@ -7,6 +8,7 @@ import type {
ErrorTrackingStoredIssueSummaryApi,
ErrorTrackingIssueSummaryResponseApi,
} from '../../generated/api.schemas'
+import { issuePaneSectionsLogic } from './issuePaneSectionsLogic'
import { issueSummaryLogic } from './issueSummaryLogic'
jest.mock('../../generated/api')
@@ -25,6 +27,12 @@ const SUMMARY: ErrorTrackingStoredIssueSummaryApi = {
const READY: ErrorTrackingIssueSummaryResponseApi = { status: 'ready', summary: SUMMARY, reason: null }
const NOT_GENERATED: ErrorTrackingIssueSummaryResponseApi = { status: 'not_generated', summary: null, reason: null }
const UNAVAILABLE: ErrorTrackingIssueSummaryResponseApi = { status: 'unavailable', summary: null, reason: 'disabled' }
+const AI_NOT_APPROVED: ErrorTrackingIssueSummaryResponseApi = {
+ status: 'unavailable',
+ summary: null,
+ reason: 'ai_not_approved',
+}
+const RESTRICTED: ErrorTrackingIssueSummaryResponseApi = { status: 'unavailable', summary: null, reason: 'restricted' }
describe('issueSummaryLogic', () => {
const retrieve = jest.mocked(errorTrackingIssuesSummaryRetrieve)
@@ -32,11 +40,13 @@ describe('issueSummaryLogic', () => {
beforeEach(() => {
jest.useFakeTimers()
+ jest.setSystemTime(new Date('2026-11-04T12:00:00Z'))
initKeaTests()
})
afterEach(() => {
logic?.unmount()
+ localStorage.clear()
jest.useRealTimers()
jest.resetAllMocks()
})
@@ -46,31 +56,73 @@ describe('issueSummaryLogic', () => {
}
it.each([
- ['a summary is stored', READY, 'ready'],
- ['no summary is stored', NOT_GENERATED, 'hidden'],
- ['summaries are unavailable', UNAVAILABLE, 'hidden'],
- ])('reads once and never polls when %s', async (_name, response, view) => {
- retrieve.mockResolvedValue(response)
- logic = issueSummaryLogic({ issueId: ISSUE_ID })
- logic.mount()
+ ['a summary is stored', READY, null, 'ready'],
+ ['no summary is stored for an older issue', NOT_GENERATED, '2026-11-04T11:00:00Z', 'not_generated'],
+ ['no summary is stored yet for a new issue', NOT_GENERATED, '2026-11-04T11:59:00Z', 'writing'],
+ ['summaries are off for the project', UNAVAILABLE, null, 'hidden'],
+ ['the organization has not approved AI', AI_NOT_APPROVED, null, 'ai_not_approved'],
+ ['the person cannot read the summary sources', RESTRICTED, null, 'restricted'],
+ ])(
+ 'shows nothing before the answer, then reads once and never polls when %s',
+ async (_name, response, firstSeen, view) => {
+ retrieve.mockResolvedValue(response)
+ logic = issueSummaryLogic({ issueId: ISSUE_ID, firstSeen })
+ logic.mount()
+ expect(logic.values.view).toBe('hidden')
- await expectLogic(logic).toDispatchActions(['loadSummarySuccess']).toMatchValues({ view })
- await advance(60_000)
- expect(retrieve).toHaveBeenCalledTimes(1)
- })
+ await expectLogic(logic).toDispatchActions(['loadSummarySuccess']).toMatchValues({ view })
+ await advance(60_000)
+ expect(retrieve).toHaveBeenCalledTimes(1)
+ }
+ )
- it('shows a failed read and recovers on retry', async () => {
+ it('shows nothing when the first read fails, and recovers on retry', async () => {
retrieve.mockRejectedValueOnce(new Error('500')).mockResolvedValue(READY)
jest.spyOn(console, 'error').mockImplementation(() => {})
- logic = issueSummaryLogic({ issueId: ISSUE_ID })
+ logic = issueSummaryLogic({ issueId: ISSUE_ID, firstSeen: null })
logic.mount()
await advance(0)
- expect(logic.values.view).toBe('failed')
+ expect(logic.values.view).toBe('hidden')
expect(retrieve).toHaveBeenCalledTimes(1)
logic.actions.loadSummary()
await advance(0)
expect(logic.values.view).toBe('ready')
})
+
+ it('shows a failed check once an earlier read said summaries are on', async () => {
+ retrieve.mockResolvedValueOnce(NOT_GENERATED).mockRejectedValueOnce(new Error('500'))
+ jest.spyOn(console, 'error').mockImplementation(() => {})
+ logic = issueSummaryLogic({ issueId: ISSUE_ID, firstSeen: null })
+ logic.mount()
+
+ await advance(0)
+ expect(logic.values.view).toBe('not_generated')
+
+ logic.actions.loadSummary()
+ await advance(0)
+ expect(logic.values.view).toBe('failed')
+ })
+
+ it('reports whether the summary was open when viewed, and sends the rating', async () => {
+ const capture = jest.spyOn(posthog, 'capture')
+ retrieve.mockResolvedValue(READY)
+ issuePaneSectionsLogic.mount()
+ issuePaneSectionsLogic.actions.setSummaryOpen(true)
+ logic = issueSummaryLogic({ issueId: ISSUE_ID, firstSeen: null })
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadSummarySuccess'])
+ logic.actions.sendFeedback('bad')
+
+ expect(capture).toHaveBeenCalledWith(
+ 'error_tracking_issue_summary_viewed',
+ expect.objectContaining({ issue_id: ISSUE_ID, summary_open: true })
+ )
+ expect(capture).toHaveBeenCalledWith(
+ 'error_tracking_issue_summary_feedback',
+ expect.objectContaining({ issue_id: ISSUE_ID, feedback: 'bad', generated_at: SUMMARY.generated_at })
+ )
+ })
})
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.ts
index 220b6c10d593..537cbf7b09a5 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/issueSummaryLogic.ts
@@ -1,7 +1,8 @@
-import { MakeLogicType, actions, afterMount, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import posthog from 'posthog-js'
+import { dayjs } from 'lib/dayjs'
import { getCurrentTeamId } from 'lib/utils/getAppContext'
import { errorTrackingIssuesSummaryRetrieve } from '../../generated/api'
@@ -9,17 +10,31 @@ import type {
ErrorTrackingStoredIssueSummaryApi,
ErrorTrackingIssueSummaryResponseApi,
} from '../../generated/api.schemas'
+import { issuePaneSectionsLogic } from './issuePaneSectionsLogic'
export interface IssueSummaryLogicProps {
issueId: string
+ firstSeen: string | null
}
export type IssueSummaryFeedback = 'good' | 'bad'
-export type IssueSummaryView = 'hidden' | 'failed' | 'ready'
+export type IssueSummaryView =
+ | 'hidden'
+ | 'failed'
+ | 'ready'
+ | 'writing'
+ | 'not_generated'
+ | 'ai_not_approved'
+ | 'restricted'
+
+// The issue-created workflow writes the summary soon after the first exception. Until this much time has passed, a
+// missing summary is most likely still being written, not skipped.
+const SUMMARY_WRITE_WINDOW_MINUTES = 5
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface issueSummaryLogicValues {
+ summaryOpen: boolean // issuePaneSectionsLogic
feedback: IssueSummaryFeedback | null
loadFailed: boolean
summary: ErrorTrackingStoredIssueSummaryApi | null
@@ -60,7 +75,11 @@ export interface issueSummaryLogicMeta {
summary: (
summaryResponse: ErrorTrackingIssueSummaryResponseApi | null
) => ErrorTrackingStoredIssueSummaryApi | null
- view: (summary: ErrorTrackingStoredIssueSummaryApi | null, loadFailed: boolean) => IssueSummaryView
+ view: (
+ summaryResponse: ErrorTrackingIssueSummaryResponseApi | null,
+ loadFailed: boolean,
+ firstSeen: string | null
+ ) => IssueSummaryView
}
}
@@ -72,9 +91,10 @@ export type issueSummaryLogicType = MakeLogicType<
>
export const issueSummaryLogic = kea<issueSummaryLogicType>([
- props({} as IssueSummaryLogicProps),
+ props({ firstSeen: null } as IssueSummaryLogicProps),
key((props) => props.issueId),
path((key) => ['products', 'error_tracking', 'scenes', 'ErrorTrackingIssueScene', 'issueSummaryLogic', key]),
+ connect(() => ({ values: [issuePaneSectionsLogic, ['summaryOpen']] })),
actions({
markLoadFailed: true,
sendFeedback: (feedback: IssueSummaryFeedback) => ({ feedback }),
@@ -119,16 +139,31 @@ export const issueSummaryLogic = kea<issueSummaryLogicType>([
summaryResponse?.summary ?? null,
],
view: [
- (s) => [s.summary, s.loadFailed],
- (summary: ErrorTrackingStoredIssueSummaryApi | null, loadFailed: boolean): IssueSummaryView => {
- if (summary) {
+ (s, p) => [s.summaryResponse, s.loadFailed, p.firstSeen],
+ (
+ summaryResponse: ErrorTrackingIssueSummaryResponseApi | null,
+ loadFailed: boolean,
+ firstSeen: string | null
+ ): IssueSummaryView => {
+ if (summaryResponse?.summary) {
return 'ready'
}
if (loadFailed) {
- return 'failed'
+ // Only the backend knows whether summaries are on for the project. Until an answer says they are,
+ // a failure shows nothing, so a project without them never sees a summary row.
+ return summaryResponse !== null && summaryResponse.reason !== 'disabled' ? 'failed' : 'hidden'
+ }
+ if (summaryResponse?.status === 'not_generated') {
+ const isNew =
+ firstSeen !== null &&
+ dayjs().diff(dayjs(firstSeen), 'minute', true) < SUMMARY_WRITE_WINDOW_MINUTES
+ return isNew ? 'writing' : 'not_generated'
+ }
+ if (summaryResponse?.reason === 'ai_not_approved' || summaryResponse?.reason === 'restricted') {
+ return summaryResponse.reason
}
- // Before the first answer and when no summary is stored. Most teams do not have summaries,
- // so a placeholder here would flash on every issue page.
+ // Before the first answer, and when summaries are off for the project, which is most teams. A
+ // line here would flash on every issue page, or tell people about a feature they do not have.
return 'hidden'
},
],
@@ -140,6 +175,8 @@ export const issueSummaryLogic = kea<issueSummaryLogicType>([
cache.viewedGeneratedAt = summary.generated_at
posthog.capture('error_tracking_issue_summary_viewed', {
issue_id: props.issueId,
+ // A person can keep the summary closed, so the event alone does not mean they read it.
+ summary_open: values.summaryOpen,
category: summary.category,
model: summary.model,
generated_at: summary.generated_at,