@firstpick/pi-package-webui 0.10.3 → 0.10.5
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/DEVELOPMENT.md +2 -2
- package/package.json +2 -2
- package/public/app.js +53 -23
- package/public/index.html +1 -1
- package/public/styles.css +11 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +37 -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/git-footer-context-menu-static.test.mjs +1 -1
- package/tests/stats-dashboard-static.test.mjs +11 -0
package/DEVELOPMENT.md
CHANGED
|
@@ -239,7 +239,7 @@ npx playwright test --project=chromium tests/browser/subagent-observability.spec
|
|
|
239
239
|
|
|
240
240
|
The footer picker keeps presentation state browser-local under `pi-webui-footer-scoped-model-layout-v1`; only normalized `flat` and `advanced` values are accepted. Storage events adopt the value across same-origin tabs without a settings write. The context-menu checkbox names the destination layout: **Toggle advanced** in flat mode and **Toggle Simple** in advanced mode. Advanced rendering groups `orderedFooterScopedModels()` by provider, sorts only the provider groups, and retains the existing order inside every group. Provider containers are labelled ARIA groups, and option buttons carry stable provider/model indices for clamped directional focus movement.
|
|
241
241
|
|
|
242
|
-
Advanced options use a roving tab stop. Arrow, `Home`, and `End` keys move focus only; `Enter` and `Space` call the existing model-selection path, while `Escape` closes and restores the footer trigger. Pointer drag and `Alt+ArrowUp` / `Alt+ArrowDown` listeners remain in the flat branch only. The desktop picker uses intrinsic provider-column width, temporarily escapes the chat-panel clip, and raises the workspace stacking context above side panels. Its width is capped to a viewport gutter and the provider row becomes internally scrollable at that cap. Narrow-screen groups stack vertically, so neither layout creates page-level horizontal overflow.
|
|
242
|
+
Advanced options use a roving tab stop. Arrow, `Home`, and `End` keys move focus only; `Enter` and `Space` call the existing model-selection path, while `Escape` closes and restores the footer trigger. Pointer drag and `Alt+ArrowUp` / `Alt+ArrowDown` listeners remain in the flat branch only. The desktop picker uses intrinsic provider-column width, temporarily escapes the chat-panel clip, and raises the workspace stacking context above side panels. Keyboard help uses inline-size containment so it wraps to the picker width without its full sentence widening the popup. Its width is capped to a viewport gutter and the provider row becomes internally scrollable at that cap. Narrow-screen groups stack vertically, so neither layout creates page-level horizontal overflow.
|
|
243
243
|
|
|
244
244
|
Focused validation:
|
|
245
245
|
|
|
@@ -249,7 +249,7 @@ node --check public/app.js
|
|
|
249
249
|
npx playwright test tests/browser/footer-model-advanced-layout.spec.mjs --project=chromium
|
|
250
250
|
```
|
|
251
251
|
|
|
252
|
-
The static contract covers Model-only menu visibility, normalized persistence and storage adoption, grouping, semantics, keyboard behavior, flat reorder isolation, bounded side-panel overlay stacking, and responsive CSS hooks. The Chromium fixtures cover toggle synchronization/reload, group and model order, directional focus, model application, `Escape` focus restoration, flat `Alt+Arrow` and pointer selection, narrow-viewport overflow, and a ten-provider case that verifies viewport capping, side-panel overlap, paint order, and horizontal scrolling.
|
|
252
|
+
The static contract covers Model-only menu visibility, normalized persistence and storage adoption, grouping, semantics, keyboard behavior, flat reorder isolation, bounded side-panel overlay stacking, and responsive CSS hooks. The Chromium fixtures cover toggle synchronization/reload, group and model order, directional focus, model application, `Escape` focus restoration, flat `Alt+Arrow` and pointer selection, narrow-viewport overflow, intrinsic sizing with one, three, and six providers, and a ten-provider case that verifies viewport capping, side-panel overlap, paint order, and horizontal scrolling.
|
|
253
253
|
|
|
254
254
|
## Control Deck side-panel architecture
|
|
255
255
|
|
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.5",
|
|
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/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
13
13
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
14
14
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
15
|
-
<link rel="stylesheet" href="/styles.css?v=
|
|
15
|
+
<link rel="stylesheet" href="/styles.css?v=153" />
|
|
16
16
|
<script>
|
|
17
17
|
// Public-only issue-bot runtime configuration. Keep disabled unless the gateway,
|
|
18
18
|
// Turnstile site key, exact CORS origin, and private-report destination are approved.
|
package/public/styles.css
CHANGED
|
@@ -6175,6 +6175,8 @@ body.footer-model-picker-open .statusbar {
|
|
|
6175
6175
|
overflow: hidden;
|
|
6176
6176
|
}
|
|
6177
6177
|
.footer-model-picker-advanced .footer-model-picker-source {
|
|
6178
|
+
/* Let provider columns set the picker width, not the keyboard-help sentence. */
|
|
6179
|
+
contain: inline-size;
|
|
6178
6180
|
width: 100%;
|
|
6179
6181
|
max-width: none;
|
|
6180
6182
|
}
|
|
@@ -13219,6 +13221,15 @@ body.subagent-terminal-active .composer-remote-mic-consent {
|
|
|
13219
13221
|
color: var(--ctp-red);
|
|
13220
13222
|
border-color: rgba(243, 139, 168, 0.38);
|
|
13221
13223
|
}
|
|
13224
|
+
.stats-overlay-cost-warning {
|
|
13225
|
+
margin: 0 0 0.72rem;
|
|
13226
|
+
padding: 0.62rem 0.75rem;
|
|
13227
|
+
border: 1px solid rgba(249, 226, 175, 0.38);
|
|
13228
|
+
border-radius: 0.75rem;
|
|
13229
|
+
background: rgba(249, 226, 175, 0.08);
|
|
13230
|
+
color: var(--ctp-yellow);
|
|
13231
|
+
line-height: 1.45;
|
|
13232
|
+
}
|
|
13222
13233
|
.stats-overlay-tabs {
|
|
13223
13234
|
display: flex;
|
|
13224
13235
|
gap: 0.42rem;
|
|
@@ -193,6 +193,43 @@ test.afterAll(async () => {
|
|
|
193
193
|
await rm(tempRoot, { recursive: true, force: true });
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
+
for (const providerCount of [1, 3, 6]) {
|
|
197
|
+
test(`${providerCount} provider columns determine desktop picker width instead of keyboard help`, async ({ page }) => {
|
|
198
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
199
|
+
await installFixture(page, manyProviderModels.slice(0, providerCount));
|
|
200
|
+
await preparePage(page);
|
|
201
|
+
const menu = await openModelMenu(page);
|
|
202
|
+
await menu.toggle.click();
|
|
203
|
+
const picker = await openPicker(page, /footer-model-picker-advanced/, providerCount);
|
|
204
|
+
const geometry = await picker.evaluate((node) => {
|
|
205
|
+
const rect = node.getBoundingClientRect();
|
|
206
|
+
const style = getComputedStyle(node);
|
|
207
|
+
const columns = node.querySelector(".footer-model-provider-columns");
|
|
208
|
+
const help = node.querySelector("#footerModelPickerHelp");
|
|
209
|
+
return {
|
|
210
|
+
width: rect.width,
|
|
211
|
+
contentWidth: node.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight),
|
|
212
|
+
columnsWidth: columns.getBoundingClientRect().width,
|
|
213
|
+
helpWidth: help.getBoundingClientRect().width,
|
|
214
|
+
helpHeight: help.getBoundingClientRect().height,
|
|
215
|
+
helpLineHeight: parseFloat(getComputedStyle(help).lineHeight),
|
|
216
|
+
helpClientWidth: help.clientWidth,
|
|
217
|
+
helpScrollWidth: help.scrollWidth,
|
|
218
|
+
left: rect.left,
|
|
219
|
+
right: rect.right,
|
|
220
|
+
viewportWidth: window.innerWidth,
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
assert.ok(geometry.contentWidth - geometry.columnsWidth < 60, `picker should hug its provider columns: ${JSON.stringify(geometry)}`);
|
|
224
|
+
assert.ok(Math.abs(geometry.helpWidth - geometry.contentWidth) <= 1, `help should use the resulting content width: ${JSON.stringify(geometry)}`);
|
|
225
|
+
if (providerCount <= 3) {
|
|
226
|
+
assert.ok(geometry.helpHeight > geometry.helpLineHeight, `help should wrap instead of widening the picker: ${JSON.stringify(geometry)}`);
|
|
227
|
+
}
|
|
228
|
+
assert.equal(geometry.helpScrollWidth, geometry.helpClientWidth, "wrapped help should not overflow horizontally");
|
|
229
|
+
assert.ok(geometry.left >= 7 && geometry.right <= geometry.viewportWidth - 7, `picker should remain within viewport gutters: ${JSON.stringify(geometry)}`);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
196
233
|
test("many provider columns grow over side panels, stop at the viewport, and scroll internally", async ({ page }) => {
|
|
197
234
|
await page.setViewportSize({ width: 1440, height: 900 });
|
|
198
235
|
await installFixture(page, manyProviderModels);
|
|
@@ -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,
|
|
@@ -138,7 +138,7 @@ assert.match(
|
|
|
138
138
|
);
|
|
139
139
|
assert.match(
|
|
140
140
|
css,
|
|
141
|
-
/\.footer-model-picker-advanced \{[\s\S]*width:\s*max-content;[\s\S]*max-width:\s*calc\(100vw - 1rem\);[\s\S]*\.footer-model-picker-advanced \.footer-model-picker-source \{[\s\S]*width:\s*100%;[\s\S]*max-width:\s*none;[\s\S]*\.footer-model-provider-columns \{[\s\S]*grid-auto-flow:\s*column;[\s\S]*grid-auto-columns:\s*13rem;[\s\S]*width:\s*fit-content;[\s\S]*max-width:\s*calc\(100vw - 2\.5rem\);[\s\S]*overflow:\s*auto;/,
|
|
141
|
+
/\.footer-model-picker-advanced \{[\s\S]*width:\s*max-content;[\s\S]*max-width:\s*calc\(100vw - 1rem\);[\s\S]*\.footer-model-picker-advanced \.footer-model-picker-source \{[\s\S]*contain:\s*inline-size;[\s\S]*width:\s*100%;[\s\S]*max-width:\s*none;[\s\S]*\.footer-model-provider-columns \{[\s\S]*grid-auto-flow:\s*column;[\s\S]*grid-auto-columns:\s*13rem;[\s\S]*width:\s*fit-content;[\s\S]*max-width:\s*calc\(100vw - 2\.5rem\);[\s\S]*overflow:\s*auto;/,
|
|
142
142
|
"desktop advanced layout should give help text the full picker width, grow by provider count, stop at the viewport, and scroll internally",
|
|
143
143
|
);
|
|
144
144
|
assert.match(
|
|
@@ -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
|
}
|