Skip to content

chore(activity-monitor): drop dead output-tracking assignments in ALERT_RINGING#198

Open
dormouse-bot wants to merge 1 commit into
mainfrom
fix/activity-monitor-dead-assignments
Open

chore(activity-monitor): drop dead output-tracking assignments in ALERT_RINGING#198
dormouse-bot wants to merge 1 commit into
mainfrom
fix/activity-monitor-dead-assignments

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Surfaced by the nightly code-quality survey.

In ActivityMonitor.onData, the ALERT_RINGING branch assigns firstOutputAt and outputCountSinceAttention immediately before calling enterMightBeBusy(), but neither assignment is ever read:

  • enterMightBeBusy() doesn't touch either field — it clears the activity timers, sets status to MIGHT_BE_BUSY, and arms busyConfirmTimer.
  • Every path out of MIGHT_BE_BUSY overwrites both fields before they can be read: the confirm timer calls seedFromLatestOutput() (which re-derives firstOutputAt from lastOutputAt and resets the count) before transitioning to NOTHING_TO_SHOW, and an intervening onData in MIGHT_BE_BUSY calls enterBusy()resetOutputTracking(). The only readers of these fields (handleNothingToShowOutput, the busyCandidateTimer callback) run exclusively in NOTHING_TO_SHOW, which is never reached with the line-80/81 values intact.

So the two assignments are dead. They also mislead: they mimic the seeding in handleNothingToShowOutput, implying they prime output tracking for the transition, when in fact the seeding is redone downstream. Removing them.

No behavior change, so no regression test accompanies this — the existing activity-monitor.test.ts (21 cases, including the attention-gated ALERT_RINGING → resume transition) passes unchanged, and tsc -b is clean (now is still used earlier in onData).

…RT_RINGING

The firstOutputAt/outputCountSinceAttention assignments in the ALERT_RINGING
branch of onData are overwritten before any read (enterMightBeBusy never reads
them; seedFromLatestOutput or enterBusy resets them downstream). Remove the
dead, misleading lines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5a4e470
Status: ✅  Deploy successful!
Preview URL: https://cf30a564.mouseterm.pages.dev
Branch Preview URL: https://fix-activity-monitor-dead-as.mouseterm.pages.dev

View logs

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.

1 participant