Skip to content

Commit 8df3f20

Browse files
authored
fix(blocks): allow tool expansion in disabled mode, improve child deploy badge freshness (#4002)
1 parent df2c47a commit 8df3f20

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function WorkflowToolDeployBadge({
210210
workflowId: string
211211
onDeploySuccess?: () => void
212212
}) {
213-
const { data, isLoading } = useDeploymentInfo(workflowId)
213+
const { data, isLoading } = useDeploymentInfo(workflowId, { refetchOnMount: 'always' })
214214
const { mutate, isPending: isDeploying } = useDeployWorkflow()
215215
const userPermissions = useUserPermissionsContext()
216216

@@ -1021,13 +1021,13 @@ export const ToolInput = memo(function ToolInput({
10211021
[isPreview, disabled, selectedTools, setStoreValue]
10221022
)
10231023

1024-
const [previewExpanded, setPreviewExpanded] = useState<Record<number, boolean>>({})
1024+
const [localExpanded, setLocalExpanded] = useState<Record<number, boolean>>({})
10251025

10261026
const toggleToolExpansion = (toolIndex: number) => {
1027-
if ((isPreview && !allowExpandInPreview) || disabled) return
1027+
if (isPreview && !allowExpandInPreview) return
10281028

1029-
if (isPreview) {
1030-
setPreviewExpanded((prev) => ({
1029+
if (isPreview || disabled) {
1030+
setLocalExpanded((prev) => ({
10311031
...prev,
10321032
[toolIndex]: !(prev[toolIndex] ?? !!selectedTools[toolIndex]?.isExpanded),
10331033
}))
@@ -1689,8 +1689,8 @@ export const ToolInput = memo(function ToolInput({
16891689
const hasToolBody = hasOperations || hasParams
16901690

16911691
const isExpandedForDisplay = hasToolBody
1692-
? isPreview
1693-
? (previewExpanded[toolIndex] ?? !!tool.isExpanded)
1692+
? isPreview || disabled
1693+
? (localExpanded[toolIndex] ?? !!tool.isExpanded)
16941694
: !!tool.isExpanded
16951695
: false
16961696

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/hooks/use-child-workflow.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export interface UseChildWorkflowReturn {
1111

1212
/**
1313
* Manages child workflow deployment status for workflow selector blocks.
14-
* Uses the shared useDeploymentInfo query (same source of truth as the
15-
* editor header's Deploy button) for consistent deployment detection.
14+
* Uses useDeploymentInfo which computes needsRedeployment server-side via
15+
* hasWorkflowChanged — the same comparison the deploy button uses — so the
16+
* badge stays aligned with the child workflow's Live/Update header.
1617
*/
1718
export function useChildWorkflow(
1819
blockId: string,
@@ -39,7 +40,8 @@ export function useChildWorkflow(
3940
}
4041

4142
const { data, isPending } = useDeploymentInfo(
42-
isWorkflowSelector ? (childWorkflowId ?? null) : null
43+
isWorkflowSelector ? (childWorkflowId ?? null) : null,
44+
{ refetchOnMount: 'always' }
4345
)
4446

4547
const childIsDeployed = data?.isDeployed ?? null

apps/sim/hooks/queries/deployments.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@ async function fetchDeploymentInfo(
8383
* Hook to fetch deployment info for a workflow.
8484
* Provides isDeployed status, deployedAt timestamp, apiKey info, and needsRedeployment flag.
8585
*/
86-
export function useDeploymentInfo(workflowId: string | null, options?: { enabled?: boolean }) {
86+
export function useDeploymentInfo(
87+
workflowId: string | null,
88+
options?: { enabled?: boolean; refetchOnMount?: boolean | 'always' }
89+
) {
8790
return useQuery({
8891
queryKey: deploymentKeys.info(workflowId),
8992
queryFn: ({ signal }) => fetchDeploymentInfo(workflowId!, signal),
9093
enabled: Boolean(workflowId) && (options?.enabled ?? true),
9194
staleTime: 30 * 1000, // 30 seconds
9295
placeholderData: keepPreviousData,
96+
...(options?.refetchOnMount !== undefined && { refetchOnMount: options.refetchOnMount }),
9397
})
9498
}
9599

0 commit comments

Comments
 (0)