Skip to content

fix(ui): split higher-rate threshold hints from model context limits#47540

Open
futuremind2026 wants to merge 7 commits intoopenclaw:mainfrom
MaGonglei:pr/gpt54-context-threshold-ui-20260316-01
Open

fix(ui): split higher-rate threshold hints from model context limits#47540
futuremind2026 wants to merge 7 commits intoopenclaw:mainfrom
MaGonglei:pr/gpt54-context-threshold-ui-20260316-01

Conversation

@futuremind2026
Copy link
Copy Markdown
Contributor

@futuremind2026 futuremind2026 commented Mar 15, 2026

Summary

  • split chat context messaging into distinct signals for:
    • higher-rate pricing threshold
    • model context ceiling
  • add gateway.controlUi.chat.showPricingThreshold
  • keep the existing 85%+ model-context warning path for known models
  • fix the oversized/unstable notice rendering in Control UI

Current 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.ts
  • src/config/schema.labels.ts
  • src/config/types.gateway.ts
  • src/config/zod-schema.ts
  • src/gateway/control-ui*
  • ui/src/styles/components.css
  • ui/src/ui/chat-context-notice.browser.test.ts
  • ui/src/ui/controllers/control-ui-bootstrap*
  • ui/src/ui/views/chat.ts
  • related UI wiring/tests

Generated docs-baseline churn was intentionally removed during the refresh so this PR stays reviewable.

Behavior

  • render a compact, stable context notice in Control UI
  • show higher-rate pricing threshold separately from the model-context ceiling
  • preserve the high-context warning for known models even before the pricing threshold is crossed
  • allow operators to hide pricing-threshold hints with gateway.controlUi.chat.showPricingThreshold

Validation

Local refresh validation:

  • passed: node scripts/ui.js build
  • note: temporary local test-worktree environment on my side could not resolve the root vitest package reliably after refresh, so authoritative verification should come from GitHub Actions on this refreshed branch

Notes

  • duplicate combined draft PR #48898 was closed; this PR remains the canonical upstream UI thread for this change set
  • scope remains limited to Control UI / config plumbing only

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: M labels Mar 15, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 15, 2026

Greptile Summary

This PR correctly separates the UI presentation of higher-rate pricing thresholds from model context-limit warnings, adds a config toggle (gateway.controlUi.chat.showPricingThreshold), and fixes a layout regression with the oversized SVG notice. The config plumbing, CSS, and bootstrap controller changes are all clean and consistent.

However, there is a logic defect in renderContextNotice (ui/src/ui/views/chat.ts) that causes a silent regression for known models:

  • The function contains two independent early-return guards. The first (line 341) allows execution to continue whenever modelRatio >= 0.85. The second (line 351) uses the condition shouldShowPricing || shouldShowModelWarning || (!known && modelRatio >= 0.85) — where !known means only unknown models get the fallback 85 % warning.
  • Consequence: for any model listed in KNOWN_CONTEXT_THRESHOLDS (all GPT-5.4 variants and Gemini models) where usage is between 85 % and 100 % of the model limit and the pricing threshold has not been crossed, the second guard fires and returns nothing, suppressing the notice entirely. This is a regression from the previous behaviour where any model at ≥ 85 % would show a warning.
  • The browser tests added in chat-context-notice.browser.test.ts do not cover this path (test 1 uses an unknown model; test 2 uses GPT-5.4 above the pricing threshold), so the bug goes undetected in CI.

The fix is straightforward: change !known && modelRatio >= 0.85 to just modelRatio >= 0.85 in the shouldShow expression, or consolidate both guards into a single expression.

Confidence Score: 2/5

  • Not safe to merge as-is; the double-guard logic in renderContextNotice silently suppresses 85-99% context warnings for all models in KNOWN_CONTEXT_THRESHOLDS.
  • The config plumbing, CSS, and bootstrap controller are all correct and well-tested. The logic bug in the core rendering function is a one-line fix, but it represents a real functional regression: users on GPT-5.4 or Gemini models whose context usage is between 85% and 100% of the model limit (without crossing the pricing threshold) will receive no warning at all, which is worse than the previous behaviour. The existing browser tests do not cover this path, making it easy to miss without targeted review.
  • ui/src/ui/views/chat.ts — specifically the shouldShow expression on line 351 inside renderContextNotice.
