Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(trace timeline view): add timeline view for traces and observations (#2283)

marliessophie535e6ecb669e
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 56515b2932..a8beab3d8c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -267,6 +267,9 @@ importers:
'@marsidev/react-turnstile':
specifier: ^0.5.4
+ '@mui/x-tree-view':
+ specifier: ^7.6.2
'@next-auth/prisma-adapter':
specifier: ^1.0.7
version: 1.0.7(@prisma/[email protected])([email protected])
@@ -1554,7 +1557,6 @@ packages:
dependencies:
'@babel/highlight': 7.24.5
picocolors: 1.0.1
- dev: true
resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==}
@@ -1814,7 +1816,6 @@ packages:
resolution: {integrity: sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA==}
engines: {node: '>=6.9.0'}
- dev: true
resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==}
@@ -1858,7 +1859,6 @@ packages:
chalk: 2.4.2
js-tokens: 4.0.0
picocolors: 1.0.1
- dev: true
resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==}
@@ -2265,6 +2265,128 @@ packages:
dependencies:
'@jridgewell/trace-mapping': 0.3.9
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==}
+ dependencies:
+ '@babel/helper-module-imports': 7.24.7
+ '@babel/runtime': 7.24.7
+ '@emotion/hash': 0.9.1
+ '@emotion/memoize': 0.8.1
+ '@emotion/serialize': 1.1.4
+ babel-plugin-macros: 3.1.0
+ convert-source-map: 1.9.0
+ escape-string-regexp: 4.0.0
+ find-root: 1.1.0
+ source-map: 0.5.7
+ stylis: 4.2.0
+ transitivePeerDependencies:
+ - supports-color
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-P34z9ssTCBi3e9EI1ZsWpNHcfY1r09ZO0rZbRO2ob3ZQMnFI35jB536qoXbkdesr5EUhYi22anuEJuyxifaqAQ==}
+ dependencies:
+ '@emotion/memoize': 0.8.1
+ '@emotion/sheet': 1.2.2
+ '@emotion/utils': 1.2.1
+ '@emotion/weak-memoize': 0.3.1
+ stylis: 4.2.0
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ==}
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==}
+ dependencies:
+ '@emotion/memoize': 0.8.1
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==}
+ dev: false
+
+ resolution: {integrity: sha512-t8AjMlF0gHpvvxk5mAtCqR4vmxiGHCeJBaQO6gncUSdklELOgtwjerNY2yuJNfwnc6vi16U/+uMF+afIawJ9iw==}
+ peerDependencies:
+ '@types/react': '*'
+ react: '>=16.8.0'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@emotion/babel-plugin': 11.11.0
+ '@emotion/cache': 11.11.0
+ '@emotion/serialize': 1.1.4
+ '@emotion/use-insertion-effect-with-fallbacks': 1.0.1([email protected])
+ '@emotion/utils': 1.2.1
+ '@emotion/weak-memoize': 0.3.1
+ '@types/react': 18.2.79
+ hoist-non-react-statics: 3.3.2
+ react: 18.2.0
+ transitivePeerDependencies:
+ - supports-color
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-RIN04MBT8g+FnDwgvIUi8czvr1LU1alUMI05LekWB5DGyTm8cCBMCRpq3GqaiyEDRptEXOyXnvZ58GZYu4kBxQ==}
+ dependencies:
+ '@emotion/hash': 0.9.1
+ '@emotion/memoize': 0.8.1
+ '@emotion/unitless': 0.8.1
+ '@emotion/utils': 1.2.1
+ csstype: 3.1.3
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-0QBtGvaqtWi+nx6doRwDdBIzhNdZrXUppvTM4dtZZWEGTXL/XE/yJxLMGlDT1Gt+UHH5IX1n+jkXyytE/av7OA==}
+ dev: false
+
+ resolution: {integrity: sha512-/ZjjnaNKvuMPxcIiUkf/9SHoG4Q196DRl1w82hQ3WCsjo1IUR8uaGWrC6a87CrYAW0Kb/pK7hk8BnLgLRi9KoQ==}
+ peerDependencies:
+ '@emotion/react': ^11.0.0-rc.0
+ '@types/react': '*'
+ react: '>=16.8.0'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@emotion/babel-plugin': 11.11.0
+ '@emotion/is-prop-valid': 1.2.2
+ '@emotion/react': 11.11.4(@types/[email protected])([email protected])
+ '@emotion/serialize': 1.1.4
+ '@emotion/use-insertion-effect-with-fallbacks': 1.0.1([email protected])
+ '@emotion/utils': 1.2.1
+ '@types/react': 18.2.79
+ react: 18.2.0
+ transitivePeerDependencies:
+ - supports-color
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==}
+ dev: false
+
+ resolution: {integrity: sha512-jT/qyKZ9rzLErtrjGgdkMBn2OP8wl0G3sQlBb3YPryvKHsjvINUhVaPFfP+fpBcOkmrVOVEEHQFJ7nbj2TH2gw==}
+ peerDependencies:
+ react: '>=16.8.0'
+ dependencies:
+ react: 18.2.0
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-Y2tGf3I+XVnajdItskUCn6LX+VUDmP6lTL4fcqsXAv43dnlbZiuW4MWQW38rW/BVWSE7Q/7+XQocmpnRYILUmg==}
+ dev: false
+
+ /@emotion/[email protected]:
+ resolution: {integrity: sha512-EsBwpc7hBUJWAsNPBmJy4hxWx12v6bshQsldrVmjxJoc3isbxhOrF2IcCpaXxfvq03NwkI7sbsOLXbYuqF/8Ww==}
+ dev: false
+
/@esbuild/[email protected]:
resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==}
engines: {node: '>=12'}
@@ -3666,6 +3788,194 @@ packages:
strict-event-emitter: 0.5.1
dev: true
+ resolution: {integrity: sha512-I/lGHztkCzvwlXpjD2+SNmvNQvB4227xBXhISPjEaJUXGImOQ9f3D2Yj/T3KasSI/h0MLWy74X0J6clhPmsRbQ==}
+ engines: {node: '>=12.0.0'}
+ peerDependencies:
+ '@types/react': ^17.0.0 || ^18.0.0
+ react: ^17.0.0 || ^18.0.0
+ react-dom: ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@floating-ui/react-dom': 2.0.8([email protected])([email protected])
+ '@mui/types': 7.2.14(@types/[email protected])
+ '@mui/utils': 5.15.14(@types/[email protected])([email protected])
+ '@popperjs/core': 2.11.8
+ '@types/react': 18.2.79
+ clsx: 2.1.1
+ prop-types: 15.8.1
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
+ resolution: {integrity: sha512-tCHSi/Tomez9ERynFhZRvFO6n9ATyrPs+2N80DMDzp6xDVirbBjEwhPcE+x7Lj+nwYw0SqFkOxyvMP0irnm55w==}
+ dev: false
+
+ resolution: {integrity: sha512-lp5xQBbcRuxNtjpWU0BWZgIrv2XLUz4RJ0RqFXBdESIsKoGCQZ6P3wwU5ZPuj5TjssNiKv9AlM+vHopRxZhvVQ==}
+ engines: {node: '>=12.0.0'}
+ peerDependencies:
+ '@emotion/react': ^11.5.0
+ '@emotion/styled': ^11.3.0
+ '@types/react': ^17.0.0 || ^18.0.0
+ react: ^17.0.0 || ^18.0.0
+ react-dom: ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@emotion/react':
+ optional: true
+ '@emotion/styled':
+ optional: true
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@emotion/react': 11.11.4(@types/[email protected])([email protected])
+ '@emotion/styled': 11.11.5(@emotion/[email protected])(@types/[email protected])([email protected])
+ '@mui/base': 5.0.0-beta.40(@types/[email protected])([email protected])([email protected])
+ '@mui/core-downloads-tracker': 5.15.19
+ '@mui/system': 5.15.15(@emotion/[email protected])(@emotion/[email protected])(@types/[email protected])([email protected])
+ '@mui/types': 7.2.14(@types/[email protected])
+ '@mui/utils': 5.15.14(@types/[email protected])([email protected])
+ '@types/react': 18.2.79
+ '@types/react-transition-group': 4.4.10
+ clsx: 2.1.1
+ csstype: 3.1.3
+ prop-types: 15.8.1
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ react-is: 18.2.0
+ react-transition-group: 4.4.5([email protected])([email protected])
+ dev: false
+
+ resolution: {integrity: sha512-UH0EiZckOWcxiXLX3Jbb0K7rC8mxTr9L9l6QhOZxYc4r8FHUkefltV9VDGLrzCaWh30SQiJvAEd7djX3XXY6Xw==}
+ engines: {node: '>=12.0.0'}
+ peerDependencies:
+ '@types/react': ^17.0.0 || ^18.0.0
+ react: ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@mui/utils': 5.15.14(@types/[email protected])([email protected])
+ '@types/react': 18.2.79
+ prop-types: 15.8.1
+ react: 18.2.0
+ dev: false
+
+ resolution: {integrity: sha512-RILkuVD8gY6PvjZjqnWhz8fu68dVkqhM5+jYWfB5yhlSQKg+2rHkmEwm75XIeAqI3qwOndK6zELK5H6Zxn4NHw==}
+ engines: {node: '>=12.0.0'}
+ peerDependencies:
+ '@emotion/react': ^11.4.1
+ '@emotion/styled': ^11.3.0
+ react: ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@emotion/react':
+ optional: true
+ '@emotion/styled':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@emotion/cache': 11.11.0
+ '@emotion/react': 11.11.4(@types/[email protected])([email protected])
+ '@emotion/styled': 11.11.5(@emotion/[email protected])(@types/[email protected])([email protected])
+ csstype: 3.1.3
+ prop-types: 15.8.1
+ react: 18.2.0
+ dev: false
+
+ resolution: {integrity: sha512-aulox6N1dnu5PABsfxVGOZffDVmlxPOVgj56HrUnJE8MCSh8lOvvkd47cebIVQQYAjpwieXQXiDPj5pwM40jTQ==}
+ engines: {node: '>=12.0.0'}
+ peerDependencies:
+ '@emotion/react': ^11.5.0
+ '@emotion/styled': ^11.3.0
+ '@types/react': ^17.0.0 || ^18.0.0
+ react: ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@emotion/react':
+ optional: true
+ '@emotion/styled':
+ optional: true
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@emotion/react': 11.11.4(@types/[email protected])([email protected])
+ '@emotion/styled': 11.11.5(@emotion/[email protected])(@types/[email protected])([email protected])
+ '@mui/private-theming': 5.15.14(@types/[email protected])([email protected])
+ '@mui/styled-engine': 5.15.14(@emotion/[email protected])(@emotion/[email protected])([email protected])
+ '@mui/types': 7.2.14(@types/[email protected])
+ '@mui/utils': 5.15.14(@types/[email protected])([email protected])
+ '@types/react': 18.2.79
+ clsx: 2.1.1
+ csstype: 3.1.3
+ prop-types: 15.8.1
+ react: 18.2.0
+ dev: false
+
+ resolution: {integrity: sha512-MZsBZ4q4HfzBsywtXgM1Ksj6HDThtiwmOKUXH1pKYISI9gAVXCNHNpo7TlGoGrBaYWZTdNoirIN7JsQcQUjmQQ==}
+ peerDependencies:
+ '@types/react': ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@types/react': 18.2.79
+ dev: false
+
+ resolution: {integrity: sha512-0lF/7Hh/ezDv5X7Pry6enMsbYyGKjADzvHyo3Qrc/SSlTsQ1VkbDMbH0m2t3OR5iIVLwMoxwM7yGd+6FCMtTFA==}
+ engines: {node: '>=12.0.0'}
+ peerDependencies:
+ '@types/react': ^17.0.0 || ^18.0.0
+ react: ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@types/prop-types': 15.7.11
+ '@types/react': 18.2.79
+ prop-types: 15.8.1
+ react: 18.2.0
+ react-is: 18.2.0
+ dev: false
+
+ resolution: {integrity: sha512-0LBoKUQvMzNzJN7UmGqGV4A3NpRxB8liPrjQMfkbI6LrXBbDlqyEdJWRseK1RzxYxTfH71HqW9Z3E2wS62P1Sg==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ '@emotion/react': ^11.9.0
+ '@emotion/styled': ^11.8.1
+ '@mui/material': ^5.15.14
+ react: ^17.0.0 || ^18.0.0
+ react-dom: ^17.0.0 || ^18.0.0
+ dependencies:
+ '@babel/runtime': 7.24.7
+ '@emotion/react': 11.11.4(@types/[email protected])([email protected])
+ '@emotion/styled': 11.11.5(@emotion/[email protected])(@types/[email protected])([email protected])
+ '@mui/base': 5.0.0-beta.40(@types/[email protected])([email protected])([email protected])
+ '@mui/material': 5.15.19(@emotion/[email protected])(@emotion/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@mui/system': 5.15.15(@emotion/[email protected])(@emotion/[email protected])(@types/[email protected])([email protected])
+ '@mui/utils': 5.15.14(@types/[email protected])([email protected])
+ '@types/react-transition-group': 4.4.10
+ clsx: 2.1.1
+ prop-types: 15.8.1
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ react-transition-group: 4.4.5([email protected])([email protected])
+ transitivePeerDependencies:
+ - '@types/react'
+ dev: false
+
resolution: {integrity: sha512-Cdko4KfcmKjsyHFrWwZ//lfLUbcLqlyFqjd/nYE2m3aZ7tjMNUjpks47iw7NTCnXf+5UWz5Ypyt1dSs1EP5QJw==}
peerDependencies:
@@ -4305,6 +4615,10 @@ packages:
config-chain: 1.1.13
dev: true
+ /@popperjs/[email protected]:
+ resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==}
+ dev: false
+
resolution: {integrity: sha512-uYdfpPncbZ/syJyiYBwGZS8Gt1PTNoErNYMuqHDa2r30rNSFtgTA/LXsSk55R7pdRTMi5pHkeP9B14K6nHmwkg==}
engines: {node: '>=16.13'}
@@ -7335,6 +7649,10 @@ packages:
resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==}
dev: true
+ resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==}
+ dev: false
+
resolution: {integrity: sha512-qZAvkv1K3QbmHHFYSNRYPkRjOWRLBYrL4B9c+wG0GSVGBw0NtJwPcgx/DSddeDJvRGMHCEQ4VMEVfuJ/0gZ3XQ==}
dependencies:
@@ -7370,6 +7688,12 @@ packages:
dependencies:
'@types/react': 18.2.79
+ resolution: {integrity: sha512-hT/+s0VQs2ojCX823m60m5f0sL5idt9SO6Tj6Dg+rdphGPIeJbJ6CxvBYkgkGKrYeDjvIpKTR38UzmtHJOGW3Q==}
+ dependencies:
+ '@types/react': 18.2.79
+ dev: false
+
resolution: {integrity: sha512-RwGAGXPl9kSXwdNTafkOEuFrTBD5SA2B3iEB96xi8+xu5ddUa/cpvyVCSNn+asgLCTHkb5ZxN8gbuibYJi4s1w==}
dependencies:
@@ -8747,6 +9071,15 @@ packages:
'@types/babel__traverse': 7.20.5
dev: true
+ resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}
+ engines: {node: '>=10', npm: '>=6'}
+ dependencies:
+ '@babel/runtime': 7.24.7
+ cosmiconfig: 7.1.0
+ resolve: 1.22.8
+ dev: false
+
resolution: {integrity: sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==}
peerDependencies:
@@ -9023,7 +9356,6 @@ packages:
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
engines: {node: '>=6'}
- dev: true
resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==}
@@ -9403,6 +9735,10 @@ packages:
engines: {node: '>= 0.6'}
dev: false
+ resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==}
+ dev: false
+
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
@@ -9449,6 +9785,17 @@ packages:
vary: 1.1.2
dev: false
+ resolution: {integrity: sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==}
+ engines: {node: '>=10'}
+ dependencies:
+ '@types/parse-json': 4.0.2
+ import-fresh: 3.3.0
+ parse-json: 5.2.0
+ path-type: 4.0.0
+ yaml: 1.10.2
+ dev: false
+
resolution: {integrity: sha512-/UkO2JKI18b5jVMJUp0lvKFMpa/Gye+ZgZjKD+DGEN9y7NRcf/nK1A0sp67ONmKtnDCNMS44E6jrk0Yc3bDuUw==}
engines: {node: '>=14'}
@@ -10169,7 +10516,6 @@ packages:
resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==}
dependencies:
is-arrayish: 0.2.1
- dev: true
resolution: {integrity: sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==}
@@ -10393,7 +10739,6 @@ packages:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
- dev: true
resolution: {integrity: sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==}
@@ -11293,6 +11638,10 @@ packages:
pkg-dir: 4.2.0
dev: true
+ resolution: {integrity: sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==}
+ dev: false
+
resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==}
engines: {node: '>=8'}
@@ -12032,7 +12381,6 @@ packages:
dependencies:
parent-module: 1.0.1
resolve-from: 4.0.0
- dev: true
resolution: {integrity: sha512-9WOz1Yh/cvO/p69sxRmhyQwrIGGSp7EIdcb+fFNVi7CzQGQB8U1/1XrKVSbEd/GNOAeM0peJtmi7+qphe7NvAw==}
@@ -12207,7 +12555,6 @@ packages:
resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==}
- dev: true
resolution: {integrity: sha512-Y1JXKrfykRJGdlDwdKlLpLyMIiWqWvuSd17TvZk68PLAOGOoF4Xyav1z0Xhoi+gCYjZVeC5SI+hYFOfvXmGRCA==}
@@ -14887,7 +15234,6 @@ packages:
engines: {node: '>=6'}
dependencies:
callsites: 3.1.0
- dev: true
resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==}
@@ -14897,7 +15243,6 @@ packages:
error-ex: 1.3.2
json-parse-even-better-errors: 2.3.1
lines-and-columns: 1.2.4
- dev: true
resolution: {integrity: sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==}
@@ -14967,7 +15312,6 @@ packages:
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
engines: {node: '>=8'}
- dev: true
resolution: {integrity: sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==}
@@ -15767,7 +16111,6 @@ packages:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
- dev: true
resolution: {integrity: sha512-I42jl7L3Ze6kZaq+7zXWSunBa3b1on5yfvUW6Eo/3fFOj6dZ5Bqmcd264nJbTK/gn1HjjILAjSwnZbV4RpSaNQ==}
@@ -16147,7 +16490,6 @@ packages:
resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}
engines: {node: '>=4'}
- dev: true
resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}
@@ -16647,6 +16989,11 @@ packages:
source-map: 0.6.1
dev: false
+ resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==}
+ engines: {node: '>=0.10.0'}
+ dev: false
+
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
engines: {node: '>=0.10.0'}
@@ -16934,6 +17281,10 @@ packages:
react: 18.2.0
dev: false
+ resolution: {integrity: sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==}
+ dev: false
+
resolution: {integrity: sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==}
engines: {node: '>=16 || 14 >=14.17'}
@@ -18373,6 +18724,11 @@ packages:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
+ resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
+ engines: {node: '>= 6'}
+ dev: false
+
resolution: {integrity: sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==}
engines: {node: '>= 14'}
diff --git a/web/package.json b/web/package.json
index b1f3d94a18..3b12b8a9e8 100644
--- a/web/package.json
+++ b/web/package.json
@@ -36,6 +36,7 @@
"@langfuse/ee": "workspace:*",
"@langfuse/shared": "workspace:*",
"@marsidev/react-turnstile": "^0.5.4",
+ "@mui/x-tree-view": "^7.6.2",
"@next-auth/prisma-adapter": "^1.0.7",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
diff --git a/web/src/components/trace/ObservationTree.tsx b/web/src/components/trace/ObservationTree.tsx
index 6d1ad4d0d6..e08759c8f2 100644
--- a/web/src/components/trace/ObservationTree.tsx
+++ b/web/src/components/trace/ObservationTree.tsx
@@ -1,6 +1,6 @@
import { type NestedObservation } from "@/src/utils/types";
import { cn } from "@/src/utils/tailwind";
-import { type Trace, type Score, $Enums } from "@langfuse/shared";
+import { type Trace, type Score, type $Enums } from "@langfuse/shared";
import { GroupedScoreBadges } from "@/src/components/grouped-score-badge";
import { Fragment } from "react";
import { type ObservationReturnType } from "@/src/server/api/routers/traces";
@@ -10,6 +10,10 @@ import { MinusCircle, MinusIcon, PlusCircleIcon, PlusIcon } from "lucide-react";
import { Toggle } from "@/src/components/ui/toggle";
import { Button } from "@/src/components/ui/button";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import {
+ nestObservations,
+ treeItemColors,
+} from "@/src/components/trace/lib/helpers";
export const ObservationTree = (props: {
observations: ObservationReturnType[];
@@ -257,53 +261,14 @@ const ObservationTreeNode = (props: {
const ColorCodedObservationType = (props: {
observationType: $Enums.ObservationType;
}) => {
- const colors: Record<$Enums.ObservationType, string> = {
- [$Enums.ObservationType.SPAN]: "bg-muted-blue",
- [$Enums.ObservationType.GENERATION]: "bg-muted-orange",
- [$Enums.ObservationType.EVENT]: "bg-muted-green",
- };
-
return (
<span
className={cn(
"self-start rounded-sm p-1 text-xs",
- colors[props.observationType],
+ treeItemColors.get(props.observationType),
)}
>
{props.observationType}
</span>
);
};
-
-export function nestObservations(
- list: ObservationReturnType[],
-): NestedObservation[] {
- if (list.length === 0) return [];
-
- // Step 1: Create a map where the keys are object IDs, and the values are
- // the corresponding objects with an added 'children' property.
- const map = new Map<string, NestedObservation>();
- for (const obj of list) {
- map.set(obj.id, { ...obj, children: [] });
- }
-
- // Step 2: Create another map for the roots of all trees.
- const roots = new Map<string, NestedObservation>();
-
- // Step 3: Populate the 'children' arrays and root map.
- for (const obj of map.values()) {
- if (obj.parentObservationId) {
- const parent = map.get(obj.parentObservationId);
- if (parent) {
- parent.children.push(obj);
- }
- } else {
- roots.set(obj.id, obj);
- }
- }
-
- // TODO sum token amounts per level
-
- // Step 4: Return the roots.
- return Array.from(roots.values());
-}
diff --git a/web/src/components/trace/TraceTimelineView.tsx b/web/src/components/trace/TraceTimelineView.tsx
new file mode 100644
index 0000000000..65d7c5ea22
--- /dev/null
+++ b/web/src/components/trace/TraceTimelineView.tsx
@@ -0,0 +1,383 @@
+import { Card } from "@/src/components/ui/card";
+import { type ObservationReturnType } from "@/src/server/api/routers/traces";
+import { type Score, type Trace } from "@langfuse/shared";
+
+import React, { useEffect, useRef, useState } from "react";
+import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
+import { TreeItem } from "@mui/x-tree-view/TreeItem";
+
+import { MinusIcon, PlusIcon, PanelRightOpen } from "lucide-react";
+import { nestObservations } from "@/src/components/trace/lib/helpers";
+import { type NestedObservation } from "@/src/utils/types";
+import { cn } from "@/src/utils/tailwind";
+import { Button } from "@/src/components/ui/button";
+import {
+ type TreeItemType,
+ treeItemColors,
+} from "@/src/components/trace/lib/helpers";
+import {
+ Drawer,
+ DrawerContent,
+ DrawerTrigger,
+} from "@/src/components/ui/drawer";
+import { TracePreview } from "@/src/components/trace/TracePreview";
+import { ObservationPreview } from "@/src/components/trace/ObservationPreview";
+import useSessionStorage from "@/src/components/useSessionStorage";
+
+// Fixed widths for styling for v1
+const SCALE_WIDTH = 800;
+const STEP_SIZE = 100;
+const CARD_PADDING = 60;
+const LABEL_WIDTH = 35;
+const MIN_LABEL_WIDTH = 250;
+const TREE_INDENTATION = 12; // default in MUI X TreeView
+
+const PREDEFINED_STEP_SIZES = [
+ 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 2.5, 3, 4, 5, 6, 7, 8, 9, 10,
+];
+
+const calculateStepSize = (latency: number, scaleWidth: number) => {
+ const calculatedStepSize = latency / (scaleWidth / STEP_SIZE);
+ return (
+ PREDEFINED_STEP_SIZES.find((step) => step >= calculatedStepSize) ||
+ PREDEFINED_STEP_SIZES[PREDEFINED_STEP_SIZES.length - 1]
+ );
+};
+
+function TreeItemInner({
+ latency,
+ totalScaleSpan,
+ type,
+ startOffset = 0,
+ name,
+ children,
+ setBackgroundColor,
+ level = 0,
+ cardWidth,
+}: {
+ latency: number;
+ totalScaleSpan: number;
+ type: TreeItemType;
+ startOffset?: number;
+ name?: string | null;
+ children?: React.ReactNode;
+ setBackgroundColor: (color: string) => void;
+ level?: number;
+ cardWidth: number;
+}) {
+ const itemWidth = (latency / totalScaleSpan) * SCALE_WIDTH;
+ const itemOffsetLabelWidth = itemWidth + startOffset + LABEL_WIDTH;
+ const customLabelWidth = cardWidth - SCALE_WIDTH - CARD_PADDING;
+
+ return (
+ <div className="group my-1 grid w-full min-w-fit grid-cols-[1fr,auto] items-center">
+ <div
+ className="flex flex-row items-center gap-2"
+ style={{
+ maxWidth: customLabelWidth - level * TREE_INDENTATION,
+ minWidth: MIN_LABEL_WIDTH - LABEL_WIDTH - level * TREE_INDENTATION,
+ }}
+ >
+ <span
+ className={cn("rounded-sm p-1 text-xs", treeItemColors.get(type))}
+ >
+ {type}
+ </span>
+ <span className="w-fit-content overflow-hidden text-ellipsis whitespace-nowrap break-all text-sm">
+ {name}
+ </span>
+ <div
+ className="w-6 flex-1"
+ onClick={(event) => {
+ event.stopPropagation();
+ }}
+ >
+ <Drawer
+ onOpenChange={(open) => setBackgroundColor(open ? "!bg-muted" : "")}
+ >
+ <DrawerTrigger asChild>
+ <Button
+ className="focus:none active:none hidden justify-start hover:!bg-transparent group-hover:block"
+ type="button"
+ size="xs"
+ variant="ghost"
+ >
+ <PanelRightOpen className="h-4 w-4"></PanelRightOpen>
+ </Button>
+ </DrawerTrigger>
+ <DrawerContent className="h-1/2 w-full overflow-hidden md:w-3/5 lg:w-3/5 xl:w-3/5 2xl:w-3/5">
+ {children}
+ </DrawerContent>
+ </Drawer>
+ </div>
+ </div>
+ <div className="flex items-center" style={{ width: `${SCALE_WIDTH}px` }}>
+ <div className={`relative w-[${SCALE_WIDTH}px]`}>
+ <div className="ml-4 mr-4 h-full border-r-2"></div>
+ <div
+ className={cn(
+ "flex h-5 items-center justify-end rounded-sm",
+ itemWidth
+ ? treeItemColors.get(type)
+ : "border border-dashed bg-muted",
+ )}
+ style={{
+ width: `${itemWidth || 10}px`,
+ marginLeft: `${startOffset}px`,
+ }}
+ >
+ <span
+ className={cn(
+ "hidden justify-end text-xs text-muted-foreground group-hover:block",
+ itemOffsetLabelWidth > SCALE_WIDTH
+ ? "mr-1"
+ : !!latency
+ ? "-mr-9"
+ : "-mr-6",
+ )}
+ >
+ {!!latency ? `${latency.toFixed(2)}s` : "n/a"}
+ </span>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+function TraceTreeItem({
+ observation,
+ level = 0,
+ traceStartTime,
+ totalScaleSpan,
+ projectId,
+ scores,
+ observations,
+ cardWidth,
+}: {
+ observation: NestedObservation;
+ level: number;
+ traceStartTime: Date;
+ totalScaleSpan: number;
+ projectId: string;
+ scores: Score[];
+ observations: Array<ObservationReturnType>;
+ cardWidth: number;
+}) {
+ const { startTime, endTime } = observation || {};
+ const [backgroundColor, setBackgroundColor] = useState("");
+
+ const latency = endTime
+ ? (endTime.getTime() - startTime.getTime()) / 1000
+ : 0;
+ const startOffset =
+ ((startTime.getTime() - traceStartTime.getTime()) / totalScaleSpan / 1000) *
+ SCALE_WIDTH;
+
+ return (
+ <TreeItem
+ classes={{
+ content: `border-l border-dashed !rounded-xs ${backgroundColor} !min-w-fit hover:!bg-muted`,
+ selected: "!bg-background !important hover:!bg-muted",
+ label: "!min-w-fit",
+ }}
+ key={observation.id}
+ itemId={observation.id}
+ label={
+ <TreeItemInner
+ latency={latency}
+ type={observation.type}
+ name={observation.name}
+ startOffset={startOffset}
+ totalScaleSpan={totalScaleSpan}
+ setBackgroundColor={setBackgroundColor}
+ level={level}
+ cardWidth={cardWidth}
+ >
+ <>
+ <h3 className="mb-6 px-8 pt-8 text-2xl font-semibold tracking-tight">
+ Detail view
+ </h3>
+ <div className="overflow-y-auto px-8 pb-8 pt-2">
+ <ObservationPreview
+ observations={observations}
+ scores={scores}
+ projectId={projectId}
+ currentObservationId={observation.id}
+ traceId={observation.traceId}
+ />
+ </div>
+ </>
+ </TreeItemInner>
+ }
+ >
+ {Array.isArray(observation.children)
+ ? observation.children.map((child) => (
+ <TraceTreeItem
+ key={child.id}
+ observation={child}
+ level={level + 1}
+ traceStartTime={traceStartTime}
+ totalScaleSpan={totalScaleSpan}
+ projectId={projectId}
+ scores={scores}
+ observations={observations}
+ cardWidth={cardWidth}
+ />
+ ))
+ : null}
+ </TreeItem>
+ );
+}
+
+export function TraceTimelineView({
+ trace,
+ observations,
+ projectId,
+ scores,
+}: {
+ trace: Trace & { latency?: number };
+ observations: Array<ObservationReturnType>;
+ projectId: string;
+ scores: Score[];
+}) {
+ const { latency, name, id } = trace;
+ const [backgroundColor, setBackgroundColor] = useState("");
+ const [expandedItems, setExpandedItems] = useSessionStorage<string[]>(
+ `${trace.id}-expanded`,
+ [trace.id],
+ );
+
+ const [cardWidth, setCardWidth] = useState(0);
+ const parentRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const handleResize = () => {
+ if (parentRef.current) {
+ const availableWidth = parentRef.current.offsetWidth;
+ setCardWidth(availableWidth);
+ }
+ };
+
+ handleResize();
+ window.addEventListener("resize", handleResize); // Recalculate on window resize
+
+ return () => {
+ window.removeEventListener("resize", handleResize);
+ };
+ }, [parentRef]);
+
+ if (!latency) return null;
+
+ const nestedObservations = nestObservations(observations);
+ const stepSize = calculateStepSize(latency, SCALE_WIDTH);
+ const totalScaleSpan = stepSize * (SCALE_WIDTH / STEP_SIZE);
+
+ return (
+ <div ref={parentRef} className="w-full">
+ <Card
+ className="flex max-h-[calc(100dvh-24rem)] flex-col overflow-x-auto overflow-y-hidden"
+ style={{ width: cardWidth }}
+ >
+ <div className="grid w-full grid-cols-[1fr,auto] items-center p-2">
+ <h3
+ className="p-2 text-2xl font-semibold tracking-tight"
+ style={{
+ minWidth: `${MIN_LABEL_WIDTH}px`,
+ }}
+ >
+ Trace Timeline
+ </h3>
+ <div
+ className="relative mr-2 h-4"
+ style={{ width: `${SCALE_WIDTH}px` }}
+ >
+ {Array.from({ length: SCALE_WIDTH / STEP_SIZE + 1 }).map(
+ (_, index) => {
+ const step = stepSize * index;
+ const isLastStep = index === SCALE_WIDTH / STEP_SIZE;
+
+ return isLastStep ? (
+ <span
+ className="absolute -right-2 text-xs text-muted-foreground"
+ key={index}
+ >
+ {step.toFixed(2)}s
+ </span>
+ ) : (
+ <div
+ key={index}
+ className="absolute h-full border border-l text-xs"
+ style={{ left: `${index * STEP_SIZE}px` }}
+ >
+ <span className="absolute left-2 text-xs text-muted-foreground">
+ {step.toFixed(2)}s
+ </span>
+ </div>
+ );
+ },
+ )}
+ </div>
+ </div>
+ <div className="min-w-fit overflow-y-auto p-2">
+ <SimpleTreeView
+ slots={{
+ expandIcon: PlusIcon,
+ collapseIcon: MinusIcon,
+ }}
+ expandedItems={expandedItems}
+ onExpandedItemsChange={(_, itemIds) => setExpandedItems(itemIds)}
+ itemChildrenIndentation={TREE_INDENTATION}
+ >
+ <TreeItem
+ key={id}
+ itemId={id}
+ classes={{
+ content: `${backgroundColor} !min-w-fit !hover:bg-muted`,
+ selected: "!bg-background !important hover:!bg-muted",
+ label: "!min-w-fit",
+ }}
+ label={
+ <TreeItemInner
+ name={name}
+ latency={latency}
+ totalScaleSpan={totalScaleSpan}
+ setBackgroundColor={setBackgroundColor}
+ type="TRACE"
+ cardWidth={cardWidth}
+ >
+ <div className="overflow-y-auto p-8">
+ <h3 className="mb-6 text-2xl font-semibold tracking-tight">
+ Detail view
+ </h3>
+ <TracePreview
+ trace={trace}
+ observations={observations}
+ scores={scores}
+ />
+ </div>
+ </TreeItemInner>
+ }
+ >
+ {Boolean(nestedObservations.length)
+ ? nestedObservations.map((observation) => (
+ <TraceTreeItem
+ key={observation.id}
+ observation={observation}
+ level={1}
+ traceStartTime={nestedObservations[0].startTime}
+ totalScaleSpan={totalScaleSpan}
+ projectId={projectId}
+ scores={scores}
+ observations={observations}
+ cardWidth={cardWidth}
+ />
+ ))
+ : null}
+ </TreeItem>
+ </SimpleTreeView>
+ </div>
+ </Card>
+ </div>
+ );
+}
diff --git a/web/src/components/trace/index.tsx b/web/src/components/trace/index.tsx
index 7bebec0b74..8c8c13a98b 100644
--- a/web/src/components/trace/index.tsx
+++ b/web/src/components/trace/index.tsx
@@ -6,7 +6,7 @@ import { TracePreview } from "./TracePreview";
import Header from "@/src/components/layouts/header";
import { Badge } from "@/src/components/ui/badge";
import { TraceAggUsageBadge } from "@/src/components/token-usage-badge";
-import { StringParam, useQueryParam } from "use-query-params";
+import { StringParam, useQueryParam, withDefault } from "use-query-params";
import { PublishTraceSwitch } from "@/src/components/publish-object-switch";
import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";
import { useRouter } from "next/router";
@@ -18,12 +18,22 @@ import { ErrorPage } from "@/src/components/error-page";
import { TagTraceDetailsPopover } from "@/src/features/tag/components/TagTraceDetailsPopover";
import useLocalStorage from "@/src/components/useLocalStorage";
import { Toggle } from "@/src/components/ui/toggle";
-import { Award, ChevronsDownUp, ChevronsUpDown } from "lucide-react";
+import {
+ Award,
+ ChevronsDownUp,
+ ChevronsUpDown,
+ ListTree,
+ Network,
+ Terminal,
+} from "lucide-react";
import { usdFormatter } from "@/src/utils/numbers";
import Decimal from "decimal.js";
import { useCallback, useState } from "react";
import { DeleteButton } from "@/src/components/deleteButton";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";
+import { TraceTimelineView } from "@/src/components/trace/TraceTimelineView";
+import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";
export function Trace(props: {
observations: Array<ObservationReturnType>;
@@ -199,6 +209,11 @@ export function TracePage({ traceId }: { traceId: string }) {
const totalCost = calculateDisplayTotalCost(trace.data?.observations ?? []);
+ const [selectedTab, setSelectedTab] = useQueryParam(
+ "display",
+ withDefault(StringParam, "details"),
+ );
+
if (trace.error?.data?.code === "UNAUTHORIZED")
return <ErrorPage message="You do not have access to this trace." />;
if (!trace.data) return <div>loading...</div>;
@@ -227,9 +242,17 @@ export function TracePage({ traceId }: { traceId: string }) {
/>
<DetailPageNav
currentId={traceId}
- path={(id) =>
- `/project/${router.query.projectId as string}/traces/${id}`
- }
+ path={(id) => {
+ const { view, display, projectId } = router.query;
+ const queryParams = new URLSearchParams({
+ ...(typeof view === "string" ? { view } : {}),
+ ...(typeof display === "string" ? { display } : {}),
+ });
+ const queryParamString = Boolean(queryParams.size)
+ ? `?${queryParams.toString()}`
+ : "";
+ return `/project/${projectId as string}/traces/${id}${queryParamString}`;
+ }}
listKey="traces"
/>
<DeleteButton
@@ -281,15 +304,67 @@ export function TracePage({ traceId }: { traceId: string }) {
/>
</div>
</div>
- <div className="mt-5 flex-1 overflow-hidden border-t pt-5">
- <Trace
- key={trace.data.id}
- trace={trace.data}
- scores={trace.data.scores}
- projectId={trace.data.projectId}
- observations={trace.data.observations}
- />
- </div>
+ <Tabs
+ value={selectedTab}
+ onValueChange={setSelectedTab}
+ className="flex w-full justify-end border-b bg-background"
+ >
+ <TabsList className="bg-background py-0">
+ <TabsTrigger
+ value="details"
+ className="h-full rounded-none border-b-4 border-transparent data-[state=active]:border-primary-accent data-[state=active]:shadow-none"
+ >
+ <Network className="mr-1 h-4 w-4"></Network>
+ Tree
+ </TabsTrigger>
+ <TabsTrigger
+ value="timeline"
+ className="h-full rounded-none border-b-4 border-transparent data-[state=active]:border-primary-accent data-[state=active]:shadow-none"
+ >
+ <ListTree className="mr-1 h-4 w-4"></ListTree>
+ Timeline
+ <Badge className="pointer-events-none ml-2 px-1.5">Beta</Badge>
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
+ {selectedTab === "details" && (
+ <div className="mt-5 flex-1 overflow-hidden border-t pt-5">
+ <Trace
+ key={trace.data.id}
+ trace={trace.data}
+ scores={trace.data.scores}
+ projectId={trace.data.projectId}
+ observations={trace.data.observations}
+ />
+ </div>
+ )}
+ {selectedTab === "timeline" && (
+ <div className="mt-5 flex-1 flex-col space-y-5 overflow-hidden">
+ <Alert>
+ <Terminal className="h-4 w-4" />
+ <AlertTitle>New Trace Design Beta</AlertTitle>
+ <AlertDescription>
+ We value your feedback! Share your thoughts on{" "}
+ <a
+ href="https://github.com/orgs/langfuse/discussions/2195"
+ target="_blank"
+ className="underline"
+ rel="noopener noreferrer"
+ >
+ GitHub discussions
+ </a>
+ .
+ </AlertDescription>
+ </Alert>
+ <TraceTimelineView
+ key={trace.data.id}
+ trace={trace.data}
+ scores={trace.data.scores}
+ observations={trace.data.observations}
+ projectId={trace.data.projectId}
+ />
+ </div>
+ )}
</div>
);
}
diff --git a/web/src/components/trace/lib/helpers.ts b/web/src/components/trace/lib/helpers.ts
new file mode 100644
index 0000000000..6674bfffd7
--- /dev/null
+++ b/web/src/components/trace/lib/helpers.ts
@@ -0,0 +1,50 @@
+import { $Enums } from "@langfuse/shared";
+import { type NestedObservation } from "@/src/utils/types";
+import { type ObservationReturnType } from "@/src/server/api/routers/traces";
+
+export type TreeItemType = $Enums.ObservationType | "TRACE";
+
+export const treeItemColors: Map<TreeItemType, string> = new Map([
+ [$Enums.ObservationType.SPAN, "bg-muted-blue"],
+ [$Enums.ObservationType.GENERATION, "bg-muted-orange"],
+ [$Enums.ObservationType.EVENT, "bg-muted-green"],
+ ["TRACE", "bg-input"],
+]);
+
+export function nestObservations(
+ list: ObservationReturnType[],
+): NestedObservation[] {
+ if (list.length === 0) return [];
+
+ // Step 1: Create a map where the keys are object IDs, and the values are
+ // the corresponding objects with an added 'children' property.
+ const map = new Map<string, NestedObservation>();
+ for (const obj of list) {
+ map.set(obj.id, { ...obj, children: [] });
+ }
+
+ // Step 2: Create another map for the roots of all trees.
+ const roots = new Map<string, NestedObservation>();
+
+ // Step 3: Populate the 'children' arrays and root map.
+ for (const obj of map.values()) {
+ if (obj.parentObservationId) {
+ const parent = map.get(obj.parentObservationId);
+ if (parent) {
+ parent.children.push(obj);
+ }
+ } else {
+ roots.set(obj.id, obj);
+ }
+ }
+
+ // Step 4: Sort children by start time for each parent
+ for (const obj of map.values()) {
+ obj.children.sort((a, b) => a.startTime.getTime() - b.startTime.getTime());
+ }
+
+ // TODO sum token amounts per level
+
+ // Step 5: Return the roots.
+ return Array.from(roots.values());
+}
diff --git a/web/src/components/useSessionStorage.tsx b/web/src/components/useSessionStorage.tsx
new file mode 100644
index 0000000000..ddc494ed4f
--- /dev/null
+++ b/web/src/components/useSessionStorage.tsx
@@ -0,0 +1,58 @@
+import { useState, useEffect } from "react";
+
+/**
+ * useSessionStorage is a hook for managing data with the sessionStorage API.
+ *
+ * @param {string} sessionStorageKey - The key under which the value is stored in sessionStorage.
+ * @param {T} initialValue - The initial value of the data to be stored.
+ *
+ * Note: The object T should be able to be stringified, as it will be stored in sessionStorage as a string.
+ *
+ * @return An array with three elements:
+ * value: Current value
+ * setValue: Function to update the value
+ * clearValue: Function to remove value from the session storage.
+ * This function will also reset the value to initial value
+ *
+ * @template T - The type of the data to be stored in sessionStorage. It should be a type that can be stringified.
+ *
+ * @throws Will throw an error if the stringifying the value or accessing session storage fails.
+ */
+function useSessionStorage<T>(
+ sessionStorageKey: string,
+ initialValue: T,
+): [T, React.Dispatch<React.SetStateAction<T>>, () => void] {
+ const [value, setValue] = useState<T>(() => {
+ if (typeof window === "undefined") {
+ return initialValue;
+ }
+ try {
+ const storedValue = sessionStorage.getItem(sessionStorageKey);
+ return storedValue ? (JSON.parse(storedValue) as T) : initialValue;
+ } catch (error) {
+ console.error("Error reading from session storage", error);
+ return initialValue;
+ }
+ });
+
+ const clearValue = () => {
+ try {
+ sessionStorage.removeItem(sessionStorageKey);
+ setValue(initialValue);
+ } catch (error) {
+ console.error("Error clearing session storage", error);
+ }
+ };
+
+ useEffect(() => {
+ try {
+ sessionStorage.setItem(sessionStorageKey, JSON.stringify(value));
+ } catch (error) {
+ console.error("Error writing to session storage", error);
+ }
+ }, [sessionStorageKey, value]);
+
+ return [value, setValue, clearValue] as const;
+}
+
+export default useSessionStorage;