@po.dev/pi-usage-dashboard 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +10 -4
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -1192,12 +1192,18 @@ function footerModelLabel(ctx: Pick<ExtensionCommandContext, "model" | "thinking
|
|
|
1192
1192
|
return model.reasoning && ctx.thinkingLevel ? `${label} • ${ctx.thinkingLevel}` : label;
|
|
1193
1193
|
}
|
|
1194
1194
|
|
|
1195
|
-
function setUsageFooter(ctx: Pick<ExtensionCommandContext, "ui" | "model" | "thinkingLevel">, totals: TotalStats): void {
|
|
1195
|
+
function setUsageFooter(ctx: Pick<ExtensionCommandContext, "ui" | "model" | "thinkingLevel" | "getContextUsage">, totals: TotalStats): void {
|
|
1196
1196
|
ctx.ui.setFooter((_tui, theme) => ({
|
|
1197
1197
|
invalidate() {},
|
|
1198
1198
|
render(width: number): string[] {
|
|
1199
|
-
const
|
|
1200
|
-
const
|
|
1199
|
+
const context = ctx.getContextUsage();
|
|
1200
|
+
const compactAt = context ? context.contextWindow - 16_384 : 0;
|
|
1201
|
+
const left = context?.tokens === null ? "?" : context ? formatTokens(Math.max(0, compactAt - context.tokens)) : "?";
|
|
1202
|
+
const contextStatus = context
|
|
1203
|
+
? " · " + theme.fg("warning", `${context.percent?.toFixed(1) ?? "?"}%`) + theme.fg("dim", "/") + theme.fg("success", `${left} left`) + " " + theme.fg("accent", "(auto)")
|
|
1204
|
+
: "";
|
|
1205
|
+
const usage = theme.fg("thinkingHigh", "Usage:") + " " + theme.fg("accent", "(Today)") + " · " + theme.fg("accent", formatCost(totals.cost)) + " · " + theme.fg("text", `${formatTokens(totals.tokens.total)} tokens`) + " · " + theme.fg("success", `↑${formatTokens(totals.tokens.input + totals.tokens.cacheWrite)}`) + " · " + theme.fg("warning", `↓${formatTokens(totals.tokens.output)}`) + " · " + theme.fg("thinkingHigh", `${formatTokens(totals.tokens.cacheRead + totals.tokens.cacheWrite)} cache`) + contextStatus;
|
|
1206
|
+
const model = theme.fg("accent", footerModelLabel(ctx));
|
|
1201
1207
|
const gap = width - visibleWidth(usage) - visibleWidth(model);
|
|
1202
1208
|
return [gap >= 2 ? usage + " ".repeat(gap) + model : truncateToWidth(usage, width)];
|
|
1203
1209
|
},
|
|
@@ -1205,7 +1211,7 @@ function setUsageFooter(ctx: Pick<ExtensionCommandContext, "ui" | "model" | "thi
|
|
|
1205
1211
|
}
|
|
1206
1212
|
|
|
1207
1213
|
export default function (pi: ExtensionAPI) {
|
|
1208
|
-
const refreshFooter = (ctx: Pick<ExtensionCommandContext, "hasUI" | "ui" | "model" | "thinkingLevel">) => {
|
|
1214
|
+
const refreshFooter = (ctx: Pick<ExtensionCommandContext, "hasUI" | "ui" | "model" | "thinkingLevel" | "getContextUsage">) => {
|
|
1209
1215
|
if (!ctx.hasUI) return;
|
|
1210
1216
|
void collectUsageData().then((data) => {
|
|
1211
1217
|
if (!data) return;
|