AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

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

Open CMKH1337 opened this issue 4 months ago • 0 comments

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

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

Modifications / 改动点

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

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

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

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


Checklist / 检查清单

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

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

  • [x] 🤓 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.txt 和 pyproject.toml 文件相应位置。

  • [x] 😮 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.

CMKH1337 avatar Jul 18 '26 19:07 CMKH1337