Skip to content

Refactor current chat state decomposition into focused StateFlows#256

Closed
fakelog wants to merge 1 commit intomonogram-android:developfrom
fakelog:current-chat-state-decomposition
Closed

Refactor current chat state decomposition into focused StateFlows#256
fakelog wants to merge 1 commit intomonogram-android:developfrom
fakelog:current-chat-state-decomposition

Conversation

@fakelog
Copy link
Copy Markdown
Contributor

@fakelog fakelog commented Apr 15, 2026

Previously, a single broad state object caused unnecessary recompositions of the entire ChatContent screen on unrelated changes (input, search, selection, pinned state, viewers, overlays, appearance flags).

Now state is split by responsibility:

  • chatUiState: top bar, screen-level flags, dialogs, topic/navigation state
  • messagesState: message list, loading, pagination, scroll commands and viewport state
  • selectionState: selected messages and selection mode
  • searchState: search query and search mode
  • inputState: draft, reply/edit state, bot commands, inline results, sticker sheet
  • pinnedState: pinned banner and pinned messages sheet
  • mediaViewerState: image/video/web/mini app viewers
  • appearanceState: wallpaper and message rendering preferences

Benefits:

  • Unrelated updates no longer recompose the whole chat screen
  • Heavy UI like the message list subscribes to narrower flows, reducing noise
  • Screen state aligns better with actual UI responsibilities, improving maintainability
  • Background, message list and message options no longer depend on the monolithic state directly

Additionally, moved ChatContent subtrees to the focused state models so the UI no longer collects the broad component state at the root.

Previously, a single broad state object caused unnecessary recompositions of the entire ChatContent screen on unrelated changes (input, search, selection, pinned state, viewers, overlays, appearance flags).

Now state is split by responsibility:
- chatUiState: top bar, screen-level flags, dialogs, topic/navigation state
- messagesState: message list, loading, pagination, scroll commands and viewport state
- selectionState: selected messages and selection mode
- searchState: search query and search mode
- inputState: draft, reply/edit state, bot commands, inline results, sticker sheet
- pinnedState: pinned banner and pinned messages sheet
- mediaViewerState: image/video/web/mini app viewers
- appearanceState: wallpaper and message rendering preferences

Benefits:
- Unrelated updates no longer recompose the whole chat screen
- Heavy UI like the message list subscribes to narrower flows, reducing noise
- Screen state aligns better with actual UI responsibilities, improving maintainability
- Background, message list and message options no longer depend on the monolithic state directly

Additionally, moved ChatContent subtrees to the focused state models so the UI no longer collects the broad component state at the root.
@fakelog fakelog force-pushed the current-chat-state-decomposition branch from 261ff61 to cf8343d Compare April 15, 2026 16:51
@fakelog fakelog closed this Apr 15, 2026
@fakelog fakelog deleted the current-chat-state-decomposition branch April 15, 2026 17:09
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