Show session summary on exit for ctrl+c x 2. Fix exit UI (#963)

This commit is contained in:
Abhi
2025-06-11 20:08:32 -04:00
committed by GitHub
parent e02a035ab4
commit dd53e5c96a
3 changed files with 70 additions and 19 deletions

View File

@@ -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;