Skip to main content

mj_controller/server/
config_view.rs

1use super::*;
2
3pub fn viewer_config_options(
4    config_options: &[agent_client_protocol::schema::v1::SessionConfigOption],
5    facts: &mj_core::acp::AcpSessionFacts,
6) -> Vec<ViewerConfigOption> {
7    ["model", "effort"]
8        .into_iter()
9        .filter_map(|key| {
10            let choices = mj_core::acp::session_config_choices(config_options, key);
11            if choices.is_empty() {
12                return None;
13            }
14            Some(ViewerConfigOption {
15                key: key.to_owned(),
16                label: key.to_owned(),
17                current: match key {
18                    "model" => facts.current_model(),
19                    "effort" => facts.current_effort(),
20                    _ => None,
21                }
22                .map(str::to_owned),
23                choices: choices
24                    .into_iter()
25                    .map(|choice| ViewerConfigChoice {
26                        value: choice.value,
27                        name: choice.name,
28                        description: choice.description,
29                    })
30                    .collect(),
31            })
32        })
33        .collect()
34}
35
36pub fn session_config_view(
37    harness: mj_core::config::HarnessKind,
38    state: &mj_core::relay::RelayOperationalState,
39) -> Vec<ViewerConfigOption> {
40    // Selectors are ACP categories; the config map supplies legacy current values.
41    let facts = mj_core::acp::AcpSessionFacts::from_operational(
42        harness,
43        &state.config,
44        &state.config_options,
45        state.modes.as_ref(),
46    );
47    viewer_config_options(&state.config_options, &facts)
48}