Skip to content

Conversation

Copy link

Copilot AI commented Sep 8, 2025

Problem

The infoExitOnScroll feature was not working correctly. When a user toggled gameInfo on and then scrolled, the info panel should automatically toggle off (as if the toggle key was pressed again), but it wasn't happening.

Root Cause

The issue was in the state machine flow and timing of when resetInfoToggle() was called:

  1. Bypassed State Machine: The resetInfoToggle() function directly called exit methods (gameInfoExit(), collectionInfoExit(), buildInfoExit()) and immediately set boolean flags to false, bypassing the proper state machine transitions.

  2. Missing Animation Coordination: Manual toggle properly uses state machine transitions (RETROFE_GAMEINFO_EXIT → animation → flag reset), but scroll-triggered exit skipped this flow, causing timing and animation issues.

  3. Immediate Flag Reset: Boolean flags were reset immediately instead of being coordinated with the exit animation sequence.

Solution

This fix implements proper state machine transitions for scroll-triggered info exits:

Key Changes

1. Enhanced resetInfoToggle() Function

  • Changed return type from void to RETROFE_STATE
  • Now returns appropriate exit state (RETROFE_GAMEINFO_EXIT, RETROFE_COLLECIONINFO_EXIT, RETROFE_BUILDINFO_EXIT)
  • Sets boolean flags to false before returning exit state (matching manual toggle behavior)

2. Added Pending State Management

  • Added pendingScrollState_ member to store intended scroll direction
  • Allows scroll action to be preserved during info exit sequence

3. Updated Scroll Input Handling

  • All scroll input handling in processUserInput() now checks resetInfoToggle() return value
  • If info panel is active, stores scroll direction and returns exit state
  • Only proceeds with direct scrolling if no info panel is active

4. Enhanced State Machine

  • Updated exit state handlers (RETROFE_GAMEINFO_EXIT, RETROFE_COLLECIONINFO_EXIT, RETROFE_BUILDINFO_EXIT)
  • After calling exit functions, checks for pending scroll state
  • Transitions to pending scroll state if set, otherwise follows normal flow

Result

The infoExitOnScroll feature now works correctly:

  1. Proper Animation Timing: Info panels exit with the same smooth animations as manual toggle
  2. Coordinated State Flow: Exit animations complete before scrolling begins
  3. Preserved User Intent: Scroll direction is preserved and executed after info exit
  4. Consistent Behavior: Matches the timing and visual behavior of manual toggle

Testing

Created comprehensive unit tests verifying:

  • Game info, collection info, and build info panels all exit properly through state machine
  • Scroll direction is preserved and executed after exit completes
  • Direct scrolling works normally when no info panels are active
  • Boolean flags are reset at the correct time in the sequence

The fix ensures that when infoExitOnScroll is enabled and the user scrolls while any info panel is active, the info panel smoothly exits before scrolling proceeds, matching the expected behavior described in the issue.

This pull request was created as a result of the following prompt from Copilot chat.

Problem Description

The infoExitOnScroll feature is not working correctly. When a user toggles gameInfo on and then scrolls, the info panel should automatically toggle off (as if the toggle key was pressed again), but it's not happening.

Root Cause Analysis

After analyzing the code and debug logs, I've identified the issue is in the state machine flow and timing of when resetInfoToggle() is called:

  1. State Transition Issue: When infoExitOnScroll is enabled and scrolling occurs, resetInfoToggle() is called immediately, but the state machine doesn't properly handle the info exit states.

  2. Missing State Flow: The resetInfoToggle() function calls the appropriate exit functions (gameInfoExit(), collectionInfoExit(), buildInfoExit()) but doesn't transition through the proper state machine states that would complete the exit animation sequence.

  3. Timing Problem: The function sets the boolean flags (gameInfo_, collectionInfo_, buildInfo_) to false immediately, but the page animations and state transitions aren't properly coordinated.

Current Problematic Code

In processUserInput(), when scrolling is detected with infoExitOnScroll enabled:

if (infoExitOnScroll)
{
    resetInfoToggle();
}
return RETROFE_SCROLL_FORWARD; // or RETROFE_SCROLL_BACK

The resetInfoToggle() function currently does:

void RetroFE::resetInfoToggle() {
    if (gameInfo_)
    {
        currentPage_->gameInfoExit();
        gameInfo_ = false;
    }
    else if (collectionInfo_)
    {
        currentPage_->collectionInfoExit();
        collectionInfo_ = false;
    }
    else if (buildInfo_)
    {
        currentPage_->buildInfoExit();
        buildInfo_ = false;
    }
}

Expected Behavior

When infoExitOnScroll is enabled and the user scrolls while any info panel is active, the info panel should smoothly exit (same as if the user pressed the toggle key manually).

Solution Requirements

The fix should:

  1. Properly transition through the appropriate exit states (RETROFE_GAMEINFO_EXIT, RETROFE_COLLECIONINFO_EXIT, RETROFE_BUILDINFO_EXIT)
  2. Maintain the same animation and timing behavior as manual toggle
  3. Ensure the boolean flags are reset at the correct time in the state flow
  4. Handle the transition back to the appropriate scroll state after the info exit is complete

Debug Log Evidence

The logs show:

[2025-09-08 12:40:45] [DEBUG] [RetroFE] Transitioning from RETROFE_IDLE to RETROFE_GAMEINFO_ENTER
[2025-09-08 12:40:45] [DEBUG] [RetroFE] Transitioning from RETROFE_GAMEINFO_ENTER to RETROFE_PLAYLIST_ENTER
[2025-09-08 12:40:46] [INFO] [RetroFE] Resetting info toggles
[2025-09-08 12:40:46] [DEBUG] [RetroFE] Transitioning from RETROFE_IDLE to RETROFE_SCROLL_BACK

This shows that resetInfoToggle() is being called ("Resetting info toggles"), but the proper exit state transitions are not occurring.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits September 8, 2025 16:53
Co-authored-by: inigomonyota <96964704+inigomonyota@users.noreply.github.com>
Co-authored-by: inigomonyota <96964704+inigomonyota@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix infoExitOnScroll not working properly when scrolling Fix infoExitOnScroll feature by implementing proper state machine transitions Sep 8, 2025
Copilot AI requested a review from inigomonyota September 8, 2025 16:56
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.

2 participants