PetAgent/backend
wsb1224 f8e70e3fd5 修复token余额不足时仍能继续使用功能的问题
根因:后端扣费用的是 fallback_amount=200(最低消费),用户剩14个token
时 14<200 导致扣费失败,但原有逻辑只在 remaining<=0 时才终止会话和
通知前端,remaining=14>0 时扣费失败被静默忽略。

修复:
- 后端 voice_chat_router.py:扣费失败时(charge 返回 success=false)
  始终终止事件循环并发送 error 事件,不再只判断 remaining<=0
- 后端 chat_router.py:文字聊天扣费失败时也发送 error 事件通知前端
- 前端 chatStore.js:token_update 消息带 warning 字段时(扣费失败),
  标记 _realtimeTokenExhausted=true,断开 WebSocket,阻止继续使用

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-07 14:05:21 +08:00
..
api 修复token余额不足时仍能继续使用功能的问题 2026-06-07 14:05:21 +08:00
config
migrations 修复toekn权限和语音聊天功能 2026-06-07 10:22:37 +08:00
models 修复toekn权限和语音聊天功能 2026-06-07 10:22:37 +08:00
scripts 修复toekn权限和语音聊天功能 2026-06-07 10:22:37 +08:00
services 修复toekn权限和语音聊天功能 2026-06-07 10:22:37 +08:00
utils 修复toekn权限和语音聊天功能 2026-05-26 13:12:09 +08:00
__init__.py
main.py
nohup.out
pet_data.db
requirements.txt
run.py
start.sh
test_token_charge.py 修复toekn权限和语音聊天功能 2026-05-26 13:12:09 +08:00
test_voice_conversation.py