Skip to content

refactor(ui): split chat-send.ts along ack/request/drain/lifecycle seams - #113052

Merged
steipete merged 2 commits into
mainfrom
claude/chat-send-split
Jul 23, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/chat-send-split

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Closes #112742. ui/src/pages/chat/chat-send.ts was ~2,330 lines under a grandfathered max-lines suppression, mixing four concerns: chat.send ack normalization, wire requests/session routing, the stored-outbox drain scheduler, and the send/retry lifecycle. The drain machinery operated on outbox state owned elsewhere since the composer split (#112649), and the file was the hottest merge-conflict zone in chat (it conflicted in two of the last three PRs touching this area).

Why This Change Was Made

Mechanical extraction along ownership seams — code moved, not rewritten:

  • chat-send-contract.ts absorbs ack normalization (it owns the ack shape)
  • chat-send-request.ts (101 lines): wire requests + session routing
  • chat-outbox-drain.ts (628 lines): drain lanes, retry timers, head reconciliation — colocated with the outbox ownership boundary
  • chat-send-actions.ts / chat-send-queue-state.ts / chat-send-submit.ts: retry/steer actions, queue-state helpers, submission routing
  • chat-send.ts keeps the send lifecycle as its identity: now 719 lines, with its max-lines suppression and baseline entry removed

No compatibility re-exports remain. Runtime import cycles avoided by hoisting ChatHost into the contract module, type-only imports, and injecting the drain's two lifecycle callbacks.

User Impact

None — behavior-neutral. Lower review cost on the most-touched chat file; drain logic lives next to the outbox modules it operates on; one fewer grandfathered suppression.

Evidence

  • Full chat page suite on the rebased head (post connection-union main): 69 files / 1,746 tests passed (9 skipped, pre-existing).
  • UI tsgo clean; check:import-cycles: 0 runtime value cycles; max-lines ratchet OK with the chat-send entry removed (1,130 suppressions remain repo-wide, down 1).
  • Type-aware oxlint clean; knip production/full-tree scans: zero unused exports.
  • Rebase over the phase-union landing was conflict-free (the two refactors touched disjoint files by design).
  • Codex autoreview on the final commit: clean, 0.97.
  • Numstat: +1,851/−1,685 non-test (net +166 for module boundaries and cycle-breaking); tests +8/−8 (import-owner updates only).

chat-send.ts was ~2,330 lines under a grandfathered max-lines
suppression, mixing ack normalization, wire requests/routing, the
stored-outbox drain scheduler, retry/steer actions, and the send
lifecycle. Mechanical extraction into owned modules:

- chat-send-contract.ts absorbs ack normalization (it owns the ack shape)
- chat-send-request.ts: wire requests + session routing
- chat-outbox-drain.ts: drain lanes, retry timers, head reconciliation —
  colocated with the outbox ownership boundary from the composer split
- chat-send-actions.ts / chat-send-queue-state.ts / chat-send-submit.ts:
  retry/steer actions, queue-state helpers, submission routing
- chat-send.ts keeps the send lifecycle (719 lines); its max-lines
  suppression and baseline entry are removed

No compatibility re-exports; cycles broken by hoisting ChatHost into the
contract module and injecting the drain's two lifecycle callbacks.

Closes #112742.
@steipete
steipete marked this pull request as ready for review July 23, 2026 14:07
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Jul 23, 2026
@clawsweeper

clawsweeper Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: refactor(ui): split chat-send.ts along ack/request/drain/lifecycle seams This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit dedf85a into main Jul 23, 2026
93 checks passed
@steipete
steipete deleted the claude/chat-send-split branch July 23, 2026 15:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 24, 2026
…ams (openclaw#113052)

* refactor(ui): split chat-send.ts along ack/request/drain/lifecycle seams

chat-send.ts was ~2,330 lines under a grandfathered max-lines
suppression, mixing ack normalization, wire requests/routing, the
stored-outbox drain scheduler, retry/steer actions, and the send
lifecycle. Mechanical extraction into owned modules:

- chat-send-contract.ts absorbs ack normalization (it owns the ack shape)
- chat-send-request.ts: wire requests + session routing
- chat-outbox-drain.ts: drain lanes, retry timers, head reconciliation —
  colocated with the outbox ownership boundary from the composer split
- chat-send-actions.ts / chat-send-queue-state.ts / chat-send-submit.ts:
  retry/steer actions, queue-state helpers, submission routing
- chat-send.ts keeps the send lifecycle (719 lines); its max-lines
  suppression and baseline entry are removed

No compatibility re-exports; cycles broken by hoisting ChatHost into the
contract module and injecting the drain's two lifecycle callbacks.

Closes openclaw#112742.

* fix(ui): extract chat-send ack shapes into a leaf module to break the madge type cycle
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 maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Split chat-send.ts along ack/routing/lifecycle/drain seams

1 participant