* 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>
User description
概述
useCallback中,状态逻辑难以推理、调试和扩展。本次重构将其统一为单一onEvent(type, payload)事件通道,引入eventReducer纯函数集中管理状态转换,为后续 Phase 2(前端消息分组、多轮工具调用)奠定基础eventReducer改动
BridgeHandler.ktbuildEventJS辅助方法,重写notifyXxx内部实现,新增notifyRoundEnd占位方法useBridge.tsonEvent处理器替代 15 个回调参数App.tsxhandleEvent+useState<AppState>替代 15 个useCallbackeventReducer.tsbridge.d.tsBridge接口更新为单一onEventChatService.kt测试计划
eventReducer测试用例,覆盖全部事件类型PR Type
Enhancement, Tests
Description
Unify 15 bridge callbacks into single
onEvent(type, payload)channel with eventReducerAdd micro-batching with 16ms timer flush for token/log streaming to reduce EDT overhead
Introduce
round_endevent and lazy bubble creation to fix execution card orderingAdd BridgeHandlerBatchingTest and eventReducer.test.mjs covering batching and state logic
Diagram Walkthrough
flowchart LR A[Kotlin Backend] -->|"notifyXxx(msgId, data)"| B[BridgeHandler] B -->|"buildEventJS(type, payload)"| C{Event Type} C -->|"token/log"| D[enqueueJS - buffer] C -->|"start/end/error"| E[flushAndPush - immediate] D -->|"16ms timer"| F[flushPendingBuffer] F --> G[Browser JS] E --> G G -->|"onEvent(type, payloadJson)"| H[useBridge] H --> I[eventReducer] I --> J[App State]File Walkthrough
6 files
Add buildEventJS and buffering logicReplace 15 useCallback with handleEvent + eventReducerExport Message type from eventReducerNew pure function for event-to-state mappingSingle onEvent handler instead of 15 callbacksUpdate Bridge interface with single onEvent1 files
Remove bridgeNotifiedStart, add lazy bubble logic3 files
Test micro-batching mechanismAdd rapid multi-line output testTest all eventReducer cases2 files
Add Phase 1 unified event channel specAdd Phase 2 message grouping design spec2 files
Add eventReducer test to test commandAdd eventReducer to test build include1 files