diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-09 19:19:45 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-09 19:19:45 +0200 |
| commit | 2af1bbb82852ebebb59ef431e5362c0f3993e5a0 (patch) | |
| tree | cf20e499c14fb4fd6c1e56c99adc35626faead9c /internal/tui/components/core | |
| parent | b12ca55594c4a4c5cc0e81971df719a382f1f344 (diff) | |
| parent | 635324d386d52e117efea6fcbe9dbf306ec75653 (diff) | |
| download | opencode-2af1bbb82852ebebb59ef431e5362c0f3993e5a0.tar.gz opencode-2af1bbb82852ebebb59ef431e5362c0f3993e5a0.zip | |
Merge pull request #25 from kujtimiihoxha/cleanup-logs-status
Cleanup Logs and Status
Diffstat (limited to 'internal/tui/components/core')
| -rw-r--r-- | internal/tui/components/core/status.go | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/internal/tui/components/core/status.go b/internal/tui/components/core/status.go index 83ef07fe3..d2f14ad00 100644 --- a/internal/tui/components/core/status.go +++ b/internal/tui/components/core/status.go @@ -7,7 +7,6 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/kujtimiihoxha/termai/internal/config" "github.com/kujtimiihoxha/termai/internal/llm/models" - "github.com/kujtimiihoxha/termai/internal/pubsub" "github.com/kujtimiihoxha/termai/internal/tui/styles" "github.com/kujtimiihoxha/termai/internal/tui/util" "github.com/kujtimiihoxha/termai/internal/version" @@ -20,8 +19,8 @@ type statusCmp struct { } // clearMessageCmd is a command that clears status messages after a timeout -func (m statusCmp) clearMessageCmd() tea.Cmd { - return tea.Tick(m.messageTTL, func(time.Time) tea.Msg { +func (m statusCmp) clearMessageCmd(ttl time.Duration) tea.Cmd { + return tea.Tick(ttl, func(time.Time) tea.Msg { return util.ClearStatusMsg{} }) } @@ -34,13 +33,14 @@ func (m statusCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: m.width = msg.Width - return m, m.clearMessageCmd() - case pubsub.Event[util.InfoMsg]: - m.info = &msg.Payload - return m, m.clearMessageCmd() + return m, nil case util.InfoMsg: m.info = &msg - return m, m.clearMessageCmd() + ttl := msg.TTL + if ttl == 0 { + ttl = m.messageTTL + } + return m, m.clearMessageCmd(ttl) case util.ClearStatusMsg: m.info = nil } @@ -66,7 +66,13 @@ func (m statusCmp) View() string { case util.InfoTypeError: infoStyle = infoStyle.Background(styles.Red) } - status += infoStyle.Render(m.info.Msg) + // Truncate message if it's longer than available width + msg := m.info.Msg + availWidth := m.availableFooterMsgWidth() - 3 // Account for ellipsis + if len(msg) > availWidth && availWidth > 0 { + msg = msg[:availWidth] + "..." + } + status += infoStyle.Render(msg) } else { status += styles.Padded. Foreground(styles.Base). @@ -91,6 +97,6 @@ func (m statusCmp) model() string { func NewStatusCmp() tea.Model { return &statusCmp{ - messageTTL: 15 * time.Second, + messageTTL: 10 * time.Second, } } |
