Commit 04010126ff

04010126ff8c6c7d5bfcb08b17aac83fb8ee1c06

parent: b7fe34020a

Unregistered key

vaw <git@nlih.de> · 2026-09-04 16:33 UTC
committer: <git@ulyssa.dev>

Support using room aliases and DMs with `:space child set` (#672)

Layout: unified · split

docs/iamb.1 +1 −1
@@ -250,7 +250,7 @@ Show the display name you currently have in this room.
250250.El
251251.Sh "SPACE COMMANDS"
252252.Bl -tag -width Ds
253.It Sy ":space child set [room_id] [arguments]"
253.It Sy ":space child set [room] [arguments]"
254254Add a room to the currently focused space.
255255.Dq ++suggested
256256marks the room as a suggested child.
src/base.rs +8 −3
@@ -195,9 +195,14 @@ pub enum MessageAction {
195195pub enum SpaceAction {
196196 /// Add a room or update metadata.
197197 ///
198 /// The [`Option<String>`] argument is the order parameter.
199 /// The [`bool`] argument indicates whether the room is suggested.
200 SetChild(OwnedRoomId, Option<String>, bool),
198 SetChild {
199 /// The room ID, alias, or a user whose DM room should be added to the space.
200 child: String,
201 /// The order parameter to use when sorting children in the space.
202 order: Option<String>,
203 /// Whether the room is suggested.
204 suggested: bool,
205 },
201206
202207 /// Remove the selected room.
203208 RemoveChild,
src/commands.rs +16 −20
@@ -6,7 +6,6 @@ use std::{convert::TryFrom, str::FromStr as _};
66
77use matrix_sdk::ruma::{
88 OwnedMxcUri,
9 OwnedRoomId,
109 OwnedRoomOrAliasId,
1110 OwnedUserId,
1211 RoomVersionId,
@@ -732,15 +731,15 @@ fn iamb_room(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
732731 },
733732 ("version", "upgrade", None) => return Result::Err(CommandError::InvalidArgument),
734733
735 // :room aliases show
734 // :room alias show
736735 ("alias", "show", None) => RoomAction::Show(RoomField::Aliases).into(),
737736 ("alias", "show", Some(_)) => return Result::Err(CommandError::InvalidArgument),
738737
739 // :room aliases unset <alias>
738 // :room alias unset <alias>
740739 ("alias", "unset", Some(s)) => RoomAction::Unset(RoomField::Alias(s)).into(),
741740 ("alias", "unset", None) => return Result::Err(CommandError::InvalidArgument),
742741
743 // :room aliases set <alias>
742 // :room alias set <alias>
744743 ("alias", "set", Some(s)) => RoomAction::Set(RoomField::Alias(s), "".into()).into(),
745744 ("alias", "set", None) => return Result::Err(CommandError::InvalidArgument),
746745
@@ -882,15 +881,12 @@ fn iamb_space(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
882881 }
883882 }
884883
885 let child = if let Some(child) = raw_child {
886 OwnedRoomId::from_str(&child)
887 .map_err(|_| CommandError::Error("Invalid room id specified".into()))?
888 } else {
884 let Some(child) = raw_child else {
889885 let msg = "Must specify a room to add";
890886 return Err(CommandError::Error(msg.into()));
891887 };
892888
893 SpaceAction::SetChild(child, order, suggested).into()
889 SpaceAction::SetChild { child, order, suggested }.into()
894890 },
895891 _ => return Result::Err(CommandError::InvalidArgument),
896892 };
@@ -1113,7 +1109,7 @@ pub fn setup_commands() -> ProgramCommands {
11131109#[cfg(test)]
11141110mod tests {
11151111 use super::*;
1116 use matrix_sdk::ruma::{room_id, user_id};
1112 use matrix_sdk::ruma::user_id;
11171113 use modalkit::actions::WindowAction;
11181114 use modalkit::editing::context::EditContext;
11191115
@@ -1493,16 +1489,20 @@ mod tests {
14931489
14941490 let cmd = "space child set !roomid:example.org";
14951491 let res = cmds.input_cmd(cmd, ctx.clone()).unwrap();
1496 let act = SpaceAction::SetChild(room_id!("!roomid:example.org").to_owned(), None, false);
1492 let act = SpaceAction::SetChild {
1493 child: "!roomid:example.org".to_owned(),
1494 order: None,
1495 suggested: false,
1496 };
14971497 assert_eq!(res, vec![(act.into(), ctx.clone())]);
14981498
14991499 let cmd = "space child set ++order=abcd ++suggested !roomid:example.org";
15001500 let res = cmds.input_cmd(cmd, ctx.clone()).unwrap();
1501 let act = SpaceAction::SetChild(
1502 room_id!("!roomid:example.org").to_owned(),
1503 Some("abcd".into()),
1504 true,
1505 );
1501 let act = SpaceAction::SetChild {
1502 child: "!roomid:example.org".to_owned(),
1503 order: Some("abcd".into()),
1504 suggested: true,
1505 };
15061506 assert_eq!(res, vec![(act.into(), ctx.clone())]);
15071507
15081508 let cmd = "space child set ++order=abcd ++order=1234 !roomid:example.org";
@@ -1528,10 +1528,6 @@ mod tests {
15281528 let res = cmds.input_cmd(cmd, ctx.clone());
15291529 assert_eq!(res, Err(CommandError::InvalidArgument));
15301530
1531 let cmd = "space child set foo";
1532 let res = cmds.input_cmd(cmd, ctx.clone());
1533 assert_eq!(res, Err(CommandError::Error("Invalid room id specified".into())));
1534
15351531 let cmd = "space child set";
15361532 let res = cmds.input_cmd(cmd, ctx.clone());
15371533 assert_eq!(res, Err(CommandError::Error("Must specify a room to add".into())));
src/windows/room/space.rs +3 −1
@@ -90,7 +90,7 @@ impl SpaceState {
9090 store: &mut ProgramStore,
9191 ) -> IambResult<EditInfo> {
9292 match act {
93 SpaceAction::SetChild(child_id, order, suggested) => {
93 SpaceAction::SetChild { child, order, suggested } => {
9494 if !self
9595 .room
9696 .power_levels()
@@ -105,6 +105,8 @@ impl SpaceState {
105105 return Err(IambError::InsufficientPermission.into());
106106 }
107107
108 let child_id = store.application.worker.join_room(child)?;
109
108110 let via = self.room.route().await.map_err(IambError::from)?;
109111 let mut ev = SpaceChildEventContent::new(via);
110112 ev.order = order