Prompt To Fix All With AI
This 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

Comment thread ui/src/ui/views/chat.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/ui/views/chat.ts Outdated
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Mar 16, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/ui/views/chat.ts Outdated
@futuremind2026
Copy link
Copy Markdown
Contributor Author

Thanks — I pushed a follow-up fix in 0e8e0719ea.

This addresses two issues:

  1. Fix the control-ui “Model context / Used” bug
  • Used now reflects the current live model context (totalTokens)
  • it no longer falls back to cumulative session usage (inputTokens)
  • inputTokens is still used only for the higher-rate pricing threshold check
  • when cumulative usage is high but current context is still below the ceiling, the UI now explains that auto-compaction tracks current context, not cumulative usage
  1. Fix the warning regression for known models
  • for known models, the warning should still appear when model context usage is already high (e.g. 85%+), even if the pricing threshold has not been crossed yet
  • shouldShow now preserves that warning path instead of effectively limiting it to the pricing-threshold case

Also included:

  • regression coverage in ui/src/ui/chat-context-notice.browser.test.ts
  • config/docs follow-up for gateway.controlUi.chat.showPricingThreshold
  • a fix in src/config/doc-baseline.ts so config:docs:check compares JSON baselines semantically and does not fail just because oxfmt reordered the generated JSON

Validation run:

  • pnpm run config:docs:gen
  • pnpm exec oxfmt --write docs/.generated/config-baseline.json src/config/doc-baseline.ts
  • pnpm run config:docs:check
  • pnpm run format:check
  • pnpm exec vitest run --config vitest.unit.config.ts src/config/doc-baseline.test.ts
  • pnpm --dir ui test src/ui/chat-context-notice.browser.test.ts

@futuremind2026 futuremind2026 force-pushed the pr/gpt54-context-threshold-ui-20260316-01 branch from 0e8e071 to fadaf18 Compare March 17, 2026 14:59
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Mar 17, 2026
@futuremind2026
Copy link
Copy Markdown
Contributor Author

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.

@MaGonglei
Copy link
Copy Markdown

Status update after refresh onto current main:

  • This PR was rebuilt on top of current openclaw/main and now only keeps the remaining UI/control-ui changes that are not in upstream yet.
  • The duplicate combined draft PR was closed instead of maintaining overlapping review threads.
  • Generated docs-baseline churn was intentionally dropped.

Current CI note:

  • The failing Windows shards are hitting the same unrelated failures seen on another independent refreshed PR in this maintenance batch.
  • The current failures are in src/plugins/bundle-mcp.test.ts, src/plugin-sdk/index.test.ts, src/memory/embeddings-gemini.test.ts, src/logging/logger.browser-import.test.ts, and src/hooks/plugin-hooks.test.ts.
  • Those files are outside this PR's diff.

I am keeping this PR open because the remaining diff is still real and not covered by upstream yet.

@MaGonglei
Copy link
Copy Markdown

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/styles/components.css
@futuremind2026
Copy link
Copy Markdown
Contributor Author

Follow-up update after the latest review comment:

  • Fixed the stacked context-notice cascade issue in b757d900b6 by scoping the legacy single-line pill rules in ui/src/styles/chat/layout.css to .context-notice:not(.context-notice--stacked).
  • Restored the warning icon inside the stacked summary so the compact badge-sized icon regression remains covered in ui/src/ui/views/chat.browser.test.ts.

Validation rerun on the refreshed branch:

  • pnpm exec vitest run src/gateway/control-ui.http.test.ts
  • pnpm --dir ui test -- src/ui/chat-context-notice.browser.test.ts src/ui/views/chat.browser.test.ts src/ui/controllers/control-ui-bootstrap.test.ts

Current CI note:

  • The remaining Windows failures still point at shared baseline issues outside this PR diff: path normalization in src/plugins/bundle-mcp.test.ts (RUNNER~1 vs runneradmin plus slash normalization) and missing dist/plugin-sdk in src/plugin-sdk/index.test.ts.
  • extension-fast (telegram) is also failing outside this PR diff on mocked media fetch retries.
  • None of those files are touched by this branch.

@futuremind2026 futuremind2026 force-pushed the pr/gpt54-context-threshold-ui-20260316-01 branch from b757d90 to a0fe731 Compare March 19, 2026 02:20
@MaGonglei
Copy link
Copy Markdown

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:

  • keep the 85%+ context warning path for known models
  • preserve the stale-row fallback when totalTokens is temporarily missing
  • keep the stacked context notice layout from being overridden by the legacy single-line pill rules

Validation rerun on the refreshed branch:

  • pnpm exec vitest run src/gateway/control-ui.http.test.ts
  • pnpm --dir ui test -- src/ui/chat-context-notice.browser.test.ts src/ui/views/chat.browser.test.ts src/ui/controllers/control-ui-bootstrap.test.ts
  • pnpm check

CI has been re-triggered after the force-push.

@futuremind2026
Copy link
Copy Markdown
Contributor Author

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:

  • pnpm run test:ui -- src/ui/chat-context-notice.browser.test.ts

@futuremind2026 futuremind2026 force-pushed the pr/gpt54-context-threshold-ui-20260316-01 branch from 868bd4c to 0eae6c8 Compare March 23, 2026 22:01
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/ui/views/chat.ts Outdated
@futuremind2026
Copy link
Copy Markdown
Contributor Author

Refreshed this branch onto the latest origin/main and kept the verified runtime fixes in place.

Additional follow-up in this refresh:

  • restored the otalTokensFresh === false guard in the chat context notice path
  • kept the fallback-to-inputTokens behavior when otalTokens is missing
  • retained the legacy google-gemini-cli/gemini-3-pro-preview threshold coverage
  • aligned the UI + gateway regression tests after the rebase
  • regenerated src/config/schema.base.generated.ts so the config schema stays in sync

Scoped verification completed:

  • cd ui && pnpm exec vitest run --config vitest.config.ts src/ui/views/chat.test.ts src/ui/chat-context-notice.browser.test.ts src/ui/controllers/control-ui-bootstrap.test.ts
  • pnpm exec vitest run src/gateway/control-ui.http.test.ts
  • pnpm build

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/ui/views/chat.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/styles/components.css
@futuremind2026 futuremind2026 force-pushed the pr/gpt54-context-threshold-ui-20260316-01 branch from 166e736 to b5ddc23 Compare March 26, 2026 09:55
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Mar 26, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/ui/views/chat.ts Outdated
@futuremind2026 futuremind2026 force-pushed the pr/gpt54-context-threshold-ui-20260316-01 branch from b5ddc23 to bb87738 Compare March 27, 2026 17:19
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread docs/.generated/config-baseline.jsonl Outdated
Comment thread ui/src/styles/components.css
@futuremind2026 futuremind2026 force-pushed the pr/gpt54-context-threshold-ui-20260316-01 branch from bb87738 to 774d558 Compare March 27, 2026 17:50
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ui/src/ui/views/chat.ts
Comment on lines +353 to +356
const shouldShowPricing =
showPricingThresholdNotice &&
typeof known?.pricingThresholdTokens === "number" &&
inputUsed >= known.pricingThresholdTokens;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 29, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 29, 2026

Codex review: found issues before merge.

Summary
The PR adds a Control UI chat pricing-threshold setting, carries it through Gateway bootstrap/UI state, and rewrites context notice rendering/styles/tests to separate pricing hints from model context warnings.

Reproducibility: yes. The review findings are source-reproducible by comparing PR-head src/gateway/control-ui.ts:347-376 and ui/src/ui/views/chat.ts:341-356 with current main's authorized bootstrap route and fresh-context notice model.

Next step before merge
Maintainers need to decide the pricing-threshold source/UX and either refresh or replace the stale branch against current auth and context-notice code.

Security
Needs attention: The diff needs attention because the stale branch would reintroduce unauthenticated Control UI bootstrap metadata exposure.

Review findings

  • [P1] Preserve bootstrap auth when adding chat settings — src/gateway/control-ui.ts:370-375
  • [P2] Base pricing hints on fresh context usage — ui/src/ui/views/chat.ts:353-356
  • [P2] Prevent stacked notice CSS from being overridden — ui/src/styles/components.css:1401-1408
Review details

Best 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 src/gateway/control-ui.ts:347-376 and ui/src/ui/views/chat.ts:341-356 with current main's authorized bootstrap route and fresh-context notice model.

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:

  • [P1] Preserve bootstrap auth when adding chat settings — src/gateway/control-ui.ts:370-375
    Current main gates /__openclaw/control-ui-config.json with authorizeControlUiReadRequest, but this stale handler sends the bootstrap payload and new chat setting without that check. Rebase this field into the current authorized handler so auth-enabled gateways do not expose bootstrap metadata to anonymous callers.
    Confidence: 0.9
  • [P2] Base pricing hints on fresh context usage — ui/src/ui/views/chat.ts:353-356
    shouldShowPricing is driven by cumulative session.inputTokens, which can include multiple calls, retries, cached input, and tool-loop usage. That can show a higher-rate billing warning when no fresh prompt/context snapshot crossed the provider tier, so use a fresh request/context usage signal instead.
    Confidence: 0.84
  • [P2] Prevent stacked notice CSS from being overridden — ui/src/styles/components.css:1401-1408
    styles.css imports chat.css after components.css, and PR-head chat/layout.css still has a later plain .context-notice rule with equal specificity that resets display and white-space. Increase specificity or update the later rule so stacked threshold/context notices wrap as intended.
    Confidence: 0.86
  • [P2] Update the current config baseline artifact — docs/.generated/config-baseline.jsonl:1
    Current main tracks generated config-doc drift through docs/.generated/config-baseline.sha256, but this branch modifies the removed full JSON/JSONL baseline files. Rebase onto the current workflow and update the SHA artifact instead of resurrecting obsolete generated outputs.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.91

Security concerns:

  • [high] Bootstrap config auth regression — src/gateway/control-ui.ts:370
    The PR adds chat bootstrap metadata on an older /__openclaw/control-ui-config.json response path that lacks current main's authorizeControlUiReadRequest gate, so auth-enabled gateways could expose bootstrap metadata to anonymous requests.
    Confidence: 0.9

Acceptance criteria:

  • pnpm test src/gateway/control-ui.http.test.ts
  • pnpm test ui/src/ui/chat/context-notice.test.ts ui/src/ui/views/chat.test.ts ui/src/ui/controllers/sessions.test.ts ui/src/ui/app-gateway.sessions.node.test.ts
  • pnpm test ui/src/ui/controllers/control-ui-bootstrap.test.ts
  • pnpm config:docs:check
  • pnpm check:changed

What I checked:

  • Current main lacks the proposed setting: A current-main search found no showPricingThreshold, pricingThreshold, KNOWN_CONTEXT_THRESHOLDS, higher-rate, or gateway.controlUi.chat implementation; the current gateway.controlUi schema has no nested chat object. (src/config/zod-schema.ts:784, 8e79392dccf4)
  • Current main protects bootstrap config: The current bootstrap route authorizes CONTROL_UI_BOOTSTRAP_CONFIG_PATH with authorizeControlUiReadRequest before returning metadata. (src/gateway/control-ui.ts:759, 8e79392dccf4)
  • PR head serves bootstrap metadata without the current auth gate: PR head returns the bootstrap payload and added chat.contextNotice.showPricingThreshold field without the current main authorization guard. (src/gateway/control-ui.ts:347, 774d558e6424)
  • PR pricing check uses cumulative input tokens: PR head computes shouldShowPricing from session.inputTokens, while current main's context notice intentionally uses fresh totalTokens and hides stale totals. (ui/src/ui/views/chat.ts:353, 774d558e6424)
  • Current main context notice is fresh-context only: getContextNoticeViewModel returns null for totalTokensFresh === false and renders from session.totalTokens, not aggregate inputTokens. (ui/src/ui/chat/context-notice.ts:64, 8e79392dccf4)
  • PR stacked styles are still overridden by later chat CSS: PR head imports chat.css after components.css; chat/layout.css then defines a later plain .context-notice rule with equal specificity that resets display and white-space. (ui/src/styles/components.css:1401, 774d558e6424)

Likely related people:

  • BunsDev: Merged the current Control UI context freshness/compaction notice work and later added similar Control UI chat configuration/bootstrap plumbing for chat message width. (role: recent adjacent owner; confidence: high; commits: da773175f2eb, 5fce2f6b0fb1; files: ui/src/ui/chat/context-notice.ts, ui/src/ui/views/chat.ts, ui/src/ui/controllers/sessions.ts)
  • drobison00: Merged the current authenticated Control UI bootstrap config route that this stale PR would bypass. (role: introduced bootstrap auth behavior; confidence: high; commits: 2321d67263bc; files: src/gateway/control-ui.ts, src/gateway/control-ui.http.test.ts, ui/src/ui/controllers/control-ui-bootstrap.ts)
  • Sid-Qin: Earlier added server-version bootstrap contract/wiring that is part of the same Control UI bootstrap surface touched by this PR. (role: bootstrap contract adjacent owner; confidence: medium; commits: 3a6b412f00a6; files: src/gateway/control-ui-contract.ts, src/gateway/control-ui.ts, ui/src/ui/controllers/control-ui-bootstrap.ts)

Remaining risk / open question:

  • Provider higher-rate thresholds are product and pricing metadata; hard-coding them in UI code can become inaccurate if the provider contract changes.
  • The PR branch is stale relative to current bootstrap auth, context notice, and config-doc generation workflows, so direct merge would reintroduce fixed mainline regressions.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8e79392dccf4.

@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 29, 2026

Codex review: found issues before merge.

What this changes:

The PR adds gateway.controlUi.chat.showPricingThreshold, wires it through Gateway bootstrap and Control UI state, and changes chat context notices/styles/tests to show pricing-threshold hints separately from model context limits.

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:

  • [P1] Preserve bootstrap auth when adding chat settings — src/gateway/control-ui.ts:370-375
  • [P2] Base threshold warnings on fresh request context — ui/src/ui/views/chat.ts:353-356
Review details

Best possible solution:

Rebase or replace the branch on current main, implement the threshold split in the current ui/src/ui/chat/context-notice.ts model, preserve #70247 bootstrap authorization and #71297 fresh-total/compaction behavior, settle the pricing-threshold source of truth, and align schema docs generation with the current SHA baseline workflow.

Full review comments:

  • [P1] Preserve bootstrap auth when adding chat settings — src/gateway/control-ui.ts:370-375
    Current main requires Control UI read auth before serving /__openclaw/control-ui-config.json, but this branch adds the chat setting on a stale handler that returns the bootstrap payload without that gate. Rebase onto the current handler and add the new field inside the already-authorized response path, otherwise unauthenticated callers can read bootstrap metadata again.
    Confidence: 0.88
  • [P2] Base threshold warnings on fresh request context — ui/src/ui/views/chat.ts:353-356
    shouldShowPricing is driven by cumulative session.inputTokens, which can include multiple calls and tool-loop usage. That can show “Higher-rate billing threshold crossed” when no single fresh prompt/context snapshot crossed the provider tier, so use fresh context/request usage instead of aggregate session input.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.87

