go/cmd/core-ide/ide_service.go
Snider e8119a49eb fix(core-ide): use path-based routing for multi-window SPA, clean up formatting
Switch Angular from hash-based to path-based routing so each Wails window
(/tray, /main, /settings) loads its correct route. Archive GitHub Actions
workflows to .gh-actions/, update Forgejo deploy registry to dappco.re/osi,
and apply gofmt/alignment fixes across packages.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-09 01:50:57 +00:00

83 lines
2.1 KiB
Go

package main
import (
"context"
"log"
"github.com/host-uk/core/pkg/mcp/ide"
"github.com/host-uk/core/pkg/ws"
"github.com/wailsapp/wails/v3/pkg/application"
)
// IDEService provides core IDE bindings for the frontend.
type IDEService struct {
app *application.App
ideSub *ide.Subsystem
hub *ws.Hub
}
// NewIDEService creates a new IDEService.
func NewIDEService(ideSub *ide.Subsystem, hub *ws.Hub) *IDEService {
return &IDEService{ideSub: ideSub, hub: hub}
}
// ServiceName returns the service name for Wails.
func (s *IDEService) ServiceName() string { return "IDEService" }
// ServiceStartup is called when the Wails application starts.
func (s *IDEService) ServiceStartup(_ context.Context, _ application.ServiceOptions) error {
log.Println("IDEService started")
return nil
}
// ServiceShutdown is called when the Wails application shuts down.
func (s *IDEService) ServiceShutdown() error {
log.Println("IDEService shutdown")
return nil
}
// ConnectionStatus represents the IDE bridge connection state.
type ConnectionStatus struct {
BridgeConnected bool `json:"bridgeConnected"`
LaravelURL string `json:"laravelUrl"`
WSClients int `json:"wsClients"`
WSChannels int `json:"wsChannels"`
}
// GetConnectionStatus returns the current bridge and WebSocket status.
func (s *IDEService) GetConnectionStatus() ConnectionStatus {
connected := false
if s.ideSub.Bridge() != nil {
connected = s.ideSub.Bridge().Connected()
}
stats := s.hub.Stats()
return ConnectionStatus{
BridgeConnected: connected,
WSClients: stats.Clients,
WSChannels: stats.Channels,
}
}
// DashboardData aggregates data for the dashboard view.
type DashboardData struct {
Connection ConnectionStatus `json:"connection"`
}
// GetDashboard returns aggregated dashboard data.
func (s *IDEService) GetDashboard() DashboardData {
return DashboardData{
Connection: s.GetConnectionStatus(),
}
}
// ShowWindow shows a named window.
func (s *IDEService) ShowWindow(name string) {
if s.app == nil {
return
}
if w, ok := s.app.Window.Get(name); ok {
w.Show()
w.Focus()
}
}