Repository navigation
feat: SSE 流式记账对话(话术+接棒+卡片入场) - #62
Merged
Merged
Conversation
POST /chat/stream 和 POST /record-ocr/stream 两个 SSE 端点,让记账时 先流式吐出 CoCo 口吻的话术再发送账单卡片,消除等待感。 话术生成与 extract_bill 并发,上游错误帧(如限流)显式抛出并映射为 StreamErrorEvent,避免"账单出来但零话术"的静默失败。 Co-Authored-By: Claude <noreply@anthropic.com>
StreamEvent 判别联合(chunk/bill/text/asr/error)与后端 Pydantic schema 一一对应,供 mobile 的 SSE 消费层复用,避免前后端手写两份漂移。 Co-Authored-By: Claude <noreply@anthropic.com>
- 引入 react-native-sse 消费 /chat/stream 和 /record-ocr/stream,onEvent 用 Promise 链串行化避免乱序 - StreamingBubble 复用现有气泡样式 + 末尾光标闪烁 - 三入口(文字/语音/OCR)统一通过 runStream 走流式,闭包局部累积缓冲 消除共享态污染 - buildListItems 通过「内容匹配」让真实 text 气泡接棒 StreamingBubble, finally 块 await invalidateQueries 再 setStreamingText(null),消除 "user 消息从卡片底部闪回中间"的位置跳动 - RecordCard 仅对会话内新增的卡片应用 FadeInDown 250ms,首屏历史无动画 - OCR 失败时软删"正在识别"提示,服务端有错误文案时不重复弹 onFail - SSE 接棒逻辑抽到 chat-list-items.ts + 单测覆盖接棒/typing/非匹配分支 Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
让文字/语音/OCR 三种记账入口在 LLM 解析期间先流式吐出一段 CoCo 口吻的话术,再把账单卡片从下方淡入滑上,消除用户"按下就等几秒"的等待感。
/chat/stream和/record-ocr/stream两个 SSE 端点,话术 LLM 与extract_bill并发执行;事件协议用StreamChunkEvent/StreamBillEvent/StreamTextEvent/StreamAsrEvent/StreamErrorEvent判别联合;上游限流/鉴权错误帧显式抛出并映射为 error 事件,避免静默失败react-native-sse,Promise 链串行化onEvent防乱序;新增StreamingBubble配合末尾光标闪烁;buildListItems通过「内容匹配」让真实 text 气泡零闪烁接棒流式气泡;RecordCard仅对会话内新增的卡片应用FadeInDown 250ms(首屏历史不抖)@coco/shared/types/stream.ts统一前后端事件契约,消除漂移buildListItems接棒判定 6 个 case,覆盖匹配/不匹配/typing 降级/非 assistant-text 不触发接棒Test plan
just cicd-be: ruff + 49 pytest 通过just cicd-fe: eslint + prettier + typecheck + 19 suites / 183 tests 通过RecordCard无入场动画(首屏不抖)Co-Authored-By: Claude noreply@anthropic.com