Acceptance criteria:

  • pnpm test ui/src/ui/chat/context-notice.test.ts ui/src/ui/views/chat.test.ts ui/src/ui/controllers/sessions.test.ts ui/src/ui/app-gateway.sessions.node.test.ts
  • pnpm test src/gateway/control-ui.http.test.ts
  • pnpm test ui/src/ui/controllers/control-ui-bootstrap.test.ts
  • pnpm config:docs:check
  • pnpm check:changed

What I checked:

  • Current main context notice is fresh-context only: getContextNoticeViewModel reads fresh session.totalTokens over contextTokens, returns null for totalTokensFresh === false, and has no pricing-threshold branch. (ui/src/ui/chat/context-notice.ts:54, e46dccb35374)
  • Current main chat call site has no pricing setting: renderChat calls renderContextNotice with the active session, default context tokens, and compaction options only; no showPricingThresholdNotice or bootstrap-derived chat setting is present. (ui/src/ui/views/chat.ts:1106, e46dccb35374)
  • Current main config schema lacks proposed key: gateway.controlUi contains hosting/embed/auth-hardening fields and no nested chat object or showPricingThreshold boolean. A repository search for showPricingThreshold, pricingThreshold, KNOWN_CONTEXT_THRESHOLDS, higher-rate, and gateway.controlUi.chat found no mainline implementation. (src/config/zod-schema.ts:737, e46dccb35374)
  • Current main protects the bootstrap config endpoint: Current main authorizes /__openclaw/control-ui-config.json with authorizeControlUiReadRequest before sending bootstrap metadata. (src/gateway/control-ui.ts:759, e46dccb35374)
  • PR head is stale on bootstrap auth: The PR head serves the bootstrap config and added chat setting without the current main auth gate, so rebasing this work must preserve fix(gateway): require auth for control ui bootstrap config #70247's authorization boundary. (src/gateway/control-ui.ts:370, 774d558e6424)
  • PR pricing check uses cumulative input tokens: The PR computes shouldShowPricing from session.inputTokens, while current docs state provider usage can include cached input, output, and multiple tool-loop calls and can overstate live context. (ui/src/ui/views/chat.ts:353, 774d558e6424)

Likely related people:

  • BunsDev: Merged Fix Control UI context freshness and compaction CTA #71297, which owns the current Control UI context freshness, session usage merge, context notice, and compaction CTA path that this PR must preserve or extend. (role: recent adjacent owner; confidence: high; commits: da773175f2eb, fc5920fb5134; files: ui/src/ui/chat/context-notice.ts, ui/src/ui/controllers/sessions.ts, ui/src/ui/views/chat.ts)
  • drobison00: Introduced the current authenticated Control UI bootstrap route and nearby avatar auth behavior, which are the Gateway/auth boundaries this stale PR must preserve when adding bootstrap chat settings. (role: recent adjacent owner; confidence: high; commits: 2321d67263bc, 2ce16e558e99; files: src/gateway/control-ui.ts, src/gateway/control-ui-contract.ts, ui/src/ui/controllers/control-ui-bootstrap.ts)
  • steipete: Recent path history shows repeated maintenance across config schema and Control UI bootstrap/chat surfaces involved in this rebase and product decision. (role: recent maintainer; confidence: medium; commits: 2b811fe6d9e3, 74fb6be71680, 596b88986de2; files: src/config/zod-schema.ts, src/config/types.gateway.ts, ui/src/ui/controllers/control-ui-bootstrap.ts)

Remaining risk / open question:

  • The PR head is stale against current main and lacks the authenticated Control UI bootstrap path added by fix(gateway): require auth for control ui bootstrap config #70247; rebasing must preserve that security boundary before adding any new bootstrap payload fields.
  • Pricing-threshold semantics remain unresolved: the PR uses cumulative inputTokens, which can include multiple model/tool-loop calls and may create false higher-rate billing warnings if the threshold is per request/prompt snapshot.
  • The branch still carries generated docs/.generated/config-baseline.json and .jsonl changes even though current main tracks config docs baselines by SHA file only.

Codex review notes: model gpt-5.5, reasoning high; reviewed against e46dccb35374.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants