Skip to content

feat(ai): add dashboard tools for AI chat#16517

Merged
FelixMalfait merged 1 commit intomainfrom
feat/ai-dashboard-tools
Dec 12, 2025
Merged

feat(ai): add dashboard tools for AI chat#16517
FelixMalfait merged 1 commit intomainfrom
feat/ai-dashboard-tools

Conversation

@FelixMalfait
Copy link
Copy Markdown
Member

Summary

  • Implements real tools for the dashboard-building skill to create and manage dashboards through the AI chat interface
  • Adds 6 new dashboard tools: create_complete_dashboard, list_dashboards, get_dashboard, add_dashboard_widget, update_dashboard_widget, delete_dashboard_widget
  • Improves widget configuration robustness with typed Zod schemas and discriminated unions for graph types

Key Changes

New Dashboard Tools:

  • create_complete_dashboard - Creates a dashboard with layout, tab, and widgets in a single call
  • list_dashboards - Lists all dashboards in the workspace
  • get_dashboard - Gets full dashboard details including tabs and widget configurations
  • add_dashboard_widget - Adds a widget to an existing dashboard tab
  • update_dashboard_widget - Updates widget properties or configuration
  • delete_dashboard_widget - Removes a widget from a dashboard

Widget Configuration Improvements:

  • Typed Zod schemas for each chart type (AGGREGATE, BAR, LINE, PIE)
  • Discriminated union validation based on graphType
  • Widget-level error handling for partial success when creating dashboards
  • Clear documentation about required objectMetadataId and field UUIDs

Skill Documentation Updates:

  • Updated dashboard-building.skill.ts with critical guidance about looking up field metadata first
  • Added workflow instructions: use list_object_metadata_items before creating GRAPH widgets
  • Practical grid layout recommendations

Test plan

  • Create a new dashboard via AI chat
  • Verify widgets display data correctly when proper field IDs are provided
  • Test adding/updating/deleting widgets on existing dashboards
  • Verify error messages are helpful when configuration is incorrect

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 18 files

