Skip to content

Fix OpenCode startup parser crash in the mobile terminal engine - #24626

Merged
nwparker merged 1 commit into
mainfrom
fix/opencode-mobile-mode-query-campaign
Oct 2, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/opencode-mobile-mode-query-campaign

Conversation

@nwparker

@nwparker nwparker commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

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

  • I manually tested these changes locally
  • Automated tests added/updated

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

  • Not applicable; no upstream skill material copied.

Notes

Generated engine files are ignored and recreated by mobile postinstall. The old-WebView runtime shims and syntax target remain in place.

Checklist

  • This PR is small and focused
  • I explained the before/after, mechanism, and choice
  • Before/after screenshots attached
  • Self-reviewed
  • Cross-platform and SSH impact considered
  • Focused tests and changed quality pass; CI covers full mobile build

mobile-public-before

mobile-after-tab-return

@nwparker
nwparker marked this pull request as ready for review October 2, 2026 08:36
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: dca98f59-9f66-4700-829d-df3933a9c2d8

📥 Commits

Reviewing files that changed from the base of the PR and between efbf651 and 9595d5b.

📒 Files selected for processing (2)
  • mobile/scripts/build-terminal-webview-engine.mjs
  • mobile/src/terminal/terminal-webview-engine.test.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker force-pushed the fix/opencode-mobile-mode-query-campaign branch from 132d3f3 to 9595d5b Compare October 2, 2026 09:46

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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 minifySyntax for the mobile WebView engine — replaces minify: true with minifyWhitespace/minifyIdentifiers in build-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$p query, 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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 8186ded into main Oct 2, 2026
23 checks passed
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