From b83cd37ed487cc7e7bb66453ba1740f8f4f5c8f2 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Tue, 13 Oct 2026 08:29:29 +0800 Subject: [PATCH 1/3] web(#2929): rest bucket gets its own gray in legend and bands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The chart legend's 'rest' swatch shared the parent group's purple (#8250df == det.cause_unattrib), so 其余 was indistinguishable from 未归因回补 itself. Point CAUSE_COLOR.rest and the two standalone legend swatches at #9aa1a8 — the same light gray the economics card chips already use (#2934/e76b35f9), keeping card<->chart consistent. --- src/web/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/web/client.ts b/src/web/client.ts index 1dbee04fa6..78eed3747e 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -850,7 +850,7 @@ export const WEB_CLIENT = `(function () { // the same bucket membership the economics card aggregates. The gap // heuristic remains only as the legacy fallback for old ledgers whose // lines carry no attribution fields. - const CAUSE_COLOR = { cold: "#6e7681", comp: "#bf8700", seam: "#cf222e", pt: "#1a7f37", ps: "#f0883e", rw: "#57606a", rest: "#8250df" }; + const CAUSE_COLOR = { cold: "#6e7681", comp: "#bf8700", seam: "#cf222e", pt: "#1a7f37", ps: "#f0883e", rw: "#57606a", rest: "#9aa1a8" }; const CAUSE_KEY = { cold: "det.cause_cold", comp: "det.cause_comp", seam: "det.legend_seam", pt: "det.leg_pttl", ps: "det.leg_pside", rw: "det.leg_rewind", rest: "det.cause_ttl" }; let foldTailClaims = 0; const causes = lines.map((l, i) => { @@ -1269,7 +1269,7 @@ export const WEB_CLIENT = `(function () { if (seam.providerTtl.count > 0) sub.push(legendItem("background:#1a7f37", t("det.leg_pttl"))); if (seam.providerSide.count > 0) sub.push(legendItem("background:#f0883e", t("det.leg_pside"))); if (seam.rewinds.count > 0) sub.push(legendItem("background:#57606a", t("det.leg_rewind"))); - sub.push(legendItem("background:#8250df", t("det.leg_rest"))); + sub.push(legendItem("background:#9aa1a8", t("det.leg_rest"))); parts.push('' + legendItem("background:#8250df", t("det.cause_unattrib")) + '⊇' From b4645f5f64e6dd72632a9079d4893be031cea14a Mon Sep 17 00:00:00 2001 From: ework-agent Date: Tue, 13 Oct 2026 08:36:28 +0800 Subject: [PATCH 2/3] web(#2929): no-seam fallback rest swatch also gets its own gray (#2959) --- src/web/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/client.ts b/src/web/client.ts index 78eed3747e..4f2f3ed5d1 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -1276,7 +1276,7 @@ export const WEB_CLIENT = `(function () { + sub.join("") + ""); } else { - parts.push(legendItem("background:#8250df", t("det.cause_ttl"))); + parts.push(legendItem("background:#9aa1a8", t("det.cause_ttl"))); } if (d.systemPromptTokens || lines.length >= 20) parts.push(legendItem("border:1.5px solid #8b949e;background:#f2f5f7;", d.systemPromptTokens ? t("det.legend_base") : t("det.legend_base_est"))); parts.push(""); From 857517e591aa6788dcd211a662a0aa8956ec00bd Mon Sep 17 00:00:00 2001 From: ework-agent Date: Tue, 13 Oct 2026 09:39:52 +0800 Subject: [PATCH 3/3] web(#2929): percentages in cache-economics tiles and chips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Top-of-page surfaces (overview table, hit row) speak in % while the economics card only gave absolutes — inconsistent for a card whose job is 'where did this go'. Now: - each tile value gets its share of TOTAL INPUT — same denominator as the cache-hit % above (new content 1.3%, post-fold rebuild 0.5%, unattributed repay 1.5%); - the unattributed tile's chips get their share of that tile's parent total instead (41% provider-side / 32% rest / 15% rewind / 11% seam), since 'what eats the 2.6M' is the split users actually compare; - zero values render no percentage; abortCorrelated stays a bare count marker (it carries no token charge). Pure numeric formatting — no i18n keys, no ledger changes. --- src/web/client.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/web/client.ts b/src/web/client.ts index 4f2f3ed5d1..1d0d934430 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -1363,24 +1363,33 @@ export const WEB_CLIENT = `(function () { const tot = ledger.totals; parts.push('
' + t("det.cache_econ") + "" + (tot ? (tot.balanced ? ' ' + t("det.ce_balanced") + "" : ' ' + t("det.ce_unbalanced") + "") : "") + '
' + (d.ledger ? '
" : "")); if (tot) { + // #2929: percentages mirror the top-of-page basis — share of TOTAL + // INPUT (same denominator as the cache-hit % above). The + // unattributed tile's chips instead show their share of that + // bucket's parent total — "what eats the 2.6M" is the useful split. + const inp = Number(tot.input) || 0; + const parentU = Number(tot.ttlRepay) || 0; + const pc = (x) => (x >= 10 ? x.toFixed(0) : x.toFixed(1)) + "%"; + const pctIn = (v) => (+v > 0 && inp > 0) ? ' ' + pc((+v / inp) * 100) + "" : ""; + const pctU = (v) => (parentU > 0 && +v > 0) ? " (" + pc((+v / parentU) * 100) + ")" : ""; parts.push('
'); - mini(parts, t("det.ce_new"), fmtW(tot.newContent || 0)); - mini(parts, t("det.ce_comp"), fmtW(tot.compRepay || 0), false, (tot.compRepay || 0) > 0 ? t("det.ce_comp_hint") : ""); + mini(parts, t("det.ce_new"), fmtW(tot.newContent || 0) + pctIn(tot.newContent || 0)); + mini(parts, t("det.ce_comp"), fmtW(tot.compRepay || 0) + pctIn(tot.compRepay || 0), false, (tot.compRepay || 0) > 0 ? t("det.ce_comp_hint") : ""); // #2929: the unattributed bucket shows its own composition INSIDE the // tile (label · value · then the parts, top to bottom) — containment // rendered as layout, not as a caption floating beside the tiles. - const plainUnattrib = () => '
' + t("det.ce_ttl") + '
' + fmtW(tot.ttlRepay || 0) + "
"; + const plainUnattrib = () => '
' + t("det.ce_ttl") + '
' + fmtW(tot.ttlRepay || 0) + pctIn(tot.ttlRepay || 0) + "
"; if (seam && (seam.missed > 0 || seam.providerTtl.count > 0 || seam.providerSide.count > 0 || seam.rewinds.count > 0)) { var uChips = []; - if (seam.missed > 0 || seam.suspects > 0) uChips.push('' + t("det.attr_seam") + " " + fmtW(seam.missed) + (seam.suspects > 0 ? " ×" + seam.suspects : "") + ""); - if (seam.providerTtl.missed > 0 || seam.providerTtl.count > 0) uChips.push('' + t("det.attr_ttl") + " " + fmtW(seam.providerTtl.missed) + (seam.providerTtl.count > 0 ? " ×" + seam.providerTtl.count : "") + ""); - if (seam.providerSide.missed > 0 || seam.providerSide.count > 0) uChips.push('' + t("det.attr_provider") + " " + fmtW(seam.providerSide.missed) + (seam.providerSide.count > 0 ? " ×" + seam.providerSide.count : "") + ""); - if (seam.rewinds.missed > 0 || seam.rewinds.count > 0) uChips.push('' + t("det.attr_rewind") + " " + fmtW(seam.rewinds.missed) + (seam.rewinds.count > 0 ? " ×" + seam.rewinds.count : "") + ""); + if (seam.missed > 0 || seam.suspects > 0) uChips.push('' + t("det.attr_seam") + " " + fmtW(seam.missed) + (seam.suspects > 0 ? " ×" + seam.suspects : "") + pctU(seam.missed) + ""); + if (seam.providerTtl.missed > 0 || seam.providerTtl.count > 0) uChips.push('' + t("det.attr_ttl") + " " + fmtW(seam.providerTtl.missed) + (seam.providerTtl.count > 0 ? " ×" + seam.providerTtl.count : "") + pctU(seam.providerTtl.missed) + ""); + if (seam.providerSide.missed > 0 || seam.providerSide.count > 0) uChips.push('' + t("det.attr_provider") + " " + fmtW(seam.providerSide.missed) + (seam.providerSide.count > 0 ? " ×" + seam.providerSide.count : "") + pctU(seam.providerSide.missed) + ""); + if (seam.rewinds.missed > 0 || seam.rewinds.count > 0) uChips.push('' + t("det.attr_rewind") + " " + fmtW(seam.rewinds.missed) + (seam.rewinds.count > 0 ? " ×" + seam.rewinds.count : "") + pctU(seam.rewinds.missed) + ""); if (seam.abortCorrelated > 0) uChips.push('' + t("det.attr_abort") + " ×" + seam.abortCorrelated + ""); var uRest = Math.max(0, (tot.ttlRepay || 0) - seam.missed - seam.providerTtl.missed - seam.providerSide.missed - seam.rewinds.missed); - if (uRest > 8192) uChips.push('' + t("det.attr_rest", { x: fmtW(uRest) }) + ""); + if (uRest > 8192) uChips.push('' + t("det.attr_rest", { x: fmtW(uRest) }) + pctU(uRest) + ""); if (uChips.length) { - parts.push('
' + t("det.ce_ttl") + '
' + fmtW(tot.ttlRepay || 0) + '
' + parts.push('
' + t("det.ce_ttl") + '
' + fmtW(tot.ttlRepay || 0) + pctIn(tot.ttlRepay || 0) + '
' + '
' + escapeHtml(t("det.ce_breakdown")) + "
" + uChips.join("
") + "
"); } else { parts.push(plainUnattrib()); @@ -1388,7 +1397,7 @@ export const WEB_CLIENT = `(function () { } else { parts.push(plainUnattrib()); } - mini(parts, t("det.ce_residual"), fmtW(tot.residual || 0)); + mini(parts, t("det.ce_residual"), fmtW(tot.residual || 0) + pctIn(tot.residual || 0)); parts.push("
"); } const folds = ledger.folds || [];