Skip to content

✨ add gitmoji-aware commit message generation#658

Open
SOUMITRO-SAHA wants to merge 22 commits into
pingdotgg:mainfrom
SOUMITRO-SAHA:feature/gitmoji-commit-support-638
Open

✨ add gitmoji-aware commit message generation#658
SOUMITRO-SAHA wants to merge 22 commits into
pingdotgg:mainfrom
SOUMITRO-SAHA:feature/gitmoji-commit-support-638

Conversation

@SOUMITRO-SAHA
Copy link
Copy Markdown

@SOUMITRO-SAHA SOUMITRO-SAHA commented Mar 9, 2026

  • 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

What Changed

This PR adds support for gitmoji-style commit messages by reading git configuration and adjusting the AI prompt accordingly.

Implementation:

  • Read t3code.commitMessageStyle from git config during commit message generation
  • Wire GitCore service into CodexTextGeneration layer to access config
  • Conditionally modify AI prompt based on config value:
    • gitmoji → Include gitmoji emoji instructions and examples
    • conventional or unset → Use conventional commit style
  • Handle case-insensitive matching and partial matches (e.g., use-gitmoji)
  • Add 8 comprehensive test cases covering all config scenarios
  • Add user documentation in docs/features/gitmoji-support.md
    Files changed:
  • apps/server/src/git/Layers/CodexTextGeneration.ts - Core implementation
  • apps/server/src/git/Layers/CodexTextGeneration.test.ts - Test coverage
  • apps/server/src/serverLayers.ts - Layer composition
  • docs/features/gitmoji-support.md - User documentation

Why

Addresses #638 - Users requested gitmoji support to keep generated commits consistent with repos that already use gitmoji. This is especially useful for teams that have adopted gitmoji as part of their workflow.

Approach:

  • Configuration-based: Users opt-in via git config (no breaking changes)
  • Backward compatible: Defaults to conventional style when config not set
  • Flexible: Supports repository-specific and global configuration
  • Safe: Handles invalid config values gracefully with fallback to conventional

UI Changes

N/A - This is a backend-only change. The generated commit messages will include gitmoji emojis when enabled.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Example:

Before:

add gitmoji feature documentation

- Add comprehensive guide in docs/features/gitmoji-support.md
- Document enable/disable commands
- Include commit examples with and without gitmoji
- List supported gitmoji emojis
- Note platform availability (web, desktop)

After:

✨ add gitmoji-aware commit message generation

- 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
- Add comprehensive guide in docs/features/gitmoji-support.md
- Note platform availability (web, desktop)

Note

Add gitmoji-aware commit message generation modes to commit workflow

  • Adds a commitMessageMode parameter (standard, auto, gitmoji, custom) to the commit generation pipeline, from the API contract through to the AI prompt builder in CodexTextGeneration.
  • In auto mode, GitCore.getRecentCommitMessages inspects recent non-merge commits and a new analyzeCommitPatterns utility detects emoji prefixes, scopes, and conventional types to inject a representative example into the prompt.
  • In gitmoji mode, emoji guidance is added to the prompt; in custom mode, the user-provided commit message is forwarded as a template/instructions rather than used as the final commit.
  • Adds a CommitModeSelector UI component to the commit dialog, with predefined custom templates sourced from a new commitTemplates contract package.
  • Risk: CodexTextGeneration now depends on GitCore at runtime; misconfigured layer wiring will cause generation to fail.

Macroscope summarized 4b5ed82.

- 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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 9, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bd8eccac-0f62-4c18-9f18-5ef96bca8344

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable poems in the walkthrough.

Disable the reviews.poem setting to disable the poems in the walkthrough.

@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 9, 2026
@binbandit
Copy link
Copy Markdown
Contributor

binbandit commented Mar 9, 2026

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:

@SOUMITRO-SAHA
Copy link
Copy Markdown
Author

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.
Thanks again for the feedback.

@binbandit
Copy link
Copy Markdown
Contributor

@juliusmarminge until I get knighted, you wanna speak to this?

@UtkarshUsername
Copy link
Copy Markdown
Contributor

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.

I agree. This would be the best way to do it. It will support people's different preferences, without forcing any pattern on them.

@github-actions github-actions Bot added the size:XL 500-999 changed lines (additions + deletions). label Mar 16, 2026
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.
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels Mar 16, 2026
@SOUMITRO-SAHA SOUMITRO-SAHA force-pushed the feature/gitmoji-commit-support-638 branch from 9e7b4aa to 59e7682 Compare March 16, 2026 10:56
- 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
@SOUMITRO-SAHA
Copy link
Copy Markdown
Author

I have tested the implementation locally and everything is working as expected.
Feel free to test it on your end as well and let me know if you notice anything that needs improvement.

Hi @binbandit @juliusmarminge

This PR improves commit message generation by analysing previous commit messages more efficiently.
To reduce token consumption, I implemented analyzeCommitPatterns.ts, a regex-based analyser that detects the basic structure of existing commit messages. This allows us to avoid sending the entire commit history to the AI, which would otherwise consume more tokens during generation.

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:

1. Emoji + Type + Scope (most structured)
      ✨ feat(git): improve commit pattern detection logic
2. (Emoji + Type) OR (Type + Scope)
    🐛 fix: handle empty commit history safely
    OR
    feat(commit): support emoji detection
3. Any Single Pattern
    📚 update documentation
4. First Commit (fallback)

One well-structured example is often more effective than many mixed-quality examples.

Test Coverage for analyzeCommitPatterns

Added 31 comprehensive tests, covering:

  • All pattern combinations (emoji + type + scope, etc.)
  • One-line commits
  • Edge cases (empty messages, special characters, code blocks)
  • Real-world mixed styles

Test Results
✓ 31 tests passed
✓ Edge cases covered
✓ Type safety ensured

Quick Test Commands

# Test only the pattern analysis (31 tests)
cd apps/server && bun run test analyzeCommitPatterns.test.ts
# Test the Codex text generation (13 tests)
cd apps/server && bun run test CodexTextGeneration.test.ts

@juliusmarminge
Copy link
Copy Markdown
Member

Some thoughts after reading the conversation (haven't read code)

  • Why a git config and not an app level setting? (ref move some settings to server authorative #1033 for the need for server based config)
  • Is past-repo-conventions the only supported option here? For reference, we probably wanna move this repo to using conventional commits but there's pretty much none of those in the history so this would not work for t3code repo as is.
    • I'm thinking (maybe a bit longer term but don't wanna make decisions now that makes those plans more difficult down the road) is to have different options, like gitmoji, conventional commits, infer from repo, and custom (user can write free form text that we put in the prompt)
  • We should consider how this affects PR title/body generations (people will wanna configure at least PR titles as well so the whole system feels uniform.
    • Potentially also branch name generations

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

@SOUMITRO-SAHA
Copy link
Copy Markdown
Author

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:

  • Auto → (Default Mode) This will follow the current flow.
    It analyses past commit messages, selects the best example, and then passes that example to the prompt generation step (infer from repo).

  • Gitmoji → Generates commit messages using Gitmoji while still following a conventional commit style.

  • Conventional → Generates commit messages strictly following the conventional commit format with predefined instructions.

  • Custom → Opens an input field where the user can provide their own example or prompt.
    In this mode, the user's input will have the highest priority while still following the conventional structure.

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.

image

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
@SOUMITRO-SAHA
Copy link
Copy Markdown
Author

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:

  • Multiple Commit Message Styles: Users can now choose from several generation modes:

    • Standard: The existing default behaviour
    • Auto: Intelligently analyses past commits to determine the most likely style (e.g., conventional, gitmoji)
    • Gitmoji: Generates commit messages with gitmoji prefixes
    • Custom: Allows users to leverage predefined templates
    • Direct Message: Uses the user's input directly as the commit message
  • Backend-Driven: The entire workflow is handled on the backend. Users simply trigger the "Generate Commit" action, and the server manages the selected mode without any client-side configuration.

  • Extensible by Design: The architecture is highly scalable, making it easy to add new features. For example, we can extend the custom mode to support user-defined templates in the future.

  • Intuitive User Interface: The UI is designed to be simple and clear, following the project's existing standards. The new options should be easy to understand without extra documentation.

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:

Watch the demo

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants