Files
buzz/desktop/src/features/mesh-compute/meshMemoryModel.test.mjs
Michael Neale d23e3cf237 fix(mesh): state what is shared plainly, and scope the memory meter
Drops two captions that hedged or mislabeled facts we have.

"Join to see live detail" was wrong twice over: in that state the only thing to
join is sharing, and the field already shows what the community has published.
"Last reported by the community" annotated a real fact with doubt -- the notes
are current within 120s, and what we know is shared should be shown as shared.
The live-vs-relay difference is already carried by the geometry: relay nodes get
no synthetic RTT, and the centre is hollow with no spokes because adjacency is
what we cannot assert. A caption repeating that was noise.

The only surviving caption states something the drawing cannot: alone on the
mesh.

The memory meter is per-node and now says so -- "This computer · model uses 10
GB of 40 GB". It sits directly beneath a radar field showing the whole
community, so an unqualified figure read as mesh-wide utilization: a number
nobody has, since members publish their own capacity but nothing about each
other's live allocation. A test pins the scoping rather than the wording.

Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-08-05 12:51:57 +10:00

85 lines
2.2 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { deriveMeshMemoryModel } from "./meshMemoryModel.ts";
const catalog = {
gpuName: "Apple GPU",
vramDisplay: "32 GB",
vramGb: 32,
recommended: "gemma",
entries: [
{
name: "gemma",
size: "8GB",
sizeGb: 8,
description: "",
fit: "comfortable",
installed: true,
recommended: true,
curated: true,
},
],
};
test("prefers the runtime's reported model footprint", () => {
const model = deriveMeshMemoryModel({
view: {
connected: true,
selfCapacityGb: 40,
selfModelSizeGb: 10,
peers: [],
},
catalog,
modelRef: "gemma",
});
assert.equal(model.label, "This computer · model uses 10 GB of 40 GB");
assert.equal(model.usedSegments, 3);
});
test("falls back to the selected catalog model before runtime status arrives", () => {
const model = deriveMeshMemoryModel({
view: null,
catalog,
modelRef: "gemma",
});
assert.equal(model.label, "This computer · model uses 8 GB of 32 GB");
assert.equal(model.usedSegments, 3);
});
test("unknown model size shows available memory without inventing use", () => {
const model = deriveMeshMemoryModel({
view: null,
catalog,
modelRef: "custom/model",
});
assert.equal(model.label, "This computer · 32 GB AI memory");
assert.equal(model.usedSegments, 0);
});
test("every label names this computer, never the mesh", () => {
// The meter sits directly under a radar field showing the whole community.
// An unqualified "10 of 40 GB" would read as mesh-wide utilization, which is
// a number nobody has: members publish their own capacity, not each other's
// live allocation.
const cases = [
{
view: {
connected: true,
selfCapacityGb: 40,
selfModelSizeGb: 10,
peers: [],
},
catalog,
modelRef: "gemma",
},
{ view: null, catalog, modelRef: "gemma" },
{ view: null, catalog, modelRef: "custom/model" },
{ view: null, catalog: null, modelRef: null },
];
for (const input of cases) {
const model = deriveMeshMemoryModel(input);
assert.match(model.label, /this computer/i, model.label);
}
});