Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • improve dashboard performance, enrich charts, consolidate routes, remove older routes in favor of workspace metrics route, add paginated logs loading in executions dashboard.

Type of Change

  • Other: Improvement

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Oct 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 16, 2025 10:50pm

@waleedlatif1 waleedlatif1 merged commit 22f9d6e into staging Oct 16, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/dash branch October 16, 2025 22:53
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

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 finalOutput from executionData in 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
Loading

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant