Repository navigation
feat: WebSocket /ws/chat + fusion-studio integration (v0.4.1) - #16
Merged
Merged
Conversation
….4.1) - Add WebSocket /ws/chat to projectApiServer for streaming chat (subprocess mode: fusion-code --output-format=stream-json) - Protocol: chat.stream/chat.cancel → chat_event/chat_done NDJSON (compatible with StreamingBridge) - Add start.sh for UpstreamServiceManager auto-start - Update README with WS endpoint docs - Bump version to 0.4.1 Fusion-Studio issues filed: - #9 Layer 1: upstream service registration - #10 Layer 2: FusionCodeAPIClient - #11 Layer 3: StreamingBridge WS integration - PR #12: Layer 1+2 implementation 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dahai80
added a commit
that referenced
this pull request
Aug 28, 2026
…186) Extract the setMessages state-sync wrapper from REPL.tsx into a pure helper src/utils/messagesSetter.ts (applySetMessages). No React hooks, no JSX, no await — only side effects are mutating 3 refs (messagesRef/userInputBaselineRef/userMessagePendingRef) and calling rawSetMessages, byte-identical to the inlined useCallback body. The body maintains a ref mirror of the messages array plus two placeholder-tracking refs: (1) compute next (functional action or direct value) and sync messagesRef.current; (2) if next shrank (compact/rewind/clear) clamp baseline to 0 so the placeholder length check can't go stale; (3) if next grew while userMessagePending, inspect the added slice — if it contains a human turn, clear pending (user message landed); otherwise bump baseline to next.length so the placeholder stays visible for async bridge/hook/scheduled messages landing ahead of the user message. REPL keeps a thin useCallback wrapper whose deps array [] is unchanged verbatim (all deps are refs + rawSetMessages captured in the setters object, no closures). Downstream reads the same const name. Tests (src/__tests__/utils/messagesSetter.test.ts, 8 cases) cover: direct-value vs functional action, shrink clamp, grow-with-human (clears pending), grow-without-human (bumps baseline), grow-without- pending (no-op), prepend slice path, and the prev-empty guard. Real isHumanTurn predicate (type==='user' && !isMeta && toolUseResult===undefined) exercised via minimal fake messages. Gates: typecheck 0 / 873 tests / biome clean / build:dev pass. REPL 6455 -> 6434 (-21). Cumulative across 16 slices: -662. Co-authored-by: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 28, 2026
#187) Extract setInputValue useCallback body (27 LOC, 3 deps) to pure-helper src/utils/inputValueState.ts applySetInputValue(). Same aggregate-input pattern as slices #15/#16: typed InputValueStateSetters (7 fields), REPL keeps useCallback thin wrapper, deps array [setIsPromptInputActive, repinScroll, trySuggestBgPRIntercept] unchanged verbatim. RECENT_SCROLL_REPIN_WINDOW_MS (REPL-local const 3000) passed as recentScrollRepinWindowMs field to keep helper pure-agnostic. Behavior: (1) trySuggestBgPRIntercept(prev,value) hit -> early return; (2) empty->non-empty + scroll-stale (>= window) -> repinScroll; (3) sync inputValueRef.current + setInputValueRaw + setIsPromptInputActive(trim>0). Tests: 8 cases (repin+write+activate, intercept early-return, non-empty guard, scroll within-window/boundary, empty deactivate, whitespace guard, ref-sync-before-setters). 881/881 pass, typecheck 0, biome clean, build:dev ok. REPL 6434 -> 6420 (-14). Cumulative 7096 -> 6420 (-676) across 16 slices. Zero REPL import churn. Byte-identical behavior (deps + ref reads unchanged). Co-authored-by: Claude Fable 5 <[email protected]>
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
v0.4.1 补丁版本,在 v0.4.0 基础上新增 WebSocket 流式对话端点,完成 fusion-code ↔ fusion-studio 三层集成方案的 fusion-code 侧实现。
变更
/ws/chat(src/server/projectApiServer.ts)fusion-code --output-format=stream-json,转发 NDJSON 到 WS 客户端chat.stream/chat.cancel→chat_event/chat_done(兼容 StreamingBridge)start.sh— 供 UpstreamServiceManager 调用Fusion-Studio 侧跟进
Test Plan
bun test tests/server/projectApiServer.test.ts— 15 passbun test tests/lib/claudemd-parser.test.ts— 7 passbun run build— 编译成功🤖 Generated with Claude Code