Skip to content

refactor(client): cut cognitive complexity in chat panel body wrapper#1115

Open
NC1107 wants to merge 1 commit into
mainfrom
refactor/chat-panel-body-listener-helper
Open

refactor(client): cut cognitive complexity in chat panel body wrapper#1115
NC1107 wants to merge 1 commit into
mainfrom
refactor/chat-panel-body-listener-helper

Conversation

@NC1107
Copy link
Copy Markdown
Owner

@NC1107 NC1107 commented May 22, 2026

Summary

`buildChatContentBox` sat at S3776 cognitive complexity 16 (budget 15). The top function computed both `useColumn` and `useColumnDrawer` inline AND branched on them again at the bottom to wrap the chatArea. Now it's a flat linear sequence: layout decision → build chatArea → wrap. No behaviour change.

Behind the scenes

  • Extracted `_ColumnLayoutDecision` data class + `_resolveColumnLayout` helper.
  • Extracted `_wrapForColumnLayout` so the 3-way switch (column/drawer/plain) lives in one place.

Test plan

  • `flutter test test/widgets/chat_panel_test.dart test/widgets/chat_panel/` — 19/19 pass
  • `flutter analyze` clean
  • `dart format` clean

References #1104.

buildChatContentBox sat at S3776 cognitive complexity 16 (budget 15) because
it computed both useColumn and useColumnDrawer inline AND branched on them
again at the bottom to wrap the chatArea. Pulled the layout decision into a
small _ColumnLayoutDecision data class + _resolveColumnLayout helper, and the
3-way wrapping into _wrapForColumnLayout. The top function is now a flat
linear sequence well under the budget; no behaviour change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant