mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Merge pull request #1219 from afarber/1181-resume-session-id
feat: show session resume command on exit
This commit is contained in:
@@ -867,6 +867,7 @@ export default {
|
|||||||
// Exit Screen / Stats
|
// Exit Screen / Stats
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
'Agent powering down. Goodbye!': 'Agent powering down. Goodbye!',
|
'Agent powering down. Goodbye!': 'Agent powering down. Goodbye!',
|
||||||
|
'To continue this session, run': 'To continue this session, run',
|
||||||
'Interaction Summary': 'Interaction Summary',
|
'Interaction Summary': 'Interaction Summary',
|
||||||
'Session ID:': 'Session ID:',
|
'Session ID:': 'Session ID:',
|
||||||
'Tool Calls:': 'Tool Calls:',
|
'Tool Calls:': 'Tool Calls:',
|
||||||
|
|||||||
@@ -820,6 +820,7 @@ export default {
|
|||||||
// Exit Screen / Stats
|
// Exit Screen / Stats
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
'Agent powering down. Goodbye!': 'Qwen Code 正在关闭,再见!',
|
'Agent powering down. Goodbye!': 'Qwen Code 正在关闭,再见!',
|
||||||
|
'To continue this session, run': '要继续此会话,请运行',
|
||||||
'Interaction Summary': '交互摘要',
|
'Interaction Summary': '交互摘要',
|
||||||
'Session ID:': '会话 ID:',
|
'Session ID:': '会话 ID:',
|
||||||
'Tool Calls:': '工具调用:',
|
'Tool Calls:': '工具调用:',
|
||||||
|
|||||||
@@ -20,16 +20,21 @@ vi.mock('../contexts/SessionContext.js', async (importOriginal) => {
|
|||||||
|
|
||||||
const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats);
|
const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats);
|
||||||
|
|
||||||
const renderWithMockedStats = (metrics: SessionMetrics) => {
|
const renderWithMockedStats = (
|
||||||
|
metrics: SessionMetrics,
|
||||||
|
sessionId: string = 'test-session-id-12345',
|
||||||
|
promptCount: number = 5,
|
||||||
|
) => {
|
||||||
useSessionStatsMock.mockReturnValue({
|
useSessionStatsMock.mockReturnValue({
|
||||||
stats: {
|
stats: {
|
||||||
|
sessionId,
|
||||||
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(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,6 +75,38 @@ describe('<SessionSummaryDisplay />', () => {
|
|||||||
const output = lastFrame();
|
const output = lastFrame();
|
||||||
|
|
||||||
expect(output).toContain('Agent powering down. Goodbye!');
|
expect(output).toContain('Agent powering down. Goodbye!');
|
||||||
|
expect(output).toContain('To continue this session, run');
|
||||||
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
|
import { Box, Text } from 'ink';
|
||||||
import { StatsDisplay } from './StatsDisplay.js';
|
import { StatsDisplay } from './StatsDisplay.js';
|
||||||
|
import { useSessionStats } from '../contexts/SessionContext.js';
|
||||||
|
import { theme } from '../semantic-colors.js';
|
||||||
import { t } from '../../i18n/index.js';
|
import { t } from '../../i18n/index.js';
|
||||||
|
|
||||||
interface SessionSummaryDisplayProps {
|
interface SessionSummaryDisplayProps {
|
||||||
@@ -14,9 +17,28 @@ interface SessionSummaryDisplayProps {
|
|||||||
|
|
||||||
export const SessionSummaryDisplay: React.FC<SessionSummaryDisplayProps> = ({
|
export const SessionSummaryDisplay: React.FC<SessionSummaryDisplayProps> = ({
|
||||||
duration,
|
duration,
|
||||||
}) => (
|
}) => {
|
||||||
<StatsDisplay
|
const { stats } = useSessionStats();
|
||||||
title={t('Agent powering down. Goodbye!')}
|
|
||||||
duration={duration}
|
// Only show the resume message if there were messages in the session
|
||||||
/>
|
const hasMessages = stats.promptCount > 0;
|
||||||
);
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<StatsDisplay
|
||||||
|
title={t('Agent powering down. Goodbye!')}
|
||||||
|
duration={duration}
|
||||||
|
/>
|
||||||
|
{hasMessages && (
|
||||||
|
<Box marginTop={1}>
|
||||||
|
<Text color={theme.text.secondary}>
|
||||||
|
{t('To continue this session, run')}{' '}
|
||||||
|
<Text color={theme.text.accent}>
|
||||||
|
qwen --resume {stats.sessionId}
|
||||||
|
</Text>
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ exports[`<SessionSummaryDisplay /> > renders the summary display with a title 1`
|
|||||||
│ Agent powering down. Goodbye! │
|
│ Agent powering down. Goodbye! │
|
||||||
│ │
|
│ │
|
||||||
│ Interaction Summary │
|
│ Interaction Summary │
|
||||||
│ Session ID: │
|
│ Session ID: test-session-id-12345 │
|
||||||
│ Tool Calls: 0 ( ✓ 0 x 0 ) │
|
│ Tool Calls: 0 ( ✓ 0 x 0 ) │
|
||||||
│ Success Rate: 0.0% │
|
│ Success Rate: 0.0% │
|
||||||
│ Code Changes: +42 -15 │
|
│ Code Changes: +42 -15 │
|
||||||
@@ -26,5 +26,7 @@ exports[`<SessionSummaryDisplay /> > renders the summary display with a title 1`
|
|||||||
│ │
|
│ │
|
||||||
│ » Tip: For a full token breakdown, run \`/stats model\`. │
|
│ » Tip: For a full token breakdown, run \`/stats model\`. │
|
||||||
│ │
|
│ │
|
||||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
To continue this session, run qwen --resume test-session-id-12345"
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user