Skip to content

Commit e707653

Browse files
committed
improvement: blocks, preview, avatars
1 parent fb57c1d commit e707653

File tree

9 files changed

+57
-103
lines changed

9 files changed

+57
-103
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/general/general.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ export function GeneralDeploy({
334334
}}
335335
onPaneClick={() => setExpandedSelectedBlockId(null)}
336336
selectedBlockId={expandedSelectedBlockId}
337-
lightweight
338337
/>
339338
</div>
340339
{expandedSelectedBlockId && workflowToShow.blocks?.[expandedSelectedBlockId] && (

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/connections/connections.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export { ActionBar } from './action-bar/action-bar'
2-
export { Connections } from './connections/connections'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import { getBaseUrl } from '@/lib/core/utils/urls'
99
import { createMcpToolId } from '@/lib/mcp/utils'
1010
import { getProviderIdFromServiceId } from '@/lib/oauth'
1111
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
12-
import {
13-
ActionBar,
14-
Connections,
15-
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components'
12+
import { ActionBar } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components'
1613
import {
1714
useBlockProperties,
1815
useChildWorkflow,
@@ -934,8 +931,6 @@ export const WorkflowBlock = memo(function WorkflowBlock({
934931
<ActionBar blockId={id} blockType={type} disabled={!userPermissions.canEdit} />
935932
)}
936933

937-
{shouldShowDefaultHandles && <Connections blockId={id} />}
938-
939934
{shouldShowDefaultHandles && (
940935
<Handle
941936
type='target'

apps/sim/app/workspace/[workspaceId]/w/components/preview/components/block-details-sidebar.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,11 +1156,6 @@ function BlockDetailsSidebarContent({
11561156
<span className='min-w-0 flex-1 truncate font-medium text-[14px] text-[var(--text-primary)]'>
11571157
{block.name || blockConfig.name}
11581158
</span>
1159-
{block.enabled === false && (
1160-
<Badge variant='red' size='sm'>
1161-
Disabled
1162-
</Badge>
1163-
)}
11641159
{onClose && (
11651160
<Button variant='ghost' className='!p-[4px] flex-shrink-0' onClick={onClose}>
11661161
<X className='h-[14px] w-[14px]' />

apps/sim/app/workspace/[workspaceId]/w/components/preview/preview.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,18 @@ interface FitViewOnChangeProps {
181181
*/
182182
function FitViewOnChange({ nodeIds, fitPadding }: FitViewOnChangeProps) {
183183
const { fitView } = useReactFlow()
184-
const hasFittedRef = useRef(false)
184+
const lastNodeIdsRef = useRef<string | null>(null)
185185

186186
useEffect(() => {
187-
if (nodeIds.length > 0 && !hasFittedRef.current) {
188-
hasFittedRef.current = true
189-
// Small delay to ensure nodes are rendered before fitting
190-
const timeoutId = setTimeout(() => {
191-
fitView({ padding: fitPadding, duration: 200 })
192-
}, 50)
193-
return () => clearTimeout(timeoutId)
194-
}
187+
if (!nodeIds.length) return
188+
const shouldFit = lastNodeIdsRef.current !== nodeIds
189+
if (!shouldFit) return
190+
lastNodeIdsRef.current = nodeIds
191+
192+
const timeoutId = setTimeout(() => {
193+
fitView({ padding: fitPadding, duration: 200 })
194+
}, 50)
195+
return () => clearTimeout(timeoutId)
195196
}, [nodeIds, fitPadding, fitView])
196197

197198
return null

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/folder-item/folder-item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export function FolderItem({
342342
spellCheck='false'
343343
/>
344344
) : (
345-
<>
345+
<div className='flex min-w-0 flex-1 items-center gap-[8px]'>
346346
<span
347347
className='min-w-0 flex-1 truncate font-medium text-[var(--text-tertiary)] group-hover:text-[var(--text-primary)]'
348348
onDoubleClick={handleDoubleClick}
@@ -357,7 +357,7 @@ export function FolderItem({
357357
>
358358
<MoreHorizontal className='h-[14px] w-[14px] text-[var(--text-tertiary)]' />
359359
</button>
360-
</>
360+
</div>
361361
)}
362362
</div>
363363

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/workflow-item/avatars/avatars.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { type CSSProperties, useEffect, useMemo } from 'react'
3+
import { type CSSProperties, useMemo } from 'react'
44
import { Avatar, AvatarFallback, AvatarImage, Tooltip } from '@/components/emcn'
55
import { useSession } from '@/lib/auth/auth-client'
66
import { getUserColor } from '@/lib/workspaces/colors'
@@ -19,11 +19,6 @@ const AVATAR_CONFIG = {
1919

2020
interface AvatarsProps {
2121
workflowId: string
22-
/**
23-
* Callback fired when the presence visibility changes.
24-
* Used by parent components to adjust layout (e.g., text truncation spacing).
25-
*/
26-
onPresenceChange?: (hasAvatars: boolean) => void
2722
}
2823

2924
interface PresenceUser {
@@ -85,7 +80,7 @@ function UserAvatar({ user, index }: UserAvatarProps) {
8580
* @param props - Component props
8681
* @returns Avatar stack for workflow presence
8782
*/
88-
export function Avatars({ workflowId, onPresenceChange }: AvatarsProps) {
83+
export function Avatars({ workflowId }: AvatarsProps) {
8984
const { presenceUsers, currentWorkflowId } = useSocket()
9085
const { data: session } = useSession()
9186
const currentUserId = session?.user?.id
@@ -127,19 +122,12 @@ export function Avatars({ workflowId, onPresenceChange }: AvatarsProps) {
127122
return { visibleUsers: visible, overflowCount: overflow }
128123
}, [workflowUsers, maxVisible])
129124

130-
useEffect(() => {
131-
const hasAnyAvatars = visibleUsers.length > 0
132-
if (typeof onPresenceChange === 'function') {
133-
onPresenceChange(hasAnyAvatars)
134-
}
135-
}, [visibleUsers, onPresenceChange])
136-
137125
if (visibleUsers.length === 0) {
138126
return null
139127
}
140128

141129
return (
142-
<div className='-space-x-1 flex items-center'>
130+
<div className='-space-x-1 flex flex-shrink-0 items-center'>
143131
{overflowCount > 0 && (
144132
<Tooltip.Root>
145133
<Tooltip.Trigger asChild>

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/workflow-item/workflow-item.tsx

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ export function WorkflowItem({
6464
const [deleteModalNames, setDeleteModalNames] = useState<string | string[]>('')
6565
const [canDeleteCaptured, setCanDeleteCaptured] = useState(true)
6666

67-
const [hasAvatars, setHasAvatars] = useState(false)
68-
6967
const capturedSelectionRef = useRef<{
7068
workflowIds: string[]
7169
workflowNames: string | string[]
@@ -319,48 +317,50 @@ export function WorkflowItem({
319317
className='h-[14px] w-[14px] flex-shrink-0 rounded-[4px]'
320318
style={{ backgroundColor: workflow.color }}
321319
/>
322-
<div className={clsx('min-w-0 flex-1', hasAvatars && 'pr-[8px]')}>
323-
{isEditing ? (
324-
<input
325-
ref={inputRef}
326-
value={editValue}
327-
onChange={(e) => setEditValue(e.target.value)}
328-
onKeyDown={handleKeyDown}
329-
onBlur={handleInputBlur}
330-
className={clsx(
331-
'w-full border-0 bg-transparent p-0 font-medium text-[14px] outline-none focus:outline-none focus:ring-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0',
332-
active
333-
? 'text-[var(--text-primary)]'
334-
: 'text-[var(--text-tertiary)] group-hover:text-[var(--text-primary)]'
335-
)}
336-
maxLength={100}
337-
disabled={isRenaming}
338-
onClick={(e) => {
339-
e.preventDefault()
340-
e.stopPropagation()
341-
}}
342-
autoComplete='off'
343-
autoCorrect='off'
344-
autoCapitalize='off'
345-
spellCheck='false'
346-
/>
347-
) : (
348-
<div
349-
className={clsx(
350-
'truncate font-medium',
351-
active
352-
? 'text-[var(--text-primary)]'
353-
: 'text-[var(--text-tertiary)] group-hover:text-[var(--text-primary)]'
354-
)}
355-
onDoubleClick={handleDoubleClick}
356-
>
357-
{workflow.name}
358-
</div>
359-
)}
320+
<div className='min-w-0 flex-1'>
321+
<div className='flex min-w-0 items-center gap-[8px]'>
322+
{isEditing ? (
323+
<input
324+
ref={inputRef}
325+
value={editValue}
326+
onChange={(e) => setEditValue(e.target.value)}
327+
onKeyDown={handleKeyDown}
328+
onBlur={handleInputBlur}
329+
className={clsx(
330+
'w-full min-w-0 border-0 bg-transparent p-0 font-medium text-[14px] outline-none focus:outline-none focus:ring-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0',
331+
active
332+
? 'text-[var(--text-primary)]'
333+
: 'text-[var(--text-tertiary)] group-hover:text-[var(--text-primary)]'
334+
)}
335+
maxLength={100}
336+
disabled={isRenaming}
337+
onClick={(e) => {
338+
e.preventDefault()
339+
e.stopPropagation()
340+
}}
341+
autoComplete='off'
342+
autoCorrect='off'
343+
autoCapitalize='off'
344+
spellCheck='false'
345+
/>
346+
) : (
347+
<div
348+
className={clsx(
349+
'min-w-0 flex-1 truncate font-medium',
350+
active
351+
? 'text-[var(--text-primary)]'
352+
: 'text-[var(--text-tertiary)] group-hover:text-[var(--text-primary)]'
353+
)}
354+
onDoubleClick={handleDoubleClick}
355+
>
356+
{workflow.name}
357+
</div>
358+
)}
359+
{!isEditing && <Avatars workflowId={workflow.id} />}
360+
</div>
360361
</div>
361362
{!isEditing && (
362363
<>
363-
<Avatars workflowId={workflow.id} onPresenceChange={setHasAvatars} />
364364
<button
365365
type='button'
366366
onPointerDown={handleMorePointerDown}

0 commit comments

Comments
 (0)