fix(windows): launch commands on the interactive desktop

This commit is contained in:
cabbage committed 2026-10-27 18:35:29 +00:00
1 parent 30e7bb8545
commit 8d28925e44
20 files changed
+1036 -28

No files matched your search

@@ -0,0 +1,43 @@
package windows
import (
"fmt"
"strings"
"github.com/rvbox/rvbox/internal/client/supervisor"
)
const interactiveDesktop = `winsta0\default`
// Desktop placement follows the selected identity, never a caller-supplied
// desktop name. Session 0 contexts keep their noninteractive desktop.
func desktopForIdentity(identity supervisor.EffectiveIdentity) (string, error) {
switch ExecutionContext(identity.Context) {
case ContextActiveUser, ContextActiveUserElevated, ContextActiveSystem:
if identity.SessionID == 0 {
return "", fmt.Errorf("active execution context has no interactive session")
}
return interactiveDesktop, nil
case ContextLocalService, ContextLocalSystem:
if identity.SessionID != 0 {
return "", fmt.Errorf("local execution context unexpectedly targets session %d", identity.SessionID)
}
return "", nil
default:
return "", fmt.Errorf("unknown Windows execution context %q", identity.Context)
}
}
func validateInteractiveDesktop(desktop string) error {
if !strings.EqualFold(desktop, interactiveDesktop) {
return fmt.Errorf("interactive desktop mismatch: got %q, want %q", desktop, interactiveDesktop)
}
return nil
}
func launcherAbortError(payload []byte) error {
if len(payload) == 0 || len(payload) > 4096 {
return fmt.Errorf("launcher preparation failed without a valid diagnostic")
}
return fmt.Errorf("launcher preparation failed: %s", payload)
}