From 49a83110fb17478ff1b7fd7b2d5236c2a9945e69 Mon Sep 17 00:00:00 2001 From: Snider Date: Fri, 13 Mar 2026 14:53:50 +0000 Subject: [PATCH] refactor(display): migrate stale Wails calls to IPC, remove wrapper types Migrate handleOpenFile to dialog.TaskOpenFile IPC, handleSaveFile/handleRun/ handleBuild to ActionIDECommand IPC. Remove DialogManager, EnvManager, EventManager interfaces and wailsDialogManager, wailsEnvManager, wailsEventManager adapter structs. App interface now has Quit() + Logger() only. Co-Authored-By: Claude Opus 4.6 --- pkg/display/display.go | 27 ++++++++++-------- pkg/display/interfaces.go | 59 ++++----------------------------------- 2 files changed, 21 insertions(+), 65 deletions(-) diff --git a/pkg/display/display.go b/pkg/display/display.go index 6b1de86..b6c396f 100644 --- a/pkg/display/display.go +++ b/pkg/display/display.go @@ -841,25 +841,30 @@ func (s *Service) handleNewFile() { } func (s *Service) handleOpenFile() { - dialog := s.app.Dialog().OpenFile() - dialog.SetTitle("Open File") - dialog.CanChooseFiles(true) - dialog.CanChooseDirectories(false) - result, err := dialog.PromptForSingleSelection() - if err != nil || result == "" { + result, handled, err := s.Core().PERFORM(dialog.TaskOpenFile{ + Opts: dialog.OpenFileOptions{ + Title: "Open File", + AllowMultiple: false, + }, + }) + if err != nil || !handled { + return + } + paths, ok := result.([]string) + if !ok || len(paths) == 0 { return } _, _, _ = s.Core().PERFORM(window.TaskOpenWindow{ Opts: []window.WindowOption{ window.WithName("editor"), - window.WithTitle(result + " - Editor"), - window.WithURL("/#/developer/editor?file=" + result), + window.WithTitle(paths[0] + " - Editor"), + window.WithURL("/#/developer/editor?file=" + paths[0]), window.WithSize(1200, 800), }, }) } -func (s *Service) handleSaveFile() { s.app.Event().Emit("ide:save") } +func (s *Service) handleSaveFile() { _ = s.Core().ACTION(ActionIDECommand{Command: "save"}) } func (s *Service) handleOpenEditor() { _, _, _ = s.Core().PERFORM(window.TaskOpenWindow{ Opts: []window.WindowOption{ @@ -880,8 +885,8 @@ func (s *Service) handleOpenTerminal() { }, }) } -func (s *Service) handleRun() { s.app.Event().Emit("ide:run") } -func (s *Service) handleBuild() { s.app.Event().Emit("ide:build") } +func (s *Service) handleRun() { _ = s.Core().ACTION(ActionIDECommand{Command: "run"}) } +func (s *Service) handleBuild() { _ = s.Core().ACTION(ActionIDECommand{Command: "build"}) } // --- Tray (setup delegated via IPC) --- diff --git a/pkg/display/interfaces.go b/pkg/display/interfaces.go index 324bd97..2ca6738 100644 --- a/pkg/display/interfaces.go +++ b/pkg/display/interfaces.go @@ -1,39 +1,16 @@ // pkg/display/interfaces.go package display -import ( - "github.com/wailsapp/wails/v3/pkg/application" - "github.com/wailsapp/wails/v3/pkg/events" -) +import "github.com/wailsapp/wails/v3/pkg/application" // App abstracts the Wails application for the orchestrator. +// After Spec D cleanup, only Quit() and Logger() remain — +// all other Wails Manager APIs are accessed via IPC. type App interface { - Dialog() DialogManager - Env() EnvManager - Event() EventManager Logger() Logger Quit() } -// DialogManager wraps Wails dialog operations. -type DialogManager interface { - Info() *application.MessageDialog - Warning() *application.MessageDialog - OpenFile() *application.OpenFileDialogStruct -} - -// EnvManager wraps Wails environment queries. -type EnvManager interface { - Info() application.EnvironmentInfo - IsDarkMode() bool -} - -// EventManager wraps Wails application events. -type EventManager interface { - OnApplicationEvent(eventType events.ApplicationEventType, handler func(*application.ApplicationEvent)) func() - Emit(name string, data ...any) bool -} - // Logger wraps Wails logging. type Logger interface { Info(message string, args ...any) @@ -48,31 +25,5 @@ func newWailsApp(app *application.App) App { return &wailsApp{app: app} } -func (w *wailsApp) Dialog() DialogManager { return &wailsDialogManager{app: w.app} } -func (w *wailsApp) Env() EnvManager { return &wailsEnvManager{app: w.app} } -func (w *wailsApp) Event() EventManager { return &wailsEventManager{app: w.app} } -func (w *wailsApp) Logger() Logger { return w.app.Logger } -func (w *wailsApp) Quit() { w.app.Quit() } - -type wailsDialogManager struct{ app *application.App } - -func (d *wailsDialogManager) Info() *application.MessageDialog { return d.app.Dialog.Info() } -func (d *wailsDialogManager) Warning() *application.MessageDialog { return d.app.Dialog.Warning() } -func (d *wailsDialogManager) OpenFile() *application.OpenFileDialogStruct { - return d.app.Dialog.OpenFile() -} - -type wailsEnvManager struct{ app *application.App } - -func (e *wailsEnvManager) Info() application.EnvironmentInfo { return e.app.Env.Info() } -func (e *wailsEnvManager) IsDarkMode() bool { return e.app.Env.IsDarkMode() } - -type wailsEventManager struct{ app *application.App } - -func (ev *wailsEventManager) OnApplicationEvent(eventType events.ApplicationEventType, handler func(*application.ApplicationEvent)) func() { - return ev.app.Event.OnApplicationEvent(eventType, handler) -} -func (ev *wailsEventManager) Emit(name string, data ...any) bool { - return ev.app.Event.Emit(name, data...) -} - +func (w *wailsApp) Logger() Logger { return w.app.Logger } +func (w *wailsApp) Quit() { w.app.Quit() }