Fix Snapmaker account login not persisting across restarts - #715
Open
amitamit10 wants to merge 1 commit into
Open
Fix Snapmaker account login not persisting across restarts#715amitamit10 wants to merge 1 commit into
amitamit10 wants to merge 1 commit into
Conversation
The native SMUserInfo struct (m_login_userinfo) that backs sw_GetUserLoginState was only ever populated in-memory during an active login flow (WebSMUserLoginDialog::OnNavigationRequest) and was never written to or restored from AppConfig. Every app restart therefore started with an empty, logged-out struct regardless of whether the embedded webview still had a valid cached token, so the Snapmaker login screen reappeared on every launch. This persists the token/account/nickname/icon/id to a new "sm_user" AppConfig section on successful login, restores it into m_login_userinfo right after AppConfig::load() during startup (before the webview's first sw_GetUserLoginState call), and clears the persisted section on logout so a revoked token isn't restored. Fixes Snapmaker#669
physicsG
added a commit
to physicsG/OrcaSlicer
that referenced
this pull request
Aug 23, 2026
…view is listening
The restore ran in post_init(), and the account was live in C++ from then on - but the home page
still offered Login/Register over it. Two separate reasons, one per end of startup, and fixing
either alone does not work:
- post_init() is too late for anything that asks. The webview queries the login state once,
early, and by then the answer was still "offline". PR Snapmaker#715, an outside contributor's, moved
its restore into init_app_config() for exactly this reason, and that placement is right
- init_app_config() is too early to tell anyone. set_user_login() notifies through
m_user_login_subscribers, and at that point in startup the webview does not exist, so the
notification reaches nobody. Moving the restore there alone made it worse, not better:
measured, the webview went from being told "online" once to never being told at all
So both. The state is restored in init_app_config(), before anything can ask for it, and
sm_announce_login() repeats it in post_init() once there is something subscribed to hear it. The
log now shows the restore, the re-announce, and the webview receiving status: online.
The page still renders Login/Register after all that, which is as far as this can be taken from
here: the saved token is days old, and the header says plainly that nothing re-validates it -
"a stale token simply fails on the next API call and the user re-logs in". Whether a fresh token
lands differently is a question for the next real login, not for this branch.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #669 (and the same underlying cause behind the related reports in #226, #116, and #716).
The native
SMUserInfostruct (m_login_userinfo), which backssw_GetUserLoginStatefor the embedded Flutter login webview, was only ever populated in-memory during an active login flow (WebSMUserLoginDialog::OnNavigationRequest) and was never written to or restored fromAppConfig. Every app restart therefore started with an empty, logged-out struct — regardless of whether the embedded webview's ownlocalStoragestill had a cached token — so the login screen reappeared on every launch even though the account token itself was still valid.This was reproducible outside the Flatpak sandbox too (confirmed on a from-source Linux build), which rules out sandbox/permission causes such as keyring access or the webview's local-server port.
Platform scope
All existing reports of this symptom are Linux-only, but the affected code (
WebSMUserLoginDialog::OnNavigationRequest,GUI_App::sm_get_login_info, theSMUserInfostruct) has no#ifdef _WIN32/__APPLE__guards anywhere — it's plain cross-platform C++ shared by every build. The native "am I logged in" check always reads fromm_login_userinfo, which resets to its default (logged-out) state on every process launch regardless of OS or webview backend (WebKitGTK/WebView2/WKWebView). I don't have a Windows or macOS machine to confirm directly, but nothing in the code path is platform-specific, so this likely affects those builds too, just underreported so far.Fix
WebSMUserLoginDialog.cpp), persist token/account/nickname/icon/id to a newsm_userAppConfigsection and save immediately.GUI_App.cpp), right afterAppConfig::load()and before the webview's firstsw_GetUserLoginStatecall, restore the saved session intom_login_userinfoif a token is present.sm_request_user_logout), clear the persistedsm_user.tokenso a revoked session isn't restored on next launch.Test plan
sm_usersection written toAppConfig(~/.config/Snapmaker_Orca/Snapmaker_Orca.conf) with token/account/nickname/icon/id