Add long-context usage warning indicator#13254
Conversation
Co-Authored-By: Oz <oz-agent@warp.dev>
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds long-context pricing-warning state, wiring from conversation usage/model metadata, a themed context-window chip warning, and persistence/API fields for total input token counts.
Concerns
- The warning visibility path does not consult the new
LongContextWarningfeature flag, so the new UI can appear outside the intended dogfood/flag rollout. - This is a user-facing UI change, but the PR description does not include screenshots or a screen recording demonstrating the warning end to end. Please attach visual evidence for this change before merge.
Verdict
Found: 0 critical, 2 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| { | ||
| let usage = conversation.context_window_usage(); | ||
| let icon = icon_for_context_window_usage(usage); | ||
| let show_long_context_warning = self.long_context_warning_state.is_visible(); |
There was a problem hiding this comment.
LongContextWarning feature flag, so any user with threshold metadata can see the UI outside the intended rollout. Gate the visibility on FeatureFlag::LongContextWarning.is_enabled().
| let show_long_context_warning = self.long_context_warning_state.is_visible(); | |
| let show_long_context_warning = FeatureFlag::LongContextWarning.is_enabled() | |
| && self.long_context_warning_state.is_visible(); |
Adds a long-context usage warning indicator to the agent input footer, with the client deciding visibility from server-provided threshold and input data.
total_input_tokens(latest primary-agent call input tokens of the latest persisted charged/BYOK request) through the proto stream, GraphQL restore, and local persistence, and expose each model'slongContextThresholdonLlmContextWindow.provider == OpenAI && total_input_tokens > thresholdfor the active model.crates/persistence/src/model.rs,app/src/ai/agent/conversation.rs: persist/applytotal_input_tokens(nonzero overwrites, zero keeps previous, matching server merge semantics).crates/graphql/src/api/...,crates/warp_graphql_schema/api/schema.graphql:totalInputTokenson conversation usage; nullablelongContextThresholdonLlmContextWindow;LLMContextWindow.long_context_thresholdon the client model metadata.app/src/ai/blocklist/usage/mod.rs:LongContextWarningStatenow holds tokens + active model provider/threshold and derives visibility; UI rendering (icon, tooltip, yellow warning theme) is unchanged.Counterparts:
total_input_tokens, pinned at7de66cc8)Linked Issue
ready-to-specorready-to-implement.Testing
app/src/ai/blocklist/usage/mod_tests.rs: threshold boundary (at vs +1), no-threshold model (Auto), non-OpenAI providers hidden despite threshold, model-switch recompute (lower/higher/non-OpenAI), zero tokens, icon behavior.crates/persistence/src/model_tests.rs:total_input_tokensJSON round-trip and legacy-row default.cargo nextesttargeted run (56 tests) passes;./script/formatrun;cargo clippy --all-targets -- -D warningsclean on touched packages (warp,persistence,warp_graphql).Screenshots / Videos
https://www.loom.com/share/e2ea70c8db7a4ce6ada8c766c5a425da
different themes:
https://www.loom.com/share/9d0d634e82314f39ba8e1eab0c69363e
Agent Mode
Plan: https://staging.warp.dev/drive/notebook/yJt0g7NfiwnSYuQdNfQAO1
Conversation: https://staging.warp.dev/conversation/4321295c-fe0b-4a19-9382-44738d7db792
Co-Authored-By: Oz oz-agent@warp.dev