Skip to content

Conversation

@emily8rown
Copy link
Contributor

@emily8rown emily8rown commented Nov 27, 2025

Summary

Add keyboard shortcuts (Cmd/Ctrl + Left/Right arrow keys) to navigate between commits in the Profiler's snapshot view.

Moved filteredCommitIndices management and commit navigation logic (selectNextCommitIndex, selectPrevCommitIndex) from SnapshotSelector into useCommitFilteringAndNavigation used by ProfilerContext to enable keyboard shortcuts from the top-level Profiler component.

How did you test this change?

  • New tests in ProfilerContext-tests
  • Built and tested in browser: yarn build:<browser name>
  • Ran tests: yarn run test:<browser name>
  • Manually verified Left/Right arrow navigation cycles through commits
  • Verified navigation respects commit duration filter

Chrome:

Screen.Recording.2025-11-27.at.18.19.45.mov

Edge with duration filter:

Screen.Recording.2025-11-28.at.12.23.23.mov

firefox mixing hotkey with clicking arrow buttons:

Screen.Recording.2025-11-28.at.12.34.07.mov

@meta-cla meta-cla bot added the CLA Signed label Nov 27, 2025
@emily8rown emily8rown marked this pull request as ready for review November 28, 2025 14:22
@emily8rown emily8rown requested a review from hoxyq November 28, 2025 14:23
selectedCommitIndex !== null
) {
// Left/Right to navigate commits
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably check for Cmd key as well. I think we should keep just arrow navigations for changes between nodes in tree view (outside of the scope for this PR), and Cmd + ->, Cmd + <- for navigation between commits. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's nicer to have them unique but the arrow navigation for the tree view nodes only works when one has just been selected and when that has happened even having them as different shortcuts you can't use a shortcut to navigate between commits. I'm not convinced how much the tab navigation one will be used if your mouse has already selected a tab in the area there just before, and therefore it could be nicer to leave the shortcut as arrow key for simplicity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it would confuse people they are switching tabs when they expect to switch commits if they don't realise they need to select it

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I am following. We don't have keyboard navigation for the flamegraph in Profiler tree, right? But if we would add one, it would probably be done by using only arrow keys.

If so, then it would conflict with the navigation between commits. That's my current thinking, what is the alternative?

@emily8rown emily8rown requested a review from hoxyq December 9, 2025 15:51
Copy link
Contributor

@hoxyq hoxyq left a comment

Choose a reason for hiding this comment

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

Looks good, left a minor suggestion to avoid cascading update.

Also, could you please validate that reload-and-profile works after these changes?

Comment on lines +260 to +267
// Clear selections when starting a new profiling session
useEffect(() => {
if (isProfiling) {
selectCommitIndex(null);
selectFiberID(null);
selectFiberName(null);
}
}
}, [isProfiling, selectCommitIndex]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this logic be moved to startProfiling() callback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants