Repository navigation
Conversation
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/dashboard/services/chat_service.py" line_range="1161" />
<code_context>
+ if msg_type in ("plain", "error"):
+ if msg_type == "error":
+ run.status = "failed"
+ run.llm_checkpoint_id = None
for accumulator in (pending_accumulator, display_accumulator):
accumulator.add_plain(
</code_context>
<issue_to_address>
**Editing failed prompts is rejected**
When preprocessing fails before an LLM-history turn is created and the user later retries or edits the saved message, clearing `run.llm_checkpoint_id` does not clear the checkpoint on the already-saved user history record. `update_message` then looks for a turn that does not exist, so the edit request fails.
Clear the checkpoint on the persisted user history record as well as on the run when preprocessing fails.
Also at `astrbot/dashboard/services/live_chat_service.py:708-709`.
</issue_to_address>
### Comment 2
<location path="dashboard/src/components/chat/ThreadPanel.vue" line_range="287-290" />
<code_context>
if (type === "error") {
markMessageStarted(botRecord);
- appendPlain(botRecord, `\n\n${String(data)}`);
+ botRecord.content.message.push({
+ type: "plain",
+ text: String(data),
+ error_code: payload.error_code,
+ });
return;
</code_context>
<issue_to_address>
**Failed replies retain regenerate action**
When a ThreadPanel bot record receives a run snapshot with a checkpoint before `message_saved` carries a null checkpoint, the `message_saved` handler uses `data?.llm_checkpoint_id || botRecord.llm_checkpoint_id`, so it retains the old checkpoint. The UI offers regeneration for the failed message, and the request is rejected because the saved bot message has no checkpoint.
When the event supplies a null checkpoint, overwrite the bot record’s checkpoint with null instead of falling back to its previous value.
Also at `astrbot/dashboard/services/chat_service.py:1161`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the new error path is wrong, failed chat runs could be marked failed and an error message/end event could be written into the conversation state instead of only being logged. Reverting stops the behavior for future runs, while any incorrect stored transcript or run state would require bounded cleanup or a rerun.
Blocking findings: astrbot/dashboard/services/chat_service.py:1161, dashboard/src/components/chat/ThreadPanel.vue:290
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the new error path is wrong, failed WebChat turns could be recorded with incorrect status or leave pending output and edit state inconsistent; these records and state are bounded and can be repaired or retried. Reverting prevents future occurrences but does not remove error messages or status changes already persisted.
7a8801a to
c7a1e8e
Compare
Uploading an MP3 in WebChat without FFmpeg leaves the assistant reply stuck on the loading/thinking indicator indefinitely. Refreshing the page or reopening the conversation restores the same stuck state. Preprocessing only logs the exception and never ends the response stream, so the request remains active instead of showing an error and finishing.
Modifications / 改动点
Return an error followed by an end event when WebChat preprocessing fails.
Preserve errors in SSE/WebSocket history without invalid regeneration checkpoints.
Localize missing-FFmpeg and generic failure messages in Chinese, English, Japanese and Russian, including after reload.
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Verification steps:
Validated locally: the above flow; 20 existing tests in
test_webchat_queue_lifecycle.py,test_chat_route.pyandtest_live_chat_service.py; Ruff; frontend typecheck/build; documentation build.Before
After (中文)
After (English)
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 checked the affected WebUI instructions and screenshots in
docs/zhanddocs/enagainst the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog./ 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新
docs/zh和docs/en的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。🤓 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.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Complete WebChat responses cleanly when message preprocessing fails and preserve the resulting localized error state across reloads.
New Features:
Bug Fixes: