diff options
| author | adamdottv <[email protected]> | 2025-05-29 15:30:39 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-29 15:30:39 -0500 |
| commit | 913b3434d8243cc9681a3bf7520e7b027ec3853b (patch) | |
| tree | e1a16ff571053aafec5b0a93f1b7ab85694357f2 /internal/tui/components | |
| parent | 1c01ee48340c524af9223fac43f21d3a545e4583 (diff) | |
| download | opencode-913b3434d8243cc9681a3bf7520e7b027ec3853b.tar.gz opencode-913b3434d8243cc9681a3bf7520e7b027ec3853b.zip | |
wip: refactoring tui
Diffstat (limited to 'internal/tui/components')
| -rw-r--r-- | internal/tui/components/chat/editor.go | 13 | ||||
| -rw-r--r-- | internal/tui/components/chat/messages.go | 9 | ||||
| -rw-r--r-- | internal/tui/components/chat/sidebar.go | 76 | ||||
| -rw-r--r-- | internal/tui/components/dialog/session.go | 18 |
4 files changed, 15 insertions, 101 deletions
diff --git a/internal/tui/components/chat/editor.go b/internal/tui/components/chat/editor.go index 17fb82c20..c3b06787e 100644 --- a/internal/tui/components/chat/editor.go +++ b/internal/tui/components/chat/editor.go @@ -143,11 +143,6 @@ func (m *editorCmp) Init() tea.Cmd { } func (m *editorCmp) send() tea.Cmd { - if m.app.PrimaryAgentOLD.IsSessionBusy(m.app.CurrentSessionOLD.ID) { - status.Warn("Agent is working, please wait...") - return nil - } - value := m.textarea.Value() m.textarea.Reset() attachments := m.attachments @@ -217,10 +212,10 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } if key.Matches(msg, editorMaps.OpenEditor) { - if m.app.PrimaryAgentOLD.IsSessionBusy(m.app.CurrentSessionOLD.ID) { - status.Warn("Agent is working, please wait...") - return m, nil - } + // if m.app.PrimaryAgentOLD.IsSessionBusy(m.app.CurrentSessionOLD.ID) { + // status.Warn("Agent is working, please wait...") + // return m, nil + // } value := m.textarea.Value() m.textarea.Reset() return m, m.openEditor(value) diff --git a/internal/tui/components/chat/messages.go b/internal/tui/components/chat/messages.go index 196d774cb..92e6ec471 100644 --- a/internal/tui/components/chat/messages.go +++ b/internal/tui/components/chat/messages.go @@ -10,7 +10,6 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "github.com/sst/opencode/internal/message" - "github.com/sst/opencode/internal/session" "github.com/sst/opencode/internal/tui/app" "github.com/sst/opencode/internal/tui/components/dialog" "github.com/sst/opencode/internal/tui/state" @@ -72,7 +71,7 @@ func (m *messagesCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.renderView() return m, nil case state.SessionSelectedMsg: - cmd := m.Reload(msg) + cmd := m.Reload() return m, cmd case state.SessionClearedMsg: m.rendering = false @@ -98,10 +97,6 @@ func (m *messagesCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Batch(cmds...) } -func (m *messagesCmp) IsAgentWorking() bool { - return m.app.PrimaryAgentOLD.IsSessionBusy(m.app.CurrentSessionOLD.ID) -} - func (m *messagesCmp) renderView() { if m.width == 0 { return @@ -313,7 +308,7 @@ func (m *messagesCmp) GetSize() (int, int) { return m.width, m.height } -func (m *messagesCmp) Reload(session *session.Session) tea.Cmd { +func (m *messagesCmp) Reload() tea.Cmd { m.rendering = true return func() tea.Msg { m.renderView() diff --git a/internal/tui/components/chat/sidebar.go b/internal/tui/components/chat/sidebar.go index 1f038a9b0..4a85784fc 100644 --- a/internal/tui/components/chat/sidebar.go +++ b/internal/tui/components/chat/sidebar.go @@ -1,7 +1,6 @@ package chat import ( - "context" "fmt" "sort" "strings" @@ -205,81 +204,6 @@ func NewSidebarCmp(app *app.App) tea.Model { } } -func (m *sidebarCmp) loadModifiedFiles(ctx context.Context) { - if m.app.CurrentSessionOLD.ID == "" { - return - } - - // TODO: History service not implemented in API yet - return - /* - // Get all latest files for this session - latestFiles, err := m.app.History.ListLatestSessionFiles(ctx, m.app.CurrentSession.ID) - if err != nil { - return - } - - // Get all files for this session (to find initial versions) - allFiles, err := m.app.History.ListBySession(ctx, m.app.CurrentSession.ID) - if err != nil { - return - } - */ - - // Clear the existing map to rebuild it - m.modFiles = make(map[string]struct { - additions int - removals int - }) - - /* - // Process each latest file - for _, file := range latestFiles { - // Skip if this is the initial version (no changes to show) - if file.Version == history.InitialVersion { - continue - } - - // Find the initial version for this specific file - var initialVersion history.File - for _, v := range allFiles { - if v.Path == file.Path && v.Version == history.InitialVersion { - initialVersion = v - break - } - } - - // Skip if we can't find the initial version - if initialVersion.ID == "" { - continue - } - if initialVersion.Content == file.Content { - continue - } - - // Calculate diff between initial and latest version - _, additions, removals := diff.GenerateDiff(initialVersion.Content, file.Content, file.Path) - - // Only add to modified files if there are changes - if additions > 0 || removals > 0 { - // Remove working directory prefix from file path - displayPath := file.Path - workingDir := config.WorkingDirectory() - displayPath = strings.TrimPrefix(displayPath, workingDir) - displayPath = strings.TrimPrefix(displayPath, "/") - - m.modFiles[displayPath] = struct { - additions int - removals int - }{ - additions: additions, - removals: removals, - } - } - } - */ -} - // Helper function to get the display path for a file func getDisplayPath(path string) string { workingDir := config.WorkingDirectory() diff --git a/internal/tui/components/dialog/session.go b/internal/tui/components/dialog/session.go index 0ec828266..fd08a7db5 100644 --- a/internal/tui/components/dialog/session.go +++ b/internal/tui/components/dialog/session.go @@ -4,28 +4,28 @@ import ( "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/sst/opencode/internal/session" "github.com/sst/opencode/internal/tui/layout" "github.com/sst/opencode/internal/tui/styles" "github.com/sst/opencode/internal/tui/theme" "github.com/sst/opencode/internal/tui/util" + "github.com/sst/opencode/pkg/client" ) // CloseSessionDialogMsg is sent when the session dialog is closed type CloseSessionDialogMsg struct { - Session *session.Session + Session *client.SessionInfo } // SessionDialog interface for the session switching dialog type SessionDialog interface { tea.Model layout.Bindings - SetSessions(sessions []session.Session) + SetSessions(sessions []client.SessionInfo) SetSelectedSession(sessionID string) } type sessionDialogCmp struct { - sessions []session.Session + sessions []client.SessionInfo selectedIdx int width int height int @@ -89,7 +89,7 @@ func (s *sessionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, sessionKeys.Enter): if len(s.sessions) > 0 { selectedSession := s.sessions[s.selectedIdx] - s.selectedSessionID = selectedSession.ID + s.selectedSessionID = selectedSession.Id return s, util.CmdHandler(CloseSessionDialogMsg{ Session: &selectedSession, @@ -189,13 +189,13 @@ func (s *sessionDialogCmp) BindingKeys() []key.Binding { return layout.KeyMapToSlice(sessionKeys) } -func (s *sessionDialogCmp) SetSessions(sessions []session.Session) { +func (s *sessionDialogCmp) SetSessions(sessions []client.SessionInfo) { s.sessions = sessions // If we have a selected session ID, find its index if s.selectedSessionID != "" { for i, sess := range sessions { - if sess.ID == s.selectedSessionID { + if sess.Id == s.selectedSessionID { s.selectedIdx = i return } @@ -212,7 +212,7 @@ func (s *sessionDialogCmp) SetSelectedSession(sessionID string) { // Update the selected index if sessions are already loaded if len(s.sessions) > 0 { for i, sess := range s.sessions { - if sess.ID == sessionID { + if sess.Id == sessionID { s.selectedIdx = i return } @@ -223,7 +223,7 @@ func (s *sessionDialogCmp) SetSelectedSession(sessionID string) { // NewSessionDialogCmp creates a new session switching dialog func NewSessionDialogCmp() SessionDialog { return &sessionDialogCmp{ - sessions: []session.Session{}, + sessions: []client.SessionInfo{}, selectedIdx: 0, selectedSessionID: "", } |
