Skip to content

Bugfix: retain agent during thread switches - #3884

Merged
WMC001 merged 5 commits into
developfrom
xyq/bugfix_2.5.1-2
Sep 9, 2026
Merged

Bugfix: retain agent during thread switches#3884
WMC001 merged 5 commits into
developfrom
xyq/bugfix_2.5.1-2

Conversation

@xuyaqist

@xuyaqist xuyaqist commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

修复从“当前会话”切换至其他conversation又切换回来,agent id遗失的问题
image

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
Copilot AI lite review requested due to automatic review settings September 8, 2026 01:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 agentId via thread.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.

Comment thread frontend/app/[locale]/newchat/page.tsx
@WMC001
WMC001 merged commit 1f9e8c5 into develop Sep 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants