🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(dashboard): make dashboard widgets draggable (#6891)
Steffen Schmitz5ab8e4219f0d
diff --git a/packages/shared/prisma/migrations/20250519145128_resize_dashboard_y_axis_components/migration.sql b/packages/shared/prisma/migrations/20250519145128_resize_dashboard_y_axis_components/migration.sqlnew file mode 100644index 0000000000..8adad2a583--- /dev/null+++ b/packages/shared/prisma/migrations/20250519145128_resize_dashboard_y_axis_components/migration.sql@@ -0,0 +1,31 @@+/* Triple y and y_size in dashboards.definition->'widgets' */+WITH updated AS (+ SELECT+ id,+ jsonb_set(+ definition, -- original JSON+ '{widgets}', -- path to replace+ (+ SELECT jsonb_agg( -- rebuild widgets array+ /* 1) y * 3 2) y_size * 3 */+ jsonb_set(+ jsonb_set(widget, '{y}',+ to_jsonb( ((widget->>'y')::int * 3) ), /* y */+ true+ ),+ '{y_size}',+ to_jsonb( ((widget->>'y_size')::int * 3) ),/* y_size */+ true+ )+ )+ FROM jsonb_array_elements(definition->'widgets') AS widget+ ),+ true -- create path if absent+ ) AS new_def+ FROM dashboards+ WHERE definition ? 'widgets' -- only rows that have widgets+)+UPDATE dashboards d+SET definition = u.new_def+FROM updated u+WHERE d.id = u.id;diff --git a/packages/shared/prisma/seed.ts b/packages/shared/prisma/seed.tsindex 4158b86263..cc6049da4f 100644--- a/packages/shared/prisma/seed.ts+++ b/packages/shared/prisma/seed.ts@@ -496,7 +496,7 @@ async function createDashboardsAndWidgets(projects: Project[]) {x: 0,y: 0,x_size: 6,- y_size: 2,+ y_size: 6,},{type: "widget",@@ -505,7 +505,7 @@ async function createDashboardsAndWidgets(projects: Project[]) {x: 6,y: 0,x_size: 6,- y_size: 2,+ y_size: 6,},],},diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex e28e2c52e2..dce80c26ef 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -58,7 +58,7 @@ importers:version: 14.2.26(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected])next-auth:specifier: ^4.24.11- version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])+ version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])zod:specifier: ^3.23.8version: 3.23.8@@ -232,7 +232,7 @@ importers:version: 4.0.2next-auth:specifier: ^4.24.11- version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])+ version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])nodemailer:specifier: ^6.9.15version: 6.9.15@@ -669,6 +669,9 @@ importers:react-dom:specifier: 18.2.0version: 18.2.0([email protected])+ react-grid-layout:+ specifier: ^1.5.1react-hook-form:specifier: ^7.51.5version: 7.51.5([email protected])@@ -790,6 +793,9 @@ importers:'@types/react-dom':specifier: ~18.2.25version: 18.2.25+ '@types/react-grid-layout':+ specifier: ^1.3.5+ version: 1.3.5'@types/react-syntax-highlighter':specifier: ^15.5.13version: 15.5.13@@ -5165,6 +5171,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-o/V48vf4MQh7juIKZU2QGDfli6p1+OOi5oXx36Hffpc9adsHeXjVp8rHuPkjd8VT8sOJ2Zp05HR7CdpGTIUFUA==}+ '@types/[email protected]':+ resolution: {integrity: sha512-WH/po1gcEcoR6y857yAnPGug+ZhkF4PaTUxgAbwfeSH/QOgVSakKHBXoPGad/sEznmkiaK3pqHk+etdWisoeBQ==}+'@types/[email protected]':resolution: {integrity: sha512-uLGJ87j6Sz8UaBAooU0T6lWJ0dBmjZgN1PZTrj05TNql2/XpC6+4HhMT5syIdFUUt+FASfCeLLv4kBygNU+8qA==}@@ -6172,6 +6181,10 @@ packages:resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}engines: {node: '>=12'}+ resolution: {integrity: sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==}+ engines: {node: '>=6'}+resolution: {integrity: sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q==}engines: {node: '>=6'}@@ -7398,6 +7411,9 @@ packages:resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==}+ resolution: {integrity: sha512-G3BSX9cfKttjr+2o1O22tYMLq0DPluZnYtq1rXumE1SpL/F/SLIfHx08WYQoWSIpeMYf8sRbJ8++71+v6Pnxfg==}+resolution: {integrity: sha512-WF1Wi8PwwSY7/6Kx0vKXtw8RwuSGoM1bvDaJbu7MxDlR1vovZjIAKrnzyrThgAjm6JDTu0fVgWXDlMGspodfoQ==}engines: {node: '>=6.0.0'}@@ -9460,6 +9476,7 @@ packages:resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}engines: {node: '>=10.5.0'}+ deprecated: Use your platform's native DOMException insteadresolution: {integrity: sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==}@@ -10344,6 +10361,18 @@ packages:peerDependencies:react: ^18.2.0+ resolution: {integrity: sha512-LtY5Xw1zTPqHkVmtM3X8MUOxNDOUhv/khTgBgrUvwaS064bwVvxT+q5El0uUFNx5IEPKXuRejr7UqLwBIg5pdw==}+ peerDependencies:+ react: '>= 16.3.0'+ react-dom: '>= 16.3.0'++ resolution: {integrity: sha512-4Fr+kKMk0+m1HL/BWfHxi/lRuaOmDNNKQDcu7m12+NEYcen20wIuZFo789u3qWCyvUsNUxCiyf0eKq4WiJSNYw==}+ peerDependencies:+ react: '>= 16.3.0'+ react-dom: '>= 16.3.0'+resolution: {integrity: sha512-J2ILT5gWx1XUIJRETiA7M19iXHlG74+6O3KApzvqB/w8S5NQR7AbU8HVZrMALdmDgWpRPYiZJl0zx8Z4L2mP6Q==}engines: {node: '>=12.22.0'}@@ -10405,6 +10434,11 @@ packages:react: ^16.14.0 || ^17.0.0 || ^18.0.0react-dom: ^16.14.0 || ^17.0.0 || ^18.0.0+ resolution: {integrity: sha512-vKpeHhI5OZvYn82kXOs1bC8aOXktGU5AmKAgaZS4F5JPburCtbmDPqE7Pzp+1kN4+Wb81LlF33VpGwWwtXem+w==}+ peerDependencies:+ react: '>= 16.3'+resolution: {integrity: sha512-N6/UiRLGQyGUqrarhBZmrSmHi2FXSD++N5VbSKsBBvWfG0ZV7asvUBluSv5lSzdMyEVjzZ6Y8DL4OHABiztDOg==}engines: {node: '>=14'}@@ -10576,6 +10610,9 @@ packages:resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}+ resolution: {integrity: sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==}+resolution: {integrity: sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==}engines: {node: '>=8'}@@ -12818,25 +12855,6 @@ snapshots:- '@aws-sdk/client-sso-oidc'- aws-crt- '@aws-sdk/[email protected]':- dependencies:- '@aws-sdk/core': 3.667.0- '@aws-sdk/credential-provider-env': 3.667.0- '@aws-sdk/credential-provider-http': 3.667.0- '@aws-sdk/credential-provider-process': 3.667.0- '@aws-sdk/credential-provider-sso': 3.675.0- '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])- '@aws-sdk/types': 3.667.0- '@smithy/credential-provider-imds': 3.2.4- '@smithy/property-provider': 3.1.7- '@smithy/shared-ini-file-loader': 3.1.8- '@smithy/types': 3.5.0- tslib: 2.8.1- transitivePeerDependencies:- - '@aws-sdk/client-sso-oidc'- - aws-crt- optional: true-'@aws-sdk/[email protected](@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])':dependencies:'@aws-sdk/client-sts': 3.668.0@@ -12894,26 +12912,6 @@ snapshots:- '@aws-sdk/client-sts'- aws-crt- '@aws-sdk/[email protected]':- dependencies:- '@aws-sdk/credential-provider-env': 3.667.0- '@aws-sdk/credential-provider-http': 3.667.0- '@aws-sdk/credential-provider-ini': 3.675.0- '@aws-sdk/credential-provider-process': 3.667.0- '@aws-sdk/credential-provider-sso': 3.675.0- '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])- '@aws-sdk/types': 3.667.0- '@smithy/credential-provider-imds': 3.2.4- '@smithy/property-provider': 3.1.7- '@smithy/shared-ini-file-loader': 3.1.8- '@smithy/types': 3.5.0- tslib: 2.8.1- transitivePeerDependencies:- - '@aws-sdk/client-sso-oidc'- - '@aws-sdk/client-sts'- - aws-crt- optional: true-'@aws-sdk/[email protected](@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])':dependencies:'@aws-sdk/credential-provider-env': 3.667.0@@ -12975,21 +12973,6 @@ snapshots:- '@aws-sdk/client-sso-oidc'- aws-crt- '@aws-sdk/[email protected]':- dependencies:- '@aws-sdk/client-sso': 3.675.0- '@aws-sdk/core': 3.667.0- '@aws-sdk/token-providers': 3.667.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))- '@aws-sdk/types': 3.667.0- '@smithy/property-provider': 3.1.7- '@smithy/shared-ini-file-loader': 3.1.8- '@smithy/types': 3.5.0- tslib: 2.8.1- transitivePeerDependencies:- - '@aws-sdk/client-sso-oidc'- - aws-crt- optional: true-dependencies:'@aws-sdk/client-sso': 3.675.0@@ -13407,7 +13390,7 @@ snapshots:'@babel/traverse': 7.24.1'@babel/types': 7.24.0convert-source-map: 2.0.0- debug: 4.3.7+ debug: 4.3.7([email protected])gensync: 1.0.0-beta.2json5: 2.2.3semver: 6.3.1@@ -13634,7 +13617,7 @@ snapshots:'@babel/helper-split-export-declaration': 7.22.6'@babel/parser': 7.24.1'@babel/types': 7.24.0- debug: 4.3.7+ debug: 4.3.7([email protected])globals: 11.12.0transitivePeerDependencies:- supports-color@@ -14142,7 +14125,7 @@ snapshots:'@eslint/[email protected]':dependencies:ajv: 6.12.6- debug: 4.3.7+ debug: 4.3.7([email protected])espree: 9.6.1globals: 13.24.0ignore: 5.3.1@@ -14282,7 +14265,7 @@ snapshots:'@humanwhocodes/[email protected]':dependencies:'@humanwhocodes/object-schema': 2.0.2- debug: 4.3.7+ debug: 4.3.7([email protected])minimatch: 3.1.2transitivePeerDependencies:- supports-color@@ -14720,7 +14703,7 @@ snapshots:'@aws-sdk/client-bedrock-agent-runtime': 3.668.0'@aws-sdk/client-bedrock-runtime': 3.668.0'@aws-sdk/client-kendra': 3.668.0- '@aws-sdk/credential-provider-node': 3.675.0+ '@aws-sdk/credential-provider-node': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])'@langchain/core': 0.3.18([email protected]([email protected]))zod: 3.23.8zod-to-json-schema: 3.23.5([email protected])@@ -17798,6 +17781,10 @@ snapshots:dependencies:'@types/react': 18.2.79+ '@types/[email protected]':+ dependencies:+ '@types/react': 18.2.79+'@types/[email protected]':dependencies:'@types/react': 18.2.79@@ -17949,7 +17936,7 @@ snapshots:dependencies:'@typescript-eslint/typescript-estree': 6.21.0([email protected])'@typescript-eslint/utils': 6.21.0([email protected])([email protected])- debug: 4.3.7+ debug: 4.3.7([email protected])eslint: 8.57.0ts-api-utils: 1.3.0([email protected])optionalDependencies:@@ -17961,7 +17948,7 @@ snapshots:dependencies:'@typescript-eslint/typescript-estree': 7.3.1([email protected])'@typescript-eslint/utils': 7.3.1([email protected])([email protected])- debug: 4.3.7+ debug: 4.3.7([email protected])eslint: 8.57.0ts-api-utils: 1.3.0([email protected])optionalDependencies:@@ -18010,7 +17997,7 @@ snapshots:dependencies:'@typescript-eslint/types': 7.12.0'@typescript-eslint/visitor-keys': 7.12.0- debug: 4.3.7+ debug: 4.3.7([email protected])globby: 11.1.0is-glob: 4.0.3minimatch: 9.0.5@@ -18025,7 +18012,7 @@ snapshots:dependencies:'@typescript-eslint/types': 7.3.1'@typescript-eslint/visitor-keys': 7.3.1- debug: 4.3.7+ debug: 4.3.7([email protected])globby: 11.1.0is-glob: 4.0.3minimatch: 9.0.3@@ -18142,7 +18129,7 @@ snapshots:'@typescript-eslint/eslint-plugin': 7.3.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])'@typescript-eslint/parser': 7.12.0([email protected])([email protected])eslint-config-prettier: 9.1.0([email protected])- eslint-import-resolver-alias: 1.1.2([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))+ eslint-import-resolver-alias: 1.1.2([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])eslint-plugin-eslint-comments: 3.2.0([email protected])eslint-plugin-import: 2.29.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])@@ -18188,7 +18175,7 @@ snapshots:dependencies:'@vitest/spy': 2.1.2estree-walker: 3.0.3- magic-string: 0.30.17+ magic-string: 0.30.11optionalDependencies:vite: 5.2.14(@types/[email protected])optional: true@@ -19090,6 +19077,8 @@ snapshots:strip-ansi: 6.0.1wrap-ansi: 7.0.0+ [email protected]: {}+@@ -19655,10 +19644,6 @@ snapshots:dependencies:ms: 2.1.2- dependencies:- ms: 2.1.3-dependencies:ms: 2.1.3@@ -20148,7 +20133,7 @@ snapshots:eslint: 8.57.0eslint-plugin-turbo: 1.13.4([email protected])- [email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])):+ [email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])):dependencies:eslint-plugin-import: 2.29.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])@@ -20162,7 +20147,7 @@ snapshots:[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]):dependencies:- debug: 4.3.7+ debug: 4.3.7([email protected])enhanced-resolve: 5.17.1eslint: 8.57.0eslint-module-utils: 2.8.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected])@@ -20239,7 +20224,7 @@ snapshots:doctrine: 2.1.0eslint: 8.57.0eslint-import-resolver-node: 0.3.9- eslint-module-utils: 2.8.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected])+ eslint-module-utils: 2.8.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])hasown: 2.0.2is-core-module: 2.15.1is-glob: 4.0.3@@ -20649,6 +20634,8 @@ snapshots:+ [email protected]: {}+@@ -21313,7 +21300,7 @@ snapshots:dependencies:agent-base: 7.1.3- debug: 4.3.7+ debug: 4.3.7([email protected])transitivePeerDependencies:- supports-color@@ -22088,7 +22075,7 @@ snapshots:dependencies:- '@types/node': 20.10.5+ '@types/node': 20.14.8merge-stream: 2.0.0supports-color: 8.1.1@@ -23150,23 +23137,6 @@ snapshots:optionalDependencies:nodemailer: 6.9.15- [email protected](patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]):- dependencies:- '@babel/runtime': 7.26.0- '@panva/hkdf': 1.1.1- cookie: 0.7.2- jose: 4.15.5- next: 14.2.26(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected])- oauth: 0.9.15- openid-client: 5.6.5- preact: 10.19.7- preact-render-to-string: 5.2.6([email protected])- react: 18.2.0- react-dom: 18.2.0([email protected])- uuid: 8.3.2- optionalDependencies:- nodemailer: 6.9.15-[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]([email protected]))([email protected])):dependencies:next: 14.2.26(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected])@@ -24103,6 +24073,24 @@ snapshots:react: 18.2.0scheduler: 0.23.0+ dependencies:+ clsx: 1.2.1+ prop-types: 15.8.1+ react: 18.2.0+ react-dom: 18.2.0([email protected])++ dependencies:+ clsx: 2.1.1+ fast-equals: 4.0.3+ prop-types: 15.8.1+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ resize-observer-polyfill: 1.5.1+dependencies:react: 18.2.0@@ -24166,6 +24154,14 @@ snapshots:react: 18.2.0react-dom: 18.2.0([email protected])+ dependencies:+ prop-types: 15.8.1+ react: 18.2.0+ transitivePeerDependencies:+ - react-dom+dependencies:hyphenate-style-name: 1.0.4@@ -24419,7 +24415,7 @@ snapshots:dependencies:- debug: 4.3.7+ debug: 4.3.7([email protected])module-details-from-path: 1.0.3resolve: 1.22.8transitivePeerDependencies:@@ -24427,6 +24423,8 @@ snapshots:+ [email protected]: {}+dependencies:resolve-from: 5.0.0@@ -25639,7 +25637,7 @@ snapshots:[email protected](@types/[email protected]):dependencies:cac: 6.7.14- debug: 4.4.0+ debug: 4.3.7([email protected])pathe: 1.1.2vite: 5.2.14(@types/[email protected])transitivePeerDependencies:@@ -25726,8 +25724,8 @@ snapshots:'@vitest/spy': 2.1.2'@vitest/utils': 2.1.2chai: 5.1.1- debug: 4.4.0- magic-string: 0.30.17+ debug: 4.3.7([email protected])+ magic-string: 0.30.11pathe: 1.1.2std-env: 3.7.0tinybench: 2.9.0diff --git a/web/package.json b/web/package.jsonindex 61379b4caf..69f94b7fed 100644--- a/web/package.json+++ b/web/package.json@@ -136,6 +136,7 @@"react": "18.2.0","react-day-picker": "^8.10.1","react-dom": "18.2.0",+ "react-grid-layout": "^1.5.1","react-hook-form": "^7.51.5","react-icons": "^5.2.1","react-markdown": "^9.0.1",@@ -178,6 +179,7 @@"@types/node": "20.10.5","@types/react": "~18.2.79","@types/react-dom": "~18.2.25",+ "@types/react-grid-layout": "^1.3.5","@types/react-syntax-highlighter": "^15.5.13","@types/uuid": "^9.0.8","@typescript-eslint/eslint-plugin": "^6.21.0",diff --git a/web/src/components/ui/chart.tsx b/web/src/components/ui/chart.tsxindex 6a916ed3fe..1bcae119b9 100644--- a/web/src/components/ui/chart.tsx+++ b/web/src/components/ui/chart.tsx@@ -1,50 +1,50 @@-"use client"+"use client";-import * as React from "react"-import * as RechartsPrimitive from "recharts"+import * as React from "react";+import * as RechartsPrimitive from "recharts";-import { cn } from "@/src/utils/tailwind"+import { cn } from "@/src/utils/tailwind";// Format: { THEME_NAME: CSS_SELECTOR }-const THEMES = { light: "", dark: ".dark" } as const+const THEMES = { light: "", dark: ".dark" } as const;export type ChartConfig = {[k in string]: {- label?: React.ReactNode- icon?: React.ComponentType+ label?: React.ReactNode;+ icon?: React.ComponentType;} & (| { color?: string; theme?: never }| { color?: never; theme: Record<keyof typeof THEMES, string> }- )-}+ );+};type ChartContextProps = {- config: ChartConfig-}+ config: ChartConfig;+};-const ChartContext = React.createContext<ChartContextProps | null>(null)+const ChartContext = React.createContext<ChartContextProps | null>(null);function useChart() {- const context = React.useContext(ChartContext)+ const context = React.useContext(ChartContext);if (!context) {- throw new Error("useChart must be used within a <ChartContainer />")+ throw new Error("useChart must be used within a <ChartContainer />");}- return context+ return context;}const ChartContainer = React.forwardRef<HTMLDivElement,React.ComponentProps<"div"> & {- config: ChartConfig+ config: ChartConfig;children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer- >["children"]+ >["children"];}>(({ id, className, children, config, ...props }, ref) => {- const uniqueId = React.useId()- const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`+ const uniqueId = React.useId();+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;return (<ChartContext.Provider value={{ config }}>@@ -52,8 +52,8 @@ const ChartContainer = React.forwardRef<data-chart={chartId}ref={ref}className={cn(- "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",- className+ "h-full w-full flex-1 justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",+ className,)}{...props}>@@ -63,17 +63,17 @@ const ChartContainer = React.forwardRef<</RechartsPrimitive.ResponsiveContainer></div></ChartContext.Provider>- )-})-ChartContainer.displayName = "Chart"+ );+});+ChartContainer.displayName = "Chart";const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {const colorConfig = Object.entries(config).filter(- ([, config]) => config.theme || config.color- )+ ([, config]) => config.theme || config.color,+ );if (!colorConfig.length) {- return null+ return null;}return (@@ -87,30 +87,30 @@ ${colorConfig.map(([key, itemConfig]) => {const color =itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||- itemConfig.color- return color ? ` --color-${key}: ${color};` : null+ itemConfig.color;+ return color ? ` --color-${key}: ${color};` : null;}).join("\n")}}-`+`,).join("\n"),}}/>- )-}+ );+};-const ChartTooltip = RechartsPrimitive.Tooltip+const ChartTooltip = RechartsPrimitive.Tooltip;const ChartTooltipContent = React.forwardRef<HTMLDivElement,React.ComponentProps<typeof RechartsPrimitive.Tooltip> &React.ComponentProps<"div"> & {- hideLabel?: boolean- hideIndicator?: boolean- indicator?: "line" | "dot" | "dashed"- nameKey?: string- labelKey?: string+ hideLabel?: boolean;+ hideIndicator?: boolean;+ indicator?: "line" | "dot" | "dashed";+ nameKey?: string;+ labelKey?: string;}>((@@ -129,36 +129,36 @@ const ChartTooltipContent = React.forwardRef<nameKey,labelKey,},- ref+ ref,) => {- const { config } = useChart()+ const { config } = useChart();const tooltipLabel = React.useMemo(() => {if (hideLabel || !payload?.length) {- return null+ return null;}- const [item] = payload- const key = `${labelKey || item?.dataKey || item?.name || "value"}`- const itemConfig = getPayloadConfigFromPayload(config, item, key)+ const [item] = payload;+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`;+ const itemConfig = getPayloadConfigFromPayload(config, item, key);const value =!labelKey && typeof label === "string"? config[label as keyof typeof config]?.label || label- : itemConfig?.label+ : itemConfig?.label;if (labelFormatter) {return (<div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>- )+ );}if (!value) {- return null+ return null;}- return <div className={cn("font-medium", labelClassName)}>{value}</div>+ return <div className={cn("font-medium", labelClassName)}>{value}</div>;}, [label,labelFormatter,@@ -167,35 +167,35 @@ const ChartTooltipContent = React.forwardRef<labelClassName,config,labelKey,- ])+ ]);if (!active || !payload?.length) {- return null+ return null;}- const nestLabel = payload.length === 1 && indicator !== "dot"+ const nestLabel = payload.length === 1 && indicator !== "dot";return (<divref={ref}className={cn("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",- className+ className,)}>{!nestLabel ? tooltipLabel : null}<div className="grid gap-1.5">{payload.map((item, index) => {- const key = `${nameKey || item.name || item.dataKey || "value"}`- const itemConfig = getPayloadConfigFromPayload(config, item, key)- const indicatorColor = color || item.payload.fill || item.color+ const key = `${nameKey || item.name || item.dataKey || "value"}`;+ const itemConfig = getPayloadConfigFromPayload(config, item, key);+ const indicatorColor = color || item.payload.fill || item.color;return (<divkey={item.dataKey}className={cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",- indicator === "dot" && "items-center"+ indicator === "dot" && "items-center",)}>{formatter && item?.value !== undefined && item.name ? (@@ -215,7 +215,7 @@ const ChartTooltipContent = React.forwardRef<"w-0 border-[1.5px] border-dashed bg-transparent":indicator === "dashed","my-0.5": nestLabel && indicator === "dashed",- }+ },)}style={{@@ -229,7 +229,7 @@ const ChartTooltipContent = React.forwardRef<<divclassName={cn("flex flex-1 justify-between leading-none",- nestLabel ? "items-end" : "items-center"+ nestLabel ? "items-end" : "items-center",)}><div className="grid gap-1.5">@@ -247,33 +247,33 @@ const ChartTooltipContent = React.forwardRef<</>)}</div>- )+ );})}</div></div>- )- }-)-ChartTooltipContent.displayName = "ChartTooltip"+ );+ },+);+ChartTooltipContent.displayName = "ChartTooltip";-const ChartLegend = RechartsPrimitive.Legend+const ChartLegend = RechartsPrimitive.Legend;const ChartLegendContent = React.forwardRef<HTMLDivElement,React.ComponentProps<"div"> &Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {- hideIcon?: boolean- nameKey?: string+ hideIcon?: boolean;+ nameKey?: string;}>(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey },- ref+ ref,) => {- const { config } = useChart()+ const { config } = useChart();if (!payload?.length) {- return null+ return null;}return (@@ -282,18 +282,18 @@ const ChartLegendContent = React.forwardRef<className={cn("flex items-center justify-center gap-4",verticalAlign === "top" ? "pb-3" : "pt-3",- className+ className,)}>{payload.map((item) => {- const key = `${nameKey || item.dataKey || "value"}`- const itemConfig = getPayloadConfigFromPayload(config, item, key)+ const key = `${nameKey || item.dataKey || "value"}`;+ const itemConfig = getPayloadConfigFromPayload(config, item, key);return (<divkey={item.value}className={cn(- "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",)}>{itemConfig?.icon && !hideIcon ? (@@ -308,22 +308,22 @@ const ChartLegendContent = React.forwardRef<)}{itemConfig?.label}</div>- )+ );})}</div>- )- }-)-ChartLegendContent.displayName = "ChartLegend"+ );+ },+);+ChartLegendContent.displayName = "ChartLegend";// Helper to extract item config from a payload.function getPayloadConfigFromPayload(config: ChartConfig,payload: unknown,- key: string+ key: string,) {if (typeof payload !== "object" || payload === null) {- return undefined+ return undefined;}const payloadPayload =@@ -331,15 +331,15 @@ function getPayloadConfigFromPayload(typeof payload.payload === "object" &&payload.payload !== null? payload.payload- : undefined+ : undefined;- let configLabelKey: string = key+ let configLabelKey: string = key;if (key in payload &&typeof payload[key as keyof typeof payload] === "string") {- configLabelKey = payload[key as keyof typeof payload] as string+ configLabelKey = payload[key as keyof typeof payload] as string;} else if (payloadPayload &&key in payloadPayload &&@@ -347,12 +347,12 @@ function getPayloadConfigFromPayload() {configLabelKey = payloadPayload[key as keyof typeof payloadPayload- ] as string+ ] as string;}return configLabelKey in config? config[configLabelKey]- : config[key as keyof typeof config]+ : config[key as keyof typeof config];}export {@@ -362,4 +362,4 @@ export {ChartLegend,ChartLegendContent,ChartStyle,-}+};diff --git a/web/src/features/widgets/chart-library/Chart.tsx b/web/src/features/widgets/chart-library/Chart.tsxindex 91f7cc9c21..1362e95335 100644--- a/web/src/features/widgets/chart-library/Chart.tsx+++ b/web/src/features/widgets/chart-library/Chart.tsx@@ -77,6 +77,8 @@ export const Chart = ({);return (- <CardContent>{shouldWarn ? renderWarning() : renderChart()}</CardContent>+ <CardContent className={"h-full"}>+ {shouldWarn ? renderWarning() : renderChart()}+ </CardContent>);};diff --git a/web/src/features/widgets/components/DashboardGrid.tsx b/web/src/features/widgets/components/DashboardGrid.tsxnew file mode 100644index 0000000000..ed2ea3143a--- /dev/null+++ b/web/src/features/widgets/components/DashboardGrid.tsx@@ -0,0 +1,104 @@+import { Responsive, WidthProvider } from "react-grid-layout";+import "react-grid-layout/css/styles.css";+import "react-resizable/css/styles.css";+import { type WidgetPlacement } from "../components/DashboardWidget";+import { DashboardWidget } from "@/src/features/widgets";+import { type FilterState } from "@langfuse/shared";+import { useState, useCallback } from "react";++const ResponsiveGridLayout = WidthProvider(Responsive);++export function DashboardGrid({+ widgets,+ onChange,+ canEdit,+ dashboardId,+ projectId,+ dateRange,+ filterState,+ onDeleteWidget,+ dashboardOwner,+}: {+ widgets: WidgetPlacement[];+ onChange: (widgets: WidgetPlacement[]) => void;+ canEdit: boolean;+ dashboardId: string;+ projectId: string;+ dateRange: { from: Date; to: Date } | undefined;+ filterState: FilterState;+ onDeleteWidget: (tileId: string) => void;+ dashboardOwner: "LANGFUSE" | "PROJECT" | undefined;+}) {+ const [rowHeight, setRowHeight] = useState(150);++ const handleWidthChange = useCallback(+ (containerWidth: number) => {+ const calculatedRowHeight = ((containerWidth / 12) * 9) / 16;+ if (calculatedRowHeight !== rowHeight) {+ setRowHeight(calculatedRowHeight);+ }+ },+ [rowHeight],+ );++ // Convert WidgetPlacement to react-grid-layout format+ const layout = widgets.map((w) => ({+ i: w.id,+ x: w.x,+ y: w.y,+ w: w.x_size,+ h: w.y_size,+ isDraggable: canEdit,+ }));++ const handleLayoutChange = (newLayout: any[]) => {+ if (!canEdit) return;++ // Update widget positions based on the new layout+ const updatedWidgets = widgets.map((w) => {+ const layoutItem = newLayout.find((item) => item.i === w.id);+ if (!layoutItem) return w;++ return {+ ...w,+ x: layoutItem.x,+ y: layoutItem.y,+ x_size: layoutItem.w,+ y_size: layoutItem.h,+ };+ });++ onChange(updatedWidgets);+ };++ return (+ <ResponsiveGridLayout+ className="layout"+ layouts={{ lg: layout }}+ cols={{ lg: 12, md: 12, sm: 12, xs: 12, xxs: 12 }}+ margin={[16, 16]}+ rowHeight={rowHeight}+ isDraggable={canEdit}+ isResizable={canEdit}+ onDragStop={handleLayoutChange} // Save immediately when drag stops+ onResizeStop={handleLayoutChange} // Save immediately when resize stops+ onWidthChange={handleWidthChange}+ draggableHandle=".drag-handle"+ useCSSTransforms+ >+ {widgets.map((widget) => (+ <div key={widget.id} className="max-h-full max-w-full">+ <DashboardWidget+ dashboardId={dashboardId}+ projectId={projectId}+ placement={widget}+ dateRange={dateRange}+ filterState={filterState}+ onDeleteWidget={onDeleteWidget}+ dashboardOwner={dashboardOwner || "PROJECT"}+ />+ </div>+ ))}+ </ResponsiveGridLayout>+ );+}diff --git a/web/src/features/widgets/components/DashboardWidget.tsx b/web/src/features/widgets/components/DashboardWidget.tsxindex db65b77554..71f22c0f35 100644--- a/web/src/features/widgets/components/DashboardWidget.tsx+++ b/web/src/features/widgets/components/DashboardWidget.tsx@@ -9,13 +9,18 @@ import { type z } from "zod";import { Chart } from "@/src/features/widgets/chart-library/Chart";import { type FilterState } from "@langfuse/shared";import { isTimeSeriesChart } from "@/src/features/widgets/chart-library/utils";-import { PencilIcon, TrashIcon, CopyIcon } from "lucide-react";+import {+ PencilIcon,+ TrashIcon,+ CopyIcon,+ GripVerticalIcon,+} from "lucide-react";import { useRouter } from "next/router";import { startCase } from "lodash";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { showErrorToast } from "@/src/features/notifications/showErrorToast";-interface WidgetPlacement {+export interface WidgetPlacement {id: string;widgetId: string;x: number;@@ -25,11 +30,6 @@ interface WidgetPlacement {type: "widget";}-// Generate grid classes for each widget based on position and size-const getGridClasses = (widget: WidgetPlacement) => {- return `col-start-${widget.x + 1} col-span-${widget.x_size} row-start-${widget.y + 1} row-span-${widget.y_size}`;-};-export function DashboardWidget({projectId,dashboardId,@@ -169,7 +169,7 @@ export function DashboardWidget({if (widget.isLoading) {return (<div- className={`${getGridClasses(placement)} flex items-center justify-center rounded-lg border bg-background p-4`}+ className={`flex items-center justify-center rounded-lg border bg-background p-4`}><div className="text-muted-foreground">Loading...</div></div>@@ -179,7 +179,7 @@ export function DashboardWidget({if (!widget.data) {return (<div- className={`${getGridClasses(placement)} flex items-center justify-center rounded-lg border bg-background p-4`}+ className={`flex items-center justify-center rounded-lg border bg-background p-4`}><div className="text-muted-foreground">Widget not found</div></div>@@ -188,7 +188,7 @@ export function DashboardWidget({return (<div- className={`${getGridClasses(placement)} group flex flex-col overflow-hidden rounded-lg border bg-background p-4`}+ className={`group flex h-full w-full flex-col overflow-hidden rounded-lg border bg-background p-4`}><div className="mb-2 flex items-center justify-between"><span className="font-medium">@@ -199,6 +199,10 @@ export function DashboardWidget({</span>{hasCUDAccess && (<div className="flex space-x-2">+ <GripVerticalIcon+ size={16}+ className="drag-handle hidden cursor-grab text-muted-foreground hover:text-foreground active:cursor-grabbing group-hover:block"+ />{widget.data.owner === "PROJECT" ? (<buttononClick={handleEdit}diff --git a/web/src/features/widgets/components/WidgetForm.tsx b/web/src/features/widgets/components/WidgetForm.tsxindex e9a7ba5f33..0e3d06c412 100644--- a/web/src/features/widgets/components/WidgetForm.tsx+++ b/web/src/features/widgets/components/WidgetForm.tsx@@ -708,7 +708,7 @@ export function WidgetForm({{/* Right column - Chart */}<div className="w-2/3">- <Card>+ <Card className={"aspect-video"}><CardHeader><CardTitle>{widgetName}</CardTitle><CardDescription>{widgetDescription}</CardDescription>diff --git a/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsx b/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsxindex d85fccf3c7..fb135f5e22 100644--- a/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsx+++ b/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsx@@ -2,7 +2,6 @@ import { useRouter } from "next/router";import { api } from "@/src/utils/api";import Page from "@/src/components/layouts/page";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";-import { DashboardWidget } from "@/src/features/widgets";import { DatePickerWithRange } from "@/src/components/date-picker";import { PopoverFilterBuilder } from "@/src/features/filters/components/filter-builder";import { useDashboardDateRange } from "@/src/hooks/useDashboardDateRange";@@ -20,6 +19,7 @@ import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccesimport { v4 as uuidv4 } from "uuid";import { useDebounce } from "@/src/hooks/useDebounce";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { DashboardGrid } from "@/src/features/widgets/components/DashboardGrid";interface WidgetPlacement {id: string;@@ -124,7 +124,7 @@ export default function DashboardDetail() {x: 0, // Start at lefty: maxY, // Place below existing widgetsx_size: 6, // Default size (half of 12-column grid)- y_size: 2, // Default height of 2 rows+ y_size: 6, // Default height of 6 rowstype: "widget",};@@ -402,20 +402,26 @@ export default function DashboardDetail() {/></div></div>- <div className="grid grid-cols-12 gap-4">- {localDashboardDefinition.widgets.map((widgetPlacement) => (- <DashboardWidget- key={widgetPlacement.id}- dashboardId={dashboardId}- projectId={projectId}- placement={widgetPlacement}- dateRange={dateRange}- filterState={userFilterState}- onDeleteWidget={handleDeleteWidget}- dashboardOwner={dashboard.data?.owner}- />- ))}- </div>+ <DashboardGrid+ widgets={localDashboardDefinition.widgets}+ onChange={(updatedWidgets) => {+ setLocalDashboardDefinition({+ ...localDashboardDefinition,+ widgets: updatedWidgets,+ });+ saveDashboardChanges({+ ...localDashboardDefinition,+ widgets: updatedWidgets,+ });+ }}+ canEdit={hasCUDAccess}+ dashboardId={dashboardId}+ projectId={projectId}+ dateRange={dateRange}+ filterState={userFilterState}+ onDeleteWidget={handleDeleteWidget}+ dashboardOwner={dashboard.data?.owner}+ /></div>)}</Page>diff --git a/web/src/styles/globals.css b/web/src/styles/globals.cssindex c745d75518..0d2b6db121 100644--- a/web/src/styles/globals.css+++ b/web/src/styles/globals.css@@ -194,3 +194,23 @@appearance: none;}}++/* Custom styles for react-grid-layout resize handle */+.react-resizable-handle {+ position: absolute;+ bottom: 5px !important;+ right: 5px !important;+ background-image: none !important;+ display: flex;+ align-items: center;+ justify-content: center;+ color: hsl(var(--muted-foreground));+}++.react-resizable-handle::after {+ content: "";+ width: 10px !important;+ height: 10px !important;+ border-right: 2px solid currentColor !important;+ border-bottom: 2px solid currentColor !important;+}