From 5c50e911d203fc0a7ae6407f84bdfafd8c1f19f4 Mon Sep 17 00:00:00 2001 From: "continue[bot]" Date: Sat, 6 Dec 2025 01:52:23 +0000 Subject: [PATCH 1/4] fix: Initialize usage field in createSession and startNewSession Ensures all new sessions have the usage tracking structure initialized to prevent undefined field errors. Co-authored-by: nate --- extensions/cli/src/session.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/extensions/cli/src/session.ts b/extensions/cli/src/session.ts index c99f72cc3..7f223df30 100644 --- a/extensions/cli/src/session.ts +++ b/extensions/cli/src/session.ts @@ -322,6 +322,15 @@ export function createSession(history: ChatHistoryItem[] = []): Session { title: DEFAULT_SESSION_TITLE, workspaceDirectory: process.cwd(), history, + usage: { + totalCost: 0, + promptTokens: 0, + completionTokens: 0, + promptTokensDetails: { + cachedTokens: 0, + cacheWriteTokens: 0, + }, + }, }; SessionManager.getInstance().setSession(session); return session; @@ -553,6 +562,15 @@ export function startNewSession(history: ChatHistoryItem[] = []): Session { title: DEFAULT_SESSION_TITLE, workspaceDirectory: process.cwd(), history, + usage: { + totalCost: 0, + promptTokens: 0, + completionTokens: 0, + promptTokensDetails: { + cachedTokens: 0, + cacheWriteTokens: 0, + }, + }, }; manager.setSession(newSession);