Skip to content

Conversation

ysfscream
Copy link
Member

PR Checklist

If you have any questions, you can refer to the Contributing Guide

What is the current behavior?

The Copilot preset prompt selection panel (PresetPromptSelect.vue) appears automatically whenever the Copilot input field (CopilotInput.vue) receives focus. This can be intrusive and annoying for users who want to type a message. Additionally, once the panel appears, keyboard navigation (up/down/left/right arrows) does not work because the focus remains in the input field, and there's no dedicated way (like pressing Esc) to dismiss the panel without selecting an item or clicking outside.

Issue Number: None

What is the new behavior?

This PR significantly improves the usability of the Copilot preset prompts:

  1. Trigger Change: The preset prompt panel (PresetPromptSelect.vue) is no longer triggered by focusing the input field. Instead, it appears only when the user types a / character at the beginning of the CopilotInput.vue field.
  2. Keyboard Navigation: When the panel appears (after typing /), focus is automatically transferred to the panel itself, allowing users to navigate the preset prompts using the up/down/left/right arrow keys and select with Enter.
  3. Escape Key Dismissal: Users can now press the Esc key to dismiss the preset prompt panel when it is visible. This clears the input field and hides the panel.
  4. Updated Placeholder: The placeholder text in the CopilotInput.vue field has been updated across all languages to inform users about the new / trigger (e.g., "Enter message, use / for preset prompts, ↩︎ to send").

This makes accessing preset prompts an explicit action initiated by the user with /, enables keyboard accessibility, and provides a standard way to close the panel, leading to a much smoother user experience.

image

Does this PR introduce a breaking change?

  • Yes
  • No

Specific Instructions

Reviewers should check:

  • The preset prompt panel appears only when / is the first character in the input.
  • Arrow key navigation works correctly within the panel once it appears.
  • Pressing Esc dismisses the panel and clears the input when the panel is visible.
  • Selecting a preset prompt replaces the / and potentially other text in the input field.
  • Clicking outside the panel still correctly dismisses it.
  • The updated placeholder text is displayed correctly.

Other information

This change modifies src/components/ai/CopilotInput.vue to handle the new trigger logic, focus management, and Esc key binding. It also modifies src/components/ai/PresetPromptSelect.vue to add a method for receiving focus, and updates translations in src/lang/copilot.ts.

… nvm default version

Now using node v16.14.2 (npm v8.5.0)
@ysfscream ysfscream requested a review from Copilot April 14, 2025 13:38
@ysfscream ysfscream self-assigned this Apr 14, 2025
@ysfscream ysfscream requested a review from Red-Asuka April 14, 2025 13:39
@ysfscream ysfscream added enhancement New feature or request refactor Refactor code or architecture UI/UX Improve some UI \ UX desktop MQTTX Desktop labels Apr 14, 2025
@ysfscream ysfscream moved this to In Progress in MQTTX Apr 14, 2025
@ysfscream ysfscream added this to the v1.12.0 milestone Apr 14, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@Red-Asuka Red-Asuka merged commit a038bce into main Apr 15, 2025
4 checks passed
@Red-Asuka Red-Asuka deleted the ysf/desktop branch April 15, 2025 01:26
@github-project-automation github-project-automation bot moved this from In Progress to Done in MQTTX Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop MQTTX Desktop enhancement New feature or request refactor Refactor code or architecture UI/UX Improve some UI \ UX
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants