feat(gui): gpt-5.4-mini/mature pass 3

Constraint:

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-04-18 08:42:23 +01:00
parent 6a4edb0090
commit 12ad42555c
5 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1 @@
- @bug pkg/window/state.go:26 — window state persistence writes to the default home config path, which breaks restricted test/runtime environments unless the target path is configurable.

View file

@ -143,10 +143,16 @@ type WindowEventContext struct {
}
func (c *WindowEventContext) DroppedFiles() []string {
if c == nil {
return nil
}
return append([]string(nil), c.droppedFiles...)
}
func (c *WindowEventContext) DropTargetDetails() *DropTargetDetails {
if c == nil {
return nil
}
if c.dropDetails == nil {
return nil
}
@ -165,6 +171,9 @@ type WindowEvent struct {
}
func (e *WindowEvent) Context() *WindowEventContext {
if e == nil {
return nil
}
if e.ctx == nil {
e.ctx = &WindowEventContext{}
}

View file

@ -249,6 +249,19 @@ func TestApplication_WindowEvent_Ugly(t *testing.T) {
assert.Equal(t, []string{"file"}, event.Context().DroppedFiles())
}
func TestApplication_WindowEvent_NilReceiver(t *testing.T) {
var event *WindowEvent
assert.Nil(t, event.Context())
}
func TestApplication_WindowEventContext_NilReceiver(t *testing.T) {
var ctx *WindowEventContext
assert.Empty(t, ctx.DroppedFiles())
assert.Nil(t, ctx.DropTargetDetails())
}
func TestApplication_WebviewWindow_Good(t *testing.T) {
manager := &WindowManager{}
window := manager.NewWithOptions(WebviewWindowOptions{

View file

@ -45,6 +45,9 @@ func (e *ApplicationEvent) Context() *ApplicationEventContext {
//
// event.Cancel()
func (e *ApplicationEvent) Cancel() {
if e == nil {
return
}
e.cancelled.Store(true)
}
@ -52,6 +55,9 @@ func (e *ApplicationEvent) Cancel() {
//
// if event.IsCancelled() { return }
func (e *ApplicationEvent) IsCancelled() bool {
if e == nil {
return false
}
return e.cancelled.Load()
}
@ -69,6 +75,9 @@ type CustomEvent struct {
//
// event.Cancel()
func (e *CustomEvent) Cancel() {
if e == nil {
return
}
e.cancelled.Store(true)
}
@ -76,6 +85,9 @@ func (e *CustomEvent) Cancel() {
//
// if event.IsCancelled() { return }
func (e *CustomEvent) IsCancelled() bool {
if e == nil {
return false
}
return e.cancelled.Load()
}

View file

@ -35,6 +35,15 @@ func TestEvents_CustomEvent_Ugly(t *testing.T) {
assert.Equal(t, []any{"a", 1}, event.Data)
}
func TestEvents_CustomEvent_NilReceiver(t *testing.T) {
var event *CustomEvent
assert.NotPanics(t, func() {
event.Cancel()
})
assert.False(t, event.IsCancelled())
}
func TestEvents_ApplicationEvent_Good(t *testing.T) {
event := &ApplicationEvent{Id: 7, ctx: newApplicationEventContext()}
@ -60,6 +69,15 @@ func TestEvents_ApplicationEvent_Ugly(t *testing.T) {
assert.True(t, event.IsCancelled())
}
func TestEvents_ApplicationEvent_NilReceiver(t *testing.T) {
var event *ApplicationEvent
assert.NotPanics(t, func() {
event.Cancel()
})
assert.False(t, event.IsCancelled())
}
func TestEvents_EventManager_Emit_Good(t *testing.T) {
manager := newEventManager()
calls := 0