Skip to content

Show active thread first in stack trace view#827

Merged
xusheng6 merged 2 commits intodevfrom
copilot/fix-726
Sep 19, 2025
Merged

Show active thread first in stack trace view#827
xusheng6 merged 2 commits intodevfrom
copilot/fix-726

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 16, 2025

When debugging programs with many threads, users had to scroll through the stack trace view to find the active thread, which was displayed in arbitrary order along with other threads. This made debugging multi-threaded applications inefficient and frustrating.

This PR modifies the thread display order in the stack trace view so that the active thread always appears at the top of the list, providing immediate access to the most relevant debugging information.

Changes Made

  • Modified ThreadFrameModel::updateRows() in ui/threadframes.cpp to sort threads before displaying them
  • Added sorting logic that prioritizes the active thread while maintaining consistent ordering for remaining threads
  • Added #include <algorithm> header to support the sorting functionality

Implementation Details

The sorting uses a custom comparator that:

  1. Places the active thread (identified by controller->GetActiveThread().m_tid) first
  2. Sorts remaining threads by thread ID for predictable, consistent ordering
  3. Preserves all existing functionality and UI behavior
std::sort(threads.begin(), threads.end(), [activeThreadId](const DebugThread& a, const DebugThread& b) {
    bool aIsActive = (a.m_tid == activeThreadId);
    bool bIsActive = (b.m_tid == activeThreadId);
    
    if (aIsActive && !bIsActive) return true;
    if (!aIsActive && bIsActive) return false;
    
    return a.m_tid < b.m_tid;
});

Benefits

  • Improved debugging workflow: No more scrolling to find the active thread
  • Better user experience: Most relevant information is immediately visible
  • Consistent behavior: Predictable thread ordering makes the interface more intuitive
  • Minimal impact: Only 15 lines of code added, no breaking changes

Fixes #726.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Active thread should be on top in the stack trace view Show active thread first in stack trace view Sep 16, 2025
Copilot AI requested a review from xusheng6 September 16, 2025 13:50
@xusheng6 xusheng6 marked this pull request as ready for review September 19, 2025 09:03
@xusheng6 xusheng6 merged commit 103f9ae into dev Sep 19, 2025
1 check was pending
@xusheng6 xusheng6 deleted the copilot/fix-726 branch September 24, 2025 03:39
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.

Active thread should be on top in the stack trace view

3 participants