From d2f1e43d1d6048c17fa736eab16de045747b3e2e Mon Sep 17 00:00:00 2001
From: Jeff Carr <jcarr@wit.com>
Date: Sat, 30 Aug 2025 19:38:21 -0500
Subject: minor fixes

---
 packages/cli/src/ui/App.tsx | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'packages/cli/src/ui/App.tsx')

diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx
index ebd24e97..c5a49684 100644
--- a/packages/cli/src/ui/App.tsx
+++ b/packages/cli/src/ui/App.tsx
@@ -86,6 +86,7 @@ import { KeypressProvider } from './contexts/KeypressContext.js';
 import { useKittyKeyboardProtocol } from './hooks/useKittyKeyboardProtocol.js';
 import { keyMatchers, Command } from './keyMatchers.js';
 import * as fs from 'fs';
+import * as path from 'path';
 import { UpdateNotification } from './components/UpdateNotification.js';
 import {
   isProQuotaExceededError,
@@ -643,6 +644,13 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
     previousStreamingState.current = streamingState;
   }, [streamingState, sessionStats.sessionId]);
 
+  useEffect(() => {
+    process.on('exit', () => {
+      const statsPath = path.join('/tmp', `regex.${sessionStats.sessionId}.stats`);
+      fs.writeFileSync(statsPath, JSON.stringify(sessionStats, null, 2));
+    });
+  }, [sessionStats]);
+
   const handleIdePromptComplete = useCallback(
     (result: IdeIntegrationNudgeResult) => {
       if (result.userSelection === 'yes') {
-- 
cgit v1.2.3

