Skip to content

Commit b07dd22

Browse files
committed
fix(pulse-monitor): reset heartbeat after tool execution to prevent false positives
Tools can take arbitrary time, so we need a fresh baseline after execution. Previously, lastHeartbeat wasn't updated after tool.execute.after, causing stalled detection to trigger immediately after long-running tools. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent c7d29fe commit b07dd22

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/hooks/pulse-monitor.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ export function createPulseMonitorHook(ctx: PluginInput) {
132132
// Pause monitoring while tool runs locally (tools can take time)
133133
stopMonitoring()
134134
},
135-
"tool.execute.after": async (_input: { sessionID: string }) => {
136-
// Don't forcefully restart monitoring here to avoid false positives
135+
"tool.execute.after": async (input: { sessionID: string }) => {
136+
// Reset heartbeat after tool execution to prevent false positives
137+
// Tools can take arbitrary time, so we need a fresh baseline
138+
if (input.sessionID && currentSessionID === input.sessionID) {
139+
lastHeartbeat = Date.now()
140+
}
141+
// Don't forcefully restart monitoring here
137142
// Monitoring will naturally resume when next session/message event arrives
138143
// This prevents stalled detection on legitimately idle sessions
139144
}

0 commit comments

Comments
 (0)