-
Notifications
You must be signed in to change notification settings - Fork 3.3k
improvement(dashboard): improve dashboard performance, enrich charts, consolidate routes #1662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… consolidate routes
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR consolidates dashboard routes and significantly improves performance by replacing two legacy API endpoints with a single optimized metrics endpoint. The new /api/workspaces/[id]/metrics/executions route efficiently computes execution metrics including percentile-based duration analysis (p50/p90/p99) using in-memory bucketing instead of multiple database queries.
Key improvements:
- Consolidated route architecture eliminates redundant API calls and reduces code duplication
- Enhanced charts now display duration percentiles (p50/p90/p99) with interactive legend controls
- Added infinite scroll pagination for execution logs using IntersectionObserver with fallback
- Improved output display by extracting
finalOutputfromexecutionDatain logs API - Dynamic segment sizing based on viewport width optimizes chart rendering
Issues found:
- Two instances of
as any[]type assertions in the new metrics route violate TypeScript type safety guidelines (lines 57 and 83)
Confidence Score: 4/5
- Safe to merge with minor type safety issues that should be addressed
- The PR delivers solid performance improvements and feature enhancements with clean implementation. Score reduced from 5 to 4 due to two
as any[]type assertions that violate established TypeScript type safety guidelines. These are syntax issues rather than logical bugs, but should be fixed to maintain codebase standards. - apps/sim/app/api/workspaces/[id]/metrics/executions/route.ts - Fix type assertions at lines 57 and 83
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/workspaces/[id]/metrics/executions/route.ts | 5/5 | New consolidated metrics API endpoint replaces two older routes, efficiently computing percentile-based duration metrics (p50/p90/p99) alongside execution counts and success rates using in-memory bucketing |
| apps/sim/app/workspace/[workspaceId]/logs/executions-dashboard.tsx | 4/5 | Major refactor with updated API integration, infinite scroll for logs, dynamic segment sizing, enriched duration charts with percentiles (p50/p90/p99), and improved finalOutput extraction logic |
| apps/sim/app/workspace/[workspaceId]/logs/components/dashboard/line-chart.tsx | 5/5 | Enhanced chart component with multi-series support, interactive legend for toggling series visibility, improved hover interactions, and percentile line rendering with dashed styling |
| apps/sim/app/workspace/[workspaceId]/logs/components/dashboard/workflow-details.tsx | 5/5 | Added infinite scroll support using IntersectionObserver with scroll-based fallback, displays percentile duration charts (p50/p90/p99), and shows finalOutput in execution logs |
Sequence Diagram
sequenceDiagram
participant User
participant Dashboard as executions-dashboard.tsx
participant MetricsAPI as /api/workspaces/[id]/metrics/executions
participant LogsAPI as /api/logs
participant DB as Database
User->>Dashboard: Load dashboard
Dashboard->>MetricsAPI: GET (segments, timeRange, filters)
MetricsAPI->>DB: Query workflows by workspace/folder/ids
DB-->>MetricsAPI: Return workflows
MetricsAPI->>DB: Query execution logs (startedAt, level, duration)
DB-->>MetricsAPI: Return logs
MetricsAPI->>MetricsAPI: Bucket logs into time segments
MetricsAPI->>MetricsAPI: Calculate percentiles (p50/p90/p99)
MetricsAPI-->>Dashboard: Return metrics with segments
Dashboard->>LogsAPI: GET first 50 logs (offset=0, details=full)
LogsAPI->>DB: Query logs with executionData
DB-->>LogsAPI: Return detailed logs
LogsAPI->>LogsAPI: Extract finalOutput from executionData
LogsAPI-->>Dashboard: Return logs with finalOutput
Dashboard->>Dashboard: Render charts with percentile series
Dashboard->>Dashboard: Display initial logs
User->>Dashboard: Click workflow to expand
Dashboard->>LogsAPI: GET workflow-specific logs
LogsAPI->>DB: Query workflow logs
DB-->>LogsAPI: Return logs
LogsAPI-->>Dashboard: Return workflow logs
Dashboard->>Dashboard: Show workflow details with p50/p90/p99 charts
User->>Dashboard: Scroll to bottom of logs
Dashboard->>Dashboard: IntersectionObserver triggers
Dashboard->>LogsAPI: GET next 50 logs (offset=50)
LogsAPI->>DB: Query next batch
DB-->>LogsAPI: Return logs
LogsAPI-->>Dashboard: Return more logs
Dashboard->>Dashboard: Append logs to list
3 files reviewed, 2 comments
Summary
Type of Change
Testing
Tested manually
Checklist