feat: add TUI auto-refresh with configurable interval and manual refresh
Introduce background data refresh so the dashboard stays current without restarting. This touches four layers: Config (config.go): - New TUIConfig struct with AutoRefresh (bool) and RefreshIntervalSec (int) fields, defaulting to enabled at 30-second intervals. - Minimum interval floor of 10 seconds enforced at load time. App core (app.go): - RefreshDataMsg type for background refresh completion signaling. - Auto-refresh state: interval timer, refreshing flag, lastRefresh timestamp. Checked on every tick; fires refreshDataCmd when elapsed. - refreshDataCmd: background goroutine that loads session data via cache (with uncached fallback) and posts RefreshDataMsg on completion. - Manual refresh keybind: 'r' triggers immediate refresh. - Auto-refresh toggle keybind: 'R' toggles auto-refresh and persists the preference to config.toml. - Help text updated with r/R keybind documentation. Status bar (statusbar.go): - Shows spinning refresh indicator during active refresh. - Shows auto-refresh icon when auto-refresh is enabled. Settings tab (tab_settings.go): - Two new editable fields: Auto Refresh (bool) and Refresh Interval (seconds with 10s minimum). - Settings display reads live App state to stay consistent with the R toggle keybind (avoids stale config-file reads). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,21 +12,29 @@ import (
|
||||
)
|
||||
|
||||
// RenderStatusBar renders the bottom status bar with optional rate limit indicators.
|
||||
func RenderStatusBar(width int, dataAge string, subData *claudeai.SubscriptionData) string {
|
||||
func RenderStatusBar(width int, dataAge string, subData *claudeai.SubscriptionData, refreshing, autoRefresh bool) string {
|
||||
t := theme.Active
|
||||
|
||||
style := lipgloss.NewStyle().
|
||||
Foreground(t.TextMuted).
|
||||
Width(width)
|
||||
|
||||
left := " [?]help [q]uit"
|
||||
left := " [?]help [r]efresh [q]uit"
|
||||
|
||||
// Build rate limit indicators for the middle section
|
||||
ratePart := renderStatusRateLimits(subData)
|
||||
|
||||
right := ""
|
||||
if dataAge != "" {
|
||||
right = fmt.Sprintf("Data: %s ", dataAge)
|
||||
// Build right side with refresh status
|
||||
var right string
|
||||
if refreshing {
|
||||
refreshStyle := lipgloss.NewStyle().Foreground(t.Accent)
|
||||
right = refreshStyle.Render("↻ refreshing ")
|
||||
} else if dataAge != "" {
|
||||
autoStr := ""
|
||||
if autoRefresh {
|
||||
autoStr = "↻ "
|
||||
}
|
||||
right = fmt.Sprintf("%sData: %s ", autoStr, dataAge)
|
||||
}
|
||||
|
||||
// Layout: left + ratePart + right, with padding distributed
|
||||
|
||||
Reference in New Issue
Block a user