[PR 14] Implement UiState and Base Chat/Session ViewModels (E1.S*, E2.S*, E6.S*) #60

Closed
opened 2025-06-25 00:06:58 +00:00 by rwachters · 0 comments
rwachters commented 2025-06-25 00:06:58 +00:00 (Migrated from github.com)

Summary

Define UiState and implement base ViewModels for chat and session state management using the KMP ViewModel pattern.

Details

  • Define the UiState<E, T> sealed class (if not done).
  • Create ChatState and SessionListState classes inheriting from ViewModel.
  • Define core StateFlows for session and list state.
  • Implement ChatState.loadSession and ChatState.sendMessage using viewModelScope.launch and calling ChatApi/SessionApi, folding over the Either results to update state.
  • Implement SessionListState.loadSessionsAndGroups using parZip and folding over results.
  • Implement SessionListState.selectSession and buildThreadBranch function.
  • Implement SessionListData data class with groupedSessions property.
  • Ensure Koin modules in app provide API client implementations for ViewModels.

Dependencies

  • PRs 11, 12, 13 (Frontend clients)
  • Arrow Core/Fx, KMP ViewModel, StateFlow
  • PRs 1, 3 (Backend services/API)

Tests

  • Unit tests for ViewModel logic using runTest (testing state transitions based on mocked API client results).

Assignee

Maya

Labels

frontend, viewmodel, state, arrow, good first issue

## Summary Define UiState and implement base ViewModels for chat and session state management using the KMP ViewModel pattern. ## Details - Define the `UiState<E, T>` sealed class (if not done). - Create `ChatState` and `SessionListState` classes inheriting from `ViewModel`. - Define core `StateFlow`s for session and list state. - Implement `ChatState.loadSession` and `ChatState.sendMessage` using `viewModelScope.launch` and calling `ChatApi`/`SessionApi`, folding over the `Either` results to update state. - Implement `SessionListState.loadSessionsAndGroups` using `parZip` and folding over results. - Implement `SessionListState.selectSession` and `buildThreadBranch` function. - Implement `SessionListData` data class with `groupedSessions` property. - Ensure Koin modules in `app` provide API client implementations for ViewModels. ## Dependencies - PRs 11, 12, 13 (Frontend clients) - Arrow Core/Fx, KMP ViewModel, StateFlow - PRs 1, 3 (Backend services/API) ## Tests - Unit tests for ViewModel logic using `runTest` (testing state transitions based on mocked API client results). ## Assignee Maya ## Labels frontend, viewmodel, state, arrow, good first issue
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Torvian.eu/chatbot#60
No description provided.