-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
96 lines (83 loc) · 2.64 KB
/
Copy pathmain.go
File metadata and controls
96 lines (83 loc) · 2.64 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
package main
import (
"embed"
_ "embed"
"log"
"log/slog"
"github.com/wailsapp/wails/v3/pkg/application"
mcpapp "mcp-overwatch/internal/app"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed assets/tray-icon.png
var trayIconBytes []byte
func main() {
// Wire up the application with all domain services.
a := mcpapp.NewApp()
// Create the Wails application.
wailsApp := application.New(application.Options{
Name: "MCP Overwatch",
Description: "A unified manager for MCP servers",
// Suppress per-binding-call info logs (Wails 3 alpha logs every result
// payload at info, which dumps multi-MB JSON to the dev terminal for
// stats endpoints).
LogLevel: slog.LevelWarn,
Services: []application.Service{
application.NewService(a.CatalogueService),
application.NewService(a.ServerService),
application.NewService(a.ImportService),
application.NewService(a.LogService),
application.NewService(a.StatsService),
application.NewService(a.SettingsService),
},
Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets),
},
OnShutdown: a.OnShutdown,
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: false,
},
})
// Give the app a reference to the Wails app for event emission.
a.SetWailsApp(wailsApp)
// Run startup logic (reset statuses, start proxy, sync registry, auto-start servers).
if err := a.OnStartup(); err != nil {
log.Fatalf("startup failed: %v", err)
}
// Create the main window with frameless style for custom title bar.
mainWindow := wailsApp.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "MCP Overwatch",
Width: 1200,
Height: 800,
Frameless: true,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
BackgroundColour: application.NewRGB(15, 20, 25),
URL: "/",
})
// Set up system tray.
trayMenu := application.NewMenu()
trayMenu.Add("Open").OnClick(func(ctx *application.Context) {
mainWindow.Show().Focus()
})
trayMenu.AddSeparator()
trayMenu.Add("Quit").OnClick(func(ctx *application.Context) {
wailsApp.Quit()
})
systray := wailsApp.SystemTray.New()
systray.SetIcon(trayIconBytes)
systray.SetTooltip("MCP Overwatch \u2014 0 servers active")
systray.SetMenu(trayMenu)
systray.OnClick(func() {
mainWindow.Show().Focus()
})
// Store systray reference in the app for dynamic tooltip updates.
a.SetSystemTray(systray)
// Run the application (blocks until exit).
if err := wailsApp.Run(); err != nil {
log.Fatal(err)
}
}