Skip to content

improvement(deployments): simplify deployments for chat and indicate active version#1730

Merged
icecrasher321 merged 12 commits intostagingfrom
improvement/deployment-ux
Oct 25, 2025
Merged

improvement(deployments): simplify deployments for chat and indicate active version#1730
icecrasher321 merged 12 commits intostagingfrom
improvement/deployment-ux

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Oct 25, 2025

Summary

  • Make the active version clear + not require API key for chat deployments.
  • Fix Qdrant

Type of Change

  • Bug fix

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 25, 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 25, 2025 11:53pm

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

Greptile Summary

This PR simplifies chat deployments by removing the API key requirement and automatically billing the workspace owner instead. A new centralized deployWorkflow() helper was introduced to handle deployment logic consistently across the codebase.

Key Changes

  • Chat deployments no longer require users to select an API key - workspace owner is automatically billed for usage
  • New deployWorkflow() helper in db-helpers.ts centralizes deployment logic (version management, API key pinning, telemetry)
  • Chat creation/update now auto-deploys the workflow to ensure the latest version is always active
  • Frontend removes pre-deployment step from chat creation flow
  • Version activation UI improved to show active version more clearly

Issues Found

  • Logic issue: Chat update continues even if workflow redeployment fails, potentially causing runtime errors if output configs reference non-existent blocks in the old deployed version (apps/sim/app/api/chat/manage/[id]/route.ts:138-152)
  • Style issue: Missing warning log when workspace lookup fails but execution continues with fallback user ID (apps/sim/app/api/chat/[identifier]/route.ts:113-124)

Confidence Score: 3/5

  • This PR has a logic issue that could cause runtime failures when chat updates fail to redeploy
  • Score reflects one critical logic issue where chat updates continue despite redeployment failures, which could cause runtime errors if the chat's output configs reference blocks that don't exist in the old deployed version. The billing logic change (workspace owner billing) appears sound but has minor error handling gaps. The refactoring to centralize deployment logic is well-executed.
  • Pay close attention to apps/sim/app/api/chat/manage/[id]/route.ts - the redeployment failure handling needs to be fixed before merge

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/api/chat/[identifier]/route.ts 4/5 Added workspace owner billing logic - chat execution now bills workspace owner instead of requiring API key. Added workspace import and query to resolve owner ID.
apps/sim/lib/workflows/db-helpers.ts 5/5 Added new deployWorkflow helper function to centralize deployment logic - creates deployment version, handles API key pinning, and tracks telemetry.
apps/sim/app/api/chat/route.ts 5/5 Chat creation now auto-deploys workflow using new deployWorkflow helper. Removed requirement for workflow to be pre-deployed.
apps/sim/app/api/chat/manage/[id]/route.ts 5/5 Chat updates now trigger workflow redeployment to ensure latest version is active.
apps/sim/app/api/workflows/[id]/deploy/route.ts 5/5 Refactored to use centralized deployWorkflow helper, reducing duplication. API key validation and telemetry tracking moved to helper function.

Sequence Diagram

sequenceDiagram
    participant User
    participant ChatUI as Chat Deploy UI
    participant ChatAPI as /api/chat (POST)
    participant DeployHelper as deployWorkflow()
    participant DB as Database
    participant ChatEndpoint as /api/chat/[identifier]
    participant WorkspaceOwner as Workspace Owner

    User->>ChatUI: Create/Update Chat Deployment
    ChatUI->>ChatAPI: POST chat config (no API key)
    
    Note over ChatAPI,DeployHelper: Auto-deploy workflow
    ChatAPI->>DeployHelper: deployWorkflow(workflowId, userId)
    DeployHelper->>DB: Load workflow from normalized tables
    DeployHelper->>DB: Create new deployment version
    DeployHelper->>DB: Set isActive=true, isDeployed=true
    DeployHelper-->>ChatAPI: { success: true, version: N }
    
    ChatAPI->>DB: Create/Update chat record
    ChatAPI-->>ChatUI: { chatUrl, success }
    ChatUI-->>User: Show success + chat URL
    
    Note over User,ChatEndpoint: External user accesses chat
    User->>ChatEndpoint: POST message to chat
    ChatEndpoint->>DB: Get chat + workflow details
    ChatEndpoint->>DB: Get workspace owner ID
    Note over ChatEndpoint,WorkspaceOwner: Bill workspace owner
    ChatEndpoint->>WorkspaceOwner: Execute workflow (executingUserId = ownerId)
    WorkspaceOwner-->>ChatEndpoint: Stream response
    ChatEndpoint-->>User: Return chat response
Loading

14 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 merged commit ad7b791 into staging Oct 25, 2025
9 checks passed
waleedlatif1 pushed a commit that referenced this pull request Oct 27, 2025
…active version (#1730)

* improvement(deployment-ux): deployment should indicate and make details configurable when activating previous version

* fix activation UI

* remove redundant code

* revert pulsing dot

* fix redeploy bug

* bill workspace owner for deployed chat

* deployed chat

* fix bugs

* fix tests, address greptile

* fix

* ui bug to load api key

* fix qdrant fetch tool
@waleedlatif1 waleedlatif1 deleted the improvement/deployment-ux branch October 30, 2025 06:22
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