Skip to content

Commit 261156f

Browse files
committed
fix(logs): prevent log-row arrow navigation when trace tab is active
1 parent 2303a71 commit 261156f

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/log-details.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ interface LogDetailsProps {
273273
onRetryExecution?: () => void
274274
/** Whether a retry is currently in progress */
275275
isRetryPending?: boolean
276+
/** Fires when the active tab changes, so the parent can gate its own keyboard handlers */
277+
onActiveTabChange?: (tab: LogDetailsTab) => void
276278
}
277279

278280
/**
@@ -293,6 +295,7 @@ export const LogDetails = memo(function LogDetails({
293295
hasPrev = false,
294296
onRetryExecution,
295297
isRetryPending = false,
298+
onActiveTabChange,
296299
}: LogDetailsProps) {
297300
const [isExecutionSnapshotOpen, setIsExecutionSnapshotOpen] = useState(false)
298301
const [activeTab, setActiveTab] = useState<LogDetailsTab>('overview')
@@ -334,6 +337,10 @@ export const LogDetails = memo(function LogDetails({
334337

335338
const resolvedTab: LogDetailsTab = activeTab === 'trace' && !showTraceTab ? 'overview' : activeTab
336339

340+
useEffect(() => {
341+
onActiveTabChange?.(resolvedTab)
342+
}, [resolvedTab, onActiveTabChange])
343+
337344
const workflowOutput = useMemo(() => {
338345
const executionData = log?.executionData as
339346
| { finalOutput?: Record<string, unknown> }

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ export default function Logs() {
293293
const shouldScrollIntoViewRef = useRef(false)
294294
const logsRefetchRef = useRef<() => void>(() => {})
295295
const activeLogRefetchRef = useRef<() => void>(() => {})
296+
const activeLogTabRef = useRef<string>('overview')
296297
const logsQueryRef = useRef({ isFetching: false, hasNextPage: false, fetchNextPage: () => {} })
297298
const [isNotificationSettingsOpen, setIsNotificationSettingsOpen] = useState(false)
298299
const [activeSort, setActiveSort] = useState<{
@@ -473,6 +474,7 @@ export default function Logs() {
473474

474475
const handleCloseSidebar = useCallback(() => {
475476
dispatch({ type: 'CLOSE_SIDEBAR' })
477+
activeLogTabRef.current = 'overview'
476478
}, [])
477479

478480
const handleLogContextMenu = useCallback(
@@ -700,6 +702,8 @@ export default function Logs() {
700702
const handleKeyDown = (e: KeyboardEvent) => {
701703
const tag = (e.target as HTMLElement)?.tagName
702704
if (tag === 'INPUT' || tag === 'TEXTAREA') return
705+
// When the trace tab is active, arrow keys belong to TraceView's span navigator.
706+
if (activeLogTabRef.current === 'trace') return
703707
const currentLogs = logsRef.current
704708
const currentIndex = selectedLogIndexRef.current
705709
if (currentLogs.length === 0) return
@@ -811,6 +815,9 @@ export default function Logs() {
811815
hasPrev={selectedLogIndex > 0}
812816
onRetryExecution={handleRetrySidebarExecution}
813817
isRetryPending={retryExecution.isPending}
818+
onActiveTabChange={(tab) => {
819+
activeLogTabRef.current = tab
820+
}}
814821
/>
815822
)
816823

0 commit comments

Comments
 (0)