-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
97 lines (90 loc) · 2.78 KB
/
Copy pathmain.go
File metadata and controls
97 lines (90 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Command opencraft is the opencraft desktop application. It runs the
// assembled flowcraft runtime behind a Wails shell: Go bindings drive
// sessions, agents, and configuration, while the event bridge pushes
// runtime streams (tokens, tool calls, interactions) into the React
// frontend embedded in the binary.
package main
import (
"context"
"embed"
"log"
"os"
"runtime"
"github.com/GizClaw/opencraft/internal/desktop"
"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/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
//go:embed all:frontend/dist
var assets embed.FS
func main() {
// execd is the internal self-forked sandbox child (see
// execd_main.go). It must be handled before any GUI machinery
// starts: the desktop process forks itself with `opencraft execd`
// when a sandboxed command needs an isolated process server.
if len(os.Args) > 1 && os.Args[1] == "execd" {
runExecServer()
return
}
app, err := desktop.New(desktop.Options{})
if err != nil {
log.Fatalf("opencraft: %v", err)
}
opts := &options.App{
Title: "OpenCraft",
Width: 1440,
Height: 900,
MinWidth: 1024,
MinHeight: 700,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 15, G: 18, B: 24, A: 1},
OnStartup: func(ctx context.Context) {
app.Startup(ctx)
applyOpenCraftWindowStyle()
},
OnShutdown: app.Shutdown,
Bind: []interface{}{
app,
},
}
switch runtime.GOOS {
case "darwin":
// Hidden, inset title bar on macOS: the system frame (rounded
// corners, shadow, traffic lights) stays native while the
// content extends to the top; the traffic lights are nudged
// into alignment with the chat header by
// applyOpenCraftWindowStyle. Frameless must stay off here —
// Wails would strip the traffic lights entirely.
opts.Mac = &mac.Options{
TitleBar: mac.TitleBarHiddenInset(),
}
case "windows", "linux":
// Frameless + custom title bar on Windows/Linux to match the
// macOS look: the webview renders the brand strip and window
// controls, and Wails' built-in CSS drag/edge-resize handles
// the window chrome. macOS keeps its native traffic lights.
opts.Frameless = true
switch runtime.GOOS {
case "windows":
// Keep the Windows 11 rounded corners and Aero shadow;
// the theme follows the system (WebView2 UI chrome).
opts.Windows = &windows.Options{
Theme: windows.SystemDefault,
}
case "linux":
opts.Linux = &linux.Options{
ProgramName: "OpenCraft",
WebviewGpuPolicy: linux.WebviewGpuPolicyAlways,
}
}
}
err = wails.Run(opts)
if err != nil {
log.Fatalf("opencraft: %v", err)
}
}