:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(dashboards): add collapse and color settings to tile groups (#116028)
Paul D'Ambra82cf3eed45a3
diff --git a/frontend/src/lib/components/TileDecorations/TileDecorations.stories.tsx b/frontend/src/lib/components/TileDecorations/TileDecorations.stories.tsxindex 7d4bc5dd06da..60ca5c445942 100644--- a/frontend/src/lib/components/TileDecorations/TileDecorations.stories.tsx+++ b/frontend/src/lib/components/TileDecorations/TileDecorations.stories.tsx@@ -84,7 +84,7 @@ export const WinnerWithGroupTitle: Story = {dashboardMocks(buildDashboard({ 1: { badge: 'winner', group_key: 'launch' }, 2: { group_key: 'launch' } },- { group_titles: { launch: 'Launch metrics' } }+ { groups: { launch: { title: 'Launch metrics' } } })),],diff --git a/frontend/src/scenes/dashboard/DashboardItems.tsx b/frontend/src/scenes/dashboard/DashboardItems.tsxindex b8f17da7ae04..ca3a5aa28cba 100644--- a/frontend/src/scenes/dashboard/DashboardItems.tsx+++ b/frontend/src/scenes/dashboard/DashboardItems.tsx@@ -256,11 +256,11 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsPtiles: tiles || [],layout: layouts[activeBreakpoint],activeBreakpoint,- groupTitles: dashboard?.customization?.group_titles,+ groups: dashboard?.customization?.groups,compactor: gridCompactor,widgetTilesShown,}),- [tiles, layouts, activeBreakpoint, dashboard?.customization?.group_titles, gridCompactor, widgetTilesShown]+ [tiles, layouts, activeBreakpoint, dashboard?.customization?.groups, gridCompactor, widgetTilesShown])const decorationsByTileId = useMemo(() =>diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex c0bc5b3a944e..957b1e4b8e4a 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -92,6 +92,7 @@ import type { ScopeObjectEnumApi } from 'products/access_control/frontend/generaimport { AlertType } from 'products/alerts/frontend/types'import type { BatchExportApi } from 'products/batch_exports/frontend/generated/api.schemas'import type { CohortRealtimeReadinessApi } from 'products/cohorts/frontend/generated/api.schemas'+import type { DashboardTileGroupApi } from 'products/dashboards/frontend/generated/api.schemas'import {type LineageIssueApi,type NodeApiSuspended,@@ -2822,7 +2823,7 @@ export interface DashboardType extends DashboardBasicType {customization?: {tile_spacing?: DashboardTileSpacinglayout_compaction?: 'vertical' | 'horizontal' | 'stable'- group_titles?: Record<string, string>+ groups?: Record<string, DashboardTileGroupApi>}}diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.pyindex c4543bf8e4ca..f16a04e75414 100644--- a/posthog/api/test/dashboards/test_dashboard.py+++ b/posthog/api/test/dashboards/test_dashboard.py@@ -1,6 +1,7 @@import jsonimport datetimefrom collections.abc import Callable+from typing import Anyimport time_machinefrom posthog.test.base import APIBaseTest, FuzzyInt, QueryMatchingTest, snapshot_postgres_queries@@ -728,67 +729,184 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):Dashboard.objects.get(id=copied_id).customization, {"show_legend": False, "tile_spacing": "wide"})- def test_dashboard_group_titles_are_saved_replaced_cleared_and_duplicated(self) -> None:+ def test_dashboard_groups_are_saved_replaced_cleared_and_duplicated(self) -> None:dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})- self.dashboard_api.update_dashboard(dashboard_id, {"grid_spacing": "relaxed"})_, updated = self.dashboard_api.update_dashboard(- dashboard_id, {"group_titles": {"plans": "Pricing plans", "regions": "Regions"}}+ dashboard_id,+ {+ "grid_spacing": "relaxed",+ "groups": {+ "plans": {"title": "Pricing plans", "collapsed": True, "color": "purple"},+ "regions": {},+ },+ },)self.assertEqual(updated["customization"],- {"tile_spacing": "relaxed", "group_titles": {"plans": "Pricing plans", "regions": "Regions"}},+ {+ "tile_spacing": "relaxed",+ "group_titles": {"plans": "Pricing plans"},+ "groups": {+ "plans": {"title": "Pricing plans", "collapsed": True, "color": "purple"},+ "regions": {"collapsed": False, "color": None},+ },+ },)- _, updated = self.dashboard_api.update_dashboard(dashboard_id, {"group_titles": {"plans": "Plans"}})- self.assertEqual(updated["customization"], {"tile_spacing": "relaxed", "group_titles": {"plans": "Plans"}})+ _, updated = self.dashboard_api.update_dashboard(dashboard_id, {"groups": {"plans": {"title": "Plans"}}})+ plans_only = {+ "tile_spacing": "relaxed",+ "group_titles": {"plans": "Plans"},+ "groups": {"plans": {"title": "Plans", "collapsed": False, "color": None}},+ }+ self.assertEqual(updated["customization"], plans_only)+ self.assertEqual(+ Dashboard.objects.get(id=dashboard_id).customization,+ {"tile_spacing": "relaxed", "groups": {"plans": {"title": "Plans"}}},+ )_, copied = self.dashboard_api.create_dashboard({"name": "copy", "use_dashboard": dashboard_id})- self.assertEqual(copied["customization"], {"tile_spacing": "relaxed", "group_titles": {"plans": "Plans"}})+ self.assertEqual(copied["customization"], plans_only)- _, updated = self.dashboard_api.update_dashboard(dashboard_id, {"group_titles": None})+ _, updated = self.dashboard_api.update_dashboard(dashboard_id, {"groups": None})self.assertEqual(updated["customization"], {"tile_spacing": "relaxed"})- def test_dashboard_group_title_keys_are_stripped_to_match_tile_group_keys(self) -> None:+ @parameterized.expand(+ [+ ("replace", {" plans ": "New plans", "new": "New group"}, {"plans": "New plans", "new": "New group"}),+ ("empty", {}, {}),+ ("null", None, {}),+ ]+ )+ def test_legacy_group_titles_preserve_group_settings(+ self, _name: str, titles: dict[str, str] | None, expected_titles: dict[str, str]+ ) -> None:dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})- self.dashboard_api.create_insight({"dashboards": [dashboard_id], "name": "insight"})- tile_id = self.dashboard_api.get_dashboard(dashboard_id)["tiles"][0]["id"]+ settings = {"collapsed": True, "color": "purple"}+ Dashboard.objects.filter(id=dashboard_id).update(+ customization={+ "tile_spacing": "relaxed",+ "group_titles": {"legacy": "Legacy title"},+ "groups": {"plans": {"title": "Plans", **settings}, "regions": {"title": "Regions", **settings}},+ }+ )- self.dashboard_api.update_dashboard(dashboard_id, {"tiles": [{"id": tile_id, "group_key": " plans "}]})- _, updated = self.dashboard_api.update_dashboard(dashboard_id, {"group_titles": {" plans ": "Pricing plans"}})+ _, updated = self.dashboard_api.update_dashboard(dashboard_id, {"group_titles": titles})- dashboard = self.dashboard_api.get_dashboard(dashboard_id, query_params={"refresh": False})- self.assertEqual(updated["customization"], {"group_titles": {"plans": "Pricing plans"}})- self.assertEqual(dashboard["tiles"][0]["group_key"], "plans")- self.assertEqual(dashboard["customization"]["group_titles"], {"plans": "Pricing plans"})+ stored_groups: dict[str, dict[str, Any]] = {"plans": dict(settings), "regions": dict(settings)}+ for key, title in expected_titles.items():+ stored_groups.setdefault(key, {})["title"] = title+ self.assertEqual(updated["customization"].get("group_titles", {}), expected_titles)+ self.assertEqual(+ updated["customization"]["groups"],+ {key: {"collapsed": False, "color": None, **group} for key, group in stored_groups.items()},+ )+ self.assertEqual(+ Dashboard.objects.get(id=dashboard_id).customization, {"tile_spacing": "relaxed", "groups": stored_groups}+ )++ def test_legacy_group_titles_on_create_are_stored_as_groups(self) -> None:+ dashboard_id, response = self.dashboard_api.create_dashboard(+ {"name": "dashboard", "group_titles": {"plans": "Plans"}}+ )++ self.assertEqual(response["customization"]["group_titles"], {"plans": "Plans"})+ self.assertEqual(+ Dashboard.objects.get(id=dashboard_id).customization, {"groups": {"plans": {"title": "Plans"}}}+ )++ @parameterized.expand([("create",), ("update",)])+ def test_groups_and_group_titles_together_are_rejected(self, action: str) -> None:+ data = {"group_titles": {"old": "Old"}, "groups": {"new": {"title": "New"}}}+ if action == "create":+ _, response = self.dashboard_api.create_dashboard(+ {"name": "dashboard", **data}, expected_status=status.HTTP_400_BAD_REQUEST+ )+ else:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ _, response = self.dashboard_api.update_dashboard(+ dashboard_id, data, expected_status=status.HTTP_400_BAD_REQUEST+ )- def test_dashboard_group_titles_with_padded_keys_saved_earlier_are_read_stripped(self) -> None:+ self.assertEqual(response["attr"], "groups")++ @parameterized.expand(+ [+ ("drop_groups_left_with_only_a_title", 100, False, 1),+ ("keep_settings_at_limit", 99, True, 100),+ ("reject_above_limit", 100, True, None),+ ]+ )+ def test_legacy_group_titles_respect_group_limit(+ self, _name: str, count: int, collapsed: bool, expected_count: int | None+ ) -> None:dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})- Dashboard.objects.filter(id=dashboard_id).update(- customization={"group_titles": {" plans ": "Pricing plans", " ": "Blank"}}+ customization = {+ "groups": {+ str(index): {"title": "Old title", **({"collapsed": True} if collapsed else {})}+ for index in range(count)+ }+ }+ Dashboard.objects.filter(id=dashboard_id).update(customization=customization)+ _, response = self.dashboard_api.update_dashboard(+ dashboard_id,+ {"group_titles": {"new": "New title"}},+ expected_status=status.HTTP_400_BAD_REQUEST if expected_count is None else status.HTTP_200_OK,)+ if expected_count is None:+ self.assertEqual(response["attr"], "group_titles")+ self.assertEqual(Dashboard.objects.get(id=dashboard_id).customization, customization)+ else:+ self.assertEqual(len(response["customization"]["groups"]), expected_count)+ self.assertEqual(response["customization"]["group_titles"], {"new": "New title"})- dashboard = self.dashboard_api.get_dashboard(dashboard_id, query_params={"refresh": False})+ def test_writing_groups_replaces_group_titles_saved_earlier(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ Dashboard.objects.filter(id=dashboard_id).update(customization={"group_titles": {"plans": "Pricing plans"}})++ self.dashboard_api.update_dashboard(dashboard_id, {"groups": {"regions": {"title": "Regions"}}})- self.assertEqual(dashboard["customization"], {"group_titles": {"plans": "Pricing plans"}})+ self.assertEqual(+ Dashboard.objects.get(id=dashboard_id).customization, {"groups": {"regions": {"title": "Regions"}}}+ )++ def test_dashboard_group_keys_are_stripped_to_match_tile_group_keys(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ self.dashboard_api.create_insight({"dashboards": [dashboard_id], "name": "insight"})+ tile_id = self.dashboard_api.get_dashboard(dashboard_id)["tiles"][0]["id"]++ self.dashboard_api.update_dashboard(dashboard_id, {"tiles": [{"id": tile_id, "group_key": " plans "}]})+ _, updated = self.dashboard_api.update_dashboard(+ dashboard_id, {"groups": {" plans ": {"title": "Pricing plans"}}}+ )++ dashboard = self.dashboard_api.get_dashboard(dashboard_id, query_params={"refresh": False})+ stripped = {"plans": {"title": "Pricing plans", "collapsed": False, "color": None}}+ self.assertEqual(updated["customization"], {"groups": stripped, "group_titles": {"plans": "Pricing plans"}})+ self.assertEqual(dashboard["tiles"][0]["group_key"], "plans")+ self.assertEqual(dashboard["customization"]["groups"], stripped)@parameterized.expand([- ("blank_key", {" ": "Blank"}),- ("too_long_key", {"k" * 101: "Too long"}),- ("keys_equal_after_strip", {"plans": "Plans", " plans ": "Padded plans"}),- ("null_character_key", {"plans\u0000": "Plans"}),- ("too_many_titles", {f"group-{index}": "Title" for index in range(101)}),+ ("blank_key", {" ": {}}),+ ("too_long_key", {"k" * 101: {}}),+ ("keys_equal_after_strip", {"plans": {}, " plans ": {}}),+ ("null_character_key", {"plans\u0000": {}}),+ ("too_many_groups", {f"group-{index}": {} for index in range(101)}),+ ("title_too_long", {"plans": {"title": "t" * 201}}),+ ("unknown_color", {"plans": {"color": "pink"}}),+ ("settings_not_an_object", {"plans": "Pricing plans"}),])- def test_dashboard_group_titles_are_rejected_when_invalid(self, _name: str, group_titles: dict[str, str]) -> None:+ def test_dashboard_groups_are_rejected_when_invalid(self, _name: str, groups: dict) -> None:dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})_, response = self.dashboard_api.update_dashboard(- dashboard_id, {"group_titles": group_titles}, expected_status=status.HTTP_400_BAD_REQUEST+ dashboard_id, {"groups": groups}, expected_status=status.HTTP_400_BAD_REQUEST)- self.assertEqual(response["attr"], "group_titles")+ self.assertTrue(response["attr"].startswith("groups"), response)@parameterized.expand([("horizontal",), ("stable",)])def test_dashboard_layout_compaction_is_saved_and_duplicated(self, layout_compaction: str) -> None:@@ -2068,7 +2186,7 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):_, response = self.dashboard_api.update_dashboard(dashboard_id,{- "group_titles": {"plans": "Pricing plans"},+ "groups": {"plans": {"title": "Pricing plans"}},"tiles": [{"id": first_tile_id, "badge": "winner"},{"id": second_tile_id, **invalid_marking},@@ -2099,7 +2217,7 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):dashboard_id,{"name": "renamed",- "group_titles": {"plans": "Pricing plans"},+ "groups": {"plans": {"title": "Pricing plans"}},"tiles": [{"id": text_tile["id"], "text": {"body": "edited"}, **invalid_marking}],},expected_status=status.HTTP_400_BAD_REQUEST,@@ -2869,7 +2987,10 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):self.dashboard_api.get_dashboard(dashboard.pk, team_id=team2.pk, expected_status=status.HTTP_403_FORBIDDEN)def test_patch_api_as_form_data(self):- dashboard = Dashboard.objects.create(team=self.team, name="dashboard", created_by=self.user)+ customization = {"groups": {"plans": {"title": "Plans"}}}+ dashboard = Dashboard.objects.create(+ team=self.team, name="dashboard", created_by=self.user, customization=customization+ )response = self.client.patch(f"/api/projects/{self.team.id}/dashboards/{dashboard.pk}/",data="name=replaced",@@ -2877,6 +2998,7 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):)self.assertEqual(response.status_code, 200, response.content)self.assertEqual(response.json()["name"], "replaced")+ self.assertEqual(Dashboard.objects.get(id=dashboard.pk).customization, customization)def test_dashboard_does_not_load_insight_that_was_deleted(self) -> None:dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.pyindex 588296a43847..57a17e997e6d 100644--- a/products/dashboards/backend/api/dashboard.py+++ b/products/dashboards/backend/api/dashboard.py@@ -4,7 +4,7 @@ import reimport jsonimport uuidimport builtins-from collections.abc import AsyncGenerator+from collections.abc import AsyncGenerator, Mappingfrom concurrent.futures import ThreadPoolExecutor, as_completedfrom contextlib import nullcontextfrom enum import StrEnum@@ -41,10 +41,12 @@ from drf_spectacular.types import OpenApiTypesfrom drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_field, extend_schema_viewfrom opentelemetry import tracefrom rest_framework import exceptions, serializers, status, viewsets+from rest_framework.fields import emptyfrom rest_framework.permissions import SAFE_METHODS, BasePermissionfrom rest_framework.request import Requestfrom rest_framework.response import Responsefrom rest_framework.serializers import BaseSerializer+from rest_framework.utils import htmlfrom rest_framework.utils.serializer_helpers import ReturnDictfrom posthog.schema import InsightVizNode@@ -125,10 +127,13 @@ from products.dashboards.backend.api.dashboard_template_json_schema_parser imporDashboardTemplateCreationJSONSchemaParser,)from products.dashboards.backend.api.widget_openapi_serializers import (+ DASHBOARD_TILE_GROUP_DEFAULTS,GROUP_TITLES_HELP_TEXT,+ GROUPS_HELP_TEXT,WIDGET_BATCH_ADD_OPENAPI_HELP,AddDashboardWidgetRequestOpenApi,BreakdownColorConfigSerializer,+ DashboardTileGroupSerializer,DashboardWidgetConfigField,PatchedDashboardOpenApiSerializer,UpdateDashboardWidgetRequestOpenApi,@@ -138,7 +143,7 @@ from products.dashboards.backend.constants import (DASHBOARD_GRID_COLUMN_COUNT,MAX_GROUP_KEY_LENGTH,MAX_GROUP_TITLE_LENGTH,- MAX_GROUP_TITLES,+ MAX_GROUPS,MAX_TEXT_TILE_AGENT_CONTEXT_LENGTH,MAX_WIDGETS_BATCH_SIZE,RUN_INSIGHTS_DEFAULT_MAX_RESULT_CHARS,@@ -223,28 +228,87 @@ def _normalized_group_key(group_key: str) -> str:return group_key-def _valid_group_titles(customization: Any) -> dict[str, str]:- group_titles = _normalize_dashboard_customization(customization).get("group_titles")- if not isinstance(group_titles, dict):- return {}- valid_titles: dict[str, str] = {}- for key, title in group_titles.items():- if not isinstance(key, str) or not isinstance(title, str):+_NO_DEFAULT = object()+++def _is_stored_group_setting(field: str, setting: Any) -> bool:+ if field == "title":+ return bool(setting)+ return setting != DASHBOARD_TILE_GROUP_DEFAULTS.get(field, _NO_DEFAULT)+++def _without_default_settings(group: Mapping[str, Any]) -> dict[str, Any]:+ return {field: setting for field, setting in group.items() if _is_stored_group_setting(field, setting)}+++def _sparse_group(group_settings: Any) -> dict[str, Any] | None:+ group = DashboardTileGroupSerializer(data=group_settings)+ if not group.is_valid():+ return None+ return _without_default_settings(group.validated_data)+++def _stored_groups(customization: Any) -> dict[str, dict[str, Any]]:+ customization = _normalize_dashboard_customization(customization)+ groups = customization.get("groups") if isinstance(customization.get("groups"), dict) else {}+ titles = customization.get("group_titles") if isinstance(customization.get("group_titles"), dict) else {}+ stored: dict[str, dict[str, Any]] = {}+ for raw_key in {**groups, **titles}:+ if not isinstance(raw_key, str):continuetry:- group_key = _normalized_group_key(key)+ group_key = _normalized_group_key(raw_key)except serializers.ValidationError:continue- if group_key:- valid_titles[group_key] = title- return valid_titles+ group = _sparse_group(groups.get(raw_key, {}))+ # Only a server from before `groups` writes `group_titles`, so a stored title there is the newer one.+ title = _sparse_group({"title": titles[raw_key]}) if raw_key in titles else None+ if group_key and (group is not None or title is not None):+ stored[group_key] = {**(group or {}), **(title or {})}+ return stored+++def _with_groups(customization: dict[str, Any], groups: dict[str, dict[str, Any]] | None) -> dict[str, Any]:+ customization = {key: value for key, value in customization.items() if key not in ("groups", "group_titles")}+ if groups:+ customization["groups"] = groups+ return customization-def _with_group_titles(customization: dict[str, Any], group_titles: dict[str, str] | None) -> dict[str, Any]:- customization = {key: value for key, value in customization.items() if key != "group_titles"}- if group_titles:- customization["group_titles"] = group_titles- return customization+def _with_group_titles(customization: dict[str, Any], titles: dict[str, str] | None) -> dict[str, Any]:+ groups = {+ key: {field: value for field, value in group.items() if field != "title"}+ for key, group in _stored_groups(customization).items()+ }+ for key, title in (titles or {}).items():+ groups.setdefault(key, {})["title"] = title+ groups = {key: group for key, group in groups.items() if group}+ if len(groups) > MAX_GROUPS:+ raise serializers.ValidationError({"group_titles": f"A dashboard can have at most {MAX_GROUPS} groups."})+ return _with_groups(customization, groups)+++def _validated_group_keys[T](value: dict[str, T]) -> dict[str, T]:+ if len(value) > MAX_GROUPS:+ raise serializers.ValidationError(f"A dashboard can have at most {MAX_GROUPS} groups.")+ normalized: dict[str, T] = {}+ for key, item in value.items():+ group_key = _normalized_group_key(key)+ if not group_key:+ raise serializers.ValidationError("Group keys can't be empty.")+ if len(group_key) > MAX_GROUP_KEY_LENGTH:+ raise serializers.ValidationError(f"Group keys can have at most {MAX_GROUP_KEY_LENGTH} characters.")+ if group_key in normalized:+ raise serializers.ValidationError(f'Group key "{group_key}" is used more than once.')+ normalized[group_key] = item+ return normalized+++class _GroupDictField(serializers.DictField):+ # DRF reads a dict field that form data omits as an empty dict, and an empty dict clears the stored groups.+ def get_value(self, dictionary: Any) -> Any:+ value = super().get_value(dictionary)+ return empty if html.is_html_input(dictionary) and not value else valuedef _effective_layout_compaction(customization: Any) -> str:@@ -324,6 +388,7 @@ DASHBOARD_SHARED_FIELDS = ["customization","grid_spacing","layout_compaction",+ "groups","group_titles",]@@ -1348,6 +1413,11 @@ class DashboardCustomizationSerializer(serializers.Serializer):"to the left, and stable preserves positions while moving colliding tiles."),)+ groups = serializers.DictField(+ child=DashboardTileGroupSerializer(),+ required=False,+ help_text=GROUPS_HELP_TEXT,+ )group_titles = serializers.DictField(child=serializers.CharField(),required=False,@@ -1416,7 +1486,14 @@ class DashboardMetadataSerializer(DashboardBasicSerializer):"to the left, and stable preserves positions while moving colliding tiles."),)- group_titles = serializers.DictField(+ groups = _GroupDictField(+ child=DashboardTileGroupSerializer(),+ required=False,+ allow_null=True,+ write_only=True,+ help_text=GROUPS_HELP_TEXT,+ )+ group_titles = _GroupDictField(child=serializers.CharField(max_length=MAX_GROUP_TITLE_LENGTH),required=False,allow_null=True,@@ -1436,22 +1513,18 @@ class DashboardMetadataSerializer(DashboardBasicSerializer):"last_accessed_at",]- def validate_group_titles(self, value: dict[str, str] | None) -> dict[str, str] | None:+ def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:+ if "groups" in attrs and "group_titles" in attrs:+ raise serializers.ValidationError({"groups": "Send groups or group_titles, not both."})+ return super().validate(attrs)++ def validate_groups(self, value: dict[str, dict[str, Any]] | None) -> dict[str, dict[str, Any]] | None:if value is None:return None- if len(value) > MAX_GROUP_TITLES:- raise serializers.ValidationError(f"A dashboard can have at most {MAX_GROUP_TITLES} group titles.")- normalized: dict[str, str] = {}- for key, title in value.items():- group_key = _normalized_group_key(key)- if not group_key:- raise serializers.ValidationError("Group keys can't be empty.")- if len(group_key) > MAX_GROUP_KEY_LENGTH:- raise serializers.ValidationError(f"Group keys can have at most {MAX_GROUP_KEY_LENGTH} characters.")- if group_key in normalized:- raise serializers.ValidationError(f'Group key "{group_key}" is used more than once.')- normalized[group_key] = title- return normalized+ return {key: _without_default_settings(group) for key, group in _validated_group_keys(value).items()}++ def validate_group_titles(self, value: dict[str, str] | None) -> dict[str, str] | None:+ return None if value is None else _validated_group_keys(value)def get_filters(self, dashboard: Dashboard) -> dict:request = self.context.get("request")@@ -1468,9 +1541,12 @@ class DashboardMetadataSerializer(DashboardBasicSerializer):result["tile_spacing"] = tile_spacingif isinstance(layout_compaction, str) and layout_compaction in DASHBOARD_GRID_COMPACTION_MODES:result["layout_compaction"] = layout_compaction- group_titles = _valid_group_titles(customization)- if group_titles:- result["group_titles"] = group_titles+ groups = _stored_groups(customization)+ if groups:+ result["groups"] = {key: {**DASHBOARD_TILE_GROUP_DEFAULTS, **group} for key, group in groups.items()}+ titles = {key: group["title"] for key, group in groups.items() if "title" in group}+ if titles:+ result["group_titles"] = titlesreturn resultdef get_variables(self, dashboard: Dashboard) -> dict | None:@@ -1818,6 +1894,8 @@ class DashboardSerializer(DashboardMetadataSerializer):team = self.context["get_team"]()grid_spacing = validated_data.pop("grid_spacing", None)layout_compaction = validated_data.pop("layout_compaction", None)+ has_groups = "groups" in validated_data+ groups = validated_data.pop("groups", None)has_group_titles = "group_titles" in validated_datagroup_titles = validated_data.pop("group_titles", None)current_count = Dashboard.objects.filter(team_id=team_id, deleted=False).count()@@ -1882,6 +1960,8 @@ class DashboardSerializer(DashboardMetadataSerializer):**validated_data.get("customization", {}),"layout_compaction": layout_compaction,}+ if has_groups:+ validated_data["customization"] = _with_groups(validated_data.get("customization", {}), groups)if has_group_titles:validated_data["customization"] = _with_group_titles(validated_data.get("customization", {}), group_titles)@@ -2110,6 +2190,11 @@ class DashboardSerializer(DashboardMetadataSerializer):**({"tile_spacing": grid_spacing} if grid_spacing is not None else {}),**({"layout_compaction": layout_compaction} if layout_compaction is not None else {}),}+ if "groups" in validated_data:+ validated_data["customization"] = _with_groups(+ validated_data.get("customization", _normalize_dashboard_customization(instance.customization)),+ validated_data.pop("groups"),+ )if "group_titles" in validated_data:validated_data["customization"] = _with_group_titles(validated_data.get("customization", _normalize_dashboard_customization(instance.customization)),@@ -2843,7 +2928,7 @@ class DashboardSerializer(DashboardMetadataSerializer):def validate(self, data):if data.get("use_dashboard", None) and data.get("use_template", None):raise serializers.ValidationError("`use_dashboard` and `use_template` cannot be used together")- return data+ return super().validate(data)def _update_creation_mode(self, validated_data, use_template: str, use_dashboard: int):if use_template:diff --git a/products/dashboards/backend/api/test/test_dashboard_groups.py b/products/dashboards/backend/api/test/test_dashboard_groups.pynew file mode 100644index 000000000000..ad0157b3c8ac--- /dev/null+++ b/products/dashboards/backend/api/test/test_dashboard_groups.py@@ -0,0 +1,59 @@+from typing import Any++from django.test import SimpleTestCase++from parameterized import parameterized++from products.dashboards.backend.api.dashboard import _stored_groups+++class TestStoredGroups(SimpleTestCase):+ # Explicitly typed so mypy doesn't narrow the customization type from the first+ # cases and then reject a later case that mixes value types (str, bool, None).+ cases: list[tuple[str, Any, dict[str, Any]]] = [+ ("no_customization", None, {}),+ (+ "group_titles_saved_before_groups_existed",+ {"group_titles": {"plans": "Pricing plans"}},+ {"plans": {"title": "Pricing plans"}},+ ),+ (+ "group_titles_win_because_only_an_older_server_writes_them",+ {+ "group_titles": {"plans": "New title"},+ "groups": {"plans": {"title": "Old title", "color": "green"}, "regions": {}},+ },+ {"plans": {"title": "New title", "color": "green"}, "regions": {}},+ ),+ (+ "invalid_settings_keep_the_group_title",+ {"group_titles": {"plans": "Plans"}, "groups": {"plans": {"color": "pink"}}},+ {"plans": {"title": "Plans"}},+ ),+ (+ "padded_and_blank_keys",+ {"groups": {" plans ": {"title": "Pricing plans"}, " ": {"title": "Blank"}}},+ {"plans": {"title": "Pricing plans"}},+ ),+ (+ "invalid_entries_are_dropped",+ {+ "groups": {+ "plans": {"color": "pink"},+ "regions": "Regions",+ "nulls\u0000": {},+ "kept": {"collapsed": True, "title": ""},+ }+ },+ {"kept": {"collapsed": True}},+ ),+ (+ "settings_equal_to_defaults_are_dropped",+ {"groups": {"plans": {"title": "Plans", "collapsed": False, "color": None}}},+ {"plans": {"title": "Plans"}},+ ),+ ]++ @parameterized.expand(cases)+ def test_reads_stored_groups(self, _name: str, customization: Any, expected: dict) -> None:+ assert _stored_groups(customization) == expecteddiff --git a/products/dashboards/backend/api/widget_openapi_serializers.py b/products/dashboards/backend/api/widget_openapi_serializers.pyindex f1cd9a5f331b..b0cfcf4b8211 100644--- a/products/dashboards/backend/api/widget_openapi_serializers.py+++ b/products/dashboards/backend/api/widget_openapi_serializers.py@@ -7,13 +7,16 @@ package."""from products.dashboards.backend.widget_specs.openapi import (+ DASHBOARD_TILE_GROUP_DEFAULTS,GROUP_TITLES_HELP_TEXT,+ GROUPS_HELP_TEXT,WIDGET_BATCH_ADD_OPENAPI_HELP,WIDGET_CONFIG_SERIALIZERS,AddDashboardWidgetRequestOpenApi,BreakdownColorConfigSerializer,DashboardPatchTileOpenApiSerializer,DashboardPatchWidgetOpenApiSerializer,+ DashboardTileGroupSerializer,DashboardWidgetConfigField,DashboardWidgetConfigOpenApi,PatchedDashboardOpenApiSerializer,@@ -33,6 +36,9 @@ __all__ = ["UpdateDashboardWidgetRequestOpenApi","WidgetCatalogEntryOpenApi","WidgetCatalogResponseSerializer",+ "DashboardTileGroupSerializer",+ "DASHBOARD_TILE_GROUP_DEFAULTS",+ "GROUPS_HELP_TEXT","GROUP_TITLES_HELP_TEXT","WIDGET_BATCH_ADD_OPENAPI_HELP","WIDGET_CONFIG_SERIALIZERS",diff --git a/products/dashboards/backend/constants.py b/products/dashboards/backend/constants.pyindex f72ec1c6da2c..fba194870d3b 100644--- a/products/dashboards/backend/constants.py+++ b/products/dashboards/backend/constants.py@@ -24,7 +24,7 @@ LOGS_LIST_DEFAULT_LIMIT = 50MAX_WIDGETS_BATCH_SIZE = 10MAX_TEXT_TILE_AGENT_CONTEXT_LENGTH = 10_000-MAX_GROUP_TITLES = 100+MAX_GROUPS = 100MAX_GROUP_KEY_LENGTH = 100MAX_GROUP_TITLE_LENGTH = 200diff --git a/products/dashboards/backend/models/dashboard.py b/products/dashboards/backend/models/dashboard.pyindex 7978fcd28bff..ad93fadaf129 100644--- a/products/dashboards/backend/models/dashboard.py+++ b/products/dashboards/backend/models/dashboard.py@@ -34,6 +34,15 @@ class LayoutCompaction(models.TextChoices):DASHBOARD_GRID_COMPACTION_MODES = tuple(LayoutCompaction.values)+class DashboardTileGroupColor(models.TextChoices):+ BLUE = "blue", "Blue"+ PURPLE = "purple", "Purple"+ GREEN = "green", "Green"+ YELLOW = "yellow", "Yellow"+ ORANGE = "orange", "Orange"+ RED = "red", "Red"++class DashboardManager(RootTeamManager):def get_queryset(self):return super().get_queryset().exclude(deleted=True)diff --git a/products/dashboards/backend/models/dashboard_tile.py b/products/dashboards/backend/models/dashboard_tile.pyindex 95b96d844789..a8111f868e4b 100644--- a/products/dashboards/backend/models/dashboard_tile.py+++ b/products/dashboards/backend/models/dashboard_tile.py@@ -113,7 +113,7 @@ class DashboardTile(models.Model):transparent_background = models.BooleanField(null=True, blank=True)- # Tiles that share a group key belong together. The dashboard's `customization.group_titles` names each group.+ # Tiles that share a group key belong together. The dashboard's `customization.groups` holds each group's title and style.group_key = models.CharField(max_length=MAX_GROUP_KEY_LENGTH, null=True, blank=True)badge = models.CharField(max_length=20, choices=DashboardTileBadge.choices, null=True)diff --git a/products/dashboards/backend/widget_specs/openapi.py b/products/dashboards/backend/widget_specs/openapi.pyindex 0544bc6951f4..8aebd3fc692d 100644--- a/products/dashboards/backend/widget_specs/openapi.py+++ b/products/dashboards/backend/widget_specs/openapi.py@@ -13,18 +13,28 @@ from products.dashboards.backend.constants import (MAX_GROUP_KEY_LENGTH,MAX_GROUP_TITLE_LENGTH,)-from products.dashboards.backend.models.dashboard import DASHBOARD_GRID_COMPACTION_MODES, DASHBOARD_GRID_SPACING_GAPS+from products.dashboards.backend.models.dashboard import (+ DASHBOARD_GRID_COMPACTION_MODES,+ DASHBOARD_GRID_SPACING_GAPS,+ DashboardTileGroupColor,+)from products.dashboards.backend.models.dashboard_tile import DashboardTileBadgefrom products.dashboards.backend.widget_specs.pydantic_openapi import pydantic_config_field, pydantic_stub_serializerfrom products.dashboards.backend.widget_specs.registry import EXPECTED_WIDGET_TYPES, WIDGET_SPECS+GROUPS_HELP_TEXT = (+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a "+ "heading that viewers can open and close. Viewers who do not have bands yet see only the group title above "+ "its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."+)GROUP_TITLES_HELP_TEXT = (- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. "- "A write replaces the whole map. Send an empty object or null to remove all group titles."+ "Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps "+ "the other group settings. Send an empty object or null to clear titles. Do not send it with groups.")GROUP_KEY_HELP_TEXT = ("Key that puts this tile in a group with the other tiles that have the same key on this dashboard. "- "Set the group's title in the dashboard's group_titles. Null or an empty string removes the tile from its group."+ "Set the group's title and style in the dashboard's groups. Null or an empty string removes the tile from its "+ "group.")BADGE_HELP_TEXT = ("Badge on the tile. winner shows a crown in the top left corner, for example to mark the best tile in a group. "@@ -32,6 +42,33 @@ BADGE_HELP_TEXT = ("More than one tile in a group can have the winner badge.")++DASHBOARD_TILE_GROUP_DEFAULTS = {"collapsed": False, "color": None}+++# No field has a default, so a write stores only the settings the client sent.+class DashboardTileGroupSerializer(serializers.Serializer):+ title = serializers.CharField(+ max_length=MAX_GROUP_TITLE_LENGTH,+ required=False,+ allow_blank=True,+ help_text="Heading for the group. When it is blank or omitted, the heading shows the number of tiles.",+ )+ collapsed = serializers.BooleanField(+ required=False,+ help_text=(+ "Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their "+ "browser keeps that choice and it wins over this default."+ ),+ )+ color = serializers.ChoiceField(+ choices=DashboardTileGroupColor.choices,+ required=False,+ allow_null=True,+ help_text="Color of a dot before the group heading. Null or omitted shows no dot.",+ )++WIDGET_BATCH_ADD_OPENAPI_HELP = ("Widget tiles to add atomically. Supported widget_type values: "+ ", ".join(sorted(EXPECTED_WIDGET_TYPES))@@ -459,6 +496,12 @@ class PatchedDashboardOpenApiSerializer(serializers.Serializer):"to the left, and stable preserves positions while moving colliding tiles."),)+ groups = serializers.DictField(+ child=DashboardTileGroupSerializer(),+ required=False,+ allow_null=True,+ help_text=GROUPS_HELP_TEXT,+ )group_titles = serializers.DictField(child=serializers.CharField(max_length=MAX_GROUP_TITLE_LENGTH),required=False,diff --git a/products/dashboards/frontend/dashboardTileGroups.test.ts b/products/dashboards/frontend/dashboardTileGroups.test.tsindex 2339eb0b92dd..a11488cb6124 100644--- a/products/dashboards/frontend/dashboardTileGroups.test.ts+++ b/products/dashboards/frontend/dashboardTileGroups.test.ts@@ -6,6 +6,7 @@ import type { DashboardLayoutSize, DashboardTile, DashboardWidgetModel, TileLayoimport { DashboardGridCompaction, getDashboardGridCompactor } from './dashboardCustomization'import { getGroupTitlesByTileId, hasTileDecorations } from './dashboardTileGroups'+import type { DashboardTileGroupApi } from './generated/api.schemas'const tile = (id: number, group_key: string | null): DashboardTile =>({ id, group_key, layouts: {}, color: null }) as DashboardTile@@ -27,7 +28,7 @@ interface GroupTitlesCase {tiles: DashboardTile[]layout: Layout | undefinedbreakpoint?: DashboardLayoutSize- groupTitles: Record<string, string> | undefined+ groups: Record<string, DashboardTileGroupApi> | undefinedwidgetTilesShown: booleanexpected: Record<number, string>}@@ -43,7 +44,7 @@ describe('dashboardTileGroups', () => {{ i: '3', x: 0, y: 2, w: 4, h: 2 },{ i: '4', x: 0, y: 4, w: 4, h: 2 },],- groupTitles: { plans: 'Pricing plans', regions: 'Regions' },+ groups: { plans: { title: 'Pricing plans' }, regions: { title: 'Regions' } },widgetTilesShown: true,expected: { 2: 'Pricing plans', 3: 'Regions' },},@@ -51,7 +52,7 @@ describe('dashboardTileGroups', () => {name: 'skips groups without a title',tiles: [tile(1, 'plans'), tile(2, 'untitled')],layout: undefined,- groupTitles: { plans: 'Pricing plans' } as Record<string, string>,+ groups: { plans: { title: 'Pricing plans' }, untitled: {} },widgetTilesShown: true,expected: { 1: 'Pricing plans' },},@@ -59,7 +60,7 @@ describe('dashboardTileGroups', () => {name: 'draws nothing when the dashboard has no group titles',tiles: [tile(1, 'plans')],layout: undefined,- groupTitles: undefined,+ groups: undefined,widgetTilesShown: true,expected: {},},@@ -67,7 +68,7 @@ describe('dashboardTileGroups', () => {name: `ignores the inherited object key ${groupKey}`,tiles: [tile(1, groupKey)],layout: undefined,- groupTitles: { plans: 'Pricing plans' } as Record<string, string>,+ groups: { plans: { title: 'Pricing plans' } },widgetTilesShown: true,expected: {},})),@@ -81,7 +82,7 @@ describe('dashboardTileGroups', () => {{ i: '1', x: 0, y: 0, w: 6, h: 2 },{ i: '2', x: 6, y: 0, w: 6, h: 2 },],- groupTitles: { plans: 'Pricing plans' },+ groups: { plans: { title: 'Pricing plans' } },widgetTilesShown,expected,})),@@ -95,26 +96,23 @@ describe('dashboardTileGroups', () => {tiles,layout: calculateLayouts(tiles)[breakpoint],breakpoint,- groupTitles: { plans: 'Pricing plans' },+ groups: { plans: { title: 'Pricing plans' } },widgetTilesShown: true,expected,}}),- ] as GroupTitlesCase[])(- '$name',- ({ tiles, layout, breakpoint = 'sm', groupTitles, widgetTilesShown, expected }) => {- expect(- getGroupTitlesByTileId({- tiles,- layout,- activeBreakpoint: breakpoint,- groupTitles,- compactor: getDashboardGridCompactor(DashboardGridCompaction.Vertical),- widgetTilesShown,- })- ).toEqual(expected)- }- )+ ] as GroupTitlesCase[])('$name', ({ tiles, layout, breakpoint = 'sm', groups, widgetTilesShown, expected }) => {+ expect(+ getGroupTitlesByTileId({+ tiles,+ layout,+ activeBreakpoint: breakpoint,+ groups,+ compactor: getDashboardGridCompactor(DashboardGridCompaction.Vertical),+ widgetTilesShown,+ })+ ).toEqual(expected)+ })it.each([{diff --git a/products/dashboards/frontend/dashboardTileGroups.ts b/products/dashboards/frontend/dashboardTileGroups.tsindex 7f1a828ab55e..8da3c6f2961d 100644--- a/products/dashboards/frontend/dashboardTileGroups.ts+++ b/products/dashboards/frontend/dashboardTileGroups.ts@@ -6,17 +6,19 @@ import { BREAKPOINT_COLUMN_COUNTS } from 'scenes/dashboard/dashboardUtils'import type { DashboardLayoutSize, DashboardTile } from '~/types'+import type { DashboardTileGroupApi } from './generated/api.schemas'+interface GroupTitlesInput {tiles: DashboardTile[]layout: Layout | undefinedactiveBreakpoint: DashboardLayoutSize- groupTitles: Record<string, string> | undefined+ groups: Record<string, DashboardTileGroupApi> | undefinedcompactor: CompactorwidgetTilesShown: boolean}-function getGroupTitle(groupTitles: Record<string, string>, groupKey: string): string | undefined {- const title: unknown = Object.hasOwn(groupTitles, groupKey) ? groupTitles[groupKey] : undefined+function getGroupTitle(groups: Record<string, DashboardTileGroupApi>, groupKey: string): string | undefined {+ const title: unknown = Object.hasOwn(groups, groupKey) ? groups[groupKey]?.title : undefinedreturn typeof title === 'string' && title ? title : undefined}@@ -37,11 +39,11 @@ export function getGroupTitlesByTileId({tiles,layout,activeBreakpoint,- groupTitles,+ groups,compactor,widgetTilesShown,}: GroupTitlesInput): Record<number, string> {- if (!groupTitles) {+ if (!groups) {return {}}const renderedTiles = tiles.filter((tile) => !tile.widget || widgetTilesShown)@@ -58,7 +60,7 @@ export function getGroupTitlesByTileId({if (!tile.group_key) {continue}- const title = getGroupTitle(groupTitles, tile.group_key)+ const title = getGroupTitle(groups, tile.group_key)if (!title) {continue}diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 680ff264833c..cb09743b11e5 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -292,7 +292,52 @@ export type DashboardApiPersistedFilters = { [key: string]: unknown } | nullexport type DashboardApiPersistedVariables = { [key: string]: unknown } | null/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * * `blue` - Blue+ * * `purple` - Purple+ * * `green` - Green+ * * `yellow` - Yellow+ * * `orange` - Orange+ * * `red` - Red+ */+export type DashboardTileGroupColorEnumApi =+ (typeof DashboardTileGroupColorEnumApi)[keyof typeof DashboardTileGroupColorEnumApi]++export const DashboardTileGroupColorEnumApi = {+ Blue: 'blue',+ Purple: 'purple',+ Green: 'green',+ Yellow: 'yellow',+ Orange: 'orange',+ Red: 'red',+} as const++export interface DashboardTileGroupApi {+ /**+ * Heading for the group. When it is blank or omitted, the heading shows the number of tiles.+ * @maxLength 200+ */+ title?: string+ /** Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default. */+ collapsed?: boolean+ /** Color of a dot before the group heading. Null or omitted shows no dot.+ *+ * * `blue` - Blue+ * * `purple` - Purple+ * * `green` - Green+ * * `yellow` - Yellow+ * * `orange` - Orange+ * * `red` - Red */+ color?: DashboardTileGroupColorEnumApi | null+}++/**+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+export type DashboardApiGroups = { [key: string]: DashboardTileGroupApi } | null++/**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/export type DashboardApiGroupTitles = { [key: string]: string } | null@@ -368,7 +413,12 @@ export const LayoutCompactionEnumApi = {} as const/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ */+export type DashboardCustomizationApiGroups = { [key: string]: DashboardTileGroupApi }++/**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.*/export type DashboardCustomizationApiGroupTitles = { [key: string]: string }@@ -387,7 +437,9 @@ export interface DashboardCustomizationApi {* * `horizontal` - horizontal* * `stable` - stable */layout_compaction?: LayoutCompactionEnumApi- /** Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles. */+ /** Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings. */+ groups?: DashboardCustomizationApiGroups+ /** Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups. */group_titles?: DashboardCustomizationApiGroupTitles}@@ -475,7 +527,12 @@ export interface DashboardApi {* * `stable` - stable */layout_compaction?: LayoutCompactionEnumApi/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+ groups?: DashboardApiGroups+ /**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/group_titles?: DashboardApiGroupTitles@@ -494,7 +551,13 @@ export interface DashboardApi {}/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+export type PatchedPatchedDashboardOpenApiApiGroups = { [key: string]: DashboardTileGroupApi } | null++/**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/export type PatchedPatchedDashboardOpenApiApiGroupTitles = { [key: string]: string } | null@@ -1079,7 +1142,7 @@ export interface DashboardPatchTileOpenApiApi {/** Whether to show the tile's description underneath its title on the dashboard. Works for every tile type. The description itself is unaffected and still comes from the tile's insight, text, or widget content — this only toggles whether it renders on the dashboard. */show_description?: boolean/**- * Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title in the dashboard's group_titles. Null or an empty string removes the tile from its group.+ * Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title and style in the dashboard's groups. Null or an empty string removes the tile from its group.* @maxLength 100* @nullable*/@@ -1140,7 +1203,12 @@ export interface PatchedPatchedDashboardOpenApiApi {* * `stable` - stable */layout_compaction?: LayoutCompactionEnumApi/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+ groups?: PatchedPatchedDashboardOpenApiApiGroups+ /**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/group_titles?: PatchedPatchedDashboardOpenApiApiGroupTitlesdiff --git a/products/dashboards/frontend/generated/api.zod.ts b/products/dashboards/frontend/generated/api.zod.tsindex f8e8e7f8e539..aa3df256911d 100644--- a/products/dashboards/frontend/generated/api.zod.ts+++ b/products/dashboards/frontend/generated/api.zod.ts@@ -132,6 +132,8 @@ export const DashboardTemplatesCopyBetweenProjectsCreateBody = /* @__PURE__ */ zexport const dashboardsCreateBodyNameMax = 400export const dashboardsCreateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')+export const dashboardsCreateBodyGroupsTitleMax = 200+export const dashboardsCreateBodyGroupTitlesMaxOne = 200export const dashboardsCreateBodyDeleteInsightsDefault = false@@ -205,11 +207,47 @@ export const DashboardsCreateBody = /* @__PURE__ */ zod.describe('How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.\n\n\* `vertical` - vertical\n\* `horizontal` - horizontal\n\* `stable` - stable'),+ groups: zod+ .record(+ zod.string(),+ zod.object({+ title: zod+ .string()+ .max(dashboardsCreateBodyGroupsTitleMax)+ .optional()+ .describe(+ 'Heading for the group. When it is blank or omitted, the heading shows the number of tiles.'+ ),+ collapsed: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.'+ ),+ color: zod+ .union([+ zod+ .enum(['blue', 'purple', 'green', 'yellow', 'orange', 'red'])+ .describe(+ '\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Color of a dot before the group heading. Null or omitted shows no dot.\n\n\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ })+ )+ .nullish()+ .describe(+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."+ ),group_titles: zod.record(zod.string(), zod.string().max(dashboardsCreateBodyGroupTitlesMaxOne)).nullish().describe(- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ 'Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.'),use_template: zod.string()@@ -227,6 +265,8 @@ export const DashboardsCreateBody = /* @__PURE__ */ zodexport const dashboardsUpdateBodyNameMax = 400export const dashboardsUpdateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')+export const dashboardsUpdateBodyGroupsTitleMax = 200+export const dashboardsUpdateBodyGroupTitlesMaxOne = 200export const dashboardsUpdateBodyDeleteInsightsDefault = false@@ -300,11 +340,47 @@ export const DashboardsUpdateBody = /* @__PURE__ */ zod.describe('How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.\n\n\* `vertical` - vertical\n\* `horizontal` - horizontal\n\* `stable` - stable'),+ groups: zod+ .record(+ zod.string(),+ zod.object({+ title: zod+ .string()+ .max(dashboardsUpdateBodyGroupsTitleMax)+ .optional()+ .describe(+ 'Heading for the group. When it is blank or omitted, the heading shows the number of tiles.'+ ),+ collapsed: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.'+ ),+ color: zod+ .union([+ zod+ .enum(['blue', 'purple', 'green', 'yellow', 'orange', 'red'])+ .describe(+ '\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Color of a dot before the group heading. Null or omitted shows no dot.\n\n\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ })+ )+ .nullish()+ .describe(+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."+ ),group_titles: zod.record(zod.string(), zod.string().max(dashboardsUpdateBodyGroupTitlesMaxOne)).nullish().describe(- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ 'Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.'),use_template: zod.string()@@ -322,6 +398,8 @@ export const DashboardsUpdateBody = /* @__PURE__ */ zodexport const dashboardsPartialUpdateBodyNameMax = 400export const dashboardsPartialUpdateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')+export const dashboardsPartialUpdateBodyGroupsTitleMax = 200+export const dashboardsPartialUpdateBodyGroupTitlesMaxOne = 200export const dashboardsPartialUpdateBodyTilesItemLayoutsOneSmOneXMin = 0@@ -495,11 +573,47 @@ export const DashboardsPartialUpdateBody = /* @__PURE__ */ zod.describe('How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.\n\n\* `vertical` - vertical\n\* `horizontal` - horizontal\n\* `stable` - stable'),+ groups: zod+ .record(+ zod.string(),+ zod.object({+ title: zod+ .string()+ .max(dashboardsPartialUpdateBodyGroupsTitleMax)+ .optional()+ .describe(+ 'Heading for the group. When it is blank or omitted, the heading shows the number of tiles.'+ ),+ collapsed: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.'+ ),+ color: zod+ .union([+ zod+ .enum(['blue', 'purple', 'green', 'yellow', 'orange', 'red'])+ .describe(+ '\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Color of a dot before the group heading. Null or omitted shows no dot.\n\n\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ })+ )+ .nullish()+ .describe(+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."+ ),group_titles: zod.record(zod.string(), zod.string().max(dashboardsPartialUpdateBodyGroupTitlesMaxOne)).nullish().describe(- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ 'Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.'),tiles: zod.array(@@ -566,7 +680,7 @@ export const DashboardsPartialUpdateBody = /* @__PURE__ */ zod.max(dashboardsPartialUpdateBodyTilesItemGroupKeyMax).nullish().describe(- "Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title in the dashboard's group_titles. Null or an empty string removes the tile from its group."+ "Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title and style in the dashboard's groups. Null or an empty string removes the tile from its group."),badge: zod.union([@@ -1755,6 +1869,8 @@ export const dashboardsCreateFromTemplateJsonCreateBodyNameMax = 400export const dashboardsCreateFromTemplateJsonCreateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')+export const dashboardsCreateFromTemplateJsonCreateBodyGroupsTitleMax = 200+export const dashboardsCreateFromTemplateJsonCreateBodyGroupTitlesMaxOne = 200export const dashboardsCreateFromTemplateJsonCreateBodyDeleteInsightsDefault = false@@ -1828,11 +1944,47 @@ export const DashboardsCreateFromTemplateJsonCreateBody = /* @__PURE__ */ zod.describe('How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.\n\n\* `vertical` - vertical\n\* `horizontal` - horizontal\n\* `stable` - stable'),+ groups: zod+ .record(+ zod.string(),+ zod.object({+ title: zod+ .string()+ .max(dashboardsCreateFromTemplateJsonCreateBodyGroupsTitleMax)+ .optional()+ .describe(+ 'Heading for the group. When it is blank or omitted, the heading shows the number of tiles.'+ ),+ collapsed: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.'+ ),+ color: zod+ .union([+ zod+ .enum(['blue', 'purple', 'green', 'yellow', 'orange', 'red'])+ .describe(+ '\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Color of a dot before the group heading. Null or omitted shows no dot.\n\n\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ })+ )+ .nullish()+ .describe(+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."+ ),group_titles: zod.record(zod.string(), zod.string().max(dashboardsCreateFromTemplateJsonCreateBodyGroupTitlesMaxOne)).nullish().describe(- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ 'Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.'),use_template: zod.string()@@ -1857,6 +2009,8 @@ export const dashboardsCreateUnlistedDashboardCreateBodyNameMax = 400export const dashboardsCreateUnlistedDashboardCreateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')+export const dashboardsCreateUnlistedDashboardCreateBodyGroupsTitleMax = 200+export const dashboardsCreateUnlistedDashboardCreateBodyGroupTitlesMaxOne = 200export const dashboardsCreateUnlistedDashboardCreateBodyDeleteInsightsDefault = false@@ -1930,11 +2084,47 @@ export const DashboardsCreateUnlistedDashboardCreateBody = /* @__PURE__ */ zod.describe('How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.\n\n\* `vertical` - vertical\n\* `horizontal` - horizontal\n\* `stable` - stable'),+ groups: zod+ .record(+ zod.string(),+ zod.object({+ title: zod+ .string()+ .max(dashboardsCreateUnlistedDashboardCreateBodyGroupsTitleMax)+ .optional()+ .describe(+ 'Heading for the group. When it is blank or omitted, the heading shows the number of tiles.'+ ),+ collapsed: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.'+ ),+ color: zod+ .union([+ zod+ .enum(['blue', 'purple', 'green', 'yellow', 'orange', 'red'])+ .describe(+ '\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Color of a dot before the group heading. Null or omitted shows no dot.\n\n\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ })+ )+ .nullish()+ .describe(+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."+ ),group_titles: zod.record(zod.string(), zod.string().max(dashboardsCreateUnlistedDashboardCreateBodyGroupTitlesMaxOne)).nullish().describe(- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ 'Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.'),use_template: zod.string()diff --git a/products/dashboards/mcp/tools.yaml b/products/dashboards/mcp/tools.yamlindex 28d5c2ca7af7..dbe5ba29baef 100644--- a/products/dashboards/mcp/tools.yaml+++ b/products/dashboards/mcp/tools.yaml@@ -57,6 +57,7 @@ tools:- persisted_filters- persisted_variables- _create_in_folder+ - group_titlesresponse:exclude:- user_access_level@@ -447,12 +448,16 @@ tools:request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Usedashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. This tooldoes not change a widget tile's own settings (`config`, `name`, `description`): use- dashboard-widgets-batch-update for that. To group tiles, give each tile in the group the same `group_key`,- and set the group's title in `group_titles` (a map from group key to title, which replaces the stored map).- To mark a tile, set its `badge`: `winner` shows a crown, for example on the best tile in a group, and- `cheeky-hog` shows a hedgehog on hover. Set `badge` or `group_key` to null to remove it. To add new widget- tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to- save context — use dashboard-insights-run to fetch the actual data for each insight.+ dashboard-widgets-batch-update for that. To group tiles, give each tile in the group the same `group_key`.+ Set each group's settings in `groups`, a map from group key to settings that replaces the stored map:+ `title`, `collapsed` to start the group closed, and `color` for a colored dot before the heading (blue,+ purple, green, yellow, orange, red, or null for no dot). Viewers see each group as a band that they can open+ and close. Viewers who do not have bands yet, and shared dashboards, see only the group title above its+ tiles. Put tiles that viewers check less often in a group that starts closed. To mark a tile, set its+ `badge`: `winner` shows a crown, for example on the best tile in a group, and `cheeky-hog` shows a hedgehog+ on hover. Set `badge` or `group_key` to null to remove it. To add new widget tiles to this dashboard, use+ dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use+ dashboard-insights-run to fetch the actual data for each insight.exclude_params:- creation_mode- is_shared@@ -462,6 +467,7 @@ tools:- persisted_filters- persisted_variables- _create_in_folder+ - group_titles- tiles.*.widgetparam_overrides:id:diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.tsindex 3f2af054c42c..9055a2ff3c95 100644--- a/products/desktop/packages/api-client/src/generated.ts+++ b/products/desktop/packages/api-client/src/generated.ts@@ -6176,9 +6176,30 @@ export namespace Schemas {* * `stable` - stable*/export type LayoutCompactionEnum = "vertical" | "horizontal" | "stable";+ /**+ * * `blue` - Blue+ * * `purple` - Purple+ * * `green` - Green+ * * `yellow` - Yellow+ * * `orange` - Orange+ * * `red` - Red+ */+ export type DashboardTileGroupColorEnum =+ | "blue"+ | "purple"+ | "green"+ | "yellow"+ | "orange"+ | "red";+ export type DashboardTileGroup = Partial<{+ title: string;+ collapsed: boolean;+ color: DashboardTileGroupColorEnum | NullEnum;+ }>;export type DashboardCustomization = Partial<{tile_spacing: TileSpacingEnum;layout_compaction: LayoutCompactionEnum;+ groups: Record<string, DashboardTileGroup>;group_titles: Record<string, string>;}>;/**@@ -6261,6 +6282,10 @@ export namespace Schemas {* Serializer mixin that handles tags for objects.*/layout_compaction?: (LayoutCompactionEnum & unknown) | undefined;+ /**+ * Serializer mixin that handles tags for objects.+ */+ groups?: (Record<string, DashboardTileGroup> | null) | undefined;/*** Serializer mixin that handles tags for objects.*/@@ -19441,6 +19466,7 @@ export namespace Schemas {quick_filter_ids: Array<string> | null;grid_spacing: TileSpacingEnum;layout_compaction: LayoutCompactionEnum;+ groups: Record<string, DashboardTileGroup> | null;group_titles: Record<string, string> | null;tiles: Array<DashboardPatchTileOpenApi>;use_template: string;diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex f93779bc844e..230799c47cc9 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -3902,7 +3902,7 @@}},"dashboard-update": {- "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, and filters. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. This tool does not change a widget tile's own settings (`config`, `name`, `description`): use dashboard-widgets-batch-update for that. To group tiles, give each tile in the group the same `group_key`, and set the group's title in `group_titles` (a map from group key to title, which replaces the stored map). To mark a tile, set its `badge`: `winner` shows a crown, for example on the best tile in a group, and `cheeky-hog` shows a hedgehog on hover. Set `badge` or `group_key` to null to remove it. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",+ "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, and filters. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. This tool does not change a widget tile's own settings (`config`, `name`, `description`): use dashboard-widgets-batch-update for that. To group tiles, give each tile in the group the same `group_key`. Set each group's settings in `groups`, a map from group key to settings that replaces the stored map: `title`, `collapsed` to start the group closed, and `color` for a colored dot before the heading (blue, purple, green, yellow, orange, red, or null for no dot). Viewers see each group as a band that they can open and close. Viewers who do not have bands yet, and shared dashboards, see only the group title above its tiles. Put tiles that viewers check less often in a group that starts closed. To mark a tile, set its `badge`: `winner` shows a crown, for example on the best tile in a group, and `cheeky-hog` shows a hedgehog on hover. Set `badge` or `group_key` to null to remove it. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.","category": "Dashboards","feature": "dashboards","summary": "Update dashboard",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 0d7082d7dea5..294a8f3bbb7d 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -3917,7 +3917,7 @@}},"dashboard-update": {- "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, and filters. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. This tool does not change a widget tile's own settings (`config`, `name`, `description`): use dashboard-widgets-batch-update for that. To group tiles, give each tile in the group the same `group_key`, and set the group's title in `group_titles` (a map from group key to title, which replaces the stored map). To mark a tile, set its `badge`: `winner` shows a crown, for example on the best tile in a group, and `cheeky-hog` shows a hedgehog on hover. Set `badge` or `group_key` to null to remove it. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",+ "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, and filters. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. This tool does not change a widget tile's own settings (`config`, `name`, `description`): use dashboard-widgets-batch-update for that. To group tiles, give each tile in the group the same `group_key`. Set each group's settings in `groups`, a map from group key to settings that replaces the stored map: `title`, `collapsed` to start the group closed, and `color` for a colored dot before the heading (blue, purple, green, yellow, orange, red, or null for no dot). Viewers see each group as a band that they can open and close. Viewers who do not have bands yet, and shared dashboards, see only the group title above its tiles. Put tiles that viewers check less often in a group that starts closed. To mark a tile, set its `badge`: `winner` shows a crown, for example on the best tile in a group, and `cheeky-hog` shows a hedgehog on hover. Set `badge` or `group_key` to null to remove it. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.","category": "Dashboards","feature": "dashboards","summary": "Update dashboard",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex e82a25f04916..6b0f14e84a08 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -28063,7 +28063,52 @@ export namespace Schemas {export type DashboardPersistedVariables = { [key: string]: unknown } | null;/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * * `blue` - Blue+ * * `purple` - Purple+ * * `green` - Green+ * * `yellow` - Yellow+ * * `orange` - Orange+ * * `red` - Red+ */+ export type DashboardTileGroupColorEnum = typeof DashboardTileGroupColorEnum[keyof typeof DashboardTileGroupColorEnum];+++ export const DashboardTileGroupColorEnum = {+ Blue: 'blue',+ Purple: 'purple',+ Green: 'green',+ Yellow: 'yellow',+ Orange: 'orange',+ Red: 'red',+ } as const;++ export interface DashboardTileGroup {+ /**+ * Heading for the group. When it is blank or omitted, the heading shows the number of tiles.+ * @maxLength 200+ */+ title?: string;+ /** Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default. */+ collapsed?: boolean;+ /** Color of a dot before the group heading. Null or omitted shows no dot.+ *+ * * `blue` - Blue+ * * `purple` - Purple+ * * `green` - Green+ * * `yellow` - Yellow+ * * `orange` - Orange+ * * `red` - Red */+ color?: DashboardTileGroupColorEnum | null;+ }++ /**+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+ export type DashboardGroups = {[key: string]: DashboardTileGroup} | null;++ /**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/export type DashboardGroupTitles = {[key: string]: string} | null;@@ -28119,7 +28164,12 @@ export namespace Schemas {} as const;/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ */+ export type DashboardCustomizationGroups = {[key: string]: DashboardTileGroup};++ /**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.*/export type DashboardCustomizationGroupTitles = {[key: string]: string};@@ -28138,7 +28188,9 @@ export namespace Schemas {* * `horizontal` - horizontal* * `stable` - stable */layout_compaction?: LayoutCompactionEnum;- /** Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles. */+ /** Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings. */+ groups?: DashboardCustomizationGroups;+ /** Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups. */group_titles?: DashboardCustomizationGroupTitles;}@@ -28226,7 +28278,12 @@ export namespace Schemas {* * `stable` - stable */layout_compaction?: LayoutCompactionEnum;/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+ groups?: DashboardGroups;+ /**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/group_titles?: DashboardGroupTitles;@@ -28604,7 +28661,7 @@ export namespace Schemas {/** Whether to show the tile's description underneath its title on the dashboard. Works for every tile type. The description itself is unaffected and still comes from the tile's insight, text, or widget content — this only toggles whether it renders on the dashboard. */show_description?: boolean;/**- * Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title in the dashboard's group_titles. Null or an empty string removes the tile from its group.+ * Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title and style in the dashboard's groups. Null or an empty string removes the tile from its group.* @maxLength 100* @nullable*/@@ -86866,7 +86923,13 @@ export namespace Schemas {}/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+ export type PatchedPatchedDashboardOpenApiGroups = {[key: string]: DashboardTileGroup} | null;++ /**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/export type PatchedPatchedDashboardOpenApiGroupTitles = {[key: string]: string} | null;@@ -86918,7 +86981,12 @@ export namespace Schemas {* * `stable` - stable */layout_compaction?: LayoutCompactionEnum;/**- * Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles.+ * Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings.+ * @nullable+ */+ groups?: PatchedPatchedDashboardOpenApiGroups;+ /**+ * Deprecated: use groups. Titles for tile groups, keyed by group_key. A write replaces all titles and keeps the other group settings. Send an empty object or null to clear titles. Do not send it with groups.* @nullable*/group_titles?: PatchedPatchedDashboardOpenApiGroupTitles;diff --git a/services/mcp/src/generated/dashboards/api.ts b/services/mcp/src/generated/dashboards/api.tsindex b29738588188..c79f64185a62 100644--- a/services/mcp/src/generated/dashboards/api.ts+++ b/services/mcp/src/generated/dashboards/api.ts@@ -113,7 +113,7 @@ export const DashboardsCreateQueryParams = () => zod.object({export const dashboardsCreateBodyNameMax = 400export const dashboardsCreateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')-export const dashboardsCreateBodyGroupTitlesMaxOne = 200+export const dashboardsCreateBodyGroupsTitleMax = 200export const dashboardsCreateBodyDeleteInsightsDefault = false@@ -184,11 +184,41 @@ export const DashboardsCreateBody = () => zod.describe('How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.\n\n\* `vertical` - vertical\n\* `horizontal` - horizontal\n\* `stable` - stable'),- group_titles: zod- .record(zod.string(), zod.string().max(dashboardsCreateBodyGroupTitlesMaxOne))+ groups: zod+ .record(+ zod.string(),+ zod.object({+ title: zod+ .string()+ .max(dashboardsCreateBodyGroupsTitleMax)+ .optional()+ .describe(+ 'Heading for the group. When it is blank or omitted, the heading shows the number of tiles.'+ ),+ collapsed: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.'+ ),+ color: zod+ .union([+ zod+ .enum(['blue', 'purple', 'green', 'yellow', 'orange', 'red'])+ .describe(+ '\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Color of a dot before the group heading. Null or omitted shows no dot.\n\n\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ })+ ).nullish().describe(- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."),use_template: zod.string()@@ -255,7 +285,7 @@ export const DashboardsPartialUpdateQueryParams = () => zod.object({export const dashboardsPartialUpdateBodyNameMax = 400export const dashboardsPartialUpdateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')-export const dashboardsPartialUpdateBodyGroupTitlesMaxOne = 200+export const dashboardsPartialUpdateBodyGroupsTitleMax = 200export const dashboardsPartialUpdateBodyTilesItemLayoutsOneSmOneXMin = 0export const dashboardsPartialUpdateBodyTilesItemLayoutsOneSmOneXMax = 11@@ -368,11 +398,41 @@ export const DashboardsPartialUpdateBody = () => zod.describe('How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.\n\n\* `vertical` - vertical\n\* `horizontal` - horizontal\n\* `stable` - stable'),- group_titles: zod- .record(zod.string(), zod.string().max(dashboardsPartialUpdateBodyGroupTitlesMaxOne))+ groups: zod+ .record(+ zod.string(),+ zod.object({+ title: zod+ .string()+ .max(dashboardsPartialUpdateBodyGroupsTitleMax)+ .optional()+ .describe(+ 'Heading for the group. When it is blank or omitted, the heading shows the number of tiles.'+ ),+ collapsed: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.'+ ),+ color: zod+ .union([+ zod+ .enum(['blue', 'purple', 'green', 'yellow', 'orange', 'red'])+ .describe(+ '\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Color of a dot before the group heading. Null or omitted shows no dot.\n\n\* `blue` - Blue\n\* `purple` - Purple\n\* `green` - Green\n\* `yellow` - Yellow\n\* `orange` - Orange\n\* `red` - Red'+ ),+ })+ ).nullish().describe(- "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."),tiles: zod.array(@@ -439,7 +499,7 @@ export const DashboardsPartialUpdateBody = () => zod.max(dashboardsPartialUpdateBodyTilesItemGroupKeyMax).nullish().describe(- "Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title in the dashboard's group_titles. Null or an empty string removes the tile from its group."+ "Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title and style in the dashboard's groups. Null or an empty string removes the tile from its group."),badge: zod.union([diff --git a/services/mcp/src/tools/generated/dashboards.ts b/services/mcp/src/tools/generated/dashboards.tsindex d73fc5159926..a1f003020439 100644--- a/services/mcp/src/tools/generated/dashboards.ts+++ b/services/mcp/src/tools/generated/dashboards.ts@@ -59,8 +59,8 @@ const dashboardCreate = (): ToolBase<if (params.layout_compaction !== undefined) {body['layout_compaction'] = params.layout_compaction}- if (params.group_titles !== undefined) {- body['group_titles'] = params.group_titles+ if (params.groups !== undefined) {+ body['groups'] = params.groups}if (params.use_template !== undefined) {body['use_template'] = params.use_template@@ -615,8 +615,8 @@ const dashboardUpdate = (): ToolBase<if (params.layout_compaction !== undefined) {body['layout_compaction'] = params.layout_compaction}- if (params.group_titles !== undefined) {- body['group_titles'] = params.group_titles+ if (params.groups !== undefined) {+ body['groups'] = params.groups}if (params.tiles !== undefined) {body['tiles'] = params.tilesdiff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.jsonindex 877b152288f9..8bb35cff1ade 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.json@@ -93,12 +93,35 @@"enum": ["tight", "condensed", "standard", "relaxed", "wide"],"type": "string"},- "group_titles": {+ "groups": {"anyOf": [{"additionalProperties": {- "maxLength": 200,- "type": "string"+ "properties": {+ "collapsed": {+ "description": "Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.",+ "type": "boolean"+ },+ "color": {+ "anyOf": [+ {+ "description": "* `blue` - Blue\n* `purple` - Purple\n* `green` - Green\n* `yellow` - Yellow\n* `orange` - Orange\n* `red` - Red",+ "enum": ["blue", "purple", "green", "yellow", "orange", "red"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Color of a dot before the group heading. Null or omitted shows no dot.\n\n* `blue` - Blue\n* `purple` - Purple\n* `green` - Green\n* `yellow` - Yellow\n* `orange` - Orange\n* `red` - Red"+ },+ "title": {+ "description": "Heading for the group. When it is blank or omitted, the heading shows the number of tiles.",+ "maxLength": 200,+ "type": "string"+ }+ },+ "type": "object"},"propertyNames": {"type": "string"@@ -109,7 +132,7 @@"type": "null"}],- "description": "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ "description": "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."},"include_dashboards": {"description": "Opt in to receiving the deprecated `dashboards` field in insight payloads. Once opt-in enforcement is enabled, API-token callers stop receiving it by default; use `dashboard_tiles` instead.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.jsonindex a35ce3a3ef82..0e691360914e 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json@@ -123,12 +123,35 @@"enum": ["tight", "condensed", "standard", "relaxed", "wide"],"type": "string"},- "group_titles": {+ "groups": {"anyOf": [{"additionalProperties": {- "maxLength": 200,- "type": "string"+ "properties": {+ "collapsed": {+ "description": "Whether the group starts closed. Defaults to false. When a viewer opens or closes the group, their browser keeps that choice and it wins over this default.",+ "type": "boolean"+ },+ "color": {+ "anyOf": [+ {+ "description": "* `blue` - Blue\n* `purple` - Purple\n* `green` - Green\n* `yellow` - Yellow\n* `orange` - Orange\n* `red` - Red",+ "enum": ["blue", "purple", "green", "yellow", "orange", "red"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Color of a dot before the group heading. Null or omitted shows no dot.\n\n* `blue` - Blue\n* `purple` - Purple\n* `green` - Green\n* `yellow` - Yellow\n* `orange` - Orange\n* `red` - Red"+ },+ "title": {+ "description": "Heading for the group. When it is blank or omitted, the heading shows the number of tiles.",+ "maxLength": 200,+ "type": "string"+ }+ },+ "type": "object"},"propertyNames": {"type": "string"@@ -139,7 +162,7 @@"type": "null"}],- "description": "Titles for tile groups, keyed by the tiles' group_key. The dashboard shows a title above its group. A write replaces the whole map. Send an empty object or null to remove all group titles."+ "description": "Settings for tile groups, keyed by the tiles' group_key. Each group shows as a band of its tiles under a heading that viewers can open and close. Viewers who do not have bands yet see only the group title above its tiles. A write replaces the whole map. Send an empty object or null to remove all group settings."},"id": {"description": "A unique integer value identifying this dashboard.",@@ -215,7 +238,7 @@"type": "null"}],- "description": "Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title in the dashboard's group_titles. Null or an empty string removes the tile from its group."+ "description": "Key that puts this tile in a group with the other tiles that have the same key on this dashboard. Set the group's title and style in the dashboard's groups. Null or an empty string removes the tile from its group."},"id": {"description": "Dashboard tile ID to update.",