Skip to main content

## execute_switch

# Function execute_switch

Source

    async fn execute_switch(
        app: &AppHandle,
        db: &Arc<RusqliteService>,
        repository_manager: &State<'_, RepositoryManagerWrapper>,
        session_poller: &State<'_, SessionPollerWrapper>,
        from: Option<&str>,
        to: &str,
    ) -> Result<(), String>

Expand description

Run a switch plan.

The ordering comes from `crate::profiles::switch::plan` rather than being written out here, because the ordering is the invariant worth testing and an end-to-end switch needs two real accounts on a real server to exercise.

One step is deliberately not executed here: `BuildRepository`. Repository handles are created by the frontend (`repository_create`) because building one needs the token and URL it already assembles at login, so the `profile-switched` event is the signal to do it. What stays in Rust is the part that matters — that the old handle is destroyed before the active user flips, so nothing can write under the wrong id in between.

TRACES: UR-082 | DR-270