diff options
| author | adamdottv <[email protected]> | 2025-05-29 14:39:37 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-29 14:39:37 -0500 |
| commit | 50ba0b380bbbd5b78c1399f15c6b785c223fc620 (patch) | |
| tree | 7857e485fe46fb97625d464a1f59dd08d5107e60 /internal | |
| parent | 6cccbdccd3139c9d548d3794e88d1f7065def7d4 (diff) | |
| download | opencode-50ba0b380bbbd5b78c1399f15c6b785c223fc620.tar.gz opencode-50ba0b380bbbd5b78c1399f15c6b785c223fc620.zip | |
wip: refactoring tui
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/tui/tui.go | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 885736ddc..ed207b704 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -16,7 +16,6 @@ import ( "github.com/sst/opencode/internal/message" "github.com/sst/opencode/internal/permission" "github.com/sst/opencode/internal/pubsub" - "github.com/sst/opencode/internal/session" "github.com/sst/opencode/internal/status" "github.com/sst/opencode/internal/tui/components/chat" "github.com/sst/opencode/internal/tui/components/core" @@ -194,6 +193,26 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case spinner.TickMsg: return a.updateAllPages(msg) + case client.EventSessionUpdated: + if msg.Properties.Info.Id == a.app.Session.Id { + a.app.Session = &msg.Properties.Info + return a.updateAllPages(state.StateUpdatedMsg{State: nil}) + } + + case client.EventMessageUpdated: + if msg.Properties.Info.Metadata.SessionID == a.app.Session.Id { + for i, m := range a.app.Messages { + if m.Id == msg.Properties.Info.Id { + a.app.Messages[i] = msg.Properties.Info + slog.Debug("Updated message", "message", msg.Properties.Info) + return a.updateAllPages(state.StateUpdatedMsg{State: nil}) + } + } + a.app.Messages = append(a.app.Messages, msg.Properties.Info) + slog.Debug("Appended message", "message", msg.Properties.Info) + return a.updateAllPages(state.StateUpdatedMsg{State: nil}) + } + case tea.WindowSizeMsg: msg.Height -= 2 // Make space for the status bar a.width, a.height = msg.Width, msg.Height @@ -259,34 +278,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { a.app.CurrentSessionOLD = msg return a.updateAllPages(msg) - case pubsub.Event[session.Session]: - if msg.Type == session.EventSessionUpdated { - if a.app.CurrentSessionOLD.ID == msg.Payload.ID { - a.app.CurrentSessionOLD = &msg.Payload - } - } - - case client.EventMessageUpdated: - if msg.Properties.Info.Metadata.SessionID == a.app.Session.Id { - for i, m := range a.app.Messages { - if m.Id == msg.Properties.Info.Id { - a.app.Messages[i] = msg.Properties.Info - slog.Debug("Updated message", "message", msg.Properties.Info) - return a.updateAllPages(state.StateUpdatedMsg{State: nil}) - } - } - - a.app.Messages = append(a.app.Messages, msg.Properties.Info) - slog.Debug("Appended message", "message", msg.Properties.Info) - return a.updateAllPages(state.StateUpdatedMsg{State: nil}) - } - - case client.EventSessionUpdated: - if msg.Properties.Info.Id == a.app.Session.Id { - a.app.Session = &msg.Properties.Info - return a.updateAllPages(state.StateUpdatedMsg{State: nil}) - } - case dialog.CloseQuitMsg: a.showQuit = false return a, nil |
