The open source coding agent.
TypeScript
wip: refactoring tui
adamdottvd70201cd9365
diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex 19125210d5c..0bda5facbf3 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 structuresplits := strings.Split(msg.Key, "/")- current := newState+ current := a.app.Statefor i, part := range splits {if i == len(splits)-1 {- // Last part - set the valuecurrent[part] = msg.Content} else {- // Intermediate parts - ensure map existsif _, exists := current[part]; !exists {current[part] = make(map[string]any)}- // Navigate to the next levelnextLevel, ok := current[part].(map[string]any)if !ok {- // If it's not a map, replace it with a new mapcurrent[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.ChatPagemodel := &appModel{