Scope generate_code_review_content to the window's team - #15560
Open
warp-agent-staging[bot] wants to merge 4 commits into
Open
Scope generate_code_review_content to the window's team#15560warp-agent-staging[bot] wants to merge 4 commits into
warp-agent-staging[bot] wants to merge 4 commits into
Conversation
Adds the X-Warp-Team-Uid header to the client-side POST /ai/generate_code_review_content call so commit-message and PR title/body generation resolve against the window's team instead of the server's lowest-team-id fallback.
All three callers are in-crate (remote_server::server_model); the constructor doesn't need to be more public than team_uid(), which it feeds.
Contributor
Author
|
This PR was generated with Warp. Comment |
Drop the comments that restate which code path a parameter reaches or the resolve-before-call sequencing; a reader following the code already learns that. Keep the daemon-headless comments and the trimmed doc on none_for_headless_context, which document a deliberate decision rather than mechanism.
Its only callers are the remote-server daemon's RPC handlers, which are only reachable from a #[cfg(not(target_family = "wasm"))] worker command. On the wasm target those handlers are themselves dead code, so this new pub(crate) fn had no live caller there, tripping the dead_code lint under -D warnings. Same idiom as list_agent_messages_for_task a few lines above in ai.rs.
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.


Description
Scopes the client-side
POST /ai/generate_code_review_contentcall (commit-message autogen and PR title/body generation inGitDialog) to the window's team by sendingX-Warp-Team-Uid.Previously this request carried no team header. The server falls through
GetActiveTeamOrFallbackToPrincipal→GetTeamForPrincipal, which picks the caller's lowest team id — an arbitrary team, not the one the window is actually working in. Since this endpoint's server handler (generate_code_review_content.go) writes billing metadata, an unscoped call attributed usage to the wrong team for any multi-team user whose window wasn't on their lowest-id team.The team now comes from the window (
ViewContext<GitDialog>→UserWorkspaces::team_context_for_view), resolved right before the model call so it can't drift to a fallback. That scope is threaded as aRequestTeamScopethroughDiffStateModel→LocalDiffStateModel→git_actions::{run_commit_chain, create_pr, generate_commit_message}→AIClient::generate_code_review_content, which is the one call site that actually sends the header (mirrors the/ai/multi-agentpattern from #15355).The remote-server daemon path (
RemoteDiffStateModel→ RPC →ServerModelhandlers) also calls this same endpoint, but the daemon is headless and has no window/team concept at all, so there's no live scope to resolve there. Those call sites now passRequestTeamScope::none_for_headless_context(), explicitly, rather than guessing a team — this is unchanged behavior for that path (no header was sent before either).Linked Issue
N/A — this PR was dispatched directly as part of a header-scoping cleanup pass, not from a tracked issue.
Testing
./script/formatandcargo clippy -p warp --lib --tests -- -D warningspass with no findings.cargo nextest run -p warpforcode_review::,remote_server::, andserver_api::ai::(150 tests, 149 passed / 128 + 149 across both runs; the one failure,ambient_agent_headers_for_task_overrides_existing_cloud_agent_header, is a pre-existing sandbox limitation — it also fails on unmodifiedmasterhere because thenscnamespace command is denied in this environment — and is unrelated to this change).RequestTeamScope/TEAM_UID_HEADERfrom [multi-team] Scope multi-agent requests to a team #15355.Screenshots / Videos
Not applicable — no UI change.
Agent Mode