Repository navigation
fix(chat): refresh agent instances when a thread mints one - #111
Merged
Merged
Conversation
Threads mints a fresh instance for every agent added to a thread, so the thread CreateThread returns names an id the cached instance list has never seen. Chat creation only invalidated the thread list, so the new row and its header fell back to (unknown participant) until a reload refetched the instances. Creating a chat now invalidates the instance list too. Threads that arrive from elsewhere -- an agent opening one with you, or a participant someone else adds -- have no such hook, so an unresolved participant id triggers one refetch as well, tracked in a ref so an id that stays unresolvable cannot loop.
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.
Problem
Starting a new thread showed
(unknown participant)in the sidebar row and the header until the page was reloaded.Threads mints a fresh agent instance for every agent added to a thread (
createAgentInstancein threads/internal/server/server.go), so the threadCreateThreadreturns carries an instance id the cachedagent-instanceslist has never seen.useCreateChatonly invalidated['chats','list'], anduseAgentInstanceshas no refetch trigger beyond a mount, so the name only appeared after a reload.Follow-up to 1cc1026, which made existing instances resolve; this makes newly minted ones resolve too.
Change
useCreateChatalso invalidates['agent-instances'].Verification
useCreateChatasserting both invalidations.pnpm test58/58,pnpm typecheck,pnpm lintall clean.devspace dev(chat.agyn.dev serves the dev tree); browser check done by the author, not automated.