Repository navigation
fix(session): replace unreliable OpenInputDesktop with WTSQuerySessionInformation - #194
Merged
dongle-china merged 2 commits intoNov 16, 2026
Conversation
📝 Contributor agreement requiredThank you for opening this pull request! Before CI can run, please sign the SniShaper contributor agreement. Reply to this pull request with a comment containing the word agree (e.g. "I agree") to confirm that you have read and accept:
Once you reply, the |
dongle-china
enabled auto-merge (squash)
November 16, 2026 12:02
Contributor
|
agree |
|
🔓 CI gate unlocked by maintainer |
The secrets context cannot be referenced in a job-level if: the workflow fails to start with no jobs scheduled. Detect fork PRs via github.event.pull_request.head.repo.fork instead; it is null on push events, so direct runs keep the syntax-bot reporting. Co-authored-by: SniShaper <SniShaper@proton.me>
dongle-china
force-pushed
the
fix/session-guard-use-wts-api
branch
from
November 16, 2026 12:20
8756f72 to
6c6a5ad
Compare
Contributor
|
感谢修复此问题,我们将会在检查通过后合并。 |
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.
Context
This is a follow-up to the early-logon autostart bug (#192) and the wait-loop fix in the launch sequence. While the launch sequence now waits for the desktop, the underlying
NonInteractiveSession()check still relies onOpenInputDesktop, which is notoriously unreliable for detecting if the desktop is truly ready.OpenInputDesktopfrequently returns0(failure) during the early logon phase before the shell is fully initialized. It is also bound to user input states (such as the lock screen), making it a poor choice for determining session readiness. Microsoft's own recommendation for polling session state isWTSQuerySessionInformation.Changes
OpenInputDesktoplogic fromNonInteractiveSession().WTSQuerySessionInformationWviawtsapi32.dllto queryWTSConnectState.WTSActive(0).WTSConnectedorWTSInitializing, it correctly identifies that the desktop is not yet ready.ProcessIdToSessionId) as the first line of defense.varblock to keep the diff clean.This ensures that the system will not mistakenly fall back to CLI mode during the critical window of the user logging in, especially when combined with the
--startupwait loop.Verification Needed
The changes are based on Microsoft's documented behavior for
WTSQuerySessionInformationWandWTSConnectState. However, I have not been able to run a full test matrix across all scenarios (e.g., fast user switching, remote desktop, and actual session 0 automation).Reviewers/maintainers should verify:
WTSActivecheck across different Windows versions.return false(defaulting to GUI when API fails) behaves correctly in edge cases.Platform note
Windows-only change. Linux and macOS rely on environment variables (
DISPLAY/WAYLAND_DISPLAY) and are unaffected by this PR.