Skip to content

feat(chat): fold AI process by round + quiet fold bar + row rhythm - #8

Merged
tall-1997 merged 2 commits into
mainfrom
feature/chat-round-collapse
Oct 13, 2026
Merged

tall-1997 merged 2 commits into
mainfrom
feature/chat-round-collapse

Conversation

@tall-1997

Copy link
Copy Markdown
Owner

背景

会话页 UI 对标报告(taixu / OmniBot)的 PR-1 + PR-2 + P1-3 合并落地:AI 过程折叠从"按 assistant 消息"改为"按轮次",折叠条降噪,行间距建立节奏体系。用户已确认折叠条文案保持原样(chat_process_summary_* 未动)。

轮次折叠模型(ChatFlatItems.kt)

  • 折叠单位 = 轮次:一条用户消息起到下一条用户消息前为止。一轮一条折叠条、轮级统计;折叠条归属轮次最后一条 assistant 消息(messageId == 展开键,ChatScreen 的切换代码零改动)
  • 四条规则(taixu RoundCollapse + OmniBot 一条式):
    1. 可折叠步数 ≤ 2 的轮次永不折叠(给两行内容配一条折叠条是噪音);
    2. 运行中的轮次永远全开(effectiveExpanded = isRunning || expanded)——完成即自动收起,无需任何收起触发器;
    3. 收拢时保留最新 2 步可见("刚才在干什么"的尾巴);
    4. 说话人/子代理过滤抽成 effectiveBlocks,轮次预扫描与行循环共享,折叠条统计与实际渲染永不漂移
  • 单通道:isFloatingProcessTool 在折叠开启时恒为 false——运行中的轮次在列表内展示全部步骤,视口底部悬浮条不再重复显示同一张工具卡(悬浮条仅服务折叠关闭模式;PR-3 将整体移除)

折叠条降噪(ChatAssistantMessageUI.kt)

居中文字 + 两侧发丝线(taixu RoundCollapseButton 模式),onSurfaceVariant 主题色,失败仅状态图标染 error——替换原来的 accent 填充卡片 + 描边 + iOS 蓝/红硬编码。文案不变。

行间距节奏(P1-3)

flatItemTopGap 纯函数投影替换 spacedBy(2.dp) 与各行自带 padding(UserBubble 10/14+4、AssistantHeader 10+2、ThinkingBlock 4、ToolCallPill 3):

场景 间距
用户气泡上方(轮次边界) 12dp(连续用户消息 16dp)
用户气泡 → 助手头部 16dp(保留既有调校)
过程行 → 过程行 2.5dp(密集活动簇)
过程行 → 正文 4dp
同消息 md 段落流 2dp
其他 8dp

测试

  • ChatFlatItemsProcessFoldTest / ChatFlatItemsToolOnlyFoldTest 按新契约重写:运行中全开、≤2 不折、保留最新 2 步、多消息轮次一条折叠条、resume 续写并入前一轮、轮次键 = 最后一条 assistant 消息 id
  • 时间线回归 / 群聊说话人 / 子代理可见性套件未改动,行为兼容

风险与回滚

行为变更点:折叠开启时运行中的轮次不再"边跑边收"(改为完成后整体收起,与 taixu/OmniBot 一致);悬浮工具条在折叠开启时不再出现(列表内已展示)。回滚 = revert 本提交,无数据迁移。

PR-1 + PR-2 + P1-3 of the chat-page UI plan (会话页UI优化建议报告.md):

Round model (ChatFlatItems.kt):
- fold unit is now the ROUND (user message -> next user message), not the
  assistant message: one bar per round, round-wide totals, bar owned by the
  round's LAST assistant message (messageId == expansion key)
- rules: <=2 foldable steps never fold; a running round is always open
  (effectiveExpanded = isRunning || expanded) so completion auto-collapses
  with no trigger of its own; a collapsed round keeps its latest 2 steps
  visible; speaker/sub-agent filters extracted into effectiveBlocks so the
  pre-pass and the row loop can never disagree about foldable steps
- isFloatingProcessTool: single channel — with folding on the running round
  renders every step in-list, so the viewport-pinned overlay only serves
  fold-OFF mode (removes the in-flight tool double display)

Fold bar (ChatAssistantMessageUI.kt):
- quiet divider style: centred label between two hairlines in
  onSurfaceVariant (taixu RoundCollapseButton pattern), failure tints the
  status icon with theme error; copy unchanged (chat_process_summary_*)

Row rhythm (P1-3):
- flatItemTopGap pure projection replaces LazyColumn spacedBy(2.dp) and the
  per-row ad-hoc paddings (UserBubble 10/14+4, AssistantHeader 10+2,
  ThinkingBlock 4, ToolCallPill 3): user bubble 12dp (16dp back-to-back),
  user->header 16dp, process->process 2.5dp, process->text 4dp,
  same-message md flow 2dp, default 8dp

Tests: ChatFlatItemsProcessFoldTest / ToolOnlyFoldTest rewritten to the new
contract (running rounds open, <=2 never folds, keep-2 tail, multi-message
rounds, resume joins the previous round); timeline/group-speaker/sub-agent
suites unchanged and still green.
@tall-1997
tall-1997 merged commit 662e6d3 into main Oct 13, 2026
1 check passed
@tall-1997
tall-1997 deleted the feature/chat-round-collapse branch October 13, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant