fix: ctrl-c exit + agent dump
This commit is contained in:
@@ -1094,6 +1094,7 @@ export default function App({
|
||||
{showExitStats && (
|
||||
<SessionStatsComponent
|
||||
stats={sessionStatsRef.current.getSnapshot()}
|
||||
agentId={agentId}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user