Skip to content

Improve validation and error feedback for Co-Authors input - #21851

Open
hi2242 wants to merge 3 commits into
desktop:developmentfrom
hi2242:issue-21736
Open

hi2242 wants to merge 3 commits into
desktop:developmentfrom
hi2242:issue-21736

Conversation

@hi2242

@hi2242 hi2242 commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

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

image

Then press Space

image

After

image

Then press Space

image

Release notes

Notes: Added validation and error feedback when attempting to add yourself or a duplicate user as a co-author.

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
Copilot AI review requested due to automatic review settings March 25, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

hi2242 added 2 commits March 25, 2026 18:16
…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.
@tidy-dev tidy-dev added ready-for-review Pull Requests that are ready to be reviewed by the maintainers external Pull request originating outside of the Desktop core team labels Oct 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external Pull request originating outside of the Desktop core team ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve UX for Co-Authors: Prevent self-assignment and provide duplicate warning

3 participants