Repository navigation
Conversation
This branch has not been deployed
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.
Problem
Right after
ui.submit, oneui.matchesRPC sometimes gets no reply at all.pollhad no per-attempt bound, so that single attempt waited through the whole wait timeout, andwaitForfailed withUiWaitTimeoutErroreven though the text was on screen. The next call returnstrueimmediately.Root cause (in OpenCode, not Drive)
A wire trace (logging each frame sent and received in
opencode-protocol.ts) showed that Drive sent{"id":23,"method":"ui.matches"}and OpenCode never sent a response with id 23. Drive's RPC client is fine. The isolated instance'sopencode.logshows why:packages/simulation/src/frontend/actions.ts:94:screen()callscurrentRenderBuffer.getRealCharBytes(). While a render holds the output buffer lease (which happens while the first streamed reply is painting), that call throwsOutputBusy.ui.matches(frontend/server.ts:24) wraps it inEffect.sync, so the error becomes a defect.packages/simulation/src/control-server.ts:46-47:Effect.catchonly handles typed failures and sends a JSON-RPC error. The defect falls through toEffect.catchCause, which only logs a warning and never replies. The client is left waiting forever.(Line numbers are from OpenCode
dev@ b4c5c9cae3.) The proper fix in OpenCode is to send a JSON-RPC error from thecatchCausebranch, or to retry or await the render before reading the buffer.ui.stateandui.snapshotgo through the same path and have the same exposure.Fix in Drive
Until OpenCode sends that reply,
waitFor,getElement, andgetNodebound each polling attempt tomin(requestTimeout / 2, 1s). A timed-out attempt counts as "not yet", and the loop polls again, so one lost reply can't take over the whole wait. Direct calls (ui.matches(),ui.state()) keep the existingUiTimeoutErrorbehavior, and polling still does not retry RPC errors.Verification
ui.matches,ui.state, andui.snapshot. With the fix,waitFor,getNode, andgetElementall succeed. Onmainit fails withUiTimeoutError.opencode2:llm.serve("Hello there."),ui.submit("Say hi"), thenui.waitFor("Hello there.", { timeout: 5000 }), run 12 times each:main: 6/12 timed out withUiWaitTimeoutError.bun run checkandbun run testpass.