Skip to content

Fix Windows token never saved on first login (Test-Path false positive)#144

Merged
HayatoYagi merged 3 commits into
masterfrom
copilot/fix-windows-github-login-persistence
Mar 22, 2026
Merged

Fix Windows token never saved on first login (Test-Path false positive)#144
HayatoYagi merged 3 commits into
masterfrom
copilot/fix-windows-github-login-persistence

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 22, 2026

On Windows, the OAuth token was never persisted to disk, causing the user to be logged out on every app restart — including after MSI installs.

Root cause

saveToWindowsDpapi opened its PowerShell script with a file-existence guard:

if (!(Test-Path $env:GHPV_PATH)) { exit 1 }

On first login the token file doesn't exist yet (that's the point of the call), so Test-Path returns $false and the script exits with code 1 before writing anything. The failure is silently discarded by the caller.

Fix

Replace the file-existence check with an env-var-is-set check:

if ([string]::IsNullOrWhiteSpace($env:GHPV_PATH)) { exit 1 }

This guards only against a missing GHPV_PATH variable (which we always inject), not against the destination file being absent. The existing New-Item line already handles directory creation when needed.

The analogous Test-Path guard in loadFromWindowsDpapiFile is intentional and untouched — loading from a non-existent file should short-circuit.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx3072M -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/gradle-daemon-main-8.14.3.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Windows dev run does not persist GitHub login across app restarts</issue_title>
<issue_description>## Summary
On Windows, GitHub login state is not persisted across app restarts when running the app in dev mode from Android Studio.

What we know

  • macOS does not show this problem on master; login state is preserved across restarts there.
  • On Windows, restarting the app logs the user out every time.
  • In the current Windows environment, neither of these token files exists after login:
    • %APPDATA%\PRsVisualizerForGitHub\oauth_token.dpapi
    • %APPDATA%\GitHubPRsVisualizer\oauth_token.dpapi
  • That suggests this is not only a restore issue; token save itself appears to be failing on Windows.

Relevant history

  • Commit cd12f56 (2026-03-01, Rename app to PRs Visualizer for GitHub (Rename app to PRs Visualizer for GitHub #91)) changed the Windows token path from:
    • %APPDATA%\GitHubPRsVisualizer\oauth_token.dpapi
      to:
    • %APPDATA%\PRsVisualizerForGitHub\oauth_token.dpapi
  • That path change can explain loss of previously saved Windows sessions after the rename.
  • However, the current behavior in Android Studio dev mode appears worse: no token file is being created at all.

Likely scope

Windows-specific bug in GitHubTokenStore save/load behavior or in how the Windows secure-storage subprocess behaves under Android Studio dev runs.

Not yet confirmed

  • Whether the failure is in save, load, or both during Android Studio dev runs.
  • Whether packaged Windows builds are also affected, or only dev runs.
  • Whether the subprocess-based PowerShell invocation is failing silently.
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@HayatoYagi windowsだとmsi経由でインストールしてもログイン状態が維持されないことを確認

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ath check in PowerShell script

The saveToWindowsDpapi script checked `Test-Path $env:GHPV_PATH` (file
existence) before saving.  On first login the destination file does not
exist yet, so Test-Path returns false, the script exits with code 1, and the
token is never written to disk.  Subsequent restarts find no token file and
log the user out every time.

Fix: replace the file-existence guard with an env-var-is-set guard
(`[string]::IsNullOrWhiteSpace($env:GHPV_PATH)`) so the script only
aborts when the path variable is not provided, not when the file is absent.

Co-authored-by: HayatoYagi <26685974+HayatoYagi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/HayatoYagi/PRs_Visualizer/sessions/e87c1986-c9a4-43ff-b2ab-550bf140ca44
Copilot AI changed the title [WIP] Fix GitHub login persistence issue on Windows Fix Windows token never saved on first login (Test-Path false positive) Mar 22, 2026
Copilot AI requested a review from HayatoYagi March 22, 2026 06:45
@HayatoYagi HayatoYagi marked this pull request as ready for review March 22, 2026 07:03
@HayatoYagi HayatoYagi merged commit ea8a9cc into master Mar 22, 2026
1 check passed
@HayatoYagi HayatoYagi deleted the copilot/fix-windows-github-login-persistence branch March 22, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows dev run does not persist GitHub login across app restarts

2 participants