Repository navigation
Tests: make the --help, media scan, installer comparer and harness resolver checks hold on every host - #14116
Conversation
An inherited TERMINAL_WIDTH is passed to Rich as an explicit width, and GITHUB_ACTIONS, FORCE_COLOR or PY_COLORS force a terminal whose colour codes split every flag, so COLUMNS=200 alone still fails on those hosts (Ubuntu and macOS runners included). Also decode the child's UTF-8 output as UTF-8.
The scan also reads hf_default_cache_dir() (Path.home()/.cache, which ignores XDG_CACHE_HOME), the LM Studio, Hermes, Ollama and oMLX folders and ./models, so a developer with an image model in the default HF cache, or running pytest from a folder with models/, saw extra rows (4 failures).
…in between A partial frame between two full bars is a second transfer, and two full bars with different raw sizes are two downloads; both used to collapse to one bar after size normalisation and could hide an extra download.
… eager
A const evaluated on load that calls an arrow or function left with an
unresolved reference (directly or through another one) is dropped like one
that reads the reference itself, and const v = function () {...}(); is no
longer treated as a lazy function.
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. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0d9e8814b
ℹ️ 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".
| re.search(rf"(?<![\w$.]){re.escape(dep)}\s*\(|\bnew\s+{re.escape(dep)}\b", _blank_noise(text)) | ||
| for dep in wanted & partial |
There was a problem hiding this comment.
Restrict partial-helper checks to load-time calls
When an eager object or array initializer contains a lazy callback that calls a partial helper, this regex treats the nested call as if it ran during initialization. For example, const TABLE = { run: () => f() } is removed when f has an unresolved dependency, even though creating TABLE never calls f; an emitted function that references TABLE then fails with ReferenceError when the harness invokes it. The call detection needs to exclude calls inside nested function/arrow bodies.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9a63041: the load-time call check now skips the bodies of nested arrow and function expressions, so { run: () => f() } keeps TABLE. New test test_a_callback_that_calls_a_half_resolved_helper_is_not_a_load_time_call fails on the previous commit and passes now.
| grown = { | ||
| name | ||
| for name, (kind, _, wanted) in pulled.items() | ||
| if kind not in eager and not wanted <= set(pulled) - partial |
There was a problem hiding this comment.
Exclude erased type references from partial helpers
When a helper mentions an unresolved imported symbol only in a TypeScript annotation, wanted still contains that symbol and this condition marks the helper partial. An eager declaration such as const TABLE = { v: f() } is consequently dropped even though Node strips the annotation and f() is otherwise safe, leaving retained functions that reference TABLE to fail at runtime. Partial propagation should consider runtime dependencies rather than type-only references.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9a63041: a reference that resolves to a type or interface (also when declared in a .tsx file, which is never lifted) is erased by Node, so it no longer counts as a missing runtime value. New test test_a_type_only_reference_does_not_make_a_helper_half_resolved covers it.
| and line == lines[-1] | ||
| and not frame_since_kept | ||
| and _NUMBER.findall(raw) == last_numbers | ||
| and _FULL_PROGRESS_FRAME.fullmatch(line.strip()) |
There was a problem hiding this comment.
Strip ANSI metadata before comparing redraw values
On ANSI-enabled captures, two redraws of the same completed bar can differ only in whether one frame carries a style escape such as \x1b[32m; normalise_line deliberately removes that escape, but _NUMBER.findall(raw) includes its 32, so the otherwise identical redraw is retained. If only one side records that terminal-control variant, the differential lane reports a user-visible change even though both normalized bars and their transfer sizes are identical. Compare numbers after removing ANSI/control sequences while preserving the unnormalized progress values.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in bba7ec5: terminal escapes are stripped before the transfer figures are compared, so a redraw that only adds a colour escape is still a redraw. New test test_a_redraw_that_only_adds_a_colour_escape_is_still_a_redraw fails on the previous commit and passes now.
…r an eager const
A callback nested in an eager initializer ({ run: () => f() }) does not run
on load, and a name that resolves to a type or interface (even in a .tsx
file) is erased by Node, so neither dooms the const any more.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a63041945
ℹ️ 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".
| i, n = 0, len(blanked) | ||
| while i < n: | ||
| arrow = blanked.startswith("=>", i) | ||
| func = re.match(r"function\b", blanked[i:]) and (i == 0 or not (blanked[i - 1].isalnum() or blanked[i - 1] in "_$")) |
There was a problem hiding this comment.
Preserve calls made inside immediately invoked functions
When an eager initializer is an IIFE that calls a partially resolved helper, this scan removes the IIFE body as though it were a lazy callback. For example, const value = function () { return f(); }(); is classified as eager, but _load_time_text hides the f() call; if f has an unresolved dependency, value is retained and the generated harness throws during initialization. Distinguish invoked function expressions from deferred callbacks when removing function bodies.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in d127f65: a function or arrow body followed by a call is kept in the load-time scan, so function () { return f(); }() and (() => f())() count as load-time calls of f. New test test_an_immediately_invoked_function_calling_a_half_resolved_helper_is_dropped fails on the previous commit and passes now.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d127f651e5
ℹ️ 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".
| r"(?:async\s+function\b|function\b|(?:async\s*)?(?:\([^()]*\)|[A-Za-z_$][\w$]*)\s*=>)" | ||
| ) | ||
| # `const v = function () { ... }();` runs on load: an immediately invoked function stays eager. | ||
| _IIFE_TAIL_RE = re.compile(r"\}\s*\)?\s*\([^()]*\)\s*$") |
There was a problem hiding this comment.
Detect IIFEs whose arguments contain calls
The [^()]* argument matcher misclassifies an IIFE whenever its argument list contains a nested call, such as const value = function () { return f(); }(Math.max(1, 2));. It is then marked as a lazy function, so if f is partially resolved the declaration remains in the generated harness and throws during module initialization. Fresh evidence: the current resolver emits this declaration unchanged and Node raises ReferenceError before the harness runs; the invocation tail needs balanced-parenthesis handling rather than forbidding parentheses.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 2603b81 with a simpler rule instead of more call detection: deciding which calls in an initializer run on load (IIFE arguments, aliases, optional calls, method bodies, short-circuits) needs an evaluator, so an eager const that references a helper left with an unresolved name, by any path, is now dropped. A load-time crash costs more than the lazy ReferenceError a dropped declaration can cause, which is the rule this file already follows. Each of these shapes is covered by test_any_eager_reference_to_a_half_resolved_helper_drops_the_const. Over every top-level declaration in studio/frontend/src this changes 68 harnesses: none stops loading, and two that crashed on load on main now load.
| grown = { | ||
| name | ||
| for name, (kind, _, wanted) in pulled.items() | ||
| if kind not in eager and not wanted <= set(pulled) - partial |
There was a problem hiding this comment.
Propagate partialness through callable aliases
When a partial helper is first assigned to an eager alias, as in const alias = f; const TABLE = { v: alias() };, this set excludes alias solely because it is a const. Consequently the later call is not recognized as invoking a partial helper, all three declarations are emitted, and initialization throws when alias() reaches f's missing dependency. Partial callable state needs to flow through such aliases before eager callers are classified.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 2603b81 with a simpler rule instead of more call detection: deciding which calls in an initializer run on load (IIFE arguments, aliases, optional calls, method bodies, short-circuits) needs an evaluator, so an eager const that references a helper left with an unresolved name, by any path, is now dropped. A load-time crash costs more than the lazy ReferenceError a dropped declaration can cause, which is the rule this file already follows. Each of these shapes is covered by test_any_eager_reference_to_a_half_resolved_helper_drops_the_const. Over every top-level declaration in studio/frontend/src this changes 68 harnesses: none stops loading, and two that crashed on load on main now load.
| re.search( | ||
| rf"(?<![\w$.]){re.escape(dep)}\s*\(|\bnew\s+{re.escape(dep)}\b", | ||
| _load_time_text(_blank_noise(text)), |
There was a problem hiding this comment.
Recognize optional calls of partial helpers
For an eager initializer such as const TABLE = { v: f?.() };, this call regex does not match because ?. appears between the dependency name and (. Since the emitted f declaration exists, optional chaining does not short-circuit; it executes f and reaches its unresolved dependency, crashing the generated harness during initialization. The load-time call detection should include optional-call syntax.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 2603b81 with a simpler rule instead of more call detection: deciding which calls in an initializer run on load (IIFE arguments, aliases, optional calls, method bodies, short-circuits) needs an evaluator, so an eager const that references a helper left with an unresolved name, by any path, is now dropped. A load-time crash costs more than the lazy ReferenceError a dropped declaration can cause, which is the rule this file already follows. Each of these shapes is covered by test_any_eager_reference_to_a_half_resolved_helper_drops_the_const. Over every top-level declaration in studio/frontend/src this changes 68 harnesses: none stops loading, and two that crashed on load on main now load.
| arrow = blanked.startswith("=>", i) | ||
| func = re.match(r"function\b", blanked[i:]) and (i == 0 or not (blanked[i - 1].isalnum() or blanked[i - 1] in "_$")) | ||
| if not (arrow or func): |
There was a problem hiding this comment.
Exclude method bodies from the load-time scan
This scanner removes arrow and function bodies but leaves object and class method bodies in the load-time text. Thus safe declarations such as const TABLE = { run() { return f(); } }; or class Safe { run() { return f(); } } are dropped when f is partial even though defining them never invokes f; a retained function that returns TABLE or Safe then throws ReferenceError. Method, getter, and setter bodies need the same deferred-body treatment as other non-invoked functions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 2603b81 with a simpler rule instead of more call detection: deciding which calls in an initializer run on load (IIFE arguments, aliases, optional calls, method bodies, short-circuits) needs an evaluator, so an eager const that references a helper left with an unresolved name, by any path, is now dropped. A load-time crash costs more than the lazy ReferenceError a dropped declaration can cause, which is the rule this file already follows. Each of these shapes is covered by test_any_eager_reference_to_a_half_resolved_helper_drops_the_const. Over every top-level declaration in studio/frontend/src this changes 68 harnesses: none stops loading, and two that crashed on load on main now load.
| re.search( | ||
| rf"(?<![\w$.]){re.escape(dep)}\s*\(|\bnew\s+{re.escape(dep)}\b", | ||
| _load_time_text(_blank_noise(text)), |
There was a problem hiding this comment.
Respect short-circuiting before marking eager calls unsafe
The regex treats every syntactic call as executed at load time, even when control flow makes it unreachable. For example, const SAFE = !true && f(); is an accepted safe initializer and evaluates without calling a partial f, but the new check drops SAFE; a retained read() that returns it then fails with ReferenceError. The load-time analysis must account for statically short-circuited logical or conditional branches rather than treating mere call syntax as execution.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 2603b81 with a simpler rule instead of more call detection: deciding which calls in an initializer run on load (IIFE arguments, aliases, optional calls, method bodies, short-circuits) needs an evaluator, so an eager const that references a helper left with an unresolved name, by any path, is now dropped. A load-time crash costs more than the lazy ReferenceError a dropped declaration can cause, which is the rule this file already follows. Each of these shapes is covered by test_any_eager_reference_to_a_half_resolved_helper_drops_the_const. Over every top-level declaration in studio/frontend/src this changes 68 harnesses: none stops loading, and two that crashed on load on main now load.
Deciding which calls in an initializer run on load (IIFE arguments, aliases, optional calls, method bodies, short-circuits) needs an evaluator. Follow the file's rule instead: a load-time crash costs more than a dropped declaration, so an eager const that references a helper left with an unresolved name, by any path, is dropped. Over every top-level declaration in studio/frontend/src this changes 68 harnesses: none stops loading, and two that crashed on load on main (imageOptionIds, videoOptionIds in model-catalog.check.ts) now load.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2603b81da8
ℹ️ 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 target is None or hops > 8: | ||
| return False |
There was a problem hiding this comment.
Follow type-only re-exports before marking helpers partial
Fresh evidence in the current code: when an annotation is imported through a barrel using export type { Props } from "./types", _Module._parse does not put that export in reexports, so this branch returns false even though Props is erased by Node. A helper annotated with Props is therefore marked partial, an eager constant using the helper is pruned, and an emitted accessor for that constant fails with ReferenceError; recognize type-only re-exports while following the type.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ed898a1: export type { ... } from re-exports are now parsed (kept apart from value re-exports, so they are never lifted) and followed when deciding whether a name is erased. New test test_a_type_reexported_through_a_barrel_is_still_erased.
| if _FUNCTION_DECL_RE.match(text.lstrip()) and ( | ||
| not _FUNCTION_KEYWORD_INIT_RE.search(text) or tail.endswith("}") |
There was a problem hiding this comment.
Keep asserted function expressions lazy
When a function expression has an erased TypeScript suffix such as const f = function () { return missing(); } as Fn, the tail no longer ends in }, so this condition classifies the declaration as eager even though constructing it executes nothing. If another lifted function merely returns f, partial-dependency pruning deletes f and that accessor now throws ReferenceError; detect an actual invocation after the function expression rather than using the final character.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ed898a1: a function expression counts as invoked only when a call follows its body (function () {...}(...)), so {...} as Fn and {...} satisfies Fn stay lazy. New test test_an_asserted_function_expression_stays_lazy.
| def _raw_numbers(raw: str) -> list[str]: | ||
| """The transfer figures a frame shows, without the digits inside its terminal escapes.""" | ||
| return _NUMBER.findall(_CONTROL.sub("", raw)) |
There was a problem hiding this comment.
Include size units when identifying redraws
When consecutive completed bars have the same numeric mantissas but different units, such as 1.0 MB / 1.0 MB followed by 1.0 GB / 1.0 GB, both normalize to the same line and _raw_numbers returns ['1.0', '1.0'] for each. If no partial frame or header was captured between them, the second genuine transfer is discarded as a redraw, so a base transcript with two downloads compares equal to a head transcript containing only the first; compare the raw transfer values including their units after stripping controls.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c6ce5a4: a repeated bar is dropped only when the whole raw frame matches, sizes and units included, after terminal escapes are stripped. New test test_two_finished_downloads_differing_only_in_units_still_compare.
…re calling a bar a redraw
…ions lazy
export type { A } from "./x" in a barrel names a type Node erases, and
function () {...} as Fn builds a function without calling it; only a call
right after the body (function () {...}(...)) makes it run on load.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed898a141b
ℹ️ 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 name in home.declarations: | ||
| return all(kind in {"type", "interface"} for kind, _ in home.declarations[name]) |
There was a problem hiding this comment.
Ignore value symbols used only in erased type positions
Fresh evidence after the current type-only fix: a value declaration can also appear solely in an erased annotation, as in const g = (cb: typeof f) => 1, where f is a half-resolved helper. Because this check classifies f by its declaration kind rather than by the reference's syntactic position, g becomes partial and an otherwise safe eager initializer calling g is removed; a retained accessor for that initializer then throws ReferenceError, even though Node erases typeof f and the original initializer is safe.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this one: telling an erased typeof f in an annotation apart from a runtime use needs a TypeScript-aware parse of the reference position, which this helper deliberately does not do. The cost is the conservative side of the rule here: the eager const is dropped rather than risk a load-time crash, and a test that then calls its accessor fails with a named ReferenceError. No declaration in studio/frontend/src has this shape today.
| _TYPE_REEXPORT_RE = re.compile( | ||
| r"^export\s+type\s+\{(?P<names>[^}]*)\}\s+from\s+[\"'](?P<spec>[^\"']+)[\"']", re.MULTILINE |
There was a problem hiding this comment.
Parse inline type-only re-exports
This only recognizes export type { Props }, not the equally valid and already-used frontend form export { type Props } from "./types" (for example, studio/frontend/src/components/file-viewer/index.ts). When a sliced helper imports such a type through the barrel, the normal re-export parser skips the type entry and this map never records it, so the helper is marked partial, safe eager dependents are pruned, and retained accessors fail with ReferenceError.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 7910a30: the type entries of export { type A, B } from ... are recorded as erased types, so a helper annotated with a type from such a barrel is not marked partial. New test test_an_inline_type_reexport_through_a_barrel_is_still_erased.
| if depth == 0: | ||
| return blanked[i + 1 :].lstrip().startswith(("(", ")(")) |
There was a problem hiding this comment.
Treat method-invoked function expressions as eager
Fresh evidence beyond the direct-IIFE fix: an initializer such as const value = function () { return missing(); }.call(null); also invokes the function during module loading, but the suffix does not start with either accepted pattern. The declaration is therefore classified as a lazy function and retained despite its unresolved dependency, causing the generated harness to throw before its tests run; .apply(...) and optional method calls have the same problem.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this one: an IIFE spelled function () {...}.call(...) or .apply(...) is not a shape the frontend uses (none in studio/frontend/src), and following method-call invocations would need a real expression parser. The direct function () {...}(...) form, the one that occurs, is handled.
| def _raw_frame(raw: str) -> str: | ||
| """The frame as drawn, sizes and units included, without terminal escapes or spacing.""" | ||
| return " ".join(_CONTROL.sub("", raw).split()) |
There was a problem hiding this comment.
Strip redraw backspaces from raw frames
When the terminal emits a duplicate completed bar with \x08 backspace controls, normalise_line removes those controls, so the normalized lines compare equal, but _raw_frame retains them because _CONTROL only strips ANSI escape sequences and split() does not discard backspaces. The duplicate is therefore kept and a transcript that captured this redraw variant compares different from an otherwise identical run; apply the same backspace/control stripping before comparing raw frames while preserving the transfer sizes and units.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e0963be: the raw frame drops the same carriage returns and backspaces the line normaliser drops, then compares sizes and units. New test test_a_redraw_drawn_with_backspaces_is_still_a_redraw.
…ore comparing raw frames
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ 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". |
Follow-up to #13265, #13395 and #13701. Each one was rechecked on other hosts and environments, and these four gaps showed up. Each one reproduces on
mainand is fixed here. No product code changes.Studio
--helptest (#13265)COLUMNS=200is not enough. Typer passes an inheritedTERMINAL_WIDTHto Rich as an explicit width.GITHUB_ACTIONS,FORCE_COLORorPY_COLORSforce terminal mode, whose colour codes split every flag (--modelno longer appears as a substring). On staging, the test fails onubuntu-latestandmacos-15for exactly this reason. The test now also setsTERMINAL_WIDTH=200and_TYPER_FORCE_DISABLE_TERMINAL=1(both present from Typer 0.19, the floor), and it decodes the child's output as UTF-8 so a CJK Windows code page cannot break the decode.mainTERMINAL_WIDTH=80GITHUB_ACTIONS=trueFORCE_COLOR=1PY_COLORS=1GITHUB_ACTIONS=true TERM=dumbMedia scan tests (#13395)
test_media_model_index_accounts.pyandtest_openai_catalog.pyclearedHF_HOMEand redirectedXDG_CACHE_HOME. The scan also reads:hf_default_cache_dir(), which isPath.home() / ".cache" / "huggingface" / "hub"and ignoresXDG_CACHE_HOME;./modelsunder the working directory.So the most common developer setup, an image model in the default HF cache, still added rows. Both fixtures now point those helpers at the test's temp dir and run from it. Patching the helpers rather than
HOMEmeans the fix works the same on Windows (USERPROFILE), macOS and Linux.Result with a fake image model planted in each location (33 tests in each case):
main~/.cache/huggingface/hub,~/.lmstudio/models,OLLAMA_MODELSmodels/<x>/model_index.jsonInstaller differential comparer (#13265)
The rule that drops a repeated 100% bar (a winget redraw) compared lines after sizes were normalised. That made two genuinely different events collapse into one bar and compare equal:
A repeat is now dropped only when no partial frame was seen since the kept bar and the raw numbers match. Two new tests cover these cases; they fail on
mainand pass here. The existing redraw test still passes (94 passed).Node harness resolver (#13701)
#13701 lets a
constbound to an arrow or function expression be lifted even when some of its references cannot be. Two shapes could now load-crash a harness:const TABLE = { v: f() }, directly or through another helper);const v = function () { ... }();, which runs on load.The first is now dropped like a const that reads the missing reference itself. A const that only names the helper (
[g]) is kept. The second stays eager.No current frontend source has either shape: a sweep of every top-level declaration in
studio/frontend/srcfound no harness that loads only on one side. All 278 tests that use the resolver pass, and the two new tests fail with the old resolver.