Optimize Compose app list rendering and incremental loading#14
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1836903c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| for (chunk in sortedPackages.chunked(30)) { | ||
| for (chunk in packages.chunked(30)) { |
There was a problem hiding this comment.
Preserve global app sorting when loading in chunks
Chunking packages before sorting only orders apps within each 30-item block, so the final list order now depends on the package manager’s enumeration order instead of a global app-name sort. On devices with more than one chunk, this makes the main list and filteredAppData.take(10) suggestions non-alphabetical and unstable across refreshes, which is a user-visible regression from the previous globally sorted behavior.
Useful? React with 👍 / 👎.
Motivation
Description
var allAppData by remember { mutableStateOf<List<AppData>>(emptyList()) }withval allAppData = remember { mutableStateListOf<AppData>() }and added a lightweightappDataVersion(mutableIntStateOf) to signal meaningful item changes.allAppData.clear()+allAppData.addAll(chunk)instead ofallAppData = allAppData + chunkto avoid list copying and broad recompositions.allAppData[targetIndex] = ...) and bumpappDataVersionto allow targeted downstream updates.derivedStateOffiltering keyed on the whole list with aproduceStatethat is keyed byquery,filters,allAppData.size, andappDataVersionto debounce / reduce filter recomputation.drawBehindcustom line drawing and added aHorizontalDividerin the item layout to avoid per-frame draw callbacks during scroll.80x80to48x48and changed the loading path to chunk-first then sort-per-chunk (.chunked(30)+.sortedBy { it.appName }) to improve first-paint latency and reduce upfront sorting cost.Testing
./gradlew :app:compileDebugKotlin, which failed in this environment with/bin/bash: line 1: ./gradlew: Permission deniedand environmentJAVACMDissues.bash ./gradlew :app:compileDebugKotlin, which also failed due to the environment's missing Java runtime (exec: : not found).Codex Task