Skip to content

Commit 849ea64

Browse files
waleedlatif1claude
andcommitted
fix(logs): guard navigation arrows when selected log is off-page
Deep-linked logs resolved via useLogByExecutionId may not be in the current page list, leaving selectedLogIndex at -1. The hasNext prop was evaluating -1 < logs.length - 1 (true for any non-empty list), which enabled the next arrow and jumped to the first item on click. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e98e80a commit 849ea64

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/logs

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export default function Logs() {
452452
const handleNavigateNext = useCallback(() => {
453453
const idx = selectedLogIndexRef.current
454454
const currentLogs = logsRef.current
455-
if (idx < currentLogs.length - 1) {
455+
if (idx >= 0 && idx < currentLogs.length - 1) {
456456
shouldScrollIntoViewRef.current = true
457457
dispatch({ type: 'SELECT_LOG', logId: currentLogs[idx + 1].id })
458458
}
@@ -801,7 +801,7 @@ export default function Logs() {
801801
onClose={handleCloseSidebar}
802802
onNavigateNext={handleNavigateNext}
803803
onNavigatePrev={handleNavigatePrev}
804-
hasNext={selectedLogIndex < logs.length - 1}
804+
hasNext={selectedLogIndex >= 0 && selectedLogIndex < logs.length - 1}
805805
hasPrev={selectedLogIndex > 0}
806806
onRetryExecution={handleRetrySidebarExecution}
807807
isRetryPending={retryExecution.isPending}

0 commit comments

Comments
 (0)