A small transaction editing screen sometimes shows the wrong result after confirming a set of rows. The correct atomicity of saving must be restored, and the UI must see exactly the snapshot of data that the user confirmed.
Requirements
- The screen runs on Android API 35, Kotlin 2.0,
kotlinx.coroutines 1.8.1.
- It uses a single
ViewModel, StateFlow, and Room withTransaction.
- The batch operation must save all changes in one transaction.
- After a successful confirmation, the screen must show the results from the confirmed snapshot, not from an already mutated list in memory.
- It is assumed that the process is not killed during the operation; only a normal configuration change and a repeated action call are checked.
Reproduction
- Open the screen with two transaction rows.
- Modify both rows and press
Apply.
- Immediately after that, read the displayed summary and the saved records.
- Repeat the scenario with a list refresh before confirmation to make sure the screen does not take an outdated data position.
Expected behavior
- Both confirmed edits remain in the database, or none remain in case of an error — no partial state.
- The final text on the screen matches the data that were passed for confirmation.
- Reapplying must not reuse an already mutated internal list.