mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
fix(blocks): allow tool expansion in disabled mode, improve child deploy badge freshness (#4002)
This commit is contained in:
@@ -210,7 +210,7 @@ function WorkflowToolDeployBadge({
|
||||
workflowId: string
|
||||
onDeploySuccess?: () => void
|
||||
}) {
|
||||
const { data, isLoading } = useDeploymentInfo(workflowId)
|
||||
const { data, isLoading } = useDeploymentInfo(workflowId, { refetchOnMount: 'always' })
|
||||
const { mutate, isPending: isDeploying } = useDeployWorkflow()
|
||||
const userPermissions = useUserPermissionsContext()
|
||||
|
||||
@@ -1021,13 +1021,13 @@ export const ToolInput = memo(function ToolInput({
|
||||
[isPreview, disabled, selectedTools, setStoreValue]
|
||||
)
|
||||
|
||||
const [previewExpanded, setPreviewExpanded] = useState<Record<number, boolean>>({})
|
||||
const [localExpanded, setLocalExpanded] = useState<Record<number, boolean>>({})
|
||||
|
||||
const toggleToolExpansion = (toolIndex: number) => {
|
||||
if ((isPreview && !allowExpandInPreview) || disabled) return
|
||||
if (isPreview && !allowExpandInPreview) return
|
||||
|
||||
if (isPreview) {
|
||||
setPreviewExpanded((prev) => ({
|
||||
if (isPreview || disabled) {
|
||||
setLocalExpanded((prev) => ({
|
||||
...prev,
|
||||
[toolIndex]: !(prev[toolIndex] ?? !!selectedTools[toolIndex]?.isExpanded),
|
||||
}))
|
||||
@@ -1689,8 +1689,8 @@ export const ToolInput = memo(function ToolInput({
|
||||
const hasToolBody = hasOperations || hasParams
|
||||
|
||||
const isExpandedForDisplay = hasToolBody
|
||||
? isPreview
|
||||
? (previewExpanded[toolIndex] ?? !!tool.isExpanded)
|
||||
? isPreview || disabled
|
||||
? (localExpanded[toolIndex] ?? !!tool.isExpanded)
|
||||
: !!tool.isExpanded
|
||||
: false
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ export interface UseChildWorkflowReturn {
|
||||
|
||||
/**
|
||||
* Manages child workflow deployment status for workflow selector blocks.
|
||||
* Uses the shared useDeploymentInfo query (same source of truth as the
|
||||
* editor header's Deploy button) for consistent deployment detection.
|
||||
* Uses useDeploymentInfo which computes needsRedeployment server-side via
|
||||
* hasWorkflowChanged — the same comparison the deploy button uses — so the
|
||||
* badge stays aligned with the child workflow's Live/Update header.
|
||||
*/
|
||||
export function useChildWorkflow(
|
||||
blockId: string,
|
||||
@@ -39,7 +40,8 @@ export function useChildWorkflow(
|
||||
}
|
||||
|
||||
const { data, isPending } = useDeploymentInfo(
|
||||
isWorkflowSelector ? (childWorkflowId ?? null) : null
|
||||
isWorkflowSelector ? (childWorkflowId ?? null) : null,
|
||||
{ refetchOnMount: 'always' }
|
||||
)
|
||||
|
||||
const childIsDeployed = data?.isDeployed ?? null
|
||||
|
||||
@@ -83,13 +83,17 @@ async function fetchDeploymentInfo(
|
||||
* Hook to fetch deployment info for a workflow.
|
||||
* Provides isDeployed status, deployedAt timestamp, apiKey info, and needsRedeployment flag.
|
||||
*/
|
||||
export function useDeploymentInfo(workflowId: string | null, options?: { enabled?: boolean }) {
|
||||
export function useDeploymentInfo(
|
||||
workflowId: string | null,
|
||||
options?: { enabled?: boolean; refetchOnMount?: boolean | 'always' }
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: deploymentKeys.info(workflowId),
|
||||
queryFn: ({ signal }) => fetchDeploymentInfo(workflowId!, signal),
|
||||
enabled: Boolean(workflowId) && (options?.enabled ?? true),
|
||||
staleTime: 30 * 1000, // 30 seconds
|
||||
placeholderData: keepPreviousData,
|
||||
...(options?.refetchOnMount !== undefined && { refetchOnMount: options.refetchOnMount }),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user