Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: busiest day keeps the darkest token activity shade (follow-up to #14600) (#14630)

Michael Hana493452d6f2c
diff --git a/studio/frontend/src/features/profile/utils/stats-format.ts b/studio/frontend/src/features/profile/utils/stats-format.ts
index f5ef6106d55..023ccbd6a2c 100644
--- a/studio/frontend/src/features/profile/utils/stats-format.ts
+++ b/studio/frontend/src/features/profile/utils/stats-format.ts
@@ -302,23 +302,23 @@ export function formatMilliseconds(ms: number): string {
export type HeatLevel = 0 | 1 | 2 | 3 | 4;
-/** Quartiles of the active days, not ratios to the peak: one outlier washed out every other day. */
-export function heatThresholds(values: readonly number[]): [number, number, number] {
+/** Quartiles of the active days, then the busiest. Not ratios to the peak: one outlier washed out every other day. */
+export function heatThresholds(values: readonly number[]): [number, number, number, number] {
const active = values.filter((value) => value > 0).sort((a, b) => a - b);
- if (active.length === 0) return [0, 0, 0];
+ if (active.length === 0) return [0, 0, 0, 0];
const at = (fraction: number) =>
active[Math.min(active.length - 1, Math.floor(fraction * active.length))] ?? 0;
- return [at(0.25), at(0.5), at(0.75)];
+ return [at(0.25), at(0.5), at(0.75), active.at(-1) ?? 0];
}
-/** A day's shade, 0 for none. Days at a shared quartile (a lone day, days all alike) take the strongest. */
+/** A day's shade, 0 for none. The busiest always takes the strongest: with 2 to 4 active days it is the top quartile itself. */
export function heatLevel(
tokens: number,
- thresholds: readonly [number, number, number],
+ thresholds: readonly [number, number, number, number],
): HeatLevel {
if (tokens <= 0) return 0;
- const [q1, q2, q3] = thresholds;
- if (tokens > q3 || (q1 === q3 && tokens >= q3)) return 4;
+ const [q1, q2, q3, peak] = thresholds;
+ if (tokens > q3 || tokens >= peak) return 4;
if (tokens > q2) return 3;
if (tokens > q1) return 2;
return 1;
diff --git a/studio/frontend/tests/profile-stats-format.test.ts b/studio/frontend/tests/profile-stats-format.test.ts
index 09ce74799f3..665f7b3339a 100644
--- a/studio/frontend/tests/profile-stats-format.test.ts
+++ b/studio/frontend/tests/profile-stats-format.test.ts
@@ -179,7 +179,7 @@ test("profile counts follow the selected locale's plural rules", () => {
test("heat levels split the active days into quartiles", () => {
const days = [0, 0, 100, 200, 300, 400, 500, 600, 700, 50_000];
const thresholds = heatThresholds(days);
- assert.deepEqual(thresholds, [300, 500, 700]);
+ assert.deepEqual(thresholds, [300, 500, 700, 50_000]);
assert.equal(heatLevel(0, thresholds), 0);
assert.equal(heatLevel(100, thresholds), 1);
assert.equal(heatLevel(400, thresholds), 2);
@@ -192,13 +192,25 @@ test("heat levels split the active days into quartiles", () => {
test("a lone active day, or days all alike, take the strongest shade", () => {
assert.equal(heatLevel(5, heatThresholds([0, 5, 0])), 4);
assert.equal(heatLevel(80, heatThresholds([80, 80, 80])), 4);
- assert.deepEqual(heatThresholds([0, 0]), [0, 0, 0]);
+ assert.deepEqual(heatThresholds([0, 0]), [0, 0, 0, 0]);
// Coinciding quartiles promote only the days at them, not a smaller day below.
const repeated = heatThresholds([10, 100, 100, 100, 100, 100, 100, 100]);
assert.equal(heatLevel(100, repeated), 4);
assert.equal(heatLevel(10, repeated), 1);
});
+test("the busiest day takes the strongest shade with only a few active days", () => {
+ for (const days of [
+ [1_000, 50_000],
+ [1_000, 20_000, 50_000],
+ [1_000, 8_000, 20_000, 50_000],
+ ]) {
+ const thresholds = heatThresholds(days);
+ assert.equal(heatLevel(50_000, thresholds), 4, String(days));
+ assert.equal(heatLevel(1_000, thresholds), 1, String(days));
+ }
+});
+
test("the grid ends on today's week and pads only real gaps", () => {
// Wed 2026-10-07 .. Wed 2026-10-21: three Monday-started weeks.
const daily = Array.from({ length: 15 }, (_, index) => ({