You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrate Compose Samples away from using value based BasicTextField - #1745
Migrates all remaining value-based text fields across compose-samples to state-based TextFieldState APIs (Compose 1.13 / Material 3 1.5):
-Jetcaster: : Migrated TV BasicTextField and Mobile SearchBar to TextFieldState / SearchBarState, hoisting keywordState onto SearchScreenViewModel.
-Jetsnack: Migrated SearchBar's BasicTextField from TextFieldValue to TextFieldState in Search.kt.
-Reply: Migrated ReplyDockedSearchBar from deprecated DockedSearchBar to state-based SearchBar + ExpandedDockedSearchBar with TextFieldState.
-JetNews: Migrated HomeSearch's OutlinedTextField to TextFieldState, hoisting searchInputState onto HomeViewModel and updating HomeScreenTests.
MagicalMeghan
changed the title
Migrate Compose Samples away from using value based textfield
Migrate Compose Samples away from using value based BasicTextField
Nov 30, 2026
A review of the newly introduced and modified Jetpack Compose code in .gemini/pr_diff.patch was conducted across all 7 performance categories. The findings and recommended optimizations are detailed below.
Finding 1: Missing contentType in LazyColumn.items
Omitting contentType prevents Compose from reusing composition slots and layout nodes when recycling items of the same visual type during scrolling. Providing an explicit contentType allows Compose to reuse slot structures, avoiding composition disposal and inflation overhead during fast scrolling.
Rule Category: 1. State, snapshots, and stability (references/state-and-stability.md)
Why it impacts Compose performance
Unnecessary Coroutine & Flow Dispatch: LaunchedEffect(textFieldState, emails) creates a coroutine and sets up a snapshotFlow observer solely to synchronously filter the in-memory emails collection whenever textFieldState.text changes. Using coroutine dispatch and flow observation for synchronous state derivation adds unnecessary allocation and dispatch overhead.
Double Invalidation from mutableStateListOf: In the collection loop, searchResults.clear() is called immediately followed by searchResults.addAll(...). Because searchResults is an observable SnapshotStateList, each operation triggers a snapshot mutation. Readers of searchResults (such as LazyColumn and the if (searchResults.isNotEmpty()) check) invalidate twice per keystroke: once with an empty list, and then immediately again with the filtered results, causing layout jitter and redundant composition passes.
Suggestion
Replace the SnapshotStateList and LaunchedEffect with a synchronous derivation using remember(emails) { derivedStateOf { ... } }:
val searchResults by remember(emails) {
derivedStateOf {
val query = textFieldState.text.toString()
if (query.isEmpty()) {
emptyList()
} else {
emails.filter {
it.subject.startsWith(prefix = query, ignoreCase =true) ||
it.sender.fullName.startsWith(prefix = query, ignoreCase =true)
}
}
}
}
This derivation evaluates synchronously, updates readers atomically in a single pass without intermediate empty-state popping, and removes the need for LaunchedEffect, snapshotFlow, and mutableStateListOf allocations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates all remaining value-based text fields across compose-samples to state-based TextFieldState APIs (Compose 1.13 / Material 3 1.5):
-Jetcaster: : Migrated TV BasicTextField and Mobile SearchBar to TextFieldState / SearchBarState, hoisting keywordState onto SearchScreenViewModel.
-Jetsnack: Migrated SearchBar's BasicTextField from TextFieldValue to TextFieldState in Search.kt.
-Reply: Migrated ReplyDockedSearchBar from deprecated DockedSearchBar to state-based SearchBar + ExpandedDockedSearchBar with TextFieldState.
-JetNews: Migrated HomeSearch's OutlinedTextField to TextFieldState, hoisting searchInputState onto HomeViewModel and updating HomeScreenTests.