Update SteamApp container language handling#507
Update SteamApp container language handling#507utkarshdalal merged 4 commits intoutkarshdalal:masterfrom
Conversation
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="app/src/main/java/app/gamenative/service/SteamService.kt">
<violation number="1" location="app/src/main/java/app/gamenative/service/SteamService.kt:1005">
P2: `getContainerById` can return null, but `container.language` is dereferenced without a null check, which can crash downloads when the container doesn't exist.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
📝 WalkthroughWalkthroughThreads container language through SteamService depot selection and download flows, syncs installed app manifest language in SteamUtils, triggers re-download when container language changes from the UI, and removes a duplicate language-change handler in ContainerUtils. Changes
Sequence DiagramsequenceDiagram
autonumber
actor User
participant SteamAppScreen as "SteamAppScreen\n(UI)"
participant ContainerManager as "ContainerManager"
participant SteamService as "SteamService"
participant PrefManager as "PrefManager"
participant SteamUtils as "SteamUtils"
User->>SteamAppScreen: change container language/config
SteamAppScreen->>ContainerManager: getContainer(context, appId)
ContainerManager-->>SteamAppScreen: container { language }
SteamAppScreen->>SteamAppScreen: compare container.language vs saved config
alt languages differ
SteamAppScreen->>SteamService: downloadApp(appId, containerLanguage)
SteamService->>ContainerManager: (verify/get) container language
SteamService->>PrefManager: read fallback containerLanguage
SteamService->>SteamService: getDownloadableDepots(appId, containerLanguage)
SteamService->>SteamUtils: sync manifest language(appId, containerLanguage)
SteamUtils-->>SteamService: manifest updated
SteamService-->>SteamAppScreen: start download / return DownloadInfo
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
41a6290 to
0d2cbf0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt`:
- Around line 1002-1008: saveContainerConfig calls SteamService.downloadApp
synchronously which internally uses runBlocking and can block the main thread;
wrap the download call in a background coroutine instead. Replace the direct
SteamService.downloadApp(libraryItem.gameId) invocation in saveContainerConfig
with launching a coroutine on Dispatchers.IO (e.g.,
CoroutineScope(Dispatchers.IO).launch {
SteamService.downloadApp(libraryItem.gameId) }) so the blocking runBlocking
calls inside SteamService (getAppInfoOf, getDownloadableDepots,
ContainerManager) run off the UI thread.
🧹 Nitpick comments (1)
app/src/main/java/app/gamenative/service/SteamService.kt (1)
1004-1022: Container lookup may NPE if the container was never created for this app.
ContainerManager.getContainerById("STEAM_${appId}")on Line 1005 can returnnullif no container exists yet (e.g., first-time install before the user ever opened the container editor). The null-check on Line 1006 handles that gracefully by falling back toPrefManager.containerLanguage, so the logic is safe. However,getContainerByIdinstantiates aContainerManagerfor every download call, including resume and verify flows. Consider caching or reusing the manager if this becomes a hot path.
app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt`:
- Around line 1002-1012: The file has an extra closing brace after the
saveContainerConfig method that prematurely ends the SteamAppScreen class;
remove the stray `}` following saveContainerConfig so the class remains open and
the subsequent members (supportsContainerConfig, getExportFileExtension,
AdditionalDialogs, etc.) stay inside SteamAppScreen; verify brace balance around
the saveContainerConfig method and the SteamAppScreen class to ensure no other
unmatched braces remain.
app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt
Outdated
Show resolved
Hide resolved
Ensures Steam app downloads use the container's language setting, allowing users to download games in their preferred language. When user changed the language of the container, automatic download the required data for the new language.
…teamAppScreen.kt Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
0570fb1 to
1f9f27d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/main/java/app/gamenative/service/SteamService.kt (1)
644-712:⚠️ Potential issue | 🟠 MajorNormalize preferredLanguage before depot filtering to avoid missing language depots.
DepotInfo.languagevalues are lower-case Steam codes. IfpreferredLanguageis blank or mixed-case, the filter can reject all language-specific depots, leading to incomplete downloads. Normalize and default once per call.🔧 Suggested fix
- fun getMainAppDepots(appId: Int, containerLanguage: String): Map<Int, DepotInfo> { + fun getMainAppDepots(appId: Int, containerLanguage: String): Map<Int, DepotInfo> { val appInfo = getAppInfoOf(appId) ?: return emptyMap() val ownedDlc = runBlocking { getOwnedAppDlc(appId) } + val normalizedLanguage = containerLanguage.trim().lowercase().ifBlank { "english" } // If the game ships any 64-bit depot, prefer those and ignore x86 ones val has64Bit = appInfo.depots.values.any { it.osArch == OSArch.Arch64 } return appInfo.depots.asSequence() .filter { (depotId, depot) -> - return@filter filterForDownloadableDepots(depot, has64Bit, containerLanguage, ownedDlc) + return@filter filterForDownloadableDepots(depot, has64Bit, normalizedLanguage, ownedDlc) } .associate { it.toPair() } } ... - fun getDownloadableDepots(appId: Int, preferredLanguage: String): Map<Int, DepotInfo> { + fun getDownloadableDepots(appId: Int, preferredLanguage: String): Map<Int, DepotInfo> { val appInfo = getAppInfoOf(appId) ?: return emptyMap() val ownedDlc = runBlocking { getOwnedAppDlc(appId) } + val normalizedLanguage = preferredLanguage.trim().lowercase().ifBlank { "english" } // If the game ships any 64-bit depot, prefer those and ignore x86 ones val has64Bit = appInfo.depots.values.any { it.osArch == OSArch.Arch64 } val map = appInfo.depots .asSequence() .filter { (depotId, depot) -> - return@filter filterForDownloadableDepots(depot, has64Bit, preferredLanguage, ownedDlc) + return@filter filterForDownloadableDepots(depot, has64Bit, normalizedLanguage, ownedDlc) } ... .filter { (depotId, depot) -> - return@filter filterForDownloadableDepots(depot, has64Bit, preferredLanguage, null) + return@filter filterForDownloadableDepots(depot, has64Bit, normalizedLanguage, null) }
🤖 Fix all issues with AI agents
In `@app/src/main/java/app/gamenative/utils/SteamUtils.kt`:
- Around line 1199-1237: The manifest language should be normalized and
defaulted before writing: read container.language into userLanguage, trim and
normalize to lowercase (e.g., userLanguage =
container.language?.trim()?.lowercase()) and if empty or null set it to
"english", then use that normalized value wherever KeyValue("language",
userLanguage) or languageKey.value = userLanguage is assigned (affecting the
existing userConfig/mountedConfig handling and the final manifestData.saveToFile
call) so the manifest always contains a valid, lowercase language string.
Ensures Steam app downloads use the container's language setting, allowing users to download games in their preferred language.
When user changed the language of the container, automatic download the required data for the new language.
Also remove duplicated lines in
ContainerUtilsSummary by cubic
Steam downloads and app manifests now use each container’s language. Changing a container’s language triggers a download of the correct language files and updates the manifest.
New Features
Refactors
Written for commit 1f9f27d. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
UI Improvements