fix(activity): detect git commits via tool_result event instead of command.executed#58
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR migrates commit instrumentation from event-driven bash command detection to tool-result-driven detection. The new ChangesCommit Detection Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…mmand.executed The commit counter never incremented in production because the handler listened on command.executed and gated on name === "bash". In opencode, command.executed is emitted for slash commands only (e.g. /commit, /clear) and is published at session.idle time — it is never fired for bash tool invocations, so the regex match could never run. Move detection into the tool-completion branch of handleMessagePartUpdated, where bash tool calls actually surface (part.type === "tool" with state.status === "completed"). The new handleToolResult helper checks both the bash command input (literal shell command) and the description input (agent-provided short description) against the same git commit regex. Only successful tool calls are counted; errored bash invocations do not bump the counter, matching the prior intent that only completed commits are observable. The dead handleCommandExecuted handler and its command.executed switch case are removed along with the now-unused EventCommandExecuted import.
b04baac to
6d0dd14
Compare
Problem
opencode.commit.countnever increments, regardless of how manygit commitinvocations a session makes.Root cause
The old
handleCommandExecutedlistens tocommand.executedevents filtered byname === "bash". Butcommand.executedin opencode is for slash commands (e.g./clear), not for bash tool calls — it fires atsession.idleand never carriesname === "bash". The handler was wired to the wrong event.Fix
Bash tool completions surface as
EventMessagePartUpdatedwithpart.type === "tool"andstate.status === "completed". Move commit detection there ashandleToolResult(toolName, toolInput, sessionID, ctx), called fromhandleMessagePartUpdatedwhensuccess === true.commandanddescriptionfields of the bash tool input.handleCommandExecutedhandler, its switch case insrc/index.ts, and the unusedEventCommandExecutedimport.Strictly a bug fix — commits that previously went uncounted will now be counted.
Companion PR: #59
Summary by CodeRabbit