fix: don't hang TUI when reattaching to a deleted session (#23344)#23355
Open
serenposh wants to merge 2 commits intoanomalyco:devfrom
Open
fix: don't hang TUI when reattaching to a deleted session (#23344)#23355serenposh wants to merge 2 commits intoanomalyco:devfrom
serenposh wants to merge 2 commits intoanomalyco:devfrom
Conversation
…yco#23344) `opencode -s <deleted-id>` would render, the server 404 from `session.get` would throw past the `!result.data` guard (since `throwOnError: true` was set), surface as an unhandled rejection inside an async createEffect, and leave the TUI half-mounted with stdin in raw mode — ctrl+c, ~. and every other shortcut went unheard until the user killed the terminal. Drop `throwOnError` + add an explicit `.catch` so the existing "Session not found" toast + navigate-home path actually runs, and wrap the follow-up `sync.session.sync` the same way for the race where the session is deleted between the two calls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 #23344
Type of change
What does this PR do?
Running
opencode -s <deleted-session-id>would hang the terminal — no ctrl+c, no ~., terminal had to be killed.Cause: in
routes/session/index.tsx, the effect that loads the session callssdk.client.session.get({ sessionID }, { throwOnError: true }). For a deleted session the server returns 404, so the SDK throws before the existingif (!result.data)guard can run its "Session not found" toast +navigate({ type: "home" })recovery path. The rejection surfaces inside an asynccreateEffect, by which point the TUI has already entered raw-mode / alternate-screen — stdin is no longer reachable from the shell, so every keystroke is swallowed.Fix: drop
throwOnErrorand add an explicit.catch(() => undefined)so the existing recovery path actually runs. Also wrap the follow-upsync.session.sync(route.sessionID)in a try/catch (it also usesthrowOnError: trueinternally) to cover the narrow race where the session is deleted between the two calls.How did you verify your code works?
bun typecheckacross all workspace packages (pre-push hook) — passes.bun test --timeout 30000inpackages/opencode— 2002 pass / 11 skip / 1 todo / 0 fail.args.sessionID→route.navigate({ type: "session", ... })inapp.tsx→Session()mounts → the 404 from the get call is what killed the TUI before the guard could run. With the fix, the guard fires and you land on the home view with a "Session not found" toast.Screenshots / recordings
N/A — behavior change, not a visual change. The user-visible surface is an existing toast that was already coded but unreachable.
Checklist