fix: ctrl-c exit + agent dump

This commit is contained in:
cpacker
2025-10-25 23:37:41 -07:00
parent 2a93f9ab55
commit 83aeaff3fd
3 changed files with 5 additions and 3 deletions

View File

@@ -1094,6 +1094,7 @@ export default function App({
{showExitStats && (
<SessionStatsComponent
stats={sessionStatsRef.current.getSnapshot()}
agentId={agentId}
/>
)}

View File

@@ -86,9 +86,8 @@ export function Input({
useInput((input, key) => {
if (input === "c" && key.ctrl) {
if (ctrlCPressed) {
// Second CTRL-C - call onExit callback then exit application
// Second CTRL-C - call onExit callback which handles stats and exit
if (onExit) onExit();
process.exit(0);
} else {
// First CTRL-C - start 1-second timer
setCtrlCPressed(true);

View File

@@ -3,6 +3,7 @@ import type { SessionStatsSnapshot } from "../../agent/stats";
interface SessionStatsProps {
stats: SessionStatsSnapshot;
agentId?: string;
}
function formatDuration(ms: number): string {
@@ -16,7 +17,7 @@ function formatNumber(n: number): string {
return n.toLocaleString();
}
export function SessionStats({ stats }: SessionStatsProps) {
export function SessionStats({ stats, agentId }: SessionStatsProps) {
const wallDuration = formatDuration(stats.totalWallMs);
const apiDuration = formatDuration(stats.totalApiMs);
@@ -29,6 +30,7 @@ export function SessionStats({ stats }: SessionStatsProps) {
{formatNumber(stats.usage.promptTokens)} input,{" "}
{formatNumber(stats.usage.completionTokens)} output
</Text>
{agentId && <Text dimColor>Agent ID: {agentId}</Text>}
</Box>
);
}