Repository navigation
fix(cli): reach the probe TUI lazily — @opentui load-death under --isolate - #390
Merged
Merged
Conversation
…olate `cli.ts` statically imported `./probe/probe-tui-runtime.js`, which pulls `@opentui/core`. That dependency's module scope reads a namespace produced by a dynamic `import()` inside its own top-level await (`zig.ts`: `const module = await import(...); let targetLibPath = module.default`). Under `bun test --isolate` the namespace is handed out before that module finishes evaluating, so the read throws `Cannot access 'default' before initialization` *during @OpenTui's own evaluation* — killing the load of every file whose static graph reaches it. Measured, not assumed (po-204, bun 1.3.14, main 6f732eb): - Import ORDER is irrelevant: a bare `import "@opentui/core"` fails alone under `--isolate`, and core-first and react-first both fail. #386's proposed import-order fix cannot work. - `--isolate` is the whole trigger: every failing case passes without it. - Not @opentui-specific: a 6-line synthetic reproducing the same pattern reproduces the byte-identical error under `--isolate`. - Deferring the edge fixes it: `cli.test.ts` 0 pass/1 error -> 26 pass, `cli-passthrough.test.ts` -> 22 pass, `native-handler-advisor.test.ts` -> 40 pass, all under `--isolate` (88/0 across the three — the non-isolated figure). The pin (`probe-tui-import-graph.test.ts`) guards *reachability*, the lever that worked, with a premise control (the runtime really does pull @OpenTui), a detector control (the regex matches a positive) and a tree-wide scan, so a green line cannot stand for a regex that stopped matching. Refs #386
Owner
Author
|
Review myia-ai-01 — approved at f258a31. Lazy import removes the CLI static reachability of the TUI. Pin 5/5; reverting to static import makes 3 pins fail while both detector controls stay green. Targeted isolated tests 88/0; note that the original load death does not reproduce on ai-01 bun 1.3.13 (reported on po-2024 1.3.14). Closes #386 is appropriate: upstream reproduction tracked separately on #391. Verification delegated; authors, current head and merge-tree checked by coordinator. |
jsboige
added a commit
that referenced
this pull request
Oct 9, 2026
…nd don't read a seat's bun as CI's Measured on po-2024: the `.test-strict-baseline.json` learned at `fb16ef2d` (2026-10-06) still listed 3 `load error` entries that #390 had already fixed on 2026-10-08. Re-learning at `4989cdd3` dropped it 6 -> 1 (the by-design TEST-15, 0 added) and the comparison run returned `observed ⊆ baseline`. Reading the stale file as current had already produced one "the defect still bites" conclusion. Also recorded: the repo pins no bun, CI installs `bun-version: latest`, so a seat on an older bun is not commensurable with CI — bun 1.3.14's `--isolate` module-loader regression (oven-sh/bun#30634, #31410; fixed in 1.4.0) fires for a static import as much as a dynamic one, and for every TLA flavor measured (6/6). Refs #175, Refs #391 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
jsboige
added a commit
that referenced
this pull request
Oct 9, 2026
…nd don't read a seat's bun as CI's (#425) * docs(tests): a learned strict baseline is a snapshot — re-learn it, and don't read a seat's bun as CI's Measured on po-2024: the `.test-strict-baseline.json` learned at `fb16ef2d` (2026-10-06) still listed 3 `load error` entries that #390 had already fixed on 2026-10-08. Re-learning at `4989cdd3` dropped it 6 -> 1 (the by-design TEST-15, 0 added) and the comparison run returned `observed ⊆ baseline`. Reading the stale file as current had already produced one "the defect still bites" conclusion. Also recorded: the repo pins no bun, CI installs `bun-version: latest`, so a seat on an older bun is not commensurable with CI — bun 1.3.14's `--isolate` module-loader regression (oven-sh/bun#30634, #31410; fixed in 1.4.0) fires for a static import as much as a dynamic one, and for every TLA flavor measured (6/6). Refs #175, Refs #391 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docs(tests): slim the baseline/bun rule to the decision layer (~300 chars) Review a1d2885 (ai-01, changes requested): the host paragraph states the live baseline count lives in each machine's gitignored file, "never in this file" — the first cut wrote one seat's counts (`6 -> 1`, `fb16ef2d`, `4989cdd3`) into it. Kept to the two decisions: re-learn after any land that removes a cause of load-time death, and a seat on an older bun is not commensurable with CI. The measurements (TLA 6/6, upstream issues, 1.3.14 -> 1.4.0) already live on #391. Refs #175, Refs #391 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cli.tsstatically imported./probe/probe-tui-runtime.js, which pulls@opentui/core. That dependency's module scope reads a namespace produced by a dynamicimport()inside its own top-level await (zig.ts:const module = await import(...); let targetLibPath = module.default). Underbun test --isolatethe namespace is handed out before that module finishes evaluating, so the read throwsReferenceError: Cannot access 'default' before initializationduring @OpenTui's own evaluation — killing the load of every file whose static graph reaches it.What was measured (not assumed)
po-204, bun 1.3.14,
main6f732eb9.import "@opentui/core"fails alone under--isolate; a file importing core-then-react and a file importing react-then-core both fail. @opentui 0.1.87 TDZ load-death under per-file isolation — 3 baseline load errors, fix is an import-order change #386's proposed import-order fix cannot work — it was refuted before being attempted.--isolateis the whole trigger. Every failing case passes without it.@opentui-specific. A 6-line synthetic reproducing the same shape (A:const inner = await import("./plain.ts"); export default inner.default;then an importer readingA.default) reproduces the byte-identical error under--isolateand passes without it.@opentuiis simply the one dependency in our tree using TLA + dynamic import at module scope.Result under
--isolatecli.test.tscli-passthrough.test.tshandlers/native-handler-advisor.test.ts88/0 across the three — the figure #386 reported for the non-isolated run. The three permanent
load errorbaseline entries are gone.bunx tsc -p packages/cli/tsconfig.json --noEmiterror set is byte-identical before and after (the pre-existing tree-wide baseline is untouched).The pin
packages/cli/src/probe/probe-tui-import-graph.test.tsguards reachability — not ordering — with three controls that keep it honest: a premise control (probe-tui-runtimereally does pull@opentui/core, else the pin guards nothing), a detector control (the static-import regex matches a synthetic positive), and a tree-wide scan for any other static importer. Mutation-checked: revertingcli.tsto the static edge fails 3 of 5 tests while both controls stay green.Rescope of #386's third option
Option 3 (report upstream) was mis-targeted:
@opentuiis the victim, not the cause. The defect is bun's--isolatenot sequencing top-level await across the module graph. That report is a separate, outward-facing grain and is tracked in a follow-up issue rather than folded in here.Closes #386
Refs #175
🤖 Generated with Claude Code