package main import ( "context" "embed" "os" "time" "github.com/Nwflower/reims-go/internal/app" "github.com/Nwflower/reims-go/internal/cli" "github.com/Nwflower/reims-go/internal/host" "github.com/wailsapp/wails/v2" "github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options/assetserver" "github.com/wailsapp/wails/v2/pkg/options/windows" ) //go:embed all:frontend/dist var assets embed.FS //go:embed assets/logo.png var trayIconPNG []byte //go:embed LICENSE var licenseText string //go:embed NOTICE.md var noticeText string func main() { args := os.Args[1:] if cli.IsCommand(args) { attachConsole() os.Exit(cli.Main(args)) } launch, _ := cli.ParseWindowArgs(args) if launch.WaitPID != 0 { // Relaunched by an in-app update: let the old window exit first, or the // single-instance lock below hands this launch back to it. ctx, cancel := context.WithTimeout(context.Background(), time.Minute) _ = host.WaitProcessExit(ctx, launch.WaitPID, "") cancel() } app.RegisterLicenseTexts(licenseText, noticeText) desktopApp, hooks := app.New(trayIconPNG, launch) err := wails.Run(&options.App{ Title: "Reims-Go", StartHidden: launch.Background, // One window per user. A second launch — double-click, or `reims-go vm // start` handing a VM over — goes to the running one instead. SingleInstanceLock: &options.SingleInstanceLock{ UniqueId: cli.InstanceID, OnSecondInstanceLaunch: hooks.OnSecondInstanceLaunch, }, Width: 1120, Height: 740, MinWidth: 920, MinHeight: 600, Frameless: true, DragAndDrop: &options.DragAndDrop{ EnableFileDrop: true, DisableWebViewDrop: true, CSSDropProperty: "--wails-drop-target", CSSDropValue: "drop", }, AssetServer: &assetserver.Options{ Assets: assets, Handler: desktopApp.PluginAssetHandler(), }, BackgroundColour: &options.RGBA{R: 28, G: 28, B: 30, A: 255}, Windows: &windows.Options{ Theme: windows.Dark, WebviewIsTransparent: false, WindowIsTranslucent: false, // Disable WebView2's GPU process: Reims-Go's desktop UI is a lightweight // control panel, and software compositing avoids WebView2 GPU process crashes, // DXGI surface loss on sleep/resume, and VRAM/TDR contention with reims-vgpu. WebviewGpuIsDisabled: true, OnSuspend: hooks.OnSuspend, OnResume: hooks.OnResume, CustomTheme: &windows.ThemeSettings{ DarkModeTitleBar: windows.RGB(28, 28, 30), DarkModeTitleText: windows.RGB(245, 245, 247), DarkModeBorder: windows.RGB(58, 58, 62), }, }, OnStartup: hooks.OnStartup, OnBeforeClose: hooks.OnBeforeClose, OnShutdown: hooks.OnShutdown, Bind: []any{ desktopApp, }, }) if err != nil { println("Error:", err.Error()) } }