Skip to content

Commit dd5729f

Browse files
authored
Merge pull request #2 from dAppCore/dev
Dev
2 parents d974977 + 031c286 commit dd5729f

90 files changed

Lines changed: 7840 additions & 721 deletions

Some content is hidden

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

docs/framework/mcp-bridge.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Response:
7373
| `window_maximize` | Maximize window |
7474
| `window_minimize` | Minimize window |
7575
| `window_focus` | Bring window to front |
76+
| `window_title_set` | Alias for `window_title` |
7677

7778
### WebView Interaction
7879

@@ -84,6 +85,7 @@ Response:
8485
| `webview_screenshot` | Capture page |
8586
| `webview_navigate` | Navigate to URL |
8687
| `webview_console` | Get console messages |
88+
| `webview_errors` | Get structured JavaScript errors |
8789

8890
### Screen Management
8991

@@ -93,6 +95,8 @@ Response:
9395
| `screen_primary` | Get primary screen |
9496
| `screen_at_point` | Get screen at coordinates |
9597
| `screen_work_areas` | Get usable screen space |
98+
| `screen_work_area` | Alias for `screen_work_areas` |
99+
| `screen_for_window` | Get the screen containing a window |
96100

97101
### Layout Management
98102

docs/ref/wails-v3/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/wailsapp/wails/v3
2+
3+
go 1.24
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
placeholder

go.mod

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,71 +7,35 @@ require (
77
forge.lthn.ai/core/go v0.3.3
88
forge.lthn.ai/core/go-webview v0.1.7
99
github.com/gorilla/websocket v1.5.3
10-
github.com/leaanthony/u v1.1.1
1110
github.com/modelcontextprotocol/go-sdk v1.4.1
12-
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
1311
github.com/stretchr/testify v1.11.1
1412
github.com/wailsapp/wails/v3 v3.0.0-alpha.74
1513
)
1614

15+
replace github.com/wailsapp/wails/v3 => ./stubs/wails/v3
16+
1717
require (
18-
dario.cat/mergo v1.0.2 // indirect
1918
forge.lthn.ai/core/go-io v0.1.7 // indirect
2019
forge.lthn.ai/core/go-log v0.0.4 // indirect
21-
github.com/Microsoft/go-winio v0.6.2 // indirect
22-
github.com/ProtonMail/go-crypto v1.4.0 // indirect
23-
github.com/adrg/xdg v0.5.3 // indirect
24-
github.com/bep/debounce v1.2.1 // indirect
25-
github.com/cloudflare/circl v1.6.3 // indirect
26-
github.com/coder/websocket v1.8.14 // indirect
27-
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
2820
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
29-
github.com/ebitengine/purego v0.10.0 // indirect
30-
github.com/emirpasic/gods v1.18.1 // indirect
3121
github.com/fsnotify/fsnotify v1.9.0 // indirect
32-
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
33-
github.com/go-git/go-billy/v5 v5.8.0 // indirect
34-
github.com/go-git/go-git/v5 v5.17.0 // indirect
35-
github.com/go-ole/go-ole v1.3.0 // indirect
3622
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
37-
github.com/godbus/dbus/v5 v5.2.2 // indirect
3823
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
39-
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
4024
github.com/google/jsonschema-go v0.4.2 // indirect
41-
github.com/google/uuid v1.6.0 // indirect
42-
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
43-
github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1 // indirect
44-
github.com/kevinburke/ssh_config v1.6.0 // indirect
45-
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
46-
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
47-
github.com/lmittmann/tint v1.1.3 // indirect
48-
github.com/mattn/go-colorable v0.1.14 // indirect
49-
github.com/mattn/go-isatty v0.0.20 // indirect
5025
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
51-
github.com/pjbgf/sha1cd v0.5.0 // indirect
5226
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
53-
github.com/rivo/uniseg v0.4.7 // indirect
5427
github.com/sagikazarmark/locafero v0.12.0 // indirect
55-
github.com/samber/lo v1.53.0 // indirect
5628
github.com/segmentio/asm v1.2.1 // indirect
5729
github.com/segmentio/encoding v0.5.4 // indirect
58-
github.com/sergi/go-diff v1.4.0 // indirect
59-
github.com/skeema/knownhosts v1.3.2 // indirect
6030
github.com/spf13/afero v1.15.0 // indirect
6131
github.com/spf13/cast v1.10.0 // indirect
6232
github.com/spf13/pflag v1.0.10 // indirect
6333
github.com/spf13/viper v1.21.0 // indirect
6434
github.com/subosito/gotenv v1.6.0 // indirect
65-
github.com/wailsapp/go-webview2 v1.0.23 // indirect
66-
github.com/xanzy/ssh-agent v0.3.3 // indirect
6735
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
6836
go.yaml.in/yaml/v3 v3.0.4 // indirect
69-
golang.org/x/crypto v0.49.0 // indirect
70-
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 // indirect
71-
golang.org/x/net v0.52.0 // indirect
7237
golang.org/x/oauth2 v0.36.0 // indirect
7338
golang.org/x/sys v0.42.0 // indirect
7439
golang.org/x/text v0.35.0 // indirect
75-
gopkg.in/warnings.v0 v0.1.2 // indirect
7640
gopkg.in/yaml.v3 v3.0.1 // indirect
7741
)

