Hide resume message when session has no messages

This commit is contained in:
Alexander Farber
2025-12-11 13:10:01 +01:00
parent b67ee32481
commit ba3b576906
2 changed files with 46 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats);
const renderWithMockedStats = ( const renderWithMockedStats = (
metrics: SessionMetrics, metrics: SessionMetrics,
sessionId: string = 'test-session-id-12345', sessionId: string = 'test-session-id-12345',
promptCount: number = 5,
) => { ) => {
useSessionStatsMock.mockReturnValue({ useSessionStatsMock.mockReturnValue({
stats: { stats: {
@@ -30,10 +31,10 @@ const renderWithMockedStats = (
sessionStartTime: new Date(), sessionStartTime: new Date(),
metrics, metrics,
lastPromptTokenCount: 0, lastPromptTokenCount: 0,
promptCount: 5, promptCount,
}, },
getPromptCount: () => 5, getPromptCount: () => promptCount,
startNewPrompt: vi.fn(), startNewPrompt: vi.fn(),
}); });
@@ -78,4 +79,34 @@ describe('<SessionSummaryDisplay />', () => {
expect(output).toContain('qwen --resume test-session-id-12345'); expect(output).toContain('qwen --resume test-session-id-12345');
expect(output).toMatchSnapshot(); expect(output).toMatchSnapshot();
}); });
it('does not show resume message when there are no messages', () => {
const metrics: SessionMetrics = {
models: {},
tools: {
totalCalls: 0,
totalSuccess: 0,
totalFail: 0,
totalDurationMs: 0,
totalDecisions: { accept: 0, reject: 0, modify: 0 },
byName: {},
},
files: {
totalLinesAdded: 0,
totalLinesRemoved: 0,
},
};
// Pass promptCount = 0 to simulate no messages
const { lastFrame } = renderWithMockedStats(
metrics,
'test-session-id-12345',
0,
);
const output = lastFrame();
expect(output).toContain('Agent powering down. Goodbye!');
expect(output).not.toContain('To continue this session, run');
expect(output).not.toContain('qwen --resume');
});
}); });

View File

@@ -20,18 +20,25 @@ export const SessionSummaryDisplay: React.FC<SessionSummaryDisplayProps> = ({
}) => { }) => {
const { stats } = useSessionStats(); const { stats } = useSessionStats();
// Only show the resume message if there were messages in the session
const hasMessages = stats.promptCount > 0;
return ( return (
<> <>
<StatsDisplay <StatsDisplay
title={t('Agent powering down. Goodbye!')} title={t('Agent powering down. Goodbye!')}
duration={duration} duration={duration}
/> />
<Box marginTop={1}> {hasMessages && (
<Text color={theme.text.secondary}> <Box marginTop={1}>
{t('To continue this session, run')}{' '} <Text color={theme.text.secondary}>
<Text color={theme.text.accent}>qwen --resume {stats.sessionId}</Text> {t('To continue this session, run')}{' '}
</Text> <Text color={theme.text.accent}>
</Box> qwen --resume {stats.sessionId}
</Text>
</Text>
</Box>
)}
</> </>
); );
}; };