[fix](trx-frontend-http): make /status respect per-tab rig selection
pollFreshSnapshot() fetches GET /status on every SSE connect/reconnect, but /status always returned the global selected rig's state, overwriting the per-tab display with whichever rig was last switched to globally. Now pollFreshSnapshot passes rig_id as a query param and the /status endpoint uses the per-rig watch channel when provided, matching the /events behavior for true per-tab rig isolation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -3163,7 +3163,10 @@ function scheduleReconnect(delayMs = 1000) {
|
||||
|
||||
async function pollFreshSnapshot() {
|
||||
try {
|
||||
const resp = await fetch("/status", { cache: "no-store" });
|
||||
const statusUrl = lastActiveRigId
|
||||
? `/status?rig_id=${encodeURIComponent(lastActiveRigId)}`
|
||||
: "/status";
|
||||
const resp = await fetch(statusUrl, { cache: "no-store" });
|
||||
if (!resp.ok) return;
|
||||
const data = await resp.json();
|
||||
render(data);
|
||||
|
||||
@@ -135,13 +135,27 @@ impl SessionRigManager {
|
||||
|
||||
pub type SharedSessionRigManager = Arc<SessionRigManager>;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct StatusQuery {
|
||||
pub rig_id: Option<String>,
|
||||
}
|
||||
|
||||
#[get("/status")]
|
||||
pub async fn status_api(
|
||||
query: web::Query<StatusQuery>,
|
||||
state: web::Data<watch::Receiver<RigState>>,
|
||||
clients: web::Data<Arc<AtomicUsize>>,
|
||||
context: web::Data<Arc<FrontendRuntimeContext>>,
|
||||
) -> Result<impl Responder, Error> {
|
||||
let state = wait_for_view(state.get_ref().clone()).await?;
|
||||
// Prefer the per-rig watch channel when a rig_id is specified,
|
||||
// falling back to the global state watch.
|
||||
let rx = query
|
||||
.rig_id
|
||||
.as_deref()
|
||||
.filter(|s| !s.is_empty())
|
||||
.and_then(|rid| context.rig_state_rx(rid))
|
||||
.unwrap_or_else(|| state.get_ref().clone());
|
||||
let state = wait_for_view(rx).await?;
|
||||
let json = serde_json::to_string(&state).map_err(actix_web::error::ErrorInternalServerError)?;
|
||||
let json = inject_frontend_meta(
|
||||
&json,
|
||||
|
||||
Reference in New Issue
Block a user