Codex application override added.
This commit is contained in:
1 parent
b887f6ea95
commit
7c53cb39d4
23 files changed
+1771
-155
No files matched your search
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/applicationoverrides/codex"
|
||||
)
|
||||
|
||||
func (a *application) codex_event(text string) string {
|
||||
kind, payload, _ := strings.Cut(text, " ")
|
||||
if kind != "CODEX" {
|
||||
return "Unsupported application event"
|
||||
}
|
||||
var event codex.Event
|
||||
if err := json.Unmarshal([]byte(payload), &event); err != nil {
|
||||
return "Invalid Codex event JSON"
|
||||
}
|
||||
if a.options.TerminalMode {
|
||||
if event.Window == "" || event.Window != os.Getenv("WINDOWID") || event.Terminal != 1 {
|
||||
return "Codex event belongs to another terminal"
|
||||
}
|
||||
} else if event.Window != "" || event.Terminal != a.lastTerminal {
|
||||
return "Codex event belongs to another terminal"
|
||||
}
|
||||
selected := a.overrides[event.Terminal]
|
||||
if selected == nil || selected.id != "codex" {
|
||||
return "Codex override is not selected"
|
||||
}
|
||||
if !selected.initialized || a.overrideTransition {
|
||||
a.overrideDirty = true
|
||||
return "Codex override is loading"
|
||||
}
|
||||
adapter, ok := selected.adapter.(*codex.Adapter)
|
||||
if !ok {
|
||||
return "Codex override is unavailable"
|
||||
}
|
||||
if err := adapter.Accept(event); err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
a.overrideDirty = true
|
||||
return ""
|
||||
}
|
||||
Reference in new issue
Block a user