-
Notifications
You must be signed in to change notification settings - Fork 32
🎨🔨 AI-assisted workflow for user-facing messages #7345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pcrespov
merged 21 commits into
ITISFoundation:master
from
pcrespov:is6673/auto-user-friendly-messages
Jun 19, 2025
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
65adc96
drafts ideas
pcrespov 7a7746f
implements #7362
pcrespov f32d961
reverts bad merge
pcrespov 5e6c763
errors templates
pcrespov 415ab47
feat: Add script for rewriting error messages using OpenAI API
pcrespov 624b128
adds instructions
pcrespov 299511b
refactor: Remove message extraction, refinement, and reintegration sc…
pcrespov aa6571d
adds mark
pcrespov 5dc7ad7
feat: Update error messages to use user_message for consistency acros…
pcrespov 513ed11
other user messages
pcrespov dee5f8a
feat: Add guidelines for updating user messages and enhance user_mess…
pcrespov 345f90f
feat: Update user messages in exception handlers for clarity and vers…
pcrespov 5dcaf45
feat: Update user messages for API key errors to enhance clarity and …
pcrespov cbd0c99
feat: Enhance user messages in exception handlers with versioning sup…
pcrespov 4c15ad5
cleanup
pcrespov afb0289
minor
pcrespov 3d2fa83
refactor: Remove unused error classes and factory functions from erro…
pcrespov fab6caa
@sanderegg review: version
pcrespov d4dee86
hightlighted strictly
pcrespov 0a108cc
rerun nuew prompt
pcrespov 7ec0c5e
tune
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| --- | ||
| mode: 'edit' | ||
| description: 'Update user messages' | ||
| --- | ||
|
|
||
| This prompt guide is for updating user-facing messages in ${file} or ${selection} | ||
|
|
||
| ## What is a User Message? | ||
|
|
||
| A user message is any string that will be displayed to end-users of the application. | ||
| In our codebase, these messages are marked with the `user_message` function: | ||
|
|
||
| ```python | ||
| from common_library.user_messages import user_message | ||
|
|
||
| error_msg = user_message("Operation failed. Please try again later.") | ||
| ``` | ||
|
|
||
| ## Guidelines for Updating User Messages | ||
|
|
||
| When modifying user messages, follow these rules: | ||
|
|
||
| 1. **Version Tracking**: Every modification to a user message must include an incremented `_version` parameter: | ||
|
|
||
| ```python | ||
| # Before modification | ||
| user_message("Error: Unable to connect to the server.") | ||
|
|
||
| # After modification | ||
| user_message("Error: Cannot establish connection to the server.", _version=1) | ||
| ``` | ||
|
|
||
| 2. **F-String Preservation**: When modifying messages that use f-strings, preserve all parameters and their formatting: | ||
|
|
||
| ```python | ||
| # Before | ||
| user_message(f"Project {project_name} could not be loaded.") | ||
|
|
||
| # After (correct) | ||
| user_message(f"Unable to load project {project_name}.", _version=1) | ||
|
|
||
| # After (incorrect - lost the parameter) | ||
| user_message("Unable to load project.", _version=1) | ||
| ``` | ||
|
|
||
| 3. **Message Style**: Follow the guidelines in `${workspaceFolder}/docs/user-messages-guidelines.md` | ||
|
|
||
| 4. **Preserve Context**: Ensure the modified message conveys the same meaning and context as the original. | ||
|
|
||
| 5. **Incremental Versioning**: If a message already has a version, increment it by 1: | ||
|
|
||
| ```python | ||
| # Before | ||
| user_message("Session expired.", _version=2) | ||
|
|
||
| # After | ||
| user_message("Your session has expired. Please log in again.", _version=3) | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Simple Message Update | ||
|
|
||
| ```python | ||
| # Before | ||
| error_dialog(user_message("Failed to save changes.")) | ||
|
|
||
| # After | ||
| error_dialog(user_message("Failed to save your changes. Please try again.", _version=1)) | ||
| ``` | ||
|
|
||
| ### Example 2: F-string Message Update | ||
|
|
||
| ```python | ||
| # Before | ||
| raise ValueError(user_message(f"Invalid input parameter: {param_name}")) | ||
|
|
||
| # After | ||
| raise ValueError(user_message(f"The parameter '{param_name}' contains an invalid value.", _version=1)) | ||
| ``` | ||
|
|
||
| ### Example 3: Already Versioned Message | ||
|
|
||
| ```python | ||
| # Before | ||
| return HttpErrorInfo(status.HTTP_404_NOT_FOUND, user_message("User not found.", _version=1)) | ||
|
|
||
| # After | ||
| return HttpErrorInfo(status.HTTP_404_NOT_FOUND, user_message("The requested user could not be found.", _version=2)) | ||
| ``` | ||
|
|
||
| Remember: The goal is to improve clarity and helpfulness for end-users while maintaining accurate versioning for tracking changes. |
4 changes: 2 additions & 2 deletions
4
docs/messages-guidelines.md → docs/user-messages-guidelines.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/common-library/src/common_library/user_messages.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| def user_message(msg: str, *, _version=None) -> str: | ||
| """Marks a message as user-facing | ||
| Arguments: | ||
| msg -- human-friendly string that follows docs/user-messages-guidelines.md | ||
| _version -- version number to track changes to messages; increment when modifying an existing message | ||
| Returns: | ||
| The original message string, allowing it to be used inline in code | ||
| """ | ||
| return msg | ||
pcrespov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from common_library.user_messages import user_message | ||
|
|
||
|
|
||
| def test_user_message() -> None: | ||
|
|
||
| assert user_message("This is a user message") == "This is a user message" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.