@astrofoundry/pi-astro 0.11.0 → 0.11.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.
|
@@ -53,10 +53,10 @@ describe("formatPercent", () => {
|
|
|
53
53
|
expect(formatPercent(null)).toBe("—");
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it("rounds to nearest integer percent", () => {
|
|
56
|
+
it("rounds to nearest integer percent (input is 0-100, not 0-1)", () => {
|
|
57
57
|
expect(formatPercent(0)).toBe("0%");
|
|
58
|
-
expect(formatPercent(
|
|
59
|
-
expect(formatPercent(
|
|
58
|
+
expect(formatPercent(45.67)).toBe("46%");
|
|
59
|
+
expect(formatPercent(100)).toBe("100%");
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -13,7 +13,7 @@ export function formatCost(usd: number): string {
|
|
|
13
13
|
|
|
14
14
|
export function formatPercent(percent: number | null): string {
|
|
15
15
|
if (percent === null) return "—";
|
|
16
|
-
return `${Math.round(percent
|
|
16
|
+
return `${Math.round(percent)}%`;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function formatPathBasename(cwd: string): string {
|
|
@@ -165,7 +165,7 @@ describe("astro-footer extension", () => {
|
|
|
165
165
|
},
|
|
166
166
|
],
|
|
167
167
|
},
|
|
168
|
-
getContextUsage: () => ({ tokens: 50, contextWindow: 200_000, percent:
|
|
168
|
+
getContextUsage: () => ({ tokens: 50, contextWindow: 200_000, percent: 25 }),
|
|
169
169
|
});
|
|
170
170
|
await pi.handlers.session_start({}, ctx);
|
|
171
171
|
const factory = ctx.ui.setFooter.mock.calls[0][0] as (
|
|
@@ -87,18 +87,21 @@ describe("segments", () => {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
it("renderContext uses dim colour below 70%", () => {
|
|
90
|
-
const out = renderContext(fakeTheme, ICONS,
|
|
90
|
+
const out = renderContext(fakeTheme, ICONS, 50);
|
|
91
91
|
expect(out).toContain("<dim>");
|
|
92
|
+
expect(out).toContain("50%");
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
it("renderContext uses warning colour at and above 70%", () => {
|
|
95
|
-
const out = renderContext(fakeTheme, ICONS,
|
|
96
|
+
const out = renderContext(fakeTheme, ICONS, 70);
|
|
96
97
|
expect(out).toContain("<warning>");
|
|
98
|
+
expect(out).toContain("70%");
|
|
97
99
|
});
|
|
98
100
|
|
|
99
101
|
it("renderContext uses error colour at and above 90%", () => {
|
|
100
|
-
const out = renderContext(fakeTheme, ICONS,
|
|
102
|
+
const out = renderContext(fakeTheme, ICONS, 95);
|
|
101
103
|
expect(out).toContain("<error>");
|
|
104
|
+
expect(out).toContain("95%");
|
|
102
105
|
});
|
|
103
106
|
|
|
104
107
|
it("renderExtensionStatus uses muted colour", () => {
|
|
@@ -67,7 +67,7 @@ export function renderContext(
|
|
|
67
67
|
percent: number | null,
|
|
68
68
|
): string | null {
|
|
69
69
|
if (percent === null) return null;
|
|
70
|
-
const role: ThemeColor = percent >=
|
|
70
|
+
const role: ThemeColor = percent >= 90 ? "error" : percent >= 70 ? "warning" : "dim";
|
|
71
71
|
return `${theme.fg(role, icons.context)} ${theme.fg(role, formatPercent(percent))}`.trim();
|
|
72
72
|
}
|
|
73
73
|
|