feat(stats): save stats on exit

This commit is contained in:
Castor Regex 2025-08-24 09:30:39 -05:00 committed by Jeff Carr
parent 1ff70eeef8
commit d12a64368d
1 changed files with 17 additions and 5 deletions

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { execFile } from 'child_process';
import { useCallback, useMemo, useEffect, useState } from 'react';
import { type PartListUnion } from '@google/genai';
import process from 'node:process';
@ -403,11 +404,22 @@ export const useSlashCommandProcessor = (
return { type: 'handled' };
}
case 'quit':
setQuittingMessages(result.messages);
setTimeout(async () => {
await runExitCleanup();
process.exit(0);
}, 100);
const statsString = JSON.stringify(session.stats);
const command = '/home/jcarr/go/bin/regex';
const args = ['--stats', session.stats.sessionId, statsString];
execFile(command, args, (error, stdout, stderr) => {
if (error) {
console.error(`execFile error: ${error.message}`);
}
if (stderr) {
console.error(`stderr: ${stderr}`);
}
setQuittingMessages(result.messages);
setTimeout(async () => {
await runExitCleanup();
process.exit(0);
}, 100);
});
return { type: 'handled' };
case 'submit_prompt':