fix(windows): GUI subsystem + AttachConsole + muyue.exe canonical (v0.7.5) #12
Reference in New Issue
Block a user
Delete Branch "release/v0.7.5"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Trois bugs Windows rapportés par l'utilisateur
1. Double-clic raccourci → "This is a command line tool"
charmbracelet/huh(TUI premier lancement) détecte l'absence de TTY interactif quand le binaire est lancé via Explorer et avorte avec ce message.Fix :
root.go::isInteractiveStdin: si stdin n'est pas un character device, on sauteRunFirstTimeSetup, on persiste unconfig.Default(), l'onboarding web prend le relais.ci-{main,develop}.yml: Windows builds en GUI subsystem (-ldflags="-H=windowsgui") — plus aucune fenêtre console au double-clic.2. Sous-commandes CLI muettes en mode GUI subsystem
Avec
-H=windowsgui,muyue scan/muyue version/ etc. lancés depuis cmd.exe ne produisent plus rien.Fix : nouveau
cmd/muyue/console_windows.gobuild-taggé. À l'init(), appellekernel32!AttachConsole(ATTACH_PARENT_PROCESS). Si le parent a une console (cmd.exe / PowerShell),os.Stdout/os.Stderr/os.Stdiny sont rebindés etlog.SetOutput(os.Stderr)synchronise le logger Go. Si pas de console parent (Explorer), on exit silencieusement. Compatible des deux usages sans dual-binary.3.
muyueintrouvable en PowerShell après installCauses : binaire extrait nommé
muyue-windows-amd64.exe+ PATH utilisateur non rafraîchie dans la session courante.Fix dans
install-shortcuts:<installDir>/muyue.exe(copy, pas rename — le binaire en cours d'exécution est verrouillé sur Windows) —muyuerésout dès que PATH est en place.muyue.execanonique.$env:Path += ';...'à coller pour activer la commande dans la session courante.Versioning
Test plan
muyue versiondepuis cmd.exe → output visiblemuyuefonctionne immédiatement dans la même sessionThree Windows install/launch issues reported by the user: 1. Double-click on Desktop shortcut → dialog "This is a command line tool. You need to open cmd.exe and run it from there." Cause: charmbracelet/huh detects no TTY when launched via Explorer and aborts. Fix: - cmd/muyue/commands/root.go: skip RunFirstTimeSetup when os.Stdin is not a character device; persist config.Default() and let the React onboarding wizard handle first-run UX. - ci-{main,develop}.yml: build Windows binaries with -ldflags="-H=windowsgui" so the .exe is a GUI subsystem app — no console window flashes on double-click. 2. CLI sub-commands (`muyue scan`, `muyue install-shortcuts`, etc.) would lose all output under -H=windowsgui when launched from cmd.exe / PowerShell. Mitigation: - cmd/muyue/console_windows.go (new, build-tagged): on init(), call kernel32!AttachConsole(ATTACH_PARENT_PROCESS). If the parent has a console, rebind os.Stdout/os.Stderr/os.Stdin to it and call log.SetOutput(os.Stderr) so existing log.Printf calls surface. If no parent console (Explorer), exit silently. 3. After install, `muyue` not recognized in PowerShell. Causes: (a) the extracted binary is muyue-windows-amd64.exe, not muyue.exe; (b) the user PATH update by install-shortcuts doesn't propagate to the existing PowerShell session. Fix in install-shortcuts: - Copy self to <installDir>/muyue.exe (rename impossible — the running .exe is locked on Windows) so `muyue` resolves once PATH is set. - Update Desktop + Start Menu .lnk to target the canonical muyue.exe rather than the platform-suffixed binary. - Print the line `$env:Path += ';<installDir>'` for the user to paste, refreshing the current session immediately. - ci-main.yml install snippet bumps to 5 lines, last being `$env:Path += ";$dest"`. - internal/version/version.go: 0.7.4 → 0.7.5 - CHANGELOG.md: v0.7.5 entry covers all three fixes