refactor(usage): centralize responseUsage mode

This commit is contained in:
Peter Steinberger
2026-01-18 05:54:39 +00:00
parent e2c10a2b7a
commit 54d7551b53
4 changed files with 14 additions and 21 deletions

View File

@@ -1,5 +1,9 @@
import type { Component, TUI } from "@mariozechner/pi-tui";
import { formatThinkingLevels, normalizeUsageDisplay } from "../auto-reply/thinking.js";
import {
formatThinkingLevels,
normalizeUsageDisplay,
resolveResponseUsageMode,
} from "../auto-reply/thinking.js";
import { normalizeAgentId } from "../routing/session-key.js";
import { helpText, parseCommand } from "./commands.js";
import type { ChatLog } from "./components/chat-log.js";
@@ -324,12 +328,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
break;
}
const currentRaw = state.sessionInfo.responseUsage;
const current =
currentRaw === "full"
? "full"
: currentRaw === "tokens" || currentRaw === "on"
? "tokens"
: "off";
const current = resolveResponseUsageMode(currentRaw);
const next =
normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
try {