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.

Read the descender guard's class list wherever it is written (#8765)

Daniel Han8fef5ed22166
diff --git a/tests/studio/test_studio_text_descender_clipping.py b/tests/studio/test_studio_text_descender_clipping.py
index c7196a029b7..8fab0cba8b2 100644
--- a/tests/studio/test_studio_text_descender_clipping.py
+++ b/tests/studio/test_studio_text_descender_clipping.py
@@ -27,28 +27,43 @@ def _read(path: Path) -> str:
return path.read_text(encoding = "utf-8")
+TRIGGER_LABEL_CLASSES = frozenset({"min-w-0", "flex-1", "truncate", "font-heading", "text-ui-16"})
+
+
+SIDEBAR_ACCOUNT_CLASSES = frozenset(
+ {"flex", "flex-1", "flex-col", "group-data-[collapsible=icon]:hidden"}
+)
+
+
+def _class_lists(src: str, required: frozenset) -> list[str]:
+ """Every double-quoted literal in `src` carrying all of `required`.
+
+ Matching the `className="..."` attribute directly is not enough: an element
+ that takes a caller override is written `className={cn("...", override)}`, and
+ the class list then sits in a plain string argument. That is how the trigger
+ label stopped being checked, so both checks below read the literals wherever
+ they are written and select on the class tokens instead. Selecting on four or
+ five specific Tailwind tokens is what makes reading every literal safe.
+ """
+ return [
+ literal for literal in re.findall(r'"([^"\n]*)"', src) if required <= set(literal.split())
+ ]
+
+
def test_model_selector_trigger_label_uses_leading_tight():
src = _read(MODEL_SELECTOR)
- pattern = re.compile(
- r'<span\s+className="[^"]*\bmin-w-0\b[^"]*\bflex-1\b[^"]*\btruncate\b[^"]*\bfont-heading\b[^"]*\btext-ui-16[^"]*"',
- )
- matches = pattern.findall(src)
+ matches = _class_lists(src, TRIGGER_LABEL_CLASSES)
assert matches, "could not find ModelSelectorTrigger model-name span"
for cls in matches:
- assert "leading-tight" in cls, f"expected leading-tight, got: {cls}"
- assert "leading-none" not in cls, f"leading-none must not coexist with truncate here: {cls}"
+ assert "leading-tight" in cls.split(), f"expected leading-tight, got: {cls}"
+ assert (
+ "leading-none" not in cls.split()
+ ), f"leading-none must not coexist with truncate here: {cls}"
def test_sidebar_account_block_uses_leading_tight():
src = _read(APP_SIDEBAR)
- class_names = re.findall(r'<div\s+className="([^"]+)"', src)
- required = {
- "flex",
- "flex-1",
- "flex-col",
- "group-data-[collapsible=icon]:hidden",
- }
- matches = [classes for classes in class_names if required <= set(classes.split())]
+ matches = _class_lists(src, SIDEBAR_ACCOUNT_CLASSES)
assert matches, "could not find sidebar account-block parent div"
for classes in matches:
leading_classes = [cls for cls in classes.split() if cls.startswith("leading-")]