Skip to content

Suspend live streams whenever the viewed chat goes to null - #120

Merged
danbarker merged 1 commit into
Matronhq:mainfrom
easelyte:fix/tracker-suspend-on-close
Nov 15, 2026
Merged

danbarker merged 1 commit into
Matronhq:mainfrom
easelyte:fix/tracker-suspend-on-close

Conversation

@easelyte

Copy link
Copy Markdown
Collaborator

What

Fixes live chat state sticking after the tracker closes.

suspendLiveStreams() only ran from onTabViewChange (before && this.lastViewing === null). openTrackerView and closeTrackerView also change what is viewed: sendViewing() sends null while 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 to null calls suspendLiveStreams(). onTabViewChange now just calls sendViewing(). The previous value is captured before it is overwritten, and only after the send succeeds, which is the same condition under which lastViewing changed before.

Tests

New case in hidden-tab-lifecycle-test.ts: with a live "thinking" activity and a tool stream, opening the tracker sends viewing: null, clears the activity and marks the tool streams stale; closing the tracker re-sends viewing for 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.ts passes (29 passed, 1 skipped, which was already skipped). tsc --noEmit and prettier clean.

Bundle

gzip, production build, against main: initial +3 B, total +3 B.

🤖 Generated with Claude Code

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>
@easelyte
easelyte marked this pull request as ready for review November 15, 2026 18:33
@easelyte
easelyte requested a review from danbarker November 15, 2026 18:33
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 31df66d and ad21b58.

Files selected for processing: 2

  • src/journal/client.ts
  • test/unit-tests/journal/hidden-tab-lifecycle-test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@danbarker danbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@danbarker
danbarker merged commit b43963d into Matronhq:main Nov 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants