Repository navigation
Conversation
Add validation to the Co-Authors input field to display error messages in two scenarios: - When a user attempts to add their own account (preventing self-assignment). - When a user tries to add a co-author that has already been added (preventing silent failures on duplicates). This provides clear visual feedback and prevents logical redundancies. Fixes desktop#21736
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Co-Authors input UX by adding explicit validation feedback when a co-author addition is rejected (self-assignment and duplicates), instead of failing silently.
Changes:
- Add a transient validation message state + callout UI to the Co-Authors input for rejected additions.
- Prevent selecting/adding the currently logged-in user as a co-author (including in exact-match lookup).
- Refactor minor code organization (helpers/import ordering) around author input and autocompletion.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/styles/ui/_author-input.scss | Adds styling for the new inline validation callout under the author input. |
| app/src/ui/lib/author-input/author-input.tsx | Implements self/duplicate rejection logic, transient validation messaging, and timeout cleanup. |
| app/src/ui/lib/author-input/author-handle.tsx | Import ordering only. |
| app/src/ui/autocompletion/user-autocompletion-provider.tsx | Adds isCurrentUser helper and blocks exact-match results for the current user. |
| app/src/ui/autocompletion/autocompleting-text-input.tsx | Import ordering only. |
…callout The AuthorInput component already utilizes a dedicated visually-hidden live region to announce actions via `lastActionDescription`. Adding `role="alert"` and `aria-live="polite"` to the visual validation callout causes screen readers to announce the rejection message twice. This removes the redundant attributes from the visual callout to prevent duplicate announcements.
When a user manually types a username with leading `@` symbols (e.g., `@username` or `@@username`) and uses space-to-commit, the raw string bypasses the exact-match validation for self-assignment and duplicates. This update normalizes the `username` in `onAutocompleteItemSelected` by stripping whitespace and all leading `@` characters before running validation and creating the author. This ensures robust validation and prevents malformed co-author tags from being added.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Comment
Resubmitting with additional improvements (Previously #21821)
Hi! I’m resubmitting this PR as the previous one (#21821) was closed due to a period of inactivity without a review.
While the core goal remains the same—preventing silent failures and self-assignments in the Co-Authors input—I have updated this PR to include two additional improvements based on Copilot's code review feedback from the previous iteration:
Input Normalization: Fixed an edge case where manually typing leading @ symbols (e.g., @@username) and using space-to-commit would bypass the new validation.
Accessibility (a11y) Polish: Removed redundant screen reader announcements for the validation callout.
I would greatly appreciate it if you could take a look when you have a moment. Thank you!
Closes #21736
Description
This PR introduces explicit validation for the Co-Authors input field to prevent logical redundancies and improve UX by eliminating silent failures.
Currently, the app allows users to add their own account as a co-author, and silently ignores attempts to add duplicate co-authors without any visual feedback. While the raw Git CLI permits these, GitHub Desktop as a GUI should provide clearer guardrails.
Changes made:
Self-assignment prevention: Added validation to check if the entered handle matches the currently logged-in user. If it does, the UI now explicitly prevents the addition and displays an error state (warning message).
Duplicate prevention feedback: Modified the logic so that when a user attempts to add an already existing co-author, the action is no longer silently ignored. Instead, it triggers an error state to clearly inform the user why the action was rejected.
Input Normalization (Edge Case Fix): Added logic to strip whitespace and leading @ symbols (^@+) before validation. Previously, if a user manually typed @username or @@username and pressed Space to commit, the raw string bypassed the exact-match validation and resulted in malformed tags. This normalization ensures robust validation regardless of how the user formats their input.
Accessibility (a11y) Polish: Ensured the new visual validation callout does not conflict with the existing lastActionDescription live region, preventing screen readers from announcing the rejection message twice.
This provides users with immediate, clear visual feedback and prevents unnecessary confusion.
Screenshots
Before
UX.non-sense.in.Co-Authors.Before.mp4
After
UX.non-sense.in.Co-Authors.After.mp4
Solving additionally discovered issues
Before
Then press Space
After
Then press Space
Release notes
Notes: Added validation and error feedback when attempting to add yourself or a duplicate user as a co-author.