Client: dev-only context-window segment breakdown in usage card#12646
Draft
harryalbert wants to merge 2 commits into
Draft
Client: dev-only context-window segment breakdown in usage card#12646harryalbert wants to merge 2 commits into
harryalbert wants to merge 2 commits into
Conversation
Ingests the new `context_window_segments` field from the multi-agent StreamFinished proto and renders an expandable per-segment breakdown (system prompt, tool definitions, conversation history, etc.) beside the "Context window used" row in the conversation usage card. Values are estimated/derived, so the breakdown is labeled "ESTIMATED BREAKDOWN" and percentages are prefixed with `~`. Gated behind the dev-only `ContextWindowUsageBreakdown` feature flag (not in app/Cargo.toml `default`; enable via `--features context_window_usage_breakdown`). Temporary cross-repo wiring: points `warp_multi_agent_api` at the local warp-proto-apis checkout via a Cargo path patch (see revert TODO). Co-Authored-By: Oz <oz-agent@warp.dev>
Extends the breakdown beyond the live stream: adds the `contextWindowSegments` field + `ContextWindowSegment` type to the bundled GraphQL schema, wires matching cynic fragments in the conversation-usage and AI-conversation queries, and maps the GraphQL segments into the persistence model. Removes the empty-default workarounds on the historical paths. Co-Authored-By: Oz <oz-agent@warp.dev>
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
Client (§3) of the dev-only context-window-usage segment breakdown plan.
Ingests the new
context_window_segmentsfield on the multi-agentStreamFinished.ConversationUsageMetadataproto and renders anexpandable per-segment breakdown beside the "Context window used" row in
the conversation usage card. The breakdown lists segments such as system
prompt, tool definitions, conversation history, and latest input.
Because the per-segment values are estimated/derived (scaled to the
exact displayed total), the breakdown is introduced by an
"ESTIMATED BREAKDOWN" header and each percentage is prefixed with
~.Changes
crates/persistence/src/model.rs: newContextWindowSegmentstruct +#[serde(default)]context_window_segmentsfield onConversationUsageMetadata, with protoFromconversions (both directions).app/src/ai/agent/conversation.rs: copies segments from the proto inupdate_cost_and_usage_for_request; addscontext_window_segments()accessor.app/src/ai/blocklist/usage/conversation_usage_view.rs:ConversationUsageInfo.context_window_segments;ToggleContextWindowExpandedaction +context_window_expandedstate + mouse state;render_context_window_toggle/append_context_window_segment_rowshelpers;handle_actionwiring.app/src/terminal/view.rs: populates the segment vec when building the usage footer.ContextWindowUsageBreakdown(sibling ofContextWindowUsageV2) inwarp_features,app/src/features.rs,app/Cargo.toml. Dev-only: intentionally not added todefault; enable via--features context_window_usage_breakdown.Temporary cross-repo wiring (revert before merge)
Cargo.toml: path patch pointingwarp_multi_agent_apiat the localwarp-proto-apischeckout (with a TODO to revert and bump the git rev once the proto change merges).Verification
cargo check -p warp✓cargo check -p warp --features context_window_usage_breakdown✓cargo fmt --check✓Conversation: https://staging.warp.dev/conversation/95bb9b48-02cf-4f8d-a157-bc4653694e6f
Run: https://oz.staging.warp.dev/runs/019ecbbe-4836-75e3-987f-656c693aa297
This PR was generated with Oz.