refactor(coding-agent): derive scoped heartbeats at render time - #1749
Closed
snimu wants to merge 8 commits into
Closed
refactor(coding-agent): derive scoped heartbeats at render time#1749snimu wants to merge 8 commits into
snimu wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 972c96b. Configure here.
This was referenced Aug 27, 2026
Contributor
Author
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.

What was wrong
The TUI stored a scoped
heartbeatslist — a projection of the heartbeat catalog x connection state x subagent snapshots — kept aligned byupdateScopedHeartbeats()calls scattered across unrelated code paths. A missed call site meant stale heartbeat counts or manager rows (audit: dup-truth.md finding 5; TUI-side sibling of #1743).The fix
The stored projection, its updater, and
setHeartbeats()are deleted. The tray label, refresh scheduler, and heartbeat manager derive the scoped list from the three sources at use/render time; the manager holds only selection state by heartbeat ID (re-anchoring gracefully when the selected entry disappears). Production code is net deletion; stale test stubs of the deleted method removed.How it's verified
Reviewer accounted for all 4 former sync call sites, bounded the per-render derivation cost (tiny, overlay-scoped), traced selection survival through catalog refreshes, and confirmed the getter wiring holds no leak. Focused suites 190/190; full CI-style failing set exactly matches the stack base. Two-model implement/review loop.
Stacked on #1748 (test the whole stack at the leaf; merge base-first).
Note: intentionally no Linear ticket for this cleanup stack, so that check stays red.
Note
Low Risk
TUI-only refactor that removes duplicate state; behavior should improve when scope changes, with no security or persistence impact.
Overview
Removes the cached scoped
heartbeatslist andupdateScopedHeartbeats()sync calls from interactive mode. The tray label, refresh scheduler, and heartbeat manager now callgetScopedHeartbeats()(catalog × connection state × subagent snapshots) when they need the list.HeartbeatManagerComponentno longer takes a static array orsetHeartbeats. It receives agetHeartbeatscallback and reads the current scoped set on each render. List selection is tracked by heartbeat id instead of array index, with render-time re-anchoring when entries disappear or reorder.Connection state and subagent updates schedule a manager refresh instead of pushing an updated list. Tests cover live list updates on render and the new scoping path.
Reviewed by Cursor Bugbot for commit e953a58. Bugbot is set up for automated code reviews on this repo. Configure here.
Linear ticket: ENG-5665
(ticket linked above)
Note
Derive scoped heartbeats at render time in
HeartbeatManagerComponentHeartbeatManagerComponentwith agetHeartbeatscallback that pulls the current scoped set on each render.InteractiveMode.getScopedHeartbeatsas the single source of truth for heartbeat scoping; removes the cachedthis.heartbeatsarray and theupdateScopedHeartbeatsmethod.HeartbeatManagerComponentwith an initial heartbeats array or calledsetHeartbeatsmust migrate to thegetHeartbeatscallback — the old constructor signature andsetHeartbeatsmethod are removed.Macroscope summarized e953a58.