go.sum

Lines changed: 25 additions & 123 deletions
Large diffs are not rendered by default.

pkg/clipboard/messages.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,16 @@ type TaskSetText struct{ Text string }
99

1010
// TaskClear clears the clipboard. Result: bool (success)
1111
type TaskClear struct{}
12+
13+
// QueryImage reads an image from the clipboard. Result: ClipboardImageContent
14+
type QueryImage struct{}
15+
16+
// TaskSetImage writes image bytes to the clipboard. Result: bool (success)
17+
type TaskSetImage struct{ Data []byte }
18+
19+
// ClipboardImageContent contains clipboard image data encoded for transport.
20+
type ClipboardImageContent struct {
21+
Base64 string `json:"base64"`
22+
MimeType string `json:"mimeType"`
23+
HasContent bool `json:"hasContent"`
24+
}

pkg/clipboard/platform.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// pkg/clipboard/platform.go
22
package clipboard
33

4+
import "encoding/base64"
5+
46
// Platform abstracts the system clipboard backend.
57
type Platform interface {
68
Text() (string, bool)
@@ -12,3 +14,22 @@ type ClipboardContent struct {
1214
Text string `json:"text"`
1315
HasContent bool `json:"hasContent"`
1416
}
17+
18+
// imageReader is an optional clipboard capability for image reads.
19+
type imageReader interface {
20+
Image() ([]byte, bool)
21+
}
22+
23+
// imageWriter is an optional clipboard capability for image writes.
24+
type imageWriter interface {
25+
SetImage(data []byte) bool
26+
}
27+
28+
// encodeImageContent converts raw bytes to transport-safe clipboard image content.
29+
func encodeImageContent(data []byte) ClipboardImageContent {
30+
return ClipboardImageContent{
31+
Base64: base64.StdEncoding.EncodeToString(data),
32+
MimeType: "image/png",
33+
HasContent: len(data) > 0,
34+
}
35+
}

pkg/clipboard/service.go

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ import (
77
"forge.lthn.ai/core/go/pkg/core"
88
)
99

10-
// Options holds configuration for the clipboard service.
10+
// Options configures the clipboard service.
11+
// Use: core.WithService(clipboard.Register(platform))
1112
type Options struct{}
1213

13-
// Service is a core.Service managing clipboard operations via IPC.
14+
// Service manages clipboard operations via Core queries and tasks.
15+
// Use: svc := &clipboard.Service{}
1416
type Service struct {
1517
*core.ServiceRuntime[Options]
1618
platform Platform
1719
}
1820

19-
// Register creates a factory closure that captures the Platform adapter.
21+
// Register creates a Core service factory for the clipboard backend.
22+
// Use: core.New(core.WithService(clipboard.Register(platform)))
2023
func Register(p Platform) func(*core.Core) (any, error) {
2124
return func(c *core.Core) (any, error) {
2225
return &Service{
@@ -26,14 +29,15 @@ func Register(p Platform) func(*core.Core) (any, error) {
2629
}
2730
}
2831

29-
// OnStartup registers IPC handlers.
32+
// OnStartup registers clipboard handlers with Core.
33+
// Use: _ = svc.OnStartup(context.Background())
3034
func (s *Service) OnStartup(ctx context.Context) error {
3135
s.Core().RegisterQuery(s.handleQuery)
3236
s.Core().RegisterTask(s.handleTask)
3337
return nil
3438
}
3539

36-
// HandleIPCEvents is auto-discovered by core.WithService.
40+
// HandleIPCEvents satisfies Core's IPC hook.
3741
func (s *Service) HandleIPCEvents(c *core.Core, msg core.Message) error {
3842
return nil
3943
}
@@ -43,6 +47,12 @@ func (s *Service) handleQuery(c *core.Core, q core.Query) (any, bool, error) {
4347
case QueryText:
4448
text, ok := s.platform.Text()
4549
return ClipboardContent{Text: text, HasContent: ok && text != ""}, true, nil
50+
case QueryImage:
51+
if reader, ok := s.platform.(imageReader); ok {
52+
data, _ := reader.Image()
53+
return encodeImageContent(data), true, nil
54+
}
55+
return ClipboardImageContent{MimeType: "image/png"}, true, nil
4656
default:
4757
return nil, false, nil
4858
}
@@ -53,7 +63,17 @@ func (s *Service) handleTask(c *core.Core, t core.Task) (any, bool, error) {
5363
case TaskSetText:
5464
return s.platform.SetText(t.Text), true, nil
5565
case TaskClear:
56-
return s.platform.SetText(""), true, nil
66+
_ = s.platform.SetText("")
67+
if writer, ok := s.platform.(imageWriter); ok {
68+
// Best-effort clear for image-aware clipboard backends.
69+
_ = writer.SetImage(nil)
70+
}
71+
return true, true, nil
72+
case TaskSetImage:
73+
if writer, ok := s.platform.(imageWriter); ok {
74+
return writer.SetImage(t.Data), true, nil
75+
}
76+
return false, true, core.E("clipboard.handleTask", "clipboard image write not supported", nil)
5777
default:
5878
return nil, false, nil
5979
}

pkg/clipboard/service_test.go

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import (
1111
)
1212

1313
type mockPlatform struct {
14-
text string
15-
ok bool
14+
text string
15+
ok bool
16+
img []byte
17+
imgOk bool
1618
}
1719

1820
func (m *mockPlatform) Text() (string, bool) { return m.text, m.ok }
@@ -21,6 +23,12 @@ func (m *mockPlatform) SetText(text string) bool {
2123
m.ok = text != ""
2224
return true
2325
}
26+
func (m *mockPlatform) Image() ([]byte, bool) { return m.img, m.imgOk }
27+
func (m *mockPlatform) SetImage(data []byte) bool {
28+
m.img = data
29+
m.imgOk = len(data) > 0
30+
return true
31+
}
2432

2533
func newTestService(t *testing.T) (*Service, *core.Core) {
2634
t.Helper()
@@ -79,3 +87,34 @@ func TestTaskClear_Good(t *testing.T) {
7987
assert.Equal(t, "", r.(ClipboardContent).Text)
8088
assert.False(t, r.(ClipboardContent).HasContent)
8189
}
90+
91+
func TestQueryImage_Good(t *testing.T) {
92+
mock := &mockPlatform{img: []byte{1, 2, 3}, imgOk: true}
93+
c, err := core.New(
94+
core.WithService(Register(mock)),
95+
core.WithServiceLock(),
96+
)
97+
require.NoError(t, err)
98+
require.NoError(t, c.ServiceStartup(context.Background(), nil))
99+
100+
result, handled, err := c.QUERY(QueryImage{})
101+
require.NoError(t, err)
102+
assert.True(t, handled)
103+
image := result.(ClipboardImageContent)
104+
assert.True(t, image.HasContent)
105+
}
106+
107+
func TestTaskSetImage_Good(t *testing.T) {
108+
mock := &mockPlatform{}
109+
c, err := core.New(
110+
core.WithService(Register(mock)),
111+
core.WithServiceLock(),
112+
)
113+
require.NoError(t, err)
114+
require.NoError(t, c.ServiceStartup(context.Background(), nil))
115+
116+
_, handled, err := c.PERFORM(TaskSetImage{Data: []byte{9, 8, 7}})
117+
require.NoError(t, err)
118+
assert.True(t, handled)
119+
assert.True(t, mock.imgOk)
120+
}

pkg/display/FEATURES.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This document tracks the implementation of display server features that enable A
3131
- [x] `window_title_get` - Get current window title (returns window name)
3232
- [x] `window_always_on_top` - Pin window above others
3333
- [x] `window_background_colour` - Set window background color with alpha (transparency)
34+
- [x] `window_opacity` - Set window opacity
3435
- [x] `window_fullscreen` - Enter/exit fullscreen mode
3536

3637
---
@@ -59,13 +60,13 @@ This document tracks the implementation of display server features that enable A
5960
### Smart Layout
6061
- [x] `layout_tile` - Auto-tile windows (left/right/top/bottom/quadrants/grid)
6162
- [x] `layout_stack` - Stack windows in cascade pattern
62-
- [ ] `layout_beside_editor` - Position window beside detected IDE window
63-
- [ ] `layout_suggest` - Given screen dimensions, suggest optimal arrangement
63+
- [x] `layout_beside_editor` - Position window beside detected IDE window
64+
- [x] `layout_suggest` - Given screen dimensions, suggest optimal arrangement
6465
- [x] `layout_snap` - Snap window to screen edge/corner/center
6566

6667
### AI-Optimized Layout
67-
- [ ] `screen_find_space` - Find empty screen space for new window
68-
- [ ] `window_arrange_pair` - Put two windows side-by-side optimally
68+
- [x] `screen_find_space` - Find empty screen space for new window
69+
- [x] `window_arrange_pair` - Put two windows side-by-side optimally
6970
- [x] `layout_workflow` - Preset layouts: "coding", "debugging", "presenting", "side-by-side"
7071

7172
---
@@ -114,8 +115,8 @@ This document tracks the implementation of display server features that enable A
114115
- [x] `webview_resources` - List loaded resources (scripts, styles, images)
115116

116117
### DevTools
117-
- [ ] `webview_devtools_open` - Open DevTools for window
118-
- [ ] `webview_devtools_close` - Close DevTools
118+
- [x] `webview_devtools_open` - Open DevTools for window
119+
- [x] `webview_devtools_close` - Close DevTools
119120

120121
---
121122

@@ -124,29 +125,29 @@ This document tracks the implementation of display server features that enable A
124125
### Clipboard
125126
- [x] `clipboard_read` - Read clipboard text content
126127
- [x] `clipboard_write` - Write text to clipboard
127-
- [ ] `clipboard_read_image` - Read image from clipboard
128-
- [ ] `clipboard_write_image` - Write image to clipboard
128+
- [x] `clipboard_read_image` - Read image from clipboard
129+
- [x] `clipboard_write_image` - Write image to clipboard
129130
- [x] `clipboard_has` - Check clipboard content type
130131
- [x] `clipboard_clear` - Clear clipboard contents
131132

132133
### Notifications
133134
- [x] `notification_show` - Show native system notification (macOS/Windows/Linux)
134135
- [x] `notification_permission_request` - Request notification permission
135136
- [x] `notification_permission_check` - Check notification authorization status
136-
- [ ] `notification_clear` - Clear notifications
137-
- [ ] `notification_with_actions` - Interactive notifications with buttons
137+
- [x] `notification_clear` - Clear notifications
138+
- [x] `notification_with_actions` - Interactive notifications with buttons
138139

139140
### Dialogs
140141
- [x] `dialog_open_file` - Show file open dialog
141142
- [x] `dialog_save_file` - Show file save dialog
142143
- [x] `dialog_open_directory` - Show directory picker
143144
- [x] `dialog_message` - Show message dialog (info/warning/error) (via notification_show)
144145
- [x] `dialog_confirm` - Show confirmation dialog
145-
- [~] `dialog_prompt` - Show input prompt dialog (not supported natively in Wails v3)
146+
- [x] `dialog_prompt` - Show input prompt dialog with a webview fallback when native support is unavailable
146147

147148
### Theme & Appearance
148149
- [x] `theme_get` - Get current theme (dark/light)
149-
- [ ] `theme_set` - Set application theme
150+
- [x] `theme_set` - Set application theme
150151
- [x] `theme_system` - Get system theme preference
151152
- [x] `theme_on_change` - Subscribe to theme changes (via WebSocket events)
152153

@@ -173,7 +174,7 @@ This document tracks the implementation of display server features that enable A
173174
- [x] `tray_set_label` - Set tray label text
174175
- [x] `tray_set_menu` - Set tray menu items (with nested submenus)
175176
- [x] `tray_info` - Get tray status info
176-
- [ ] `tray_show_message` - Show tray balloon notification
177+
- [x] `tray_show_message` - Show tray balloon notification
177178

178179
---
179180

@@ -235,7 +236,6 @@ This document tracks the implementation of display server features that enable A
235236
- [x] `tray_info` - Get tray status
236237

237238
### Phase 8 - Remaining Features (Future)
238-
- [ ] window_opacity (true opacity if Wails adds support)
239239
- [ ] layout_beside_editor, layout_suggest
240240
- [ ] webview_devtools_open, webview_devtools_close
241241
- [ ] clipboard_read_image, clipboard_write_image

0 commit comments

Comments
 (0)