feat(slash-commands): usage footer modes

This commit is contained in:
Peter Steinberger
2026-01-18 05:35:22 +00:00
parent e7a4931932
commit 2dabce59ce
38 changed files with 370 additions and 303 deletions

View File

@@ -317,23 +317,30 @@ export function createCommandHandlers(context: CommandHandlerContext) {
chatLog.addSystem(`reasoning failed: ${String(err)}`);
}
break;
case "cost": {
case "usage": {
const normalized = args ? normalizeUsageDisplay(args) : undefined;
if (args && !normalized) {
chatLog.addSystem("usage: /cost <on|off>");
chatLog.addSystem("usage: /usage <off|tokens|full>");
break;
}
const current = state.sessionInfo.responseUsage === "on" ? "on" : "off";
const next = normalized ?? (current === "on" ? "off" : "on");
const currentRaw = state.sessionInfo.responseUsage;
const current =
currentRaw === "full"
? "full"
: currentRaw === "tokens" || currentRaw === "on"
? "tokens"
: "off";
const next =
normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
try {
await client.patchSession({
key: state.currentSessionKey,
responseUsage: next === "off" ? null : next,
});
chatLog.addSystem(next === "on" ? "usage line enabled" : "usage line disabled");
chatLog.addSystem(`usage footer: ${next}`);
await refreshSessionInfo();
} catch (err) {
chatLog.addSystem(`cost failed: ${String(err)}`);
chatLog.addSystem(`usage failed: ${String(err)}`);
}
break;
}