Repository navigation
Conversation
…eam.preview - `mapCachedBlock` called `stream.preview` on every multi-line block, so an addon that predates that method (a workspace tree runs its previous release's addon by design) threw `stream.preview is not a function` and took the TUI down with every edit diff, write card and code fence. - The loader's `missingNativeExport` guard covers exports, not methods; `mapCachedBlock` now checks the prototype and returns undefined, so callers keep their uncached path. - The regression test removes `preview` from the prototype; the incremental "parses only new lines" test skips without it.
Codex Review Summary: ❌ FailedThis 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 usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
roboomp
left a comment
There was a problem hiding this comment.
Thanks @andreyors. The diagnosis is clear and the fix works for the skew it targets: mapCachedBlock returns undefined before calling stream.preview, callers fall back to uncachedSpans, and the regression test strips preview from the prototype and restores it in finally.
Rank P2, a maintainer call: released installs and compiled binaries validate the addon version, so only workspace/locally built trees hit this. The loader's documented policy for those trees is to fail loudly with rebuild instructions (missingNativeExport/missingNativeClass). This PR adds a silent per-method fallback at the callsite instead. See the inline question: loader-level method stubs, or keep the fallback plus a one-time warning.
should-fix: the CHANGELOG entry needs the PR link and contributor credit.
| // runs its previous release's addon by design (see the loader's `validateLoadedBindings`), | ||
| // whose `missingNativeExport` guard covers exports, not methods. Without a provisional | ||
| // tail there is no block to reuse: the caller highlights from scratch. | ||
| if (typeof HighlightStream.prototype.preview !== "function") return undefined; |
There was a problem hiding this comment.
Question for the maintainer (design): validateLoadedBindings deliberately skips validation for workspace loads, and the comment at packages/natives/native/loader-state.js:487-490 says the mismatch "is not swallowed silently". Exports that a stale addon lacks get missingNativeExport/missingNativeClass stubs that throw with the addon path, both versions, and the rebuild command. This probe goes the other way for methods: on a stale addon it turns off block reuse with no log and no nativeAddonStatus() diagnostic, so a dev tree just gets slower and nothing tells you to rebuild. It also sets a per-callsite precedent, so every method later added to a native class needs its own typeof prototype.x guard. Two options: handle method drift in the loader so the class-level stub reports it with the same message, or keep this fallback and add a one-time logger.warn that includes nativeAddonStatus(). Released installs and compiled binaries validate the addon version, so they never reach this branch.
| - Key hints draw a theme's `symbols.overrides` for `key.*` keys, so a theme's Esc glyph now reaches the interrupt hint ([#20926](https://github.com/can1357/oh-my-pi/issues/20926), [#21128](https://github.com/can1357/oh-my-pi/pull/21128) by [@JamieJ5926](https://github.com/JamieJ5926)). | ||
| - Edit diffs preserve each line’s original spacing when highlighting changed words. Long replacements with many differing words skip word highlighting to keep rendering responsive ([#21201](https://github.com/can1357/oh-my-pi/pull/21201) by [@JustasMasiulis](https://github.com/JustasMasiulis)). | ||
| - A bracketed paste that passes its byte cap no longer delivers the rest of its body as keystrokes; the body is dropped up to the end marker ([#21124](https://github.com/can1357/oh-my-pi/pull/21124) by [@JamieJ5926](https://github.com/JamieJ5926)). | ||
| - Multi-line code in diffs, file previews and tool output renders again instead of crashing with `stream.preview is not a function` when the loaded native addon is older than the JavaScript that calls it (a workspace tree on its previous release's addon). |
There was a problem hiding this comment.
should-fix: this external contribution needs the attribution required by AGENTS.md: ([#21252](https://github.com/can1357/oh-my-pi/pull/21252) by [@andreyors](https://github.com/andreyors)). The PR checklist marks it done, but the entry doesn't have it. Also, released installs validate the addon version, so only workspace and locally built trees hit this. Consider saying that, so users of published builds don't read it as a fix for them.
What
I reviewed the diff; multi-line code crashed the TUI whenever the native addon was older than the JS, so the cached highlight path now falls back to full highlighting when
previewis missing.mapCachedBlockcallsstream.preview(...)for the provisional tail of every multi-line block. When the loaded native addon'sHighlightStreampredatespreview(a workspace tree runs its previous release's addon by design,validateLoadedBindingsskips validation there), that call throwsTypeError: stream.preview is not a functionand takes the TUI down on the first edit diff, write card or code fence. The loader'smissingNativeExportguard covers exports, not methods.mapCachedBlocknow checkstypeof HighlightStream.prototype.previewonce and returns undefined, so callers keep their existing uncached path (correct highlighting, no incremental reuse). A regression test removespreviewfrom the prototype; the incremental "parses only new lines" test isit.skipIfwithout it, since it needspreview.Why
Fatal
Uncaught exception(session exit reasonuncaught_exception) in a locally compiled binary whose embedded addon is older than the JS calling it; reproduced with the publishedpi-natives-darwin-arm64@19.4.0addon under the post-19.4.0 tree.Testing
highlightCode("const x = 1;\n/* open\nstill open", "typescript", theme)with the 19.4.0 addon throwsstream.preview is not a function. (In 'stream.preview(code.slice(end))', 'stream.preview' is undefined). After: 3 rows;renderDiffon a.tsdiff renders 5 rows.omp --resumeof the crashing session in a PTY: old binary exits 1 (uncaught_exception, fatal); rebuilt binary renders and exits 0 (dispose, normal). Resumed interactively on the rebuilt binary afterwards: no crash.bun test packages/tui/test/text178 pass / 30 skip / 0 fail;packages/tuibun run checkpasses; rootbun run check:tspasses (23 packages).check:rsnot run: no Rust toolchain locally.bun checkpasses (TypeScript half;check:rsnot runnable locally)