From 8cd926de1ed3b529da10558d3caf36f42d53d93a Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:25:27 +0200 Subject: [PATCH 01/12] W3: surface load errors on AllStorages instead of false empty state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DrawerViewModel mapped HierarchyStore.state but dropped the store's error (not even a field on DrawerUiState), so a network failure rendered 'No storages yet' — indistinguishable from a real empty account, and pull-to-refresh failures vanished. Add error to DrawerUiState, map it, gate the empty text on error == null, and render failures through the existing ErrorRetry (Assertive live region + retry). Add a DrawerViewModel error-path unit test. --- BACKLOG.md | 6 ++++ .../inventory/ui/app/DrawerViewModel.kt | 5 +++ .../inventory/ui/home/AllStoragesScreen.kt | 8 ++++- .../scuttle/inventory/DrawerViewModelTest.kt | 33 +++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/BACKLOG.md b/BACKLOG.md index 0f26fc5..dd2df05 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,12 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **AllStorages shows load errors instead of a false empty state** (wave-2 W3). + `DrawerViewModel` mapped `HierarchyStore.state` but dropped the store's `error` (it wasn't even a field + on `DrawerUiState`), so a network failure rendered "No storages yet" — indistinguishable from a real + empty account, and pull-to-refresh failures vanished silently. Added `error` to `DrawerUiState`, mapped + it, and gated the empty text on `error == null`, rendering a failure through the existing `ErrorRetry` + (Assertive live region + retry). Added a `DrawerViewModel` error-path unit test. - ✅ `2026-07-04` — **ForgotPasswordViewModel unit test** (gap analysis T21, found in the final completeness scan). A coverage sweep showed it was the only one of 16 ViewModels without a unit test, despite real `submit()` loading→sent/error logic on a security-adjacent flow. Added diff --git a/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt b/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt index d29d029..5e6df16 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt @@ -20,6 +20,10 @@ data class DrawerUiState( val missingItemCount: Int = 0, val loading: Boolean = false, val refreshing: Boolean = false, + // Surfaced from HierarchyStore so AllStorages can tell a real network failure + // apart from a genuinely empty account (W3) — without this a failed load + // rendered the "No storages yet" empty state. + val error: String? = null, ) @HiltViewModel @@ -35,6 +39,7 @@ class DrawerViewModel @Inject constructor( missingItemCount = s.missingItemCount, loading = s.loading, refreshing = s.refreshing, + error = s.error, ) }.stateIn(viewModelScope, SharingStarted.Eagerly, DrawerUiState()) diff --git a/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt index c77d5a0..ae1f14a 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt @@ -53,6 +53,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.ErrorRetry import dev.scuttle.inventory.ui.common.storageTypeLabel import dev.scuttle.inventory.data.dto.LocationDto import dev.scuttle.inventory.ui.app.DrawerViewModel @@ -111,7 +112,12 @@ fun AllStoragesScreen( ) { Spacer(Modifier.height(4.dp)) - if (state.entries.isEmpty()) { + val error = state.error + if (error != null && state.entries.isEmpty()) { + // A load failure must not masquerade as an empty account — show + // the error with a retry, not "No storages yet" (W3). + ErrorRetry(message = error, onRetry = { viewModel.refresh() }) + } else if (state.entries.isEmpty()) { Text(stringResource(R.string.all_storage_empty)) } diff --git a/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt b/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt index 0d8a1a4..a141d06 100644 --- a/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt +++ b/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt @@ -11,11 +11,15 @@ import dev.scuttle.inventory.data.location.LocationRepository import dev.scuttle.inventory.data.product.ProductRepository import dev.scuttle.inventory.data.shelf.ShelfRepository import dev.scuttle.inventory.ui.app.DrawerViewModel +import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test +import java.io.IOException class DrawerViewModelTest { @@ -120,6 +124,35 @@ class DrawerViewModelTest { assertTrue(vm.state.value.locationWarnings[10] == false) } + private class ThrowingHouseholdRepository : HouseholdRepository { + override fun getCached(): List? = null + override suspend fun list(): List = throw IOException("network down") + override suspend fun create(name: String) = throw NotImplementedError() + override suspend fun join(code: String) = throw NotImplementedError() + override suspend fun leave(householdId: Long) {} + } + + @Test + fun refresh_failure_surfaces_error_and_clears_loading() = runTest { + // W3: a failed load must reach DrawerUiState.error so AllStorages can show + // a retry instead of the "No storages yet" empty state. + val store = HierarchyStore( + ThrowingHouseholdRepository(), + FakeLocationRepository(), + FakeShelfRepository(), + FakeProductRepository(), + ) + val vm = DrawerViewModel(store, FakeLocationRepository()) + + store.refresh(userInitiated = true) + + val failed = vm.state.first { it.error != null } + assertNotNull(failed.error) + assertFalse(failed.loading) + assertFalse(failed.refreshing) + assertTrue(failed.entries.isEmpty()) + } + @Test fun delete_location_removes_it_from_entries() = runTest { val fakeLocRepo = FakeLocationRepository( From 1ae9aaa470247b21225bb9e6b911a2df392e9d99 Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:26:38 +0200 Subject: [PATCH 02/12] W4: surface load errors on missing-items screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MissingItemsViewModel exposed error but the screen never rendered it; a failed load fell through to the 'all stocked' empty state — the worst failure mode for a screen whose whole job is surfacing warnings. Render state.error via ErrorRetry when there are no items, ahead of the empty state. Add a VM error-path unit test. --- BACKLOG.md | 5 +++ .../ui/missing/MissingItemsScreen.kt | 18 ++++++++++- .../inventory/MissingItemsViewModelTest.kt | 31 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/BACKLOG.md b/BACKLOG.md index dd2df05..91bc582 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,11 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Missing-items screen surfaces load errors instead of a false "all stocked"** (wave-2 W4). + `MissingItemsViewModel` exposed `error` but `MissingItemsScreen` never rendered it — a failed load fell + through to `missing_items_empty`, i.e. a screen whose whole job is surfacing warnings would silently + claim everything's fine on a network error. Render `state.error` via `ErrorRetry(onRetry = refresh)` + when there are no items, ahead of the empty state. Added a VM error-path unit test. - ✅ `2026-07-04` — **AllStorages shows load errors instead of a false empty state** (wave-2 W3). `DrawerViewModel` mapped `HierarchyStore.state` but dropped the store's `error` (it wasn't even a field on `DrawerUiState`), so a network failure rendered "No storages yet" — indistinguishable from a real diff --git a/app/src/main/java/dev/scuttle/inventory/ui/missing/MissingItemsScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/missing/MissingItemsScreen.kt index 200cc08..17a0ca8 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/missing/MissingItemsScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/missing/MissingItemsScreen.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.ErrorRetry @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -73,7 +74,22 @@ fun MissingItemsScreen( .fillMaxSize() .padding(padding), ) { - if (state.items.isEmpty() && !state.loading) { + val error = state.error + if (error != null && state.items.isEmpty()) { + // A failed load must not fall through to "all stocked" — for a + // screen whose whole job is surfacing warnings that's the worst + // failure mode. Show the error with a retry instead (W4). + Column( + modifier = Modifier + .fillMaxSize() + .navigationBarsPadding() + .padding(horizontal = 16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + ErrorRetry(message = error, onRetry = viewModel::refresh) + } + } else if (state.items.isEmpty() && !state.loading) { Column( modifier = Modifier .fillMaxSize() diff --git a/app/src/test/java/dev/scuttle/inventory/MissingItemsViewModelTest.kt b/app/src/test/java/dev/scuttle/inventory/MissingItemsViewModelTest.kt index 107fd72..7b3101e 100644 --- a/app/src/test/java/dev/scuttle/inventory/MissingItemsViewModelTest.kt +++ b/app/src/test/java/dev/scuttle/inventory/MissingItemsViewModelTest.kt @@ -11,12 +11,15 @@ import dev.scuttle.inventory.data.location.LocationRepository import dev.scuttle.inventory.data.product.ProductRepository import dev.scuttle.inventory.data.shelf.ShelfRepository import dev.scuttle.inventory.ui.missing.MissingItemsViewModel +import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test +import java.io.IOException class MissingItemsViewModelTest { @@ -73,6 +76,34 @@ class MissingItemsViewModelTest { return MissingItemsViewModel(store) } + private class ThrowingHouseholdRepository : HouseholdRepository { + override fun getCached(): List? = null + override suspend fun list(): List = throw IOException("network down") + override suspend fun create(name: String) = throw NotImplementedError() + override suspend fun join(code: String) = throw NotImplementedError() + override suspend fun leave(householdId: Long) {} + } + + @Test + fun load_failure_surfaces_error_and_no_items() = runTest { + // W4: a failed load must expose error so the screen shows a retry rather + // than the "all stocked" empty state — the worst miss for a warnings screen. + val store = HierarchyStore( + ThrowingHouseholdRepository(), + FakeLocationRepository(), + FakeShelfRepository(), + FakeProductRepository(), + ) + val vm = MissingItemsViewModel(store) + + store.refresh(userInitiated = true) + + val failed = vm.state.first { it.error != null } + assertNotNull(failed.error) + assertFalse(failed.loading) + assertTrue(failed.items.isEmpty()) + } + @Test fun empty_when_no_mandatory_products() = runTest { val vm = viewModel( From 4bb59d96787476ef77102e5aeb28aad66cc52cf0 Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:30:31 +0200 Subject: [PATCH 03/12] W7: stop conflating empty and error states on two list screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit StorageOverviewScreen and LocationDetailScreen each rendered their error line and the empty text on a failed load, so 'No storages yet' / 'no shelves yet' showed alongside the error — a false 'your account is empty'. Gate the empty text on state.error == null in both. --- BACKLOG.md | 4 ++++ .../scuttle/inventory/ui/location/LocationDetailScreen.kt | 4 +++- .../scuttle/inventory/ui/storage/StorageOverviewScreen.kt | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BACKLOG.md b/BACKLOG.md index 91bc582..849dccf 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,10 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Empty vs error no longer conflated on StorageOverview + LocationDetail** (wave-2 W7). + Both screens rendered their error line *and* the empty text on a failed load ("Something went wrong" + + "No storages yet" / "no shelves yet") — the empty text reads as a false "your account is empty". Gated + the empty text on `state.error == null` in both. - ✅ `2026-07-04` — **Missing-items screen surfaces load errors instead of a false "all stocked"** (wave-2 W4). `MissingItemsViewModel` exposed `error` but `MissingItemsScreen` never rendered it — a failed load fell through to `missing_items_empty`, i.e. a screen whose whole job is surfacing warnings would silently diff --git a/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt index 877ef7a..7c998c6 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt @@ -195,7 +195,9 @@ fun LocationDetailScreen( } if (state.shelves.isEmpty()) { - if (!state.loading) { + // Suppress "no shelves yet" on a failed load — the error line above + // already explains it; showing both reads as a false empty (W7). + if (!state.loading && state.error == null) { Text( text = stringResource(R.string.location_no_shelves), modifier = Modifier.padding(16.dp), diff --git a/app/src/main/java/dev/scuttle/inventory/ui/storage/StorageOverviewScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/storage/StorageOverviewScreen.kt index 977029e..aab96d8 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/storage/StorageOverviewScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/storage/StorageOverviewScreen.kt @@ -143,7 +143,10 @@ fun StorageOverviewScreen( ErrorRetry(message = it, onRetry = viewModel::refresh) } - if (state.locations.isEmpty() && !state.loading) { + // Don't show the empty text on a failed load — the ErrorRetry above + // already explains it; "No storages yet" alongside would be a false + // "your account is empty" (W7). + if (state.locations.isEmpty() && !state.loading && state.error == null) { Text( text = stringResource(R.string.storage_overview_empty), modifier = Modifier.padding(top = 8.dp), From f30bf8db8eb972e1e7698c85acc1ae94437f459d Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:33:11 +0200 Subject: [PATCH 04/12] W8: announce inline error/status text to TalkBack on six screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wave-1 liveRegion=Assertive pattern wasn't propagated to the bare Text(error) on Dashboard, Households, Search, Invite, LocationDetail and Settings (join error + success) — all silent until focused. Add a shared LiveStatusText helper (Assertive live region) and route all seven sites through it, including announcing the Settings join success. --- BACKLOG.md | 5 ++++ .../inventory/ui/common/LiveStatusText.kt | 30 +++++++++++++++++++ .../inventory/ui/dashboard/DashboardScreen.kt | 3 +- .../ui/households/HouseholdsScreen.kt | 3 +- .../inventory/ui/invite/InviteScreen.kt | 3 +- .../ui/location/LocationDetailScreen.kt | 7 ++--- .../inventory/ui/search/SearchScreen.kt | 3 +- .../inventory/ui/settings/SettingsScreen.kt | 8 +++-- 8 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/dev/scuttle/inventory/ui/common/LiveStatusText.kt diff --git a/BACKLOG.md b/BACKLOG.md index 849dccf..4cd9213 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,11 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Inline error/status text is now announced by TalkBack on six screens** (wave-2 W8). + The wave-1 `liveRegion=Assertive` pattern (AuthScreen/ErrorRetry) wasn't propagated to the bare + `Text(error)` on Dashboard, Households, Search, Invite, LocationDetail, and Settings (join error *and* + success) — all left silent until focused. Added a shared `LiveStatusText` helper (Assertive live region, + error/primary color) and routed all seven sites through it, including announcing the Settings join success. - ✅ `2026-07-04` — **Empty vs error no longer conflated on StorageOverview + LocationDetail** (wave-2 W7). Both screens rendered their error line *and* the empty text on a failed load ("Something went wrong" + "No storages yet" / "no shelves yet") — the empty text reads as a false "your account is empty". Gated diff --git a/app/src/main/java/dev/scuttle/inventory/ui/common/LiveStatusText.kt b/app/src/main/java/dev/scuttle/inventory/ui/common/LiveStatusText.kt new file mode 100644 index 0000000..8e02386 --- /dev/null +++ b/app/src/main/java/dev/scuttle/inventory/ui/common/LiveStatusText.kt @@ -0,0 +1,30 @@ +package dev.scuttle.inventory.ui.common + +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.semantics.LiveRegionMode +import androidx.compose.ui.semantics.liveRegion +import androidx.compose.ui.semantics.semantics + +/** + * An inline status line (error or success) that TalkBack announces the moment it + * appears, via `liveRegion = Assertive` — the accessibility pattern established on + * AuthScreen and [ErrorRetry]. Use it for the screens whose status text has no + * Retry affordance (search/join/action feedback), so the announcement isn't left + * silent until the text happens to be focused (W8). + */ +@Composable +fun LiveStatusText( + message: String, + modifier: Modifier = Modifier, + color: Color = MaterialTheme.colorScheme.error, +) { + Text( + text = message, + color = color, + modifier = modifier.semantics { liveRegion = LiveRegionMode.Assertive }, + ) +} diff --git a/app/src/main/java/dev/scuttle/inventory/ui/dashboard/DashboardScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/dashboard/DashboardScreen.kt index 12b0f8f..d26cd1a 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/dashboard/DashboardScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/dashboard/DashboardScreen.kt @@ -44,6 +44,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.LiveStatusText import dev.scuttle.inventory.ui.theme.FrostCard @OptIn(ExperimentalMaterial3Api::class) @@ -109,7 +110,7 @@ fun DashboardScreen( .padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp), ) { - state.error?.let { Text(it, color = MaterialTheme.colorScheme.error) } + state.error?.let { LiveStatusText(it) } // Stat cards Row( diff --git a/app/src/main/java/dev/scuttle/inventory/ui/households/HouseholdsScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/households/HouseholdsScreen.kt index 09e6fb7..f85452c 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/households/HouseholdsScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/households/HouseholdsScreen.kt @@ -52,6 +52,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.LiveStatusText import dev.scuttle.inventory.ui.theme.FrostCard import dev.scuttle.inventory.ui.theme.HouseholdAvatar @@ -108,7 +109,7 @@ fun HouseholdsScreen( Spacer(Modifier.height(4.dp)) state.error?.let { - Text(text = it, color = MaterialTheme.colorScheme.error) + LiveStatusText(it) } if (state.households.isEmpty() && !state.loading) { diff --git a/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt index ee91632..6d8ef03 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt @@ -36,6 +36,7 @@ import androidx.hilt.navigation.compose.hiltViewModel import com.google.zxing.BarcodeFormat import com.google.zxing.qrcode.QRCodeWriter import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.LiveStatusText import dev.scuttle.inventory.ui.theme.SpaceMono import kotlinx.coroutines.delay @@ -81,7 +82,7 @@ fun InviteScreen( } state.error?.let { - Text(text = it, color = MaterialTheme.colorScheme.error) + LiveStatusText(it) } if (state.code.isNotEmpty()) { diff --git a/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt index 7c998c6..c67c559 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt @@ -66,6 +66,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.LiveStatusText import dev.scuttle.inventory.data.dto.ProductDto import dev.scuttle.inventory.ui.app.DrawerViewModel import dev.scuttle.inventory.ui.products.ProductsPane @@ -187,11 +188,7 @@ fun LocationDetailScreen( } state.error?.let { - Text( - text = it, - color = MaterialTheme.colorScheme.error, - modifier = Modifier.padding(16.dp), - ) + LiveStatusText(it, modifier = Modifier.padding(16.dp)) } if (state.shelves.isEmpty()) { diff --git a/app/src/main/java/dev/scuttle/inventory/ui/search/SearchScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/search/SearchScreen.kt index 96fb804..3a4a1c9 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/search/SearchScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/search/SearchScreen.kt @@ -30,6 +30,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.LiveStatusText import dev.scuttle.inventory.ui.common.SortMenu import dev.scuttle.inventory.ui.theme.FrostCard @@ -85,7 +86,7 @@ fun SearchScreen( } state.error?.let { - Text(text = it, color = MaterialTheme.colorScheme.error) + LiveStatusText(it) } if (state.query.isNotBlank() && state.results.isEmpty() && !state.loading) { diff --git a/app/src/main/java/dev/scuttle/inventory/ui/settings/SettingsScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/settings/SettingsScreen.kt index 6e80663..9b36ee8 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/settings/SettingsScreen.kt @@ -46,6 +46,7 @@ import androidx.compose.ui.platform.LocalContext import com.journeyapps.barcodescanner.ScanContract import com.journeyapps.barcodescanner.ScanOptions import dev.scuttle.inventory.R +import dev.scuttle.inventory.ui.common.LiveStatusText import dev.scuttle.inventory.data.settings.AppLanguage import dev.scuttle.inventory.ui.theme.ThemeMode @@ -133,10 +134,13 @@ fun SettingsScreen( Text(text = stringResource(R.string.settings_join_section), style = MaterialTheme.typography.titleMedium) joinState.error?.let { - Text(text = it, color = MaterialTheme.colorScheme.error) + LiveStatusText(it) } if (joinState.success) { - Text(text = stringResource(R.string.settings_join_success), color = MaterialTheme.colorScheme.primary) + LiveStatusText( + stringResource(R.string.settings_join_success), + color = MaterialTheme.colorScheme.primary, + ) } Row( modifier = Modifier.fillMaxWidth(), From 16ad684f3d76cb0603ca688a62af29e15c33a755 Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:35:03 +0200 Subject: [PATCH 05/12] W9: give warning shelf tabs a content description (not color-only) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An out-of-stock-mandatory shelf tab was marked by red text + a decorative 6dp dot with no semantics — color-only (WCAG 1.4.1) and silent to TalkBack. Add location_shelf_missing_cd (EN+NL) and a clearAndSetSemantics contentDescription ', has missing items' on the tab's text row. --- BACKLOG.md | 5 +++++ .../inventory/ui/location/LocationDetailScreen.kt | 15 +++++++++++++++ app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 22 insertions(+) diff --git a/BACKLOG.md b/BACKLOG.md index 4cd9213..05147f4 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,11 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Shelf tabs announce missing-stock instead of signalling by color alone** (wave-2 W9). + `LocationDetailScreen` marked an out-of-stock-mandatory shelf with red tab text + a decorative 6dp dot + and no semantics — color-only (WCAG 1.4.1) and silent to TalkBack. Added a `location_shelf_missing_cd` + string (EN + NL) and a `clearAndSetSemantics { contentDescription = ", has missing items" }` on + the warning tab's text row, so the state is conveyed non-visually without doubling the shelf name. - ✅ `2026-07-04` — **Inline error/status text is now announced by TalkBack on six screens** (wave-2 W8). The wave-1 `liveRegion=Assertive` pattern (AuthScreen/ErrorRetry) wasn't propagated to the bare `Text(error)` on Dashboard, Households, Search, Invite, LocationDetail, and Settings (join error *and* diff --git a/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt index c67c559..e89be9c 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/location/LocationDetailScreen.kt @@ -59,6 +59,8 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.semantics.clearAndSetSemantics +import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.stringResource @@ -208,6 +210,14 @@ fun LocationDetailScreen( val isSelected = if (state.deleteMode) shelf.id in state.selectedShelves else currentPage == index val tabHasWarning = shelfWarnings[shelf.id] == true + // The warning is conveyed visually by red text + a dot; give the + // text row a content description so it isn't color-only (WCAG + // 1.4.1) and TalkBack announces ", has missing items" (W9). + val warningCd = if (tabHasWarning && !state.deleteMode) { + stringResource(R.string.location_shelf_missing_cd, shelf.name) + } else { + null + } Tab( selected = isSelected, onClick = { @@ -224,6 +234,11 @@ fun LocationDetailScreen( Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp), + modifier = if (warningCd != null) { + Modifier.clearAndSetSemantics { contentDescription = warningCd } + } else { + Modifier + }, ) { Text( shelf.name, diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index ed7c06a..cf1cdde 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -70,6 +70,7 @@ Plank toevoegen Product toevoegen Nog geen planken. Tik op + in de bovenbalk om er een toe te voegen. + %1$s, ontbrekende artikelen Verwijderen (%d) Verwijderen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a21d742..bf14b18 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,6 +70,7 @@ Add shelf Add product No shelves yet. Tap + in the top bar to add one. + %1$s, has missing items Delete (%d) Delete From 39de98607b34a39164b83b27d892baa7fc8db378 Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:36:41 +0200 Subject: [PATCH 06/12] W10: surface drawer location-delete failures via snackbar deleteLocation had runCatching{}.onSuccess{refresh()} with no onFailure, so a failed swipe-to-delete on AllStorages was silent. Add a one-shot actionError flow (separate from the store-derived load error, since a delete fails with the list populated and the empty-state ErrorRetry would never show it), rendered through the existing SnackbarErrorEffect + a new SnackbarHost. Add a VM delete-failure unit test. --- BACKLOG.md | 6 ++++++ .../inventory/ui/app/DrawerViewModel.kt | 16 +++++++++++++++- .../inventory/ui/home/AllStoragesScreen.kt | 9 +++++++++ .../scuttle/inventory/DrawerViewModelTest.kt | 19 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/BACKLOG.md b/BACKLOG.md index 05147f4..2ae7e20 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,12 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Drawer/home location-delete failure is surfaced, not swallowed** (wave-2 W10). + `DrawerViewModel.deleteLocation` had `runCatching{…}.onSuccess{ refresh() }` with no `onFailure`, so a + failed swipe-to-delete on AllStorages left the location in place with no feedback. Added a one-shot + `actionError` flow (separate from the store-derived load `error`, since a delete fails while the list is + populated and the inline empty-state ErrorRetry would never show it), rendered via the existing + `SnackbarErrorEffect` + a new `SnackbarHost` on the screen. Added a VM delete-failure unit test. - ✅ `2026-07-04` — **Shelf tabs announce missing-stock instead of signalling by color alone** (wave-2 W9). `LocationDetailScreen` marked an out-of-stock-mandatory shelf with red tab text + a decorative 6dp dot and no semantics — color-only (WCAG 1.4.1) and silent to TalkBack. Added a `location_shelf_missing_cd` diff --git a/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt b/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt index 5e6df16..932b3ba 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/app/DrawerViewModel.kt @@ -5,10 +5,13 @@ import androidx.lifecycle.viewModelScope import dev.scuttle.inventory.data.HierarchyStore import dev.scuttle.inventory.data.HouseholdWithLocations import dev.scuttle.inventory.data.location.LocationRepository +import dev.scuttle.inventory.data.error.toUserMessage import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch @@ -45,15 +48,26 @@ class DrawerViewModel @Inject constructor( private var deleteJob: Job? = null + // One-shot delete failure, surfaced by AllStorages as a snackbar (W10). Kept + // separate from the store-derived load `error` above because a delete fails + // while the list is populated — the inline ErrorRetry (empty-state only) + // would never show it. + private val _actionError = MutableStateFlow(null) + val actionError: StateFlow = _actionError.asStateFlow() + fun refresh() = store.refresh(userInitiated = true) fun deleteLocation(householdId: Long, locationId: Long) { if (deleteJob?.isActive == true) return deleteJob = viewModelScope.launch { - runCatching { locationRepository.delete(householdId, locationId) }.onSuccess { store.refresh() } + runCatching { locationRepository.delete(householdId, locationId) } + .onSuccess { store.refresh() } + .onFailure { e -> _actionError.value = e.toUserMessage("Failed to delete location.") } } } + fun consumeActionError() { _actionError.value = null } + fun reportLocationWarning(locationId: Long, hasWarning: Boolean) = store.reportLocationWarning(locationId, hasWarning) } diff --git a/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt index ae1f14a..14ea860 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/home/AllStoragesScreen.kt @@ -32,6 +32,8 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.SwipeToDismissBox import androidx.compose.material3.SwipeToDismissBoxValue import androidx.compose.material3.Text @@ -54,6 +56,7 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import dev.scuttle.inventory.R import dev.scuttle.inventory.ui.common.ErrorRetry +import dev.scuttle.inventory.ui.common.SnackbarErrorEffect import dev.scuttle.inventory.ui.common.storageTypeLabel import dev.scuttle.inventory.data.dto.LocationDto import dev.scuttle.inventory.ui.app.DrawerViewModel @@ -72,12 +75,18 @@ fun AllStoragesScreen( ) { val state by viewModel.state.collectAsState() val localState by localViewModel.state.collectAsState() + val actionError by viewModel.actionError.collectAsState() var pendingDelete by remember { mutableStateOf?>(null) } + val snackbarHostState = remember { SnackbarHostState() } + // Surface a failed swipe-to-delete as a transient snackbar so it isn't silent (W10). + SnackbarErrorEffect(actionError, snackbarHostState, onConsumed = viewModel::consumeActionError) + val statusBarInsets = WindowInsets.statusBars Scaffold( contentWindowInsets = WindowInsets(0), modifier = modifier, + snackbarHost = { SnackbarHost(snackbarHostState) }, topBar = { TopAppBar( windowInsets = statusBarInsets, diff --git a/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt b/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt index a141d06..672d985 100644 --- a/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt +++ b/app/src/test/java/dev/scuttle/inventory/DrawerViewModelTest.kt @@ -153,6 +153,25 @@ class DrawerViewModelTest { assertTrue(failed.entries.isEmpty()) } + @Test + fun delete_location_failure_surfaces_action_error() = runTest { + // W10: a failed swipe-to-delete must not be swallowed — it surfaces as a + // one-shot actionError the screen shows as a snackbar. + val throwingLocRepo = object : LocationRepository { + override fun getCached(householdId: Long): List? = null + override suspend fun list(householdId: Long) = emptyList() + override suspend fun create(householdId: Long, name: String, type: String) = throw NotImplementedError() + override suspend fun delete(householdId: Long, locationId: Long) = throw IOException("delete failed") + } + val (store, _) = makeStore(households = emptyList()) + val vm = DrawerViewModel(store, throwingLocRepo) + + vm.deleteLocation(householdId = 1, locationId = 10) + + val message = vm.actionError.first { it != null } + assertNotNull(message) + } + @Test fun delete_location_removes_it_from_entries() = runTest { val fakeLocRepo = FakeLocationRepository( From 2f2b8ec370a069fbfc77d77da324deaf8a3b3601 Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:47:33 +0200 Subject: [PATCH 07/12] W16: add error-path unit tests for the hierarchy layer No error-path tests existed for HierarchyStore/DrawerViewModel/ MissingItemsViewModel. Add HierarchyStoreTest (refresh success populates and clears indicators; refresh failure sets error + clears loading/ refreshing). The DrawerUiState.error mapping (W3), deleteLocation failure (W10), and MissingItemsViewModel error (W4) tests landed with those fixes. All pure-JVM, no emulator. --- BACKLOG.md | 5 + .../scuttle/inventory/HierarchyStoreTest.kt | 104 ++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 app/src/test/java/dev/scuttle/inventory/HierarchyStoreTest.kt diff --git a/BACKLOG.md b/BACKLOG.md index 2ae7e20..b51ed48 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,11 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Error-path unit tests for the hierarchy layer** (wave-2 W16). There were no error-path + tests for `HierarchyStore`/`DrawerViewModel`/`MissingItemsViewModel`. Added a new `HierarchyStoreTest` + (refresh success populates + clears indicators; refresh failure sets `error` and clears loading/refreshing), + plus the `DrawerUiState.error` mapping (W3), `DrawerViewModel.deleteLocation` failure (W10), and + `MissingItemsViewModel` error (W4) tests added alongside those fixes — all pure-JVM, no emulator. - ✅ `2026-07-04` — **Drawer/home location-delete failure is surfaced, not swallowed** (wave-2 W10). `DrawerViewModel.deleteLocation` had `runCatching{…}.onSuccess{ refresh() }` with no `onFailure`, so a failed swipe-to-delete on AllStorages left the location in place with no feedback. Added a one-shot diff --git a/app/src/test/java/dev/scuttle/inventory/HierarchyStoreTest.kt b/app/src/test/java/dev/scuttle/inventory/HierarchyStoreTest.kt new file mode 100644 index 0000000..9de6e58 --- /dev/null +++ b/app/src/test/java/dev/scuttle/inventory/HierarchyStoreTest.kt @@ -0,0 +1,104 @@ +package dev.scuttle.inventory + +import android.net.Uri +import dev.scuttle.inventory.data.HierarchyStore +import dev.scuttle.inventory.data.dto.HouseholdDto +import dev.scuttle.inventory.data.dto.LocationDto +import dev.scuttle.inventory.data.dto.ProductDto +import dev.scuttle.inventory.data.dto.ShelfDto +import dev.scuttle.inventory.data.household.HouseholdRepository +import dev.scuttle.inventory.data.location.LocationRepository +import dev.scuttle.inventory.data.product.ProductRepository +import dev.scuttle.inventory.data.shelf.ShelfRepository +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull +import org.junit.Rule +import org.junit.Test +import java.io.IOException + +class HierarchyStoreTest { + + @get:Rule + val mainDispatcherRule = MainDispatcherRule() + + private class FakeHouseholdRepository( + private val households: List, + private val throwOnList: Boolean = false, + ) : HouseholdRepository { + override fun getCached(): List? = null + override suspend fun list(): List { + if (throwOnList) throw IOException("network down") + return households + } + override suspend fun create(name: String) = households.first() + override suspend fun join(code: String) = households.first() + override suspend fun leave(householdId: Long) {} + } + + private class FakeLocationRepository(private val byHousehold: Map> = emptyMap()) : LocationRepository { + override fun getCached(householdId: Long) = byHousehold[householdId] + override suspend fun list(householdId: Long) = byHousehold[householdId].orEmpty() + override suspend fun create(householdId: Long, name: String, type: String) = LocationDto(99, name, type) + override suspend fun delete(householdId: Long, locationId: Long) {} + } + + private class FakeShelfRepository(private val byLocation: Map> = emptyMap()) : ShelfRepository { + override fun getCached(householdId: Long, locationId: Long) = byLocation[locationId] + override suspend fun list(householdId: Long, locationId: Long) = byLocation[locationId].orEmpty() + override suspend fun create(householdId: Long, locationId: Long, name: String) = ShelfDto(99, name, 0, locationId) + override suspend fun delete(householdId: Long, locationId: Long, shelfId: Long) {} + } + + private class FakeProductRepository(private val byShelf: Map> = emptyMap()) : ProductRepository { + override fun getCached(householdId: Long, shelfId: Long) = byShelf[shelfId] + override suspend fun list(householdId: Long, shelfId: Long) = byShelf[shelfId].orEmpty() + override suspend fun create(householdId: Long, shelfId: Long, name: String, quantity: Int) = ProductDto(99, name, quantity, shelfId) + override suspend fun update(householdId: Long, shelfId: Long, productId: Long, name: String, description: String?, code: String?, isMandatory: Boolean) = ProductDto(productId, name, 0, shelfId) + override suspend fun add(householdId: Long, shelfId: Long, productId: Long, amount: Int) = byShelf[shelfId]!!.first { it.id == productId } + override suspend fun remove(householdId: Long, shelfId: Long, productId: Long, amount: Int) = byShelf[shelfId]!!.first { it.id == productId } + override suspend fun move(householdId: Long, shelfId: Long, productId: Long, targetShelfId: Long) = byShelf[shelfId]!!.first { it.id == productId } + override suspend fun delete(householdId: Long, shelfId: Long, productId: Long) {} + override suspend fun uploadImage(householdId: Long, shelfId: Long, productId: Long, imageUri: Uri, mimeType: String) = byShelf[shelfId]!!.first { it.id == productId } + } + + @Test + fun refresh_success_populates_state_and_clears_indicators() = runTest { + val store = HierarchyStore( + FakeHouseholdRepository(listOf(HouseholdDto(1, "Home", "AAAA"))), + FakeLocationRepository(mapOf(1L to listOf(LocationDto(10, "Fridge", "fridge")))), + FakeShelfRepository(mapOf(10L to listOf(ShelfDto(100, "Top", 0, 10)))), + FakeProductRepository(mapOf(100L to listOf(ProductDto(1, "Milk", 0, 100, is_mandatory = true)))), + ) + + store.refresh(userInitiated = true) + + val loaded = store.state.first { !it.loading } + assertNull(loaded.error) + assertFalse(loaded.refreshing) + assertEquals(1, loaded.entries.size) + assertEquals(1, loaded.missingItemCount) + } + + @Test + fun refresh_failure_sets_error_and_clears_indicators() = runTest { + // W16: a failed network refresh must set error and clear both loading and + // refreshing so the UI can leave the spinner and show the failure. + val store = HierarchyStore( + FakeHouseholdRepository(emptyList(), throwOnList = true), + FakeLocationRepository(), + FakeShelfRepository(), + FakeProductRepository(), + ) + + store.refresh(userInitiated = true) + + val failed = store.state.first { it.error != null } + assertNotNull(failed.error) + assertFalse(failed.loading) + assertFalse(failed.refreshing) + } +} From 9c9a2480cf01be4b2404bd0b536a6e33f51fb54c Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:49:22 +0200 Subject: [PATCH 08/12] W18: add concurrency cancellation to CI workflows Add concurrency group (workflow+ref) with cancel-in-progress: true to ci/debug-apk/dependency-review/instrumented/secret-scan; release keeps cancel-in-progress: false so a release build is never killed mid-upload. --- .github/workflows/ci.yml | 7 +++++++ .github/workflows/debug-apk.yml | 7 +++++++ .github/workflows/dependency-review.yml | 7 +++++++ .github/workflows/instrumented.yml | 7 +++++++ .github/workflows/release.yml | 6 ++++++ .github/workflows/secret-scan.yml | 7 +++++++ 6 files changed, 41 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06a4b85..cfc5f9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,12 @@ name: CI +# Supersede an in-flight run when a newer commit lands on the same ref, so +# rapid pushes/PR updates don't stack redundant (and, for the emulator/MySQL +# jobs, expensive) runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + # Compile + lint + unit tests for the Android client. # # Activated now that the Gradle project exists. ktlint/detekt style gating will diff --git a/.github/workflows/debug-apk.yml b/.github/workflows/debug-apk.yml index 2d6b75d..697a2fa 100644 --- a/.github/workflows/debug-apk.yml +++ b/.github/workflows/debug-apk.yml @@ -1,5 +1,12 @@ name: Debug APK +# Supersede an in-flight run when a newer commit lands on the same ref, so +# rapid pushes/PR updates don't stack redundant (and, for the emulator/MySQL +# jobs, expensive) runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: workflow_dispatch: diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 0275dd1..328cff6 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -1,5 +1,12 @@ name: Dependency review +# Supersede an in-flight run when a newer commit lands on the same ref, so +# rapid pushes/PR updates don't stack redundant (and, for the emulator/MySQL +# jobs, expensive) runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + # Flags dependency changes that introduce known-vulnerable Gradle/Maven # artifacts on a PR. GitHub-native; needs a base ref to diff, so PR-only. # No-op until the Gradle project declares dependencies. diff --git a/.github/workflows/instrumented.yml b/.github/workflows/instrumented.yml index 3556f95..4f42916 100644 --- a/.github/workflows/instrumented.yml +++ b/.github/workflows/instrumented.yml @@ -1,5 +1,12 @@ name: Instrumented tests +# Supersede an in-flight run when a newer commit lands on the same ref, so +# rapid pushes/PR updates don't stack redundant (and, for the emulator/MySQL +# jobs, expensive) runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + # End-to-end instrumented flow tests (app/src/androidTest) on an emulator. They # drive real navigation + Compose UI against a MockWebServer backend, catching # regressions the JVM unit tests can't. Emulator boot is slow (several minutes), diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41497a8..9da51d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,11 @@ name: Release +# Serialize release builds per tag but NEVER cancel one in flight — a half-built +# release + partial GitHub Release upload is worse than a redundant run. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + # Builds the Android app package when a version tag is pushed, and attaches the # artifacts to a GitHub Release. Tag with: git tag v0.1.0 && git push --tags # diff --git a/.github/workflows/secret-scan.yml b/.github/workflows/secret-scan.yml index ebe90b3..7485a2c 100644 --- a/.github/workflows/secret-scan.yml +++ b/.github/workflows/secret-scan.yml @@ -1,5 +1,12 @@ name: Secret scan +# Supersede an in-flight run when a newer commit lands on the same ref, so +# rapid pushes/PR updates don't stack redundant (and, for the emulator/MySQL +# jobs, expensive) runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + # Catches accidentally-committed secrets (keystores, signing passwords, API keys, # google-services.json values, tokens). Runs on every push to main + every PR. # Cheap and safe on any content, so it is ACTIVE immediately (not dormant). From d3fa63de965c6ff20b465730903c23d0feb212be Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:51:10 +0200 Subject: [PATCH 09/12] W19 (deferred): document ktlint/detekt gating follow-up Gating needs a baseline generated against the real codebase; this environment has no working Android toolchain (JDK 26 vs project Gradle), so blind gating could redden the whole pipeline unverifiably. Expand the ROADMAP follow-up with the concrete baseline steps. --- ROADMAP.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 28f9003..b7c23e3 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -64,8 +64,12 @@ Detailed build order: [`CLAUDE.md`](CLAUDE.md) and [`docs/android-plan.md`](docs ID token → `loginWithGoogle`) can't be exercised by CI or JVM tests. Before any release, manually verify sign-in on a device/emulator **with Play Services** and a configured Google OAuth client ID. -- [ ] **ktlint/detekt** style gating in CI — its own pass (kept out of the auth pass to - avoid blind style churn while the codebase is moving fast). +- [ ] **ktlint/detekt** style gating in CI (wave-2 W19) — its own pass. Blocked on toolchain: + gating needs a baseline generated against the real codebase, and gating blind risks reddening + the whole Android pipeline (plugin resolution affects the compile/test job; unknown violation + count). Follow-up on a machine with a JDK compatible with the project's Gradle: apply the + detekt + ktlint Gradle plugins, run `./gradlew detektBaseline ktlintCheck`, commit the baseline + file(s), then add a gating CI step mirroring Laravel's Pint+Larastan quality job. ### QUALITY - [x] **CI live and green** — wrapper validation + `testDebugUnitTest` + lint pass. From 4744ea9a1b2887cba14042a28cac60b22fba838e Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:52:50 +0200 Subject: [PATCH 10/12] W18 fix: never cancel an in-flight secret scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Security review flagged that cancel-in-progress: true on the secret-scan workflow could skip scanning an intermediate commit when a rapid follow-up push supersedes it. A secret scan is a security gate — keep the per-ref grouping but set cancel-in-progress: false so every commit is fully scanned. --- .github/workflows/secret-scan.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/secret-scan.yml b/.github/workflows/secret-scan.yml index 7485a2c..db49735 100644 --- a/.github/workflows/secret-scan.yml +++ b/.github/workflows/secret-scan.yml @@ -1,11 +1,11 @@ name: Secret scan -# Supersede an in-flight run when a newer commit lands on the same ref, so -# rapid pushes/PR updates don't stack redundant (and, for the emulator/MySQL -# jobs, expensive) runs. +# Serialize scans per ref but NEVER cancel one in flight — a secret scan is a +# security gate, so every pushed commit must be fully scanned; cancelling an +# in-flight scan on a rapid follow-up push could skip an intermediate commit. concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: false # Catches accidentally-committed secrets (keystores, signing passwords, API keys, # google-services.json values, tokens). Runs on every push to main + every PR. From 0a2571f5f4d16c3dc26d4ca1306b1e21f6dbc372 Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:55:00 +0200 Subject: [PATCH 11/12] W22: generate the invite QR off the composition thread InviteScreen built the 512x512 QR with a ~262k-pixel setPixel loop inside remember(link) on the composition thread, hitching the frame when the invite loaded. Move it to produceState + withContext(Dispatchers.Default) with a CircularProgressIndicator in the QR footprint until ready. --- BACKLOG.md | 4 ++++ .../inventory/ui/invite/InviteScreen.kt | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/BACKLOG.md b/BACKLOG.md index b51ed48..f28c26e 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,10 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Invite QR generated off the composition thread** (wave-2 W22). `InviteScreen` built the + 512×512 QR with a ~262k-pixel `setPixel` loop inside `remember(link)` — on the composition thread, so the + invite load visibly hitched. Moved it to `produceState(null, link){ withContext(Dispatchers.Default){ … } }` + with a `CircularProgressIndicator` in the QR's 220dp footprint until it's ready. - ✅ `2026-07-04` — **Error-path unit tests for the hierarchy layer** (wave-2 W16). There were no error-path tests for `HierarchyStore`/`DrawerViewModel`/`MissingItemsViewModel`. Added a new `HierarchyStoreTest` (refresh success populates + clears indicators; refresh failure sets `error` and clears loading/refreshing), diff --git a/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt b/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt index 6d8ef03..0c4ef7a 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/invite/InviteScreen.kt @@ -4,6 +4,7 @@ import android.graphics.Bitmap import android.graphics.Color as AndroidColor import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize @@ -13,6 +14,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.material3.Button +import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -22,6 +24,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -38,7 +41,9 @@ import com.google.zxing.qrcode.QRCodeWriter import dev.scuttle.inventory.R import dev.scuttle.inventory.ui.common.LiveStatusText import dev.scuttle.inventory.ui.theme.SpaceMono +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay +import kotlinx.coroutines.withContext @Composable fun InviteScreen( @@ -109,13 +114,23 @@ fun InviteScreen( textAlign = TextAlign.Center, ) - val qr = remember(state.link) { qrBitmap(state.link) } - if (qr != null) { - Image( - bitmap = qr.asImageBitmap(), + // Generate the 512×512 QR off the composition thread — the setPixel + // loop (~262k pixels) otherwise hitches the frame when the invite + // loads (W22). Show a spinner in the QR's footprint until it's ready. + val qr by produceState(null, state.link) { + value = withContext(Dispatchers.Default) { qrBitmap(state.link) } + } + val currentQr = qr + when { + currentQr != null -> Image( + bitmap = currentQr.asImageBitmap(), contentDescription = stringResource(R.string.invite_qr_cd), modifier = Modifier.size(220.dp), ) + state.link.isNotEmpty() -> Box( + modifier = Modifier.size(220.dp), + contentAlignment = Alignment.Center, + ) { CircularProgressIndicator() } } Button( From 22203eaa0dbed7cacd8b3f1fbdc032aa364e4aef Mon Sep 17 00:00:00 2001 From: S Plotnikov Date: Sat, 4 Jul 2026 14:57:39 +0200 Subject: [PATCH 12/12] W23: make drawer search reach every household, not just the first AppDrawer wired the single global Search entry to entries.firstOrNull(), so a multi-household user could only ever search their first household, silently. Keep the global entry only for a single household; with several, render a per-household search IconButton on each household row (content described 'Search ', EN+NL) so every household is reachable and the scope is explicit. No new endpoints. --- BACKLOG.md | 6 ++++ .../dev/scuttle/inventory/ui/app/AppDrawer.kt | 36 ++++++++++++++----- app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/BACKLOG.md b/BACKLOG.md index f28c26e..9f7bbfb 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -45,6 +45,12 @@ fast enough in real use, don't build it. --- ## Done +- ✅ `2026-07-04` — **Drawer search reaches every household, not just the first** (wave-2 W23). `AppDrawer` + wired the single global "Search" entry to `entries.firstOrNull()?.id`, so a multi-household user could + only ever search their first household — silently. Search is legitimately household-scoped, so: keep the + global entry only when there's exactly one household; when there are several, render a per-household + search `IconButton` on each household row (content-described "Search ", EN + NL), so every + household is reachable and the scope is explicit. No new endpoints. - ✅ `2026-07-04` — **Invite QR generated off the composition thread** (wave-2 W22). `InviteScreen` built the 512×512 QR with a ~262k-pixel `setPixel` loop inside `remember(link)` — on the composition thread, so the invite load visibly hitched. Moved it to `produceState(null, link){ withContext(Dispatchers.Default){ … } }` diff --git a/app/src/main/java/dev/scuttle/inventory/ui/app/AppDrawer.kt b/app/src/main/java/dev/scuttle/inventory/ui/app/AppDrawer.kt index 47d6cd5..9504b06 100644 --- a/app/src/main/java/dev/scuttle/inventory/ui/app/AppDrawer.kt +++ b/app/src/main/java/dev/scuttle/inventory/ui/app/AppDrawer.kt @@ -24,6 +24,7 @@ import androidx.compose.material.icons.filled.Warning import androidx.compose.material3.DrawerDefaults import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.NavigationDrawerItem import androidx.compose.material3.Surface @@ -83,14 +84,20 @@ fun AppDrawer( modifier = Modifier.padding(horizontal = 12.dp), ) - val firstHouseholdId = state.entries.firstOrNull()?.id - NavigationDrawerItem( - icon = { Icon(Icons.Default.Search, contentDescription = null) }, - label = { Text(stringResource(R.string.drawer_search)) }, - selected = false, - onClick = { firstHouseholdId?.let(onNavigateSearch) }, - modifier = Modifier.padding(horizontal = 12.dp), - ) + // Search is household-scoped. With a single household the global entry + // is unambiguous; with several, a lone "Search" would silently target + // only the first (W23), so per-household search lives on each household + // row below instead. + val soleHousehold = state.entries.singleOrNull() + if (soleHousehold != null) { + NavigationDrawerItem( + icon = { Icon(Icons.Default.Search, contentDescription = null) }, + label = { Text(stringResource(R.string.drawer_search)) }, + selected = false, + onClick = { onNavigateSearch(soleHousehold.id) }, + modifier = Modifier.padding(horizontal = 12.dp), + ) + } NavigationDrawerItem( icon = { Icon(Icons.Default.People, contentDescription = null) }, @@ -152,6 +159,19 @@ fun AppDrawer( style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) + // With more than one household, give each its own search so a + // multi-household user can search any of them, not just the + // first (W23). A single household uses the global entry above. + if (state.entries.size > 1) { + Spacer(Modifier.weight(1f)) + IconButton(onClick = { onNavigateSearch(entry.id) }) { + Icon( + Icons.Default.Search, + contentDescription = stringResource(R.string.drawer_search_household_cd, entry.name), + tint = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } } entry.locations.forEach { location -> val hasWarning = state.locationWarnings[location.id] == true diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index cf1cdde..2e21cc2 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -170,6 +170,7 @@ Alle opslag Dashboard Zoeken + Zoek in %1$s Huishoudens Ontbrekende artikelen Ontbrekende artikelen · %d diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bf14b18..e1506d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -170,6 +170,7 @@ All storage Dashboard Search + Search %1$s Households Missing items Missing items · %d