Skip to content

Scope AI generation GraphQL operations to the window's team - #15562

Open
warp-agent-staging[bot] wants to merge 1 commit into
masterfrom
factory/team-header-ai-generation
Open

Scope AI generation GraphQL operations to the window's team#15562
warp-agent-staging[bot] wants to merge 1 commit into
masterfrom
factory/team-header-ai-generation

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Client-side fix for REV-2331: when the client sends no X-Warp-Team-Uid, the server's GetActiveTeamOrFallbackToPrincipal falls back to GetTeamForPrincipal, which picks the lowest team id — an unscoped, confidently-wrong answer for multi-team users. This PR scopes the three AI-generation GraphQL operations in app/src/server/server_api/ai.rs to 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

  • Added ServerApi::send_team_scoped_graphql_request, a thin wrapper around the existing transport helper that converts a RequestTeamScope into the Option<String> team uid it expects.
  • Added a team_scope: RequestTeamScope parameter to the AIClient trait methods generate_commands_from_natural_language, generate_dialogue_answer, and generate_metadata_for_command, and switched their implementations to send_team_scoped_graphql_request.
  • Threaded a live scope into each call site, resolved from the window/view that actually issued the request (never an account-default team):
    • AIAssistantPanelView::issue_requestRequests::issue_requestgenerate_dialogue_answer, scope resolved via UserWorkspaces::team_context_for_operation(ctx) in the panel's ViewContext.
    • CommandSearchView::reset_command_search_mixer resolves the scope once per mixer reset and passes it into WarpAIDataSource::new, which carries it into generate_commands_from_natural_language.
    • WorkflowModal::issue_request (Warp Drive workflow creation modal) and WorkflowView::issue_request (workflow pane) each resolve their own scope from their ViewContext before calling generate_metadata_for_command.
  • None of the three operations' GraphQL variables (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 warp filtered to the touched surfaces (command_search, workflow_view, ai_assist, ai_assistant, modal_tests, warp_ai) — 26/26 passed.
  • This is a plumbing change (adding a header to existing requests); no new externally-observable behavior needed a new test, and no existing tests exercised these call sites' team resolution.

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
@cla-bot cla-bot Bot added the cla-signed label Aug 26, 2026
@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review August 26, 2026 05:17
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

Comment @warp-factory on this PR to send it follow-up work.

View run View conversation View on Slack

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants