Summary
When using PagedStore (store lib) or pagedLoader (container lib), the backgroundLoadState exposed via Container / StoreResult metadata is not set to BackgroundLoadState.Loading while the first page is being (re)loaded in the background. Consumers relying on metadata.backgroundLoadState (or StoreResult.isBackgroundLoading()) to drive a "refreshing" indicator get Idle during the initial page load, so the background-load signal is effectively swallowed for paged sources.
Expected behavior
While a paged source is loading its first page in the background (e.g. a silent reload/invalidate while content is still visible), emissions should carry BackgroundLoadState.Loading in their metadata, consistent with non-paged sources (FlowEmitter / StatefulEmitterImpl already do this).
Actual behavior
Paged emissions hardcode a base BackgroundLoadState.Idle. In-flight page loading is only represented through NextPageStateMetadata / PageState, never through BackgroundLoadState, so metadata.backgroundLoadState stays Idle for the first page.
Root cause / relevant code
container/src/main/java/com/elveum/container/subject/paging/internal/PageRecordsState.kt: emitUpdates() (~lines 137–178). The success path builds:
val finalMetadata = BackgroundLoadMetadata(BackgroundLoadState.Idle) + ...
This hardcodes Idle as the base and never injects Loading for an in-flight first-page load. The pending path (originEmitter.emitPendingState()) is the only place that can carry Loading, which doesn't cover the "content visible + first page reloading silently" case.
container/src/main/java/com/elveum/container/subject/paging/internal/PageLoaderImpl.kt:30: first page entry point (startLoading(pageIndex = 0, ...) → await() → emitCompletedState()).
- Metadata plumbing that carries the state through to the store side:
store/src/main/java/com/elveum/store/load/StoreResultContainerExtensions.kt and StoreResultExtensions.kt (isBackgroundLoading()).
Proposed fix
Propagate the session's background-loading status into PageRecordsState.emitUpdates() so that, while the first page load is in flight, the emitted BackgroundLoadMetadata reflects BackgroundLoadState.Loading instead of a hardcoded Idle (respecting configuration.emitBackgroundLoads).
Test gap
No test currently asserts backgroundLoadState / isBackgroundLoading() during the first page load of a paged store/loader. The existing paged assertion (store/src/test/java/com/elveum/store/paged/PagedStoreErrorsAndUpdatesTest.kt:97) only covers a silent async invalidate after the first load. Add coverage for the initial-page background-load case.
Summary
When using
PagedStore(store lib) orpagedLoader(container lib), thebackgroundLoadStateexposed viaContainer/StoreResultmetadata is not set toBackgroundLoadState.Loadingwhile the first page is being (re)loaded in the background. Consumers relying onmetadata.backgroundLoadState(orStoreResult.isBackgroundLoading()) to drive a "refreshing" indicator getIdleduring the initial page load, so the background-load signal is effectively swallowed for paged sources.Expected behavior
While a paged source is loading its first page in the background (e.g. a silent reload/invalidate while content is still visible), emissions should carry
BackgroundLoadState.Loadingin their metadata, consistent with non-paged sources (FlowEmitter/StatefulEmitterImplalready do this).Actual behavior
Paged emissions hardcode a base
BackgroundLoadState.Idle. In-flight page loading is only represented throughNextPageStateMetadata/PageState, never throughBackgroundLoadState, sometadata.backgroundLoadStatestaysIdlefor the first page.Root cause / relevant code
container/src/main/java/com/elveum/container/subject/paging/internal/PageRecordsState.kt:emitUpdates()(~lines 137–178). The success path builds:Idleas the base and never injectsLoadingfor an in-flight first-page load. The pending path (originEmitter.emitPendingState()) is the only place that can carryLoading, which doesn't cover the "content visible + first page reloading silently" case.container/src/main/java/com/elveum/container/subject/paging/internal/PageLoaderImpl.kt:30: first page entry point (startLoading(pageIndex = 0, ...)→await()→emitCompletedState()).store/src/main/java/com/elveum/store/load/StoreResultContainerExtensions.ktandStoreResultExtensions.kt(isBackgroundLoading()).Proposed fix
Propagate the session's background-loading status into
PageRecordsState.emitUpdates()so that, while the first page load is in flight, the emittedBackgroundLoadMetadatareflectsBackgroundLoadState.Loadinginstead of a hardcodedIdle(respectingconfiguration.emitBackgroundLoads).Test gap
No test currently asserts
backgroundLoadState/isBackgroundLoading()during the first page load of a paged store/loader. The existing paged assertion (store/src/test/java/com/elveum/store/paged/PagedStoreErrorsAndUpdatesTest.kt:97) only covers a silent async invalidate after the first load. Add coverage for the initial-page background-load case.