Repository navigation
Suspend live streams whenever the viewed chat goes to null - #120
Conversation
suspendLiveStreams() only ran from onTabViewChange. Opening or closing the tracker also changes what is viewed (sendViewing sends null while the tracker is open) but never suspended, so a "thinking" activity or a live tool stream could stick after the tracker closed. Move the transition check into sendViewing(): any change from a viewed chat to null suspends live streams. onTabViewChange now only calls sendViewing(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
danbarker
left a comment
There was a problem hiding this comment.
Reviewed at ad21b58. Any change from a viewed chat to none now clears the live state, including opening the tracker, and the tab-hide path still works the same way. Lint, the full jest run and the production build pass on the merge with main and #119 (total gzip 859.9 KB, within the 860 limit). Non-blocking follow-up: a thinking frame already in flight when the tracker opens lands after the clear, and nothing ends it until the next activity frame, because re-viewing replays tool output and status but not activity. The same window exists for a hidden tab. Replaying the cached activity on viewing (or treating a missing one as idle) would close both.
What
Fixes live chat state sticking after the tracker closes.
suspendLiveStreams()only ran fromonTabViewChange(before && this.lastViewing === null).openTrackerViewandcloseTrackerViewalso change what is viewed:sendViewing()sendsnullwhile the tracker is open. They never suspended, so a "thinking" activity or a live tool stream could stay live after the tracker closed, because the idle frame never arrives for a chat that is not being viewed.Fix
The transition check moves into
sendViewing(): any change from a viewed chat tonullcallssuspendLiveStreams().onTabViewChangenow just callssendViewing(). The previous value is captured before it is overwritten, and only after the send succeeds, which is the same condition under whichlastViewingchanged before.Tests
New case in
hidden-tab-lifecycle-test.ts: with a live "thinking" activity and a tool stream, opening the tracker sendsviewing: null, clears the activity and marks the tool streams stale; closing the tracker re-sendsviewingfor the chat.Written first and run against the unchanged
client.ts, it fails: the activity is still{"state":"thinking"}after the tracker opens. With the fix,hidden-tab-lifecycle-test.tspasses (29 passed, 1 skipped, which was already skipped).tsc --noEmitand prettier clean.Bundle
gzip, production build, against
main: initial +3 B, total +3 B.🤖 Generated with Claude Code