Repository navigation
Fix OpenCode startup parser crash in the mobile terminal engine - #24626
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
132d3f3 to
9595d5b
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the full PR (there was no prior Pullfrog review): one commit fixing the mobile WebView terminal engine build plus its regression test.
- Disabled
minifySyntaxfor the mobile WebView engine — replacesminify: truewithminifyWhitespace/minifyIdentifiersinbuild-terminal-webview-engine.mjs, so esbuild's syntax folding no longer drops xterm's local DECRQM enum declaration while leaving the assignment to it. - Added the startup mode-query regression test — runs the generated engine in a VM context, constructs a
Terminal, writes OpenCode's\x1b[?1004$pquery, and asserts the engine replies\x1b[?1004;2$y.
I reproduced the failure and the fix against the pinned toolchain: with minify: true the generated requestMode emits (g=>…)(void 0||(i={})) with no i declaration and throws ReferenceError: i is not defined; with minifySyntax: false the bundle keeps let i, parses at the Chrome 74 syntax floor, and answers the query as the test expects. The bundle grows ~1% and no size budget or other engine consumer is affected.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

ELI5
OpenCode can leave the mobile terminal blank when it starts. Preserve a variable in the bundled terminal engine so it can answer OpenCode’s startup query and paint the screen.
What Changed
Disable syntax minification for the mobile WebView engine while retaining identifier and whitespace minification. Add a runtime regression that writes OpenCode’s actual focus-mode query through the generated engine and checks its response.
Why
Both the pinned mobile esbuild 0.25.4 and desktop 0.25.12 remove the local enum declaration in xterm requestMode but leave an assignment to that variable. The Chrome 74 bundle then throws ReferenceError during parsing. Turning off only the failing optimization preserves old-WebView syntax support without changing xterm, user configuration, or the terminal protocol.
Linked Issue
Addresses #14185 and #12047. These broad mobile reports still need native navigation and device checks; this fixes the independently reproduced startup parser failure rather than claiming every reported visual symptom is resolved.
Visual Proof
Attached before and after show the production mobile terminal document at 400×850 in a hidden Electron iframe, connected to a real isolated OpenCode 2.0.16 PTY. Before stays blank after the startup mode query; after renders a free-model turn and survives hiding/showing the iframe while output streams. This is the actual WebView engine, not an Expo native navigation test.
Testing
The new test fails with ReferenceError before the generator change and all eight engine tests pass after it. Real OpenCode before captured 493 chunks / 206 KB and parser exceptions; after captured 530 chunks / 221 KB with no parser exceptions. Chrome 74 syntax and offline-document checks pass. Root renderer typecheck and changed-code quality gate pass. Mobile dependencies were unavailable locally, so the source tests were bundled with esbuild and executed through the installed Vitest; full mobile typecheck/build and native device validation remain for CI and platform review.
AI Disclosure
Review
Build-only change, independent of local/SSH PTY transport and folder/git workspace selection. No new colors, window presentation, keyboard shortcuts, wire fields, main plugin/status logic, or shared launch profiles.
Agent skill upstream boundary
Notes
Generated engine files are ignored and recreated by mobile postinstall. The old-WebView runtime shims and syntax target remain in place.
Checklist