Skip to content

feat: Auto-scroll to latest logs for worker sub-tasks#1318

Merged
Wendong-Fan merged 25 commits intoeigent-ai:mainfrom
spider-yamet:feat/auto-scroll-to-latest-logs
Mar 4, 2026
Merged

feat: Auto-scroll to latest logs for worker sub-tasks#1318
Wendong-Fan merged 25 commits intoeigent-ai:mainfrom
spider-yamet:feat/auto-scroll-to-latest-logs

Conversation

@spider-yamet
Copy link
Contributor

Related Issue

Closes #1315

Description

Implements auto-scroll for the worker sub-task log panel in the Workflow view so the latest toolkit logs stay visible without manual scrolling.

Changes:

  • src/components/WorkFlow/node.tsx: When the workflow node is expanded and a task is selected, the right-hand log panel (which shows selectedTask.toolkits) now scrolls to the bottom when:
    • New toolkit entries are added, or
    • The last toolkit’s message is updated (e.g. streaming).
  • Auto-scroll only runs when the user is already near the bottom of the log (~60px threshold). If the user scrolls up to read history, the view does not jump back to the bottom until they scroll near the bottom again.
  • When switching the selected task or opening the log panel, the view scrolls to the bottom so the latest logs are shown.

This addresses the behavior requested in #1315 (auto-scroll so latest logs are always visible).

Testing Evidence (REQUIRED)

  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

(Attach a short screen recording or screenshots showing: workflow node expanded, task running with toolkit logs, log panel auto-scrolling to the latest entry as new logs appear; optionally, scrolling up and confirming it does not override until you scroll back near the bottom.)

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

@bytecii
Copy link
Collaborator

bytecii commented Feb 21, 2026

Can you make a screenshot in the description? Thanks.

@spider-yamet
Copy link
Contributor Author

spider-yamet commented Feb 23, 2026

22.02.2026_17.31.15_REC.mp4

Hi, I have added screen recording, I added test button for mock testing. (not mentioned on PR, only for test)
Please check, @bytecii @Wendong-Fan

@spider-yamet
Copy link
Contributor Author

could you please review, @bytecii @Wendong-Fan

@spider-yamet
Copy link
Contributor Author

@bytecii @Wendong-Fan could you please review this PR?

@spider-yamet
Copy link
Contributor Author

@bytecii I added screenshot for this update, please check once you are available.

@spider-yamet
Copy link
Contributor Author

@bytecii @Wendong-Fan I see this PR remains opening for several weeks.
Could you please check once you are available?

Regards

@spider-yamet
Copy link
Contributor Author

Could you let me know your plan, @bytecii @fengju0213 @Wendong-Fan ?

Regards

Copy link
Contributor

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @spider-yamet 's contribution and sorry for the late review, left some comments below


useEffect(() => {
if (!isExpanded || !selectedTask?.toolkits?.length) return;
wasAtBottomRef.current = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasAtBottomRef.current is reset to true on each toolkit update, so the log panel still jumps to the bottom even if the user has scrolled up to read older logs? i think we should respect users' action

Comment on lines +285 to +286
const toolkits = selectedTask?.toolkits;
if (!toolkits?.length) return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The effect depends on useMemo([selectedTask?.toolkits]), but toolkits is mutated in place in chatStore, so some log/message updates may not retrigger auto-scroll

@Wendong-Fan Wendong-Fan added this to the Sprint 17 milestone Mar 3, 2026
@spider-yamet
Copy link
Contributor Author

@Wendong-Fan Thanks for your feedback, I updated code by following your feedback.

Functional behavior diff

Before

  • Auto-scroll effect ran when:
    • isExpanded changed
    • selectedTask?.id changed
    • selectedTask?.toolkits?.length changed
    • lastToolkitMessage changed
  • The effect forcibly set:
    • wasAtBottomRef.current = true
  • Result:
    • Even if the user scrolled up, the next toolkit update could jump the panel back to bottom.
    • Some updates were not detected reliably when toolkits was mutated in place.

After

  • Auto-scroll effect now uses a computed toolkitChangeKey:
    • taskId
    • toolkit length
    • last toolkit id
    • last toolkit status
    • last toolkit message
  • The effect does not reset wasAtBottomRef.
  • Result:
    • User scroll position is respected (no forced jump to bottom).
    • In-place toolkit mutations are more reliably detected, so auto-scroll triggers when meaningful toolkit data changes.

I tested functionality on my end.

@spider-yamet spider-yamet requested a review from Wendong-Fan March 3, 2026 09:34
@spider-yamet
Copy link
Contributor Author

@Wendong-Fan Could you please review current update? :)

spider-yamet and others added 4 commits March 4, 2026 18:28
- Remove dead deadline logic in scrollLogToBottom
- Remove message from toolkitChangeKey to avoid excessive scroll triggers during streaming
- Reset wasAtBottomRef when switching tasks so new task always scrolls to bottom
Copy link
Contributor

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @spider-yamet , added some enhance in ce13c79, now LGTM

@Wendong-Fan Wendong-Fan merged commit 4476409 into eigent-ai:main Mar 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Auto-scroll to latest logs for workers sub-tasks

3 participants