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(today): keep the briefing badge steady after refresh and poll every 5s (#110538)

Vojta Bartoš1acf9bb8975d
diff --git a/frontend/src/scenes/project-homepage/today/todayLogic.test.ts b/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
index 97359085353f..e1294c24dea6 100644
--- a/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
+++ b/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
@@ -66,6 +66,12 @@ describe('todayLogic', () => {
return briefingResponses.length > 1 ? briefingResponses.shift()! : briefingResponses[0]
},
},
+ post: {
+ '/api/projects/:team_id/today/briefing/refresh/': () => [
+ 200,
+ makeBriefing({ id: 'b-next', status: 'writing' }),
+ ],
+ },
})
initKeaTests()
})
@@ -116,6 +122,27 @@ describe('todayLogic', () => {
expect(briefingCalls).toBe(2)
})
+ it('keeps waiting from the refresh click until the reloaded briefing says it is written', async () => {
+ const shown = makeBriefing()
+ briefingResponses = [
+ [200, shown],
+ [200, { ...shown, status: 'writing' }],
+ ]
+ const logic = todayLogic()
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadPersonalBriefingSuccess']).toMatchValues({
+ briefingWaiting: false,
+ })
+
+ await expectLogic(logic, () => {
+ logic.actions.refreshBriefing()
+ })
+ .toDispatchActions(['refreshBriefing', 'refreshBriefingSuccess'])
+ .toMatchValues({ briefingWaiting: true })
+ .toDispatchActions(['loadPersonalBriefing', 'loadPersonalBriefingSuccess'])
+ .toMatchValues({ briefingWaiting: true })
+ })
+
it.each([
['crosses 8:00', new Date(2026, 8, 30, 7, 59, 45), null],
['sleeps from one afternoon to the next', new Date(2026, 8, 30, 14, 0, 0), new Date(2026, 9, 1, 14, 0, 0)],
diff --git a/frontend/src/scenes/project-homepage/today/todayLogic.ts b/frontend/src/scenes/project-homepage/today/todayLogic.ts
index b29bccf546b3..576291b76259 100644
--- a/frontend/src/scenes/project-homepage/today/todayLogic.ts
+++ b/frontend/src/scenes/project-homepage/today/todayLogic.ts
@@ -36,9 +36,9 @@ import { TodayBriefingSegment, briefingForReports, teamReportCard } from './toda
export const TOP_REPORT_COUNT = 5
const CLOCK_MS = 30_000
-export const BRIEFING_POLL_MS = 10_000
+export const BRIEFING_POLL_MS = 5_000
// The run's budget is 10 minutes (RUN_TIMEOUT in logic/generate.py). Stop asking a little after that.
-const MAX_BRIEFING_POLLS = 66
+const MAX_BRIEFING_POLLS = 132
/** Where a report was opened from, sent with the `today report opened` event. */
export type TodayReportOpenSource = 'briefing' | 'chip' | 'sidebar'
@@ -128,6 +128,7 @@ export interface todayLogicValues {
personalBriefingLoading: boolean
refreshedBriefing: BriefingApi | null
refreshedBriefingLoading: boolean
+ reloadingAfterRefresh: boolean
reportId: string | null
reportPreviews: Record<TodayReportPreview['surface'], Record<string, TodayReportPreview>>
reportSummary: string
@@ -289,7 +290,8 @@ export interface todayLogicMeta {
briefingWaiting: (
personalBriefing: BriefingApi | null,
gaveUpWaitingFor: string | null,
- refreshedBriefingLoading: boolean
+ refreshedBriefingLoading: boolean,
+ reloadingAfterRefresh: boolean
) => boolean
}
}
@@ -426,6 +428,16 @@ export const todayLogic = kea<todayLogicType>([
stopWaitingForBriefing: () => 0,
},
],
+ // The refresh call returns before the page reloads the briefing. Until that reload returns
+ // the `writing` briefing, the page still waits, so the badge does not flip back to the button.
+ reloadingAfterRefresh: [
+ false,
+ {
+ refreshBriefingSuccess: () => true,
+ loadPersonalBriefingSuccess: () => false,
+ loadPersonalBriefingFailure: () => false,
+ },
+ ],
}),
selectors({
reportId: [
@@ -507,13 +519,15 @@ export const todayLogic = kea<todayLogicType>([
// While a newer briefing is written, the server returns the shown one as `writing`, so the
// text stays on screen and the page keeps asking until the new one is ready.
briefingWaiting: [
- (s) => [s.personalBriefing, s.gaveUpWaitingFor, s.refreshedBriefingLoading],
+ (s) => [s.personalBriefing, s.gaveUpWaitingFor, s.refreshedBriefingLoading, s.reloadingAfterRefresh],
(
personalBriefing: BriefingApi | null,
gaveUpWaitingFor: string | null,
- refreshedBriefingLoading: boolean
+ refreshedBriefingLoading: boolean,
+ reloadingAfterRefresh: boolean
): boolean =>
refreshedBriefingLoading ||
+ reloadingAfterRefresh ||
(!!personalBriefing &&
personalBriefing.id !== gaveUpWaitingFor &&
!isBriefingSettled(personalBriefing)),