Scope AI generation GraphQL operations to the window's team - #15562
Open
warp-agent-staging[bot] wants to merge 1 commit into
Open
Scope AI generation GraphQL operations to the window's team#15562warp-agent-staging[bot] wants to merge 1 commit into
warp-agent-staging[bot] wants to merge 1 commit into
Conversation
Threads a live RequestTeamScope through generate_commands_from_natural_language, generate_dialogue_answer, and generate_metadata_for_command so the X-Warp-Team-Uid header reflects the window's selected team instead of letting the server fall back to the account's lowest team id. - Add ServerApi::send_team_scoped_graphql_request, wrapping the transport's team-scoped GraphQL helper from PR #15557. - Resolve the scope at each call site from the live window/view context (UserWorkspaces::team_context_for_operation) rather than an account-default team: - AIAssistantPanelView::issue_request (dialogue answers) - WarpAIDataSource / CommandSearchView (command generation) - WorkflowModal::issue_request and WorkflowView::issue_request (command metadata generation) REV-2331
Contributor
Author
|
This PR was generated with Warp. Comment |
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.



Summary
Client-side fix for REV-2331: when the client sends no
X-Warp-Team-Uid, the server'sGetActiveTeamOrFallbackToPrincipalfalls back toGetTeamForPrincipal, which picks the lowest team id — an unscoped, confidently-wrong answer for multi-team users. This PR scopes the three AI-generation GraphQL operations inapp/src/server/server_api/ai.rsto the window's live team, using the transport support landed in #15557 (BaseClient::graphql_request_options_with_team,graphql_helpers::send_team_scoped_graphql_request).Changes
ServerApi::send_team_scoped_graphql_request, a thin wrapper around the existing transport helper that converts aRequestTeamScopeinto theOption<String>team uid it expects.team_scope: RequestTeamScopeparameter to theAIClienttrait methodsgenerate_commands_from_natural_language,generate_dialogue_answer, andgenerate_metadata_for_command, and switched their implementations tosend_team_scoped_graphql_request.AIAssistantPanelView::issue_request→Requests::issue_request→generate_dialogue_answer, scope resolved viaUserWorkspaces::team_context_for_operation(ctx)in the panel'sViewContext.CommandSearchView::reset_command_search_mixerresolves the scope once per mixer reset and passes it intoWarpAIDataSource::new, which carries it intogenerate_commands_from_natural_language.WorkflowModal::issue_request(Warp Drive workflow creation modal) andWorkflowView::issue_request(workflow pane) each resolve their own scope from theirViewContextbefore callinggenerate_metadata_for_command.GenerateCommandsInput,GenerateDialogueInput,GenerateMetadataForCommandInput) name a team, so there's no risk of a header/variable mismatch.All three call chains had a genuine live window scope available (these are user-initiated actions from an open terminal/workflow window), so nothing in this group was left unscoped.
Verification
./script/format— clean.cargo clippy -p warp --lib --tests -- -D warnings— clean../script/bundle --channel oss --nouniversal --check-only— succeeded (only pre-existing, unrelated warnings).cargo nextest run -p warpfiltered to the touched surfaces (command_search,workflow_view,ai_assist,ai_assistant,modal_tests,warp_ai) — 26/26 passed.