GeezerVison is showing github.com — fix: don't hang TUI when reattaching to a deleted session (#23344) by serenposh · Pull Request #23355 · anomalyco/opencode
Conversation
serenposh
commented
Apr 19, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #23344
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
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 calls sdk.client.session.get({ sessionID }, { throwOnError: true }). For a deleted session the server returns 404, so the SDK throws before the existing if (!result.data) guard can run its "Session not found" toast + navigate({ type: "home" }) recovery path. The rejection surfaces inside an async createEffect, 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 throwOnError and add an explicit .catch(() => undefined) so the existing recovery path actually runs. Also wrap the follow-up sync.session.sync(route.sessionID) in a try/catch (it also uses throwOnError: true internally) to cover the narrow race where the session is deleted between the two calls.
How did you verify your code works?
bun typecheck across all workspace packages (pre-push hook) — passes.
bun test --timeout 30000 in packages/opencode — 2002 pass / 11 skip / 1 todo / 0 fail.
- Traced the repro:
args.sessionID → route.navigate({ type: "session", ... }) in app.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
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…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) <[email protected]>
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Automated PR Cleanup
Thank you for contributing to opencode.
Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.
This PR was closed because it matched the following cleanup criteria:
- The PR was created more than 1 month ago
- The PR had fewer than 2 positive reactions
- Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR
PRs created within the last month are not affected by this cleanup.
If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.
Thanks again for taking the time to contribute.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|