Repository navigation
fix(chat): 折叠卡片复用未折叠渲染组件;空白文本不再丢思考;块时长持久化 - #17
Merged
Merged
Conversation
…longer drops thinking; persist block timing Three defects in the fold card, all traced to the card re-implementing what the unfolded list already does: 1. 思考 0 — blank text split the run. Providers emit a bare "\n\n" before a tool call; restored sessions turn it into a text block, and the segment flush used isNotEmpty(), so a segment holding only the restored thinking block (below the 2-step card threshold) was dropped on sight. Every card read "思考 0 · 工具 N". Blank text is not reply text: the flush now requires isNotBlank(). This also fixes the live path, which materialises the same "\n\n" as a text block. 2. 时长不见 — block timing was never persisted. partsJson carried no durationMs/startTimeMs, so every restored block parsed as 0 and the cards (which sum block durations) showed no duration after a reload. buildAssistantPartsJson now writes both fields and the restore path reads them (old rows keep parsing as 0). Thinking blocks also never recorded a duration even live: creation now stamps startTimeMs and the first text / tool call settles durationMs. 3. Icons and style — the expanded card rendered its own step rows with invented icons (magnifier for tools, generic lightbulb). The card now renders steps with the SAME components as the unfolded list: ThinkingBlock for reasoning, ToolCallPill for tool calls. Icons, accent colors, duration chips, status styling and the 500ms thinking auto-collapse all come from the shared implementations — folded and unfolded stay identical by construction, not by imitation. ProcessStepRow is deleted; ProcessStepRef carries the AssistantBlock itself. Regression test: blank text between thinking and tool keeps the run together (counts 2/2 instead of dropping thinking).
…er 500ms; failed rows tint their title
Aligns the process card with the reference design (three screenshots of
an earlier fold card that never landed):
- ThinkingBlock header now shows the settled duration next to the char
count ("思考 · 4m 59s · 11k"). The duration itself was recorded by the
previous commit; this surfaces it.
- A card that just settled (reply text arrived, run left the running
set) auto-closes 500ms later instead of staying open forever — the
last steps stay readable for a beat after the text lands, the same
settle the thinking block gives its content. A card the user re-opened
by hand during or after the window is marked manualReopenedCards and
never auto-closed: user opened it, it stays open.
- A failed tool call now tints its own row's TITLE (matching the icon)
in the error colour; every other row stays normal. The reference card
colours exactly the error line, nothing else.
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.
三个缺陷,根因都是折叠卡片重复实现了未折叠列表已有的东西
1. 思考 0 —— 空白文本切段
模型在调工具前常输出裸
\n\n;恢复会话后它成为 text 块,段切分用isNotEmpty()判"正文出现",于是只装着恢复思考块的段(不足 2 步成卡门槛)被直接冲掉——每张卡都读"思考 0 · 工具 N"(用户截图实测数据:该会话每条 assistant 消息 reasoning_content 199~9263 字节全在,但卡片计数为 0)。运行时路径同样物化\n\n为 text 块,同样丢。修复:flush 判断改
isNotBlank()——空白不是正文。恢复与运行时两条路径一起治。2. 时长不见 —— 块时长从未持久化
partsJson 只存 toolUseId/name/input/description/pageURL/imageFilePath/thoughtSignature,没有 durationMs/startTimeMs。恢复后所有块时长为 0,卡片(按块时长求和)重载后无时长。
修复:序列化写入两字段、恢复侧解析(旧行解析为 0,行为不变)。思考块运行时也从未记录时长——创建时记 startTimeMs,首个 text/tool 到达时结算 durationMs。
3. 图标自造 —— 展开行不复用原组件
展开行用自造图标(工具=放大镜、思考=灯泡),与未折叠的工具胶囊/思考卡完全脱节。
修复:展开区直接渲染未折叠列表的同一组件——思考行=ThinkingBlock(500ms 自动收起、userTouched、300dp 滚动、超长窗口截断全部现成),工具行=ToolCallPill(按工具名映射的图标/强调色/时长芯片/状态样式)。ProcessStepRow 整个删除;ProcessStepRef 携带 AssistantBlock 本体。折叠与未折叠构造上一致,不是模仿式一致。
测试
新增回归:思考与工具之间的空白文本不切段(计数 2/2 而非丢思考)。本机无 JDK,编译与全量单测交 CI。