feat: introduce MessageGroup model replacing flat Message[] for grouped assistant rendering#27
Merged
Merged
Conversation
…ed assistant rendering
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
TuYv
approved these changes
Apr 21, 2026
TuYv
pushed a commit
that referenced
this pull request
Apr 21, 2026
* refactor: unify 15 bridge callbacks into single onEvent channel (#26) * feat: add landing page for beta onboarding Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: update GitHub links to genni613/CodePlanGUI Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(execution): stream assistant response after execution cards with correct ordering * fix: cancel flushTimer on dispose and synchronize flushPendingBuffer to prevent race condition and resource leak * docs: add unified event system and message grouping design spec Covers two-phase migration: Phase 1 unifies 13 bridge callbacks into a single onEvent channel with eventReducer; Phase 2 introduces MessageGroup-based rendering to eliminate backend ordering hacks (notifyRemoveMessage, bridgeNotifiedStart, lazy bubble creation). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: fix spec review issues in unified events & grouping design - Correct dispatch strategies for notifyContextFile/notifyTheme (pushJS, not flushAndPush) - Fix flushAndPush signature (String param, not lambda) - Use kotlinx.serialization instead of non-existent JSONObject.quote - Preserve useBridge bridge_ready lifecycle, don't overwrite window.__bridge - Add action field to structured_error event payload - Complete error/structured_error cases in groupReducer - Replace pseudocode token index tracking with concrete logic - Add msgId invariant note across API rounds - Handle double-encoding in restore_messages payload - Preserve debug log side effects in event handler - Add notifyStart timing consideration note for Phase 2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: fix buildEventJS contract and notifyRoundEnd safety - Change buildEventJS payload param from String to Map<String, Any?> to prevent double-encoding when callers pass pre-encoded JSON - Use mapOf() for notifyRoundEnd payload instead of string interpolation to avoid JSON injection from special characters Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: translate unified events & message grouping spec to Chinese Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: split unified events & grouping spec into two separate docs - Phase 1: unified-event-channel-design.md — single onEvent channel, eventReducer, BridgeHandler buildEventJS refactor - Phase 2: message-grouping-design.md — MessageGroup rendering, groupReducer, ChatService hack removal Each doc is self-contained for independent PR review. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: unify 15 bridge callbacks into single onEvent channel * refactor: unify 15 bridge callbacks into single onEvent channel --------- Co-authored-by: yuang.peng <yuang.peng@yaduo.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * feat: introduce MessageGroup model replacing flat Message[] for grouped assistant rendering (#27) * feat: introduce MessageGroup model replacing flat Message[] for grouped assistant rendering * fix: code review --------- Co-authored-by: yuang.peng <yuang.peng@yaduo.com> * feat: add tool execution engine with inline step visualization * fix: cr --------- Co-authored-by: yuang.peng <yuang.peng@yaduo.com> Co-authored-by: Claude Opus 4.6 <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.
User description
Summary
MessageGroup[]替代扁平Message[]渲染模型,将执行卡片和最终回答归入同一 assistant 组bridgeNotifiedStart/notifyRemoveMessage排序 hack,改为无条件的notifyStart+notifyRoundEndChanges
groupReducer.ts替代eventReducer.ts,用GroupState+MessageGroup管理状态AssistantGroup.tsx、AssistantMarkdown.tsx组件,分别渲染分组和 markdownApp.tsx:从messages[]切换到groups[],简化加载指示器(仅在无流式文本时显示 spinner)ChatService.kt:移除bridgeNotifiedStart集合,startStreamingRound()无条件发送notifyStart,onFinishReason("tool_calls")改发notifyRoundEndgroupReducer测试用例(含工具调用流程、多轮执行、会话恢复等场景)Test plan
round_end正确丢弃PR Type
Enhancement
Description
Replace flat
Message[]withMessageGroup[]for grouped assistant rendering (execution cards + final answer in same group)Remove backend
bridgeNotifiedStarthack; send unconditionalnotifyStart+notifyRoundEndfor token discardingAdd
groupReducer.tswithGroupState,AssistantGroup,HumanGrouptypes; handle 'round_end' to discard intermediate tokensAdd
AssistantGroup.tsxandAssistantMarkdown.tsxcomponents; updateApp.tsxto use groups and simplify spinner logicAdd 29
groupReducertests covering tool calls, multi-round flows, session restoreDiagram Walkthrough
File Walkthrough
5 files
Remove bridgeNotifiedStart hack, add notifyRoundEndSwitch from messages[] to groups[] with groupReducerNew component for grouped assistant renderingNew component for markdown rendering with code highlightingNew reducer with GroupState and MessageGroup types1 files
Update design doc for Phase 2 MessageGroup architecture2 files
Add groupReducer test to test scriptAdd groupReducer.ts to test build include1 files
New test file with 29 groupReducer test cases1 files