feat(display): add contextmenu integration and ActionIDECommand to orchestrator

Add HandleIPCEvents cases for contextmenu.ActionItemClicked and
ActionIDECommand, WS->IPC bridge cases for contextmenu:add/remove/get/list,
EventContextMenuClick and EventIDECommand constants.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-03-13 14:52:38 +00:00
parent 94c17b88c2
commit 07bc116abd
3 changed files with 46 additions and 0 deletions

View file

@ -9,7 +9,10 @@ import (
"forge.lthn.ai/core/go-config"
"forge.lthn.ai/core/go/pkg/core"
"encoding/json"
"forge.lthn.ai/core/gui/pkg/browser"
"forge.lthn.ai/core/gui/pkg/contextmenu"
"forge.lthn.ai/core/gui/pkg/dialog"
"forge.lthn.ai/core/gui/pkg/dock"
"forge.lthn.ai/core/gui/pkg/environment"
@ -199,6 +202,20 @@ func (s *Service) HandleIPCEvents(c *core.Core, msg core.Message) error {
if s.events != nil {
s.events.Emit(Event{Type: EventSystemResume})
}
case contextmenu.ActionItemClicked:
if s.events != nil {
s.events.Emit(Event{Type: EventContextMenuClick,
Data: map[string]any{
"menuName": m.MenuName,
"actionId": m.ActionID,
"data": m.Data,
}})
}
case ActionIDECommand:
if s.events != nil {
s.events.Emit(Event{Type: EventIDECommand,
Data: map[string]any{"command": m.Command}})
}
}
return nil
}
@ -246,6 +263,22 @@ func (s *Service) handleWSMessage(msg WSMessage) (any, bool, error) {
result, handled, err = s.Core().PERFORM(dock.TaskRemoveBadge{})
case "dock:visible":
result, handled, err = s.Core().QUERY(dock.QueryVisible{})
case "contextmenu:add":
name, _ := msg.Data["name"].(string)
menuJSON, _ := json.Marshal(msg.Data["menu"])
var menuDef contextmenu.ContextMenuDef
_ = json.Unmarshal(menuJSON, &menuDef)
result, handled, err = s.Core().PERFORM(contextmenu.TaskAdd{
Name: name, Menu: menuDef,
})
case "contextmenu:remove":
name, _ := msg.Data["name"].(string)
result, handled, err = s.Core().PERFORM(contextmenu.TaskRemove{Name: name})
case "contextmenu:get":
name, _ := msg.Data["name"].(string)
result, handled, err = s.Core().QUERY(contextmenu.QueryGet{Name: name})
case "contextmenu:list":
result, handled, err = s.Core().QUERY(contextmenu.QueryList{})
default:
return nil, false, nil
}

View file

@ -37,6 +37,7 @@ const (
EventSystemPowerChange EventType = "system.power-change"
EventSystemSuspend EventType = "system.suspend"
EventSystemResume EventType = "system.resume"
EventContextMenuClick EventType = "contextmenu.item-clicked"
)
// Event represents a display event sent to subscribers.

12
pkg/display/messages.go Normal file
View file

@ -0,0 +1,12 @@
// pkg/display/messages.go
package display
// ActionIDECommand is broadcast when a menu handler triggers an IDE command
// (save, run, build). Replaces direct s.app.Event().Emit("ide:*") calls.
// Listeners (e.g. editor windows) handle this via HandleIPCEvents.
type ActionIDECommand struct {
Command string `json:"command"` // "save", "run", "build"
}
// EventIDECommand is the WS event type for IDE commands.
const EventIDECommand EventType = "ide.command"