Skip to content

fix(autostart): wait for interactive desktop before falling back to CLI - #193

Merged
dongle-china merged 2 commits into
SnishaperTeam:mainfrom
wuguo13842:fix/autostart-wait-desktop
Nov 16, 2026
Merged

dongle-china merged 2 commits into
SnishaperTeam:mainfrom
wuguo13842:fix/autostart-wait-desktop

Conversation

@wuguo13842

Copy link
Copy Markdown
Contributor

Fixes #192

During the early logon phase, the interactive desktop is not yet ready. As a result, OpenInputDesktop inside NonInteractiveSession() fails and returns 0, causing the app to incorrectly assume it is running in a headless environment (like session 0 or winget validation).

Because of this misjudgment, the process takes the CLI fallback branch (os.Exit(cliapp.Run(...))) in main.go immediately after launch. This prevents app.NewApp() and Wails from ever initializing, which leaves the user with no tray icon, no WebView2 initialization, and no proxy running.

This is especially problematic for the "silent startup" (Hidden: true) configuration, where the user gets zero visual feedback about the crash.

Fix

Add a bounded wait loop in main.go specifically when launched with the --startup argument:

  • If --startup is present and NonInteractiveSession() returns true, poll every 500ms (up to 30 seconds) until the desktop is actually ready.
  • If the desktop becomes ready within the timeout, continue with the normal GUI initialization sequence.
  • If it times out, fall back to the CLI branch to preserve existing behavior for actual session-0 / automation scenarios.

This change does not affect normal manual launches (where the desktop is already ready), explicit CLI commands, or non-Windows platforms.

@snishaper-policy-bot

Copy link
Copy Markdown

📝 Contributor agreement required

Thank 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 cla-signed label is applied and CI starts automatically.

@snishaper-policy-bot snishaper-policy-bot Bot added the cla-pending Contributor agreement pending signature (policy-bot) label Nov 16, 2026
@dongle-china
dongle-china enabled auto-merge (squash) November 16, 2026 12:02
@dongle-china

Copy link
Copy Markdown
Contributor

agree

@snishaper-policy-bot snishaper-policy-bot Bot added cla-signed Contributor agreement signed (policy-bot) and removed cla-pending Contributor agreement pending signature (policy-bot) labels Nov 16, 2026
@snishaper-policy-bot

Copy link
Copy Markdown

🔓 CI gate unlocked by maintainer @dongle-china — the cla-signed label has been applied and CI will start automatically.

@snishaper-policy-bot snishaper-policy-bot Bot added the reviewers-assigned Reviewers assigned (policy-bot) label Nov 16, 2026
@dongle-china
dongle-china force-pushed the fix/autostart-wait-desktop branch from c2abd59 to f91e9c7 Compare November 16, 2026 12:18
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

Copy link
Copy Markdown
Contributor

感谢修复此问题,我们将会在检查通过后合并。

@dongle-china
dongle-china merged commit 939de85 into SnishaperTeam:main Nov 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed Contributor agreement signed (policy-bot) reviewers-assigned Reviewers assigned (policy-bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] v1.30 版本开启静默自启动后,开机自启动失效(无托盘图标)

2 participants