feat: display detailed session stats on exit with resume command
When quitting the CLI, users now see a comprehensive session summary: - Total API time spent and session duration - Total code changes (+additions/-deletions) - Per-model token usage breakdown (input/output/cached) - Resume command with session ID Implementation details: - Extended SessionStats type with apiTimeSpent, apiCallStartTime, and modelUsage - Added startApiCall(), stopApiCall(), and addTokensWithModel() tracking functions - Created session-stats.ts utility with formatters and generateSessionSummary() - Updated TUI exit handler to display formatted stats - Added mouse tracking disable to drainStdin() for cleaner exit - Added modifiedFiles to getState() for exit summary access
This commit is contained in:
@@ -247,6 +247,16 @@ export interface LearningResponse {
|
||||
// Session Types
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Per-model token usage tracking
|
||||
*/
|
||||
export interface ModelUsage {
|
||||
modelId: string;
|
||||
inputTokens: number;
|
||||
outputTokens: number;
|
||||
cachedTokens?: number;
|
||||
}
|
||||
|
||||
export interface SessionStats {
|
||||
startTime: number;
|
||||
inputTokens: number;
|
||||
@@ -254,6 +264,12 @@ export interface SessionStats {
|
||||
thinkingStartTime: number | null;
|
||||
lastThinkingDuration: number;
|
||||
contextMaxTokens: number;
|
||||
/** Total time spent in API calls (milliseconds) */
|
||||
apiTimeSpent: number;
|
||||
/** API call start time for tracking (null if not in a call) */
|
||||
apiCallStartTime: number | null;
|
||||
/** Per-model token usage breakdown */
|
||||
modelUsage: ModelUsage[];
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user