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(signals): preserve scout deselection during setup reloads (#126147)

Georgiy Tarasov65ea0d6d55be
diff --git a/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts b/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts
index 8eb73c1f68ce..7fe86f463d44 100644
--- a/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts
@@ -742,7 +742,7 @@ describe('Inbox setup', () => {
}
)
- it.each(['product-analytics', 'general'])('offers %s and enables it only at activation', async (name) => {
+ it.each(['product-analytics', 'general'])('keeps %s scout edits during reloads until activation', async (name) => {
hasEvents = name === 'product-analytics'
const skillName = `signals-scout-${name}`
canonicalScouts = [{ ...mockScoutConfigs[0], skill_name: skillName, enabled: false }]
@@ -753,6 +753,27 @@ describe('Inbox setup', () => {
await expectLogic(logic, () => logic.actions.toggleSuggestion(suggestion!)).toFinishAllListeners()
expect(savedDraft?.suggestions).toEqual([suggestion])
expect(enabledScouts).toEqual([])
+ const selectedState: InboxOnboardingStateApi = { draft: savedDraft, completed_at: null }
+ let finishReload!: (state: InboxOnboardingStateApi) => void
+ jest.spyOn(signalsApi, 'signalsOnboardingList').mockImplementationOnce(
+ () =>
+ new Promise((resolve) => {
+ finishReload = resolve
+ })
+ )
+ logic.actions.loadSetup()
+ logic.actions.toggleSuggestion(suggestion!)
+ expect(logic.values.draft.suggestions).toEqual([])
+ finishReload(selectedState)
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.draft.suggestions).toEqual([])
+ expect(savedDraft?.suggestions).toEqual([])
+ logic.unmount()
+ logic = inboxSetupLogic()
+ logic.mount()
+ await expectLogic(logic, () => logic.actions.startSetup()).toFinishAllListeners()
+ expect(logic.values.draft.suggestions).toEqual([])
+ await expectLogic(logic, () => logic.actions.toggleSuggestion(suggestion!)).toFinishAllListeners()
await expectLogic(logic, () => logic.actions.goToStep('github')).toFinishAllListeners()
failCompletion = false
await expectLogic(logic, () => logic.actions.activate()).toFinishAllListeners()
diff --git a/products/signals/frontend/inbox/logics/inboxSetupLogic.ts b/products/signals/frontend/inbox/logics/inboxSetupLogic.ts
index 05966ba3e1de..a3a027ff468a 100644
--- a/products/signals/frontend/inbox/logics/inboxSetupLogic.ts
+++ b/products/signals/frontend/inbox/logics/inboxSetupLogic.ts
@@ -306,6 +306,7 @@ export interface inboxSetupLogicMeta {
) => InboxSetupSource[]
draft: (
editedDraft: InboxOnboardingDraftApi | null,
+ savedState: InboxOnboardingStateApi | null,
sources: InboxSetupSource[],
visionScanners: ReplayScannerApi[] | null,
scannerInventoryKnown: boolean,
@@ -454,7 +455,6 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([
null as InboxOnboardingDraftApi | null,
{
setEditedDraft: (_, { draft }) => draft,
- loadSetupSuccess: (_, { savedState }) => savedState.draft,
},
],
saving: [false, { setSaving: (_, { saving }) => saving }],
@@ -561,14 +561,16 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([
setupSources(configs ?? [], statuses, scanners?.length ?? 0, !!team?.ingested_event),
],
draft: [
- (s) => [s.editedDraft, s.sources, s.visionScanners, s.scannerInventoryKnown, s.featureFlags],
+ (s) => [s.editedDraft, s.savedState, s.sources, s.visionScanners, s.scannerInventoryKnown, s.featureFlags],
(
- draft: InboxOnboardingDraftApi | null,
+ editedDraft: InboxOnboardingDraftApi | null,
+ savedState: InboxOnboardingStateApi | null,
sources: InboxSetupSource[],
scanners: ReplayScannerApi[] | null,
scannerInventoryKnown: boolean,
flags: FeatureFlagsSet
): InboxOnboardingDraftApi => {
+ const draft = editedDraft ?? savedState?.draft
const reconciled = draft
? reconcileInboxSetupDraft(
draft,