Skip to main content

agentmux_srv/server/app_api/
layout_intent.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! `layout.applyIntent`: a window's layout edit, computed and stored by srv
5//! (`service::layout_intents`).
6//! SPEC_STRONG_REDUCER_AUTHORITY_LAYOUT_2026_06_30.md ยง4.
7
8use super::*;
9
10pub fn register(engine: &Arc<WshRpcEngine>, state: &AppState) {
11    let state = state.clone();
12    engine.register_typed(COMMAND_LAYOUT_APPLY_INTENT, move |cmd: CommandLayoutIntentData, _ctx| {
13        let state = state.clone();
14        async move { apply_intent(&state, cmd).await }
15    });
16}
17
18pub(crate) async fn apply_intent(state: &AppState, cmd: CommandLayoutIntentData) -> Result<LayoutIntentResult, String> {
19    let view = agentmux_common::LayoutViewState {
20        focused_node_id: cmd.focused_node_id,
21        magnified_node_id: cmd.magnified_node_id,
22    };
23    let outcome = crate::server::service::layout_intents::apply_layout_intent(
24        state,
25        &cmd.tab_id,
26        cmd.intent,
27        &cmd.action_id,
28        Some(view),
29    )
30    .await?;
31    Ok(LayoutIntentResult { applied: outcome.applied, error: outcome.error, version: outcome.version })
32}