fix(ui): split higher-rate threshold hints from model context limits#47540
fix(ui): split higher-rate threshold hints from model context limits#47540futuremind2026 wants to merge 7 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR correctly separates the UI presentation of higher-rate pricing thresholds from model context-limit warnings, adds a config toggle ( However, there is a logic defect in
The fix is straightforward: change Confidence Score: 2/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: ui/src/ui/views/chat.ts
Line: 340-354
Comment:
**Second guard silently swallows 85-99% warnings for known models**
The function has two independent "return nothing" gates, but the conditions don't agree, causing a silent regression:
- Line 340 computes `shouldShowModel = modelRatio >= 0.85 || shouldShowPricing` and the first gate (line 341-343) passes control forward when `modelRatio >= 0.85`.
- Line 351 then computes `shouldShow = shouldShowPricing || shouldShowModelWarning || (!known && modelRatio >= 0.85)`.
The critical difference is `!known` in the third condition. When a model **is** in `KNOWN_CONTEXT_THRESHOLDS` (e.g. `openai/gpt-5.4`, any Gemini model), and usage is between 85 % and 100 % of the model limit, and the pricing threshold has **not** yet been crossed:
- `shouldShowPricing` = false
- `shouldShowModelWarning` = false (ratio < 1.0)
- `!known` = **false**
→ `shouldShow` = false → `return nothing` fires.
So a GPT-5.4 session at, say, 900 k / 1.05 M (86 %) with input tokens below 272 k gets **no notice at all**, even though the first guard already decided it should. The same happens for every Gemini model that only has `pricingThresholdTokens` (no `modelContextTokens`), because `known` is non-null there too.
The fix is to add `modelRatio >= 0.85` unconditionally (or just drop the second gate entirely and merge the conditions into one):
```suggestion
const shouldShowModelWarning = contextUsed >= modelLimit;
const shouldShow = shouldShowPricing || shouldShowModelWarning || modelRatio >= 0.85;
if (!shouldShow) {
return nothing;
}
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 656a9ce |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 656a9cefa9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e8e0719ea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Thanks — I pushed a follow-up fix in 0e8e0719ea. This addresses two issues:
Also included:
Validation run:
|
0e8e071 to
fadaf18
Compare
|
Refreshed this PR onto current main and removed unrelated generated docs-baseline churn. Duplicate combined draft #48898 was closed; this PR remains the canonical upstream UI thread. |
|
Status update after refresh onto current main:
Current CI note:
I am keeping this PR open because the remaining diff is still real and not covered by upstream yet. |
|
Addressed the stale-session warning regression in eb2bf34baf. The refreshed branch now falls back to inputTokens when otalTokens is temporarily unavailable, so the near-limit warning still appears for stale gateway rows instead of disappearing. A browser regression test was added in ui/src/ui/chat-context-notice.browser.test.ts for the missing- otalTokens case. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb2bf34baf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Follow-up update after the latest review comment:
Validation rerun on the refreshed branch:
Current CI note:
|
b757d90 to
a0fe731
Compare
|
Refreshed this PR onto current main and force-pushed the branch at a0fe731ac2. This push is a clean rebase refresh on top of the current upstream baseline. The previously addressed behavior fixes remain the same:
Validation rerun on the refreshed branch:
CI has been re-triggered after the force-push. |
|
Addressed one more compatibility gap here. Added the legacy Gemini aliases to KNOWN_CONTEXT_THRESHOLDS, including google-gemini-cli/gemini-3-pro-preview, so older supported Gemini sessions still go through the split pricing-threshold notice path instead of falling back to the runtime-limit-only branch. Pushed in 868bd4cc7acacd6a7c5f994ad02884d28da42eda. Added a browser regression in ui/src/ui/chat-context-notice.browser.test.ts and verified with:
|
868bd4c to
0eae6c8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0eae6c8f54
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Refreshed this branch onto the latest origin/main and kept the verified runtime fixes in place. Additional follow-up in this refresh:
Scoped verification completed:
pnpm check still hits the current unrelated origin/main lint failure in src/infra/exec-approvals-allow-always.test.ts, so I did not expand this PR to fix that separate mainline issue. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 859bbcc46f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 166e7361b8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
166e736 to
b5ddc23
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5ddc23167
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
b5ddc23 to
bb87738
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb877380f1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
bb87738 to
774d558
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 774d558e64
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const shouldShowPricing = | ||
| showPricingThresholdNotice && | ||
| typeof known?.pricingThresholdTokens === "number" && | ||
| inputUsed >= known.pricingThresholdTokens; |
There was a problem hiding this comment.
Base pricing-threshold crossing on fresh context tokens
shouldShowPricing is keyed off inputUsed (session.inputTokens), but that field is an aggregate across model calls in a run (including tool/retry loops), not a fresh context snapshot. This can mark Higher-rate billing threshold crossed. for runs where no individual request actually exceeded the model’s higher-rate tier, producing false billing warnings in chat. Use fresh context usage (totalTokens/last-call snapshot) for the threshold check instead of aggregated run input.
Useful? React with 👍 / 👎.
|
This pull request has been automatically marked as stale due to inactivity. |
|
Codex review: found issues before merge. Summary Reproducibility: yes. The review findings are source-reproducible by comparing PR-head Next step before merge Security Review findings
Review detailsBest possible solution: Rebase or replace the branch on current main, extending the current context-notice model with a maintainer-approved threshold source and adding the setting through the authorized bootstrap/config-doc hash workflow. Do we have a high-confidence way to reproduce the issue? Yes. The review findings are source-reproducible by comparing PR-head Is this the best way to solve the issue? No. The direction is useful, but this stale branch is not the best current solution because it bypasses current bootstrap auth, uses aggregate input usage for a pricing claim, and targets obsolete generated config artifacts. Full review comments:
Overall correctness: patch is incorrect Security concerns:
Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 8e79392dccf4. |
|
Codex review: found issues before merge. What this changes: The PR adds Maintainer follow-up before merge: This is an open implementation PR with a security-sensitive stale rebase, a product/accuracy decision about pricing-threshold truth, and obsolete generated baseline churn; maintainers should review or refresh it rather than handing it directly to an autonomous replacement lane. Review findings:
Review detailsBest possible solution: Rebase or replace the branch on current main, implement the threshold split in the current Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against e46dccb35374. |
Summary
gateway.controlUi.chat.showPricingThresholdCurrent Scope
This PR was refreshed on top of current
main.It now intentionally contains only the UI/config/gateway changes needed for the control-ui context notice behavior:
src/config/schema.help.tssrc/config/schema.labels.tssrc/config/types.gateway.tssrc/config/zod-schema.tssrc/gateway/control-ui*ui/src/styles/components.cssui/src/ui/chat-context-notice.browser.test.tsui/src/ui/controllers/control-ui-bootstrap*ui/src/ui/views/chat.tsGenerated docs-baseline churn was intentionally removed during the refresh so this PR stays reviewable.
Behavior
gateway.controlUi.chat.showPricingThresholdValidation
Local refresh validation:
node scripts/ui.js buildvitestpackage reliably after refresh, so authoritative verification should come from GitHub Actions on this refreshed branchNotes
#48898was closed; this PR remains the canonical upstream UI thread for this change set