Skip to content

Team selector ux fix - #31

Open
a-effort wants to merge 1 commit into
mainfrom
team-selection-single-team
Open

Team selector ux fix #31
a-effort wants to merge 1 commit into
mainfrom
team-selection-single-team

Conversation

@a-effort

@a-effort a-effort commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

UX issue
If an user has only one team, they see an error message in a form they are filling out and are required to leave their workflow to find the team switcher and make a selection, even if they are only part of 1 team. e.g.

error

Changes

  • Don't require team selection if only 1 team
  • Add the team selection option in form vs requiring the user to go to the selector at the top of the sidebar
  • Validate on form submit (vs on entering visibility)

The sidebar switcher stays authoritative for an open form (#5077) until the caller picks a team in the selector.

Root cause

Team visibility was driven entirely by the sidebar switcher, and selectedTeamId starts as null ("All teams") every session (AuthContext.tsx, also reset on login). The forms never looked at the actual team list, so they could not tell "no team chosen" apart from "only one team exists". A second, independent defect: usePromptForm re-validated in an effect whenever visibility was team, so the field turned red the moment the user picked "Team"... before they had done anything wrong.

What was added

  • src/hooks/useTeams.ts: useTeams() plus resolveTeamId(teams, selectedTeamId, explicitTeamId). Resolution order: explicit choice → sidebar's active team → the caller's personal team → first team. The last two steps are what keep a single-team caller from ever being asked, and give multi-team callers a sane default instead of an empty required field behind a disabled submit button.
  • src/components/common/TeamSelect.tsx: renders nothing below two teams; renders a labeled select above. It still renders an error with no selector, so a failed /teams load explains an inert submit button rather than failing silently.

Both are shared by all three forms, which previously each had their own copy of the sidebar-mirroring logic: prompts (usePromptForm + PromptForm), tools (ToolAdvancedSettings), servers (mcp-servers/AdvancedSettings).

Other changes

  • Error moved from visibility to teamId in the prompt schema, so the message lands on the selector rather than the visibility dropdown. API team_id field errors now map to teamId too (previously visibility).
  • i18n cleanup across all three locales (en-US, es-ES, pt-BR): removed prompts.add.visibility.team.selectedHint and ...selectFromSidebarHint; added common.team.label, common.team.placeholder, common.required. The hardcoded English equivalents in the tool and server forms are gone as well.
    -teamError prop added to ToolAdvancedSettings and mcp-servers/AdvancedSettingserrors.teamId existed in both form hooks but was never rendered anywhere.
    -usePromptForm now owns team state (teamId + setTeamId) instead of deriving it read-only from the sidebar.

Testing

npm test green: 161 files, 2857 passed / 1 skipped. Typecheck and lint clean.

New: useTeams.test.ts, TeamSelect.test.tsx. Updated the team-visibility cases in usePromptForm.test.ts, PromptForm.test.tsx, MCPServerForm.test.tsx, AdvancedSettings.test.tsx, ToolAdvancedSettings.test.tsx

The old ones asserted the sidebar hint text and the pre-submit error, both of which are the behavior being removed.

Notes

  1. Edit mode can still have its team overwritten. With team visibility, the sidebar/default wins until the user touches the selector, so editing a team-scoped server can retarget it. This is pre-existing (the old code mirrored selectedTeamId unconditionally) and not introduced here. We should consider changing this as a follow up.
  2. MCPServerForm.test.tsx > team visibility > shows the selector for several teams asserts only that the selector renders, not that it defaults to the personal team. The state does propagate correctly (verified by instrumenting the effect); that MSW-driven test's DOM would not settle on it. The defaulting behavior is asserted in AdvancedSettings.test.tsx and PromptForm.test.tsx.
  3. One test was removed: ToolAuth.test.tsx > shows team scope hint.... The hint no longer exists, and that file has no /teams mock, so any replacement would have passed for the wrong reason. Equivalent coverage lives in ToolAdvancedSettings.test.tsx.

Team visibility was driven entirely by the sidebar switcher, which starts
on "All teams" every session. A caller with one team was told to go pick
the only team they have, and the form flagged the field red the moment
they chose "Team" — before they had done anything wrong.

Resolve the team in the form instead: an explicit choice, else the
sidebar's active team, else the caller's personal (or only) team. Callers
in more than one team now pick inline via a new TeamSelect rather than
being sent to the sidebar, and the requirement is raised on submit rather
than on entering team visibility.

The sidebar switcher stays authoritative for an open form (#5077) until
the caller picks a team in the selector.

Signed-off-by: Anna Effort <anna.effort@ibm.com>
@a-effort
a-effort force-pushed the team-selection-single-team branch from d530df8 to 7d79a6b Compare August 14, 2026 20:15
@a-effort
a-effort requested review from gcgoncalves, marekdano and vishu-bh and removed request for gcgoncalves August 14, 2026 20:16
@a-effort
a-effort marked this pull request as ready for review August 14, 2026 20:16

@gcgoncalves gcgoncalves 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.

Nice validation addition. 👏

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants