feat(appd): include app_id in LaunchAck response

ipc.rs: LaunchAck gains app_id: String field so callers receive the
app identifier alongside the session handle in a single response.

main.rs: dispatch::LaunchApp constructs LaunchAck { session_id, app_id }
using the app_id that was already in scope.
Tests updated: dispatch_launch_returns_ack now asserts app_id value;
dispatch_terminate_known_returns_stopped and
dispatch_query_app_state_returns_starting use .. to ignore app_id.
This commit is contained in:
Marco Allegretti 2026-03-11 10:46:28 +01:00
parent fdeb440766
commit b5bf2e538a
2 changed files with 19 additions and 6 deletions

View file

@ -21,6 +21,7 @@ pub struct SessionInfo {
pub enum Response { pub enum Response {
LaunchAck { LaunchAck {
session_id: u64, session_id: u64,
app_id: String,
}, },
AppReady { AppReady {
session_id: u64, session_id: u64,
@ -98,11 +99,17 @@ mod tests {
#[test] #[test]
fn response_msgpack_roundtrip() { fn response_msgpack_roundtrip() {
let resp = Response::LaunchAck { session_id: 7 }; let resp = Response::LaunchAck {
session_id: 7,
app_id: "com.example.app".into(),
};
let bytes = rmp_serde::to_vec(&resp).unwrap(); let bytes = rmp_serde::to_vec(&resp).unwrap();
let decoded: Response = rmp_serde::from_slice(&bytes).unwrap(); let decoded: Response = rmp_serde::from_slice(&bytes).unwrap();
match decoded { match decoded {
Response::LaunchAck { session_id } => assert_eq!(session_id, 7), Response::LaunchAck { session_id, app_id } => {
assert_eq!(session_id, 7);
assert_eq!(app_id, "com.example.app");
}
_ => panic!("wrong variant"), _ => panic!("wrong variant"),
} }
} }

View file

@ -215,7 +215,7 @@ pub(crate) async fn dispatch(req: Request, registry: &Registry) -> Response {
tracing::warn!(session_id, error = %e, "runtime supervisor error"); tracing::warn!(session_id, error = %e, "runtime supervisor error");
} }
}); });
Response::LaunchAck { session_id } Response::LaunchAck { session_id, app_id }
} }
Request::TerminateApp { session_id } => { Request::TerminateApp { session_id } => {
let found = registry.lock().await.terminate(session_id); let found = registry.lock().await.terminate(session_id);
@ -274,7 +274,13 @@ mod tests {
) )
.await; .await;
match resp { match resp {
Response::LaunchAck { session_id } => assert!(session_id > 0), Response::LaunchAck {
session_id,
ref app_id,
} => {
assert!(session_id > 0);
assert_eq!(app_id, "com.test.app");
}
_ => panic!("expected LaunchAck"), _ => panic!("expected LaunchAck"),
} }
} }
@ -291,7 +297,7 @@ mod tests {
) )
.await; .await;
let session_id = match ack { let session_id = match ack {
Response::LaunchAck { session_id } => session_id, Response::LaunchAck { session_id, .. } => session_id,
_ => panic!("expected LaunchAck"), _ => panic!("expected LaunchAck"),
}; };
let resp = dispatch(Request::TerminateApp { session_id }, &reg).await; let resp = dispatch(Request::TerminateApp { session_id }, &reg).await;
@ -354,7 +360,7 @@ mod tests {
) )
.await; .await;
let session_id = match ack { let session_id = match ack {
Response::LaunchAck { session_id } => session_id, Response::LaunchAck { session_id, .. } => session_id,
_ => panic!(), _ => panic!(),
}; };
let resp = dispatch(Request::QueryAppState { session_id }, &reg).await; let resp = dispatch(Request::QueryAppState { session_id }, &reg).await;