mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-28 00:08:21 -05:00
Compare commits
3 Commits
fix/timeou
...
staging
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d0209a108 | ||
|
|
500dcd4734 | ||
|
|
8bdba373c6 |
@@ -3,6 +3,7 @@ import { createLogger } from '@sim/logger'
|
||||
import { useReactFlow } from 'reactflow'
|
||||
import type { AutoLayoutOptions } from '@/app/workspace/[workspaceId]/w/[workflowId]/utils/auto-layout-utils'
|
||||
import { applyAutoLayoutAndUpdateStore as applyAutoLayoutStandalone } from '@/app/workspace/[workspaceId]/w/[workflowId]/utils/auto-layout-utils'
|
||||
import { useSnapToGridSize } from '@/hooks/queries/general-settings'
|
||||
import { useCanvasViewport } from '@/hooks/use-canvas-viewport'
|
||||
|
||||
export type { AutoLayoutOptions }
|
||||
@@ -13,21 +14,28 @@ const logger = createLogger('useAutoLayout')
|
||||
* Hook providing auto-layout functionality for workflows.
|
||||
* Binds workflowId context and provides memoized callback for React components.
|
||||
* Includes automatic fitView animation after successful layout.
|
||||
* Automatically uses the user's snap-to-grid setting for grid-aligned layout.
|
||||
*
|
||||
* Note: This hook requires a ReactFlowProvider ancestor.
|
||||
*/
|
||||
export function useAutoLayout(workflowId: string | null) {
|
||||
const reactFlowInstance = useReactFlow()
|
||||
const { fitViewToBounds } = useCanvasViewport(reactFlowInstance)
|
||||
const snapToGridSize = useSnapToGridSize()
|
||||
|
||||
const applyAutoLayoutAndUpdateStore = useCallback(
|
||||
async (options: AutoLayoutOptions = {}) => {
|
||||
if (!workflowId) {
|
||||
return { success: false, error: 'No workflow ID provided' }
|
||||
}
|
||||
return applyAutoLayoutStandalone(workflowId, options)
|
||||
// Include gridSize from user's snap-to-grid setting
|
||||
const optionsWithGrid: AutoLayoutOptions = {
|
||||
...options,
|
||||
gridSize: options.gridSize ?? (snapToGridSize > 0 ? snapToGridSize : undefined),
|
||||
}
|
||||
return applyAutoLayoutStandalone(workflowId, optionsWithGrid)
|
||||
},
|
||||
[workflowId]
|
||||
[workflowId, snapToGridSize]
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface AutoLayoutOptions {
|
||||
x?: number
|
||||
y?: number
|
||||
}
|
||||
gridSize?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,6 +63,7 @@ export async function applyAutoLayoutAndUpdateStore(
|
||||
x: options.padding?.x ?? DEFAULT_LAYOUT_PADDING.x,
|
||||
y: options.padding?.y ?? DEFAULT_LAYOUT_PADDING.y,
|
||||
},
|
||||
gridSize: options.gridSize,
|
||||
}
|
||||
|
||||
// Call the autolayout API route
|
||||
|
||||
@@ -8,7 +8,7 @@ const ivm = require('isolated-vm')
|
||||
const USER_CODE_START_LINE = 4
|
||||
const pendingFetches = new Map()
|
||||
let fetchIdCounter = 0
|
||||
const FETCH_TIMEOUT_MS = 30000
|
||||
const FETCH_TIMEOUT_MS = 300000 // 5 minutes
|
||||
|
||||
/**
|
||||
* Extract line and column from error stack or message
|
||||
|
||||
@@ -516,7 +516,7 @@ export const openRouterProvider: ProviderConfig = {
|
||||
return streamingResult as StreamingExecution
|
||||
}
|
||||
|
||||
if (request.responseFormat && hasActiveTools && toolCalls.length > 0) {
|
||||
if (request.responseFormat && hasActiveTools) {
|
||||
const finalPayload: any = {
|
||||
model: payload.model,
|
||||
messages: [...currentMessages],
|
||||
|
||||
@@ -253,23 +253,6 @@ describe('executeTool Function', () => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('should handle errors from tools', async () => {
|
||||
setupFetchMock({ status: 400, ok: false, json: { error: 'Bad request' } })
|
||||
|
||||
const result = await executeTool(
|
||||
'http_request',
|
||||
{
|
||||
url: 'https://api.example.com/data',
|
||||
method: 'GET',
|
||||
},
|
||||
true
|
||||
)
|
||||
|
||||
expect(result.success).toBe(false)
|
||||
expect(result.error).toBeDefined()
|
||||
expect(result.timing).toBeDefined()
|
||||
})
|
||||
|
||||
it('should add timing information to results', async () => {
|
||||
const result = await executeTool(
|
||||
'http_request',
|
||||
|
||||
Reference in New Issue
Block a user