summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-06-18 22:59:42 -0400
committerDax Raad <[email protected]>2025-06-18 23:01:19 -0400
commitbd8c3cd0f1e30f5ed1cbf222415cef136edd14a9 (patch)
tree1e630283bb595c6e1f8ce21d83ae8ba99f24e51a /packages/tui/internal
parente5e9b3e3c04df00db57d573d3cc0a029736184b1 (diff)
downloadopencode-bd8c3cd0f1e30f5ed1cbf222415cef136edd14a9.tar.gz
opencode-bd8c3cd0f1e30f5ed1cbf222415cef136edd14a9.zip
BREAKING CONFIG CHANGE
We have changed the config format yet again - but this should be the final time. You can see the readme for more details but the summary is - got rid of global providers config - got rid of global toml - global config is now in `~/.config/opencode/config.json` - it will be merged with any project level config
Diffstat (limited to 'packages/tui/internal')
-rw-r--r--packages/tui/internal/app/app.go13
-rw-r--r--packages/tui/internal/commands/command.go20
-rw-r--r--packages/tui/internal/tui/tui.go4
3 files changed, 21 insertions, 16 deletions
diff --git a/packages/tui/internal/app/app.go b/packages/tui/internal/app/app.go
index eb4bd2dad..72e6ad5eb 100644
--- a/packages/tui/internal/app/app.go
+++ b/packages/tui/internal/app/app.go
@@ -5,6 +5,7 @@ import (
"fmt"
"path/filepath"
"sort"
+ "strings"
"log/slog"
@@ -61,8 +62,10 @@ func New(
}
configInfo := configResponse.JSON200
if configInfo.Keybinds == nil {
- keybinds := make(map[string]string)
- keybinds["leader"] = "ctrl+x"
+ leader := "ctrl+x"
+ keybinds := client.ConfigKeybinds{
+ Leader: &leader,
+ }
configInfo.Keybinds = &keybinds
}
@@ -76,6 +79,12 @@ func New(
if configInfo.Theme != nil {
appState.Theme = *configInfo.Theme
}
+ if configInfo.Model != nil {
+ splits := strings.Split(*configInfo.Model, "/")
+ appState.Provider = splits[0]
+ appState.Model = strings.Join(splits[1:], "/")
+ }
+
if appState.Theme != "" {
theme.SetTheme(appState.Theme)
}
diff --git a/packages/tui/internal/commands/command.go b/packages/tui/internal/commands/command.go
index 6f628ae31..12378c0b2 100644
--- a/packages/tui/internal/commands/command.go
+++ b/packages/tui/internal/commands/command.go
@@ -1,6 +1,7 @@
package commands
import (
+ "encoding/json"
"slices"
"strings"
@@ -106,17 +107,6 @@ func (k Command) Matches(msg tea.KeyPressMsg, leader bool) bool {
return false
}
-func (k Command) FromConfig(config *client.ConfigInfo) Command {
- if config.Keybinds == nil {
- return k
- }
- keybinds := *config.Keybinds
- if keybind, ok := keybinds[string(k.Name)]; ok {
- k.Keybindings = parseBindings(keybind)
- }
- return k
-}
-
func parseBindings(bindings ...string) []Keybinding {
var parsedBindings []Keybinding
for _, binding := range bindings {
@@ -278,8 +268,14 @@ func LoadFromConfig(config *client.ConfigInfo) CommandRegistry {
},
}
registry := make(CommandRegistry)
+ keybinds := map[string]string{}
+ marshalled, _ := json.Marshal(*config.Keybinds)
+ json.Unmarshal(marshalled, &keybinds)
for _, command := range defaults {
- registry[command.Name] = command.FromConfig(config)
+ if keybind, ok := keybinds[string(command.Name)]; ok {
+ command.Keybindings = parseBindings(keybind)
+ }
+ registry[command.Name] = command
}
return registry
}
diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.go
index 5d63a161a..25af7523d 100644
--- a/packages/tui/internal/tui/tui.go
+++ b/packages/tui/internal/tui/tui.go
@@ -509,8 +509,8 @@ func NewModel(app *app.App) tea.Model {
messagesContainer := layout.NewContainer(messages)
var leaderBinding *key.Binding
- if leader, ok := (*app.Configg.Keybinds)["leader"]; ok {
- binding := key.NewBinding(key.WithKeys(leader))
+ if (*app.Configg.Keybinds).Leader != nil {
+ binding := key.NewBinding(key.WithKeys(*app.Configg.Keybinds.Leader))
leaderBinding = &binding
}