event icon indicating copy to clipboard operation
event copied to clipboard

getUpgradeBackgroundColor and getUpgradeIntensity use different ramps for the same balance

Open kunalKumar-13 opened this issue 2 months ago • 1 comments

Summary

getUpgradeIntensity and getUpgradeBackgroundColor in utils/ThemeUtils.ts describe the same 10k–100k upgrade ramp but compute it two different ways. Menu.tsx drives one view from both, so the background tint and the glow disagree — most visibly at exactly the balance where the card first appears.

The two ramps

// utils/ThemeUtils.ts:523
export function getUpgradeIntensity(balance: number): number {
    if (balance < 10_000) return 0;
    return Math.min((balance - 10_000) / 90_000, 1);
}

// utils/ThemeUtils.ts:532
if (balance >= 10_000) {
    const ratio = Math.min(balance / 100_000, 1);   // <- not getUpgradeIntensity
    return blendHexColors(baseColor, errorColor, ratio * 0.6);
}

One subtracts the 10k floor before normalising; the other does not.

balance getUpgradeIntensity blend fraction actually used what it would be via getUpgradeIntensity
10,000 0.000 0.060 0.000
20,000 0.111 0.120 0.067
50,000 0.444 0.300 0.267
90,000 0.889 0.540 0.533
100,000 1.000 0.600 0.600

They agree at the top of the range and diverge everywhere below it.

Why it shows

views/Menu.tsx:292-297 takes both from the same balance:

const bgColor = getUpgradeBackgroundColor(themeColor('secondary'), balance) || themeColor('secondary');
const t = getUpgradeIntensity(balance);

and t drives shadowOpacity: 0.4 + t * 0.4, shadowRadius: 4 + t * 8, elevation: 4 + t * 8 and the border offsets.

The card is gated on CashuStore.totalBalanceSats >= 10_000, so the first balance at which it renders is exactly 10,000 — and there t = 0 puts the glow fully at rest while the background is already 6% blended toward the error colour. The two cues are meant to express the same urgency and they contradict each other at the threshold.

Suggested fix

Have the colour use the ramp that already exists:

const ratio = getUpgradeIntensity(balance);
return blendHexColors(baseColor, errorColor, ratio * 0.6);

That makes 10,000 a clean "just appeared, nothing yet" state and keeps 100,000 unchanged at 0.6, so only the middle of the range shifts, slightly downward.

Caveat

If the offset tint at 10k is deliberate — so the card does not appear completely flat — then the mismatch is intentional and this is only a documentation problem, since getUpgradeIntensity's docstring says "10k → 0, 100k → 1" for a band the colour function walks differently.

I have not opened a PR because it changes what the screen looks like and I have no device to capture before/after on, which CONTRIBUTING asks for. Happy to send the one-line change if you would rather have it, or to leave it if the current curve is intended.

Disclosure: found and written with AI assistance. The table above comes from running both functions as they stand in the file.

kunalKumar-13 avatar Sep 20 '26 20:09 kunalKumar-13

tackled this in https://github.com/ZeusLN/zeus/pull/4709 - please take a look

kaloudis avatar Sep 22 '26 15:09 kaloudis