pi-usage-hub 1.0.2 → 1.0.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.
- package/package.json +3 -2
- package/ui/session-panel.ts +6 -5
- package/ui/usage-window.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-usage-hub",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Usage hub for pi — provider quota/balance registry with cache, /usage-hub panel, and pull API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"url": "https://github.com/ouzhenkun/pi-usage-hub/issues"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@earendil-works/pi-coding-agent": "*"
|
|
23
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
24
|
+
"@earendil-works/pi-tui": "*"
|
|
24
25
|
},
|
|
25
26
|
"pi": {
|
|
26
27
|
"extensions": [
|
package/ui/session-panel.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// input handling, and rendering so index.ts only wires it into the overlay.
|
|
4
4
|
|
|
5
5
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { Key, matchesKey } from "@earendil-works/pi-tui";
|
|
6
7
|
import {
|
|
7
8
|
collectSessionUsage,
|
|
8
9
|
type ProviderSessionUsage,
|
|
@@ -83,8 +84,8 @@ export class SessionPanel {
|
|
|
83
84
|
/** Handle a key. Returns true if the panel consumed it. */
|
|
84
85
|
handleInput(data: string): boolean {
|
|
85
86
|
// Left/right: switch period tab
|
|
86
|
-
if (data
|
|
87
|
-
const delta = data
|
|
87
|
+
if (matchesKey(data, Key.left) || matchesKey(data, Key.right)) {
|
|
88
|
+
const delta = matchesKey(data, Key.right) ? 1 : -1;
|
|
88
89
|
this.periodIndex = (this.periodIndex + delta + PERIODS.length) % PERIODS.length;
|
|
89
90
|
this.providerIndex = 0;
|
|
90
91
|
this.expanded.clear();
|
|
@@ -93,8 +94,8 @@ export class SessionPanel {
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
// Up/down: navigate provider rows
|
|
96
|
-
if (data
|
|
97
|
-
const delta = data
|
|
97
|
+
if (matchesKey(data, Key.up) || matchesKey(data, Key.down)) {
|
|
98
|
+
const delta = matchesKey(data, Key.up) ? -1 : 1;
|
|
98
99
|
const n = this.providers().length;
|
|
99
100
|
if (n > 0) this.providerIndex = (this.providerIndex + delta + n) % n;
|
|
100
101
|
this.requestRender();
|
|
@@ -102,7 +103,7 @@ export class SessionPanel {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// Space/Enter: expand selected provider
|
|
105
|
-
if (data
|
|
106
|
+
if (matchesKey(data, Key.space) || matchesKey(data, Key.enter)) {
|
|
106
107
|
const name = this.providers()[this.providerIndex]?.provider;
|
|
107
108
|
if (name) {
|
|
108
109
|
if (this.expanded.has(name)) this.expanded.delete(name);
|
package/ui/usage-window.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Key, matchesKey } from "@earendil-works/pi-tui";
|
|
2
3
|
import type { UsageProvider, UsageReport } from "../types";
|
|
3
4
|
import { fullReport } from "./format-report";
|
|
4
5
|
import { SessionPanel } from "./session-panel";
|
|
@@ -57,7 +58,7 @@ export class UsageWindow {
|
|
|
57
58
|
this.done();
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
if (data
|
|
61
|
+
if (matchesKey(data, Key.tab)) {
|
|
61
62
|
this.mode = this.mode === "quota" ? "session" : "quota";
|
|
62
63
|
if (this.mode === "session") this.session.ensureLoaded();
|
|
63
64
|
if (this.mode === "quota") this.ensureQuotaLoaded?.();
|
|
@@ -89,7 +90,7 @@ export class UsageWindow {
|
|
|
89
90
|
for (const line of content) lines.push(row(line));
|
|
90
91
|
if (this.mode === "quota") {
|
|
91
92
|
lines.push(row());
|
|
92
|
-
lines.push(row(` ${th.fg("dim", "
|
|
93
|
+
lines.push(row(` ${th.fg("dim", "Tab switch view · Esc/q close")}`));
|
|
93
94
|
}
|
|
94
95
|
lines.push(th.fg("border", `╰${"─".repeat(innerW)}╯`));
|
|
95
96
|
return lines;
|