fix(client): chats started from new chat no longer come back empty - #106
Merged
Merged
Conversation
Opening a new chat can subscribe to its thread before the server has created it (an open diff panel does this, for example). The server answers "not found" and the client marks the thread deleted. The fix in #105 waited for a thread.created event to undo that, but the server never sends thread.created on the thread stream, so the chat stayed stuck: the header showed the server title while the body rendered the empty draft. Treat any event for a thread marked deleted as proof that it exists and reload its snapshot. Do it at most once per thread state, because archived threads also answer "not found" while their sessions keep streaming. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
If you ran something in a chat started from the new-chat screen (e.g.
/simplify) and later went back to it, the chat was empty, though the header still showed its title.Opening a new chat can subscribe to its thread before the server creates it (an open diff panel does this). The server answers "not found", so the client marks the thread
deleted. #105 was meant to undo that whenthread.createdarrived. But the server never sendsthread.createdon the thread stream (isThreadDetailEventinapps/server/src/ws.ts), so the thread stayeddeleted. The header takes its title from the shell, while the body fell back to the unsent draft. In the reported thread, the server trace shows the "not found" at 10:20:12 and the thread being created at 10:20:16. After that, the retry subscription received every event for the thread for 33 minutes, and the client ignored all of them.Now the client treats any event for a thread marked
deletedas proof that the thread exists, and reloads its snapshot. It does this at most once per thread state. Archived threads also answer "not found" while their sessions keep streaming, and reloading on every event would never settle.Tests: the #105 test used a
thread.createdevent that the real server never sends. It now uses the firstthread.message-sentand fails without the fix. A second test covers the reload-once behavior and fails without the guard. The fix is in the shared client-runtime state, so web, desktop and mobile all get it.🤖 Generated with Claude Code using Claude Opus 5.5