Add editable git commit prompt to rule store
Custom Git Commit Prompt Support
Adds user-customizable AI prompts for commit message generation via Rules Library integration.
Features
UI Integration:
- Rules Library: Settings → AI → Rules Library → “Git Commit Prompt” (built-in rule)
- Reset button (↻): Restores default prompt content with one click
- Title handling: Title is fixed to “Git Commit Prompt”; body remains fully editable
- Toggle behavior: Checkmark icon still controls whether the rule is active (
metadata.defaultflag)
Functionality:
- Custom prompt storage: Reuses Zed’s Rules Library (LMDB/heed) database
- Activation control: Custom prompt only used when
metadata.default = true - Auto-fallback: Falls back to bundled default prompt whenever the rule is inactive or loading fails
- Rule lifecycle: Commit prompt is created with default content during initial database setup
- Default state: Enabled by default (
default = trueon first initialization)
Implementation
Key files touched:
crates/prompt_store/src/prompt_store.rs– AddsPromptId::CommitMessage, initializes database entry, and forces the title to “Git Commit Prompt” when savingcrates/rules_library/src/rules_library.rs– Allows body edits, keeps title read-only, exposes reset action, and omits deletion for the built-in rulecrates/git_ui/src/git_panel.rs– Loads custom prompt only whenmetadata.defaultis true, otherwise uses the default textcrates/agent/src/agent.rs/crates/agent_ui/src/context_picker/rules_context_picker.rs– Hide the CommitMessage rule from agent pickerscrates/git_ui/Cargo.toml– Addsprompt_storedependency- Housekeeping: legacy ad-hoc tests (
git_commit_prompt_tests.rs/git_custom_commit_tests.rs) removed after migrating coverage
Key Implementation Details:
PromptIdenum gains aCommitMessagevariant alongsideEditWorkflowandUser- Special-cased store logic keeps the prompt editable but enforces the canonical title
metadata.defaultflag (toggled from the Rules Library) governs activation during commit generation- Reset action reinstates the default commit prompt content (and preserves the active/inactive flag)
- Database bootstrapping ensures the built-in rule exists with default content
- Git panel falls back gracefully to bundled text whenever the custom rule is inactive or fails to load
Testing:
- Targeted coverage via
cargo test -p prompt_store -- git_commit_prompt- Initialization with default metadata and content
- Custom body persistence while keeping title immutable
- Default-flag persistence across sessions (drop/reopen LMDB)
- Metadata cache refresh after saving custom content
Use Case:
Enables teams and individuals to enforce custom commit conventions (e.g., conventional commits, ticket references, specific format requirements) without modifying Zed source code.
Release Notes:
Feat: persist customizable git commit prompt
- register PromptId::CommitMessage as the built-in "Git Commit Prompt"
- seed PromptStore with commit_message_prompt.txt as the default body
- allow editing only the prompt body, keep the title immutable, and add reset support
- load the custom commit prompt in the git panel only when marked as default, otherwise fall back
- enforce the title invariant in PromptStore::save and refresh cached prompts after updates
| Warnings | |
|---|---|
| :warning: |
This PR is missing release notes. Please add a "Release Notes" section that describes the change:
If your change is not user-facing, you can use "N/A" for the entry:
|
Generated by :no_entry_sign: dangerJS against 43066e5b543a45a33e1c9bc8b7c265a3355c2d97
https://github.com/user-attachments/assets/d5db0cf9-8d66-4cd4-a099-bb30434d6762
There is still a layout issue: the "Git Commit Prompt" rule title still allows selection and cursor movement over it. In my opinion, this shouldn't be possible, but I haven't been able to fix it yet. Currently, it only doesn't allow editing and deletion.