mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-13 08:57:55 -05:00
Compare commits
26 Commits
fix/slack-
...
v0.5.58
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bf3d73ee6 | ||
|
|
6717ce89f4 | ||
|
|
7ffc11a738 | ||
|
|
be578e2ed7 | ||
|
|
f415e5edc4 | ||
|
|
13a6e6c3fa | ||
|
|
f5ab7f21ae | ||
|
|
bfb6fffe38 | ||
|
|
4fbec0a43f | ||
|
|
585f5e365b | ||
|
|
3792bdd252 | ||
|
|
eb5d1f3e5b | ||
|
|
54ab82c8dd | ||
|
|
f895bf469b | ||
|
|
dd3209af06 | ||
|
|
b6ba3b50a7 | ||
|
|
b304233062 | ||
|
|
57e4b49bd6 | ||
|
|
e12dd204ed | ||
|
|
3d9d9cbc54 | ||
|
|
0f4ec962ad | ||
|
|
4827866f9a | ||
|
|
3e697d9ed9 | ||
|
|
4431a1a484 | ||
|
|
4d1a9a3f22 | ||
|
|
eb07a080fb |
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ExternalLink, Users } from 'lucide-react'
|
||||
import { Button, Combobox } from '@/components/emcn/components'
|
||||
@@ -29,20 +29,6 @@ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
const logger = createLogger('CredentialSelector')
|
||||
const isBillingEnabled = isTruthy(getEnv('NEXT_PUBLIC_BILLING_ENABLED'))
|
||||
|
||||
function useStableCredentialIds(credentials: Array<{ id: string }>) {
|
||||
const knownIdsRef = useRef<Set<string>>(new Set())
|
||||
|
||||
for (const cred of credentials) {
|
||||
knownIdsRef.current.add(cred.id)
|
||||
}
|
||||
|
||||
const isKnownCredentialId = useCallback((id: string): boolean => {
|
||||
return knownIdsRef.current.has(id)
|
||||
}, [])
|
||||
|
||||
return { isKnownCredentialId }
|
||||
}
|
||||
|
||||
interface CredentialSelectorProps {
|
||||
blockId: string
|
||||
subBlock: SubBlockConfig
|
||||
@@ -106,8 +92,6 @@ export function CredentialSelector({
|
||||
refetch: refetchCredentials,
|
||||
} = useOAuthCredentials(effectiveProviderId, Boolean(effectiveProviderId))
|
||||
|
||||
const { isKnownCredentialId } = useStableCredentialIds(credentials)
|
||||
|
||||
const selectedCredential = useMemo(
|
||||
() => credentials.find((cred) => cred.id === selectedId),
|
||||
[credentials, selectedId]
|
||||
@@ -156,8 +140,7 @@ export function CredentialSelector({
|
||||
!selectedCredential &&
|
||||
!hasForeignMeta &&
|
||||
!credentialsLoading &&
|
||||
!foreignMetaLoading &&
|
||||
!isKnownCredentialId(selectedId)
|
||||
!foreignMetaLoading
|
||||
|
||||
useEffect(() => {
|
||||
if (!invalidSelection) return
|
||||
@@ -365,22 +348,10 @@ export function CredentialSelector({
|
||||
return
|
||||
}
|
||||
|
||||
if (isKnownCredentialId(value)) {
|
||||
handleSelect(value)
|
||||
return
|
||||
}
|
||||
|
||||
setIsEditing(true)
|
||||
setInputValue(value)
|
||||
},
|
||||
[
|
||||
credentials,
|
||||
credentialSets,
|
||||
handleAddCredential,
|
||||
handleSelect,
|
||||
handleCredentialSetSelect,
|
||||
isKnownCredentialId,
|
||||
]
|
||||
[credentials, credentialSets, handleAddCredential, handleSelect, handleCredentialSetSelect]
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -35,7 +35,6 @@ import { getDependsOnFields } from '@/blocks/utils'
|
||||
import { useKnowledgeBase } from '@/hooks/kb/use-knowledge'
|
||||
import { useMcpServers, useMcpToolsQuery } from '@/hooks/queries/mcp'
|
||||
import { useCredentialName } from '@/hooks/queries/oauth-credentials'
|
||||
import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
|
||||
import { useSelectorDisplayName } from '@/hooks/use-selector-display-name'
|
||||
import { useVariablesStore } from '@/stores/panel'
|
||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
@@ -613,34 +612,6 @@ export const WorkflowBlock = memo(function WorkflowBlock({
|
||||
[isDeploying, setDeploymentStatus, refetchDeployment]
|
||||
)
|
||||
|
||||
const { collaborativeSetSubblockValue } = useCollaborativeWorkflow()
|
||||
|
||||
/**
|
||||
* Clear credential-dependent fields when credential changes to prevent
|
||||
* stale data from persisting with new credentials.
|
||||
*/
|
||||
const prevCredRef = useRef<string | undefined>(undefined)
|
||||
useEffect(() => {
|
||||
const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
|
||||
if (!activeWorkflowId) return
|
||||
const current = useSubBlockStore.getState().workflowValues[activeWorkflowId]?.[id]
|
||||
if (!current) return
|
||||
const credValue = current.credential
|
||||
const cred =
|
||||
typeof credValue === 'object' && credValue !== null && 'value' in credValue
|
||||
? ((credValue as { value?: unknown }).value as string | undefined)
|
||||
: (credValue as string | undefined)
|
||||
if (prevCredRef.current !== cred) {
|
||||
const hadPreviousCredential = prevCredRef.current !== undefined
|
||||
prevCredRef.current = cred
|
||||
if (hadPreviousCredential) {
|
||||
const keys = Object.keys(current)
|
||||
const dependentKeys = keys.filter((k) => k !== 'credential')
|
||||
dependentKeys.forEach((k) => collaborativeSetSubblockValue(id, k, ''))
|
||||
}
|
||||
}
|
||||
}, [id, collaborativeSetSubblockValue])
|
||||
|
||||
const currentStoreBlock = currentWorkflow.getBlockById(id)
|
||||
|
||||
const isStarterBlock = type === 'starter'
|
||||
|
||||
Reference in New Issue
Block a user