Skip to content

fix: allow state and page to resume on app refocus instead of rerouting to login and library#604

Open
xXJSONDeruloXx wants to merge 3 commits intoutkarshdalal:masterfrom
xXJSONDeruloXx:fix/resume-state
Open

fix: allow state and page to resume on app refocus instead of rerouting to login and library#604
xXJSONDeruloXx wants to merge 3 commits intoutkarshdalal:masterfrom
xXJSONDeruloXx:fix/resume-state

Conversation

@xXJSONDeruloXx
Copy link
Contributor

@xXJSONDeruloXx xXJSONDeruloXx commented Feb 22, 2026

https://discord.com/channels/1378308569287622737/1474986033031544972


Summary by cubic

Keep the current screen and state when returning to the app, instead of redirecting to Login/Library. Settings and Edit Container now stay open while multitasking.

  • Bug Fixes
    • Redirect to Home only when on the Login screen and remove auto-redirects after Steam login; use a non-saveable hasAttemptedInitialSteamConnect to run the initial Steam connect once per app session.

Written for commit d79536f. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • App now attempts Steam connectivity only once on initial startup, reducing redundant attempts and improving startup stability.
    • Prevents unexpected automatic navigation to Home — navigation to Home now occurs only from the login screen, and initial steps won't push users away from their current screen.
    • Stops an automatic Home redirect when Steam is logged in but not kept alive, avoiding disruptive route changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fd534c and d79536f.

📒 Files selected for processing (1)
  • app/src/main/java/app/gamenative/ui/PluviaMain.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/app/gamenative/ui/PluviaMain.kt

📝 Walkthrough

Walkthrough

Adds a lifecycle-scoped boolean guard in PluviaMain.kt to ensure the initial Steam connectivity check and potential foreground SteamService start run only once, adjusts navigation conditions after intent launches to require LoginUser for certain Home navigations, and removes an automatic per-cycle Home navigation when SteamService is logged in but not kept alive.

Changes

Cohort / File(s) Summary
Pluvia main lifecycle & Steam connect
app/src/main/java/app/gamenative/ui/PluviaMain.kt
Introduce hasAttemptedInitialSteamConnect local state; run initial Steam connectivity check (and possible startForegroundService) only once; update log text to indicate "initial attempt"; keep ongoing reconnection checks unchanged.
Navigation intent logic
app/src/main/java/app/gamenative/ui/PluviaMain.kt
Tighten navigation-after-intent rules: navigate to Home only when current destination is LoginUser; extend xEnvironment-null condition to require LoginUser; remove automatic per-cycle Home navigation when SteamService is logged in but not kept alive.
Service start handling (minor adjustments)
app/src/main/java/app/gamenative/ui/PluviaMain.kt
Maintain existing GOG/Epic service start flows with minor log and condition adjustments to align with the new initial-attempt guard semantics.

Sequence Diagram(s)

sequenceDiagram
    participant Lifecycle as LifecycleOwner
    participant UI as PluviaMain UI
    participant Steam as SteamService
    participant Nav as NavController

    Lifecycle->>UI: on first lifecycle pass
    UI->>UI: check hasAttemptedInitialSteamConnect (false)
    UI->>Steam: perform initial connectivity check
    alt Steam not connected
        UI->>Steam: startForegroundService (initial attempt)
        Steam-->>UI: started / attempting
    else Steam connected
        Steam-->>UI: already logged in
    end
    UI->>Nav: handle pending intent / evaluate destination
    alt current == LoginUser and xEnvironment == null
        Nav-->>UI: navigate to Home
    else
        Nav-->>UI: keep current route
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hopped through lifecycle’s morning light,

One careful check — no frantic flight,
Steam blinks awake with a gentle nudge,
Home waits patient, no hurried judge,
A single hop, logs sing: "initial attempt" ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of the pull request: preventing unwanted rerouting to login and library pages when returning to the app.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/app/gamenative/ui/PluviaMain.kt`:
- Line 124: The saved-instance-state use of hasAttemptedInitialSteamConnect via
rememberSaveable prevents SteamService restart after system-initiated process
death; change the declaration using rememberSaveable to use remember so the flag
is ephemeral (reset on fresh process/composition) — update the var
hasAttemptedInitialSteamConnect by rememberSaveable { mutableStateOf(false) } to
use remember { mutableStateOf(false) } (also apply the same change to the other
occurrences noted around the 402-409 block) so the startForegroundService guard
doesn't short-circuit after process restore.

@phobos665
Copy link
Contributor

So the UI overhaul work already does this as far as I remember :)

@xXJSONDeruloXx
Copy link
Contributor Author

xXJSONDeruloXx commented Feb 22, 2026

@phobos665 yeah but not sure how long it will be before that merges, lots to review and discuss. any merrit to taking this for current state in mean time?

and if I recall from discord discussions, we probably want to merge in amazon games first, then another round of conflict resolution to ui overhaul as a result.

@xXJSONDeruloXx xXJSONDeruloXx moved this to PR Needs Review in Open Source Feb 23, 2026
@phobos665
Copy link
Contributor

@phobos665 yeah but not sure how long it will be before that merges, lots to review and discuss. any merrit to taking this for current state in mean time?

I'm in favour of it, I think I was slightly awkward in what I meant here.

Is this consistent with how the UI overhaul does the same functionality?

Just so you don't need to compete with 2 differing implementations

@xXJSONDeruloXx
Copy link
Contributor Author

@phobos665 yes, shouldn't conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: PR Needs Review

Development

Successfully merging this pull request may close these issues.

3 participants