: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(signals): spin only the scout button that started the task (#85751)
Andrew Maguired5945bfda66e
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton.test.tsxindex 56b48866e063..ed9e252a06bf 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton.test.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton.test.tsx@@ -6,6 +6,7 @@ import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'import { ScoutCreateButton } from './ScoutCreateButton'+import { ScoutsRosterActions } from './ScoutsRosterActions'import { ScoutSuggestButton } from './ScoutSuggestButton'jest.mock('lib/utils/accessControlUtils', () => ({@@ -80,6 +81,17 @@ describe('scout creation buttons', () => {expect(queryByText('Manual scout form')).toBeNull()})+ it('spins only the button that started the task', async () => {+ const { getByText } = render(<ScoutsRosterActions />)++ fireEvent.click(getByText('Suggest a scout'))++ // Both assertions read the same render, before the task resolves and clears the state.+ expect(getByText('Suggest a scout').closest('button')?.querySelector('.Spinner')).toBeTruthy()+ expect(getByText('Ask').closest('button')?.querySelector('.Spinner')).toBeNull()+ await waitFor(() => expect(startedChatTypes).toEqual(['author_scout']))+ })+it.each([['ScoutCreateButton', <ScoutCreateButton key="create" />, 'Create scout'],['ScoutSuggestButton', <ScoutSuggestButton key="suggest" />, 'Suggest a scout'],diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterActions.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterActions.tsxindex 2546eb433714..c90f325c0af4 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterActions.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterActions.tsx@@ -31,16 +31,30 @@ function AskAboutScoutsMenu(): JSX.Element {{ label: 'How is my scout troop performing?', chatType: 'fleet_overview' },{ label: 'What signals were emitted recently?', chatType: 'recent_signals' },]+ // Only spin for this menu's own prompts, so kicking off a task from a sibling button+ // doesn't make every scout CTA in the header look like it's loading.+ const isStarting = prompts.some(({ chatType }) => chatType === runningChatType)+ const anotherTaskIsStarting = runningChatType !== null && !isStartingreturn (<LemonMenuitems={prompts.map(({ label, chatType }) => ({label,onClick: () => startScoutChatTask(chatType, label),- disabledReason: runningChatType !== null ? 'Starting a task…' : (aiConsentDisabledReason ?? undefined),+ disabledReason: anotherTaskIsStarting+ ? 'Starting another task…'+ : isStarting+ ? 'Starting a task…'+ : (aiConsentDisabledReason ?? undefined),}))}>- <LemonButton type="secondary" size="small" icon={<IconSparkles />} loading={runningChatType !== null}>+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconSparkles />}+ loading={isStarting}+ disabledReason={anotherTaskIsStarting ? 'Starting another task…' : undefined}+ >Ask</LemonButton></LemonMenu>