pub fn write_text_agent_channel_events_system(
    channel: Res<TextAgentChannel>,
    focused_non_window_egui_context: Option<Res<FocusedNonWindowEguiContext>>,
    // We can safely assume that we have only 1 window in WASM.
    egui_context: Single<(Entity, &EguiContextSettings), (With<PrimaryWindow>, With<EguiContext>)>,
    mut egui_input_event_writer: EventWriter<EguiInputEvent>,
    mut redraw_event: EventWriter<RequestRedraw>,
) {
    let (primary_context, context_settings) = *egui_context;
    if !context_settings
        .input_system_settings
        .run_write_text_agent_channel_events_system
    {
        return;
    }

    let mut redraw = false;
    let context = focused_non_window_egui_context
        .as_deref()
        .map_or(primary_context, |context| context.0);
    while let Ok(event) = channel.receiver.try_recv() {
        redraw = true;
        egui_input_event_writer.write(EguiInputEvent { context, event });
    }
    if redraw {
        redraw_event.write(RequestRedraw);
    }
}
Listens to the [`TextAgentChannel`] channel and wraps messages into [`EguiInputEvent`] events.
src/text_agent.rs