Skip to content

Commit 7086b63

Browse files
committed
prevent unintended cascade by depends on during migration
1 parent 16d6412 commit 7086b63

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { useCredentialSets } from '@/hooks/queries/credential-sets'
2424
import { useOAuthCredentials } from '@/hooks/queries/oauth-credentials'
2525
import { useOrganizations } from '@/hooks/queries/organization'
2626
import { useSubscriptionData } from '@/hooks/queries/subscription'
27+
import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
2728
import { useCredentialRefreshTriggers } from '@/hooks/use-credential-refresh-triggers'
2829
import { getMissingRequiredScopes } from '@/hooks/use-oauth-scope-status'
2930
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
@@ -54,6 +55,7 @@ export function CredentialSelector({
5455
const [isEditing, setIsEditing] = useState(false)
5556
const { activeWorkflowId } = useWorkflowRegistry()
5657
const [storeValue, setStoreValue] = useSubBlockValue<string | null>(blockId, subBlock.id)
58+
const { collaborativeSetSubblockValue } = useCollaborativeWorkflow()
5759

5860
const requiredScopes = subBlock.requiredScopes || []
5961
const label = subBlock.placeholder || 'Select credential'
@@ -135,7 +137,9 @@ export function CredentialSelector({
135137
const data = await response.json()
136138
if (!cancelled && data.credential?.displayName) {
137139
if (data.credential.id !== selectedId) {
138-
setStoreValue(data.credential.id)
140+
collaborativeSetSubblockValue(blockId, subBlock.id, data.credential.id, {
141+
skipDependsOn: true,
142+
})
139143
}
140144
setInaccessibleCredentialName(data.credential.displayName)
141145
}

apps/sim/hooks/use-collaborative-workflow.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,12 @@ export function useCollaborativeWorkflow() {
12321232
)
12331233

12341234
const collaborativeSetSubblockValue = useCallback(
1235-
(blockId: string, subblockId: string, value: any, options?: { _visited?: Set<string> }) => {
1235+
(
1236+
blockId: string,
1237+
subblockId: string,
1238+
value: any,
1239+
options?: { _visited?: Set<string>; skipDependsOn?: boolean }
1240+
) => {
12361241
if (isApplyingRemoteChange.current) return
12371242

12381243
if (isBaselineDiffView) {
@@ -1258,6 +1263,8 @@ export function useCollaborativeWorkflow() {
12581263
})
12591264
}
12601265

1266+
if (options?.skipDependsOn) return
1267+
12611268
// Handle dependent subblock clearing (recursive calls)
12621269
try {
12631270
const visited = options?._visited || new Set<string>()

0 commit comments

Comments
 (0)