Files
eryao/docs/bugs/2026-04-08-followup-entry-bug.md
T
qzl e80a82bef4 docs: 更新协议文档,删除废弃计划文档
- 更新 http-error-codes, user-points-chat-data-protocol
- 更新 divination-run-protocol, profile-protocol
- 删除废弃的后端和前端设计计划文档
2026-04-08 17:23:02 +08:00

90 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Bug: 追问1次后无法进入查看历史记录
日期:2026-04-08
状态:已确认(未修复)
## 问题描述
追问1次之后追问入口关闭,但用户也没法点击进去查看追问的历史记录。
## 根因分析
`_loadFollowUpEligibility()` 方法(`divination_result_screen.dart:65-83`)将两个概念混为一谈:
```dart
Future<void> _loadFollowUpEligibility() async {
...
final messages = await widget.divinationApi!.getSessionMessages(
threadId: widget.data.threadId!,
);
final userCount = messages.where((msg) => msg.role == 'user').length;
...
setState(() {
_canFollowUp = userCount < 2; // 同时控制"能追问"和"能进入"
...
});
}
```
按钮逻辑(`divination_result_screen.dart:367`):
```dart
onPressed: (!_canFollowUp || _followUpEligibilityLoading)
? null // _canFollowUp = false 时按钮完全禁用
: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => FollowUpChatScreen(...),
),
);
},
```
**问题**
- `_canFollowUp = userCount < 2` 控制的是"是否还有追问配额"
-`onPressed` 把它和"是否能进入查看历史"混用了
- 导致用户追问1次后(userCount=2),`_canFollowUp=false`,按钮被禁用
- 用户**无法进入追问页面查看历史记录**
**业务逻辑分析**
- 每 session 最多2次追问(首问1次 + 追问1次)
- 追问1次后,用户不能再发送新追问
- 但**应该仍能进入查看历史记录**
### 正确的逻辑应该是
```dart
// 追问配额判断
_canFollowUp = userCount < 2;
// 能否进入查看历史(与追问次数无关,只要有历史消息就能进入)
_canEnterFollowUpChat = messages.isNotEmpty; // 或者只要有 threadId 就能进
// 按钮文案
buttonText = _canFollowUp ? l10n.followUpEntryHint : l10n.followUpViewHistory;
// 按钮是否禁用
onPressed = (_followUpEligibilityLoading)
? null // 只在加载中时禁用
: () { ... } // 始终可点击进入查看
```
## 证据
- 结果页代码:`apps/lib/features/divination/presentation/screens/divination_result_screen.dart`
- `_buildFollowUpBar`: 行 338-394
- `_loadFollowUpEligibility`: 行 65-83
- 按钮 onPress: 行 367
- 追问聊天页:`apps/lib/features/divination/presentation/screens/follow_up_chat_screen.dart`
## 修复方向
1. 分离"能否追问"和"能否进入查看历史"的逻辑
2. 按钮文案根据状态显示不同内容(能追问显示追问提示,已用完显示"查看历史")
3. 只要有 `threadId`,用户就应该能进入查看历史
---
## 相关文档
- 随访工程计划:`docs/plans/2026-04-08-followup-session-history-eng-plan.md`