fix: refresh expanded tasks from fresh snapshot#298
Merged
Conversation
refreshExpandedTasksCmd was reading tasks from a stale cached snapshot because it ran concurrently with checkServicesCmd, which only triggered an async (non-blocking) refresh. Replace the tea.Batch of per-service closures with a single tea.Cmd that calls GetOrRefreshSnapshot() once before fetching tasks, guaranteeing fresh data. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
mosonyi
requested changes
Mar 18, 2026
Collaborator
mosonyi
left a comment
There was a problem hiding this comment.
I did a manual test.
What I have changed:
- I wanted to do a rolling update to a version that does not exist.
- I pressed 'p' to see if it tried to coninuously download -> OK
- Pressed 'l' to see the logs -> OK
- Pressed ESC to go back
- The processes are not updating anymore automatically -> NOT OK!
- When I press 'p' 2 times, it updates for that particular moment, but no continuous updates anymore.
OnEnter() returned nil, so after navigating to logs and back the 2s polling ticker was never restarted — tasks stopped auto-refreshing. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
mosonyi
approved these changes
Mar 18, 2026
Collaborator
mosonyi
left a comment
There was a problem hiding this comment.
The manual test worked!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #284 — tasks in the services view now refresh on the fly while expanded.
Root cause
refreshExpandedTasksCmdandcheckServicesCmdare dispatched concurrently from theTickMsghandler (every 2s).checkServicesCmdcallsTriggerRefreshIfNeeded()which starts an async (non-blocking) background goroutine to refresh the snapshot. Meanwhile,refreshExpandedTasksCmdcallsGetTasksForService()→GetSnapshot()which returns the stale cached snapshot — the background refresh hasn't completed yet. On the next tick, the snapshot TTL (3s) often hasn't expired, so no new refresh is triggered. The result: tasks are perpetually read from stale data.Collapsing and re-expanding works because the manual toggle happens at a different point in the refresh cycle — typically after the background refresh has completed — so
GetSnapshot()returns fresh data.Fix
Replace the
tea.Batchof per-service closures with a singletea.Cmdthat callsGetOrRefreshSnapshot()(blocking, synchronous) before fetching tasks. This guarantees the global snapshot cache is fresh whenGetTasksForService()reads from it. The blocking call runs in a goroutine (tea.Cmd), so it does not freeze the UI. When the snapshot is already fresh (within 3s TTL),GetOrRefreshSnapshot()returns instantly from cache.Flow after fix
Test plan
go test ./views/services/...)golangci-lint run ./...)p, scale/restart it, verify tasks update without collapsing🤖 Generated with Claude Code