summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/tui/tui.go36
1 files changed, 2 insertions, 34 deletions
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 19125210d..0bda5facb 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -270,27 +270,19 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case *client.EventStorageWrite:
slog.Debug("Received SSE event", "key", msg.Key)
- // Create a deep copy of the state to avoid mutation issues
- newState := deepCopyState(a.app.State)
-
- // Split the key and traverse/create the nested structure
splits := strings.Split(msg.Key, "/")
- current := newState
+ current := a.app.State
for i, part := range splits {
if i == len(splits)-1 {
- // Last part - set the value
current[part] = msg.Content
} else {
- // Intermediate parts - ensure map exists
if _, exists := current[part]; !exists {
current[part] = make(map[string]any)
}
- // Navigate to the next level
nextLevel, ok := current[part].(map[string]any)
if !ok {
- // If it's not a map, replace it with a new map
current[part] = make(map[string]any)
nextLevel = current[part].(map[string]any)
}
@@ -298,11 +290,8 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
- // Update the app state
- a.app.State = newState
-
// Trigger UI update by updating all pages with the new state
- return a.updateAllPages(state.StateUpdatedMsg{State: newState})
+ return a.updateAllPages(state.StateUpdatedMsg{State: a.app.State})
case dialog.CloseQuitMsg:
a.showQuit = false
@@ -948,27 +937,6 @@ func (a appModel) View() string {
return appView
}
-// deepCopyState creates a deep copy of a map[string]any
-func deepCopyState(src map[string]any) map[string]any {
- if src == nil {
- return nil
- }
-
- dst := make(map[string]any, len(src))
- for k, v := range src {
- switch val := v.(type) {
- case map[string]any:
- // Recursively copy nested maps
- dst[k] = deepCopyState(val)
- default:
- // For other types, just copy the value
- // Note: This is still a shallow copy for slices/arrays
- dst[k] = v
- }
- }
- return dst
-}
-
func New(app *app.App) tea.Model {
startPage := page.ChatPage
model := &appModel{