Skip to content

refactor(ui): retire grandfathered oversized chat modules - #133751

Merged
steipete merged 7 commits into
mainfrom
claude/chat-surface-refactor
Aug 31, 2026
Merged

steipete merged 7 commits into
mainfrom
claude/chat-surface-refactor

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The chat surface carried four grandfathered oxlint-disable ln production files — [chat-history.ts] at 2,221 lines, [tool-stream.ts] at 1,209, [composer-persistence.ts] at 1,111, and [chat-tool-cards.ts] at 1,060 — plus accumulated duplication: state fields re-declared locally that already live on the ChatState contract, hand-rolled record guards where the canonical record-coerce helper belongs, single-use wrapper functions, duplicated tool-card predicates, and near-duplicate sender-presentation test cases from the recent forwarded-message campaign.

Why This Change Was Made

Three lanes, zero behavior change:

Lane 1 — retire the suppressions. All four files split along concept boundaries into 14 new modules (history: actions/branches/hydration/request/snapshot/state/stream/subscription; tool-stream: status/preamble; composer: session-store/queue-store; tool-cards: content/command-highlight). All 18 resulting files sit under the 700-line cap with no suppressions; the four oxlint-disable ln markers, their baseline entries, and the composer export-ignore entry are deleted. History request fencing, staged prefetch, subscription ownership, and hydration-ordering comments moved with their owning logic. The boot manifest was regenerated (pnpm ui:boot-manifest:gen); no [INEFFECTIVE_DYNAMIC_IMPORT] warnings.

Lane 2 — simplify. Removed the locally re-declared subscription state fields (they live on chat-state-contract.ts), replaced a hand-rolled block filter in heartbeat display with the canonical asOptionalObjectRecord guard (traced case-equivalent for all five block shapes), swapped a local normalizeSubscriptionKey for normalizeNullableString (identical trim/empty/non-string semantics), and deleted redundant patch/subscription wrappers and duplicated tool-card predicates. Assertion-safety baseline shrank by one more allowance.

Lane 3 — test consolidation. Table-drove six near-duplicate sender-presentation cases across message-normalizer.sender-label.test.ts and chat-message.test.ts, keeping distinct failure names and behavior coverage. Full splits of the 10k-line test files remain deliberately deferred.

User Impact

None visible — internal restructuring. The production LOC delta is net +132 (+4,061/−3,929): the growth is module imports, types, and explicit ownership boundaries purchased by retiring four suppressed oversized files — the named justification is the ownership-boundary structure itself. Tests net −11.

Evidence

  • node scripts/run-vitest.mjs ui/src/pages/chat ui/src/lib/chat — 4,426 tests passing (207 files).
  • node scripts/check-changed.mjs — fully green, proving the suppression removals hold (format, tsgo lanes, lint stripes incl. max-lines, dead-export scan, assertion ratchet, import cycles).
  • pnpm build — clean, no ineffective-dynamic-import warnings; node scripts/ui.js build — all budgets green, startup JS gzip 345,579 B (1.8 KB under the enforcement limit).
  • Codex autoreview on the branch diff — scoped-clean.
  • Behavior-sensitive Lane 2 changes hand-verified: heartbeat block-classification traced for all input shapes; normalizeNullableString semantics matched against the deleted local helper; removed state fields confirmed present on chat-state-contract.ts:70-71.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Aug 31, 2026
@steipete
steipete marked this pull request as ready for review August 31, 2026 03:02
@steipete
steipete force-pushed the claude/chat-surface-refactor branch 2 times, most recently from 856fd73 to 96899a5 Compare August 31, 2026 06:15
Retire the four grandfathered oxlint max-lines suppressions by splitting
chat-history, tool-stream, composer-persistence, and chat-tool-cards
into concept-owned modules; regenerate the boot manifest; adopt the
upstream message-visibility extraction and 800-message page limit from
the rebase.
The tool-stream split left a type-import cycle (preamble -> status ->
tool-stream). The shared host/event/status types move to
tool-stream-contract.ts, the lane's import-light leaf, and every
importer references the contract directly — no re-export barrel.
All consumers import the constant from its owner outbox-store-codec; the
composer-persistence compat re-export lost its last importer.
@steipete
steipete force-pushed the claude/chat-surface-refactor branch from 96899a5 to cab0562 Compare August 31, 2026 06:32
@steipete
steipete merged commit 701da05 into main Aug 31, 2026
152 checks passed
@steipete
steipete deleted the claude/chat-surface-refactor branch August 31, 2026 06:53
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
…33751)

* refactor(ui): split oversized chat modules

Retire the four grandfathered oxlint max-lines suppressions by splitting
chat-history, tool-stream, composer-persistence, and chat-tool-cards
into concept-owned modules; regenerate the boot manifest; adopt the
upstream message-visibility extraction and 800-message page limit from
the rebase.

* refactor(ui): simplify chat display and subscription logic

* test(ui): consolidate sender presentation coverage

* refactor(ui): extract the tool-stream leaf contract

The tool-stream split left a type-import cycle (preamble -> status ->
tool-stream). The shared host/event/status types move to
tool-stream-contract.ts, the lane's import-light leaf, and every
importer references the contract directly — no re-export barrel.

* refactor(ui): trim imports orphaned by the tool-stream contract move

* test(ui): point restored composer-lane tests at the split history modules

* refactor(ui): drop the dead interrupted-settings re-export

All consumers import the constant from its owner outbox-store-codec; the
composer-persistence compat re-export lost its last importer.
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.

1 participant