Skip to content

Comments

improvement(migration): move credential selector automigration logic to server side#3310

Merged
icecrasher321 merged 4 commits intostagingfrom
improvement/cred-migration
Feb 23, 2026
Merged

improvement(migration): move credential selector automigration logic to server side#3310
icecrasher321 merged 4 commits intostagingfrom
improvement/cred-migration

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Credentials will load in on workflow load effectively then instead of selector selection. And no workflow changes detected.

Type of Change

  • Other: UX 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 Feb 23, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 23, 2026 1:58pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Moved credential auto-migration from client to server side, eliminating false "workflow changes detected" warnings and improving UX.

  • Server-side migration now runs in loadWorkflowFromNormalizedTables and loadDeployedWorkflowState to automatically convert legacy account.id values to credential.id format
  • Removed client-side logic that previously called collaborativeSetSubblockValue when credentials loaded, which triggered workflow change detection
  • Migration persists to DB asynchronously without blocking workflow load
  • Handles both direct credential subblocks and nested credentials in agent tool arrays

Confidence Score: 4/5

  • Safe to merge with one logical issue that needs resolution
  • The migration logic is sound and the refactoring correctly moves auto-migration to the server. However, there is a logic bug in the migration function that always returns migrated: true even when no blocks were changed, which could cause unnecessary async work
  • Pay close attention to apps/sim/lib/workflows/persistence/utils.ts - verify the migration logic is correct and handles edge cases

Important Files Changed

Filename Overview
apps/sim/lib/workflows/persistence/utils.ts Added migrateCredentialIds function to auto-migrate legacy account.id to credential.id on workflow load, with fire-and-forget DB persistence
apps/sim/app/api/workflows/[id]/deployed/route.ts Refactored to use loadDeployedWorkflowState helper which now includes credential migration
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx Removed client-side auto-migration logic that called collaborativeSetSubblockValue when credential loaded

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as Deployed Workflow API
    participant Utils as persistence/utils
    participant DB as Database
    
    Client->>API: GET /api/workflows/[id]/deployed
    API->>Utils: loadDeployedWorkflowState(id)
    Utils->>DB: Fetch active deployment
    Utils->>DB: Fetch workspace ID
    Utils->>Utils: migrateCredentialIds(blocks)
    Utils->>DB: Query credentials by accountId
    Utils->>Utils: Map accountId → credentialId
    Utils-->>Utils: Fire-and-forget: persist migration
    Utils-->>API: Return migrated blocks
    API-->>Client: Return deployedState
    
    Note over Utils,DB: Async (non-blocking)
    Utils->>DB: Update workflowBlocks.subBlocks
Loading

Last reviewed commit: ff99fbe

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.

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@icecrasher321 icecrasher321 merged commit 2ae8145 into staging Feb 23, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/cred-migration branch February 23, 2026 19:55
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