Skip to content

Fix heartbeat nil value crash in timer and busy indicator#308

Draft
ElleNajt wants to merge 1 commit intoxenodium:mainfrom
ElleNajt:fix/heartbeat-nil-guard
Draft

Fix heartbeat nil value crash in timer and busy indicator#308
ElleNajt wants to merge 1 commit intoxenodium:mainfrom
ElleNajt:fix/heartbeat-nil-guard

Conversation

@ElleNajt
Copy link
Contributor

Summary

  • Guard against nil :heartbeat :value in the timer lambda and busy indicator frame function

Problem

agent-shell-heartbeat-stop sets :value to nil, but cancel-timer doesn't prevent an already-dispatched timer tick from running. When that final tick fires, it calls (1+ nil), producing:

(wrong-type-argument number-or-marker-p nil)

The same nil value propagates to agent-shell--busy-indicator-frame via mode-line redisplay during the force-mode-line-update call, triggering the error there too. This results in repeated error spam in *Messages*.

Changes

  • agent-shell-heartbeat.el: Wrap timer lambda body in when-let so it skips the tick when value is nil
  • agent-shell.el: Add value binding to when-let* in agent-shell--busy-indicator-frame so mod never receives nil

Test plan

  • Start an agent-shell session and let it run (busy indicator active)
  • Interrupt/stop the session and verify no wrong-type-argument errors in *Messages*

Written by Claude

`agent-shell-heartbeat-stop` sets `:value` to nil, but a final timer
tick can fire after cancellation and call `(1+ nil)`, causing
`(wrong-type-argument number-or-marker-p nil)`. The same nil value
propagates to `agent-shell--busy-indicator-frame` via mode-line
redisplay, triggering the error there too.

Guard both sites with `when-let` to skip when value is nil.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Copy link
Owner

@xenodium xenodium left a comment

Choose a reason for hiding this comment

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

Thank you!

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