Skip to content

Commit fbf7455

Browse files
committed
improvement: terminal expand, variables styling; refactor(float): hooks
1 parent 5756195 commit fbf7455

File tree

13 files changed

+87
-45
lines changed

13 files changed

+87
-45
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import {
2828
ChatMessage,
2929
OutputSelect,
3030
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components'
31-
import {
32-
useChatBoundarySync,
33-
useChatDrag,
34-
useChatFileUpload,
35-
useChatResize,
36-
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/chat/hooks'
31+
import { useChatFileUpload } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/chat/hooks'
3732
import { useScrollManagement } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
33+
import {
34+
useFloatBoundarySync,
35+
useFloatDrag,
36+
useFloatResize,
37+
} from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-float'
3838
import { useWorkflowExecution } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution'
3939
import type { BlockLog, ExecutionResult } from '@/executor/types'
4040
import { getChatPosition, useChatStore } from '@/stores/chat/store'
@@ -312,15 +312,15 @@ export function Chat() {
312312
)
313313

314314
// Drag hook
315-
const { handleMouseDown } = useChatDrag({
315+
const { handleMouseDown } = useFloatDrag({
316316
position: actualPosition,
317317
width: chatWidth,
318318
height: chatHeight,
319319
onPositionChange: setChatPosition,
320320
})
321321

322322
// Boundary sync hook - keeps chat within bounds when layout changes
323-
useChatBoundarySync({
323+
useFloatBoundarySync({
324324
isOpen: isChatOpen,
325325
position: actualPosition,
326326
width: chatWidth,
@@ -334,7 +334,7 @@ export function Chat() {
334334
handleMouseMove: handleResizeMouseMove,
335335
handleMouseLeave: handleResizeMouseLeave,
336336
handleMouseDown: handleResizeMouseDown,
337-
} = useChatResize({
337+
} = useFloatResize({
338338
position: actualPosition,
339339
width: chatWidth,
340340
height: chatHeight,
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
export { useChatBoundarySync } from './use-chat-boundary-sync'
2-
export { useChatDrag } from './use-chat-drag'
3-
export type { ChatFile } from './use-chat-file-upload'
4-
export { useChatFileUpload } from './use-chat-file-upload'
5-
export { useChatResize } from './use-chat-resize'
1+
export { type ChatFile, useChatFileUpload } from './use-chat-file-upload'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect } from 'react'
22
import { Input, Label } from '@/components/emcn'
33
import { getEmailDomain } from '@/lib/urls/utils'
44
import { cn } from '@/lib/utils'
5-
import { useIdentifierValidation } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/hooks/use-identifier-validation'
5+
import { useIdentifierValidation } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/hooks/use-identifier-validation'
66

77
interface IdentifierInputProps {
88
value: string

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/hooks/use-identifier-validation.ts renamed to apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/hooks/use-identifier-validation.ts

File renamed without changes.

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { useDeleteWorkflow, useImportWorkflow } from '@/app/workspace/[workspace
4343
import { useChatStore } from '@/stores/chat/store'
4444
import { usePanelStore } from '@/stores/panel/store'
4545
import type { PanelTab } from '@/stores/panel/types'
46-
import { DEFAULT_TERMINAL_HEIGHT, MIN_TERMINAL_HEIGHT, useTerminalStore } from '@/stores/terminal'
4746
import { useVariablesStore } from '@/stores/variables/store'
4847
import { useWorkflowJsonStore } from '@/stores/workflows/json/store'
4948
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
@@ -143,10 +142,6 @@ export function Panel() {
143142
openSubscriptionSettings()
144143
return
145144
}
146-
const { openOnRun, terminalHeight, setTerminalHeight } = useTerminalStore.getState()
147-
if (openOnRun && terminalHeight <= MIN_TERMINAL_HEIGHT) {
148-
setTerminalHeight(DEFAULT_TERMINAL_HEIGHT)
149-
}
150145
await handleRunWorkflow()
151146
}, [usageExceeded, handleRunWorkflow])
152147

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,23 @@ import {
1818
import { Label } from '@/components/emcn/components/label/label'
1919
import { Trash } from '@/components/emcn/icons/trash'
2020
import { cn, validateName } from '@/lib/utils'
21+
import {
22+
useFloatBoundarySync,
23+
useFloatDrag,
24+
useFloatResize,
25+
} from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
2126
import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
2227
import { useVariablesStore as usePanelVariablesStore } from '@/stores/panel/variables/store'
23-
import { getVariablesPosition, useVariablesStore } from '@/stores/variables/store'
28+
import {
29+
getVariablesPosition,
30+
MAX_VARIABLES_HEIGHT,
31+
MAX_VARIABLES_WIDTH,
32+
MIN_VARIABLES_HEIGHT,
33+
MIN_VARIABLES_WIDTH,
34+
useVariablesStore,
35+
} from '@/stores/variables/store'
2436
import type { Variable } from '@/stores/variables/types'
2537
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
26-
import { useChatBoundarySync, useChatDrag, useChatResize } from '../chat/hooks'
2738

2839
/**
2940
* Type options for variable type selection
@@ -41,7 +52,7 @@ const TYPE_OPTIONS: ComboboxOption[] = [
4152
*/
4253
const BADGE_HEIGHT = 20
4354
const BADGE_TEXT_SIZE = 13
44-
const ICON_SIZE = 14
55+
const ICON_SIZE = 13
4556
const HEADER_ICON_SIZE = 16
4657
const LINE_HEIGHT = 21
4758
const MIN_EDITOR_HEIGHT = 120
@@ -96,14 +107,14 @@ export function Variables() {
96107
[position, width, height]
97108
)
98109

99-
const { handleMouseDown } = useChatDrag({
110+
const { handleMouseDown } = useFloatDrag({
100111
position: actualPosition,
101112
width,
102113
height,
103114
onPositionChange: setPosition,
104115
})
105116

106-
useChatBoundarySync({
117+
useFloatBoundarySync({
107118
isOpen,
108119
position: actualPosition,
109120
width,
@@ -116,12 +127,16 @@ export function Variables() {
116127
handleMouseMove: handleResizeMouseMove,
117128
handleMouseLeave: handleResizeMouseLeave,
118129
handleMouseDown: handleResizeMouseDown,
119-
} = useChatResize({
130+
} = useFloatResize({
120131
position: actualPosition,
121132
width,
122133
height,
123134
onPositionChange: setPosition,
124135
onDimensionsChange: setDimensions,
136+
minWidth: MIN_VARIABLES_WIDTH,
137+
minHeight: MIN_VARIABLES_HEIGHT,
138+
maxWidth: MAX_VARIABLES_WIDTH,
139+
maxHeight: MAX_VARIABLES_HEIGHT,
125140
})
126141

127142
const [collapsedById, setCollapsedById] = useState<Record<string, boolean>>({})

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export { useAutoLayout } from './use-auto-layout'
22
export { useBlockCore } from './use-block-core'
33
export { BLOCK_DIMENSIONS, useBlockDimensions } from './use-block-dimensions'
44
export { type CurrentWorkflow, useCurrentWorkflow } from './use-current-workflow'
5+
export { useFloatBoundarySync, useFloatDrag, useFloatResize } from './use-float'
56
export { useNodeUtilities } from './use-node-utilities'
67
export { useScrollManagement } from './use-scroll-management'
78
export { useWorkflowExecution } from './use-workflow-execution'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { useFloatBoundarySync } from './use-float-boundary-sync'
2+
export { useFloatDrag } from './use-float-drag'
3+
export { useFloatResize } from './use-float-resize'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/hooks/use-chat-boundary-sync.ts renamed to apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-float/use-float-boundary-sync.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useEffect, useRef } from 'react'
22

3-
interface UseChatBoundarySyncProps {
3+
interface UseFloatBoundarySyncProps {
44
isOpen: boolean
55
position: { x: number; y: number }
66
width: number
@@ -9,17 +9,17 @@ interface UseChatBoundarySyncProps {
99
}
1010

1111
/**
12-
* Hook to synchronize chat position with layout boundary changes
13-
* Keeps chat within bounds when sidebar, panel, or terminal resize
12+
* Hook to synchronize floats position with layout boundary changes.
13+
* Keeps the float within bounds when sidebar, panel, or terminal resize.
1414
* Uses requestAnimationFrame for smooth real-time updates
1515
*/
16-
export function useChatBoundarySync({
16+
export function useFloatBoundarySync({
1717
isOpen,
1818
position,
1919
width,
2020
height,
2121
onPositionChange,
22-
}: UseChatBoundarySyncProps) {
22+
}: UseFloatBoundarySyncProps) {
2323
const rafIdRef = useRef<number | null>(null)
2424
const positionRef = useRef(position)
2525
const previousDimensionsRef = useRef({ sidebarWidth: 0, panelWidth: 0, terminalHeight: 0 })

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/hooks/use-chat-drag.ts renamed to apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-float/use-float-drag.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { useCallback, useEffect, useRef } from 'react'
22
import { constrainChatPosition } from '@/stores/chat/store'
33

4-
interface UseChatDragProps {
4+
interface UseFloatDragProps {
55
position: { x: number; y: number }
66
width: number
77
height: number
88
onPositionChange: (position: { x: number; y: number }) => void
99
}
1010

1111
/**
12-
* Hook for handling drag functionality of floating chat modal
12+
* Hook for handling drag functionality of floats.
1313
* Provides mouse event handlers and manages drag state
1414
*/
15-
export function useChatDrag({ position, width, height, onPositionChange }: UseChatDragProps) {
15+
export function useFloatDrag({ position, width, height, onPositionChange }: UseFloatDragProps) {
1616
const isDraggingRef = useRef(false)
1717
const dragStartRef = useRef({ x: 0, y: 0 })
1818
const initialPositionRef = useRef({ x: 0, y: 0 })

0 commit comments

Comments
 (0)