Files
openclaw/ui
Peter SteinbergerandGitHub d18a7cff8e refactor(ui): extract the steered-message lifecycle into a typed state machine (#111610)
* refactor(ui): extract the steered-message lifecycle into a typed state machine

The steer flow was an implicit state machine spread across five chat modules,
with chip states encoded in loosely coupled optional fields and duplicated
guard predicates. This extracts it behind structural types:

- steered-chip.ts: leaf chip model — SteeredChip union (in-flight requires
  sendState "steering"; acknowledged requires pendingRunId and forbids
  sendState), constructors, and narrowing guards; impossible states are
  unrepresentable and every call site uses the guards
- steer-lifecycle.ts: owns the steer send flow, single terminal retirement
  pipeline (remember -> materialize acked chips -> clear), and history-proven
  retirement; absorbs queued-user-turn.ts
- terminal handling in chat-gateway/chat-state and the stored-outbox history
  verification in chat-send consolidate onto the shared helpers; chat-send.ts
  shrinks by ~300 lines; net prod LOC is flat
- behavior fixes riding the pipeline: acknowledged chips retire once
  authoritative history contains their user turn (no more brief chip/history
  double display) and lingering chips keyed to a filtered run id now retire on
  the next history load
- isTerminalFailureChatSendAck moves to chat-send-contract.ts so ack
  narrowing stays type-safe at every formatter call site

* fix(ui): satisfy type, lint, and dead-export gates for the steer-lifecycle split

- restore the snapshotChatAttachments helper (oxc no-map-spread fires on the
  inlined form)
- select the stored-outbox drain head with an explicit loop; the find-predicate
  form made TS narrow away the failed state and flagged the guard (TS2367)
- drop the unused chip re-exports from steer-lifecycle and the consumer-less
  isSteeredChip guard; chip types stay module-local, guard consumers import
  the steered-chip leaf directly

* style(ui): oxfmt line joins in chat-send and chat-state
2026-07-19 21:14:56 -07:00
..