Skip to content

fix: WebChat子代理后台结果自动显示#9322

Open
CMKH1337 wants to merge 4 commits into
AstrBotDevs:masterfrom
CMKH1337:fix/webchat-background-message-polling
Open

fix: WebChat子代理后台结果自动显示#9322
CMKH1337 wants to merge 4 commits into
AstrBotDevs:masterfrom
CMKH1337:fix/webchat-background-message-polling

Conversation

@CMKH1337

@CMKH1337 CMKH1337 commented Jul 18, 2026

Copy link
Copy Markdown

修复 Issue #9321:在 WebChat 中使用后台子代理执行任务时,后台任务虽然能够完成,结果也已经保存到会话历史,但用户必须再次发送消息才能看到结果。

本次修改让当前 WebChat 会话定期检查新的历史消息,使后台子代理完成后,结果能够自动显示给用户。

Modifications / 改动点

  • 为当前 WebChat 会话增加历史消息轮询,每 2 秒检查一次。
  • 当普通 AI 回复正在进行时暂停轮询,避免覆盖正在进行的流式消息。
  • 切换会话时清理旧会话的轮询定时器。
  • 组件卸载时清理轮询定时器,避免定时器残留。
  • 修改文件:dashboard/src/composables/useMessages.ts
  • 没有引入新的依赖。
  • This is NOT a breaking change. / 这不是一个破坏性变更。

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

修改前使用webchat调用后台子代理,图中可见时隔3分钟也没有主动消息发出:
image

修改后使用webchat调用后台子代理,图中可见在同一分钟内ai主动发出结论:
image


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Poll WebChat session messages so background sub-agent results appear automatically in the current conversation.

New Features:

  • Automatically refresh WebChat session messages on a timer to surface new background sub-agent outputs without requiring user input.

Enhancements:

  • Start and stop a per-session polling timer based on the active session, and clear it on component unmount to avoid stale intervals.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. area:webui The bug / feature is about webui(dashboard) of astrbot. feature:chatui The bug / feature is about astrbot's chatui, webchat labels Jul 18, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a polling mechanism in useMessages.ts to periodically fetch session messages when a session is not actively running. The reviewer pointed out that using setInterval for asynchronous polling can lead to overlapping requests and race conditions if responses are delayed. They recommended refactoring the polling logic to use a recursive setTimeout approach instead, ensuring each request completes before the next one is scheduled.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread dashboard/src/composables/useMessages.ts

@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:webui The bug / feature is about webui(dashboard) of astrbot. feature:chatui The bug / feature is about astrbot's chatui, webchat size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant