Skip to content

use get_event_handler in upload, cherry-pick from #6100#6130

Merged
masenf merged 1 commit intoreflex-dev:mainfrom
benedikt-bartscher:use-get-event-handler-in-upload
Feb 12, 2026
Merged

use get_event_handler in upload, cherry-pick from #6100#6130
masenf merged 1 commit intoreflex-dev:mainfrom
benedikt-bartscher:use-get-event-handler-in-upload

Conversation

@benedikt-bartscher
Copy link
Contributor

No description provided.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 12, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing benedikt-bartscher:use-get-event-handler-in-upload (704df8c) with main (8e3fc08)

Open in CodSpeed

@benedikt-bartscher benedikt-bartscher marked this pull request as ready for review February 12, 2026 19:23
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 12, 2026

Greptile Overview

Greptile Summary

Refactored event handler retrieval logic by moving StateProxy wrapping from _get_event_handler to its call sites. This improves code clarity and allows _get_event_handler to accept both Event and string handler names, enabling reuse in the upload handler. The upload handler now uses _get_event_handler instead of manually parsing handler paths and retrieving substates, eliminating code duplication.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean refactoring that consolidates duplicate logic without changing behavior. All call sites properly handle StateProxy wrapping for background tasks, and the upload handler correctly validates against background tasks before accessing the handler function.
  • No files require special attention

Important Files Changed

Filename Overview
reflex/state.py Refactored _get_event_handler to accept `Event
reflex/app.py Simplified upload handler to use _get_event_handler helper method, removing duplicate logic for handler retrieval and background task validation

Sequence Diagram

sequenceDiagram
    participant Client
    participant App
    participant State
    participant StateProxy

    Note over App,State: Upload Handler Flow
    Client->>App: Upload request with handler name
    App->>State: _get_event_handler(handler_string)
    State->>State: Parse handler path
    State->>State: Get substate and handler
    State-->>App: Return (substate, event_handler)
    App->>App: Check if background task
    alt is background task
        App->>App: Raise UploadTypeError
    else not background task
        App->>App: Process upload with handler.fn
    end

    Note over App,StateProxy: Background Task Flow
    Client->>App: Event request
    App->>State: _get_event_handler(event)
    State->>State: Parse event.name
    State->>State: Get substate and handler
    State-->>App: Return (substate, handler)
    App->>App: Check if background task
    alt is background task
        App->>StateProxy: Wrap substate in StateProxy
        StateProxy->>StateProxy: Create async task
    else not background task
        App->>State: Process event normally
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

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

thanks for splitting this out. looking good

@masenf masenf merged commit 7046785 into reflex-dev:main Feb 12, 2026
47 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.

2 participants