Skip to content

Tests: make the --help, media scan, installer comparer and harness resolver checks hold on every host - #14116

Merged
danielhanchen merged 17 commits into
mainfrom
tests-generalize-1018
Oct 18, 2026
Merged

danielhanchen merged 17 commits into
mainfrom
tests-generalize-1018

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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 main and is fixed here. No product code changes.

Studio --help test (#13265)

COLUMNS=200 is not enough. Typer passes an inherited TERMINAL_WIDTH to Rich as an explicit width. GITHUB_ACTIONS, FORCE_COLOR or PY_COLORS force terminal mode, whose colour codes split every flag (--model no longer appears as a substring). On staging, the test fails on ubuntu-latest and macos-15 for exactly this reason. The test now also sets TERMINAL_WIDTH=200 and _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.

Environment main Here
none pass pass
TERMINAL_WIDTH=80 fail pass
GITHUB_ACTIONS=true fail pass
FORCE_COLOR=1 fail pass
PY_COLORS=1 fail pass
GITHUB_ACTIONS=true TERM=dumb fail pass

Media scan tests (#13395)

test_media_model_index_accounts.py and test_openai_catalog.py cleared HF_HOME and redirected XDG_CACHE_HOME. The scan also reads:

  • hf_default_cache_dir(), which is Path.home() / ".cache" / "huggingface" / "hub" and ignores XDG_CACHE_HOME;
  • the LM Studio, Hermes, Ollama and oMLX model folders, including the system-wide Ollama paths;
  • ./models under 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 HOME means 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):

Case main Here
clean 33 passed 33 passed
model in ~/.cache/huggingface/hub, ~/.lmstudio/models, OLLAMA_MODELS 4 failed 33 passed
pytest run from a folder with models/<x>/model_index.json 4 failed 33 passed

Installer 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 second transfer with no header line, where a partial frame sits between the two full bars;
  • two finished downloads of different sizes.

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 main and pass here. The existing redraw test still passes (94 passed).

Node harness resolver (#13701)

#13701 lets a const bound to an arrow or function expression be lifted even when some of its references cannot be. Two shapes could now load-crash a harness:

  • an eagerly evaluated const that calls such a helper on load (const TABLE = { v: f() }, directly or through another helper);
  • an immediately invoked 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/src found 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.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-18T10:38:50.737468Z a862fc6 New commits
🔒 Security Review ⚠️ Failed 2026-10-18T08:15:20.009974Z d0d9e88 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tests/studio/_ts_deps.py Outdated
Comment on lines +498 to +499
re.search(rf"(?<![\w$.]){re.escape(dep)}\s*\(|\bnew\s+{re.escape(dep)}\b", _blank_noise(text))
for dep in wanted & partial

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py
Comment on lines +483 to +486
grown = {
name
for name, (kind, _, wanted) in pulled.items()
if kind not in eager and not wanted <= set(pulled) - partial

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +244 to +247
and line == lines[-1]
and not frame_since_kept
and _NUMBER.findall(raw) == last_numbers
and _FULL_PROGRESS_FRAME.fullmatch(line.strip())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

pre-commit-ci Bot and others added 3 commits October 18, 2026 08:28
…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.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tests/studio/_ts_deps.py Outdated
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 "_$"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tests/studio/_ts_deps.py Outdated
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*$")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py
Comment on lines +550 to +553
grown = {
name
for name, (kind, _, wanted) in pulled.items()
if kind not in eager and not wanted <= set(pulled) - partial

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py Outdated
Comment on lines +565 to +567
re.search(
rf"(?<![\w$.]){re.escape(dep)}\s*\(|\bnew\s+{re.escape(dep)}\b",
_load_time_text(_blank_noise(text)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py Outdated
Comment on lines +404 to +406
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):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py Outdated
Comment on lines +565 to +567
re.search(
rf"(?<![\w$.]){re.escape(dep)}\s*\(|\bnew\s+{re.escape(dep)}\b",
_load_time_text(_blank_noise(text)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

pre-commit-ci Bot and others added 2 commits October 18, 2026 08:55
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.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tests/studio/_ts_deps.py
Comment on lines +429 to +430
if target is None or hops > 8:
return False

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py Outdated
Comment on lines +479 to +480
if _FUNCTION_DECL_RE.match(text.lstrip()) and (
not _FUNCTION_KEYWORD_INIT_RE.search(text) or tail.endswith("}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +229 to +231
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

…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.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tests/studio/_ts_deps.py
Comment on lines +455 to +456
if name in home.declarations:
return all(kind in {"type", "interface"} for kind, _ in home.declarations[name])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py
Comment on lines +24 to +25
_TYPE_REEXPORT_RE = re.compile(
r"^export\s+type\s+\{(?P<names>[^}]*)\}\s+from\s+[\"'](?P<spec>[^\"']+)[\"']", re.MULTILINE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/studio/_ts_deps.py
Comment on lines +57 to +58
if depth == 0:
return blanked[i + 1 :].lstrip().startswith(("(", ")("))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +228 to +230
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())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 7910a30362

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 4c5fb40 into main Oct 18, 2026
@danielhanchen
danielhanchen deleted the tests-generalize-1018 branch October 18, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant