Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Sep 3, 2025

Updates (#1237)

@vercel
Copy link

vercel bot commented Sep 3, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim (staging) Ready Ready Comment Sep 3, 2025 8:23pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 3, 2025 8:23pm

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 Summary

This PR implements a comprehensive fix for copilot statistics tracking by simplifying and centralizing the stats collection mechanism. The changes remove problematic early stats updates that were occurring at multiple points during workflow processing and consolidate stats tracking to only essential diff-related metrics.

The key changes include:

  1. Simplified API Schema: The /api/copilot/stats endpoint now only accepts three required fields (messageId, diffCreated, diffAccepted) instead of the previous complex schema with 11 optional fields including userId, chatId, duration, and token counts.

  2. Removed Premature Stats Updates: Early stats tracking has been eliminated from workflow building and editing tools that were sending stats immediately when diffs were created, before users had a chance to review changes.

  3. Centralized Stats Collection: Stats are now only sent when users explicitly accept or reject copilot suggestions in the workflow diff store, providing a cleaner user-action-driven analytics approach.

  4. Eliminated Redundant Parameters: The chatId parameter has been removed from client-side stats calls to align with the updated API contract.

These changes fit into the codebase's broader copilot system, which manages AI-generated workflow suggestions through a multi-store architecture. The copilot store handles message processing and API communication, while the workflow diff store manages the review and acceptance/rejection of proposed changes. By streamlining stats collection to focus only on the essential diff lifecycle events, this fix addresses reliability issues that were likely causing inconsistent or failed stats updates.

Confidence score: 4/5

  • This PR appears safe to merge with good confidence as it simplifies existing functionality rather than adding complex new features
  • Score reflects that this is primarily a bug fix that removes problematic code paths and consolidates stats tracking to a cleaner approach
  • Pay close attention to the API route changes and ensure upstream SIM agent API compatibility with the new simplified payload structure

5 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

const body = parsed.data as any

// Build outgoing payload for Sim Agent; do not include id
const { messageId, diffCreated, diffAccepted } = parsed.data as any
Copy link
Contributor

Choose a reason for hiding this comment

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

style: unnecessary type assertion since parsed.data is already typed from the Zod schema validation

Suggested change
const { messageId, diffCreated, diffAccepted } = parsed.data as any
const { messageId, diffCreated, diffAccepted } = parsed.data

@Sg312 Sg312 merged commit fce1423 into main Sep 3, 2025
15 checks passed
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