Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Overview

This PR adds support for custom prompt mentions using the @mention syntax in the chat input. Users can create reusable prompt templates as markdown files and reference them inline.

Changes

  • Backend: Prompt file utilities to search .cmux and ~/.cmux/prompts for markdown prompts
  • IPC Layer: Added channels for listing and reading prompts
  • Frontend: @mention autocomplete with PromptSuggestions component
  • Expansion: Prompts are expanded before sending to backend
  • Priority: Repo prompts (.cmux) override system prompts (~/.cmux/prompts)
  • Tests: Comprehensive unit tests for all prompt utilities

Usage

  1. Type @ in the chat input to see available prompts
  2. Select a prompt or type to filter
  3. Send message - @prompt-name is replaced with prompt content

Examples

System prompts: ~/.cmux/prompts/explain.md
Repo prompts: .cmux/review.md

See PROMPTS_FEATURE.md for full documentation.

Generated with cmux

- Created prompt file utilities to search .cmux and ~/.cmux/prompts for markdown prompts
- Added IPC channels for listing and reading prompts
- Implemented @mention autocomplete in ChatInput with PromptSuggestions component
- Prompts are expanded before sending to backend
- Repo prompts (.cmux) take precedence over system prompts (~/.cmux/prompts)
- Added comprehensive tests for prompt utilities

Generated with `cmux`
Generated with `cmux`
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

The previous implementation always replaced the last @ in the input,
which caused issues when editing earlier mentions in a multi-mention message.

Changes:
- getPromptSuggestions now accepts cursor position parameter
- Only considers @ before the cursor for suggestions
- handlePromptSelect replaces the @ at cursor, not the last one
- Added tests for cursor-aware behavior

Resolves Codex review feedback.

Generated with `cmux`
- Use RegExp#exec() instead of String#match()
- Use optional chaining

Generated with `cmux`
Generated with `cmux`
- Removed stray documentation file (PROMPTS_FEATURE.md)
- Extracted getPromptDirectories() helper to eliminate duplication in ipcMain
- Added comprehensive integration tests for prompts feature
  - Tests listing prompts from both system and repo directories
  - Tests repo prompts override system prompts
  - Tests reading prompt content
  - Tests handling of non-existent prompts
  - All 4 tests pass

Generated with `cmux`
- Create usePrompts hook to manage all prompt-related state and logic
- Remove 59 lines from ChatInput (950 -> 891 lines)
- Hook handles:
  - Loading available prompts from workspace
  - Generating suggestions based on cursor position
  - Expanding @mentions to their content
  - Manual dismissal of suggestions
- Improves separation of concerns and testability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant