fix: resolve settings/usage chart crash and add ClickHouse usage event seeds#19039
fix: resolve settings/usage chart crash and add ClickHouse usage event seeds#19039FelixMalfait wants to merge 13 commits intomainfrom
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:12256 This environment will automatically shut down after 5 hours. |
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/twenty-front/src/pages/settings/SettingsUsageUserDetail.tsx">
<violation number="1" location="packages/twenty-front/src/pages/settings/SettingsUsageUserDetail.tsx:103">
P2: Unconditional `previousData` fallback can render stale analytics for a different user when `userWorkspaceId` changes.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/twenty-front/src/pages/settings/SettingsUsageUserDetail.tsx
Outdated
Show resolved
Hide resolved
…t seeds The GraphWidgetLineChart used on the settings/usage page was crashing with "Instance id is not provided and cannot be found in context" because it was rendered outside the widget system context. This adds the required WidgetComponentInstanceContext provider and avoids mounting GraphWidgetLegend (which needs PageLayoutEditModeContext) when showLegend is false — applied consistently across all four chart types. Also adds usage event seeds to ClickHouse so developers get realistic credit consumption data spanning the past month for the usage analytics page. Made-with: Cursor
Made-with: Cursor
Pie chart tooltip now uses the same design language as GraphWidgetTooltip (background, border, shadow, legend dot, proper font styles) instead of a raw unstyled div. Period selector changes no longer flash the entire page. Uses Apollo's previousData to keep the current content visible while the new data loads, only showing a blank state on the very first load. Made-with: Cursor
…ge tab with Enterprise gating, model breakdown, and dollar/credit display - Split AI_TOKEN operation type into AI_CHAT_TOKEN and AI_WORKFLOW_TOKEN - Add conditional dollar vs credit display based on billing status - Add operationTypes filter to usage analytics GraphQL API - Add AI usage tab in Settings > AI (Enterprise only) - Add AI usage by model breakdown (pie chart) - Add per-user AI usage detail page - Add toDollars utility in its own file - Update ClickHouse seeds with new AI operation types and model IDs - Fix EnterprisePlanModal card layout and button colors - Link cloud usage page to AI breakdown Made-with: Cursor
41db6e3 to
775a84b
Compare
packages/twenty-front/src/pages/settings/ai/SettingsAIUsageUserDetail.tsx
Fixed
Show fixed
Hide fixed
- Add getAdminAiUsageByWorkspace method to UsageAnalyticsService (cross-workspace query) - Add getAdminAiUsageByWorkspace GraphQL query to AdminPanelResolver with workspace name resolution - Import UsageModule in AdminPanelModule - Add AI Usage by Workspace table section with Enterprise badge and period selector in SettingsAdminAI - Use existing Enterprise Tag badge pattern for the AI usage empty state - Fix duplicate import in SettingsAI and unused import in SettingsAIUsageUserDetail Made-with: Cursor
There was a problem hiding this comment.
1 issue found across 8 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx">
<violation number="1" location="packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx:260">
P2: The usage section treats query loading as an empty dataset, so it can briefly display a false “No AI usage data recorded yet.” state before the request completes.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx
Outdated
Show resolved
Hide resolved
…AI usage section - Show period selector in adornment when Enterprise is active, Enterprise badge otherwise - Use same BREAKDOWN_QUERY_LIMIT for admin workspace query instead of separate constant Made-with: Cursor
packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx
Show resolved
Hide resolved
packages/twenty-front/src/pages/settings/ai/SettingsAIUsageUserDetail.tsx
Outdated
Show resolved
Hide resolved
- Extract the Enterprise feature gate card (lock icon + Activate button) into a reusable component - Use it in both SettingsAIUsageTab and SettingsAdminAI - Show the gate card instead of the table when Enterprise is not active in admin AI usage section - Skip usage query when Enterprise is not active Made-with: Cursor
…in panel access Made-with: Cursor
There was a problem hiding this comment.
2 issues found across 22 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/twenty-server/src/database/clickHouse/seeds/fixtures.ts">
<violation number="1" location="packages/twenty-server/src/database/clickHouse/seeds/fixtures.ts:103">
P2: Use the canonical Anthropic model ID (`claude-opus-4-6`) in seed data; `claude-opus-4.6` is not a valid catalog model key.</violation>
</file>
<file name="packages/twenty-front/src/pages/settings/ai/SettingsAIUsageUserDetail.tsx">
<violation number="1" location="packages/twenty-front/src/pages/settings/ai/SettingsAIUsageUserDetail.tsx:77">
P2: Pass `skip: !userWorkspaceId` to each usage section query to avoid running unscoped analytics requests when the route param is missing.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Summary
GraphWidgetLineChartcomponent used onsettings/usagewas crashing with "Instance id is not provided and cannot be found in context" because it requiresWidgetComponentInstanceContext(for tooltip/crosshair component states) which is only provided inside the widget system. Wraps the standalone chart usages with the required context provider.GraphWidgetLegendwhen hidden: The legend component callsuseIsPageLayoutInEditMode()which requiresPageLayoutEditModeProviderContext— another context only available inside the widget system. Since the settings page passesshowLegend={false}, the fix conditionally unmounts the legend instead of always mounting it with ashowprop. Applied consistently across all four chart types (line, bar, pie, gauge).usageEventrows spanning the past 35 days with weighted user activity, weekday/weekend patterns, and gradual ramp-up. Enables developers to see the usage analytics page with data locally.Test plan
settings/usage— page should render without errorsnpx nx clickhouse:seed twenty-serverand confirm usage events are seededMade with Cursor