fix(server): reset session status to idle when async prompt fails - #46125
Open
CannonRS wants to merge 1 commit into
Open
fix(server): reset session status to idle when async prompt fails#46125CannonRS wants to merge 1 commit into
CannonRS wants to merge 1 commit into
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #45610
Type of change
What does this PR do?
The
promptAsyncHTTP handler inpackages/opencode/src/server/routes/instance/httpapi/handlers/session.tsforks the prompt into a background fiber and only publishes aSession.Event.Errorwhen the prompt fails. The session'sSessionStatusentry was never reset in that error path, so the session stays in its last non-idle status (busyorretry) and downstream callers see it as still running.This PR adds a single
statusSvc.set(sessionID, { type: "idle" })call inside theEffect.catchCauseblock ofpromptAsync, wrapped inEffect.ignoreso a transient status write failure cannot mask the original error event. The fix mirrors whatprompt.cancelalready does on the synchronous loop path and keeps the rest of the handler unchanged.The
idlestatus also publishes the existingSessionStatus.Event.Idleevent through the samestatusSvc.setpath, so subscribers (UI, TUI, plugin hooks) get a consistent transition they already handle.How did you verify your code works?
packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts(the only Hunk ingit diff upstream/dev..HEAD).promptAsync→requireSession→promptSvc.prompt→Effect.catchCause→Effect.forkIn. The new call sits inside the catch block, so it only runs when the prompt fiber actually fails.SessionStatus.set({ type: "idle" })is the same API used bySessionPrompt.canceland other status reset paths; verified it deletes the map entry and publishes theIdleevent.bun typecheckruns cleanly in the package afterbun installin the worktree (tsgo --noEmitexit 0, againstupstream/devheaddc4449df0d+ this one-line change).Screenshots / recordings
N/A — server-side fix, no UI change.
Checklist
bun typecheckinpackages/opencodepasses (tsgo --noEmitexit 0) after a freshbun installin the worktree, againstupstream/devheaddc4449df0dplus this one-line change.