fix(cli): clear stale retry/loading state after cancellation (#21096) (#21960)

Co-authored-by: Aashir Javed <Aaxhirrr@users.noreply.github.com>
Co-authored-by: Dev Randalpura <devrandalpura@google.com>
This commit is contained in:
Aashir Javed
2026-04-02 12:44:39 -07:00
committed by GitHub
parent c0dfa1aec3
commit 77027dff82
8 changed files with 194 additions and 35 deletions

View File

@@ -63,6 +63,17 @@ describe('<LoadingIndicator />', () => {
expect(lastFrame({ allowEmpty: true })?.trim()).toBe('');
});
it('should not show cancel and timer when idle even if a phrase exists', async () => {
const { lastFrame, waitUntilReady } = await renderWithContext(
<LoadingIndicator currentLoadingPhrase="Retrying..." elapsedTime={5} />,
StreamingState.Idle,
);
await waitUntilReady();
const output = lastFrame();
expect(output).toContain('Retrying...');
expect(output).not.toContain('(esc to cancel');
});
it('should render spinner, phrase, and time when streamingState is Responding', async () => {
const { lastFrame, waitUntilReady } = await renderWithContext(
<LoadingIndicator {...defaultProps} />,

View File

@@ -72,8 +72,7 @@ export const LoadingIndicator: React.FC<LoadingIndicatorProps> = ({
: undefined);
const cancelAndTimerContent =
showCancelAndTimer &&
streamingState !== StreamingState.WaitingForConfirmation
showCancelAndTimer && streamingState === StreamingState.Responding
? `(esc to cancel, ${elapsedTime < 60 ? `${elapsedTime}s` : formatDuration(elapsedTime * 1000)})`
: null;