Skip to content

Fix loading flow default bot initialization#6302

Open
SeniorZhai wants to merge 6 commits intomasterfrom
fix/loading-init-bots
Open

Fix loading flow default bot initialization#6302
SeniorZhai wants to merge 6 commits intomasterfrom
fix/loading-init-bots

Conversation

@SeniorZhai
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the post-login/loading flow to initialize a locale-specific set of default bots (and skip for configured test accounts), shifting initialization out of the name setup screen and into the loading stage.

Changes:

  • Add TEST_ACCOUNT_PREFIX to default secrets and use it to bypass default-bot initialization for test accounts.
  • Add isSimplifiedChineseLocale() to distinguish Simplified vs Traditional Chinese locales.
  • Replace single “team bot” initialization with a locale-dependent list of default bot IDs, and simplify InitializeJob to only require botId.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
local.defaults.properties Adds TEST_ACCOUNT_PREFIX default value for BuildConfig/secrets usage.
app/src/main/java/one/mixin/android/util/LanguageUtil.kt Introduces Simplified-Chinese locale detection helper used by bot selection.
app/src/main/java/one/mixin/android/ui/landing/SetupNameFragment.kt Removes unused/empty bot initialization hook.
app/src/main/java/one/mixin/android/ui/landing/LoadingFragment.kt Initializes locale-specific default bots during loading and skips for test accounts.
app/src/main/java/one/mixin/android/job/InitializeJob.kt Simplifies job input and relationship request payload.
Comments suppressed due to low confidence (1)

app/src/main/java/one/mixin/android/job/InitializeJob.kt:13

  • InitializeJob is a persisted Job (persist()), and its serialized fields changed (removed botName). To avoid deserialization failures for jobs persisted by older app versions, the serialVersionUID should be bumped when the class' serialized shape changes.
class InitializeJob(private val botId: String) :
    BaseJob(Params(PRIORITY_LOWER).groupBy(GROUP_ID).requireWebSocketConnected().persist()) {
    companion object {
        private var serialVersionUID: Long = 2L
        private const val GROUP_ID = "InitializeJob"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/java/one/mixin/android/util/LanguageUtil.kt Outdated
Comment on lines +149 to +164
initializeBots()
activity?.finish()
}

private fun initializeBots() {
val phone = Session.getAccount()?.phone.orEmpty()
val testAccountPrefix = BuildConfig.TEST_ACCOUNT_PREFIX
if (testAccountPrefix.isNotBlank() && phone.startsWith(testAccountPrefix)) {
return
}

val bots = if (isSimplifiedChineseLocale()) DEFAULT_BOTS_ZH_CN else DEFAULT_BOTS_EN
bots.forEach { botId ->
jobManager.addJobInBackground(InitializeJob(botId))
}
}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

initializeBots() enqueues 6 persisted InitializeJobs every time checkAndLoad() completes. Since InitializeActivity.showLoading() can be triggered repeatedly (e.g., from MainActivity when getIsLoaded/getIsSyncSession are false or Session.shouldUpdateKey() is true), this can repeatedly re-enqueue the same relationship requests and add avoidable startup network/work. Consider guarding with a persisted flag (per-account) or checking existing relationship in local DB before enqueuing.

Copilot uses AI. Check for mistakes.
@SeniorZhai SeniorZhai force-pushed the fix/loading-init-bots branch from 58b0d45 to 12f1d4b Compare April 20, 2026 09:36
# Conflicts:
#	app/src/main/java/one/mixin/android/job/InitializeJob.kt
@SeniorZhai SeniorZhai force-pushed the fix/loading-init-bots branch from 3b5d8c9 to 16720e6 Compare April 22, 2026 03:20
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.

2 participants