@firstpick/pi-package-webui 0.10.3 → 0.10.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 +2 -2
- package/public/app.js +53 -23
- package/public/styles.css +9 -0
- package/tests/browser/stats-overlay.spec.mjs +13 -0
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
- package/tests/fixtures/fake-pi.mjs +9 -1
- package/tests/stats-dashboard-static.test.mjs +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-package-webui#readme",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@earendil-works/pi-ai": "^0.83.0",
|
|
39
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
39
|
+
"@earendil-works/pi-coding-agent": "^0.85.0",
|
|
40
40
|
"@earendil-works/pi-tui": "^0.83.0",
|
|
41
41
|
"@firstpick/pi-utils": "^0.2.5",
|
|
42
42
|
"mermaid": "^11.15.0",
|
package/public/app.js
CHANGED
|
@@ -30812,6 +30812,12 @@ function formatStatsCost(value) {
|
|
|
30812
30812
|
return `$${cost.toFixed(2)}`;
|
|
30813
30813
|
}
|
|
30814
30814
|
|
|
30815
|
+
function formatStatsCostWithCoverage(value, unpricedMessages) {
|
|
30816
|
+
const cost = statsNumber(value);
|
|
30817
|
+
if (statsNumber(unpricedMessages) <= 0) return formatStatsCost(cost);
|
|
30818
|
+
return cost > 0 ? `${formatStatsCost(cost)} recorded + unavailable` : "unavailable";
|
|
30819
|
+
}
|
|
30820
|
+
|
|
30815
30821
|
function formatStatsPercent(value) {
|
|
30816
30822
|
return `${statsNumber(value).toFixed(1)}%`;
|
|
30817
30823
|
}
|
|
@@ -30835,6 +30841,10 @@ function formatStatsNullableCost(value) {
|
|
|
30835
30841
|
return number === null ? "n/a" : formatStatsCost(number);
|
|
30836
30842
|
}
|
|
30837
30843
|
|
|
30844
|
+
function formatStatsNullableCostWithCoverage(value, unpricedMessages) {
|
|
30845
|
+
return statsNumber(unpricedMessages) > 0 ? formatStatsCostWithCoverage(value, unpricedMessages) : formatStatsNullableCost(value);
|
|
30846
|
+
}
|
|
30847
|
+
|
|
30838
30848
|
function formatStatsNullableTokens(value) {
|
|
30839
30849
|
const number = statsNullableNumber(value);
|
|
30840
30850
|
return number === null ? "n/a" : `${formatStatsTokens(number)} tok`;
|
|
@@ -30903,7 +30913,9 @@ function statsSpendComparison(summary) {
|
|
|
30903
30913
|
recentStartDay: typeof comparison.recentStartDay === "string" ? comparison.recentStartDay : "",
|
|
30904
30914
|
recentEndDay: typeof comparison.recentEndDay === "string" ? comparison.recentEndDay : "",
|
|
30905
30915
|
recentCost: statsNumber(comparison.recentCost),
|
|
30916
|
+
recentUnpricedMessages: Math.max(0, statsNumber(comparison.recentUnpricedMessages)),
|
|
30906
30917
|
priorCost: statsNumber(comparison.priorCost),
|
|
30918
|
+
priorUnpricedMessages: Math.max(0, statsNumber(comparison.priorUnpricedMessages)),
|
|
30907
30919
|
changeCost: statsNullableNumber(comparison.changeCost),
|
|
30908
30920
|
changePercent: statsNullableNumber(comparison.changePercent),
|
|
30909
30921
|
};
|
|
@@ -30915,6 +30927,7 @@ function statsModelDriverEntries(payload) {
|
|
|
30915
30927
|
name: model?.model || "unknown",
|
|
30916
30928
|
cost: statsNumber(model?.cost),
|
|
30917
30929
|
share: statsCostShareOf(model?.cost, totalCost),
|
|
30930
|
+
unpricedMessages: statsNumber(model?.unpricedMessages),
|
|
30918
30931
|
}));
|
|
30919
30932
|
}
|
|
30920
30933
|
|
|
@@ -30924,9 +30937,15 @@ function statsSessionDriverEntries(payload) {
|
|
|
30924
30937
|
name: session?.displayName || session?.sessionId || "unknown",
|
|
30925
30938
|
cost: statsNumber(session?.cost),
|
|
30926
30939
|
share: statsCostShareOf(session?.cost, totalCost),
|
|
30940
|
+
unpricedMessages: statsNumber(session?.unpricedMessages),
|
|
30927
30941
|
}));
|
|
30928
30942
|
}
|
|
30929
30943
|
|
|
30944
|
+
function statsCostWarning(payload) {
|
|
30945
|
+
const warning = payload?.costInfo?.warning;
|
|
30946
|
+
return typeof warning === "string" ? warning.trim().slice(0, 600) : "";
|
|
30947
|
+
}
|
|
30948
|
+
|
|
30930
30949
|
function parseStatsWebuiPayloadRaw(raw) {
|
|
30931
30950
|
if (!raw) return null;
|
|
30932
30951
|
try {
|
|
@@ -31080,14 +31099,14 @@ function renderStatsBarRows(daily = []) {
|
|
|
31080
31099
|
make("span", "stats-overlay-bar-day", row.day || "—"),
|
|
31081
31100
|
bar,
|
|
31082
31101
|
make("span", "stats-overlay-bar-value", `${formatStatsTokens(row.total)} tok`),
|
|
31083
|
-
make("span", "stats-overlay-bar-cost",
|
|
31102
|
+
make("span", "stats-overlay-bar-cost", formatStatsCostWithCoverage(row.cost, row.unpricedMessages)),
|
|
31084
31103
|
);
|
|
31085
31104
|
list.append(item);
|
|
31086
31105
|
}
|
|
31087
31106
|
wrapper.append(
|
|
31088
31107
|
legend,
|
|
31089
31108
|
list,
|
|
31090
|
-
make("p", "stats-overlay-chart-caption muted", `${capped[0]?.day || "—"} → ${capped.at(-1)?.day || "—"} · peak ${formatStatsTokens(peakTokens?.total)} tok on ${peakTokens?.day || "—"} · peak spend ${
|
|
31109
|
+
make("p", "stats-overlay-chart-caption muted", `${capped[0]?.day || "—"} → ${capped.at(-1)?.day || "—"} · peak ${formatStatsTokens(peakTokens?.total)} tok on ${peakTokens?.day || "—"} · peak spend ${formatStatsCostWithCoverage(peakCost?.cost, peakCost?.unpricedMessages)} on ${peakCost?.day || "—"}`),
|
|
31091
31110
|
);
|
|
31092
31111
|
const note = statsChartWindowNote(windowed, "active days");
|
|
31093
31112
|
if (note) wrapper.append(note);
|
|
@@ -31095,13 +31114,14 @@ function renderStatsBarRows(daily = []) {
|
|
|
31095
31114
|
}
|
|
31096
31115
|
|
|
31097
31116
|
function renderStatsSpendChart(daily = []) {
|
|
31098
|
-
const rows = statsArray(daily).map((row) => ({ day: String(row?.day || "—"), cost: Math.max(0, statsNumber(row?.cost)) }));
|
|
31117
|
+
const rows = statsArray(daily).map((row) => ({ day: String(row?.day || "—"), cost: Math.max(0, statsNumber(row?.cost)), unpricedMessages: Math.max(0, statsNumber(row?.unpricedMessages)) }));
|
|
31099
31118
|
if (!rows.length) return make("p", "stats-overlay-empty muted", "No daily usage in this range.");
|
|
31100
31119
|
const windowed = statsChartWindow(rows);
|
|
31101
31120
|
const capped = windowed.capped;
|
|
31102
31121
|
const maxCost = Math.max(0, ...capped.map((row) => row.cost));
|
|
31103
31122
|
const total = capped.reduce((acc, row) => acc + row.cost, 0);
|
|
31104
|
-
|
|
31123
|
+
const unpricedMessages = capped.reduce((acc, row) => acc + row.unpricedMessages, 0);
|
|
31124
|
+
if (total <= 0) return make("p", "stats-overlay-empty muted", unpricedMessages > 0 ? `Recorded spend is unavailable for ${unpricedMessages} message${unpricedMessages === 1 ? "" : "s"} in this range.` : "No spend recorded in this range.");
|
|
31105
31125
|
const peak = capped.reduce((best, row) => (row.cost > (best?.cost ?? -1) ? row : best), null);
|
|
31106
31126
|
const wrapper = make("div", "stats-overlay-spend");
|
|
31107
31127
|
const chart = make("div", "stats-overlay-spend-chart");
|
|
@@ -31112,11 +31132,11 @@ function renderStatsSpendChart(daily = []) {
|
|
|
31112
31132
|
const bar = make("span", "stats-overlay-spend-bar");
|
|
31113
31133
|
const height = maxCost > 0 ? Math.min(100, Math.max(row.cost > 0 ? 3 : 0, (row.cost / maxCost) * 100)) : 0;
|
|
31114
31134
|
bar.style.height = `${height}%`;
|
|
31115
|
-
col.title = `${row.day}: ${
|
|
31135
|
+
col.title = `${row.day}: ${formatStatsCostWithCoverage(row.cost, row.unpricedMessages)}`;
|
|
31116
31136
|
col.append(bar);
|
|
31117
31137
|
chart.append(col);
|
|
31118
31138
|
}
|
|
31119
|
-
const caption = make("p", "stats-overlay-chart-caption muted", `Daily spend ${capped[0].day} → ${capped.at(-1).day} · total ${
|
|
31139
|
+
const caption = make("p", "stats-overlay-chart-caption muted", `Daily spend ${capped[0].day} → ${capped.at(-1).day} · total ${formatStatsCostWithCoverage(total, unpricedMessages)} · peak ${formatStatsCostWithCoverage(peak?.cost ?? 0, peak?.unpricedMessages)} on ${peak?.day ?? "—"}${windowed.truncated ? ` · latest ${capped.length} of ${windowed.total} days` : ""}`);
|
|
31120
31140
|
wrapper.append(chart, caption);
|
|
31121
31141
|
return wrapper;
|
|
31122
31142
|
}
|
|
@@ -31154,8 +31174,8 @@ function renderStatsComposition(totals = {}) {
|
|
|
31154
31174
|
|
|
31155
31175
|
function renderStatsDriverList(entries = [], emptyText = "No cost drivers in this range.") {
|
|
31156
31176
|
const rows = statsArray(entries)
|
|
31157
|
-
.map((entry) => ({ name: entry?.name || "unknown", cost: Math.max(0, statsNumber(entry?.cost)), share: statsNullableNumber(entry?.share) }))
|
|
31158
|
-
.filter((entry) => entry.cost > 0)
|
|
31177
|
+
.map((entry) => ({ name: entry?.name || "unknown", cost: Math.max(0, statsNumber(entry?.cost)), share: statsNullableNumber(entry?.share), unpricedMessages: Math.max(0, statsNumber(entry?.unpricedMessages)) }))
|
|
31178
|
+
.filter((entry) => entry.cost > 0 || entry.unpricedMessages > 0)
|
|
31159
31179
|
.slice(0, 8);
|
|
31160
31180
|
if (!rows.length) return make("p", "stats-overlay-empty muted", emptyText);
|
|
31161
31181
|
const maxCost = Math.max(...rows.map((entry) => entry.cost));
|
|
@@ -31172,7 +31192,7 @@ function renderStatsDriverList(entries = [], emptyText = "No cost drivers in thi
|
|
|
31172
31192
|
make("span", "stats-overlay-driver-rank", String(index + 1)),
|
|
31173
31193
|
make("span", "stats-overlay-driver-name", entry.name),
|
|
31174
31194
|
bar,
|
|
31175
|
-
make("span", "stats-overlay-driver-value", `${
|
|
31195
|
+
make("span", "stats-overlay-driver-value", `${formatStatsCostWithCoverage(entry.cost, entry.unpricedMessages)} · ${formatStatsNullablePercent(entry.share)}`),
|
|
31176
31196
|
);
|
|
31177
31197
|
list.append(row);
|
|
31178
31198
|
}
|
|
@@ -31194,6 +31214,14 @@ function renderStatsTopDrivers(payload) {
|
|
|
31194
31214
|
return grid;
|
|
31195
31215
|
}
|
|
31196
31216
|
|
|
31217
|
+
function renderStatsCostWarning(payload) {
|
|
31218
|
+
const warning = statsCostWarning(payload);
|
|
31219
|
+
if (!warning) return null;
|
|
31220
|
+
const note = make("p", "stats-overlay-cost-warning", warning);
|
|
31221
|
+
note.setAttribute("role", "note");
|
|
31222
|
+
return note;
|
|
31223
|
+
}
|
|
31224
|
+
|
|
31197
31225
|
function renderStatsOverview(payload) {
|
|
31198
31226
|
const node = make("div", "stats-overlay-pane stats-overlay-overview");
|
|
31199
31227
|
const totals = payload?.totals || {};
|
|
@@ -31205,12 +31233,12 @@ function renderStatsOverview(payload) {
|
|
|
31205
31233
|
const cards = make("div", "stats-overlay-cards");
|
|
31206
31234
|
cards.append(
|
|
31207
31235
|
statsMetricCard("Total tokens", formatStatsTokens(totals.total), `↑${formatStatsTokens(totals.input)} ↓${formatStatsTokens(totals.output)}`, "tone-blue"),
|
|
31208
|
-
statsMetricCard("Cost",
|
|
31209
|
-
statsMetricCard("Effective $/1M",
|
|
31236
|
+
statsMetricCard("Cost", formatStatsCostWithCoverage(totals.cost, totals.unpricedMessages), `projected 30d ${formatStatsCostWithCoverage(summary.projected30DayCost, totals.unpricedMessages)}`, "tone-green"),
|
|
31237
|
+
statsMetricCard("Effective $/1M", formatStatsNullableCostWithCoverage(statsEffectiveCostRate(summary, totals), totals.unpricedMessages), "blended rate, not provider list pricing", "tone-sky"),
|
|
31210
31238
|
statsMetricCard("Messages", String(statsNumber(totals.messages)), sessionDetail, "tone-mauve"),
|
|
31211
31239
|
statsMetricCard("PI initial prompt", `~${formatStatsTokens(payload?.promptEstimate?.total)} tok`, `${statsPromptEstimateSourceLabel(payload?.promptEstimate)} · ${payload?.promptEstimate?.confidence || "estimate"}`, "tone-yellow"),
|
|
31212
31240
|
statsMetricCard("Cached-input share", formatStatsNullablePercent(cachedShare), `reads ${formatStatsTokens(totals.cacheRead)} · writes ${formatStatsTokens(totals.cacheWrite)} of ${formatStatsTokens(statsPromptSideTokens(summary, totals))} prompt-side tok`, "tone-teal"),
|
|
31213
|
-
statsMetricCard("Active days", `${payload?.activeDayCount ?? 0}/${payload?.dayCount ?? 0}`, highest ? `peak ${highest.day} · ${
|
|
31241
|
+
statsMetricCard("Active days", `${payload?.activeDayCount ?? 0}/${payload?.dayCount ?? 0}`, highest ? `peak ${highest.day} · ${formatStatsCostWithCoverage(highest.cost, highest.unpricedMessages)}` : "no peak yet", "tone-pink"),
|
|
31214
31242
|
);
|
|
31215
31243
|
node.append(cards, make("h3", undefined, "Daily usage"), renderStatsBarRows(payload?.daily));
|
|
31216
31244
|
return node;
|
|
@@ -31224,7 +31252,7 @@ function renderStatsDaily(payload) {
|
|
|
31224
31252
|
statsArray(payload?.daily).map((row) => [
|
|
31225
31253
|
row.day || "—",
|
|
31226
31254
|
formatStatsTokens(row.total),
|
|
31227
|
-
|
|
31255
|
+
formatStatsCostWithCoverage(row.cost, row.unpricedMessages),
|
|
31228
31256
|
formatStatsTokens(row.input),
|
|
31229
31257
|
formatStatsTokens(row.output),
|
|
31230
31258
|
`${formatStatsTokens(row.cacheRead)} / ${formatStatsTokens(row.cacheWrite)}`,
|
|
@@ -31248,9 +31276,9 @@ function renderStatsModels(payload) {
|
|
|
31248
31276
|
model.model || "unknown",
|
|
31249
31277
|
formatStatsTokens(model.tokens),
|
|
31250
31278
|
formatStatsPercent(model.percent),
|
|
31251
|
-
|
|
31279
|
+
formatStatsCostWithCoverage(model.cost, model.unpricedMessages),
|
|
31252
31280
|
formatStatsPercent(model.costPercent),
|
|
31253
|
-
formatStatsCost(model.avgCostPerMillion),
|
|
31281
|
+
statsNumber(model.unpricedMessages) > 0 ? "unavailable" : formatStatsCost(model.avgCostPerMillion),
|
|
31254
31282
|
formatStatsTokens(Math.round(statsNumber(model.avgOutputTokens))),
|
|
31255
31283
|
String(statsNumber(model.messages)),
|
|
31256
31284
|
]),
|
|
@@ -31271,7 +31299,7 @@ function renderStatsSessions(payload) {
|
|
|
31271
31299
|
statsArray(payload?.expensiveSessions).map((session) => [
|
|
31272
31300
|
session.day || "—",
|
|
31273
31301
|
session.displayName || session.sessionId || "unknown",
|
|
31274
|
-
|
|
31302
|
+
formatStatsCostWithCoverage(session.cost, session.unpricedMessages),
|
|
31275
31303
|
formatStatsTokens(session.tokens),
|
|
31276
31304
|
session.model || "unknown",
|
|
31277
31305
|
]),
|
|
@@ -31288,18 +31316,19 @@ function renderStatsCostCache(payload) {
|
|
|
31288
31316
|
const comparison = statsSpendComparison(summary);
|
|
31289
31317
|
const scopedSessions = statsNullableNumber(payload?.scopedSessionCount);
|
|
31290
31318
|
const sessionDetail = scopedSessions !== null ? `per session in range (${scopedSessions})` : "per session file (legacy count)";
|
|
31319
|
+
const comparisonPartial = !!comparison && (comparison.recentUnpricedMessages > 0 || comparison.priorUnpricedMessages > 0);
|
|
31291
31320
|
const cards = make("div", "stats-overlay-cards compact");
|
|
31292
31321
|
cards.append(
|
|
31293
|
-
statsMetricCard("Avg/day",
|
|
31294
|
-
statsMetricCard("Active avg",
|
|
31295
|
-
statsMetricCard("Effective $/1M",
|
|
31322
|
+
statsMetricCard("Avg/day", formatStatsCostWithCoverage(summary.calendarAvgCost, totals.unpricedMessages), "calendar average", "tone-green"),
|
|
31323
|
+
statsMetricCard("Active avg", formatStatsCostWithCoverage(summary.activeAvgCost, totals.unpricedMessages), "per active day", "tone-teal"),
|
|
31324
|
+
statsMetricCard("Effective $/1M", formatStatsNullableCostWithCoverage(statsEffectiveCostRate(summary, totals), totals.unpricedMessages), "blended rate, not provider list pricing", "tone-blue"),
|
|
31296
31325
|
statsMetricCard("Cached-input share", formatStatsNullablePercent(statsCachedInputShare(summary, totals)), `reads ${formatStatsTokens(totals.cacheRead)} of ${formatStatsTokens(statsPromptSideTokens(summary, totals))} prompt-side tok`, "tone-yellow"),
|
|
31297
|
-
statsMetricCard("Avg cost/session",
|
|
31326
|
+
statsMetricCard("Avg cost/session", formatStatsNullableCostWithCoverage(statsAverageCostPerSession(summary, payload), totals.unpricedMessages), `${formatStatsNullableTokens(statsAverageTokensPerSession(summary, payload))} · ${sessionDetail}`, "tone-mauve"),
|
|
31298
31327
|
statsMetricCard(
|
|
31299
31328
|
"Recent spend",
|
|
31300
|
-
comparison ?
|
|
31329
|
+
comparison ? formatStatsCostWithCoverage(comparison.recentCost, comparison.recentUnpricedMessages) : "n/a",
|
|
31301
31330
|
comparison
|
|
31302
|
-
? `${comparison.recentStartDay} → ${comparison.recentEndDay} (${comparison.windowDays}d) vs prior ${comparison.windowDays}d ${
|
|
31331
|
+
? `${comparison.recentStartDay} → ${comparison.recentEndDay} (${comparison.windowDays}d) vs prior ${comparison.windowDays}d ${formatStatsCostWithCoverage(comparison.priorCost, comparison.priorUnpricedMessages)} · ${comparisonPartial ? "change unavailable" : `${formatStatsSignedCost(comparison.changeCost)} (${formatStatsNullablePercent(comparison.changePercent)})`}`
|
|
31303
31332
|
: "requires the latest stats extension",
|
|
31304
31333
|
"tone-pink",
|
|
31305
31334
|
),
|
|
@@ -31848,7 +31877,8 @@ function renderStatsOverlay() {
|
|
|
31848
31877
|
elements.statsOverlayBody.setAttribute("aria-labelledby", `statsOverlayTab-${statsOverlayActiveTab}`);
|
|
31849
31878
|
|
|
31850
31879
|
elements.statsOverlayRefreshButton.disabled = statsOverlayLoading;
|
|
31851
|
-
|
|
31880
|
+
const costWarning = renderStatsCostWarning(payload);
|
|
31881
|
+
elements.statsOverlayBody.replaceChildren(...(costWarning ? [costWarning, renderStatsOverlayPane(payload)] : [renderStatsOverlayPane(payload)]));
|
|
31852
31882
|
}
|
|
31853
31883
|
|
|
31854
31884
|
function scheduleStatsRefreshAfterCalibration(tabContext, delays = [1200]) {
|
package/public/styles.css
CHANGED
|
@@ -13219,6 +13219,15 @@ body.subagent-terminal-active .composer-remote-mic-consent {
|
|
|
13219
13219
|
color: var(--ctp-red);
|
|
13220
13220
|
border-color: rgba(243, 139, 168, 0.38);
|
|
13221
13221
|
}
|
|
13222
|
+
.stats-overlay-cost-warning {
|
|
13223
|
+
margin: 0 0 0.72rem;
|
|
13224
|
+
padding: 0.62rem 0.75rem;
|
|
13225
|
+
border: 1px solid rgba(249, 226, 175, 0.38);
|
|
13226
|
+
border-radius: 0.75rem;
|
|
13227
|
+
background: rgba(249, 226, 175, 0.08);
|
|
13228
|
+
color: var(--ctp-yellow);
|
|
13229
|
+
line-height: 1.45;
|
|
13230
|
+
}
|
|
13222
13231
|
.stats-overlay-tabs {
|
|
13223
13232
|
display: flex;
|
|
13224
13233
|
gap: 0.42rem;
|
|
@@ -139,6 +139,19 @@ test("stats overlay exposes stable tab/tabpanel semantics", async ({ page }) =>
|
|
|
139
139
|
await expect(panel).toHaveAttribute("aria-labelledby", "statsOverlayTab-sessions");
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
test("stats overlay shows one report-level warning for partial Ollama Cloud costs", async ({ page }) => {
|
|
143
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
144
|
+
await openStatsOverlay(page);
|
|
145
|
+
await emitStatsPromptFixture(page, "/stats-webui 14");
|
|
146
|
+
|
|
147
|
+
const warnings = page.locator("#statsOverlayBody .stats-overlay-cost-warning");
|
|
148
|
+
await expect(warnings).toHaveCount(1);
|
|
149
|
+
await expect(warnings).toContainText("Ollama Cloud cost estimate is partial");
|
|
150
|
+
|
|
151
|
+
await page.locator("#statsOverlayTab-daily").click();
|
|
152
|
+
await expect(warnings).toHaveCount(1);
|
|
153
|
+
});
|
|
154
|
+
|
|
142
155
|
test("stats overlay tablist supports arrow, Home, and End keyboard navigation", async ({ page }) => {
|
|
143
156
|
await page.setViewportSize({ width: 1440, height: 900 });
|
|
144
157
|
await openStatsOverlay(page);
|
|
@@ -9,7 +9,7 @@ const [catalog, app, development, manifest] = await Promise.all([
|
|
|
9
9
|
]);
|
|
10
10
|
|
|
11
11
|
assert.equal(manifest.name, "@firstpick/pi-extension-feature-system-prompt");
|
|
12
|
-
assert.equal(manifest.version, "0.1.
|
|
12
|
+
assert.equal(manifest.version, "0.1.6");
|
|
13
13
|
assert.match(
|
|
14
14
|
catalog,
|
|
15
15
|
/\["featureSystemPrompt", "@firstpick\/pi-extension-feature-system-prompt", "\^0\.1\.3"\]/,
|
|
@@ -1395,7 +1395,15 @@ function statsPromptContextFixturePayload({ malformedSnapshot = false } = {}) {
|
|
|
1395
1395
|
scopedSessionCount: 0,
|
|
1396
1396
|
dayCount: 14,
|
|
1397
1397
|
activeDayCount: 0,
|
|
1398
|
-
totals: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, cost: 0 },
|
|
1398
|
+
totals: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, cost: 0, messages: 1, unpricedMessages: 1 },
|
|
1399
|
+
costInfo: {
|
|
1400
|
+
source: "session-recorded",
|
|
1401
|
+
status: "partial",
|
|
1402
|
+
isEstimate: true,
|
|
1403
|
+
ollamaCloudMessageCount: 1,
|
|
1404
|
+
unpricedMessageCount: 1,
|
|
1405
|
+
warning: "Fixture Ollama Cloud cost estimate is partial because one token-bearing message has no recorded cost.",
|
|
1406
|
+
},
|
|
1399
1407
|
promptEstimate: {
|
|
1400
1408
|
total: 300, low: 270, high: 330, confidence: "fixture", calibrationMultiplier: 1,
|
|
1401
1409
|
calibrationSamples: 0, source: "export-html", settled: true, attempts: 0,
|
|
@@ -39,6 +39,16 @@ assert.match(statsUi, /Cached-input share/, "cached-input share label should be
|
|
|
39
39
|
assert.match(overview, /statsCachedInputShare\(summary, totals\)/, "overview should use the accurately named cached-input share");
|
|
40
40
|
assert.match(costCache, /statsCachedInputShare\(summary, totals\)/, "cost & cache should use the accurately named cached-input share");
|
|
41
41
|
|
|
42
|
+
// Recorded-cost coverage stays visible throughout the dashboard.
|
|
43
|
+
assert.match(app, /function formatStatsCostWithCoverage/, "cost formatting should distinguish unavailable cost from a real zero");
|
|
44
|
+
assert.match(helpers, /function statsCostWarning/, "the payload warning should be normalized before display");
|
|
45
|
+
assert.match(charts, /function renderStatsCostWarning/, "the dashboard should build one report-level cost warning");
|
|
46
|
+
assert.match(overview, /formatStatsCostWithCoverage\(totals\.cost, totals\.unpricedMessages\)/, "overview cost should disclose incomplete coverage");
|
|
47
|
+
assert.match(daily, /formatStatsCostWithCoverage\(row\.cost, row\.unpricedMessages\)/, "daily costs should disclose incomplete coverage");
|
|
48
|
+
assert.match(models, /formatStatsCostWithCoverage\(model\.cost, model\.unpricedMessages\)/, "model costs should disclose incomplete coverage");
|
|
49
|
+
assert.match(sessions, /formatStatsCostWithCoverage\(session\.cost, session\.unpricedMessages\)/, "session costs should disclose incomplete coverage");
|
|
50
|
+
assert.match(overlay, /const costWarning = renderStatsCostWarning\(payload\)/, "the overlay should render the report-level warning once outside its tab panes");
|
|
51
|
+
|
|
42
52
|
// Legacy v1 fallbacks: absent fields are computed client-side, explicit null renders as n/a (never fake zeroes).
|
|
43
53
|
assert.match(helpers, /key in summary/, "fallback resolvers should distinguish absent fields from explicit nulls");
|
|
44
54
|
assert.match(helpers, /cachedInputShare[\s\S]*statsNumber\(totals\?\.input\) \+ statsNumber\(totals\?\.cacheRead\) \+ statsNumber\(totals\?\.cacheWrite\)/, "legacy cached-input share fallback should use the prompt-side denominator");
|
|
@@ -243,6 +253,7 @@ for (const selector of [
|
|
|
243
253
|
".stats-overlay-bar-lane",
|
|
244
254
|
".stats-overlay-bar-fill.cost",
|
|
245
255
|
".stats-overlay-table-caption",
|
|
256
|
+
".stats-overlay-cost-warning",
|
|
246
257
|
]) {
|
|
247
258
|
assert.ok(css.includes(selector), `styles.css should define ${selector}`);
|
|
248
259
|
}
|