Scope /ai/generate_input_suggestions to the window's team - #15558
Merged
Conversation
Send X-Warp-Team-Uid on the generate_ai_input_suggestions request so the server resolves the caller's window-selected team instead of falling back to GetTeamForPrincipal's lowest-team-id default. The server-side handler reads workspace settings and billing metadata scoped to a team, so an unscoped request could silently answer for the wrong team. The scope is threaded from BlocklistAIController::team_context (already resolved per-window for Agent Mode requests), captured immediately before the request is spawned so a mid-flight team switch cannot re-attribute an in-flight suggestion.
Contributor
Author
|
This PR was generated with Warp. Comment |
The team_scope resolution already reads as pinning the scope before the async block is spawned; the comment repeated that.
IsaiahWitzke
enabled auto-merge (squash)
August 26, 2026 04:04
IsaiahWitzke
approved these changes
Aug 26, 2026
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
Scopes the
POST /ai/generate_input_suggestionscall (next-command autosuggestions) to the window's selected team by sendingX-Warp-Team-Uid.Server-side, this endpoint reaches workspace settings and billing metadata (
generate_next_command.go) that are genuinely team-scoped. Without the header, the server falls throughGetActiveTeamOrFallbackToPrincipal→GetTeamForPrincipal, which silently answers using whichever team happens to have the lowest team id — not necessarily the team the window is showing.Changes
ServerApi::generate_ai_input_suggestionsnow takes aRequestTeamScopeand sends it via theX-Warp-Team-Uidheader (server already applies it for/ai/*viaSetActiveTeamFromHeader, so no server change is needed).NextCommandModelnow holds the terminal'sBlocklistAIControllerhandle and resolves the scope viaai_controller.team_context(ctx)immediately before spawning the request, mirroring the pattern used for/ai/multi-agent(PR [multi-team] Scope multi-agent requests to a team #15355) and passive suggestions — this keeps the team pinned to whatever the window was scoped to when the suggestion was requested, even if the user switches teams while the request is in flight.generate_next_command_suggestion_with_prefix(zero-state and prefixed suggestions).Verification
cargo check -p warp --libandcargo clippy -p warp --lib --tests -- -D warnings: clean../script/format: clean (only reformatted the new lines).cargo nextest run -p warpfornext_command_model,server_api, andteam_scope: 81/82 relevant tests pass. The one failure (ambient_agent_headers_for_task_overrides_existing_cloud_agent_header) is a pre-existing sandbox limitation (the test'snscnamespace-token command is denied in this environment) reproduced identically on unmodifiedmaster, unrelated to this change.