Skip to content

Conversation

@dogi
Copy link
Member

@dogi dogi commented Nov 10, 2025

Refactors SyncManager to accept an @ApplicationScope CoroutineScope via its constructor, replacing the locally created syncScope.

This change centralizes coroutine management, improves testability, and aligns with Hilt's dependency injection best practices. The ServiceModule has been updated to provide the application-level scope to SyncManager.


https://jules.google.com/session/3228009531546273882

Refactors `SyncManager` to accept an `@ApplicationScope CoroutineScope` via its constructor, replacing the locally created `syncScope`.

This change centralizes coroutine management, improves testability, and aligns with Hilt's dependency injection best practices. The `ServiceModule` has been updated to provide the application-level scope to `SyncManager`.
@qltysh
Copy link

qltysh bot commented Nov 10, 2025

❌ 1 blocking issue (1 total)

Tool Category Rule Count
qlty Structure Function with many parameters (count = 6): provideSyncManager 1

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

private fun destroy() {
if (betaSync) {
syncScope.cancel()
ThreadSafeRealmHelper.closeThreadRealm()

P1 Badge Stop cancelling shared application scope

After this refactor SyncManager receives the global @ApplicationScope CoroutineScope, but destroy() still calls syncScope.cancel() when betaSync is true. Because AuthSessionUpdater and NetworkUtils inject the same @ApplicationScope scope, the first beta sync teardown would cancel the shared scope and permanently stop their background coroutines (network monitoring, auth session refreshes, etc.) for the lifetime of the process. Consider cancelling a child scope owned by SyncManager instead of the application-wide scope.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dogi dogi closed this Nov 10, 2025
@dogi dogi reopened this Nov 10, 2025
@dogi dogi removed the close? label Nov 10, 2025
@dogi dogi changed the title refactor(SyncManager): Use injected CoroutineScope sync: smoother manager scoping (fixes #9031) Nov 11, 2025
@dogi dogi merged commit 1803b04 into master Nov 11, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants