-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add default sessionStart handler to template #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change introduces a new "SessionStart" hook event into the codebase. It adds corresponding payload and response interfaces, handler type definitions, and updates hook dispatch logic to support the new event. A template handler for "SessionStart" is provided, and related type unions, interfaces, and switch statements are updated accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant HookSystem
participant SessionStartHandler
Client->>HookSystem: Trigger "SessionStart" event with payload
HookSystem->>SessionStartHandler: Invoke handler with payload
SessionStartHandler-->>HookSystem: Return SessionStartResponse
HookSystem->>Client: Log/return response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested labels
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
add-session-start.sed(1 hunks)templates/hooks/index.ts(2 hunks)templates/hooks/lib.ts(6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
templates/**/*
📄 CodeRabbit Inference Engine (CLAUDE.md)
Hook templates must be stored in the
templates/directory and copied to the user's.claude/directory when initialized.
Files:
templates/hooks/index.tstemplates/hooks/lib.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: johnlindquist/claude-hooks#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:51:09.840Z
Learning: Applies to .claude/{settings.json,hooks/index.ts,hooks/lib.ts,hooks/session.ts} : The generated hook system must create `.claude/settings.json`, `.claude/hooks/index.ts`, `.claude/hooks/lib.ts`, and `.claude/hooks/session.ts`.
📚 Learning: applies to .claude/{settings.json,hooks/index.ts,hooks/lib.ts,hooks/session.ts} : the generated hook...
Learnt from: CR
PR: johnlindquist/claude-hooks#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:51:09.840Z
Learning: Applies to .claude/{settings.json,hooks/index.ts,hooks/lib.ts,hooks/session.ts} : The generated hook system must create `.claude/settings.json`, `.claude/hooks/index.ts`, `.claude/hooks/lib.ts`, and `.claude/hooks/session.ts`.
Applied to files:
templates/hooks/index.tsadd-session-start.sed
📚 Learning: applies to templates/**/* : hook templates must be stored in the `templates/` directory and copied t...
Learnt from: CR
PR: johnlindquist/claude-hooks#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:51:09.840Z
Learning: Applies to templates/**/* : Hook templates must be stored in the `templates/` directory and copied to the user's `.claude/` directory when initialized.
Applied to files:
templates/hooks/index.ts
📚 Learning: hooks are executed using the bun runtime (required dependency)....
Learnt from: CR
PR: johnlindquist/claude-hooks#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:51:09.840Z
Learning: Hooks are executed using the Bun runtime (required dependency).
Applied to files:
templates/hooks/index.ts
🧬 Code Graph Analysis (2)
templates/hooks/lib.ts (1)
scripts/session-type-reference.ts (1)
BasePayload(15-18)
add-session-start.sed (1)
scripts/session-type-reference.ts (1)
BasePayload(15-18)
🔇 Additional comments (14)
add-session-start.sed (6)
3-13: LGTM - Consistent payload interface pattern.The
SessionStartPayloadinterface follows the established pattern with standard fields plus a logicalsourcefield for tracking session origin.
15-17: LGTM - Proper union type extension.The union type addition follows the discriminated union pattern correctly.
19-32: LGTM - Well-structured response interface.The
SessionStartResponseinterface follows established patterns with appropriate decision options and hook-specific output structure.
34-36: LGTM - Consistent handler type definition.The handler type follows the established pattern with proper payload and response types.
38-40: LGTM - Proper interface extension.The
HookHandlersinterface extension maintains the optional pattern and uses the correct handler type.
42-54: LGTM - Consistent runtime dispatch logic.The switch case follows the established pattern with proper async handling and fallback behavior.
templates/hooks/index.ts (3)
8-8: LGTM - Clean import addition.The
SessionStartHandlerimport is properly added and maintains alphabetical ordering.
16-41: Excellent handler implementation with helpful examples.The
sessionStarthandler follows established patterns while providing comprehensive examples for common use cases. The source-specific behavior examples and well-commented code will help developers customize the template effectively.
174-174: LGTM - Logical placement in handler configuration.The
sessionStarthandler is appropriately placed at the beginning of the handler list, reflecting its role in session initialization.templates/hooks/lib.ts (5)
289-289: LGTM - Useful optional field addition.The optional
titlefield enhances notification capabilities without breaking existing code.
320-325: LGTM - Consistent interface structure.The
SessionStartPayloadinterface properly extends the base payload pattern with a logicalsourcefield for session origin tracking.
334-334: LGTM - Proper discriminated union extension.The union type addition correctly follows the established discriminated union pattern.
379-387: LGTM - Well-structured response interface.The
SessionStartResponseinterface follows established patterns with appropriate decision options and consistent hook-specific output structure.
410-410: LGTM - Consistent handler type definition.The
SessionStartHandlertype maintains the established pattern with proper payload and response types.
|
🎉 This PR is included in version 2.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
This PR adds a default sessionStart handler to the hooks template, completing the SessionStart feature implementation.
Changes
SessionStartHandlerto the imports intemplates/hooks/index.tssessionStarthandler with:saveSessionDatasessionStartto therunHookconfigurationImplementation Details
The handler follows the same pattern as other handlers in the template:
This complements the SessionStart hook implementation in PR #50 by providing users with a ready-to-use handler template.
Testing
Related
Summary by CodeRabbit
New Features
Other Improvements