mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fixed cred selector
This commit is contained in:
@@ -13,6 +13,7 @@ import type { BreadcrumbItem } from '@/app/workspace/[workspaceId]/components'
|
||||
import { ResourceHeader } from '@/app/workspace/[workspaceId]/components'
|
||||
import { useAgent, useDeleteAgent, useUpdateAgent } from '@/hooks/queries/agents'
|
||||
import { useInlineRename } from '@/hooks/use-inline-rename'
|
||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
|
||||
const logger = createLogger('AgentDetail')
|
||||
|
||||
@@ -37,6 +38,17 @@ export function AgentDetail({ agentId, workspaceId }: AgentDetailProps) {
|
||||
const saveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const isInitializedRef = useRef(false)
|
||||
|
||||
// SubBlockStore.setValue reads activeWorkflowId from the workflow registry and no-ops when null.
|
||||
// Set the agentId as the active "workflow" so tool sub-block params (credentials, etc.) persist.
|
||||
useEffect(() => {
|
||||
useWorkflowRegistry.setState({ activeWorkflowId: agentId })
|
||||
return () => {
|
||||
if (useWorkflowRegistry.getState().activeWorkflowId === agentId) {
|
||||
useWorkflowRegistry.setState({ activeWorkflowId: null })
|
||||
}
|
||||
}
|
||||
}, [agentId])
|
||||
|
||||
useEffect(() => {
|
||||
if (agent && !isInitializedRef.current) {
|
||||
setLocalConfig(agent.config ?? {})
|
||||
|
||||
@@ -51,7 +51,10 @@ export function CredentialSelector({
|
||||
const [showOAuthModal, setShowOAuthModal] = useState(false)
|
||||
const [editingValue, setEditingValue] = useState('')
|
||||
const [isEditing, setIsEditing] = useState(false)
|
||||
const { activeWorkflowId } = useWorkflowRegistry()
|
||||
const { activeWorkflowId, workflows } = useWorkflowRegistry()
|
||||
// Only pass workflowId when it's a real registered workflow (not an agent ID set as the active context)
|
||||
const effectiveWorkflowId =
|
||||
activeWorkflowId && workflows[activeWorkflowId] ? activeWorkflowId : undefined
|
||||
const [storeValue, setStoreValue] = useSubBlockValue<string | null>(blockId, subBlock.id)
|
||||
|
||||
const requiredScopes = subBlock.requiredScopes || []
|
||||
@@ -101,7 +104,7 @@ export function CredentialSelector({
|
||||
} = useOAuthCredentials(effectiveProviderId, {
|
||||
enabled: Boolean(effectiveProviderId),
|
||||
workspaceId,
|
||||
workflowId: activeWorkflowId || undefined,
|
||||
workflowId: effectiveWorkflowId,
|
||||
})
|
||||
|
||||
const selectedCredential = useMemo(
|
||||
|
||||
@@ -72,7 +72,10 @@ export function ToolCredentialSelector({
|
||||
const [showOAuthModal, setShowOAuthModal] = useState(false)
|
||||
const [editingInputValue, setEditingInputValue] = useState('')
|
||||
const [isEditing, setIsEditing] = useState(false)
|
||||
const { activeWorkflowId } = useWorkflowRegistry()
|
||||
const { activeWorkflowId, workflows } = useWorkflowRegistry()
|
||||
// Only pass workflowId when it's a real registered workflow (not an agent ID set as the active context)
|
||||
const effectiveWorkflowId =
|
||||
activeWorkflowId && workflows[activeWorkflowId] ? activeWorkflowId : undefined
|
||||
|
||||
const selectedId = value || ''
|
||||
const effectiveLabel = label || `Select ${getProviderName(provider)} account`
|
||||
@@ -86,7 +89,7 @@ export function ToolCredentialSelector({
|
||||
} = useOAuthCredentials(effectiveProviderId, {
|
||||
enabled: Boolean(effectiveProviderId),
|
||||
workspaceId,
|
||||
workflowId: activeWorkflowId || undefined,
|
||||
workflowId: effectiveWorkflowId,
|
||||
})
|
||||
|
||||
const selectedCredential = useMemo(
|
||||
|
||||
Reference in New Issue
Block a user