mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Show session summary on exit for ctrl+c x 2. Fix exit UI (#963)
This commit is contained in:
@@ -69,6 +69,7 @@ export const useSlashCommandProcessor = (
|
||||
performMemoryRefresh: () => Promise<void>,
|
||||
toggleCorgiMode: () => void,
|
||||
showToolDescriptions: boolean = false,
|
||||
setQuittingMessages: (message: HistoryItem[]) => void,
|
||||
) => {
|
||||
const session = useSessionStats();
|
||||
const gitService = useMemo(() => {
|
||||
@@ -608,17 +609,24 @@ Add any other context about the problem here.
|
||||
name: 'quit',
|
||||
altName: 'exit',
|
||||
description: 'exit the cli',
|
||||
action: async (_mainCommand, _subCommand, _args) => {
|
||||
action: async (mainCommand, _subCommand, _args) => {
|
||||
const now = new Date();
|
||||
const { sessionStartTime, cumulative } = session.stats;
|
||||
const wallDuration = now.getTime() - sessionStartTime.getTime();
|
||||
|
||||
addMessage({
|
||||
type: MessageType.QUIT,
|
||||
stats: cumulative,
|
||||
duration: formatDuration(wallDuration),
|
||||
timestamp: new Date(),
|
||||
});
|
||||
setQuittingMessages([
|
||||
{
|
||||
type: 'user',
|
||||
text: `/${mainCommand}`,
|
||||
id: now.getTime() - 1,
|
||||
},
|
||||
{
|
||||
type: 'quit',
|
||||
stats: cumulative,
|
||||
duration: formatDuration(wallDuration),
|
||||
id: now.getTime(),
|
||||
},
|
||||
]);
|
||||
|
||||
setTimeout(() => {
|
||||
process.exit(0);
|
||||
@@ -749,6 +757,7 @@ Add any other context about the problem here.
|
||||
gitService,
|
||||
loadHistory,
|
||||
addItem,
|
||||
setQuittingMessages,
|
||||
]);
|
||||
|
||||
const handleSlashCommand = useCallback(
|
||||
@@ -763,7 +772,12 @@ Add any other context about the problem here.
|
||||
return false;
|
||||
}
|
||||
const userMessageTimestamp = Date.now();
|
||||
addItem({ type: MessageType.USER, text: trimmed }, userMessageTimestamp);
|
||||
if (trimmed !== '/quit' && trimmed !== '/exit') {
|
||||
addItem(
|
||||
{ type: MessageType.USER, text: trimmed },
|
||||
userMessageTimestamp,
|
||||
);
|
||||
}
|
||||
|
||||
let subCommand: string | undefined;
|
||||
let args: string | undefined;
|
||||
|
||||
Reference in New Issue
Block a user