Skip to content

refactor(gateway): extract chat reply dispatch - #106697

Merged
steipete merged 1 commit into
mainfrom
codex/refactor-chat-send-reply-dispatch
Jul 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/refactor-chat-send-reply-dispatch

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

chat.ts still owned the full live reply-dispatch pipeline: blocked-turn tracking, reply capture, tool-media promotion, and media transcript persistence. That made the gateway handler harder to change and review as one lifecycle.

Closes another phase of #106555.

Why This Change Was Made

  • Move live reply dispatch into chat-send-reply-dispatch.ts.
  • Keep payload capture, media transcript append, and TTS/tool-media promotion together under one owner.
  • Move transcript reply-text assembly beside the dispatcher that consumes it.
  • Leave admission, queued-turn lifecycle, agent dispatch, and finalization orchestration in chat.ts.

This reduces chat.ts from 2,806 to 2,634 lines. The extracted production module is 228 lines.

User Impact

No intended behavior change. Webchat replies retain reply directives, media transcript persistence, blocked-turn markers, and tool audio promotion.

Evidence

  • Testbox tbx_01kxeahs1200h8e66jd8fm54hb: corepack pnpm test src/gateway/server-methods/chat-send-reply-dispatch.test.ts — 1 file, 2 tests passed.
  • Fresh autoreview: clean, no accepted/actionable findings; correctness 0.97.
  • git diff --check origin/main...HEAD passed after rebasing onto current origin/main.
  • Hosted CI intentionally not awaited per maintainer direction.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime labels Jul 13, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head 3c517493995afbaf4fbc8bb5f7e34ede7a209129:

  • Testbox tbx_01kxeahs1200h8e66jd8fm54hb: corepack pnpm test src/gateway/server-methods/chat-send-reply-dispatch.test.ts — 1 file, 2 tests passed.
  • Fresh autoreview: clean; no accepted/actionable findings; correctness 0.97.
  • git diff --check origin/main...HEAD passed after rebasing onto current origin/main.
  • Focused behavior proof covers transcript reply text, blocked-turn markers, block/final capture, and tool-media promotion.

Known proof gap: hosted CI intentionally not awaited per maintainer direction.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Jul 13, 2026
@steipete
steipete merged commit 2eaf7ed into main Jul 13, 2026
69 of 73 checks passed
@steipete
steipete deleted the codex/refactor-chat-send-reply-dispatch branch July 13, 2026 18:17
@steipete

Copy link
Copy Markdown
Contributor Author

Post-merge regression on main at 8ffe428bd87c22c245dee87b9d107774f2b086bf: the extraction moved appendedWebchatAgentMedia into chat-send-reply-dispatch.ts, but chat.ts still reads that deleted local at line 1792. INTERNAL_MESSAGE_CHANNEL is also now unused in chat.ts.

Exact compiler evidence from https://github.com/openclaw/openclaw/actions/runs/29273880283:

src/gateway/server-methods/chat.ts(66,10): error TS6133: 'INTERNAL_MESSAGE_CHANNEL' is declared but its value is never read.
src/gateway/server-methods/chat.ts(1792,44): error TS2304: Cannot find name 'appendedWebchatAgentMedia'.

This independently breaks production types, test types, lint, and both plugin-SDK package-boundary gates for unrelated PR merge trees.

Clean owner-boundary repair: expose a read-only hasAppendedWebchatAgentMedia() fact from createChatSendReplyDispatch, use it where rawFinalPayloads is projected, remove the stale import, and cover the getter transition in chat-send-reply-dispatch.test.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant