feat(usage): improve usage overview styling and localization#51951
Conversation
- Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function.
…at components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction.
- Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience.
Greptile SummaryThis PR continues incremental UX improvements to the session management and usage analytics UI. The main structural change is a refactor of the flat Key changes:
Potential concerns:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: ui/src/ui/views/chat.ts
Line: 254-258
Comment:
**`parseHexRgb` silently produces `NaN` for non-hex inputs**
The function assumes exactly a 6-digit hex string. If `getComputedStyle` ever returns `--warn` or `--danger` as an `rgb(...)`, `rgba(...)`, or named color value (e.g. from a user-provided theme override), `parseInt(h.slice(0, 2), 16)` will silently return `NaN`, making `color` become `rgb(NaN, NaN, NaN)` — which browsers silently ignore, causing no color change.
The fallback `|| "#f59e0b"` only triggers when the property is empty/undefined, not when it contains a non-hex string. Consider adding a guard:
```suggestion
function parseHexRgb(hex: string): [number, number, number] | null {
const h = hex.trim().replace(/^#/, "");
if (!/^[0-9a-fA-F]{6}$/.test(h)) return null;
return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
}
```
Then guard the callers: `const parsed = parseHexRgb(warnHex); if (!parsed) return nothing;`
In practice `--warn` and `--danger` in `base.css` are always 6-digit hex today, so this won't currently bite — but it's a silent failure mode worth closing.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: ui/src/ui/views/chat.ts
Line: 275-276
Comment:
**`getComputedStyle` called on every render**
`getComputedStyle(document.documentElement)` is called inside `renderContextNotice`, which runs on every chat re-render cycle. This is a relatively expensive browser call (it forces style recalculation). Since the CSS variables `--warn` and `--danger` are only set once at startup (or on theme change), consider reading them once at module level or memoising the hex values, rather than querying them on every render.
```suggestion
// At module scope:
let _cachedWarnHex: string | null = null;
let _cachedDangerHex: string | null = null;
function getThemeColors() {
if (!_cachedWarnHex) {
const s = getComputedStyle(document.documentElement);
_cachedWarnHex = s.getPropertyValue("--warn").trim() || "#f59e0b";
_cachedDangerHex = s.getPropertyValue("--danger").trim() || "#ef4444";
}
return { warnHex: _cachedWarnHex, dangerHex: _cachedDangerHex! };
}
```
(Invalidate the cache on theme change if that's ever supported.)
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: ui/src/styles/chat/grouped.css
Line: 22-32
Comment:
**Chat message container width capped at 50% regardless of viewport**
Changing `.chat-group-messages` from `max-width: min(900px, calc(100% - 60px))` to `max-width: 50%` is a significant visual change. On narrow viewports (e.g. 375 px wide mobile), the messages column would be at most ~187 px, which can produce extremely narrow text wrapping.
Additionally, changing `.chat-group.user .chat-group-messages` from `align-items: flex-end` to `align-items: stretch`, combined with `.chat-bubble { display: block; width: 100%; }`, means user messages now stretch to the full column width instead of being content-sized and right-aligned. That's a meaningful UX shift (user bubbles become blocks, not floating right-aligned "speech bubbles").
If this is intentional for the new responsive layout, a responsive safety net would help:
```css
@media (max-width: 600px) {
.chat-group-messages {
max-width: 80%;
}
}
```
Worth verifying visually on mobile before merge.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "Merge branch 'main' ..." |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39487d6b74
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
39487d6 to
6fc4167
Compare
🔒 Aisle Security AnalysisWe found 2 potential security issue(s) in this PR:
1. 🟡 CSV/Excel formula injection in Usage CSV export (Sessions/Daily)
DescriptionThe Usage export menu allows downloading session/daily metrics as CSV. Exported cells are built from session metadata (e.g., The CSV builder only performs RFC4180-style quoting (commas/quotes/newlines) and does not neutralize spreadsheet formula metacharacters. If an exported value begins with Vulnerable flow:
Vulnerable code (export trigger): downloadTextFile(
`openclaw-usage-sessions-${exportStamp}.csv`,
buildSessionsCsv(filteredSessions),
"text/csv",
)Related escaping logic (insufficient; does not prevent formula execution): function csvEscape(value: string): string {
if (/[",\n]/.test(value)) {
return `"${value.replaceAll('"', '""')}"`;
}
return value;
}RecommendationNeutralize spreadsheet formulas before CSV quoting/escaping for all string cells. A common mitigation is to prefix dangerous values with an apostrophe ( Example fix (in function neutralizeSpreadsheetFormula(value: string): string {
// Prevent Excel/Sheets formula interpretation
if (/^\s*[=+\-@]/.test(value)) {
return `'${value}`;
}
return value;
}
function csvEscape(value: string): string {
const safe = neutralizeSpreadsheetFormula(value);
if (/[",\r\n]/.test(safe)) {
return `"${safe.replaceAll('"', '""')}"`;
}
return safe;
}Also consider:
2. 🟡 Supply-chain hardening regression: new allowlisted build-script dependencies in pnpm.onlyBuiltDependencies
DescriptionThe project uses pnpm's
When a dependency is present in Vulnerable change: "onlyBuiltDependencies": [
"@discordjs/opus",
"@tloncorp/tlon-skill",
...
]RecommendationKeep the build-script allowlist as small as possible and add compensating controls when new entries are required. Recommended actions:
Example: pin via overrides (if these are transitives): {
"pnpm": {
"overrides": {
"@discordjs/opus": "0.10.0",
"@tloncorp/tlon-skill": "0.2.2"
}
}
}This reduces unexpected upgrades while still allowing required builds for the explicitly-reviewed versions. Analyzed PR: #51951 at commit Last updated on: 2026-03-22T01:33:18Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a37f786220
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| min-height: 244px; | ||
| padding: 6px 2px 0; | ||
| overflow-x: auto; | ||
| } |
There was a problem hiding this comment.
Keep daily chart tooltip overflow visible
The daily usage tooltips are positioned above each bar (.daily-bar-tooltip uses bottom: calc(100% + 8px)), but .daily-chart-bars now sets overflow-x: auto; in browsers this makes vertical overflow non-visible, so hover tooltips get clipped/cut off instead of being readable. This regresses the day-level breakdown workflow, especially when inspecting bars near the viewport edges or after horizontal scrolling.
Useful? React with 👍 / 👎.
…w#51951) * feat(usage): add usage page styles and localization - Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function. * feat(ui): enhance styling and functionality for usage overview and chat components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction. * feat(usage): enhance usage overview styling and rendering options - Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience. * fix(ui): address review feedback on usage and chat layout * docs(changelog): add entry for usage UI improvements
…w#51951) * feat(usage): add usage page styles and localization - Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function. * feat(ui): enhance styling and functionality for usage overview and chat components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction. * feat(usage): enhance usage overview styling and rendering options - Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience. * fix(ui): address review feedback on usage and chat layout * docs(changelog): add entry for usage UI improvements
…w#51951) * feat(usage): add usage page styles and localization - Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function. * feat(ui): enhance styling and functionality for usage overview and chat components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction. * feat(usage): enhance usage overview styling and rendering options - Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience. * fix(ui): address review feedback on usage and chat layout * docs(changelog): add entry for usage UI improvements
…w#51951) * feat(usage): add usage page styles and localization - Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function. * feat(ui): enhance styling and functionality for usage overview and chat components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction. * feat(usage): enhance usage overview styling and rendering options - Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience. * fix(ui): address review feedback on usage and chat layout * docs(changelog): add entry for usage UI improvements
…w#51951) * feat(usage): add usage page styles and localization - Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function. * feat(ui): enhance styling and functionality for usage overview and chat components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction. * feat(usage): enhance usage overview styling and rendering options - Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience. * fix(ui): address review feedback on usage and chat layout * docs(changelog): add entry for usage UI improvements
…w#51951) * feat(usage): add usage page styles and localization - Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function. * feat(ui): enhance styling and functionality for usage overview and chat components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction. * feat(usage): enhance usage overview styling and rendering options - Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience. * fix(ui): address review feedback on usage and chat layout * docs(changelog): add entry for usage UI improvements
…w#51951) * feat(usage): add usage page styles and localization - Introduced a new `usage.css` file for styling the usage overview page. - Updated `en.ts` localization file to include new usage-related translations. - Refactored the usage rendering components to utilize the new localization strings for improved user experience. - Enhanced the `app-render-usage-tab.ts` to better structure the data passed to the rendering function. * feat(ui): enhance styling and functionality for usage overview and chat components - Updated `package.json` to include new built dependencies. - Refined CSS styles across various files to improve UI consistency and accessibility, including adjustments to color themes and layout structures. - Introduced new responsive grid layouts for usage overview and chat components, enhancing the user experience on different screen sizes. - Added functionality to hide context notices based on token freshness in chat view. - Implemented new rendering functions for usage statistics, improving data presentation and user interaction. * feat(usage): enhance usage overview styling and rendering options - Added new CSS classes for improved layout and styling of usage insight cards and error lists. - Updated rendering functions to support customizable class names for usage insight cards and error lists, enhancing flexibility in UI presentation. - Implemented a wide card layout and specific styling for error lists to improve visual clarity and user experience. * fix(ui): address review feedback on usage and chat layout * docs(changelog): add entry for usage UI improvements
Summary
Describe the problem and fix in 2–5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.