Prompt for AI agents (all 3 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/twenty-server/src/modules/dashboard/tools/schemas/widget.schema.ts">

<violation number="1" location="packages/twenty-server/src/modules/dashboard/tools/schemas/widget.schema.ts:50">
P1: `z.discriminatedUnion` requires a single literal value per member schema for the discriminator field. Using `z.enum` with multiple values (`VERTICAL_BAR`, `HORIZONTAL_BAR`) here will cause Zod to fail. Consider splitting this into two separate schemas or using `z.union` instead of `z.discriminatedUnion`.</violation>
</file>

<file name="packages/twenty-server/src/modules/dashboard/tools/update-dashboard-widget.tool.ts">

<violation number="1" location="packages/twenty-server/src/modules/dashboard/tools/update-dashboard-widget.tool.ts:80">
P2: Unsafe access to `error.message` without type checking. If a non-Error object is thrown, this will result in `undefined`. Consider using a type guard.</violation>
</file>

<file name="packages/twenty-server/src/engine/core-modules/skills/skills/dashboard-building.skill.ts">

<violation number="1" location="packages/twenty-server/src/engine/core-modules/skills/skills/dashboard-building.skill.ts:38">
P2: PIE chart documentation is incomplete and inconsistent with other chart types. Missing required fields: `objectMetadataId`, `aggregateFieldMetadataId`, and `aggregateOperation`. The actual Zod schema in `widget.schema.ts` requires all these fields, so AI-generated configurations will fail validation.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR


// Graph configuration schema for BAR charts
const barChartConfigSchema = z.object({
graphType: z.enum([GraphType.VERTICAL_BAR, GraphType.HORIZONTAL_BAR]),
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 12, 2025

Choose a reason for hiding this comment

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

P1: z.discriminatedUnion requires a single literal value per member schema for the discriminator field. Using z.enum with multiple values (VERTICAL_BAR, HORIZONTAL_BAR) here will cause Zod to fail. Consider splitting this into two separate schemas or using z.union instead of z.discriminatedUnion.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-server/src/modules/dashboard/tools/schemas/widget.schema.ts, line 50:

<comment>`z.discriminatedUnion` requires a single literal value per member schema for the discriminator field. Using `z.enum` with multiple values (`VERTICAL_BAR`, `HORIZONTAL_BAR`) here will cause Zod to fail. Consider splitting this into two separate schemas or using `z.union` instead of `z.discriminatedUnion`.</comment>

<file context>
@@ -0,0 +1,119 @@
+
+// Graph configuration schema for BAR charts
+const barChartConfigSchema = z.object({
+  graphType: z.enum([GraphType.VERTICAL_BAR, GraphType.HORIZONTAL_BAR]),
+  aggregateFieldMetadataId: z
+    .string()
</file context>
Fix with Cubic

} catch (error) {
return {
success: false,
message: `Failed to update widget: ${error.message}`,
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 12, 2025

Choose a reason for hiding this comment

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

P2: Unsafe access to error.message without type checking. If a non-Error object is thrown, this will result in undefined. Consider using a type guard.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-server/src/modules/dashboard/tools/update-dashboard-widget.tool.ts, line 80:

<comment>Unsafe access to `error.message` without type checking. If a non-Error object is thrown, this will result in `undefined`. Consider using a type guard.</comment>

<file context>
@@ -0,0 +1,85 @@
+    } catch (error) {
+      return {
+        success: false,
+        message: `Failed to update widget: ${error.message}`,
+        error: error.message,
+      };
</file context>
Fix with Cubic

Comment on lines +38 to +41
### GRAPH - PIE Charts
Required:
- configuration.graphType: "PIE"
- configuration.groupByFieldMetadataId: field to slice by
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 12, 2025

Choose a reason for hiding this comment

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

P2: PIE chart documentation is incomplete and inconsistent with other chart types. Missing required fields: objectMetadataId, aggregateFieldMetadataId, and aggregateOperation. The actual Zod schema in widget.schema.ts requires all these fields, so AI-generated configurations will fail validation.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-server/src/engine/core-modules/skills/skills/dashboard-building.skill.ts, line 38:

<comment>PIE chart documentation is incomplete and inconsistent with other chart types. Missing required fields: `objectMetadataId`, `aggregateFieldMetadataId`, and `aggregateOperation`. The actual Zod schema in `widget.schema.ts` requires all these fields, so AI-generated configurations will fail validation.</comment>

<file context>
@@ -8,59 +8,67 @@ export const DASHBOARD_BUILDING_SKILL: SkillDefinition = {
+- configuration.aggregateOperation: aggregation type
+- configuration.primaryAxisGroupByFieldMetadataId: field to group by (x-axis)
+
+### GRAPH - PIE Charts
+Required:
+- configuration.graphType: &quot;PIE&quot;
</file context>
Suggested change
### GRAPH - PIE Charts
Required:
- configuration.graphType: "PIE"
- configuration.groupByFieldMetadataId: field to slice by
### GRAPH - PIE Charts
Shows data distribution by category.
Required:
- objectMetadataId: UUID of the object
- configuration.graphType: "PIE"
- configuration.aggregateFieldMetadataId: field to aggregate
- configuration.aggregateOperation: aggregation type
- configuration.groupByFieldMetadataId: field to slice by
Fix with Cubic

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 12, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:25988

This environment will automatically shut down when the PR is closed or after 5 hours.

Implements real tools for the dashboard-building skill to create and manage
dashboards through the AI chat interface.

New tools:
- create_complete_dashboard: Create dashboard with layout, tab, and widgets
- list_dashboards: List all dashboards in workspace
- get_dashboard: Get full dashboard details including tabs and widgets
- add_dashboard_widget: Add widget to existing dashboard tab
- update_dashboard_widget: Update widget properties or configuration
- delete_dashboard_widget: Remove widget from dashboard

Key improvements:
- Typed Zod schemas for widget configuration validation
- Discriminated union for graph types (AGGREGATE, BAR, LINE, PIE)
- Widget-level error handling for partial success
- Updated skill documentation with field metadata lookup workflow
- Proper guidance for AI to use list_object_metadata_items first
@FelixMalfait FelixMalfait force-pushed the feat/ai-dashboard-tools branch from f725339 to 3b246fc Compare December 12, 2025 06:22
@FelixMalfait FelixMalfait merged commit 5f4f4c0 into main Dec 12, 2025
54 checks passed
@FelixMalfait FelixMalfait deleted the feat/ai-dashboard-tools branch December 12, 2025 06:35
@twenty-eng-sync
Copy link
Copy Markdown

Hey @FelixMalfait! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant