fix: return ActivityDetection from getActivityState to fix stale lastActivityAt#112
Open
AgentWrapper wants to merge 7 commits intomainfrom
Open
fix: return ActivityDetection from getActivityState to fix stale lastActivityAt#112AgentWrapper wants to merge 7 commits intomainfrom
AgentWrapper wants to merge 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
fb98372 to
df5d7bd
Compare
…adata mtime The dashboard showed "Active 2h ago" even when agents were active minutes ago because lastActivityAt was sourced from the metadata file's mtime, which only changes on metadata writes (PR creation, status updates), not during agent work. Now enrichSessionWithRuntimeState() calls getSessionInfo() to read the agent's JSONL session file mtime, updating lastActivityAt with the actual last activity timestamp. Also enriches agentInfo with live summary/cost/sessionId data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use 2099-01-01 instead of a near-future date so the test doesn't break when wall-clock time passes the hardcoded date. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…are string
getActivityState() now returns { state, timestamp } instead of a bare
ActivityState string. The timestamp comes from data the plugin already
had (JSONL file mtime), eliminating the separate getSessionInfo() call
that was used solely to update lastActivityAt.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove AgentSessionInfo.lastLogModified and lastMessageType fields (timestamp now comes from ActivityDetection, these were dead weight adding a wasted stat() call per session per poll cycle) - Add missing unit test: older ActivityDetection timestamp should not regress lastActivityAt - Add timestamp assertions to integration tests (claude-code, aider) to verify real implementations provide timestamps that feed lastActivityAt Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…egration tests Move ~200 lines of duplicated tmux TTY + PID process detection logic from 4 agent plugins into a single isAgentProcessRunning() utility in ao-core. Integration tests now fail explicitly when polling doesn't capture observations instead of silently passing via if-guards. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 tests covering the tmux TTY + ps parsing path (match on TTY, no match, empty TTY, bare command, path prefix, substring rejection, regex escaping, multiple panes, tmux failure) and PID-based fallback (alive, dead, zero, negative, NaN, string coercion) plus edge cases (no id, no pid, empty tmux id). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mocks process.kill to verify the EPERM branch (process exists but no permission to signal → returns true) and ESRCH branch (no such process → returns false). These were the last untested branches in isAgentProcessRunning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e1455f8 to
364b0d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lastActivityAtwas sourced from the metadata file's mtime (only updates on PR creation, status changes), not during agent workgetActivityState()now returnsActivityDetection { state, timestamp? }instead of a bareActivityStatestring — the timestamp comes from data the plugin already had (JSONL file mtime), requiring zero additional I/OenrichSessionWithRuntimeState()usesdetected.timestampto updatelastActivityAt, eliminating the separategetSessionInfo()call that was previously added for this purposeChanges
packages/core/src/types.ts— newActivityDetectioninterface, updatedAgent.getActivityStatereturn typepackages/core/src/session-manager.ts— usedetected.state+detected.timestampfrom activity detection{ state, timestamp }objectsTest plan
updates lastActivityAt from ActivityDetection timestamp— verifies JSONL mtime overwrites stale metadata mtimekeeps metadata lastActivityAt when ActivityDetection has no timestamp— verifies we never regressActivityDetectionshape)🤖 Generated with Claude Code