feat(frontend): team picker on create flows + per-surface last-used default - #13637
feat(frontend): team picker on create flows + per-surface last-used default#13637ntindle wants to merge 5 commits into
Conversation
…efault (SECRT-2488) Add a shared TeamPicker (contextual) that lists Organization (org-home) plus the user's teams, hidden entirely for solo users. Selecting a team stamps the create call's ownership via a per-request X-Team-Id header (no create-request body accepts a team field), captured in custom-mutator so the explicit pick wins over the store's org context. Per-surface last-used team is remembered in a new localStorage map. Teams remain badges/filters, never a context switch — the global activeTeamID is untouched. Wired: builder save-new, builder fork/duplicate, builder cron schedule, library folder create, library agent upload, schedule-agent modal, API key create (team restriction). Co-Authored-By: Claude Opus <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/batch |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/org-role-dropdown #13637 +/- ##
==========================================================
- Coverage 76.15% 76.14% -0.01%
==========================================================
Files 2733 2737 +4
Lines 202181 202239 +58
Branches 19659 19673 +14
==========================================================
+ Hits 153962 154002 +40
- Misses 43940 43958 +18
Partials 4279 4279
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/batch orgs |
1 similar comment
|
/batch orgs |
Address review on the create-flow team picker: - Choosing Organization (org-home) now drops the active-team context header instead of silently inheriting the nav team. getTeamRequestInit sends an empty X-Team-Id sentinel that customMutator reads to suppress the store-derived team header (and strips before it reaches the backend). - useCreateTeamSelection clamps a stale last-used team even when the user has no teams (solo), guarded by the store's isLoaded flag so it never clears mid-load, and now also resets the persisted value so a remount can't resurrect the deleted id. Co-Authored-By: Claude Opus <noreply@anthropic.com>
…eat/team-picker-creates Clean forward-merge (inherits OrgTeamProvider resolution). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBwmh7CkHiF8vKLBf2GWTU
…e useSupabase→useAuth (keep branch's test additions) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBwmh7CkHiF8vKLBf2GWTU
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f6b3d6b. Configure here.
| setTeamId, | ||
| hasTeams: teams.length > 0, | ||
| teamRequestInit: getTeamRequestInit(teamId), | ||
| }; |
There was a problem hiding this comment.
Stale team id in create header
Medium Severity
teamRequestInit is built from raw teamId state while useTeamPicker shows Organization whenever the id is not in the current team list. After a stale last-used id (or before clamp runs), the picker can display org-home while the create mutation still sends that obsolete id in X-Team-Id until the effect updates state.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f6b3d6b. Configure here.


Why
SECRT-2488 / SECRT-2462: the decided create-time model — explicit team picker on every create flow, defaulting to last-used per surface — existed nowhere. Every resource silently landed org-home.
What
TeamPicker(shared,components/contextual/TeamPicker/): Select of Organization + my teams; per-surface last-used default persisted in a newKey.CREATE_SURFACE_TEAMSlocalStorage map; renders nothing for solo users.X-Team-Idheader via a minimalcustom-mutatorextension (explicit pick wins over global org-context headers; the store's retiredactiveTeamIDis never touched). Backend resolves it throughget_request_context→ctx.team_id, with feat(backend): accept explicit team_id on create/save flows #13540's explicit body params as the follow-up transport once the batch's OpenAPI regenerates.Testing
18 tests: picker behavior (7), last-used helpers (7), API-key dialog header on/off (2), fork header carry (2); plus all 32 existing tests importing touched files. format/lint/types clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Jm3mCG9okfdGtAXtFaDF9A
Note
Medium Risk
Changes tenancy headers on multiple create paths (graphs, schedules, folders, API keys); incorrect header handling could mis-assign ownership, though behavior is covered by new mutator and dialog tests.
Overview
Introduces a shared
TeamPicker(Organizationvs user teams, hidden for solo users) backed byuseCreateTeamSelection, which seeds each surface from acreate-surface-teamslocalStorage map and exposesgetTeamRequestInitfor Orval mutations.Wired into: builder save-new (picker only when no
flowID), read-only duplicate/fork, builder cron schedule, library folder create, library upload, agent schedule modal, and API key create—with surface-specific labels where needed (e.g. “Restrict to team”, “Duplicate into team”).Transport: create calls pass
X-Team-Idon the request;custom-mutatornow lets an explicit team id override nav context, and an empty sentinel forces org-home by stripping the team header (so “Organization” still wins when a team is active in the shell).useSaveGraph/useDuplicateGraph/ API key hook apply the same pattern on graph create and fork.Tests cover picker behavior, last-used helpers, mutator header rules, and integration checks that fork/API-key create send or omit
X-Team-Idas expected.Reviewed by Cursor Bugbot for commit f6b3d6b. Bugbot is set up for automated code reviews on this repo. Configure here.