feat(hooks): bridge SessionStart and SessionEnd Claude Code hook events#2394
Open
jainnam-1993 wants to merge 1 commit intocode-yeongyu:devfrom
Open
feat(hooks): bridge SessionStart and SessionEnd Claude Code hook events#2394jainnam-1993 wants to merge 1 commit intocode-yeongyu:devfrom
jainnam-1993 wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Adds SessionStart/End hooks following established patterns; changes are additive and well-isolated from existing hook logic, ensuring no regressions.
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Author
|
I have read the CLA Document and I hereby sign the CLA |
Collaborator
|
recheck |
Collaborator
|
@jainnam-1993 It looks like the email of the commit and your github account do not match. Please re-author the commit with an email that is linked to your GitHub account (your no-reply github email works). |
Complete the Claude Code hook compatibility layer from 5/7 to 7/7 events. Previously, oh-my-opencode bridged PreToolUse, PostToolUse, UserPromptSubmit, Stop, and PreCompact — but SessionStart and SessionEnd were missing. This broke session context injection for users relying on Claude Code hooks (e.g., ECC's session-start.js which injects previous session summaries). Changes: - types.ts: Add SessionStart/SessionEnd to ClaudeHookEvent union and ClaudeHooksConfig interface, plus SessionStartInput/SessionEndInput types - config.ts: Add both events to normalizer and merger arrays - config-loader.ts: Add both events to disabled hooks merger - session-start.ts (new): executeSessionStartHooks collects stdout from matching hooks for context injection; executeSessionEndHooks fires hooks on session deletion (fire-and-forget) - session-event-handler.ts: Wire session.created -> SessionStart (with stdout injection via session.prompt) and session.deleted -> SessionEnd Design decisions: - SessionStart stdout is injected into session context via ctx.client.session.prompt() + createInternalAgentTextPart() - No exit-code-2 blocking for SessionStart (matches Claude Code behavior) - SessionEnd is fire-and-forget (no blocking, no injection) - Subagent sessions are skipped (parentSessionId check) - isHookDisabled() respected for both new events
69b7e03 to
f4139ce
Compare
Author
|
recheck |
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
Completes the Claude Code hook compatibility layer from 5/7 to 7/7 hook events by adding
SessionStartandSessionEndbridging.Problem
oh-my-opencode bridges 5 of 7 Claude Code hook events (PreToolUse, PostToolUse, UserPromptSubmit, Stop, PreCompact), but SessionStart and SessionEnd are missing. This breaks session context injection for users relying on Claude Code hooks — for example, ECC's
session-start.jswhich injects previous session summaries, or customsession-context-loader.shhooks.Solution
Bridge the two missing events using the same patterns established by the existing hook bridge:
session.created(OpenCode) →SessionStart(Claude Code) — hook stdout is collected and injected into the session context viactx.client.session.prompt()+createInternalAgentTextPart()session.deleted(OpenCode) →SessionEnd(Claude Code) — fire-and-forget executionFiles Changed
types.tsSessionStart/SessionEndtoClaudeHookEventunion,ClaudeHooksConfig, plus input interfacesconfig.tseventTypesarraysconfig-loader.tsmergeDisabledHooks()session-start.ts(new)executeSessionStartHooks(collects stdout) +executeSessionEndHooks(fire-and-forget)session-event-handler.tssession.created→ SessionStart andsession.deleted→ SessionEndDesign Decisions
parentSessionIdcheck (matches Stop hook pattern)isHookDisabled()respected for both new eventsVerification
bun run typecheck— passes (zero errors)bun run build— succeedsSummary by cubic
Bridges Claude Code
SessionStartandSessionEndhook events, completing the compatibility layer (5/7 → 7/7). On session create, hook stdout is injected into the session; on session delete, hooks run and per-session state is cleared.session.created→SessionStart; inject stdout viactx.client.session.prompt()withcreateInternalAgentTextPart().session.deleted→SessionEnd; fire-and-forget execution and clear per-session hook state.executeSessionStartHooks/executeSessionEndHooks; skip subagent sessions; respect disabled hooks; no exit-code-2 blocking forSessionStart.Written for commit f4139ce. Summary will update on new commits.