From 913b3434d8243cc9681a3bf7520e7b027ec3853b Mon Sep 17 00:00:00 2001 From: adamdottv <2363879+adamdottv@users.noreply.github.com> Date: Thu, 29 May 2025 15:30:39 -0500 Subject: wip: refactoring tui --- internal/tui/components/chat/editor.go | 13 ++---- internal/tui/components/chat/messages.go | 9 +--- internal/tui/components/chat/sidebar.go | 76 -------------------------------- 3 files changed, 6 insertions(+), 92 deletions(-) (limited to 'internal/tui/components/chat') 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() -- cgit v1.2.3