Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 22, 2025

This PR adds the "Preview System Prompt" button directly to the Prompts settings tab to improve discoverability and user experience.

Context

While investigating issue #7328, it was noted that the "Preview System Prompt" button exists in the Modes section but users may have difficulty finding it there. This PR adds the same functionality to the Prompts settings tab where users might naturally look for it.

Changes

  • Added "Preview System Prompt" button with copy functionality to the PromptsSettings component
  • Added dialog for displaying the system prompt content
  • Added message handlers for systemPrompt events
  • Added translation for preview description

Benefits

  • Improved Discoverability: Users can now access the system prompt preview from the Prompts settings tab, a more intuitive location
  • Better UX: Reduces confusion for users looking for prompt-related features
  • Consistency: Maintains the same functionality as the existing button in Modes section

Testing

  • All existing tests pass
  • Manual testing confirms the button works correctly
  • No breaking changes to existing functionality

Note

The original issue #7328 was closed by the reporter after finding the button in the Modes section. However, this enhancement still provides value by making the feature more discoverable.

Closes #7328


Important

Adds a "Preview System Prompt" button to PromptsSettings.tsx for improved discoverability, with dialog display and copy functionality, and updates translations in prompts.json.

  • Behavior:
    • Adds "Preview System Prompt" button to PromptsSettings.tsx for better discoverability.
    • Includes copy functionality for the system prompt.
    • Displays system prompt content in a dialog.
  • Event Handling:
    • Adds message handlers for systemPrompt events in PromptsSettings.tsx.
  • Translations:
    • Updates prompts.json to include translations for the new button and its description.

This description was created by Ellipsis for e42b6fa. You can customize this summary. It will automatically update as commits are pushed.

- Added system prompt preview functionality to PromptsSettings component
- Added dialog for displaying the system prompt content
- Added message handlers for systemPrompt events
- Added translation for preview description
- Fixes #7328
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 22, 2025 17:45
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. UI/UX UI/UX related or focused labels Aug 22, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 22, 2025
} else if (message.type === "systemPrompt") {
if (message.text) {
setSelectedPromptContent(message.text)
setSelectedPromptTitle(`System Prompt (${message.mode} mode)`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using the translation function (t) to set the system prompt title instead of a hard-coded template literal. For example, use t('prompts:systemPrompt.title', { modeName: message.mode }) to ensure consistency with translations.

Suggested change
setSelectedPromptTitle(`System Prompt (${message.mode} mode)`)
setSelectedPromptTitle(t('prompts:systemPrompt.title', { modeName: message.mode }))

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.


{/* System Prompt Preview Dialog */}
{isDialogOpen && (
<div className="fixed inset-0 flex justify-end bg-black/50 z-[1000]">
Copy link
Contributor

Choose a reason for hiding this comment

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

For improved accessibility, consider adding appropriate ARIA attributes (e.g., role='dialog', aria-modal='true') to the system prompt preview modal container.

Suggested change
<div className="fixed inset-0 flex justify-end bg-black/50 z-[1000]">
<div className="fixed inset-0 flex justify-end bg-black/50 z-[1000]" role="dialog" aria-modal="true">

Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.


<Section>
{/* System Prompt Preview Section */}
<div className="mb-4">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This component is adding significant new functionality without any test coverage. Consider adding tests for:

  • The message event handlers (lines 60-79)
  • The dialog state management
  • The button click handlers
  • The integration with vscode.postMessage

</SectionHeader>

<Section>
{/* System Prompt Preview Section */}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This entire system prompt preview section (lines 135-167) duplicates functionality that already exists in ModesView.tsx. Could we extract this into a shared component like <SystemPromptPreview /> to follow DRY principles?

setTestPrompt(message.text)
}
setIsEnhancing(false)
} else if (message.type === "systemPrompt") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missing error handling here. What happens if message.text or message.mode is undefined? Consider adding defensive checks to prevent runtime errors.

<div className="fixed inset-0 flex justify-end bg-black/50 z-[1000]">
<div className="w-[calc(100vw-100px)] h-full bg-vscode-editor-background shadow-md flex flex-col relative">
<div className="flex-1 p-5 overflow-y-auto min-h-0">
<Button
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accessibility issue: This close button only has an icon without an aria-label. Screen reader users won't know what this button does. Consider adding aria-label="Close dialog".

</div>
<div className="flex justify-end p-3 px-5 border-t border-vscode-editor-lineHighlightBorder bg-vscode-editor-background">
<Button variant="secondary" onClick={() => setIsDialogOpen(false)}>
{t("prompts:createModeDialog.close")}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This translation key 'prompts:createModeDialog.close' seems to be borrowed from a different context (createModeDialog). Consider adding a dedicated translation key for this dialog, like 'prompts:systemPromptDialog.close' for better maintainability.


{/* System Prompt Preview Dialog */}
{isDialogOpen && (
<div className="fixed inset-0 flex justify-end bg-black/50 z-[1000]">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dialog styling mixes inline Tailwind classes with what appears to be VSCode-specific CSS variables. For consistency and maintainability, consider consolidating to one approach. Also, the fixed positioning with 'inset-0' might cause issues on smaller screens.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 23, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 23, 2025
@mrubens mrubens closed this Aug 24, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 24, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR - Needs Preliminary Review size:M This PR changes 30-99 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

"Preview System Prompt" button gone in Prompts settings

4 participants