Skip to content

Commit fb597cb

Browse files
jrnxfclaude
andcommitted
Lower minimum refresh-interval from 30s to 5s
Upstream rate limiting is the job of the widget's cache duration, not the client refresh interval. A refresh-interval tick that lands inside the cache window simply re-renders existing data — no upstream call. The 30s floor was over-cautious; 5s is enough to prevent a 1s-typo footgun while letting users dial in a tight local-feel cadence on widgets like monitor or server-stats whose cache controls the actual fetch rate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 90b2a5c commit fb597cb

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ cache: 1d # 1 day
741741
> Not all widgets can have their cache duration modified. The calendar and weather widgets update on the hour and this cannot be changed.
742742

743743
#### `refresh-interval`
744-
How often the widget should automatically refresh in the browser without a full page reload. Same syntax as `cache` (a number followed by `s`, `m`, `h`, or `d`). Each tick force-fetches fresh data, bypassing the widget's cache. The minimum allowed interval is 30 seconds.
744+
How often the widget should automatically refresh in the browser without a full page reload. Same syntax as `cache` (a number followed by `s`, `m`, `h`, or `d`). Each tick re-renders the widget; if the widget's cache hasn't expired, the existing data is reused, so a tight refresh interval is safe and won't hammer upstream APIs. Use the manual refresh button to force a fresh fetch. The minimum allowed interval is 5 seconds.
745745

746746
```yaml
747747
refresh-interval: 1m

internal/glance/widget.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ var refreshIntervalDisallowedTypes = map[string]struct{}{
161161
"bookmarks": {},
162162
}
163163

164-
const minRefreshInterval = 30 * time.Second
164+
// minRefreshInterval is a floor against typos (e.g. accidentally writing 1s).
165+
// Upstream rate limiting should be handled by the widget's cache duration,
166+
// not by this floor — refresh-interval ticks below the cache return the same
167+
// data without re-fetching, so a tight client interval is safe by default.
168+
const minRefreshInterval = 5 * time.Second
165169

166170
type cacheType int
167171

internal/glance/widget_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ func TestWidgetValidateRefreshInterval(t *testing.T) {
1414
errContains string
1515
}{
1616
{name: "no interval is allowed on any type", widgetType: "clock", interval: 0},
17-
{name: "valid interval on rss", widgetType: "rss", interval: 30 * time.Second},
17+
{name: "valid interval on rss", widgetType: "rss", interval: 5 * time.Second},
1818
{name: "valid interval on hacker-news", widgetType: "hacker-news", interval: 1 * time.Minute},
19-
{name: "below minimum", widgetType: "rss", interval: 29 * time.Second, errContains: "at least 30s"},
19+
{name: "below minimum", widgetType: "rss", interval: 4 * time.Second, errContains: "at least 5s"},
2020
{name: "disallowed: clock", widgetType: "clock", interval: 1 * time.Minute, errContains: `type "clock"`},
2121
{name: "disallowed: calendar", widgetType: "calendar", interval: 1 * time.Minute, errContains: `type "calendar"`},
2222
{name: "disallowed: to-do", widgetType: "to-do", interval: 1 * time.Minute, errContains: `type "to-do"`},

0 commit comments

Comments
 (0)