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.

2.0 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

import assert from "node:assert/strict";
import test from "node:test";

import { readSrc } from "./helpers/kit.ts";

// Selected fills must sit above hover at every contrast setting, so both build on --accent.

const HUB_CSS = readSrc("features/hub/hub.css");
const PICKERS = readSrc(
  "features/model-picker/components/model-selector/pickers.tsx",
);

const selectedFill = (row: string) => {
  const rule = HUB_CSS.match(
    new RegExp(
      `html\\.dark \\.hub-page \\.${row}\\[data-selected="true"\\] \\{([^}]*)\\}`,
    ),
  );
  assert.ok(rule, `${row} has no dark selected rule`);
  return rule[1] ?? "";
};

const hoverFill = (row: string) => {
  const rule = HUB_CSS.match(
    new RegExp(`html\\.dark \\.hub-page \\.${row}:hover \\{([^}]*)\\}`),
  );
  assert.ok(rule, `${row} has no dark hover rule`);
  return rule[1] ?? "";
};

for (const row of ["catalog-row", "hub-result-row"]) {
  test(`a selected ${row} is derived from the tone it must outrank`, () => {
    assert.match(hoverFill(row), /background-color: var\(--accent\)/);
    assert.match(selectedFill(row), /var\(--foreground\) 6%, var\(--accent\)/);
  });

  test(`a selected ${row} is not a wash that the slider can flatten`, () => {
    assert.doesNotMatch(selectedFill(row), /contrast-wash-gain/);
  });
}

test("the picker reads one fit per variant, companions included", () => {
  // Fit must judge the full footprint (getVariantFit), not the bare checkpoint size.
  assert.doesNotMatch(PICKERS, /getGgufFit\(v\.size_bytes\)/);
  const at = PICKERS.indexOf("const getVariantFit = useCallback(");
  assert.notEqual(at, -1, "getVariantFit is missing");
  assert.match(
    PICKERS.slice(at, at + 400),
    /ggufVariantFitSizeBytes\(variant\)|classifyGgufFitWithLookupTables\(getGgufFit, variant\)|classifyVariantFitOnCard\(getGgufFit, variant, cardGb\)/,
  );
  assert.equal(PICKERS.match(/getVariantFit\(v\)/g)?.length, 2);
});