From 439508eb157fee3383624eef87ce6d69fafd9916 Mon Sep 17 00:00:00 2001 From: srest2021 Date: Wed, 18 Nov 2026 14:56:44 -0800 Subject: [PATCH 1/7] fix(seer): End the thinking timer when an Autofix step stops for credits A step that stopped for credits mid-tool-call has no final answer once its error block is hidden, so its thinking block looked like it was still running: expanded, with the timer counting up. The card now ends the timer at the error block's timestamp, and the block collapses. Fixes CW-3108 --- .../autofix/v3/artifactLoadingDetails.tsx | 13 +++++++-- .../events/autofix/v3/autofixCards.spec.tsx | 29 +++++++++++++++++++ .../components/chat/responseGroup.spec.tsx | 21 ++++++++++++++ .../components/chat/responseGroup.tsx | 15 ++++++---- 4 files changed, 71 insertions(+), 7 deletions(-) diff --git a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx index 546040e1b760..ab5f8745479a 100644 --- a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx +++ b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx @@ -53,9 +53,13 @@ export function ArtifactPartialDetails({blocks}: {blocks: AutofixSection['blocks return null; } + // Seer adds its error block, filtered out above, as the last block when a run + // fails. Keep its timestamp so the timer ends when the run did. + const stoppedAt = blocks[blocks.length - 1]?.timestamp; + return ( - + ); } @@ -75,7 +79,11 @@ function useStepTranscript(blocks: AutofixSection['blocks']) { /** * A step's responses, the way the Seer Agent chat draws them. */ -function StepResponses({responses, latestTodos}: ReturnType) { +function StepResponses({ + responses, + latestTodos, + stoppedAt, +}: ReturnType & {stoppedAt?: string}) { return responses.map(segment => ( )); } diff --git a/static/app/components/events/autofix/v3/autofixCards.spec.tsx b/static/app/components/events/autofix/v3/autofixCards.spec.tsx index 10fe511e1b78..cfd59ef683d2 100644 --- a/static/app/components/events/autofix/v3/autofixCards.spec.tsx +++ b/static/app/components/events/autofix/v3/autofixCards.spec.tsx @@ -2832,6 +2832,35 @@ describe('out of credits', () => { }); }); + it('ends the timer when root cause stopped mid-tool-call', () => { + mockCreditCheck('autofix_root_cause', false); + render( + , + {organization} + ); + + expect( + screen.getByRole('button', {name: /See thinking and tool calls/}) + ).toHaveAttribute('aria-expanded', 'false'); + expect(screen.getByText('2m 30s')).toBeInTheDocument(); + }); + it('keeps what the plan step wrote and disables Re-run while out of credits', async () => { mockCreditCheck('autofix_solution', false); render( diff --git a/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx b/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx index a13fcee4b0da..2d42709df280 100644 --- a/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx +++ b/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx @@ -348,6 +348,27 @@ describe('ResponseGroup', () => { ); }); + it('ends the timer when the run stopped before answering', () => { + const group = [toolUseBlock('t1')]; + + const {container} = render( + , + {organization} + ); + + expect(reasoningBox(container).querySelector('button')).toHaveAttribute( + 'aria-expanded', + 'false' + ); + expect(screen.getByText('2m 30s')).toBeInTheDocument(); + }); + it('spins inside the box while a tool works', () => { const group = [toolUseBlock('t1', {loading: true})]; diff --git a/static/app/views/seerExplorer/components/chat/responseGroup.tsx b/static/app/views/seerExplorer/components/chat/responseGroup.tsx index 8d2e1a8d821b..e2e5dbebd5ce 100644 --- a/static/app/views/seerExplorer/components/chat/responseGroup.tsx +++ b/static/app/views/seerExplorer/components/chat/responseGroup.tsx @@ -153,6 +153,11 @@ interface ResponseGroupProps { readOnly?: boolean; runId?: SeerExplorerRunId; showThinking?: boolean; + /** + * When the run stopped, if the response stopped before answering. Ends the + * ThinkingBlock's timer, which otherwise waits for a settled answer. + */ + stoppedAt?: string; } /** @@ -190,6 +195,7 @@ export const ResponseGroup = memo(function ResponseGroup({ readOnly, runId, showThinking, + stoppedAt, }: ResponseGroupProps) { // `answer` identifies the block whose content is the visible response — used to exclude it // from the ThinkingBlock trace. `settledAnswer` is the same block once it has finished @@ -215,11 +221,10 @@ export const ResponseGroup = memo(function ResponseGroup({ const [startTime] = useState(() => new Date(group[0]!.timestamp)); // `settledAnswer` is the stable "response is done" signal. `block.loading` flickers false - // between tool calls, but answer settles once - const endTime = - !settledAnswer || pendingInput - ? undefined - : new Date(group[group.length - 1]!.timestamp); + // between tool calls, but answer settles once. + // If the response stopped before answering, end at `stoppedAt`, the timestamp of the last block. + const endTimestamp = settledAnswer ? group[group.length - 1]!.timestamp : stoppedAt; + const endTime = !endTimestamp || pendingInput ? undefined : new Date(endTimestamp); return ( From f81ee71dd93475cf73b8b7975b1bef37a5c2a082 Mon Sep 17 00:00:00 2001 From: srest2021 Date: Thu, 19 Nov 2026 10:53:22 -0800 Subject: [PATCH 2/7] fix(seer): End each response's timer when that response ended Only the last response in a stopped step ran until Seer's error block. An earlier one, for example one that asked the user a question, now ends at the user's next message instead. Renames ResponseGroup's stoppedAt prop to endedAt, since it is no longer always the stop. --- .../autofix/v3/artifactLoadingDetails.tsx | 30 ++++++----- .../events/autofix/v3/autofixCards.spec.tsx | 54 ++++++++++++++----- .../components/chat/responseGroup.spec.tsx | 14 ++--- .../components/chat/responseGroup.tsx | 13 ++--- 4 files changed, 69 insertions(+), 42 deletions(-) diff --git a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx index ab5f8745479a..c5fdba1c1f13 100644 --- a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx +++ b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx @@ -73,26 +73,32 @@ function useStepTranscript(blocks: AutofixSection['blocks']) { [blocks] ); const latestTodos = useMemo(() => findLatestTodos(blocks), [blocks]); - return {responses, latestTodos}; + return {blocks, responses, latestTodos}; } /** * A step's responses, the way the Seer Agent chat draws them. */ function StepResponses({ + blocks, responses, latestTodos, stoppedAt, }: ReturnType & {stoppedAt?: string}) { - return responses.map(segment => ( - - )); + return responses.map((segment, i) => { + const nextBlock = blocks[segment.indices.at(-1)! + 1]; + return ( + + ); + }); } diff --git a/static/app/components/events/autofix/v3/autofixCards.spec.tsx b/static/app/components/events/autofix/v3/autofixCards.spec.tsx index cfd59ef683d2..21cc87af6eea 100644 --- a/static/app/components/events/autofix/v3/autofixCards.spec.tsx +++ b/static/app/components/events/autofix/v3/autofixCards.spec.tsx @@ -2752,6 +2752,24 @@ describe('out of credits', () => { }; } + function makeToolUseBlock( + id: string, + content: string, + timestamp: string, + metadata?: Record + ): AutofixSection['blocks'][number] { + return { + id, + timestamp, + message: { + role: 'tool_use', + content, + tool_calls: [{id: `${id}-call`, function: 'telemetry_live_search', args: '{}'}], + metadata, + }, + }; + } + // Seer appends this when it stops a run for credits. const seerErrorBlock = makeBlock( 'error-1', @@ -2832,33 +2850,43 @@ describe('out of credits', () => { }); }); - it('ends the timer when root cause stopped mid-tool-call', () => { + it("ends each response's timer when root cause stopped mid-tool-call", () => { mockCreditCheck('autofix_root_cause', false); render( , {organization} ); - expect( - screen.getByRole('button', {name: /See thinking and tool calls/}) - ).toHaveAttribute('aria-expanded', 'false'); - expect(screen.getByText('2m 30s')).toBeInTheDocument(); + for (const button of screen.getAllByRole('button', { + name: /See thinking and tool calls/, + })) { + expect(button).toHaveAttribute('aria-expanded', 'false'); + } + // The earlier response ends at the user's message, the last one at Seer's error block. + expect(screen.getByText('20.0s')).toBeInTheDocument(); + expect(screen.getByText('2m 0s')).toBeInTheDocument(); }); it('keeps what the plan step wrote and disables Re-run while out of credits', async () => { diff --git a/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx b/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx index 2d42709df280..fe2fb362b1d5 100644 --- a/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx +++ b/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx @@ -348,25 +348,21 @@ describe('ResponseGroup', () => { ); }); - it('ends the timer when the run stopped before answering', () => { - const group = [toolUseBlock('t1')]; + it('ends the timer at the answer when the run stopped after it', () => { + const group = [toolUseBlock('t1'), assistantBlock('a1', 'Done')]; - const {container} = render( + render( , {organization} ); - expect(reasoningBox(container).querySelector('button')).toHaveAttribute( - 'aria-expanded', - 'false' - ); - expect(screen.getByText('2m 30s')).toBeInTheDocument(); + expect(screen.getByText('1m 0s')).toBeInTheDocument(); }); it('spins inside the box while a tool works', () => { diff --git a/static/app/views/seerExplorer/components/chat/responseGroup.tsx b/static/app/views/seerExplorer/components/chat/responseGroup.tsx index e2e5dbebd5ce..f98018ce7646 100644 --- a/static/app/views/seerExplorer/components/chat/responseGroup.tsx +++ b/static/app/views/seerExplorer/components/chat/responseGroup.tsx @@ -140,6 +140,8 @@ export function deriveThinkingTitle(group: Block[]): string { interface ResponseGroupProps { blockIndex: number; group: Block[]; + /** When the response ended, for one that ended without a settled answer. */ + endedAt?: string; getPageReferrer?: () => string; interactionPending?: boolean; /** The conversation's newest todo snapshot, from `findLatestTodos`. */ @@ -153,11 +155,6 @@ interface ResponseGroupProps { readOnly?: boolean; runId?: SeerExplorerRunId; showThinking?: boolean; - /** - * When the run stopped, if the response stopped before answering. Ends the - * ThinkingBlock's timer, which otherwise waits for a settled answer. - */ - stoppedAt?: string; } /** @@ -195,7 +192,7 @@ export const ResponseGroup = memo(function ResponseGroup({ readOnly, runId, showThinking, - stoppedAt, + endedAt, }: ResponseGroupProps) { // `answer` identifies the block whose content is the visible response — used to exclude it // from the ThinkingBlock trace. `settledAnswer` is the same block once it has finished @@ -222,8 +219,8 @@ export const ResponseGroup = memo(function ResponseGroup({ const [startTime] = useState(() => new Date(group[0]!.timestamp)); // `settledAnswer` is the stable "response is done" signal. `block.loading` flickers false // between tool calls, but answer settles once. - // If the response stopped before answering, end at `stoppedAt`, the timestamp of the last block. - const endTimestamp = settledAnswer ? group[group.length - 1]!.timestamp : stoppedAt; + // Without a settled answer, end at `endedAt` if the caller passed it. + const endTimestamp = settledAnswer ? group[group.length - 1]!.timestamp : endedAt; const endTime = !endTimestamp || pendingInput ? undefined : new Date(endTimestamp); return ( From dc41f4674a64deff99cf968bc136b17ac29a0f4d Mon Sep 17 00:00:00 2001 From: srest2021 Date: Thu, 19 Nov 2026 11:44:41 -0800 Subject: [PATCH 3/7] ref(seer): Check the segment's last index instead of asserting it --- .../components/events/autofix/v3/artifactLoadingDetails.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx index c5fdba1c1f13..e58ef397fb20 100644 --- a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx +++ b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx @@ -3,6 +3,7 @@ import {useMemo, useState} from 'react'; import {MessageRow, ThinkingBlock} from '@sentry/scraps/chat'; import {type AutofixSection} from 'sentry/components/events/autofix/useExplorerAutofix'; +import {defined} from 'sentry/utils/defined'; import { groupTranscript, ResponseGroup, @@ -86,7 +87,8 @@ function StepResponses({ stoppedAt, }: ReturnType & {stoppedAt?: string}) { return responses.map((segment, i) => { - const nextBlock = blocks[segment.indices.at(-1)! + 1]; + const lastIndex = segment.indices.at(-1); + const nextBlock = defined(lastIndex) ? blocks[lastIndex + 1] : undefined; return ( Date: Thu, 19 Nov 2026 13:20:14 -0800 Subject: [PATCH 4/7] fix(seer): End a response at the user message that follows it A response followed by a user message ended at Seer's error block when it was the step's last response, so a step that ran out of credits right after the user's message counted their time as Seer's. Every response now ends at the user message after it, or at the error block when nothing follows. Splits the tests into one case each, including a running step. --- .../autofix/v3/artifactLoadingDetails.tsx | 8 +- .../events/autofix/v3/autofixCards.spec.tsx | 148 ++++++++++++++---- 2 files changed, 122 insertions(+), 34 deletions(-) diff --git a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx index e58ef397fb20..039ff9732bd8 100644 --- a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx +++ b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx @@ -86,7 +86,7 @@ function StepResponses({ latestTodos, stoppedAt, }: ReturnType & {stoppedAt?: string}) { - return responses.map((segment, i) => { + return responses.map(segment => { const lastIndex = segment.indices.at(-1); const nextBlock = defined(lastIndex) ? blocks[lastIndex + 1] : undefined; return ( @@ -97,9 +97,9 @@ function StepResponses({ latestTodos={latestTodos} readOnly showThinking - // The timestamp of Seer's error block for the last segment, or of the user - // message that ended an earlier one. - endedAt={i === responses.length - 1 ? stoppedAt : nextBlock?.timestamp} + // The timestamp of the user message that ended the segment or, when nothing + // follows it, of Seer's error block. + endedAt={nextBlock?.timestamp ?? stoppedAt} /> ); }); diff --git a/static/app/components/events/autofix/v3/autofixCards.spec.tsx b/static/app/components/events/autofix/v3/autofixCards.spec.tsx index 21cc87af6eea..9ffd2a274bce 100644 --- a/static/app/components/events/autofix/v3/autofixCards.spec.tsx +++ b/static/app/components/events/autofix/v3/autofixCards.spec.tsx @@ -92,6 +92,32 @@ function makePrIterationBlock( }; } +function makeToolUseBlock( + id: string, + content: string, + timestamp: string, + metadata?: Record +): AutofixSection['blocks'][number] { + return { + id, + timestamp, + message: { + role: 'tool_use', + content, + tool_calls: [{id: `${id}-call`, function: 'telemetry_live_search', args: '{}'}], + metadata, + }, + }; +} + +function makeUserBlock( + id: string, + content: string, + timestamp: string +): AutofixSection['blocks'][number] { + return {id, timestamp, message: {role: 'user', content}}; +} + function makePatch(repoName: string, path: string): ExplorerFilePatch { return { repo_name: repoName, @@ -341,6 +367,47 @@ describe('ArtifactCard', () => { expect(screen.queryByText('Thinking...')).not.toBeInTheDocument(); }); + it("ends a running step's response at the user's message and keeps the next one running", () => { + render( + + ); + + expect(screen.getByText('20.0s')).toBeInTheDocument(); + // Only the replied-to response collapses to its summary. + expect( + screen.getAllByRole('button', {name: /See thinking and tool calls/}) + ).toHaveLength(1); + }); + it('starts a new single run from Re-run', async () => { const startStepMock = jest.fn().mockResolvedValue({runId: 777, isSingleRun: true}); render( @@ -2752,24 +2819,6 @@ describe('out of credits', () => { }; } - function makeToolUseBlock( - id: string, - content: string, - timestamp: string, - metadata?: Record - ): AutofixSection['blocks'][number] { - return { - id, - timestamp, - message: { - role: 'tool_use', - content, - tool_calls: [{id: `${id}-call`, function: 'telemetry_live_search', args: '{}'}], - metadata, - }, - }; - } - // Seer appends this when it stops a run for credits. const seerErrorBlock = makeBlock( 'error-1', @@ -2850,7 +2899,7 @@ describe('out of credits', () => { }); }); - it("ends each response's timer when root cause stopped mid-tool-call", () => { + it("ends the timer at Seer's error block when root cause stopped mid-tool-call", () => { mockCreditCheck('autofix_root_cause', false); render( { section={makeOutOfCreditsSection('root_cause', [ makeToolUseBlock( 'block-1', - 'Asking which repo to use.', + 'Reading the cache module.', + '2026-01-01T00:00:00Z', + {step: 'root_cause'} + ), + {...seerErrorBlock, timestamp: '2026-01-01T00:02:30Z'}, + ])} + />, + {organization} + ); + + expect( + screen.getByRole('button', {name: /See thinking and tool calls/}) + ).toHaveAttribute('aria-expanded', 'false'); + expect(screen.getByText('2m 30s')).toBeInTheDocument(); + }); + + it('ends each response at what follows it when root cause stopped', () => { + mockCreditCheck('autofix_root_cause', false); + render( + { {organization} ); - for (const button of screen.getAllByRole('button', { - name: /See thinking and tool calls/, - })) { - expect(button).toHaveAttribute('aria-expanded', 'false'); - } // The earlier response ends at the user's message, the last one at Seer's error block. expect(screen.getByText('20.0s')).toBeInTheDocument(); expect(screen.getByText('2m 0s')).toBeInTheDocument(); }); + it("ends the timer at the user's message when root cause stopped right after it", () => { + mockCreditCheck('autofix_root_cause', false); + render( + , + {organization} + ); + + expect(screen.getByText('20.0s')).toBeInTheDocument(); + }); + it('keeps what the plan step wrote and disables Re-run while out of credits', async () => { mockCreditCheck('autofix_solution', false); render( From 306ce0ebe7734c09a1a3ec790ea81029281ccbd4 Mon Sep 17 00:00:00 2001 From: srest2021 Date: Fri, 20 Nov 2026 11:43:10 -0800 Subject: [PATCH 5/7] fix(seer): Keep earlier error blocks in a stopped step's transcript The card hid every Seer error block, not just the one it stopped at. In a single run, where a reply follows a failure without cutting it, the response before an earlier error then ran until the user's reply. Only the trailing error block is hidden now, so an earlier one stays as its response's answer. Each response ends at the next block in the full list, which drops stoppedAt. Adds tests for earlier error and credit-stop blocks, a step that doesn't end in an error block, the plan card and a stopped PR iteration, and moves the timing tests to 5-second steps. --- .../autofix/v3/artifactLoadingDetails.tsx | 38 ++-- .../events/autofix/v3/autofixCards.spec.tsx | 194 ++++++++++++++++-- .../components/chat/responseGroup.spec.tsx | 9 +- 3 files changed, 197 insertions(+), 44 deletions(-) diff --git a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx index 039ff9732bd8..1678ab8506e7 100644 --- a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx +++ b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx @@ -28,7 +28,7 @@ export function ArtifactLoadingDetails({ return ( {transcript.responses.length ? ( - + ) : ( @@ -44,23 +44,21 @@ export function ArtifactLoadingDetails({ * stopped. */ export function ArtifactPartialDetails({blocks}: {blocks: AutofixSection['blocks']}) { - const partialBlocks = useMemo( - () => blocks.filter(block => !isSeerErrorBlock(block)), - [blocks] - ); + const partialBlocks = useMemo(() => { + const lastBlock = blocks.at(-1); + return defined(lastBlock) && isSeerErrorBlock(lastBlock) + ? blocks.slice(0, -1) + : blocks; + }, [blocks]); const transcript = useStepTranscript(partialBlocks); if (!transcript.responses.length) { return null; } - // Seer adds its error block, filtered out above, as the last block when a run - // fails. Keep its timestamp so the timer ends when the run did. - const stoppedAt = blocks[blocks.length - 1]?.timestamp; - return ( - + ); } @@ -74,21 +72,23 @@ function useStepTranscript(blocks: AutofixSection['blocks']) { [blocks] ); const latestTodos = useMemo(() => findLatestTodos(blocks), [blocks]); - return {blocks, responses, latestTodos}; + return {responses, latestTodos}; } /** - * A step's responses, the way the Seer Agent chat draws them. + * A step's responses, the way the Seer Agent chat draws them. `blocks` is the + * step's full list, including the error block left out of `responses`. */ function StepResponses({ blocks, responses, latestTodos, - stoppedAt, -}: ReturnType & {stoppedAt?: string}) { +}: ReturnType & {blocks: AutofixSection['blocks']}) { return responses.map(segment => { - const lastIndex = segment.indices.at(-1); - const nextBlock = defined(lastIndex) ? blocks[lastIndex + 1] : undefined; + const lastBlock = segment.blocks.at(-1); + const nextBlock = defined(lastBlock) + ? blocks[blocks.indexOf(lastBlock) + 1] + : undefined; return ( ); }); diff --git a/static/app/components/events/autofix/v3/autofixCards.spec.tsx b/static/app/components/events/autofix/v3/autofixCards.spec.tsx index 9ffd2a274bce..d72c23ff165f 100644 --- a/static/app/components/events/autofix/v3/autofixCards.spec.tsx +++ b/static/app/components/events/autofix/v3/autofixCards.spec.tsx @@ -380,19 +380,19 @@ describe('ArtifactCard', () => { makeToolUseBlock( 'block-1', 'Reading the cache module.', - '2026-01-01T00:00:05Z', + '2026-01-01T00:00:00Z', {step: 'root_cause'} ), makeUserBlock( 'user-1', 'Also check the retry path.', - '2026-01-01T00:00:25Z' + '2026-01-01T00:00:05Z' ), { ...makeToolUseBlock( 'block-2', 'Reading the retry module.', - '2026-01-01T00:00:30Z' + '2026-01-01T00:00:10Z' ), loading: true, }, @@ -401,7 +401,7 @@ describe('ArtifactCard', () => { /> ); - expect(screen.getByText('20.0s')).toBeInTheDocument(); + expect(screen.getByText('5.0s')).toBeInTheDocument(); // Only the replied-to response collapses to its summary. expect( screen.getAllByRole('button', {name: /See thinking and tool calls/}) @@ -2899,7 +2899,47 @@ describe('out of credits', () => { }); }); - it("ends the timer at Seer's error block when root cause stopped mid-tool-call", () => { + it('ends each response at what follows it when root cause stopped', () => { + mockCreditCheck('autofix_root_cause', false); + render( + , + {organization} + ); + + // The earlier response ends at the user's message, the last one at Seer's error block. + expect(screen.getByText('5.0s')).toBeInTheDocument(); + expect(screen.getByText('10.0s')).toBeInTheDocument(); + for (const button of screen.getAllByRole('button', { + name: /See thinking and tool calls/, + })) { + expect(button).toHaveAttribute('aria-expanded', 'false'); + } + }); + + it("ends the timer at the user's message when root cause stopped right after it", () => { mockCreditCheck('autofix_root_cause', false); render( { '2026-01-01T00:00:00Z', {step: 'root_cause'} ), - {...seerErrorBlock, timestamp: '2026-01-01T00:02:30Z'}, + makeUserBlock('user-1', 'Also check the retry path.', '2026-01-01T00:00:05Z'), + {...seerErrorBlock, timestamp: '2026-01-01T00:00:10Z'}, + ])} + />, + {organization} + ); + + expect(screen.getByText('5.0s')).toBeInTheDocument(); + }); + + it("keeps an earlier error block as its response's answer when root cause stopped", () => { + mockCreditCheck('autofix_root_cause', false); + render( + , {organization} ); expect( - screen.getByRole('button', {name: /See thinking and tool calls/}) - ).toHaveAttribute('aria-expanded', 'false'); - expect(screen.getByText('2m 30s')).toBeInTheDocument(); + screen.getByText('Sorry, I encountered an unexpected error.') + ).toBeInTheDocument(); + // The earlier response ends at its error, not at the user's message after it. + expect(screen.getByText('5.0s')).toBeInTheDocument(); }); - it('ends each response at what follows it when root cause stopped', () => { + it("keeps an earlier credit stop as its response's answer when root cause stopped again", () => { mockCreditCheck('autofix_root_cause', false); render( { makeToolUseBlock( 'block-1', 'Reading the cache module.', - '2026-01-01T00:00:05Z', + '2026-01-01T00:00:00Z', {step: 'root_cause'} ), - makeUserBlock('user-1', 'Also check the retry path.', '2026-01-01T00:00:25Z'), + { + ...seerErrorBlock, + id: 'error-out-of-credits-0', + timestamp: '2026-01-01T00:00:05Z', + }, + makeUserBlock('user-1', 'Added credits, go on.', '2026-01-01T00:00:10Z'), makeToolUseBlock( 'block-2', 'Searching for the cache key.', - '2026-01-01T00:00:30Z' + '2026-01-01T00:00:15Z' ), - {...seerErrorBlock, timestamp: '2026-01-01T00:02:30Z'}, + { + ...seerErrorBlock, + id: 'error-out-of-credits-1', + timestamp: '2026-01-01T00:00:20Z', + }, ])} />, {organization} ); - // The earlier response ends at the user's message, the last one at Seer's error block. - expect(screen.getByText('20.0s')).toBeInTheDocument(); - expect(screen.getByText('2m 0s')).toBeInTheDocument(); + // The earlier stop's message stays, the one the card's stop line explains doesn't. + expect(screen.getAllByText(/so I stopped here/)).toHaveLength(1); }); - it("ends the timer at the user's message when root cause stopped right after it", () => { + it("hides no block when the step's last block isn't Seer's error block", () => { mockCreditCheck('autofix_root_cause', false); render( { makeToolUseBlock( 'block-1', 'Reading the cache module.', - '2026-01-01T00:00:05Z', + '2026-01-01T00:00:00Z', {step: 'root_cause'} ), - makeUserBlock('user-1', 'Also check the retry path.', '2026-01-01T00:00:25Z'), - {...seerErrorBlock, timestamp: '2026-01-01T00:02:30Z'}, + { + ...makeBlock('error-0', 'Sorry, I encountered an unexpected error.'), + timestamp: '2026-01-01T00:00:05Z', + }, + makeUserBlock('user-1', 'Try again.', '2026-01-01T00:00:10Z'), + { + ...makeBlock('block-2', 'The cache key omits the org slug.'), + timestamp: '2026-01-01T00:00:15Z', + }, + ])} + />, + {organization} + ); + + expect( + screen.getByText('Sorry, I encountered an unexpected error.') + ).toBeInTheDocument(); + expect(screen.getByText('The cache key omits the org slug.')).toBeInTheDocument(); + }); + + it("ends the timer at Seer's error block when the plan stopped", () => { + mockCreditCheck('autofix_solution', false); + render( + , {organization} ); - expect(screen.getByText('20.0s')).toBeInTheDocument(); + expect(screen.getByText('5.0s')).toBeInTheDocument(); + }); + + it("ends the timer at Seer's error block when a PR iteration stopped", () => { + mockCreditCheck('autofix_pr_iteration', false); + render( + , + {organization} + ); + + expect(screen.getByText('5.0s')).toBeInTheDocument(); + expect( + screen.getByRole('button', {name: /See thinking and tool calls/}) + ).toHaveAttribute('aria-expanded', 'false'); }); it('keeps what the plan step wrote and disables Re-run while out of credits', async () => { diff --git a/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx b/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx index fe2fb362b1d5..6cd6506fedc6 100644 --- a/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx +++ b/static/app/views/seerExplorer/components/chat/responseGroup.spec.tsx @@ -349,7 +349,10 @@ describe('ResponseGroup', () => { }); it('ends the timer at the answer when the run stopped after it', () => { - const group = [toolUseBlock('t1'), assistantBlock('a1', 'Done')]; + const group = [ + {...toolUseBlock('t1'), timestamp: '2024-01-01T00:00:00Z'}, + {...assistantBlock('a1', 'Done'), timestamp: '2024-01-01T00:00:05Z'}, + ]; render( { blockIndex={1} latestTodos={findLatestTodos(group)} showThinking - endedAt="2024-01-01T00:05:00Z" + endedAt="2024-01-01T00:00:10Z" />, {organization} ); - expect(screen.getByText('1m 0s')).toBeInTheDocument(); + expect(screen.getByText('5.0s')).toBeInTheDocument(); }); it('spins inside the box while a tool works', () => { From 24f5b34606beb624f34bdff904f0eed434f91ea6 Mon Sep 17 00:00:00 2001 From: srest2021 Date: Fri, 20 Nov 2026 12:09:38 -0800 Subject: [PATCH 6/7] fix(seer): Hide every error block in a stopped step again Showing earlier error blocks read as Seer repeating itself, since the card doesn't draw the user's replies between them. The card hides every Seer error block again, as before. Timers stay right, because each response ends at the next block in the full list, hidden or not. Groups the transcript tests, drops the two that only applied to showing earlier error blocks and renames the rest. --- .../autofix/v3/artifactLoadingDetails.tsx | 12 +- .../events/autofix/v3/autofixCards.spec.tsx | 361 +++++++----------- .../components/chat/responseGroup.spec.tsx | 2 +- 3 files changed, 152 insertions(+), 223 deletions(-) diff --git a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx index 1678ab8506e7..95030df2f320 100644 --- a/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx +++ b/static/app/components/events/autofix/v3/artifactLoadingDetails.tsx @@ -44,12 +44,10 @@ export function ArtifactLoadingDetails({ * stopped. */ export function ArtifactPartialDetails({blocks}: {blocks: AutofixSection['blocks']}) { - const partialBlocks = useMemo(() => { - const lastBlock = blocks.at(-1); - return defined(lastBlock) && isSeerErrorBlock(lastBlock) - ? blocks.slice(0, -1) - : blocks; - }, [blocks]); + const partialBlocks = useMemo( + () => blocks.filter(block => !isSeerErrorBlock(block)), + [blocks] + ); const transcript = useStepTranscript(partialBlocks); if (!transcript.responses.length) { @@ -77,7 +75,7 @@ function useStepTranscript(blocks: AutofixSection['blocks']) { /** * A step's responses, the way the Seer Agent chat draws them. `blocks` is the - * step's full list, including the error block left out of `responses`. + * step's full list, including the error blocks left out of `responses`. */ function StepResponses({ blocks, diff --git a/static/app/components/events/autofix/v3/autofixCards.spec.tsx b/static/app/components/events/autofix/v3/autofixCards.spec.tsx index d72c23ff165f..1b3458ca18d9 100644 --- a/static/app/components/events/autofix/v3/autofixCards.spec.tsx +++ b/static/app/components/events/autofix/v3/autofixCards.spec.tsx @@ -367,7 +367,7 @@ describe('ArtifactCard', () => { expect(screen.queryByText('Thinking...')).not.toBeInTheDocument(); }); - it("ends a running step's response at the user's message and keeps the next one running", () => { + it("ends a response at the user's message while root cause is still running", () => { render( { }); }); - it('ends each response at what follows it when root cause stopped', () => { - mockCreditCheck('autofix_root_cause', false); - render( - , - {organization} - ); - - // The earlier response ends at the user's message, the last one at Seer's error block. - expect(screen.getByText('5.0s')).toBeInTheDocument(); - expect(screen.getByText('10.0s')).toBeInTheDocument(); - for (const button of screen.getAllByRole('button', { - name: /See thinking and tool calls/, - })) { - expect(button).toHaveAttribute('aria-expanded', 'false'); - } - }); - - it("ends the timer at the user's message when root cause stopped right after it", () => { - mockCreditCheck('autofix_root_cause', false); - render( - , - {organization} - ); - - expect(screen.getByText('5.0s')).toBeInTheDocument(); - }); - - it("keeps an earlier error block as its response's answer when root cause stopped", () => { - mockCreditCheck('autofix_root_cause', false); - render( - , - {organization} - ); + describe("a stopped step's transcript", () => { + it("ends the timer at Seer's error block when a PR iteration stopped", () => { + mockCreditCheck('autofix_pr_iteration', false); + render( + , + {organization} + ); - expect( - screen.getByText('Sorry, I encountered an unexpected error.') - ).toBeInTheDocument(); - // The earlier response ends at its error, not at the user's message after it. - expect(screen.getByText('5.0s')).toBeInTheDocument(); - }); + expect(screen.getByText('5.0s')).toBeInTheDocument(); + expect( + screen.getByRole('button', {name: /See thinking and tool calls/}) + ).toHaveAttribute('aria-expanded', 'false'); + }); - it("keeps an earlier credit stop as its response's answer when root cause stopped again", () => { - mockCreditCheck('autofix_root_cause', false); - render( - , - {organization} - ); + it("ends the timer at Seer's error block when the plan stopped", () => { + mockCreditCheck('autofix_solution', false); + render( + , + {organization} + ); - // The earlier stop's message stays, the one the card's stop line explains doesn't. - expect(screen.getAllByText(/so I stopped here/)).toHaveLength(1); - }); + expect(screen.getByText('5.0s')).toBeInTheDocument(); + }); - it("hides no block when the step's last block isn't Seer's error block", () => { - mockCreditCheck('autofix_root_cause', false); - render( - , - {organization} - ); + it("ends the timer at the user's message when root cause stopped right after it", () => { + mockCreditCheck('autofix_root_cause', false); + render( + , + {organization} + ); - expect( - screen.getByText('Sorry, I encountered an unexpected error.') - ).toBeInTheDocument(); - expect(screen.getByText('The cache key omits the org slug.')).toBeInTheDocument(); - }); + expect(screen.getByText('5.0s')).toBeInTheDocument(); + }); - it("ends the timer at Seer's error block when the plan stopped", () => { - mockCreditCheck('autofix_solution', false); - render( - , - {organization} - ); + it('ends each response at the block after it when root cause stopped', () => { + mockCreditCheck('autofix_root_cause', false); + render( + , + {organization} + ); - expect(screen.getByText('5.0s')).toBeInTheDocument(); - }); + // The earlier response ends at the user's message, the last one at Seer's error block. + expect(screen.getByText('5.0s')).toBeInTheDocument(); + expect(screen.getByText('10.0s')).toBeInTheDocument(); + for (const button of screen.getAllByRole('button', { + name: /See thinking and tool calls/, + })) { + expect(button).toHaveAttribute('aria-expanded', 'false'); + } + }); - it("ends the timer at Seer's error block when a PR iteration stopped", () => { - mockCreditCheck('autofix_pr_iteration', false); - render( -