Bugfix: retain agent during thread switches - #3884
Merged
Merged
Conversation
Bind the selected agent to new thread metadata so switching back restores the correct agent. Co-authored-by: Codex <noreply@openai.com> Generated-by: gpt-5-codex
Support local custom metadata updates for new conversations so selecting an agent opens its chat and restores that agent after switching threads. Co-authored-by: Codex <noreply@openai.com> Generated-by: gpt-5-codex
Initialize a newly selected agent thread before writing custom metadata so assistant-ui accepts the update and preserves the agent across thread switches. Co-authored-by: Codex <noreply@openai.com> Generated-by: gpt-5-codex
Remove the successful image fetch status log while retaining request and error diagnostics. Co-authored-by: Codex <noreply@openai.com> Generated-by: gpt-5-codex
xuyaqist
requested review from
Dallas98,
WMC001 and
jeffwu-1999
as code owners
September 8, 2026 01:59
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new thread initialization/binding path can throw at runtime if mainThreadId is missing or the thread item isn’t available yet, so it needs a defensive guard before calling initialize()/updateCustom().
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes the “agent id lost after switching conversations and switching back” issue in the new chat flow by persisting the selected agent into the local thread’s custom metadata (so assistant-ui can restore it when navigating between threads).
Changes:
- On landing agent selection, initializes the newly-created thread and stores
agentIdviathread.updateCustom(...). - Adds a
RemoteThreadListAdapter.updateCustom(...)no-op implementation so metadata updates are accepted even before a backend conversation ID exists. - Adds a lightweight regression test that asserts the agent/thread binding behavior via static source checks.
File summaries
| File | Description |
|---|---|
| frontend/tests/newchatThreadAgentBinding.test.ts | Adds regression tests asserting thread initialization + agent metadata binding and adapter support. |
| frontend/services/storageService.ts | Removes verbose fetch logging from fetchImageBlob. |
| frontend/app/[locale]/newchat/page.tsx | Stores selected agentId into the newly created thread’s custom metadata after switching threads. |
| frontend/app/[locale]/newchat/adapter/conversation-thread-list-adapter.tsx | Implements updateCustom as a no-op to support local metadata updates for new threads without backend IDs. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
WMC001
approved these changes
Sep 9, 2026
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.
修复从“当前会话”切换至其他conversation又切换回来,agent id遗失的问题
