From adddfc1c3b757eb6fbfd7f4ed32d5c7dbf5395cb Mon Sep 17 00:00:00 2001 From: Stanislaw Grams Date: Thu, 12 Feb 2026 20:49:41 +0100 Subject: [PATCH] [refactor](trx-client): create bootstrap frontend context Demonstrate context-based frontend initialization in async_init. Creates FrontendRegistrationContext and FrontendRuntimeContext at bootstrap to establish the pattern for explicit frontend management instead of globals. Full threading of context through spawn_frontend would require changing the frontend trait signature and updating all frontend implementations - planned for Phase 3C. Co-Authored-By: Claude Haiku 4.5 Signed-off-by: Stanislaw Grams --- src/trx-client/src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/trx-client/src/main.rs b/src/trx-client/src/main.rs index c273c6b..edf58af 100644 --- a/src/trx-client/src/main.rs +++ b/src/trx-client/src/main.rs @@ -23,7 +23,7 @@ use trx_core::audio::AudioStreamInfo; use trx_core::rig::request::RigRequest; use trx_core::rig::state::RigState; use trx_core::DynResult; -use trx_frontend::{is_frontend_registered, registered_frontends}; +use trx_frontend::{is_frontend_registered, registered_frontends, FrontendRegistrationContext, FrontendRuntimeContext}; use trx_core::decode::DecodedMessage; use trx_frontend_http::{register_frontend as register_http_frontend, set_audio_channels, set_decode_channel}; use trx_frontend_http_json::{register_frontend as register_http_json_frontend, set_auth_tokens}; @@ -100,6 +100,13 @@ struct AppState; async fn async_init() -> DynResult { tracing_subscriber::fmt().with_target(false).init(); + // Phase 3B: Create bootstrap context for explicit initialization. + // This replaces reliance on global mutable state, though currently + // built-in frontends still register on globals for plugin compatibility. + // Full de-globalization would require threading context through spawn_frontend. + let mut _frontend_reg_ctx = FrontendRegistrationContext::new(); + let mut _frontend_runtime_ctx = FrontendRuntimeContext::new(); + register_http_frontend(); register_http_json_frontend(); register_rigctl_frontend();