mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-15 08:55:05 -05:00
Compare commits
6 Commits
v0.5.89
...
fix/logs-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca0105aceb | ||
|
|
9f98f59cc7 | ||
|
|
11b46bff62 | ||
|
|
363ee594fd | ||
|
|
72d613e92a | ||
|
|
3ef6b05035 |
@@ -1,2 +1,2 @@
|
|||||||
export type { StatusBarSegment } from './status-bar'
|
export type { StatusBarSegment } from './status-bar'
|
||||||
export { default, StatusBar } from './status-bar'
|
export { StatusBar } from './status-bar'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export interface StatusBarSegment {
|
|||||||
timestamp: string
|
timestamp: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StatusBar({
|
function StatusBarInner({
|
||||||
segments,
|
segments,
|
||||||
selectedSegmentIndices,
|
selectedSegmentIndices,
|
||||||
onSegmentClick,
|
onSegmentClick,
|
||||||
@@ -127,4 +127,45 @@ export function StatusBar({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(StatusBar)
|
/**
|
||||||
|
* Custom equality function for StatusBar memo.
|
||||||
|
* Performs structural comparison of segments array to avoid re-renders
|
||||||
|
* when poll data returns new object references with identical content.
|
||||||
|
*/
|
||||||
|
function areStatusBarPropsEqual(
|
||||||
|
prev: Parameters<typeof StatusBarInner>[0],
|
||||||
|
next: Parameters<typeof StatusBarInner>[0]
|
||||||
|
): boolean {
|
||||||
|
if (prev.workflowId !== next.workflowId) return false
|
||||||
|
if (prev.segmentDurationMs !== next.segmentDurationMs) return false
|
||||||
|
if (prev.preferBelow !== next.preferBelow) return false
|
||||||
|
|
||||||
|
if (prev.selectedSegmentIndices !== next.selectedSegmentIndices) {
|
||||||
|
if (!prev.selectedSegmentIndices || !next.selectedSegmentIndices) return false
|
||||||
|
if (prev.selectedSegmentIndices.length !== next.selectedSegmentIndices.length) return false
|
||||||
|
for (let i = 0; i < prev.selectedSegmentIndices.length; i++) {
|
||||||
|
if (prev.selectedSegmentIndices[i] !== next.selectedSegmentIndices[i]) return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev.segments !== next.segments) {
|
||||||
|
if (prev.segments.length !== next.segments.length) return false
|
||||||
|
for (let i = 0; i < prev.segments.length; i++) {
|
||||||
|
const ps = prev.segments[i]
|
||||||
|
const ns = next.segments[i]
|
||||||
|
if (
|
||||||
|
ps.successRate !== ns.successRate ||
|
||||||
|
ps.hasExecutions !== ns.hasExecutions ||
|
||||||
|
ps.totalExecutions !== ns.totalExecutions ||
|
||||||
|
ps.successfulExecutions !== ns.successfulExecutions ||
|
||||||
|
ps.timestamp !== ns.timestamp
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StatusBar = memo(StatusBarInner, areStatusBarPropsEqual)
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export type { WorkflowExecutionItem } from './workflows-list'
|
export type { WorkflowExecutionItem } from './workflows-list'
|
||||||
export { default, WorkflowsList } from './workflows-list'
|
export { WorkflowsList } from './workflows-list'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface WorkflowExecutionItem {
|
|||||||
overallSuccessRate: number
|
overallSuccessRate: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function WorkflowsList({
|
function WorkflowsListInner({
|
||||||
filteredExecutions,
|
filteredExecutions,
|
||||||
expandedWorkflowId,
|
expandedWorkflowId,
|
||||||
onToggleWorkflow,
|
onToggleWorkflow,
|
||||||
@@ -103,7 +103,7 @@ export function WorkflowsList({
|
|||||||
<StatusBar
|
<StatusBar
|
||||||
segments={workflow.segments}
|
segments={workflow.segments}
|
||||||
selectedSegmentIndices={selectedSegments[workflow.workflowId] || null}
|
selectedSegmentIndices={selectedSegments[workflow.workflowId] || null}
|
||||||
onSegmentClick={onSegmentClick as any}
|
onSegmentClick={onSegmentClick}
|
||||||
workflowId={workflow.workflowId}
|
workflowId={workflow.workflowId}
|
||||||
segmentDurationMs={segmentDurationMs}
|
segmentDurationMs={segmentDurationMs}
|
||||||
preferBelow={idx < 2}
|
preferBelow={idx < 2}
|
||||||
@@ -124,4 +124,4 @@ export function WorkflowsList({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(WorkflowsList)
|
export const WorkflowsList = memo(WorkflowsListInner)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { Loader2 } from 'lucide-react'
|
import { Loader2 } from 'lucide-react'
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
import { formatLatency } from '@/app/workspace/[workspaceId]/logs/utils'
|
import { formatLatency } from '@/app/workspace/[workspaceId]/logs/utils'
|
||||||
@@ -141,10 +141,10 @@ function toWorkflowExecution(wf: WorkflowStats): WorkflowExecution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Dashboard({ stats, isLoading, error }: DashboardProps) {
|
function DashboardInner({ stats, isLoading, error }: DashboardProps) {
|
||||||
const [selectedSegments, setSelectedSegments] = useState<Record<string, number[]>>({})
|
const [selectedSegments, setSelectedSegments] = useState<Record<string, number[]>>({})
|
||||||
const [lastAnchorIndices, setLastAnchorIndices] = useState<Record<string, number>>({})
|
const [lastAnchorIndices, setLastAnchorIndices] = useState<Record<string, number>>({})
|
||||||
const barsAreaRef = useRef<HTMLDivElement | null>(null)
|
const lastAnchorIndicesRef = useRef<Record<string, number>>({})
|
||||||
|
|
||||||
const { workflowIds, searchQuery, toggleWorkflowId, timeRange } = useFilterStore()
|
const { workflowIds, searchQuery, toggleWorkflowId, timeRange } = useFilterStore()
|
||||||
|
|
||||||
@@ -152,20 +152,79 @@ export default function Dashboard({ stats, isLoading, error }: DashboardProps) {
|
|||||||
|
|
||||||
const expandedWorkflowId = workflowIds.length === 1 ? workflowIds[0] : null
|
const expandedWorkflowId = workflowIds.length === 1 ? workflowIds[0] : null
|
||||||
|
|
||||||
const { executions, aggregateSegments, segmentMs } = useMemo(() => {
|
const { rawExecutions, aggregateSegments, segmentMs } = useMemo(() => {
|
||||||
if (!stats) {
|
if (!stats) {
|
||||||
return { executions: [], aggregateSegments: [], segmentMs: 0 }
|
return { rawExecutions: [], aggregateSegments: [], segmentMs: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
const workflowExecutions = stats.workflows.map(toWorkflowExecution)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
executions: workflowExecutions,
|
rawExecutions: stats.workflows.map(toWorkflowExecution),
|
||||||
aggregateSegments: stats.aggregateSegments,
|
aggregateSegments: stats.aggregateSegments,
|
||||||
segmentMs: stats.segmentMs,
|
segmentMs: stats.segmentMs,
|
||||||
}
|
}
|
||||||
}, [stats])
|
}, [stats])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stabilize execution objects: reuse previous references for workflows
|
||||||
|
* whose segment data hasn't structurally changed between polls.
|
||||||
|
* This prevents cascading re-renders through WorkflowsList → StatusBar.
|
||||||
|
*/
|
||||||
|
const prevExecutionsRef = useRef<WorkflowExecution[]>([])
|
||||||
|
|
||||||
|
const executions = useMemo(() => {
|
||||||
|
const prevMap = new Map(prevExecutionsRef.current.map((e) => [e.workflowId, e]))
|
||||||
|
let anyChanged = false
|
||||||
|
|
||||||
|
const result = rawExecutions.map((exec) => {
|
||||||
|
const prev = prevMap.get(exec.workflowId)
|
||||||
|
if (!prev) {
|
||||||
|
anyChanged = true
|
||||||
|
return exec
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
prev.overallSuccessRate !== exec.overallSuccessRate ||
|
||||||
|
prev.workflowName !== exec.workflowName ||
|
||||||
|
prev.segments.length !== exec.segments.length
|
||||||
|
) {
|
||||||
|
anyChanged = true
|
||||||
|
return exec
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < prev.segments.length; i++) {
|
||||||
|
const ps = prev.segments[i]
|
||||||
|
const ns = exec.segments[i]
|
||||||
|
if (
|
||||||
|
ps.totalExecutions !== ns.totalExecutions ||
|
||||||
|
ps.successfulExecutions !== ns.successfulExecutions ||
|
||||||
|
ps.timestamp !== ns.timestamp ||
|
||||||
|
ps.avgDurationMs !== ns.avgDurationMs ||
|
||||||
|
ps.p50Ms !== ns.p50Ms ||
|
||||||
|
ps.p90Ms !== ns.p90Ms ||
|
||||||
|
ps.p99Ms !== ns.p99Ms
|
||||||
|
) {
|
||||||
|
anyChanged = true
|
||||||
|
return exec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return prev
|
||||||
|
})
|
||||||
|
|
||||||
|
if (
|
||||||
|
!anyChanged &&
|
||||||
|
result.length === prevExecutionsRef.current.length &&
|
||||||
|
result.every((r, i) => r === prevExecutionsRef.current[i])
|
||||||
|
) {
|
||||||
|
return prevExecutionsRef.current
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}, [rawExecutions])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
prevExecutionsRef.current = executions
|
||||||
|
}, [executions])
|
||||||
|
|
||||||
const lastExecutionByWorkflow = useMemo(() => {
|
const lastExecutionByWorkflow = useMemo(() => {
|
||||||
const map = new Map<string, number>()
|
const map = new Map<string, number>()
|
||||||
for (const wf of executions) {
|
for (const wf of executions) {
|
||||||
@@ -312,6 +371,8 @@ export default function Dashboard({ stats, isLoading, error }: DashboardProps) {
|
|||||||
[toggleWorkflowId]
|
[toggleWorkflowId]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
lastAnchorIndicesRef.current = lastAnchorIndices
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles segment click for selecting time segments.
|
* Handles segment click for selecting time segments.
|
||||||
* @param workflowId - The workflow containing the segment
|
* @param workflowId - The workflow containing the segment
|
||||||
@@ -361,7 +422,7 @@ export default function Dashboard({ stats, isLoading, error }: DashboardProps) {
|
|||||||
} else if (mode === 'range') {
|
} else if (mode === 'range') {
|
||||||
setSelectedSegments((prev) => {
|
setSelectedSegments((prev) => {
|
||||||
const currentSegments = prev[workflowId] || []
|
const currentSegments = prev[workflowId] || []
|
||||||
const anchor = lastAnchorIndices[workflowId] ?? segmentIndex
|
const anchor = lastAnchorIndicesRef.current[workflowId] ?? segmentIndex
|
||||||
const [start, end] =
|
const [start, end] =
|
||||||
anchor < segmentIndex ? [anchor, segmentIndex] : [segmentIndex, anchor]
|
anchor < segmentIndex ? [anchor, segmentIndex] : [segmentIndex, anchor]
|
||||||
const range = Array.from({ length: end - start + 1 }, (_, i) => start + i)
|
const range = Array.from({ length: end - start + 1 }, (_, i) => start + i)
|
||||||
@@ -370,12 +431,12 @@ export default function Dashboard({ stats, isLoading, error }: DashboardProps) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[lastAnchorIndices]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedSegments({})
|
setSelectedSegments((prev) => (Object.keys(prev).length > 0 ? {} : prev))
|
||||||
setLastAnchorIndices({})
|
setLastAnchorIndices((prev) => (Object.keys(prev).length > 0 ? {} : prev))
|
||||||
}, [stats, timeRange, workflowIds, searchQuery])
|
}, [stats, timeRange, workflowIds, searchQuery])
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -493,7 +554,7 @@ export default function Dashboard({ stats, isLoading, error }: DashboardProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='min-h-0 flex-1 overflow-hidden' ref={barsAreaRef}>
|
<div className='min-h-0 flex-1 overflow-hidden'>
|
||||||
<WorkflowsList
|
<WorkflowsList
|
||||||
filteredExecutions={filteredExecutions as WorkflowExecution[]}
|
filteredExecutions={filteredExecutions as WorkflowExecution[]}
|
||||||
expandedWorkflowId={expandedWorkflowId}
|
expandedWorkflowId={expandedWorkflowId}
|
||||||
@@ -507,3 +568,5 @@ export default function Dashboard({ stats, isLoading, error }: DashboardProps) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default memo(DashboardInner)
|
||||||
|
|||||||
@@ -43,11 +43,12 @@ import { useLogDetailsUIStore } from '@/stores/logs/store'
|
|||||||
/**
|
/**
|
||||||
* Workflow Output section with code viewer, copy, search, and context menu functionality
|
* Workflow Output section with code viewer, copy, search, and context menu functionality
|
||||||
*/
|
*/
|
||||||
function WorkflowOutputSection({ output }: { output: Record<string, unknown> }) {
|
const WorkflowOutputSection = memo(
|
||||||
|
function WorkflowOutputSection({ output }: { output: Record<string, unknown> }) {
|
||||||
const contentRef = useRef<HTMLDivElement>(null)
|
const contentRef = useRef<HTMLDivElement>(null)
|
||||||
const [copied, setCopied] = useState(false)
|
const [copied, setCopied] = useState(false)
|
||||||
|
const copyTimerRef = useRef<number | null>(null)
|
||||||
|
|
||||||
// Context menu state
|
|
||||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
||||||
const [contextMenuPosition, setContextMenuPosition] = useState({ x: 0, y: 0 })
|
const [contextMenuPosition, setContextMenuPosition] = useState({ x: 0, y: 0 })
|
||||||
|
|
||||||
@@ -81,10 +82,17 @@ function WorkflowOutputSection({ output }: { output: Record<string, unknown> })
|
|||||||
const handleCopy = useCallback(() => {
|
const handleCopy = useCallback(() => {
|
||||||
navigator.clipboard.writeText(jsonString)
|
navigator.clipboard.writeText(jsonString)
|
||||||
setCopied(true)
|
setCopied(true)
|
||||||
setTimeout(() => setCopied(false), 1500)
|
if (copyTimerRef.current !== null) window.clearTimeout(copyTimerRef.current)
|
||||||
|
copyTimerRef.current = window.setTimeout(() => setCopied(false), 1500)
|
||||||
closeContextMenu()
|
closeContextMenu()
|
||||||
}, [jsonString, closeContextMenu])
|
}, [jsonString, closeContextMenu])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (copyTimerRef.current !== null) window.clearTimeout(copyTimerRef.current)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
const handleSearch = useCallback(() => {
|
const handleSearch = useCallback(() => {
|
||||||
activateSearch()
|
activateSearch()
|
||||||
closeContextMenu()
|
closeContextMenu()
|
||||||
@@ -185,7 +193,12 @@ function WorkflowOutputSection({ output }: { output: Record<string, unknown> })
|
|||||||
>
|
>
|
||||||
<ArrowDown className='h-[12px] w-[12px]' />
|
<ArrowDown className='h-[12px] w-[12px]' />
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant='ghost' className='!p-1' onClick={closeSearch} aria-label='Close search'>
|
<Button
|
||||||
|
variant='ghost'
|
||||||
|
className='!p-1'
|
||||||
|
onClick={closeSearch}
|
||||||
|
aria-label='Close search'
|
||||||
|
>
|
||||||
<X className='h-[12px] w-[12px]' />
|
<X className='h-[12px] w-[12px]' />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -220,7 +233,9 @@ function WorkflowOutputSection({ output }: { output: Record<string, unknown> })
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
|
(prev, next) => prev.output === next.output
|
||||||
|
)
|
||||||
|
|
||||||
interface LogDetailsProps {
|
interface LogDetailsProps {
|
||||||
/** The log to display details for */
|
/** The log to display details for */
|
||||||
@@ -278,7 +293,6 @@ export const LogDetails = memo(function LogDetails({
|
|||||||
return isWorkflowExecutionLog && log?.cost
|
return isWorkflowExecutionLog && log?.cost
|
||||||
}, [log, isWorkflowExecutionLog])
|
}, [log, isWorkflowExecutionLog])
|
||||||
|
|
||||||
// Extract and clean the workflow final output (recursively remove hidden keys for cleaner display)
|
|
||||||
const workflowOutput = useMemo(() => {
|
const workflowOutput = useMemo(() => {
|
||||||
const executionData = log?.executionData as
|
const executionData = log?.executionData as
|
||||||
| { finalOutput?: Record<string, unknown> }
|
| { finalOutput?: Record<string, unknown> }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import type { RefObject } from 'react'
|
import type { RefObject } from 'react'
|
||||||
|
import { memo } from 'react'
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverAnchor,
|
PopoverAnchor,
|
||||||
@@ -29,7 +30,7 @@ interface LogRowContextMenuProps {
|
|||||||
* Context menu for log rows.
|
* Context menu for log rows.
|
||||||
* Provides quick actions for copying data, navigation, and filtering.
|
* Provides quick actions for copying data, navigation, and filtering.
|
||||||
*/
|
*/
|
||||||
export function LogRowContextMenu({
|
export const LogRowContextMenu = memo(function LogRowContextMenu({
|
||||||
isOpen,
|
isOpen,
|
||||||
position,
|
position,
|
||||||
menuRef,
|
menuRef,
|
||||||
@@ -121,4 +122,4 @@ export function LogRowContextMenu({
|
|||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ interface LogRowProps {
|
|||||||
log: WorkflowLog
|
log: WorkflowLog
|
||||||
isSelected: boolean
|
isSelected: boolean
|
||||||
onClick: (log: WorkflowLog) => void
|
onClick: (log: WorkflowLog) => void
|
||||||
|
onHover?: (log: WorkflowLog) => void
|
||||||
onContextMenu?: (e: React.MouseEvent, log: WorkflowLog) => void
|
onContextMenu?: (e: React.MouseEvent, log: WorkflowLog) => void
|
||||||
selectedRowRef: React.RefObject<HTMLTableRowElement | null> | null
|
selectedRowRef: React.RefObject<HTMLTableRowElement | null> | null
|
||||||
}
|
}
|
||||||
@@ -33,7 +34,14 @@ interface LogRowProps {
|
|||||||
* Uses shallow comparison for the log object.
|
* Uses shallow comparison for the log object.
|
||||||
*/
|
*/
|
||||||
const LogRow = memo(
|
const LogRow = memo(
|
||||||
function LogRow({ log, isSelected, onClick, onContextMenu, selectedRowRef }: LogRowProps) {
|
function LogRow({
|
||||||
|
log,
|
||||||
|
isSelected,
|
||||||
|
onClick,
|
||||||
|
onHover,
|
||||||
|
onContextMenu,
|
||||||
|
selectedRowRef,
|
||||||
|
}: LogRowProps) {
|
||||||
const formattedDate = useMemo(() => formatDate(log.createdAt), [log.createdAt])
|
const formattedDate = useMemo(() => formatDate(log.createdAt), [log.createdAt])
|
||||||
const isDeletedWorkflow = !log.workflow?.id && !log.workflowId
|
const isDeletedWorkflow = !log.workflow?.id && !log.workflowId
|
||||||
const workflowName = isDeletedWorkflow
|
const workflowName = isDeletedWorkflow
|
||||||
@@ -43,6 +51,8 @@ const LogRow = memo(
|
|||||||
|
|
||||||
const handleClick = useCallback(() => onClick(log), [onClick, log])
|
const handleClick = useCallback(() => onClick(log), [onClick, log])
|
||||||
|
|
||||||
|
const handleMouseEnter = useCallback(() => onHover?.(log), [onHover, log])
|
||||||
|
|
||||||
const handleContextMenu = useCallback(
|
const handleContextMenu = useCallback(
|
||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent) => {
|
||||||
if (onContextMenu) {
|
if (onContextMenu) {
|
||||||
@@ -61,6 +71,7 @@ const LogRow = memo(
|
|||||||
isSelected && 'bg-[var(--surface-3)] dark:bg-[var(--surface-4)]'
|
isSelected && 'bg-[var(--surface-3)] dark:bg-[var(--surface-4)]'
|
||||||
)}
|
)}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
onMouseEnter={handleMouseEnter}
|
||||||
onContextMenu={handleContextMenu}
|
onContextMenu={handleContextMenu}
|
||||||
>
|
>
|
||||||
<div className='flex flex-1 items-center'>
|
<div className='flex flex-1 items-center'>
|
||||||
@@ -142,7 +153,8 @@ const LogRow = memo(
|
|||||||
prevProps.log.id === nextProps.log.id &&
|
prevProps.log.id === nextProps.log.id &&
|
||||||
prevProps.log.duration === nextProps.log.duration &&
|
prevProps.log.duration === nextProps.log.duration &&
|
||||||
prevProps.log.status === nextProps.log.status &&
|
prevProps.log.status === nextProps.log.status &&
|
||||||
prevProps.isSelected === nextProps.isSelected
|
prevProps.isSelected === nextProps.isSelected &&
|
||||||
|
prevProps.onHover === nextProps.onHover
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -151,6 +163,7 @@ interface RowProps {
|
|||||||
logs: WorkflowLog[]
|
logs: WorkflowLog[]
|
||||||
selectedLogId: string | null
|
selectedLogId: string | null
|
||||||
onLogClick: (log: WorkflowLog) => void
|
onLogClick: (log: WorkflowLog) => void
|
||||||
|
onLogHover?: (log: WorkflowLog) => void
|
||||||
onLogContextMenu?: (e: React.MouseEvent, log: WorkflowLog) => void
|
onLogContextMenu?: (e: React.MouseEvent, log: WorkflowLog) => void
|
||||||
selectedRowRef: React.RefObject<HTMLTableRowElement | null>
|
selectedRowRef: React.RefObject<HTMLTableRowElement | null>
|
||||||
isFetchingNextPage: boolean
|
isFetchingNextPage: boolean
|
||||||
@@ -167,6 +180,7 @@ function Row({
|
|||||||
logs,
|
logs,
|
||||||
selectedLogId,
|
selectedLogId,
|
||||||
onLogClick,
|
onLogClick,
|
||||||
|
onLogHover,
|
||||||
onLogContextMenu,
|
onLogContextMenu,
|
||||||
selectedRowRef,
|
selectedRowRef,
|
||||||
isFetchingNextPage,
|
isFetchingNextPage,
|
||||||
@@ -198,6 +212,7 @@ function Row({
|
|||||||
log={log}
|
log={log}
|
||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
onClick={onLogClick}
|
onClick={onLogClick}
|
||||||
|
onHover={onLogHover}
|
||||||
onContextMenu={onLogContextMenu}
|
onContextMenu={onLogContextMenu}
|
||||||
selectedRowRef={isSelected ? selectedRowRef : null}
|
selectedRowRef={isSelected ? selectedRowRef : null}
|
||||||
/>
|
/>
|
||||||
@@ -209,6 +224,7 @@ export interface LogsListProps {
|
|||||||
logs: WorkflowLog[]
|
logs: WorkflowLog[]
|
||||||
selectedLogId: string | null
|
selectedLogId: string | null
|
||||||
onLogClick: (log: WorkflowLog) => void
|
onLogClick: (log: WorkflowLog) => void
|
||||||
|
onLogHover?: (log: WorkflowLog) => void
|
||||||
onLogContextMenu?: (e: React.MouseEvent, log: WorkflowLog) => void
|
onLogContextMenu?: (e: React.MouseEvent, log: WorkflowLog) => void
|
||||||
selectedRowRef: React.RefObject<HTMLTableRowElement | null>
|
selectedRowRef: React.RefObject<HTMLTableRowElement | null>
|
||||||
hasNextPage: boolean
|
hasNextPage: boolean
|
||||||
@@ -227,6 +243,7 @@ export function LogsList({
|
|||||||
logs,
|
logs,
|
||||||
selectedLogId,
|
selectedLogId,
|
||||||
onLogClick,
|
onLogClick,
|
||||||
|
onLogHover,
|
||||||
onLogContextMenu,
|
onLogContextMenu,
|
||||||
selectedRowRef,
|
selectedRowRef,
|
||||||
hasNextPage,
|
hasNextPage,
|
||||||
@@ -272,6 +289,7 @@ export function LogsList({
|
|||||||
logs,
|
logs,
|
||||||
selectedLogId,
|
selectedLogId,
|
||||||
onLogClick,
|
onLogClick,
|
||||||
|
onLogHover,
|
||||||
onLogContextMenu,
|
onLogContextMenu,
|
||||||
selectedRowRef,
|
selectedRowRef,
|
||||||
isFetchingNextPage,
|
isFetchingNextPage,
|
||||||
@@ -281,6 +299,7 @@ export function LogsList({
|
|||||||
logs,
|
logs,
|
||||||
selectedLogId,
|
selectedLogId,
|
||||||
onLogClick,
|
onLogClick,
|
||||||
|
onLogHover,
|
||||||
onLogContextMenu,
|
onLogContextMenu,
|
||||||
selectedRowRef,
|
selectedRowRef,
|
||||||
isFetchingNextPage,
|
isFetchingNextPage,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { createLogger } from '@sim/logger'
|
import { createLogger } from '@sim/logger'
|
||||||
import { Plus, X } from 'lucide-react'
|
import { Plus, X } from 'lucide-react'
|
||||||
import {
|
import {
|
||||||
@@ -113,7 +113,7 @@ function formatAlertConfigLabel(config: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NotificationSettings({
|
export const NotificationSettings = memo(function NotificationSettings({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
@@ -144,7 +144,7 @@ export function NotificationSettings({
|
|||||||
slackChannelId: '',
|
slackChannelId: '',
|
||||||
slackChannelName: '',
|
slackChannelName: '',
|
||||||
slackAccountId: '',
|
slackAccountId: '',
|
||||||
useAlertRule: false,
|
|
||||||
alertRule: 'none' as AlertRule,
|
alertRule: 'none' as AlertRule,
|
||||||
consecutiveFailures: 3,
|
consecutiveFailures: 3,
|
||||||
failureRatePercent: 50,
|
failureRatePercent: 50,
|
||||||
@@ -212,7 +212,7 @@ export function NotificationSettings({
|
|||||||
slackChannelId: '',
|
slackChannelId: '',
|
||||||
slackChannelName: '',
|
slackChannelName: '',
|
||||||
slackAccountId: '',
|
slackAccountId: '',
|
||||||
useAlertRule: false,
|
|
||||||
alertRule: 'none',
|
alertRule: 'none',
|
||||||
consecutiveFailures: 3,
|
consecutiveFailures: 3,
|
||||||
failureRatePercent: 50,
|
failureRatePercent: 50,
|
||||||
@@ -484,7 +484,6 @@ export function NotificationSettings({
|
|||||||
slackChannelId: subscription.slackConfig?.channelId || '',
|
slackChannelId: subscription.slackConfig?.channelId || '',
|
||||||
slackChannelName: subscription.slackConfig?.channelName || '',
|
slackChannelName: subscription.slackConfig?.channelName || '',
|
||||||
slackAccountId: subscription.slackConfig?.accountId || '',
|
slackAccountId: subscription.slackConfig?.accountId || '',
|
||||||
useAlertRule: !!subscription.alertConfig,
|
|
||||||
alertRule: subscription.alertConfig?.rule || 'none',
|
alertRule: subscription.alertConfig?.rule || 'none',
|
||||||
consecutiveFailures: subscription.alertConfig?.consecutiveFailures || 3,
|
consecutiveFailures: subscription.alertConfig?.consecutiveFailures || 3,
|
||||||
failureRatePercent: subscription.alertConfig?.failureRatePercent || 50,
|
failureRatePercent: subscription.alertConfig?.failureRatePercent || 50,
|
||||||
@@ -1289,4 +1288,4 @@ export function NotificationSettings({
|
|||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useCallback, useMemo, useState } from 'react'
|
import { memo, useCallback, useMemo, useState } from 'react'
|
||||||
import { ArrowUp, Bell, Library, MoreHorizontal, RefreshCw } from 'lucide-react'
|
import { ArrowUp, Bell, Library, MoreHorizontal, RefreshCw } from 'lucide-react'
|
||||||
import { useParams } from 'next/navigation'
|
import { useParams } from 'next/navigation'
|
||||||
import {
|
import {
|
||||||
@@ -149,7 +149,7 @@ function getTriggerIcon(
|
|||||||
* @param props - The component props
|
* @param props - The component props
|
||||||
* @returns The complete logs toolbar
|
* @returns The complete logs toolbar
|
||||||
*/
|
*/
|
||||||
export function LogsToolbar({
|
export const LogsToolbar = memo(function LogsToolbar({
|
||||||
viewMode,
|
viewMode,
|
||||||
onViewModeChange,
|
onViewModeChange,
|
||||||
isRefreshing,
|
isRefreshing,
|
||||||
@@ -749,4 +749,4 @@ export function LogsToolbar({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'
|
||||||
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { Loader2 } from 'lucide-react'
|
import { Loader2 } from 'lucide-react'
|
||||||
import { useParams } from 'next/navigation'
|
import { useParams } from 'next/navigation'
|
||||||
import { cn } from '@/lib/core/utils/cn'
|
import { cn } from '@/lib/core/utils/cn'
|
||||||
@@ -10,12 +11,17 @@ import {
|
|||||||
hasActiveFilters,
|
hasActiveFilters,
|
||||||
} from '@/lib/logs/filters'
|
} from '@/lib/logs/filters'
|
||||||
import { parseQuery, queryToApiParams } from '@/lib/logs/query-parser'
|
import { parseQuery, queryToApiParams } from '@/lib/logs/query-parser'
|
||||||
|
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
|
||||||
import { useFolders } from '@/hooks/queries/folders'
|
import { useFolders } from '@/hooks/queries/folders'
|
||||||
import { useDashboardStats, useLogDetail, useLogsList } from '@/hooks/queries/logs'
|
import {
|
||||||
|
prefetchLogDetail,
|
||||||
|
useDashboardStats,
|
||||||
|
useLogDetail,
|
||||||
|
useLogsList,
|
||||||
|
} from '@/hooks/queries/logs'
|
||||||
import { useDebounce } from '@/hooks/use-debounce'
|
import { useDebounce } from '@/hooks/use-debounce'
|
||||||
import { useFilterStore } from '@/stores/logs/filters/store'
|
import { useFilterStore } from '@/stores/logs/filters/store'
|
||||||
import type { WorkflowLog } from '@/stores/logs/filters/types'
|
import type { WorkflowLog } from '@/stores/logs/filters/types'
|
||||||
import { useUserPermissionsContext } from '../providers/workspace-permissions-provider'
|
|
||||||
import {
|
import {
|
||||||
Dashboard,
|
Dashboard,
|
||||||
ExecutionSnapshot,
|
ExecutionSnapshot,
|
||||||
@@ -30,6 +36,38 @@ import { LOG_COLUMN_ORDER, LOG_COLUMNS } from './utils'
|
|||||||
const LOGS_PER_PAGE = 50 as const
|
const LOGS_PER_PAGE = 50 as const
|
||||||
const REFRESH_SPINNER_DURATION_MS = 1000 as const
|
const REFRESH_SPINNER_DURATION_MS = 1000 as const
|
||||||
|
|
||||||
|
interface LogSelectionState {
|
||||||
|
selectedLogId: string | null
|
||||||
|
isSidebarOpen: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
type LogSelectionAction =
|
||||||
|
| { type: 'TOGGLE_LOG'; logId: string }
|
||||||
|
| { type: 'SELECT_LOG'; logId: string }
|
||||||
|
| { type: 'CLOSE_SIDEBAR' }
|
||||||
|
| { type: 'TOGGLE_SIDEBAR' }
|
||||||
|
|
||||||
|
function logSelectionReducer(
|
||||||
|
state: LogSelectionState,
|
||||||
|
action: LogSelectionAction
|
||||||
|
): LogSelectionState {
|
||||||
|
switch (action.type) {
|
||||||
|
case 'TOGGLE_LOG':
|
||||||
|
if (state.selectedLogId === action.logId && state.isSidebarOpen) {
|
||||||
|
return { selectedLogId: null, isSidebarOpen: false }
|
||||||
|
}
|
||||||
|
return { selectedLogId: action.logId, isSidebarOpen: true }
|
||||||
|
case 'SELECT_LOG':
|
||||||
|
return { ...state, selectedLogId: action.logId }
|
||||||
|
case 'CLOSE_SIDEBAR':
|
||||||
|
return { selectedLogId: null, isSidebarOpen: false }
|
||||||
|
case 'TOGGLE_SIDEBAR':
|
||||||
|
return state.selectedLogId ? { ...state, isSidebarOpen: !state.isSidebarOpen } : state
|
||||||
|
default:
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs page component displaying workflow execution history.
|
* Logs page component displaying workflow execution history.
|
||||||
* Supports filtering, search, live updates, and detailed log inspection.
|
* Supports filtering, search, live updates, and detailed log inspection.
|
||||||
@@ -60,11 +98,13 @@ export default function Logs() {
|
|||||||
setWorkspaceId(workspaceId)
|
setWorkspaceId(workspaceId)
|
||||||
}, [workspaceId, setWorkspaceId])
|
}, [workspaceId, setWorkspaceId])
|
||||||
|
|
||||||
const [selectedLogId, setSelectedLogId] = useState<string | null>(null)
|
const [{ selectedLogId, isSidebarOpen }, dispatch] = useReducer(logSelectionReducer, {
|
||||||
const [isSidebarOpen, setIsSidebarOpen] = useState(false)
|
selectedLogId: null,
|
||||||
|
isSidebarOpen: false,
|
||||||
|
})
|
||||||
const selectedRowRef = useRef<HTMLTableRowElement | null>(null)
|
const selectedRowRef = useRef<HTMLTableRowElement | null>(null)
|
||||||
const loaderRef = useRef<HTMLDivElement>(null)
|
const loaderRef = useRef<HTMLDivElement>(null)
|
||||||
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
|
||||||
const isInitialized = useRef<boolean>(false)
|
const isInitialized = useRef<boolean>(false)
|
||||||
|
|
||||||
const [searchQuery, setSearchQuery] = useState('')
|
const [searchQuery, setSearchQuery] = useState('')
|
||||||
@@ -82,6 +122,13 @@ export default function Logs() {
|
|||||||
const [isVisuallyRefreshing, setIsVisuallyRefreshing] = useState(false)
|
const [isVisuallyRefreshing, setIsVisuallyRefreshing] = useState(false)
|
||||||
const [isExporting, setIsExporting] = useState(false)
|
const [isExporting, setIsExporting] = useState(false)
|
||||||
const isSearchOpenRef = useRef<boolean>(false)
|
const isSearchOpenRef = useRef<boolean>(false)
|
||||||
|
const refreshTimersRef = useRef(new Set<number>())
|
||||||
|
const logsRef = useRef<WorkflowLog[]>([])
|
||||||
|
const selectedLogIndexRef = useRef(-1)
|
||||||
|
const selectedLogIdRef = useRef<string | null>(null)
|
||||||
|
const logsRefetchRef = useRef<() => void>(() => {})
|
||||||
|
const activeLogRefetchRef = useRef<() => void>(() => {})
|
||||||
|
const logsQueryRef = useRef({ isFetching: false, hasNextPage: false, fetchNextPage: () => {} })
|
||||||
const [isNotificationSettingsOpen, setIsNotificationSettingsOpen] = useState(false)
|
const [isNotificationSettingsOpen, setIsNotificationSettingsOpen] = useState(false)
|
||||||
const userPermissions = useUserPermissionsContext()
|
const userPermissions = useUserPermissionsContext()
|
||||||
|
|
||||||
@@ -94,8 +141,19 @@ export default function Logs() {
|
|||||||
const [previewLogId, setPreviewLogId] = useState<string | null>(null)
|
const [previewLogId, setPreviewLogId] = useState<string | null>(null)
|
||||||
|
|
||||||
const activeLogId = isPreviewOpen ? previewLogId : selectedLogId
|
const activeLogId = isPreviewOpen ? previewLogId : selectedLogId
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const detailRefetchInterval = useCallback(
|
||||||
|
(query: { state: { data?: WorkflowLog } }) => {
|
||||||
|
if (!isLive) return false
|
||||||
|
const status = query.state.data?.status
|
||||||
|
return status === 'running' || status === 'pending' ? 3000 : false
|
||||||
|
},
|
||||||
|
[isLive]
|
||||||
|
)
|
||||||
|
|
||||||
const activeLogQuery = useLogDetail(activeLogId ?? undefined, {
|
const activeLogQuery = useLogDetail(activeLogId ?? undefined, {
|
||||||
refetchInterval: isLive ? 3000 : false,
|
refetchInterval: detailRefetchInterval,
|
||||||
})
|
})
|
||||||
|
|
||||||
const logFilters = useMemo(
|
const logFilters = useMemo(
|
||||||
@@ -154,42 +212,73 @@ export default function Logs() {
|
|||||||
return { ...selectedLogFromList, ...activeLogQuery.data }
|
return { ...selectedLogFromList, ...activeLogQuery.data }
|
||||||
}, [selectedLogFromList, activeLogQuery.data, isPreviewOpen])
|
}, [selectedLogFromList, activeLogQuery.data, isPreviewOpen])
|
||||||
|
|
||||||
|
const handleLogHover = useCallback(
|
||||||
|
(log: WorkflowLog) => {
|
||||||
|
prefetchLogDetail(queryClient, log.id)
|
||||||
|
},
|
||||||
|
[queryClient]
|
||||||
|
)
|
||||||
|
|
||||||
useFolders(workspaceId)
|
useFolders(workspaceId)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
logsRef.current = logs
|
||||||
|
}, [logs])
|
||||||
|
useEffect(() => {
|
||||||
|
selectedLogIndexRef.current = selectedLogIndex
|
||||||
|
}, [selectedLogIndex])
|
||||||
|
useEffect(() => {
|
||||||
|
selectedLogIdRef.current = selectedLogId
|
||||||
|
}, [selectedLogId])
|
||||||
|
useEffect(() => {
|
||||||
|
logsRefetchRef.current = logsQuery.refetch
|
||||||
|
}, [logsQuery.refetch])
|
||||||
|
useEffect(() => {
|
||||||
|
activeLogRefetchRef.current = activeLogQuery.refetch
|
||||||
|
}, [activeLogQuery.refetch])
|
||||||
|
useEffect(() => {
|
||||||
|
logsQueryRef.current = {
|
||||||
|
isFetching: logsQuery.isFetching,
|
||||||
|
hasNextPage: logsQuery.hasNextPage ?? false,
|
||||||
|
fetchNextPage: logsQuery.fetchNextPage,
|
||||||
|
}
|
||||||
|
}, [logsQuery.isFetching, logsQuery.hasNextPage, logsQuery.fetchNextPage])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timers = refreshTimersRef.current
|
||||||
|
return () => {
|
||||||
|
timers.forEach((id) => window.clearTimeout(id))
|
||||||
|
timers.clear()
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isInitialized.current) {
|
if (isInitialized.current) {
|
||||||
setStoreSearchQuery(debouncedSearchQuery)
|
setStoreSearchQuery(debouncedSearchQuery)
|
||||||
}
|
}
|
||||||
}, [debouncedSearchQuery, setStoreSearchQuery])
|
}, [debouncedSearchQuery, setStoreSearchQuery])
|
||||||
|
|
||||||
const handleLogClick = useCallback(
|
const handleLogClick = useCallback((log: WorkflowLog) => {
|
||||||
(log: WorkflowLog) => {
|
dispatch({ type: 'TOGGLE_LOG', logId: log.id })
|
||||||
if (selectedLogId === log.id && isSidebarOpen) {
|
}, [])
|
||||||
setIsSidebarOpen(false)
|
|
||||||
setSelectedLogId(null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setSelectedLogId(log.id)
|
|
||||||
setIsSidebarOpen(true)
|
|
||||||
},
|
|
||||||
[selectedLogId, isSidebarOpen]
|
|
||||||
)
|
|
||||||
|
|
||||||
const handleNavigateNext = useCallback(() => {
|
const handleNavigateNext = useCallback(() => {
|
||||||
if (selectedLogIndex < logs.length - 1) {
|
const idx = selectedLogIndexRef.current
|
||||||
setSelectedLogId(logs[selectedLogIndex + 1].id)
|
const currentLogs = logsRef.current
|
||||||
|
if (idx < currentLogs.length - 1) {
|
||||||
|
dispatch({ type: 'SELECT_LOG', logId: currentLogs[idx + 1].id })
|
||||||
}
|
}
|
||||||
}, [selectedLogIndex, logs])
|
}, [])
|
||||||
|
|
||||||
const handleNavigatePrev = useCallback(() => {
|
const handleNavigatePrev = useCallback(() => {
|
||||||
if (selectedLogIndex > 0) {
|
const idx = selectedLogIndexRef.current
|
||||||
setSelectedLogId(logs[selectedLogIndex - 1].id)
|
if (idx > 0) {
|
||||||
|
dispatch({ type: 'SELECT_LOG', logId: logsRef.current[idx - 1].id })
|
||||||
}
|
}
|
||||||
}, [selectedLogIndex, logs])
|
}, [])
|
||||||
|
|
||||||
const handleCloseSidebar = useCallback(() => {
|
const handleCloseSidebar = useCallback(() => {
|
||||||
setIsSidebarOpen(false)
|
dispatch({ type: 'CLOSE_SIDEBAR' })
|
||||||
setSelectedLogId(null)
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleLogContextMenu = useCallback((e: React.MouseEvent, log: WorkflowLog) => {
|
const handleLogContextMenu = useCallback((e: React.MouseEvent, log: WorkflowLog) => {
|
||||||
@@ -260,26 +349,34 @@ export default function Logs() {
|
|||||||
|
|
||||||
const handleRefresh = useCallback(() => {
|
const handleRefresh = useCallback(() => {
|
||||||
setIsVisuallyRefreshing(true)
|
setIsVisuallyRefreshing(true)
|
||||||
setTimeout(() => setIsVisuallyRefreshing(false), REFRESH_SPINNER_DURATION_MS)
|
const timerId = window.setTimeout(() => {
|
||||||
logsQuery.refetch()
|
setIsVisuallyRefreshing(false)
|
||||||
if (selectedLogId) {
|
refreshTimersRef.current.delete(timerId)
|
||||||
activeLogQuery.refetch()
|
}, REFRESH_SPINNER_DURATION_MS)
|
||||||
|
refreshTimersRef.current.add(timerId)
|
||||||
|
logsRefetchRef.current()
|
||||||
|
if (selectedLogIdRef.current) {
|
||||||
|
activeLogRefetchRef.current()
|
||||||
}
|
}
|
||||||
}, [logsQuery, activeLogQuery, selectedLogId])
|
}, [])
|
||||||
|
|
||||||
const handleToggleLive = useCallback(() => {
|
const handleToggleLive = useCallback(() => {
|
||||||
const newIsLive = !isLive
|
setIsLive((prev) => {
|
||||||
setIsLive(newIsLive)
|
if (!prev) {
|
||||||
|
|
||||||
if (newIsLive) {
|
|
||||||
setIsVisuallyRefreshing(true)
|
setIsVisuallyRefreshing(true)
|
||||||
setTimeout(() => setIsVisuallyRefreshing(false), REFRESH_SPINNER_DURATION_MS)
|
const timerId = window.setTimeout(() => {
|
||||||
logsQuery.refetch()
|
setIsVisuallyRefreshing(false)
|
||||||
if (selectedLogId) {
|
refreshTimersRef.current.delete(timerId)
|
||||||
activeLogQuery.refetch()
|
}, REFRESH_SPINNER_DURATION_MS)
|
||||||
|
refreshTimersRef.current.add(timerId)
|
||||||
|
logsRefetchRef.current()
|
||||||
|
if (selectedLogIdRef.current) {
|
||||||
|
activeLogRefetchRef.current()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isLive, logsQuery, activeLogQuery, selectedLogId])
|
return !prev
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
const prevIsFetchingRef = useRef(logsQuery.isFetching)
|
const prevIsFetchingRef = useRef(logsQuery.isFetching)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -289,11 +386,15 @@ export default function Logs() {
|
|||||||
|
|
||||||
if (isLive && !wasFetching && isFetching) {
|
if (isLive && !wasFetching && isFetching) {
|
||||||
setIsVisuallyRefreshing(true)
|
setIsVisuallyRefreshing(true)
|
||||||
setTimeout(() => setIsVisuallyRefreshing(false), REFRESH_SPINNER_DURATION_MS)
|
const timerId = window.setTimeout(() => {
|
||||||
|
setIsVisuallyRefreshing(false)
|
||||||
|
refreshTimersRef.current.delete(timerId)
|
||||||
|
}, REFRESH_SPINNER_DURATION_MS)
|
||||||
|
refreshTimersRef.current.add(timerId)
|
||||||
}
|
}
|
||||||
}, [logsQuery.isFetching, isLive])
|
}, [logsQuery.isFetching, isLive])
|
||||||
|
|
||||||
const handleExport = async () => {
|
const handleExport = useCallback(async () => {
|
||||||
setIsExporting(true)
|
setIsExporting(true)
|
||||||
try {
|
try {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
@@ -327,7 +428,17 @@ export default function Logs() {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsExporting(false)
|
setIsExporting(false)
|
||||||
}
|
}
|
||||||
}
|
}, [
|
||||||
|
workspaceId,
|
||||||
|
level,
|
||||||
|
triggers,
|
||||||
|
workflowIds,
|
||||||
|
folderIds,
|
||||||
|
timeRange,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
debouncedSearchQuery,
|
||||||
|
])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isInitialized.current) {
|
if (!isInitialized.current) {
|
||||||
@@ -348,41 +459,59 @@ export default function Logs() {
|
|||||||
}, [initializeFromURL])
|
}, [initializeFromURL])
|
||||||
|
|
||||||
const loadMoreLogs = useCallback(() => {
|
const loadMoreLogs = useCallback(() => {
|
||||||
if (!logsQuery.isFetching && logsQuery.hasNextPage) {
|
const { isFetching, hasNextPage, fetchNextPage } = logsQueryRef.current
|
||||||
logsQuery.fetchNextPage()
|
if (!isFetching && hasNextPage) {
|
||||||
|
fetchNextPage()
|
||||||
}
|
}
|
||||||
}, [logsQuery])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
if (isSearchOpenRef.current) return
|
if (isSearchOpenRef.current) return
|
||||||
if (logs.length === 0) return
|
const currentLogs = logsRef.current
|
||||||
|
const currentIndex = selectedLogIndexRef.current
|
||||||
|
if (currentLogs.length === 0) return
|
||||||
|
|
||||||
if (selectedLogIndex === -1 && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
if (currentIndex === -1 && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setSelectedLogId(logs[0].id)
|
dispatch({ type: 'SELECT_LOG', logId: currentLogs[0].id })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === 'ArrowUp' && !e.metaKey && !e.ctrlKey && selectedLogIndex > 0) {
|
if (e.key === 'ArrowUp' && !e.metaKey && !e.ctrlKey && currentIndex > 0) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
handleNavigatePrev()
|
handleNavigatePrev()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === 'ArrowDown' && !e.metaKey && !e.ctrlKey && selectedLogIndex < logs.length - 1) {
|
if (
|
||||||
|
e.key === 'ArrowDown' &&
|
||||||
|
!e.metaKey &&
|
||||||
|
!e.ctrlKey &&
|
||||||
|
currentIndex < currentLogs.length - 1
|
||||||
|
) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
handleNavigateNext()
|
handleNavigateNext()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === 'Enter' && selectedLogId) {
|
if (e.key === 'Enter' && selectedLogIdRef.current) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setIsSidebarOpen(!isSidebarOpen)
|
dispatch({ type: 'TOGGLE_SIDEBAR' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown)
|
window.addEventListener('keydown', handleKeyDown)
|
||||||
return () => window.removeEventListener('keydown', handleKeyDown)
|
return () => window.removeEventListener('keydown', handleKeyDown)
|
||||||
}, [logs, selectedLogIndex, isSidebarOpen, selectedLogId, handleNavigateNext, handleNavigatePrev])
|
}, [handleNavigateNext, handleNavigatePrev])
|
||||||
|
|
||||||
|
const handleCloseContextMenu = useCallback(() => setContextMenuOpen(false), [])
|
||||||
|
const handleOpenNotificationSettings = useCallback(() => setIsNotificationSettingsOpen(true), [])
|
||||||
|
const handleSearchOpenChange = useCallback((open: boolean) => {
|
||||||
|
isSearchOpenRef.current = open
|
||||||
|
}, [])
|
||||||
|
const handleClosePreview = useCallback(() => {
|
||||||
|
setIsPreviewOpen(false)
|
||||||
|
setPreviewLogId(null)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const isDashboardView = viewMode === 'dashboard'
|
const isDashboardView = viewMode === 'dashboard'
|
||||||
|
|
||||||
@@ -402,12 +531,10 @@ export default function Logs() {
|
|||||||
onExport={handleExport}
|
onExport={handleExport}
|
||||||
canEdit={userPermissions.canEdit}
|
canEdit={userPermissions.canEdit}
|
||||||
hasLogs={logs.length > 0}
|
hasLogs={logs.length > 0}
|
||||||
onOpenNotificationSettings={() => setIsNotificationSettingsOpen(true)}
|
onOpenNotificationSettings={handleOpenNotificationSettings}
|
||||||
searchQuery={searchQuery}
|
searchQuery={searchQuery}
|
||||||
onSearchQueryChange={setSearchQuery}
|
onSearchQueryChange={setSearchQuery}
|
||||||
onSearchOpenChange={(open: boolean) => {
|
onSearchOpenChange={handleSearchOpenChange}
|
||||||
isSearchOpenRef.current = open
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -449,7 +576,7 @@ export default function Logs() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Table body - virtualized */}
|
{/* Table body - virtualized */}
|
||||||
<div className='min-h-0 flex-1 overflow-hidden' ref={scrollContainerRef}>
|
<div className='min-h-0 flex-1 overflow-hidden'>
|
||||||
{logsQuery.isLoading && !logsQuery.data ? (
|
{logsQuery.isLoading && !logsQuery.data ? (
|
||||||
<div className='flex h-full items-center justify-center'>
|
<div className='flex h-full items-center justify-center'>
|
||||||
<div className='flex items-center gap-[8px] text-[var(--text-secondary)]'>
|
<div className='flex items-center gap-[8px] text-[var(--text-secondary)]'>
|
||||||
@@ -476,6 +603,7 @@ export default function Logs() {
|
|||||||
logs={logs}
|
logs={logs}
|
||||||
selectedLogId={selectedLogId}
|
selectedLogId={selectedLogId}
|
||||||
onLogClick={handleLogClick}
|
onLogClick={handleLogClick}
|
||||||
|
onLogHover={handleLogHover}
|
||||||
onLogContextMenu={handleLogContextMenu}
|
onLogContextMenu={handleLogContextMenu}
|
||||||
selectedRowRef={selectedRowRef}
|
selectedRowRef={selectedRowRef}
|
||||||
hasNextPage={logsQuery.hasNextPage ?? false}
|
hasNextPage={logsQuery.hasNextPage ?? false}
|
||||||
@@ -511,7 +639,7 @@ export default function Logs() {
|
|||||||
isOpen={contextMenuOpen}
|
isOpen={contextMenuOpen}
|
||||||
position={contextMenuPosition}
|
position={contextMenuPosition}
|
||||||
menuRef={contextMenuRef}
|
menuRef={contextMenuRef}
|
||||||
onClose={() => setContextMenuOpen(false)}
|
onClose={handleCloseContextMenu}
|
||||||
log={contextMenuLog}
|
log={contextMenuLog}
|
||||||
onCopyExecutionId={handleCopyExecutionId}
|
onCopyExecutionId={handleCopyExecutionId}
|
||||||
onOpenWorkflow={handleOpenWorkflow}
|
onOpenWorkflow={handleOpenWorkflow}
|
||||||
@@ -528,10 +656,7 @@ export default function Logs() {
|
|||||||
traceSpans={activeLogQuery.data.executionData?.traceSpans}
|
traceSpans={activeLogQuery.data.executionData?.traceSpans}
|
||||||
isModal
|
isModal
|
||||||
isOpen={isPreviewOpen}
|
isOpen={isPreviewOpen}
|
||||||
onClose={() => {
|
onClose={handleClosePreview}
|
||||||
setIsPreviewOpen(false)
|
|
||||||
setPreviewLogId(null)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -239,8 +239,13 @@ export const ComboBox = memo(function ComboBox({
|
|||||||
*/
|
*/
|
||||||
const defaultOptionValue = useMemo(() => {
|
const defaultOptionValue = useMemo(() => {
|
||||||
if (defaultValue !== undefined) {
|
if (defaultValue !== undefined) {
|
||||||
|
// Validate that the default value exists in the available (filtered) options
|
||||||
|
const defaultInOptions = evaluatedOptions.find((opt) => getOptionValue(opt) === defaultValue)
|
||||||
|
if (defaultInOptions) {
|
||||||
return defaultValue
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
// Default not available (e.g. provider disabled) — fall through to other fallbacks
|
||||||
|
}
|
||||||
|
|
||||||
// For model field, default to claude-sonnet-4-5 if available
|
// For model field, default to claude-sonnet-4-5 if available
|
||||||
if (subBlockId === 'model') {
|
if (subBlockId === 'model') {
|
||||||
|
|||||||
@@ -223,7 +223,12 @@ function resolveToolsDisplay(
|
|||||||
* - Resolves tool names from block registry
|
* - Resolves tool names from block registry
|
||||||
* - Shows '-' for other selector types that need hydration
|
* - Shows '-' for other selector types that need hydration
|
||||||
*/
|
*/
|
||||||
function SubBlockRow({ title, value, subBlock, rawValue }: SubBlockRowProps) {
|
const SubBlockRow = memo(function SubBlockRow({
|
||||||
|
title,
|
||||||
|
value,
|
||||||
|
subBlock,
|
||||||
|
rawValue,
|
||||||
|
}: SubBlockRowProps) {
|
||||||
const isPasswordField = subBlock?.password === true
|
const isPasswordField = subBlock?.password === true
|
||||||
const maskedValue = isPasswordField && value && value !== '-' ? '•••' : null
|
const maskedValue = isPasswordField && value && value !== '-' ? '•••' : null
|
||||||
|
|
||||||
@@ -255,7 +260,7 @@ function SubBlockRow({ title, value, subBlock, rawValue }: SubBlockRowProps) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preview block component for workflow visualization.
|
* Preview block component for workflow visualization.
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ import { createLogger } from '@sim/logger'
|
|||||||
import { AgentIcon } from '@/components/icons'
|
import { AgentIcon } from '@/components/icons'
|
||||||
import type { BlockConfig } from '@/blocks/types'
|
import type { BlockConfig } from '@/blocks/types'
|
||||||
import { AuthMode } from '@/blocks/types'
|
import { AuthMode } from '@/blocks/types'
|
||||||
import { getApiKeyCondition } from '@/blocks/utils'
|
import { getApiKeyCondition, getModelOptions } from '@/blocks/utils'
|
||||||
import {
|
import {
|
||||||
getBaseModelProviders,
|
getBaseModelProviders,
|
||||||
getMaxTemperature,
|
getMaxTemperature,
|
||||||
getProviderIcon,
|
|
||||||
getReasoningEffortValuesForModel,
|
getReasoningEffortValuesForModel,
|
||||||
getThinkingLevelsForModel,
|
getThinkingLevelsForModel,
|
||||||
getVerbosityValuesForModel,
|
getVerbosityValuesForModel,
|
||||||
@@ -18,7 +17,6 @@ import {
|
|||||||
providers,
|
providers,
|
||||||
supportsTemperature,
|
supportsTemperature,
|
||||||
} from '@/providers/utils'
|
} from '@/providers/utils'
|
||||||
import { useProvidersStore } from '@/stores/providers'
|
|
||||||
import type { ToolResponse } from '@/tools/types'
|
import type { ToolResponse } from '@/tools/types'
|
||||||
|
|
||||||
const logger = createLogger('AgentBlock')
|
const logger = createLogger('AgentBlock')
|
||||||
@@ -121,21 +119,7 @@ Return ONLY the JSON array.`,
|
|||||||
placeholder: 'Type or select a model...',
|
placeholder: 'Type or select a model...',
|
||||||
required: true,
|
required: true,
|
||||||
defaultValue: 'claude-sonnet-4-5',
|
defaultValue: 'claude-sonnet-4-5',
|
||||||
options: () => {
|
options: getModelOptions,
|
||||||
const providersState = useProvidersStore.getState()
|
|
||||||
const baseModels = providersState.providers.base.models
|
|
||||||
const ollamaModels = providersState.providers.ollama.models
|
|
||||||
const vllmModels = providersState.providers.vllm.models
|
|
||||||
const openrouterModels = providersState.providers.openrouter.models
|
|
||||||
const allModels = Array.from(
|
|
||||||
new Set([...baseModels, ...ollamaModels, ...vllmModels, ...openrouterModels])
|
|
||||||
)
|
|
||||||
|
|
||||||
return allModels.map((model) => {
|
|
||||||
const icon = getProviderIcon(model)
|
|
||||||
return { label: model, id: model, ...(icon && { icon }) }
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'vertexCredential',
|
id: 'vertexCredential',
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import { createLogger } from '@sim/logger'
|
import { createLogger } from '@sim/logger'
|
||||||
import { ChartBarIcon } from '@/components/icons'
|
import { ChartBarIcon } from '@/components/icons'
|
||||||
import type { BlockConfig, ParamType } from '@/blocks/types'
|
import type { BlockConfig, ParamType } from '@/blocks/types'
|
||||||
import { getProviderCredentialSubBlocks, PROVIDER_CREDENTIAL_INPUTS } from '@/blocks/utils'
|
import {
|
||||||
|
getModelOptions,
|
||||||
|
getProviderCredentialSubBlocks,
|
||||||
|
PROVIDER_CREDENTIAL_INPUTS,
|
||||||
|
} from '@/blocks/utils'
|
||||||
import type { ProviderId } from '@/providers/types'
|
import type { ProviderId } from '@/providers/types'
|
||||||
import { getBaseModelProviders, getProviderIcon } from '@/providers/utils'
|
import { getBaseModelProviders } from '@/providers/utils'
|
||||||
import { useProvidersStore } from '@/stores/providers/store'
|
|
||||||
import type { ToolResponse } from '@/tools/types'
|
import type { ToolResponse } from '@/tools/types'
|
||||||
|
|
||||||
const logger = createLogger('EvaluatorBlock')
|
const logger = createLogger('EvaluatorBlock')
|
||||||
@@ -175,21 +178,7 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = {
|
|||||||
placeholder: 'Type or select a model...',
|
placeholder: 'Type or select a model...',
|
||||||
required: true,
|
required: true,
|
||||||
defaultValue: 'claude-sonnet-4-5',
|
defaultValue: 'claude-sonnet-4-5',
|
||||||
options: () => {
|
options: getModelOptions,
|
||||||
const providersState = useProvidersStore.getState()
|
|
||||||
const baseModels = providersState.providers.base.models
|
|
||||||
const ollamaModels = providersState.providers.ollama.models
|
|
||||||
const vllmModels = providersState.providers.vllm.models
|
|
||||||
const openrouterModels = providersState.providers.openrouter.models
|
|
||||||
const allModels = Array.from(
|
|
||||||
new Set([...baseModels, ...ollamaModels, ...vllmModels, ...openrouterModels])
|
|
||||||
)
|
|
||||||
|
|
||||||
return allModels.map((model) => {
|
|
||||||
const icon = getProviderIcon(model)
|
|
||||||
return { label: model, id: model, ...(icon && { icon }) }
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
...getProviderCredentialSubBlocks(),
|
...getProviderCredentialSubBlocks(),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { ShieldCheckIcon } from '@/components/icons'
|
import { ShieldCheckIcon } from '@/components/icons'
|
||||||
import type { BlockConfig } from '@/blocks/types'
|
import type { BlockConfig } from '@/blocks/types'
|
||||||
import { getProviderCredentialSubBlocks, PROVIDER_CREDENTIAL_INPUTS } from '@/blocks/utils'
|
import {
|
||||||
import { getProviderIcon } from '@/providers/utils'
|
getModelOptions,
|
||||||
import { useProvidersStore } from '@/stores/providers/store'
|
getProviderCredentialSubBlocks,
|
||||||
|
PROVIDER_CREDENTIAL_INPUTS,
|
||||||
|
} from '@/blocks/utils'
|
||||||
import type { ToolResponse } from '@/tools/types'
|
import type { ToolResponse } from '@/tools/types'
|
||||||
|
|
||||||
export interface GuardrailsResponse extends ToolResponse {
|
export interface GuardrailsResponse extends ToolResponse {
|
||||||
@@ -111,21 +113,7 @@ Return ONLY the regex pattern - no explanations, no quotes, no forward slashes,
|
|||||||
type: 'combobox',
|
type: 'combobox',
|
||||||
placeholder: 'Type or select a model...',
|
placeholder: 'Type or select a model...',
|
||||||
required: true,
|
required: true,
|
||||||
options: () => {
|
options: getModelOptions,
|
||||||
const providersState = useProvidersStore.getState()
|
|
||||||
const baseModels = providersState.providers.base.models
|
|
||||||
const ollamaModels = providersState.providers.ollama.models
|
|
||||||
const vllmModels = providersState.providers.vllm.models
|
|
||||||
const openrouterModels = providersState.providers.openrouter.models
|
|
||||||
const allModels = Array.from(
|
|
||||||
new Set([...baseModels, ...ollamaModels, ...vllmModels, ...openrouterModels])
|
|
||||||
)
|
|
||||||
|
|
||||||
return allModels.map((model) => {
|
|
||||||
const icon = getProviderIcon(model)
|
|
||||||
return { label: model, id: model, ...(icon && { icon }) }
|
|
||||||
})
|
|
||||||
},
|
|
||||||
condition: {
|
condition: {
|
||||||
field: 'validationType',
|
field: 'validationType',
|
||||||
value: ['hallucination'],
|
value: ['hallucination'],
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { ConnectIcon } from '@/components/icons'
|
import { ConnectIcon } from '@/components/icons'
|
||||||
import { AuthMode, type BlockConfig } from '@/blocks/types'
|
import { AuthMode, type BlockConfig } from '@/blocks/types'
|
||||||
import { getProviderCredentialSubBlocks, PROVIDER_CREDENTIAL_INPUTS } from '@/blocks/utils'
|
import {
|
||||||
|
getModelOptions,
|
||||||
|
getProviderCredentialSubBlocks,
|
||||||
|
PROVIDER_CREDENTIAL_INPUTS,
|
||||||
|
} from '@/blocks/utils'
|
||||||
import type { ProviderId } from '@/providers/types'
|
import type { ProviderId } from '@/providers/types'
|
||||||
import { getBaseModelProviders, getProviderIcon } from '@/providers/utils'
|
import { getBaseModelProviders } from '@/providers/utils'
|
||||||
import { useProvidersStore } from '@/stores/providers'
|
|
||||||
import type { ToolResponse } from '@/tools/types'
|
import type { ToolResponse } from '@/tools/types'
|
||||||
|
|
||||||
interface RouterResponse extends ToolResponse {
|
interface RouterResponse extends ToolResponse {
|
||||||
@@ -134,25 +137,6 @@ Respond with a JSON object containing:
|
|||||||
- reasoning: A brief explanation (1-2 sentences) of why you chose this route`
|
- reasoning: A brief explanation (1-2 sentences) of why you chose this route`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to get model options for both router versions.
|
|
||||||
*/
|
|
||||||
const getModelOptions = () => {
|
|
||||||
const providersState = useProvidersStore.getState()
|
|
||||||
const baseModels = providersState.providers.base.models
|
|
||||||
const ollamaModels = providersState.providers.ollama.models
|
|
||||||
const vllmModels = providersState.providers.vllm.models
|
|
||||||
const openrouterModels = providersState.providers.openrouter.models
|
|
||||||
const allModels = Array.from(
|
|
||||||
new Set([...baseModels, ...ollamaModels, ...vllmModels, ...openrouterModels])
|
|
||||||
)
|
|
||||||
|
|
||||||
return allModels.map((model) => {
|
|
||||||
const icon = getProviderIcon(model)
|
|
||||||
return { label: model, id: model, ...(icon && { icon }) }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legacy Router Block (block-based routing).
|
* Legacy Router Block (block-based routing).
|
||||||
* Hidden from toolbar but still supported for existing workflows.
|
* Hidden from toolbar but still supported for existing workflows.
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { TranslateIcon } from '@/components/icons'
|
import { TranslateIcon } from '@/components/icons'
|
||||||
import { AuthMode, type BlockConfig } from '@/blocks/types'
|
import { AuthMode, type BlockConfig } from '@/blocks/types'
|
||||||
import { getProviderCredentialSubBlocks, PROVIDER_CREDENTIAL_INPUTS } from '@/blocks/utils'
|
import {
|
||||||
import { getProviderIcon } from '@/providers/utils'
|
getModelOptions,
|
||||||
import { useProvidersStore } from '@/stores/providers/store'
|
getProviderCredentialSubBlocks,
|
||||||
|
PROVIDER_CREDENTIAL_INPUTS,
|
||||||
|
} from '@/blocks/utils'
|
||||||
|
|
||||||
const getTranslationPrompt = (targetLanguage: string) =>
|
const getTranslationPrompt = (targetLanguage: string) =>
|
||||||
`Translate the following text into ${targetLanguage || 'English'}. Output ONLY the translated text with no additional commentary, explanations, or notes.`
|
`Translate the following text into ${targetLanguage || 'English'}. Output ONLY the translated text with no additional commentary, explanations, or notes.`
|
||||||
@@ -38,18 +40,7 @@ export const TranslateBlock: BlockConfig = {
|
|||||||
type: 'combobox',
|
type: 'combobox',
|
||||||
placeholder: 'Type or select a model...',
|
placeholder: 'Type or select a model...',
|
||||||
required: true,
|
required: true,
|
||||||
options: () => {
|
options: getModelOptions,
|
||||||
const providersState = useProvidersStore.getState()
|
|
||||||
const baseModels = providersState.providers.base.models
|
|
||||||
const ollamaModels = providersState.providers.ollama.models
|
|
||||||
const openrouterModels = providersState.providers.openrouter.models
|
|
||||||
const allModels = Array.from(new Set([...baseModels, ...ollamaModels, ...openrouterModels]))
|
|
||||||
|
|
||||||
return allModels.map((model) => {
|
|
||||||
const icon = getProviderIcon(model)
|
|
||||||
return { label: model, id: model, ...(icon && { icon }) }
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
...getProviderCredentialSubBlocks(),
|
...getProviderCredentialSubBlocks(),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,32 @@
|
|||||||
import { isHosted } from '@/lib/core/config/feature-flags'
|
import { isHosted } from '@/lib/core/config/feature-flags'
|
||||||
import type { BlockOutput, OutputFieldDefinition, SubBlockConfig } from '@/blocks/types'
|
import type { BlockOutput, OutputFieldDefinition, SubBlockConfig } from '@/blocks/types'
|
||||||
import { getHostedModels, getProviderFromModel, providers } from '@/providers/utils'
|
import {
|
||||||
|
getHostedModels,
|
||||||
|
getProviderFromModel,
|
||||||
|
getProviderIcon,
|
||||||
|
providers,
|
||||||
|
} from '@/providers/utils'
|
||||||
import { useProvidersStore } from '@/stores/providers/store'
|
import { useProvidersStore } from '@/stores/providers/store'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns model options for combobox subblocks, combining all provider sources.
|
||||||
|
*/
|
||||||
|
export function getModelOptions() {
|
||||||
|
const providersState = useProvidersStore.getState()
|
||||||
|
const baseModels = providersState.providers.base.models
|
||||||
|
const ollamaModels = providersState.providers.ollama.models
|
||||||
|
const vllmModels = providersState.providers.vllm.models
|
||||||
|
const openrouterModels = providersState.providers.openrouter.models
|
||||||
|
const allModels = Array.from(
|
||||||
|
new Set([...baseModels, ...ollamaModels, ...vllmModels, ...openrouterModels])
|
||||||
|
)
|
||||||
|
|
||||||
|
return allModels.map((model) => {
|
||||||
|
const icon = getProviderIcon(model)
|
||||||
|
return { label: model, id: model, ...(icon && { icon }) }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a field is included in the dependsOn config.
|
* Checks if a field is included in the dependsOn config.
|
||||||
* Handles both simple array format and object format with all/any fields.
|
* Handles both simple array format and object format with all/any fields.
|
||||||
|
|||||||
@@ -1008,7 +1008,7 @@ const VirtualizedViewerInner = memo(function VirtualizedViewerInner({
|
|||||||
* Non-virtualized code viewer implementation.
|
* Non-virtualized code viewer implementation.
|
||||||
* Renders all lines directly without windowing.
|
* Renders all lines directly without windowing.
|
||||||
*/
|
*/
|
||||||
function ViewerInner({
|
const ViewerInner = memo(function ViewerInner({
|
||||||
code,
|
code,
|
||||||
showGutter,
|
showGutter,
|
||||||
language,
|
language,
|
||||||
@@ -1181,7 +1181,7 @@ function ViewerInner({
|
|||||||
</Content>
|
</Content>
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Readonly code viewer with optional gutter and syntax highlighting.
|
* Readonly code viewer with optional gutter and syntax highlighting.
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { keepPreviousData, useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
import {
|
||||||
|
keepPreviousData,
|
||||||
|
type QueryClient,
|
||||||
|
useInfiniteQuery,
|
||||||
|
useQuery,
|
||||||
|
useQueryClient,
|
||||||
|
} from '@tanstack/react-query'
|
||||||
import { getEndDateFromTimeRange, getStartDateFromTimeRange } from '@/lib/logs/filters'
|
import { getEndDateFromTimeRange, getStartDateFromTimeRange } from '@/lib/logs/filters'
|
||||||
import { parseQuery, queryToApiParams } from '@/lib/logs/query-parser'
|
import { parseQuery, queryToApiParams } from '@/lib/logs/query-parser'
|
||||||
import type {
|
import type {
|
||||||
@@ -146,17 +152,45 @@ export function useLogsList(
|
|||||||
|
|
||||||
interface UseLogDetailOptions {
|
interface UseLogDetailOptions {
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
refetchInterval?: number | false
|
refetchInterval?:
|
||||||
|
| number
|
||||||
|
| false
|
||||||
|
| ((query: { state: { data?: WorkflowLog } }) => number | false | undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLogDetail(logId: string | undefined, options?: UseLogDetailOptions) {
|
export function useLogDetail(logId: string | undefined, options?: UseLogDetailOptions) {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: logKeys.detail(logId),
|
queryKey: logKeys.detail(logId),
|
||||||
queryFn: () => fetchLogDetail(logId as string),
|
queryFn: () => fetchLogDetail(logId as string),
|
||||||
enabled: Boolean(logId) && (options?.enabled ?? true),
|
enabled: Boolean(logId) && (options?.enabled ?? true),
|
||||||
refetchInterval: options?.refetchInterval ?? false,
|
refetchInterval: options?.refetchInterval ?? false,
|
||||||
staleTime: 30 * 1000,
|
staleTime: 30 * 1000,
|
||||||
placeholderData: keepPreviousData,
|
initialData: () => {
|
||||||
|
if (!logId) return undefined
|
||||||
|
const listQueries = queryClient.getQueriesData<{
|
||||||
|
pages: { logs: WorkflowLog[] }[]
|
||||||
|
}>({
|
||||||
|
queryKey: logKeys.lists(),
|
||||||
|
})
|
||||||
|
for (const [, data] of listQueries) {
|
||||||
|
const match = data?.pages?.flatMap((p) => p.logs).find((l) => l.id === logId)
|
||||||
|
if (match) return match
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
},
|
||||||
|
initialDataUpdatedAt: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefetches log detail data on hover for instant panel rendering on click.
|
||||||
|
*/
|
||||||
|
export function prefetchLogDetail(queryClient: QueryClient, logId: string) {
|
||||||
|
queryClient.prefetchQuery({
|
||||||
|
queryKey: logKeys.detail(logId),
|
||||||
|
queryFn: () => fetchLogDetail(logId),
|
||||||
|
staleTime: 30 * 1000,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ export const vertexProvider: ProviderConfig = {
|
|||||||
executeRequest: async (
|
executeRequest: async (
|
||||||
request: ProviderRequest
|
request: ProviderRequest
|
||||||
): Promise<ProviderResponse | StreamingExecution> => {
|
): Promise<ProviderResponse | StreamingExecution> => {
|
||||||
const vertexProject = env.VERTEX_PROJECT || request.vertexProject
|
const vertexProject = request.vertexProject || env.VERTEX_PROJECT
|
||||||
const vertexLocation = env.VERTEX_LOCATION || request.vertexLocation || 'us-central1'
|
const vertexLocation = request.vertexLocation || env.VERTEX_LOCATION || 'us-central1'
|
||||||
|
|
||||||
if (!vertexProject) {
|
if (!vertexProject) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user