@po.dev/pi-usage-dashboard 0.1.3 → 0.1.4

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 +7 -9
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -833,20 +833,18 @@ class UsageComponent {
833
833
  lines.push(th.fg("dim", " ".repeat(labelW) + " └" + Array.from({ length: axisW }, (_, i) => i % slotW === 0 ? "┬" : "─").join("")));
834
834
  lines.push(th.fg("dim", " ".repeat(labelW + 2) + days.map((day) => day.label.padEnd(slotW)).join("").trimEnd()));
835
835
  lines.push("");
836
+ const detail = model.providers.find((p) => p.name === this.graphDetailProvider);
837
+ const rows = detail?.models.slice(0, 8) ?? [];
838
+ const prefix = " ";
839
+ const costWidth = Math.max(visibleWidth("Cost ($)"), ...rows.map((m) => visibleWidth(formatAxisCost(m.cost))));
840
+ const tokenWidth = Math.max(visibleWidth("Token usage"), ...rows.map((m) => visibleWidth(formatTokens(m.tokens))));
841
+ const modelWidth = Math.max(visibleWidth("Model"), Math.min(Math.max(visibleWidth("Model"), ...rows.map((m) => visibleWidth(m.name))), width - visibleWidth(prefix) - costWidth - tokenWidth - 3));
836
842
  for (let i = 0; i < model.providers.length; i++) {
837
843
  const p = model.providers[i]!;
838
844
  const cursor = i === this.graphLegendIndex ? th.fg("accent", "▸ ") : " ";
839
845
  const marker = this.graphHidden.has(p.name) ? th.fg("dim", "·") : seriesColor(i) + "•" + COLOR_RESET;
840
846
  lines.push(`${cursor}${marker} ${padRight(this.graphHidden.has(p.name) ? th.fg("dim", p.name) : p.name, 24)} ${padLeft(formatValue(p.total), 8)}`);
841
- }
842
- const detail = model.providers.find((p) => p.name === this.graphDetailProvider);
843
- if (detail) {
844
- const rows = detail.models.slice(0, 8);
845
- const prefix = " · ";
846
- const costWidth = Math.max(visibleWidth("Cost ($)"), ...rows.map((m) => visibleWidth(formatAxisCost(m.cost))));
847
- const tokenWidth = Math.max(visibleWidth("Token usage"), ...rows.map((m) => visibleWidth(formatTokens(m.tokens))));
848
- const modelWidth = Math.max(visibleWidth("Model"), Math.min(Math.max(...rows.map((m) => visibleWidth(m.name))), width - visibleWidth(prefix) - costWidth - tokenWidth - 3));
849
- lines.push("", th.fg("accent", `${detail.name} by model`));
847
+ if (p !== detail) continue;
850
848
  lines.push(this.theme.fg("muted", `${prefix}${padRight("Model", modelWidth)} ${padLeft("Cost ($)", costWidth)} ${padLeft("Token usage", tokenWidth)}`));
851
849
  for (const m of rows) {
852
850
  lines.push(`${prefix}${padRight(truncateToWidth(m.name, modelWidth), modelWidth)} ${padLeft(formatAxisCost(m.cost), costWidth)} ${padLeft(formatTokens(m.tokens), tokenWidth)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@po.dev/pi-usage-dashboard",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Local token and cost dashboard for pi sessions",
5
5
  "keywords": [
6
6
  "pi-package",