swarm-controller+swarm-ui: merge config-PR into GET /api/agents/status
Per mara's review call on this PR: "the view should be filled by a single backend call." AgentsPage.tsx was doing three fetches (/api/agents, /api/config-prs, /api/agents/status) and joining them client-side by name. Moves the config-PR join server-side instead: AgentStatusRow gains a config_pr field, populated by get_agents_status's handler from AppState::config_prs after agent_status::AgentStatusReader::view() returns - not inside that module, which has no forge client and stays that way (see the field's doc comment for why the handler is the right layer for this merge, not the reader). AgentsPage.tsx now does exactly one fetch and no client-side joining at all - the wire row is the table row. Dropped the separate AgentStatusRow TS interface (folded into AgentRow, which now mirrors the backend type field-for-field) and the /api/agents + /api/config-prs fetches entirely; neither is needed once /api/agents/status already returns every roster agent with its config PR attached. ConfigPrStatus gained Deserialize (previously Serialize-only) since AgentStatusRow derives both and a struct's derive requires every field to support it.
This commit is contained in:
parent
00cca0c903
commit
50650476ad
4 changed files with 69 additions and 61 deletions
|
|
@ -27,7 +27,7 @@ use forgejo_api::structs::{
|
|||
use forgejo_api::{ApiErrorKind, Auth, Forgejo, ForgejoError};
|
||||
use futures_util::{StreamExt as _, TryStreamExt as _};
|
||||
use reqwest::StatusCode;
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ use crate::webhook::DeliveryKind;
|
|||
|
||||
/// An agent's open config-PR, as [`Client::list_open_config_prs`] reports it
|
||||
/// and `GET /api/agents/{name}/config-pr` serves it.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, ToSchema)]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema)]
|
||||
pub struct ConfigPrStatus {
|
||||
pub pr_number: u64,
|
||||
/// Absent only if Forgejo itself omitted the field — every real PR has
|
||||
|
|
|
|||
Loading…
Reference in a new issue