fix(ui): use totalTokens instead of inputTokens for context notice banner#46620
fix(ui): use totalTokens instead of inputTokens for context notice banner#46620IgnacioPro wants to merge 6 commits intoopenclaw:mainfrom
Conversation
…nner - Fix openclaw#46582: Changed renderContextNotice() to use session?.totalTokens instead of session?.inputTokens - This ensures the context warning banner accurately reflects total token usage - Updated test fixture to include totalTokens field - Added test case to verify banner doesn't show when inputTokens is high but totalTokens is low - Configured vitest to include chat.browser.test.ts in test suite
Greptile SummaryThis PR fixes the context warning banner to use
Confidence Score: 3/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: vitest.config.ts
Line: 88
Comment:
**Duplicate test registration causes double test execution**
`ui/vitest.config.ts` already picks up `*.browser.test.ts` files via the `browser` project:
```ts
// ui/vitest.config.ts
defineProject({
test: {
name: "browser",
include: ["src/**/*.browser.test.ts"], // matches ui/src/ui/views/chat.browser.test.ts
browser: { enabled: true, provider: playwright(), ... },
},
}),
```
Adding the same file here means it runs **twice**: once in Playwright/Chromium (the intended environment), and once in this root config's `pool: "forks"` (Node.js) environment — which has no DOM and no `jsdom` environment configured. The root `test/setup.ts` does not establish any DOM globals either.
The `chat.browser.test.ts` test uses real browser APIs (`getComputedStyle`, `getBoundingClientRect`) that require an actual browser or at minimum `jsdom`. Running it under `pool: "forks"` without a DOM environment risks silently degraded assertions or `document is not defined` failures that hide true regressions.
This line should be removed from the root `vitest.config.ts` — the file is already covered by `ui/vitest.config.ts`.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 4b259be |
There was a problem hiding this comment.
Pull request overview
This PR fixes an inaccurate “context usage” warning banner in the chat UI by basing the banner threshold on the session’s context-size snapshot (totalTokens) instead of cumulative input tokens (inputTokens), addressing the regression reported in #46582.
Changes:
- Update
renderContextNotice()to compute usage fromsession?.totalTokens. - Update the chat context-notice browser test fixture to include
totalTokens. - Add a browser test case ensuring the banner does not appear when
inputTokensis high buttotalTokensis low.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| vitest.config.ts | Adds the new chat browser test file to the root Vitest include list. |
| ui/src/ui/views/chat.ts | Switches banner usage calculation from inputTokens to totalTokens. |
| ui/src/ui/views/chat.browser.test.ts | Updates fixtures and adds a regression test for the banner logic change. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b259becdb
ℹ️ 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".
|
✅ Fixed CI: added |
# Conflicts: # src/gateway/server/ws-connection/message-handler.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5cba7b23c3
ℹ️ 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".
| } from "./src/mention.js"; | ||
| export { feishuPlugin } from "./src/channel.js"; | ||
|
|
||
| export default defineChannelPluginEntry({ |
There was a problem hiding this comment.
Restore feishuPlugin named export
Removing the feishuPlugin re-export from this module breaks existing named imports (src/channels/plugins/bundled.ts imports { feishuPlugin } from extensions/feishu/index.js), so loading bundled channel plugins will fail once this commit lands. This turns an unrelated UI fix into a channel-registry/runtime break for any startup path that evaluates bundled plugins.
Useful? React with 👍 / 👎.
# Conflicts: # src/plugin-sdk/index.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4de4c7cf8d
ℹ️ 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".
| export type { OpenClawConfig } from "../config/config.js"; | ||
| /** @deprecated Use OpenClawConfig instead */ | ||
| export type { OpenClawConfig as ClawdbotConfig } from "../config/config.js"; | ||
| export { isDangerousNameMatchingEnabled } from "../config/dangerous-name-matching.js"; |
There was a problem hiding this comment.
Keep root plugin-sdk export surface minimal
Re-exporting isDangerousNameMatchingEnabled from the root SDK entrypoint breaks the existing root-surface contract: src/plugin-sdk/index.test.ts ("keeps the root runtime surface intentionally small") explicitly asserts that this symbol is not present on openclaw/plugin-sdk. With this line added, that expectation flips and the root entry now leaks internal runtime helpers that were intentionally kept off the top-level API.
Useful? React with 👍 / 👎.
|
Closing this as implemented after Codex review. Current What I checked:
So I’m closing this as already implemented rather than keeping a duplicate issue open. Review notes: reviewed against 56fe2aab9c87; fix evidence: commit f85806b6d786. |
Fixes #46582
Changes
renderContextNotice()to usesession?.totalTokensinstead ofsession?.inputTokenstotalTokensfieldinputTokensis high buttotalTokensis lowTesting