Skip to content

Commit 51a01a3

Browse files
cpcloudclaude
andcommitted
fix(insights): add timeout, fix refresh cancel, schedule stale tick
- fetchInsights now uses context.WithTimeout with the configured LLM inference timeout instead of a bare cancel-only context. - refreshInsights explicitly cancels in-flight requests and clears the loading flag before calling maybeStartInsights, so pressing r during a fetch actually restarts it. - maybeStartInsights schedules insightsStaleTick when reusing cached results so the "x ago" indicator keeps updating on dashboard reopen. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 123b4ee commit 51a01a3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

internal/app/dashboard.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,10 +1023,11 @@ func (m *Model) fetchInsights() tea.Cmd {
10231023
store := m.store
10241024
extraContext := m.llmExtraContext
10251025
gen := m.dash.insights.generation
1026+
timeout := m.chatInferenceTimeout()
10261027

10271028
//nolint:gosec // cancel stored in m.dash.insights.cancel
1028-
ctx, cancel := context.WithCancel(
1029-
context.Background(),
1029+
ctx, cancel := context.WithTimeout(
1030+
context.Background(), timeout,
10301031
)
10311032
m.dash.insights.cancel = cancel
10321033

@@ -1083,6 +1084,8 @@ func (m *Model) fetchInsights() tea.Cmd {
10831084

10841085
// refreshInsights cancels any in-flight request and starts a fresh fetch.
10851086
func (m *Model) refreshInsights() tea.Cmd {
1087+
m.cancelInsights()
1088+
m.dash.insights.loading = false
10861089
m.dash.insights.stale = true
10871090
return m.maybeStartInsights()
10881091
}
@@ -1096,9 +1099,9 @@ func (m *Model) maybeStartInsights() tea.Cmd {
10961099
if m.dash.insights.loading {
10971100
return nil
10981101
}
1099-
// Already have fresh results.
1102+
// Already have fresh results — just keep the staleness tick running.
11001103
if len(m.dash.insights.items) > 0 && !m.dash.insights.stale {
1101-
return nil
1104+
return insightsStaleTick()
11021105
}
11031106
return tea.Batch(m.fetchInsights(), m.dash.spinner.Tick)
11041107
}

0 commit comments

Comments
 (0)