✨ add gitmoji-aware commit message generation#658
Conversation
- Read `t3code.commitMessageStyle` from git config to switch prompt style - Wire `GitCore` into `CodexTextGeneration` runtime/test layers - Add coverage for gitmoji/conventional fallback cases and new feature docs
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can disable poems in the walkthrough.Disable the |
|
I feel like this is not the best way to do this, nor should we? I believe we could instead tailor the prompt to give the ai a snippet of some of the previous commit messages, and ask it to follow the same detected style. This way we can ensure that we support the majority of commit message patterns without hard-coding anything like this. @t3dotgg Do you have an plans around this kind of work that you want to weigh in with? My above "solution" would work to resolve: |
|
Hi @binbandit , thanks for the suggestion and sorry for the delayed reply. I did not receive the notification earlier and only noticed your comment while reviewing my PRs today. Your idea about adapting the prompt using a few previous commit messages to detect and follow the existing style makes sense. That approach would likely make the system more flexible and avoid hard-coding behaviour for specific commit formats. When I originally implemented this change, I interpreted the issue as requesting a switchable feature (enable/disable). Because of that, I added the configuration option to explicitly control the behaviour. My goal was to provide a straightforward solution that satisfies the requirement described in the issue. However, I agree that dynamically inferring the style from recent commit messages could be a cleaner and more scalable approach. It would allow the tool to support different commit message conventions (with emojis, without emojis, conventional commits, etc.) without needing explicit configuration. Before making further changes, I would like to confirm the preferred direction with the maintainers. Would you prefer that I update this implementation to follow the prompt-based approach you suggested, or should the configurable switch remain the intended solution? Happy to adjust the implementation based on the maintainers’ guidance. |
|
@juliusmarminge until I get knighted, you wanna speak to this? |
I agree. This would be the best way to do it. It will support people's different preferences, without forcing any pattern on them. |
feat(git): add getRecentCommitMessages function Add method to retrieve recent commit messages from git repository. Supports optional count parameter with default of 5 messages. Excludes merge commits and returns clean message list. - Add interface definition in GitCoreShape - Implement git log command execution with proper error handling - Add comprehensive unit tests for functionality - Follows existing Effect patterns in codebase This commit adds new git functionality that can be used for features like gitmoji suggestions or commit history analysis.
Add intelligent analysis of git commit messages to detect patterns and provide examples. Supports emoji detection, conventional commit types, and scope analysis for AI prompt generation. - Add analyzeCommitPatterns function with comprehensive interface - Implement pattern detection for emojis, types, and scopes with configurable thresholds - Select best commit examples based on pattern completeness - Provide detailed analysis output with detected patterns - Add extensive test coverage (18 test cases) covering all edge cases - Handle various commit formats: one-liners, multi-line, mixed styles - Support Unicode emojis and conventional commit specification - Graceful handling of empty repositories and git command failures This commit adds sophisticated pattern detection that can help AI systems understand and adapt to existing commit styles in repositories.
9e7b4aa to
59e7682
Compare
- Add repository pattern analysis and recent examples for more consistent generated commit messages - Align formatting instructions with detected style for predictable commit output across projects - Expand conventional type guidance and imperative rules for clearer, review-ready commit subjects
This PR improves commit message generation by analysing previous commit messages more efficiently. Because of this, I adopted a pattern-aware prompt optimisation approach, using only one high-quality example in the prompt to guide commit message generation. Instead of passing 10+ raw commits, we select the single best example using the following priority order: Priority Order: One well-structured example is often more effective than many mixed-quality examples. Test Coverage for
|
|
Some thoughts after reading the conversation (haven't read code)
Don't wanna put all this on you, but also kinda reluctant to make some half-baked solution that we end up throwing away in a week |
|
Hi @juliusmarminge , In this PR, we are no longer setting up or updating any Git configuration. Based on our previous discussion, I have fully migrated the implementation so that it only analyses past commit messages and generates a new commit message based on those examples. In short, this PR does not modify Git config at all; it only considers previous commit messages to infer and generate the next commit message. After reading your reply, it became clear that you are absolutely right about keeping configuration strictly on the server side. With that in mind, I would like to propose a slightly different approach. Proposed idea (UI based selection): The commit message generation style would depend on the mode selected by the user, giving them full control over the output. Modes:
Note: The Conventional flow refers to the instruction format currently used in the main branch. I have attached a small UI example to illustrate this idea.
Please let me know if you think this approach is reasonable. If it looks good, I can proceed with implementing it. Also, if you would like me to include the new branch generation logic in this PR as well, please share some guidance or requirements so that I can incorporate that change here too. |
- for conventional, gitmoji, and custom commit message generation - for exposing commit style controls in the commit dialog
Redesign commit mode selector with enhanced template management and
better UX.
- Add improved template selection with visual feedback and accessibility
attributes
- Remove custom instructions complexity for simpler workflow
- Implement template state management with refs for better tracking
- Improve visual feedback for selected templates with aria-* roles
- Standardize commit mode naming ("Conventional" → "Standard")
- Add proper keyboard navigation and focus management
- Simplify template application and removal logic
The changes represent a comprehensive improvement to the commit message
interface, focusing on usability, accessibility, and reduced complexity
while maintaining all core functionality.
- Pass `commitMessage` into custom-mode generation instead of a separate instructions field - Add coverage to verify custom mode forwards the provided message
- Add free-form `message` input to commit message generation - Default commit message mode to `standard`
- Update Codex text generation tests for auto, standard, gitmoji, and custom commit modes - Refresh prompt assertions to match the new base rules and repository analysis handling
Implement intelligent template extraction and processing for custom commit mode. - Add extractCustomCommitTemplate function to parse user input for templates and guidance - Extract quoted templates from user messages using regex pattern matching - Preserve user guidance as separate from template content - Update custom mode prompt to generate new commit messages rather than output templates literally - Remove old commit message parsing for custom mode to prevent conflicts - Add comprehensive tests for template extraction functionality - Improve gitmoji mode support with explicit gitmoji instruction - Standardize auto mode to use repository analysis more effectively The changes enhance the custom commit mode by intelligently extracting templates from user input while preserving additional guidance, creating a more flexible and powerful commit message generation system.
Enhance the custom commit message generation to better handle templates and user guidance. Changes: - Add logic to identify and filter out the template line from guidance - Prevent duplication when template and guidance are the same - Improve prompt clarity with better section headers - Rename "Extracted commit template" to "Commit message template to follow" - Rename "Original user message" to "Additional user context" - Add validation to ensure guidance is unique and not template repetition This ensures that when users provide templates like: template: <type>: <subject> Fix authentication bug The backend properly separates the template from the guidance and generates commit messages like: "feat: Fix authentication bug" Fixes pingdotgg#638
- add commit mode metadata - add custom commit template presets
- export commitTemplates from packages/contracts - verify built-in commit modes and custom templates
- Import commit mode and template definitions from contracts - Keep selector icon rendering aligned with shared metadata
- Make custom commit generation follow the provided template exactly - Update the standard ticket template to use GitHub issue references
Remove unnecessary template extraction logic and let AI parse custom commit instructions directly. This reduces complexity and improves flexibility by delegating parsing to the model. - Remove extractCustomCommitTemplate function (54 lines) - Simplify custom mode to pass message directly to AI - Update test expectations for new behavior - Fix regex pattern in commitTemplates.test.ts The AI can now understand and apply custom templates without preprocessing, making the system more maintainable and flexible.
Enhance commit message generation with more structured and specific instructions to ensure higher quality and consistency in generated commit messages. - Replace generic custom instructions with detailed template guidance - Add specific requirements for placeholder resolution - Include instruction to extract and preserve GitHub/Jira references - Enforce strict template adherence for more reliable output - Ensure complete and descriptive commit messages Closes pingdotgg#638
|
Hi @juliusmarminge and @binbandit , I'm excited to share this pull request, which introduces a comprehensive commit message generation engine This feature gives users full control over their commit message style, moving beyond the standard format. Here’s a breakdown of the new capabilities:
This PR has grown from a small feature into a robust "commit machine" based on our previous discussions. Given the scope of the changes, I’ve taken extra care with testing. I reviewed the implementation using AI tools (Claude 4.6, Gemini 3.1 Pro, and z.ai 5) and added thorough test cases to cover the functionality. I’ve attached a demo video below to show everything in action: Fingers crossed this adds real value to the project 🤞 Looking forward to your feedback. Please let me know if you have any questions or suggestions. |


t3code.commitMessageStylefrom git config to switch prompt styleGitCoreintoCodexTextGenerationruntime/test layersWhat Changed
This PR adds support for
gitmoji-stylecommit messages by reading git configuration and adjusting the AI prompt accordingly.Implementation:
t3code.commitMessageStylefrom git config during commit message generationGitCoreservice intoCodexTextGenerationlayer to access configgitmoji→ Include gitmoji emoji instructions and examplesconventionalor unset → Use conventional commit styleuse-gitmoji)docs/features/gitmoji-support.mdFiles changed:
apps/server/src/git/Layers/CodexTextGeneration.ts- Core implementationapps/server/src/git/Layers/CodexTextGeneration.test.ts- Test coverageapps/server/src/serverLayers.ts- Layer compositiondocs/features/gitmoji-support.md- User documentationWhy
Addresses #638 - Users requested
gitmojisupport to keep generated commits consistent with repos that already usegitmoji. This is especially useful for teams that have adopted gitmoji as part of their workflow.Approach:
UI Changes
N/A - This is a backend-only change. The generated commit messages will include gitmoji emojis when enabled.
Checklist
Example:
Before:
After:
Note
Add gitmoji-aware commit message generation modes to commit workflow
commitMessageModeparameter (standard,auto,gitmoji,custom) to the commit generation pipeline, from the API contract through to the AI prompt builder inCodexTextGeneration.automode,GitCore.getRecentCommitMessagesinspects recent non-merge commits and a newanalyzeCommitPatternsutility detects emoji prefixes, scopes, and conventional types to inject a representative example into the prompt.gitmojimode, emoji guidance is added to the prompt; incustommode, the user-provided commit message is forwarded as a template/instructions rather than used as the final commit.CommitModeSelectorUI component to the commit dialog, with predefined custom templates sourced from a newcommitTemplatescontract package.CodexTextGenerationnow depends onGitCoreat runtime; misconfigured layer wiring will cause generation to fail.Macroscope summarized 4b5ed82.