Skip to content

fix: use current provider selection when regenerating chat message - #9402

Open
wcqqq1214 wants to merge 1 commit into
AstrBotDevs:masterfrom
wcqqq1214:fix/chat-regenerate-provider-fallback
Open

fix: use current provider selection when regenerating chat message#9402
wcqqq1214 wants to merge 1 commit into
AstrBotDevs:masterfrom
wcqqq1214:fix/chat-regenerate-provider-fallback

Conversation

@wcqqq1214

@wcqqq1214 wcqqq1214 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #9400.

On the chat page, clicking the basic Retry button did not read the provider currently selected in the UI. It emitted a retry event with no selection, so handleRegenerateMessage passed empty strings as selected_provider / selected_model. The backend then fell back to the provider persisted for the session (provider_perf_chat_completion), which was the original failing/renamed provider — so switching to a valid provider and retrying still failed with 未找到指定的提供商.

Sending a new message already resolves the current selection via getSelectedProviderSelection(); regenerate now does the same when no explicit selection is passed.

Modifications / 改动点

  • dashboard/src/components/chat/Chat.vue: in handleRegenerateMessage, fall back to getSelectedProviderSelection() (current UI selection) when no explicit selection is provided. The "retry with a specific model" path (retryWithModel, which passes an explicit selection) is unchanged, and the fallback is evaluated lazily so its side effects don't run on that path.

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

End-to-end verification with a real backend + WebUI in a headless browser, intercepting the actual regenerate request body. Two chat providers were configured; the UI had good_provider selected.

Before the fix (reverted temporarily to confirm reproduction):

INTERCEPTED regenerate body: {"selected_provider":"","selected_model":"",...}
FAIL: basic retry sent selected_provider="" (expected "good_provider")

After the fix:

INTERCEPTED regenerate body: {"selected_provider":"good_provider","selected_model":"",...}
PASS: basic retry sent the currently-selected provider

vue-tsc --noEmit passes.


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc. (N/A — bug fix only)
  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 I have ensured that no new dependencies are introduced.
  • 😮 My changes do not introduce malicious code.

Summary

Bug Fixes:

  • Fix basic chat retry so regenerated messages use the active provider selection instead of falling back to an empty or outdated provider.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. area:webui The bug / feature is about webui(dashboard) of astrbot. labels Jul 26, 2026
Basic retry sent an empty provider, so the backend fell back to the stale persisted provider. Fall back to the current UI selection, matching send behavior.

Closes AstrBotDevs#9400
@wcqqq1214
wcqqq1214 force-pushed the fix/chat-regenerate-provider-fallback branch from 2cd1e82 to da12e3e Compare July 26, 2026 10:45

@sourcery-ai sourcery-ai Bot 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. area:webui The bug / feature is about webui(dashboard) of astrbot. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]聊天页面第一次使用配置不完整的供应商,出现invaild key错误

1 participant