Repository navigation
Studio: match the update banner tests on classes, not on file substrings - #10267
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… ungated one is required
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 386c60f867
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| rule is in force needs `_unconditional`. | ||
| """ | ||
| for token_variants, token_utility in _tokens(source): | ||
| if token_utility == utility and set(variants) <= set(token_variants): |
There was a problem hiding this comment.
Reject extra gates on required layout utilities
If a required floor or shrink utility gains an unrelated variant, this subset comparison still reports it as present. For example, changing the scaled floor to md:has-[[data-slot=update-release-notes]]:min-h-[...] passes _assert_floored, although widths from 384px up to the md breakpoint then have no floor because the narrow override ends at 383px. Positive layout guarantees should require the expected variant set rather than accepting arbitrary additional gates.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed on the browser card at 386c60f86 by writing the scaled floor as md:has-[...]:min-h-[calc(109px+80px*var(--ui-font-scale,1))], which leaves every width from 384px to the md breakpoint with no floor, the narrow override having stopped at 383px: 4 passed.
Fixed in 9aa6060fc. _only_under(source, utility, *variants) replaces the subset test for every positive guarantee, requiring the utility to be written and to carry exactly the named gates each time. _applies stays a subset test and is now used only for the absence checks, where "under any gate or none" is the question being asked.
The same mutation now fails, and so does the reverse one raised in the next thread.
| start, _ = _opening_tag(source, match.start()) | ||
| key = "className={cn(" | ||
| at = source.index(key, start) | ||
| return _unpositioned_branch(_COMMENT.sub("", source[at : match.start()])) |
There was a problem hiding this comment.
Read the root class from the whole opening tag
When data-testid is moved before className on either banner root—a behavior-preserving JSX attribute reorder—at is greater than match.start(), so the following slice is empty and _unpositioned_branch raises instead of checking the unchanged classes. The lookup should use both bounds returned by _opening_tag so this root anchor is actually independent of attribute order.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and this is the same bug as the one fixed last round, which I applied to _class_on_testid and not to _card_slot. Confirmed at 386c60f86 by moving data-testid="web-update-banner" above className={cn(, which changes nothing: 1 failed, on the raise rather than on an assertion.
Fixed in 9aa6060fc. _card_slot now takes both bounds from _opening_tag, finds className={cn( within the whole tag, and slices to the end of the tag rather than to the anchor. The reorder above now passes.
| assert _applies( | ||
| root, scaled, _NOTES_GATE | ||
| ), f"the {card} card's floor is fixed or ungated, so it is wrong at other type sizes" |
There was a problem hiding this comment.
Reject an ungated duplicate of each floor
If the gated floor remains but the same min-h-[...] utility is also added unconditionally to the root, this existence check still passes. The ungated declaration then reserves the card's full floor when no release-notes panel is rendered, recreating the empty-height regression these assertions claim to guard, while both floor tests remain green. Explicitly reject occurrences of each floor that omit _NOTES_GATE.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at 386c60f86 by leaving the gated floor in place and adding min-h-[calc(109px+80px*var(--ui-font-scale,1))] to the root ungated, which reserves the card's full floor with no notes panel rendered and is the empty-height regression #10229 fixed: 4 passed.
Fixed in 9aa6060fc by the same helper as the sibling thread. _only_under requires every occurrence of the floor utility to carry exactly the named gates, so a second ungated declaration fails rather than being ignored because a gated one exists.
| assert not _applies( | ||
| root, "min-h-0" |
There was a problem hiding this comment.
Recognize important utilities in the prohibition
If the root gains Tailwind's important form !min-h-0, _split_variants returns !min-h-0 as the utility, so this prohibition still passes even though that rule overrides the non-important floor and allows the rail to squeeze the card. This syntax is already used elsewhere in the frontend, including studio/frontend/src/app/routes/__root.tsx; normalize the important marker when matching prohibited utilities.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at 386c60f86 by adding !min-h-0 to both roots: 4 passed, although it beats the floor and lets the rail squeeze the card.
Fixed in 9aa6060fc. _split_variants strips the important marker from the utility, in both the leading !min-h-0 and the trailing min-h-0! form, so an important rule is matched as the rule it is. That applies to every check in the file, not only the prohibition: an important shrink-0 now satisfies the guarantee it genuinely provides.
Thanks for the pointer to app/routes/__root.tsx. I checked that the syntax is in use before treating this as reachable rather than theoretical.
| some other attribute, which is an order dependency of exactly the kind this | ||
| file is being fixed for. | ||
| """ | ||
| start = source.rindex("<", 0, at) |
There was a problem hiding this comment.
Distinguish JSX comparisons from opening tags
When any attribute before the anchored data-testid contains a <—for example disabled={count < limit}—this raw reverse search treats the comparison operator as the element's opening delimiter. The subsequent scan starts with unmatched closing braces and raises unterminated JSX opening tag, so a behavior-preserving attribute addition breaks these class tests. Locate the actual JSX element start while respecting attribute expressions and literals rather than selecting the last raw <.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at 386c60f86 by adding disabled={count < limit} ahead of the anchored attribute: 2 failed, with unterminated JSX opening tag.
Fixed in 9aa6060fc. _tag_end(source, start, at) now returns None rather than a bound when the candidate does not open a tag that reaches at with the tag still open and at depth zero, which a comparison operator cannot do because it runs out of depth on the closing brace. _opening_tag tries candidates from the nearest < outwards and takes the first that is accepted, so the real element start is found. It raises a named assertion, not a ValueError, if there is none.
The helper test covers a < in an attribute expression with the anchor on either side of className.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9aa6060fcb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if char in "\"'`": | ||
| index = _skip_literal(source, index) | ||
| continue |
There was a problem hiding this comment.
Skip comments while scanning JSX opening tags
When a comment inside the className={cn(...)} expression contains syntax characters, _tag_end interprets them as JSX: for example, changing the existing comment to // notes don't shrink makes the apostrophe start an unterminated string, while /* unmatched } is prose */ corrupts the bracket depth. Both are valid behavior-preserving comment edits, but _opening_tag then raises and breaks the banner tests, so comments need to be skipped before literal and bracket tracking.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at 9aa6060fc by rewriting the existing comment to // them, shrink-0 is what the card don't give up.: 2 failed, on unterminated ' literal.
Fixed in 9ec1ab65a. Comments are blanked before any scan, in both the // and /* */ forms, so prose cannot open a literal or unbalance the brackets. Blanked rather than removed, each character replaced by a space and newlines kept, so every offset the scanners hand around stays where it was.
The edit above now passes, and so does an unmatched } written in a block comment.
| _NOTES_GATE = "has-[[data-slot=update-release-notes]]" | ||
|
|
||
|
|
||
| _COMMENT = re.compile(r"//[^\n]*") |
There was a problem hiding this comment.
Strip block comments before tokenizing card classes
When an in-cn() comment uses the valid /* ... */ form, _COMMENT leaves its contents in the string passed to _only_under. The existing banner comment already mentions shrink-0, so converting it to a block comment and accidentally removing the real shrink-0 class would leave the floor assertion green even though the rail can now squeeze the card; strip both JavaScript comment forms before extracting tokens.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and this is the one of the three that loosened a guarantee rather than risking a false failure, so thank you for it.
The comment in question is real, at web/update-banner.tsx:91:
// them, shrink-0 keeps the compact card at its natural height.
Confirmed at 9aa6060fc by converting that pair of lines to a block comment and deleting the actual shrink-0 from the root: 4 passed, with the rail able to squeeze the card and nothing red.
Fixed in 9ec1ab65a by the same change as the sibling thread. _without_comments blanks both forms before tokenizing, so a class named in prose is no longer a class. That mutation now fails.
The stripping was there for exactly this reason and only covered //, which is the half of it that never showed up in these files.
| _, end = _opening_tag(source, match.start()) | ||
| key = 'className="' | ||
| at = source.index(key, end) + len(key) | ||
| return source[at : source.index('"', at)] |
There was a problem hiding this comment.
Read expression-valued classes from the painted surface
When the painted surface's literal class is wrapped in the already-used cn(...) helper, with no change to the resulting DOM classes, this search skips that element and returns the dismiss button's next literal className instead. test_only_the_notes_region_scrolls then reports all of the surface rules missing, so the extractor should bound itself to the first child element and handle a class expression rather than searching globally for the next literal attribute.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at 9aa6060fc by wrapping the surface's literal in cn(...), which renders identical DOM classes: 1 failed, reporting every rule on that element as missing because the search had moved on to the dismiss button.
Fixed in 9ec1ab65a. _card_surface is bounded to the root's first child now, found through _opening_tag rather than by scanning forward for the next literal attribute, and _class_value reads a className in either form, collecting the literals out of an expression. _class_on_testid uses the same reader, so neither anchor depends on the value being written as a plain string.
The wrap above now passes.
|
@codex review |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ec1ab65af
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return match.group(1) | ||
|
|
||
|
|
||
| _COMMENT_SPAN = re.compile(r"//[^\n]*|/\*.*?\*/", re.DOTALL) |
There was a problem hiding this comment.
Preserve URL literals while stripping comments
When a target opening tag or class expression contains a string such as bg-[url(https://example.com/card.svg)], this regex treats the // inside the literal as a line comment and blanks the rest of the line, including subsequent classes or the closing quote. The JSX remains valid, but _class_on_testid can lose its anchor and _card_surface can report an unterminated literal, so adding an unrelated URL-valued attribute or class can break these tests. Comment stripping needs to recognize string and template literals before matching comment delimiters.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at 9ec1ab65a by adding bg-[url(https://x.test/a.svg)] to the surface: 1 failed, the // inside the literal having blanked the rest of the line along with its closing quote.
Fixed in 2a47acd82. _without_comments walks the source and skips string and template literals before it will treat // or /* as an opener, so a URL in a class stays a URL. It still blanks rather than removes, so every offset the scanners hand around is unchanged.
| if char in "\"'`": | ||
| end = _skip_literal(tag, index) | ||
| parts.append(tag[index + 1 : end - 1]) | ||
| index = end |
There was a problem hiding this comment.
Reject conditional surface utilities
When a required surface class is made conditional, every quoted branch is still appended as though it were rendered. For example, after replacing the unconditional overflow-hidden with cn(false && "overflow-hidden", "..."), test_only_the_notes_region_scrolls remains green even though the painted surface no longer clips at runtime. The extractor should distinguish unconditional classes from conditional alternatives, or the assertion should reject required rules found only in conditional expressions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and the pair of these is the sharper version of a mistake the whole PR is about, so I have taken the general fix rather than the narrow one.
Confirmed at 9ec1ab65a: replacing the surface's overflow-hidden with cn(false && "overflow-hidden", "...") left 4 passed while the painted surface no longer clips.
The root cause is that _class_value read every literal out of the expression, which asks "is this class written here" when the assertion means "does this class always render". Those are different questions and the file has been answering the wrong one.
Fixed in 2a47acd82. _always_rendered splits a cn() on its top-level commas and keeps only the arguments that are a bare literal. cn(open && "x") renders x sometimes, and a rule the card must always carry is not satisfied by sometimes; cn(false && "x") renders it never. Neither now counts, while cn("x") and className="x" both do.
The mutation above now fails, as does the cn(open ? "a" : "z", "b") form.
| key = "className={cn(" | ||
| tag = clean[start:end] | ||
| assert key in tag, "the card's root no longer builds its classes with cn()" | ||
| return _unpositioned_branch(clean[start + tag.index(key) : end]) |
There was a problem hiding this comment.
Reject conditionally disabled floor utilities
When the floor-bearing argument in either banner is changed to false && "has-[...]:min-h-[...] ...", this returns the raw branch and _tokens still sees every required floor and shrink utility; both _assert_floored calls therefore pass while those rules never reach the DOM. Required rail classes need to be verified as active arguments rather than merely appearing anywhere in the unpositioned expression.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and the same cause as the sibling thread. Confirmed at 9ec1ab65a by rewriting the floor-bearing argument to false && "has-[...]:min-h-[...] ...": 4 passed, with neither floor nor shrink reaching the DOM.
Fixed in 2a47acd82. _card_slot no longer returns the raw text of the unpositioned branch for _tokens to scan. It returns what that branch always renders, through the same _always_rendered used for the surface, so a rail class behind a constant is absent as far as _assert_floored is concerned.
Both floor tests now fail on that mutation.
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a47acd821
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| part = argument.strip() | ||
| if part[:1] in ('"', "'", "`") and _skip_literal(part, 0) == len(part): | ||
| literals.append(part[1:-1]) | ||
| return " ".join(literals) |
There was a problem hiding this comment.
Apply cn's merge semantics before asserting classes
When a later unconditional literal conflicts with a required utility—for example, adding "has-[[data-slot=update-release-notes]]:min-h-[1px]" after the scaled floor in either banner's existing cn()—this joins both raw literals, so _only_under still finds the expected floor and the tests pass. At runtime, however, cn runs twMerge(clsx(inputs)) (studio/frontend/src/lib/utils.ts:21-22), which removes the earlier floor and leaves only the 1px replacement. Account for Tailwind conflict resolution, or explicitly reject conflicting utilities, before treating these literals as the classes that render.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct on the mechanism, and I am not going to act on it here. Recording why, since it is the one item in this PR I am leaving open rather than fixing.
cn is twMerge(clsx(inputs)), so a later conflicting utility removes an earlier one and the class that renders is not the class that is written. This file reads source, so it cannot see that.
I checked whether it is reachable today rather than assuming. Neither banner has a conflicting pair: the two floors differ by variant (has-[...] against max-[383px]:has-[...]), which twMerge keeps separately, and shrink-0 and has-[...]:shrink are different utilities under different gates. So the mutation you describe has to be introduced deliberately.
Reimplementing Tailwind's conflict resolution in a Python test to defend against that is disproportionate and would itself be a source of wrong answers, and rejecting all conflicts outright would fail the moment a legitimate override is added. The layer that sees evaluated classes is the browser probe #10229 added, tests/studio/playwright_update_banner_layout.py, which measures the rendered card. That is where this belongs.
Two of the three in this round were reachable and are fixed in a9c081791.
|
|
||
| def _class_const(source: str, name: str) -> str: | ||
| """The class string of an exported `const NAME = "..."`.""" | ||
| match = re.search(rf'\b{re.escape(name)}\b\s*=\s*\n?\s*"([^"]*)"', source) |
There was a problem hiding this comment.
Ignore commented-out class constants
If either checked layout constant has an old declaration left in a // or /* ... */ comment before the active export, this raw search returns the commented value. For example, a commented copy of the correct UPDATE_NOTES_ROOT_CLASS followed by an active value missing min-h-0, flex-1, and overflow-hidden still makes test_only_the_notes_region_scrolls pass. Unlike the banner extractors, this helper never strips comments or anchors the match to an active export const, so a stale comment can mask a real layout regression.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and it is the same soundness hole as the block-comment one from the last round, in the one extractor I did not carry the fix into. Confirmed at 2a47acd82 by leaving a correct single-line commented copy of UPDATE_NOTES_ROOT_CLASS above an active one cut down to "mt-3 flex": 4 passed, with min-h-0, flex-1 and overflow-hidden all gone from the live constant.
Fixed in a9c081791. _class_const runs _without_comments first, like the banner extractors, and anchors on export const rather than the bare name, so neither a commented declaration nor a local of the same name can answer for the exported one.
That mutation now fails both parametrizations.
| child = clean.index("<", end) | ||
| start, child_end = _opening_tag(clean, child + 1) | ||
| return _class_value(clean[start:child_end], "the painted surface") |
There was a problem hiding this comment.
Skip transparent fragments when locating the card surface
When either banner wraps its existing painted <div> in a React fragment (<>...</>), the rendered DOM and layout are unchanged because the fragment emits no element, but this lookup treats the fragment's < as the first child opening tag. _class_value then raises that the painted surface has no className, causing test_only_the_notes_region_scrolls to fail on a behavior-preserving JSX refactor. Traverse transparent fragments to the first rendered child element rather than assuming the next raw < is the surface.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at 2a47acd82 by wrapping the painted <div> in a fragment, which emits no element and changes no rendered class: 1 failed, on the painted surface carries no className.
Fixed in a9c081791. _card_surface steps over <> before taking the first child's opening tag, so a transparent wrapper is treated as what it is rather than as the surface.
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9c0817913
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if char in "\"'`": | ||
| index = _skip_literal(source, index) |
There was a problem hiding this comment.
Distinguish JSX text apostrophes from string literals
When unquoted JSX text anywhere in a banner contains an apostrophe, _without_comments treats it as the start of a JavaScript string and scans until another apostrophe—or raises if none is found. For example, adding We're ready to the compact Tauri banner before the full update card leaves all relevant DOM classes unchanged but makes _card_slot and _card_surface raise unterminated ' literal, breaking these tests on a valid copy-only edit. Only invoke the literal skipper in JavaScript/string contexts rather than on every quote in the TSX source.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. It took me two attempts to reproduce, which is worth recording: adding an apostrophe to the browser banner's copy does nothing, because that file already contains one and the count stays even. The desktop banner has none, so changing its Remind me later to Unsloth's reminder is enough: 2 failed at a9c081791, on unterminated ' literal.
Fixed in 2c1eaa6ee. The scanners no longer treat ' as a literal opener at all. The frontend is formatted to double quotes and none of the four files this test reads contains a single-quoted string, so the only thing a bare ' can be here is prose, and prose must not steer a scan.
That edit now passes.
| for argument in _arguments(text): | ||
| part = argument.strip() | ||
| if part[:1] in ('"', "'", "`") and _skip_literal(part, 0) == len(part): | ||
| literals.append(part[1:-1]) |
There was a problem hiding this comment.
Recurse into unconditional nested class combiners
When an always-on literal is grouped in a nested cn(...), this loop discards the whole nested call because it accepts only top-level bare literals. Wrapping the two existing unpositioned-card arguments as cn(cn("...", "...")) renders the same classes, but _card_slot becomes empty and both floor tests fail. Since nesting cn is a behavior-preserving grouping refactor, _always_rendered should recursively extract unconditional arguments from nested class combiners.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. Confirmed at a9c081791 by wrapping the two unpositioned arguments as cn(cn("...", "...")), which renders the same classes: 1 failed, the slot having come back empty.
Fixed in 2c1eaa6ee. _always_rendered recurses into an argument that is itself a fully balanced call, so grouping is grouping. It still takes only arguments that always render, at every level, so the false && "..." case from the last round stays caught inside a nested combiner too.
| if char in "([{": | ||
| depth += 1 | ||
| elif char in ")]}": | ||
| depth -= 1 | ||
| elif char == ":" and depth == 0 and text[index - 1] != "?": | ||
| return text[index + 1 :] |
There was a problem hiding this comment.
Track nested ternaries when selecting the rail branch
When the positioned arm gains its own ternary, this scan treats that inner ternary's colon as the separator for the outer positioned ? ... : .... For example, positioned ? compact ? "fixed" : cn("<expected floors>") : cn("min-h-0") makes _card_slot inspect the positioned arm's classes and ignore the actual rail arm; all floor assertions can then pass even though the unpositioned card renders min-h-0 and none of the required floors. Track ternary nesting, not only bracket depth, before returning the outer false arm.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and this one is a soundness hole rather than a false failure, so thank you for it.
My first attempt at reproducing it passed, and the reason is worth stating: I left the real rail arm intact, so returning it was the right answer and the test was correct to be green. The hole needs the rail arm to be the broken one. Written as positioned ? compact ? "fixed" : cn("<the floors> shrink-0") : cn("min-h-0"), so the floors sit in the positioned arm and the card renders min-h-0: 4 passed at a9c081791, with the rail able to squeeze the card to nothing.
Fixed in 2c1eaa6ee. _unpositioned_branch counts ternary nesting as well as brackets, so an inner ? raises what the next : closes and only the outer separator returns the branch. Optional chaining is not counted as a ternary.
That mutation now fails.
…ry is not the separator
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c1eaa6ee5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| elif _CALL.match(part) and _balanced(part, part.index("(")) == len(part): | ||
| # Grouping the arguments in a nested `cn()` renders the same | ||
| # classes, so it has to read the same rather than as none at all. | ||
| literals.append(_always_rendered(part)) |
There was a problem hiding this comment.
Restrict recursion to actual class combiners
When a required class literal is passed to any other call accepted by cn, this branch still treats that call as a transparent class combiner. For example, wrapping the floor string in Boolean("has-[...]:min-h-[...]") makes clsx receive true and emit none of those classes, but _always_rendered recursively extracts the literal and _assert_floored passes for both banners. Match only known transparent combiners such as cn/clsx rather than every identifier followed by (.
Useful? React with 👍 / 👎.
| elif char == "?" and depth == 0 and text[index + 1 : index + 2] not in (".", "?"): | ||
| pending += 1 |
There was a problem hiding this comment.
Consume both characters of nullish coalescing
When the positioned arm uses top-level nullish coalescing, such as positioned ? positionedClasses ?? fallback : cn("rail ..."), the first ? is ignored but the second is counted as a nested ternary. The actual outer colon then leaves pending nonzero and _unpositioned_branch raises, breaking both floor tests even though the rail-facing branch and its classes are unchanged. Recognize or advance past the complete ?? operator.
Useful? React with 👍 / 👎.
| if text[:1] in _QUOTES and _skip_literal(text, 0) == len(text): | ||
| return text[1:-1] |
There was a problem hiding this comment.
Parse template interpolations before accepting classes
When a required class is conditional inside a template literal, this branch treats the entire template source as an always-rendered literal. For example, changing the floor argument to `${notesOpen && "has-[...]:min-h-[...] ..."}` makes the floor disappear whenever notesOpen is false, but _tokens still extracts the quoted utilities from the ${...} source and _assert_floored passes. Template literals containing interpolations need expression-aware handling rather than being returned as static class text.
Useful? React with 👍 / 👎.
| if char in "([{": | ||
| depth += 1 | ||
| elif char in ")]}": | ||
| depth -= 1 |
There was a problem hiding this comment.
Skip regular-expression literals while scanning tags
When an attribute expression before the anchored data-testid contains a regex with bracket characters—for example disabled={/}/.test(value)} or disabled={/[)]/.test(value)}—the regex punctuation is counted as JSX-expression delimiters here. _opening_tag then rejects the real opening tag and the class tests fail even though adding that attribute does not alter any checked classes. The scanner needs to skip regular-expression literals just as it skips string literals.
Useful? React with 👍 / 👎.
…slothai#10289) `Repo tests (CPU)` is red on `main`, on one test out of 15,843, asserting `const writesByKey = new Map<string, Promise<void>>();`. unslothai#10160 is right and reordered nothing. Letting the API load settings panel forget an entry means `putModelOverride` returns a `ModelOverrideWriteResult` carrying `removedKeys` rather than `void`, and the queue it is stored in changed type with it. Three of the test's four assertions still match byte for byte: the key folded through `modelOverrideKey(normalizeModelIdentity, normalizeGgufVariantIdentity)`, the chain on the settled tail, and only the last writer clearing the slot. The one that broke names the promise's value type, and what a write resolves to has nothing to do with the order writes commit in. The assertion now pins serialisation through one in-flight promise per key without naming what that promise resolves to. Re-syncing the literal instead would leave it failing the next time the result type changes, which is a change that reorders nothing; this is the same shape as unslothai#10267 and unslothai#10231. One assertion is added rather than only relaxed, `writesByKey.set(key, write);`. Without the tail being stored, every writer chains on the same empty slot and the ordering is gone, and nothing in the test noticed. Verified by breaking it. Six edits to `model-overrides.ts`, each run against the test, compared with what a plain re-sync of the literal would give: | edit | re-synced literal | this change | | --- | --- | --- | | baseline | passed | passed | | result type changes again, ordering untouched | failed | passed | | the tail is never stored, a real ordering loss | passed | failed | | serialisation removed entirely | failed | failed | | writes no longer chain on the tail | failed | failed | | any writer clears the slot, not just the last | failed | failed | | the key stops folding the identity | failed | failed | The two middle rows are the point: the re-sync stays brittle against a harmless change and stays blind to a real one. `tests/studio/test_model_picker_contracts.py`: 191 passed. No source changes. Staging CI green.
…rd (unslothai#10307) `Repo tests (CPU)` was red on `main` at `99a83f6a6` and `a2a4143ce`, and so on PRs branched from them, on one test out of 15,899: ``` FAILED tests/studio/test_auth_form_input_count.py::test_auth_flow_routes_do_not_mount_global_settings assert 'if (!active || !mounted) return null;' in mount ``` unslothai#10237 gave `SettingsDialogMount` a second surface, so the single lazy-mount flag became two: ```diff - const [mounted, setMounted] = useState(open || monitorOpen); - if (!active || !mounted) return null; + if (!active || !(settingsMounted || monitorMounted)) return null; ``` That is right and it did not open the auth routes. `!active` still short-circuits, so an inactive mount still renders nothing, which is the whole of what this test is named for. The other two assertions in the test still match byte for byte, so the chain it protects, auth route to `active={false}` to nothing rendered, is intact at every link. The assertion had simply quoted the auth gate and the lazy-mount bookkeeping as one string. ## The change Assert the property rather than a spelling: `SettingsDialogMount` must return null from its own top level on every inactive render. The guard is read as a parse, because a textual match is what got us here: - Comments and string bodies are blanked first, in a same-length copy so indices still line up. The assertion this replaces matched `// if (!active || !mounted) return null;` just as happily as the live line, so the guard could have been struck out entirely and the test would have stayed green. - The slice is the real function body. The signature is `({ active }: { active: boolean })`, so the body brace is found by walking the parameter list rather than taking the first brace after the name. - Only statements directly in that body count, so `(active) => { if (!active) return null; }` cannot answer for the component. - The condition must be a disjunction whose first operand is `!active`. A top-level `?` or `,` disqualifies it, since both bind looser than `||`: `!active || mounted ? false : true` and `!active || track(), active` each leave the disjunction as a discarded sub-expression and skip the return while inactive. `?.` and `??` are neither. - `{ return null; }` is accepted alongside `return null;`, so a bracing pass does not go red for nothing. This is the same shape as unslothai#10267, unslothai#10231, unslothai#10289 and unslothai#10297. The file had already reached that conclusion twice on its own, as "Lock the count, not the spelling, so a rename does not falsely fail" and "Lock the behaviour, not one spelling of it, so either form passes". This assertion had not had the treatment. ## Verified by breaking it The predicate was checked directly against 15 conditions, all correct. Then fifteen edits to `settings-dialog-mount.tsx`, each run against the test, next to what a plain re-sync of the literal would give: | edit | re-synced literal | this change | | --- | --- | --- | | baseline | passed | passed | | both mount flags renamed | **failed** | **passed** | | a third surface joins the mount | **failed** | **passed** | | the operands reordered | **failed** | **passed** | | back to a single flag, as before unslothai#10237 | **failed** | **passed** | | optional chaining in the second operand | **failed** | **passed** | | the guard braced by a formatter | **failed** | **passed** | | the `!active` half dropped | failed | failed | | `||` becomes `&&` | failed | failed | | the whole guard deleted | failed | failed | | the gate inverted to `active` | failed | failed | | a ternary swallows the disjunction | failed | failed | | a comma expression discards the disjunction | failed | failed | | the guard moved into a nested callback | failed | failed | | the guard survives only as a comment | **passed** | **failed** | Six harmless forms pass where a re-sync goes red on all six, none of which touches the auth routes. Nine real regressions fail. The last row is the one that matters most: a re-sync, and the assertion that was there before it, both accept a guard that exists only as a comment. `tests/studio`: 7483 passed, 195 skipped. No source changes. Staging CI green.
Repo tests (CPU)is red onmainat8e26d2c2b, and on #10247, #10257, #10263, #10264 and #10265, which is every open PR that has run it since. Four failures out of 15,833:The banner fix is right and every rule these tests name is still there
#10229 is what turned them red. It did not touch this file, and no source change is needed here.
The first pair assert one verbatim run of classes on the card's painted surface. #10229 inserted
growinto the middle of it, so short notes paint the whole floor instead of leaving a gap. The cap,min-h-0,flex-colandoverflow-hiddenare all still on that element, in that order, with one class added between two of them.The other two assert the floor:
The floor constants are unchanged, as #10229 said. What changed is that the floor is now gated on the notes panel actually being rendered, which is the fix:
A second variant between
max-[383px]:and the utility, and the contiguous substring is gone. Only_NARROW_FLOOR_WEBand_NARROW_FLOOR_TAURIfail, because they are the only two that name a variant; the scaled pair still match as a suffix. That asymmetry is the tell that these are string assertions, not layout assertions.So the tests are the wrong half. This is the same shape as the
mklinkkwargs case in #10231: a check written as one exact literal over something that is a set, which then reports every legitimate edit as a regression and takes a greenmainwith it.The change
Match Tailwind tokens instead of file substrings.
_applies(source, utility, *variants)splits each class token on its top-level colons, depth-aware so an arbitrary value keeps its own brackets, and asks whether that utility appears under all of the required variants. Order between variants is Tailwind's business, so an added gate no longer reads as a missing rule, and a longer utility that merely ends with this one no longer counts as one._assert_classesdoes the same for a plain run of classes.The floor constants drop the
max-[383px]:prefix and it is passed as a variant instead.The assertions are stronger, not just looser
The floor pair now read off the rail-facing root, taken from the anchor to
data-testidso the wholecn()is in scope and with//comments stripped, since both files describe these classes in prose right beside them. On top of the two floors they now also require:shrink-0on the root, which is what holds the button row when there is no floor because there are no noteshas-[[data-slot=update-release-notes]]:shrink, so the notes can still give up their height once there are somemin-h-0on the root, which would let the rail squeeze the card past its floorThe last four are #10229's contract. It pins them in
studio/frontend/tests/update-banner-flex-priority.test.ts; this file asserted only the floors, and would have passed a card that was squeezable to nothing in the state the report was about.Verified by breaking it, not by watching it pass
Eight mutations of the two banners, each run against the four tests:
max-[383px]gateshrink-0becomesmin-h-0min-h-0The last three rows are the point. Rows 5 and 7 are regressions the previous version of these tests did not catch at all, and row 7 is the exact bug #10229 fixed.
tests/studio/test_update_release_notes.py: 187 passed. No source file changes, and no other test in the file changes behaviour.