Skip to content

fix: replace snackbar-based batch progress with state-driven composable#1509

Merged
lihenggui merged 1 commit into
mainfrom
fix/snackbar-progress-display
Mar 22, 2026
Merged

fix: replace snackbar-based batch progress with state-driven composable#1509
lihenggui merged 1 commit into
mainfrom
fix/snackbar-progress-display

Conversation

@lihenggui

Copy link
Copy Markdown
Owner

Summary

Fixes #1504

  • Replaced SnackbarHostState.showSnackbar() progress display with a state-driven ProcessingProgressSnackbar composable that updates instantly
  • Applied fix to both AppDetail and RuleDetail screens (same bug existed in both)
  • Extracted shared ProcessingProgress data class and ProcessingProgressSnackbar composable to core:ui

Root Cause

showSnackbar() is a suspend function that enforces a minimum ~3-second display (SnackbarDuration.Short). During batch operations processing 100+ components, each emission queued a new snackbar — the UI showed "5/100" long after all 100 components were already done.

Solution

Progress is now a piece of StateFlow state in the ViewModel. The composable reads it reactively and re-renders instantly on every update, bypassing the snackbar queue entirely. Progress auto-clears 2 seconds after completion.

Test plan

  • ./gradlew :feature:appdetail:impl:testFossDebugUnitTest passes
  • ./gradlew :feature:ruledetail:impl:testFossDebugUnitTest passes
  • ./gradlew spotlessCheck passes
  • Manual: batch disable all components in an app → progress updates in real-time, shows "Operation completed" briefly, then dismisses

@lihenggui lihenggui force-pushed the fix/snackbar-progress-display branch from 65529ef to 8cb194a Compare March 21, 2026 23:55
Fixes #1504

The batch disable/enable progress display was lagging behind the actual
operation because SnackbarHostState.showSnackbar() enforces a minimum
3-second display duration per call. Each component processed queued a
new snackbar, causing the UI to show stale progress long after completion.

Replace the snackbar-based approach with a state-driven
ProcessingProgressSnackbar composable that updates instantly via
ViewModel StateFlow. Applied to both AppDetail and RuleDetail screens.
@lihenggui lihenggui force-pushed the fix/snackbar-progress-display branch from 8cb194a to 4a50c96 Compare March 22, 2026 00:14
@lihenggui lihenggui merged commit 52a6b50 into main Mar 22, 2026
4 checks passed
@lihenggui lihenggui deleted the fix/snackbar-progress-display branch March 22, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 进度显示疑似异常

1 participant