Skip to content

Commit a5e5839

Browse files
committed
refactor: move service wrappers from main.go to their respective packages
1 parent 5be7a77 commit a5e5839

66 files changed

Lines changed: 1438 additions & 1217 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Claude Code Guidelines
2+
3+
## Wails Bindings
4+
5+
**Always use the Taskfile task to generate bindings.** Never run `wails3 generate bindings` manually.
6+
7+
```bash
8+
task bindings
9+
```
10+
11+
This ensures bindings are generated with the correct flags, output directory (`packages/omniviewdev-runtime/src/bindings`), and cleanup. The raw `wails3` command generates to the wrong location.
12+
13+
## Build & Test
14+
15+
```bash
16+
GOWORK=off go build . # Build the Go backend
17+
GOWORK=off go test ./... -count=1 # Run all Go tests
18+
task dev # Run the full app in dev mode
19+
```
20+
21+
Use `GOWORK=off` for all Go commands — the module is not in the parent `go.work` file.
22+
23+
## Commits
24+
25+
- Do not add `Co-Authored-By` or any Claude attribution to commits or PRs.

backend/pkg/plugin/adapters.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package plugin
2+
3+
// PluginRefAdapter adapts plugin.Manager to devserver.PluginRef.
4+
type PluginRefAdapter struct{ Mgr Manager }
5+
6+
func (a *PluginRefAdapter) GetDevPluginInfo(pluginID string) (bool, string, error) {
7+
info, err := a.Mgr.GetPlugin(pluginID)
8+
if err != nil {
9+
return false, "", err
10+
}
11+
return info.DevMode, info.DevPath, nil
12+
}
13+
14+
// PluginReloaderAdapter adapts plugin.Manager to devserver.PluginReloader.
15+
type PluginReloaderAdapter struct{ Mgr Manager }
16+
17+
func (a *PluginReloaderAdapter) ReloadPlugin(id string) error {
18+
_, err := a.Mgr.ReloadPlugin(id)
19+
return err
20+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package data
2+
3+
import (
4+
"context"
5+
6+
"github.com/wailsapp/wails/v3/pkg/application"
7+
)
8+
9+
// ServiceWrapper is an explicit delegation wrapper around data.Controller.
10+
type ServiceWrapper struct {
11+
Ctrl Controller
12+
}
13+
14+
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
15+
if ss, ok := s.Ctrl.(interface {
16+
ServiceStartup(context.Context, application.ServiceOptions) error
17+
}); ok {
18+
return ss.ServiceStartup(ctx, options)
19+
}
20+
return nil
21+
}
22+
func (s *ServiceWrapper) ServiceShutdown() error {
23+
if ss, ok := s.Ctrl.(interface{ ServiceShutdown() error }); ok {
24+
return ss.ServiceShutdown()
25+
}
26+
return nil
27+
}
28+
func (s *ServiceWrapper) Get(pluginID, key string) (any, error) {
29+
return s.Ctrl.Get(pluginID, key)
30+
}
31+
func (s *ServiceWrapper) Set(pluginID, key string, value any) error {
32+
return s.Ctrl.Set(pluginID, key, value)
33+
}
34+
func (s *ServiceWrapper) Delete(pluginID, key string) error {
35+
return s.Ctrl.Delete(pluginID, key)
36+
}
37+
func (s *ServiceWrapper) Keys(pluginID string) ([]string, error) {
38+
return s.Ctrl.Keys(pluginID)
39+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package devserver
2+
3+
import (
4+
"context"
5+
6+
"github.com/wailsapp/wails/v3/pkg/application"
7+
)
8+
9+
// ServiceWrapper exposes only frontend-safe methods of devserver.DevServerManager.
10+
// The DevServerManager implements ServiceStartup/ServiceShutdown directly,
11+
// but registering it raw causes service/model shadowing. This wrapper separates
12+
// the service identity from the model type.
13+
type ServiceWrapper struct {
14+
Mgr *DevServerManager
15+
}
16+
17+
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
18+
return s.Mgr.ServiceStartup(ctx, options)
19+
}
20+
func (s *ServiceWrapper) ServiceShutdown() error {
21+
return s.Mgr.ServiceShutdown()
22+
}
23+
func (s *ServiceWrapper) StartDevServer(pluginID string) (DevServerState, error) {
24+
return s.Mgr.StartDevServer(pluginID)
25+
}
26+
func (s *ServiceWrapper) StartDevServerForPath(pluginID, devPath string) (DevServerState, error) {
27+
return s.Mgr.StartDevServerForPath(pluginID, devPath)
28+
}
29+
func (s *ServiceWrapper) StopDevServer(pluginID string) error {
30+
return s.Mgr.StopDevServer(pluginID)
31+
}
32+
func (s *ServiceWrapper) RestartDevServer(pluginID string) (DevServerState, error) {
33+
return s.Mgr.RestartDevServer(pluginID)
34+
}
35+
func (s *ServiceWrapper) RebuildPlugin(pluginID string) error {
36+
return s.Mgr.RebuildPlugin(pluginID)
37+
}
38+
func (s *ServiceWrapper) GetDevServerState(pluginID string) DevServerState {
39+
return s.Mgr.GetDevServerState(pluginID)
40+
}
41+
func (s *ServiceWrapper) ListDevServerStates() []DevServerState {
42+
return s.Mgr.ListDevServerStates()
43+
}
44+
func (s *ServiceWrapper) GetDevServerLogs(pluginID string, count int) []LogEntry {
45+
return s.Mgr.GetDevServerLogs(pluginID, count)
46+
}
47+
func (s *ServiceWrapper) IsManaged(pluginID string) bool {
48+
return s.Mgr.IsManaged(pluginID)
49+
}
50+
func (s *ServiceWrapper) GetExternalPluginInfo(pluginID string) *DevInfoFile {
51+
return s.Mgr.GetExternalPluginInfo(pluginID)
52+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package exec
2+
3+
import (
4+
"context"
5+
6+
execsdk "github.com/omniviewdev/plugin-sdk/pkg/v1/exec"
7+
"github.com/wailsapp/wails/v3/pkg/application"
8+
)
9+
10+
// ServiceWrapper is an explicit delegation wrapper around exec.Controller.
11+
// Excluded: OnPluginInit, OnPluginStart, OnPluginStop, OnPluginShutdown,
12+
//
13+
// OnPluginDestroy
14+
type ServiceWrapper struct {
15+
Ctrl Controller
16+
}
17+
18+
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
19+
if ss, ok := s.Ctrl.(interface {
20+
ServiceStartup(context.Context, application.ServiceOptions) error
21+
}); ok {
22+
return ss.ServiceStartup(ctx, options)
23+
}
24+
return nil
25+
}
26+
func (s *ServiceWrapper) ServiceShutdown() error {
27+
if ss, ok := s.Ctrl.(interface{ ServiceShutdown() error }); ok {
28+
return ss.ServiceShutdown()
29+
}
30+
return nil
31+
}
32+
func (s *ServiceWrapper) CreateSession(plugin, connectionID string, opts execsdk.SessionOptions) (*execsdk.Session, error) {
33+
return s.Ctrl.CreateSession(plugin, connectionID, opts)
34+
}
35+
func (s *ServiceWrapper) CreateTerminal(opts execsdk.SessionOptions) (*execsdk.Session, error) {
36+
return s.Ctrl.CreateTerminal(opts)
37+
}
38+
func (s *ServiceWrapper) ListSessions() ([]*execsdk.Session, error) {
39+
return s.Ctrl.ListSessions()
40+
}
41+
func (s *ServiceWrapper) GetSession(sessionID string) (*execsdk.Session, error) {
42+
return s.Ctrl.GetSession(sessionID)
43+
}
44+
func (s *ServiceWrapper) AttachSession(sessionID string) (*execsdk.Session, []byte, error) {
45+
return s.Ctrl.AttachSession(sessionID)
46+
}
47+
func (s *ServiceWrapper) DetachSession(sessionID string) (*execsdk.Session, error) {
48+
return s.Ctrl.DetachSession(sessionID)
49+
}
50+
func (s *ServiceWrapper) WriteSession(sessionID string, data []byte) error {
51+
return s.Ctrl.WriteSession(sessionID, data)
52+
}
53+
func (s *ServiceWrapper) CloseSession(sessionID string) error {
54+
return s.Ctrl.CloseSession(sessionID)
55+
}
56+
func (s *ServiceWrapper) ResizeSession(sessionID string, rows, cols uint16) error {
57+
return s.Ctrl.ResizeSession(sessionID, rows, cols)
58+
}
59+
func (s *ServiceWrapper) GetHandler(plugin, resource string) *execsdk.Handler {
60+
return s.Ctrl.GetHandler(plugin, resource)
61+
}
62+
func (s *ServiceWrapper) GetHandlers() map[string]map[string]execsdk.Handler {
63+
return s.Ctrl.GetHandlers()
64+
}
65+
func (s *ServiceWrapper) GetPluginHandlers(plugin string) map[string]execsdk.Handler {
66+
return s.Ctrl.GetPluginHandlers(plugin)
67+
}
68+
func (s *ServiceWrapper) ListPlugins() ([]string, error) {
69+
return s.Ctrl.ListPlugins()
70+
}
71+
func (s *ServiceWrapper) HasPlugin(pluginID string) bool {
72+
return s.Ctrl.HasPlugin(pluginID)
73+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package logs
2+
3+
import (
4+
"context"
5+
6+
logssdk "github.com/omniviewdev/plugin-sdk/pkg/v1/logs"
7+
"github.com/wailsapp/wails/v3/pkg/application"
8+
)
9+
10+
// ServiceWrapper is an explicit delegation wrapper around logs.Controller.
11+
// Excluded: OnPluginInit, OnPluginStart, OnPluginStop, OnPluginShutdown,
12+
//
13+
// OnPluginDestroy
14+
type ServiceWrapper struct {
15+
Ctrl Controller
16+
}
17+
18+
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
19+
if ss, ok := s.Ctrl.(interface {
20+
ServiceStartup(context.Context, application.ServiceOptions) error
21+
}); ok {
22+
return ss.ServiceStartup(ctx, options)
23+
}
24+
return nil
25+
}
26+
func (s *ServiceWrapper) ServiceShutdown() error {
27+
if ss, ok := s.Ctrl.(interface{ ServiceShutdown() error }); ok {
28+
return ss.ServiceShutdown()
29+
}
30+
return nil
31+
}
32+
func (s *ServiceWrapper) GetSupportedResources(pluginID string) []logssdk.Handler {
33+
return s.Ctrl.GetSupportedResources(pluginID)
34+
}
35+
func (s *ServiceWrapper) CreateSession(plugin, connectionID string, opts logssdk.CreateSessionOptions) (*logssdk.LogSession, error) {
36+
return s.Ctrl.CreateSession(plugin, connectionID, opts)
37+
}
38+
func (s *ServiceWrapper) GetSession(sessionID string) (*logssdk.LogSession, error) {
39+
return s.Ctrl.GetSession(sessionID)
40+
}
41+
func (s *ServiceWrapper) ListSessions() ([]*logssdk.LogSession, error) {
42+
return s.Ctrl.ListSessions()
43+
}
44+
func (s *ServiceWrapper) CloseSession(sessionID string) error {
45+
return s.Ctrl.CloseSession(sessionID)
46+
}
47+
func (s *ServiceWrapper) SendCommand(sessionID string, cmd logssdk.LogStreamCommand) error {
48+
return s.Ctrl.SendCommand(sessionID, cmd)
49+
}
50+
func (s *ServiceWrapper) UpdateSessionOptions(sessionID string, opts logssdk.LogSessionOptions) (*logssdk.LogSession, error) {
51+
return s.Ctrl.UpdateSessionOptions(sessionID, opts)
52+
}
53+
func (s *ServiceWrapper) ListPlugins() ([]string, error) {
54+
return s.Ctrl.ListPlugins()
55+
}
56+
func (s *ServiceWrapper) HasPlugin(pluginID string) bool {
57+
return s.Ctrl.HasPlugin(pluginID)
58+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package metric
2+
3+
import (
4+
"context"
5+
"time"
6+
7+
metricsdk "github.com/omniviewdev/plugin-sdk/pkg/v1/metric"
8+
"github.com/wailsapp/wails/v3/pkg/application"
9+
)
10+
11+
// ServiceWrapper is an explicit delegation wrapper around metric.Controller.
12+
// Excluded: OnPluginInit, OnPluginStart, OnPluginStop, OnPluginShutdown,
13+
//
14+
// OnPluginDestroy
15+
type ServiceWrapper struct {
16+
Ctrl Controller
17+
}
18+
19+
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
20+
if ss, ok := s.Ctrl.(interface {
21+
ServiceStartup(context.Context, application.ServiceOptions) error
22+
}); ok {
23+
return ss.ServiceStartup(ctx, options)
24+
}
25+
return nil
26+
}
27+
func (s *ServiceWrapper) ServiceShutdown() error {
28+
if ss, ok := s.Ctrl.(interface{ ServiceShutdown() error }); ok {
29+
return ss.ServiceShutdown()
30+
}
31+
return nil
32+
}
33+
func (s *ServiceWrapper) GetProviders() []MetricProviderSummary {
34+
return s.Ctrl.GetProviders()
35+
}
36+
func (s *ServiceWrapper) GetProvidersForResource(resourceKey string) []MetricProviderSummary {
37+
return s.Ctrl.GetProvidersForResource(resourceKey)
38+
}
39+
func (s *ServiceWrapper) Query(pluginID, connectionID string, req metricsdk.QueryRequest) (*metricsdk.QueryResponse, error) {
40+
return s.Ctrl.Query(pluginID, connectionID, req)
41+
}
42+
func (s *ServiceWrapper) QueryAll(connectionID, resourceKey, resourceID, namespace string,
43+
resourceData map[string]interface{}, metricIDs []string,
44+
shape metricsdk.MetricShape, startTime, endTime time.Time, step time.Duration,
45+
) (map[string]*metricsdk.QueryResponse, error) {
46+
return s.Ctrl.QueryAll(connectionID, resourceKey, resourceID, namespace, resourceData, metricIDs, shape, startTime, endTime, step)
47+
}
48+
func (s *ServiceWrapper) Subscribe(pluginID, connectionID string, req SubscribeRequest) (string, error) {
49+
return s.Ctrl.Subscribe(pluginID, connectionID, req)
50+
}
51+
func (s *ServiceWrapper) Unsubscribe(subscriptionID string) error {
52+
return s.Ctrl.Unsubscribe(subscriptionID)
53+
}
54+
func (s *ServiceWrapper) ListPlugins() ([]string, error) {
55+
return s.Ctrl.ListPlugins()
56+
}
57+
func (s *ServiceWrapper) HasPlugin(pluginID string) bool {
58+
return s.Ctrl.HasPlugin(pluginID)
59+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package networker
2+
3+
import (
4+
"context"
5+
6+
networkersdk "github.com/omniviewdev/plugin-sdk/pkg/v1/networker"
7+
"github.com/wailsapp/wails/v3/pkg/application"
8+
)
9+
10+
// ServiceWrapper is an explicit delegation wrapper around networker.Controller.
11+
// Excluded: OnPluginInit, OnPluginStart, OnPluginStop, OnPluginShutdown,
12+
//
13+
// OnPluginDestroy
14+
type ServiceWrapper struct {
15+
Ctrl Controller
16+
}
17+
18+
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
19+
if ss, ok := s.Ctrl.(interface {
20+
ServiceStartup(context.Context, application.ServiceOptions) error
21+
}); ok {
22+
return ss.ServiceStartup(ctx, options)
23+
}
24+
return nil
25+
}
26+
func (s *ServiceWrapper) ServiceShutdown() error {
27+
if ss, ok := s.Ctrl.(interface{ ServiceShutdown() error }); ok {
28+
return ss.ServiceShutdown()
29+
}
30+
return nil
31+
}
32+
func (s *ServiceWrapper) GetSupportedPortForwardTargets(pluginID string) ([]string, error) {
33+
return s.Ctrl.GetSupportedPortForwardTargets(pluginID)
34+
}
35+
func (s *ServiceWrapper) GetPortForwardSession(sessionID string) (*networkersdk.PortForwardSession, error) {
36+
return s.Ctrl.GetPortForwardSession(sessionID)
37+
}
38+
func (s *ServiceWrapper) ListPortForwardSessions(pluginID, connectionID string) ([]*networkersdk.PortForwardSession, error) {
39+
return s.Ctrl.ListPortForwardSessions(pluginID, connectionID)
40+
}
41+
func (s *ServiceWrapper) ListAllPortForwardSessions() ([]*networkersdk.PortForwardSession, error) {
42+
return s.Ctrl.ListAllPortForwardSessions()
43+
}
44+
func (s *ServiceWrapper) FindPortForwardSessions(pluginID, connectionID string, request networkersdk.FindPortForwardSessionRequest) ([]*networkersdk.PortForwardSession, error) {
45+
return s.Ctrl.FindPortForwardSessions(pluginID, connectionID, request)
46+
}
47+
func (s *ServiceWrapper) StartResourcePortForwardingSession(pluginID, connectionID string, opts networkersdk.PortForwardSessionOptions) (*networkersdk.PortForwardSession, error) {
48+
return s.Ctrl.StartResourcePortForwardingSession(pluginID, connectionID, opts)
49+
}
50+
func (s *ServiceWrapper) ClosePortForwardSession(sessionID string) (*networkersdk.PortForwardSession, error) {
51+
return s.Ctrl.ClosePortForwardSession(sessionID)
52+
}
53+
func (s *ServiceWrapper) ListPlugins() ([]string, error) {
54+
return s.Ctrl.ListPlugins()
55+
}
56+
func (s *ServiceWrapper) HasPlugin(pluginID string) bool {
57+
return s.Ctrl.HasPlugin(pluginID)
58+
}

0 commit comments

Comments
 (0)