fix(sessions): reset token counts to 0 on /new (#1523)
- Set inputTokens, outputTokens, totalTokens to 0 in sessions.reset - Clear TUI sessionInfo tokens immediately before async reset - Prevents stale token display after session reset Fixes #1523
This commit is contained in:
@@ -251,6 +251,10 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
lastChannel: entry?.lastChannel,
|
||||
lastTo: entry?.lastTo,
|
||||
skillsSnapshot: entry?.skillsSnapshot,
|
||||
// Reset token counts to 0 on session reset (#1523)
|
||||
inputTokens: 0,
|
||||
outputTokens: 0,
|
||||
totalTokens: 0,
|
||||
};
|
||||
store[primaryKey] = nextEntry;
|
||||
return nextEntry;
|
||||
|
||||
@@ -408,6 +408,12 @@ export function createCommandHandlers(context: CommandHandlerContext) {
|
||||
case "new":
|
||||
case "reset":
|
||||
try {
|
||||
// Clear token counts immediately to avoid stale display (#1523)
|
||||
state.sessionInfo.inputTokens = null;
|
||||
state.sessionInfo.outputTokens = null;
|
||||
state.sessionInfo.totalTokens = null;
|
||||
tui.requestRender();
|
||||
|
||||
await client.resetSession(state.currentSessionKey);
|
||||
chatLog.addSystem(`session ${state.currentSessionKey} reset`);
|
||||
await loadHistory();
|
||||
|
||||
Reference in New Issue
Block a user