Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/debug-apk.yml
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/instrumented.yml
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/secret-scan.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: Secret scan

# 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: false

# 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).
Expand Down
46 changes: 46 additions & 0 deletions BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,52 @@ 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 <household>", 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){ … } }`
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),
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
`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`
string (EN + NL) and a `clearAndSetSemantics { contentDescription = "<shelf>, 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*
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
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
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
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
Expand Down
8 changes: 6 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
36 changes: 28 additions & 8 deletions app/src/main/java/dev/scuttle/inventory/ui/app/AppDrawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) },
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,6 +23,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
Expand All @@ -35,20 +42,32 @@ class DrawerViewModel @Inject constructor(
missingItemCount = s.missingItemCount,
loading = s.loading,
refreshing = s.refreshing,
error = s.error,
)
}.stateIn(viewModelScope, SharingStarted.Eagerly, DrawerUiState())

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<String?>(null)
val actionError: StateFlow<String?> = _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)
}
Original file line number Diff line number Diff line change
@@ -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 },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,6 +55,8 @@ 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.SnackbarErrorEffect
import dev.scuttle.inventory.ui.common.storageTypeLabel
import dev.scuttle.inventory.data.dto.LocationDto
import dev.scuttle.inventory.ui.app.DrawerViewModel
Expand All @@ -71,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<Pair<HouseholdWithLocations, LocationDto>?>(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,
Expand Down Expand Up @@ -111,7 +121,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))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand Down
Loading
Loading