@po.dev/pi-usage-dashboard 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/index.ts +14 -4
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -1126,18 +1126,27 @@ class UsageComponent {
1126
1126
  // Extension Entry Point
1127
1127
  // =============================================================================
1128
1128
 
1129
- function setUsageFooter(ctx: { ui: ExtensionCommandContext["ui"] }, totals: TotalStats): void {
1129
+ function footerModelLabel(ctx: Pick<ExtensionCommandContext, "model" | "thinkingLevel">): string {
1130
+ const model = ctx.model;
1131
+ if (!model) return "no-model";
1132
+ const label = `(${model.provider}) ${model.id}`;
1133
+ return model.reasoning && ctx.thinkingLevel ? `${label} • ${ctx.thinkingLevel}` : label;
1134
+ }
1135
+
1136
+ function setUsageFooter(ctx: Pick<ExtensionCommandContext, "ui" | "model" | "thinkingLevel">, totals: TotalStats): void {
1130
1137
  ctx.ui.setFooter((_tui, theme) => ({
1131
1138
  invalidate() {},
1132
1139
  render(width: number): string[] {
1133
- const line = theme.fg("thinkingHigh", "Usage:") + " " + 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`) + theme.fg("dim", " · (Today)");
1134
- return [truncateToWidth(line, width)];
1140
+ const usage = theme.fg("thinkingHigh", "Usage:") + " " + 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`) + theme.fg("dim", " · (Today)");
1141
+ const model = theme.fg("dim", footerModelLabel(ctx));
1142
+ const gap = width - visibleWidth(usage) - visibleWidth(model);
1143
+ return [gap >= 2 ? usage + " ".repeat(gap) + model : truncateToWidth(usage, width)];
1135
1144
  },
1136
1145
  }));
1137
1146
  }
1138
1147
 
1139
1148
  export default function (pi: ExtensionAPI) {
1140
- const refreshFooter = (ctx: { hasUI: boolean; ui: ExtensionCommandContext["ui"] }) => {
1149
+ const refreshFooter = (ctx: Pick<ExtensionCommandContext, "hasUI" | "ui" | "model" | "thinkingLevel">) => {
1141
1150
  if (!ctx.hasUI) return;
1142
1151
  void collectUsageData().then((data) => {
1143
1152
  if (!data) return;
@@ -1155,6 +1164,7 @@ export default function (pi: ExtensionAPI) {
1155
1164
  };
1156
1165
  pi.on("session_start", (_event, ctx) => { snapshotPrompt(ctx); refreshFooter(ctx); });
1157
1166
  pi.on("message_end", (_event, ctx) => { snapshotPrompt(ctx); refreshFooter(ctx); });
1167
+ pi.on("model_select", (_event, ctx) => { refreshFooter(ctx); });
1158
1168
  pi.registerCommand("usage", {
1159
1169
  description: "Show usage statistics dashboard",
1160
1170
  handler: async (_args: string, ctx: ExtensionCommandContext) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@po.dev/pi-usage-dashboard",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Local token and cost dashboard for pi sessions",
5
5
  "keywords": ["pi-package", "pi", "usage", "tokens", "dashboard"],
6
6
  "license": "MIT",