Skip to content

Scope /ai/generate_input_suggestions to the window's team - #15558

Merged
IsaiahWitzke merged 2 commits into
masterfrom
factory/team-header-input-suggestions
Aug 26, 2026
Merged

Scope /ai/generate_input_suggestions to the window's team#15558
IsaiahWitzke merged 2 commits into
masterfrom
factory/team-header-input-suggestions

Conversation

@warp-agent-staging

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

Copy link
Copy Markdown
Contributor

Summary

Scopes the POST /ai/generate_input_suggestions call (next-command autosuggestions) to the window's selected team by sending X-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 through GetActiveTeamOrFallbackToPrincipalGetTeamForPrincipal, 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_suggestions now takes a RequestTeamScope and sends it via the X-Warp-Team-Uid header (server already applies it for /ai/* via SetActiveTeamFromHeader, so no server change is needed).
  • NextCommandModel now holds the terminal's BlocklistAIController handle and resolves the scope via ai_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.
  • Threaded the resolved scope through both call sites in generate_next_command_suggestion_with_prefix (zero-state and prefixed suggestions).

Verification

  • cargo check -p warp --lib and cargo clippy -p warp --lib --tests -- -D warnings: clean.
  • ./script/format: clean (only reformatted the new lines).
  • cargo nextest run -p warp for next_command_model, server_api, and team_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's nsc namespace-token command is denied in this environment) reproduced identically on unmodified master, unrelated to this change.
  • No UI-visible behavior changed (this is a header addition on an existing background request), so no visual proof was captured.

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.
@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 03:55
@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

The team_scope resolution already reads as pinning the scope before the
async block is spawned; the comment repeated that.
@IsaiahWitzke
IsaiahWitzke enabled auto-merge (squash) August 26, 2026 04:04
@IsaiahWitzke
IsaiahWitzke merged commit 711a44e into master Aug 26, 2026
27 checks passed
@IsaiahWitzke
IsaiahWitzke deleted the factory/team-header-input-suggestions branch August 26, 2026 04:30
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.

1 participant