Fix 'no thread found' error when restoring agent thread on workspace open#49045
Merged
Fix 'no thread found' error when restoring agent thread on workspace open#49045
Conversation
…space open Don't serialize empty threads that won't be in the DB, and validate thread exists in the DB before attempting to restore it on load.
When the agent panel serializes the last active thread's session ID and that thread doesn't exist in the database on restart (e.g. empty thread that was never persisted), the panel would show 'Error Loading Zed Agent' / 'Failed to Launch'. Now AgentPanel::load() queries the database to verify the thread exists before attempting restoration. If the thread is missing, it logs an error and falls back to the default behavior (creating a new thread).
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.
When the multi-workspace thread restoration feature serializes the active thread's session ID, it includes empty threads that were never persisted to the database (because
NativeAgent::save_threadskips empty threads). On restart,AgentPanel::load()tries to restore this thread by callingload_agent_thread(), which queries the SQLite DB. Since the empty thread was never saved, the query returnsNone, which becomes the error: "no thread found with ID: SessionId(...)". This shows as "Error Loading Zed Agent" / "Failed to Launch" in the UI.Fix:
Before attempting to restore a serialized thread on panel load, query the DB to verify the thread actually exists. If it doesn't, log an error and skip restoration (the panel falls back to creating a new thread as normal).
Closes AI-19
Release Notes: