Skip to content

Feature: Commit Templates — .gitmessage integration and in-app template management #26

@zelon

Description

@zelon

Overview

Add commit template support to help teams enforce consistent commit message conventions. Templates can be loaded from the repository's .gitmessage file (via git config commit.template) or managed directly inside the app and stored per-user.

Proposed Features

.gitmessage Integration

  • Automatically detect commit.template from git config on repo load
  • Display the file content as a read-only "Repo Template" entry in the template picker
  • Prompt the user to apply it when opening the Pending tab if the commit message is empty

In-App Template Management

  • Create, edit, and delete named templates (e.g. feat, fix, docs, chore)
  • Each template supports <placeholder> markers (e.g. <title>, <issue>, <details>)
  • Tab key navigates between placeholders after a template is applied
  • Templates stored in localStorage per installation

Validation (Optional per Template)

  • Each template can have an optional regex validation pattern
  • Real-time check as the user types — shows a warning if the message does not match
  • Does not block the commit; warns only

ASCII Mockups

Template picker dropdown (next to "Commit message" label):

┌─────────────────────────────────────────────┐
│ Commit message                  [Template ▾] │
│ ┌─────────────────────────────────────────┐ │
│ │  Enter commit message...                │ │
│ └─────────────────────────────────────────┘ │
│                          ┌────────────────┐  │
│                          │ 📄 .gitmessage │  │
│                          │────────────────│  │
│                          │ feat           │  │
│                          │ fix            │  │
│                          │ docs           │  │
│                          │ chore          │  │
│                          │────────────────│  │
│                          │ ⚙ Manage...   │  │
│                          └────────────────┘  │
│ [✓ Amend]    [✦ AI commit message] [Commit] │
└─────────────────────────────────────────────┘

After applying a template:

┌─────────────────────────────────────────────┐
│ Commit message       [Template: feat ▾] [✕] │
│ ┌─────────────────────────────────────────┐ │
│ │feat: <title>                            │ │
│ │                                         │ │
│ │Body: <details>                          │ │
│ │                                         │ │
│ │Closes: #<issue>                         │ │
│ └─────────────────────────────────────────┘ │
│ ⭾ Tab to jump to next field (3 remaining)  │
│ [✓ Amend]    [✦ AI commit message] [Commit] │
└─────────────────────────────────────────────┘

Validation warning:

┌─────────────────────────────────────────────┐
│ Commit message       [Template: feat ▾] [✕] │
│ ┌─────────────────────────────────────────┐ │
│ │fix something                            │ │
│ └─────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────┐ │
│ │ ⚠ Does not match "feat" pattern         │ │
│ │   Expected: ^feat: .{1,50}$            │ │
│ └─────────────────────────────────────────┘ │
│ [✓ Amend]    [✦ AI commit message] [Commit] │
└─────────────────────────────────────────────┘

Template manager modal:

┌────────────────────────────────────────────────────────┐
│  Commit Templates                                  [✕]  │
├────────────────────────────────────────────────────────┤
│  ┌─────────────────┐  ┌─────────────────────────────┐  │
│  │ 📄 .gitmessage  │  │ Name                        │  │
│  │─────────────────│  │ ┌─────────────────────────┐ │  │
│  │ ▶ feat          │  │ │ feat                    │ │  │
│  │   fix           │  │ └─────────────────────────┘ │  │
│  │   docs          │  │ Content                     │  │
│  │   chore         │  │ ┌─────────────────────────┐ │  │
│  │                 │  │ │feat: <title>            │ │  │
│  │ [+ New]         │  │ │                         │ │  │
│  └─────────────────┘  │ │Body: <details>          │ │  │
│                        │ │                         │ │  │
│                        │ │Closes: #<issue>         │ │  │
│                        │ └─────────────────────────┘ │  │
│                        │ Validation pattern (regex)  │  │
│                        │ ┌─────────────────────────┐ │  │
│                        │ │ ^feat: .{1,50}$         │ │  │
│                        │ └─────────────────────────┘ │  │
│                        │ [Delete]  [Cancel]  [Save]  │  │
│                        └─────────────────────────────┘  │
└────────────────────────────────────────────────────────┘

Implementation Notes

  • Data model:

    interface CommitTemplate {
      id: string;                  // UUID
      name: string;                // e.g. "feat"
      content: string;             // body with <placeholder> markers
      validationPattern?: string;  // optional regex
    }
    // stored in localStorage: "wimygit_commit_templates"
  • Files to add / modify:

    File Change
    src/components/tabs/PendingTab.tsx Template button, dropdown, apply logic, Tab navigation, validation warning
    src/components/shared/TemplateManagerModal.tsx New — CRUD modal for templates
    src/lib/git-api.ts Add getCommitTemplatePath()
    src-tauri/src/lib.rs Register get_commit_template_path command
    src-tauri/src/executor.rs Helper to run git config commit.template
  • Suggested implementation order:

    1. Rust command to read git config commit.template
    2. TemplateManagerModal with localStorage persistence
    3. Dropdown integration in PendingTab
    4. Placeholder Tab-key navigation
    5. Real-time regex validation + warning UI

Related Features

  • Pairs naturally with the existing AI commit message generator
  • Validation patterns make it easy to enforce Conventional Commits or custom team standards

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions